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 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/bookmarks/bookmark_index.h" | 10 #include "chrome/browser/bookmarks/bookmark_index.h" |
11 #include "chrome/common/important_file_writer.h" | 11 #include "chrome/common/important_file_writer.h" |
12 | 12 |
13 class BookmarkModel; | 13 class BookmarkModel; |
14 class BookmarkPermanentNode; | 14 class BookmarkPermanentNode; |
15 class Profile; | 15 |
| 16 namespace content { |
| 17 class BrowserContext; |
| 18 } |
16 | 19 |
17 // BookmarkLoadDetails is used by BookmarkStorage when loading bookmarks. | 20 // BookmarkLoadDetails is used by BookmarkStorage when loading bookmarks. |
18 // BookmarkModel creates a BookmarkLoadDetails and passes it (including | 21 // BookmarkModel creates a BookmarkLoadDetails and passes it (including |
19 // ownership) to BookmarkStorage. BookmarkStorage loads the bookmarks (and | 22 // ownership) to BookmarkStorage. BookmarkStorage loads the bookmarks (and |
20 // index) in the background thread, then calls back to the BookmarkModel (on | 23 // index) in the background thread, then calls back to the BookmarkModel (on |
21 // the main thread) when loading is done, passing ownership back to the | 24 // the main thread) when loading is done, passing ownership back to the |
22 // BookmarkModel. While loading BookmarkModel does not maintain references to | 25 // BookmarkModel. While loading BookmarkModel does not maintain references to |
23 // the contents of the BookmarkLoadDetails, this ensures we don't have any | 26 // the contents of the BookmarkLoadDetails, this ensures we don't have any |
24 // threading problems. | 27 // threading problems. |
25 class BookmarkLoadDetails { | 28 class BookmarkLoadDetails { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 89 |
87 // BookmarkStorage handles reading/write the bookmark bar model. The | 90 // BookmarkStorage handles reading/write the bookmark bar model. The |
88 // BookmarkModel uses the BookmarkStorage to load bookmarks from disk, as well | 91 // BookmarkModel uses the BookmarkStorage to load bookmarks from disk, as well |
89 // as notifying the BookmarkStorage every time the model changes. | 92 // as notifying the BookmarkStorage every time the model changes. |
90 // | 93 // |
91 // Internally BookmarkStorage uses BookmarkCodec to do the actual read/write. | 94 // Internally BookmarkStorage uses BookmarkCodec to do the actual read/write. |
92 class BookmarkStorage : public ImportantFileWriter::DataSerializer, | 95 class BookmarkStorage : public ImportantFileWriter::DataSerializer, |
93 public base::RefCountedThreadSafe<BookmarkStorage> { | 96 public base::RefCountedThreadSafe<BookmarkStorage> { |
94 public: | 97 public: |
95 // Creates a BookmarkStorage for the specified model | 98 // Creates a BookmarkStorage for the specified model |
96 BookmarkStorage(Profile* profile, BookmarkModel* model); | 99 BookmarkStorage(content::BrowserContext* context, BookmarkModel* model); |
97 | 100 |
98 // Loads the bookmarks into the model, notifying the model when done. This | 101 // Loads the bookmarks into the model, notifying the model when done. This |
99 // takes ownership of |details|. See BookmarkLoadDetails for details. | 102 // takes ownership of |details|. See BookmarkLoadDetails for details. |
100 void LoadBookmarks(BookmarkLoadDetails* details); | 103 void LoadBookmarks(BookmarkLoadDetails* details); |
101 | 104 |
102 // Schedules saving the bookmark bar model to disk. | 105 // Schedules saving the bookmark bar model to disk. |
103 void ScheduleSave(); | 106 void ScheduleSave(); |
104 | 107 |
105 // Notification the bookmark bar model is going to be deleted. If there is | 108 // Notification the bookmark bar model is going to be deleted. If there is |
106 // a pending save, it is saved immediately. | 109 // a pending save, it is saved immediately. |
(...skipping 20 matching lines...) Expand all Loading... |
127 // Helper to write bookmark data safely. | 130 // Helper to write bookmark data safely. |
128 ImportantFileWriter writer_; | 131 ImportantFileWriter writer_; |
129 | 132 |
130 // See class description of BookmarkLoadDetails for details on this. | 133 // See class description of BookmarkLoadDetails for details on this. |
131 scoped_ptr<BookmarkLoadDetails> details_; | 134 scoped_ptr<BookmarkLoadDetails> details_; |
132 | 135 |
133 DISALLOW_COPY_AND_ASSIGN(BookmarkStorage); | 136 DISALLOW_COPY_AND_ASSIGN(BookmarkStorage); |
134 }; | 137 }; |
135 | 138 |
136 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ | 139 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ |
OLD | NEW |