OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bookmarks/bookmark_model.h" | 5 #include "chrome/browser/bookmarks/bookmark_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 DCHECK(details_delete_me); | 572 DCHECK(details_delete_me); |
573 scoped_ptr<BookmarkLoadDetails> details(details_delete_me); | 573 scoped_ptr<BookmarkLoadDetails> details(details_delete_me); |
574 if (loaded_) { | 574 if (loaded_) { |
575 // We should only ever be loaded once. | 575 // We should only ever be loaded once. |
576 NOTREACHED(); | 576 NOTREACHED(); |
577 return; | 577 return; |
578 } | 578 } |
579 | 579 |
580 next_node_id_ = details->max_id(); | 580 next_node_id_ = details->max_id(); |
581 if (details->computed_checksum() != details->stored_checksum()) | 581 if (details->computed_checksum() != details->stored_checksum()) |
582 SetFileChanged(); | 582 file_changed_ = true; |
583 if (details->computed_checksum() != details->stored_checksum() || | 583 if (details->computed_checksum() != details->stored_checksum() || |
584 details->ids_reassigned()) { | 584 details->ids_reassigned()) { |
585 // If bookmarks file changed externally, the IDs may have changed | 585 // If bookmarks file changed externally, the IDs may have changed |
586 // externally. In that case, the decoder may have reassigned IDs to make | 586 // externally. In that case, the decoder may have reassigned IDs to make |
587 // them unique. So when the file has changed externally, we should save the | 587 // them unique. So when the file has changed externally, we should save the |
588 // bookmarks file to persist new IDs. | 588 // bookmarks file to persist new IDs. |
589 if (store_.get()) | 589 if (store_.get()) |
590 store_->ScheduleSave(); | 590 store_->ScheduleSave(); |
591 } | 591 } |
592 bookmark_bar_node_ = details->release_bb_node(); | 592 bookmark_bar_node_ = details->release_bb_node(); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 if (node->is_url()) | 822 if (node->is_url()) |
823 nodes_ordered_by_url_set_.insert(node); | 823 nodes_ordered_by_url_set_.insert(node); |
824 for (int i = 0; i < node->child_count(); ++i) | 824 for (int i = 0; i < node->child_count(); ++i) |
825 PopulateNodesByURL(node->GetChild(i)); | 825 PopulateNodesByURL(node->GetChild(i)); |
826 } | 826 } |
827 | 827 |
828 int64 BookmarkModel::generate_next_node_id() { | 828 int64 BookmarkModel::generate_next_node_id() { |
829 return next_node_id_++; | 829 return next_node_id_++; |
830 } | 830 } |
831 | 831 |
832 void BookmarkModel::SetFileChanged() { | |
833 file_changed_ = true; | |
834 } | |
835 | |
836 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { | 832 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { |
837 BookmarkNode* bb_node = CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); | 833 BookmarkNode* bb_node = CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); |
838 BookmarkNode* other_node = CreatePermanentNode(BookmarkNode::OTHER_NODE); | 834 BookmarkNode* other_node = CreatePermanentNode(BookmarkNode::OTHER_NODE); |
839 BookmarkNode* synced_node = CreatePermanentNode(BookmarkNode::SYNCED); | 835 BookmarkNode* synced_node = CreatePermanentNode(BookmarkNode::SYNCED); |
840 return new BookmarkLoadDetails(bb_node, other_node, synced_node, | 836 return new BookmarkLoadDetails(bb_node, other_node, synced_node, |
841 new BookmarkIndex(profile_), next_node_id_); | 837 new BookmarkIndex(profile_), next_node_id_); |
842 } | 838 } |
OLD | NEW |