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

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

Issue 2658743002: [Sync] Add ProfileSyncService::GetModelTypeStoreFactory. (Closed)
Patch Set: Fix iOS PSS factory. Created 3 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/device_info_sync_bridge.h" 5 #include "components/sync/device_info/device_info_sync_bridge.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 specifics->set_device_type(info.device_type()); 79 specifics->set_device_type(info.device_type());
80 specifics->set_signin_scoped_device_id(info.signin_scoped_device_id()); 80 specifics->set_signin_scoped_device_id(info.signin_scoped_device_id());
81 specifics->set_last_updated_timestamp(last_updated_timestamp); 81 specifics->set_last_updated_timestamp(last_updated_timestamp);
82 return specifics; 82 return specifics;
83 } 83 }
84 84
85 } // namespace 85 } // namespace
86 86
87 DeviceInfoSyncBridge::DeviceInfoSyncBridge( 87 DeviceInfoSyncBridge::DeviceInfoSyncBridge(
88 LocalDeviceInfoProvider* local_device_info_provider, 88 LocalDeviceInfoProvider* local_device_info_provider,
89 const StoreFactoryFunction& callback, 89 const ModelTypeStoreFactory& store_factory,
90 const ChangeProcessorFactory& change_processor_factory) 90 const ChangeProcessorFactory& change_processor_factory)
91 : ModelTypeSyncBridge(change_processor_factory, DEVICE_INFO), 91 : ModelTypeSyncBridge(change_processor_factory, DEVICE_INFO),
92 local_device_info_provider_(local_device_info_provider) { 92 local_device_info_provider_(local_device_info_provider) {
93 DCHECK(local_device_info_provider); 93 DCHECK(local_device_info_provider);
94 94
95 // This is not threadsafe, but presuably the provider initializes on the same 95 // This is not threadsafe, but presuably the provider initializes on the same
96 // thread as us so we're okay. 96 // thread as us so we're okay.
97 if (local_device_info_provider->GetLocalDeviceInfo()) { 97 if (local_device_info_provider->GetLocalDeviceInfo()) {
98 OnProviderInitialized(); 98 OnProviderInitialized();
99 } else { 99 } else {
100 subscription_ = local_device_info_provider->RegisterOnInitializedCallback( 100 subscription_ = local_device_info_provider->RegisterOnInitializedCallback(
101 base::Bind(&DeviceInfoSyncBridge::OnProviderInitialized, 101 base::Bind(&DeviceInfoSyncBridge::OnProviderInitialized,
102 base::Unretained(this))); 102 base::Unretained(this)));
103 } 103 }
104 104
105 callback.Run( 105 store_factory.Run(
106 base::Bind(&DeviceInfoSyncBridge::OnStoreCreated, base::AsWeakPtr(this))); 106 base::Bind(&DeviceInfoSyncBridge::OnStoreCreated, base::AsWeakPtr(this)));
107 } 107 }
108 108
109 DeviceInfoSyncBridge::~DeviceInfoSyncBridge() {} 109 DeviceInfoSyncBridge::~DeviceInfoSyncBridge() {}
110 110
111 std::unique_ptr<MetadataChangeList> 111 std::unique_ptr<MetadataChangeList>
112 DeviceInfoSyncBridge::CreateMetadataChangeList() { 112 DeviceInfoSyncBridge::CreateMetadataChangeList() {
113 return WriteBatch::CreateMetadataChangeList(); 113 return WriteBatch::CreateMetadataChangeList();
114 } 114 }
115 115
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 473
474 int DeviceInfoSyncBridge::CountActiveDevices(const Time now) const { 474 int DeviceInfoSyncBridge::CountActiveDevices(const Time now) const {
475 return std::count_if(all_data_.begin(), all_data_.end(), 475 return std::count_if(all_data_.begin(), all_data_.end(),
476 [now](ClientIdToSpecifics::const_reference pair) { 476 [now](ClientIdToSpecifics::const_reference pair) {
477 return DeviceInfoUtil::IsActive( 477 return DeviceInfoUtil::IsActive(
478 GetLastUpdateTime(*pair.second), now); 478 GetLastUpdateTime(*pair.second), now);
479 }); 479 });
480 } 480 }
481 481
482 } // namespace syncer 482 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/device_info/device_info_sync_bridge.h ('k') | components/sync/model/model_type_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698