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/files/file_path.h" | |
8 #include "base/files/important_file_writer.h" | 9 #include "base/files/important_file_writer.h" |
9 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
11 #include "components/bookmarks/core/browser/bookmark_node.h" | 12 #include "components/bookmarks/core/browser/bookmark_node.h" |
12 | 13 |
13 class BookmarkIndex; | 14 class BookmarkIndex; |
14 class BookmarkModel; | 15 class BookmarkModel; |
15 | 16 |
16 namespace base { | 17 namespace base { |
17 class SequencedTaskRunner; | 18 class SequencedTaskRunner; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 }; | 109 }; |
109 | 110 |
110 // BookmarkStorage handles reading/write the bookmark bar model. The | 111 // BookmarkStorage handles reading/write the bookmark bar model. The |
111 // BookmarkModel uses the BookmarkStorage to load bookmarks from disk, as well | 112 // BookmarkModel uses the BookmarkStorage to load bookmarks from disk, as well |
112 // as notifying the BookmarkStorage every time the model changes. | 113 // as notifying the BookmarkStorage every time the model changes. |
113 // | 114 // |
114 // Internally BookmarkStorage uses BookmarkCodec to do the actual read/write. | 115 // Internally BookmarkStorage uses BookmarkCodec to do the actual read/write. |
115 class BookmarkStorage : public base::ImportantFileWriter::DataSerializer, | 116 class BookmarkStorage : public base::ImportantFileWriter::DataSerializer, |
116 public base::RefCountedThreadSafe<BookmarkStorage> { | 117 public base::RefCountedThreadSafe<BookmarkStorage> { |
117 public: | 118 public: |
118 // Creates a BookmarkStorage for the specified model | 119 // Creates a BookmarkStorage for the specified model. The data will be loaded |
119 BookmarkStorage(content::BrowserContext* context, | 120 // from and saved to a location derived from |profile_path|. The IO code will |
120 BookmarkModel* model, | 121 // be executed as a task in |sequenced_task_runner|. |
122 BookmarkStorage(BookmarkModel* model, | |
123 const base::FilePath& profile_path, | |
121 base::SequencedTaskRunner* sequenced_task_runner); | 124 base::SequencedTaskRunner* sequenced_task_runner); |
122 | 125 |
123 // Loads the bookmarks into the model, notifying the model when done. This | 126 // Loads the bookmarks into the model, notifying the model when done. This |
124 // takes ownership of |details|. See BookmarkLoadDetails for details. | 127 // takes ownership of |details| and send the |OnLoadFinished| callback from |
125 void LoadBookmarks(BookmarkLoadDetails* details); | 128 // a task in |task_runner|. See BookmarkLoadDetails for details. |
129 void LoadBookmarks( | |
130 BookmarkLoadDetails* details, | |
sky
2014/04/23 20:32:07
Can you make this take a scoped_ptr?
sdefresne
2014/04/24 12:30:15
Done.
| |
131 const scoped_refptr<base::SequencedTaskRunner>& task_runner); | |
126 | 132 |
127 // Schedules saving the bookmark bar model to disk. | 133 // Schedules saving the bookmark bar model to disk. |
128 void ScheduleSave(); | 134 void ScheduleSave(); |
129 | 135 |
130 // Notification the bookmark bar model is going to be deleted. If there is | 136 // Notification the bookmark bar model is going to be deleted. If there is |
131 // a pending save, it is saved immediately. | 137 // a pending save, it is saved immediately. |
132 void BookmarkModelDeleted(); | 138 void BookmarkModelDeleted(); |
133 | 139 |
134 // Callback from backend after loading the bookmark file. | 140 // Callback from backend after loading the bookmark file. |
135 void OnLoadFinished(); | 141 void OnLoadFinished(); |
(...skipping 19 matching lines...) Expand all Loading... | |
155 // See class description of BookmarkLoadDetails for details on this. | 161 // See class description of BookmarkLoadDetails for details on this. |
156 scoped_ptr<BookmarkLoadDetails> details_; | 162 scoped_ptr<BookmarkLoadDetails> details_; |
157 | 163 |
158 // Sequenced task runner where file I/O operations will be performed at. | 164 // Sequenced task runner where file I/O operations will be performed at. |
159 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_; | 165 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_; |
160 | 166 |
161 DISALLOW_COPY_AND_ASSIGN(BookmarkStorage); | 167 DISALLOW_COPY_AND_ASSIGN(BookmarkStorage); |
162 }; | 168 }; |
163 | 169 |
164 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ | 170 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ |
OLD | NEW |