OLD | NEW |
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_driver/generic_change_processor.h" | 5 #include "components/sync_driver/generic_change_processor.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
16 #include "components/sync_driver/sync_api_component_factory.h" | 16 #include "components/sync_driver/sync_api_component_factory.h" |
17 #include "components/sync_driver/sync_client.h" | 17 #include "components/sync_driver/sync_client.h" |
18 #include "sync/api/sync_change.h" | 18 #include "sync/api/sync_change.h" |
19 #include "sync/api/sync_error.h" | 19 #include "sync/api/sync_error.h" |
20 #include "sync/api/syncable_service.h" | 20 #include "sync/api/syncable_service.h" |
21 #include "sync/internal_api/public/base_node.h" | 21 #include "sync/internal_api/public/base_node.h" |
22 #include "sync/internal_api/public/change_record.h" | 22 #include "sync/internal_api/public/change_record.h" |
| 23 #include "sync/internal_api/public/data_type_error_handler.h" |
23 #include "sync/internal_api/public/read_node.h" | 24 #include "sync/internal_api/public/read_node.h" |
24 #include "sync/internal_api/public/read_transaction.h" | 25 #include "sync/internal_api/public/read_transaction.h" |
25 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" | 26 #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
26 #include "sync/internal_api/public/write_node.h" | 27 #include "sync/internal_api/public/write_node.h" |
27 #include "sync/internal_api/public/write_transaction.h" | 28 #include "sync/internal_api/public/write_transaction.h" |
28 #include "sync/syncable/entry.h" // TODO(tim): Bug 123674. | 29 #include "sync/syncable/entry.h" // TODO(tim): Bug 123674. |
29 | 30 |
30 namespace sync_driver { | 31 namespace sync_driver { |
31 | 32 |
32 namespace { | 33 namespace { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 sync_id, read_node.GetEntitySpecifics(), | 101 sync_id, read_node.GetEntitySpecifics(), |
101 read_node.GetModificationTime(), attachment_ids, | 102 read_node.GetModificationTime(), attachment_ids, |
102 attachment_service_proxy); | 103 attachment_service_proxy); |
103 } | 104 } |
104 } | 105 } |
105 | 106 |
106 } // namespace | 107 } // namespace |
107 | 108 |
108 GenericChangeProcessor::GenericChangeProcessor( | 109 GenericChangeProcessor::GenericChangeProcessor( |
109 syncer::ModelType type, | 110 syncer::ModelType type, |
110 DataTypeErrorHandler* error_handler, | 111 syncer::DataTypeErrorHandler* error_handler, |
111 const base::WeakPtr<syncer::SyncableService>& local_service, | 112 const base::WeakPtr<syncer::SyncableService>& local_service, |
112 const base::WeakPtr<syncer::SyncMergeResult>& merge_result, | 113 const base::WeakPtr<syncer::SyncMergeResult>& merge_result, |
113 syncer::UserShare* user_share, | 114 syncer::UserShare* user_share, |
114 SyncClient* sync_client, | 115 SyncClient* sync_client, |
115 std::unique_ptr<syncer::AttachmentStoreForSync> attachment_store) | 116 std::unique_ptr<syncer::AttachmentStoreForSync> attachment_store) |
116 : ChangeProcessor(error_handler), | 117 : ChangeProcessor(error_handler), |
117 type_(type), | 118 type_(type), |
118 local_service_(local_service), | 119 local_service_(local_service), |
119 merge_result_(merge_result), | 120 merge_result_(merge_result), |
120 share_handle_(user_share), | 121 share_handle_(user_share), |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 321 |
321 // WARNING: this code is sensitive to compiler optimizations. Be careful | 322 // WARNING: this code is sensitive to compiler optimizations. Be careful |
322 // modifying any code around an OnSingleDataTypeUnrecoverableError call, else | 323 // modifying any code around an OnSingleDataTypeUnrecoverableError call, else |
323 // the compiler attempts to merge it with other calls, losing useful information | 324 // the compiler attempts to merge it with other calls, losing useful information |
324 // in breakpad uploads. | 325 // in breakpad uploads. |
325 syncer::SyncError LogLookupFailure( | 326 syncer::SyncError LogLookupFailure( |
326 syncer::BaseNode::InitByLookupResult lookup_result, | 327 syncer::BaseNode::InitByLookupResult lookup_result, |
327 const tracked_objects::Location& from_here, | 328 const tracked_objects::Location& from_here, |
328 const std::string& error_prefix, | 329 const std::string& error_prefix, |
329 syncer::ModelType type, | 330 syncer::ModelType type, |
330 DataTypeErrorHandler* error_handler) { | 331 syncer::DataTypeErrorHandler* error_handler) { |
331 switch (lookup_result) { | 332 switch (lookup_result) { |
332 case syncer::BaseNode::INIT_FAILED_ENTRY_NOT_GOOD: { | 333 case syncer::BaseNode::INIT_FAILED_ENTRY_NOT_GOOD: { |
333 syncer::SyncError error; | 334 syncer::SyncError error; |
334 error.Reset(from_here, | 335 error.Reset(from_here, |
335 error_prefix + | 336 error_prefix + |
336 "could not find entry matching the lookup criteria.", | 337 "could not find entry matching the lookup criteria.", |
337 type); | 338 type); |
338 error_handler->OnSingleDataTypeUnrecoverableError(error); | 339 error_handler->OnSingleDataTypeUnrecoverableError(error); |
339 LOG(ERROR) << "Delete: Bad entry."; | 340 LOG(ERROR) << "Delete: Bad entry."; |
340 return error; | 341 return error; |
(...skipping 29 matching lines...) Expand all Loading... |
370 LOG(ERROR) << "Delete: Unknown error."; | 371 LOG(ERROR) << "Delete: Unknown error."; |
371 return error; | 372 return error; |
372 } | 373 } |
373 } | 374 } |
374 } | 375 } |
375 | 376 |
376 syncer::SyncError AttemptDelete(const syncer::SyncChange& change, | 377 syncer::SyncError AttemptDelete(const syncer::SyncChange& change, |
377 syncer::ModelType type, | 378 syncer::ModelType type, |
378 const std::string& type_str, | 379 const std::string& type_str, |
379 syncer::WriteNode* node, | 380 syncer::WriteNode* node, |
380 DataTypeErrorHandler* error_handler) { | 381 syncer::DataTypeErrorHandler* error_handler) { |
381 DCHECK_EQ(change.change_type(), syncer::SyncChange::ACTION_DELETE); | 382 DCHECK_EQ(change.change_type(), syncer::SyncChange::ACTION_DELETE); |
382 if (change.sync_data().IsLocal()) { | 383 if (change.sync_data().IsLocal()) { |
383 const std::string& tag = syncer::SyncDataLocal(change.sync_data()).GetTag(); | 384 const std::string& tag = syncer::SyncDataLocal(change.sync_data()).GetTag(); |
384 if (tag.empty()) { | 385 if (tag.empty()) { |
385 syncer::SyncError error( | 386 syncer::SyncError error( |
386 FROM_HERE, | 387 FROM_HERE, |
387 syncer::SyncError::DATATYPE_ERROR, | 388 syncer::SyncError::DATATYPE_ERROR, |
388 "Failed to delete " + type_str + " node. Local data, empty tag. " + | 389 "Failed to delete " + type_str + " node. Local data, empty tag. " + |
389 change.location().ToString(), | 390 change.location().ToString(), |
390 type); | 391 type); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 } | 695 } |
695 } | 696 } |
696 | 697 |
697 std::unique_ptr<syncer::AttachmentService> | 698 std::unique_ptr<syncer::AttachmentService> |
698 GenericChangeProcessor::GetAttachmentService() const { | 699 GenericChangeProcessor::GetAttachmentService() const { |
699 return std::unique_ptr<syncer::AttachmentService>( | 700 return std::unique_ptr<syncer::AttachmentService>( |
700 new syncer::AttachmentServiceProxy(attachment_service_proxy_)); | 701 new syncer::AttachmentServiceProxy(attachment_service_proxy_)); |
701 } | 702 } |
702 | 703 |
703 } // namespace sync_driver | 704 } // namespace sync_driver |
OLD | NEW |