OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 "crash-reporter/crash_collector.h" | 5 #include "crash-reporter/crash_collector.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <pwd.h> // For struct passwd. | 8 #include <pwd.h> // For struct passwd. |
9 #include <sys/types.h> // for mode_t. | 9 #include <sys/types.h> // for mode_t. |
10 | 10 |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 if (sides.size() != 2) { | 241 if (sides.size() != 2) { |
242 any_errors = true; | 242 any_errors = true; |
243 continue; | 243 continue; |
244 } | 244 } |
245 dictionary->insert(std::pair<std::string, std::string>(sides[0], sides[1])); | 245 dictionary->insert(std::pair<std::string, std::string>(sides[0], sides[1])); |
246 } | 246 } |
247 return !any_errors; | 247 return !any_errors; |
248 } | 248 } |
249 | 249 |
250 void CrashCollector::WriteCrashMetaData(const FilePath &meta_path, | 250 void CrashCollector::WriteCrashMetaData(const FilePath &meta_path, |
251 const std::string &exec_name) { | 251 const std::string &exec_name, |
| 252 const std::string &payload_path) { |
252 std::map<std::string, std::string> contents; | 253 std::map<std::string, std::string> contents; |
253 if (!ReadKeyValueFile(FilePath(std::string(kLsbRelease)), '=', &contents)) { | 254 if (!ReadKeyValueFile(FilePath(std::string(kLsbRelease)), '=', &contents)) { |
254 logger_->LogError("Problem parsing %s", kLsbRelease); | 255 logger_->LogError("Problem parsing %s", kLsbRelease); |
255 // Even though there was some failure, take as much as we could read. | 256 // Even though there was some failure, take as much as we could read. |
256 } | 257 } |
257 std::string version("unknown"); | 258 std::string version("unknown"); |
258 std::map<std::string, std::string>::iterator i; | 259 std::map<std::string, std::string>::iterator i; |
259 if ((i = contents.find("CHROMEOS_RELEASE_VERSION")) != contents.end()) { | 260 if ((i = contents.find("CHROMEOS_RELEASE_VERSION")) != contents.end()) { |
260 version = i->second; | 261 version = i->second; |
261 } | 262 } |
| 263 int64 payload_size = -1; |
| 264 file_util::GetFileSize(FilePath(payload_path), &payload_size); |
262 std::string meta_data = StringPrintf("exec_name=%s\n" | 265 std::string meta_data = StringPrintf("exec_name=%s\n" |
263 "ver=%s\n" | 266 "ver=%s\n" |
| 267 "payload_size=%lld\n" |
264 "done=1\n", | 268 "done=1\n", |
265 exec_name.c_str(), | 269 exec_name.c_str(), |
266 version.c_str()); | 270 version.c_str(), |
| 271 payload_size); |
267 if (!file_util::WriteFile(meta_path, meta_data.c_str(), meta_data.size())) { | 272 if (!file_util::WriteFile(meta_path, meta_data.c_str(), meta_data.size())) { |
268 logger_->LogError("Unable to write %s", meta_path.value().c_str()); | 273 logger_->LogError("Unable to write %s", meta_path.value().c_str()); |
269 } | 274 } |
270 } | 275 } |
OLD | NEW |