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

Side by Side Diff: base/message_pump_default.cc

Issue 3805: autorelease message pumps (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 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 | « base/build/base.vcproj ('k') | base/message_pump_libevent.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « base/build/base.vcproj ('k') | base/message_pump_libevent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698