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

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

Issue 2847003005: Reland "Add enable_ipc_logging build argument" (Closed)
Patch Set: Reland "Add enable_ipc_logging build argument" Created 3 years, 7 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 channel_->Init( 406 channel_->Init(
407 IPC::ChannelMojo::CreateClientFactory( 407 IPC::ChannelMojo::CreateClientFactory(
408 std::move(handle), ChildProcess::current()->io_task_runner()), 408 std::move(handle), ChildProcess::current()->io_task_runner()),
409 true /* create_pipe_now */); 409 true /* create_pipe_now */);
410 } 410 }
411 411
412 void ChildThreadImpl::Init(const Options& options) { 412 void ChildThreadImpl::Init(const Options& options) {
413 g_lazy_tls.Pointer()->Set(this); 413 g_lazy_tls.Pointer()->Set(this);
414 on_channel_error_called_ = false; 414 on_channel_error_called_ = false;
415 message_loop_ = base::MessageLoop::current(); 415 message_loop_ = base::MessageLoop::current();
416 #ifdef IPC_MESSAGE_LOG_ENABLED 416 #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED)
417 // We must make sure to instantiate the IPC Logger *before* we create the 417 // We must make sure to instantiate the IPC Logger *before* we create the
418 // channel, otherwise we can get a callback on the IO thread which creates 418 // channel, otherwise we can get a callback on the IO thread which creates
419 // the logger, and the logger does not like being created on the IO thread. 419 // the logger, and the logger does not like being created on the IO thread.
420 IPC::Logging::GetInstance(); 420 IPC::Logging::GetInstance();
421 #endif 421 #endif
422 422
423 channel_ = 423 channel_ =
424 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(), 424 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(),
425 ChildProcess::current()->GetShutDownEvent()); 425 ChildProcess::current()->GetShutDownEvent());
426 #ifdef IPC_MESSAGE_LOG_ENABLED 426 #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED)
427 if (!IsInBrowserProcess()) 427 if (!IsInBrowserProcess())
428 IPC::Logging::GetInstance()->SetIPCSender(this); 428 IPC::Logging::GetInstance()->SetIPCSender(this);
429 #endif 429 #endif
430 430
431 if (!IsInBrowserProcess()) { 431 if (!IsInBrowserProcess()) {
432 // Don't double-initialize IPC support in single-process mode. 432 // Don't double-initialize IPC support in single-process mode.
433 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport( 433 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport(
434 GetIOTaskRunner(), mojo::edk::ScopedIPCSupport::ShutdownPolicy::FAST)); 434 GetIOTaskRunner(), mojo::edk::ScopedIPCSupport::ShutdownPolicy::FAST));
435 InitializeMojoIPCChannel(); 435 InitializeMojoIPCChannel();
436 } 436 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 FROM_HERE, base::Bind(&ChildThreadImpl::EnsureConnected, 547 FROM_HERE, base::Bind(&ChildThreadImpl::EnsureConnected,
548 channel_connected_factory_->GetWeakPtr()), 548 channel_connected_factory_->GetWeakPtr()),
549 base::TimeDelta::FromSeconds(connection_timeout)); 549 base::TimeDelta::FromSeconds(connection_timeout));
550 550
551 #if defined(OS_ANDROID) 551 #if defined(OS_ANDROID)
552 g_quit_closure.Get().BindToMainThread(); 552 g_quit_closure.Get().BindToMainThread();
553 #endif 553 #endif
554 } 554 }
555 555
556 ChildThreadImpl::~ChildThreadImpl() { 556 ChildThreadImpl::~ChildThreadImpl() {
557 #ifdef IPC_MESSAGE_LOG_ENABLED 557 #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED)
558 IPC::Logging::GetInstance()->SetIPCSender(NULL); 558 IPC::Logging::GetInstance()->SetIPCSender(NULL);
559 #endif 559 #endif
560 560
561 channel_->RemoveFilter(histogram_message_filter_.get()); 561 channel_->RemoveFilter(histogram_message_filter_.get());
562 channel_->RemoveFilter(sync_message_filter_.get()); 562 channel_->RemoveFilter(sync_message_filter_.get());
563 563
564 // The ChannelProxy object caches a pointer to the IPC thread, so need to 564 // The ChannelProxy object caches a pointer to the IPC thread, so need to
565 // reset it as it's not guaranteed to outlive this object. 565 // reset it as it's not guaranteed to outlive this object.
566 // NOTE: this also has the side-effect of not closing the main IPC channel to 566 // NOTE: this also has the side-effect of not closing the main IPC channel to
567 // the browser process. This is needed because this is the signal that the 567 // the browser process. This is needed because this is the signal that the
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 bool ChildThreadImpl::OnMessageReceived(const IPC::Message& msg) { 673 bool ChildThreadImpl::OnMessageReceived(const IPC::Message& msg) {
674 // Resource responses are sent to the resource dispatcher. 674 // Resource responses are sent to the resource dispatcher.
675 if (resource_dispatcher_->OnMessageReceived(msg)) 675 if (resource_dispatcher_->OnMessageReceived(msg))
676 return true; 676 return true;
677 if (file_system_dispatcher_->OnMessageReceived(msg)) 677 if (file_system_dispatcher_->OnMessageReceived(msg))
678 return true; 678 return true;
679 679
680 bool handled = true; 680 bool handled = true;
681 IPC_BEGIN_MESSAGE_MAP(ChildThreadImpl, msg) 681 IPC_BEGIN_MESSAGE_MAP(ChildThreadImpl, msg)
682 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) 682 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown)
683 #if defined(IPC_MESSAGE_LOG_ENABLED) 683 #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED)
684 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled, 684 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled,
685 OnSetIPCLoggingEnabled) 685 OnSetIPCLoggingEnabled)
686 #endif 686 #endif
687 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProfilerStatus, 687 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProfilerStatus,
688 OnSetProfilerStatus) 688 OnSetProfilerStatus)
689 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData, 689 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData,
690 OnGetChildProfilerData) 690 OnGetChildProfilerData)
691 IPC_MESSAGE_HANDLER(ChildProcessMsg_ProfilingPhaseCompleted, 691 IPC_MESSAGE_HANDLER(ChildProcessMsg_ProfilingPhaseCompleted,
692 OnProfilingPhaseCompleted) 692 OnProfilingPhaseCompleted)
693 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProcessBackgrounded, 693 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProcessBackgrounded,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 740
741 void ChildThreadImpl::OnProcessPurgeAndSuspend() { 741 void ChildThreadImpl::OnProcessPurgeAndSuspend() {
742 } 742 }
743 743
744 void ChildThreadImpl::OnProcessResume() {} 744 void ChildThreadImpl::OnProcessResume() {}
745 745
746 void ChildThreadImpl::OnShutdown() { 746 void ChildThreadImpl::OnShutdown() {
747 base::MessageLoop::current()->QuitWhenIdle(); 747 base::MessageLoop::current()->QuitWhenIdle();
748 } 748 }
749 749
750 #if defined(IPC_MESSAGE_LOG_ENABLED) 750 #if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED)
751 void ChildThreadImpl::OnSetIPCLoggingEnabled(bool enable) { 751 void ChildThreadImpl::OnSetIPCLoggingEnabled(bool enable) {
752 if (enable) 752 if (enable)
753 IPC::Logging::GetInstance()->Enable(); 753 IPC::Logging::GetInstance()->Enable();
754 else 754 else
755 IPC::Logging::GetInstance()->Disable(); 755 IPC::Logging::GetInstance()->Disable();
756 } 756 }
757 #endif // IPC_MESSAGE_LOG_ENABLED 757 #endif // IPC_MESSAGE_LOG_ENABLED
758 758
759 void ChildThreadImpl::OnSetProfilerStatus(ThreadData::Status status) { 759 void ChildThreadImpl::OnSetProfilerStatus(ThreadData::Status status) {
760 ThreadData::InitializeAndSetTrackingStatus(status); 760 ThreadData::InitializeAndSetTrackingStatus(status);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 Listener* route = router_.GetRoute(routing_id); 820 Listener* route = router_.GetRoute(routing_id);
821 if (route) 821 if (route)
822 route->OnAssociatedInterfaceRequest(name, request.PassHandle()); 822 route->OnAssociatedInterfaceRequest(name, request.PassHandle());
823 } 823 }
824 824
825 bool ChildThreadImpl::IsInBrowserProcess() const { 825 bool ChildThreadImpl::IsInBrowserProcess() const {
826 return static_cast<bool>(browser_process_io_runner_); 826 return static_cast<bool>(browser_process_io_runner_);
827 } 827 }
828 828
829 } // namespace content 829 } // 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