Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7672)

Unified Diff: chrome_frame/chrome_frame_delegate.h

Issue 8555001: base::Bind: Convert chrome_frame/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: TaskMarshaller fix. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome_frame/chrome_frame_automation.cc ('k') | chrome_frame/custom_sync_call_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_frame/chrome_frame_delegate.h
diff --git a/chrome_frame/chrome_frame_delegate.h b/chrome_frame/chrome_frame_delegate.h
index d2e992153ff3985907ffa04138b18fb078c419f6..d95347ad55f91a2549d83d5493c35d46c7724732 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,17 @@ 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 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 +162,7 @@ template <class T> class TaskMarshallerThroughWindowsMessages
<< pending_tasks_.size()
<< " pending tasks";
while (!pending_tasks_.empty()) {
- Task* task = pending_tasks_.front();
+ PendingTask* task = pending_tasks_.front();
pending_tasks_.pop();
delete task;
}
@@ -176,9 +176,9 @@ 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);
+ base::PendingTask* task = reinterpret_cast<base::PendingTask*>(wparam);
if (task && PopTask(task)) {
- task->Run();
+ task->task.Run();
awong 2011/11/18 02:21:10 Being OCD...but can we call the local variable pen
James Hawkins 2011/11/18 02:24:44 Done.
delete task;
}
@@ -187,7 +187,7 @@ template <class T> class TaskMarshallerThroughWindowsMessages
return 0;
}
- inline void PushTask(Task* task) {
+ inline void PushTask(base::PendingTask* task) {
base::AutoLock lock(lock_);
pending_tasks_.push(task);
}
@@ -195,7 +195,7 @@ template <class T> class TaskMarshallerThroughWindowsMessages
// If the given 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(PendingTask* task) {
base::AutoLock lock(lock_);
if (!pending_tasks_.empty() && task == pending_tasks_.front()) {
pending_tasks_.pop();
@@ -206,7 +206,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_
« no previous file with comments | « chrome_frame/chrome_frame_automation.cc ('k') | chrome_frame/custom_sync_call_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698