| OLD | NEW |
| 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 #include "content/child/child_thread_impl.h" | 5 #include "content/child/child_thread_impl.h" |
| 6 | 6 |
| 7 #include <signal.h> | 7 #include <signal.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "base/single_thread_task_runner.h" | 25 #include "base/single_thread_task_runner.h" |
| 26 #include "base/strings/string_number_conversions.h" | 26 #include "base/strings/string_number_conversions.h" |
| 27 #include "base/strings/string_util.h" | 27 #include "base/strings/string_util.h" |
| 28 #include "base/synchronization/condition_variable.h" | 28 #include "base/synchronization/condition_variable.h" |
| 29 #include "base/synchronization/lock.h" | 29 #include "base/synchronization/lock.h" |
| 30 #include "base/threading/thread_local.h" | 30 #include "base/threading/thread_local.h" |
| 31 #include "base/threading/thread_task_runner_handle.h" | 31 #include "base/threading/thread_task_runner_handle.h" |
| 32 #include "base/timer/elapsed_timer.h" | 32 #include "base/timer/elapsed_timer.h" |
| 33 #include "base/tracked_objects.h" | 33 #include "base/tracked_objects.h" |
| 34 #include "build/build_config.h" | 34 #include "build/build_config.h" |
| 35 #include "components/discardable_memory/client/child_discardable_shared_memory_m
anager.h" |
| 35 #include "components/tracing/child/child_trace_message_filter.h" | 36 #include "components/tracing/child/child_trace_message_filter.h" |
| 36 #include "content/child/child_discardable_shared_memory_manager.h" | |
| 37 #include "content/child/child_histogram_message_filter.h" | 37 #include "content/child/child_histogram_message_filter.h" |
| 38 #include "content/child/child_process.h" | 38 #include "content/child/child_process.h" |
| 39 #include "content/child/child_resource_message_filter.h" | 39 #include "content/child/child_resource_message_filter.h" |
| 40 #include "content/child/child_shared_bitmap_manager.h" | 40 #include "content/child/child_shared_bitmap_manager.h" |
| 41 #include "content/child/fileapi/file_system_dispatcher.h" | 41 #include "content/child/fileapi/file_system_dispatcher.h" |
| 42 #include "content/child/fileapi/webfilesystem_impl.h" | 42 #include "content/child/fileapi/webfilesystem_impl.h" |
| 43 #include "content/child/memory/child_memory_message_filter.h" | 43 #include "content/child/memory/child_memory_message_filter.h" |
| 44 #include "content/child/notifications/notification_dispatcher.h" | 44 #include "content/child/notifications/notification_dispatcher.h" |
| 45 #include "content/child/power_monitor_broadcast_source.h" | 45 #include "content/child/power_monitor_broadcast_source.h" |
| 46 #include "content/child/push_messaging/push_dispatcher.h" | 46 #include "content/child/push_messaging/push_dispatcher.h" |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 #if defined(OS_ANDROID) | 347 #if defined(OS_ANDROID) |
| 348 if (!handled && msg.is_sync()) { | 348 if (!handled && msg.is_sync()) { |
| 349 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); | 349 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); |
| 350 reply->set_reply_error(); | 350 reply->set_reply_error(); |
| 351 Send(reply); | 351 Send(reply); |
| 352 } | 352 } |
| 353 #endif | 353 #endif |
| 354 return handled; | 354 return handled; |
| 355 } | 355 } |
| 356 | 356 |
| 357 class ChildThreadImpl::ChildDiscardableSharedMemoryManagerDelegate |
| 358 : public discardable_memory::ChildDiscardableSharedMemoryManager::Delegate { |
| 359 public: |
| 360 explicit ChildDiscardableSharedMemoryManagerDelegate( |
| 361 scoped_refptr<ThreadSafeSender> sender) |
| 362 : sender_(sender) {} |
| 363 ~ChildDiscardableSharedMemoryManagerDelegate() override {} |
| 364 |
| 365 void AllocateLockedDiscardableSharedMemory( |
| 366 size_t size, |
| 367 discardable_memory::DiscardableSharedMemoryId id, |
| 368 base::SharedMemoryHandle* handle) override { |
| 369 sender_->Send( |
| 370 new ChildProcessHostMsg_SyncAllocateLockedDiscardableSharedMemory( |
| 371 size, id, handle)); |
| 372 } |
| 373 |
| 374 void DeletedDiscardableSharedMemory( |
| 375 discardable_memory::DiscardableSharedMemoryId id) override { |
| 376 sender_->Send(new ChildProcessHostMsg_DeletedDiscardableSharedMemory(id)); |
| 377 } |
| 378 |
| 379 private: |
| 380 scoped_refptr<ThreadSafeSender> sender_; |
| 381 }; |
| 382 |
| 357 ChildThreadImpl::ChildThreadImpl() | 383 ChildThreadImpl::ChildThreadImpl() |
| 358 : route_provider_binding_(this), | 384 : route_provider_binding_(this), |
| 359 associated_interface_provider_bindings_( | 385 associated_interface_provider_bindings_( |
| 360 mojo::BindingSetDispatchMode::WITH_CONTEXT), | 386 mojo::BindingSetDispatchMode::WITH_CONTEXT), |
| 361 router_(this), | 387 router_(this), |
| 362 channel_connected_factory_( | 388 channel_connected_factory_( |
| 363 new base::WeakPtrFactory<ChildThreadImpl>(this)), | 389 new base::WeakPtrFactory<ChildThreadImpl>(this)), |
| 364 weak_factory_(this) { | 390 weak_factory_(this) { |
| 365 Init(Options::Builder().Build()); | 391 Init(Options::Builder().Build()); |
| 366 } | 392 } |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 channel_connected_factory_->GetWeakPtr()), | 583 channel_connected_factory_->GetWeakPtr()), |
| 558 base::TimeDelta::FromSeconds(connection_timeout)); | 584 base::TimeDelta::FromSeconds(connection_timeout)); |
| 559 | 585 |
| 560 #if defined(OS_ANDROID) | 586 #if defined(OS_ANDROID) |
| 561 g_quit_closure.Get().BindToMainThread(); | 587 g_quit_closure.Get().BindToMainThread(); |
| 562 #endif | 588 #endif |
| 563 | 589 |
| 564 shared_bitmap_manager_.reset( | 590 shared_bitmap_manager_.reset( |
| 565 new ChildSharedBitmapManager(thread_safe_sender())); | 591 new ChildSharedBitmapManager(thread_safe_sender())); |
| 566 | 592 |
| 567 discardable_shared_memory_manager_.reset( | 593 child_discardable_shared_memory_manager_delegate_ = |
| 568 new ChildDiscardableSharedMemoryManager(thread_safe_sender())); | 594 base::MakeUnique<ChildDiscardableSharedMemoryManagerDelegate>( |
| 595 thread_safe_sender()); |
| 596 discardable_shared_memory_manager_ = |
| 597 base::MakeUnique<discardable_memory::ChildDiscardableSharedMemoryManager>( |
| 598 child_discardable_shared_memory_manager_delegate_.get()); |
| 569 } | 599 } |
| 570 | 600 |
| 571 ChildThreadImpl::~ChildThreadImpl() { | 601 ChildThreadImpl::~ChildThreadImpl() { |
| 572 #ifdef IPC_MESSAGE_LOG_ENABLED | 602 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 573 IPC::Logging::GetInstance()->SetIPCSender(NULL); | 603 IPC::Logging::GetInstance()->SetIPCSender(NULL); |
| 574 #endif | 604 #endif |
| 575 | 605 |
| 576 channel_->RemoveFilter(histogram_message_filter_.get()); | 606 channel_->RemoveFilter(histogram_message_filter_.get()); |
| 577 channel_->RemoveFilter(sync_message_filter_.get()); | 607 channel_->RemoveFilter(sync_message_filter_.get()); |
| 578 | 608 |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 connected_to_browser_ = true; | 916 connected_to_browser_ = true; |
| 887 child_info_ = local_info; | 917 child_info_ = local_info; |
| 888 browser_info_ = remote_info; | 918 browser_info_ = remote_info; |
| 889 } | 919 } |
| 890 | 920 |
| 891 bool ChildThreadImpl::IsInBrowserProcess() const { | 921 bool ChildThreadImpl::IsInBrowserProcess() const { |
| 892 return static_cast<bool>(browser_process_io_runner_); | 922 return static_cast<bool>(browser_process_io_runner_); |
| 893 } | 923 } |
| 894 | 924 |
| 895 } // namespace content | 925 } // namespace content |
| OLD | NEW |