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

Side by Side Diff: components/sync_driver/device_info_sync_service.h

Issue 1907683003: Convert //components/sync_driver from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build fix, address feedback Created 4 years, 8 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 COMPONENTS_SYNC_DRIVER_DEVICE_INFO_SYNC_SERVICE_H_ 5 #ifndef COMPONENTS_SYNC_DRIVER_DEVICE_INFO_SYNC_SERVICE_H_
6 #define COMPONENTS_SYNC_DRIVER_DEVICE_INFO_SYNC_SERVICE_H_ 6 #define COMPONENTS_SYNC_DRIVER_DEVICE_INFO_SYNC_SERVICE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory>
11 #include <string> 12 #include <string>
12 13
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "base/timer/timer.h" 18 #include "base/timer/timer.h"
19 #include "components/sync_driver/device_info_tracker.h" 19 #include "components/sync_driver/device_info_tracker.h"
20 #include "sync/api/sync_change.h" 20 #include "sync/api/sync_change.h"
21 #include "sync/api/sync_change_processor.h" 21 #include "sync/api/sync_change_processor.h"
22 #include "sync/api/sync_data.h" 22 #include "sync/api/sync_data.h"
23 #include "sync/api/sync_error_factory.h" 23 #include "sync/api/sync_error_factory.h"
24 #include "sync/api/syncable_service.h" 24 #include "sync/api/syncable_service.h"
(...skipping 14 matching lines...) Expand all
39 public DeviceInfoTracker { 39 public DeviceInfoTracker {
40 public: 40 public:
41 explicit DeviceInfoSyncService( 41 explicit DeviceInfoSyncService(
42 LocalDeviceInfoProvider* local_device_info_provider); 42 LocalDeviceInfoProvider* local_device_info_provider);
43 ~DeviceInfoSyncService() override; 43 ~DeviceInfoSyncService() override;
44 44
45 // syncer::SyncableService implementation. 45 // syncer::SyncableService implementation.
46 syncer::SyncMergeResult MergeDataAndStartSyncing( 46 syncer::SyncMergeResult MergeDataAndStartSyncing(
47 syncer::ModelType type, 47 syncer::ModelType type,
48 const syncer::SyncDataList& initial_sync_data, 48 const syncer::SyncDataList& initial_sync_data,
49 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, 49 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor,
50 scoped_ptr<syncer::SyncErrorFactory> error_handler) override; 50 std::unique_ptr<syncer::SyncErrorFactory> error_handler) override;
51 void StopSyncing(syncer::ModelType type) override; 51 void StopSyncing(syncer::ModelType type) override;
52 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override; 52 syncer::SyncDataList GetAllSyncData(syncer::ModelType type) const override;
53 syncer::SyncError ProcessSyncChanges( 53 syncer::SyncError ProcessSyncChanges(
54 const tracked_objects::Location& from_here, 54 const tracked_objects::Location& from_here,
55 const syncer::SyncChangeList& change_list) override; 55 const syncer::SyncChangeList& change_list) override;
56 56
57 // DeviceInfoTracker implementation. 57 // DeviceInfoTracker implementation.
58 bool IsSyncing() const override; 58 bool IsSyncing() const override;
59 scoped_ptr<DeviceInfo> GetDeviceInfo( 59 std::unique_ptr<DeviceInfo> GetDeviceInfo(
60 const std::string& client_id) const override; 60 const std::string& client_id) const override;
61 ScopedVector<DeviceInfo> GetAllDeviceInfo() const override; 61 ScopedVector<DeviceInfo> GetAllDeviceInfo() const override;
62 void AddObserver(Observer* observer) override; 62 void AddObserver(Observer* observer) override;
63 void RemoveObserver(Observer* observer) override; 63 void RemoveObserver(Observer* observer) override;
64 int CountActiveDevices() const override; 64 int CountActiveDevices() const override;
65 65
66 private: 66 private:
67 friend class DeviceInfoSyncServiceTest; 67 friend class DeviceInfoSyncServiceTest;
68 68
69 // Create SyncData from local DeviceInfo. 69 // Create SyncData from local DeviceInfo.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // device depends on the amount of time since it was updated, which means 107 // device depends on the amount of time since it was updated, which means
108 // comparing it against the current time. |now| is passed into this method to 108 // comparing it against the current time. |now| is passed into this method to
109 // allow unit tests to control expected results. 109 // allow unit tests to control expected results.
110 int CountActiveDevices(const base::Time now) const; 110 int CountActiveDevices(const base::Time now) const;
111 111
112 // |local_device_info_provider_| isn't owned. 112 // |local_device_info_provider_| isn't owned.
113 const LocalDeviceInfoProvider* const local_device_info_provider_; 113 const LocalDeviceInfoProvider* const local_device_info_provider_;
114 114
115 // Receives ownership of |sync_processor_| and |error_handler_| in 115 // Receives ownership of |sync_processor_| and |error_handler_| in
116 // MergeDataAndStartSyncing() and destroy them in StopSyncing(). 116 // MergeDataAndStartSyncing() and destroy them in StopSyncing().
117 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; 117 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor_;
118 scoped_ptr<syncer::SyncErrorFactory> error_handler_; 118 std::unique_ptr<syncer::SyncErrorFactory> error_handler_;
119 119
120 // Cache of all syncable and local data. 120 // Cache of all syncable and local data.
121 typedef std::map<std::string, syncer::SyncData> SyncDataMap; 121 typedef std::map<std::string, syncer::SyncData> SyncDataMap;
122 SyncDataMap all_data_; 122 SyncDataMap all_data_;
123 123
124 // Registered observers, not owned. 124 // Registered observers, not owned.
125 base::ObserverList<Observer, true> observers_; 125 base::ObserverList<Observer, true> observers_;
126 126
127 // Used to update our local device info once every pulse interval. 127 // Used to update our local device info once every pulse interval.
128 base::OneShotTimer pulse_timer_; 128 base::OneShotTimer pulse_timer_;
129 129
130 DISALLOW_COPY_AND_ASSIGN(DeviceInfoSyncService); 130 DISALLOW_COPY_AND_ASSIGN(DeviceInfoSyncService);
131 }; 131 };
132 132
133 } // namespace sync_driver 133 } // namespace sync_driver
134 134
135 #endif // COMPONENTS_SYNC_DRIVER_DEVICE_INFO_SYNC_SERVICE_H_ 135 #endif // COMPONENTS_SYNC_DRIVER_DEVICE_INFO_SYNC_SERVICE_H_
OLDNEW
« no previous file with comments | « components/sync_driver/device_info_service_unittest.cc ('k') | components/sync_driver/device_info_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698