summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy/websocket_resource.cc
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-05 20:08:24 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-05 20:08:24 +0000
commitc9eb5058727792d807a475026f33e428813fdd0c (patch)
treeadcc38af58d1203e89ef556f3510f15cb2946011 /ppapi/proxy/websocket_resource.cc
parent02506d484620d02edead710dc856ab8a28813c3b (diff)
downloadchromium_src-c9eb5058727792d807a475026f33e428813fdd0c.zip
chromium_src-c9eb5058727792d807a475026f33e428813fdd0c.tar.gz
chromium_src-c9eb5058727792d807a475026f33e428813fdd0c.tar.bz2
PPAPI: Get TrackedCallback ready for running on non-main threads.
When CompletionCallbacks can run on background threads, ClearAndRun doesn't make sense anymore. Because the call may bounce to a different thread, we can't guarantee we'll run it right away, so setting the callback pointer to NULL is no longer a good way to indicate the callback has been run. Instead, callers should just use Run(), and rely on IsPending() to tell them if the call is still pending. TrackedCallback also can not use WeakPtrs, because those DCHECK if they are dereferenced on a different thread than they were created on. In particular, if a PPB implementation calls callback_->Run(PP_OK), that almost always happens on the main thread, and creates a WeakPtr<TrackedCallback> there. But Run will sometimes have to schedule a task on a non-main thread, and the WeakPtr will fail there. Note that because all this happens behind the proxy lock, it actually would be safe. But I just went with a bool flag to do the same checking as before, rather than try to subvert the WeakPtr checks. The CL for the Callbacks-on-background-threads feature is basically working and is here: https://chromiumcodereview.appspot.com/10910099 BUG=92909 Review URL: https://chromiumcodereview.appspot.com/10909244 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166009 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/websocket_resource.cc')
-rw-r--r--ppapi/proxy/websocket_resource.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/ppapi/proxy/websocket_resource.cc b/ppapi/proxy/websocket_resource.cc
index eb4176f..c45de90 100644
--- a/ppapi/proxy/websocket_resource.cc
+++ b/ppapi/proxy/websocket_resource.cc
@@ -371,7 +371,7 @@ void WebSocketResource::OnPluginMsgConnectReply(
protocol_ = new StringVar(protocol);
url_ = new StringVar(url);
}
- TrackedCallback::ClearAndRun(&connect_callback_, params.result());
+ connect_callback_->Run(params.result());
}
void WebSocketResource::OnPluginMsgCloseReply(
@@ -412,7 +412,7 @@ void WebSocketResource::OnPluginMsgReceiveTextReply(
if (!TrackedCallback::IsPending(receive_callback_))
return;
- TrackedCallback::ClearAndRun(&receive_callback_, DoReceive());
+ receive_callback_->Run(DoReceive());
}
void WebSocketResource::OnPluginMsgReceiveBinaryReply(
@@ -432,7 +432,7 @@ void WebSocketResource::OnPluginMsgReceiveBinaryReply(
if (!TrackedCallback::IsPending(receive_callback_))
return;
- TrackedCallback::ClearAndRun(&receive_callback_, DoReceive());
+ receive_callback_->Run(DoReceive());
}
void WebSocketResource::OnPluginMsgErrorReply(
@@ -445,7 +445,7 @@ void WebSocketResource::OnPluginMsgErrorReply(
// No more text or binary messages will be received. If there is ongoing
// ReceiveMessage(), we must invoke the callback with error code here.
receive_callback_var_ = NULL;
- TrackedCallback::ClearAndRun(&receive_callback_, PP_ERROR_FAILED);
+ receive_callback_->Run(PP_ERROR_FAILED);
}
void WebSocketResource::OnPluginMsgBufferedAmountReply(