|
OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_PROFILER_CONTROLLER_H_ | |
6 #define CONTENT_BROWSER_PROFILER_CONTROLLER_H_ | |
7 | |
8 #include <set> | |
9 #include <string> | |
10 | |
11 #include "base/memory/singleton.h" | |
12 #include "base/process.h" | |
13 #include "content/common/child_process_info.h" | |
14 #include "content/common/content_export.h" | |
15 | |
16 class ProfilerMessageFilter; | |
17 | |
18 // Objects interested in receiving profiler data derive from ProfilerSubscriber. | |
19 // See also: profiler_message_filter.h | |
20 // See also: child_profiler_message_filter.h | |
21 class CONTENT_EXPORT ProfilerSubscriber { | |
jam
2011/11/19 23:36:25
nit: please put this in a separate file
ramant (doing other things)
2011/11/25 23:59:48
Done.
| |
22 public: | |
23 virtual void OnBrowserChildProfilerDataCollected( | |
24 int sequence_number, | |
25 const std::string& profiler_data) = 0; | |
26 | |
27 virtual void OnIsProfilerEnabledForChildProcess( | |
28 base::ProcessId child_process_id) = 0; | |
29 | |
30 protected: | |
31 virtual ~ProfilerSubscriber(); | |
32 }; | |
33 | |
34 // ProfilerController is used on the browser processes to collect profiler data. | |
jam
2011/11/19 23:36:25
nit: process not processes, since there's only one
ramant (doing other things)
2011/11/25 23:59:48
Done.
| |
35 // Only the browser UI thread is allowed to interact with the ProfilerController | |
36 // object. All calls on the ProfilerSubscriber happen on the UI thread. | |
37 class CONTENT_EXPORT ProfilerController { | |
jam
2011/11/19 23:36:25
for this and above, since we're currently working
ramant (doing other things)
2011/11/25 23:59:48
Done.
| |
38 public: | |
39 static ProfilerController* GetInstance(); | |
40 | |
41 // Register the subscriber so that it will be called when | |
42 // for example OnProfilerDataCollected is returning profiler data from a child | |
43 // process. | |
44 void RegisterSubscriber(ProfilerSubscriber* subscriber); | |
45 | |
46 // Cancel the subscriber so that it will not be called when | |
47 // for example OnProfilerDataCollected is returning profiler data from a child | |
48 // processes. Safe to call even if caller is not the current subscriber. | |
49 void CancelSubscriber(ProfilerSubscriber* subscriber); | |
jam
2011/11/19 23:36:25
nit: the convention is register/unregister
ramant (doing other things)
2011/11/25 23:59:48
Done.
| |
50 | |
51 private: | |
52 friend struct DefaultSingletonTraits<ProfilerController>; | |
53 friend class ProfilerMessageFilter; | |
54 | |
55 ProfilerController(); | |
56 ~ProfilerController(); | |
57 | |
58 void OnProfilerDataCollected(int sequence_number, | |
59 const std::string& profiler_data); | |
60 | |
61 void OnIsProfilerEnabled(base::ProcessId child_process_id); | |
62 | |
63 ProfilerSubscriber* subscriber_; | |
64 | |
65 DISALLOW_COPY_AND_ASSIGN(ProfilerController); | |
66 }; | |
67 | |
68 #endif // CONTENT_BROWSER_PROFILER_CONTROLLER_H_ | |
69 | |
OLD | NEW |