summaryrefslogtreecommitdiffstats
path: root/webkit/plugins/ppapi
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/plugins/ppapi')
-rw-r--r--webkit/plugins/ppapi/callbacks.cc8
-rw-r--r--webkit/plugins/ppapi/callbacks.h2
-rw-r--r--webkit/plugins/ppapi/message_channel.cc15
-rw-r--r--webkit/plugins/ppapi/message_channel.h5
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.cc6
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.h6
-rw-r--r--webkit/plugins/ppapi/plugin_delegate.h27
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc3
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc5
-rw-r--r--webkit/plugins/ppapi/ppb_context_3d_impl.cc6
-rw-r--r--webkit/plugins/ppapi/ppb_context_3d_impl.h4
-rw-r--r--webkit/plugins/ppapi/ppb_file_io_impl.cc12
-rw-r--r--webkit/plugins/ppapi/ppb_file_io_impl.h3
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc10
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.h3
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_3d_impl.cc15
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_3d_impl.h5
-rw-r--r--webkit/plugins/ppapi/ppb_scrollbar_impl.cc13
-rw-r--r--webkit/plugins/ppapi/ppb_scrollbar_impl.h3
-rw-r--r--webkit/plugins/ppapi/ppb_surface_3d_impl.cc8
-rw-r--r--webkit/plugins/ppapi/ppb_surface_3d_impl.h2
-rw-r--r--webkit/plugins/ppapi/quota_file_io.cc7
-rw-r--r--webkit/plugins/ppapi/quota_file_io.h2
-rw-r--r--webkit/plugins/ppapi/quota_file_io_unittest.cc21
24 files changed, 111 insertions, 80 deletions
diff --git a/webkit/plugins/ppapi/callbacks.cc b/webkit/plugins/ppapi/callbacks.cc
index 69cd2e8..84fffd0 100644
--- a/webkit/plugins/ppapi/callbacks.cc
+++ b/webkit/plugins/ppapi/callbacks.cc
@@ -6,6 +6,7 @@
#include <algorithm>
+#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/message_loop.h"
@@ -95,10 +96,11 @@ void TrackedCallback::PostAbort() {
if (!completed()) {
aborted_ = true;
// Post a task for the abort (only if necessary).
- if (abort_impl_factory_.empty()) {
+ if (!abort_impl_factory_.HasWeakPtrs()) {
MessageLoop::current()->PostTask(
FROM_HERE,
- abort_impl_factory_.NewRunnableMethod(&TrackedCallback::AbortImpl));
+ base::Bind(&TrackedCallback::AbortImpl,
+ abort_impl_factory_.GetWeakPtr()));
}
}
}
@@ -132,7 +134,7 @@ TrackedCompletionCallback::TrackedCompletionCallback(
void TrackedCompletionCallback::Run(int32_t result) {
if (!completed()) {
// Cancel any pending calls.
- abort_impl_factory_.RevokeAll();
+ abort_impl_factory_.InvalidateWeakPtrs();
// Copy |callback_| and look at |aborted()| now, since |MarkAsCompleted()|
// may delete us.
diff --git a/webkit/plugins/ppapi/callbacks.h b/webkit/plugins/ppapi/callbacks.h
index 99e8e1e..5fbee60 100644
--- a/webkit/plugins/ppapi/callbacks.h
+++ b/webkit/plugins/ppapi/callbacks.h
@@ -163,7 +163,7 @@ class TrackedCallback : public base::RefCountedThreadSafe<TrackedCallback> {
// Factory used by |PostAbort()|. Note that it's safe to cancel any pending
// posted aborts on destruction -- before it's destroyed, the "owning"
// |CallbackTracker| must have gone through and done (synchronous) |Abort()|s.
- ScopedRunnableMethodFactory<TrackedCallback> abort_impl_factory_;
+ base::WeakPtrFactory<TrackedCallback> abort_impl_factory_;
private:
scoped_refptr<CallbackTracker> tracker_;
diff --git a/webkit/plugins/ppapi/message_channel.cc b/webkit/plugins/ppapi/message_channel.cc
index 33eacfa..e49ada6 100644
--- a/webkit/plugins/ppapi/message_channel.cc
+++ b/webkit/plugins/ppapi/message_channel.cc
@@ -7,6 +7,7 @@
#include <cstdlib>
#include <string>
+#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
@@ -284,7 +285,7 @@ MessageChannel::MessageChannel(PluginInstance* instance)
: instance_(instance),
passthrough_object_(NULL),
np_object_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
VOID_TO_NPVARIANT(onmessage_invoker_);
// Now create an NPObject for receiving calls to postMessage. This sets the
@@ -347,9 +348,9 @@ void MessageChannel::PostMessageToJavaScript(PP_Var message_data) {
MessageLoop::current()->PostTask(
FROM_HERE,
- method_factory_.NewRunnableMethod(
- &MessageChannel::PostMessageToJavaScriptImpl,
- var_copy));
+ base::Bind(&MessageChannel::PostMessageToJavaScriptImpl,
+ weak_ptr_factory_.GetWeakPtr(),
+ var_copy));
}
void MessageChannel::PostMessageToJavaScriptImpl(PP_Var message_data) {
@@ -396,9 +397,9 @@ void MessageChannel::PostMessageToNative(PP_Var message_data) {
PP_Var var_copy(CopyPPVar(message_data));
MessageLoop::current()->PostTask(FROM_HERE,
- method_factory_.NewRunnableMethod(
- &MessageChannel::PostMessageToNativeImpl,
- var_copy));
+ base::Bind(&MessageChannel::PostMessageToNativeImpl,
+ weak_ptr_factory_.GetWeakPtr(),
+ var_copy));
}
void MessageChannel::PostMessageToNativeImpl(PP_Var message_data) {
diff --git a/webkit/plugins/ppapi/message_channel.h b/webkit/plugins/ppapi/message_channel.h
index c6470c4..d7979f1 100644
--- a/webkit/plugins/ppapi/message_channel.h
+++ b/webkit/plugins/ppapi/message_channel.h
@@ -96,8 +96,9 @@ class MessageChannel {
// channel's instance. This is used by PostMessageToNative.
void PostMessageToNativeImpl(PP_Var message_data);
- // Ensure pending tasks will not fire after this object is destroyed.
- ScopedRunnableMethodFactory<MessageChannel> method_factory_;
+ // This is used to ensure pending tasks will not fire after this object is
+ // destroyed.
+ base::WeakPtrFactory<MessageChannel> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(MessageChannel);
};
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc
index cd43087..7725db3 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.cc
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc
@@ -85,12 +85,12 @@ bool MockPluginDelegate::RunFileChooser(
bool MockPluginDelegate::AsyncOpenFile(const FilePath& path,
int flags,
- AsyncOpenFileCallback* callback) {
+ const AsyncOpenFileCallback& callback) {
return false;
}
bool MockPluginDelegate::AsyncOpenFileSystemURL(
- const GURL& path, int flags, AsyncOpenFileCallback* callback) {
+ const GURL& path, int flags, const AsyncOpenFileCallback& callback) {
return false;
}
@@ -144,7 +144,7 @@ bool MockPluginDelegate::ReadDirectory(
void MockPluginDelegate::QueryAvailableSpace(
const GURL& origin, quota::StorageType type,
- AvailableSpaceCallback* callback) {
+ const AvailableSpaceCallback& callback) {
}
void MockPluginDelegate::WillUpdateFile(const GURL& file_path) {
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h
index d96b860..75f5de1 100644
--- a/webkit/plugins/ppapi/mock_plugin_delegate.h
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.h
@@ -40,10 +40,10 @@ class MockPluginDelegate : public PluginDelegate {
WebKit::WebFileChooserCompletion* chooser_completion);
virtual bool AsyncOpenFile(const FilePath& path,
int flags,
- AsyncOpenFileCallback* callback);
+ const AsyncOpenFileCallback& callback);
virtual bool AsyncOpenFileSystemURL(const GURL& path,
int flags,
- AsyncOpenFileCallback* callback);
+ const AsyncOpenFileCallback& callback);
virtual bool OpenFileSystem(
const GURL& url,
fileapi::FileSystemType type,
@@ -69,7 +69,7 @@ class MockPluginDelegate : public PluginDelegate {
fileapi::FileSystemCallbackDispatcher* dispatcher);
virtual void QueryAvailableSpace(const GURL& origin,
quota::StorageType type,
- AvailableSpaceCallback* callback);
+ const AvailableSpaceCallback& callback);
virtual void WillUpdateFile(const GURL& file_path);
virtual void DidUpdateFile(const GURL& file_path, int64_t delta);
virtual base::PlatformFileError OpenFile(const PepperFilePath& path,
diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h
index f69bf24..0a7e47f 100644
--- a/webkit/plugins/ppapi/plugin_delegate.h
+++ b/webkit/plugins/ppapi/plugin_delegate.h
@@ -7,7 +7,7 @@
#include <string>
-#include "base/callback_old.h"
+#include "base/callback.h"
#include "base/message_loop_proxy.h"
#include "base/memory/ref_counted.h"
#include "base/platform_file.h"
@@ -181,11 +181,11 @@ class PluginDelegate {
// Set an optional callback that will be invoked when the context is lost
// (e.g. gpu process crash). Takes ownership of the callback.
- virtual void SetContextLostCallback(Callback0::Type* callback) = 0;
+ virtual void SetContextLostCallback(
+ const base::Callback<void()>& callback) = 0;
- // Run the task once the channel has been flushed. Takes care of deleting
- // the task whether the echo succeeds or not.
- virtual bool Echo(Task* task) = 0;
+ // Run the callback once the channel has been flushed.
+ virtual bool Echo(const base::Callback<void()>& callback) = 0;
};
class PlatformAudio {
@@ -306,14 +306,15 @@ class PluginDelegate {
WebKit::WebFileChooserCompletion* chooser_completion) = 0;
// Sends an async IPC to open a file.
- typedef Callback2<base::PlatformFileError, base::PassPlatformFile
- >::Type AsyncOpenFileCallback;
+ typedef base::Callback<void (base::PlatformFileError, base::PassPlatformFile)>
+ AsyncOpenFileCallback;
virtual bool AsyncOpenFile(const FilePath& path,
int flags,
- AsyncOpenFileCallback* callback) = 0;
- virtual bool AsyncOpenFileSystemURL(const GURL& path,
- int flags,
- AsyncOpenFileCallback* callback) = 0;
+ const AsyncOpenFileCallback& callback) = 0;
+ virtual bool AsyncOpenFileSystemURL(
+ const GURL& path,
+ int flags,
+ const AsyncOpenFileCallback& callback) = 0;
virtual bool OpenFileSystem(
const GURL& url,
@@ -346,10 +347,10 @@ class PluginDelegate {
virtual void PublishPolicy(const std::string& policy_json) = 0;
// For quota handlings for FileIO API.
- typedef Callback1<int64>::Type AvailableSpaceCallback;
+ typedef base::Callback<void (int64)> AvailableSpaceCallback;
virtual void QueryAvailableSpace(const GURL& origin,
quota::StorageType type,
- AvailableSpaceCallback* callback) = 0;
+ const AvailableSpaceCallback& callback) = 0;
virtual void WillUpdateFile(const GURL& file_path) = 0;
virtual void DidUpdateFile(const GURL& file_path, int64_t delta) = 0;
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 43fbd6f..b7877e7 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -6,6 +6,7 @@
#include <set>
+#include "base/bind.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -163,7 +164,7 @@ void CallOnMainThread(int delay_in_msec,
if (callback.func) {
GetMainThreadMessageLoop()->PostDelayedTask(
FROM_HERE,
- NewRunnableFunction(callback.func, callback.user_data, result),
+ base::Bind(callback.func, callback.user_data, result),
delay_in_msec);
}
}
diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index 6df29ee..da85c07 100644
--- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -4,6 +4,7 @@
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+#include "base/bind.h"
#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -977,7 +978,7 @@ bool PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) {
ReportGeometry();
} else {
MessageLoop::current()->PostTask(
- FROM_HERE, NewRunnableMethod(this, &PluginInstance::ReportGeometry));
+ FROM_HERE, base::Bind(&PluginInstance::ReportGeometry, this));
}
return true;
}
@@ -1007,7 +1008,7 @@ void PluginInstance::FlashSetFullscreen(bool fullscreen, bool delay_report) {
ReportGeometry();
} else {
MessageLoop::current()->PostTask(
- FROM_HERE, NewRunnableMethod(this, &PluginInstance::ReportGeometry));
+ FROM_HERE, base::Bind(&PluginInstance::ReportGeometry, this));
}
}
}
diff --git a/webkit/plugins/ppapi/ppb_context_3d_impl.cc b/webkit/plugins/ppapi/ppb_context_3d_impl.cc
index 544adbb..5acf56c 100644
--- a/webkit/plugins/ppapi/ppb_context_3d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_context_3d_impl.cc
@@ -4,6 +4,7 @@
#include "webkit/plugins/ppapi/ppb_context_3d_impl.h"
+#include "base/bind.h"
#include "base/logging.h"
#include "base/shared_memory.h"
#include "gpu/command_buffer/client/gles2_cmd_helper.h"
@@ -72,7 +73,7 @@ PPB_Context3D_Impl::PPB_Context3D_Impl(PP_Instance instance)
transfer_buffer_id_(0),
draw_surface_(NULL),
read_surface_(NULL),
- callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+ weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
}
PPB_Context3D_Impl::~PPB_Context3D_Impl() {
@@ -304,7 +305,8 @@ bool PPB_Context3D_Impl::InitRaw(PP_Config3D_Dev config,
}
platform_context_->SetContextLostCallback(
- callback_factory_.NewCallback(&PPB_Context3D_Impl::OnContextLost));
+ base::Bind(&PPB_Context3D_Impl::OnContextLost,
+ weak_ptr_factory_.GetWeakPtr()));
return true;
}
diff --git a/webkit/plugins/ppapi/ppb_context_3d_impl.h b/webkit/plugins/ppapi/ppb_context_3d_impl.h
index 5b56482..66f23e2 100644
--- a/webkit/plugins/ppapi/ppb_context_3d_impl.h
+++ b/webkit/plugins/ppapi/ppb_context_3d_impl.h
@@ -5,8 +5,8 @@
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_CONTEXT_3D_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_CONTEXT_3D_IMPL_H_
-#include "base/memory/scoped_callback_factory.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "ppapi/shared_impl/resource.h"
#include "ppapi/thunk/ppb_context_3d_api.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
@@ -110,7 +110,7 @@ class PPB_Context3D_Impl : public ::ppapi::Resource,
PPB_Surface3D_Impl* draw_surface_;
PPB_Surface3D_Impl* read_surface_;
- base::ScopedCallbackFactory<PPB_Context3D_Impl> callback_factory_;
+ base::WeakPtrFactory<PPB_Context3D_Impl> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(PPB_Context3D_Impl);
};
diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.cc b/webkit/plugins/ppapi/ppb_file_io_impl.cc
index 1460b27..213071e 100644
--- a/webkit/plugins/ppapi/ppb_file_io_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_io_impl.cc
@@ -4,6 +4,7 @@
#include "webkit/plugins/ppapi/ppb_file_io_impl.h"
+#include "base/bind.h"
#include "base/callback.h"
#include "base/file_util.h"
#include "base/file_util_proxy.h"
@@ -54,7 +55,8 @@ PPB_FileIO_Impl::PPB_FileIO_Impl(PP_Instance instance)
file_(base::kInvalidPlatformFileValue),
file_system_type_(PP_FILESYSTEMTYPE_INVALID),
pending_op_(OPERATION_NONE),
- info_(NULL) {
+ info_(NULL),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
}
PPB_FileIO_Impl::~PPB_FileIO_Impl() {
@@ -95,16 +97,16 @@ int32_t PPB_FileIO_Impl::Open(PP_Resource pp_file_ref,
file_system_url_ = file_ref->GetFileSystemURL();
if (!plugin_delegate->AsyncOpenFileSystemURL(
file_system_url_, flags,
- callback_factory_.NewCallback(
- &PPB_FileIO_Impl::AsyncOpenFileCallback)))
+ base::Bind(&PPB_FileIO_Impl::AsyncOpenFileCallback,
+ weak_ptr_factory_.GetWeakPtr())))
return PP_ERROR_FAILED;
} else {
if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL)
return PP_ERROR_FAILED;
if (!plugin_delegate->AsyncOpenFile(
file_ref->GetSystemPath(), flags,
- callback_factory_.NewCallback(
- &PPB_FileIO_Impl::AsyncOpenFileCallback)))
+ base::Bind(&PPB_FileIO_Impl::AsyncOpenFileCallback,
+ weak_ptr_factory_.GetWeakPtr())))
return PP_ERROR_FAILED;
}
diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.h b/webkit/plugins/ppapi/ppb_file_io_impl.h
index 5da3aeb..ec55fb5 100644
--- a/webkit/plugins/ppapi/ppb_file_io_impl.h
+++ b/webkit/plugins/ppapi/ppb_file_io_impl.h
@@ -12,6 +12,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_callback_factory.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/platform_file.h"
#include "ppapi/c/pp_file_info.h"
#include "ppapi/c/pp_time.h"
@@ -143,6 +144,8 @@ class PPB_FileIO_Impl : public ::ppapi::Resource,
// of type PP_FILESYSTEMTYPE_LOCAL{PERSISTENT,TEMPORARY} is opened.
scoped_ptr<QuotaFileIO> quota_file_io_;
+ base::WeakPtrFactory<PPB_FileIO_Impl> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Impl);
};
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index bbef628..a6c12a8 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -6,6 +6,7 @@
#include <iterator>
+#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/task.h"
@@ -155,7 +156,8 @@ PPB_Graphics2D_Impl::PPB_Graphics2D_Impl(PP_Instance instance)
: Resource(instance),
bound_instance_(NULL),
offscreen_flush_pending_(false),
- is_always_opaque_(false) {
+ is_always_opaque_(false),
+ weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
}
PPB_Graphics2D_Impl::~PPB_Graphics2D_Impl() {
@@ -622,9 +624,9 @@ void PPB_Graphics2D_Impl::ScheduleOffscreenCallback(
offscreen_flush_pending_ = true;
MessageLoop::current()->PostTask(
FROM_HERE,
- NewRunnableMethod(this,
- &PPB_Graphics2D_Impl::ExecuteOffscreenCallback,
- callback));
+ base::Bind(&PPB_Graphics2D_Impl::ExecuteOffscreenCallback,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback));
}
void PPB_Graphics2D_Impl::ExecuteOffscreenCallback(FlushCallbackData data) {
diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.h b/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
index fc36f18..f100f67 100644
--- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
@@ -8,6 +8,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/memory/weak_ptr.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/ppb_graphics_2d.h"
#include "ppapi/shared_impl/resource.h"
@@ -174,6 +175,8 @@ class PPB_Graphics2D_Impl : public ::ppapi::Resource,
// This allows us to do more optimized painting in some cases.
bool is_always_opaque_;
+ base::WeakPtrFactory<PPB_Graphics2D_Impl> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(PPB_Graphics2D_Impl);
};
diff --git a/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
index cdd7d6c7..1e26319 100644
--- a/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
@@ -4,6 +4,7 @@
#include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
+#include "base/bind.h"
#include "base/message_loop.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "webkit/plugins/ppapi/plugin_module.h"
@@ -54,8 +55,7 @@ PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PP_Instance instance)
: Resource(instance),
bound_to_instance_(false),
commit_pending_(false),
- callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
- method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+ weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
}
PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() {
@@ -165,8 +165,8 @@ int32 PPB_Graphics3D_Impl::DoSwapBuffers() {
if (gles2_impl())
gles2_impl()->SwapBuffers();
- platform_context_->Echo(method_factory_.NewRunnableMethod(
- &PPB_Graphics3D_Impl::OnSwapBuffers));
+ platform_context_->Echo(base::Bind(&PPB_Graphics3D_Impl::OnSwapBuffers,
+ weak_ptr_factory_.GetWeakPtr()));
return PP_OK_COMPLETIONPENDING;
}
@@ -202,7 +202,8 @@ bool PPB_Graphics3D_Impl::InitRaw(PP_Resource share_context,
return false;
platform_context_->SetContextLostCallback(
- callback_factory_.NewCallback(&PPB_Graphics3D_Impl::OnContextLost));
+ base::Bind(&PPB_Graphics3D_Impl::OnContextLost,
+ weak_ptr_factory_.GetWeakPtr()));
return true;
}
@@ -233,8 +234,8 @@ void PPB_Graphics3D_Impl::OnContextLost() {
// Send context lost to plugin. This may have been caused by a PPAPI call, so
// avoid re-entering.
- MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
- this, &PPB_Graphics3D_Impl::SendContextLost));
+ MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
+ &PPB_Graphics3D_Impl::SendContextLost, weak_ptr_factory_.GetWeakPtr()));
}
void PPB_Graphics3D_Impl::SendContextLost() {
diff --git a/webkit/plugins/ppapi/ppb_graphics_3d_impl.h b/webkit/plugins/ppapi/ppb_graphics_3d_impl.h
index 5029b91..250911b 100644
--- a/webkit/plugins/ppapi/ppb_graphics_3d_impl.h
+++ b/webkit/plugins/ppapi/ppb_graphics_3d_impl.h
@@ -5,7 +5,7 @@
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_
-#include "base/memory/scoped_callback_factory.h"
+#include "base/memory/weak_ptr.h"
#include "ppapi/shared_impl/graphics_3d_impl.h"
#include "ppapi/shared_impl/resource.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
@@ -86,8 +86,7 @@ class PPB_Graphics3D_Impl : public ::ppapi::Resource,
bool commit_pending_;
// PluginDelegate's 3D Context. Responsible for providing the command buffer.
scoped_ptr<PluginDelegate::PlatformContext3D> platform_context_;
- base::ScopedCallbackFactory<PPB_Graphics3D_Impl> callback_factory_;
- ScopedRunnableMethodFactory<PPB_Graphics3D_Impl> method_factory_;
+ base::WeakPtrFactory<PPB_Graphics3D_Impl> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl);
};
diff --git a/webkit/plugins/ppapi/ppb_scrollbar_impl.cc b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
index 797f7bf..e731e63 100644
--- a/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
+++ b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
@@ -4,6 +4,7 @@
#include "webkit/plugins/ppapi/ppb_scrollbar_impl.h"
+#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "ppapi/c/dev/ppp_scrollbar_dev.h"
@@ -44,7 +45,7 @@ PP_Resource PPB_Scrollbar_Impl::Create(PP_Instance instance,
PPB_Scrollbar_Impl::PPB_Scrollbar_Impl(PP_Instance instance)
: PPB_Widget_Impl(instance),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
}
PPB_Scrollbar_Impl::~PPB_Scrollbar_Impl() {
@@ -210,13 +211,13 @@ void PPB_Scrollbar_Impl::invalidateScrollbarRect(
// Can't call into the client to tell them about the invalidate right away,
// since the PPB_Scrollbar_Impl code is still in the middle of updating its
// internal state.
- // Note: we use a method factory here instead of NewRunnableMethod because the
- // latter would modify the lifetime of this object. That might make
- // WebKit::WebScrollbar outlive WebKit::WebPluginContainer, which is against
- // its contract.
+ // Note: we use a WeakPtrFactory here so that a lingering callback can not
+ // modify the lifetime of this object. Otherwise, WebKit::WebScrollbar could
+ // outlive WebKit::WebPluginContainer, which is against its contract.
MessageLoop::current()->PostTask(
FROM_HERE,
- method_factory_.NewRunnableMethod(&PPB_Scrollbar_Impl::NotifyInvalidate));
+ base::Bind(&PPB_Scrollbar_Impl::NotifyInvalidate,
+ weak_ptr_factory_.GetWeakPtr()));
}
void PPB_Scrollbar_Impl::getTickmarks(
diff --git a/webkit/plugins/ppapi/ppb_scrollbar_impl.h b/webkit/plugins/ppapi/ppb_scrollbar_impl.h
index f08aff4..cbc4ceb 100644
--- a/webkit/plugins/ppapi/ppb_scrollbar_impl.h
+++ b/webkit/plugins/ppapi/ppb_scrollbar_impl.h
@@ -7,6 +7,7 @@
#include <vector>
+#include "base/memory/weak_ptr.h"
#include "base/task.h"
#include "ppapi/thunk/ppb_scrollbar_api.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
@@ -65,7 +66,7 @@ class PPB_Scrollbar_Impl : public PPB_Widget_Impl,
scoped_ptr<WebKit::WebScrollbar> scrollbar_;
// Used so that the post task for Invalidate doesn't keep an extra reference.
- ScopedRunnableMethodFactory<PPB_Scrollbar_Impl> method_factory_;
+ base::WeakPtrFactory<PPB_Scrollbar_Impl> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(PPB_Scrollbar_Impl);
};
diff --git a/webkit/plugins/ppapi/ppb_surface_3d_impl.cc b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc
index 89ff723..6002c1e 100644
--- a/webkit/plugins/ppapi/ppb_surface_3d_impl.cc
+++ b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc
@@ -4,6 +4,7 @@
#include "webkit/plugins/ppapi/ppb_surface_3d_impl.h"
+#include "base/bind.h"
#include "base/message_loop.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "gpu/command_buffer/common/command_buffer.h"
@@ -25,7 +26,7 @@ PPB_Surface3D_Impl::PPB_Surface3D_Impl(PP_Instance instance)
bound_to_instance_(false),
swap_initiated_(false),
context_(NULL),
- method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+ weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
}
PPB_Surface3D_Impl::~PPB_Surface3D_Impl() {
@@ -82,8 +83,9 @@ int32_t PPB_Surface3D_Impl::SwapBuffers(PP_CompletionCallback callback) {
gpu::gles2::GLES2Implementation* impl = context_->gles2_impl();
if (impl)
context_->gles2_impl()->SwapBuffers();
- context_->platform_context()->Echo(method_factory_.NewRunnableMethod(
- &PPB_Surface3D_Impl::OnSwapBuffers));
+ context_->platform_context()->Echo(
+ base::Bind(&PPB_Surface3D_Impl::OnSwapBuffers,
+ weak_ptr_factory_.GetWeakPtr()));
// |SwapBuffers()| should not call us back synchronously, but double-check.
DCHECK(!swap_callback_->completed());
return PP_OK_COMPLETIONPENDING;
diff --git a/webkit/plugins/ppapi/ppb_surface_3d_impl.h b/webkit/plugins/ppapi/ppb_surface_3d_impl.h
index fb21e2f..f6455a4 100644
--- a/webkit/plugins/ppapi/ppb_surface_3d_impl.h
+++ b/webkit/plugins/ppapi/ppb_surface_3d_impl.h
@@ -76,7 +76,7 @@ class PPB_Surface3D_Impl : public ::ppapi::Resource,
// The context this surface is currently bound to.
PPB_Context3D_Impl* context_;
- ScopedRunnableMethodFactory<PPB_Surface3D_Impl> method_factory_;
+ base::WeakPtrFactory<PPB_Surface3D_Impl> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(PPB_Surface3D_Impl);
};
diff --git a/webkit/plugins/ppapi/quota_file_io.cc b/webkit/plugins/ppapi/quota_file_io.cc
index 63db38e..4a26f67 100644
--- a/webkit/plugins/ppapi/quota_file_io.cc
+++ b/webkit/plugins/ppapi/quota_file_io.cc
@@ -6,6 +6,7 @@
#include <algorithm>
+#include "base/bind.h"
#include "base/stl_util.h"
#include "base/message_loop_proxy.h"
#include "base/task.h"
@@ -223,7 +224,8 @@ QuotaFileIO::QuotaFileIO(
outstanding_errors_(0),
max_written_offset_(0),
inflight_operations_(0),
- callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+ callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
+ weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
DCHECK_NE(base::kInvalidPlatformFileValue, file_);
DCHECK_NE(quota::kStorageTypeUnknown, storage_type_);
}
@@ -303,7 +305,8 @@ bool QuotaFileIO::RegisterOperationForQuotaChecks(
++outstanding_quota_queries_;
plugin_delegate->QueryAvailableSpace(
GURL(file_url_.path()).GetOrigin(), storage_type_,
- callback_factory_.NewCallback(&QuotaFileIO::DidQueryAvailableSpace));
+ base::Bind(&QuotaFileIO::DidQueryAvailableSpace,
+ weak_ptr_factory_.GetWeakPtr()));
}
pending_operations_.push_back(op.release());
return true;
diff --git a/webkit/plugins/ppapi/quota_file_io.h b/webkit/plugins/ppapi/quota_file_io.h
index a57b0dd..02abdd1 100644
--- a/webkit/plugins/ppapi/quota_file_io.h
+++ b/webkit/plugins/ppapi/quota_file_io.h
@@ -9,6 +9,7 @@
#include "base/file_util_proxy.h"
#include "base/memory/scoped_callback_factory.h"
+#include "base/memory/weak_ptr.h"
#include "base/platform_file.h"
#include "googleurl/src/gurl.h"
#include "ppapi/c/pp_file_info.h"
@@ -104,6 +105,7 @@ class QuotaFileIO {
int inflight_operations_;
base::ScopedCallbackFactory<QuotaFileIO> callback_factory_;
+ base::WeakPtrFactory<QuotaFileIO> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(QuotaFileIO);
};
diff --git a/webkit/plugins/ppapi/quota_file_io_unittest.cc b/webkit/plugins/ppapi/quota_file_io_unittest.cc
index a2356fa..2b7d575 100644
--- a/webkit/plugins/ppapi/quota_file_io_unittest.cc
+++ b/webkit/plugins/ppapi/quota_file_io_unittest.cc
@@ -7,7 +7,9 @@
#include <string>
#include "base/basictypes.h"
+#include "base/bind.h"
#include "base/memory/scoped_callback_factory.h"
+#include "base/memory/weak_ptr.h"
#include "base/message_loop.h"
#include "base/platform_file.h"
#include "base/scoped_temp_dir.h"
@@ -33,7 +35,7 @@ class QuotaMockPluginDelegate : public MockPluginDelegate {
: available_space_(0),
will_update_count_(0),
file_thread_(MessageLoopProxy::current()),
- runnable_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
+ weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
}
virtual ~QuotaMockPluginDelegate() {}
@@ -44,11 +46,13 @@ class QuotaMockPluginDelegate : public MockPluginDelegate {
virtual void QueryAvailableSpace(
const GURL& origin,
quota::StorageType type,
- Callback* callback) OVERRIDE {
- DCHECK(callback);
+ const Callback& callback) OVERRIDE {
+ DCHECK(!callback.is_null());
MessageLoopProxy::current()->PostTask(
- FROM_HERE, runnable_factory_.NewRunnableMethod(
- &QuotaMockPluginDelegate::RunAvailableSpaceCallback, callback));
+ FROM_HERE, base::Bind(
+ &QuotaMockPluginDelegate::RunAvailableSpaceCallback,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback));
}
virtual void WillUpdateFile(const GURL& file_path) OVERRIDE {
@@ -67,16 +71,15 @@ class QuotaMockPluginDelegate : public MockPluginDelegate {
int64_t available_space() const { return available_space_; }
private:
- void RunAvailableSpaceCallback(Callback* callback) {
- callback->Run(available_space_);
- delete callback;
+ void RunAvailableSpaceCallback(const Callback& callback) {
+ callback.Run(available_space_);
}
int64_t available_space_;
int will_update_count_;
GURL file_path_;
scoped_refptr<MessageLoopProxy> file_thread_;
- ScopedRunnableMethodFactory<QuotaMockPluginDelegate> runnable_factory_;
+ base::WeakPtrFactory<QuotaMockPluginDelegate> weak_ptr_factory_;
};
} // namespace