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

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

Issue 2485623002: discardable_memory: Using mojo IPC to replace Chrome IPC (Closed)
Patch Set: Rebase Created 4 years, 1 month 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/single_thread_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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 virtual void OnProcessBackgrounded(bool backgrounded); 218 virtual void OnProcessBackgrounded(bool backgrounded);
219 virtual void OnProcessPurgeAndSuspend(); 219 virtual void OnProcessPurgeAndSuspend();
220 virtual void OnProcessResume(); 220 virtual void OnProcessResume();
221 221
222 // IPC::Listener implementation: 222 // IPC::Listener implementation:
223 bool OnMessageReceived(const IPC::Message& msg) override; 223 bool OnMessageReceived(const IPC::Message& msg) override;
224 void OnChannelConnected(int32_t peer_pid) override; 224 void OnChannelConnected(int32_t peer_pid) override;
225 void OnChannelError() override; 225 void OnChannelError() override;
226 226
227 bool IsInBrowserProcess() const; 227 bool IsInBrowserProcess() const;
228 scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner(); 228 scoped_refptr<base::SingleThreadTaskRunner> GetIOTaskRunner();
229 229
230 private: 230 private:
231 class ChildThreadMessageRouter : public IPC::MessageRouter { 231 class ChildThreadMessageRouter : public IPC::MessageRouter {
232 public: 232 public:
233 // |sender| must outlive this object. 233 // |sender| must outlive this object.
234 explicit ChildThreadMessageRouter(IPC::Sender* sender); 234 explicit ChildThreadMessageRouter(IPC::Sender* sender);
235 bool Send(IPC::Message* msg) override; 235 bool Send(IPC::Message* msg) override;
236 236
237 // MessageRouter overrides. 237 // MessageRouter overrides.
238 bool RouteMessage(const IPC::Message& msg) override; 238 bool RouteMessage(const IPC::Message& msg) override;
239 239
240 private: 240 private:
241 IPC::Sender* const sender_; 241 IPC::Sender* const sender_;
242 }; 242 };
243 243
244 class ClientDiscardableSharedMemoryManagerDelegate;
245
246 void Init(const Options& options); 244 void Init(const Options& options);
247 245
248 // We create the channel first without connecting it so we can add filters 246 // We create the channel first without connecting it so we can add filters
249 // prior to any messages being received, then connect it afterwards. 247 // prior to any messages being received, then connect it afterwards.
250 void ConnectChannel(); 248 void ConnectChannel();
251 249
252 // IPC message handlers. 250 // IPC message handlers.
253 void OnShutdown(); 251 void OnShutdown();
254 void OnSetProfilerStatus(tracked_objects::ThreadData::Status status); 252 void OnSetProfilerStatus(tracked_objects::ThreadData::Status status);
255 void OnGetChildProfilerData(int sequence_number, int current_profiling_phase); 253 void OnGetChildProfilerData(int sequence_number, int current_profiling_phase);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 324
327 scoped_refptr<NotificationDispatcher> notification_dispatcher_; 325 scoped_refptr<NotificationDispatcher> notification_dispatcher_;
328 326
329 scoped_refptr<PushDispatcher> push_dispatcher_; 327 scoped_refptr<PushDispatcher> push_dispatcher_;
330 328
331 std::unique_ptr<ChildSharedBitmapManager> shared_bitmap_manager_; 329 std::unique_ptr<ChildSharedBitmapManager> shared_bitmap_manager_;
332 330
333 std::unique_ptr<discardable_memory::ClientDiscardableSharedMemoryManager> 331 std::unique_ptr<discardable_memory::ClientDiscardableSharedMemoryManager>
334 discardable_shared_memory_manager_; 332 discardable_shared_memory_manager_;
335 333
336 std::unique_ptr<ClientDiscardableSharedMemoryManagerDelegate>
337 client_discardable_shared_memory_manager_delegate_;
338
339 std::unique_ptr<base::PowerMonitor> power_monitor_; 334 std::unique_ptr<base::PowerMonitor> power_monitor_;
340 335
341 scoped_refptr<base::SequencedTaskRunner> browser_process_io_runner_; 336 scoped_refptr<base::SingleThreadTaskRunner> browser_process_io_runner_;
342 337
343 std::unique_ptr<base::WeakPtrFactory<ChildThreadImpl>> 338 std::unique_ptr<base::WeakPtrFactory<ChildThreadImpl>>
344 channel_connected_factory_; 339 channel_connected_factory_;
345 340
346 base::WeakPtrFactory<ChildThreadImpl> weak_factory_; 341 base::WeakPtrFactory<ChildThreadImpl> weak_factory_;
347 342
348 DISALLOW_COPY_AND_ASSIGN(ChildThreadImpl); 343 DISALLOW_COPY_AND_ASSIGN(ChildThreadImpl);
349 }; 344 };
350 345
351 struct ChildThreadImpl::Options { 346 struct ChildThreadImpl::Options {
352 Options(const Options& other); 347 Options(const Options& other);
353 ~Options(); 348 ~Options();
354 349
355 class Builder; 350 class Builder;
356 351
357 bool auto_start_service_manager_connection; 352 bool auto_start_service_manager_connection;
358 bool connect_to_browser; 353 bool connect_to_browser;
359 scoped_refptr<base::SequencedTaskRunner> browser_process_io_runner; 354 bool init_discardable_memory;
355 scoped_refptr<base::SingleThreadTaskRunner> browser_process_io_runner;
360 std::vector<IPC::MessageFilter*> startup_filters; 356 std::vector<IPC::MessageFilter*> startup_filters;
361 std::string in_process_service_request_token; 357 std::string in_process_service_request_token;
362 358
363 private: 359 private:
364 Options(); 360 Options();
365 }; 361 };
366 362
367 class ChildThreadImpl::Options::Builder { 363 class ChildThreadImpl::Options::Builder {
368 public: 364 public:
369 Builder(); 365 Builder();
370 366
371 Builder& InBrowserProcess(const InProcessChildThreadParams& params); 367 Builder& InBrowserProcess(const InProcessChildThreadParams& params);
372 Builder& AutoStartServiceManagerConnection(bool auto_start); 368 Builder& AutoStartServiceManagerConnection(bool auto_start);
369 Builder& InitDiscardableMemory(bool discardable_memory);
373 Builder& ConnectToBrowser(bool connect_to_browser); 370 Builder& ConnectToBrowser(bool connect_to_browser);
374 Builder& AddStartupFilter(IPC::MessageFilter* filter); 371 Builder& AddStartupFilter(IPC::MessageFilter* filter);
375 372
376 Options Build(); 373 Options Build();
377 374
378 private: 375 private:
379 struct Options options_; 376 struct Options options_;
380 377
381 DISALLOW_COPY_AND_ASSIGN(Builder); 378 DISALLOW_COPY_AND_ASSIGN(Builder);
382 }; 379 };
383 380
384 } // namespace content 381 } // namespace content
385 382
386 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_ 383 #endif // CONTENT_CHILD_CHILD_THREAD_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698