OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/browser_watcher/stability_report_user_stream_data_source.h" | 5 #include "components/browser_watcher/stability_report_user_stream_data_source.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 DCHECK(!data_.empty()); | 66 DCHECK(!data_.empty()); |
67 return data_.size(); | 67 return data_.size(); |
68 } | 68 } |
69 | 69 |
70 bool BufferExtensionStreamDataSource::ReadStreamData(Delegate* delegate) { | 70 bool BufferExtensionStreamDataSource::ReadStreamData(Delegate* delegate) { |
71 DCHECK(!data_.empty()); | 71 DCHECK(!data_.empty()); |
72 return delegate->ExtensionStreamDataSourceRead( | 72 return delegate->ExtensionStreamDataSourceRead( |
73 data_.size() ? data_.data() : nullptr, data_.size()); | 73 data_.size() ? data_.data() : nullptr, data_.size()); |
74 } | 74 } |
75 | 75 |
76 // TODO(manzagop): collection should factor in whether this is a true crash or | |
77 // dump without crashing. | |
76 std::unique_ptr<BufferExtensionStreamDataSource> CollectReport( | 78 std::unique_ptr<BufferExtensionStreamDataSource> CollectReport( |
77 const base::FilePath& path) { | 79 const base::FilePath& path) { |
78 StabilityReport report; | 80 StabilityReport report; |
79 CollectionStatus status = Extract(path, &report); | 81 CollectionStatus status = Extract(path, &report); |
80 UMA_HISTOGRAM_ENUMERATION("ActivityTracker.CollectCrash.Status", status, | 82 UMA_HISTOGRAM_ENUMERATION("ActivityTracker.CollectCrash.Status", status, |
81 COLLECTION_STATUS_MAX); | 83 COLLECTION_STATUS_MAX); |
82 if (status != SUCCESS) | 84 if (status != SUCCESS) |
83 return nullptr; | 85 return nullptr; |
84 | 86 |
85 // Open (with delete) and then immediately close the file by going out of | 87 // Open (with delete) and then immediately close the file by going out of |
86 // scope. This should cause the stability debugging file to be deleted prior | 88 // scope. This should cause the stability debugging file to be deleted prior |
87 // to the next execution. | 89 // to the next execution. |
88 // TODO(manzagop): set the persistent allocator file's state to deleted in | 90 // TODO(manzagop): set the persistent allocator file's state to deleted in |
Sigurður Ásgeirsson
2017/05/30 13:46:37
This seems like a potentially important gotcha her
manzagop (departed)
2017/05/30 16:16:54
Correct. Note currently we undercount, as crashes
| |
89 // case the file can't be deleted. | 91 // case the file can't be deleted. |
90 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ | | 92 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ | |
91 base::File::FLAG_DELETE_ON_CLOSE); | 93 base::File::FLAG_DELETE_ON_CLOSE); |
92 UMA_HISTOGRAM_BOOLEAN("ActivityTracker.CollectCrash.OpenForDeleteSuccess", | 94 UMA_HISTOGRAM_BOOLEAN("ActivityTracker.CollectCrash.OpenForDeleteSuccess", |
93 file.IsValid()); | 95 file.IsValid()); |
96 UMA_STABILITY_HISTOGRAM_COUNTS_100("ActivityTracker.CollectCrash.CrashCount", | |
Sigurður Ásgeirsson
2017/05/30 13:46:37
QQ: is this the best way to record this? I've seen
manzagop (departed)
2017/05/30 16:16:54
I'd want the metric to be usable in a timeline for
| |
97 1); | |
94 | 98 |
95 std::unique_ptr<BufferExtensionStreamDataSource> source( | 99 std::unique_ptr<BufferExtensionStreamDataSource> source( |
96 new BufferExtensionStreamDataSource(kStabilityReportStreamType)); | 100 new BufferExtensionStreamDataSource(kStabilityReportStreamType)); |
97 return source->Init(report) ? std::move(source) : nullptr; | 101 return source->Init(report) ? std::move(source) : nullptr; |
98 } | 102 } |
99 | 103 |
100 } // namespace | 104 } // namespace |
101 | 105 |
102 StabilityReportUserStreamDataSource::StabilityReportUserStreamDataSource( | 106 StabilityReportUserStreamDataSource::StabilityReportUserStreamDataSource( |
103 const base::FilePath& user_data_dir) | 107 const base::FilePath& user_data_dir) |
(...skipping 12 matching lines...) Expand all Loading... | |
116 if (!PathExists(stability_file)) { | 120 if (!PathExists(stability_file)) { |
117 // Either this is not an instrumented process (currently only browser | 121 // Either this is not an instrumented process (currently only browser |
118 // processes can be instrumented), or the stability file cannot be found. | 122 // processes can be instrumented), or the stability file cannot be found. |
119 return nullptr; | 123 return nullptr; |
120 } | 124 } |
121 | 125 |
122 return CollectReport(stability_file); | 126 return CollectReport(stability_file); |
123 } | 127 } |
124 | 128 |
125 } // namespace browser_watcher | 129 } // namespace browser_watcher |
OLD | NEW |