summaryrefslogtreecommitdiffstats
path: root/webkit
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 /webkit
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 'webkit')
-rw-r--r--webkit/plugins/ppapi/audio_helper.cc2
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc14
-rw-r--r--webkit/plugins/ppapi/ppb_broker_impl.cc4
-rw-r--r--webkit/plugins/ppapi/ppb_flash_menu_impl.cc2
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.h2
-rw-r--r--webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.cc3
-rw-r--r--webkit/plugins/ppapi/ppb_url_loader_impl.cc2
7 files changed, 13 insertions, 16 deletions
diff --git a/webkit/plugins/ppapi/audio_helper.cc b/webkit/plugins/ppapi/audio_helper.cc
index 686ac90..f7ad230 100644
--- a/webkit/plugins/ppapi/audio_helper.cc
+++ b/webkit/plugins/ppapi/audio_helper.cc
@@ -63,7 +63,7 @@ void AudioHelper::StreamCreated(
shared_memory_size_for_create_callback_ = shared_memory_size;
socket_for_create_callback_.reset(new base::SyncSocket(socket_handle));
- ::ppapi::TrackedCallback::ClearAndRun(&create_callback_, PP_OK);
+ create_callback_->Run(PP_OK);
// It might be nice to close the handles here to free up some system
// resources, but we can't since there's a race condition. The handles must
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 9e95b07..795a00e 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -639,8 +639,8 @@ PluginInstance::~PluginInstance() {
i != plugin_object_copy.end(); ++i)
delete *i;
- if (lock_mouse_callback_)
- TrackedCallback::ClearAndAbort(&lock_mouse_callback_);
+ if (TrackedCallback::IsPending(lock_mouse_callback_))
+ lock_mouse_callback_->Abort();
delegate_->InstanceDeleted(this);
module_->InstanceDeleted(this);
@@ -2034,7 +2034,7 @@ void PluginInstance::UpdateFlashFullscreenState(bool flash_fullscreen) {
if (flash_fullscreen == flash_fullscreen_) {
// Manually clear callback when fullscreen fails with mouselock pending.
if (!flash_fullscreen && is_mouselock_pending)
- TrackedCallback::ClearAndRun(&lock_mouse_callback_, PP_ERROR_FAILED);
+ lock_mouse_callback_->Run(PP_ERROR_FAILED);
return;
}
@@ -2053,7 +2053,7 @@ void PluginInstance::UpdateFlashFullscreenState(bool flash_fullscreen) {
flash_fullscreen_ = flash_fullscreen;
if (is_mouselock_pending && !delegate()->IsMouseLocked(this)) {
if (!delegate()->LockMouse(this))
- TrackedCallback::ClearAndRun(&lock_mouse_callback_, PP_ERROR_FAILED);
+ lock_mouse_callback_->Run(PP_ERROR_FAILED);
}
if (PluginHasFocus() != old_plugin_focus)
@@ -2316,10 +2316,8 @@ bool PluginInstance::IsProcessingUserGesture() {
}
void PluginInstance::OnLockMouseACK(bool succeeded) {
- if (TrackedCallback::IsPending(lock_mouse_callback_)) {
- TrackedCallback::ClearAndRun(&lock_mouse_callback_,
- succeeded ? PP_OK : PP_ERROR_FAILED);
- }
+ if (TrackedCallback::IsPending(lock_mouse_callback_))
+ lock_mouse_callback_->Run(succeeded ? PP_OK : PP_ERROR_FAILED);
}
void PluginInstance::OnMouseLockLost() {
diff --git a/webkit/plugins/ppapi/ppb_broker_impl.cc b/webkit/plugins/ppapi/ppb_broker_impl.cc
index 49342fc..e8063f1 100644
--- a/webkit/plugins/ppapi/ppb_broker_impl.cc
+++ b/webkit/plugins/ppapi/ppb_broker_impl.cc
@@ -64,7 +64,7 @@ int32_t PPB_Broker_Impl::Connect(
broker_ = plugin_instance->delegate()->ConnectToBroker(this);
if (!broker_) {
- TrackedCallback::ClearAndAbort(&connect_callback_);
+ connect_callback_->Abort();
return PP_ERROR_FAILED;
}
@@ -95,7 +95,7 @@ void PPB_Broker_Impl::BrokerConnected(int32_t handle, int32_t result) {
// Synchronous calls are not supported.
DCHECK(TrackedCallback::IsPending(connect_callback_));
- TrackedCallback::ClearAndRun(&connect_callback_, result);
+ connect_callback_->Run(result);
}
} // namespace ppapi
diff --git a/webkit/plugins/ppapi/ppb_flash_menu_impl.cc b/webkit/plugins/ppapi/ppb_flash_menu_impl.cc
index e0c405e..7452061 100644
--- a/webkit/plugins/ppapi/ppb_flash_menu_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_menu_impl.cc
@@ -176,7 +176,7 @@ void PPB_Flash_Menu_Impl::CompleteShow(int32_t result,
}
selected_id_out_ = NULL;
- TrackedCallback::ClearAndRun(&callback_, rv);
+ callback_->Run(rv);
}
} // namespace ppapi
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.h b/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
index de32660..5419daa 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
@@ -117,7 +117,7 @@ class PPB_Graphics2D_Impl : public ::ppapi::Resource,
}
void Execute(int32_t result) {
- ::ppapi::TrackedCallback::ClearAndRun(&callback_, result);
+ callback_->Run(result);
}
void PostAbort() {
diff --git a/webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.cc b/webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.cc
index 5f023ae..d52c6e1 100644
--- a/webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.cc
+++ b/webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.cc
@@ -50,8 +50,7 @@ void PPB_TCPServerSocket_Private_Impl::OnAcceptCompleted(
}
tcp_socket_buffer_ = NULL;
- ::ppapi::TrackedCallback::ClearAndRun(&accept_callback_,
- succeeded ? PP_OK : PP_ERROR_FAILED);
+ accept_callback_->Run(succeeded ? PP_OK : PP_ERROR_FAILED);
}
void PPB_TCPServerSocket_Private_Impl::SendListen(
diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.cc b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
index 2884e8f..81e5a0d 100644
--- a/webkit/plugins/ppapi/ppb_url_loader_impl.cc
+++ b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
@@ -445,7 +445,7 @@ void PPB_URLLoader_Impl::RunCallback(int32_t result) {
// callbacks get called in an unexpected order.
user_buffer_ = NULL;
user_buffer_size_ = 0;
- TrackedCallback::ClearAndRun(&pending_callback_, result);
+ pending_callback_->Run(result);
}
size_t PPB_URLLoader_Impl::FillUserBuffer() {