Make USB permissions work in the new permission message system
[chromium-blink-merge.git] / content / browser / profiler_controller_impl.h
blobcf2c10cb656c194e341cc44db362464b18dc2e8e
1 // Copyright (c) 2012 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.
5 #ifndef CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_
6 #define CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_
8 #include "base/memory/singleton.h"
9 #include "base/process/process.h"
10 #include "content/common/content_export.h"
11 #include "content/public/browser/profiler_controller.h"
12 #include "content/public/common/process_type.h"
14 namespace tracked_objects {
15 struct ProcessDataSnapshot;
18 namespace content {
20 // ProfilerController's implementation.
21 class ProfilerControllerImpl : public ProfilerController {
22 public:
23 static ProfilerControllerImpl* GetInstance();
25 // Normally instantiated when the child process is launched. Only one instance
26 // should be created per process.
27 ProfilerControllerImpl();
28 ~ProfilerControllerImpl() override;
30 // Notify the |subscriber_| that it should expect at least |pending_processes|
31 // additional calls to OnProfilerDataCollected(). OnPendingProcess() may be
32 // called repeatedly; the last call will have |end| set to true, indicating
33 // that there is no longer a possibility for the count of pending processes to
34 // increase. This is called on the UI thread.
35 void OnPendingProcesses(int sequence_number, int pending_processes, bool end);
37 // Send the |profiler_data| back to the |subscriber_|.
38 // This can be called from any thread.
39 void OnProfilerDataCollected(
40 int sequence_number,
41 const tracked_objects::ProcessDataSnapshot& profiler_data,
42 content::ProcessType process_type);
44 // ProfilerController implementation:
45 void Register(ProfilerSubscriber* subscriber) override;
46 void Unregister(const ProfilerSubscriber* subscriber) override;
47 void GetProfilerData(int sequence_number,
48 int current_profiling_phase) override;
49 void OnProfilingPhaseCompleted(int profiling_phase) override;
51 private:
52 friend struct DefaultSingletonTraits<ProfilerControllerImpl>;
54 // Contact child processes and get their profiler data.
55 void GetProfilerDataFromChildProcesses(int sequence_number,
56 int current_profiling_phase);
58 // Contact child processes and notify them of a profiling phase completion.
59 static void NotifyChildProcessesOfProfilingPhaseCompletion(
60 int profiling_phase);
62 ProfilerSubscriber* subscriber_;
64 DISALLOW_COPY_AND_ASSIGN(ProfilerControllerImpl);
67 } // namespace content
69 #endif // CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_