OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_ |
6 #define CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_ | 6 #define CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_ |
7 | 7 |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/tracked_objects.h" | |
10 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
11 #include "content/public/browser/profiler_controller.h" | 10 #include "content/public/browser/profiler_controller.h" |
12 | 11 |
13 namespace content { | 12 namespace content { |
14 | 13 |
15 // ProfilerController's implementation. | 14 // ProfilerController's implementation. |
16 class CONTENT_EXPORT ProfilerControllerImpl : public ProfilerController { | 15 class CONTENT_EXPORT ProfilerControllerImpl : public ProfilerController { |
17 public: | 16 public: |
18 static ProfilerControllerImpl* GetInstance(); | 17 static ProfilerControllerImpl* GetInstance(); |
19 | 18 |
20 // Normally instantiated when the child process is launched. Only one instance | 19 // Normally instantiated when the child process is launched. Only one instance |
21 // should be created per process. | 20 // should be created per process. |
22 ProfilerControllerImpl(); | 21 ProfilerControllerImpl(); |
23 virtual ~ProfilerControllerImpl(); | 22 virtual ~ProfilerControllerImpl(); |
24 | 23 |
25 // Send number of pending processes to subscriber_. |end| is set to true if it | 24 // Send number of pending processes to subscriber_. |end| is set to true if it |
26 // is the last time. This is called on UI thread. | 25 // is the last time. This is called on UI thread. |
27 void OnPendingProcesses(int sequence_number, int pending_processes, bool end); | 26 void OnPendingProcesses(int sequence_number, int pending_processes, bool end); |
28 | 27 |
29 // Send profiler_data back to subscriber_. subscriber_ assumes the ownership | 28 // Send profiler_data back to subscriber_. subscriber_ assumes the ownership |
30 // of profiler_data. This is called on UI thread. | 29 // of profiler_data. This is called on UI thread. |
31 void OnProfilerDataCollected(int sequence_number, | 30 void OnProfilerDataCollected(int sequence_number, |
32 base::DictionaryValue* profiler_data); | 31 base::DictionaryValue* profiler_data); |
33 | 32 |
34 // ProfilerController implementation: | 33 // ProfilerController implementation: |
35 virtual void Register(ProfilerSubscriber* subscriber) OVERRIDE; | 34 virtual void Register(ProfilerSubscriber* subscriber) OVERRIDE; |
36 virtual void Unregister(ProfilerSubscriber* subscriber) OVERRIDE; | 35 virtual void Unregister(ProfilerSubscriber* subscriber) OVERRIDE; |
37 virtual void GetProfilerData(int sequence_number) OVERRIDE; | 36 virtual void GetProfilerData(int sequence_number) OVERRIDE; |
38 virtual void SetProfilerStatus( | 37 virtual void SetProfilerStatus(bool enable) OVERRIDE; |
39 tracked_objects::ThreadData::Status status) OVERRIDE; | |
40 | 38 |
41 private: | 39 private: |
42 friend struct DefaultSingletonTraits<ProfilerControllerImpl>; | 40 friend struct DefaultSingletonTraits<ProfilerControllerImpl>; |
43 | 41 |
44 // Contact child processes and get their profiler data. | 42 // Contact child processes and get their profiler data. |
45 void GetProfilerDataFromChildProcesses(int sequence_number); | 43 void GetProfilerDataFromChildProcesses(int sequence_number); |
46 | 44 |
47 // Contact child processes and set profiler status to |enable|. | 45 // Contact child processes and set profiler status to |enable|. |
48 void SetProfilerStatusInChildProcesses( | 46 void SetProfilerStatusInChildProcesses(bool enable); |
49 tracked_objects::ThreadData::Status status); | |
50 | 47 |
51 ProfilerSubscriber* subscriber_; | 48 ProfilerSubscriber* subscriber_; |
52 | 49 |
53 DISALLOW_COPY_AND_ASSIGN(ProfilerControllerImpl); | 50 DISALLOW_COPY_AND_ASSIGN(ProfilerControllerImpl); |
54 }; | 51 }; |
55 | 52 |
56 } // namespace content | 53 } // namespace content |
57 | 54 |
58 #endif // CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_ | 55 #endif // CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_ |
59 | 56 |
OLD | NEW |