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

Unified Diff: base/message_loop.cc

Issue 6094005: Create "Prebind" a wrapper to tr1::bind. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/base
Patch Set: Remove closure.h and ThunkState Created 9 years, 12 months 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 | « base/message_loop.h ('k') | base/prebind.h » ('j') | base/prebind.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop.cc
diff --git a/base/message_loop.cc b/base/message_loop.cc
index 49d76a03bfed8c8ad9d8775b83fc4ecac67759fe..fd1c24f62bf7408db8a31611b8c12c780d86908d 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -306,6 +306,30 @@ void MessageLoop::QuitNow() {
}
}
+// This is a complete hack just for the proof of concept. Really, we want
+// to modify PendingTask to understand base::Thunk.
+class ThunkTaskAdapter : public Task {
+ public:
+ explicit ThunkTaskAdapter(base::Thunk<void(void)> t)
+ : thunk_(t) {
+ }
+
+ virtual void Run() {
+ thunk_();
+ }
+
+ private:
+ base::Thunk<void(void)> thunk_;
+};
+
+void MessageLoop::PostThunk(
+ const tracked_objects::Location& from_here,
+ base::Thunk<void(void)> thunk) {
+ // The wrapping of Thunk in Task will screw up task tracking...that will be
+ // fixed if we correctly refactor message loop's PendingTask.
+ PostTask_Helper(from_here, new ThunkTaskAdapter(thunk), 0, true);
+}
+
void MessageLoop::PostTask(
const tracked_objects::Location& from_here, Task* task) {
PostTask_Helper(from_here, task, 0, true);
@@ -316,6 +340,15 @@ void MessageLoop::PostDelayedTask(
PostTask_Helper(from_here, task, delay_ms, true);
}
+void MessageLoop::PostDelayedThunk(
+ const tracked_objects::Location& from_here,
+ base::Thunk<void(void)> thunk,
+ int64 delay_ms) {
+ // The wrapping of Closure in Task will screw up task tracking...that will be
+ // fixed if we correctly refactor message loop's PendingTask.
+ PostTask_Helper(from_here, new ThunkTaskAdapter(thunk), delay_ms, true);
+}
+
void MessageLoop::PostNonNestableTask(
const tracked_objects::Location& from_here, Task* task) {
PostTask_Helper(from_here, task, 0, false);
« no previous file with comments | « base/message_loop.h ('k') | base/prebind.h » ('j') | base/prebind.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698