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

Side by Side 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, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/message_loop.h" 5 #include "base/message_loop.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 299
300 void MessageLoop::QuitNow() { 300 void MessageLoop::QuitNow() {
301 DCHECK_EQ(this, current()); 301 DCHECK_EQ(this, current());
302 if (state_) { 302 if (state_) {
303 pump_->Quit(); 303 pump_->Quit();
304 } else { 304 } else {
305 NOTREACHED() << "Must be inside Run to call Quit"; 305 NOTREACHED() << "Must be inside Run to call Quit";
306 } 306 }
307 } 307 }
308 308
309 // This is a complete hack just for the proof of concept. Really, we want
310 // to modify PendingTask to understand base::Thunk.
311 class ThunkTaskAdapter : public Task {
312 public:
313 explicit ThunkTaskAdapter(base::Thunk<void(void)> t)
314 : thunk_(t) {
315 }
316
317 virtual void Run() {
318 thunk_();
319 }
320
321 private:
322 base::Thunk<void(void)> thunk_;
323 };
324
325 void MessageLoop::PostThunk(
326 const tracked_objects::Location& from_here,
327 base::Thunk<void(void)> thunk) {
328 // The wrapping of Thunk in Task will screw up task tracking...that will be
329 // fixed if we correctly refactor message loop's PendingTask.
330 PostTask_Helper(from_here, new ThunkTaskAdapter(thunk), 0, true);
331 }
332
309 void MessageLoop::PostTask( 333 void MessageLoop::PostTask(
310 const tracked_objects::Location& from_here, Task* task) { 334 const tracked_objects::Location& from_here, Task* task) {
311 PostTask_Helper(from_here, task, 0, true); 335 PostTask_Helper(from_here, task, 0, true);
312 } 336 }
313 337
314 void MessageLoop::PostDelayedTask( 338 void MessageLoop::PostDelayedTask(
315 const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { 339 const tracked_objects::Location& from_here, Task* task, int64 delay_ms) {
316 PostTask_Helper(from_here, task, delay_ms, true); 340 PostTask_Helper(from_here, task, delay_ms, true);
317 } 341 }
318 342
343 void MessageLoop::PostDelayedThunk(
344 const tracked_objects::Location& from_here,
345 base::Thunk<void(void)> thunk,
346 int64 delay_ms) {
347 // The wrapping of Closure in Task will screw up task tracking...that will be
348 // fixed if we correctly refactor message loop's PendingTask.
349 PostTask_Helper(from_here, new ThunkTaskAdapter(thunk), delay_ms, true);
350 }
351
319 void MessageLoop::PostNonNestableTask( 352 void MessageLoop::PostNonNestableTask(
320 const tracked_objects::Location& from_here, Task* task) { 353 const tracked_objects::Location& from_here, Task* task) {
321 PostTask_Helper(from_here, task, 0, false); 354 PostTask_Helper(from_here, task, 0, false);
322 } 355 }
323 356
324 void MessageLoop::PostNonNestableDelayedTask( 357 void MessageLoop::PostNonNestableDelayedTask(
325 const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { 358 const tracked_objects::Location& from_here, Task* task, int64 delay_ms) {
326 PostTask_Helper(from_here, task, delay_ms, false); 359 PostTask_Helper(from_here, task, delay_ms, false);
327 } 360 }
328 361
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 Watcher *delegate) { 735 Watcher *delegate) {
703 return pump_libevent()->WatchFileDescriptor( 736 return pump_libevent()->WatchFileDescriptor(
704 fd, 737 fd,
705 persistent, 738 persistent,
706 static_cast<base::MessagePumpLibevent::Mode>(mode), 739 static_cast<base::MessagePumpLibevent::Mode>(mode),
707 controller, 740 controller,
708 delegate); 741 delegate);
709 } 742 }
710 743
711 #endif 744 #endif
OLDNEW
« 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