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 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ | 5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ |
6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ | 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "chrome/browser/bookmarks/bookmark_index.h" | 12 #include "chrome/browser/bookmarks/bookmark_index.h" |
13 #include "chrome/common/important_file_writer.h" | 13 #include "chrome/common/important_file_writer.h" |
14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
16 | 16 |
17 class BookmarkModel; | 17 class BookmarkModel; |
18 class BookmarkNode; | 18 class BookmarkPermanentNode; |
19 class Profile; | 19 class Profile; |
20 | 20 |
21 // BookmarkLoadDetails is used by BookmarkStorage when loading bookmarks. | 21 // BookmarkLoadDetails is used by BookmarkStorage when loading bookmarks. |
22 // BookmarkModel creates a BookmarkLoadDetails and passes it (including | 22 // BookmarkModel creates a BookmarkLoadDetails and passes it (including |
23 // ownership) to BookmarkStorage. BoomarkStorage loads the bookmarks (and index) | 23 // ownership) to BookmarkStorage. BoomarkStorage loads the bookmarks (and index) |
24 // in the background thread, then calls back to the BookmarkModel (on the main | 24 // in the background thread, then calls back to the BookmarkModel (on the main |
25 // thread) when loading is done, passing ownership back to the BookmarkModel. | 25 // thread) when loading is done, passing ownership back to the BookmarkModel. |
26 // While loading BookmarkModel does not maintain references to the contents | 26 // While loading BookmarkModel does not maintain references to the contents |
27 // of the BookmarkLoadDetails, this ensures we don't have any threading | 27 // of the BookmarkLoadDetails, this ensures we don't have any threading |
28 // problems. | 28 // problems. |
29 class BookmarkLoadDetails { | 29 class BookmarkLoadDetails { |
30 public: | 30 public: |
31 BookmarkLoadDetails(BookmarkNode* bb_node, | 31 BookmarkLoadDetails(BookmarkPermanentNode* bb_node, |
32 BookmarkNode* other_folder_node, | 32 BookmarkPermanentNode* other_folder_node, |
33 BookmarkNode* mobile_folder_node, | 33 BookmarkPermanentNode* mobile_folder_node, |
34 BookmarkIndex* index, | 34 BookmarkIndex* index, |
35 int64 max_id); | 35 int64 max_id); |
36 ~BookmarkLoadDetails(); | 36 ~BookmarkLoadDetails(); |
37 | 37 |
38 BookmarkNode* bb_node() { return bb_node_.get(); } | 38 BookmarkPermanentNode* bb_node() { return bb_node_.get(); } |
39 BookmarkNode* release_bb_node() { return bb_node_.release(); } | 39 BookmarkPermanentNode* release_bb_node() { return bb_node_.release(); } |
40 BookmarkNode* mobile_folder_node() { return mobile_folder_node_.get(); } | 40 BookmarkPermanentNode* mobile_folder_node() { |
41 BookmarkNode* release_mobile_folder_node() { | 41 return mobile_folder_node_.get(); |
| 42 } |
| 43 BookmarkPermanentNode* release_mobile_folder_node() { |
42 return mobile_folder_node_.release(); | 44 return mobile_folder_node_.release(); |
43 } | 45 } |
44 BookmarkNode* other_folder_node() { return other_folder_node_.get(); } | 46 BookmarkPermanentNode* other_folder_node() { |
45 BookmarkNode* release_other_folder_node() { | 47 return other_folder_node_.get(); |
| 48 } |
| 49 BookmarkPermanentNode* release_other_folder_node() { |
46 return other_folder_node_.release(); | 50 return other_folder_node_.release(); |
47 } | 51 } |
48 BookmarkIndex* index() { return index_.get(); } | 52 BookmarkIndex* index() { return index_.get(); } |
49 BookmarkIndex* release_index() { return index_.release(); } | 53 BookmarkIndex* release_index() { return index_.release(); } |
50 | 54 |
51 // Max id of the nodes. | 55 // Max id of the nodes. |
52 void set_max_id(int64 max_id) { max_id_ = max_id; } | 56 void set_max_id(int64 max_id) { max_id_ = max_id; } |
53 int64 max_id() const { return max_id_; } | 57 int64 max_id() const { return max_id_; } |
54 | 58 |
55 // Computed checksum. | 59 // Computed checksum. |
56 void set_computed_checksum(const std::string& value) { | 60 void set_computed_checksum(const std::string& value) { |
57 computed_checksum_ = value; | 61 computed_checksum_ = value; |
58 } | 62 } |
59 const std::string& computed_checksum() const { return computed_checksum_; } | 63 const std::string& computed_checksum() const { return computed_checksum_; } |
60 | 64 |
61 // Stored checksum. | 65 // Stored checksum. |
62 void set_stored_checksum(const std::string& value) { | 66 void set_stored_checksum(const std::string& value) { |
63 stored_checksum_ = value; | 67 stored_checksum_ = value; |
64 } | 68 } |
65 const std::string& stored_checksum() const { return stored_checksum_; } | 69 const std::string& stored_checksum() const { return stored_checksum_; } |
66 | 70 |
67 // Whether ids were reassigned. IDs are reassigned during decoding if the | 71 // Whether ids were reassigned. IDs are reassigned during decoding if the |
68 // checksum of the file doesn't match, some IDs are missing or not | 72 // checksum of the file doesn't match, some IDs are missing or not |
69 // unique. Basically, if the user modified the bookmarks directly we'll | 73 // unique. Basically, if the user modified the bookmarks directly we'll |
70 // reassign the ids to ensure they are unique. | 74 // reassign the ids to ensure they are unique. |
71 void set_ids_reassigned(bool value) { ids_reassigned_ = value; } | 75 void set_ids_reassigned(bool value) { ids_reassigned_ = value; } |
72 bool ids_reassigned() const { return ids_reassigned_; } | 76 bool ids_reassigned() const { return ids_reassigned_; } |
73 | 77 |
74 private: | 78 private: |
75 scoped_ptr<BookmarkNode> bb_node_; | 79 scoped_ptr<BookmarkPermanentNode> bb_node_; |
76 scoped_ptr<BookmarkNode> other_folder_node_; | 80 scoped_ptr<BookmarkPermanentNode> other_folder_node_; |
77 scoped_ptr<BookmarkNode> mobile_folder_node_; | 81 scoped_ptr<BookmarkPermanentNode> mobile_folder_node_; |
78 scoped_ptr<BookmarkIndex> index_; | 82 scoped_ptr<BookmarkIndex> index_; |
79 int64 max_id_; | 83 int64 max_id_; |
80 std::string computed_checksum_; | 84 std::string computed_checksum_; |
81 std::string stored_checksum_; | 85 std::string stored_checksum_; |
82 bool ids_reassigned_; | 86 bool ids_reassigned_; |
83 | 87 |
84 DISALLOW_COPY_AND_ASSIGN(BookmarkLoadDetails); | 88 DISALLOW_COPY_AND_ASSIGN(BookmarkLoadDetails); |
85 }; | 89 }; |
86 | 90 |
87 // BookmarkStorage handles reading/write the bookmark bar model. The | 91 // BookmarkStorage handles reading/write the bookmark bar model. The |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // Path to temporary file created during migrating bookmarks from history. | 163 // Path to temporary file created during migrating bookmarks from history. |
160 const FilePath tmp_history_path_; | 164 const FilePath tmp_history_path_; |
161 | 165 |
162 // See class description of BookmarkLoadDetails for details on this. | 166 // See class description of BookmarkLoadDetails for details on this. |
163 scoped_ptr<BookmarkLoadDetails> details_; | 167 scoped_ptr<BookmarkLoadDetails> details_; |
164 | 168 |
165 DISALLOW_COPY_AND_ASSIGN(BookmarkStorage); | 169 DISALLOW_COPY_AND_ASSIGN(BookmarkStorage); |
166 }; | 170 }; |
167 | 171 |
168 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ | 172 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ |
OLD | NEW |