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

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

Issue 1398153002: Don't use base::MessageLoop::{Quit,QuitClosure} in content/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
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 8
9 #include <string> 9 #include <string>
10 10
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 quota_dispatcher_.reset(); 538 quota_dispatcher_.reset();
539 WebFileSystemImpl::DeleteThreadSpecificInstance(); 539 WebFileSystemImpl::DeleteThreadSpecificInstance();
540 } 540 }
541 541
542 void ChildThreadImpl::OnChannelConnected(int32 peer_pid) { 542 void ChildThreadImpl::OnChannelConnected(int32 peer_pid) {
543 channel_connected_factory_.InvalidateWeakPtrs(); 543 channel_connected_factory_.InvalidateWeakPtrs();
544 } 544 }
545 545
546 void ChildThreadImpl::OnChannelError() { 546 void ChildThreadImpl::OnChannelError() {
547 set_on_channel_error_called(true); 547 set_on_channel_error_called(true);
548 base::MessageLoop::current()->Quit(); 548 base::MessageLoop::current()->QuitWhenIdle();
549 } 549 }
550 550
551 bool ChildThreadImpl::Send(IPC::Message* msg) { 551 bool ChildThreadImpl::Send(IPC::Message* msg) {
552 DCHECK(base::MessageLoop::current() == message_loop()); 552 DCHECK(base::MessageLoop::current() == message_loop());
553 if (!channel_) { 553 if (!channel_) {
554 delete msg; 554 delete msg;
555 return false; 555 return false;
556 } 556 }
557 557
558 return channel_->Send(msg); 558 return channel_->Send(msg);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 658
659 void ChildThreadImpl::OnProcessBackgrounded(bool backgrounded) { 659 void ChildThreadImpl::OnProcessBackgrounded(bool backgrounded) {
660 // Set timer slack to maximum on main thread when in background. 660 // Set timer slack to maximum on main thread when in background.
661 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; 661 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE;
662 if (backgrounded) 662 if (backgrounded)
663 timer_slack = base::TIMER_SLACK_MAXIMUM; 663 timer_slack = base::TIMER_SLACK_MAXIMUM;
664 base::MessageLoop::current()->SetTimerSlack(timer_slack); 664 base::MessageLoop::current()->SetTimerSlack(timer_slack);
665 } 665 }
666 666
667 void ChildThreadImpl::OnShutdown() { 667 void ChildThreadImpl::OnShutdown() {
668 base::MessageLoop::current()->Quit(); 668 base::MessageLoop::current()->QuitWhenIdle();
669 } 669 }
670 670
671 #if defined(IPC_MESSAGE_LOG_ENABLED) 671 #if defined(IPC_MESSAGE_LOG_ENABLED)
672 void ChildThreadImpl::OnSetIPCLoggingEnabled(bool enable) { 672 void ChildThreadImpl::OnSetIPCLoggingEnabled(bool enable) {
673 if (enable) 673 if (enable)
674 IPC::Logging::GetInstance()->Enable(); 674 IPC::Logging::GetInstance()->Enable();
675 else 675 else
676 IPC::Logging::GetInstance()->Disable(); 676 IPC::Logging::GetInstance()->Disable();
677 } 677 }
678 #endif // IPC_MESSAGE_LOG_ENABLED 678 #endif // IPC_MESSAGE_LOG_ENABLED
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 // It may block the child thread if so. 713 // It may block the child thread if so.
714 void ChildThreadImpl::ShutdownThread() { 714 void ChildThreadImpl::ShutdownThread() {
715 DCHECK(!ChildThreadImpl::current()) << 715 DCHECK(!ChildThreadImpl::current()) <<
716 "this method should NOT be called from child thread itself"; 716 "this method should NOT be called from child thread itself";
717 g_quit_closure.Get().PostQuitFromNonMainThread(); 717 g_quit_closure.Get().PostQuitFromNonMainThread();
718 } 718 }
719 #endif 719 #endif
720 720
721 void ChildThreadImpl::OnProcessFinalRelease() { 721 void ChildThreadImpl::OnProcessFinalRelease() {
722 if (on_channel_error_called_) { 722 if (on_channel_error_called_) {
723 base::MessageLoop::current()->Quit(); 723 base::MessageLoop::current()->QuitWhenIdle();
724 return; 724 return;
725 } 725 }
726 726
727 // The child process shutdown sequence is a request response based mechanism, 727 // The child process shutdown sequence is a request response based mechanism,
728 // where we send out an initial feeler request to the child process host 728 // where we send out an initial feeler request to the child process host
729 // instance in the browser to verify if it's ok to shutdown the child process. 729 // instance in the browser to verify if it's ok to shutdown the child process.
730 // The browser then sends back a response if it's ok to shutdown. This avoids 730 // The browser then sends back a response if it's ok to shutdown. This avoids
731 // race conditions if the process refcount is 0 but there's an IPC message 731 // race conditions if the process refcount is 0 but there's an IPC message
732 // inflight that would addref it. 732 // inflight that would addref it.
733 Send(new ChildProcessHostMsg_ShutdownRequest); 733 Send(new ChildProcessHostMsg_ShutdownRequest);
734 } 734 }
735 735
736 void ChildThreadImpl::EnsureConnected() { 736 void ChildThreadImpl::EnsureConnected() {
737 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; 737 VLOG(0) << "ChildThreadImpl::EnsureConnected()";
738 base::Process::Current().Terminate(0, false); 738 base::Process::Current().Terminate(0, false);
739 } 739 }
740 740
741 bool ChildThreadImpl::IsInBrowserProcess() const { 741 bool ChildThreadImpl::IsInBrowserProcess() const {
742 return browser_process_io_runner_; 742 return browser_process_io_runner_;
743 } 743 }
744 744
745 } // namespace content 745 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_aura_browsertest.cc ('k') | content/gpu/gpu_child_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698