summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/glue/local_device_info_provider_impl.h
blob: 4c8145fffd70c5a83e6bd6a55336f93829d81b90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_SYNC_GLUE_LOCAL_DEVICE_INFO_PROVIDER_IMPL_H_
#define CHROME_BROWSER_SYNC_GLUE_LOCAL_DEVICE_INFO_PROVIDER_IMPL_H_

#include "base/memory/weak_ptr.h"
#include "components/sync_driver/device_info.h"
#include "components/sync_driver/local_device_info_provider.h"

namespace chrome {
class VersionInfo;
}

namespace browser_sync {

class LocalDeviceInfoProviderImpl
    : public sync_driver::LocalDeviceInfoProvider {
 public:
  LocalDeviceInfoProviderImpl();
  ~LocalDeviceInfoProviderImpl() override;

  // LocalDeviceInfoProvider implementation.
  const sync_driver::DeviceInfo* GetLocalDeviceInfo() const override;
  std::string GetLocalSyncCacheGUID() const override;
  void Initialize(const std::string& cache_guid,
                  const std::string& signin_scoped_device_id) override;
  scoped_ptr<Subscription> RegisterOnInitializedCallback(
      const base::Closure& callback) override;

  // Helper to construct a user agent string (ASCII) suitable for use by
  // the syncapi for any HTTP communication. This string is used by the sync
  // backend for classifying client types when calculating statistics.
  static std::string MakeUserAgentForSyncApi(
      const chrome::VersionInfo& version_info);

 private:
  void InitializeContinuation(const std::string& guid,
                              const std::string& signin_scoped_device_id,
                              const std::string& session_name);

  std::string cache_guid_;
  scoped_ptr<sync_driver::DeviceInfo> local_device_info_;
  base::CallbackList<void(void)> callback_list_;
  base::WeakPtrFactory<LocalDeviceInfoProviderImpl> weak_factory_;

  DISALLOW_COPY_AND_ASSIGN(LocalDeviceInfoProviderImpl);
};

}  // namespace browser_sync

#endif  // CHROME_BROWSER_SYNC_GLUE_LOCAL_DEVICE_INFO_PROVIDER_IMPL_H_