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

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: Another rebase 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 #include "sync/internal_api/public/util/sync_string_conversions.h" 30 #include "sync/internal_api/public/util/sync_string_conversions.h"
31 31
32 using syncer::sessions::SyncSessionSnapshot; 32 using syncer::sessions::SyncSessionSnapshot;
33 33
34 // TODO(rsimha): Remove the following lines once crbug.com/91863 is fixed. 34 // TODO(rsimha): Remove the following lines once crbug.com/91863 is fixed.
35 // The amount of time for which we wait for a live sync operation to complete. 35 // The amount of time for which we wait for a live sync operation to complete.
36 static const int kLiveSyncOperationTimeoutMs = 45000; 36 static const int kLiveSyncOperationTimeoutMs = 45000;
37 37
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 DVLOG(1) << GetClientInfoString("AwaitStatusChangeWithTimeout succeeded"); 751 DVLOG(1) << GetClientInfoString("AwaitStatusChangeWithTimeout succeeded");
752 return true; 752 return true;
753 } else { 753 } else {
754 DVLOG(0) << GetClientInfoString("AwaitStatusChangeWithTimeout timed out"); 754 DVLOG(0) << GetClientInfoString("AwaitStatusChangeWithTimeout timed out");
755 return false; 755 return false;
756 } 756 }
757 } 757 }
758 758
759 ProfileSyncService::Status ProfileSyncServiceHarness::GetStatus() { 759 ProfileSyncService::Status ProfileSyncServiceHarness::GetStatus() {
760 DCHECK(service() != NULL) << "GetStatus(): service() is NULL."; 760 DCHECK(service() != NULL) << "GetStatus(): service() is NULL.";
761 return service()->QueryDetailedSyncStatus(); 761 ProfileSyncService::Status result;
762 service()->QueryDetailedSyncStatus(&result);
763 return result;
762 } 764 }
763 765
764 // We use this function to share code between IsFullySynced and IsDataSynced 766 // We use this function to share code between IsFullySynced and IsDataSynced
765 // while ensuring that all conditions are evaluated using on the same snapshot. 767 // while ensuring that all conditions are evaluated using on the same snapshot.
766 bool ProfileSyncServiceHarness::IsDataSyncedImpl( 768 bool ProfileSyncServiceHarness::IsDataSyncedImpl(
767 const SyncSessionSnapshot& snap) { 769 const SyncSessionSnapshot& snap) {
768 return snap.num_simple_conflicts() == 0 && 770 return snap.num_simple_conflicts() == 0 &&
769 ServiceIsPushingChanges() && 771 ServiceIsPushingChanges() &&
770 GetStatus().notifications_enabled && 772 GetStatus().notifications_enabled &&
771 !service()->HasUnsyncedItems() && 773 !service()->HasUnsyncedItems() &&
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 return GetLastSessionSnapshot().num_entries(); 1100 return GetLastSessionSnapshot().num_entries();
1099 } 1101 }
1100 1102
1101 size_t ProfileSyncServiceHarness::GetNumDatatypes() const { 1103 size_t ProfileSyncServiceHarness::GetNumDatatypes() const {
1102 browser_sync::DataTypeController::StateMap state_map; 1104 browser_sync::DataTypeController::StateMap state_map;
1103 service_->GetDataTypeControllerStates(&state_map); 1105 service_->GetDataTypeControllerStates(&state_map);
1104 return state_map.size(); 1106 return state_map.size();
1105 } 1107 }
1106 1108
1107 std::string ProfileSyncServiceHarness::GetServiceStatus() { 1109 std::string ProfileSyncServiceHarness::GetServiceStatus() {
1108 DictionaryValue value; 1110 scoped_ptr<DictionaryValue> value(
1109 sync_ui_util::ConstructAboutInformation(service_, &value); 1111 sync_ui_util::ConstructAboutInformation(service_));
1110 std::string service_status; 1112 std::string service_status;
1111 base::JSONWriter::WriteWithOptions(&value, 1113 base::JSONWriter::WriteWithOptions(value.get(),
1112 base::JSONWriter::OPTIONS_PRETTY_PRINT, 1114 base::JSONWriter::OPTIONS_PRETTY_PRINT,
1113 &service_status); 1115 &service_status);
1114 return service_status; 1116 return service_status;
1115 } 1117 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | chrome/browser/sync/profile_sync_service_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698