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

Unified Diff: base/message_pump_default.cc

Issue 16897006: Move message_pump to base/message_loop. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/message_pump_default.h ('k') | base/message_pump_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_pump_default.cc
diff --git a/base/message_pump_default.cc b/base/message_pump_default.cc
deleted file mode 100644
index 649e2aac1392a228d430910c975cf6956e6335ac..0000000000000000000000000000000000000000
--- a/base/message_pump_default.cc
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/message_pump_default.h"
-
-#include "base/logging.h"
-#include "base/threading/thread_restrictions.h"
-
-#if defined(OS_MACOSX)
-#include "base/mac/scoped_nsautorelease_pool.h"
-#endif
-
-namespace base {
-
-MessagePumpDefault::MessagePumpDefault()
- : keep_running_(true),
- event_(false, false) {
-}
-
-void MessagePumpDefault::Run(Delegate* delegate) {
- DCHECK(keep_running_) << "Quit must have been called outside of Run!";
-
- for (;;) {
-#if defined(OS_MACOSX)
- mac::ScopedNSAutoreleasePool autorelease_pool;
-#endif
-
- bool did_work = delegate->DoWork();
- if (!keep_running_)
- break;
-
- did_work |= delegate->DoDelayedWork(&delayed_work_time_);
- if (!keep_running_)
- break;
-
- if (did_work)
- continue;
-
- did_work = delegate->DoIdleWork();
- if (!keep_running_)
- break;
-
- if (did_work)
- continue;
-
- base::ThreadRestrictions::ScopedAllowWait allow_wait;
- if (delayed_work_time_.is_null()) {
- event_.Wait();
- } else {
- TimeDelta delay = delayed_work_time_ - TimeTicks::Now();
- if (delay > TimeDelta()) {
- event_.TimedWait(delay);
- } else {
- // It looks like delayed_work_time_ indicates a time in the past, so we
- // need to call DoDelayedWork now.
- delayed_work_time_ = TimeTicks();
- }
- }
- // Since event_ is auto-reset, we don't need to do anything special here
- // other than service each delegate method.
- }
-
- keep_running_ = true;
-}
-
-void MessagePumpDefault::Quit() {
- keep_running_ = false;
-}
-
-void MessagePumpDefault::ScheduleWork() {
- // Since this can be called on any thread, we need to ensure that our Run
- // loop wakes up.
- event_.Signal();
-}
-
-void MessagePumpDefault::ScheduleDelayedWork(
- const TimeTicks& delayed_work_time) {
- // We know that we can't be blocked on Wait right now since this method can
- // only be called on the same thread as Run, so we only need to update our
- // record of how long to sleep when we do sleep.
- delayed_work_time_ = delayed_work_time;
-}
-
-} // namespace base
« no previous file with comments | « base/message_pump_default.h ('k') | base/message_pump_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698