| 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 #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 scoped_ptr<LocalDeviceInfoProvider::Subscription> | |
| 26 LocalDeviceInfoProviderImpl::RegisterOnInitializedCallback( | |
| 27 const base::Closure& callback) { | |
| 28 DCHECK(!local_device_info_.get()); | |
| 29 return callback_list_.Add(callback); | |
| 30 } | |
| 31 | |
| 32 void LocalDeviceInfoProviderImpl::Initialize(const std::string& cache_guid) { | |
| 33 DCHECK(!cache_guid.empty()); | |
| 34 cache_guid_ = cache_guid; | |
| 35 DeviceInfo::CreateLocalDeviceInfo( | |
| 36 cache_guid_, | |
| 37 base::Bind(&LocalDeviceInfoProviderImpl::InitializeContinuation, | |
| 38 weak_factory_.GetWeakPtr())); | |
| 39 } | |
| 40 | |
| 41 void LocalDeviceInfoProviderImpl::InitializeContinuation( | |
| 42 const DeviceInfo& local_info) { | |
| 43 // Copy constructor is disallowed in DeviceInfo, construct a new one from | |
| 44 // the fields passed in local_info. | |
| 45 local_device_info_.reset( | |
| 46 new DeviceInfo( | |
| 47 local_info.guid(), | |
| 48 local_info.client_name(), | |
| 49 local_info.chrome_version(), | |
| 50 local_info.sync_user_agent(), | |
| 51 local_info.device_type())); | |
| 52 | |
| 53 // Notify observers. | |
| 54 callback_list_.Notify(); | |
| 55 } | |
| 56 | |
| 57 } // namespace browser_sync | |
| 58 | |
| OLD | NEW |