| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 // BookmarkStorage ------------------------------------------------------------- | 147 // BookmarkStorage ------------------------------------------------------------- |
| 148 | 148 |
| 149 BookmarkStorage::BookmarkStorage( | 149 BookmarkStorage::BookmarkStorage( |
| 150 BookmarkModel* model, | 150 BookmarkModel* model, |
| 151 const base::FilePath& profile_path, | 151 const base::FilePath& profile_path, |
| 152 base::SequencedTaskRunner* sequenced_task_runner) | 152 base::SequencedTaskRunner* sequenced_task_runner) |
| 153 : model_(model), | 153 : model_(model), |
| 154 writer_(profile_path.Append(kBookmarksFileName), | 154 writer_(profile_path.Append(kBookmarksFileName), |
| 155 sequenced_task_runner, | 155 sequenced_task_runner, |
| 156 base::TimeDelta::FromMilliseconds(kSaveDelayMS)), | 156 base::TimeDelta::FromMilliseconds(kSaveDelayMS), |
| 157 "BookmarkStorage"), |
| 157 sequenced_task_runner_(sequenced_task_runner), | 158 sequenced_task_runner_(sequenced_task_runner), |
| 158 weak_factory_(this) { | 159 weak_factory_(this) {} |
| 159 } | |
| 160 | 160 |
| 161 BookmarkStorage::~BookmarkStorage() { | 161 BookmarkStorage::~BookmarkStorage() { |
| 162 if (writer_.HasPendingWrite()) | 162 if (writer_.HasPendingWrite()) |
| 163 writer_.DoScheduledWrite(); | 163 writer_.DoScheduledWrite(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void BookmarkStorage::LoadBookmarks( | 166 void BookmarkStorage::LoadBookmarks( |
| 167 std::unique_ptr<BookmarkLoadDetails> details, | 167 std::unique_ptr<BookmarkLoadDetails> details, |
| 168 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { | 168 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { |
| 169 sequenced_task_runner_->PostTask( | 169 sequenced_task_runner_->PostTask( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 229 } |
| 230 | 230 |
| 231 std::unique_ptr<std::string> data(new std::string); | 231 std::unique_ptr<std::string> data(new std::string); |
| 232 if (!SerializeData(data.get())) | 232 if (!SerializeData(data.get())) |
| 233 return false; | 233 return false; |
| 234 writer_.WriteNow(std::move(data)); | 234 writer_.WriteNow(std::move(data)); |
| 235 return true; | 235 return true; |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace bookmarks | 238 } // namespace bookmarks |
| OLD | NEW |