Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifdef NDEBUG |
|
Paweł Hajdan Jr.
2011/03/18 19:59:03
I'm not a fan of different behavior in debug vs. r
Denis Lagno
2011/03/21 01:18:53
I removed dependency on NDEBUG but instead added d
| |
| 25 const int kDefaultCommitIntervalMs = 2000; | |
|
Paweł Hajdan Jr.
2011/03/18 19:59:03
I'm not sure whether decreasing this interval is t
brettw
2011/03/18 20:30:21
If we do keep this different, there should be a co
Denis Lagno
2011/03/21 01:18:53
Done.
Denis Lagno
2011/03/21 01:18:53
original problem I've encountered was the fact tha
| |
| 26 #else | |
| 27 const int kDefaultCommitIntervalMs = 100000; | |
| 28 #endif | |
| 25 | 29 |
| 26 class WriteToDiskTask : public Task { | 30 class WriteToDiskTask : public Task { |
| 27 public: | 31 public: |
| 28 WriteToDiskTask(const FilePath& path, const std::string& data) | 32 WriteToDiskTask(const FilePath& path, const std::string& data) |
| 29 : path_(path), | 33 : path_(path), |
| 30 data_(data) { | 34 data_(data) { |
| 31 } | 35 } |
| 32 | 36 |
| 33 virtual void Run() { | 37 virtual void Run() { |
| 34 // Write the data to a temp file then rename to avoid data loss if we crash | 38 // 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 Loading... | |
| 140 DCHECK(serializer_); | 144 DCHECK(serializer_); |
| 141 std::string data; | 145 std::string data; |
| 142 if (serializer_->SerializeData(&data)) { | 146 if (serializer_->SerializeData(&data)) { |
| 143 WriteNow(data); | 147 WriteNow(data); |
| 144 } else { | 148 } else { |
| 145 LOG(WARNING) << "failed to serialize data to be saved in " | 149 LOG(WARNING) << "failed to serialize data to be saved in " |
| 146 << path_.value(); | 150 << path_.value(); |
| 147 } | 151 } |
| 148 serializer_ = NULL; | 152 serializer_ = NULL; |
| 149 } | 153 } |
| OLD | NEW |