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