OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/hash_tables.h" | 9 #include "base/hash_tables.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/task.h" | 11 #include "base/task.h" |
| 12 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/bookmarks/bookmark_model.h" | 13 #include "chrome/browser/bookmarks/bookmark_model.h" |
13 #include "chrome/browser/chrome_thread.h" | 14 #include "chrome/browser/chrome_thread.h" |
14 #include "chrome/browser/profile.h" | 15 #include "chrome/browser/profile.h" |
15 #include "chrome/browser/sync/engine/syncapi.h" | 16 #include "chrome/browser/sync/engine/syncapi.h" |
16 #include "chrome/browser/sync/glue/bookmark_change_processor.h" | 17 #include "chrome/browser/sync/glue/bookmark_change_processor.h" |
17 #include "chrome/browser/sync/profile_sync_service.h" | 18 #include "chrome/browser/sync/profile_sync_service.h" |
18 | 19 |
19 namespace browser_sync { | 20 namespace browser_sync { |
20 | 21 |
21 // The sync protocol identifies top-level entities by means of well-known tags, | 22 // The sync protocol identifies top-level entities by means of well-known tags, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 : parent_node_(parent_node) { | 87 : parent_node_(parent_node) { |
87 for (int i = 0; i < parent_node_->GetChildCount(); ++i) { | 88 for (int i = 0; i < parent_node_->GetChildCount(); ++i) { |
88 child_nodes_.insert(parent_node_->GetChild(i)); | 89 child_nodes_.insert(parent_node_->GetChild(i)); |
89 } | 90 } |
90 } | 91 } |
91 | 92 |
92 const BookmarkNode* BookmarkNodeFinder::FindBookmarkNode( | 93 const BookmarkNode* BookmarkNodeFinder::FindBookmarkNode( |
93 const sync_api::BaseNode& sync_node) { | 94 const sync_api::BaseNode& sync_node) { |
94 // Create a bookmark node from the given sync node. | 95 // Create a bookmark node from the given sync node. |
95 BookmarkNode temp_node(sync_node.GetURL()); | 96 BookmarkNode temp_node(sync_node.GetURL()); |
96 temp_node.SetTitle(sync_node.GetTitle()); | 97 temp_node.SetTitle(WideToUTF16Hack(sync_node.GetTitle())); |
97 if (sync_node.GetIsFolder()) | 98 if (sync_node.GetIsFolder()) |
98 temp_node.set_type(BookmarkNode::FOLDER); | 99 temp_node.set_type(BookmarkNode::FOLDER); |
99 else | 100 else |
100 temp_node.set_type(BookmarkNode::URL); | 101 temp_node.set_type(BookmarkNode::URL); |
101 | 102 |
102 const BookmarkNode* result = NULL; | 103 const BookmarkNode* result = NULL; |
103 BookmarkNodesSet::iterator iter = child_nodes_.find(&temp_node); | 104 BookmarkNodesSet::iterator iter = child_nodes_.find(&temp_node); |
104 if (iter != child_nodes_.end()) { | 105 if (iter != child_nodes_.end()) { |
105 result = *iter; | 106 result = *iter; |
106 // Remove the matched node so we don't match with it again. | 107 // Remove the matched node so we don't match with it again. |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 | 540 |
540 // It's possible that the number of nodes in the bookmark model is not the | 541 // It's possible that the number of nodes in the bookmark model is not the |
541 // same as number of nodes in the sync model. This can happen when the sync | 542 // same as number of nodes in the sync model. This can happen when the sync |
542 // model doesn't get a chance to persist its changes, for example when | 543 // model doesn't get a chance to persist its changes, for example when |
543 // Chrome does not shut down gracefully. In such cases we can't trust the | 544 // Chrome does not shut down gracefully. In such cases we can't trust the |
544 // loaded associations. | 545 // loaded associations. |
545 return sync_node_count == id_index.count(); | 546 return sync_node_count == id_index.count(); |
546 } | 547 } |
547 | 548 |
548 } // namespace browser_sync | 549 } // namespace browser_sync |
OLD | NEW |