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