Chromium Code Reviews| 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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 | 378 |
| 379 void DeviceInfoSyncBridge::OnReadAllMetadata( | 379 void DeviceInfoSyncBridge::OnReadAllMetadata( |
| 380 SyncError error, | 380 SyncError error, |
| 381 std::unique_ptr<MetadataBatch> metadata_batch) { | 381 std::unique_ptr<MetadataBatch> metadata_batch) { |
| 382 change_processor()->OnMetadataLoaded(error, std::move(metadata_batch)); | 382 change_processor()->OnMetadataLoaded(error, std::move(metadata_batch)); |
| 383 ReconcileLocalAndStored(); | 383 ReconcileLocalAndStored(); |
| 384 } | 384 } |
| 385 | 385 |
| 386 void DeviceInfoSyncBridge::OnCommit(Result result) { | 386 void DeviceInfoSyncBridge::OnCommit(Result result) { |
| 387 if (result != Result::SUCCESS) { | 387 if (result != Result::SUCCESS) { |
| 388 change_processor()->CreateAndUploadError(FROM_HERE, | 388 change_processor()->OnUnrecoverableError( |
| 389 "Failed a write to store."); | 389 SyncError(FROM_HERE, SyncError::DATATYPE_ERROR, |
| 390 "Failed a write to store.", type())); | |
| 390 } | 391 } |
| 391 } | 392 } |
| 392 | 393 |
| 393 void DeviceInfoSyncBridge::ReconcileLocalAndStored() { | 394 void DeviceInfoSyncBridge::ReconcileLocalAndStored() { |
| 394 // On initial syncing we will have a change processor here, but it will not be | 395 // On initial syncing we will have a change processor here, but it will not be |
| 395 // tracking changes. We need to persist a copy of our local device info to | 396 // tracking changes. We need to persist a copy of our local device info to |
| 396 // disk, but the Put call to the processor will be ignored. That should be | 397 // disk, but the Put call to the processor will be ignored. That should be |
| 397 // fine however, as the discrepancy will be picked up later in merge. We don't | 398 // fine however, as the discrepancy will be picked up later in merge. We don't |
| 398 // bother trying to track this case and act intelligently because simply not | 399 // bother trying to track this case and act intelligently because simply not |
| 399 // much of a benefit in doing so. | 400 // much of a benefit in doing so. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 469 [now](ClientIdToSpecifics::const_reference pair) { | 470 [now](ClientIdToSpecifics::const_reference pair) { |
| 470 return DeviceInfoUtil::IsActive( | 471 return DeviceInfoUtil::IsActive( |
| 471 GetLastUpdateTime(*pair.second), now); | 472 GetLastUpdateTime(*pair.second), now); |
| 472 }); | 473 }); |
| 473 } | 474 } |
| 474 | 475 |
| 475 void DeviceInfoSyncBridge::ReportStartupErrorToSync(const std::string& msg) { | 476 void DeviceInfoSyncBridge::ReportStartupErrorToSync(const std::string& msg) { |
| 476 // TODO(skym): Shouldn't need to log this here, reporting should always log. | 477 // TODO(skym): Shouldn't need to log this here, reporting should always log. |
| 477 LOG(WARNING) << msg; | 478 LOG(WARNING) << msg; |
| 478 change_processor()->OnMetadataLoaded( | 479 change_processor()->OnMetadataLoaded( |
| 479 change_processor()->CreateAndUploadError(FROM_HERE, msg), nullptr); | 480 change_processor()->CreateAndUploadError(FROM_HERE, msg, type()), |
|
skym
2017/01/05 17:03:49
What if, we instead abandon the old error interfac
maxbogue
2017/01/07 00:12:39
Done!
| |
| 481 nullptr); | |
| 480 } | 482 } |
| 481 | 483 |
| 482 } // namespace syncer | 484 } // namespace syncer |
| OLD | NEW |