OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_PROFILING_HOST_PROFILING_PROCESS_HOST_H_ | |
6 #define CHROME_BROWSER_PROFILING_HOST_PROFILING_PROCESS_HOST_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/process/process.h" | |
10 | |
11 namespace base { | |
12 class CommandLine; | |
13 } | |
14 | |
15 namespace profiling { | |
16 | |
17 // Represents the browser side of the profiling process (//chrome/profiling). | |
18 // | |
19 // The profiling process is a singleton. The profiling process infrastructure | |
20 // is implemented in the Chrome layer so doesn't depend on the content | |
21 // infrastructure for managing child processes. | |
22 // | |
23 // Not thread safe. Should be used on the browser UI thread only. | |
24 // | |
25 // The profing process host can be started normally while Chrome is running, | |
26 // but can also start in a partial mode where the memory logging connections | |
27 // are active but the Mojo control channel has not yet been connected. This is | |
28 // to support starting the profiling process very early in the startup | |
29 // process (to get most memory events) before other infrastructure like the | |
30 // I/O thread has been started. | |
31 class ProfilingProcessHost { | |
32 public: | |
33 // Launches the profiling process if necessary and returns a pointer to it. | |
34 static ProfilingProcessHost* EnsureStarted(); | |
35 | |
36 // Returns a pointer to the current global profiling process host or, if | |
37 // no profiling process is launched, null. | |
awong
2017/06/29 18:39:32
null -> nullptr
| |
38 static ProfilingProcessHost* Get(); | |
39 | |
40 // Appends necessary switches to a command line for a child process. These | |
41 // switches will causse the child process to start in the profiling mode | |
42 // currently active. | |
awong
2017/06/29 18:39:32
"Appends necessary switches to a command line for
| |
43 static void AddSwitchesToChildCmdLine(base::CommandLine* child_cmd_line); | |
44 | |
45 private: | |
46 ProfilingProcessHost(); | |
47 ~ProfilingProcessHost(); | |
48 | |
49 void Launch(); | |
50 | |
51 // Use process_.IsValid() to determine if the child process has been launched. | |
52 base::Process process_; | |
53 std::string pipe_id_; | |
54 | |
55 DISALLOW_COPY_AND_ASSIGN(ProfilingProcessHost); | |
56 }; | |
57 | |
58 } // namespace profiling | |
59 | |
60 #endif // CHROME_BROWSER_PROFILING_HOST_PROFILING_PROCESS_HOST_H_ | |
OLD | NEW |