| 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 #include "base/tracked_objects.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| 11 namespace base { | 11 namespace base { |
| 12 | 12 |
| 13 RunLoop::RunLoop() | 13 RunLoop::RunLoop() |
| 14 : loop_(MessageLoop::current()), | 14 : loop_(MessageLoop::current()), |
| 15 previous_run_loop_(NULL), | 15 previous_run_loop_(NULL), |
| 16 run_depth_(0), | 16 run_depth_(0), |
| 17 run_called_(false), | 17 run_called_(false), |
| 18 quit_called_(false), | 18 quit_called_(false), |
| 19 running_(false), | 19 running_(false), |
| 20 quit_when_idle_received_(false), | 20 quit_when_idle_received_(false), |
| 21 weak_factory_(this) { | 21 weak_factory_(this) { |
| 22 DCHECK(loop_); |
| 22 } | 23 } |
| 23 | 24 |
| 24 RunLoop::~RunLoop() { | 25 RunLoop::~RunLoop() { |
| 25 } | 26 } |
| 26 | 27 |
| 27 void RunLoop::Run() { | 28 void RunLoop::Run() { |
| 28 DCHECK(thread_checker_.CalledOnValidThread()); | 29 DCHECK(thread_checker_.CalledOnValidThread()); |
| 29 if (!BeforeRun()) | 30 if (!BeforeRun()) |
| 30 return; | 31 return; |
| 31 | 32 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 92 |
| 92 // Pop RunLoop stack: | 93 // Pop RunLoop stack: |
| 93 loop_->run_loop_ = previous_run_loop_; | 94 loop_->run_loop_ = previous_run_loop_; |
| 94 | 95 |
| 95 // Execute deferred QuitNow, if any: | 96 // Execute deferred QuitNow, if any: |
| 96 if (previous_run_loop_ && previous_run_loop_->quit_called_) | 97 if (previous_run_loop_ && previous_run_loop_->quit_called_) |
| 97 loop_->QuitNow(); | 98 loop_->QuitNow(); |
| 98 } | 99 } |
| 99 | 100 |
| 100 } // namespace base | 101 } // namespace base |
| OLD | NEW |