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

Side by Side Diff: base/message_loop.h

Issue 6374010: Add MessageLoop::AssertIdle(). Use in ChromeOS audio threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « no previous file | base/message_loop.cc » ('j') | base/message_loop.cc » ('J')
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 #ifndef BASE_MESSAGE_LOOP_H_ 5 #ifndef BASE_MESSAGE_LOOP_H_
6 #define BASE_MESSAGE_LOOP_H_ 6 #define BASE_MESSAGE_LOOP_H_
7 #pragma once 7 #pragma once
8 8
9 #include <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 return !high_resolution_timer_expiration_.is_null(); 308 return !high_resolution_timer_expiration_.is_null();
309 #else 309 #else
310 return true; 310 return true;
311 #endif 311 #endif
312 } 312 }
313 313
314 // When we go into high resolution timer mode, we will stay in hi-res mode 314 // When we go into high resolution timer mode, we will stay in hi-res mode
315 // for at least 1s. 315 // for at least 1s.
316 static const int kHighResolutionTimerModeLeaseTimeMs = 1000; 316 static const int kHighResolutionTimerModeLeaseTimeMs = 1000;
317 317
318 // Asserts that the MessageLoop is "idle". in reality, we only check
319 // |incoming_queue_|, since we don't want to lock |work_queue_|.
320 void AssertIdle() const;
321
318 //---------------------------------------------------------------------------- 322 //----------------------------------------------------------------------------
319 protected: 323 protected:
320 struct RunState { 324 struct RunState {
321 // Used to count how many Run() invocations are on the stack. 325 // Used to count how many Run() invocations are on the stack.
322 int run_depth; 326 int run_depth;
323 327
324 // Used to record that Quit() was called, or that we should quit the pump 328 // Used to record that Quit() was called, or that we should quit the pump
325 // once it becomes idle. 329 // once it becomes idle.
326 bool quit_received; 330 bool quit_received;
327 331
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 // insider a (accidentally induced?) nested message pump. 458 // insider a (accidentally induced?) nested message pump.
455 bool nestable_tasks_allowed_; 459 bool nestable_tasks_allowed_;
456 460
457 bool exception_restoration_; 461 bool exception_restoration_;
458 462
459 std::string thread_name_; 463 std::string thread_name_;
460 // A profiling histogram showing the counts of various messages and events. 464 // A profiling histogram showing the counts of various messages and events.
461 scoped_refptr<base::Histogram> message_histogram_; 465 scoped_refptr<base::Histogram> message_histogram_;
462 466
463 // A null terminated list which creates an incoming_queue of tasks that are 467 // A null terminated list which creates an incoming_queue of tasks that are
464 // aquired under a mutex for processing on this instance's thread. These tasks 468 // acquired under a mutex for processing on this instance's thread. These task s
465 // have not yet been sorted out into items for our work_queue_ vs items that 469 // have not yet been sorted out into items for our work_queue_ vs items that
466 // will be handled by the TimerManager. 470 // will be handled by the TimerManager.
467 TaskQueue incoming_queue_; 471 TaskQueue incoming_queue_;
468 // Protect access to incoming_queue_. 472 // Protect access to incoming_queue_.
469 base::Lock incoming_queue_lock_; 473 mutable base::Lock incoming_queue_lock_;
470 474
471 RunState* state_; 475 RunState* state_;
472 476
473 #if defined(OS_WIN) 477 #if defined(OS_WIN)
474 base::TimeTicks high_resolution_timer_expiration_; 478 base::TimeTicks high_resolution_timer_expiration_;
475 #endif 479 #endif
476 480
477 // The next sequence number to use for delayed tasks. 481 // The next sequence number to use for delayed tasks.
478 int next_sequence_num_; 482 int next_sequence_num_;
479 483
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 #endif // defined(OS_POSIX) 601 #endif // defined(OS_POSIX)
598 }; 602 };
599 603
600 // Do not add any member variables to MessageLoopForIO! This is important b/c 604 // Do not add any member variables to MessageLoopForIO! This is important b/c
601 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra 605 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra
602 // data that you need should be stored on the MessageLoop's pump_ instance. 606 // data that you need should be stored on the MessageLoop's pump_ instance.
603 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), 607 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO),
604 MessageLoopForIO_should_not_have_extra_member_variables); 608 MessageLoopForIO_should_not_have_extra_member_variables);
605 609
606 #endif // BASE_MESSAGE_LOOP_H_ 610 #endif // BASE_MESSAGE_LOOP_H_
OLDNEW
« no previous file with comments | « no previous file | base/message_loop.cc » ('j') | base/message_loop.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698