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

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

Issue 2545523007: Revert of discardable_memory: Using mojo IPC to replace Chrome IPC (Closed)
Patch Set: Created 4 years 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/DEPS ('k') | content/child/child_thread_impl.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_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/single_thread_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/associated_interfaces.mojom.h" 21 #include "content/common/associated_interfaces.mojom.h"
22 #include "content/common/content_export.h" 22 #include "content/common/content_export.h"
23 #include "content/public/child/child_thread.h" 23 #include "content/public/child/child_thread.h"
24 #include "ipc/ipc.mojom.h" 24 #include "ipc/ipc.mojom.h"
25 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED. 25 #include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
26 #include "ipc/ipc_platform_file.h" 26 #include "ipc/ipc_platform_file.h"
27 #include "ipc/message_router.h" 27 #include "ipc/message_router.h"
28 #include "mojo/public/cpp/bindings/associated_binding.h" 28 #include "mojo/public/cpp/bindings/associated_binding.h"
(...skipping 12 matching lines...) Expand all
41 namespace service_manager { 41 namespace service_manager {
42 class Connection; 42 class Connection;
43 } // namespace service_manager 43 } // namespace service_manager
44 44
45 namespace mojo { 45 namespace mojo {
46 namespace edk { 46 namespace edk {
47 class ScopedIPCSupport; 47 class ScopedIPCSupport;
48 } // namespace edk 48 } // namespace edk
49 } // namespace mojo 49 } // namespace mojo
50 50
51 namespace discardable_memory {
52 class ClientDiscardableSharedMemoryManager;
53 } // namespace discardable_memory
54
51 namespace content { 55 namespace content {
52 class ChildHistogramMessageFilter; 56 class ChildHistogramMessageFilter;
53 class ChildResourceMessageFilter; 57 class ChildResourceMessageFilter;
54 class ChildSharedBitmapManager; 58 class ChildSharedBitmapManager;
55 class FileSystemDispatcher; 59 class FileSystemDispatcher;
56 class InProcessChildThreadParams; 60 class InProcessChildThreadParams;
57 class NotificationDispatcher; 61 class NotificationDispatcher;
58 class PushDispatcher; 62 class PushDispatcher;
59 class ServiceWorkerMessageFilter; 63 class ServiceWorkerMessageFilter;
60 class QuotaDispatcher; 64 class QuotaDispatcher;
(...skipping 15 matching lines...) Expand all
76 // Allow to be used for single-process mode and for in process gpu mode via 80 // Allow to be used for single-process mode and for in process gpu mode via
77 // options. 81 // options.
78 explicit ChildThreadImpl(const Options& options); 82 explicit ChildThreadImpl(const Options& options);
79 // ChildProcess::main_thread() is reset after Shutdown(), and before the 83 // ChildProcess::main_thread() is reset after Shutdown(), and before the
80 // destructor, so any subsystem that relies on ChildProcess::main_thread() 84 // destructor, so any subsystem that relies on ChildProcess::main_thread()
81 // must be terminated before Shutdown returns. In particular, if a subsystem 85 // must be terminated before Shutdown returns. In particular, if a subsystem
82 // has a thread that post tasks to ChildProcess::main_thread(), that thread 86 // has a thread that post tasks to ChildProcess::main_thread(), that thread
83 // should be joined in Shutdown(). 87 // should be joined in Shutdown().
84 ~ChildThreadImpl() override; 88 ~ChildThreadImpl() override;
85 virtual void Shutdown(); 89 virtual void Shutdown();
90 void ShutdownDiscardableSharedMemoryManager();
86 91
87 // IPC::Sender implementation: 92 // IPC::Sender implementation:
88 bool Send(IPC::Message* msg) override; 93 bool Send(IPC::Message* msg) override;
89 94
90 // ChildThread implementation: 95 // ChildThread implementation:
91 #if defined(OS_WIN) 96 #if defined(OS_WIN)
92 void PreCacheFont(const LOGFONT& log_font) override; 97 void PreCacheFont(const LOGFONT& log_font) override;
93 void ReleaseCachedFonts() override; 98 void ReleaseCachedFonts() override;
94 #endif 99 #endif
95 void RecordAction(const base::UserMetricsAction& action) override; 100 void RecordAction(const base::UserMetricsAction& action) override;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 132
128 #if defined(OS_LINUX) 133 #if defined(OS_LINUX)
129 void SetThreadPriority(base::PlatformThreadId id, 134 void SetThreadPriority(base::PlatformThreadId id,
130 base::ThreadPriority priority); 135 base::ThreadPriority priority);
131 #endif 136 #endif
132 137
133 ChildSharedBitmapManager* shared_bitmap_manager() const { 138 ChildSharedBitmapManager* shared_bitmap_manager() const {
134 return shared_bitmap_manager_.get(); 139 return shared_bitmap_manager_.get();
135 } 140 }
136 141
142 discardable_memory::ClientDiscardableSharedMemoryManager*
143 discardable_shared_memory_manager() const {
144 return discardable_shared_memory_manager_.get();
145 }
146
137 ResourceDispatcher* resource_dispatcher() const { 147 ResourceDispatcher* resource_dispatcher() const {
138 return resource_dispatcher_.get(); 148 return resource_dispatcher_.get();
139 } 149 }
140 150
141 FileSystemDispatcher* file_system_dispatcher() const { 151 FileSystemDispatcher* file_system_dispatcher() const {
142 return file_system_dispatcher_.get(); 152 return file_system_dispatcher_.get();
143 } 153 }
144 154
145 QuotaDispatcher* quota_dispatcher() const { 155 QuotaDispatcher* quota_dispatcher() const {
146 return quota_dispatcher_.get(); 156 return quota_dispatcher_.get();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 virtual void OnProcessBackgrounded(bool backgrounded); 218 virtual void OnProcessBackgrounded(bool backgrounded);
209 virtual void OnProcessPurgeAndSuspend(); 219 virtual void OnProcessPurgeAndSuspend();
210 virtual void OnProcessResume(); 220 virtual void OnProcessResume();
211 221
212 // IPC::Listener implementation: 222 // IPC::Listener implementation:
213 bool OnMessageReceived(const IPC::Message& msg) override; 223 bool OnMessageReceived(const IPC::Message& msg) override;
214 void OnChannelConnected(int32_t peer_pid) override; 224 void OnChannelConnected(int32_t peer_pid) override;
215 void OnChannelError() override; 225 void OnChannelError() override;
216 226
217 bool IsInBrowserProcess() const; 227 bool IsInBrowserProcess() const;
218 scoped_refptr<base::SingleThreadTaskRunner> GetIOTaskRunner(); 228 scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner();
219 229
220 private: 230 private:
221 class ChildThreadMessageRouter : public IPC::MessageRouter { 231 class ChildThreadMessageRouter : public IPC::MessageRouter {
222 public: 232 public:
223 // |sender| must outlive this object. 233 // |sender| must outlive this object.
224 explicit ChildThreadMessageRouter(IPC::Sender* sender); 234 explicit ChildThreadMessageRouter(IPC::Sender* sender);
225 bool Send(IPC::Message* msg) override; 235 bool Send(IPC::Message* msg) override;
226 236
227 // MessageRouter overrides. 237 // MessageRouter overrides.
228 bool RouteMessage(const IPC::Message& msg) override; 238 bool RouteMessage(const IPC::Message& msg) override;
229 239
230 private: 240 private:
231 IPC::Sender* const sender_; 241 IPC::Sender* const sender_;
232 }; 242 };
233 243
244 class ClientDiscardableSharedMemoryManagerDelegate;
245
234 void Init(const Options& options); 246 void Init(const Options& options);
235 247
236 // We create the channel first without connecting it so we can add filters 248 // We create the channel first without connecting it so we can add filters
237 // prior to any messages being received, then connect it afterwards. 249 // prior to any messages being received, then connect it afterwards.
238 void ConnectChannel(); 250 void ConnectChannel();
239 251
240 // IPC message handlers. 252 // IPC message handlers.
241 void OnShutdown(); 253 void OnShutdown();
242 void OnSetProfilerStatus(tracked_objects::ThreadData::Status status); 254 void OnSetProfilerStatus(tracked_objects::ThreadData::Status status);
243 void OnGetChildProfilerData(int sequence_number, int current_profiling_phase); 255 void OnGetChildProfilerData(int sequence_number, int current_profiling_phase);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 scoped_refptr<ServiceWorkerMessageFilter> service_worker_message_filter_; 323 scoped_refptr<ServiceWorkerMessageFilter> service_worker_message_filter_;
312 324
313 scoped_refptr<QuotaMessageFilter> quota_message_filter_; 325 scoped_refptr<QuotaMessageFilter> quota_message_filter_;
314 326
315 scoped_refptr<NotificationDispatcher> notification_dispatcher_; 327 scoped_refptr<NotificationDispatcher> notification_dispatcher_;
316 328
317 scoped_refptr<PushDispatcher> push_dispatcher_; 329 scoped_refptr<PushDispatcher> push_dispatcher_;
318 330
319 std::unique_ptr<ChildSharedBitmapManager> shared_bitmap_manager_; 331 std::unique_ptr<ChildSharedBitmapManager> shared_bitmap_manager_;
320 332
333 std::unique_ptr<discardable_memory::ClientDiscardableSharedMemoryManager>
334 discardable_shared_memory_manager_;
335
336 std::unique_ptr<ClientDiscardableSharedMemoryManagerDelegate>
337 client_discardable_shared_memory_manager_delegate_;
338
321 std::unique_ptr<base::PowerMonitor> power_monitor_; 339 std::unique_ptr<base::PowerMonitor> power_monitor_;
322 340
323 scoped_refptr<base::SingleThreadTaskRunner> browser_process_io_runner_; 341 scoped_refptr<base::SequencedTaskRunner> browser_process_io_runner_;
324 342
325 std::unique_ptr<base::WeakPtrFactory<ChildThreadImpl>> 343 std::unique_ptr<base::WeakPtrFactory<ChildThreadImpl>>
326 channel_connected_factory_; 344 channel_connected_factory_;
327 345
328 base::WeakPtrFactory<ChildThreadImpl> weak_factory_; 346 base::WeakPtrFactory<ChildThreadImpl> weak_factory_;
329 347
330 DISALLOW_COPY_AND_ASSIGN(ChildThreadImpl); 348 DISALLOW_COPY_AND_ASSIGN(ChildThreadImpl);
331 }; 349 };
332 350
333 struct ChildThreadImpl::Options { 351 struct ChildThreadImpl::Options {
334 Options(const Options& other); 352 Options(const Options& other);
335 ~Options(); 353 ~Options();
336 354
337 class Builder; 355 class Builder;
338 356
339 bool auto_start_service_manager_connection; 357 bool auto_start_service_manager_connection;
340 bool connect_to_browser; 358 bool connect_to_browser;
341 scoped_refptr<base::SingleThreadTaskRunner> browser_process_io_runner; 359 scoped_refptr<base::SequencedTaskRunner> browser_process_io_runner;
342 std::vector<IPC::MessageFilter*> startup_filters; 360 std::vector<IPC::MessageFilter*> startup_filters;
343 std::string in_process_service_request_token; 361 std::string in_process_service_request_token;
344 362
345 private: 363 private:
346 Options(); 364 Options();
347 }; 365 };
348 366
349 class ChildThreadImpl::Options::Builder { 367 class ChildThreadImpl::Options::Builder {
350 public: 368 public:
351 Builder(); 369 Builder();
352 370
353 Builder& InBrowserProcess(const InProcessChildThreadParams& params); 371 Builder& InBrowserProcess(const InProcessChildThreadParams& params);
354 Builder& AutoStartServiceManagerConnection(bool auto_start); 372 Builder& AutoStartServiceManagerConnection(bool auto_start);
355 Builder& ConnectToBrowser(bool connect_to_browser); 373 Builder& ConnectToBrowser(bool connect_to_browser);
356 Builder& AddStartupFilter(IPC::MessageFilter* filter); 374 Builder& AddStartupFilter(IPC::MessageFilter* filter);
357 375
358 Options Build(); 376 Options Build();
359 377
360 private: 378 private:
361 struct Options options_; 379 struct Options options_;
362 380
363 DISALLOW_COPY_AND_ASSIGN(Builder); 381 DISALLOW_COPY_AND_ASSIGN(Builder);
364 }; 382 };
365 383
366 } // namespace content 384 } // namespace content
367 385
368 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_ 386 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_
OLDNEW
« no previous file with comments | « content/child/DEPS ('k') | content/child/child_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698