OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 void BookmarkModelAssociator::Disassociate(int64 sync_id) { | 215 void BookmarkModelAssociator::Disassociate(int64 sync_id) { |
216 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 216 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
217 SyncIdToBookmarkNodeMap::iterator iter = id_map_inverse_.find(sync_id); | 217 SyncIdToBookmarkNodeMap::iterator iter = id_map_inverse_.find(sync_id); |
218 if (iter == id_map_inverse_.end()) | 218 if (iter == id_map_inverse_.end()) |
219 return; | 219 return; |
220 id_map_.erase(iter->second->id()); | 220 id_map_.erase(iter->second->id()); |
221 id_map_inverse_.erase(iter); | 221 id_map_inverse_.erase(iter); |
222 dirty_associations_sync_ids_.erase(sync_id); | 222 dirty_associations_sync_ids_.erase(sync_id); |
223 } | 223 } |
224 | 224 |
225 bool BookmarkModelAssociator::ChromeModelHasUserCreatedNodes(bool* has_nodes) { | |
226 DCHECK(has_nodes); | |
227 BookmarkModel* model = sync_service_->profile()->GetBookmarkModel(); | |
228 DCHECK(model->IsLoaded()); | |
229 | |
230 *has_nodes = model->GetBookmarkBarNode()->GetChildCount() > 0 || | |
231 model->other_node()->GetChildCount() > 0; | |
232 return true; | |
233 } | |
234 | |
235 bool BookmarkModelAssociator::SyncModelHasUserCreatedNodes(bool* has_nodes) { | 225 bool BookmarkModelAssociator::SyncModelHasUserCreatedNodes(bool* has_nodes) { |
236 DCHECK(has_nodes); | 226 DCHECK(has_nodes); |
237 *has_nodes = false; | 227 *has_nodes = false; |
238 int64 bookmark_bar_sync_id; | 228 int64 bookmark_bar_sync_id; |
239 if (!GetSyncIdForTaggedNode(kBookmarkBarTag, &bookmark_bar_sync_id)) { | 229 if (!GetSyncIdForTaggedNode(kBookmarkBarTag, &bookmark_bar_sync_id)) { |
240 return false; | 230 return false; |
241 } | 231 } |
242 int64 other_bookmarks_sync_id; | 232 int64 other_bookmarks_sync_id; |
243 if (!GetSyncIdForTaggedNode(kOtherBookmarksTag, &other_bookmarks_sync_id)) { | 233 if (!GetSyncIdForTaggedNode(kOtherBookmarksTag, &other_bookmarks_sync_id)) { |
244 return false; | 234 return false; |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 | 539 |
550 // It's possible that the number of nodes in the bookmark model is not the | 540 // It's possible that the number of nodes in the bookmark model is not the |
551 // same as number of nodes in the sync model. This can happen when the sync | 541 // same as number of nodes in the sync model. This can happen when the sync |
552 // model doesn't get a chance to persist its changes, for example when | 542 // model doesn't get a chance to persist its changes, for example when |
553 // Chrome does not shut down gracefully. In such cases we can't trust the | 543 // Chrome does not shut down gracefully. In such cases we can't trust the |
554 // loaded associations. | 544 // loaded associations. |
555 return sync_node_count == id_index.count(); | 545 return sync_node_count == id_index.count(); |
556 } | 546 } |
557 | 547 |
558 } // namespace browser_sync | 548 } // namespace browser_sync |
OLD | NEW |