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

Side by Side Diff: content/child/child_thread.h

Issue 236813002: Move Mojo channel initialization closer to IPC::Channel setup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more missing deps Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.cc ('k') | content/child/child_thread.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_CHILD_CHILD_THREAD_H_ 5 #ifndef CONTENT_CHILD_CHILD_THREAD_H_
6 #define CONTENT_CHILD_CHILD_THREAD_H_ 6 #define CONTENT_CHILD_CHILD_THREAD_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/shared_memory.h" 12 #include "base/memory/shared_memory.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/power_monitor/power_monitor.h" 14 #include "base/power_monitor/power_monitor.h"
15 #include "base/tracked_objects.h" 15 #include "base/tracked_objects.h"
16 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
17 #include "content/common/message_router.h" 17 #include "content/common/message_router.h"
18 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. 18 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
19 #include "mojo/public/interfaces/shell/shell.mojom.h"
19 20
20 namespace base { 21 namespace base {
21 class MessageLoop; 22 class MessageLoop;
22 23
23 namespace debug { 24 namespace debug {
24 class TraceMemoryController; 25 class TraceMemoryController;
25 } // namespace debug 26 } // namespace debug
26 } // namespace base 27 } // namespace base
27 28
28 namespace IPC { 29 namespace IPC {
29 class SyncChannel; 30 class SyncChannel;
30 class SyncMessageFilter; 31 class SyncMessageFilter;
31 } // namespace IPC 32 } // namespace IPC
32 33
33 namespace blink { 34 namespace blink {
34 class WebFrame; 35 class WebFrame;
35 } // namespace blink 36 } // namespace blink
36 37
37 namespace webkit_glue { 38 namespace webkit_glue {
38 class ResourceLoaderBridge; 39 class ResourceLoaderBridge;
39 } // namespace webkit_glue 40 } // namespace webkit_glue
40 41
41 namespace content { 42 namespace content {
42 class ChildHistogramMessageFilter; 43 class ChildHistogramMessageFilter;
43 class ChildResourceMessageFilter; 44 class ChildResourceMessageFilter;
44 class ChildSharedBitmapManager; 45 class ChildSharedBitmapManager;
45 class FileSystemDispatcher; 46 class FileSystemDispatcher;
47 class MojoApplication;
46 class ServiceWorkerDispatcher; 48 class ServiceWorkerDispatcher;
47 class ServiceWorkerMessageFilter; 49 class ServiceWorkerMessageFilter;
48 class QuotaDispatcher; 50 class QuotaDispatcher;
49 class QuotaMessageFilter; 51 class QuotaMessageFilter;
50 class ResourceDispatcher; 52 class ResourceDispatcher;
51 class SocketStreamDispatcher; 53 class SocketStreamDispatcher;
52 class ThreadSafeSender; 54 class ThreadSafeSender;
53 class WebSocketDispatcher; 55 class WebSocketDispatcher;
54 struct RequestInfo; 56 struct RequestInfo;
55 57
56 // The main thread of a child process derives from this class. 58 // The main thread of a child process derives from this class.
57 class CONTENT_EXPORT ChildThread : public IPC::Listener, public IPC::Sender { 59 class CONTENT_EXPORT ChildThread : public IPC::Listener,
60 public IPC::Sender,
61 public mojo::ShellClient {
58 public: 62 public:
59 // Creates the thread. 63 // Creates the thread.
60 ChildThread(); 64 ChildThread();
61 // Used for single-process mode and for in process gpu mode. 65 // Used for single-process mode and for in process gpu mode.
62 explicit ChildThread(const std::string& channel_name); 66 explicit ChildThread(const std::string& channel_name);
63 // ChildProcess::main_thread() is reset after Shutdown(), and before the 67 // ChildProcess::main_thread() is reset after Shutdown(), and before the
64 // destructor, so any subsystem that relies on ChildProcess::main_thread() 68 // destructor, so any subsystem that relies on ChildProcess::main_thread()
65 // must be terminated before Shutdown returns. In particular, if a subsystem 69 // must be terminated before Shutdown returns. In particular, if a subsystem
66 // has a thread that post tasks to ChildProcess::main_thread(), that thread 70 // has a thread that post tasks to ChildProcess::main_thread(), that thread
67 // should be joined in Shutdown(). 71 // should be joined in Shutdown().
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 167
164 void set_on_channel_error_called(bool on_channel_error_called) { 168 void set_on_channel_error_called(bool on_channel_error_called) {
165 on_channel_error_called_ = on_channel_error_called; 169 on_channel_error_called_ = on_channel_error_called;
166 } 170 }
167 171
168 // IPC::Listener implementation: 172 // IPC::Listener implementation:
169 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 173 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
170 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 174 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
171 virtual void OnChannelError() OVERRIDE; 175 virtual void OnChannelError() OVERRIDE;
172 176
177 // mojo::ShellClient implementation:
178 virtual void AcceptConnection(
179 const mojo::String& service_name,
180 mojo::ScopedMessagePipeHandle message_pipe) OVERRIDE;
181
173 private: 182 private:
174 class ChildThreadMessageRouter : public MessageRouter { 183 class ChildThreadMessageRouter : public MessageRouter {
175 public: 184 public:
176 // |sender| must outlive this object. 185 // |sender| must outlive this object.
177 explicit ChildThreadMessageRouter(IPC::Sender* sender); 186 explicit ChildThreadMessageRouter(IPC::Sender* sender);
178 virtual bool Send(IPC::Message* msg) OVERRIDE; 187 virtual bool Send(IPC::Message* msg) OVERRIDE;
179 188
180 private: 189 private:
181 IPC::Sender* const sender_; 190 IPC::Sender* const sender_;
182 }; 191 };
183 192
184 void Init(); 193 void Init();
185 194
186 // IPC message handlers. 195 // IPC message handlers.
187 void OnShutdown(); 196 void OnShutdown();
188 void OnSetProfilerStatus(tracked_objects::ThreadData::Status status); 197 void OnSetProfilerStatus(tracked_objects::ThreadData::Status status);
189 void OnGetChildProfilerData(int sequence_number); 198 void OnGetChildProfilerData(int sequence_number);
190 void OnDumpHandles(); 199 void OnDumpHandles();
191 #ifdef IPC_MESSAGE_LOG_ENABLED 200 #ifdef IPC_MESSAGE_LOG_ENABLED
192 void OnSetIPCLoggingEnabled(bool enable); 201 void OnSetIPCLoggingEnabled(bool enable);
193 #endif 202 #endif
194 #if defined(USE_TCMALLOC) 203 #if defined(USE_TCMALLOC)
195 void OnGetTcmallocStats(); 204 void OnGetTcmallocStats();
196 #endif 205 #endif
197 206
198 void EnsureConnected(); 207 void EnsureConnected();
199 208
209 scoped_ptr<MojoApplication> mojo_application_;
210
200 std::string channel_name_; 211 std::string channel_name_;
201 scoped_ptr<IPC::SyncChannel> channel_; 212 scoped_ptr<IPC::SyncChannel> channel_;
202 213
203 // Allows threads other than the main thread to send sync messages. 214 // Allows threads other than the main thread to send sync messages.
204 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; 215 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_;
205 216
206 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 217 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
207 218
208 // Implements message routing functionality to the consumers of ChildThread. 219 // Implements message routing functionality to the consumers of ChildThread.
209 ChildThreadMessageRouter router_; 220 ChildThreadMessageRouter router_;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 scoped_ptr<base::PowerMonitor> power_monitor_; 258 scoped_ptr<base::PowerMonitor> power_monitor_;
248 259
249 bool in_browser_process_; 260 bool in_browser_process_;
250 261
251 DISALLOW_COPY_AND_ASSIGN(ChildThread); 262 DISALLOW_COPY_AND_ASSIGN(ChildThread);
252 }; 263 };
253 264
254 } // namespace content 265 } // namespace content
255 266
256 #endif // CONTENT_CHILD_CHILD_THREAD_H_ 267 #endif // CONTENT_CHILD_CHILD_THREAD_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.cc ('k') | content/child/child_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698