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

Issue 10909244: PPAPI: Get TrackedCallback ready for running on non-main threads. (Closed)

Created:
8 years, 3 months ago by dmichael (off chromium)
Modified:
8 years, 1 month ago
Reviewers:
viettrungluu
CC:
chromium-reviews, darin-cc_chromium.org
Visibility:
Public.

Description

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 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=166009

Patch Set 1 #

Total comments: 1

Patch Set 2 : #

Patch Set 3 : merge #

Total comments: 6

Patch Set 4 : megamerge #

Patch Set 5 : Fix review comment #

Patch Set 6 : Merged. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+124 lines, -177 lines) Patch
M ppapi/proxy/file_chooser_resource.cc View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M ppapi/proxy/flash_device_id_resource.cc View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M ppapi/proxy/ppb_broker_proxy.cc View 1 chunk +1 line, -1 line 0 comments Download
M ppapi/proxy/ppb_file_system_proxy.cc View 1 chunk +1 line, -1 line 0 comments Download
M ppapi/proxy/ppb_flash_menu_proxy.cc View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M ppapi/proxy/ppb_graphics_2d_proxy.cc View 1 2 chunks +2 lines, -2 lines 0 comments Download
M ppapi/proxy/ppb_instance_proxy.cc View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M ppapi/proxy/ppb_talk_private_proxy.cc View 1 chunk +1 line, -1 line 0 comments Download
M ppapi/proxy/ppb_tcp_server_socket_private_proxy.cc View 1 chunk +1 line, -2 lines 0 comments Download
M ppapi/proxy/ppb_url_loader_proxy.cc View 1 2 3 1 chunk +2 lines, -2 lines 0 comments Download
M ppapi/proxy/printing_resource.cc View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M ppapi/proxy/websocket_resource.cc View 1 2 3 4 5 4 chunks +4 lines, -4 lines 0 comments Download
M ppapi/shared_impl/ppb_audio_input_shared.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M ppapi/shared_impl/ppb_graphics_3d_shared.cc View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M ppapi/shared_impl/ppb_video_capture_shared.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M ppapi/shared_impl/ppb_video_decoder_shared.cc View 2 chunks +3 lines, -3 lines 0 comments Download
M ppapi/shared_impl/private/ppb_host_resolver_shared.cc View 1 chunk +1 line, -2 lines 0 comments Download
M ppapi/shared_impl/private/ppb_tcp_server_socket_shared.cc View 2 chunks +3 lines, -3 lines 0 comments Download
M ppapi/shared_impl/private/tcp_socket_private_impl.cc View 5 chunks +6 lines, -9 lines 0 comments Download
M ppapi/shared_impl/private/udp_socket_private_impl.cc View 4 chunks +4 lines, -6 lines 0 comments Download
M ppapi/shared_impl/tracked_callback.h View 1 2 3 4 4 chunks +10 lines, -18 lines 0 comments Download
M ppapi/shared_impl/tracked_callback.cc View 3 chunks +62 lines, -97 lines 0 comments Download
M webkit/plugins/ppapi/audio_helper.cc View 1 chunk +1 line, -1 line 0 comments Download
M webkit/plugins/ppapi/ppapi_plugin_instance.cc View 1 2 3 4 5 4 chunks +6 lines, -8 lines 0 comments Download
M webkit/plugins/ppapi/ppb_broker_impl.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M webkit/plugins/ppapi/ppb_flash_menu_impl.cc View 1 chunk +1 line, -1 line 0 comments Download
M webkit/plugins/ppapi/ppb_graphics_2d_impl.h View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M webkit/plugins/ppapi/ppb_tcp_server_socket_private_impl.cc View 1 chunk +1 line, -2 lines 0 comments Download
M webkit/plugins/ppapi/ppb_url_loader_impl.cc View 1 2 3 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 8 (0 generated)
dmichael (off chromium)
http://codereview.chromium.org/10909244/diff/1/ppapi/shared_impl/tracked_callback.cc File ppapi/shared_impl/tracked_callback.cc (left): http://codereview.chromium.org/10909244/diff/1/ppapi/shared_impl/tracked_callback.cc#oldcode64 ppapi/shared_impl/tracked_callback.cc:64: // resource. It turns out it does make sense... ...
8 years, 3 months ago (2012-09-14 21:30:36 UTC) #1
dmichael (off chromium)
Ahoy, matey. I've maaaarrrrged the CL. 'Tis not as haaarrd as it looks, and sends ...
8 years, 3 months ago (2012-09-19 18:04:02 UTC) #2
viettrungluu
https://chromiumcodereview.appspot.com/10909244/diff/17001/ppapi/proxy/file_chooser_resource.cc File ppapi/proxy/file_chooser_resource.cc (right): https://chromiumcodereview.appspot.com/10909244/diff/17001/ppapi/proxy/file_chooser_resource.cc#newcode129 ppapi/proxy/file_chooser_resource.cc:129: callback_->Run(params.result()); I don't see how you can leave the ...
8 years, 2 months ago (2012-09-25 00:18:11 UTC) #3
dmichael (off chromium)
Thanks for the review! I'm back from leave now, sorry for the delay in responding. ...
8 years, 1 month ago (2012-10-24 21:40:52 UTC) #4
dmichael (off chromium)
Ping?
8 years, 1 month ago (2012-10-31 16:03:05 UTC) #5
viettrungluu
LGTM I think, but you break it you buy it. :) Assuming that everyone is ...
8 years, 1 month ago (2012-11-02 21:29:24 UTC) #6
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/dmichael@chromium.org/10909244/38001
8 years, 1 month ago (2012-11-05 17:43:30 UTC) #7
commit-bot: I haz the power
8 years, 1 month ago (2012-11-05 20:08:26 UTC) #8
Change committed as 166009

Powered by Google App Engine
This is Rietveld 408576698