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

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: 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 "base/callback_list.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "chrome/browser/sync/glue/device_info.h"
12 #include "sync/api/sync_change_processor.h"
13 #include "sync/api/sync_data.h"
14 #include "sync/api/sync_error_factory.h"
15 #include "sync/api/syncable_service.h"
16
17 namespace browser_sync {
18
19 class LocalDeviceInfoProvider;
20
21 // SyncableService implementation for DEVICE_INFO model type.
22 class DeviceInfoSyncService : public syncer::SyncableService {
23 public:
24 explicit DeviceInfoSyncService(
25 LocalDeviceInfoProvider* local_device_info_provider);
26 virtual ~DeviceInfoSyncService();
27
28 // syncer::SyncableService implementation.
29 virtual syncer::SyncMergeResult MergeDataAndStartSyncing(
30 syncer::ModelType type,
31 const syncer::SyncDataList& initial_sync_data,
32 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
33 scoped_ptr<syncer::SyncErrorFactory> error_handler) OVERRIDE;
34 virtual void StopSyncing(syncer::ModelType type) OVERRIDE;
35 virtual syncer::SyncDataList GetAllSyncData(
36 syncer::ModelType type) const OVERRIDE;
37 virtual syncer::SyncError ProcessSyncChanges(
38 const tracked_objects::Location& from_here,
39 const syncer::SyncChangeList& change_list) OVERRIDE;
40
41 // DeviceInfoSyncService API
stanisc 2014/07/30 18:57:50 Will add missing period at the end of the sentence
stanisc 2014/08/01 18:54:51 Done.
42 scoped_ptr<DeviceInfo> GetDeviceInfo(const std::string& client_id) const;
43 ScopedVector<DeviceInfo> GetAllDeviceInfo() const;
44
45 typedef base::CallbackList<void(void)>::Subscription Subscription;
pavely 2014/07/31 22:52:40 nit: typedef should be before ctor (http://google-
stanisc 2014/08/01 18:54:51 Done.
46
47 // Registers an observer callback to be called on syncing any updated
48 // DeviceInfo. The callback remains registered until the returned
49 // Subscription is destroyed, which must occur before this object
50 // is destroyed.
51 scoped_ptr<Subscription> RegisterOnDeviceInfoChangedCallback(
52 const base::Closure& callback);
53
54 private:
55 // Create SyncData from local DeviceInfo.
56 static syncer::SyncData CreateLocalData(const DeviceInfo* info);
57 // Allocate new DeviceInfo from SyncData.
58 static DeviceInfo* CreateDeviceInfo(const syncer::SyncData sync_data);
59 // Store SyncData in the cache.
60 void StoreSyncData(
61 const std::string& client_id, const syncer::SyncData& sync_data);
62 // Delete SyncData from the cache.
63 void DeleteSyncData(const std::string& client_id);
64
65 // |local_device_info_provider_| isn't owned.
66 const LocalDeviceInfoProvider* const local_device_info_provider_;
67
68 // Receives ownership of |sync_processor_| and |error_handler_| in
69 // MergeDataAndStartSyncing() and destroy them in StopSyncing().
70 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
71 scoped_ptr<syncer::SyncErrorFactory> error_handler_;
72
73 // Cache of all syncable and local data.
74 typedef std::map<std::string, syncer::SyncData> SyncDataMap;
75 SyncDataMap all_data_;
76
77 // Registered observer callbacks.
78 base::CallbackList<void(void)> callback_list_;
79
80 DISALLOW_COPY_AND_ASSIGN(DeviceInfoSyncService);
81 };
82
83 } // namespace browser_sync
84
85 #endif // CHROME_BROWSER_SYNC_GLUE_DEVICE_INFO_SYNC_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698