summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-23 14:27:42 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-23 14:27:42 +0000
commitaed965375dec978e7feb8722b1b94250a2a6e039 (patch)
tree9f8ccdf7a3902fa1db54e0c036f7cb9ca96775fb /webkit
parent94bd0a2e94c1f07ccc0236a95e57a2e16b94038a (diff)
downloadchromium_src-aed965375dec978e7feb8722b1b94250a2a6e039.zip
chromium_src-aed965375dec978e7feb8722b1b94250a2a6e039.tar.gz
chromium_src-aed965375dec978e7feb8722b1b94250a2a6e039.tar.bz2
PPAPI: Make blocking completion callbacks work.
This also makes scoped_refptr<TrackedCallback> the "new" way to pass completion callbacks in an API. This allows the Enter object to handle checking for blocking callbacks on the main thread to report error, and blocking if on the background thread. This way, interfaces don't have to write any special cases for blocking callbacks. When built with enable_pepper_threading=1 locally, URLLoader tests all pass for blocking completion callbacks. I haven't updated all tests yet. BUG=92909 TEST= Review URL: https://chromiumcodereview.appspot.com/10081020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143806 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/plugins/ppapi/file_callbacks.cc6
-rw-r--r--webkit/plugins/ppapi/file_callbacks.h4
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc14
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc20
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h8
-rw-r--r--webkit/plugins/ppapi/ppb_audio_impl.cc7
-rw-r--r--webkit/plugins/ppapi/ppb_audio_impl.h7
-rw-r--r--webkit/plugins/ppapi/ppb_audio_input_impl.cc19
-rw-r--r--webkit/plugins/ppapi/ppb_audio_input_impl.h13
-rw-r--r--webkit/plugins/ppapi/ppb_broker_impl.cc10
-rw-r--r--webkit/plugins/ppapi/ppb_broker_impl.h3
-rw-r--r--webkit/plugins/ppapi/ppb_directory_reader_impl.cc5
-rw-r--r--webkit/plugins/ppapi/ppb_directory_reader_impl.h8
-rw-r--r--webkit/plugins/ppapi/ppb_file_chooser_impl.cc19
-rw-r--r--webkit/plugins/ppapi/ppb_file_chooser_impl.h18
-rw-r--r--webkit/plugins/ppapi/ppb_file_io_impl.cc61
-rw-r--r--webkit/plugins/ppapi/ppb_file_io_impl.h61
-rw-r--r--webkit/plugins/ppapi/ppb_file_ref_impl.cc20
-rw-r--r--webkit/plugins/ppapi/ppb_file_ref_impl.h20
-rw-r--r--webkit/plugins/ppapi/ppb_file_system_impl.cc14
-rw-r--r--webkit/plugins/ppapi/ppb_file_system_impl.h5
-rw-r--r--webkit/plugins/ppapi/ppb_flash_menu_impl.cc10
-rw-r--r--webkit/plugins/ppapi/ppb_flash_menu_impl.h9
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc11
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.h3
-rw-r--r--webkit/plugins/ppapi/ppb_layer_compositor_impl.cc5
-rw-r--r--webkit/plugins/ppapi/ppb_layer_compositor_impl.h5
-rw-r--r--webkit/plugins/ppapi/ppb_url_loader_impl.cc27
-rw-r--r--webkit/plugins/ppapi/ppb_url_loader_impl.h23
-rw-r--r--webkit/plugins/ppapi/ppb_video_capture_impl.cc11
-rw-r--r--webkit/plugins/ppapi/ppb_video_capture_impl.h4
-rw-r--r--webkit/plugins/ppapi/ppb_video_decoder_impl.cc16
-rw-r--r--webkit/plugins/ppapi/ppb_video_decoder_impl.h11
-rw-r--r--webkit/plugins/ppapi/ppb_websocket_impl.cc27
-rw-r--r--webkit/plugins/ppapi/ppb_websocket_impl.h21
35 files changed, 255 insertions, 270 deletions
diff --git a/webkit/plugins/ppapi/file_callbacks.cc b/webkit/plugins/ppapi/file_callbacks.cc
index e9e1aee..0ab4453 100644
--- a/webkit/plugins/ppapi/file_callbacks.cc
+++ b/webkit/plugins/ppapi/file_callbacks.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -25,11 +25,11 @@ namespace ppapi {
FileCallbacks::FileCallbacks(
Resource* resource,
- PP_CompletionCallback callback,
+ scoped_refptr<TrackedCallback> callback,
PP_FileInfo* info,
scoped_refptr<PPB_FileSystem_Impl> file_system,
scoped_refptr<PPB_DirectoryReader_Impl> directory_reader)
- : callback_(new TrackedCallback(resource, callback)),
+ : callback_(callback),
info_(info),
file_system_(file_system),
directory_reader_(directory_reader) {
diff --git a/webkit/plugins/ppapi/file_callbacks.h b/webkit/plugins/ppapi/file_callbacks.h
index 8c00336..c254dab 100644
--- a/webkit/plugins/ppapi/file_callbacks.h
+++ b/webkit/plugins/ppapi/file_callbacks.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -36,7 +36,7 @@ class PPB_FileSystem_Impl;
class FileCallbacks : public fileapi::FileSystemCallbackDispatcher {
public:
FileCallbacks(::ppapi::Resource* resource,
- PP_CompletionCallback callback,
+ scoped_refptr< ::ppapi::TrackedCallback> callback,
PP_FileInfo* info,
scoped_refptr<PPB_FileSystem_Impl> file_system,
scoped_refptr<PPB_DirectoryReader_Impl> directory_reader);
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 423209f..7098f70 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -154,12 +154,6 @@ PluginModuleSet* GetLivePluginSet() {
return &live_plugin_libs;
}
-base::MessageLoopProxy* GetMainThreadMessageLoop() {
- CR_DEFINE_STATIC_LOCAL(scoped_refptr<base::MessageLoopProxy>, proxy,
- (base::MessageLoopProxy::current()));
- return proxy.get();
-}
-
// PPB_Core --------------------------------------------------------------------
void AddRefResource(PP_Resource resource) {
@@ -182,7 +176,7 @@ void CallOnMainThread(int delay_in_msec,
PP_CompletionCallback callback,
int32_t result) {
if (callback.func) {
- GetMainThreadMessageLoop()->PostDelayedTask(
+ PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostDelayedTask(
FROM_HERE,
base::Bind(callback.func, callback.user_data, result),
base::TimeDelta::FromMilliseconds(delay_in_msec));
@@ -190,7 +184,8 @@ void CallOnMainThread(int delay_in_msec,
}
PP_Bool IsMainThread() {
- return BoolToPPBool(GetMainThreadMessageLoop()->BelongsToCurrentThread());
+ return BoolToPPBool(PpapiGlobals::Get()->
+ GetMainThreadMessageLoop()->BelongsToCurrentThread());
}
const PPB_Core core_interface = {
@@ -427,7 +422,8 @@ PluginModule::PluginModule(const std::string& name,
memset(&entry_points_, 0, sizeof(entry_points_));
pp_module_ = HostGlobals::Get()->AddModule(this);
- GetMainThreadMessageLoop(); // Initialize the main thread message loop.
+ // Initialize the main thread message loop.
+ PpapiGlobals::Get()->GetMainThreadMessageLoop();
GetLivePluginSet()->insert(this);
}
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 3b6f263..96a08ad 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -107,6 +107,7 @@ using ppapi::PPB_View_Shared;
using ppapi::PPP_Instance_Combined;
using ppapi::ScopedPPResource;
using ppapi::StringVar;
+using ppapi::TrackedCallback;
using ppapi::thunk::EnterResourceNoLock;
using ppapi::thunk::PPB_Buffer_API;
using ppapi::thunk::PPB_Graphics2D_API;
@@ -350,7 +351,6 @@ PluginInstance::PluginInstance(
text_input_caret_set_(false),
selection_caret_(0),
selection_anchor_(0),
- lock_mouse_callback_(PP_BlockUntilComplete()),
pending_user_gesture_(0.0),
flash_impl_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
pp_instance_ = HostGlobals::Get()->AddInstance(this);
@@ -378,8 +378,8 @@ PluginInstance::~PluginInstance() {
i != plugin_object_copy.end(); ++i)
delete *i;
- if (lock_mouse_callback_.func)
- PP_RunAndClearCompletionCallback(&lock_mouse_callback_, PP_ERROR_ABORTED);
+ if (lock_mouse_callback_)
+ TrackedCallback::ClearAndAbort(&lock_mouse_callback_);
delegate_->InstanceDeleted(this);
module_->InstanceDeleted(this);
@@ -1595,12 +1595,12 @@ bool PluginInstance::IsProcessingUserGesture() {
}
void PluginInstance::OnLockMouseACK(bool succeeded) {
- if (!lock_mouse_callback_.func) {
+ if (TrackedCallback::IsPending(lock_mouse_callback_)) {
NOTREACHED();
return;
}
- PP_RunAndClearCompletionCallback(&lock_mouse_callback_,
- succeeded ? PP_OK : PP_ERROR_FAILED);
+ TrackedCallback::ClearAndRun(&lock_mouse_callback_,
+ succeeded ? PP_OK : PP_ERROR_FAILED);
}
void PluginInstance::OnMouseLockLost() {
@@ -1954,12 +1954,8 @@ PP_Bool PluginInstance::SetCursor(PP_Instance instance,
}
int32_t PluginInstance::LockMouse(PP_Instance instance,
- PP_CompletionCallback callback) {
- if (!callback.func) {
- // Don't support synchronous call.
- return PP_ERROR_BLOCKS_MAIN_THREAD;
- }
- if (lock_mouse_callback_.func) // A lock is pending.
+ scoped_refptr<TrackedCallback> callback) {
+ if (TrackedCallback::IsPending(lock_mouse_callback_))
return PP_ERROR_INPROGRESS;
if (delegate()->IsMouseLocked(this))
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index 7ae152a..7250e88 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h
@@ -37,6 +37,7 @@
#include "ppapi/c/private/ppp_instance_private.h"
#include "ppapi/shared_impl/ppb_instance_shared.h"
#include "ppapi/shared_impl/ppb_view_shared.h"
+#include "ppapi/shared_impl/tracked_callback.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
@@ -371,8 +372,9 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
PP_MouseCursor_Type type,
PP_Resource image,
const PP_Point* hot_spot) OVERRIDE;
- virtual int32_t LockMouse(PP_Instance instance,
- PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t LockMouse(
+ PP_Instance instance,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
virtual void UnlockMouse(PP_Instance instance) OVERRIDE;
virtual PP_Bool GetDefaultPrintSettings(
PP_Instance instance,
@@ -646,7 +648,7 @@ class WEBKIT_PLUGINS_EXPORT PluginInstance :
size_t selection_caret_;
size_t selection_anchor_;
- PP_CompletionCallback lock_mouse_callback_;
+ scoped_refptr< ::ppapi::TrackedCallback> lock_mouse_callback_;
// Track pending user gestures so out-of-process plugins can respond to
// a user gesture after it has been processed.
diff --git a/webkit/plugins/ppapi/ppb_audio_impl.cc b/webkit/plugins/ppapi/ppb_audio_impl.cc
index f5b64ad..7024aea 100644
--- a/webkit/plugins/ppapi/ppb_audio_impl.cc
+++ b/webkit/plugins/ppapi/ppb_audio_impl.cc
@@ -112,8 +112,9 @@ PP_Bool PPB_Audio_Impl::StopPlayback() {
return PP_TRUE;
}
-int32_t PPB_Audio_Impl::OpenTrusted(PP_Resource config,
- PP_CompletionCallback create_callback) {
+int32_t PPB_Audio_Impl::OpenTrusted(
+ PP_Resource config,
+ scoped_refptr<TrackedCallback> create_callback) {
// Validate the config and keep a reference to it.
EnterResourceNoLock<PPB_AudioConfig_API> enter(config, true);
if (enter.failed())
@@ -135,7 +136,7 @@ int32_t PPB_Audio_Impl::OpenTrusted(PP_Resource config,
// At this point, we are guaranteeing ownership of the completion
// callback. Audio promises to fire the completion callback
// once and only once.
- SetCreateCallback(new TrackedCallback(this, create_callback));
+ SetCreateCallback(create_callback);
return PP_OK_COMPLETIONPENDING;
}
diff --git a/webkit/plugins/ppapi/ppb_audio_impl.h b/webkit/plugins/ppapi/ppb_audio_impl.h
index 19acfc3..be41e36 100644
--- a/webkit/plugins/ppapi/ppb_audio_impl.h
+++ b/webkit/plugins/ppapi/ppb_audio_impl.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -57,8 +57,9 @@ class PPB_Audio_Impl : public ::ppapi::Resource,
virtual PP_Resource GetCurrentConfig() OVERRIDE;
virtual PP_Bool StartPlayback() OVERRIDE;
virtual PP_Bool StopPlayback() OVERRIDE;
- virtual int32_t OpenTrusted(PP_Resource config_id,
- PP_CompletionCallback create_callback) OVERRIDE;
+ virtual int32_t OpenTrusted(
+ PP_Resource config_id,
+ scoped_refptr< ::ppapi::TrackedCallback> create_callback) OVERRIDE;
virtual int32_t GetSyncSocket(int* sync_socket) OVERRIDE;
virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) OVERRIDE;
diff --git a/webkit/plugins/ppapi/ppb_audio_input_impl.cc b/webkit/plugins/ppapi/ppb_audio_input_impl.cc
index fe1036d..3b4d609 100644
--- a/webkit/plugins/ppapi/ppb_audio_input_impl.cc
+++ b/webkit/plugins/ppapi/ppb_audio_input_impl.cc
@@ -42,7 +42,7 @@ PP_Resource PPB_AudioInput_Impl::Create0_1(
audio_input(new PPB_AudioInput_Impl(instance));
int32_t result = audio_input->Open(
"", config, audio_input_callback, user_data,
- MakeIgnoredCompletionCallback());
+ MakeIgnoredCompletionCallback(audio_input.get()));
if (result != PP_OK && result != PP_OK_COMPLETIONPENDING)
return 0;
return audio_input->GetReference();
@@ -51,7 +51,7 @@ PP_Resource PPB_AudioInput_Impl::Create0_1(
int32_t PPB_AudioInput_Impl::OpenTrusted(
const std::string& device_id,
PP_Resource config,
- const PP_CompletionCallback& create_callback) {
+ scoped_refptr<TrackedCallback> create_callback) {
return CommonOpen(device_id, config, NULL, NULL, create_callback);
}
@@ -104,13 +104,13 @@ void PPB_AudioInput_Impl::StreamCreationFailed() {
int32_t PPB_AudioInput_Impl::InternalEnumerateDevices(
PP_Resource* devices,
- PP_CompletionCallback callback) {
+ scoped_refptr<TrackedCallback> callback) {
PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this);
if (!plugin_delegate)
return PP_ERROR_FAILED;
devices_ = devices;
- enumerate_devices_callback_ = new TrackedCallback(this, callback);
+ enumerate_devices_callback_ = callback;
plugin_delegate->EnumerateDevices(
PP_DEVICETYPE_DEV_AUDIOCAPTURE,
base::Bind(&PPB_AudioInput_Impl::EnumerateDevicesCallbackFunc,
@@ -118,10 +118,11 @@ int32_t PPB_AudioInput_Impl::InternalEnumerateDevices(
return PP_OK_COMPLETIONPENDING;
}
-int32_t PPB_AudioInput_Impl::InternalOpen(const std::string& device_id,
- PP_AudioSampleRate sample_rate,
- uint32_t sample_frame_count,
- PP_CompletionCallback callback) {
+int32_t PPB_AudioInput_Impl::InternalOpen(
+ const std::string& device_id,
+ PP_AudioSampleRate sample_rate,
+ uint32_t sample_frame_count,
+ scoped_refptr<TrackedCallback> callback) {
PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this);
if (!plugin_delegate)
return PP_ERROR_FAILED;
@@ -131,7 +132,7 @@ int32_t PPB_AudioInput_Impl::InternalOpen(const std::string& device_id,
audio_input_ = plugin_delegate->CreateAudioInput(
device_id, sample_rate, sample_frame_count, this);
if (audio_input_) {
- open_callback_ = new TrackedCallback(this, callback);
+ open_callback_ = callback;
return PP_OK_COMPLETIONPENDING;
} else {
return PP_ERROR_FAILED;
diff --git a/webkit/plugins/ppapi/ppb_audio_input_impl.h b/webkit/plugins/ppapi/ppb_audio_input_impl.h
index 186a148..d7a1e0c 100644
--- a/webkit/plugins/ppapi/ppb_audio_input_impl.h
+++ b/webkit/plugins/ppapi/ppb_audio_input_impl.h
@@ -39,7 +39,7 @@ class PPB_AudioInput_Impl : public ::ppapi::PPB_AudioInput_Shared,
virtual int32_t OpenTrusted(
const std::string& device_id,
PP_Resource config,
- const PP_CompletionCallback& create_callback) OVERRIDE;
+ scoped_refptr< ::ppapi::TrackedCallback> create_callback) OVERRIDE;
virtual int32_t GetSyncSocket(int* sync_socket) OVERRIDE;
virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) OVERRIDE;
virtual const DeviceRefDataVector& GetDeviceRefData() const OVERRIDE;
@@ -54,11 +54,12 @@ class PPB_AudioInput_Impl : public ::ppapi::PPB_AudioInput_Shared,
// PPB_AudioInput_Shared implementation.
virtual int32_t InternalEnumerateDevices(
PP_Resource* devices,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t InternalOpen(const std::string& device_id,
- PP_AudioSampleRate sample_rate,
- uint32_t sample_frame_count,
- PP_CompletionCallback callback) OVERRIDE;
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual int32_t InternalOpen(
+ const std::string& device_id,
+ PP_AudioSampleRate sample_rate,
+ uint32_t sample_frame_count,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
virtual PP_Bool InternalStartCapture() OVERRIDE;
virtual PP_Bool InternalStopCapture() OVERRIDE;
virtual void InternalClose() OVERRIDE;
diff --git a/webkit/plugins/ppapi/ppb_broker_impl.cc b/webkit/plugins/ppapi/ppb_broker_impl.cc
index 289b173..2386e0d 100644
--- a/webkit/plugins/ppapi/ppb_broker_impl.cc
+++ b/webkit/plugins/ppapi/ppb_broker_impl.cc
@@ -40,12 +40,8 @@ PPB_Broker_API* PPB_Broker_Impl::AsPPB_Broker_API() {
return this;
}
-int32_t PPB_Broker_Impl::Connect(PP_CompletionCallback connect_callback) {
- if (!connect_callback.func) {
- // Synchronous calls are not supported.
- return PP_ERROR_BLOCKS_MAIN_THREAD;
- }
-
+int32_t PPB_Broker_Impl::Connect(
+ scoped_refptr<TrackedCallback> connect_callback) {
// TODO(ddorwin): Return PP_ERROR_FAILED if plugin is in-process.
if (broker_) {
@@ -61,7 +57,7 @@ int32_t PPB_Broker_Impl::Connect(PP_CompletionCallback connect_callback) {
// and BrokerConnected is called before ConnectToBroker returns.
// Because it must be created now, it must be aborted and cleared if
// ConnectToBroker fails.
- connect_callback_ = new TrackedCallback(this, connect_callback);
+ connect_callback_ = connect_callback;
broker_ = plugin_instance->delegate()->ConnectToBroker(this);
if (!broker_) {
diff --git a/webkit/plugins/ppapi/ppb_broker_impl.h b/webkit/plugins/ppapi/ppb_broker_impl.h
index 51b5f00..6799c4f 100644
--- a/webkit/plugins/ppapi/ppb_broker_impl.h
+++ b/webkit/plugins/ppapi/ppb_broker_impl.h
@@ -32,7 +32,8 @@ class WEBKIT_PLUGINS_EXPORT PPB_Broker_Impl
virtual ::ppapi::thunk::PPB_Broker_API* AsPPB_Broker_API() OVERRIDE;
// PPB_BrokerTrusted implementation.
- virtual int32_t Connect(PP_CompletionCallback connect_callback) OVERRIDE;
+ virtual int32_t Connect(
+ scoped_refptr< ::ppapi::TrackedCallback> connect_callback) OVERRIDE;
virtual int32_t GetHandle(int32_t* handle) OVERRIDE;
void BrokerConnected(int32_t handle, int32_t result);
diff --git a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
index 2f38121..ec1315e 100644
--- a/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
+++ b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
@@ -23,6 +23,7 @@
#include "webkit/plugins/ppapi/resource_helper.h"
using ::ppapi::PpapiGlobals;
+using ::ppapi::TrackedCallback;
using ::ppapi::thunk::EnterResourceNoLock;
using ::ppapi::thunk::PPB_DirectoryReader_API;
using ::ppapi::thunk::PPB_FileRef_API;
@@ -80,9 +81,7 @@ PPB_DirectoryReader_API* PPB_DirectoryReader_Impl::AsPPB_DirectoryReader_API() {
int32_t PPB_DirectoryReader_Impl::GetNextEntry(
PP_DirectoryEntry_Dev* entry,
- PP_CompletionCallback callback) {
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
+ scoped_refptr<TrackedCallback> callback) {
if (directory_ref_->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
return PP_ERROR_FAILED;
diff --git a/webkit/plugins/ppapi/ppb_directory_reader_impl.h b/webkit/plugins/ppapi/ppb_directory_reader_impl.h
index b7cae31..10d567a 100644
--- a/webkit/plugins/ppapi/ppb_directory_reader_impl.h
+++ b/webkit/plugins/ppapi/ppb_directory_reader_impl.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,7 +12,6 @@
#include "ppapi/shared_impl/resource.h"
#include "ppapi/thunk/ppb_directory_reader_api.h"
-struct PP_CompletionCallback;
struct PP_DirectoryEntry_Dev;
namespace webkit {
@@ -34,8 +33,9 @@ class PPB_DirectoryReader_Impl
OVERRIDE;
// PPB_DirectoryReader_API implementation.
- virtual int32_t GetNextEntry(PP_DirectoryEntry_Dev* entry,
- PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t GetNextEntry(
+ PP_DirectoryEntry_Dev* entry,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
void AddNewEntries(const std::vector<base::FileUtilProxy::Entry>& entries,
bool has_more);
diff --git a/webkit/plugins/ppapi/ppb_file_chooser_impl.cc b/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
index a40d694..40ef147 100644
--- a/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
@@ -165,11 +165,7 @@ void PPB_FileChooser_Impl::StoreChosenFiles(
}
int32_t PPB_FileChooser_Impl::ValidateCallback(
- const PP_CompletionCallback& callback) {
- // We only support non-blocking calls.
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
-
+ scoped_refptr<TrackedCallback> callback) {
if (TrackedCallback::IsPending(callback_))
return PP_ERROR_INPROGRESS;
@@ -177,15 +173,14 @@ int32_t PPB_FileChooser_Impl::ValidateCallback(
}
void PPB_FileChooser_Impl::RegisterCallback(
- const PP_CompletionCallback& callback) {
- DCHECK(callback.func);
+ scoped_refptr<TrackedCallback> callback) {
DCHECK(!TrackedCallback::IsPending(callback_));
PluginModule* plugin_module = ResourceHelper::GetPluginModule(this);
if (!plugin_module)
return;
- callback_ = new TrackedCallback(this, callback);
+ callback_ = callback;
}
void PPB_FileChooser_Impl::RunCallback(int32_t result) {
@@ -193,7 +188,7 @@ void PPB_FileChooser_Impl::RunCallback(int32_t result) {
}
int32_t PPB_FileChooser_Impl::Show(const PP_ArrayOutput& output,
- const PP_CompletionCallback& callback) {
+ scoped_refptr<TrackedCallback> callback) {
int32_t result = Show0_5(callback);
if (result == PP_OK_COMPLETIONPENDING)
output_.set_pp_array_output(output);
@@ -204,7 +199,7 @@ int32_t PPB_FileChooser_Impl::ShowWithoutUserGesture(
PP_Bool save_as,
PP_Var suggested_file_name,
const PP_ArrayOutput& output,
- const PP_CompletionCallback& callback) {
+ scoped_refptr<TrackedCallback> callback) {
int32_t result = ShowWithoutUserGesture0_5(save_as, suggested_file_name,
callback);
if (result == PP_OK_COMPLETIONPENDING)
@@ -212,7 +207,7 @@ int32_t PPB_FileChooser_Impl::ShowWithoutUserGesture(
return result;
}
-int32_t PPB_FileChooser_Impl::Show0_5(const PP_CompletionCallback& callback) {
+int32_t PPB_FileChooser_Impl::Show0_5(scoped_refptr<TrackedCallback> callback) {
PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
if (!plugin_instance)
return PP_ERROR_FAILED;
@@ -224,7 +219,7 @@ int32_t PPB_FileChooser_Impl::Show0_5(const PP_CompletionCallback& callback) {
int32_t PPB_FileChooser_Impl::ShowWithoutUserGesture0_5(
PP_Bool save_as,
PP_Var suggested_file_name,
- const PP_CompletionCallback& callback) {
+ scoped_refptr<TrackedCallback> callback) {
int32_t rv = ValidateCallback(callback);
if (rv != PP_OK)
return rv;
diff --git a/webkit/plugins/ppapi/ppb_file_chooser_impl.h b/webkit/plugins/ppapi/ppb_file_chooser_impl.h
index 396c583..59de2ac 100644
--- a/webkit/plugins/ppapi/ppb_file_chooser_impl.h
+++ b/webkit/plugins/ppapi/ppb_file_chooser_impl.h
@@ -16,8 +16,6 @@
#include "ppapi/thunk/ppb_file_chooser_api.h"
#include "webkit/plugins/webkit_plugins_export.h"
-struct PP_CompletionCallback;
-
namespace ppapi {
class TrackedCallback;
}
@@ -63,28 +61,30 @@ class PPB_FileChooser_Impl : public ::ppapi::Resource,
// Check that |callback| is valid (only non-blocking operation is supported)
// and that no callback is already pending. Returns |PP_OK| if okay, else
// |PP_ERROR_...| to be returned to the plugin.
- int32_t ValidateCallback(const PP_CompletionCallback& callback);
+ int32_t ValidateCallback(scoped_refptr< ::ppapi::TrackedCallback> callback);
// Sets up |callback| as the pending callback. This should only be called once
// it is certain that |PP_OK_COMPLETIONPENDING| will be returned.
- void RegisterCallback(const PP_CompletionCallback& callback);
+ void RegisterCallback(scoped_refptr< ::ppapi::TrackedCallback> callback);
void RunCallback(int32_t result);
// PPB_FileChooser_API implementation.
- virtual int32_t Show(const PP_ArrayOutput& output,
- const PP_CompletionCallback& callback) OVERRIDE;
+ virtual int32_t Show(
+ const PP_ArrayOutput& output,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
virtual int32_t ShowWithoutUserGesture(
PP_Bool save_as,
PP_Var suggested_file_name,
const PP_ArrayOutput& output,
- const PP_CompletionCallback& callback);
- virtual int32_t Show0_5(const PP_CompletionCallback& callback) OVERRIDE;
+ scoped_refptr< ::ppapi::TrackedCallback> callback);
+ virtual int32_t Show0_5(
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
virtual PP_Resource GetNextChosenFile() OVERRIDE;
virtual int32_t ShowWithoutUserGesture0_5(
PP_Bool save_as,
PP_Var suggested_file_name,
- const PP_CompletionCallback& callback) OVERRIDE;
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
// Splits a comma-separated MIME type/extension list |accept_types|, trims the
// resultant split types, makes them lowercase, and returns them.
diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.cc b/webkit/plugins/ppapi/ppb_file_io_impl.cc
index 7fa69bc..d102270 100644
--- a/webkit/plugins/ppapi/ppb_file_io_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_io_impl.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -29,6 +29,7 @@
using ppapi::PPTimeToTime;
using ppapi::TimeToPPTime;
+using ppapi::TrackedCallback;
using ppapi::thunk::PPB_FileRef_API;
namespace webkit {
@@ -44,10 +45,11 @@ PPB_FileIO_Impl::~PPB_FileIO_Impl() {
Close();
}
-int32_t PPB_FileIO_Impl::OpenValidated(PP_Resource file_ref_resource,
- PPB_FileRef_API* file_ref_api,
- int32_t open_flags,
- PP_CompletionCallback callback) {
+int32_t PPB_FileIO_Impl::OpenValidated(
+ PP_Resource file_ref_resource,
+ PPB_FileRef_API* file_ref_api,
+ int32_t open_flags,
+ scoped_refptr<TrackedCallback> callback) {
PPB_FileRef_Impl* file_ref = static_cast<PPB_FileRef_Impl*>(file_ref_api);
int flags = 0;
@@ -79,8 +81,9 @@ int32_t PPB_FileIO_Impl::OpenValidated(PP_Resource file_ref_resource,
return PP_OK_COMPLETIONPENDING;
}
-int32_t PPB_FileIO_Impl::QueryValidated(PP_FileInfo* info,
- PP_CompletionCallback callback) {
+int32_t PPB_FileIO_Impl::QueryValidated(
+ PP_FileInfo* info,
+ scoped_refptr<TrackedCallback> callback) {
PluginDelegate* plugin_delegate = GetPluginDelegate();
if (!plugin_delegate)
return PP_ERROR_FAILED;
@@ -95,9 +98,10 @@ int32_t PPB_FileIO_Impl::QueryValidated(PP_FileInfo* info,
return PP_OK_COMPLETIONPENDING;
}
-int32_t PPB_FileIO_Impl::TouchValidated(PP_Time last_access_time,
- PP_Time last_modified_time,
- PP_CompletionCallback callback) {
+int32_t PPB_FileIO_Impl::TouchValidated(
+ PP_Time last_access_time,
+ PP_Time last_modified_time,
+ scoped_refptr<TrackedCallback> callback) {
PluginDelegate* plugin_delegate = GetPluginDelegate();
if (!plugin_delegate)
return PP_ERROR_FAILED;
@@ -114,10 +118,11 @@ int32_t PPB_FileIO_Impl::TouchValidated(PP_Time last_access_time,
return PP_OK_COMPLETIONPENDING;
}
-int32_t PPB_FileIO_Impl::ReadValidated(int64_t offset,
- char* buffer,
- int32_t bytes_to_read,
- PP_CompletionCallback callback) {
+int32_t PPB_FileIO_Impl::ReadValidated(
+ int64_t offset,
+ char* buffer,
+ int32_t bytes_to_read,
+ scoped_refptr<TrackedCallback> callback) {
PluginDelegate* plugin_delegate = GetPluginDelegate();
if (!plugin_delegate)
return PP_ERROR_FAILED;
@@ -133,10 +138,11 @@ int32_t PPB_FileIO_Impl::ReadValidated(int64_t offset,
return PP_OK_COMPLETIONPENDING;
}
-int32_t PPB_FileIO_Impl::WriteValidated(int64_t offset,
- const char* buffer,
- int32_t bytes_to_write,
- PP_CompletionCallback callback) {
+int32_t PPB_FileIO_Impl::WriteValidated(
+ int64_t offset,
+ const char* buffer,
+ int32_t bytes_to_write,
+ scoped_refptr<TrackedCallback> callback) {
PluginDelegate* plugin_delegate = GetPluginDelegate();
if (!plugin_delegate)
return PP_ERROR_FAILED;
@@ -160,8 +166,9 @@ int32_t PPB_FileIO_Impl::WriteValidated(int64_t offset,
return PP_OK_COMPLETIONPENDING;
}
-int32_t PPB_FileIO_Impl::SetLengthValidated(int64_t length,
- PP_CompletionCallback callback) {
+int32_t PPB_FileIO_Impl::SetLengthValidated(
+ int64_t length,
+ scoped_refptr<TrackedCallback> callback) {
PluginDelegate* plugin_delegate = GetPluginDelegate();
if (!plugin_delegate)
return PP_ERROR_FAILED;
@@ -184,7 +191,8 @@ int32_t PPB_FileIO_Impl::SetLengthValidated(int64_t length,
return PP_OK_COMPLETIONPENDING;
}
-int32_t PPB_FileIO_Impl::FlushValidated(PP_CompletionCallback callback) {
+int32_t PPB_FileIO_Impl::FlushValidated(
+ scoped_refptr<TrackedCallback> callback) {
PluginDelegate* plugin_delegate = GetPluginDelegate();
if (!plugin_delegate)
return PP_ERROR_FAILED;
@@ -222,8 +230,8 @@ int32_t PPB_FileIO_Impl::GetOSFileDescriptor() {
int32_t PPB_FileIO_Impl::WillWrite(int64_t offset,
int32_t bytes_to_write,
- PP_CompletionCallback callback) {
- int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback);
+ scoped_refptr<TrackedCallback> callback) {
+ int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE);
if (rv != PP_OK)
return rv;
@@ -240,9 +248,10 @@ int32_t PPB_FileIO_Impl::WillWrite(int64_t offset,
return PP_OK_COMPLETIONPENDING;
}
-int32_t PPB_FileIO_Impl::WillSetLength(int64_t length,
- PP_CompletionCallback callback) {
- int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE, callback);
+int32_t PPB_FileIO_Impl::WillSetLength(
+ int64_t length,
+ scoped_refptr<TrackedCallback> callback) {
+ int32_t rv = CommonCallValidation(true, OPERATION_EXCLUSIVE);
if (rv != PP_OK)
return rv;
diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.h b/webkit/plugins/ppapi/ppb_file_io_impl.h
index 27353c6..2298d87 100644
--- a/webkit/plugins/ppapi/ppb_file_io_impl.h
+++ b/webkit/plugins/ppapi/ppb_file_io_impl.h
@@ -13,8 +13,6 @@
#include "ppapi/shared_impl/ppb_file_io_shared.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
-struct PP_CompletionCallback;
-
namespace webkit {
namespace ppapi {
@@ -29,34 +27,43 @@ class PPB_FileIO_Impl : public ::ppapi::PPB_FileIO_Shared {
// as the "Validated" versions below).
virtual void Close() OVERRIDE;
virtual int32_t GetOSFileDescriptor() OVERRIDE;
- virtual int32_t WillWrite(int64_t offset,
- int32_t bytes_to_write,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t WillSetLength(int64_t length,
- PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t WillWrite(
+ int64_t offset,
+ int32_t bytes_to_write,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual int32_t WillSetLength(
+ int64_t length,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
private:
// FileIOImpl overrides.
- virtual int32_t OpenValidated(PP_Resource file_ref_resource,
- ::ppapi::thunk::PPB_FileRef_API* file_ref_api,
- int32_t open_flags,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t QueryValidated(PP_FileInfo* info,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t TouchValidated(PP_Time last_access_time,
- PP_Time last_modified_time,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t ReadValidated(int64_t offset,
- char* buffer,
- int32_t bytes_to_read,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t WriteValidated(int64_t offset,
- const char* buffer,
- int32_t bytes_to_write,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t SetLengthValidated(int64_t length,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t FlushValidated(PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t OpenValidated(
+ PP_Resource file_ref_resource,
+ ::ppapi::thunk::PPB_FileRef_API* file_ref_api,
+ int32_t open_flags,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual int32_t QueryValidated(
+ PP_FileInfo* info,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual int32_t TouchValidated(
+ PP_Time last_access_time,
+ PP_Time last_modified_time,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual int32_t ReadValidated(
+ int64_t offset,
+ char* buffer,
+ int32_t bytes_to_read,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual int32_t WriteValidated(
+ int64_t offset,
+ const char* buffer,
+ int32_t bytes_to_write,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual int32_t SetLengthValidated(
+ int64_t length,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual int32_t FlushValidated(
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
// Returns the plugin delegate for this resource if it exists, or NULL if it
// doesn't. Calling code should always check for NULL.
diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.cc b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
index 48115e5..a3864f8 100644
--- a/webkit/plugins/ppapi/ppb_file_ref_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
@@ -25,6 +25,7 @@ using ppapi::HostResource;
using ppapi::PPB_FileRef_CreateInfo;
using ppapi::PPTimeToTime;
using ppapi::StringVar;
+using ppapi::TrackedCallback;
using ppapi::thunk::EnterResourceNoLock;
using ppapi::thunk::PPB_FileRef_API;
using ppapi::thunk::PPB_FileSystem_API;
@@ -165,10 +166,9 @@ PP_Resource PPB_FileRef_Impl::GetParent() {
return parent_ref->GetReference();
}
-int32_t PPB_FileRef_Impl::MakeDirectory(PP_Bool make_ancestors,
- PP_CompletionCallback callback) {
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
+int32_t PPB_FileRef_Impl::MakeDirectory(
+ PP_Bool make_ancestors,
+ scoped_refptr<TrackedCallback> callback) {
if (!IsValidNonExternalFileSystem())
return PP_ERROR_NOACCESS;
@@ -184,9 +184,7 @@ int32_t PPB_FileRef_Impl::MakeDirectory(PP_Bool make_ancestors,
int32_t PPB_FileRef_Impl::Touch(PP_Time last_access_time,
PP_Time last_modified_time,
- PP_CompletionCallback callback) {
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
+ scoped_refptr<TrackedCallback> callback) {
if (!IsValidNonExternalFileSystem())
return PP_ERROR_NOACCESS;
@@ -202,9 +200,7 @@ int32_t PPB_FileRef_Impl::Touch(PP_Time last_access_time,
return PP_OK_COMPLETIONPENDING;
}
-int32_t PPB_FileRef_Impl::Delete(PP_CompletionCallback callback) {
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
+int32_t PPB_FileRef_Impl::Delete(scoped_refptr<TrackedCallback> callback) {
if (!IsValidNonExternalFileSystem())
return PP_ERROR_NOACCESS;
@@ -219,9 +215,7 @@ int32_t PPB_FileRef_Impl::Delete(PP_CompletionCallback callback) {
}
int32_t PPB_FileRef_Impl::Rename(PP_Resource new_pp_file_ref,
- PP_CompletionCallback callback) {
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
+ scoped_refptr<TrackedCallback> callback) {
EnterResourceNoLock<PPB_FileRef_API> enter(new_pp_file_ref, true);
if (enter.failed())
return PP_ERROR_BADRESOURCE;
diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.h b/webkit/plugins/ppapi/ppb_file_ref_impl.h
index 91d1551..9b33758 100644
--- a/webkit/plugins/ppapi/ppb_file_ref_impl.h
+++ b/webkit/plugins/ppapi/ppb_file_ref_impl.h
@@ -39,14 +39,18 @@ class PPB_FileRef_Impl : public ::ppapi::PPB_FileRef_Shared {
// PPB_FileRef_API implementation (not provided by PPB_FileRef_Shared).
virtual PP_Resource GetParent() OVERRIDE;
- virtual int32_t MakeDirectory(PP_Bool make_ancestors,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t Touch(PP_Time last_access_time,
- PP_Time last_modified_time,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t Delete(PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t Rename(PP_Resource new_file_ref,
- PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t MakeDirectory(
+ PP_Bool make_ancestors,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual int32_t Touch(
+ PP_Time last_access_time,
+ PP_Time last_modified_time,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual int32_t Delete(
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual int32_t Rename(
+ PP_Resource new_file_ref,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
virtual PP_Var GetAbsolutePath();
PPB_FileSystem_Impl* file_system() const { return file_system_.get(); }
diff --git a/webkit/plugins/ppapi/ppb_file_system_impl.cc b/webkit/plugins/ppapi/ppb_file_system_impl.cc
index 9428e3a..ae9edeb 100644
--- a/webkit/plugins/ppapi/ppb_file_system_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_system_impl.cc
@@ -21,6 +21,7 @@
#include "webkit/plugins/ppapi/resource_helper.h"
using ppapi::thunk::PPB_FileSystem_API;
+using ppapi::TrackedCallback;
namespace webkit {
namespace ppapi {
@@ -52,10 +53,7 @@ PPB_FileSystem_API* PPB_FileSystem_Impl::AsPPB_FileSystem_API() {
}
int32_t PPB_FileSystem_Impl::Open(int64_t expected_size,
- PP_CompletionCallback callback) {
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
-
+ scoped_refptr<TrackedCallback> callback) {
// Should not allow multiple opens.
if (called_open_)
return PP_ERROR_INPROGRESS;
@@ -81,10 +79,10 @@ int32_t PPB_FileSystem_Impl::Open(int64_t expected_size,
return PP_ERROR_FAILED;
if (!plugin_instance->delegate()->OpenFileSystem(
- plugin_instance->container()->element().document().url(),
- file_system_type, expected_size,
- new FileCallbacks(this, callback, NULL,
- scoped_refptr<PPB_FileSystem_Impl>(this), NULL)))
+ plugin_instance->container()->element().document().url(),
+ file_system_type, expected_size,
+ new FileCallbacks(this, callback, NULL,
+ scoped_refptr<PPB_FileSystem_Impl>(this), NULL)))
return PP_ERROR_FAILED;
return PP_OK_COMPLETIONPENDING;
}
diff --git a/webkit/plugins/ppapi/ppb_file_system_impl.h b/webkit/plugins/ppapi/ppb_file_system_impl.h
index c963ce3..7864989 100644
--- a/webkit/plugins/ppapi/ppb_file_system_impl.h
+++ b/webkit/plugins/ppapi/ppb_file_system_impl.h
@@ -33,8 +33,9 @@ class PPB_FileSystem_Impl : public ::ppapi::Resource,
void set_opened(bool opened) { opened_ = opened; }
// PPB_FileSystem_API implementation.
- virtual int32_t Open(int64_t expected_size,
- PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t Open(
+ int64_t expected_size,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
virtual PP_FileSystemType GetType() OVERRIDE;
private:
diff --git a/webkit/plugins/ppapi/ppb_flash_menu_impl.cc b/webkit/plugins/ppapi/ppb_flash_menu_impl.cc
index aa3f768..e0c405e 100644
--- a/webkit/plugins/ppapi/ppb_flash_menu_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_menu_impl.cc
@@ -130,15 +130,12 @@ PPB_Flash_Menu_API* PPB_Flash_Menu_Impl::AsPPB_Flash_Menu_API() {
int32_t PPB_Flash_Menu_Impl::Show(const PP_Point* location,
int32_t* selected_id_out,
- PP_CompletionCallback callback) {
+ scoped_refptr<TrackedCallback> callback) {
// |location| is not (currently) optional.
// TODO(viettrungluu): Make it optional and default to the current mouse pos?
if (!location)
return PP_ERROR_BADARGUMENT;
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
-
if (TrackedCallback::IsPending(callback_))
return PP_ERROR_INPROGRESS;
@@ -150,16 +147,13 @@ int32_t PPB_Flash_Menu_Impl::Show(const PP_Point* location,
plugin_instance, this, gfx::Point(location->x, location->y));
if (rv == PP_OK_COMPLETIONPENDING) {
// Record callback and output buffers.
- callback_ = new TrackedCallback(this, callback);
+ callback_ = callback;
selected_id_out_ = selected_id_out;
} else {
// This should never be completed synchronously successfully.
DCHECK_NE(rv, PP_OK);
}
return rv;
-
- NOTIMPLEMENTED();
- return PP_ERROR_FAILED;
}
void PPB_Flash_Menu_Impl::CompleteShow(int32_t result,
diff --git a/webkit/plugins/ppapi/ppb_flash_menu_impl.h b/webkit/plugins/ppapi/ppb_flash_menu_impl.h
index 92daa64..33ce588 100644
--- a/webkit/plugins/ppapi/ppb_flash_menu_impl.h
+++ b/webkit/plugins/ppapi/ppb_flash_menu_impl.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -34,9 +34,10 @@ class PPB_Flash_Menu_Impl : public ::ppapi::Resource,
virtual ::ppapi::thunk::PPB_Flash_Menu_API* AsPPB_Flash_Menu_API() OVERRIDE;
// PPB_Flash_Menu implementation.
- virtual int32_t Show(const PP_Point* location,
- int32_t* selected_id_out,
- PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t Show(
+ const PP_Point* location,
+ int32_t* selected_id_out,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
// Called to complete |Show()|.
WEBKIT_PLUGINS_EXPORT void CompleteShow(int32_t result, unsigned action);
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index 3a6a1a8..69ac176 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -314,11 +314,8 @@ void PPB_Graphics2D_Impl::ReplaceContents(PP_Resource image_data) {
queued_operations_.push_back(operation);
}
-int32_t PPB_Graphics2D_Impl::Flush(PP_CompletionCallback callback) {
+int32_t PPB_Graphics2D_Impl::Flush(scoped_refptr<TrackedCallback> callback) {
TRACE_EVENT0("pepper", "PPB_Graphics2D_Impl::Flush");
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
-
// Don't allow more than one pending flush at a time.
if (HasPendingFlush())
return PP_ERROR_INPROGRESS;
@@ -374,11 +371,9 @@ int32_t PPB_Graphics2D_Impl::Flush(PP_CompletionCallback callback) {
if (nothing_visible) {
// There's nothing visible to invalidate so just schedule the callback to
// execute in the next round of the message loop.
- ScheduleOffscreenCallback(FlushCallbackData(
- scoped_refptr<TrackedCallback>(new TrackedCallback(this, callback))));
+ ScheduleOffscreenCallback(FlushCallbackData(callback));
} else {
- unpainted_flush_callback_.Set(
- scoped_refptr<TrackedCallback>(new TrackedCallback(this, callback)));
+ unpainted_flush_callback_.Set(callback);
}
return PP_OK_COMPLETIONPENDING;
}
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.h b/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
index 3b8ce9a..69e0f96 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
@@ -49,7 +49,8 @@ class PPB_Graphics2D_Impl : public ::ppapi::Resource,
virtual void Scroll(const PP_Rect* clip_rect,
const PP_Point* amount) OVERRIDE;
virtual void ReplaceContents(PP_Resource image_data) OVERRIDE;
- virtual int32_t Flush(PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t Flush(
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
bool ReadImageData(PP_Resource image, const PP_Point* top_left);
diff --git a/webkit/plugins/ppapi/ppb_layer_compositor_impl.cc b/webkit/plugins/ppapi/ppb_layer_compositor_impl.cc
index 542feb1..32b859a 100644
--- a/webkit/plugins/ppapi/ppb_layer_compositor_impl.cc
+++ b/webkit/plugins/ppapi/ppb_layer_compositor_impl.cc
@@ -5,8 +5,10 @@
#include "webkit/plugins/ppapi/ppb_layer_compositor_impl.h"
#include "ppapi/c/pp_errors.h"
+#include "ppapi/shared_impl/tracked_callback.h"
#include "webkit/plugins/ppapi/common.h"
+using ppapi::TrackedCallback;
using ppapi::thunk::PPB_LayerCompositor_API;
namespace webkit {
@@ -45,7 +47,8 @@ void PPB_LayerCompositor_Impl::SetDisplay(PP_Resource layer,
void PPB_LayerCompositor_Impl::MarkAsDirty(PP_Resource layer) {
}
-int32_t PPB_LayerCompositor_Impl::SwapBuffers(PP_CompletionCallback callback) {
+int32_t PPB_LayerCompositor_Impl::SwapBuffers(
+ scoped_refptr<TrackedCallback> callback) {
return PP_ERROR_FAILED;
}
diff --git a/webkit/plugins/ppapi/ppb_layer_compositor_impl.h b/webkit/plugins/ppapi/ppb_layer_compositor_impl.h
index b1e4cac..1ec1c0d 100644
--- a/webkit/plugins/ppapi/ppb_layer_compositor_impl.h
+++ b/webkit/plugins/ppapi/ppb_layer_compositor_impl.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -33,7 +33,8 @@ class PPB_LayerCompositor_Impl
virtual void SetRect(PP_Resource layer, const PP_Rect* rect) OVERRIDE;
virtual void SetDisplay(PP_Resource layer, PP_Bool is_displayed) OVERRIDE;
virtual void MarkAsDirty(PP_Resource layer) OVERRIDE;
- virtual int32_t SwapBuffers(PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t SwapBuffers(
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(PPB_LayerCompositor_Impl);
diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.cc b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
index 7e4fdef..efb36cc 100644
--- a/webkit/plugins/ppapi/ppb_url_loader_impl.cc
+++ b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
@@ -96,7 +96,7 @@ void PPB_URLLoader_Impl::InstanceWasDeleted() {
}
int32_t PPB_URLLoader_Impl::Open(PP_Resource request_id,
- PP_CompletionCallback callback) {
+ scoped_refptr<TrackedCallback> callback) {
// Main document loads are already open, so don't allow people to open them
// again.
if (main_document_loader_)
@@ -172,7 +172,8 @@ int32_t PPB_URLLoader_Impl::Open(PP_Resource request_id,
return PP_OK_COMPLETIONPENDING;
}
-int32_t PPB_URLLoader_Impl::FollowRedirect(PP_CompletionCallback callback) {
+int32_t PPB_URLLoader_Impl::FollowRedirect(
+ scoped_refptr<TrackedCallback> callback) {
int32_t rv = ValidateCallback(callback);
if (rv != PP_OK)
return rv;
@@ -215,9 +216,10 @@ PP_Resource PPB_URLLoader_Impl::GetResponseInfo() {
return response_info_->GetReference();
}
-int32_t PPB_URLLoader_Impl::ReadResponseBody(void* buffer,
- int32_t bytes_to_read,
- PP_CompletionCallback callback) {
+int32_t PPB_URLLoader_Impl::ReadResponseBody(
+ void* buffer,
+ int32_t bytes_to_read,
+ scoped_refptr<TrackedCallback> callback) {
int32_t rv = ValidateCallback(callback);
if (rv != PP_OK)
return rv;
@@ -244,7 +246,7 @@ int32_t PPB_URLLoader_Impl::ReadResponseBody(void* buffer,
}
int32_t PPB_URLLoader_Impl::FinishStreamingToFile(
- PP_CompletionCallback callback) {
+ scoped_refptr<TrackedCallback> callback) {
int32_t rv = ValidateCallback(callback);
if (rv != PP_OK)
return rv;
@@ -395,10 +397,9 @@ void PPB_URLLoader_Impl::FinishLoading(int32_t done_status) {
RunCallback(done_status_);
}
-int32_t PPB_URLLoader_Impl::ValidateCallback(PP_CompletionCallback callback) {
- // We only support non-blocking calls.
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
+int32_t PPB_URLLoader_Impl::ValidateCallback(
+ scoped_refptr<TrackedCallback> callback) {
+ DCHECK(callback);
if (TrackedCallback::IsPending(pending_callback_))
return PP_ERROR_INPROGRESS;
@@ -406,15 +407,15 @@ int32_t PPB_URLLoader_Impl::ValidateCallback(PP_CompletionCallback callback) {
return PP_OK;
}
-void PPB_URLLoader_Impl::RegisterCallback(PP_CompletionCallback callback) {
- DCHECK(callback.func);
+void PPB_URLLoader_Impl::RegisterCallback(
+ scoped_refptr<TrackedCallback> callback) {
DCHECK(!TrackedCallback::IsPending(pending_callback_));
PluginModule* plugin_module = ResourceHelper::GetPluginModule(this);
if (!plugin_module)
return;
- pending_callback_ = new TrackedCallback(this, callback);
+ pending_callback_ = callback;
}
void PPB_URLLoader_Impl::RunCallback(int32_t result) {
diff --git a/webkit/plugins/ppapi/ppb_url_loader_impl.h b/webkit/plugins/ppapi/ppb_url_loader_impl.h
index 948f928..38a1b52 100644
--- a/webkit/plugins/ppapi/ppb_url_loader_impl.h
+++ b/webkit/plugins/ppapi/ppb_url_loader_impl.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -39,20 +39,23 @@ class PPB_URLLoader_Impl : public ::ppapi::Resource,
virtual void InstanceWasDeleted() OVERRIDE;
// PPB_URLLoader_API implementation.
- virtual int32_t Open(PP_Resource request_id,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t FollowRedirect(PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t Open(
+ PP_Resource request_id,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual int32_t FollowRedirect(
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
virtual PP_Bool GetUploadProgress(int64_t* bytes_sent,
int64_t* total_bytes_to_be_sent) OVERRIDE;
virtual PP_Bool GetDownloadProgress(
int64_t* bytes_received,
int64_t* total_bytes_to_be_received) OVERRIDE;
virtual PP_Resource GetResponseInfo() OVERRIDE;
- virtual int32_t ReadResponseBody(void* buffer,
- int32_t bytes_to_read,
- PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t ReadResponseBody(
+ void* buffer,
+ int32_t bytes_to_read,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
virtual int32_t FinishStreamingToFile(
- PP_CompletionCallback callback) OVERRIDE;
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
virtual void Close() OVERRIDE;
virtual void GrantUniversalAccess() OVERRIDE;
virtual void SetStatusCallback(
@@ -89,11 +92,11 @@ class PPB_URLLoader_Impl : public ::ppapi::Resource,
// Check that |callback| is valid (only non-blocking operation is supported)
// and that no callback is already pending. Returns |PP_OK| if okay, else
// |PP_ERROR_...| to be returned to the plugin.
- int32_t ValidateCallback(PP_CompletionCallback callback);
+ int32_t ValidateCallback(scoped_refptr< ::ppapi::TrackedCallback> callback);
// Sets up |callback| as the pending callback. This should only be called once
// it is certain that |PP_OK_COMPLETIONPENDING| will be returned.
- void RegisterCallback(PP_CompletionCallback callback);
+ void RegisterCallback(scoped_refptr< ::ppapi::TrackedCallback> callback);
void RunCallback(int32_t result);
diff --git a/webkit/plugins/ppapi/ppb_video_capture_impl.cc b/webkit/plugins/ppapi/ppb_video_capture_impl.cc
index 9a00155..40612f0 100644
--- a/webkit/plugins/ppapi/ppb_video_capture_impl.cc
+++ b/webkit/plugins/ppapi/ppb_video_capture_impl.cc
@@ -173,13 +173,13 @@ void PPB_VideoCapture_Impl::OnInitialized(media::VideoCapture* capture,
int32_t PPB_VideoCapture_Impl::InternalEnumerateDevices(
PP_Resource* devices,
- const PP_CompletionCallback& callback) {
+ scoped_refptr<TrackedCallback> callback) {
PluginInstance* instance = ResourceHelper::GetPluginInstance(this);
if (!instance)
return PP_ERROR_FAILED;
devices_ = devices;
- enumerate_devices_callback_ = new TrackedCallback(this, callback);
+ enumerate_devices_callback_ = callback;
instance->delegate()->EnumerateDevices(
PP_DEVICETYPE_DEV_VIDEOCAPTURE,
base::Bind(&PPB_VideoCapture_Impl::EnumerateDevicesCallbackFunc,
@@ -191,13 +191,10 @@ int32_t PPB_VideoCapture_Impl::InternalOpen(
const std::string& device_id,
const PP_VideoCaptureDeviceInfo_Dev& requested_info,
uint32_t buffer_count,
- const PP_CompletionCallback& callback) {
+ scoped_refptr<TrackedCallback> callback) {
// It is able to complete synchronously if the default device is used.
bool sync_completion = device_id.empty();
- if (!callback.func && !sync_completion)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
-
PluginInstance* instance = ResourceHelper::GetPluginInstance(this);
if (!instance)
return PP_ERROR_FAILED;
@@ -212,7 +209,7 @@ int32_t PPB_VideoCapture_Impl::InternalOpen(
OnInitialized(platform_video_capture_.get(), true);
return PP_OK;
} else {
- open_callback_ = new TrackedCallback(this, callback);
+ open_callback_ = callback;
return PP_OK_COMPLETIONPENDING;
}
}
diff --git a/webkit/plugins/ppapi/ppb_video_capture_impl.h b/webkit/plugins/ppapi/ppb_video_capture_impl.h
index 8c77138..06e63aa 100644
--- a/webkit/plugins/ppapi/ppb_video_capture_impl.h
+++ b/webkit/plugins/ppapi/ppb_video_capture_impl.h
@@ -54,12 +54,12 @@ class PPB_VideoCapture_Impl
// PPB_VideoCapture_Shared implementation.
virtual int32_t InternalEnumerateDevices(
PP_Resource* devices,
- const PP_CompletionCallback& callback) OVERRIDE;
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
virtual int32_t InternalOpen(
const std::string& device_id,
const PP_VideoCaptureDeviceInfo_Dev& requested_info,
uint32_t buffer_count,
- const PP_CompletionCallback& callback) OVERRIDE;
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
virtual int32_t InternalStartCapture() OVERRIDE;
virtual int32_t InternalReuseBuffer(uint32_t buffer) OVERRIDE;
virtual int32_t InternalStopCapture() OVERRIDE;
diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
index ab0773c..9c63e13 100644
--- a/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
+++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
@@ -24,6 +24,7 @@
#include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
#include "webkit/plugins/ppapi/resource_helper.h"
+using ppapi::TrackedCallback;
using ppapi::thunk::EnterResourceNoLock;
using ppapi::thunk::PPB_Buffer_API;
using ppapi::thunk::PPB_Graphics3D_API;
@@ -126,10 +127,7 @@ bool PPB_VideoDecoder_Impl::Init(
int32_t PPB_VideoDecoder_Impl::Decode(
const PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
- PP_CompletionCallback callback) {
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
-
+ scoped_refptr<TrackedCallback> callback) {
if (!platform_video_decoder_)
return PP_ERROR_BADRESOURCE;
@@ -178,10 +176,7 @@ void PPB_VideoDecoder_Impl::ReusePictureBuffer(int32_t picture_buffer_id) {
platform_video_decoder_->ReusePictureBuffer(picture_buffer_id);
}
-int32_t PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) {
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
-
+int32_t PPB_VideoDecoder_Impl::Flush(scoped_refptr<TrackedCallback> callback) {
if (!platform_video_decoder_)
return PP_ERROR_BADRESOURCE;
@@ -193,10 +188,7 @@ int32_t PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback callback) {
return PP_OK_COMPLETIONPENDING;
}
-int32_t PPB_VideoDecoder_Impl::Reset(PP_CompletionCallback callback) {
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
-
+int32_t PPB_VideoDecoder_Impl::Reset(scoped_refptr<TrackedCallback> callback) {
if (!platform_video_decoder_)
return PP_ERROR_BADRESOURCE;
diff --git a/webkit/plugins/ppapi/ppb_video_decoder_impl.h b/webkit/plugins/ppapi/ppb_video_decoder_impl.h
index 895874b3..f82f702 100644
--- a/webkit/plugins/ppapi/ppb_video_decoder_impl.h
+++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.h
@@ -39,13 +39,16 @@ class PPB_VideoDecoder_Impl : public ::ppapi::PPB_VideoDecoder_Shared,
PP_VideoDecoder_Profile profile);
// PPB_VideoDecoder_API implementation.
- virtual int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
- PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t Decode(
+ const PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
virtual void AssignPictureBuffers(
uint32_t no_of_buffers, const PP_PictureBuffer_Dev* buffers) OVERRIDE;
virtual void ReusePictureBuffer(int32_t picture_buffer_id) OVERRIDE;
- virtual int32_t Flush(PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t Reset(PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t Flush(
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual int32_t Reset(
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
virtual void Destroy() OVERRIDE;
// media::VideoDecodeAccelerator::Client implementation.
diff --git a/webkit/plugins/ppapi/ppb_websocket_impl.cc b/webkit/plugins/ppapi/ppb_websocket_impl.cc
index 8cdada8..bc9fae4 100644
--- a/webkit/plugins/ppapi/ppb_websocket_impl.cc
+++ b/webkit/plugins/ppapi/ppb_websocket_impl.cc
@@ -107,7 +107,7 @@ PPB_WebSocket_API* PPB_WebSocket_Impl::AsPPB_WebSocket_API() {
int32_t PPB_WebSocket_Impl::Connect(PP_Var url,
const PP_Var protocols[],
uint32_t protocol_count,
- PP_CompletionCallback callback) {
+ scoped_refptr<TrackedCallback> callback) {
// Check mandatory interfaces.
PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
DCHECK(plugin_instance);
@@ -181,10 +181,6 @@ int32_t PPB_WebSocket_Impl::Connect(PP_Var url,
}
WebString web_protocols = WebString::fromUTF8(protocol_string);
- // Validate |callback| (Doesn't support blocking callback)
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
-
// Create WebKit::WebSocket object and connect.
WebDocument document = plugin_instance->container()->element().document();
websocket_.reset(WebSocket::create(document, this));
@@ -199,14 +195,14 @@ int32_t PPB_WebSocket_Impl::Connect(PP_Var url,
state_ = PP_WEBSOCKETREADYSTATE_CONNECTING;
// Install callback.
- connect_callback_ = new TrackedCallback(this, callback);
+ connect_callback_ = callback;
return PP_OK_COMPLETIONPENDING;
}
int32_t PPB_WebSocket_Impl::Close(uint16_t code,
PP_Var reason,
- PP_CompletionCallback callback) {
+ scoped_refptr<TrackedCallback> callback) {
// Check mandarory interfaces.
if (!websocket_.get())
return PP_ERROR_FAILED;
@@ -248,12 +244,8 @@ int32_t PPB_WebSocket_Impl::Close(uint16_t code,
if (state_ == PP_WEBSOCKETREADYSTATE_CLOSED)
return PP_OK;
- // Validate |callback| (Doesn't support blocking callback)
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
-
// Install |callback|.
- close_callback_ = new TrackedCallback(this, callback);
+ close_callback_ = callback;
// Abort ongoing connect.
if (state_ == PP_WEBSOCKETREADYSTATE_CONNECTING) {
@@ -283,8 +275,9 @@ int32_t PPB_WebSocket_Impl::Close(uint16_t code,
return PP_OK_COMPLETIONPENDING;
}
-int32_t PPB_WebSocket_Impl::ReceiveMessage(PP_Var* message,
- PP_CompletionCallback callback) {
+int32_t PPB_WebSocket_Impl::ReceiveMessage(
+ PP_Var* message,
+ scoped_refptr<TrackedCallback> callback) {
// Check state.
if (state_ == PP_WEBSOCKETREADYSTATE_INVALID ||
state_ == PP_WEBSOCKETREADYSTATE_CONNECTING)
@@ -305,14 +298,10 @@ int32_t PPB_WebSocket_Impl::ReceiveMessage(PP_Var* message,
if (error_was_received_)
return PP_ERROR_FAILED;
- // Validate |callback| (Doesn't support blocking callback)
- if (!callback.func)
- return PP_ERROR_BLOCKS_MAIN_THREAD;
-
// Or retain |message| as buffer to store and install |callback|.
wait_for_receive_ = true;
receive_callback_var_ = message;
- receive_callback_ = new TrackedCallback(this, callback);
+ receive_callback_ = callback;
return PP_OK_COMPLETIONPENDING;
}
diff --git a/webkit/plugins/ppapi/ppb_websocket_impl.h b/webkit/plugins/ppapi/ppb_websocket_impl.h
index 765e6c9..0bdaf4b 100644
--- a/webkit/plugins/ppapi/ppb_websocket_impl.h
+++ b/webkit/plugins/ppapi/ppb_websocket_impl.h
@@ -39,15 +39,18 @@ class PPB_WebSocket_Impl : public ::ppapi::Resource,
virtual ::ppapi::thunk::PPB_WebSocket_API* AsPPB_WebSocket_API() OVERRIDE;
// PPB_WebSocket_API implementation.
- virtual int32_t Connect(PP_Var url,
- const PP_Var protocols[],
- uint32_t protocol_count,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t Close(uint16_t code,
- PP_Var reason,
- PP_CompletionCallback callback) OVERRIDE;
- virtual int32_t ReceiveMessage(PP_Var* message,
- PP_CompletionCallback callback) OVERRIDE;
+ virtual int32_t Connect(
+ PP_Var url,
+ const PP_Var protocols[],
+ uint32_t protocol_count,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual int32_t Close(
+ uint16_t code,
+ PP_Var reason,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
+ virtual int32_t ReceiveMessage(
+ PP_Var* message,
+ scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
virtual int32_t SendMessage(PP_Var message) OVERRIDE;
virtual uint64_t GetBufferedAmount() OVERRIDE;
virtual uint16_t GetCloseCode() OVERRIDE;