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

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

Issue 42113: Ensure that a listener's OnChannelConnected is called before OnMessageReceive... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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 | « no previous file | 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 #include "base/lock.h" 9 #include "base/lock.h"
10 #include "base/ref_counted.h" 10 #include "base/ref_counted.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 bool create_pipe_now); 131 bool create_pipe_now);
132 132
133 // Used internally to hold state that is referenced on the IPC thread. 133 // Used internally to hold state that is referenced on the IPC thread.
134 class Context : public base::RefCountedThreadSafe<Context>, 134 class Context : public base::RefCountedThreadSafe<Context>,
135 public Channel::Listener { 135 public Channel::Listener {
136 public: 136 public:
137 Context(Channel::Listener* listener, MessageFilter* filter, 137 Context(Channel::Listener* listener, MessageFilter* filter,
138 MessageLoop* ipc_thread); 138 MessageLoop* ipc_thread);
139 virtual ~Context() { } 139 virtual ~Context() { }
140 MessageLoop* ipc_message_loop() const { return ipc_message_loop_; } 140 MessageLoop* ipc_message_loop() const { return ipc_message_loop_; }
141 Channel::Listener* listener() const { return listener_; }
142 const std::wstring& channel_id() const { return channel_id_; } 141 const std::wstring& channel_id() const { return channel_id_; }
143 142
143 // Dispatches a message on the listener thread.
144 void OnDispatchMessage(const Message& message);
145
144 protected: 146 protected:
145 // IPC::Channel::Listener methods: 147 // IPC::Channel::Listener methods:
146 virtual void OnMessageReceived(const Message& message); 148 virtual void OnMessageReceived(const Message& message);
147 virtual void OnChannelConnected(int32 peer_pid); 149 virtual void OnChannelConnected(int32 peer_pid);
148 virtual void OnChannelError(); 150 virtual void OnChannelError();
149 151
150 // Like OnMessageReceived but doesn't try the filters. 152 // Like OnMessageReceived but doesn't try the filters.
151 void OnMessageReceivedNoFilter(const Message& message); 153 void OnMessageReceivedNoFilter(const Message& message);
152 154
153 // Gives the filters a chance at processing |message|. 155 // Gives the filters a chance at processing |message|.
(...skipping 11 matching lines...) Expand all
165 167
166 private: 168 private:
167 friend class ChannelProxy; 169 friend class ChannelProxy;
168 // Create the Channel 170 // Create the Channel
169 void CreateChannel(const std::wstring& id, const Channel::Mode& mode); 171 void CreateChannel(const std::wstring& id, const Channel::Mode& mode);
170 172
171 // Methods called via InvokeLater: 173 // Methods called via InvokeLater:
172 void OnSendMessage(Message* message_ptr); 174 void OnSendMessage(Message* message_ptr);
173 void OnAddFilter(MessageFilter* filter); 175 void OnAddFilter(MessageFilter* filter);
174 void OnRemoveFilter(MessageFilter* filter); 176 void OnRemoveFilter(MessageFilter* filter);
175 void OnDispatchMessage(const Message& message); 177 void OnDispatchConnected();
176 void OnDispatchConnected(int32 peer_pid);
177 void OnDispatchError(); 178 void OnDispatchError();
178 179
179 MessageLoop* listener_message_loop_; 180 MessageLoop* listener_message_loop_;
180 Channel::Listener* listener_; 181 Channel::Listener* listener_;
181 182
182 // List of filters. This is only accessed on the IPC thread. 183 // List of filters. This is only accessed on the IPC thread.
183 std::vector<scoped_refptr<MessageFilter> > filters_; 184 std::vector<scoped_refptr<MessageFilter> > filters_;
184 MessageLoop* ipc_message_loop_; 185 MessageLoop* ipc_message_loop_;
185 Channel* channel_; 186 Channel* channel_;
186 std::wstring channel_id_; 187 std::wstring channel_id_;
188 int peer_pid_;
189 bool channel_connected_called_;
187 }; 190 };
188 191
189 Context* context() { return context_; } 192 Context* context() { return context_; }
190 193
191 private: 194 private:
192 void Init(const std::wstring& channel_id, Channel::Mode mode, 195 void Init(const std::wstring& channel_id, Channel::Mode mode,
193 MessageLoop* ipc_thread_loop, bool create_pipe_now); 196 MessageLoop* ipc_thread_loop, bool create_pipe_now);
194 197
195 // By maintaining this indirection (ref-counted) to our internal state, we 198 // By maintaining this indirection (ref-counted) to our internal state, we
196 // can safely be destroyed while the background thread continues to do stuff 199 // can safely be destroyed while the background thread continues to do stuff
197 // that involves this data. 200 // that involves this data.
198 scoped_refptr<Context> context_; 201 scoped_refptr<Context> context_;
199 }; 202 };
200 203
201 } // namespace IPC 204 } // namespace IPC
202 205
203 #endif // CHROME_COMMON_IPC_CHANNEL_PROXY_H__ 206 #endif // CHROME_COMMON_IPC_CHANNEL_PROXY_H__
OLDNEW
« no previous file with comments | « no previous file | chrome/common/ipc_channel_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698