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

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: rebase again 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 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 if (wait_state_ == SYNC_DISABLED) { 747 if (wait_state_ == SYNC_DISABLED) {
748 LOG(ERROR) << "Sync disabled for " << profile_debug_name_ << "."; 748 LOG(ERROR) << "Sync disabled for " << profile_debug_name_ << ".";
749 return false; 749 return false;
750 } 750 }
751 scoped_refptr<StateChangeTimeoutEvent> timeout_signal( 751 scoped_refptr<StateChangeTimeoutEvent> timeout_signal(
752 new StateChangeTimeoutEvent(this, reason)); 752 new StateChangeTimeoutEvent(this, reason));
753 { 753 {
754 // Set the flag to tell SignalStateComplete() that it's OK to quit out of 754 // Set the flag to tell SignalStateComplete() that it's OK to quit out of
755 // the MessageLoop if we hit a state transition. 755 // the MessageLoop if we hit a state transition.
756 waiting_for_status_change_ = true; 756 waiting_for_status_change_ = true;
757 MessageLoop* loop = MessageLoop::current(); 757 base::MessageLoop* loop = base::MessageLoop::current();
758 MessageLoop::ScopedNestableTaskAllower allow(loop); 758 base::MessageLoop::ScopedNestableTaskAllower allow(loop);
759 loop->PostDelayedTask( 759 loop->PostDelayedTask(
760 FROM_HERE, 760 FROM_HERE,
761 base::Bind(&StateChangeTimeoutEvent::Callback, 761 base::Bind(&StateChangeTimeoutEvent::Callback,
762 timeout_signal.get()), 762 timeout_signal.get()),
763 base::TimeDelta::FromMilliseconds(timeout_milliseconds)); 763 base::TimeDelta::FromMilliseconds(timeout_milliseconds));
764 loop->Run(); 764 loop->Run();
765 waiting_for_status_change_ = false; 765 waiting_for_status_change_ = false;
766 } 766 }
767 767
768 if (timeout_signal->Abort()) { 768 if (timeout_signal->Abort()) {
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 1127
1128 std::string ProfileSyncServiceHarness::GetServiceStatus() { 1128 std::string ProfileSyncServiceHarness::GetServiceStatus() {
1129 scoped_ptr<DictionaryValue> value( 1129 scoped_ptr<DictionaryValue> value(
1130 sync_ui_util::ConstructAboutInformation(service_)); 1130 sync_ui_util::ConstructAboutInformation(service_));
1131 std::string service_status; 1131 std::string service_status;
1132 base::JSONWriter::WriteWithOptions(value.get(), 1132 base::JSONWriter::WriteWithOptions(value.get(),
1133 base::JSONWriter::OPTIONS_PRETTY_PRINT, 1133 base::JSONWriter::OPTIONS_PRETTY_PRINT,
1134 &service_status); 1134 &service_status);
1135 return service_status; 1135 return service_status;
1136 } 1136 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698