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

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

Issue 2138263002: Revert of Move content's shell connections to the IO thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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_IMPL_H_ 5 #ifndef CONTENT_CHILD_CHILD_THREAD_IMPL_H_
6 #define CONTENT_CHILD_CHILD_THREAD_IMPL_H_ 6 #define CONTENT_CHILD_CHILD_THREAD_IMPL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/shared_memory.h" 15 #include "base/memory/shared_memory.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/power_monitor/power_monitor.h" 17 #include "base/power_monitor/power_monitor.h"
18 #include "base/sequenced_task_runner.h" 18 #include "base/sequenced_task_runner.h"
19 #include "base/tracked_objects.h" 19 #include "base/tracked_objects.h"
20 #include "build/build_config.h" 20 #include "build/build_config.h"
21 #include "content/common/content_export.h" 21 #include "content/common/content_export.h"
22 #include "content/public/child/child_thread.h" 22 #include "content/public/child/child_thread.h"
23 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. 23 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
24 #include "ipc/ipc_platform_file.h" 24 #include "ipc/ipc_platform_file.h"
25 #include "ipc/message_router.h" 25 #include "ipc/message_router.h"
26 #include "services/shell/public/cpp/service.h"
26 27
27 namespace base { 28 namespace base {
28 class MessageLoop; 29 class MessageLoop;
29 } // namespace base 30 } // namespace base
30 31
31 namespace IPC { 32 namespace IPC {
32 class MessageFilter; 33 class MessageFilter;
33 class SyncChannel; 34 class SyncChannel;
34 class SyncMessageFilter; 35 class SyncMessageFilter;
35 } // namespace IPC 36 } // namespace IPC
(...skipping 24 matching lines...) Expand all
60 class QuotaMessageFilter; 61 class QuotaMessageFilter;
61 class ResourceDispatcher; 62 class ResourceDispatcher;
62 class ThreadSafeSender; 63 class ThreadSafeSender;
63 class WebSocketDispatcher; 64 class WebSocketDispatcher;
64 class WebSocketMessageFilter; 65 class WebSocketMessageFilter;
65 struct RequestInfo; 66 struct RequestInfo;
66 67
67 // The main thread of a child process derives from this class. 68 // The main thread of a child process derives from this class.
68 class CONTENT_EXPORT ChildThreadImpl 69 class CONTENT_EXPORT ChildThreadImpl
69 : public IPC::Listener, 70 : public IPC::Listener,
70 virtual public ChildThread { 71 virtual public ChildThread,
72 public NON_EXPORTED_BASE(shell::Service){
71 public: 73 public:
72 struct CONTENT_EXPORT Options; 74 struct CONTENT_EXPORT Options;
73 75
74 // Creates the thread. 76 // Creates the thread.
75 ChildThreadImpl(); 77 ChildThreadImpl();
76 // Allow to be used for single-process mode and for in process gpu mode via 78 // Allow to be used for single-process mode and for in process gpu mode via
77 // options. 79 // options.
78 explicit ChildThreadImpl(const Options& options); 80 explicit ChildThreadImpl(const Options& options);
79 // ChildProcess::main_thread() is reset after Shutdown(), and before the 81 // ChildProcess::main_thread() is reset after Shutdown(), and before the
80 // destructor, so any subsystem that relies on ChildProcess::main_thread() 82 // destructor, so any subsystem that relies on ChildProcess::main_thread()
(...skipping 11 matching lines...) Expand all
92 #if defined(OS_WIN) 94 #if defined(OS_WIN)
93 void PreCacheFont(const LOGFONT& log_font) override; 95 void PreCacheFont(const LOGFONT& log_font) override;
94 void ReleaseCachedFonts() override; 96 void ReleaseCachedFonts() override;
95 #endif 97 #endif
96 void RecordAction(const base::UserMetricsAction& action) override; 98 void RecordAction(const base::UserMetricsAction& action) override;
97 void RecordComputedAction(const std::string& action) override; 99 void RecordComputedAction(const std::string& action) override;
98 MojoShellConnection* GetMojoShellConnection() override; 100 MojoShellConnection* GetMojoShellConnection() override;
99 shell::InterfaceRegistry* GetInterfaceRegistry() override; 101 shell::InterfaceRegistry* GetInterfaceRegistry() override;
100 shell::InterfaceProvider* GetRemoteInterfaces() override; 102 shell::InterfaceProvider* GetRemoteInterfaces() override;
101 103
104 // shell::Service:
105 shell::InterfaceRegistry* GetInterfaceRegistryForConnection() override;
106 shell::InterfaceProvider* GetInterfaceProviderForConnection() override;
107
102 IPC::SyncChannel* channel() { return channel_.get(); } 108 IPC::SyncChannel* channel() { return channel_.get(); }
103 109
104 IPC::MessageRouter* GetRouter(); 110 IPC::MessageRouter* GetRouter();
105 111
106 // Allocates a block of shared memory of the given size. Returns NULL on 112 // Allocates a block of shared memory of the given size. Returns NULL on
107 // failure. 113 // failure.
108 // Note: On posix, this requires a sync IPC to the browser process, 114 // Note: On posix, this requires a sync IPC to the browser process,
109 // but on windows the child process directly allocates the block. 115 // but on windows the child process directly allocates the block.
110 std::unique_ptr<base::SharedMemory> AllocateSharedMemory(size_t buf_size); 116 std::unique_ptr<base::SharedMemory> AllocateSharedMemory(size_t buf_size);
111 117
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // process. 202 // process.
197 static void ShutdownThread(); 203 static void ShutdownThread();
198 #endif 204 #endif
199 205
200 protected: 206 protected:
201 friend class ChildProcess; 207 friend class ChildProcess;
202 208
203 // Called when the process refcount is 0. 209 // Called when the process refcount is 0.
204 void OnProcessFinalRelease(); 210 void OnProcessFinalRelease();
205 211
206 // Implemented by subclasses to attach ConnectionFilters to the thread's
207 // shell connection.
208 virtual void AddConnectionFilters(MojoShellConnection* connection);
209
210 virtual bool OnControlMessageReceived(const IPC::Message& msg); 212 virtual bool OnControlMessageReceived(const IPC::Message& msg);
211 virtual void OnProcessBackgrounded(bool backgrounded); 213 virtual void OnProcessBackgrounded(bool backgrounded);
212 virtual void OnProcessPurgeAndSuspend(); 214 virtual void OnProcessPurgeAndSuspend();
213 215
214 // IPC::Listener implementation: 216 // IPC::Listener implementation:
215 bool OnMessageReceived(const IPC::Message& msg) override; 217 bool OnMessageReceived(const IPC::Message& msg) override;
216 void OnChannelConnected(int32_t peer_pid) override; 218 void OnChannelConnected(int32_t peer_pid) override;
217 void OnChannelError() override; 219 void OnChannelError() override;
218 220
219 bool IsInBrowserProcess() const; 221 bool IsInBrowserProcess() const;
(...skipping 24 matching lines...) Expand all
244 void OnSetProfilerStatus(tracked_objects::ThreadData::Status status); 246 void OnSetProfilerStatus(tracked_objects::ThreadData::Status status);
245 void OnGetChildProfilerData(int sequence_number, int current_profiling_phase); 247 void OnGetChildProfilerData(int sequence_number, int current_profiling_phase);
246 void OnProfilingPhaseCompleted(int profiling_phase); 248 void OnProfilingPhaseCompleted(int profiling_phase);
247 #ifdef IPC_MESSAGE_LOG_ENABLED 249 #ifdef IPC_MESSAGE_LOG_ENABLED
248 void OnSetIPCLoggingEnabled(bool enable); 250 void OnSetIPCLoggingEnabled(bool enable);
249 #endif 251 #endif
250 252
251 void EnsureConnected(); 253 void EnsureConnected();
252 254
253 std::unique_ptr<mojo::edk::ScopedIPCSupport> mojo_ipc_support_; 255 std::unique_ptr<mojo::edk::ScopedIPCSupport> mojo_ipc_support_;
256 std::unique_ptr<MojoShellConnection> mojo_shell_connection_;
254 std::unique_ptr<shell::InterfaceRegistry> interface_registry_; 257 std::unique_ptr<shell::InterfaceRegistry> interface_registry_;
255 std::unique_ptr<shell::InterfaceProvider> remote_interfaces_; 258 std::unique_ptr<shell::InterfaceProvider> remote_interfaces_;
256 std::unique_ptr<MojoShellConnection> mojo_shell_connection_;
257 259
258 std::string channel_name_; 260 std::string channel_name_;
259 std::unique_ptr<IPC::SyncChannel> channel_; 261 std::unique_ptr<IPC::SyncChannel> channel_;
260 262
261 // Allows threads other than the main thread to send sync messages. 263 // Allows threads other than the main thread to send sync messages.
262 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; 264 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_;
263 265
264 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 266 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
265 267
266 // Implements message routing functionality to the consumers of 268 // Implements message routing functionality to the consumers of
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 302
301 std::unique_ptr<ChildGpuMemoryBufferManager> gpu_memory_buffer_manager_; 303 std::unique_ptr<ChildGpuMemoryBufferManager> gpu_memory_buffer_manager_;
302 304
303 std::unique_ptr<ChildDiscardableSharedMemoryManager> 305 std::unique_ptr<ChildDiscardableSharedMemoryManager>
304 discardable_shared_memory_manager_; 306 discardable_shared_memory_manager_;
305 307
306 std::unique_ptr<base::PowerMonitor> power_monitor_; 308 std::unique_ptr<base::PowerMonitor> power_monitor_;
307 309
308 scoped_refptr<base::SequencedTaskRunner> browser_process_io_runner_; 310 scoped_refptr<base::SequencedTaskRunner> browser_process_io_runner_;
309 311
310 std::unique_ptr<base::WeakPtrFactory<ChildThreadImpl>> 312 base::WeakPtrFactory<ChildThreadImpl> channel_connected_factory_;
311 channel_connected_factory_;
312
313 base::WeakPtrFactory<ChildThreadImpl> weak_factory_;
314 313
315 DISALLOW_COPY_AND_ASSIGN(ChildThreadImpl); 314 DISALLOW_COPY_AND_ASSIGN(ChildThreadImpl);
316 }; 315 };
317 316
318 struct ChildThreadImpl::Options { 317 struct ChildThreadImpl::Options {
319 Options(const Options& other); 318 Options(const Options& other);
320 ~Options(); 319 ~Options();
321 320
322 class Builder; 321 class Builder;
323 322
(...skipping 21 matching lines...) Expand all
345 344
346 private: 345 private:
347 struct Options options_; 346 struct Options options_;
348 347
349 DISALLOW_COPY_AND_ASSIGN(Builder); 348 DISALLOW_COPY_AND_ASSIGN(Builder);
350 }; 349 };
351 350
352 } // namespace content 351 } // namespace content
353 352
354 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_ 353 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_
OLDNEW
« no previous file with comments | « content/child/background_sync/background_sync_provider.cc ('k') | content/child/child_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698