summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-18 20:44:22 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-18 20:44:22 +0000
commitbb04c4ed964981493b8727cf67257d2ad6e8128b (patch)
tree0da5525bc43e817bbbd5dc0b691dfd6cdbbe322a
parent94dde4b7d804f3e8c92fbbaf56251717f9a2cc40 (diff)
downloadchromium_src-bb04c4ed964981493b8727cf67257d2ad6e8128b.zip
chromium_src-bb04c4ed964981493b8727cf67257d2ad6e8128b.tar.gz
chromium_src-bb04c4ed964981493b8727cf67257d2ad6e8128b.tar.bz2
base::Bind: Convert chrome_frame/.
BUG=none TEST=none R=csilv@chromium.org Review URL: http://codereview.chromium.org/8555001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110744 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/threading/worker_pool.h2
-rw-r--r--chrome_frame/cfproxy_test.cc33
-rw-r--r--chrome_frame/chrome_frame_automation.cc62
-rw-r--r--chrome_frame/chrome_frame_delegate.h44
-rw-r--r--chrome_frame/custom_sync_call_context.h10
-rw-r--r--chrome_frame/external_tab_test.cc43
-rw-r--r--chrome_frame/task_marshaller.cc1
-rw-r--r--chrome_frame/task_marshaller.h3
-rw-r--r--chrome_frame/test/automation_client_mock.cc13
-rw-r--r--chrome_frame/test/chrome_frame_test_utils.h14
-rw-r--r--chrome_frame/test/chrome_frame_ui_test_utils.cc7
-rw-r--r--chrome_frame/test/infobar_unittests.cc17
-rw-r--r--chrome_frame/test/mock_ie_event_sink_actions.h60
-rw-r--r--chrome_frame/test/proxy_factory_mock.cc5
-rw-r--r--chrome_frame/test/test_server.cc12
-rw-r--r--chrome_frame/test/url_request_test.cc21
-rw-r--r--chrome_frame/test/win_event_receiver.cc14
-rw-r--r--chrome_frame/urlmon_url_request.cc48
-rw-r--r--chrome_frame/urlmon_url_request.h7
-rw-r--r--chrome_frame/urlmon_url_request_private.h8
20 files changed, 225 insertions, 199 deletions
diff --git a/base/threading/worker_pool.h b/base/threading/worker_pool.h
index f8d5ad5..7eabe8f 100644
--- a/base/threading/worker_pool.h
+++ b/base/threading/worker_pool.h
@@ -32,7 +32,7 @@ class BASE_EXPORT WorkerPool {
// false if |task| could not be posted to a worker thread. Regardless of
// return value, ownership of |task| is transferred to the worker pool.
//
- // TODO(ajwong): Remove the Task* based overload once we've finishsed the
+ // TODO(ajwong): Remove the Task* based overload once we've finished the
// Task -> Closure migration.
static bool PostTask(const tracked_objects::Location& from_here,
Task* task, bool task_is_slow);
diff --git a/chrome_frame/cfproxy_test.cc b/chrome_frame/cfproxy_test.cc
index 6599000..4174133 100644
--- a/chrome_frame/cfproxy_test.cc
+++ b/chrome_frame/cfproxy_test.cc
@@ -3,6 +3,9 @@
// found in the LICENSE file.
#include <string>
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/waitable_event.h"
@@ -101,20 +104,28 @@ struct MockCFProxyTraits : public CFProxyTraits {
// You may find API_FIRE_XXXX macros (see below) handy instead.
void FireConnect(base::TimeDelta t) {
ASSERT_TRUE(ipc_loop != NULL);
- ipc_loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(listener,
- &IPC::Channel::Listener::OnChannelConnected, 0), t.InMilliseconds());
+ ipc_loop->PostDelayedTask(
+ FROM_HERE, base::Bind(&IPC::Channel::Listener::OnChannelConnected,
+ base::Unretained(listener), 0),
+ t.InMilliseconds());
}
void FireError(base::TimeDelta t) {
ASSERT_TRUE(ipc_loop != NULL);
- ipc_loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(listener,
- &IPC::Channel::Listener::OnChannelError), t.InMilliseconds());
+ ipc_loop->PostDelayedTask(
+ FROM_HERE, base::Bind(&IPC::Channel::Listener::OnChannelError,
+ base::Unretained(listener)),
+ t.InMilliseconds());
}
void FireMessage(const IPC::Message& m, base::TimeDelta t) {
ASSERT_TRUE(ipc_loop != NULL);
- ipc_loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(listener,
- &IPC::Channel::Listener::OnMessageReceived, m), t.InMilliseconds());
+ ipc_loop->PostDelayedTask(
+ FROM_HERE,
+ base::IgnoreReturn<bool>(
+ base::Bind(&IPC::Channel::Listener::OnMessageReceived,
+ base::Unretained(listener), m)),
+ t.InMilliseconds());
}
MockCFProxyTraits() : ipc_loop(NULL) {}
@@ -124,14 +135,13 @@ struct MockCFProxyTraits : public CFProxyTraits {
IPC::Channel::Listener* listener;
};
-// Handy macros when we want so similate something on the IPC thread.
+// Handy macros when we want so simulate something on the IPC thread.
#define API_FIRE_CONNECT(api, t) InvokeWithoutArgs(CreateFunctor(&api, \
&MockCFProxyTraits::FireConnect, t))
#define API_FIRE_ERROR(api, t) InvokeWithoutArgs(CreateFunctor(&api, \
&MockCFProxyTraits::FireError, t))
#define API_FIRE_MESSAGE(api, t) InvokeWithoutArgs(CreateFunctor(&api, \
&MockCFProxyTraits::FireMessage, t))
-DISABLE_RUNNABLE_METHOD_REFCOUNT(IPC::Channel::Listener);
TEST(ChromeProxy, DelegateAddRemove) {
StrictMock<MockCFProxyTraits> api;
@@ -323,7 +333,6 @@ inline IPC::Message* CreateReply(M* m, const A& a, const B& b, const C& c,
return r;
}} // namespace
-DISABLE_RUNNABLE_METHOD_REFCOUNT(SyncMsgSender);
TEST(SyncMsgSender, Deserialize) {
// Note the ipc thread is not actually needed, but we try to be close
// to real-world conditions - that SyncMsgSender works from multiple threads.
@@ -349,8 +358,10 @@ TEST(SyncMsgSender, Deserialize) {
kSessionId));
// Execute replies in a worker thread.
- ipc.message_loop()->PostTask(FROM_HERE, NewRunnableMethod(&queue,
- &SyncMsgSender::OnReplyReceived, r.get()));
+ ipc.message_loop()->PostTask(
+ FROM_HERE,
+ base::IgnoreReturn<bool>(base::Bind(&SyncMsgSender::OnReplyReceived,
+ base::Unretained(&queue), r.get())));
ipc.Stop();
// Expect that tab 6 has been associated with the delegate.
diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc
index fcc2e50..81740e6 100644
--- a/chrome_frame/chrome_frame_automation.cc
+++ b/chrome_frame/chrome_frame_automation.cc
@@ -4,6 +4,8 @@
#include "chrome_frame/chrome_frame_automation.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
@@ -196,8 +198,6 @@ struct LaunchTimeStats {
#endif
};
-DISABLE_RUNNABLE_METHOD_REFCOUNT(AutomationProxyCacheEntry);
-
AutomationProxyCacheEntry::AutomationProxyCacheEntry(
ChromeFrameLaunchParams* params, LaunchDelegate* delegate)
: profile_name(params->profile_name()),
@@ -208,8 +208,9 @@ AutomationProxyCacheEntry::AutomationProxyCacheEntry(
// Use scoped_refptr so that the params will get released when the task
// has been run.
scoped_refptr<ChromeFrameLaunchParams> ref_params(params);
- thread_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(this,
- &AutomationProxyCacheEntry::CreateProxy, ref_params, delegate));
+ thread_->message_loop()->PostTask(
+ FROM_HERE, base::Bind(&AutomationProxyCacheEntry::CreateProxy,
+ base::Unretained(this), ref_params, delegate));
}
AutomationProxyCacheEntry::~AutomationProxyCacheEntry() {
@@ -409,8 +410,6 @@ void AutomationProxyCacheEntry::OnChannelError() {
}
}
-DISABLE_RUNNABLE_METHOD_REFCOUNT(ProxyFactory);
-
ProxyFactory::ProxyFactory() {
}
@@ -445,8 +444,9 @@ void ProxyFactory::GetAutomationServer(
} else if (delegate) {
// Notify the new delegate of the launch status from the worker thread
// and add it to the list of delegates.
- entry->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(entry.get(),
- &AutomationProxyCacheEntry::AddDelegate, delegate));
+ entry->message_loop()->PostTask(
+ FROM_HERE, base::Bind(&AutomationProxyCacheEntry::AddDelegate,
+ base::Unretained(entry.get()), delegate));
}
DCHECK(automation_server_id != NULL);
@@ -483,9 +483,10 @@ bool ProxyFactory::ReleaseAutomationServer(void* server_id,
bool last_delegate = false;
if (delegate) {
base::WaitableEvent done(true, false);
- entry->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(entry,
- &AutomationProxyCacheEntry::RemoveDelegate, delegate, &done,
- &last_delegate));
+ entry->message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&AutomationProxyCacheEntry::RemoveDelegate,
+ base::Unretained(entry), delegate, &done, &last_delegate));
done.Wait();
}
@@ -882,19 +883,21 @@ void ChromeFrameAutomationClient::LaunchComplete(
}
} else {
// Launch failed. Note, we cannot delete proxy here.
- PostTask(FROM_HERE, NewRunnableMethod(this,
- &ChromeFrameAutomationClient::InitializeComplete, result));
+ PostTask(FROM_HERE,
+ base::Bind(&ChromeFrameAutomationClient::InitializeComplete,
+ base::Unretained(this), result));
}
}
void ChromeFrameAutomationClient::AutomationServerDied() {
// Make sure we notify our delegate.
- PostTask(FROM_HERE, NewRunnableMethod(this,
- &ChromeFrameAutomationClient::InitializeComplete,
- AUTOMATION_SERVER_CRASHED));
+ PostTask(
+ FROM_HERE, base::Bind(&ChromeFrameAutomationClient::InitializeComplete,
+ base::Unretained(this), AUTOMATION_SERVER_CRASHED));
// Then uninitialize.
- PostTask(FROM_HERE, NewRunnableMethod(this,
- &ChromeFrameAutomationClient::Uninitialize));
+ PostTask(
+ FROM_HERE, base::Bind(&ChromeFrameAutomationClient::Uninitialize,
+ base::Unretained(this)));
}
void ChromeFrameAutomationClient::InitializeComplete(
@@ -994,8 +997,10 @@ bool ChromeFrameAutomationClient::ProcessUrlRequestMessage(TabProxy* tab,
break;
}
- PostTask(FROM_HERE, NewRunnableMethod(this,
- &ChromeFrameAutomationClient::ProcessUrlRequestMessage, tab, msg, true));
+ PostTask(
+ FROM_HERE, base::IgnoreReturn<bool>(base::Bind(
+ &ChromeFrameAutomationClient::ProcessUrlRequestMessage,
+ base::Unretained(this), tab, msg, true)));
return true;
}
@@ -1014,8 +1019,9 @@ bool ChromeFrameAutomationClient::OnMessageReceived(TabProxy* tab,
if (chrome_frame_delegate_ == NULL)
return false;
- PostTask(FROM_HERE, NewRunnableMethod(this,
- &ChromeFrameAutomationClient::OnMessageReceivedUIThread, msg));
+ PostTask(FROM_HERE,
+ base::Bind(&ChromeFrameAutomationClient::OnMessageReceivedUIThread,
+ base::Unretained(this), msg));
return true;
}
@@ -1025,8 +1031,10 @@ void ChromeFrameAutomationClient::OnChannelError(TabProxy* tab) {
if (chrome_frame_delegate_ == NULL)
return;
- PostTask(FROM_HERE, NewRunnableMethod(this,
- &ChromeFrameAutomationClient::OnChannelErrorUIThread));
+ PostTask(
+ FROM_HERE,
+ base::Bind(&ChromeFrameAutomationClient::OnChannelErrorUIThread,
+ base::Unretained(this)));
}
void ChromeFrameAutomationClient::OnMessageReceivedUIThread(
@@ -1058,9 +1066,9 @@ void ChromeFrameAutomationClient::ReportNavigationError(
if (ui_thread_id_ == base::PlatformThread::CurrentId()) {
chrome_frame_delegate_->OnLoadFailed(error_code, url);
} else {
- PostTask(FROM_HERE, NewRunnableMethod(this,
- &ChromeFrameAutomationClient::ReportNavigationError,
- error_code, url));
+ PostTask(FROM_HERE,
+ base::Bind(&ChromeFrameAutomationClient::ReportNavigationError,
+ base::Unretained(this), error_code, url));
}
}
diff --git a/chrome_frame/chrome_frame_delegate.h b/chrome_frame/chrome_frame_delegate.h
index d2e9921..2373b94 100644
--- a/chrome_frame/chrome_frame_delegate.h
+++ b/chrome_frame/chrome_frame_delegate.h
@@ -12,8 +12,10 @@
#include <string>
#include <vector>
+#include "base/callback.h"
#include "base/file_path.h"
#include "base/location.h"
+#include "base/pending_task.h"
#include "base/synchronization/lock.h"
#include "base/task.h"
#include "chrome/common/automation_constants.h"
@@ -65,9 +67,6 @@ class ChromeFrameDelegate {
virtual ~ChromeFrameDelegate() {}
};
-// Disable refcounting of ChromeFrameDelegate.
-DISABLE_RUNNABLE_METHOD_REFCOUNT(ChromeFrameDelegate);
-
extern UINT kAutomationServerReady;
extern UINT kMessageFromChromeFrame;
@@ -92,7 +91,7 @@ class ChromeFrameDelegateImpl : public ChromeFrameDelegate {
virtual void OnHostMoved() {}
protected:
- // Protected methods to be overriden.
+ // Protected methods to be overridden.
virtual void OnNavigationStateChanged(
int flags, const NavigationInfo& nav_info) {}
virtual void OnUpdateTargetUrl(const std::wstring& new_target_url) {}
@@ -129,7 +128,7 @@ class ChromeFrameDelegateImpl : public ChromeFrameDelegate {
class TaskMarshaller { // NOLINT
public:
virtual void PostTask(const tracked_objects::Location& from_here,
- Task* task) = 0;
+ const base::Closure& task) = 0;
};
// T is expected to be something CWindowImpl derived, or at least to have
@@ -138,16 +137,18 @@ template <class T> class TaskMarshallerThroughWindowsMessages
: public TaskMarshaller {
public:
TaskMarshallerThroughWindowsMessages() {}
- virtual void PostTask(const tracked_objects::Location& from_here,
- Task* task) {
+ virtual void PostTask(const tracked_objects::Location& posted_from,
+ const base::Closure& task) OVERRIDE {
T* this_ptr = static_cast<T*>(this);
if (this_ptr->IsWindow()) {
this_ptr->AddRef();
- PushTask(task);
- this_ptr->PostMessage(MSG_EXECUTE_TASK, reinterpret_cast<WPARAM>(task));
+ base::PendingTask* pending_task =
+ new base::PendingTask(posted_from, task);
+ PushTask(pending_task);
+ this_ptr->PostMessage(MSG_EXECUTE_TASK,
+ reinterpret_cast<WPARAM>(pending_task));
} else {
DVLOG(1) << "Dropping MSG_EXECUTE_TASK message for destroyed window.";
- delete task;
}
}
@@ -162,7 +163,7 @@ template <class T> class TaskMarshallerThroughWindowsMessages
<< pending_tasks_.size()
<< " pending tasks";
while (!pending_tasks_.empty()) {
- Task* task = pending_tasks_.front();
+ base::PendingTask* task = pending_tasks_.front();
pending_tasks_.pop();
delete task;
}
@@ -176,10 +177,11 @@ template <class T> class TaskMarshallerThroughWindowsMessages
enum { MSG_EXECUTE_TASK = WM_APP + 6 };
inline LRESULT ExecuteTask(UINT, WPARAM wparam, LPARAM,
BOOL& handled) { // NOLINT
- Task* task = reinterpret_cast<Task*>(wparam);
- if (task && PopTask(task)) {
- task->Run();
- delete task;
+ base::PendingTask* pending_task =
+ reinterpret_cast<base::PendingTask*>(wparam);
+ if (pending_task && PopTask(pending_task)) {
+ pending_task->task.Run();
+ delete pending_task;
}
T* this_ptr = static_cast<T*>(this);
@@ -187,17 +189,17 @@ template <class T> class TaskMarshallerThroughWindowsMessages
return 0;
}
- inline void PushTask(Task* task) {
+ inline void PushTask(base::PendingTask* pending_task) {
base::AutoLock lock(lock_);
- pending_tasks_.push(task);
+ pending_tasks_.push(pending_task);
}
- // If the given task is front of the queue, removes the task and returns true,
+ // If |pending_task| is front of the queue, removes the task and returns true,
// otherwise we assume this is an already destroyed task (but Window message
// had remained in the thread queue).
- inline bool PopTask(Task* task) {
+ inline bool PopTask(base::PendingTask* pending_task) {
base::AutoLock lock(lock_);
- if (!pending_tasks_.empty() && task == pending_tasks_.front()) {
+ if (!pending_tasks_.empty() && pending_task == pending_tasks_.front()) {
pending_tasks_.pop();
return true;
}
@@ -206,7 +208,7 @@ template <class T> class TaskMarshallerThroughWindowsMessages
}
base::Lock lock_;
- std::queue<Task*> pending_tasks_;
+ std::queue<base::PendingTask*> pending_tasks_;
};
#endif // CHROME_FRAME_CHROME_FRAME_DELEGATE_H_
diff --git a/chrome_frame/custom_sync_call_context.h b/chrome_frame/custom_sync_call_context.h
index 9bdce87..e2691b8 100644
--- a/chrome_frame/custom_sync_call_context.h
+++ b/chrome_frame/custom_sync_call_context.h
@@ -6,6 +6,8 @@
#define CHROME_FRAME_CUSTOM_SYNC_CALL_CONTEXT_H_
#include <vector>
+
+#include "base/bind.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/waitable_event.h"
#include "chrome_frame/sync_msg_reply_dispatcher.h"
@@ -30,11 +32,9 @@ class CreateExternalTabContext
AutomationLaunchResult launch_result =
client_->CreateExternalTabComplete(chrome_window, tab_window,
tab_handle, session_id);
- client_->PostTask(FROM_HERE,
- NewRunnableMethod(
- client_.get(),
- &ChromeFrameAutomationClient::InitializeComplete,
- launch_result));
+ client_->PostTask(
+ FROM_HERE, base::Bind(&ChromeFrameAutomationClient::InitializeComplete,
+ client_.get(), launch_result));
}
private:
diff --git a/chrome_frame/external_tab_test.cc b/chrome_frame/external_tab_test.cc
index 0069522..5017eb2 100644
--- a/chrome_frame/external_tab_test.cc
+++ b/chrome_frame/external_tab_test.cc
@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/location.h"
-#include "base/task.h"
-#include "base/threading/thread.h"
#include "chrome_frame/external_tab.h"
// #include "base/synchronization/waitable_event.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/location.h"
+#include "base/threading/thread.h"
#include "chrome/common/automation_messages.h"
#include "chrome_frame/navigation_constraints.h"
#include "chrome_frame/test/chrome_frame_test_utils.h"
@@ -16,12 +17,6 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gmock_mutant.h"
-
-
-// DISABLE_RUNNABLE_METHOD_REFCOUNT(ExternalTabProxy);
-// DISABLE_RUNNABLE_METHOD_REFCOUNT(UIDelegate);
-DISABLE_RUNNABLE_METHOD_REFCOUNT(ChromeProxyDelegate);
-
using testing::StrictMock;
using testing::_;
using testing::Invoke;
@@ -109,27 +104,39 @@ struct AsyncEventCreator {
}
void Fire_Connected(ChromeProxy* proxy, base::TimeDelta delay) {
- ipc_loop_->PostDelayedTask(FROM_HERE, NewRunnableMethod(delegate_,
- &ChromeProxyDelegate::Connected, proxy), delay.InMilliseconds());
+ ipc_loop_->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&ChromeProxyDelegate::Connected, base::Unretained(delegate_),
+ proxy),
+ delay.InMilliseconds());
}
void Fire_PeerLost(ChromeProxy* proxy,
ChromeProxyDelegate::DisconnectReason reason, base::TimeDelta delay) {
- ipc_loop_->PostDelayedTask(FROM_HERE, NewRunnableMethod(delegate_,
- &ChromeProxyDelegate::PeerLost, proxy, reason), delay.InMilliseconds());
+ ipc_loop_->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&ChromeProxyDelegate::PeerLost, base::Unretained(delegate_),
+ proxy, reason),
+ delay.InMilliseconds());
}
void Fire_Disconnected(base::TimeDelta delay) {
- ipc_loop_->PostDelayedTask(FROM_HERE, NewRunnableMethod(delegate_,
- &ChromeProxyDelegate::Disconnected), delay.InMilliseconds());
+ ipc_loop_->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&ChromeProxyDelegate::Disconnected,
+ base::Unretained(delegate_)),
+ delay.InMilliseconds());
}
void Fire_CompletedCreateTab(bool success, HWND chrome_wnd, HWND tab_window,
int tab_handle, int session_id,
base::TimeDelta delay) {
- ipc_loop_->PostDelayedTask(FROM_HERE, NewRunnableMethod(delegate_,
- &ChromeProxyDelegate::Completed_CreateTab, success, chrome_wnd,
- tab_window, tab_handle, session_id), delay.InMilliseconds());
+ ipc_loop_->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&ChromeProxyDelegate::Completed_CreateTab,
+ base::Unretained(delegate_), success, chrome_wnd, tab_window,
+ tab_handle, session_id),
+ delay.InMilliseconds());
}
private:
diff --git a/chrome_frame/task_marshaller.cc b/chrome_frame/task_marshaller.cc
index 9ad74a0..5bc6a12 100644
--- a/chrome_frame/task_marshaller.cc
+++ b/chrome_frame/task_marshaller.cc
@@ -17,6 +17,7 @@ TaskMarshallerThroughMessageQueue::~TaskMarshallerThroughMessageQueue() {
void TaskMarshallerThroughMessageQueue::PostTask(
const tracked_objects::Location& from_here, const base::Closure& task) {
DCHECK(wnd_ != NULL);
+
lock_.Acquire();
bool has_work = !pending_tasks_.empty();
pending_tasks_.push(task);
diff --git a/chrome_frame/task_marshaller.h b/chrome_frame/task_marshaller.h
index c36a3f7..e4b53c3 100644
--- a/chrome_frame/task_marshaller.h
+++ b/chrome_frame/task_marshaller.h
@@ -17,8 +17,9 @@
#include "base/time.h"
class Task;
+
namespace tracked_objects {
- class Location;
+class Location;
}
// TaskMarshallerThroughMessageQueue is similar to base::MessageLoopForUI
diff --git a/chrome_frame/test/automation_client_mock.cc b/chrome_frame/test/automation_client_mock.cc
index 9ff5b61..68deba6 100644
--- a/chrome_frame/test/automation_client_mock.cc
+++ b/chrome_frame/test/automation_client_mock.cc
@@ -4,7 +4,8 @@
#include "chrome_frame/test/automation_client_mock.h"
-#include "base/callback.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "chrome/common/automation_messages.h"
#include "chrome_frame/custom_sync_call_context.h"
#include "chrome_frame/navigation_constraints.h"
@@ -18,10 +19,6 @@ using testing::_;
using testing::CreateFunctor;
using testing::Return;
-DISABLE_RUNNABLE_METHOD_REFCOUNT(LaunchDelegate);
-DISABLE_RUNNABLE_METHOD_REFCOUNT(ChromeFrameAutomationClient);
-DISABLE_RUNNABLE_METHOD_REFCOUNT(chrome_frame_test::TimedMsgLoop);
-
MATCHER_P(LaunchParamProfileEq, profile_name, "Check for profile name") {
return arg->profile_name().compare(profile_name) == 0;
}
@@ -33,9 +30,9 @@ void MockProxyFactory::GetServerImpl(ChromeFrameAutomationProxy* pxy,
ChromeFrameLaunchParams* params,
void** automation_server_id) {
*automation_server_id = proxy_id;
- Task* task = NewRunnableMethod(d,
- &LaunchDelegate::LaunchComplete, pxy, result);
- loop_->PostDelayedTask(FROM_HERE, task,
+ loop_->PostDelayedTask(FROM_HERE,
+ base::Bind(&LaunchDelegate::LaunchComplete,
+ base::Unretained(d), pxy, result),
params->launch_timeout() / 2);
}
diff --git a/chrome_frame/test/chrome_frame_test_utils.h b/chrome_frame/test/chrome_frame_test_utils.h
index ed4a379..518958ac 100644
--- a/chrome_frame/test/chrome_frame_test_utils.h
+++ b/chrome_frame/test/chrome_frame_test_utils.h
@@ -190,9 +190,14 @@ class TimedMsgLoop {
loop_.MessageLoop::Run();
}
- void PostDelayedTask(
- const tracked_objects::Location& from_here, Task* task, int64 delay_ms) {
- loop_.PostDelayedTask(from_here, task, delay_ms);
+ void PostTask(const tracked_objects::Location& from_here,
+ const base::Closure& task) {
+ loop_.PostTask(from_here, task);
+ }
+
+ void PostDelayedTask(const tracked_objects::Location& from_here,
+ const base::Closure& task, int64 delay_ms) {
+ loop_.PostDelayedTask(from_here, task, delay_ms);
}
void Quit() {
@@ -201,7 +206,8 @@ class TimedMsgLoop {
void QuitAfter(int seconds) {
quit_loop_invoked_ = true;
- loop_.PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask, 1000 * seconds);
+ loop_.PostDelayedTask(
+ FROM_HERE, MessageLoop::QuitClosure(), 1000 * seconds);
}
bool WasTimedOut() const {
diff --git a/chrome_frame/test/chrome_frame_ui_test_utils.cc b/chrome_frame/test/chrome_frame_ui_test_utils.cc
index 80a7ead..ffec433 100644
--- a/chrome_frame/test/chrome_frame_ui_test_utils.cc
+++ b/chrome_frame/test/chrome_frame_ui_test_utils.cc
@@ -9,6 +9,7 @@
#include <sstream>
#include <stack>
+#include "base/bind.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
#include "base/path_service.h"
@@ -658,9 +659,9 @@ void AccEventObserver::OnEventReceived(DWORD event,
LONG child_id) {
// Process events in a separate task to stop reentrancy problems.
DCHECK(MessageLoop::current());
- MessageLoop::current()->PostTask(FROM_HERE,
- NewRunnableMethod(event_handler_.get(), &EventHandler::Handle,
- event, hwnd, object_id, child_id));
+ MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(&EventHandler::Handle, event_handler_.get(), event,
+ hwnd, object_id, child_id));
}
// AccEventObserver::EventHandler methods
diff --git a/chrome_frame/test/infobar_unittests.cc b/chrome_frame/test/infobar_unittests.cc
index 1707d60..6704e29 100644
--- a/chrome_frame/test/infobar_unittests.cc
+++ b/chrome_frame/test/infobar_unittests.cc
@@ -8,6 +8,8 @@
#include <atlmisc.h>
#include <atlwin.h>
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/string_number_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -18,9 +20,6 @@
#include "chrome_frame/infobars/internal/subclassing_window_with_delegate.h"
#include "chrome_frame/test/chrome_frame_test_utils.h"
-DISABLE_RUNNABLE_METHOD_REFCOUNT(InfobarContent::Frame);
-DISABLE_RUNNABLE_METHOD_REFCOUNT(InfobarManager);
-
namespace {
RECT kInitialParentWindowRect = {20, 20, 300, 300};
@@ -404,17 +403,13 @@ ACTION_P(ResetFlag, flag) {
}
ACTION_P2(AsynchronousCloseOnFrame, loop, frame) {
- loop->PostDelayedTask(
- FROM_HERE,
- NewRunnableMethod(*frame, &InfobarContent::Frame::CloseInfobar),
- 0);
+ loop->PostTask(FROM_HERE, base::Bind(&InfobarContent::Frame::CloseInfobar,
+ base::Unretained(*frame)));
}
ACTION_P2(AsynchronousHideOnManager, loop, manager) {
- loop->PostDelayedTask(
- FROM_HERE,
- NewRunnableMethod(manager, &InfobarManager::Hide, TOP_INFOBAR),
- 0);
+ loop->PostTask(FROM_HERE, base::Bind(&InfobarManager::Hide,
+ base::Unretained(manager), TOP_INFOBAR));
}
}; // namespace
diff --git a/chrome_frame/test/mock_ie_event_sink_actions.h b/chrome_frame/test/mock_ie_event_sink_actions.h
index 6e15563..fc57b53 100644
--- a/chrome_frame/test/mock_ie_event_sink_actions.h
+++ b/chrome_frame/test/mock_ie_event_sink_actions.h
@@ -9,6 +9,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/bind.h"
#include "base/threading/platform_thread.h"
#include "base/time.h"
#include "chrome/common/chrome_switches.h"
@@ -38,8 +39,8 @@ ACTION_P2(Navigate, mock, navigate_url) {
}
ACTION_P3(DelayNavigateToCurrentUrl, mock, loop, delay) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(&NavigateToCurrentUrl,
- mock), delay);
+ loop->PostDelayedTask(FROM_HERE,
+ base::Bind(&NavigateToCurrentUrl, mock), delay);
}
ACTION_P(CloseBrowserMock, mock) {
@@ -47,8 +48,11 @@ ACTION_P(CloseBrowserMock, mock) {
}
ACTION_P3(DelayCloseBrowserMock, loop, delay, mock) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(),
- &IEEventSink::CloseWebBrowser), delay);
+ loop->PostDelayedTask(
+ FROM_HERE,
+ base::IgnoreReturn<HRESULT>(
+ base::Bind(&IEEventSink::CloseWebBrowser, mock->event_sink())),
+ delay);
}
ACTION_P2(ConnectDocPropNotifySink, mock, sink) {
@@ -66,24 +70,27 @@ ACTION_P(DisconnectDocPropNotifySink, sink) {
ACTION_P8(DelayExecCommand, mock, loop, delay, cmd_group_guid, cmd_id,
cmd_exec_opt, in_args, out_args) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(),
- &IEEventSink::Exec, cmd_group_guid, cmd_id, cmd_exec_opt, in_args,
- out_args), delay);
+ loop->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&IEEventSink::Exec, mock->event_sink(), cmd_group_guid, cmd_id,
+ cmd_exec_opt, in_args, out_args),
+ delay);
}
ACTION_P3(DelayGoBack, mock, loop, delay) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(),
- &IEEventSink::GoBack), delay);
+ loop->PostDelayedTask(
+ FROM_HERE, base::Bind(&IEEventSink::GoBack, mock->event_sink()), delay);
}
ACTION_P3(DelayGoForward, mock, loop, delay) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(),
- &IEEventSink::GoForward), delay);
+ loop->PostDelayedTask(
+ FROM_HERE, base::Bind(&IEEventSink::GoForward, mock->event_sink()),
+ delay);
}
ACTION_P3(DelayRefresh, mock, loop, delay) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(),
- &IEEventSink::Refresh), delay);
+ loop->PostDelayedTask(
+ FROM_HERE, base::Bind(&IEEventSink::Refresh, mock->event_sink()), delay);
}
ACTION_P2(PostMessageToCF, mock, message) {
@@ -269,9 +276,7 @@ ACTION(DoCloseWindow) {
ACTION_P(DelayDoCloseWindow, delay) {
DCHECK(MessageLoop::current());
MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- NewRunnableFunction(DoCloseWindowNow, arg0),
- delay);
+ FROM_HERE, base::Bind(DoCloseWindowNow, arg0), delay);
}
ACTION(KillChromeFrameProcesses) {
@@ -375,31 +380,32 @@ ACTION_P(SetFocusToRenderer, mock) {
}
ACTION_P4(DelaySendChar, loop, delay, c, mod) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
- simulate_input::SendCharA, c, mod), delay);
+ loop->PostDelayedTask(
+ FROM_HERE, base::Bind(simulate_input::SendCharA, c, mod), delay);
}
ACTION_P4(DelaySendScanCode, loop, delay, c, mod) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
- simulate_input::SendScanCode, c, mod), delay);
+ loop->PostDelayedTask(
+ FROM_HERE, base::Bind(simulate_input::SendScanCode, c, mod), delay);
}
// This function selects the address bar via the Alt+d shortcut.
ACTION_P3(TypeUrlInAddressBar, loop, url, delay) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
- simulate_input::SendCharA, 'd', simulate_input::ALT),
- delay);
+ loop->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(simulate_input::SendCharA, 'd', simulate_input::ALT), delay);
const unsigned int kInterval = 500;
int next_delay = delay + kInterval;
- loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
- simulate_input::SendStringW, url), next_delay);
+ loop->PostDelayedTask(
+ FROM_HERE, base::Bind(simulate_input::SendStringW, url), next_delay);
next_delay = next_delay + kInterval;
- loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
- simulate_input::SendCharA, VK_RETURN, simulate_input::NONE),
+ loop->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(simulate_input::SendCharA, VK_RETURN, simulate_input::NONE),
next_delay);
}
diff --git a/chrome_frame/test/proxy_factory_mock.cc b/chrome_frame/test/proxy_factory_mock.cc
index e8f8ba7..5b6ecbc 100644
--- a/chrome_frame/test/proxy_factory_mock.cc
+++ b/chrome_frame/test/proxy_factory_mock.cc
@@ -1,6 +1,7 @@
-// Copyright (c) 2006-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.
+
#include "base/synchronization/waitable_event.h"
#include "chrome_frame/crash_reporting/crash_metrics.h"
#include "chrome_frame/test/proxy_factory_mock.h"
@@ -11,8 +12,6 @@
using testing::CreateFunctor;
using testing::_;
-DISABLE_RUNNABLE_METHOD_REFCOUNT(MockProxyFactory);
-
TEST(ProxyFactoryTest, CreateDestroy) {
CrashMetricsReporter::GetInstance()->set_active(true);
diff --git a/chrome_frame/test/test_server.cc b/chrome_frame/test/test_server.cc
index c43c5ef..f2d7de3 100644
--- a/chrome_frame/test/test_server.cc
+++ b/chrome_frame/test/test_server.cc
@@ -6,6 +6,7 @@
#include <objbase.h>
#include <urlmon.h>
+#include "base/bind.h"
#include "base/logging.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
@@ -324,8 +325,9 @@ void ConfigurableConnection::SendChunk() {
cur_pos_ += bytes_to_send;
if (cur_pos_ < size) {
- MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod(this,
- &ConfigurableConnection::SendChunk), options_.timeout_);
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE, base::Bind(&ConfigurableConnection::SendChunk, this),
+ options_.timeout_);
} else {
socket_ = 0; // close the connection.
}
@@ -371,9 +373,9 @@ void ConfigurableConnection::SendWithOptions(const std::string& headers,
data_.append("\r\n");
}
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- NewRunnableMethod(this, &ConfigurableConnection::SendChunk),
- options.timeout_);
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE, base::Bind(&ConfigurableConnection::SendChunk, this),
+ options.timeout_);
}
} // namespace test_server
diff --git a/chrome_frame/test/url_request_test.cc b/chrome_frame/test/url_request_test.cc
index f91fb9e..9274cce 100644
--- a/chrome_frame/test/url_request_test.cc
+++ b/chrome_frame/test/url_request_test.cc
@@ -5,6 +5,8 @@
#include <atlbase.h>
#include <atlcom.h>
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/win/scoped_com_initializer.h"
#include "chrome/common/automation_messages.h"
#include "chrome_frame/test/chrome_frame_test_utils.h"
@@ -50,13 +52,12 @@ class MockUrlDelegate : public PluginUrlRequestDelegate {
static bool ImplementsThreadSafeReferenceCounting() {
return false;
}
- void AddRef() {}
- void Release() {}
void PostponeReadRequest(chrome_frame_test::TimedMsgLoop* loop,
UrlmonUrlRequest* request, int bytes_to_read) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(this,
- &MockUrlDelegate::RequestRead, request, bytes_to_read), 0);
+ loop->PostTask(FROM_HERE,
+ base::Bind(&MockUrlDelegate::RequestRead,
+ base::Unretained(this), request, bytes_to_read));
}
private:
@@ -243,14 +244,14 @@ TEST(UrlmonUrlRequestTest, ZeroLengthResponse) {
}
ACTION_P4(ManagerRead, loop, mgr, request_id, bytes_to_read) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mgr,
- &UrlmonUrlRequestManager::ReadUrlRequest, request_id,
- bytes_to_read), 0);
+ loop->PostTask(FROM_HERE,
+ base::Bind(&UrlmonUrlRequestManager::ReadUrlRequest,
+ base::Unretained(mgr), request_id, bytes_to_read));
}
ACTION_P3(ManagerEndRequest, loop, mgr, request_id) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mgr,
- &UrlmonUrlRequestManager::EndUrlRequest, request_id,
- net::URLRequestStatus()), 0);
+ loop->PostTask(FROM_HERE, base::Bind(&UrlmonUrlRequestManager::EndUrlRequest,
+ base::Unretained(mgr), request_id,
+ net::URLRequestStatus()));
}
// Simplest test - retrieve file from local web server.
diff --git a/chrome_frame/test/win_event_receiver.cc b/chrome_frame/test/win_event_receiver.cc
index a187556..045a48c 100644
--- a/chrome_frame/test/win_event_receiver.cc
+++ b/chrome_frame/test/win_event_receiver.cc
@@ -1,14 +1,15 @@
-// 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.
#include "chrome_frame/test/win_event_receiver.h"
+#include "base/bind.h"
#include "base/logging.h"
+#include "base/memory/weak_ptr.h"
#include "base/message_loop.h"
#include "base/win/object_watcher.h"
#include "base/string_util.h"
-
#include "chrome_frame/function_stub.h"
// WinEventReceiver methods
@@ -93,7 +94,7 @@ class WindowWatchdog::ProcessExitObserver
HANDLE process_handle_;
HWND hwnd_;
- ScopedRunnableMethodFactory<ProcessExitObserver> method_task_factory_;
+ base::WeakPtrFactory<ProcessExitObserver> weak_factory_;
base::win::ObjectWatcher object_watcher_;
DISALLOW_COPY_AND_ASSIGN(ProcessExitObserver);
@@ -104,7 +105,7 @@ WindowWatchdog::ProcessExitObserver::ProcessExitObserver(
: window_watchdog_(window_watchdog),
process_handle_(NULL),
hwnd_(hwnd),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_task_factory_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
DWORD pid = 0;
::GetWindowThreadProcessId(hwnd, &pid);
if (pid != 0) {
@@ -116,9 +117,8 @@ WindowWatchdog::ProcessExitObserver::ProcessExitObserver(
} else {
// Process is gone, so the window must be gone too. Notify our observer!
MessageLoop::current()->PostTask(
- FROM_HERE,
- method_task_factory_.NewRunnableMethod(
- &ProcessExitObserver::OnObjectSignaled, HANDLE(NULL)));
+ FROM_HERE, base::Bind(&ProcessExitObserver::OnObjectSignaled,
+ weak_factory_.GetWeakPtr(), HANDLE(NULL)));
}
}
diff --git a/chrome_frame/urlmon_url_request.cc b/chrome_frame/urlmon_url_request.cc
index ea903da..ee0fa6b 100644
--- a/chrome_frame/urlmon_url_request.cc
+++ b/chrome_frame/urlmon_url_request.cc
@@ -7,7 +7,8 @@
#include <urlmon.h>
#include <wininet.h>
-#include "base/callback_old.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
@@ -162,21 +163,20 @@ HRESULT UrlmonUrlRequest::InitPending(const GURL& url, IMoniker* moniker,
return S_OK;
}
-void UrlmonUrlRequest::TerminateBind(TerminateBindCallback* callback) {
+void UrlmonUrlRequest::TerminateBind(const TerminateBindCallback& callback) {
DCHECK_EQ(thread_, base::PlatformThread::CurrentId());
DVLOG(1) << __FUNCTION__ << me();
cleanup_transaction_ = false;
if (status_.get_state() == Status::DONE) {
// Binding is stopped. Note result could be an error.
- callback->Run(moniker_, bind_context_, upload_data_,
- request_headers_.c_str());
- delete callback;
+ callback.Run(moniker_, bind_context_, upload_data_,
+ request_headers_.c_str());
} else {
// WORKING (ABORTING?). Save the callback.
// Now we will return INET_TERMINATE_BIND from ::OnDataAvailable() and in
// ::OnStopBinding will invoke the callback passing our moniker and
// bind context.
- terminate_bind_callback_.reset(callback);
+ terminate_bind_callback_ = callback;
if (pending_data_) {
// For downloads to work correctly, we must induce a call to
// OnDataAvailable so that we can download INET_E_TERMINATED_BIND and
@@ -369,8 +369,8 @@ STDMETHODIMP UrlmonUrlRequest::OnStopBinding(HRESULT result, LPCWSTR error) {
if (result == INET_E_TERMINATED_BIND) {
if (terminate_requested()) {
- terminate_bind_callback_->Run(moniker_, bind_context_, upload_data_,
- request_headers_.c_str());
+ terminate_bind_callback_.Run(moniker_, bind_context_, upload_data_,
+ request_headers_.c_str());
} else {
cleanup_transaction_ = true;
}
@@ -1020,9 +1020,9 @@ void UrlmonUrlRequestManager::StartRequest(int request_id,
<< " on background thread";
background_thread_->message_loop()->PostTask(
FROM_HERE,
- NewRunnableMethod(this, &UrlmonUrlRequestManager::StartRequestHelper,
- request_id, request_info, &background_request_map_,
- &background_resource_map_lock_));
+ base::Bind(&UrlmonUrlRequestManager::StartRequestHelper,
+ base::Unretained(this), request_id, request_info,
+ &background_request_map_, &background_resource_map_lock_));
return;
}
StartRequestHelper(request_id, request_info, &request_map_, NULL);
@@ -1106,9 +1106,8 @@ void UrlmonUrlRequestManager::ReadRequest(int request_id, int bytes_to_read) {
request = LookupRequest(request_id, &background_request_map_);
if (request) {
background_thread_->message_loop()->PostTask(
- FROM_HERE,
- NewRunnableMethod(request.get(),
- &UrlmonUrlRequest::Read, bytes_to_read));
+ FROM_HERE, base::IgnoreReturn<bool>(base::Bind(
+ &UrlmonUrlRequest::Read, request.get(), bytes_to_read)));
}
}
if (!request)
@@ -1133,10 +1132,8 @@ void UrlmonUrlRequestManager::DownloadRequestInHost(int request_id) {
if (request) {
background_thread_->message_loop()->PostTask(
FROM_HERE,
- NewRunnableMethod(
- this,
- &UrlmonUrlRequestManager::DownloadRequestInHostHelper,
- request.get()));
+ base::Bind(&UrlmonUrlRequestManager::DownloadRequestInHostHelper,
+ base::Unretained(this), request.get()));
}
}
if (!request)
@@ -1146,8 +1143,9 @@ void UrlmonUrlRequestManager::DownloadRequestInHost(int request_id) {
void UrlmonUrlRequestManager::DownloadRequestInHostHelper(
UrlmonUrlRequest* request) {
DCHECK(request);
- UrlmonUrlRequest::TerminateBindCallback* callback = NewCallback(this,
- &UrlmonUrlRequestManager::BindTerminated);
+ UrlmonUrlRequest::TerminateBindCallback callback =
+ base::Bind(&UrlmonUrlRequestManager::BindTerminated,
+ base::Unretained(this));
request->TerminateBind(callback);
}
@@ -1233,8 +1231,7 @@ void UrlmonUrlRequestManager::EndRequest(int request_id) {
if (request) {
background_request_map_.erase(request_id);
background_thread_->message_loop()->PostTask(
- FROM_HERE,
- NewRunnableMethod(request.get(), &UrlmonUrlRequest::Stop));
+ FROM_HERE, base::Bind(&UrlmonUrlRequest::Stop, request.get()));
}
}
if (!request)
@@ -1256,10 +1253,9 @@ void UrlmonUrlRequestManager::StopAll() {
if (background_worker_thread_enabled_) {
DCHECK(background_thread_.get());
background_thread_->message_loop()->PostTask(
- FROM_HERE,
- NewRunnableMethod(
- this, &UrlmonUrlRequestManager::StopAllRequestsHelper,
- &background_request_map_, &background_resource_map_lock_));
+ FROM_HERE, base::Bind(&UrlmonUrlRequestManager::StopAllRequestsHelper,
+ base::Unretained(this), &background_request_map_,
+ &background_resource_map_lock_));
background_thread_->Stop();
background_thread_.reset();
}
diff --git a/chrome_frame/urlmon_url_request.h b/chrome_frame/urlmon_url_request.h
index 8967d9f..037de1d 100644
--- a/chrome_frame/urlmon_url_request.h
+++ b/chrome_frame/urlmon_url_request.h
@@ -83,13 +83,6 @@ class UrlmonUrlRequestManager
private:
friend class MessageLoop;
- friend struct RunnableMethodTraits<UrlmonUrlRequestManager>;
-
- // This method is needed to support PostTask on this object.
- static bool ImplementsThreadSafeReferenceCounting() { return true; }
-
- void AddRef() {}
- void Release() {}
// PluginUrlRequestManager implementation.
virtual PluginUrlRequestManager::ThreadSafeFlags GetThreadSafeFlags();
diff --git a/chrome_frame/urlmon_url_request_private.h b/chrome_frame/urlmon_url_request_private.h
index ad4a691..1ce650b 100644
--- a/chrome_frame/urlmon_url_request_private.h
+++ b/chrome_frame/urlmon_url_request_private.h
@@ -38,9 +38,9 @@ class UrlmonUrlRequest
// Used from "DownloadRequestInHost".
// Callback will be invoked either right away (if operation is finished) or
// from inside ::OnStopBinding() when it is safe to reuse the bind_context.
- typedef Callback4<IMoniker*, IBindCtx*, IStream*, const char*>::Type
+ typedef base::Callback<void(IMoniker*, IBindCtx*, IStream*, const char*)>
TerminateBindCallback;
- void TerminateBind(TerminateBindCallback* callback);
+ void TerminateBind(const TerminateBindCallback& callback);
// Parent Window for UrlMon error dialogs
void set_parent_window(HWND parent_window) {
@@ -118,7 +118,7 @@ class UrlmonUrlRequest
}
bool terminate_requested() const {
- return terminate_bind_callback_.get() != NULL;
+ return !terminate_bind_callback_.is_null();
}
std::string response_headers() {
@@ -245,7 +245,7 @@ class UrlmonUrlRequest
// Set to true if the ChromeFrame instance is running in privileged mode.
bool privileged_mode_;
bool pending_;
- scoped_ptr<TerminateBindCallback> terminate_bind_callback_;
+ TerminateBindCallback terminate_bind_callback_;
std::string response_headers_;
// Defaults to true and indicates whether we want to keep the original
// transaction alive when we receive the last data notification from