OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "components/bookmarks/browser/bookmark_storage.h" | 5 #include "components/bookmarks/browser/bookmark_storage.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 } | 155 } |
156 | 156 |
157 BookmarkStorage::~BookmarkStorage() { | 157 BookmarkStorage::~BookmarkStorage() { |
158 if (writer_.HasPendingWrite()) | 158 if (writer_.HasPendingWrite()) |
159 writer_.DoScheduledWrite(); | 159 writer_.DoScheduledWrite(); |
160 } | 160 } |
161 | 161 |
162 void BookmarkStorage::LoadBookmarks( | 162 void BookmarkStorage::LoadBookmarks( |
163 scoped_ptr<BookmarkLoadDetails> details, | 163 scoped_ptr<BookmarkLoadDetails> details, |
164 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { | 164 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { |
165 sequenced_task_runner_->PostTask(FROM_HERE, | 165 sequenced_task_runner_->PostTask( |
166 base::Bind(&LoadCallback, | 166 FROM_HERE, |
167 writer_.path(), | 167 base::Bind(&LoadCallback, writer_.path(), weak_factory_.GetWeakPtr(), |
168 weak_factory_.GetWeakPtr(), | 168 base::Passed(&details), base::RetainedRef(task_runner))); |
169 base::Passed(&details), | |
170 task_runner)); | |
171 } | 169 } |
172 | 170 |
173 void BookmarkStorage::ScheduleSave() { | 171 void BookmarkStorage::ScheduleSave() { |
174 switch (backup_state_) { | 172 switch (backup_state_) { |
175 case BACKUP_NONE: | 173 case BACKUP_NONE: |
176 backup_state_ = BACKUP_DISPATCHED; | 174 backup_state_ = BACKUP_DISPATCHED; |
177 sequenced_task_runner_->PostTaskAndReply( | 175 sequenced_task_runner_->PostTaskAndReply( |
178 FROM_HERE, base::Bind(&BackupCallback, writer_.path()), | 176 FROM_HERE, base::Bind(&BackupCallback, writer_.path()), |
179 base::Bind(&BookmarkStorage::OnBackupFinished, | 177 base::Bind(&BookmarkStorage::OnBackupFinished, |
180 weak_factory_.GetWeakPtr())); | 178 weak_factory_.GetWeakPtr())); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 224 } |
227 | 225 |
228 scoped_ptr<std::string> data(new std::string); | 226 scoped_ptr<std::string> data(new std::string); |
229 if (!SerializeData(data.get())) | 227 if (!SerializeData(data.get())) |
230 return false; | 228 return false; |
231 writer_.WriteNow(std::move(data)); | 229 writer_.WriteNow(std::move(data)); |
232 return true; | 230 return true; |
233 } | 231 } |
234 | 232 |
235 } // namespace bookmarks | 233 } // namespace bookmarks |
OLD | NEW |