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 #include "content/browser/trace_message_filter.h" | 5 #include "content/browser/trace_message_filter.h" |
6 | 6 |
7 #include "content/browser/trace_controller_impl.h" | 7 #include "content/browser/trace_controller_impl.h" |
8 #include "content/common/child_process_messages.h" | 8 #include "content/common/child_process_messages.h" |
9 | 9 |
10 using content::BrowserMessageFilter; | 10 using content::BrowserMessageFilter; |
11 using content::BrowserThread; | 11 using content::BrowserThread; |
12 using content::TraceControllerImpl; | 12 using content::TraceControllerImpl; |
13 | 13 |
14 TraceMessageFilter::TraceMessageFilter() : | 14 TraceMessageFilter::TraceMessageFilter() : |
15 has_child_(false), | 15 has_child_(false), |
16 is_awaiting_end_ack_(false), | 16 is_awaiting_end_ack_(false), |
17 is_awaiting_bpf_ack_(false) { | 17 is_awaiting_bpf_ack_(false) { |
18 } | 18 } |
19 | 19 |
20 TraceMessageFilter::~TraceMessageFilter() { | |
21 } | |
22 | |
23 void TraceMessageFilter::OnFilterAdded(IPC::Channel* channel) { | 20 void TraceMessageFilter::OnFilterAdded(IPC::Channel* channel) { |
24 // Always on IO thread (BrowserMessageFilter guarantee). | 21 // Always on IO thread (BrowserMessageFilter guarantee). |
25 BrowserMessageFilter::OnFilterAdded(channel); | 22 BrowserMessageFilter::OnFilterAdded(channel); |
26 } | 23 } |
27 | 24 |
28 void TraceMessageFilter::OnChannelClosing() { | 25 void TraceMessageFilter::OnChannelClosing() { |
29 // Always on IO thread (BrowserMessageFilter guarantee). | 26 // Always on IO thread (BrowserMessageFilter guarantee). |
30 BrowserMessageFilter::OnChannelClosing(); | 27 BrowserMessageFilter::OnChannelClosing(); |
31 | 28 |
32 if (has_child_) { | 29 if (has_child_) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 Send(new ChildProcessMsg_EndTracing); | 71 Send(new ChildProcessMsg_EndTracing); |
75 } | 72 } |
76 | 73 |
77 void TraceMessageFilter::SendGetTraceBufferPercentFull() { | 74 void TraceMessageFilter::SendGetTraceBufferPercentFull() { |
78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
79 DCHECK(!is_awaiting_bpf_ack_); | 76 DCHECK(!is_awaiting_bpf_ack_); |
80 is_awaiting_bpf_ack_ = true; | 77 is_awaiting_bpf_ack_ = true; |
81 Send(new ChildProcessMsg_GetTraceBufferPercentFull); | 78 Send(new ChildProcessMsg_GetTraceBufferPercentFull); |
82 } | 79 } |
83 | 80 |
| 81 TraceMessageFilter::~TraceMessageFilter() {} |
| 82 |
84 void TraceMessageFilter::OnChildSupportsTracing() { | 83 void TraceMessageFilter::OnChildSupportsTracing() { |
85 has_child_ = true; | 84 has_child_ = true; |
86 TraceControllerImpl::GetInstance()->AddFilter(this); | 85 TraceControllerImpl::GetInstance()->AddFilter(this); |
87 } | 86 } |
88 | 87 |
89 void TraceMessageFilter::OnEndTracingAck( | 88 void TraceMessageFilter::OnEndTracingAck( |
90 const std::vector<std::string>& known_categories) { | 89 const std::vector<std::string>& known_categories) { |
91 // is_awaiting_end_ack_ should always be true here, but check in case the | 90 // is_awaiting_end_ack_ should always be true here, but check in case the |
92 // child process is compromised. | 91 // child process is compromised. |
93 if (is_awaiting_end_ack_) { | 92 if (is_awaiting_end_ack_) { |
(...skipping 13 matching lines...) Expand all Loading... |
107 } | 106 } |
108 | 107 |
109 void TraceMessageFilter::OnTraceBufferPercentFullReply(float percent_full) { | 108 void TraceMessageFilter::OnTraceBufferPercentFullReply(float percent_full) { |
110 if (is_awaiting_bpf_ack_) { | 109 if (is_awaiting_bpf_ack_) { |
111 is_awaiting_bpf_ack_ = false; | 110 is_awaiting_bpf_ack_ = false; |
112 TraceControllerImpl::GetInstance()->OnTraceBufferPercentFullReply( | 111 TraceControllerImpl::GetInstance()->OnTraceBufferPercentFullReply( |
113 percent_full); | 112 percent_full); |
114 } | 113 } |
115 } | 114 } |
116 | 115 |
OLD | NEW |