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

Side by Side Diff: chrome/browser/sync/profile_sync_service_harness.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
OLDNEW
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 "chrome/browser/sync/profile_sync_service_harness.h" 5 #include "chrome/browser/sync/profile_sync_service_harness.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <iterator> 8 #include <iterator>
9 #include <ostream> 9 #include <ostream>
10 #include <set> 10 #include <set>
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 } 285 }
286 286
287 void ProfileSyncServiceHarness::SignalStateCompleteWithNextState( 287 void ProfileSyncServiceHarness::SignalStateCompleteWithNextState(
288 WaitState next_state) { 288 WaitState next_state) {
289 wait_state_ = next_state; 289 wait_state_ = next_state;
290 SignalStateComplete(); 290 SignalStateComplete();
291 } 291 }
292 292
293 void ProfileSyncServiceHarness::SignalStateComplete() { 293 void ProfileSyncServiceHarness::SignalStateComplete() {
294 if (waiting_for_status_change_) 294 if (waiting_for_status_change_)
295 MessageLoop::current()->QuitWhenIdle(); 295 base::MessageLoop::current()->QuitWhenIdle();
296 } 296 }
297 297
298 bool ProfileSyncServiceHarness::RunStateChangeMachine() { 298 bool ProfileSyncServiceHarness::RunStateChangeMachine() {
299 WaitState original_wait_state = wait_state_; 299 WaitState original_wait_state = wait_state_;
300 switch (wait_state_) { 300 switch (wait_state_) {
301 case WAITING_FOR_ON_BACKEND_INITIALIZED: { 301 case WAITING_FOR_ON_BACKEND_INITIALIZED: {
302 DVLOG(1) << GetClientInfoString("WAITING_FOR_ON_BACKEND_INITIALIZED"); 302 DVLOG(1) << GetClientInfoString("WAITING_FOR_ON_BACKEND_INITIALIZED");
303 if (service()->GetAuthError().state() == 303 if (service()->GetAuthError().state() ==
304 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS) { 304 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS) {
305 // Our credentials were rejected. Do not wait any more. 305 // Our credentials were rejected. Do not wait any more.
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 if (wait_state_ == SYNC_DISABLED) { 768 if (wait_state_ == SYNC_DISABLED) {
769 LOG(ERROR) << "Sync disabled for " << profile_debug_name_ << "."; 769 LOG(ERROR) << "Sync disabled for " << profile_debug_name_ << ".";
770 return false; 770 return false;
771 } 771 }
772 scoped_refptr<StateChangeTimeoutEvent> timeout_signal( 772 scoped_refptr<StateChangeTimeoutEvent> timeout_signal(
773 new StateChangeTimeoutEvent(this, reason)); 773 new StateChangeTimeoutEvent(this, reason));
774 { 774 {
775 // Set the flag to tell SignalStateComplete() that it's OK to quit out of 775 // Set the flag to tell SignalStateComplete() that it's OK to quit out of
776 // the MessageLoop if we hit a state transition. 776 // the MessageLoop if we hit a state transition.
777 waiting_for_status_change_ = true; 777 waiting_for_status_change_ = true;
778 MessageLoop* loop = MessageLoop::current(); 778 base::MessageLoop* loop = base::MessageLoop::current();
779 MessageLoop::ScopedNestableTaskAllower allow(loop); 779 base::MessageLoop::ScopedNestableTaskAllower allow(loop);
780 loop->PostDelayedTask( 780 loop->PostDelayedTask(
781 FROM_HERE, 781 FROM_HERE,
782 base::Bind(&StateChangeTimeoutEvent::Callback, 782 base::Bind(&StateChangeTimeoutEvent::Callback, timeout_signal.get()),
783 timeout_signal.get()),
784 base::TimeDelta::FromMilliseconds(timeout_milliseconds)); 783 base::TimeDelta::FromMilliseconds(timeout_milliseconds));
785 loop->Run(); 784 loop->Run();
786 waiting_for_status_change_ = false; 785 waiting_for_status_change_ = false;
787 } 786 }
788 787
789 if (timeout_signal->Abort()) { 788 if (timeout_signal->Abort()) {
790 DVLOG(1) << GetClientInfoString("AwaitStatusChangeWithTimeout succeeded"); 789 DVLOG(1) << GetClientInfoString("AwaitStatusChangeWithTimeout succeeded");
791 return true; 790 return true;
792 } else { 791 } else {
793 DVLOG(0) << GetClientInfoString("AwaitStatusChangeWithTimeout timed out"); 792 DVLOG(0) << GetClientInfoString("AwaitStatusChangeWithTimeout timed out");
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 1147
1149 std::string ProfileSyncServiceHarness::GetServiceStatus() { 1148 std::string ProfileSyncServiceHarness::GetServiceStatus() {
1150 scoped_ptr<DictionaryValue> value( 1149 scoped_ptr<DictionaryValue> value(
1151 sync_ui_util::ConstructAboutInformation(service_)); 1150 sync_ui_util::ConstructAboutInformation(service_));
1152 std::string service_status; 1151 std::string service_status;
1153 base::JSONWriter::WriteWithOptions(value.get(), 1152 base::JSONWriter::WriteWithOptions(value.get(),
1154 base::JSONWriter::OPTIONS_PRETTY_PRINT, 1153 base::JSONWriter::OPTIONS_PRETTY_PRINT,
1155 &service_status); 1154 &service_status);
1156 return service_status; 1155 return service_status;
1157 } 1156 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698