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

Unified Diff: webkit/plugins/ppapi/ppb_flash_net_connector_impl.cc

Issue 9015009: Use the new callback tracker and delete the old one (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add IsPending Created 8 years, 12 months 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
« no previous file with comments | « webkit/plugins/ppapi/ppb_flash_net_connector_impl.h ('k') | webkit/plugins/ppapi/ppb_transport_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppb_flash_net_connector_impl.cc
diff --git a/webkit/plugins/ppapi/ppb_flash_net_connector_impl.cc b/webkit/plugins/ppapi/ppb_flash_net_connector_impl.cc
index 139995927746a32f2a914addffe43b82e54df29b..62ad9b93e1fb859b12280b60bc688d6550fca528 100644
--- a/webkit/plugins/ppapi/ppb_flash_net_connector_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_net_connector_impl.cc
@@ -12,7 +12,8 @@
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/resource_helper.h"
-using ::ppapi::thunk::PPB_Flash_NetConnector_API;
+using ppapi::thunk::PPB_Flash_NetConnector_API;
+using ppapi::TrackedCallback;
namespace webkit {
namespace ppapi {
@@ -46,7 +47,7 @@ int32_t PPB_Flash_NetConnector_Impl::ConnectTcp(
if (!callback.func)
return PP_ERROR_BLOCKS_MAIN_THREAD;
- if (callback_.get() && !callback_->completed())
+ if (TrackedCallback::IsPending(callback_))
return PP_ERROR_INPROGRESS;
PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
@@ -55,9 +56,7 @@ int32_t PPB_Flash_NetConnector_Impl::ConnectTcp(
int32_t rv = plugin_instance->delegate()->ConnectTcp(this, host, port);
if (rv == PP_OK_COMPLETIONPENDING) {
// Record callback and output buffers.
- callback_ = new TrackedCompletionCallback(
- plugin_instance->module()->GetCallbackTracker(),
- pp_resource(), callback);
+ callback_ = new TrackedCallback(this, callback);
socket_out_ = socket_out;
local_addr_out_ = local_addr_out;
remote_addr_out_ = remote_addr_out;
@@ -81,7 +80,7 @@ int32_t PPB_Flash_NetConnector_Impl::ConnectTcpAddress(
if (!callback.func)
return PP_ERROR_BLOCKS_MAIN_THREAD;
- if (callback_.get() && !callback_->completed())
+ if (TrackedCallback::IsPending(callback_))
return PP_ERROR_INPROGRESS;
PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
@@ -90,9 +89,7 @@ int32_t PPB_Flash_NetConnector_Impl::ConnectTcpAddress(
int32_t rv = plugin_instance->delegate()->ConnectTcpAddress(this, addr);
if (rv == PP_OK_COMPLETIONPENDING) {
// Record callback and output buffers.
- callback_ = new TrackedCompletionCallback(
- plugin_instance->module()->GetCallbackTracker(),
- pp_resource(), callback);
+ callback_ = new TrackedCallback(this, callback);
socket_out_ = socket_out;
local_addr_out_ = local_addr_out;
remote_addr_out_ = remote_addr_out;
@@ -124,16 +121,10 @@ void PPB_Flash_NetConnector_Impl::CompleteConnectTcp(
}
}
- // Theoretically, the plugin should be allowed to try another |ConnectTcp()|
- // from the callback.
- scoped_refptr<TrackedCompletionCallback> callback;
- callback.swap(callback_);
- // Wipe everything else out for safety.
socket_out_ = NULL;
local_addr_out_ = NULL;
remote_addr_out_ = NULL;
-
- callback->Run(rv); // Will complete abortively if necessary.
+ TrackedCallback::ClearAndRun(&callback_, rv);
}
} // namespace ppapi
« no previous file with comments | « webkit/plugins/ppapi/ppb_flash_net_connector_impl.h ('k') | webkit/plugins/ppapi/ppb_transport_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698