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

Side by Side Diff: base/message_loop.cc

Issue 3076015: Delete tasks unconditionally in MessageLoop::DeletePendingTasks(). (Closed)
Patch Set: Created 10 years, 4 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 | no next file » | 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) 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/histogram.h" 10 #include "base/histogram.h"
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 bool did_work = !work_queue_.empty(); 459 bool did_work = !work_queue_.empty();
460 while (!work_queue_.empty()) { 460 while (!work_queue_.empty()) {
461 PendingTask pending_task = work_queue_.front(); 461 PendingTask pending_task = work_queue_.front();
462 work_queue_.pop(); 462 work_queue_.pop();
463 if (!pending_task.delayed_run_time.is_null()) { 463 if (!pending_task.delayed_run_time.is_null()) {
464 // We want to delete delayed tasks in the same order in which they would 464 // We want to delete delayed tasks in the same order in which they would
465 // normally be deleted in case of any funny dependencies between delayed 465 // normally be deleted in case of any funny dependencies between delayed
466 // tasks. 466 // tasks.
467 AddToDelayedWorkQueue(pending_task); 467 AddToDelayedWorkQueue(pending_task);
468 } else { 468 } else {
469 // TODO(darin): Delete all tasks once it is safe to do so.
470 // Until it is totally safe, just do it when running Purify or
471 // Valgrind.
472 #if defined(PURIFY)
473 delete pending_task.task; 469 delete pending_task.task;
474 #elif defined(OS_POSIX)
475 if (RUNNING_ON_VALGRIND)
476 delete pending_task.task;
477 #endif // defined(OS_POSIX)
478 } 470 }
479 } 471 }
480 did_work |= !deferred_non_nestable_work_queue_.empty(); 472 did_work |= !deferred_non_nestable_work_queue_.empty();
481 while (!deferred_non_nestable_work_queue_.empty()) { 473 while (!deferred_non_nestable_work_queue_.empty()) {
482 // TODO(darin): Delete all tasks once it is safe to do so. 474 delete deferred_non_nestable_work_queue_.front().task;
483 // Until it is totaly safe, only delete them under Purify and Valgrind.
484 Task* task = NULL;
485 #if defined(PURIFY)
486 task = deferred_non_nestable_work_queue_.front().task;
487 #elif defined(OS_POSIX)
488 if (RUNNING_ON_VALGRIND)
489 task = deferred_non_nestable_work_queue_.front().task;
490 #endif
491 deferred_non_nestable_work_queue_.pop(); 475 deferred_non_nestable_work_queue_.pop();
492 if (task)
493 delete task;
494 } 476 }
495 did_work |= !delayed_work_queue_.empty(); 477 did_work |= !delayed_work_queue_.empty();
496 while (!delayed_work_queue_.empty()) { 478 while (!delayed_work_queue_.empty()) {
497 Task* task = delayed_work_queue_.top().task; 479 delete delayed_work_queue_.top().task;
jar (doing other things) 2010/08/03 02:40:35 A task deletion may have a side effect, which may
498 delayed_work_queue_.pop(); 480 delayed_work_queue_.pop();
499 delete task;
500 } 481 }
501 return did_work; 482 return did_work;
502 } 483 }
503 484
504 bool MessageLoop::DoWork() { 485 bool MessageLoop::DoWork() {
505 if (!nestable_tasks_allowed_) { 486 if (!nestable_tasks_allowed_) {
506 // Task can't be executed right now. 487 // Task can't be executed right now.
507 return false; 488 return false;
508 } 489 }
509 490
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 Watcher *delegate) { 659 Watcher *delegate) {
679 return pump_libevent()->WatchFileDescriptor( 660 return pump_libevent()->WatchFileDescriptor(
680 fd, 661 fd,
681 persistent, 662 persistent,
682 static_cast<base::MessagePumpLibevent::Mode>(mode), 663 static_cast<base::MessagePumpLibevent::Mode>(mode),
683 controller, 664 controller,
684 delegate); 665 delegate);
685 } 666 }
686 667
687 #endif 668 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698