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

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

Issue 10152003: sync: Make BaseNode lookup-related Init functions return specific failures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 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 | « no previous file | chrome/browser/sync/glue/bookmark_model_associator.h » ('j') | 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_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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 if (index > -1) 452 if (index > -1)
453 model->Remove(parent, index); 453 model->Remove(parent, index);
454 dst = NULL; 454 dst = NULL;
455 } else { 455 } else {
456 DCHECK_EQ((it->action == 456 DCHECK_EQ((it->action ==
457 sync_api::ChangeRecord::ACTION_ADD), (dst == NULL)) 457 sync_api::ChangeRecord::ACTION_ADD), (dst == NULL))
458 << "ACTION_ADD should be seen if and only if the node is unknown."; 458 << "ACTION_ADD should be seen if and only if the node is unknown.";
459 passed_deletes = true; 459 passed_deletes = true;
460 460
461 sync_api::ReadNode src(trans); 461 sync_api::ReadNode src(trans);
462 if (!src.InitByIdLookup(it->id)) { 462 if (src.InitByIdLookup(it->id) != sync_api::BaseNode::INIT_OK) {
463 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE, 463 error_handler()->OnSingleDatatypeUnrecoverableError(FROM_HERE,
464 "ApplyModelChanges was passed a bad ID"); 464 "ApplyModelChanges was passed a bad ID");
465 return; 465 return;
466 } 466 }
467 467
468 if (!CreateOrUpdateBookmarkNode(&src, model)) { 468 if (!CreateOrUpdateBookmarkNode(&src, model)) {
469 // Because the Synced Bookmarks node can be created server side, it's 469 // Because the Synced Bookmarks node can be created server side, it's
470 // possible it'll arrive at the client as an update. In that case it 470 // possible it'll arrive at the client as an update. In that case it
471 // won't have been associated at startup, the GetChromeNodeFromSyncId 471 // won't have been associated at startup, the GetChromeNodeFromSyncId
472 // call above will return NULL, and we won't detect it as a permanent 472 // call above will return NULL, and we won't detect it as a permanent
473 // node, resulting in us trying to create it here (which will 473 // node, resulting in us trying to create it here (which will
474 // fail). Therefore, we add special logic here just to detect the 474 // fail). Therefore, we add special logic here just to detect the
475 // Synced Bookmarks folder. 475 // Synced Bookmarks folder.
476 sync_api::ReadNode synced_bookmarks(trans); 476 sync_api::ReadNode synced_bookmarks(trans);
477 if (synced_bookmarks.InitByTagLookup(kMobileBookmarksTag) && 477 if (synced_bookmarks.InitByTagLookup(kMobileBookmarksTag) ==
478 sync_api::BaseNode::INIT_OK &&
478 synced_bookmarks.GetId() == it->id) { 479 synced_bookmarks.GetId() == it->id) {
479 // This is a newly created Synced Bookmarks node. Associate it. 480 // This is a newly created Synced Bookmarks node. Associate it.
480 model_associator_->Associate(model->mobile_node(), it->id); 481 model_associator_->Associate(model->mobile_node(), it->id);
481 } else { 482 } else {
482 // We ignore bookmarks we can't add. Chances are this is caused by 483 // We ignore bookmarks we can't add. Chances are this is caused by
483 // a bookmark that was not fully associated. 484 // a bookmark that was not fully associated.
484 LOG(ERROR) << "Failed to create bookmark node with title " 485 LOG(ERROR) << "Failed to create bookmark node with title "
485 << src.GetTitle() + " and url " 486 << src.GetTitle() + " and url "
486 << src.GetURL().possibly_invalid_spec(); 487 << src.GetURL().possibly_invalid_spec();
487 } 488 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 const BookmarkNode* bookmark_node, 616 const BookmarkNode* bookmark_node,
616 BookmarkModel* model, 617 BookmarkModel* model,
617 sync_api::WriteNode* sync_node) { 618 sync_api::WriteNode* sync_node) {
618 std::vector<unsigned char> favicon_bytes; 619 std::vector<unsigned char> favicon_bytes;
619 EncodeFavicon(bookmark_node, model, &favicon_bytes); 620 EncodeFavicon(bookmark_node, model, &favicon_bytes);
620 if (!favicon_bytes.empty()) 621 if (!favicon_bytes.empty())
621 sync_node->SetFaviconBytes(favicon_bytes); 622 sync_node->SetFaviconBytes(favicon_bytes);
622 } 623 }
623 624
624 } // namespace browser_sync 625 } // namespace browser_sync
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/glue/bookmark_model_associator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698