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

Side by Side Diff: chrome/common/important_file_writer.cc

Issue 6713033: Tweak commit interval for ScheduleSavePersistentPrefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added comments + changed ifdef Created 9 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/common/important_file_writer.h" 5 #include "chrome/common/important_file_writer.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_loop_proxy.h" 14 #include "base/message_loop_proxy.h"
15 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
16 #include "base/task.h" 16 #include "base/task.h"
17 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "base/time.h" 18 #include "base/time.h"
19 19
20 using base::TimeDelta; 20 using base::TimeDelta;
21 21
22 namespace { 22 namespace {
23 23
24 const int kDefaultCommitIntervalMs = 10000; 24 #if defined(OFFICIAL_BUILD) || defined(GOOGLE_CHROME_BUILD)
brettw 2011/03/21 05:59:31 This seems like a much much worse idea than NDEBUG
Denis Lagno 2011/03/21 13:07:21 another attempt..
25 // 2 seconds interval provides reasonable optimization by coalescing burst of
26 // writes yet this value is reasonably low to be safe.
27 const int kDefaultCommitIntervalMs = 2000;
28 #else
29 // For development builds we increase commit interval in order to ease
30 // manifestation of bugs caused by some exit path failing to commit pending
31 // writes.
32 const int kDefaultCommitIntervalMs = 60000;
33 #endif
25 34
26 class WriteToDiskTask : public Task { 35 class WriteToDiskTask : public Task {
27 public: 36 public:
28 WriteToDiskTask(const FilePath& path, const std::string& data) 37 WriteToDiskTask(const FilePath& path, const std::string& data)
29 : path_(path), 38 : path_(path),
30 data_(data) { 39 data_(data) {
31 } 40 }
32 41
33 virtual void Run() { 42 virtual void Run() {
34 // Write the data to a temp file then rename to avoid data loss if we crash 43 // Write the data to a temp file then rename to avoid data loss if we crash
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 DCHECK(serializer_); 149 DCHECK(serializer_);
141 std::string data; 150 std::string data;
142 if (serializer_->SerializeData(&data)) { 151 if (serializer_->SerializeData(&data)) {
143 WriteNow(data); 152 WriteNow(data);
144 } else { 153 } else {
145 LOG(WARNING) << "failed to serialize data to be saved in " 154 LOG(WARNING) << "failed to serialize data to be saved in "
146 << path_.value(); 155 << path_.value();
147 } 156 }
148 serializer_ = NULL; 157 serializer_ = NULL;
149 } 158 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698