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

Unified Diff: ppapi/shared_impl/ppb_file_io_shared.cc

Issue 9053003: Convert ppapi/shared to use TrackedCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/shared_impl/ppb_file_io_shared.cc
diff --git a/ppapi/shared_impl/ppb_file_io_shared.cc b/ppapi/shared_impl/ppb_file_io_shared.cc
index dcad4d70caa44dbc94005d56dd6728a77af7252b..b3eefbc493ba7d84c920b3363462838aa7442d46 100644
--- a/ppapi/shared_impl/ppb_file_io_shared.cc
+++ b/ppapi/shared_impl/ppb_file_io_shared.cc
@@ -24,8 +24,6 @@ using thunk::PPB_FileRef_API;
PPB_FileIO_Shared::CallbackEntry::CallbackEntry()
: read_buffer(NULL),
info(NULL) {
- callback.func = NULL;
- callback.user_data = NULL;
}
PPB_FileIO_Shared::CallbackEntry::CallbackEntry(const CallbackEntry& entry)
@@ -59,11 +57,8 @@ PPB_FileIO_Shared::~PPB_FileIO_Shared() {
void PPB_FileIO_Shared::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 (size_t i = 0; i < callbacks_.size(); i++) {
- MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
- callbacks_[i].callback.func, callbacks_[i].callback.user_data,
- static_cast<int32_t>(PP_ERROR_ABORTED)));
- }
+ for (size_t i = 0; i < callbacks_.size(); i++)
viettrungluu 2012/01/03 22:43:46 I suppose you could also use PostAbortForResource(
brettw 2012/01/04 00:27:29 Actually I can just delete this code, it's already
+ callbacks_[i].callback->PostAbort();
callbacks_.erase(callbacks_.begin(), callbacks_.end());
}
@@ -217,7 +212,7 @@ void PPB_FileIO_Shared::RegisterCallback(OperationType op,
(pending_op_ != OPERATION_EXCLUSIVE && pending_op_ == op));
CallbackEntry entry;
- entry.callback = callback;
+ entry.callback = new TrackedCallback(this, callback);
entry.read_buffer = read_buffer;
entry.info = info;
callbacks_.push_back(entry);
@@ -233,7 +228,7 @@ void PPB_FileIO_Shared::RunAndRemoveFirstPendingCallback(int32_t result) {
if (callbacks_.empty())
pending_op_ = OPERATION_NONE;
- PP_RunCompletionCallback(&front.callback, result);
+ front.callback->Run(result);
}
} // namespace ppapi

Powered by Google App Engine
This is Rietveld 408576698