base::Bind: Convert chrome_frame/.
BUG=none
TEST=none
[email protected]
Review URL: http://codereview.chromium.org/8555001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110744 0039d316-1c4b-4281-b951-d872f2087c98
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 @@
virtual ~ChromeFrameDelegate() {}
};
-// Disable refcounting of ChromeFrameDelegate.
-DISABLE_RUNNABLE_METHOD_REFCOUNT(ChromeFrameDelegate);
-
extern UINT kAutomationServerReady;
extern UINT kMessageFromChromeFrame;
@@ -92,7 +91,7 @@
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 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 @@
: 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 @@
<< 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 @@
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 @@
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 @@
}
base::Lock lock_;
- std::queue<Task*> pending_tasks_;
+ std::queue<base::PendingTask*> pending_tasks_;
};
#endif // CHROME_FRAME_CHROME_FRAME_DELEGATE_H_