| 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 "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 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 bool ProfileSyncServiceHarness::AwaitStatusChangeWithTimeout( | 739 bool ProfileSyncServiceHarness::AwaitStatusChangeWithTimeout( |
| 740 int timeout_milliseconds, | 740 int timeout_milliseconds, |
| 741 const std::string& reason) { | 741 const std::string& reason) { |
| 742 DVLOG(1) << GetClientInfoString("AwaitStatusChangeWithTimeout"); | 742 DVLOG(1) << GetClientInfoString("AwaitStatusChangeWithTimeout"); |
| 743 if (wait_state_ == SYNC_DISABLED) { | 743 if (wait_state_ == SYNC_DISABLED) { |
| 744 LOG(ERROR) << "Sync disabled for " << profile_debug_name_ << "."; | 744 LOG(ERROR) << "Sync disabled for " << profile_debug_name_ << "."; |
| 745 return false; | 745 return false; |
| 746 } | 746 } |
| 747 scoped_refptr<StateChangeTimeoutEvent> timeout_signal( | 747 scoped_refptr<StateChangeTimeoutEvent> timeout_signal( |
| 748 new StateChangeTimeoutEvent(this, reason)); | 748 new StateChangeTimeoutEvent(this, reason)); |
| 749 MessageLoop* loop = MessageLoop::current(); | 749 { |
| 750 bool did_allow_nestable_tasks = loop->NestableTasksAllowed(); | 750 MessageLoop* loop = MessageLoop::current(); |
| 751 loop->SetNestableTasksAllowed(true); | 751 MessageLoop::ScopedNestableTaskAllower allow(loop); |
| 752 loop->PostDelayedTask( | 752 loop->PostDelayedTask( |
| 753 FROM_HERE, | 753 FROM_HERE, |
| 754 base::Bind(&StateChangeTimeoutEvent::Callback, | 754 base::Bind(&StateChangeTimeoutEvent::Callback, |
| 755 timeout_signal.get()), | 755 timeout_signal.get()), |
| 756 base::TimeDelta::FromMilliseconds(timeout_milliseconds)); | 756 base::TimeDelta::FromMilliseconds(timeout_milliseconds)); |
| 757 loop->Run(); | 757 loop->Run(); |
| 758 loop->SetNestableTasksAllowed(did_allow_nestable_tasks); | 758 } |
| 759 |
| 759 if (timeout_signal->Abort()) { | 760 if (timeout_signal->Abort()) { |
| 760 DVLOG(1) << GetClientInfoString("AwaitStatusChangeWithTimeout succeeded"); | 761 DVLOG(1) << GetClientInfoString("AwaitStatusChangeWithTimeout succeeded"); |
| 761 return true; | 762 return true; |
| 762 } else { | 763 } else { |
| 763 DVLOG(0) << GetClientInfoString("AwaitStatusChangeWithTimeout timed out"); | 764 DVLOG(0) << GetClientInfoString("AwaitStatusChangeWithTimeout timed out"); |
| 764 return false; | 765 return false; |
| 765 } | 766 } |
| 766 } | 767 } |
| 767 | 768 |
| 768 ProfileSyncService::Status ProfileSyncServiceHarness::GetStatus() { | 769 ProfileSyncService::Status ProfileSyncServiceHarness::GetStatus() { |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 return state_map.size(); | 1117 return state_map.size(); |
| 1117 } | 1118 } |
| 1118 | 1119 |
| 1119 std::string ProfileSyncServiceHarness::GetServiceStatus() { | 1120 std::string ProfileSyncServiceHarness::GetServiceStatus() { |
| 1120 DictionaryValue value; | 1121 DictionaryValue value; |
| 1121 sync_ui_util::ConstructAboutInformation(service_, &value); | 1122 sync_ui_util::ConstructAboutInformation(service_, &value); |
| 1122 std::string service_status; | 1123 std::string service_status; |
| 1123 base::JSONWriter::Write(&value, true, &service_status); | 1124 base::JSONWriter::Write(&value, true, &service_status); |
| 1124 return service_status; | 1125 return service_status; |
| 1125 } | 1126 } |
| OLD | NEW |