Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: components/bookmarks/browser/bookmark_storage.cc

Issue 1265363002: Cleanup nits in ImportantFileWriter and JsonPrefStore. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/prefs/json_pref_store.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « base/prefs/json_pref_store.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698