| 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/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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |