Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: chrome/browser/sync/glue/bookmark_change_processor.cc

Issue 10553042: sync: don't make DataTypeErrorHandler inherit UnrecoverableErrorHandler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/bookmark_change_processor.h" 5 #include "chrome/browser/sync/glue/bookmark_change_processor.h"
6 6
7 #include <stack> 7 #include <stack>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 BookmarkModelAssociator* associator, 170 BookmarkModelAssociator* associator,
171 DataTypeErrorHandler* error_handler) { 171 DataTypeErrorHandler* error_handler) {
172 const BookmarkNode* child = parent->GetChild(index); 172 const BookmarkNode* child = parent->GetChild(index);
173 DCHECK(child); 173 DCHECK(child);
174 174
175 // Create a WriteNode container to hold the new node. 175 // Create a WriteNode container to hold the new node.
176 sync_api::WriteNode sync_child(trans); 176 sync_api::WriteNode sync_child(trans);
177 177
178 // Actually create the node with the appropriate initial position. 178 // Actually create the node with the appropriate initial position.
179 if (!PlaceSyncNode(CREATE, parent, index, trans, &sync_child, associator)) { 179 if (!PlaceSyncNode(CREATE, parent, index, trans, &sync_child, associator)) {
180 error_handler->OnUnrecoverableError(FROM_HERE, 180 error_handler->OnSingleDatatypeUnrecoverableError(FROM_HERE,
181 "Sync node creation failed; recovery unlikely"); 181 "Sync node creation failed; recovery unlikely");
182 return sync_api::kInvalidId; 182 return sync_api::kInvalidId;
183 } 183 }
184 184
185 UpdateSyncNodeProperties(child, model, &sync_child); 185 UpdateSyncNodeProperties(child, model, &sync_child);
186 186
187 // Associate the ID from the sync domain with the bookmark node, so that we 187 // Associate the ID from the sync domain with the bookmark node, so that we
188 // can refer back to this item later. 188 // can refer back to this item later.
189 associator->Associate(child, sync_child.GetId()); 189 associator->Associate(child, sync_child.GetId());
190 190
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // Lookup the sync node that's associated with |child|. 296 // Lookup the sync node that's associated with |child|.
297 sync_api::WriteNode sync_node(&trans); 297 sync_api::WriteNode sync_node(&trans);
298 if (!model_associator_->InitSyncNodeFromChromeId(child->id(), &sync_node)) { 298 if (!model_associator_->InitSyncNodeFromChromeId(child->id(), &sync_node)) {
299 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE, 299 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
300 std::string()); 300 std::string());
301 return; 301 return;
302 } 302 }
303 303
304 if (!PlaceSyncNode(MOVE, new_parent, new_index, &trans, &sync_node, 304 if (!PlaceSyncNode(MOVE, new_parent, new_index, &trans, &sync_node,
305 model_associator_)) { 305 model_associator_)) {
306 error_handler()->OnUnrecoverableError(FROM_HERE, std::string()); 306 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
307 std::string());
307 return; 308 return;
308 } 309 }
309 } 310 }
310 311
311 void BookmarkChangeProcessor::BookmarkNodeFaviconChanged( 312 void BookmarkChangeProcessor::BookmarkNodeFaviconChanged(
312 BookmarkModel* model, 313 BookmarkModel* model,
313 const BookmarkNode* node) { 314 const BookmarkNode* node) {
314 DCHECK(running()); 315 DCHECK(running());
315 BookmarkNodeChanged(model, node); 316 BookmarkNodeChanged(model, node);
316 } 317 }
(...skipping 12 matching lines...) Expand all
329 &sync_child)) { 330 &sync_child)) {
330 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE, 331 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
331 std::string()); 332 std::string());
332 return; 333 return;
333 } 334 }
334 DCHECK_EQ(sync_child.GetParentId(), 335 DCHECK_EQ(sync_child.GetParentId(),
335 model_associator_->GetSyncIdFromChromeId(node->id())); 336 model_associator_->GetSyncIdFromChromeId(node->id()));
336 337
337 if (!PlaceSyncNode(MOVE, node, i, &trans, &sync_child, 338 if (!PlaceSyncNode(MOVE, node, i, &trans, &sync_child,
338 model_associator_)) { 339 model_associator_)) {
339 error_handler()->OnUnrecoverableError(FROM_HERE, std::string()); 340 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
341 std::string());
340 return; 342 return;
341 } 343 }
342 } 344 }
343 } 345 }
344 346
345 // static 347 // static
346 bool BookmarkChangeProcessor::PlaceSyncNode(MoveOrCreate operation, 348 bool BookmarkChangeProcessor::PlaceSyncNode(MoveOrCreate operation,
347 const BookmarkNode* parent, int index, sync_api::WriteTransaction* trans, 349 const BookmarkNode* parent, int index, sync_api::WriteTransaction* trans,
348 sync_api::WriteNode* dst, BookmarkModelAssociator* associator) { 350 sync_api::WriteNode* dst, BookmarkModelAssociator* associator) {
349 sync_api::ReadNode sync_parent(trans); 351 sync_api::ReadNode sync_parent(trans);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 // reparented by a later change record. Move them to a temporary place. 463 // reparented by a later change record. Move them to a temporary place.
462 if (!dst) // Can't do anything if we can't find the chrome node. 464 if (!dst) // Can't do anything if we can't find the chrome node.
463 continue; 465 continue;
464 const BookmarkNode* parent = dst->parent(); 466 const BookmarkNode* parent = dst->parent();
465 if (!dst->empty()) { 467 if (!dst->empty()) {
466 if (!foster_parent) { 468 if (!foster_parent) {
467 foster_parent = model->AddFolder(model->other_node(), 469 foster_parent = model->AddFolder(model->other_node(),
468 model->other_node()->child_count(), 470 model->other_node()->child_count(),
469 string16()); 471 string16());
470 if (!foster_parent) { 472 if (!foster_parent) {
471 error_handler()->OnUnrecoverableError(FROM_HERE, 473 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
472 "Failed to create foster parent."); 474 "Failed to create foster parent.");
473 return; 475 return;
474 } 476 }
475 } 477 }
476 for (int i = dst->child_count() - 1; i >= 0; --i) { 478 for (int i = dst->child_count() - 1; i >= 0; --i) {
477 model->Move(dst->GetChild(i), foster_parent, 479 model->Move(dst->GetChild(i), foster_parent,
478 foster_parent->child_count()); 480 foster_parent->child_count());
479 } 481 }
480 } 482 }
481 DCHECK_EQ(dst->child_count(), 0) << "Node being deleted has children"; 483 DCHECK_EQ(dst->child_count(), 0) << "Node being deleted has children";
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 const BookmarkNode* bookmark_node, 650 const BookmarkNode* bookmark_node,
649 BookmarkModel* model, 651 BookmarkModel* model,
650 sync_api::WriteNode* sync_node) { 652 sync_api::WriteNode* sync_node) {
651 std::vector<unsigned char> favicon_bytes; 653 std::vector<unsigned char> favicon_bytes;
652 EncodeFavicon(bookmark_node, model, &favicon_bytes); 654 EncodeFavicon(bookmark_node, model, &favicon_bytes);
653 if (!favicon_bytes.empty()) 655 if (!favicon_bytes.empty())
654 sync_node->SetFaviconBytes(favicon_bytes); 656 sync_node->SetFaviconBytes(favicon_bytes);
655 } 657 }
656 658
657 } // namespace browser_sync 659 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698