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

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

Issue 1995573003: [tracing] Introduce BACKGROUND mode in MemoryInfra (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: with periodic again. Created 4 years, 7 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 #ifndef BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ 5 #ifndef BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_
6 #define BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ 6 #define BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/atomicops.h" 15 #include "base/atomicops.h"
16 #include "base/containers/hash_tables.h" 16 #include "base/containers/hash_tables.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/memory/singleton.h" 19 #include "base/memory/singleton.h"
20 #include "base/synchronization/lock.h" 20 #include "base/synchronization/lock.h"
21 #include "base/timer/timer.h"
22 #include "base/trace_event/memory_dump_request_args.h" 21 #include "base/trace_event/memory_dump_request_args.h"
23 #include "base/trace_event/process_memory_dump.h" 22 #include "base/trace_event/process_memory_dump.h"
24 #include "base/trace_event/trace_event.h" 23 #include "base/trace_event/trace_event.h"
25 24
26 namespace base { 25 namespace base {
27 26
28 class SingleThreadTaskRunner; 27 class SingleThreadTaskRunner;
29 class Thread; 28 class Thread;
30 29
31 namespace trace_event { 30 namespace trace_event {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // When set to true, calling |RegisterMemoryDumpProvider| is a no-op. 138 // When set to true, calling |RegisterMemoryDumpProvider| is a no-op.
140 void set_dumper_registrations_ignored_for_testing(bool ignored) { 139 void set_dumper_registrations_ignored_for_testing(bool ignored) {
141 dumper_registrations_ignored_for_testing_ = ignored; 140 dumper_registrations_ignored_for_testing_ = ignored;
142 } 141 }
143 142
144 private: 143 private:
145 friend std::default_delete<MemoryDumpManager>; // For the testing instance. 144 friend std::default_delete<MemoryDumpManager>; // For the testing instance.
146 friend struct DefaultSingletonTraits<MemoryDumpManager>; 145 friend struct DefaultSingletonTraits<MemoryDumpManager>;
147 friend class MemoryDumpManagerDelegate; 146 friend class MemoryDumpManagerDelegate;
148 friend class MemoryDumpManagerTest; 147 friend class MemoryDumpManagerTest;
148 class PeriodicGlobalDumpInvokeHelper;
Primiano Tucci (use gerrit) 2016/05/26 17:20:53 I think just PeriodicDumpHelper is enough (which a
ssid 2016/05/26 22:12:54 I think after including start and stop it is more
149 149
150 // Descriptor used to hold information about registered MDPs. 150 // Descriptor used to hold information about registered MDPs.
151 // Some important considerations about lifetime of this object: 151 // Some important considerations about lifetime of this object:
152 // - In nominal conditions, all the MemoryDumpProviderInfo instances live in 152 // - In nominal conditions, all the MemoryDumpProviderInfo instances live in
153 // the |dump_providers_| collection (% unregistration while dumping). 153 // the |dump_providers_| collection (% unregistration while dumping).
154 // - Upon each dump they (actually their scoped_refptr-s) are copied into 154 // - Upon each dump they (actually their scoped_refptr-s) are copied into
155 // the ProcessMemoryDumpAsyncState. This is to allow removal (see below). 155 // the ProcessMemoryDumpAsyncState. This is to allow removal (see below).
156 // - When the MDP.OnMemoryDump() is invoked, the corresponding MDPInfo copy 156 // - When the MDP.OnMemoryDump() is invoked, the corresponding MDPInfo copy
157 // inside ProcessMemoryDumpAsyncState is removed. 157 // inside ProcessMemoryDumpAsyncState is removed.
158 // - In most cases, the MDPInfo is destroyed within UnregisterDumpProvider(). 158 // - In most cases, the MDPInfo is destroyed within UnregisterDumpProvider().
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 193
194 // The |options| arg passed to RegisterDumpProvider(). 194 // The |options| arg passed to RegisterDumpProvider().
195 const MemoryDumpProvider::Options options; 195 const MemoryDumpProvider::Options options;
196 196
197 // For fail-safe logic (auto-disable failing MDPs). 197 // For fail-safe logic (auto-disable failing MDPs).
198 int consecutive_failures; 198 int consecutive_failures;
199 199
200 // Flagged either by the auto-disable logic or during unregistration. 200 // Flagged either by the auto-disable logic or during unregistration.
201 bool disabled; 201 bool disabled;
202 202
203 // True if the dump provider is not whitelited for background mode.
Primiano Tucci (use gerrit) 2016/05/26 17:20:53 nit: whitelisted
ssid 2016/05/26 22:12:54 Done.
204 const bool disabled_for_background_mode;
Primiano Tucci (use gerrit) 2016/05/26 17:20:53 in order to make this less confusing (initially I
ssid 2016/05/26 22:12:54 Done thanks
205
203 private: 206 private:
204 friend class base::RefCountedThreadSafe<MemoryDumpProviderInfo>; 207 friend class base::RefCountedThreadSafe<MemoryDumpProviderInfo>;
205 ~MemoryDumpProviderInfo(); 208 ~MemoryDumpProviderInfo();
206 209
207 DISALLOW_COPY_AND_ASSIGN(MemoryDumpProviderInfo); 210 DISALLOW_COPY_AND_ASSIGN(MemoryDumpProviderInfo);
208 }; 211 };
209 212
210 // Holds the state of a process memory dump that needs to be carried over 213 // Holds the state of a process memory dump that needs to be carried over
211 // across task runners in order to fulfil an asynchronous CreateProcessDump() 214 // across task runners in order to fulfil an asynchronous CreateProcessDump()
212 // request. At any time exactly one task runner owns a 215 // request. At any time exactly one task runner owns a
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 321
319 // Protects from concurrent accesses to the |dump_providers_*| and |delegate_| 322 // Protects from concurrent accesses to the |dump_providers_*| and |delegate_|
320 // to guard against disabling logging while dumping on another thread. 323 // to guard against disabling logging while dumping on another thread.
321 Lock lock_; 324 Lock lock_;
322 325
323 // Optimization to avoid attempting any memory dump (i.e. to not walk an empty 326 // Optimization to avoid attempting any memory dump (i.e. to not walk an empty
324 // dump_providers_enabled_ list) when tracing is not enabled. 327 // dump_providers_enabled_ list) when tracing is not enabled.
325 subtle::AtomicWord memory_tracing_enabled_; 328 subtle::AtomicWord memory_tracing_enabled_;
326 329
327 // For time-triggered periodic dumps. 330 // For time-triggered periodic dumps.
328 RepeatingTimer periodic_dump_timer_; 331 std::unique_ptr<PeriodicGlobalDumpInvokeHelper> periodic_dump_helper_;
329 332
330 // Thread used for MemoryDumpProviders which don't specify a task runner 333 // Thread used for MemoryDumpProviders which don't specify a task runner
331 // affinity. 334 // affinity.
332 std::unique_ptr<Thread> dump_thread_; 335 std::unique_ptr<Thread> dump_thread_;
333 336
334 // The unique id of the child process. This is created only for tracing and is 337 // The unique id of the child process. This is created only for tracing and is
335 // expected to be valid only when tracing is enabled. 338 // expected to be valid only when tracing is enabled.
336 uint64_t tracing_process_id_; 339 uint64_t tracing_process_id_;
337 340
338 // When true, calling |RegisterMemoryDumpProvider| is a no-op. 341 // When true, calling |RegisterMemoryDumpProvider| is a no-op.
(...skipping 26 matching lines...) Expand all
365 } 368 }
366 369
367 private: 370 private:
368 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); 371 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate);
369 }; 372 };
370 373
371 } // namespace trace_event 374 } // namespace trace_event
372 } // namespace base 375 } // namespace base
373 376
374 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ 377 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/memory_dump_manager.cc » ('j') | base/trace_event/memory_dump_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698