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_mock.h" |
| 6 |
| 7 namespace browser_sync { |
| 8 |
| 9 LocalDeviceInfoProviderMock::LocalDeviceInfoProviderMock() |
| 10 : is_initialized_(false) {} |
| 11 |
| 12 LocalDeviceInfoProviderMock::LocalDeviceInfoProviderMock( |
| 13 const std::string& guid, |
| 14 const std::string& client_name, |
| 15 const std::string& chrome_version, |
| 16 const std::string& sync_user_agent, |
| 17 const sync_pb::SyncEnums::DeviceType device_type) |
| 18 : is_initialized_(true) { |
| 19 local_device_info_.reset( |
| 20 new DeviceInfo( |
| 21 guid, |
| 22 client_name, |
| 23 chrome_version, |
| 24 sync_user_agent, |
| 25 device_type)); |
| 26 } |
| 27 |
| 28 LocalDeviceInfoProviderMock::~LocalDeviceInfoProviderMock() {} |
| 29 |
| 30 const DeviceInfo* |
| 31 LocalDeviceInfoProviderMock::GetLocalDeviceInfo() const { |
| 32 return is_initialized_ ? local_device_info_.get() : NULL; |
| 33 } |
| 34 |
| 35 std::string LocalDeviceInfoProviderMock::GetLocalSyncCacheGUID() const { |
| 36 return local_device_info_.get() ? local_device_info_->guid() : ""; |
| 37 } |
| 38 |
| 39 void LocalDeviceInfoProviderMock::Initialize(const std::string& cache_guid) { |
| 40 // Ignored for the mock provider. |
| 41 } |
| 42 |
| 43 scoped_ptr<LocalDeviceInfoProvider::Subscription> |
| 44 LocalDeviceInfoProviderMock::RegisterOnInitializedCallback( |
| 45 const base::Closure& callback) { |
| 46 DCHECK(!is_initialized_); |
| 47 return callback_list_.Add(callback); |
| 48 } |
| 49 |
| 50 void LocalDeviceInfoProviderMock::SetInitialized(bool is_initialized) { |
| 51 is_initialized_ = is_initialized; |
| 52 if (is_initialized_) { |
| 53 callback_list_.Notify(); |
| 54 } |
| 55 } |
| 56 |
| 57 } // namespace browser_sync |
| 58 |
OLD | NEW |