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

Side by Side Diff: chrome/common/ipc_channel_proxy.h

Issue 155876: Revert r21117 as it caused reliability failures.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/histogram_synchronizer.cc ('k') | chrome/common/ipc_channel_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_COMMON_IPC_CHANNEL_PROXY_H__ 5 #ifndef CHROME_COMMON_IPC_CHANNEL_PROXY_H__
6 #define CHROME_COMMON_IPC_CHANNEL_PROXY_H__ 6 #define CHROME_COMMON_IPC_CHANNEL_PROXY_H__
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/ref_counted.h" 10 #include "base/ref_counted.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 virtual bool Send(Message* message); 110 virtual bool Send(Message* message);
111 111
112 // Used to intercept messages as they are received on the background thread. 112 // Used to intercept messages as they are received on the background thread.
113 // 113 //
114 // Ordinarily, messages sent to the ChannelProxy are routed to the matching 114 // Ordinarily, messages sent to the ChannelProxy are routed to the matching
115 // listener on the worker thread. This API allows code to intercept messages 115 // listener on the worker thread. This API allows code to intercept messages
116 // before they are sent to the worker thread. 116 // before they are sent to the worker thread.
117 void AddFilter(MessageFilter* filter); 117 void AddFilter(MessageFilter* filter);
118 void RemoveFilter(MessageFilter* filter); 118 void RemoveFilter(MessageFilter* filter);
119 119
120 // Called to clear the pointer to the IPC message loop when it's going away.
121 void ClearIPCMessageLoop();
122
123 #if defined(OS_POSIX) 120 #if defined(OS_POSIX)
124 // Calls through to the underlying channel's methods. 121 // Calls through to the underlying channel's methods.
125 // TODO(playmobil): For now this is only implemented in the case of 122 // TODO(playmobil): For now this is only implemented in the case of
126 // create_pipe_now = true, we need to figure this out for the latter case. 123 // create_pipe_now = true, we need to figure this out for the latter case.
127 int GetClientFileDescriptor() const; 124 int GetClientFileDescriptor() const;
128 #endif // defined(OS_POSIX) 125 #endif // defined(OS_POSIX)
129 126
130 protected: 127 protected:
131 class Context; 128 class Context;
132 // A subclass uses this constructor if it needs to add more information 129 // A subclass uses this constructor if it needs to add more information
133 // to the internal state. If create_pipe_now is true, the pipe is created 130 // to the internal state. If create_pipe_now is true, the pipe is created
134 // immediately. Otherwise it's created on the IO thread. 131 // immediately. Otherwise it's created on the IO thread.
135 ChannelProxy(const std::string& channel_id, Channel::Mode mode, 132 ChannelProxy(const std::string& channel_id, Channel::Mode mode,
136 MessageLoop* ipc_thread_loop, Context* context, 133 MessageLoop* ipc_thread_loop, Context* context,
137 bool create_pipe_now); 134 bool create_pipe_now);
138 135
139 // Used internally to hold state that is referenced on the IPC thread. 136 // Used internally to hold state that is referenced on the IPC thread.
140 class Context : public base::RefCountedThreadSafe<Context>, 137 class Context : public base::RefCountedThreadSafe<Context>,
141 public Channel::Listener { 138 public Channel::Listener {
142 public: 139 public:
143 Context(Channel::Listener* listener, MessageFilter* filter, 140 Context(Channel::Listener* listener, MessageFilter* filter,
144 MessageLoop* ipc_thread); 141 MessageLoop* ipc_thread);
145 virtual ~Context() { } 142 virtual ~Context() { }
146 void ClearIPCMessageLoop() { ipc_message_loop_ = NULL; }
147 MessageLoop* ipc_message_loop() const { return ipc_message_loop_; } 143 MessageLoop* ipc_message_loop() const { return ipc_message_loop_; }
148 const std::string& channel_id() const { return channel_id_; } 144 const std::string& channel_id() const { return channel_id_; }
149 145
150 // Dispatches a message on the listener thread. 146 // Dispatches a message on the listener thread.
151 void OnDispatchMessage(const Message& message); 147 void OnDispatchMessage(const Message& message);
152 148
153 protected: 149 protected:
154 // IPC::Channel::Listener methods: 150 // IPC::Channel::Listener methods:
155 virtual void OnMessageReceived(const Message& message); 151 virtual void OnMessageReceived(const Message& message);
156 virtual void OnChannelConnected(int32 peer_pid); 152 virtual void OnChannelConnected(int32 peer_pid);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 200
205 // By maintaining this indirection (ref-counted) to our internal state, we 201 // By maintaining this indirection (ref-counted) to our internal state, we
206 // can safely be destroyed while the background thread continues to do stuff 202 // can safely be destroyed while the background thread continues to do stuff
207 // that involves this data. 203 // that involves this data.
208 scoped_refptr<Context> context_; 204 scoped_refptr<Context> context_;
209 }; 205 };
210 206
211 } // namespace IPC 207 } // namespace IPC
212 208
213 #endif // CHROME_COMMON_IPC_CHANNEL_PROXY_H__ 209 #endif // CHROME_COMMON_IPC_CHANNEL_PROXY_H__
OLDNEW
« no previous file with comments | « chrome/common/histogram_synchronizer.cc ('k') | chrome/common/ipc_channel_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698