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

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: Closure example ported to Prebinds Created 10 years 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
Index: base/message_loop.cc
diff --git a/base/message_loop.cc b/base/message_loop.cc
index 49d76a03bfed8c8ad9d8775b83fc4ecac67759fe..929127813338dd1aad0d0bdb84d0015f7101f610 100644
--- a/base/message_loop.cc
+++ b/base/message_loop.cc
@@ -306,6 +306,32 @@ void MessageLoop::QuitNow() {
}
}
+// This is a complete hack just for the proof of concept. Really, we want
+// to modify PendingTask to understand base::Closure.
+class ClosureTaskAdapter : public Task {
+ public:
+ explicit ClosureTaskAdapter(const tracked_objects::Location& from_here,
+ base::Closure c)
+ : closure_(c) {
+ closure_.tracked()->SetBirthPlace(from_here);
+ }
+
+ virtual void Run() {
+ closure_();
+ }
+
+ private:
+ base::Closure closure_;
+};
+
+void MessageLoop::PostClosure(
+ const tracked_objects::Location& from_here, base::Closure closure) {
+ // 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 ClosureTaskAdapter(from_here, closure), 0,
+ true);
+}
+
void MessageLoop::PostTask(
const tracked_objects::Location& from_here, Task* task) {
PostTask_Helper(from_here, task, 0, true);
@@ -316,6 +342,15 @@ void MessageLoop::PostDelayedTask(
PostTask_Helper(from_here, task, delay_ms, true);
}
+void MessageLoop::PostDelayedClosure(
+ const tracked_objects::Location& from_here, base::Closure closure,
+ 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 ClosureTaskAdapter(from_here, closure),
+ delay_ms, true);
+}
+
void MessageLoop::PostNonNestableTask(
const tracked_objects::Location& from_here, Task* task) {
PostTask_Helper(from_here, task, 0, false);

Powered by Google App Engine
This is Rietveld 408576698