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

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

Issue 3056029: Move the number conversions from string_util to a new file.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/extensions/update_manifest.cc ('k') | chrome/common/logging_chrome.cc » ('j') | 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) 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 <ostream> 9 #include <ostream>
10 #include <string> 10 #include <string>
11 11
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/message_loop_proxy.h" 15 #include "base/message_loop_proxy.h"
16 #include "base/string_util.h" 16 #include "base/string_number_conversions.h"
17 #include "base/task.h" 17 #include "base/task.h"
18 #include "base/thread.h" 18 #include "base/thread.h"
19 #include "base/time.h" 19 #include "base/time.h"
20 20
21 using base::TimeDelta; 21 using base::TimeDelta;
22 22
23 namespace { 23 namespace {
24 24
25 const int kDefaultCommitIntervalMs = 10000; 25 const int kDefaultCommitIntervalMs = 10000;
26 26
(...skipping 18 matching lines...) Expand all
45 } 45 }
46 46
47 size_t bytes_written = fwrite(data_.data(), 1, data_.length(), tmp_file); 47 size_t bytes_written = fwrite(data_.data(), 1, data_.length(), tmp_file);
48 if (!file_util::CloseFile(tmp_file)) { 48 if (!file_util::CloseFile(tmp_file)) {
49 file_util::Delete(tmp_file_path, false); 49 file_util::Delete(tmp_file_path, false);
50 LogFailure("failed to close temporary file"); 50 LogFailure("failed to close temporary file");
51 return; 51 return;
52 } 52 }
53 if (bytes_written < data_.length()) { 53 if (bytes_written < data_.length()) {
54 file_util::Delete(tmp_file_path, false); 54 file_util::Delete(tmp_file_path, false);
55 LogFailure("error writing, bytes_written=" + UintToString( 55 LogFailure("error writing, bytes_written=" +
56 static_cast<unsigned int>(bytes_written))); 56 base::Uint64ToString(bytes_written));
57 return; 57 return;
58 } 58 }
59 59
60 if (file_util::ReplaceFile(tmp_file_path, path_)) { 60 if (file_util::ReplaceFile(tmp_file_path, path_)) {
61 LogSuccess(); 61 LogSuccess();
62 return; 62 return;
63 } 63 }
64 64
65 file_util::Delete(tmp_file_path, false); 65 file_util::Delete(tmp_file_path, false);
66 LogFailure("could not rename temporary file"); 66 LogFailure("could not rename temporary file");
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 DCHECK(serializer_); 141 DCHECK(serializer_);
142 std::string data; 142 std::string data;
143 if (serializer_->SerializeData(&data)) { 143 if (serializer_->SerializeData(&data)) {
144 WriteNow(data); 144 WriteNow(data);
145 } else { 145 } else {
146 LOG(WARNING) << "failed to serialize data to be saved in " 146 LOG(WARNING) << "failed to serialize data to be saved in "
147 << path_.value(); 147 << path_.value();
148 } 148 }
149 serializer_ = NULL; 149 serializer_ = NULL;
150 } 150 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/update_manifest.cc ('k') | chrome/common/logging_chrome.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698