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