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

Side by Side Diff: components/browser_watcher/stability_report_user_stream_data_source.cc

Issue 2910003002: Stability instrumentation: metrics for collection on crash (Closed)
Patch Set: Set pma state to deleted Created 3 years, 6 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
OLDNEW
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
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 MarkStabilityFileDeleted(path);
86 // scope. This should cause the stability debugging file to be deleted prior 88 UMA_STABILITY_HISTOGRAM_COUNTS_100("ActivityTracker.CollectCrash.CrashCount",
87 // to the next execution. 89 1);
88 // TODO(manzagop): set the persistent allocator file's state to deleted in
89 // case the file can't be deleted.
90 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ |
91 base::File::FLAG_DELETE_ON_CLOSE);
92 UMA_HISTOGRAM_BOOLEAN("ActivityTracker.CollectCrash.OpenForDeleteSuccess",
93 file.IsValid());
94 90
95 std::unique_ptr<BufferExtensionStreamDataSource> source( 91 std::unique_ptr<BufferExtensionStreamDataSource> source(
96 new BufferExtensionStreamDataSource(kStabilityReportStreamType)); 92 new BufferExtensionStreamDataSource(kStabilityReportStreamType));
97 return source->Init(report) ? std::move(source) : nullptr; 93 return source->Init(report) ? std::move(source) : nullptr;
98 } 94 }
99 95
100 } // namespace 96 } // namespace
101 97
102 StabilityReportUserStreamDataSource::StabilityReportUserStreamDataSource( 98 StabilityReportUserStreamDataSource::StabilityReportUserStreamDataSource(
103 const base::FilePath& user_data_dir) 99 const base::FilePath& user_data_dir)
(...skipping 12 matching lines...) Expand all
116 if (!PathExists(stability_file)) { 112 if (!PathExists(stability_file)) {
117 // Either this is not an instrumented process (currently only browser 113 // Either this is not an instrumented process (currently only browser
118 // processes can be instrumented), or the stability file cannot be found. 114 // processes can be instrumented), or the stability file cannot be found.
119 return nullptr; 115 return nullptr;
120 } 116 }
121 117
122 return CollectReport(stability_file); 118 return CollectReport(stability_file);
123 } 119 }
124 120
125 } // namespace browser_watcher 121 } // namespace browser_watcher
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698