OLD | NEW |
1 // Copyright (c) 2011 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 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 DCHECK(serializer); | 139 DCHECK(serializer); |
140 serializer_ = serializer; | 140 serializer_ = serializer; |
141 | 141 |
142 if (!MessageLoop::current()) { | 142 if (!MessageLoop::current()) { |
143 // Happens in unit tests. | 143 // Happens in unit tests. |
144 DoScheduledWrite(); | 144 DoScheduledWrite(); |
145 return; | 145 return; |
146 } | 146 } |
147 | 147 |
148 if (!timer_.IsRunning()) { | 148 if (!timer_.IsRunning()) { |
149 timer_.Start(FROM_HERE, commit_interval_, this, | 149 timer_.Start(commit_interval_, this, |
150 &ImportantFileWriter::DoScheduledWrite); | 150 &ImportantFileWriter::DoScheduledWrite); |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 void ImportantFileWriter::DoScheduledWrite() { | 154 void ImportantFileWriter::DoScheduledWrite() { |
155 DCHECK(serializer_); | 155 DCHECK(serializer_); |
156 std::string data; | 156 std::string data; |
157 if (serializer_->SerializeData(&data)) { | 157 if (serializer_->SerializeData(&data)) { |
158 WriteNow(data); | 158 WriteNow(data); |
159 } else { | 159 } else { |
160 LOG(WARNING) << "failed to serialize data to be saved in " | 160 LOG(WARNING) << "failed to serialize data to be saved in " |
161 << path_.value(); | 161 << path_.value(); |
162 } | 162 } |
163 serializer_ = NULL; | 163 serializer_ = NULL; |
164 } | 164 } |
OLD | NEW |