diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-12 17:05:38 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-12 17:05:38 +0000 |
commit | 82f4b8292a2bf50213b9ae86399303f907e930e0 (patch) | |
tree | 4701b624938ffd1630058f9c80e8a0fe832d9d17 /webkit | |
parent | f4d2041dee86fcb95027234278f43d4bc6ae7564 (diff) | |
download | chromium_src-82f4b8292a2bf50213b9ae86399303f907e930e0.zip chromium_src-82f4b8292a2bf50213b9ae86399303f907e930e0.tar.gz chromium_src-82f4b8292a2bf50213b9ae86399303f907e930e0.tar.bz2 |
base::Bind: Conversions in webkit/plugins/npapi.
BUG=none
TEST=none
R=csilv@chromium.org
Review URL: http://codereview.chromium.org/8539023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109802 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/plugins/npapi/plugin_instance.cc | 13 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_stream.cc | 7 | ||||
-rw-r--r-- | webkit/plugins/npapi/webplugin_delegate_impl.h | 6 | ||||
-rw-r--r-- | webkit/plugins/npapi/webplugin_delegate_impl_win.cc | 20 | ||||
-rw-r--r-- | webkit/plugins/npapi/webplugin_impl.cc | 11 | ||||
-rw-r--r-- | webkit/plugins/npapi/webplugin_impl.h | 3 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_surface_3d_impl.cc | 4 |
7 files changed, 35 insertions, 29 deletions
diff --git a/webkit/plugins/npapi/plugin_instance.cc b/webkit/plugins/npapi/plugin_instance.cc index 30e16a5..464e6b2 100644 --- a/webkit/plugins/npapi/plugin_instance.cc +++ b/webkit/plugins/npapi/plugin_instance.cc @@ -4,6 +4,7 @@ #include "webkit/plugins/npapi/plugin_instance.h" +#include "base/bind.h" #include "build/build_config.h" #include "base/file_util.h" #include "base/message_loop.h" @@ -431,8 +432,8 @@ void PluginInstance::DidManualLoadFail() { void PluginInstance::PluginThreadAsyncCall(void (*func)(void *), void *user_data) { message_loop_->PostTask( - FROM_HERE, NewRunnableMethod( - this, &PluginInstance::OnPluginThreadAsyncCall, func, user_data)); + FROM_HERE, base::Bind(&PluginInstance::OnPluginThreadAsyncCall, this, + func, user_data)); } void PluginInstance::OnPluginThreadAsyncCall(void (*func)(void *), @@ -460,8 +461,7 @@ uint32 PluginInstance::ScheduleTimer(uint32 interval, // Schedule the callback. MessageLoop::current()->PostDelayedTask( FROM_HERE, - NewRunnableMethod( - this, &PluginInstance::OnTimerCall, func, npp_, timer_id), + base::Bind(&PluginInstance::OnTimerCall, this, func, npp_, timer_id), interval); return timer_id; } @@ -499,12 +499,11 @@ void PluginInstance::OnTimerCall(void (*func)(NPP id, uint32 timer_id), return; // Reschedule repeating timers after invoking the callback so callback is not - // re-entered if it pumps the messager loop. + // re-entered if it pumps the message loop. if (info.repeat) { MessageLoop::current()->PostDelayedTask( FROM_HERE, - NewRunnableMethod( - this, &PluginInstance::OnTimerCall, func, npp_, timer_id), + base::Bind(&PluginInstance::OnTimerCall, this, func, npp_, timer_id), info.interval); } else { timers_.erase(it); diff --git a/webkit/plugins/npapi/plugin_stream.cc b/webkit/plugins/npapi/plugin_stream.cc index fee63eb..c45c8a2 100644 --- a/webkit/plugins/npapi/plugin_stream.cc +++ b/webkit/plugins/npapi/plugin_stream.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -8,6 +8,7 @@ #include "webkit/plugins/npapi/plugin_stream.h" +#include "base/bind.h" #include "base/message_loop.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" @@ -145,8 +146,8 @@ bool PluginStream::WriteToPlugin(const char *buf, const int length, delivery_data_.resize(previous_size + remaining); data_offset_ = data_offset; memcpy(&delivery_data_[previous_size], buf + written, remaining); - MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( - this, &PluginStream::OnDelayDelivery)); + MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(&PluginStream::OnDelayDelivery, this)); } return true; diff --git a/webkit/plugins/npapi/webplugin_delegate_impl.h b/webkit/plugins/npapi/webplugin_delegate_impl.h index 0010d3b..0a2fb75 100644 --- a/webkit/plugins/npapi/webplugin_delegate_impl.h +++ b/webkit/plugins/npapi/webplugin_delegate_impl.h @@ -20,6 +20,10 @@ #include "webkit/plugins/npapi/webplugin_delegate.h" #include "webkit/glue/webcursor.h" +#if defined(OS_WIN) && !defined(USE_AURA) +#include "base/memory/weak_ptr.h" +#endif + #if defined(USE_X11) #include "ui/base/x/x11_util.h" @@ -519,7 +523,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate { // Runnable Method Factory used to invoke the OnUserGestureEnd method // asynchronously. - ScopedRunnableMethodFactory<WebPluginDelegateImpl> user_gesture_msg_factory_; + base::WeakPtrFactory<WebPluginDelegateImpl> user_gesture_msg_factory_; // Handle to the mouse hook installed for certain windowed plugins like // flash. diff --git a/webkit/plugins/npapi/webplugin_delegate_impl_win.cc b/webkit/plugins/npapi/webplugin_delegate_impl_win.cc index 61e39da..a4ee57a 100644 --- a/webkit/plugins/npapi/webplugin_delegate_impl_win.cc +++ b/webkit/plugins/npapi/webplugin_delegate_impl_win.cc @@ -8,6 +8,8 @@ #include <string> #include <vector> +#include "base/bind.h" +#include "base/compiler_specific.h" #include "base/file_util.h" #include "base/lazy_instance.h" #include "base/memory/scoped_ptr.h" @@ -324,8 +326,7 @@ WebPluginDelegateImpl::WebPluginDelegateImpl( handle_event_message_filter_hook_(NULL), handle_event_pump_messages_event_(NULL), user_gesture_message_posted_(false), -#pragma warning(suppress: 4355) // can use this - user_gesture_msg_factory_(this), + ALLOW_THIS_IN_INITIALIZER_LIST(user_gesture_msg_factory_(this)), handle_event_depth_(0), mouse_hook_(NULL), first_set_window_call_(true), @@ -698,8 +699,8 @@ void WebPluginDelegateImpl::OnThrottleMessage() { } if (!throttle_queue_was_empty) { - MessageLoop::current()->PostDelayedTask(FROM_HERE, - NewRunnableFunction(&WebPluginDelegateImpl::OnThrottleMessage), + MessageLoop::current()->PostDelayedTask( + FROM_HERE, base::Bind(&WebPluginDelegateImpl::OnThrottleMessage), kFlashWMUSERMessageThrottleDelayMs); } } @@ -721,8 +722,8 @@ void WebPluginDelegateImpl::ThrottleMessage(WNDPROC proc, HWND hwnd, throttle_queue->push_back(msg); if (throttle_queue->size() == 1) { - MessageLoop::current()->PostDelayedTask(FROM_HERE, - NewRunnableFunction(&WebPluginDelegateImpl::OnThrottleMessage), + MessageLoop::current()->PostDelayedTask( + FROM_HERE, base::Bind(&WebPluginDelegateImpl::OnThrottleMessage), kFlashWMUSERMessageThrottleDelayMs); } } @@ -1080,9 +1081,10 @@ LRESULT CALLBACK WebPluginDelegateImpl::NativeWndProc( delegate->instance()->PushPopupsEnabledState(true); - MessageLoop::current()->PostDelayedTask(FROM_HERE, - delegate->user_gesture_msg_factory_.NewRunnableMethod( - &WebPluginDelegateImpl::OnUserGestureEnd), + MessageLoop::current()->PostDelayedTask( + FROM_HERE, + base::Bind(&WebPluginDelegateImpl::OnUserGestureEnd, + delegate->user_gesture_msg_factory_.GetWeakPtr()), kWindowedPluginPopupTimerMs); } diff --git a/webkit/plugins/npapi/webplugin_impl.cc b/webkit/plugins/npapi/webplugin_impl.cc index 0203872..b78aeab 100644 --- a/webkit/plugins/npapi/webplugin_impl.cc +++ b/webkit/plugins/npapi/webplugin_impl.cc @@ -4,6 +4,7 @@ #include "webkit/plugins/npapi/webplugin_impl.h" +#include "base/bind.h" #include "base/logging.h" #include "base/memory/linked_ptr.h" #include "base/message_loop.h" @@ -347,9 +348,9 @@ void WebPluginImpl::updateGeometry( // geometry received by a call to setFrameRect in the Webkit // layout code path. To workaround this issue we download the // plugin source url on a timer. - MessageLoop::current()->PostDelayedTask( - FROM_HERE, method_factory_.NewRunnableMethod( - &WebPluginImpl::OnDownloadPluginSrcUrl), 0); + MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(&WebPluginImpl::OnDownloadPluginSrcUrl, + weak_factory_.GetWeakPtr())); } } @@ -474,7 +475,7 @@ WebPluginImpl::WebPluginImpl( ignore_response_error_(false), file_path_(file_path), mime_type_(UTF16ToASCII(params.mimeType)), - ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { + ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size()); StringToLowerASCII(&mime_type_); @@ -1350,7 +1351,7 @@ void WebPluginImpl::TearDownPluginInstance( // This needs to be called now and not in the destructor since the // webframe_ might not be valid anymore. webframe_ = NULL; - method_factory_.RevokeAll(); + weak_factory_.InvalidateWeakPtrs(); } void WebPluginImpl::SetReferrer(WebKit::WebURLRequest* request, diff --git a/webkit/plugins/npapi/webplugin_impl.h b/webkit/plugins/npapi/webplugin_impl.h index 70b1eff..2664f43 100644 --- a/webkit/plugins/npapi/webplugin_impl.h +++ b/webkit/plugins/npapi/webplugin_impl.h @@ -12,7 +12,6 @@ #include "base/basictypes.h" #include "base/file_path.h" #include "base/memory/weak_ptr.h" -#include "base/task.h" #include "googleurl/src/gurl.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" @@ -297,7 +296,7 @@ class WebPluginImpl : public WebPlugin, std::vector<std::string> arg_names_; std::vector<std::string> arg_values_; - ScopedRunnableMethodFactory<WebPluginImpl> method_factory_; + base::WeakPtrFactory<WebPluginImpl> weak_factory_; DISALLOW_COPY_AND_ASSIGN(WebPluginImpl); }; diff --git a/webkit/plugins/ppapi/ppb_surface_3d_impl.cc b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc index 6002c1e..e7f81c8 100644 --- a/webkit/plugins/ppapi/ppb_surface_3d_impl.cc +++ b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc @@ -170,8 +170,8 @@ void PPB_Surface3D_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_Surface3D_Impl::SendContextLost)); + MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(&PPB_Surface3D_Impl::SendContextLost, this)); } void PPB_Surface3D_Impl::SendContextLost() { |