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::GetSyncUserAgent() const {
40 std::string
LocalDeviceInfoProviderMock::GetLocalSyncCacheGUID() const {
41 return local_device_info_
.get() ? local_device_info_
->guid() : "";
44 void LocalDeviceInfoProviderMock::Initialize(
45 const std::string
& cache_guid
, const std::string
& signin_scoped_device_id
) {
46 // Ignored for the mock provider.
49 scoped_ptr
<LocalDeviceInfoProvider::Subscription
>
50 LocalDeviceInfoProviderMock::RegisterOnInitializedCallback(
51 const base::Closure
& callback
) {
52 DCHECK(!is_initialized_
);
53 return callback_list_
.Add(callback
);
56 void LocalDeviceInfoProviderMock::SetInitialized(bool is_initialized
) {
57 is_initialized_
= is_initialized
;
58 if (is_initialized_
) {
59 callback_list_
.Notify();
63 } // namespace sync_driver