Commit 82f4b829 authored by jhawkins@chromium.org's avatar jhawkins@chromium.org

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
parent f4d2041d
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "webkit/plugins/npapi/plugin_instance.h" #include "webkit/plugins/npapi/plugin_instance.h"
#include "base/bind.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "base/file_util.h" #include "base/file_util.h"
#include "base/message_loop.h" #include "base/message_loop.h"
...@@ -431,8 +432,8 @@ void PluginInstance::DidManualLoadFail() { ...@@ -431,8 +432,8 @@ void PluginInstance::DidManualLoadFail() {
void PluginInstance::PluginThreadAsyncCall(void (*func)(void *), void PluginInstance::PluginThreadAsyncCall(void (*func)(void *),
void *user_data) { void *user_data) {
message_loop_->PostTask( message_loop_->PostTask(
FROM_HERE, NewRunnableMethod( FROM_HERE, base::Bind(&PluginInstance::OnPluginThreadAsyncCall, this,
this, &PluginInstance::OnPluginThreadAsyncCall, func, user_data)); func, user_data));
} }
void PluginInstance::OnPluginThreadAsyncCall(void (*func)(void *), void PluginInstance::OnPluginThreadAsyncCall(void (*func)(void *),
...@@ -460,8 +461,7 @@ uint32 PluginInstance::ScheduleTimer(uint32 interval, ...@@ -460,8 +461,7 @@ uint32 PluginInstance::ScheduleTimer(uint32 interval,
// Schedule the callback. // Schedule the callback.
MessageLoop::current()->PostDelayedTask( MessageLoop::current()->PostDelayedTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod( base::Bind(&PluginInstance::OnTimerCall, this, func, npp_, timer_id),
this, &PluginInstance::OnTimerCall, func, npp_, timer_id),
interval); interval);
return timer_id; return timer_id;
} }
...@@ -499,12 +499,11 @@ void PluginInstance::OnTimerCall(void (*func)(NPP id, uint32 timer_id), ...@@ -499,12 +499,11 @@ void PluginInstance::OnTimerCall(void (*func)(NPP id, uint32 timer_id),
return; return;
// Reschedule repeating timers after invoking the callback so callback is not // 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) { if (info.repeat) {
MessageLoop::current()->PostDelayedTask( MessageLoop::current()->PostDelayedTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod( base::Bind(&PluginInstance::OnTimerCall, this, func, npp_, timer_id),
this, &PluginInstance::OnTimerCall, func, npp_, timer_id),
info.interval); info.interval);
} else { } else {
timers_.erase(it); timers_.erase(it);
......
// 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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "webkit/plugins/npapi/plugin_stream.h" #include "webkit/plugins/npapi/plugin_stream.h"
#include "base/bind.h"
#include "base/message_loop.h" #include "base/message_loop.h"
#include "base/string_util.h" #include "base/string_util.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
...@@ -145,8 +146,8 @@ bool PluginStream::WriteToPlugin(const char *buf, const int length, ...@@ -145,8 +146,8 @@ bool PluginStream::WriteToPlugin(const char *buf, const int length,
delivery_data_.resize(previous_size + remaining); delivery_data_.resize(previous_size + remaining);
data_offset_ = data_offset; data_offset_ = data_offset;
memcpy(&delivery_data_[previous_size], buf + written, remaining); memcpy(&delivery_data_[previous_size], buf + written, remaining);
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( MessageLoop::current()->PostTask(
this, &PluginStream::OnDelayDelivery)); FROM_HERE, base::Bind(&PluginStream::OnDelayDelivery, this));
} }
return true; return true;
......
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
#include "webkit/plugins/npapi/webplugin_delegate.h" #include "webkit/plugins/npapi/webplugin_delegate.h"
#include "webkit/glue/webcursor.h" #include "webkit/glue/webcursor.h"
#if defined(OS_WIN) && !defined(USE_AURA)
#include "base/memory/weak_ptr.h"
#endif
#if defined(USE_X11) #if defined(USE_X11)
#include "ui/base/x/x11_util.h" #include "ui/base/x/x11_util.h"
...@@ -519,7 +523,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate { ...@@ -519,7 +523,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
// Runnable Method Factory used to invoke the OnUserGestureEnd method // Runnable Method Factory used to invoke the OnUserGestureEnd method
// asynchronously. // 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 // Handle to the mouse hook installed for certain windowed plugins like
// flash. // flash.
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/file_util.h" #include "base/file_util.h"
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
...@@ -324,8 +326,7 @@ WebPluginDelegateImpl::WebPluginDelegateImpl( ...@@ -324,8 +326,7 @@ WebPluginDelegateImpl::WebPluginDelegateImpl(
handle_event_message_filter_hook_(NULL), handle_event_message_filter_hook_(NULL),
handle_event_pump_messages_event_(NULL), handle_event_pump_messages_event_(NULL),
user_gesture_message_posted_(false), user_gesture_message_posted_(false),
#pragma warning(suppress: 4355) // can use this ALLOW_THIS_IN_INITIALIZER_LIST(user_gesture_msg_factory_(this)),
user_gesture_msg_factory_(this),
handle_event_depth_(0), handle_event_depth_(0),
mouse_hook_(NULL), mouse_hook_(NULL),
first_set_window_call_(true), first_set_window_call_(true),
...@@ -698,8 +699,8 @@ void WebPluginDelegateImpl::OnThrottleMessage() { ...@@ -698,8 +699,8 @@ void WebPluginDelegateImpl::OnThrottleMessage() {
} }
if (!throttle_queue_was_empty) { if (!throttle_queue_was_empty) {
MessageLoop::current()->PostDelayedTask(FROM_HERE, MessageLoop::current()->PostDelayedTask(
NewRunnableFunction(&WebPluginDelegateImpl::OnThrottleMessage), FROM_HERE, base::Bind(&WebPluginDelegateImpl::OnThrottleMessage),
kFlashWMUSERMessageThrottleDelayMs); kFlashWMUSERMessageThrottleDelayMs);
} }
} }
...@@ -721,8 +722,8 @@ void WebPluginDelegateImpl::ThrottleMessage(WNDPROC proc, HWND hwnd, ...@@ -721,8 +722,8 @@ void WebPluginDelegateImpl::ThrottleMessage(WNDPROC proc, HWND hwnd,
throttle_queue->push_back(msg); throttle_queue->push_back(msg);
if (throttle_queue->size() == 1) { if (throttle_queue->size() == 1) {
MessageLoop::current()->PostDelayedTask(FROM_HERE, MessageLoop::current()->PostDelayedTask(
NewRunnableFunction(&WebPluginDelegateImpl::OnThrottleMessage), FROM_HERE, base::Bind(&WebPluginDelegateImpl::OnThrottleMessage),
kFlashWMUSERMessageThrottleDelayMs); kFlashWMUSERMessageThrottleDelayMs);
} }
} }
...@@ -1080,9 +1081,10 @@ LRESULT CALLBACK WebPluginDelegateImpl::NativeWndProc( ...@@ -1080,9 +1081,10 @@ LRESULT CALLBACK WebPluginDelegateImpl::NativeWndProc(
delegate->instance()->PushPopupsEnabledState(true); delegate->instance()->PushPopupsEnabledState(true);
MessageLoop::current()->PostDelayedTask(FROM_HERE, MessageLoop::current()->PostDelayedTask(
delegate->user_gesture_msg_factory_.NewRunnableMethod( FROM_HERE,
&WebPluginDelegateImpl::OnUserGestureEnd), base::Bind(&WebPluginDelegateImpl::OnUserGestureEnd,
delegate->user_gesture_msg_factory_.GetWeakPtr()),
kWindowedPluginPopupTimerMs); kWindowedPluginPopupTimerMs);
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "webkit/plugins/npapi/webplugin_impl.h" #include "webkit/plugins/npapi/webplugin_impl.h"
#include "base/bind.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/linked_ptr.h" #include "base/memory/linked_ptr.h"
#include "base/message_loop.h" #include "base/message_loop.h"
...@@ -347,9 +348,9 @@ void WebPluginImpl::updateGeometry( ...@@ -347,9 +348,9 @@ void WebPluginImpl::updateGeometry(
// geometry received by a call to setFrameRect in the Webkit // geometry received by a call to setFrameRect in the Webkit
// layout code path. To workaround this issue we download the // layout code path. To workaround this issue we download the
// plugin source url on a timer. // plugin source url on a timer.
MessageLoop::current()->PostDelayedTask( MessageLoop::current()->PostTask(
FROM_HERE, method_factory_.NewRunnableMethod( FROM_HERE, base::Bind(&WebPluginImpl::OnDownloadPluginSrcUrl,
&WebPluginImpl::OnDownloadPluginSrcUrl), 0); weak_factory_.GetWeakPtr()));
} }
} }
...@@ -474,7 +475,7 @@ WebPluginImpl::WebPluginImpl( ...@@ -474,7 +475,7 @@ WebPluginImpl::WebPluginImpl(
ignore_response_error_(false), ignore_response_error_(false),
file_path_(file_path), file_path_(file_path),
mime_type_(UTF16ToASCII(params.mimeType)), 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()); DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size());
StringToLowerASCII(&mime_type_); StringToLowerASCII(&mime_type_);
...@@ -1350,7 +1351,7 @@ void WebPluginImpl::TearDownPluginInstance( ...@@ -1350,7 +1351,7 @@ void WebPluginImpl::TearDownPluginInstance(
// This needs to be called now and not in the destructor since the // This needs to be called now and not in the destructor since the
// webframe_ might not be valid anymore. // webframe_ might not be valid anymore.
webframe_ = NULL; webframe_ = NULL;
method_factory_.RevokeAll(); weak_factory_.InvalidateWeakPtrs();
} }
void WebPluginImpl::SetReferrer(WebKit::WebURLRequest* request, void WebPluginImpl::SetReferrer(WebKit::WebURLRequest* request,
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/file_path.h" #include "base/file_path.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/task.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
...@@ -297,7 +296,7 @@ class WebPluginImpl : public WebPlugin, ...@@ -297,7 +296,7 @@ class WebPluginImpl : public WebPlugin,
std::vector<std::string> arg_names_; std::vector<std::string> arg_names_;
std::vector<std::string> arg_values_; std::vector<std::string> arg_values_;
ScopedRunnableMethodFactory<WebPluginImpl> method_factory_; base::WeakPtrFactory<WebPluginImpl> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(WebPluginImpl); DISALLOW_COPY_AND_ASSIGN(WebPluginImpl);
}; };
......
...@@ -170,8 +170,8 @@ void PPB_Surface3D_Impl::OnContextLost() { ...@@ -170,8 +170,8 @@ void PPB_Surface3D_Impl::OnContextLost() {
// Send context lost to plugin. This may have been caused by a PPAPI call, so // Send context lost to plugin. This may have been caused by a PPAPI call, so
// avoid re-entering. // avoid re-entering.
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( MessageLoop::current()->PostTask(
this, &PPB_Surface3D_Impl::SendContextLost)); FROM_HERE, base::Bind(&PPB_Surface3D_Impl::SendContextLost, this));
} }
void PPB_Surface3D_Impl::SendContextLost() { void PPB_Surface3D_Impl::SendContextLost() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment