Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Unified Diff: ipc/ipc_channel_proxy.h

Issue 6711024: Example of how to interpose yourself in a message stream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ipc/ipc_channel_proxy.h
===================================================================
--- ipc/ipc_channel_proxy.h (revision 83739)
+++ ipc/ipc_channel_proxy.h (working copy)
@@ -99,6 +99,15 @@
}
};
+ // Interface for a filter to be imposed on outgoing messages which can
+ // re-write the message. Used mainly for testing.
+ class OutgoingMessageFilter {
+ public:
+ // Returns a re-written message, freeing the original, or simply the
+ // original unchanged if no rewrite indicated.
+ virtual Message *Rewrite(Message *message) = 0;
+ };
+
// Initializes a channel proxy. The channel_handle and mode parameters are
// passed directly to the underlying IPC::Channel. The listener is called on
// the thread that creates the ChannelProxy. The filter's OnMessageReceived
@@ -140,6 +149,10 @@
void AddFilter(MessageFilter* filter);
void RemoveFilter(MessageFilter* filter);
+ void set_outgoing_message_filter(OutgoingMessageFilter* filter) {
+ outgoing_message_filter_ = filter;
+ }
+
// Called to clear the pointer to the IPC message loop when it's going away.
void ClearIPCMessageLoop();
@@ -235,6 +248,10 @@
Context* context() { return context_; }
+ OutgoingMessageFilter* outgoing_message_filter() {
+ return outgoing_message_filter_;
+ }
+
private:
friend class SendTask;
@@ -245,6 +262,8 @@
// can safely be destroyed while the background thread continues to do stuff
// that involves this data.
scoped_refptr<Context> context_;
+
+ OutgoingMessageFilter* outgoing_message_filter_;
};
} // namespace IPC

Powered by Google App Engine
This is Rietveld 408576698