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

Side by Side Diff: base/trace_event/memory_dump_manager.cc

Issue 1028333002: Chromium -> Mojo roll. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/trace_event/memory_dump_manager.h" 5 #include "base/trace_event/memory_dump_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/atomic_sequence_num.h" 9 #include "base/atomic_sequence_num.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 return Singleton<MemoryDumpManager, 53 return Singleton<MemoryDumpManager,
54 LeakySingletonTraits<MemoryDumpManager>>::get(); 54 LeakySingletonTraits<MemoryDumpManager>>::get();
55 } 55 }
56 56
57 // static 57 // static
58 void MemoryDumpManager::SetInstanceForTesting(MemoryDumpManager* instance) { 58 void MemoryDumpManager::SetInstanceForTesting(MemoryDumpManager* instance) {
59 g_instance_for_testing = instance; 59 g_instance_for_testing = instance;
60 } 60 }
61 61
62 MemoryDumpManager::MemoryDumpManager() : memory_tracing_enabled_(0) { 62 MemoryDumpManager::MemoryDumpManager()
63 : dump_provider_currently_active_(nullptr), memory_tracing_enabled_(0) {
63 } 64 }
64 65
65 MemoryDumpManager::~MemoryDumpManager() { 66 MemoryDumpManager::~MemoryDumpManager() {
66 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(this); 67 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(this);
67 } 68 }
68 69
69 void MemoryDumpManager::Initialize() { 70 void MemoryDumpManager::Initialize() {
70 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list. 71 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list.
71 trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(this); 72 trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(this);
72 } 73 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 uint64 guid) { 122 uint64 guid) {
122 bool did_any_provider_dump = false; 123 bool did_any_provider_dump = false;
123 scoped_ptr<ProcessMemoryDump> pmd(new ProcessMemoryDump()); 124 scoped_ptr<ProcessMemoryDump> pmd(new ProcessMemoryDump());
124 125
125 // Serialize dump point generation so that memory dump providers don't have to 126 // Serialize dump point generation so that memory dump providers don't have to
126 // deal with thread safety. 127 // deal with thread safety.
127 { 128 {
128 AutoLock lock(lock_); 129 AutoLock lock(lock_);
129 for (auto it = dump_providers_enabled_.begin(); 130 for (auto it = dump_providers_enabled_.begin();
130 it != dump_providers_enabled_.end();) { 131 it != dump_providers_enabled_.end();) {
131 MemoryDumpProvider* dump_provider = *it; 132 dump_provider_currently_active_ = *it;
132 if (dump_provider->DumpInto(pmd.get())) { 133 if (dump_provider_currently_active_->DumpInto(pmd.get())) {
133 did_any_provider_dump = true; 134 did_any_provider_dump = true;
134 ++it; 135 ++it;
135 } else { 136 } else {
136 LOG(ERROR) << "The memory dumper " << dump_provider->GetFriendlyName() 137 LOG(ERROR) << "The memory dumper "
138 << dump_provider_currently_active_->GetFriendlyName()
137 << " failed, possibly due to sandboxing (crbug.com/461788), " 139 << " failed, possibly due to sandboxing (crbug.com/461788), "
138 "disabling it for current process. Try restarting chrome " 140 "disabling it for current process. Try restarting chrome "
139 "with the --no-sandbox switch."; 141 "with the --no-sandbox switch.";
140 it = dump_providers_enabled_.erase(it); 142 it = dump_providers_enabled_.erase(it);
141 } 143 }
144 dump_provider_currently_active_ = nullptr;
142 } 145 }
143 } 146 }
144 147
145 // Don't create a dump point if all the dumpers failed. 148 // Don't create a dump point if all the dumpers failed.
146 if (!did_any_provider_dump) 149 if (!did_any_provider_dump)
147 return; 150 return;
148 151
149 scoped_refptr<ConvertableToTraceFormat> event_value(new TracedValue()); 152 scoped_refptr<ConvertableToTraceFormat> event_value(new TracedValue());
150 pmd->AsValueInto(static_cast<TracedValue*>(event_value.get())); 153 pmd->AsValueInto(static_cast<TracedValue*>(event_value.get()));
151 const char* const event_name = DumpPointTypeToString(dump_point_type); 154 const char* const event_name = DumpPointTypeToString(dump_point_type);
(...skipping 23 matching lines...) Expand all
175 } 178 }
176 179
177 void MemoryDumpManager::OnTraceLogDisabled() { 180 void MemoryDumpManager::OnTraceLogDisabled() {
178 AutoLock lock(lock_); 181 AutoLock lock(lock_);
179 dump_providers_enabled_.clear(); 182 dump_providers_enabled_.clear();
180 subtle::NoBarrier_Store(&memory_tracing_enabled_, 0); 183 subtle::NoBarrier_Store(&memory_tracing_enabled_, 0);
181 } 184 }
182 185
183 } // namespace trace_event 186 } // namespace trace_event
184 } // namespace base 187 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/memory_dump_manager.h ('k') | base/trace_event/memory_dump_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698