| 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" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 void LoadBookmarks(BookmarkLoadDetails* details); | 101 void LoadBookmarks(BookmarkLoadDetails* details); |
| 102 | 102 |
| 103 // Schedules saving the bookmark bar model to disk. | 103 // Schedules saving the bookmark bar model to disk. |
| 104 void ScheduleSave(); | 104 void ScheduleSave(); |
| 105 | 105 |
| 106 // Notification the bookmark bar model is going to be deleted. If there is | 106 // Notification the bookmark bar model is going to be deleted. If there is |
| 107 // a pending save, it is saved immediately. | 107 // a pending save, it is saved immediately. |
| 108 void BookmarkModelDeleted(); | 108 void BookmarkModelDeleted(); |
| 109 | 109 |
| 110 // ImportantFileWriter::DataSerializer | 110 // ImportantFileWriter::DataSerializer |
| 111 virtual bool SerializeData(std::string* output); | 111 virtual bool SerializeData(std::string* output) OVERRIDE; |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 friend class base::RefCountedThreadSafe<BookmarkStorage>; | 114 friend class base::RefCountedThreadSafe<BookmarkStorage>; |
| 115 | 115 |
| 116 virtual ~BookmarkStorage(); | 116 virtual ~BookmarkStorage(); |
| 117 | 117 |
| 118 class LoadTask; | 118 class LoadTask; |
| 119 | 119 |
| 120 // Callback from backend with the results of the bookmark file. | 120 // Callback from backend with the results of the bookmark file. |
| 121 // This may be called multiple times, with different paths. This happens when | 121 // This may be called multiple times, with different paths. This happens when |
| (...skipping 11 matching lines...) Expand all Loading... |
| 133 // from that file. | 133 // from that file. |
| 134 void OnHistoryFinishedWriting(); | 134 void OnHistoryFinishedWriting(); |
| 135 | 135 |
| 136 // Called after we loaded file generated by history. Saves the data, deletes | 136 // Called after we loaded file generated by history. Saves the data, deletes |
| 137 // the temporary file, and notifies the model. | 137 // the temporary file, and notifies the model. |
| 138 void FinishHistoryMigration(); | 138 void FinishHistoryMigration(); |
| 139 | 139 |
| 140 // content::NotificationObserver | 140 // content::NotificationObserver |
| 141 virtual void Observe(int type, | 141 virtual void Observe(int type, |
| 142 const content::NotificationSource& source, | 142 const content::NotificationSource& source, |
| 143 const content::NotificationDetails& details); | 143 const content::NotificationDetails& details) OVERRIDE; |
| 144 | 144 |
| 145 // Serializes the data and schedules save using ImportantFileWriter. | 145 // Serializes the data and schedules save using ImportantFileWriter. |
| 146 // Returns true on successful serialization. | 146 // Returns true on successful serialization. |
| 147 bool SaveNow(); | 147 bool SaveNow(); |
| 148 | 148 |
| 149 // Keep the pointer to profile, we may need it for migration from history. | 149 // Keep the pointer to profile, we may need it for migration from history. |
| 150 Profile* profile_; | 150 Profile* profile_; |
| 151 | 151 |
| 152 // The model. The model is NULL once BookmarkModelDeleted has been invoked. | 152 // The model. The model is NULL once BookmarkModelDeleted has been invoked. |
| 153 BookmarkModel* model_; | 153 BookmarkModel* model_; |
| 154 | 154 |
| 155 // Helper to write bookmark data safely. | 155 // Helper to write bookmark data safely. |
| 156 ImportantFileWriter writer_; | 156 ImportantFileWriter writer_; |
| 157 | 157 |
| 158 // Helper to ensure that we unregister from notifications on destruction. | 158 // Helper to ensure that we unregister from notifications on destruction. |
| 159 content::NotificationRegistrar notification_registrar_; | 159 content::NotificationRegistrar notification_registrar_; |
| 160 | 160 |
| 161 // Path to temporary file created during migrating bookmarks from history. | 161 // Path to temporary file created during migrating bookmarks from history. |
| 162 const FilePath tmp_history_path_; | 162 const FilePath tmp_history_path_; |
| 163 | 163 |
| 164 // See class description of BookmarkLoadDetails for details on this. | 164 // See class description of BookmarkLoadDetails for details on this. |
| 165 scoped_ptr<BookmarkLoadDetails> details_; | 165 scoped_ptr<BookmarkLoadDetails> details_; |
| 166 | 166 |
| 167 DISALLOW_COPY_AND_ASSIGN(BookmarkStorage); | 167 DISALLOW_COPY_AND_ASSIGN(BookmarkStorage); |
| 168 }; | 168 }; |
| 169 | 169 |
| 170 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ | 170 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ |
| OLD | NEW |