| OLD | NEW |
| 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 } | 380 } |
| 381 | 381 |
| 382 void DeviceInfoSyncBridge::OnReadAllMetadata( | 382 void DeviceInfoSyncBridge::OnReadAllMetadata( |
| 383 base::Optional<ModelError> error, | 383 base::Optional<ModelError> error, |
| 384 std::unique_ptr<MetadataBatch> metadata_batch) { | 384 std::unique_ptr<MetadataBatch> metadata_batch) { |
| 385 if (error) { | 385 if (error) { |
| 386 change_processor()->ReportError(error.value()); | 386 change_processor()->ReportError(error.value()); |
| 387 return; | 387 return; |
| 388 } | 388 } |
| 389 | 389 |
| 390 change_processor()->OnMetadataLoaded(std::move(metadata_batch)); | 390 change_processor()->ModelReadyToSync(std::move(metadata_batch)); |
| 391 ReconcileLocalAndStored(); | 391 ReconcileLocalAndStored(); |
| 392 } | 392 } |
| 393 | 393 |
| 394 void DeviceInfoSyncBridge::OnCommit(Result result) { | 394 void DeviceInfoSyncBridge::OnCommit(Result result) { |
| 395 if (result != Result::SUCCESS) { | 395 if (result != Result::SUCCESS) { |
| 396 change_processor()->ReportError(FROM_HERE, "Failed a write to store."); | 396 change_processor()->ReportError(FROM_HERE, "Failed a write to store."); |
| 397 } | 397 } |
| 398 } | 398 } |
| 399 | 399 |
| 400 void DeviceInfoSyncBridge::ReconcileLocalAndStored() { | 400 void DeviceInfoSyncBridge::ReconcileLocalAndStored() { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |