summaryrefslogtreecommitdiffstats
path: root/chrome_frame/chrome_frame_delegate.h
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 /chrome_frame/chrome_frame_delegate.h
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
Diffstat (limited to 'chrome_frame/chrome_frame_delegate.h')
-rw-r--r--chrome_frame/chrome_frame_delegate.h44
1 files changed, 23 insertions, 21 deletions
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_