Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Side by Side Diff: components/sync_driver/local_device_info_provider_mock.cc

Issue 2203673002: [Sync] Move //components/sync_driver to //components/sync/driver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sd-a
Patch Set: Full change rebased on static lib. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "components/sync_driver/local_device_info_provider_mock.h"
6
7 namespace sync_driver {
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 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 DeviceInfo* LocalDeviceInfoProviderMock::GetLocalDeviceInfo() const {
33 return is_initialized_ ? local_device_info_.get() : nullptr;
34 }
35
36 std::string LocalDeviceInfoProviderMock::GetSyncUserAgent() const {
37 return "useragent";
38 }
39
40 std::string LocalDeviceInfoProviderMock::GetLocalSyncCacheGUID() const {
41 return local_device_info_.get() ? local_device_info_->guid() : "";
42 }
43
44 void LocalDeviceInfoProviderMock::Initialize(
45 const std::string& cache_guid,
46 const std::string& signin_scoped_device_id,
47 const scoped_refptr<base::TaskRunner>& blocking_task_runner) {
48 local_device_info_.reset(new DeviceInfo(
49 cache_guid, "client_name", "chrome_version", GetSyncUserAgent(),
50 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, signin_scoped_device_id));
51 SetInitialized(true);
52 }
53
54 void LocalDeviceInfoProviderMock::Initialize(
55 std::unique_ptr<DeviceInfo> local_device_info) {
56 local_device_info_.swap(local_device_info);
57 SetInitialized(true);
58 }
59
60 std::unique_ptr<LocalDeviceInfoProvider::Subscription>
61 LocalDeviceInfoProviderMock::RegisterOnInitializedCallback(
62 const base::Closure& callback) {
63 DCHECK(!is_initialized_);
64 return callback_list_.Add(callback);
65 }
66
67 void LocalDeviceInfoProviderMock::Clear() {
68 local_device_info_.reset();
69 is_initialized_ = false;
70 }
71
72 void LocalDeviceInfoProviderMock::SetInitialized(bool is_initialized) {
73 is_initialized_ = is_initialized;
74 if (is_initialized_) {
75 callback_list_.Notify();
76 }
77 }
78
79 } // namespace sync_driver
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698