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

Side by Side Diff: chrome/browser/sync/glue/local_device_info_provider_impl.cc

Issue 367153005: Sync: Refactoring of DEVICE_INFO syncable type - Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed build issues in browser_tests Created 6 years, 5 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
(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 #include "chrome/browser/sync/glue/local_device_info_provider_impl.h"
6
7 namespace browser_sync {
8
9 LocalDeviceInfoProviderImpl::LocalDeviceInfoProviderImpl()
10 : weak_factory_(this) {
11 }
12
13 LocalDeviceInfoProviderImpl::~LocalDeviceInfoProviderImpl() {
14 }
15
16 const DeviceInfo*
17 LocalDeviceInfoProviderImpl::GetLocalDeviceInfo() const {
18 return local_device_info_.get();
19 }
20
21 std::string LocalDeviceInfoProviderImpl::GetLocalSyncCacheGUID() const {
22 return cache_guid_;
23 }
24
25 bool LocalDeviceInfoProviderImpl::IsInitialized() const {
26 return !!local_device_info_.get();
27 }
28
29 scoped_ptr<LocalDeviceInfoProvider::Subscription>
30 LocalDeviceInfoProviderImpl::RegisterOnInitializedCallback(
31 const base::Closure& callback) {
32 DCHECK(!IsInitialized());
33 return callback_list_.Add(callback);
34 }
35
36 void LocalDeviceInfoProviderImpl::Initialize(const std::string& cache_guid) {
maniscalco 2014/07/08 21:17:53 Can cache_guid be an empty string? If not, consid
stanisc 2014/07/09 21:58:36 Done.
37 cache_guid_ = cache_guid;
38 DeviceInfo::CreateLocalDeviceInfo(
39 cache_guid_,
40 base::Bind(&LocalDeviceInfoProviderImpl::InitializeContinuation,
41 weak_factory_.GetWeakPtr()));
42 }
43
44 void LocalDeviceInfoProviderImpl::InitializeContinuation(
45 const DeviceInfo& local_info) {
46 // Copy constructor is disallowed in DeviceInfo, construct a new one from
47 // the fields passed in local_info
48 local_device_info_.reset(
49 new DeviceInfo(
50 local_info.guid(),
51 local_info.client_name(),
52 local_info.chrome_version(),
53 local_info.sync_user_agent(),
54 local_info.device_type()));
55
56 // Notify observers
57 callback_list_.Notify();
58 }
59
60 } // namespace browser_sync
61
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698