OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_pump_default.h" | 5 #include "base/message_pump_default.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/scoped_nsautorelease_pool.h" |
8 | 9 |
9 namespace base { | 10 namespace base { |
10 | 11 |
11 MessagePumpDefault::MessagePumpDefault() | 12 MessagePumpDefault::MessagePumpDefault() |
12 : keep_running_(true), | 13 : keep_running_(true), |
13 event_(false, false) { | 14 event_(false, false) { |
14 } | 15 } |
15 | 16 |
16 void MessagePumpDefault::Run(Delegate* delegate) { | 17 void MessagePumpDefault::Run(Delegate* delegate) { |
17 DCHECK(keep_running_) << "Quit must have been called outside of Run!"; | 18 DCHECK(keep_running_) << "Quit must have been called outside of Run!"; |
18 | 19 |
19 for (;;) { | 20 for (;;) { |
| 21 ScopedNSAutoreleasePool autorelease_pool; |
| 22 |
20 bool did_work = delegate->DoWork(); | 23 bool did_work = delegate->DoWork(); |
21 if (!keep_running_) | 24 if (!keep_running_) |
22 break; | 25 break; |
23 | 26 |
24 did_work |= delegate->DoDelayedWork(&delayed_work_time_); | 27 did_work |= delegate->DoDelayedWork(&delayed_work_time_); |
25 if (!keep_running_) | 28 if (!keep_running_) |
26 break; | 29 break; |
27 | 30 |
28 if (did_work) | 31 if (did_work) |
29 continue; | 32 continue; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 69 |
67 void MessagePumpDefault::ScheduleDelayedWork(const Time& delayed_work_time) { | 70 void MessagePumpDefault::ScheduleDelayedWork(const Time& delayed_work_time) { |
68 // We know that we can't be blocked on Wait right now since this method can | 71 // We know that we can't be blocked on Wait right now since this method can |
69 // only be called on the same thread as Run, so we only need to update our | 72 // only be called on the same thread as Run, so we only need to update our |
70 // record of how long to sleep when we do sleep. | 73 // record of how long to sleep when we do sleep. |
71 delayed_work_time_ = delayed_work_time; | 74 delayed_work_time_ = delayed_work_time; |
72 } | 75 } |
73 | 76 |
74 } // namespace base | 77 } // namespace base |
75 | 78 |
OLD | NEW |