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

Side by Side Diff: content/common/child_thread.cc

Issue 10694014: Cleanup IPC::ChannelProxy to use SingleThreadTaskRunner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
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/common/child_thread.h" 5 #include "content/common/child_thread.h"
6 6
7 #include "base/allocator/allocator_extension.h" 7 #include "base/allocator/allocator_extension.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/process.h" 10 #include "base/process.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 IPC::Logging::GetInstance()->SetIPCSender(NULL); 68 IPC::Logging::GetInstance()->SetIPCSender(NULL);
69 #endif 69 #endif
70 70
71 channel_->RemoveFilter(sync_message_filter_.get()); 71 channel_->RemoveFilter(sync_message_filter_.get());
72 72
73 // Close this channel before resetting the message loop attached to it so 73 // Close this channel before resetting the message loop attached to it so
74 // the message loop can call ChannelProxy::Context::OnChannelClosed(), which 74 // the message loop can call ChannelProxy::Context::OnChannelClosed(), which
75 // releases the reference count to this channel. 75 // releases the reference count to this channel.
76 channel_->Close(); 76 channel_->Close();
77 77
78 // TODO(sergeyu): The comment below is not up to date. Figure out if
jam 2012/07/01 22:19:41 no need for the TODO, I'm looking into this :) htt
Sergey Ulanov 2012/07/02 18:44:34 Done.
79 // we still need this call and update the comment or remove it.
80 //
78 // The ChannelProxy object caches a pointer to the IPC thread, so need to 81 // The ChannelProxy object caches a pointer to the IPC thread, so need to
79 // reset it as it's not guaranteed to outlive this object. 82 // reset it as it's not guaranteed to outlive this object.
80 // NOTE: this also has the side-effect of not closing the main IPC channel to 83 // NOTE: this also has the side-effect of not closing the main IPC channel to
81 // the browser process. This is needed because this is the signal that the 84 // the browser process. This is needed because this is the signal that the
82 // browser uses to know that this process has died, so we need it to be alive 85 // browser uses to know that this process has died, so we need it to be alive
83 // until this process is shut down, and the OS closes the handle 86 // until this process is shut down, and the OS closes the handle
84 // automatically. We used to watch the object handle on Windows to do this, 87 // automatically. We used to watch the object handle on Windows to do this,
85 // but it wasn't possible to do so on POSIX. 88 // but it wasn't possible to do so on POSIX.
86 channel_->ClearIPCMessageLoop(); 89 channel_->ClearIPCTaskRunner();
87 } 90 }
88 91
89 void ChildThread::OnChannelError() { 92 void ChildThread::OnChannelError() {
90 set_on_channel_error_called(true); 93 set_on_channel_error_called(true);
91 MessageLoop::current()->Quit(); 94 MessageLoop::current()->Quit();
92 } 95 }
93 96
94 bool ChildThread::Send(IPC::Message* msg) { 97 bool ChildThread::Send(IPC::Message* msg) {
95 DCHECK(MessageLoop::current() == message_loop()); 98 DCHECK(MessageLoop::current() == message_loop());
96 if (!channel_.get()) { 99 if (!channel_.get()) {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 } 279 }
277 280
278 // The child process shutdown sequence is a request response based mechanism, 281 // The child process shutdown sequence is a request response based mechanism,
279 // where we send out an initial feeler request to the child process host 282 // where we send out an initial feeler request to the child process host
280 // instance in the browser to verify if it's ok to shutdown the child process. 283 // instance in the browser to verify if it's ok to shutdown the child process.
281 // The browser then sends back a response if it's ok to shutdown. This avoids 284 // The browser then sends back a response if it's ok to shutdown. This avoids
282 // race conditions if the process refcount is 0 but there's an IPC message 285 // race conditions if the process refcount is 0 but there's an IPC message
283 // inflight that would addref it. 286 // inflight that would addref it.
284 Send(new ChildProcessHostMsg_ShutdownRequest); 287 Send(new ChildProcessHostMsg_ShutdownRequest);
285 } 288 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698