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

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

Issue 2767193002: Postmortem report collection: validate internal state (Closed)
Patch Set: Created 3 years, 9 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 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 #include "components/browser_watcher/postmortem_report_extractor.h" 5 #include "components/browser_watcher/postmortem_report_extractor.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/debug/activity_analyzer.h" 12 #include "base/debug/activity_analyzer.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/metrics/histogram_macros.h"
15 #include "base/metrics/persistent_memory_allocator.h"
14 #include "base/strings/string_piece.h" 16 #include "base/strings/string_piece.h"
15 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
18 #include "components/browser_watcher/stability_data_names.h" 20 #include "components/browser_watcher/stability_data_names.h"
19 #include "components/variations/active_field_trials.h" 21 #include "components/variations/active_field_trials.h"
20 #include "third_party/crashpad/crashpad/util/misc/uuid.h" 22 #include "third_party/crashpad/crashpad/util/misc/uuid.h"
21 23
22 namespace browser_watcher { 24 namespace browser_watcher {
23 25
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 CollectionStatus Extract(const base::FilePath& stability_file, 208 CollectionStatus Extract(const base::FilePath& stability_file,
207 StabilityReport* report) { 209 StabilityReport* report) {
208 DCHECK(report); 210 DCHECK(report);
209 211
210 // Create a global analyzer. 212 // Create a global analyzer.
211 std::unique_ptr<GlobalActivityAnalyzer> global_analyzer = 213 std::unique_ptr<GlobalActivityAnalyzer> global_analyzer =
212 GlobalActivityAnalyzer::CreateWithFile(stability_file); 214 GlobalActivityAnalyzer::CreateWithFile(stability_file);
213 if (!global_analyzer) 215 if (!global_analyzer)
214 return ANALYZER_CREATION_FAILED; 216 return ANALYZER_CREATION_FAILED;
215 217
218 uint8_t allocator_state = global_analyzer->allocator().GetMemoryState();
bcwhite 2017/03/23 11:32:44 I think it would be better to add a GetMemoryState
bcwhite 2017/03/23 11:35:40 Make that... MEMORY_FULL = 100, // MEMORY_USER
manzagop (departed) 2017/03/23 19:18:54 Acknowledged.
manzagop (departed) 2017/03/23 19:18:54 Hm, maybe it's best to decouple the two. Tell me w
bcwhite 2017/03/23 21:10:43 The memory state was written expecting that it wou
manzagop (departed) 2017/03/23 21:25:02 I'm not sure I follow. Here are the main things: -
bcwhite 2017/03/24 12:49:04 If you ignore the implementation details, you can
219 if (allocator_state == base::PersistentMemoryAllocator::MEMORY_UNINITIALIZED)
220 return ALLOCATOR_UNINITIALIZED;
221 if (allocator_state == base::PersistentMemoryAllocator::MEMORY_DELETED)
222 return ALLOCATOR_DELETED;
223 if (global_analyzer->allocator().IsCorrupt())
224 return ALLOCATOR_CORRUPT;
225 UMA_HISTOGRAM_BOOLEAN("ActivityTracker.Collect.IsAllocatorFull",
bcwhite 2017/03/23 11:32:44 I think it would be better to just enable the inte
manzagop (departed) 2017/03/23 19:18:54 Removed the fullness histogram. Will the histogram
bcwhite 2017/03/23 21:10:43 They're specific to the allocator's name: UMA.Per
manzagop (departed) 2017/03/23 21:25:02 Great!
226 global_analyzer->allocator().IsFull());
227
216 // Early exit if there is no data. 228 // Early exit if there is no data.
217 std::vector<std::string> log_messages = global_analyzer->GetLogMessages(); 229 std::vector<std::string> log_messages = global_analyzer->GetLogMessages();
218 ActivityUserData::Snapshot global_data_snapshot = 230 ActivityUserData::Snapshot global_data_snapshot =
219 global_analyzer->GetGlobalUserDataSnapshot(); 231 global_analyzer->GetGlobalUserDataSnapshot();
220 ThreadActivityAnalyzer* thread_analyzer = global_analyzer->GetFirstAnalyzer(); 232 ThreadActivityAnalyzer* thread_analyzer = global_analyzer->GetFirstAnalyzer();
221 if (log_messages.empty() && global_data_snapshot.empty() && 233 if (log_messages.empty() && global_data_snapshot.empty() &&
222 !thread_analyzer) { 234 !thread_analyzer) {
223 return DEBUG_FILE_NO_DATA; 235 return DEBUG_FILE_NO_DATA;
224 } 236 }
225 237
(...skipping 27 matching lines...) Expand all
253 CollectThread(thread_analyzer->activity_snapshot(), thread_state); 265 CollectThread(thread_analyzer->activity_snapshot(), thread_state);
254 } 266 }
255 267
256 // Collect module information. 268 // Collect module information.
257 CollectModuleInformation(global_analyzer->GetModules(), process_state); 269 CollectModuleInformation(global_analyzer->GetModules(), process_state);
258 270
259 return SUCCESS; 271 return SUCCESS;
260 } 272 }
261 273
262 } // namespace browser_watcher 274 } // namespace browser_watcher
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698