| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // Note: aside from using windows headers to obtain the definitions of minidump | 5 // Note: aside from using windows headers to obtain the definitions of minidump |
| 6 // structures, nothing here is windows specific. This seems like the best | 6 // structures, nothing here is windows specific. This seems like the best |
| 7 // approach given this code is for temporary experimentation on Windows. | 7 // approach given this code is for temporary experimentation on Windows. |
| 8 // Longer term, Crashpad will take over the minidump writing in this case as | 8 // Longer term, Crashpad will take over the minidump writing in this case as |
| 9 // well. | 9 // well. |
| 10 | 10 |
| 11 #include "components/browser_watcher/postmortem_minidump_writer.h" | 11 #include "components/browser_watcher/postmortem_minidump_writer.h" |
| 12 | 12 |
| 13 #include <windows.h> // NOLINT | 13 #include <windows.h> // NOLINT |
| 14 #include <dbghelp.h> | 14 #include <dbghelp.h> |
| 15 | 15 |
| 16 #include <map> | 16 #include <map> |
| 17 #include <type_traits> | 17 #include <type_traits> |
| 18 #include <vector> | 18 #include <vector> |
| 19 | 19 |
| 20 #include "base/files/file_util.h" | 20 #include "base/files/file_util.h" |
| 21 #include "base/macros.h" | 21 #include "base/macros.h" |
| 22 #include "base/metrics/histogram_macros.h" | 22 #include "base/metrics/histogram_macros.h" |
| 23 #include "base/numerics/safe_math.h" | 23 #include "base/numerics/safe_math.h" |
| 24 #include "base/strings/string_piece.h" | 24 #include "base/strings/string_piece.h" |
| 25 #include "components/browser_watcher/minidump_user_streams.h" |
| 25 #include "components/browser_watcher/stability_data_names.h" | 26 #include "components/browser_watcher/stability_data_names.h" |
| 26 #include "third_party/crashpad/crashpad/minidump/minidump_extensions.h" | 27 #include "third_party/crashpad/crashpad/minidump/minidump_extensions.h" |
| 27 | 28 |
| 28 namespace browser_watcher { | 29 namespace browser_watcher { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 // The stream type assigned to the minidump stream that holds the serialized | |
| 33 // stability report. | |
| 34 // Note: the value was obtained by adding 1 to the stream type used for holding | |
| 35 // the SyzyAsan proto. | |
| 36 // TODO(manzagop): centralize the stream type definitions to avoid issues. | |
| 37 const uint32_t kStabilityReportStreamType = 0x4B6B0002; | |
| 38 | |
| 39 struct ProductDetails { | 33 struct ProductDetails { |
| 40 std::string product; | 34 std::string product; |
| 41 std::string channel; | 35 std::string channel; |
| 42 std::string platform; | 36 std::string platform; |
| 43 std::string version; | 37 std::string version; |
| 44 }; | 38 }; |
| 45 | 39 |
| 46 bool GetStringFromTypedValueMap( | 40 bool GetStringFromTypedValueMap( |
| 47 const google::protobuf::Map<std::string, TypedValue>& map, | 41 const google::protobuf::Map<std::string, TypedValue>& map, |
| 48 const std::string& key, | 42 const std::string& key, |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 const crashpad::UUID& client_id, | 486 const crashpad::UUID& client_id, |
| 493 const crashpad::UUID& report_id, | 487 const crashpad::UUID& report_id, |
| 494 StabilityReport* report) { | 488 StabilityReport* report) { |
| 495 DCHECK(report); | 489 DCHECK(report); |
| 496 | 490 |
| 497 PostmortemMinidumpWriter writer; | 491 PostmortemMinidumpWriter writer; |
| 498 return writer.WriteDump(minidump_file, client_id, report_id, report); | 492 return writer.WriteDump(minidump_file, client_id, report_id, report); |
| 499 } | 493 } |
| 500 | 494 |
| 501 } // namespace browser_watcher | 495 } // namespace browser_watcher |
| OLD | NEW |