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

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

Issue 285333003: Support exposing Mojo services between render frames, render threads, and their respective hosts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 6 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
« no previous file with comments | « content/child/BUILD.gn ('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/child/mojo/mojo_application.h"
16 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
17 #include "content/common/message_router.h" 18 #include "content/common/message_router.h"
18 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. 19 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
19 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
20 20
21 namespace base { 21 namespace base {
22 class MessageLoop; 22 class MessageLoop;
23 23
24 namespace debug { 24 namespace debug {
25 class TraceMemoryController; 25 class TraceMemoryController;
26 } // namespace debug 26 } // namespace debug
27 } // namespace base 27 } // namespace base
28 28
29 namespace IPC { 29 namespace IPC {
30 class SyncChannel; 30 class SyncChannel;
31 class SyncMessageFilter; 31 class SyncMessageFilter;
32 } // namespace IPC 32 } // namespace IPC
33 33
34 namespace blink { 34 namespace blink {
35 class WebFrame; 35 class WebFrame;
36 } // namespace blink 36 } // namespace blink
37 37
38 namespace webkit_glue { 38 namespace webkit_glue {
39 class ResourceLoaderBridge; 39 class ResourceLoaderBridge;
40 } // namespace webkit_glue 40 } // namespace webkit_glue
41 41
42 namespace content { 42 namespace content {
43 class ChildHistogramMessageFilter; 43 class ChildHistogramMessageFilter;
44 class ChildResourceMessageFilter; 44 class ChildResourceMessageFilter;
45 class ChildSharedBitmapManager; 45 class ChildSharedBitmapManager;
46 class FileSystemDispatcher; 46 class FileSystemDispatcher;
47 class MojoApplication;
48 class ServiceWorkerDispatcher; 47 class ServiceWorkerDispatcher;
49 class ServiceWorkerMessageFilter; 48 class ServiceWorkerMessageFilter;
50 class QuotaDispatcher; 49 class QuotaDispatcher;
51 class QuotaMessageFilter; 50 class QuotaMessageFilter;
52 class ResourceDispatcher; 51 class ResourceDispatcher;
53 class SocketStreamDispatcher; 52 class SocketStreamDispatcher;
54 class ThreadSafeSender; 53 class ThreadSafeSender;
55 class WebSocketDispatcher; 54 class WebSocketDispatcher;
56 struct RequestInfo; 55 struct RequestInfo;
57 56
58 // The main thread of a child process derives from this class. 57 // The main thread of a child process derives from this class.
59 class CONTENT_EXPORT ChildThread 58 class CONTENT_EXPORT ChildThread : public IPC::Listener, public IPC::Sender {
60 : public IPC::Listener,
61 public IPC::Sender,
62 public NON_EXPORTED_BASE(mojo::ServiceProvider) {
63 public: 59 public:
64 // Creates the thread. 60 // Creates the thread.
65 ChildThread(); 61 ChildThread();
66 // Used for single-process mode and for in process gpu mode. 62 // Used for single-process mode and for in process gpu mode.
67 explicit ChildThread(const std::string& channel_name); 63 explicit ChildThread(const std::string& channel_name);
68 // ChildProcess::main_thread() is reset after Shutdown(), and before the 64 // ChildProcess::main_thread() is reset after Shutdown(), and before the
69 // destructor, so any subsystem that relies on ChildProcess::main_thread() 65 // destructor, so any subsystem that relies on ChildProcess::main_thread()
70 // must be terminated before Shutdown returns. In particular, if a subsystem 66 // must be terminated before Shutdown returns. In particular, if a subsystem
71 // has a thread that post tasks to ChildProcess::main_thread(), that thread 67 // has a thread that post tasks to ChildProcess::main_thread(), that thread
72 // should be joined in Shutdown(). 68 // should be joined in Shutdown().
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 142
147 // Returns the one child thread. Can only be called on the main thread. 143 // Returns the one child thread. Can only be called on the main thread.
148 static ChildThread* current(); 144 static ChildThread* current();
149 145
150 #if defined(OS_ANDROID) 146 #if defined(OS_ANDROID)
151 // Called on Android's service thread to shutdown the main thread of this 147 // Called on Android's service thread to shutdown the main thread of this
152 // process. 148 // process.
153 static void ShutdownThread(); 149 static void ShutdownThread();
154 #endif 150 #endif
155 151
152 ServiceRegistry* service_registry() const {
153 return mojo_application_->service_registry();
154 }
155
156 protected: 156 protected:
157 friend class ChildProcess; 157 friend class ChildProcess;
158 158
159 // Called when the process refcount is 0. 159 // Called when the process refcount is 0.
160 void OnProcessFinalRelease(); 160 void OnProcessFinalRelease();
161 161
162 virtual bool OnControlMessageReceived(const IPC::Message& msg); 162 virtual bool OnControlMessageReceived(const IPC::Message& msg);
163 163
164 void set_on_channel_error_called(bool on_channel_error_called) { 164 void set_on_channel_error_called(bool on_channel_error_called) {
165 on_channel_error_called_ = on_channel_error_called; 165 on_channel_error_called_ = on_channel_error_called;
166 } 166 }
167 167
168 // IPC::Listener implementation: 168 // IPC::Listener implementation:
169 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 169 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
170 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 170 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
171 virtual void OnChannelError() OVERRIDE; 171 virtual void OnChannelError() OVERRIDE;
172 172
173 // mojo::ServiceProvider implementation:
174 virtual void ConnectToService(
175 const mojo::String& service_url,
176 const mojo::String& service_name,
177 mojo::ScopedMessagePipeHandle message_pipe,
178 const mojo::String& requestor_url) OVERRIDE;
179
180 private: 173 private:
181 class ChildThreadMessageRouter : public MessageRouter { 174 class ChildThreadMessageRouter : public MessageRouter {
182 public: 175 public:
183 // |sender| must outlive this object. 176 // |sender| must outlive this object.
184 explicit ChildThreadMessageRouter(IPC::Sender* sender); 177 explicit ChildThreadMessageRouter(IPC::Sender* sender);
185 virtual bool Send(IPC::Message* msg) OVERRIDE; 178 virtual bool Send(IPC::Message* msg) OVERRIDE;
186 179
187 private: 180 private:
188 IPC::Sender* const sender_; 181 IPC::Sender* const sender_;
189 }; 182 };
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 scoped_ptr<base::PowerMonitor> power_monitor_; 250 scoped_ptr<base::PowerMonitor> power_monitor_;
258 251
259 bool in_browser_process_; 252 bool in_browser_process_;
260 253
261 DISALLOW_COPY_AND_ASSIGN(ChildThread); 254 DISALLOW_COPY_AND_ASSIGN(ChildThread);
262 }; 255 };
263 256
264 } // namespace content 257 } // namespace content
265 258
266 #endif // CONTENT_CHILD_CHILD_THREAD_H_ 259 #endif // CONTENT_CHILD_CHILD_THREAD_H_
OLDNEW
« no previous file with comments | « content/child/BUILD.gn ('k') | content/child/child_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698