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

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

Issue 10696107: sync: Track validity of about:sync fields (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update Created 8 years, 5 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>
11 #include <sstream> 11 #include <sstream>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/base64.h" 14 #include "base/base64.h"
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
18 #include "base/json/json_writer.h" 18 #include "base/json/json_writer.h"
19 #include "base/location.h" 19 #include "base/location.h"
20 #include "base/logging.h" 20 #include "base/logging.h"
21 #include "base/memory/ref_counted.h" 21 #include "base/memory/ref_counted.h"
22 #include "base/message_loop.h" 22 #include "base/message_loop.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/signin/signin_manager.h" 24 #include "chrome/browser/signin/signin_manager.h"
25 #include "chrome/browser/sync/about_sync_util.h"
25 #include "chrome/browser/sync/glue/data_type_controller.h" 26 #include "chrome/browser/sync/glue/data_type_controller.h"
26 #include "chrome/browser/sync/profile_sync_service_factory.h" 27 #include "chrome/browser/sync/profile_sync_service_factory.h"
27 #include "chrome/browser/sync/sync_ui_util.h"
28 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
29 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" 29 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
30 30
31 using syncer::sessions::SyncSessionSnapshot; 31 using syncer::sessions::SyncSessionSnapshot;
32 32
33 // TODO(rsimha): Remove the following lines once crbug.com/91863 is fixed. 33 // TODO(rsimha): Remove the following lines once crbug.com/91863 is fixed.
34 // The amount of time for which we wait for a live sync operation to complete. 34 // The amount of time for which we wait for a live sync operation to complete.
35 static const int kLiveSyncOperationTimeoutMs = 45000; 35 static const int kLiveSyncOperationTimeoutMs = 45000;
36 36
37 // The amount of time we wait for test cases that verify exponential backoff. 37 // The amount of time we wait for test cases that verify exponential backoff.
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 DVLOG(1) << GetClientInfoString("AwaitStatusChangeWithTimeout succeeded"); 750 DVLOG(1) << GetClientInfoString("AwaitStatusChangeWithTimeout succeeded");
751 return true; 751 return true;
752 } else { 752 } else {
753 DVLOG(0) << GetClientInfoString("AwaitStatusChangeWithTimeout timed out"); 753 DVLOG(0) << GetClientInfoString("AwaitStatusChangeWithTimeout timed out");
754 return false; 754 return false;
755 } 755 }
756 } 756 }
757 757
758 ProfileSyncService::Status ProfileSyncServiceHarness::GetStatus() { 758 ProfileSyncService::Status ProfileSyncServiceHarness::GetStatus() {
759 DCHECK(service() != NULL) << "GetStatus(): service() is NULL."; 759 DCHECK(service() != NULL) << "GetStatus(): service() is NULL.";
760 return service()->QueryDetailedSyncStatus(); 760 ProfileSyncService::Status result;
761 service()->QueryDetailedSyncStatus(&result);
762 return result;
761 } 763 }
762 764
763 // We use this function to share code between IsFullySynced and IsDataSynced 765 // We use this function to share code between IsFullySynced and IsDataSynced
764 // while ensuring that all conditions are evaluated using on the same snapshot. 766 // while ensuring that all conditions are evaluated using on the same snapshot.
765 bool ProfileSyncServiceHarness::IsDataSyncedImpl( 767 bool ProfileSyncServiceHarness::IsDataSyncedImpl(
766 const SyncSessionSnapshot& snap) { 768 const SyncSessionSnapshot& snap) {
767 return snap.num_simple_conflicts() == 0 && 769 return snap.num_simple_conflicts() == 0 &&
768 ServiceIsPushingChanges() && 770 ServiceIsPushingChanges() &&
769 GetStatus().notifications_enabled && 771 GetStatus().notifications_enabled &&
770 !service()->HasUnsyncedItems() && 772 !service()->HasUnsyncedItems() &&
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 return GetLastSessionSnapshot().num_entries(); 1099 return GetLastSessionSnapshot().num_entries();
1098 } 1100 }
1099 1101
1100 size_t ProfileSyncServiceHarness::GetNumDatatypes() const { 1102 size_t ProfileSyncServiceHarness::GetNumDatatypes() const {
1101 browser_sync::DataTypeController::StateMap state_map; 1103 browser_sync::DataTypeController::StateMap state_map;
1102 service_->GetDataTypeControllerStates(&state_map); 1104 service_->GetDataTypeControllerStates(&state_map);
1103 return state_map.size(); 1105 return state_map.size();
1104 } 1106 }
1105 1107
1106 std::string ProfileSyncServiceHarness::GetServiceStatus() { 1108 std::string ProfileSyncServiceHarness::GetServiceStatus() {
1107 DictionaryValue value; 1109 scoped_ptr<DictionaryValue> value(
1108 sync_ui_util::ConstructAboutInformation(service_, &value); 1110 sync_ui_util::ConstructAboutInformation(service_));
1109 std::string service_status; 1111 std::string service_status;
1110 base::JSONWriter::WriteWithOptions(&value, 1112 base::JSONWriter::WriteWithOptions(value.get(),
1111 base::JSONWriter::OPTIONS_PRETTY_PRINT, 1113 base::JSONWriter::OPTIONS_PRETTY_PRINT,
1112 &service_status); 1114 &service_status);
1113 return service_status; 1115 return service_status;
1114 } 1116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698