diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-03 22:44:58 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-03 22:44:58 +0000 |
commit | 73b61881322b88e5bb10fdb9891e6772da334d08 (patch) | |
tree | 845d86b72e8a66d1daf578e3c5ab604b503376e2 /ppapi/proxy/ppb_url_loader_proxy.cc | |
parent | aafbcb57bbc46cd82c29fdb3c216ad7b15803704 (diff) | |
download | chromium_src-73b61881322b88e5bb10fdb9891e6772da334d08.zip chromium_src-73b61881322b88e5bb10fdb9891e6772da334d08.tar.gz chromium_src-73b61881322b88e5bb10fdb9891e6772da334d08.tar.bz2 |
Revert 95309 - I need to fix some bugs with this.
Add a template to handle properly issuing completion callbacks. This fixes
some bugs where we forgot to issue completion callbacks in some error cases
in the proxy, and cleans up the cases that were already doing this properly.
This removes the PPB_AudioTrusted_API and folds those functions into the
regular Audio API. I'm trying to merge more things to have a smaller explosion
of APIs and the boilerplate associated with them.
Review URL: http://codereview.chromium.org/7551032
TBR=brettw@chromium.org
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95342 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/ppb_url_loader_proxy.cc')
-rw-r--r-- | ppapi/proxy/ppb_url_loader_proxy.cc | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/ppapi/proxy/ppb_url_loader_proxy.cc b/ppapi/proxy/ppb_url_loader_proxy.cc index 1fc4db1..b2d6276 100644 --- a/ppapi/proxy/ppb_url_loader_proxy.cc +++ b/ppapi/proxy/ppb_url_loader_proxy.cc @@ -517,12 +517,21 @@ void PPB_URLLoader_Proxy::OnMsgReadResponseBody( // TODO(brettw) have a way to check for out-of-memory. info->read_buffer.resize(bytes_to_read); - EnterHostFromHostResourceForceCallback<PPB_URLLoader_API> enter( - loader, callback_factory_, &PPB_URLLoader_Proxy::OnReadCallback, info); + CompletionCallback callback = callback_factory_.NewOptionalCallback( + &PPB_URLLoader_Proxy::OnReadCallback, info); + + EnterHostFromHostResource<PPB_URLLoader_API> enter(loader); + int32_t result = PP_ERROR_BADRESOURCE; if (enter.succeeded()) { - enter.SetResult(enter.object()->ReadResponseBody( + result = enter.object()->ReadResponseBody( const_cast<char*>(info->read_buffer.c_str()), - bytes_to_read, enter.callback())); + bytes_to_read, callback.pp_completion_callback()); + } + if (result != PP_OK_COMPLETIONPENDING) { + // Send error (or perhaps success for synchronous reads) back to plugin. + // The callback function is already set up to do this and also delete the + // callback info. + callback.Run(result); } } |