blob: 3248d9293eb613bbcb0a0b37d8554b7c8c6a88e1 [file] [log] [blame]
[email protected]702a12d2012-02-10 19:43:421// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]33047f12011-12-01 23:20:202// 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
avib7348942015-12-25 20:57:108#include "base/macros.h"
[email protected]33047f12011-12-01 23:20:209#include "base/memory/singleton.h"
[email protected]fa20e002013-07-23 21:20:5410#include "base/process/process.h"
[email protected]33047f12011-12-01 23:20:2011#include "content/common/content_export.h"
12#include "content/public/browser/profiler_controller.h"
[email protected]1cb05db2012-04-13 00:39:2613#include "content/public/common/process_type.h"
14
15namespace tracked_objects {
16struct ProcessDataSnapshot;
17}
[email protected]33047f12011-12-01 23:20:2018
19namespace content {
20
21// ProfilerController's implementation.
[email protected]1cb05db2012-04-13 00:39:2622class ProfilerControllerImpl : public ProfilerController {
[email protected]33047f12011-12-01 23:20:2023 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();
dchengc2282aa2014-10-21 12:07:5829 ~ProfilerControllerImpl() override;
[email protected]33047f12011-12-01 23:20:2030
[email protected]1cb05db2012-04-13 00:39:2631 // 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]33047f12011-12-01 23:20:2036 void OnPendingProcesses(int sequence_number, int pending_processes, bool end);
37
[email protected]1cb05db2012-04-13 00:39:2638 // Send the |profiler_data| back to the |subscriber_|.
[email protected]3d662c32012-04-25 00:05:1739 // This can be called from any thread.
[email protected]1cb05db2012-04-13 00:39:2640 void OnProfilerDataCollected(
41 int sequence_number,
42 const tracked_objects::ProcessDataSnapshot& profiler_data,
vadimt379d7fe2015-04-01 00:09:3543 content::ProcessType process_type);
[email protected]33047f12011-12-01 23:20:2044
45 // ProfilerController implementation:
dchengc2282aa2014-10-21 12:07:5846 void Register(ProfilerSubscriber* subscriber) override;
47 void Unregister(const ProfilerSubscriber* subscriber) override;
vadimte2de4732015-04-27 21:43:0248 void GetProfilerData(int sequence_number,
49 int current_profiling_phase) override;
50 void OnProfilingPhaseCompleted(int profiling_phase) override;
[email protected]33047f12011-12-01 23:20:2051
52 private:
olli.raula36aa8be2015-09-10 11:14:2253 friend struct base::DefaultSingletonTraits<ProfilerControllerImpl>;
[email protected]33047f12011-12-01 23:20:2054
55 // Contact child processes and get their profiler data.
vadimte2de4732015-04-27 21:43:0256 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]33047f12011-12-01 23:20:2062
[email protected]33047f12011-12-01 23:20:2063 ProfilerSubscriber* subscriber_;
64
65 DISALLOW_COPY_AND_ASSIGN(ProfilerControllerImpl);
66};
67
68} // namespace content
69
70#endif // CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_