Chromium Code Reviews| 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 e34bdb0853cc6200d3a494969fe8582eb2040f79..7512b17a66709854ef06aa9986ec7065ef8b83a0 100644 |
| --- a/base/trace_event/memory_dump_manager.h |
| +++ b/base/trace_event/memory_dump_manager.h |
| @@ -36,6 +36,7 @@ class MemoryDumpSessionState; |
| // RequestDumpPoint(). The extension by Un(RegisterDumpProvider). |
| class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver { |
| public: |
| + static const int kInvalidTracingProcessId = -1; |
| static const char* const kTraceCategoryForTesting; |
| static MemoryDumpManager* GetInstance(); |
| @@ -81,6 +82,24 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver { |
| return session_state_; |
| } |
| + // Derives a tracing process id from a child process id. Child process ids |
| + // cannot be used directly in tracing for security reasons (see: discussion in |
| + // crrev.com/1173263004). This method is meant to be used when dumping |
| + // cross-process shared memory from a process which knows the child process id |
| + // of its endpoints. The value returned by this method is guaranteed to be |
| + // equal to the value returned by tracing_process_id() in the corresponding |
| + // child process. |
| + static int ChildProcessIdToTracingProcessId(int child_id); |
| + |
| + // Returns a unique id for the current process. The id can be retrieved only |
| + // by child processes and only when tracing is enabled. This is intended to |
| + // express cross-process sharing of memory dumps on the child-process side, |
| + // without having to know the self child process id. |
|
picksi
2015/06/24 11:12:43
'self child' looks like a typo? Do you just mean c
Primiano Tucci (use gerrit)
2015/06/24 17:47:35
This means here "the child process id of the child
|
| + int tracing_process_id() const { |
| + DCHECK_NE(tracing_process_id_, kInvalidTracingProcessId); |
| + return tracing_process_id_; |
| + } |
| + |
| private: |
| // Descriptor struct used to hold information about registered MDPs. It is |
| // deliberately copyable, in order to allow to be used as hash_map value. |
| @@ -121,6 +140,13 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver { |
| MemoryDumpProvider* mdp, |
| scoped_refptr<ProcessMemoryDumpHolder> pmd_holder); |
| + // Pass kInvalidTracingProcessId for invalidating the id. |
| + void set_tracing_process_id(int id) { |
| + DCHECK(tracing_process_id_ == kInvalidTracingProcessId || |
| + id == kInvalidTracingProcessId); |
| + tracing_process_id_ = id; |
| + } |
| + |
| hash_map<MemoryDumpProvider*, MemoryDumpProviderInfo> dump_providers_; |
| // Shared among all the PMDs to keep state scoped to the tracing session. |
| @@ -139,6 +165,10 @@ class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver { |
| // For time-triggered periodic dumps. |
| RepeatingTimer<MemoryDumpManager> periodic_dump_timer_; |
| + // The unique id of the child process. This is created only for tracing and is |
| + // expected to be valid only when tracing is enabled. |
| + int tracing_process_id_; |
| + |
| // Skips the auto-registration of the core dumpers during Initialize(). |
| bool skip_core_dumpers_auto_registration_for_testing_; |
| @@ -165,6 +195,10 @@ class BASE_EXPORT MemoryDumpManagerDelegate { |
| MemoryDumpManager::GetInstance()->CreateProcessDump(args, callback); |
| } |
| + void set_tracing_process_id(int id) { |
| + MemoryDumpManager::GetInstance()->set_tracing_process_id(id); |
| + } |
| + |
| private: |
| DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); |
| }; |