| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chromecast/crash/linux/dump_info.h" | 4 #include "chromecast/crash/linux/dump_info.h" |
| 5 | 5 |
| 6 #include <errno.h> | 6 #include <errno.h> |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ptr_util.h" |
| 11 #include "base/values.h" | 12 #include "base/values.h" |
| 12 | 13 |
| 13 namespace chromecast { | 14 namespace chromecast { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 const char kDumpTimeFormat[] = "%Y-%m-%d %H:%M:%S"; | 18 const char kDumpTimeFormat[] = "%Y-%m-%d %H:%M:%S"; |
| 18 const unsigned kDumpTimeMaxLen = 255; | 19 const unsigned kDumpTimeMaxLen = 255; |
| 19 | 20 |
| 20 const int kNumRequiredParams = 5; | 21 const int kNumRequiredParams = 5; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 LOG(INFO) << "strftime failed"; | 56 LOG(INFO) << "strftime failed"; |
| 56 return; | 57 return; |
| 57 } | 58 } |
| 58 | 59 |
| 59 valid_ = true; | 60 valid_ = true; |
| 60 } | 61 } |
| 61 | 62 |
| 62 DumpInfo::~DumpInfo() { | 63 DumpInfo::~DumpInfo() { |
| 63 } | 64 } |
| 64 | 65 |
| 65 scoped_ptr<base::Value> DumpInfo::GetAsValue() const { | 66 std::unique_ptr<base::Value> DumpInfo::GetAsValue() const { |
| 66 scoped_ptr<base::Value> result = make_scoped_ptr(new base::DictionaryValue()); | 67 std::unique_ptr<base::Value> result = |
| 68 base::WrapUnique(new base::DictionaryValue()); |
| 67 base::DictionaryValue* entry; | 69 base::DictionaryValue* entry; |
| 68 result->GetAsDictionary(&entry); | 70 result->GetAsDictionary(&entry); |
| 69 entry->SetString(kNameKey, params_.process_name); | 71 entry->SetString(kNameKey, params_.process_name); |
| 70 | 72 |
| 71 struct tm* tm = gmtime(&dump_time_); | 73 struct tm* tm = gmtime(&dump_time_); |
| 72 char buf[kDumpTimeMaxLen]; | 74 char buf[kDumpTimeMaxLen]; |
| 73 int n = strftime(buf, kDumpTimeMaxLen, kDumpTimeFormat, tm); | 75 int n = strftime(buf, kDumpTimeMaxLen, kDumpTimeFormat, tm); |
| 74 DCHECK_GT(n, 0); | 76 DCHECK_GT(n, 0); |
| 75 std::string dump_time(buf); | 77 std::string dump_time(buf); |
| 76 entry->SetString(kDumpTimeKey, dump_time); | 78 entry->SetString(kDumpTimeKey, dump_time); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 char* text = strptime(timestr.c_str(), kDumpTimeFormat, &tm); | 156 char* text = strptime(timestr.c_str(), kDumpTimeFormat, &tm); |
| 155 dump_time_ = mktime(&tm); | 157 dump_time_ = mktime(&tm); |
| 156 if (!text || dump_time_ < 0) { | 158 if (!text || dump_time_ < 0) { |
| 157 LOG(INFO) << "Failed to convert dump time invalid"; | 159 LOG(INFO) << "Failed to convert dump time invalid"; |
| 158 return false; | 160 return false; |
| 159 } | 161 } |
| 160 return true; | 162 return true; |
| 161 } | 163 } |
| 162 | 164 |
| 163 } // namespace chromecast | 165 } // namespace chromecast |
| OLD | NEW |