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

Side by Side Diff: base/message_loop.cc

Issue 115328: During shutdown delete any pending tasks if running under Valgrind. (Closed)
Patch Set: "code reviews fixes" Created 11 years, 7 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 | base/third_party/valgrind/README » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_pump_default.h" 12 #include "base/message_pump_default.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/thread_local.h" 14 #include "base/thread_local.h"
15 15
16 #if defined(OS_MACOSX) 16 #if defined(OS_MACOSX)
17 #include "base/message_pump_mac.h" 17 #include "base/message_pump_mac.h"
18 #endif 18 #endif
19 #if defined(OS_POSIX) 19 #if defined(OS_POSIX)
20 #include "base/message_pump_libevent.h" 20 #include "base/message_pump_libevent.h"
21 #include "base/third_party/valgrind/valgrind.h"
21 #endif 22 #endif
22 #if defined(OS_LINUX) 23 #if defined(OS_LINUX)
23 #include "base/message_pump_glib.h" 24 #include "base/message_pump_glib.h"
24 #endif 25 #endif
25 26
26 using base::Time; 27 using base::Time;
27 using base::TimeDelta; 28 using base::TimeDelta;
28 29
29 // A lazily created thread local storage for quick access to a thread's message 30 // A lazily created thread local storage for quick access to a thread's message
30 // loop, if one exists. This should be safe and free of static constructors. 31 // loop, if one exists. This should be safe and free of static constructors.
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 while (!work_queue_.empty()) { 359 while (!work_queue_.empty()) {
359 PendingTask pending_task = work_queue_.front(); 360 PendingTask pending_task = work_queue_.front();
360 work_queue_.pop(); 361 work_queue_.pop();
361 if (!pending_task.delayed_run_time.is_null()) { 362 if (!pending_task.delayed_run_time.is_null()) {
362 // We want to delete delayed tasks in the same order in which they would 363 // We want to delete delayed tasks in the same order in which they would
363 // normally be deleted in case of any funny dependencies between delayed 364 // normally be deleted in case of any funny dependencies between delayed
364 // tasks. 365 // tasks.
365 AddToDelayedWorkQueue(pending_task); 366 AddToDelayedWorkQueue(pending_task);
366 } else { 367 } else {
367 // TODO(darin): Delete all tasks once it is safe to do so. 368 // TODO(darin): Delete all tasks once it is safe to do so.
368 // Until it is totally safe, just do it when running purify. 369 // Until it is totally safe, just do it when running Purify or
370 // Valgrind.
371 #if defined(OS_WIN)
369 #ifdef PURIFY 372 #ifdef PURIFY
370 delete pending_task.task; 373 delete pending_task.task;
371 #endif // PURIFY 374 #endif // PURIFY
375 #elif defined(OS_POSIX)
376 if (RUNNING_ON_VALGRIND)
377 delete pending_task.task;
378 #endif // defined(OS_POSIX)
372 } 379 }
373 } 380 }
374 did_work |= !deferred_non_nestable_work_queue_.empty(); 381 did_work |= !deferred_non_nestable_work_queue_.empty();
375 while (!deferred_non_nestable_work_queue_.empty()) { 382 while (!deferred_non_nestable_work_queue_.empty()) {
376 // TODO(darin): Delete all tasks once it is safe to do so. 383 // TODO(darin): Delete all tasks once it is safe to do so.
377 // Until it is totaly safe, just delete them to keep purify happy. 384 // Until it is totaly safe, just delete them to keep purify happy.
378 #ifdef PURIFY 385 #ifdef PURIFY
379 Task* task = deferred_non_nestable_work_queue_.front().task; 386 Task* task = deferred_non_nestable_work_queue_.front().task;
380 #endif 387 #endif
381 deferred_non_nestable_work_queue_.pop(); 388 deferred_non_nestable_work_queue_.pop();
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 Watcher *delegate) { 615 Watcher *delegate) {
609 return pump_libevent()->WatchFileDescriptor( 616 return pump_libevent()->WatchFileDescriptor(
610 fd, 617 fd,
611 persistent, 618 persistent,
612 static_cast<base::MessagePumpLibevent::Mode>(mode), 619 static_cast<base::MessagePumpLibevent::Mode>(mode),
613 controller, 620 controller,
614 delegate); 621 delegate);
615 } 622 }
616 623
617 #endif 624 #endif
OLDNEW
« no previous file with comments | « no previous file | base/third_party/valgrind/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698