Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: chrome/browser/bookmarks/bookmark_storage.h

Issue 242693003: Introduce BookmarkClient interface to abstract embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing reviewer comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/bookmarks/bookmark_model.h" 12 #include "chrome/browser/bookmarks/bookmark_model.h"
12 13
13 class BookmarkIndex; 14 class BookmarkIndex;
14 class BookmarkModel; 15 class BookmarkModel;
15 class BookmarkPermanentNode; 16 class BookmarkPermanentNode;
16 17
17 namespace base { 18 namespace base {
18 class SequencedTaskRunner; 19 class SequencedTaskRunner;
19 } 20 }
20 21
21 namespace content {
22 class BrowserContext;
23 }
24
25 // BookmarkLoadDetails is used by BookmarkStorage when loading bookmarks. 22 // BookmarkLoadDetails is used by BookmarkStorage when loading bookmarks.
26 // BookmarkModel creates a BookmarkLoadDetails and passes it (including 23 // BookmarkModel creates a BookmarkLoadDetails and passes it (including
27 // ownership) to BookmarkStorage. BookmarkStorage loads the bookmarks (and 24 // ownership) to BookmarkStorage. BookmarkStorage loads the bookmarks (and
28 // index) in the background thread, then calls back to the BookmarkModel (on 25 // index) in the background thread, then calls back to the BookmarkModel (on
29 // the main thread) when loading is done, passing ownership back to the 26 // the main thread) when loading is done, passing ownership back to the
30 // BookmarkModel. While loading BookmarkModel does not maintain references to 27 // BookmarkModel. While loading BookmarkModel does not maintain references to
31 // the contents of the BookmarkLoadDetails, this ensures we don't have any 28 // the contents of the BookmarkLoadDetails, this ensures we don't have any
32 // threading problems. 29 // threading problems.
33 class BookmarkLoadDetails { 30 class BookmarkLoadDetails {
34 public: 31 public:
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 107
111 // BookmarkStorage handles reading/write the bookmark bar model. The 108 // BookmarkStorage handles reading/write the bookmark bar model. The
112 // BookmarkModel uses the BookmarkStorage to load bookmarks from disk, as well 109 // BookmarkModel uses the BookmarkStorage to load bookmarks from disk, as well
113 // as notifying the BookmarkStorage every time the model changes. 110 // as notifying the BookmarkStorage every time the model changes.
114 // 111 //
115 // Internally BookmarkStorage uses BookmarkCodec to do the actual read/write. 112 // Internally BookmarkStorage uses BookmarkCodec to do the actual read/write.
116 class BookmarkStorage : public base::ImportantFileWriter::DataSerializer, 113 class BookmarkStorage : public base::ImportantFileWriter::DataSerializer,
117 public base::RefCountedThreadSafe<BookmarkStorage> { 114 public base::RefCountedThreadSafe<BookmarkStorage> {
118 public: 115 public:
119 // Creates a BookmarkStorage for the specified model 116 // Creates a BookmarkStorage for the specified model
120 BookmarkStorage(content::BrowserContext* context, 117 BookmarkStorage(BookmarkModel* model,
121 BookmarkModel* model, 118 const base::FilePath& profile_path,
sky 2014/04/18 17:05:04 Document profile_path here and task_runner below.
122 base::SequencedTaskRunner* sequenced_task_runner); 119 base::SequencedTaskRunner* sequenced_task_runner);
123 120
124 // Loads the bookmarks into the model, notifying the model when done. This 121 // Loads the bookmarks into the model, notifying the model when done. This
125 // takes ownership of |details|. See BookmarkLoadDetails for details. 122 // takes ownership of |details|. See BookmarkLoadDetails for details.
126 void LoadBookmarks(BookmarkLoadDetails* details); 123 void LoadBookmarks(
124 BookmarkLoadDetails* details,
125 const scoped_refptr<base::SequencedTaskRunner>& task_runner);
127 126
128 // Schedules saving the bookmark bar model to disk. 127 // Schedules saving the bookmark bar model to disk.
129 void ScheduleSave(); 128 void ScheduleSave();
130 129
131 // Notification the bookmark bar model is going to be deleted. If there is 130 // Notification the bookmark bar model is going to be deleted. If there is
132 // a pending save, it is saved immediately. 131 // a pending save, it is saved immediately.
133 void BookmarkModelDeleted(); 132 void BookmarkModelDeleted();
134 133
135 // Callback from backend after loading the bookmark file. 134 // Callback from backend after loading the bookmark file.
136 void OnLoadFinished(); 135 void OnLoadFinished();
(...skipping 19 matching lines...) Expand all
156 // See class description of BookmarkLoadDetails for details on this. 155 // See class description of BookmarkLoadDetails for details on this.
157 scoped_ptr<BookmarkLoadDetails> details_; 156 scoped_ptr<BookmarkLoadDetails> details_;
158 157
159 // Sequenced task runner where file I/O operations will be performed at. 158 // Sequenced task runner where file I/O operations will be performed at.
160 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_; 159 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_;
161 160
162 DISALLOW_COPY_AND_ASSIGN(BookmarkStorage); 161 DISALLOW_COPY_AND_ASSIGN(BookmarkStorage);
163 }; 162 };
164 163
165 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ 164 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698