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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 void QuitNow(); | 256 void QuitNow(); |
256 | 257 |
257 // TODO(jbates) remove this. crbug.com/131220. See QuitWhenIdleClosure(). | 258 // TODO(jbates) remove this. crbug.com/131220. See QuitWhenIdleClosure(). |
258 static Closure QuitClosure() { return QuitWhenIdleClosure(); } | 259 static Closure QuitClosure() { return QuitWhenIdleClosure(); } |
259 | 260 |
260 // Deprecated: use RunLoop instead. | 261 // Deprecated: use RunLoop instead. |
261 // Construct a Closure that will call QuitWhenIdle(). Useful to schedule an | 262 // Construct a Closure that will call QuitWhenIdle(). Useful to schedule an |
262 // arbitrary MessageLoop to QuitWhenIdle. | 263 // arbitrary MessageLoop to QuitWhenIdle. |
263 static Closure QuitWhenIdleClosure(); | 264 static Closure QuitWhenIdleClosure(); |
264 | 265 |
266 // Set the timer slack for this message loop. | |
267 void SetTimerSlack(TimerSlack timer_slack) { | |
268 pump_->SetTimerSlack(timer_slack); | |
DaleCurtis
2014/05/29 18:03:08
nit: indent is off.
jeremy
2014/06/02 10:21:28
Done.
| |
269 } | |
270 | |
265 // Returns true if this loop is |type|. This allows subclasses (especially | 271 // Returns true if this loop is |type|. This allows subclasses (especially |
266 // those in tests) to specialize how they are identified. | 272 // those in tests) to specialize how they are identified. |
267 virtual bool IsType(Type type) const; | 273 virtual bool IsType(Type type) const; |
268 | 274 |
269 // Returns the type passed to the constructor. | 275 // Returns the type passed to the constructor. |
270 Type type() const { return type_; } | 276 Type type() const { return type_; } |
271 | 277 |
272 // Optional call to connect the thread name with this loop. | 278 // Optional call to connect the thread name with this loop. |
273 void set_thread_name(const std::string& thread_name) { | 279 void set_thread_name(const std::string& thread_name) { |
274 DCHECK(thread_name_.empty()) << "Should not rename this thread!"; | 280 DCHECK(thread_name_.empty()) << "Should not rename this thread!"; |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
630 | 636 |
631 // Do not add any member variables to MessageLoopForIO! This is important b/c | 637 // Do not add any member variables to MessageLoopForIO! This is important b/c |
632 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 638 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
633 // data that you need should be stored on the MessageLoop's pump_ instance. | 639 // data that you need should be stored on the MessageLoop's pump_ instance. |
634 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 640 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
635 MessageLoopForIO_should_not_have_extra_member_variables); | 641 MessageLoopForIO_should_not_have_extra_member_variables); |
636 | 642 |
637 } // namespace base | 643 } // namespace base |
638 | 644 |
639 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ | 645 #endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_ |
OLD | NEW |