OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/run_loop.h" | 5 #include "base/run_loop.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/tracked_objects.h" | |
8 | 9 |
9 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
10 #include "base/message_loop/message_pump_dispatcher.h" | 11 #include "base/message_loop/message_pump_dispatcher.h" |
11 #endif | 12 #endif |
12 | 13 |
13 namespace base { | 14 namespace base { |
14 | 15 |
15 RunLoop::RunLoop() | 16 RunLoop::RunLoop() |
16 : loop_(MessageLoop::current()), | 17 : loop_(MessageLoop::current()), |
17 previous_run_loop_(NULL), | 18 previous_run_loop_(NULL), |
(...skipping 21 matching lines...) Expand all Loading... | |
39 weak_factory_(this) { | 40 weak_factory_(this) { |
40 } | 41 } |
41 #endif | 42 #endif |
42 | 43 |
43 RunLoop::~RunLoop() { | 44 RunLoop::~RunLoop() { |
44 } | 45 } |
45 | 46 |
46 void RunLoop::Run() { | 47 void RunLoop::Run() { |
47 if (!BeforeRun()) | 48 if (!BeforeRun()) |
48 return; | 49 return; |
49 loop_->RunHandler(); | 50 { |
jar (doing other things)
2014/09/05 04:36:05
nit: You probably don't need curlies, unless the d
vadimt
2014/09/05 20:25:54
Done.
| |
51 // Use task stopwatch to exclude the loop run time from the current task, if | |
52 // any. | |
53 tracked_objects::TaskStopwatch stopwatch; | |
54 loop_->RunHandler(); | |
55 stopwatch.Stop(); | |
56 } | |
50 AfterRun(); | 57 AfterRun(); |
51 } | 58 } |
52 | 59 |
53 void RunLoop::RunUntilIdle() { | 60 void RunLoop::RunUntilIdle() { |
54 quit_when_idle_received_ = true; | 61 quit_when_idle_received_ = true; |
55 Run(); | 62 Run(); |
56 } | 63 } |
57 | 64 |
58 void RunLoop::Quit() { | 65 void RunLoop::Quit() { |
59 quit_called_ = true; | 66 quit_called_ = true; |
(...skipping 29 matching lines...) Expand all Loading... | |
89 | 96 |
90 // Pop RunLoop stack: | 97 // Pop RunLoop stack: |
91 loop_->run_loop_ = previous_run_loop_; | 98 loop_->run_loop_ = previous_run_loop_; |
92 | 99 |
93 // Execute deferred QuitNow, if any: | 100 // Execute deferred QuitNow, if any: |
94 if (previous_run_loop_ && previous_run_loop_->quit_called_) | 101 if (previous_run_loop_ && previous_run_loop_->quit_called_) |
95 loop_->QuitNow(); | 102 loop_->QuitNow(); |
96 } | 103 } |
97 | 104 |
98 } // namespace base | 105 } // namespace base |
OLD | NEW |