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

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

Issue 430583003: Refactor syncable DEVICE_INFO type from ChangeProcessor to SyncableService - Part 2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed CR feedback, added DeviceInfoTracker interface. Created 6 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_SYNC_SERVICE_H_
6 #define CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_SYNC_SERVICE_H_
7
8 #include "chrome/browser/sync/glue/device_info_tracker.h"
9 #include "sync/api/sync_change_processor.h"
10 #include "sync/api/sync_data.h"
11 #include "sync/api/sync_error_factory.h"
12 #include "sync/api/syncable_service.h"
13
14 namespace browser_sync {
15
16 class LocalDeviceInfoProvider;
17
18 // SyncableService implementation for DEVICE_INFO model type.
19 class DeviceInfoSyncService : public syncer::SyncableService,
20 public DeviceInfoTracker {
21 public:
22 explicit DeviceInfoSyncService(
23 LocalDeviceInfoProvider* local_device_info_provider);
24 virtual ~DeviceInfoSyncService();
25
26 // syncer::SyncableService implementation.
27 virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
28 syncer::ModelType type,
29 const syncer::SyncDataList& initial_sync_data,
30 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
31 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE;
32 virtual void StopSyncing(syncer::ModelType type) OVERRIDE;
33 virtual syncer::SyncDataList GetAllSyncData(
34 syncer::ModelType type) const OVERRIDE;
35 virtual syncer::SyncError ProcessSyncChanges(
36 const tracked_objects::Location& from_here,
37 const syncer::SyncChangeList& change_list) OVERRIDE;
38
39 // DeviceInfoTracker implementation.
40 virtual scoped_ptr<DeviceInfo> GetDeviceInfo(
41 const std::string& client_id) const OVERRIDE;
42 virtual ScopedVector<DeviceInfo> GetAllDeviceInfo() const OVERRIDE;
43 virtual scoped_ptr<Subscription> RegisterOnDeviceInfoChangedCallback(
44 const base::Closure& callback) OVERRIDE;
45
46 private:
47 // Create SyncData from local DeviceInfo.
rlarocque 2014/08/01 20:40:36 nit: I prefer to have a whitespace line before a c
48 static syncer::SyncData CreateLocalData(const DeviceInfo* info);
49 // Allocate new DeviceInfo from SyncData.
50 static DeviceInfo* CreateDeviceInfo(const syncer::SyncData sync_data);
51 // Store SyncData in the cache.
52 void StoreSyncData(const std::string& client_id,
53 const syncer::SyncData& sync_data);
54 // Delete SyncData from the cache.
55 void DeleteSyncData(const std::string& client_id);
56
57 // |local_device_info_provider_| isn't owned.
58 const LocalDeviceInfoProvider* const local_device_info_provider_;
59
60 // Receives ownership of |sync_processor_| and |error_handler_| in
61 // MergeDataAndStartSyncing() and destroy them in StopSyncing().
62 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
63 scoped_ptr<syncer::SyncErrorFactory> error_handler_;
64
65 // Cache of all syncable and local data.
66 typedef std::map<std::string, syncer::SyncData> SyncDataMap;
67 SyncDataMap all_data_;
rlarocque 2014/08/01 20:40:36 I think Pavel already pointed this out, but I'll m
stanisc 2014/08/01 21:37:42 Yeah, I've thought about using native DeviceInfo w
rlarocque 2014/08/01 23:03:23 SGTM for now. I see this as an experiment. Since
68
69 // Registered observer callbacks.
70 base::CallbackList<void(void)> callback_list_;
rlarocque 2014/08/01 20:40:36 Why not use base/observer_list.h?
stanisc 2014/08/01 21:37:42 I thought CallbackList was simpler and more elegan
stanisc 2014/08/01 22:55:50 Done.
71
72 DISALLOW_COPY_AND_ASSIGN(DeviceInfoSyncService);
73 };
74
75 } // namespace browser_sync
76
77 #endif // CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_SYNC_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698