| 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/important_file_writer.h" |
| 8 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_index.h" | 11 #include "chrome/browser/bookmarks/bookmark_index.h" |
| 11 #include "chrome/common/important_file_writer.h" | |
| 12 | 12 |
| 13 class BookmarkModel; | 13 class BookmarkModel; |
| 14 class BookmarkPermanentNode; | 14 class BookmarkPermanentNode; |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 class BrowserContext; | 17 class BrowserContext; |
| 18 } | 18 } |
| 19 | 19 |
| 20 // BookmarkLoadDetails is used by BookmarkStorage when loading bookmarks. | 20 // BookmarkLoadDetails is used by BookmarkStorage when loading bookmarks. |
| 21 // BookmarkModel creates a BookmarkLoadDetails and passes it (including | 21 // BookmarkModel creates a BookmarkLoadDetails and passes it (including |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 bool ids_reassigned_; | 85 bool ids_reassigned_; |
| 86 | 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(BookmarkLoadDetails); | 87 DISALLOW_COPY_AND_ASSIGN(BookmarkLoadDetails); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 // BookmarkStorage handles reading/write the bookmark bar model. The | 90 // BookmarkStorage handles reading/write the bookmark bar model. The |
| 91 // BookmarkModel uses the BookmarkStorage to load bookmarks from disk, as well | 91 // BookmarkModel uses the BookmarkStorage to load bookmarks from disk, as well |
| 92 // as notifying the BookmarkStorage every time the model changes. | 92 // as notifying the BookmarkStorage every time the model changes. |
| 93 // | 93 // |
| 94 // Internally BookmarkStorage uses BookmarkCodec to do the actual read/write. | 94 // Internally BookmarkStorage uses BookmarkCodec to do the actual read/write. |
| 95 class BookmarkStorage : public ImportantFileWriter::DataSerializer, | 95 class BookmarkStorage : public base::ImportantFileWriter::DataSerializer, |
| 96 public base::RefCountedThreadSafe<BookmarkStorage> { | 96 public base::RefCountedThreadSafe<BookmarkStorage> { |
| 97 public: | 97 public: |
| 98 // Creates a BookmarkStorage for the specified model | 98 // Creates a BookmarkStorage for the specified model |
| 99 BookmarkStorage(content::BrowserContext* context, BookmarkModel* model); | 99 BookmarkStorage(content::BrowserContext* context, BookmarkModel* model); |
| 100 | 100 |
| 101 // 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 |
| 102 // takes ownership of |details|. See BookmarkLoadDetails for details. | 102 // takes ownership of |details|. See BookmarkLoadDetails for details. |
| 103 void LoadBookmarks(BookmarkLoadDetails* details); | 103 void LoadBookmarks(BookmarkLoadDetails* details); |
| 104 | 104 |
| 105 // Schedules saving the bookmark bar model to disk. | 105 // Schedules saving the bookmark bar model to disk. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 121 virtual ~BookmarkStorage(); | 121 virtual ~BookmarkStorage(); |
| 122 | 122 |
| 123 // Serializes the data and schedules save using ImportantFileWriter. | 123 // Serializes the data and schedules save using ImportantFileWriter. |
| 124 // Returns true on successful serialization. | 124 // Returns true on successful serialization. |
| 125 bool SaveNow(); | 125 bool SaveNow(); |
| 126 | 126 |
| 127 // The model. The model is NULL once BookmarkModelDeleted has been invoked. | 127 // The model. The model is NULL once BookmarkModelDeleted has been invoked. |
| 128 BookmarkModel* model_; | 128 BookmarkModel* model_; |
| 129 | 129 |
| 130 // Helper to write bookmark data safely. | 130 // Helper to write bookmark data safely. |
| 131 ImportantFileWriter writer_; | 131 base::ImportantFileWriter writer_; |
| 132 | 132 |
| 133 // See class description of BookmarkLoadDetails for details on this. | 133 // See class description of BookmarkLoadDetails for details on this. |
| 134 scoped_ptr<BookmarkLoadDetails> details_; | 134 scoped_ptr<BookmarkLoadDetails> details_; |
| 135 | 135 |
| 136 DISALLOW_COPY_AND_ASSIGN(BookmarkStorage); | 136 DISALLOW_COPY_AND_ASSIGN(BookmarkStorage); |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ | 139 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ |
| OLD | NEW |