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

Side by Side Diff: chrome/browser/sync/glue/device_info_sync_service.h

Issue 566623003: Refactor syncable DEVICE_INFO type from ChangeProcessor to SyncableService - part 3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit test fixes Created 6 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_SYNC_SERVICE_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_SYNC_SERVICE_H_
6 #define CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_SYNC_SERVICE_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_SYNC_SERVICE_H_
7 7
8 #include "base/observer_list.h" 8 #include "base/observer_list.h"
9 #include "chrome/browser/sync/glue/device_info_tracker.h" 9 #include "chrome/browser/sync/glue/device_info_tracker.h"
10 #include "sync/api/sync_change_processor.h" 10 #include "sync/api/sync_change_processor.h"
(...skipping 26 matching lines...) Expand all
37 const tracked_objects::Location& from_here, 37 const tracked_objects::Location& from_here,
38 const syncer::SyncChangeList& change_list) OVERRIDE; 38 const syncer::SyncChangeList& change_list) OVERRIDE;
39 39
40 // DeviceInfoTracker implementation. 40 // DeviceInfoTracker implementation.
41 virtual scoped_ptr<DeviceInfo> GetDeviceInfo( 41 virtual scoped_ptr<DeviceInfo> GetDeviceInfo(
42 const std::string& client_id) const OVERRIDE; 42 const std::string& client_id) const OVERRIDE;
43 virtual ScopedVector<DeviceInfo> GetAllDeviceInfo() const OVERRIDE; 43 virtual ScopedVector<DeviceInfo> GetAllDeviceInfo() const OVERRIDE;
44 virtual void AddObserver(Observer* observer) OVERRIDE; 44 virtual void AddObserver(Observer* observer) OVERRIDE;
45 virtual void RemoveObserver(Observer* observer) OVERRIDE; 45 virtual void RemoveObserver(Observer* observer) OVERRIDE;
46 46
47 // Called to update local device backup time in the directory.
stanisc 2014/09/16 00:17:40 I need to change this comment. It doesn't come fro
stanisc 2014/09/18 22:46:54 Done.
48 void UpdateLocalDeviceBackupTime(base::Time backup_time);
49 // Reads local device backup time from the directory.
50 base::Time GetLocalDeviceBackupTime() const;
stanisc 2014/09/16 00:17:40 I need to change this comment. It doesn't come fro
stanisc 2014/09/18 22:46:54 Done.
51
47 private: 52 private:
48 // Create SyncData from local DeviceInfo. 53 // Create SyncData from local DeviceInfo (and backup timestamp).
stanisc 2014/09/16 00:17:40 I should replace "backup timestamp" with |local_de
stanisc 2014/09/18 22:46:53 Done.
49 static syncer::SyncData CreateLocalData(const DeviceInfo* info); 54 syncer::SyncData CreateLocalData(const DeviceInfo* info);
55 // Create SyncData from EntitySpecifics.
56 static syncer::SyncData CreateLocalData(
57 const sync_pb::EntitySpecifics& entity);
58
50 // Allocate new DeviceInfo from SyncData. 59 // Allocate new DeviceInfo from SyncData.
51 static DeviceInfo* CreateDeviceInfo(const syncer::SyncData sync_data); 60 static DeviceInfo* CreateDeviceInfo(const syncer::SyncData sync_data);
52 // Store SyncData in the cache. 61 // Store SyncData in the cache.
53 void StoreSyncData(const std::string& client_id, 62 void StoreSyncData(const std::string& client_id,
54 const syncer::SyncData& sync_data); 63 const syncer::SyncData& sync_data);
55 // Delete SyncData from the cache. 64 // Delete SyncData from the cache.
56 void DeleteSyncData(const std::string& client_id); 65 void DeleteSyncData(const std::string& client_id);
57 // Notify all registered observers. 66 // Notify all registered observers.
58 void NotifyObservers(); 67 void NotifyObservers();
59 68
69 // Updates backup time in place in |sync_data| if it is different than
70 // the one stored in |local_device_backup_time_|.
71 // Returns true if backup time was updated.
72 bool UpdateBackupTime(syncer::SyncData& sync_data);
73
74 // |local_device_backup_time_| accessors.
75 int64 local_device_backup_time() const { return local_device_backup_time_; }
76 bool has_local_device_backup_time() const {
77 return local_device_backup_time_ >= 0;
78 }
79 void set_local_device_backup_time(int64 value) {
80 local_device_backup_time_ = value;
81 }
82 void clear_local_device_backup_time() { local_device_backup_time_ = -1; }
83
84 // Local device last set backup time (in proto format).
85 // -1 if the value hasn't been specified
86 int64 local_device_backup_time_;
pavely 2014/09/17 23:04:38 Consider storing local_device_backup_time_ as base
stanisc 2014/09/18 22:46:53 That is exactly what I had when I first implemente
87
60 // |local_device_info_provider_| isn't owned. 88 // |local_device_info_provider_| isn't owned.
61 const LocalDeviceInfoProvider* const local_device_info_provider_; 89 const LocalDeviceInfoProvider* const local_device_info_provider_;
62 90
63 // Receives ownership of |sync_processor_| and |error_handler_| in 91 // Receives ownership of |sync_processor_| and |error_handler_| in
64 // MergeDataAndStartSyncing() and destroy them in StopSyncing(). 92 // MergeDataAndStartSyncing() and destroy them in StopSyncing().
65 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; 93 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
66 scoped_ptr<syncer::SyncErrorFactory> error_handler_; 94 scoped_ptr<syncer::SyncErrorFactory> error_handler_;
67 95
68 // Cache of all syncable and local data. 96 // Cache of all syncable and local data.
69 typedef std::map<std::string, syncer::SyncData> SyncDataMap; 97 typedef std::map<std::string, syncer::SyncData> SyncDataMap;
70 SyncDataMap all_data_; 98 SyncDataMap all_data_;
71 99
72 // Registered observers, not owned. 100 // Registered observers, not owned.
73 ObserverList<Observer, true> observers_; 101 ObserverList<Observer, true> observers_;
74 102
75 DISALLOW_COPY_AND_ASSIGN(DeviceInfoSyncService); 103 DISALLOW_COPY_AND_ASSIGN(DeviceInfoSyncService);
76 }; 104 };
77 105
78 } // namespace browser_sync 106 } // namespace browser_sync
79 107
80 #endif // CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_SYNC_SERVICE_H_ 108 #endif // CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_SYNC_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698