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_service.h" | 5 #include "components/sync/device_info/device_info_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "components/sync/api/entity_change.h" | 15 #include "components/sync/api/entity_change.h" |
16 #include "components/sync/api/metadata_batch.h" | 16 #include "components/sync/api/metadata_batch.h" |
17 #include "components/sync/api/sync_error.h" | 17 #include "components/sync/api/sync_error.h" |
18 #include "components/sync/base/time.h" | 18 #include "components/sync/base/time.h" |
19 #include "components/sync/core/data_batch_impl.h" | 19 #include "components/sync/core/data_batch_impl.h" |
20 #include "components/sync/device_info/device_info_util.h" | 20 #include "components/sync/device_info/device_info_util.h" |
21 #include "components/sync/protocol/data_type_state.pb.h" | 21 #include "components/sync/protocol/model_type_state.pb.h" |
22 #include "components/sync/protocol/sync.pb.h" | 22 #include "components/sync/protocol/sync.pb.h" |
23 | 23 |
24 namespace syncer { | 24 namespace syncer { |
25 | 25 |
26 using base::Time; | 26 using base::Time; |
27 using base::TimeDelta; | 27 using base::TimeDelta; |
28 using sync_pb::DataTypeState; | |
29 using sync_pb::DeviceInfoSpecifics; | 28 using sync_pb::DeviceInfoSpecifics; |
30 using sync_pb::EntitySpecifics; | 29 using sync_pb::EntitySpecifics; |
| 30 using sync_pb::ModelTypeState; |
31 | 31 |
32 using Record = ModelTypeStore::Record; | 32 using Record = ModelTypeStore::Record; |
33 using RecordList = ModelTypeStore::RecordList; | 33 using RecordList = ModelTypeStore::RecordList; |
34 using Result = ModelTypeStore::Result; | 34 using Result = ModelTypeStore::Result; |
35 using WriteBatch = ModelTypeStore::WriteBatch; | 35 using WriteBatch = ModelTypeStore::WriteBatch; |
36 | 36 |
37 DeviceInfoService::DeviceInfoService( | 37 DeviceInfoService::DeviceInfoService( |
38 LocalDeviceInfoProvider* local_device_info_provider, | 38 LocalDeviceInfoProvider* local_device_info_provider, |
39 const StoreFactoryFunction& callback, | 39 const StoreFactoryFunction& callback, |
40 const ChangeProcessorFactory& change_processor_factory) | 40 const ChangeProcessorFactory& change_processor_factory) |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 // is created later. | 379 // is created later. |
380 has_metadata_loaded_ = true; | 380 has_metadata_loaded_ = true; |
381 | 381 |
382 if (!change_processor()) { | 382 if (!change_processor()) { |
383 // This means we haven't been told to start syncing and we don't have any | 383 // This means we haven't been told to start syncing and we don't have any |
384 // local metadata. | 384 // local metadata. |
385 return; | 385 return; |
386 } | 386 } |
387 | 387 |
388 std::unique_ptr<MetadataBatch> batch(new MetadataBatch()); | 388 std::unique_ptr<MetadataBatch> batch(new MetadataBatch()); |
389 DataTypeState state; | 389 ModelTypeState state; |
390 if (state.ParseFromString(global_metadata)) { | 390 if (state.ParseFromString(global_metadata)) { |
391 batch->SetDataTypeState(state); | 391 batch->SetModelTypeState(state); |
392 } else { | 392 } else { |
393 // TODO(skym): How bad is this scenario? We may be able to just give an | 393 // TODO(skym): How bad is this scenario? We may be able to just give an |
394 // empty batch to the processor and we'll treat corrupted data type state | 394 // empty batch to the processor and we'll treat corrupted data type state |
395 // as no data type state at all. The question is do we want to add any of | 395 // as no data type state at all. The question is do we want to add any of |
396 // the entity metadata to the batch or completely skip that step? We're | 396 // the entity metadata to the batch or completely skip that step? We're |
397 // going to have to perform a merge shortly. Does this decision/logic even | 397 // going to have to perform a merge shortly. Does this decision/logic even |
398 // belong in this service? | 398 // belong in this service? |
399 change_processor()->OnMetadataLoaded( | 399 change_processor()->OnMetadataLoaded( |
400 change_processor()->CreateAndUploadError( | 400 change_processor()->CreateAndUploadError( |
401 FROM_HERE, "Failed to deserialize global metadata."), | 401 FROM_HERE, "Failed to deserialize global metadata."), |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 Time DeviceInfoService::GetLastUpdateTime( | 515 Time DeviceInfoService::GetLastUpdateTime( |
516 const DeviceInfoSpecifics& specifics) { | 516 const DeviceInfoSpecifics& specifics) { |
517 if (specifics.has_last_updated_timestamp()) { | 517 if (specifics.has_last_updated_timestamp()) { |
518 return ProtoTimeToTime(specifics.last_updated_timestamp()); | 518 return ProtoTimeToTime(specifics.last_updated_timestamp()); |
519 } else { | 519 } else { |
520 return Time(); | 520 return Time(); |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 } // namespace syncer | 524 } // namespace syncer |
OLD | NEW |