| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 extra_nodes_ = load_extra_callback_.Run(&max_id_); | 139 extra_nodes_ = load_extra_callback_.Run(&max_id_); |
| 140 } | 140 } |
| 141 | 141 |
| 142 // BookmarkStorage ------------------------------------------------------------- | 142 // BookmarkStorage ------------------------------------------------------------- |
| 143 | 143 |
| 144 BookmarkStorage::BookmarkStorage( | 144 BookmarkStorage::BookmarkStorage( |
| 145 BookmarkModel* model, | 145 BookmarkModel* model, |
| 146 const base::FilePath& profile_path, | 146 const base::FilePath& profile_path, |
| 147 base::SequencedTaskRunner* sequenced_task_runner) | 147 base::SequencedTaskRunner* sequenced_task_runner) |
| 148 : model_(model), | 148 : model_(model), |
| 149 writer_(profile_path.Append(bookmarks::kBookmarksFileName), | 149 writer_(profile_path.Append(kBookmarksFileName), sequenced_task_runner), |
| 150 sequenced_task_runner), | |
| 151 weak_factory_(this) { | 150 weak_factory_(this) { |
| 152 sequenced_task_runner_ = sequenced_task_runner; | 151 sequenced_task_runner_ = sequenced_task_runner; |
| 153 writer_.set_commit_interval(base::TimeDelta::FromMilliseconds(kSaveDelayMS)); | 152 writer_.set_commit_interval(base::TimeDelta::FromMilliseconds(kSaveDelayMS)); |
| 154 sequenced_task_runner_->PostTask(FROM_HERE, | 153 sequenced_task_runner_->PostTask(FROM_HERE, |
| 155 base::Bind(&BackupCallback, writer_.path())); | 154 base::Bind(&BackupCallback, writer_.path())); |
| 156 } | 155 } |
| 157 | 156 |
| 158 BookmarkStorage::~BookmarkStorage() { | 157 BookmarkStorage::~BookmarkStorage() { |
| 159 if (writer_.HasPendingWrite()) | 158 if (writer_.HasPendingWrite()) |
| 160 writer_.DoScheduledWrite(); | 159 writer_.DoScheduledWrite(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 } | 206 } |
| 208 | 207 |
| 209 std::string data; | 208 std::string data; |
| 210 if (!SerializeData(&data)) | 209 if (!SerializeData(&data)) |
| 211 return false; | 210 return false; |
| 212 writer_.WriteNow(data); | 211 writer_.WriteNow(data); |
| 213 return true; | 212 return true; |
| 214 } | 213 } |
| 215 | 214 |
| 216 } // namespace bookmarks | 215 } // namespace bookmarks |
| OLD | NEW |