| 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_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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 if (BookmarkChangeProcessor::SetBookmarkFavicon( | 459 if (BookmarkChangeProcessor::SetBookmarkFavicon( |
| 460 &sync_child_node, child_node, bookmark_model_)) { | 460 &sync_child_node, child_node, bookmark_model_)) { |
| 461 BookmarkChangeProcessor::SetSyncNodeFavicon( | 461 BookmarkChangeProcessor::SetSyncNodeFavicon( |
| 462 child_node, bookmark_model_, &sync_child_node); | 462 child_node, bookmark_model_, &sync_child_node); |
| 463 } | 463 } |
| 464 } else { | 464 } else { |
| 465 // Create a new bookmark node for the sync node. | 465 // Create a new bookmark node for the sync node. |
| 466 child_node = BookmarkChangeProcessor::CreateBookmarkNode( | 466 child_node = BookmarkChangeProcessor::CreateBookmarkNode( |
| 467 &sync_child_node, parent_node, bookmark_model_, index); | 467 &sync_child_node, parent_node, bookmark_model_, index); |
| 468 if (!child_node) { | 468 if (!child_node) { |
| 469 error->Reset(FROM_HERE, | 469 // This can happen if a sync bookmark node doesn't have a valid url. |
| 470 "Failed to create bookmark node with title " + | 470 // As far as we can tell, it appears this can only happen if something |
| 471 sync_child_node.GetTitle() + " and url " + | 471 // interrupts association. For now, we just ignore the bookmark. |
| 472 sync_child_node.GetURL().possibly_invalid_spec(), | 472 LOG(ERROR) << "Failed to create bookmark node with title " |
| 473 model_type()); | 473 << sync_child_node.GetTitle() << " and url " |
| 474 return false; | 474 << sync_child_node.GetURL().possibly_invalid_spec(); |
| 475 } | 475 } |
| 476 } | 476 } |
| 477 Associate(child_node, sync_child_id); | 477 if (child_node) { |
| 478 Associate(child_node, sync_child_id); |
| 479 } |
| 478 if (sync_child_node.GetIsFolder()) | 480 if (sync_child_node.GetIsFolder()) |
| 479 dfs_stack.push(sync_child_id); | 481 dfs_stack.push(sync_child_id); |
| 480 | 482 |
| 481 sync_child_id = sync_child_node.GetSuccessorId(); | 483 sync_child_id = sync_child_node.GetSuccessorId(); |
| 482 ++index; | 484 ++index; |
| 483 } | 485 } |
| 484 | 486 |
| 485 // At this point all the children nodes of the parent sync node have | 487 // At this point all the children nodes of the parent sync node have |
| 486 // corresponding children in the parent bookmark node and they are all in | 488 // corresponding children in the parent bookmark node and they are all in |
| 487 // the right positions: from 0 to index - 1. | 489 // the right positions: from 0 to index - 1. |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 bool BookmarkModelAssociator::CryptoReadyIfNecessary() { | 644 bool BookmarkModelAssociator::CryptoReadyIfNecessary() { |
| 643 // We only access the cryptographer while holding a transaction. | 645 // We only access the cryptographer while holding a transaction. |
| 644 sync_api::ReadTransaction trans(FROM_HERE, user_share_); | 646 sync_api::ReadTransaction trans(FROM_HERE, user_share_); |
| 645 const syncable::ModelTypeSet encrypted_types = | 647 const syncable::ModelTypeSet encrypted_types = |
| 646 sync_api::GetEncryptedTypes(&trans); | 648 sync_api::GetEncryptedTypes(&trans); |
| 647 return !encrypted_types.Has(syncable::BOOKMARKS) || | 649 return !encrypted_types.Has(syncable::BOOKMARKS) || |
| 648 trans.GetCryptographer()->is_ready(); | 650 trans.GetCryptographer()->is_ready(); |
| 649 } | 651 } |
| 650 | 652 |
| 651 } // namespace browser_sync | 653 } // namespace browser_sync |
| OLD | NEW |