summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy/ppb_file_ref_proxy.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-05 18:17:05 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-05 18:17:05 +0000
commita78956be12c7d66aeacdb371cfe957014e6e0fff (patch)
tree7cc23f63df2090b2be8b27a9959bf54e34acf8f9 /ppapi/proxy/ppb_file_ref_proxy.cc
parent09c37bac05f382080e064d0bf96c7387f5f00c4b (diff)
downloadchromium_src-a78956be12c7d66aeacdb371cfe957014e6e0fff.zip
chromium_src-a78956be12c7d66aeacdb371cfe957014e6e0fff.tar.gz
chromium_src-a78956be12c7d66aeacdb371cfe957014e6e0fff.tar.bz2
Convert proxy callbacks to use TrackedCallback.
This converts all free-standing refs of PP_CompletionCallback to use the new TrackedCallback. BUG= TEST= Review URL: http://codereview.chromium.org/9003009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116509 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy/ppb_file_ref_proxy.cc')
-rw-r--r--ppapi/proxy/ppb_file_ref_proxy.cc18
1 files changed, 6 insertions, 12 deletions
diff --git a/ppapi/proxy/ppb_file_ref_proxy.cc b/ppapi/proxy/ppb_file_ref_proxy.cc
index e481f86..7c12ea3 100644
--- a/ppapi/proxy/ppb_file_ref_proxy.cc
+++ b/ppapi/proxy/ppb_file_ref_proxy.cc
@@ -17,6 +17,7 @@
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/serialized_var.h"
#include "ppapi/shared_impl/ppb_file_ref_shared.h"
+#include "ppapi/shared_impl/tracked_callback.h"
#include "ppapi/thunk/resource_creation_api.h"
#include "ppapi/thunk/thunk.h"
@@ -68,7 +69,7 @@ class FileRef : public PPB_FileRef_Shared {
// the callback will be identified when it's passed to the host and then
// back here.
int next_callback_id_;
- typedef std::map<int, PP_CompletionCallback> PendingCallbackMap;
+ typedef std::map<int, scoped_refptr<TrackedCallback> > PendingCallbackMap;
PendingCallbackMap pending_callbacks_;
DISALLOW_IMPLICIT_CONSTRUCTORS(FileRef);
@@ -85,14 +86,7 @@ FileRef::~FileRef() {
}
void FileRef::LastPluginRefWasDeleted() {
- // Abort all pending callbacks. Do this by posting a task to avoid reentering
- // the plugin's Release() call that probably deleted this object.
- for (PendingCallbackMap::iterator i = pending_callbacks_.begin();
- i != pending_callbacks_.end(); ++i) {
- MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
- i->second.func, i->second.user_data,
- static_cast<int32_t>(PP_ERROR_ABORTED)));
- }
+ // The callback tracker will abort our callbacks for us.
pending_callbacks_.clear();
}
@@ -172,9 +166,9 @@ void FileRef::ExecuteCallback(int callback_id, int32_t result) {
}
// Executing the callback may mutate the callback list.
- PP_CompletionCallback callback = found->second;
+ scoped_refptr<TrackedCallback> callback = found->second;
pending_callbacks_.erase(found);
- PP_RunCompletionCallback(&callback, result);
+ callback->Run(result);
}
int FileRef::SendCallback(PP_CompletionCallback callback) {
@@ -185,7 +179,7 @@ int FileRef::SendCallback(PP_CompletionCallback callback) {
while (pending_callbacks_.find(next_callback_id_) != pending_callbacks_.end())
next_callback_id_++;
- pending_callbacks_[next_callback_id_] = callback;
+ pending_callbacks_[next_callback_id_] = new TrackedCallback(this, callback);
return next_callback_id_++;
}