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

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

Issue 1951703002: [Sync] Clear LocalDeviceInfoProvider cache on sync DB destruction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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_LOCAL_DEVICE_INFO_PROVIDER_H_ 5 #ifndef COMPONENTS_SYNC_DRIVER_LOCAL_DEVICE_INFO_PROVIDER_H_
6 #define COMPONENTS_SYNC_DRIVER_LOCAL_DEVICE_INFO_PROVIDER_H_ 6 #define COMPONENTS_SYNC_DRIVER_LOCAL_DEVICE_INFO_PROVIDER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback_list.h" 11 #include "base/callback_list.h"
12 #include "base/threading/non_thread_safe.h"
12 13
13 namespace base { 14 namespace base {
14 class TaskRunner; 15 class TaskRunner;
15 } 16 }
16 17
17 namespace sync_driver { 18 namespace sync_driver {
18 19
19 class DeviceInfo; 20 class DeviceInfo;
20 21
21 // Interface for providing sync specific information about the 22 // Interface for providing sync specific information about the
22 // local device. 23 // local device.
23 class LocalDeviceInfoProvider { 24 class LocalDeviceInfoProvider : public base::NonThreadSafe {
pavely 2016/05/04 22:22:10 LocalDeviceInfoProvider is an interface while NonT
maxbogue 2016/05/04 23:19:47 Done.
24 public: 25 public:
25 typedef base::CallbackList<void(void)>::Subscription Subscription; 26 typedef base::CallbackList<void(void)>::Subscription Subscription;
26 27
27 virtual ~LocalDeviceInfoProvider() {} 28 virtual ~LocalDeviceInfoProvider() {}
28 29
29 // Returns sync's representation of the local device info; 30 // Returns sync's representation of the local device info, or nullptr if the
30 // NULL if the device info is unavailable. 31 // device info is unavailable. The returned object is fully owned by
31 // The returned object is fully owned by LocalDeviceInfoProvider (must not 32 // LocalDeviceInfoProvider; it must not be freed by the caller and should not
32 // be freed by the caller). It remains valid until LocalDeviceInfoProvider 33 // be stored.
33 // is destroyed.
34 virtual const DeviceInfo* GetLocalDeviceInfo() const = 0; 34 virtual const DeviceInfo* GetLocalDeviceInfo() const = 0;
35 35
36 // Constructs a user agent string (ASCII) suitable for use by the syncapi 36 // Constructs a user agent string (ASCII) suitable for use by the syncapi
37 // for any HTTP communication. This string is used by the sync backend for 37 // for any HTTP communication. This string is used by the sync backend for
38 // classifying client types when calculating statistics. 38 // classifying client types when calculating statistics.
39 virtual std::string GetSyncUserAgent() const = 0; 39 virtual std::string GetSyncUserAgent() const = 0;
40 40
41 // Returns a GUID string used for creation of the machine tag for 41 // Returns a GUID string used for creation of the machine tag for
42 // this local session; an empty sting if LocalDeviceInfoProvider hasn't been 42 // this local session; an empty sting if LocalDeviceInfoProvider hasn't been
43 // initialized yet. 43 // initialized yet.
44 virtual std::string GetLocalSyncCacheGUID() const = 0; 44 virtual std::string GetLocalSyncCacheGUID() const = 0;
45 45
46 // Starts initializing local device info. 46 // Starts initializing local device info.
47 virtual void Initialize( 47 virtual void Initialize(
48 const std::string& cache_guid, 48 const std::string& cache_guid,
49 const std::string& signin_scoped_device_id, 49 const std::string& signin_scoped_device_id,
50 const scoped_refptr<base::TaskRunner>& blocking_task_runner) = 0; 50 const scoped_refptr<base::TaskRunner>& blocking_task_runner) = 0;
51 51
52 // Registers a callback to be called when local device info becomes available. 52 // Registers a callback to be called when local device info becomes available.
53 // The callback will remain registered until the 53 // The callback will remain registered until the
54 // returned Subscription is destroyed, which must occur before the 54 // returned Subscription is destroyed, which must occur before the
55 // CallbackList is destroyed. 55 // CallbackList is destroyed.
56 virtual std::unique_ptr<Subscription> RegisterOnInitializedCallback( 56 virtual std::unique_ptr<Subscription> RegisterOnInitializedCallback(
57 const base::Closure& callback) = 0; 57 const base::Closure& callback) = 0;
58
59 // Clears all cached data, returning to an uninitialized state.
60 virtual void Clear() = 0;
58 }; 61 };
59 62
60 } // namespace sync_driver 63 } // namespace sync_driver
61 64
62 #endif // COMPONENTS_SYNC_DRIVER_LOCAL_DEVICE_INFO_PROVIDER_H_ 65 #endif // COMPONENTS_SYNC_DRIVER_LOCAL_DEVICE_INFO_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698