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

Unified Diff: base/trace_event/memory_dump_manager.h

Issue 1618703004: [MemoryInfra] Support dump providers running on SequencedTaskRunner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes. Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/trace_event/memory_dump_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/memory_dump_manager.h
diff --git a/base/trace_event/memory_dump_manager.h b/base/trace_event/memory_dump_manager.h
index b7130795ff7140f353d5e0f0d04fdd6e194fe287..e9b09f8f0c3b9e3f88b53d569684c5b7f4133a17 100644
--- a/base/trace_event/memory_dump_manager.h
+++ b/base/trace_event/memory_dump_manager.h
@@ -69,9 +69,9 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver {
// - name: a friendly name (duplicates allowed). Used for debugging and
// run-time profiling of memory-infra internals. Must be a long-lived
// C string.
- // - task_runner: if non-null, all the calls to |mdp| will be
- // issued on the given thread. Otherwise, |mdp| should be able to
- // handle calls on arbitrary threads.
+ // - task_runner: either a SingleThreadTaskRunner or SequencedTaskRunner. All
+ // the calls to |mdp| will be run on the given |task_runner|. If passed
+ // null |mdp| should be able to handle calls on arbitrary threads.
// - options: extra optional arguments. See memory_dump_provider.h.
void RegisterDumpProvider(
MemoryDumpProvider* mdp,
@@ -81,7 +81,12 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver {
MemoryDumpProvider* mdp,
const char* name,
const scoped_refptr<SingleThreadTaskRunner>& task_runner,
- const MemoryDumpProvider::Options& options);
+ MemoryDumpProvider::Options options);
+ void RegisterDumpProviderWithSequencedTaskRunner(
+ MemoryDumpProvider* mdp,
+ const char* name,
+ const scoped_refptr<SequencedTaskRunner>& task_runner,
+ MemoryDumpProvider::Options options);
void UnregisterDumpProvider(MemoryDumpProvider* mdp);
// Unregisters an unbound dump provider and takes care about its deletion
@@ -153,14 +158,15 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver {
// inside ProcessMemoryDumpAsyncState is removed.
// - In most cases, the MDPInfo is destroyed within UnregisterDumpProvider().
// - If UnregisterDumpProvider() is called while a dump is in progress, the
- // MDPInfo is destroyed in the epilogue of ContinueAsyncProcessDump(), when
- // the copy inside ProcessMemoryDumpAsyncState is erase()-d.
+ // MDPInfo is destroyed in SetupNextMemoryDump() or InvokeOnMemoryDump(),
+ // when the copy inside ProcessMemoryDumpAsyncState is erase()-d.
// - The non-const fields of MemoryDumpProviderInfo are safe to access only
- // in the |task_runner| thread, unless the thread has been destroyed.
+ // on tasks running in the |task_runner|, unless the thread has been
+ // destroyed.
struct MemoryDumpProviderInfo
: public RefCountedThreadSafe<MemoryDumpProviderInfo> {
- // Define a total order based on the thread (i.e. |task_runner|) affinity,
- // so that all MDP belonging to the same thread are adjacent in the set.
+ // Define a total order based on the |task_runner| affinity, so that MDPs
+ // belonging to the same SequencedTaskRunner are adjacent in the set.
struct Comparator {
bool operator()(const scoped_refptr<MemoryDumpProviderInfo>& a,
const scoped_refptr<MemoryDumpProviderInfo>& b) const;
@@ -171,7 +177,7 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver {
MemoryDumpProviderInfo(
MemoryDumpProvider* dump_provider,
const char* name,
- const scoped_refptr<SingleThreadTaskRunner>& task_runner,
+ const scoped_refptr<SequencedTaskRunner>& task_runner,
const MemoryDumpProvider::Options& options);
MemoryDumpProvider* const dump_provider;
@@ -183,9 +189,9 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver {
// Human readable name, for debugging and testing. Not necessarily unique.
const char* const name;
- // The task_runner affinity. Can be nullptr, in which case the dump provider
+ // The task runner affinity. Can be nullptr, in which case the dump provider
// will be invoked on |dump_thread_|.
- const scoped_refptr<SingleThreadTaskRunner> task_runner;
+ const scoped_refptr<SequencedTaskRunner> task_runner;
// The |options| arg passed to RegisterDumpProvider().
const MemoryDumpProvider::Options options;
@@ -204,8 +210,9 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver {
};
// Holds the state of a process memory dump that needs to be carried over
- // across threads in order to fulfil an asynchronous CreateProcessDump()
- // request. At any time exactly one thread owns a ProcessMemoryDumpAsyncState.
+ // across task runners in order to fulfil an asynchronous CreateProcessDump()
+ // request. At any time exactly one task runner owns a
+ // ProcessMemoryDumpAsyncState.
struct ProcessMemoryDumpAsyncState {
ProcessMemoryDumpAsyncState(
MemoryDumpRequestArgs req_args,
@@ -277,17 +284,30 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver {
void CreateProcessDump(const MemoryDumpRequestArgs& args,
const MemoryDumpCallback& callback);
- // Continues the ProcessMemoryDump started by CreateProcessDump(), hopping
- // across threads as needed as specified by MDPs in RegisterDumpProvider().
- void ContinueAsyncProcessDump(
- ProcessMemoryDumpAsyncState* owned_pmd_async_state);
+ // Calls InvokeOnMemoryDump() for the next MDP on the task runner specified by
+ // the MDP while registration. On failure to do so, skips and continues to
+ // next MDP.
+ void SetupNextMemoryDump(
+ scoped_ptr<ProcessMemoryDumpAsyncState> pmd_async_state);
+
+ // Invokes OnMemoryDump() of the next MDP and calls SetupNextMemoryDump() at
+ // the end to continue the ProcessMemoryDump. Should be called on the MDP task
+ // runner.
+ void InvokeOnMemoryDump(ProcessMemoryDumpAsyncState* owned_pmd_async_state);
+
+ // Helper for RegierDumpProvider* functions.
+ void RegisterDumpProviderInternal(
+ MemoryDumpProvider* mdp,
+ const char* name,
+ const scoped_refptr<SequencedTaskRunner>& task_runner,
+ const MemoryDumpProvider::Options& options);
// Helper for the public UnregisterDumpProvider* functions.
void UnregisterDumpProviderInternal(MemoryDumpProvider* mdp,
bool take_mdp_ownership_and_delete_async);
- // An ordererd set of registered MemoryDumpProviderInfo(s), sorted by thread
- // affinity (MDPs belonging to the same thread are adjacent).
+ // An ordererd set of registered MemoryDumpProviderInfo(s), sorted by task
+ // runner affinity (MDPs belonging to the same task runners are adjacent).
MemoryDumpProviderInfo::OrderedSet dump_providers_;
// Shared among all the PMDs to keep state scoped to the tracing session.
@@ -309,7 +329,8 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver {
// For time-triggered periodic dumps.
RepeatingTimer periodic_dump_timer_;
- // Thread used for MemoryDumpProviders which don't specify a thread affinity.
+ // Thread used for MemoryDumpProviders which don't specify a task runner
+ // affinity.
scoped_ptr<Thread> dump_thread_;
// The unique id of the child process. This is created only for tracing and is
« no previous file with comments | « no previous file | base/trace_event/memory_dump_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698