[email protected] | 702a12d | 2012-02-10 19:43:42 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 33047f1 | 2011-12-01 23:20:20 | [diff] [blame] | 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 CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_ | ||||
6 | #define CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_ | ||||
7 | |||||
avi | b734894 | 2015-12-25 20:57:10 | [diff] [blame] | 8 | #include "base/macros.h" |
[email protected] | 33047f1 | 2011-12-01 23:20:20 | [diff] [blame] | 9 | #include "base/memory/singleton.h" |
[email protected] | fa20e00 | 2013-07-23 21:20:54 | [diff] [blame] | 10 | #include "base/process/process.h" |
[email protected] | 33047f1 | 2011-12-01 23:20:20 | [diff] [blame] | 11 | #include "content/common/content_export.h" |
12 | #include "content/public/browser/profiler_controller.h" | ||||
[email protected] | 1cb05db | 2012-04-13 00:39:26 | [diff] [blame] | 13 | #include "content/public/common/process_type.h" |
14 | |||||
15 | namespace tracked_objects { | ||||
16 | struct ProcessDataSnapshot; | ||||
17 | } | ||||
[email protected] | 33047f1 | 2011-12-01 23:20:20 | [diff] [blame] | 18 | |
19 | namespace content { | ||||
20 | |||||
21 | // ProfilerController's implementation. | ||||
[email protected] | 1cb05db | 2012-04-13 00:39:26 | [diff] [blame] | 22 | class ProfilerControllerImpl : public ProfilerController { |
[email protected] | 33047f1 | 2011-12-01 23:20:20 | [diff] [blame] | 23 | public: |
24 | static ProfilerControllerImpl* GetInstance(); | ||||
25 | |||||
26 | // Normally instantiated when the child process is launched. Only one instance | ||||
27 | // should be created per process. | ||||
28 | ProfilerControllerImpl(); | ||||
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 29 | ~ProfilerControllerImpl() override; |
[email protected] | 33047f1 | 2011-12-01 23:20:20 | [diff] [blame] | 30 | |
[email protected] | 1cb05db | 2012-04-13 00:39:26 | [diff] [blame] | 31 | // Notify the |subscriber_| that it should expect at least |pending_processes| |
32 | // additional calls to OnProfilerDataCollected(). OnPendingProcess() may be | ||||
33 | // called repeatedly; the last call will have |end| set to true, indicating | ||||
34 | // that there is no longer a possibility for the count of pending processes to | ||||
35 | // increase. This is called on the UI thread. | ||||
[email protected] | 33047f1 | 2011-12-01 23:20:20 | [diff] [blame] | 36 | void OnPendingProcesses(int sequence_number, int pending_processes, bool end); |
37 | |||||
[email protected] | 1cb05db | 2012-04-13 00:39:26 | [diff] [blame] | 38 | // Send the |profiler_data| back to the |subscriber_|. |
[email protected] | 3d662c3 | 2012-04-25 00:05:17 | [diff] [blame] | 39 | // This can be called from any thread. |
[email protected] | 1cb05db | 2012-04-13 00:39:26 | [diff] [blame] | 40 | void OnProfilerDataCollected( |
41 | int sequence_number, | ||||
42 | const tracked_objects::ProcessDataSnapshot& profiler_data, | ||||
vadimt | 379d7fe | 2015-04-01 00:09:35 | [diff] [blame] | 43 | content::ProcessType process_type); |
[email protected] | 33047f1 | 2011-12-01 23:20:20 | [diff] [blame] | 44 | |
45 | // ProfilerController implementation: | ||||
dcheng | c2282aa | 2014-10-21 12:07:58 | [diff] [blame] | 46 | void Register(ProfilerSubscriber* subscriber) override; |
47 | void Unregister(const ProfilerSubscriber* subscriber) override; | ||||
vadimt | e2de473 | 2015-04-27 21:43:02 | [diff] [blame] | 48 | void GetProfilerData(int sequence_number, |
49 | int current_profiling_phase) override; | ||||
50 | void OnProfilingPhaseCompleted(int profiling_phase) override; | ||||
[email protected] | 33047f1 | 2011-12-01 23:20:20 | [diff] [blame] | 51 | |
52 | private: | ||||
olli.raula | 36aa8be | 2015-09-10 11:14:22 | [diff] [blame] | 53 | friend struct base::DefaultSingletonTraits<ProfilerControllerImpl>; |
[email protected] | 33047f1 | 2011-12-01 23:20:20 | [diff] [blame] | 54 | |
55 | // Contact child processes and get their profiler data. | ||||
vadimt | e2de473 | 2015-04-27 21:43:02 | [diff] [blame] | 56 | void GetProfilerDataFromChildProcesses(int sequence_number, |
57 | int current_profiling_phase); | ||||
58 | |||||
59 | // Contact child processes and notify them of a profiling phase completion. | ||||
60 | static void NotifyChildProcessesOfProfilingPhaseCompletion( | ||||
61 | int profiling_phase); | ||||
[email protected] | 33047f1 | 2011-12-01 23:20:20 | [diff] [blame] | 62 | |
[email protected] | 33047f1 | 2011-12-01 23:20:20 | [diff] [blame] | 63 | ProfilerSubscriber* subscriber_; |
64 | |||||
65 | DISALLOW_COPY_AND_ASSIGN(ProfilerControllerImpl); | ||||
66 | }; | ||||
67 | |||||
68 | } // namespace content | ||||
69 | |||||
70 | #endif // CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_ |