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

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

Issue 2777983005: Reland "Add enable_ipc_logging build argument" (Closed)
Patch Set: Created 3 years, 8 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/child_thread_impl.h ('k') | content/common/child_process_host_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 #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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 channel_->Init( 407 channel_->Init(
408 IPC::ChannelMojo::CreateClientFactory( 408 IPC::ChannelMojo::CreateClientFactory(
409 std::move(handle), ChildProcess::current()->io_task_runner()), 409 std::move(handle), ChildProcess::current()->io_task_runner()),
410 true /* create_pipe_now */); 410 true /* create_pipe_now */);
411 } 411 }
412 412
413 void ChildThreadImpl::Init(const Options& options) { 413 void ChildThreadImpl::Init(const Options& options) {
414 g_lazy_tls.Pointer()->Set(this); 414 g_lazy_tls.Pointer()->Set(this);
415 on_channel_error_called_ = false; 415 on_channel_error_called_ = false;
416 message_loop_ = base::MessageLoop::current(); 416 message_loop_ = base::MessageLoop::current();
417 #ifdef IPC_MESSAGE_LOG_ENABLED 417 #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED)
418 // We must make sure to instantiate the IPC Logger *before* we create the 418 // We must make sure to instantiate the IPC Logger *before* we create the
419 // channel, otherwise we can get a callback on the IO thread which creates 419 // channel, otherwise we can get a callback on the IO thread which creates
420 // the logger, and the logger does not like being created on the IO thread. 420 // the logger, and the logger does not like being created on the IO thread.
421 IPC::Logging::GetInstance(); 421 IPC::Logging::GetInstance();
422 #endif 422 #endif
423 423
424 channel_ = 424 channel_ =
425 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(), 425 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(),
426 ChildProcess::current()->GetShutDownEvent()); 426 ChildProcess::current()->GetShutDownEvent());
427 #ifdef IPC_MESSAGE_LOG_ENABLED 427 #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED)
428 if (!IsInBrowserProcess()) 428 if (!IsInBrowserProcess())
429 IPC::Logging::GetInstance()->SetIPCSender(this); 429 IPC::Logging::GetInstance()->SetIPCSender(this);
430 #endif 430 #endif
431 431
432 if (!IsInBrowserProcess()) { 432 if (!IsInBrowserProcess()) {
433 // Don't double-initialize IPC support in single-process mode. 433 // Don't double-initialize IPC support in single-process mode.
434 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport( 434 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport(
435 GetIOTaskRunner(), mojo::edk::ScopedIPCSupport::ShutdownPolicy::FAST)); 435 GetIOTaskRunner(), mojo::edk::ScopedIPCSupport::ShutdownPolicy::FAST));
436 InitializeMojoIPCChannel(); 436 InitializeMojoIPCChannel();
437 } 437 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 FROM_HERE, base::Bind(&ChildThreadImpl::EnsureConnected, 563 FROM_HERE, base::Bind(&ChildThreadImpl::EnsureConnected,
564 channel_connected_factory_->GetWeakPtr()), 564 channel_connected_factory_->GetWeakPtr()),
565 base::TimeDelta::FromSeconds(connection_timeout)); 565 base::TimeDelta::FromSeconds(connection_timeout));
566 566
567 #if defined(OS_ANDROID) 567 #if defined(OS_ANDROID)
568 g_quit_closure.Get().BindToMainThread(); 568 g_quit_closure.Get().BindToMainThread();
569 #endif 569 #endif
570 } 570 }
571 571
572 ChildThreadImpl::~ChildThreadImpl() { 572 ChildThreadImpl::~ChildThreadImpl() {
573 #ifdef IPC_MESSAGE_LOG_ENABLED 573 #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED)
574 IPC::Logging::GetInstance()->SetIPCSender(NULL); 574 IPC::Logging::GetInstance()->SetIPCSender(NULL);
575 #endif 575 #endif
576 576
577 channel_->RemoveFilter(histogram_message_filter_.get()); 577 channel_->RemoveFilter(histogram_message_filter_.get());
578 channel_->RemoveFilter(sync_message_filter_.get()); 578 channel_->RemoveFilter(sync_message_filter_.get());
579 579
580 // The ChannelProxy object caches a pointer to the IPC thread, so need to 580 // The ChannelProxy object caches a pointer to the IPC thread, so need to
581 // reset it as it's not guaranteed to outlive this object. 581 // reset it as it's not guaranteed to outlive this object.
582 // NOTE: this also has the side-effect of not closing the main IPC channel to 582 // NOTE: this also has the side-effect of not closing the main IPC channel to
583 // the browser process. This is needed because this is the signal that the 583 // the browser process. This is needed because this is the signal that the
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 bool ChildThreadImpl::OnMessageReceived(const IPC::Message& msg) { 713 bool ChildThreadImpl::OnMessageReceived(const IPC::Message& msg) {
714 // Resource responses are sent to the resource dispatcher. 714 // Resource responses are sent to the resource dispatcher.
715 if (resource_dispatcher_->OnMessageReceived(msg)) 715 if (resource_dispatcher_->OnMessageReceived(msg))
716 return true; 716 return true;
717 if (file_system_dispatcher_->OnMessageReceived(msg)) 717 if (file_system_dispatcher_->OnMessageReceived(msg))
718 return true; 718 return true;
719 719
720 bool handled = true; 720 bool handled = true;
721 IPC_BEGIN_MESSAGE_MAP(ChildThreadImpl, msg) 721 IPC_BEGIN_MESSAGE_MAP(ChildThreadImpl, msg)
722 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) 722 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown)
723 #if defined(IPC_MESSAGE_LOG_ENABLED) 723 #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED)
724 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled, 724 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled,
725 OnSetIPCLoggingEnabled) 725 OnSetIPCLoggingEnabled)
726 #endif 726 #endif
727 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProfilerStatus, 727 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProfilerStatus,
728 OnSetProfilerStatus) 728 OnSetProfilerStatus)
729 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData, 729 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData,
730 OnGetChildProfilerData) 730 OnGetChildProfilerData)
731 IPC_MESSAGE_HANDLER(ChildProcessMsg_ProfilingPhaseCompleted, 731 IPC_MESSAGE_HANDLER(ChildProcessMsg_ProfilingPhaseCompleted,
732 OnProfilingPhaseCompleted) 732 OnProfilingPhaseCompleted)
733 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProcessBackgrounded, 733 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProcessBackgrounded,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 784
785 void ChildThreadImpl::OnProcessPurgeAndSuspend() { 785 void ChildThreadImpl::OnProcessPurgeAndSuspend() {
786 } 786 }
787 787
788 void ChildThreadImpl::OnProcessResume() {} 788 void ChildThreadImpl::OnProcessResume() {}
789 789
790 void ChildThreadImpl::OnShutdown() { 790 void ChildThreadImpl::OnShutdown() {
791 base::MessageLoop::current()->QuitWhenIdle(); 791 base::MessageLoop::current()->QuitWhenIdle();
792 } 792 }
793 793
794 #if defined(IPC_MESSAGE_LOG_ENABLED) 794 #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED)
795 void ChildThreadImpl::OnSetIPCLoggingEnabled(bool enable) { 795 void ChildThreadImpl::OnSetIPCLoggingEnabled(bool enable) {
796 if (enable) 796 if (enable)
797 IPC::Logging::GetInstance()->Enable(); 797 IPC::Logging::GetInstance()->Enable();
798 else 798 else
799 IPC::Logging::GetInstance()->Disable(); 799 IPC::Logging::GetInstance()->Disable();
800 } 800 }
801 #endif // IPC_MESSAGE_LOG_ENABLED 801 #endif // IPC_MESSAGE_LOG_ENABLED
802 802
803 void ChildThreadImpl::OnSetProfilerStatus(ThreadData::Status status) { 803 void ChildThreadImpl::OnSetProfilerStatus(ThreadData::Status status) {
804 ThreadData::InitializeAndSetTrackingStatus(status); 804 ThreadData::InitializeAndSetTrackingStatus(status);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 connected_to_browser_ = true; 875 connected_to_browser_ = true;
876 child_info_ = local_info; 876 child_info_ = local_info;
877 browser_info_ = remote_info; 877 browser_info_ = remote_info;
878 } 878 }
879 879
880 bool ChildThreadImpl::IsInBrowserProcess() const { 880 bool ChildThreadImpl::IsInBrowserProcess() const {
881 return static_cast<bool>(browser_process_io_runner_); 881 return static_cast<bool>(browser_process_io_runner_);
882 } 882 }
883 883
884 } // namespace content 884 } // namespace content
OLDNEW
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/common/child_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698