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 COMPONENTS_TRACING_CHILD_CHILD_TRACE_MESSAGE_FILTER_H_ | 5 #ifndef COMPONENTS_TRACING_CHILD_CHILD_TRACE_MESSAGE_FILTER_H_ |
6 #define COMPONENTS_TRACING_CHILD_CHILD_TRACE_MESSAGE_FILTER_H_ | 6 #define COMPONENTS_TRACING_CHILD_CHILD_TRACE_MESSAGE_FILTER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "base/trace_event/memory_dump_request_args.h" | |
16 #include "components/tracing/tracing_export.h" | 15 #include "components/tracing/tracing_export.h" |
17 #include "ipc/message_filter.h" | 16 #include "ipc/message_filter.h" |
18 | 17 |
19 namespace base { | 18 namespace base { |
20 class SingleThreadTaskRunner; | 19 class SingleThreadTaskRunner; |
21 } | 20 } |
22 | 21 |
23 namespace tracing { | 22 namespace tracing { |
24 | 23 |
25 // This class sends and receives trace messages on child processes. | 24 // This class sends and receives trace messages on child processes. |
26 class TRACING_EXPORT ChildTraceMessageFilter : public IPC::MessageFilter { | 25 class TRACING_EXPORT ChildTraceMessageFilter : public IPC::MessageFilter { |
27 public: | 26 public: |
28 explicit ChildTraceMessageFilter( | 27 explicit ChildTraceMessageFilter( |
29 base::SingleThreadTaskRunner* ipc_task_runner); | 28 base::SingleThreadTaskRunner* ipc_task_runner); |
30 | 29 |
31 // IPC::MessageFilter implementation. | 30 // IPC::MessageFilter implementation. |
32 void OnFilterAdded(IPC::Channel* channel) override; | 31 void OnFilterAdded(IPC::Channel* channel) override; |
33 void OnFilterRemoved() override; | 32 void OnFilterRemoved() override; |
34 bool OnMessageReceived(const IPC::Message& message) override; | 33 bool OnMessageReceived(const IPC::Message& message) override; |
35 | 34 |
36 void SendGlobalMemoryDumpRequest( | |
37 const base::trace_event::MemoryDumpRequestArgs& args, | |
38 const base::trace_event::MemoryDumpCallback& callback); | |
39 | |
40 base::SingleThreadTaskRunner* ipc_task_runner() const { | 35 base::SingleThreadTaskRunner* ipc_task_runner() const { |
41 return ipc_task_runner_; | 36 return ipc_task_runner_; |
42 } | 37 } |
43 | 38 |
44 protected: | 39 protected: |
45 ~ChildTraceMessageFilter() override; | 40 ~ChildTraceMessageFilter() override; |
46 | 41 |
47 private: | 42 private: |
48 friend class ChildTraceMessageFilterTest; | 43 friend class ChildTraceMessageFilterTest; |
49 | 44 |
50 // Message handlers. | 45 // Message handlers. |
51 void OnBeginTracing(const std::string& trace_config_str, | 46 void OnBeginTracing(const std::string& trace_config_str, |
52 base::TimeTicks browser_time, | 47 base::TimeTicks browser_time, |
53 uint64_t tracing_process_id); | 48 uint64_t tracing_process_id); |
54 void OnEndTracing(); | 49 void OnEndTracing(); |
55 void OnCancelTracing(); | 50 void OnCancelTracing(); |
56 void OnGetTraceLogStatus(); | 51 void OnGetTraceLogStatus(); |
57 void OnSetWatchEvent(const std::string& category_name, | 52 void OnSetWatchEvent(const std::string& category_name, |
58 const std::string& event_name); | 53 const std::string& event_name); |
59 void OnCancelWatchEvent(); | 54 void OnCancelWatchEvent(); |
60 void OnWatchEventMatched(); | 55 void OnWatchEventMatched(); |
61 void OnProcessMemoryDumpRequest( | |
62 const base::trace_event::MemoryDumpRequestArgs& args); | |
63 void OnGlobalMemoryDumpResponse(uint64_t dump_guid, bool success); | |
64 void OnSetUMACallback(const std::string& histogram_name, | 56 void OnSetUMACallback(const std::string& histogram_name, |
65 int histogram_lower_value, | 57 int histogram_lower_value, |
66 int histogram_upper_value, | 58 int histogram_upper_value, |
67 bool repeat); | 59 bool repeat); |
68 void OnClearUMACallback(const std::string& histogram_name); | 60 void OnClearUMACallback(const std::string& histogram_name); |
69 void OnHistogramChanged(const std::string& histogram_name, | 61 void OnHistogramChanged(const std::string& histogram_name, |
70 base::Histogram::Sample reference_lower_value, | 62 base::Histogram::Sample reference_lower_value, |
71 base::Histogram::Sample reference_upper_value, | 63 base::Histogram::Sample reference_upper_value, |
72 bool repeat, | 64 bool repeat, |
73 base::Histogram::Sample actual_value); | 65 base::Histogram::Sample actual_value); |
74 void SendTriggerMessage(const std::string& histogram_name); | 66 void SendTriggerMessage(const std::string& histogram_name); |
75 void SendAbortBackgroundTracingMessage(); | 67 void SendAbortBackgroundTracingMessage(); |
76 | 68 |
77 // Callback from trace subsystem. | 69 // Callback from trace subsystem. |
78 void OnTraceDataCollected( | 70 void OnTraceDataCollected( |
79 const scoped_refptr<base::RefCountedString>& events_str_ptr, | 71 const scoped_refptr<base::RefCountedString>& events_str_ptr, |
80 bool has_more_events); | 72 bool has_more_events); |
81 | 73 |
82 void OnProcessMemoryDumpDone(uint64_t dump_guid, bool success); | |
83 | |
84 void SetSenderForTesting(IPC::Sender* sender); | 74 void SetSenderForTesting(IPC::Sender* sender); |
85 | 75 |
86 IPC::Sender* sender_; | 76 IPC::Sender* sender_; |
87 base::SingleThreadTaskRunner* ipc_task_runner_; | 77 base::SingleThreadTaskRunner* ipc_task_runner_; |
88 | 78 |
89 // guid of the outstanding request (to the Browser's MemoryDumpManager), if | |
90 // any. 0 if there is no request pending. | |
91 uint64_t pending_memory_dump_guid_; | |
92 | |
93 // callback of the outstanding memory dump request, if any. | |
94 base::trace_event::MemoryDumpCallback pending_memory_dump_callback_; | |
95 | |
96 base::Time histogram_last_changed_; | 79 base::Time histogram_last_changed_; |
97 | 80 |
98 DISALLOW_COPY_AND_ASSIGN(ChildTraceMessageFilter); | 81 DISALLOW_COPY_AND_ASSIGN(ChildTraceMessageFilter); |
99 }; | 82 }; |
100 | 83 |
101 } // namespace tracing | 84 } // namespace tracing |
102 | 85 |
103 #endif // COMPONENTS_TRACING_CHILD_CHILD_TRACE_MESSAGE_FILTER_H_ | 86 #endif // COMPONENTS_TRACING_CHILD_CHILD_TRACE_MESSAGE_FILTER_H_ |
OLD | NEW |