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

Side by Side Diff: base/message_loop.cc

Issue 8212006: base::Bind: Cleanup in automation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mac build fix. Created 9 years, 2 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
« no previous file with comments | « base/message_loop.h ('k') | chrome/browser/automation/automation_provider_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 base::Bind( 299 base::Bind(
300 &base::subtle::TaskClosureAdapter::Run, 300 &base::subtle::TaskClosureAdapter::Run,
301 new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)), 301 new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)),
302 from_here, 302 from_here,
303 CalculateDelayedRuntime(delay_ms), false); 303 CalculateDelayedRuntime(delay_ms), false);
304 AddToIncomingQueue(&pending_task); 304 AddToIncomingQueue(&pending_task);
305 } 305 }
306 306
307 void MessageLoop::PostTask( 307 void MessageLoop::PostTask(
308 const tracked_objects::Location& from_here, const base::Closure& task) { 308 const tracked_objects::Location& from_here, const base::Closure& task) {
309 CHECK(!task.is_null()); 309 CHECK(!task.is_null()) << from_here.ToString();
310 PendingTask pending_task(task, from_here, CalculateDelayedRuntime(0), true); 310 PendingTask pending_task(task, from_here, CalculateDelayedRuntime(0), true);
311 AddToIncomingQueue(&pending_task); 311 AddToIncomingQueue(&pending_task);
312 } 312 }
313 313
314 void MessageLoop::PostDelayedTask( 314 void MessageLoop::PostDelayedTask(
315 const tracked_objects::Location& from_here, const base::Closure& task, 315 const tracked_objects::Location& from_here, const base::Closure& task,
316 int64 delay_ms) { 316 int64 delay_ms) {
317 CHECK(!task.is_null()); 317 CHECK(!task.is_null()) << from_here.ToString();
318 PendingTask pending_task(task, from_here, 318 PendingTask pending_task(task, from_here,
319 CalculateDelayedRuntime(delay_ms), true); 319 CalculateDelayedRuntime(delay_ms), true);
320 AddToIncomingQueue(&pending_task); 320 AddToIncomingQueue(&pending_task);
321 } 321 }
322 322
323 void MessageLoop::PostNonNestableTask( 323 void MessageLoop::PostNonNestableTask(
324 const tracked_objects::Location& from_here, const base::Closure& task) { 324 const tracked_objects::Location& from_here, const base::Closure& task) {
325 CHECK(!task.is_null()); 325 CHECK(!task.is_null()) << from_here.ToString();
326 PendingTask pending_task(task, from_here, CalculateDelayedRuntime(0), false); 326 PendingTask pending_task(task, from_here, CalculateDelayedRuntime(0), false);
327 AddToIncomingQueue(&pending_task); 327 AddToIncomingQueue(&pending_task);
328 } 328 }
329 329
330 void MessageLoop::PostNonNestableDelayedTask( 330 void MessageLoop::PostNonNestableDelayedTask(
331 const tracked_objects::Location& from_here, const base::Closure& task, 331 const tracked_objects::Location& from_here, const base::Closure& task,
332 int64 delay_ms) { 332 int64 delay_ms) {
333 CHECK(!task.is_null()); 333 CHECK(!task.is_null()) << from_here.ToString();
334 PendingTask pending_task(task, from_here, 334 PendingTask pending_task(task, from_here,
335 CalculateDelayedRuntime(delay_ms), false); 335 CalculateDelayedRuntime(delay_ms), false);
336 AddToIncomingQueue(&pending_task); 336 AddToIncomingQueue(&pending_task);
337 } 337 }
338 338
339 void MessageLoop::Run() { 339 void MessageLoop::Run() {
340 AutoRunState save_state(this); 340 AutoRunState save_state(this);
341 RunHandler(); 341 RunHandler();
342 } 342 }
343 343
(...skipping 14 matching lines...) Expand all
358 358
359 void MessageLoop::QuitNow() { 359 void MessageLoop::QuitNow() {
360 DCHECK_EQ(this, current()); 360 DCHECK_EQ(this, current());
361 if (state_) { 361 if (state_) {
362 pump_->Quit(); 362 pump_->Quit();
363 } else { 363 } else {
364 NOTREACHED() << "Must be inside Run to call Quit"; 364 NOTREACHED() << "Must be inside Run to call Quit";
365 } 365 }
366 } 366 }
367 367
368 // static
369 base::Closure MessageLoop::QuitClosure() {
370 return base::Bind(&MessageLoop::Quit,
371 base::Unretained(MessageLoop::current()));
372 }
373
368 void MessageLoop::SetNestableTasksAllowed(bool allowed) { 374 void MessageLoop::SetNestableTasksAllowed(bool allowed) {
369 if (nestable_tasks_allowed_ != allowed) { 375 if (nestable_tasks_allowed_ != allowed) {
370 nestable_tasks_allowed_ = allowed; 376 nestable_tasks_allowed_ = allowed;
371 if (!nestable_tasks_allowed_) 377 if (!nestable_tasks_allowed_)
372 return; 378 return;
373 // Start the native pump if we are not already pumping. 379 // Start the native pump if we are not already pumping.
374 pump_->ScheduleWork(); 380 pump_->ScheduleWork();
375 } 381 }
376 } 382 }
377 383
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 Watcher *delegate) { 867 Watcher *delegate) {
862 return pump_libevent()->WatchFileDescriptor( 868 return pump_libevent()->WatchFileDescriptor(
863 fd, 869 fd,
864 persistent, 870 persistent,
865 static_cast<base::MessagePumpLibevent::Mode>(mode), 871 static_cast<base::MessagePumpLibevent::Mode>(mode),
866 controller, 872 controller,
867 delegate); 873 delegate);
868 } 874 }
869 875
870 #endif 876 #endif
OLDNEW
« no previous file with comments | « base/message_loop.h ('k') | chrome/browser/automation/automation_provider_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698