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.
5 #include "components/sync_driver/local_device_info_provider_mock.h"
7 namespace sync_driver
{
9 LocalDeviceInfoProviderMock::LocalDeviceInfoProviderMock()
10 : is_initialized_(false) {}
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(
27 signin_scoped_device_id
));
30 LocalDeviceInfoProviderMock::~LocalDeviceInfoProviderMock() {}
32 const DeviceInfo
* LocalDeviceInfoProviderMock::GetLocalDeviceInfo() const {
33 return is_initialized_
? local_device_info_
.get() : NULL
;
36 std::string
LocalDeviceInfoProviderMock::GetLocalSyncCacheGUID() const {
37 return local_device_info_
.get() ? local_device_info_
->guid() : "";
40 void LocalDeviceInfoProviderMock::Initialize(
41 const std::string
& cache_guid
, const std::string
& signin_scoped_device_id
) {
42 // Ignored for the mock provider.
45 scoped_ptr
<LocalDeviceInfoProvider::Subscription
>
46 LocalDeviceInfoProviderMock::RegisterOnInitializedCallback(
47 const base::Closure
& callback
) {
48 DCHECK(!is_initialized_
);
49 return callback_list_
.Add(callback
);
52 void LocalDeviceInfoProviderMock::SetInitialized(bool is_initialized
) {
53 is_initialized_
= is_initialized
;
54 if (is_initialized_
) {
55 callback_list_
.Notify();
59 } // namespace sync_driver