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

Side by Side Diff: base/message_loop/message_loop.h

Issue 583043005: Pending tasks in a message loop should be deleted before shutting down Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | content/renderer/renderer_main.cc » ('j') | content/renderer/renderer_main.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_
6 #define BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ 6 #define BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 10
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 364
365 protected: 365 protected:
366 virtual ~TaskObserver(); 366 virtual ~TaskObserver();
367 }; 367 };
368 368
369 // These functions can only be called on the same thread that |this| is 369 // These functions can only be called on the same thread that |this| is
370 // running on. 370 // running on.
371 void AddTaskObserver(TaskObserver* task_observer); 371 void AddTaskObserver(TaskObserver* task_observer);
372 void RemoveTaskObserver(TaskObserver* task_observer); 372 void RemoveTaskObserver(TaskObserver* task_observer);
373 373
374 // Delete tasks that haven't run yet without running them. Used in the
375 // destructor to make sure all the task's destructors get called. Returns
376 // true if some work was done.
377 bool DeletePendingTasks();
jamesr 2014/09/22 14:38:03 this doesn't make sense. ~MessageLoop() does the
378
374 #if defined(OS_WIN) 379 #if defined(OS_WIN)
375 void set_os_modal_loop(bool os_modal_loop) { 380 void set_os_modal_loop(bool os_modal_loop) {
376 os_modal_loop_ = os_modal_loop; 381 os_modal_loop_ = os_modal_loop;
377 } 382 }
378 383
379 bool os_modal_loop() const { 384 bool os_modal_loop() const {
380 return os_modal_loop_; 385 return os_modal_loop_;
381 } 386 }
382 #endif // OS_WIN 387 #endif // OS_WIN
383 388
(...skipping 27 matching lines...) Expand all
411 // Runs the specified PendingTask. 416 // Runs the specified PendingTask.
412 void RunTask(const PendingTask& pending_task); 417 void RunTask(const PendingTask& pending_task);
413 418
414 // Calls RunTask or queues the pending_task on the deferred task list if it 419 // Calls RunTask or queues the pending_task on the deferred task list if it
415 // cannot be run right now. Returns true if the task was run. 420 // cannot be run right now. Returns true if the task was run.
416 bool DeferOrRunPendingTask(const PendingTask& pending_task); 421 bool DeferOrRunPendingTask(const PendingTask& pending_task);
417 422
418 // Adds the pending task to delayed_work_queue_. 423 // Adds the pending task to delayed_work_queue_.
419 void AddToDelayedWorkQueue(const PendingTask& pending_task); 424 void AddToDelayedWorkQueue(const PendingTask& pending_task);
420 425
421 // Delete tasks that haven't run yet without running them. Used in the
422 // destructor to make sure all the task's destructors get called. Returns
423 // true if some work was done.
424 bool DeletePendingTasks();
425
426 // Returns the TaskAnnotator which is used to add debug information to posted 426 // Returns the TaskAnnotator which is used to add debug information to posted
427 // tasks. 427 // tasks.
428 debug::TaskAnnotator* task_annotator() { return &task_annotator_; } 428 debug::TaskAnnotator* task_annotator() { return &task_annotator_; }
429 429
430 // Loads tasks from the incoming queue to |work_queue_| if the latter is 430 // Loads tasks from the incoming queue to |work_queue_| if the latter is
431 // empty. 431 // empty.
432 void ReloadWorkQueue(); 432 void ReloadWorkQueue();
433 433
434 // Wakes up the message pump. Can be called on any thread. The caller is 434 // Wakes up the message pump. Can be called on any thread. The caller is
435 // responsible for synchronizing ScheduleWork() calls. 435 // responsible for synchronizing ScheduleWork() calls.
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 650
651 // Do not add any member variables to MessageLoopForIO! This is important b/c 651 // Do not add any member variables to MessageLoopForIO! This is important b/c
652 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra 652 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra
653 // data that you need should be stored on the MessageLoop's pump_ instance. 653 // data that you need should be stored on the MessageLoop's pump_ instance.
654 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), 654 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO),
655 MessageLoopForIO_should_not_have_extra_member_variables); 655 MessageLoopForIO_should_not_have_extra_member_variables);
656 656
657 } // namespace base 657 } // namespace base
658 658
659 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ 659 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/renderer_main.cc » ('j') | content/renderer/renderer_main.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698