blob: 1efbafaab7a2b31c8e65b51a5cd3b322c12dc908 [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// 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.
4
5#ifndef CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_
6#define CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_
7
8#include "base/memory/singleton.h"
9#include "base/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"
13
14namespace tracked_objects {
15struct ProcessDataSnapshot;
16}
17
18namespace content {
19
20// ProfilerController's implementation.
21class ProfilerControllerImpl : public ProfilerController {
22 public:
23 static ProfilerControllerImpl* GetInstance();
24
25 // Normally instantiated when the child process is launched. Only one instance
26 // should be created per process.
27 ProfilerControllerImpl();
28 virtual ~ProfilerControllerImpl();
29
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);
36
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,
Torne (Richard Coles)2a99a7e2013-03-28 15:31:22 +000042 int process_type);
Torne (Richard Coles)58218062012-11-14 11:43:16 +000043
44 // ProfilerController implementation:
45 virtual void Register(ProfilerSubscriber* subscriber) OVERRIDE;
46 virtual void Unregister(const ProfilerSubscriber* subscriber) OVERRIDE;
47 virtual void GetProfilerData(int sequence_number) OVERRIDE;
48
49 private:
50 friend struct DefaultSingletonTraits<ProfilerControllerImpl>;
51
52 // Contact child processes and get their profiler data.
53 void GetProfilerDataFromChildProcesses(int sequence_number);
54
55 ProfilerSubscriber* subscriber_;
56
57 DISALLOW_COPY_AND_ASSIGN(ProfilerControllerImpl);
58};
59
60} // namespace content
61
62#endif // CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_