OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/sync/glue/generic_change_processor.h" | 5 #include "chrome/browser/sync/glue/generic_change_processor.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 syncer_changes_); | 131 syncer_changes_); |
132 syncer_changes_.clear(); | 132 syncer_changes_.clear(); |
133 if (error.IsSet()) { | 133 if (error.IsSet()) { |
134 error_handler()->OnSingleDatatypeUnrecoverableError( | 134 error_handler()->OnSingleDatatypeUnrecoverableError( |
135 error.location(), error.message()); | 135 error.location(), error.message()); |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 syncer::SyncError GenericChangeProcessor::GetSyncDataForType( | 139 syncer::SyncError GenericChangeProcessor::GetSyncDataForType( |
140 syncer::ModelType type, | 140 syncer::ModelType type, |
141 syncer::SyncDataList* current_sync_data) { | 141 syncer::SyncDataList* current_sync_data) const { |
142 DCHECK(CalledOnValidThread()); | 142 DCHECK(CalledOnValidThread()); |
143 std::string type_name = syncer::ModelTypeToString(type); | 143 std::string type_name = syncer::ModelTypeToString(type); |
144 syncer::ReadTransaction trans(FROM_HERE, share_handle()); | 144 syncer::ReadTransaction trans(FROM_HERE, share_handle()); |
145 syncer::ReadNode root(&trans); | 145 syncer::ReadNode root(&trans); |
146 if (root.InitByTagLookup(syncer::ModelTypeToRootTag(type)) != | 146 if (root.InitByTagLookup(syncer::ModelTypeToRootTag(type)) != |
147 syncer::BaseNode::INIT_OK) { | 147 syncer::BaseNode::INIT_OK) { |
148 syncer::SyncError error(FROM_HERE, | 148 syncer::SyncError error(FROM_HERE, |
149 syncer::SyncError::DATATYPE_ERROR, | 149 syncer::SyncError::DATATYPE_ERROR, |
150 "Server did not create the top-level " + type_name + | 150 "Server did not create the top-level " + type_name + |
151 " node. We might be running against an out-of-" | 151 " node. We might be running against an out-of-" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 } | 296 } |
297 if (IsActOnceDataType(type)) | 297 if (IsActOnceDataType(type)) |
298 node->Drop(); | 298 node->Drop(); |
299 else | 299 else |
300 node->Tombstone(); | 300 node->Tombstone(); |
301 return syncer::SyncError(); | 301 return syncer::SyncError(); |
302 } | 302 } |
303 | 303 |
304 } // namespace | 304 } // namespace |
305 | 305 |
| 306 syncer::SyncDataList GenericChangeProcessor::GetAllSyncData( |
| 307 syncer::ModelType type) const { |
| 308 // This is slow / memory intensive. Should be used sparingly by datatypes. |
| 309 syncer::SyncDataList data; |
| 310 if (GetSyncDataForType(type, &data).IsSet()) |
| 311 return syncer::SyncDataList(); |
| 312 return data; |
| 313 } |
| 314 |
306 // WARNING: this code is sensitive to compiler optimizations. Be careful | 315 // WARNING: this code is sensitive to compiler optimizations. Be careful |
307 // modifying any code around an OnSingleDatatypeUnrecoverableError call, else | 316 // modifying any code around an OnSingleDatatypeUnrecoverableError call, else |
308 // the compiler attempts to merge it with other calls, losing useful information | 317 // the compiler attempts to merge it with other calls, losing useful information |
309 // in breakpad uploads. | 318 // in breakpad uploads. |
310 syncer::SyncError GenericChangeProcessor::ProcessSyncChanges( | 319 syncer::SyncError GenericChangeProcessor::ProcessSyncChanges( |
311 const tracked_objects::Location& from_here, | 320 const tracked_objects::Location& from_here, |
312 const syncer::SyncChangeList& list_of_changes) { | 321 const syncer::SyncChangeList& list_of_changes) { |
313 DCHECK(CalledOnValidThread()); | 322 DCHECK(CalledOnValidThread()); |
314 syncer::WriteTransaction trans(from_here, share_handle()); | 323 syncer::WriteTransaction trans(from_here, share_handle()); |
315 | 324 |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 void GenericChangeProcessor::StartImpl(Profile* profile) { | 567 void GenericChangeProcessor::StartImpl(Profile* profile) { |
559 DCHECK(CalledOnValidThread()); | 568 DCHECK(CalledOnValidThread()); |
560 } | 569 } |
561 | 570 |
562 syncer::UserShare* GenericChangeProcessor::share_handle() const { | 571 syncer::UserShare* GenericChangeProcessor::share_handle() const { |
563 DCHECK(CalledOnValidThread()); | 572 DCHECK(CalledOnValidThread()); |
564 return share_handle_; | 573 return share_handle_; |
565 } | 574 } |
566 | 575 |
567 } // namespace browser_sync | 576 } // namespace browser_sync |
OLD | NEW |