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

Side by Side Diff: base/debug/activity_analyzer.cc

Issue 2128683002: Collect unclean shutdown debug information (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tracker
Patch Set: Minimal collection to proto Created 4 years, 4 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 "base/debug/activity_analyzer.h" 5 #include "base/debug/activity_analyzer.h"
6 6
7 #include <utility>
bcwhite 2016/08/04 13:38:11 Why this?
manzagop (departed) 2016/08/10 15:59:51 It's where std::move is defined.
8
7 #include "base/files/file.h" 9 #include "base/files/file.h"
8 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
9 #include "base/files/memory_mapped_file.h" 11 #include "base/files/memory_mapped_file.h"
10 #include "base/logging.h" 12 #include "base/logging.h"
11 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
12 #include "base/stl_util.h" 14 #include "base/stl_util.h"
13 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
14 16
15 namespace base { 17 namespace base {
16 namespace debug { 18 namespace debug {
(...skipping 18 matching lines...) Expand all
35 GlobalActivityAnalyzer::GlobalActivityAnalyzer( 37 GlobalActivityAnalyzer::GlobalActivityAnalyzer(
36 std::unique_ptr<PersistentMemoryAllocator> allocator) 38 std::unique_ptr<PersistentMemoryAllocator> allocator)
37 : allocator_(std::move(allocator)), allocator_iterator_(allocator_.get()) {} 39 : allocator_(std::move(allocator)), allocator_iterator_(allocator_.get()) {}
38 40
39 GlobalActivityAnalyzer::~GlobalActivityAnalyzer() {} 41 GlobalActivityAnalyzer::~GlobalActivityAnalyzer() {}
40 42
41 #if !defined(OS_NACL) 43 #if !defined(OS_NACL)
42 std::unique_ptr<GlobalActivityAnalyzer> GlobalActivityAnalyzer::CreateWithFile( 44 std::unique_ptr<GlobalActivityAnalyzer> GlobalActivityAnalyzer::CreateWithFile(
43 const FilePath& file_path) { 45 const FilePath& file_path) {
44 std::unique_ptr<MemoryMappedFile> mmfile(new MemoryMappedFile()); 46 std::unique_ptr<MemoryMappedFile> mmfile(new MemoryMappedFile());
45 mmfile->Initialize(file_path); 47 // Note: write access is required for snapshotting, which writes a sentinel to
48 // ensure the snapshot's consistency.
49 mmfile->Initialize(file_path, MemoryMappedFile::READ_WRITE);
46 if (!mmfile->IsValid()) 50 if (!mmfile->IsValid())
47 return nullptr; 51 return nullptr;
48 52
49 if (!FilePersistentMemoryAllocator::IsFileAcceptable(*mmfile, true)) 53 if (!FilePersistentMemoryAllocator::IsFileAcceptable(*mmfile, true))
50 return nullptr; 54 return nullptr;
51 55
52 return WrapUnique(new GlobalActivityAnalyzer( 56 return WrapUnique(new GlobalActivityAnalyzer(
53 WrapUnique(new FilePersistentMemoryAllocator( 57 WrapUnique(new FilePersistentMemoryAllocator(
54 std::move(mmfile), 0, 0, base::StringPiece(), 58 std::move(mmfile), 0, 0, base::StringPiece(),
55 true)))); 59 true))));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // Add this analyzer to the map of known ones, indexed by a unique thread 121 // Add this analyzer to the map of known ones, indexed by a unique thread
118 // identifier. 122 // identifier.
119 DCHECK(!ContainsKey(analyzers_, analyzer->GetThreadKey())); 123 DCHECK(!ContainsKey(analyzers_, analyzer->GetThreadKey()));
120 analyzer->allocator_reference_ = ref; 124 analyzer->allocator_reference_ = ref;
121 analyzers_[analyzer->GetThreadKey()] = std::move(analyzer); 125 analyzers_[analyzer->GetThreadKey()] = std::move(analyzer);
122 } 126 }
123 } 127 }
124 128
125 } // namespace debug 129 } // namespace debug
126 } // namespace base 130 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698