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

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

Issue 10825325: [Sync] Dont upload an unrecoverable error for missing synced bookmark node (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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
« no previous file with comments | « chrome/browser/sync/glue/bookmark_model_associator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_model_associator.h" 5 #include "chrome/browser/sync/glue/bookmark_model_associator.h"
6 6
7 #include <stack> 7 #include <stack>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 if (bookmark->is_url()) { 324 if (bookmark->is_url()) {
325 if (bookmark->url() != sync_node->GetURL()) 325 if (bookmark->url() != sync_node->GetURL())
326 return false; 326 return false;
327 } 327 }
328 // Don't compare favicons here, because they are not really 328 // Don't compare favicons here, because they are not really
329 // user-updated and we don't have versioning information -- a site changing 329 // user-updated and we don't have versioning information -- a site changing
330 // its favicon shouldn't result in a bookmark mismatch. 330 // its favicon shouldn't result in a bookmark mismatch.
331 return true; 331 return true;
332 } 332 }
333 333
334 syncer::SyncError BookmarkModelAssociator::AssociateTaggedPermanentNode( 334 bool BookmarkModelAssociator::AssociateTaggedPermanentNode(
335 const BookmarkNode* permanent_node, const std::string&tag) { 335 const BookmarkNode* permanent_node, const std::string&tag) {
336 // Do nothing if |permanent_node| is already initialized and associated. 336 // Do nothing if |permanent_node| is already initialized and associated.
337 int64 sync_id = GetSyncIdFromChromeId(permanent_node->id()); 337 int64 sync_id = GetSyncIdFromChromeId(permanent_node->id());
338 if (sync_id != syncer::kInvalidId) 338 if (sync_id != syncer::kInvalidId)
339 return syncer::SyncError(); 339 return true;
340 if (!GetSyncIdForTaggedNode(tag, &sync_id)) 340 if (!GetSyncIdForTaggedNode(tag, &sync_id))
341 return unrecoverable_error_handler_->CreateAndUploadError( 341 return false;
342 FROM_HERE,
343 "Permanent node not found",
344 model_type());
345 342
346 Associate(permanent_node, sync_id); 343 Associate(permanent_node, sync_id);
347 return syncer::SyncError(); 344 return true;
348 } 345 }
349 346
350 bool BookmarkModelAssociator::GetSyncIdForTaggedNode(const std::string& tag, 347 bool BookmarkModelAssociator::GetSyncIdForTaggedNode(const std::string& tag,
351 int64* sync_id) { 348 int64* sync_id) {
352 syncer::ReadTransaction trans(FROM_HERE, user_share_); 349 syncer::ReadTransaction trans(FROM_HERE, user_share_);
353 syncer::ReadNode sync_node(&trans); 350 syncer::ReadNode sync_node(&trans);
354 if (sync_node.InitByTagLookup(tag.c_str()) != syncer::BaseNode::INIT_OK) 351 if (sync_node.InitByTagLookup(tag.c_str()) != syncer::BaseNode::INIT_OK)
355 return false; 352 return false;
356 *sync_id = sync_node.GetId(); 353 *sync_id = sync_node.GetId();
357 return true; 354 return true;
(...skipping 25 matching lines...) Expand all
383 // corresponding sync node. 380 // corresponding sync node.
384 // * When all children sync nodes are done, add the extra children bookmark 381 // * When all children sync nodes are done, add the extra children bookmark
385 // nodes to the sync parent node. 382 // nodes to the sync parent node.
386 // 383 //
387 // This algorithm will do a good job of merging when folder names are a good 384 // This algorithm will do a good job of merging when folder names are a good
388 // indicator of the two folders being the same. It will handle reordering and 385 // indicator of the two folders being the same. It will handle reordering and
389 // new node addition very well (without creating duplicates). 386 // new node addition very well (without creating duplicates).
390 // This algorithm will not do well if the folder name has changes but the 387 // This algorithm will not do well if the folder name has changes but the
391 // children under them are all the same. 388 // children under them are all the same.
392 389
393 syncer::SyncError error; 390 syncer::SyncError error;
tim (not reviewing) 2012/08/13 20:04:36 We don't need this anymore.
394 DCHECK(bookmark_model_->IsLoaded()); 391 DCHECK(bookmark_model_->IsLoaded());
395 392
396 // To prime our association, we associate the top-level nodes, Bookmark Bar 393 // To prime our association, we associate the top-level nodes, Bookmark Bar
397 // and Other Bookmarks. 394 // and Other Bookmarks.
398 error = AssociateTaggedPermanentNode(bookmark_model_->other_node(), 395 if (!AssociateTaggedPermanentNode(bookmark_model_->other_node(),
399 kOtherBookmarksTag); 396 kOtherBookmarksTag)) {
400 if (error.IsSet()) 397 return unrecoverable_error_handler_->CreateAndUploadError(
401 return error; 398 FROM_HERE,
399 "Other bookmarks node not found",
400 model_type());
401 }
402 402
403 error = AssociateTaggedPermanentNode(bookmark_model_->bookmark_bar_node(), 403 if (!AssociateTaggedPermanentNode(bookmark_model_->bookmark_bar_node(),
404 kBookmarkBarTag); 404 kBookmarkBarTag)) {
405 if (error.IsSet()) 405 return unrecoverable_error_handler_->CreateAndUploadError(
406 return error; 406 FROM_HERE,
407 "Bookmark bar node not found",
408 model_type());
409 }
407 410
408 error = AssociateTaggedPermanentNode(bookmark_model_->mobile_node(), 411 if (!AssociateTaggedPermanentNode(bookmark_model_->mobile_node(),
409 kMobileBookmarksTag); 412 kMobileBookmarksTag) &&
410 if (error.IsSet() && expect_mobile_bookmarks_folder_) 413 expect_mobile_bookmarks_folder_) {
411 return error; 414 return unrecoverable_error_handler_->CreateAndUploadError(
415 FROM_HERE,
416 "Mobile bookmarks node not found",
417 model_type());
418 }
412 error = syncer::SyncError(); 419 error = syncer::SyncError();
tim (not reviewing) 2012/08/13 20:04:36 Remove
413 420
414 int64 bookmark_bar_sync_id = GetSyncIdFromChromeId( 421 int64 bookmark_bar_sync_id = GetSyncIdFromChromeId(
415 bookmark_model_->bookmark_bar_node()->id()); 422 bookmark_model_->bookmark_bar_node()->id());
416 DCHECK_NE(bookmark_bar_sync_id, syncer::kInvalidId); 423 DCHECK_NE(bookmark_bar_sync_id, syncer::kInvalidId);
417 int64 other_bookmarks_sync_id = GetSyncIdFromChromeId( 424 int64 other_bookmarks_sync_id = GetSyncIdFromChromeId(
418 bookmark_model_->other_node()->id()); 425 bookmark_model_->other_node()->id());
419 DCHECK_NE(other_bookmarks_sync_id, syncer::kInvalidId); 426 DCHECK_NE(other_bookmarks_sync_id, syncer::kInvalidId);
420 int64 mobile_bookmarks_sync_id = GetSyncIdFromChromeId( 427 int64 mobile_bookmarks_sync_id = GetSyncIdFromChromeId(
421 bookmark_model_->mobile_node()->id()); 428 bookmark_model_->mobile_node()->id());
422 if (expect_mobile_bookmarks_folder_) { 429 if (expect_mobile_bookmarks_folder_) {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 bool BookmarkModelAssociator::CryptoReadyIfNecessary() { 666 bool BookmarkModelAssociator::CryptoReadyIfNecessary() {
660 // We only access the cryptographer while holding a transaction. 667 // We only access the cryptographer while holding a transaction.
661 syncer::ReadTransaction trans(FROM_HERE, user_share_); 668 syncer::ReadTransaction trans(FROM_HERE, user_share_);
662 const syncer::ModelTypeSet encrypted_types = 669 const syncer::ModelTypeSet encrypted_types =
663 syncer::GetEncryptedTypes(&trans); 670 syncer::GetEncryptedTypes(&trans);
664 return !encrypted_types.Has(syncer::BOOKMARKS) || 671 return !encrypted_types.Has(syncer::BOOKMARKS) ||
665 trans.GetCryptographer()->is_ready(); 672 trans.GetCryptographer()->is_ready();
666 } 673 }
667 674
668 } // namespace browser_sync 675 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/bookmark_model_associator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698