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