Skip to content

Commit

Permalink
Revert of ipc: Clean up interface of attachment broker. (patchset chr…
Browse files Browse the repository at this point in the history
…omium#5 id:80001 of https://codereview.chromium.org/1269553003/)

Reason for revert:
Causes failures in:

IPCAttachmentBrokerPrivilegedWinTest.SendHandle
IPCAttachmentBrokerPrivilegedWinTest.SendHandleToSelf
IPCAttachmentBrokerPrivilegedWinTest.SendHandleWithoutPermissions

on the Win7 Tests (dbg)(1) bot

http://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%281%29/builds/40372/steps/ipc_tests/logs/stdio

Original issue's description:
> ipc: Clean up interface of attachment broker.
>
> AttachmentBrokerUnprivileged now has a method
> DesignateBrokerCommunicationChannel which is used by non-broker processes to
> designate an IPC::Channel as the communication medium for brokerable attachment
> messages. IPC::Channel has a new member attachment_broker_endpoint_ which causes
> it to pass all messages through the attachment broker before forwarding them to
> the listener.
>
> BUG=493414
>
> Committed: https://crrev.com/9a06836982214f2edced21bbd1615b49e7f231bf
> Cr-Commit-Position: refs/heads/master@{#341143}

TBR=tsepez@chromium.org,erikchen@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=493414

Review URL: https://codereview.chromium.org/1259953005

Cr-Commit-Position: refs/heads/master@{#341171}
  • Loading branch information
avi authored and Commit bot committed Jul 30, 2015
1 parent 2764561 commit 0905996
Show file tree
Hide file tree
Showing 14 changed files with 4 additions and 62 deletions.
1 change: 0 additions & 1 deletion ipc/attachment_broker_privileged.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ AttachmentBrokerPrivileged::~AttachmentBrokerPrivileged() {}

void AttachmentBrokerPrivileged::RegisterCommunicationChannel(
Channel* channel) {
channel->set_attachment_broker_endpoint(true);
auto it = std::find(channels_.begin(), channels_.end(), channel);
DCHECK(channels_.end() == it);
channels_.push_back(channel);
Expand Down
5 changes: 1 addition & 4 deletions ipc/attachment_broker_privileged_win_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class IPCAttachmentBrokerPrivilegedWinTest : public IPCTestBase {
broker_->AddObserver(&observer_);
set_attachment_broker(broker_.get());
CreateChannel(&proxy_listener_);
broker_->DesignateBrokerCommunicationChannel(channel());
broker_->set_sender(channel());
ASSERT_TRUE(ConnectChannel());
ASSERT_TRUE(StartClient());
}
Expand Down Expand Up @@ -278,9 +278,6 @@ TEST_F(IPCAttachmentBrokerPrivilegedWinTest, SendHandleToSelf) {

set_broker(new MockBroker);
CommonSetUp();
// Technically, the channel is an endpoint, but we need the proxy listener to
// receive the messages so that it can quit the message loop.
channel()->set_attachment_broker_endpoint(false);
get_proxy_listener()->set_listener(get_broker());

HANDLE h = CreateTempFile();
Expand Down
10 changes: 0 additions & 10 deletions ipc/attachment_broker_unprivileged.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,10 @@

#include "ipc/attachment_broker_unprivileged.h"

#include "ipc/ipc_channel.h"

namespace IPC {

AttachmentBrokerUnprivileged::AttachmentBrokerUnprivileged() {}

AttachmentBrokerUnprivileged::~AttachmentBrokerUnprivileged() {}

void AttachmentBrokerUnprivileged::DesignateBrokerCommunicationChannel(
IPC::Channel* channel) {
DCHECK(channel);
DCHECK(!sender_);
sender_ = channel;
channel->set_attachment_broker_endpoint(true);
}

} // namespace IPC
5 changes: 1 addition & 4 deletions ipc/attachment_broker_unprivileged.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace IPC {

class Channel;
class Sender;

// This abstract subclass of AttachmentBroker is intended for use in
Expand All @@ -20,9 +19,7 @@ class IPC_EXPORT AttachmentBrokerUnprivileged : public IPC::AttachmentBroker {
AttachmentBrokerUnprivileged();
~AttachmentBrokerUnprivileged() override;

// In each unprivileged process, exactly one channel should be used to
// communicate brokerable attachments with the broker process.
void DesignateBrokerCommunicationChannel(IPC::Channel* channel);
void set_sender(IPC::Sender* sender) { sender_ = sender; }

protected:
IPC::Sender* get_sender() { return sender_; }
Expand Down
12 changes: 0 additions & 12 deletions ipc/ipc_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ class IPC_EXPORT Channel : public Sender {
Listener* listener,
AttachmentBroker* broker = nullptr);

Channel() : attachment_broker_endpoint_(false) {}
~Channel() override;

// Connect the pipe. On the server side, this will initiate
Expand Down Expand Up @@ -253,17 +252,6 @@ class IPC_EXPORT Channel : public Sender {
static void NotifyProcessForkedForTesting();
#endif

void set_attachment_broker_endpoint(bool is_endpoint) {
attachment_broker_endpoint_ = is_endpoint;
}

protected:
bool is_attachment_broker_endpoint() { return attachment_broker_endpoint_; }

private:
// Whether this channel is used as an endpoint for sending and receiving
// brokerable attachment messages to/from the broker process.
bool attachment_broker_endpoint_;
};

#if defined(OS_POSIX)
Expand Down
4 changes: 0 additions & 4 deletions ipc/ipc_channel_nacl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,6 @@ base::ProcessId ChannelNacl::GetSenderPID() {
return base::kNullProcessId;
}

bool ChannelNacl::IsAttachmentBrokerEndpoint() {
return is_attachment_broker_endpoint();
}

// Channel's methods

// static
Expand Down
1 change: 0 additions & 1 deletion ipc/ipc_channel_nacl.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class ChannelNacl : public Channel,
bool DidEmptyInputBuffers() override;
void HandleInternalMessage(const Message& msg) override;
base::ProcessId GetSenderPID() override;
bool IsAttachmentBrokerEndpoint() override;

Mode mode_;
bool waiting_connect_;
Expand Down
4 changes: 0 additions & 4 deletions ipc/ipc_channel_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -955,10 +955,6 @@ base::ProcessId ChannelPosix::GetSenderPID() {
return GetPeerPID();
}

bool ChannelPosix::IsAttachmentBrokerEndpoint() {
return is_attachment_broker_endpoint();
}

void ChannelPosix::Close() {
// Close can be called multiple time, so we need to make sure we're
// idempotent.
Expand Down
1 change: 0 additions & 1 deletion ipc/ipc_channel_posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class IPC_EXPORT ChannelPosix : public Channel,
bool DidEmptyInputBuffers() override;
void HandleInternalMessage(const Message& msg) override;
base::ProcessId GetSenderPID() override;
bool IsAttachmentBrokerEndpoint() override;

// Finds the set of file descriptors in the given message. On success,
// appends the descriptors to the input_fds_ member and returns true
Expand Down
13 changes: 2 additions & 11 deletions ipc/ipc_channel_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,9 @@ void ChannelReader::DispatchMessage(Message* m) {
IPC_MESSAGE_ID_LINE(m->type()));
#endif
m->TraceMessageEnd();

bool handled = false;
if (IsInternalMessage(*m)) {
if (IsInternalMessage(*m))
HandleInternalMessage(*m);
handled = true;
}
#if USE_ATTACHMENT_BROKER
if (!handled && IsAttachmentBrokerEndpoint() && GetAttachmentBroker()) {
handled = GetAttachmentBroker()->OnMessageReceived(*m);
}
#endif // USE_ATTACHMENT_BROKER
if (!handled)
else
listener_->OnMessageReceived(*m);
if (m->dispatch_error())
listener_->OnBadMessageReceived(*m);
Expand Down
3 changes: 0 additions & 3 deletions ipc/ipc_channel_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ class IPC_EXPORT ChannelReader : public SupportsAttachmentBrokering,
// Get the process ID for the sender of the message.
virtual base::ProcessId GetSenderPID() = 0;

// Whether the channel is an endpoint of attachment brokering.
virtual bool IsAttachmentBrokerEndpoint() = 0;

private:
FRIEND_TEST_ALL_PREFIXES(ChannelReaderTest, AttachmentAlreadyBrokered);
FRIEND_TEST_ALL_PREFIXES(ChannelReaderTest, AttachmentNotYetBrokered);
Expand Down
2 changes: 0 additions & 2 deletions ipc/ipc_channel_reader_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ class MockChannelReader : public ChannelReader {

base::ProcessId GetSenderPID() override { return base::kNullProcessId; }

bool IsAttachmentBrokerEndpoint() override { return false; }

AttachmentBroker* GetAttachmentBroker() override { return broker_; }

// This instance takes ownership of |m|.
Expand Down
4 changes: 0 additions & 4 deletions ipc/ipc_channel_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,6 @@ base::ProcessId ChannelWin::GetSenderPID() {
return GetPeerPID();
}

bool ChannelWin::IsAttachmentBrokerEndpoint() {
return is_attachment_broker_endpoint();
}

bool ChannelWin::DidEmptyInputBuffers() {
// We don't need to do anything here.
return true;
Expand Down
1 change: 0 additions & 1 deletion ipc/ipc_channel_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class ChannelWin : public Channel,
bool DidEmptyInputBuffers() override;
void HandleInternalMessage(const Message& msg) override;
base::ProcessId GetSenderPID() override;
bool IsAttachmentBrokerEndpoint() override;

static const base::string16 PipeName(const std::string& channel_id,
int32* secret);
Expand Down

0 comments on commit 0905996

Please sign in to comment.