summaryrefslogtreecommitdiffstats
path: root/content/child/webmessageportchannel_impl.cc
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-25 23:28:55 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-25 23:28:55 +0000
commitca405d2aa6618928e599d233adc1f937271e2b48 (patch)
tree6a63a236c184657736aad796a0a57ed688441a2e /content/child/webmessageportchannel_impl.cc
parentaf8630b7c4464d01726af88c3e8942be27106977 (diff)
downloadchromium_src-ca405d2aa6618928e599d233adc1f937271e2b48.zip
chromium_src-ca405d2aa6618928e599d233adc1f937271e2b48.tar.gz
chromium_src-ca405d2aa6618928e599d233adc1f937271e2b48.tar.bz2
Remove usage of ChildProcess::current() and ChildThread::current() other than on the main thread. This is needed so that single process mode will work correctly with the renderer/gpu/utility threads where we will have multiple ChildProcess objects.
While doing this, I made a few cleanups: -FileSystemDispatcher was checking the return value of sending an async IPC, which always returns true. I removed the return value of those methods and updated the callers to not handle the case which never occurs. -IPCWebSocketStreamHandleBridge was posting a task to send an async message which is needless BUG=234172 R=scottmg@chromium.org Review URL: https://codereview.chromium.org/17681004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208575 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/child/webmessageportchannel_impl.cc')
-rw-r--r--content/child/webmessageportchannel_impl.cc37
1 files changed, 21 insertions, 16 deletions
diff --git a/content/child/webmessageportchannel_impl.cc b/content/child/webmessageportchannel_impl.cc
index 98048c1..d082434 100644
--- a/content/child/webmessageportchannel_impl.cc
+++ b/content/child/webmessageportchannel_impl.cc
@@ -5,6 +5,7 @@
#include "content/child/webmessageportchannel_impl.h"
#include "base/bind.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "content/child/child_process.h"
#include "content/child/child_thread.h"
#include "content/common/worker_messages.h"
@@ -18,20 +19,24 @@ using WebKit::WebString;
namespace content {
-WebMessagePortChannelImpl::WebMessagePortChannelImpl()
+WebMessagePortChannelImpl::WebMessagePortChannelImpl(
+ base::MessageLoopProxy* child_thread_loop)
: client_(NULL),
route_id_(MSG_ROUTING_NONE),
- message_port_id_(MSG_ROUTING_NONE) {
+ message_port_id_(MSG_ROUTING_NONE),
+ child_thread_loop_(child_thread_loop) {
AddRef();
Init();
}
WebMessagePortChannelImpl::WebMessagePortChannelImpl(
int route_id,
- int message_port_id)
+ int message_port_id,
+ base::MessageLoopProxy* child_thread_loop)
: client_(NULL),
route_id_(route_id),
- message_port_id_(message_port_id) {
+ message_port_id_(message_port_id),
+ child_thread_loop_(child_thread_loop) {
AddRef();
Init();
}
@@ -65,7 +70,7 @@ void WebMessagePortChannelImpl::destroy() {
// Release the object on the main thread, since the destructor might want to
// send an IPC, and that has to happen on the main thread.
- ChildThread::current()->message_loop()->ReleaseSoon(FROM_HERE, this);
+ child_thread_loop_->ReleaseSoon(FROM_HERE, this);
}
void WebMessagePortChannelImpl::entangle(WebMessagePortChannel* channel) {
@@ -80,8 +85,8 @@ void WebMessagePortChannelImpl::entangle(WebMessagePortChannel* channel) {
void WebMessagePortChannelImpl::postMessage(
const WebString& message,
WebMessagePortChannelArray* channels) {
- if (base::MessageLoop::current() != ChildThread::current()->message_loop()) {
- ChildThread::current()->message_loop()->PostTask(
+ if (!child_thread_loop_->BelongsToCurrentThread()) {
+ child_thread_loop_->PostTask(
FROM_HERE,
base::Bind(
&WebMessagePortChannelImpl::postMessage, this, message, channels));
@@ -127,8 +132,8 @@ bool WebMessagePortChannelImpl::tryGetMessage(
}
void WebMessagePortChannelImpl::Init() {
- if (base::MessageLoop::current() != ChildThread::current()->message_loop()) {
- ChildThread::current()->message_loop()->PostTask(
+ if (!child_thread_loop_->BelongsToCurrentThread()) {
+ child_thread_loop_->PostTask(
FROM_HERE, base::Bind(&WebMessagePortChannelImpl::Init, this));
return;
}
@@ -144,8 +149,8 @@ void WebMessagePortChannelImpl::Init() {
void WebMessagePortChannelImpl::Entangle(
scoped_refptr<WebMessagePortChannelImpl> channel) {
- if (base::MessageLoop::current() != ChildThread::current()->message_loop()) {
- ChildThread::current()->message_loop()->PostTask(
+ if (!child_thread_loop_->BelongsToCurrentThread()) {
+ child_thread_loop_->PostTask(
FROM_HERE,
base::Bind(&WebMessagePortChannelImpl::Entangle, this, channel));
return;
@@ -156,8 +161,8 @@ void WebMessagePortChannelImpl::Entangle(
}
void WebMessagePortChannelImpl::QueueMessages() {
- if (base::MessageLoop::current() != ChildThread::current()->message_loop()) {
- ChildThread::current()->message_loop()->PostTask(
+ if (!child_thread_loop_->BelongsToCurrentThread()) {
+ child_thread_loop_->PostTask(
FROM_HERE, base::Bind(&WebMessagePortChannelImpl::QueueMessages, this));
return;
}
@@ -175,9 +180,9 @@ void WebMessagePortChannelImpl::QueueMessages() {
}
void WebMessagePortChannelImpl::Send(IPC::Message* message) {
- if (base::MessageLoop::current() != ChildThread::current()->message_loop()) {
+ if (!child_thread_loop_->BelongsToCurrentThread()) {
DCHECK(!message->is_sync());
- ChildThread::current()->message_loop()->PostTask(
+ child_thread_loop_->PostTask(
FROM_HERE,
base::Bind(&WebMessagePortChannelImpl::Send, this, message));
return;
@@ -207,7 +212,7 @@ void WebMessagePortChannelImpl::OnMessage(
msg.ports.resize(sent_message_port_ids.size());
for (size_t i = 0; i < sent_message_port_ids.size(); ++i) {
msg.ports[i] = new WebMessagePortChannelImpl(
- new_routing_ids[i], sent_message_port_ids[i]);
+ new_routing_ids[i], sent_message_port_ids[i], child_thread_loop_);
}
}