| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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" |
| 11 #include "content/public/common/process_type.h" |
| 12 |
| 13 namespace tracked_objects { |
| 14 struct ProcessDataSnapshot; |
| 15 } |
| 12 | 16 |
| 13 namespace content { | 17 namespace content { |
| 14 | 18 |
| 15 // ProfilerController's implementation. | 19 // ProfilerController's implementation. |
| 16 class CONTENT_EXPORT ProfilerControllerImpl : public ProfilerController { | 20 class ProfilerControllerImpl : public ProfilerController { |
| 17 public: | 21 public: |
| 18 static ProfilerControllerImpl* GetInstance(); | 22 static ProfilerControllerImpl* GetInstance(); |
| 19 | 23 |
| 20 // Normally instantiated when the child process is launched. Only one instance | 24 // Normally instantiated when the child process is launched. Only one instance |
| 21 // should be created per process. | 25 // should be created per process. |
| 22 ProfilerControllerImpl(); | 26 ProfilerControllerImpl(); |
| 23 virtual ~ProfilerControllerImpl(); | 27 virtual ~ProfilerControllerImpl(); |
| 24 | 28 |
| 25 // Send number of pending processes to subscriber_. |end| is set to true if it | 29 // Notify the |subscriber_| that it should expect at least |pending_processes| |
| 26 // is the last time. This is called on UI thread. | 30 // additional calls to OnProfilerDataCollected(). OnPendingProcess() may be |
| 31 // called repeatedly; the last call will have |end| set to true, indicating |
| 32 // that there is no longer a possibility for the count of pending processes to |
| 33 // increase. This is called on the UI thread. |
| 27 void OnPendingProcesses(int sequence_number, int pending_processes, bool end); | 34 void OnPendingProcesses(int sequence_number, int pending_processes, bool end); |
| 28 | 35 |
| 29 // Send profiler_data back to subscriber_. subscriber_ assumes the ownership | 36 // Send the |profiler_data| back to the |subscriber_|. |
| 30 // of profiler_data. This is called on UI thread. | 37 // This is called on the UI thread. |
| 31 void OnProfilerDataCollected(int sequence_number, | 38 void OnProfilerDataCollected( |
| 32 base::DictionaryValue* profiler_data); | 39 int sequence_number, |
| 40 const tracked_objects::ProcessDataSnapshot& profiler_data, |
| 41 content::ProcessType process_type); |
| 33 | 42 |
| 34 // ProfilerController implementation: | 43 // ProfilerController implementation: |
| 35 virtual void Register(ProfilerSubscriber* subscriber) OVERRIDE; | 44 virtual void Register(ProfilerSubscriber* subscriber) OVERRIDE; |
| 36 virtual void Unregister(ProfilerSubscriber* subscriber) OVERRIDE; | 45 virtual void Unregister(const ProfilerSubscriber* subscriber) OVERRIDE; |
| 37 virtual void GetProfilerData(int sequence_number) OVERRIDE; | 46 virtual void GetProfilerData(int sequence_number) OVERRIDE; |
| 38 virtual void SetProfilerStatus( | |
| 39 tracked_objects::ThreadData::Status status) OVERRIDE; | |
| 40 | 47 |
| 41 private: | 48 private: |
| 42 friend struct DefaultSingletonTraits<ProfilerControllerImpl>; | 49 friend struct DefaultSingletonTraits<ProfilerControllerImpl>; |
| 43 | 50 |
| 44 // Contact child processes and get their profiler data. | 51 // Contact child processes and get their profiler data. |
| 45 void GetProfilerDataFromChildProcesses(int sequence_number); | 52 void GetProfilerDataFromChildProcesses(int sequence_number); |
| 46 | 53 |
| 47 // Contact child processes and set profiler status to |enable|. | |
| 48 void SetProfilerStatusInChildProcesses( | |
| 49 tracked_objects::ThreadData::Status status); | |
| 50 | |
| 51 ProfilerSubscriber* subscriber_; | 54 ProfilerSubscriber* subscriber_; |
| 52 | 55 |
| 53 DISALLOW_COPY_AND_ASSIGN(ProfilerControllerImpl); | 56 DISALLOW_COPY_AND_ASSIGN(ProfilerControllerImpl); |
| 54 }; | 57 }; |
| 55 | 58 |
| 56 } // namespace content | 59 } // namespace content |
| 57 | 60 |
| 58 #endif // CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_ | 61 #endif // CONTENT_BROWSER_PROFILER_CONTROLLER_IMPL_H_ |
| 59 | |
| OLD | NEW |