From c9eb5058727792d807a475026f33e428813fdd0c Mon Sep 17 00:00:00 2001 From: "dmichael@chromium.org" <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> Date: Mon, 5 Nov 2012 20:08:24 +0000 Subject: 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 --- ppapi/shared_impl/private/ppb_host_resolver_shared.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'ppapi/shared_impl/private/ppb_host_resolver_shared.cc') diff --git a/ppapi/shared_impl/private/ppb_host_resolver_shared.cc b/ppapi/shared_impl/private/ppb_host_resolver_shared.cc index 543b1c0..ba026dc 100644 --- a/ppapi/shared_impl/private/ppb_host_resolver_shared.cc +++ b/ppapi/shared_impl/private/ppb_host_resolver_shared.cc @@ -84,8 +84,7 @@ void PPB_HostResolver_Shared::OnResolveCompleted( net_address_list_.clear(); } - TrackedCallback::ClearAndRun(&resolve_callback_, - succeeded ? PP_OK : PP_ERROR_FAILED); + resolve_callback_->Run(succeeded ? PP_OK : PP_ERROR_FAILED); } uint32 PPB_HostResolver_Shared::GenerateHostResolverID() { -- cgit v1.1