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

Side by Side Diff: components/sync/device_info/local_device_info_provider_impl.cc

Issue 2388673002: Revert of [Sync] Move //components/sync to the syncer namespace. (patchset #5 id:40001 of https://co (Closed)
Patch Set: Created 4 years, 2 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/sync/device_info/local_device_info_provider_impl.h" 5 #include "components/sync/device_info/local_device_info_provider_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/task_runner.h" 8 #include "base/task_runner.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "components/sync/base/get_session_name.h" 10 #include "components/sync/base/get_session_name.h"
11 #include "components/sync/driver/sync_util.h" 11 #include "components/sync/driver/sync_util.h"
12 12
13 namespace syncer { 13 namespace browser_sync {
14 14
15 namespace { 15 namespace {
16 16
17 sync_pb::SyncEnums::DeviceType GetLocalDeviceType(bool is_tablet) { 17 sync_pb::SyncEnums::DeviceType GetLocalDeviceType(bool is_tablet) {
18 #if defined(OS_CHROMEOS) 18 #if defined(OS_CHROMEOS)
19 return sync_pb::SyncEnums_DeviceType_TYPE_CROS; 19 return sync_pb::SyncEnums_DeviceType_TYPE_CROS;
20 #elif defined(OS_LINUX) 20 #elif defined(OS_LINUX)
21 return sync_pb::SyncEnums_DeviceType_TYPE_LINUX; 21 return sync_pb::SyncEnums_DeviceType_TYPE_LINUX;
22 #elif defined(OS_ANDROID) || defined(OS_IOS) 22 #elif defined(OS_ANDROID) || defined(OS_IOS)
23 return is_tablet ? sync_pb::SyncEnums_DeviceType_TYPE_TABLET 23 return is_tablet ? sync_pb::SyncEnums_DeviceType_TYPE_TABLET
(...skipping 15 matching lines...) Expand all
39 bool is_tablet) 39 bool is_tablet)
40 : channel_(channel), 40 : channel_(channel),
41 version_(version), 41 version_(version),
42 is_tablet_(is_tablet), 42 is_tablet_(is_tablet),
43 weak_factory_(this) { 43 weak_factory_(this) {
44 DCHECK(CalledOnValidThread()); 44 DCHECK(CalledOnValidThread());
45 } 45 }
46 46
47 LocalDeviceInfoProviderImpl::~LocalDeviceInfoProviderImpl() {} 47 LocalDeviceInfoProviderImpl::~LocalDeviceInfoProviderImpl() {}
48 48
49 const DeviceInfo* LocalDeviceInfoProviderImpl::GetLocalDeviceInfo() const { 49 const sync_driver::DeviceInfo* LocalDeviceInfoProviderImpl::GetLocalDeviceInfo()
50 const {
50 DCHECK(CalledOnValidThread()); 51 DCHECK(CalledOnValidThread());
51 return local_device_info_.get(); 52 return local_device_info_.get();
52 } 53 }
53 54
54 std::string LocalDeviceInfoProviderImpl::GetSyncUserAgent() const { 55 std::string LocalDeviceInfoProviderImpl::GetSyncUserAgent() const {
55 DCHECK(CalledOnValidThread()); 56 DCHECK(CalledOnValidThread());
56 return MakeUserAgentForSync(channel_, is_tablet_); 57 return MakeUserAgentForSync(channel_, is_tablet_);
57 } 58 }
58 59
59 std::string LocalDeviceInfoProviderImpl::GetLocalSyncCacheGUID() const { 60 std::string LocalDeviceInfoProviderImpl::GetLocalSyncCacheGUID() const {
60 DCHECK(CalledOnValidThread()); 61 DCHECK(CalledOnValidThread());
61 return cache_guid_; 62 return cache_guid_;
62 } 63 }
63 64
64 std::unique_ptr<LocalDeviceInfoProvider::Subscription> 65 std::unique_ptr<sync_driver::LocalDeviceInfoProvider::Subscription>
65 LocalDeviceInfoProviderImpl::RegisterOnInitializedCallback( 66 LocalDeviceInfoProviderImpl::RegisterOnInitializedCallback(
66 const base::Closure& callback) { 67 const base::Closure& callback) {
67 DCHECK(CalledOnValidThread()); 68 DCHECK(CalledOnValidThread());
68 DCHECK(!local_device_info_.get()); 69 DCHECK(!local_device_info_.get());
69 return callback_list_.Add(callback); 70 return callback_list_.Add(callback);
70 } 71 }
71 72
72 void LocalDeviceInfoProviderImpl::Initialize( 73 void LocalDeviceInfoProviderImpl::Initialize(
73 const std::string& cache_guid, 74 const std::string& cache_guid,
74 const std::string& signin_scoped_device_id, 75 const std::string& signin_scoped_device_id,
75 const scoped_refptr<base::TaskRunner>& blocking_task_runner) { 76 const scoped_refptr<base::TaskRunner>& blocking_task_runner) {
76 DCHECK(CalledOnValidThread()); 77 DCHECK(CalledOnValidThread());
77 DCHECK(!cache_guid.empty()); 78 DCHECK(!cache_guid.empty());
78 cache_guid_ = cache_guid; 79 cache_guid_ = cache_guid;
79 80
80 GetSessionName( 81 syncer::GetSessionName(
81 blocking_task_runner, 82 blocking_task_runner,
82 base::Bind(&LocalDeviceInfoProviderImpl::InitializeContinuation, 83 base::Bind(&LocalDeviceInfoProviderImpl::InitializeContinuation,
83 weak_factory_.GetWeakPtr(), cache_guid, 84 weak_factory_.GetWeakPtr(), cache_guid,
84 signin_scoped_device_id)); 85 signin_scoped_device_id));
85 } 86 }
86 87
87 void LocalDeviceInfoProviderImpl::InitializeContinuation( 88 void LocalDeviceInfoProviderImpl::InitializeContinuation(
88 const std::string& guid, 89 const std::string& guid,
89 const std::string& signin_scoped_device_id, 90 const std::string& signin_scoped_device_id,
90 const std::string& session_name) { 91 const std::string& session_name) {
91 DCHECK(CalledOnValidThread()); 92 DCHECK(CalledOnValidThread());
92 if (guid != cache_guid_) { 93 if (guid != cache_guid_) {
93 // Clear() happened before this callback; abort. 94 // Clear() happened before this callback; abort.
94 return; 95 return;
95 } 96 }
96 97
97 local_device_info_.reset( 98 local_device_info_.reset(new sync_driver::DeviceInfo(
98 new DeviceInfo(guid, session_name, version_, GetSyncUserAgent(), 99 guid, session_name, version_, GetSyncUserAgent(),
99 GetLocalDeviceType(is_tablet_), signin_scoped_device_id)); 100 GetLocalDeviceType(is_tablet_), signin_scoped_device_id));
100 101
101 // Notify observers. 102 // Notify observers.
102 callback_list_.Notify(); 103 callback_list_.Notify();
103 } 104 }
104 105
105 void LocalDeviceInfoProviderImpl::Clear() { 106 void LocalDeviceInfoProviderImpl::Clear() {
106 DCHECK(CalledOnValidThread()); 107 DCHECK(CalledOnValidThread());
107 cache_guid_ = ""; 108 cache_guid_ = "";
108 local_device_info_.reset(); 109 local_device_info_.reset();
109 } 110 }
110 111
111 } // namespace syncer 112 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698