OLD | NEW |
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 |
11 #include "base/base_export.h" | 11 #include "base/base_export.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/message_loop/incoming_task_queue.h" | 17 #include "base/message_loop/incoming_task_queue.h" |
18 #include "base/message_loop/message_loop_proxy.h" | 18 #include "base/message_loop/message_loop_proxy.h" |
19 #include "base/message_loop/message_loop_proxy_impl.h" | 19 #include "base/message_loop/message_loop_proxy_impl.h" |
20 #include "base/message_loop/message_pump.h" | 20 #include "base/message_loop/message_pump.h" |
| 21 #include "base/message_loop/timer_slack.h" |
21 #include "base/observer_list.h" | 22 #include "base/observer_list.h" |
22 #include "base/pending_task.h" | 23 #include "base/pending_task.h" |
23 #include "base/sequenced_task_runner_helpers.h" | 24 #include "base/sequenced_task_runner_helpers.h" |
24 #include "base/synchronization/lock.h" | 25 #include "base/synchronization/lock.h" |
25 #include "base/time/time.h" | 26 #include "base/time/time.h" |
26 #include "base/tracking_info.h" | 27 #include "base/tracking_info.h" |
27 | 28 |
28 // TODO(sky): these includes should not be necessary. Nuke them. | 29 // TODO(sky): these includes should not be necessary. Nuke them. |
29 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
30 #include "base/message_loop/message_pump_win.h" | 31 #include "base/message_loop/message_pump_win.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 void QuitNow(); | 268 void QuitNow(); |
268 | 269 |
269 // TODO(jbates) remove this. crbug.com/131220. See QuitWhenIdleClosure(). | 270 // TODO(jbates) remove this. crbug.com/131220. See QuitWhenIdleClosure(). |
270 static Closure QuitClosure() { return QuitWhenIdleClosure(); } | 271 static Closure QuitClosure() { return QuitWhenIdleClosure(); } |
271 | 272 |
272 // Deprecated: use RunLoop instead. | 273 // Deprecated: use RunLoop instead. |
273 // Construct a Closure that will call QuitWhenIdle(). Useful to schedule an | 274 // Construct a Closure that will call QuitWhenIdle(). Useful to schedule an |
274 // arbitrary MessageLoop to QuitWhenIdle. | 275 // arbitrary MessageLoop to QuitWhenIdle. |
275 static Closure QuitWhenIdleClosure(); | 276 static Closure QuitWhenIdleClosure(); |
276 | 277 |
| 278 // Set the timer slack for this message loop. |
| 279 void SetTimerSlack(TimerSlack timer_slack) { |
| 280 pump_->SetTimerSlack(timer_slack); |
| 281 } |
| 282 |
277 // Returns true if this loop is |type|. This allows subclasses (especially | 283 // Returns true if this loop is |type|. This allows subclasses (especially |
278 // those in tests) to specialize how they are identified. | 284 // those in tests) to specialize how they are identified. |
279 virtual bool IsType(Type type) const; | 285 virtual bool IsType(Type type) const; |
280 | 286 |
281 // Returns the type passed to the constructor. | 287 // Returns the type passed to the constructor. |
282 Type type() const { return type_; } | 288 Type type() const { return type_; } |
283 | 289 |
284 // Optional call to connect the thread name with this loop. | 290 // Optional call to connect the thread name with this loop. |
285 void set_thread_name(const std::string& thread_name) { | 291 void set_thread_name(const std::string& thread_name) { |
286 DCHECK(thread_name_.empty()) << "Should not rename this thread!"; | 292 DCHECK(thread_name_.empty()) << "Should not rename this thread!"; |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 | 648 |
643 // Do not add any member variables to MessageLoopForIO! This is important b/c | 649 // Do not add any member variables to MessageLoopForIO! This is important b/c |
644 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 650 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
645 // data that you need should be stored on the MessageLoop's pump_ instance. | 651 // data that you need should be stored on the MessageLoop's pump_ instance. |
646 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 652 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
647 MessageLoopForIO_should_not_have_extra_member_variables); | 653 MessageLoopForIO_should_not_have_extra_member_variables); |
648 | 654 |
649 } // namespace base | 655 } // namespace base |
650 | 656 |
651 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 657 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
OLD | NEW |