summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-11 22:35:26 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-11 22:35:26 +0000
commit57319cecbf1277567dbd0328fab1ccb741f022ac (patch)
tree24f52f0c4dd774a09c8a3d7ae5ae781e83e1ec27
parent354d49aec9a0bbae84a558bc2cddf4ccb200f955 (diff)
downloadchromium_src-57319cecbf1277567dbd0328fab1ccb741f022ac.zip
chromium_src-57319cecbf1277567dbd0328fab1ccb741f022ac.tar.gz
chromium_src-57319cecbf1277567dbd0328fab1ccb741f022ac.tar.bz2
Separate out IPC::Message::Sender and Channel::Listener into a separate class.
I fixed the places that did IPC::Channel::Sender (I don't even know how this compiled, but I presume this means the "Sender" base class of the "Channel" which ends up being right). We can fix the other users of this later. BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/10541065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141534 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/automation_provider.h10
-rw-r--r--chrome/browser/service/service_process_control.h10
-rw-r--r--content/browser/gpu/gpu_process_host_ui_shim.h10
-rw-r--r--content/browser/renderer_host/render_process_host_impl.h4
-rw-r--r--content/public/browser/render_widget_host.h3
-rw-r--r--content/public/test/mock_render_process_host.h4
-rw-r--r--ipc/ipc.gypi2
-rw-r--r--ipc/ipc_channel.h40
-rw-r--r--ipc/ipc_channel_posix_unittest.cc3
-rw-r--r--ipc/ipc_channel_proxy.cc5
-rw-r--r--ipc/ipc_channel_proxy.h17
-rw-r--r--ipc/ipc_channel_reader.cc3
-rw-r--r--ipc/ipc_channel_reader.h8
-rw-r--r--ipc/ipc_fuzzing_tests.cc6
-rw-r--r--ipc/ipc_listener.h46
-rw-r--r--ipc/ipc_logging.cc2
-rw-r--r--ipc/ipc_logging.h4
-rw-r--r--ipc/ipc_message.h19
-rw-r--r--ipc/ipc_sender.h27
-rw-r--r--ipc/ipc_sync_channel_unittest.cc4
-rw-r--r--ipc/ipc_sync_message_filter.h4
-rw-r--r--ipc/ipc_tests.cc11
22 files changed, 155 insertions, 87 deletions
diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h
index e9d2a50..1d835e5 100644
--- a/chrome/browser/automation/automation_provider.h
+++ b/chrome/browser/automation/automation_provider.h
@@ -32,6 +32,8 @@
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/trace_subscriber.h"
#include "ipc/ipc_channel.h"
+#include "ipc/ipc_listener.h"
+#include "ipc/ipc_sender.h"
#if defined(OS_WIN) && !defined(USE_AURA)
#include "ui/gfx/native_widget_types.h"
@@ -79,8 +81,8 @@ class Point;
}
class AutomationProvider
- : public IPC::Channel::Listener,
- public IPC::Message::Sender,
+ : public IPC::Listener,
+ public IPC::Sender,
public base::SupportsWeakPtr<AutomationProvider>,
public base::RefCountedThreadSafe<
AutomationProvider, content::BrowserThread::DeleteOnUIThread>,
@@ -133,10 +135,10 @@ class AutomationProvider
const content::NavigationController* controller,
const Browser* parent) const;
- // IPC::Channel::Sender implementation.
+ // IPC::Sender implementation.
virtual bool Send(IPC::Message* msg) OVERRIDE;
- // IPC::Channel::Listener implementation.
+ // IPC::Listener implementation.
virtual void OnChannelConnected(int pid) OVERRIDE;
virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
virtual void OnChannelError() OVERRIDE;
diff --git a/chrome/browser/service/service_process_control.h b/chrome/browser/service/service_process_control.h
index 9be46eb..5f79882 100644
--- a/chrome/browser/service/service_process_control.h
+++ b/chrome/browser/service/service_process_control.h
@@ -19,6 +19,8 @@
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "ipc/ipc_channel_proxy.h"
+#include "ipc/ipc_listener.h"
+#include "ipc/ipc_sender.h"
class CommandLine;
@@ -36,8 +38,8 @@ struct CloudPrintProxyInfo;
//
// This class is accessed on the UI thread through some UI actions. It then
// talks to the IPC channel on the IO thread.
-class ServiceProcessControl : public IPC::Channel::Sender,
- public IPC::Channel::Listener,
+class ServiceProcessControl : public IPC::Sender,
+ public IPC::Listener,
public content::NotificationObserver {
public:
typedef IDMap<ServiceProcessControl>::iterator iterator;
@@ -70,12 +72,12 @@ class ServiceProcessControl : public IPC::Channel::Sender,
// Virtual for testing.
virtual void Disconnect();
- // IPC::Channel::Listener implementation.
+ // IPC::Listener implementation.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
virtual void OnChannelError() OVERRIDE;
- // IPC::Channel::Sender implementation
+ // IPC::Sender implementation
virtual bool Send(IPC::Message* message) OVERRIDE;
// content::NotificationObserver implementation.
diff --git a/content/browser/gpu/gpu_process_host_ui_shim.h b/content/browser/gpu/gpu_process_host_ui_shim.h
index f99d532..ec5678c 100644
--- a/content/browser/gpu/gpu_process_host_ui_shim.h
+++ b/content/browser/gpu/gpu_process_host_ui_shim.h
@@ -21,6 +21,8 @@
#include "content/common/content_export.h"
#include "content/common/message_router.h"
#include "content/public/common/gpu_info.h"
+#include "ipc/ipc_listener.h"
+#include "ipc/ipc_sender.h"
struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params;
struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params;
@@ -38,8 +40,8 @@ class Message;
void RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg);
class GpuProcessHostUIShim
- : public IPC::Channel::Listener,
- public IPC::Channel::Sender,
+ : public IPC::Listener,
+ public IPC::Sender,
public base::NonThreadSafe {
public:
// Create a GpuProcessHostUIShim with the given ID. The object can be found
@@ -60,10 +62,10 @@ class GpuProcessHostUIShim
// Return NULL if none has been created.
CONTENT_EXPORT static GpuProcessHostUIShim* GetOneInstance();
- // IPC::Channel::Sender implementation.
+ // IPC::Sender implementation.
virtual bool Send(IPC::Message* msg) OVERRIDE;
- // IPC::Channel::Listener implementation.
+ // IPC::Listener implementation.
// The GpuProcessHost causes this to be called on the UI thread to
// dispatch the incoming messages from the GPU process, which are
// actually received on the IO thread.
diff --git a/content/browser/renderer_host/render_process_host_impl.h b/content/browser/renderer_host/render_process_host_impl.h
index bdb0fd9..7fd3e4d 100644
--- a/content/browser/renderer_host/render_process_host_impl.h
+++ b/content/browser/renderer_host/render_process_host_impl.h
@@ -95,10 +95,10 @@ class CONTENT_EXPORT RenderProcessHostImpl
virtual base::TimeDelta GetChildProcessIdleTime() const OVERRIDE;
virtual void SurfaceUpdated(int32 surface_id) OVERRIDE;
- // IPC::Channel::Sender via RenderProcessHost.
+ // IPC::Sender via RenderProcessHost.
virtual bool Send(IPC::Message* msg) OVERRIDE;
- // IPC::Channel::Listener via RenderProcessHost.
+ // IPC::Listener via RenderProcessHost.
virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
virtual void OnChannelError() OVERRIDE;
diff --git a/content/public/browser/render_widget_host.h b/content/public/browser/render_widget_host.h
index aa1e3d2..3ef3ec9 100644
--- a/content/public/browser/render_widget_host.h
+++ b/content/public/browser/render_widget_host.h
@@ -11,6 +11,7 @@
#include "content/public/browser/keyboard_listener.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "ipc/ipc_channel.h"
+#include "ipc/ipc_sender.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h"
#include "ui/gfx/size.h"
@@ -102,7 +103,7 @@ class RenderWidgetHostView;
// messages for select popups. This placement is more out of convenience than
// anything else. When the view is live, these messages are forwarded to it by
// the RenderWidgetHost's IPC message map.
-class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Sender {
+class CONTENT_EXPORT RenderWidgetHost : public IPC::Sender {
public:
// Free all backing stores used for rendering to drop memory usage.
static void RemoveAllBackingStores();
diff --git a/content/public/test/mock_render_process_host.h b/content/public/test/mock_render_process_host.h
index ca05b22..648f697 100644
--- a/content/public/test/mock_render_process_host.h
+++ b/content/public/test/mock_render_process_host.h
@@ -72,10 +72,10 @@ class MockRenderProcessHost : public RenderProcessHost {
virtual base::TimeDelta GetChildProcessIdleTime() const OVERRIDE;
virtual void SurfaceUpdated(int32 surface_id) OVERRIDE;
- // IPC::Channel::Sender via RenderProcessHost.
+ // IPC::Sender via RenderProcessHost.
virtual bool Send(IPC::Message* msg) OVERRIDE;
- // IPC::Channel::Listener via RenderProcessHost.
+ // IPC::Listener via RenderProcessHost.
virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
diff --git a/ipc/ipc.gypi b/ipc/ipc.gypi
index 0684216..f7c11a6 100644
--- a/ipc/ipc.gypi
+++ b/ipc/ipc.gypi
@@ -26,6 +26,7 @@
'ipc_channel_win.h',
'ipc_descriptors.h',
'ipc_export.h',
+ 'ipc_listener.h',
'ipc_logging.cc',
'ipc_logging.h',
'ipc_message.cc',
@@ -36,6 +37,7 @@
'ipc_param_traits.h',
'ipc_platform_file.cc',
'ipc_platform_file.h',
+ 'ipc_sender.h',
'ipc_switches.cc',
'ipc_switches.h',
'ipc_sync_channel.cc',
diff --git a/ipc/ipc_channel.h b/ipc/ipc_channel.h
index 14c375b..bb3e242 100644
--- a/ipc/ipc_channel.h
+++ b/ipc/ipc_channel.h
@@ -16,9 +16,15 @@
#include "base/process.h"
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_message.h"
+#include "ipc/ipc_sender.h"
+
+// TODO(brettw) remove this when the "typedef Sender" is removed below.
+#include "ipc/ipc_listener.h"
namespace IPC {
+class Listener;
+
//------------------------------------------------------------------------------
// See
// http://www.chromium.org/developers/design-documents/inter-process-communication
@@ -36,38 +42,16 @@ namespace IPC {
// the channel with the mode set to one of the NAMED modes. NAMED modes are
// currently used by automation and service processes.
-class IPC_EXPORT Channel : public Message::Sender {
+class IPC_EXPORT Channel : public Sender {
// Security tests need access to the pipe handle.
friend class ChannelTest;
public:
- // Implemented by consumers of a Channel to receive messages.
- class IPC_EXPORT Listener {
- public:
- virtual ~Listener() {}
-
- // Called when a message is received. Returns true iff the message was
- // handled.
- virtual bool OnMessageReceived(const Message& message) = 0;
-
- // Called when the channel is connected and we have received the internal
- // Hello message from the peer.
- virtual void OnChannelConnected(int32 peer_pid) {}
-
- // Called when an error is detected that causes the channel to close.
- // This method is not called when a channel is closed normally.
- virtual void OnChannelError() {}
-
-#if defined(OS_POSIX)
- // Called on the server side when a channel that listens for connections
- // denies an attempt to connect.
- virtual void OnChannelDenied() {}
-
- // Called on the server side when a channel that listens for connections
- // has an error that causes the listening channel to close.
- virtual void OnChannelListenError() {}
-#endif // OS_POSIX
- };
+ // IPC::Listener used to be IPC::Channel::Listener which prevented forward
+ // declarations. To keep existing code compiling, we provide this
+ // backwards-compatible definition. New code should use IPC::Listener.
+ // TODO(brettw) converto users of this and delete.
+ typedef IPC::Listener Listener;
// Flags to test modes
enum ModeFlags {
diff --git a/ipc/ipc_channel_posix_unittest.cc b/ipc/ipc_channel_posix_unittest.cc
index 24fe2b0..834f0ea 100644
--- a/ipc/ipc_channel_posix_unittest.cc
+++ b/ipc/ipc_channel_posix_unittest.cc
@@ -20,13 +20,14 @@
#include "base/path_service.h"
#include "base/test/multiprocess_test.h"
#include "base/test/test_timeouts.h"
+#include "ipc/ipc_listener.h"
#include "testing/multiprocess_func_list.h"
namespace {
static const uint32 kQuitMessage = 47;
-class IPCChannelPosixTestListener : public IPC::Channel::Listener {
+class IPCChannelPosixTestListener : public IPC::Listener {
public:
enum STATUS {
DISCONNECTED,
diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc
index b9cc79c..6d2209d 100644
--- a/ipc/ipc_channel_proxy.cc
+++ b/ipc/ipc_channel_proxy.cc
@@ -9,6 +9,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "ipc/ipc_channel_proxy.h"
+#include "ipc/ipc_listener.h"
#include "ipc/ipc_logging.h"
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_message_utils.h"
@@ -41,7 +42,7 @@ ChannelProxy::MessageFilter::~MessageFilter() {}
//------------------------------------------------------------------------------
-ChannelProxy::Context::Context(Channel::Listener* listener,
+ChannelProxy::Context::Context(Listener* listener,
base::MessageLoopProxy* ipc_message_loop)
: listener_message_loop_(base::MessageLoopProxy::current()),
listener_(listener),
@@ -274,7 +275,7 @@ void ChannelProxy::Context::OnDispatchError() {
ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle,
Channel::Mode mode,
- Channel::Listener* listener,
+ Listener* listener,
base::MessageLoopProxy* ipc_thread)
: context_(new Context(listener, ipc_thread)),
outgoing_message_filter_(NULL),
diff --git a/ipc/ipc_channel_proxy.h b/ipc/ipc_channel_proxy.h
index 6f5b96f..e323c0f 100644
--- a/ipc/ipc_channel_proxy.h
+++ b/ipc/ipc_channel_proxy.h
@@ -14,6 +14,8 @@
#include "base/synchronization/lock.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_handle.h"
+#include "ipc/ipc_listener.h"
+#include "ipc/ipc_sender.h"
namespace IPC {
@@ -47,9 +49,8 @@ class SendCallbackHelper;
// The consumer of IPC::ChannelProxy is responsible for allocating the Thread
// instance where the IPC::Channel will be created and operated.
//
-class IPC_EXPORT ChannelProxy : public Message::Sender {
+class IPC_EXPORT ChannelProxy : public Sender {
public:
-
struct MessageFilterTraits;
// A class that receives messages on the thread where the IPC channel is
@@ -124,13 +125,13 @@ class IPC_EXPORT ChannelProxy : public Message::Sender {
// IPC::Channel should be created.
ChannelProxy(const IPC::ChannelHandle& channel_handle,
Channel::Mode mode,
- Channel::Listener* listener,
+ Listener* listener,
base::MessageLoopProxy* ipc_thread_loop);
// Creates an uninitialized channel proxy. Init must be called to receive
// or send any messages. This two-step setup allows message filters to be
// added before any messages are sent or received.
- ChannelProxy(Channel::Listener* listener,
+ ChannelProxy(Listener* listener,
base::MessageLoopProxy* ipc_thread_loop);
virtual ~ChannelProxy();
@@ -194,9 +195,9 @@ class IPC_EXPORT ChannelProxy : public Message::Sender {
// Used internally to hold state that is referenced on the IPC thread.
class Context : public base::RefCountedThreadSafe<Context>,
- public Channel::Listener {
+ public Listener {
public:
- Context(Channel::Listener* listener, base::MessageLoopProxy* ipc_thread);
+ Context(Listener* listener, base::MessageLoopProxy* ipc_thread);
void ClearIPCMessageLoop() { ipc_message_loop_ = NULL; }
base::MessageLoopProxy* ipc_message_loop() const {
return ipc_message_loop_.get();
@@ -210,7 +211,7 @@ class IPC_EXPORT ChannelProxy : public Message::Sender {
friend class base::RefCountedThreadSafe<Context>;
virtual ~Context();
- // IPC::Channel::Listener methods:
+ // IPC::Listener methods:
virtual bool OnMessageReceived(const Message& message) OVERRIDE;
virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
virtual void OnChannelError() OVERRIDE;
@@ -250,7 +251,7 @@ class IPC_EXPORT ChannelProxy : public Message::Sender {
void OnDispatchError();
scoped_refptr<base::MessageLoopProxy> listener_message_loop_;
- Channel::Listener* listener_;
+ Listener* listener_;
// List of filters. This is only accessed on the IPC thread.
std::vector<scoped_refptr<MessageFilter> > filters_;
diff --git a/ipc/ipc_channel_reader.cc b/ipc/ipc_channel_reader.cc
index 5080f51..a8761cd 100644
--- a/ipc/ipc_channel_reader.cc
+++ b/ipc/ipc_channel_reader.cc
@@ -7,8 +7,7 @@
namespace IPC {
namespace internal {
-ChannelReader::ChannelReader(Channel::Listener* listener)
- : listener_(listener) {
+ChannelReader::ChannelReader(Listener* listener) : listener_(listener) {
memset(input_buf_, 0, sizeof(input_buf_));
}
diff --git a/ipc/ipc_channel_reader.h b/ipc/ipc_channel_reader.h
index 192ca2d..9c398bd 100644
--- a/ipc/ipc_channel_reader.h
+++ b/ipc/ipc_channel_reader.h
@@ -25,10 +25,10 @@ namespace internal {
// here (and rename appropriately) rather than writing a different class.
class ChannelReader {
public:
- explicit ChannelReader(Channel::Listener* listener);
+ explicit ChannelReader(Listener* listener);
virtual ~ChannelReader();
- void set_listener(Channel::Listener* listener) { listener_ = listener; }
+ void set_listener(Listener* listener) { listener_ = listener; }
// Call to process messages received from the IPC connection and dispatch
// them. Returns false on channel error. True indicates that everything
@@ -49,7 +49,7 @@ class ChannelReader {
protected:
enum ReadState { READ_SUCCEEDED, READ_FAILED, READ_PENDING };
- Channel::Listener* listener() const { return listener_; }
+ Listener* listener() const { return listener_; }
// Populates the given buffer with data from the pipe.
//
@@ -86,7 +86,7 @@ class ChannelReader {
// Returns true on success. False means channel error.
bool DispatchInputData(const char* input_data, int input_data_len);
- Channel::Listener* listener_;
+ Listener* listener_;
// We read from the pipe into this buffer. Managed by DispatchInputData, do
// not access directly outside that function.
diff --git a/ipc/ipc_fuzzing_tests.cc b/ipc/ipc_fuzzing_tests.cc
index aa1fa5f..32fe71c 100644
--- a/ipc/ipc_fuzzing_tests.cc
+++ b/ipc/ipc_fuzzing_tests.cc
@@ -115,15 +115,15 @@ TEST(IPCMessageIntegrity, ReadVectorTooLarge2) {
EXPECT_FALSE(ReadParam(&m, &iter, &vec));
}
-class SimpleListener : public IPC::Channel::Listener {
+class SimpleListener : public IPC::Listener {
public:
SimpleListener() : other_(NULL) {
}
- void Init(IPC::Message::Sender* s) {
+ void Init(IPC::Sender* s) {
other_ = s;
}
protected:
- IPC::Message::Sender* other_;
+ IPC::Sender* other_;
};
enum {
diff --git a/ipc/ipc_listener.h b/ipc/ipc_listener.h
new file mode 100644
index 0000000..49c1228
--- /dev/null
+++ b/ipc/ipc_listener.h
@@ -0,0 +1,46 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IPC_IPC_LISTENER_H_
+#define IPC_IPC_LISTENER_H_
+
+#include "base/basictypes.h"
+#include "build/build_config.h"
+#include "ipc/ipc_export.h"
+
+namespace IPC {
+
+class Message;
+
+// Implemented by consumers of a Channel to receive messages.
+class IPC_EXPORT Listener {
+ public:
+ virtual ~Listener() {}
+
+ // Called when a message is received. Returns true iff the message was
+ // handled.
+ virtual bool OnMessageReceived(const Message& message) = 0;
+
+ // Called when the channel is connected and we have received the internal
+ // Hello message from the peer.
+ virtual void OnChannelConnected(int32 peer_pid) {}
+
+ // Called when an error is detected that causes the channel to close.
+ // This method is not called when a channel is closed normally.
+ virtual void OnChannelError() {}
+
+#if defined(OS_POSIX)
+ // Called on the server side when a channel that listens for connections
+ // denies an attempt to connect.
+ virtual void OnChannelDenied() {}
+
+ // Called on the server side when a channel that listens for connections
+ // has an error that causes the listening channel to close.
+ virtual void OnChannelListenError() {}
+#endif // OS_POSIX
+};
+
+} // namespace IPC
+
+#endif // IPC_IPC_LISTENER_H_
diff --git a/ipc/ipc_logging.cc b/ipc/ipc_logging.cc
index b9ca828..25286b1 100644
--- a/ipc/ipc_logging.cc
+++ b/ipc/ipc_logging.cc
@@ -103,7 +103,7 @@ void Logging::OnSendLogs() {
sender_->Send(msg);
}
-void Logging::SetIPCSender(IPC::Message::Sender* sender) {
+void Logging::SetIPCSender(IPC::Sender* sender) {
sender_ = sender;
}
diff --git a/ipc/ipc_logging.h b/ipc/ipc_logging.h
index 83b8590..43a1394 100644
--- a/ipc/ipc_logging.h
+++ b/ipc/ipc_logging.h
@@ -59,7 +59,7 @@ class IPC_EXPORT Logging {
// Called by child processes to give the logger object the channel to send
// logging data to the browser process.
- void SetIPCSender(Message::Sender* sender);
+ void SetIPCSender(Sender* sender);
// Called in the browser process when logging data from a child process is
// received.
@@ -112,7 +112,7 @@ class IPC_EXPORT Logging {
std::vector<LogData> queued_logs_;
bool queue_invoke_later_pending_;
- Message::Sender* sender_;
+ Sender* sender_;
MessageLoop* main_thread_;
Consumer* consumer_;
diff --git a/ipc/ipc_message.h b/ipc/ipc_message.h
index 2c85e42..c3d4296 100644
--- a/ipc/ipc_message.h
+++ b/ipc/ipc_message.h
@@ -12,6 +12,9 @@
#include "base/pickle.h"
#include "ipc/ipc_export.h"
+// TODO(brettw) remove this when the "typedef Sender" is removed below.
+#include "ipc/ipc_sender.h"
+
// Ipc logging adds a dependency from the 'chrome' target on all ipc message
// classes. In a component build, this would require exporting all message
// classes, so don't support ipc logging in the components build.
@@ -39,17 +42,11 @@ struct LogData;
class IPC_EXPORT Message : public Pickle {
public:
- // Implemented by objects that can send IPC messages across a channel.
- class IPC_EXPORT Sender {
- public:
- virtual ~Sender() {}
-
- // Sends the given IPC message. The implementor takes ownership of the
- // given Message regardless of whether or not this method succeeds. This
- // is done to make this method easier to use. Returns true on success and
- // false otherwise.
- virtual bool Send(Message* msg) = 0;
- };
+ // IPC::Sender used to be IPC::Message::Sender which prevented forward
+ // declarations. To keep existing code compiling, we provide this backwards-
+ // compatible definition. New code should use IPC::Sender.
+ // TODO(brettw) convert users of this and delete.
+ typedef IPC::Sender Sender;
enum PriorityValue {
PRIORITY_LOW = 1,
diff --git a/ipc/ipc_sender.h b/ipc/ipc_sender.h
new file mode 100644
index 0000000..f70f709
--- /dev/null
+++ b/ipc/ipc_sender.h
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IPC_IPC_SENDER_H_
+#define IPC_IPC_SENDER_H_
+
+#include "ipc/ipc_export.h"
+
+namespace IPC {
+
+class Message;
+
+class IPC_EXPORT Sender {
+ public:
+ virtual ~Sender() {}
+
+ // Sends the given IPC message. The implementor takes ownership of the
+ // given Message regardless of whether or not this method succeeds. This
+ // is done to make this method easier to use. Returns true on success and
+ // false otherwise.
+ virtual bool Send(Message* msg) = 0;
+};
+
+} // namespace IPC
+
+#endif // IPC_IPC_SENDER_H_
diff --git a/ipc/ipc_sync_channel_unittest.cc b/ipc/ipc_sync_channel_unittest.cc
index 7f0a7ab..a42196b 100644
--- a/ipc/ipc_sync_channel_unittest.cc
+++ b/ipc/ipc_sync_channel_unittest.cc
@@ -21,7 +21,9 @@
#include "base/threading/platform_thread.h"
#include "base/threading/thread.h"
#include "base/synchronization/waitable_event.h"
+#include "ipc/ipc_listener.h"
#include "ipc/ipc_message.h"
+#include "ipc/ipc_sender.h"
#include "ipc/ipc_sync_message_filter.h"
#include "ipc/ipc_sync_message_unittest.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -33,7 +35,7 @@ namespace IPC {
namespace {
// Base class for a "process" with listener and IPC threads.
-class Worker : public Channel::Listener, public Message::Sender {
+class Worker : public Listener, public Sender {
public:
// Will create a channel without a name.
Worker(Channel::Mode mode, const std::string& thread_name)
diff --git a/ipc/ipc_sync_message_filter.h b/ipc/ipc_sync_message_filter.h
index a4c27a2..b551f16 100644
--- a/ipc/ipc_sync_message_filter.h
+++ b/ipc/ipc_sync_message_filter.h
@@ -27,11 +27,11 @@ namespace IPC {
// receiving messages while waiting for a response. Note that this object can
// be used to send simultaneous synchronous messages from different threads.
class IPC_EXPORT SyncMessageFilter : public ChannelProxy::MessageFilter,
- public Message::Sender {
+ public Sender {
public:
explicit SyncMessageFilter(base::WaitableEvent* shutdown_event);
- // Message::Sender implementation.
+ // MessageSender implementation.
virtual bool Send(Message* message) OVERRIDE;
// ChannelProxy::MessageFilter implementation.
diff --git a/ipc/ipc_tests.cc b/ipc/ipc_tests.cc
index 2fc817c..763a592 100644
--- a/ipc/ipc_tests.cc
+++ b/ipc/ipc_tests.cc
@@ -28,6 +28,7 @@
#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_proxy.h"
#include "ipc/ipc_message_utils.h"
+#include "ipc/ipc_sender.h"
#include "ipc/ipc_switches.h"
#include "testing/multiprocess_func_list.h"
@@ -161,7 +162,7 @@ TEST_F(IPCChannelTest, BasicMessageTest) {
EXPECT_FALSE(m.ReadWString(&iter, &vw));
}
-static void Send(IPC::Message::Sender* sender, const char* text) {
+static void Send(IPC::Sender* sender, const char* text) {
static int message_index = 0;
IPC::Message* message = new IPC::Message(0,
@@ -205,13 +206,13 @@ class MyChannelListener : public IPC::Channel::Listener {
MessageLoop::current()->Quit();
}
- void Init(IPC::Message::Sender* s) {
+ void Init(IPC::Sender* s) {
sender_ = s;
messages_left_ = 50;
}
private:
- IPC::Message::Sender* sender_;
+ IPC::Sender* sender_;
int messages_left_;
};
@@ -350,7 +351,7 @@ class ChannelListenerWithOnConnectedSend : public IPC::Channel::Listener {
MessageLoop::current()->Quit();
}
- void Init(IPC::Message::Sender* s) {
+ void Init(IPC::Sender* s) {
sender_ = s;
messages_left_ = 50;
}
@@ -364,7 +365,7 @@ class ChannelListenerWithOnConnectedSend : public IPC::Channel::Listener {
}
}
- IPC::Message::Sender* sender_;
+ IPC::Sender* sender_;
int messages_left_;
};