Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: content/browser/trace_message_filter.cc

Issue 10837082: implement SetWatchEvent and WaitForEvent for trace-based-tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update / merge -- no change Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/trace_message_filter.h ('k') | content/common/child_process_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
(...skipping 29 matching lines...) Expand all
40 bool TraceMessageFilter::OnMessageReceived(const IPC::Message& message, 40 bool TraceMessageFilter::OnMessageReceived(const IPC::Message& message,
41 bool* message_was_ok) { 41 bool* message_was_ok) {
42 // Always on IO thread (BrowserMessageFilter guarantee). 42 // Always on IO thread (BrowserMessageFilter guarantee).
43 bool handled = true; 43 bool handled = true;
44 IPC_BEGIN_MESSAGE_MAP_EX(TraceMessageFilter, message, *message_was_ok) 44 IPC_BEGIN_MESSAGE_MAP_EX(TraceMessageFilter, message, *message_was_ok)
45 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ChildSupportsTracing, 45 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ChildSupportsTracing,
46 OnChildSupportsTracing) 46 OnChildSupportsTracing)
47 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_EndTracingAck, OnEndTracingAck) 47 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_EndTracingAck, OnEndTracingAck)
48 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_TraceDataCollected, 48 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_TraceDataCollected,
49 OnTraceDataCollected) 49 OnTraceDataCollected)
50 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_TraceBufferFull, 50 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_TraceNotification,
51 OnTraceBufferFull) 51 OnTraceNotification)
52 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_TraceBufferPercentFullReply, 52 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_TraceBufferPercentFullReply,
53 OnTraceBufferPercentFullReply) 53 OnTraceBufferPercentFullReply)
54 IPC_MESSAGE_UNHANDLED(handled = false) 54 IPC_MESSAGE_UNHANDLED(handled = false)
55 IPC_END_MESSAGE_MAP_EX() 55 IPC_END_MESSAGE_MAP_EX()
56 return handled; 56 return handled;
57 } 57 }
58 58
59 void TraceMessageFilter::SendBeginTracing( 59 void TraceMessageFilter::SendBeginTracing(
60 const std::vector<std::string>& included_categories, 60 const std::vector<std::string>& included_categories,
61 const std::vector<std::string>& excluded_categories) { 61 const std::vector<std::string>& excluded_categories) {
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
63 Send(new ChildProcessMsg_BeginTracing(included_categories, 63 Send(new ChildProcessMsg_BeginTracing(included_categories,
64 excluded_categories)); 64 excluded_categories));
65 } 65 }
66 66
67 void TraceMessageFilter::SendEndTracing() { 67 void TraceMessageFilter::SendEndTracing() {
68 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 68 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
69 DCHECK(!is_awaiting_end_ack_); 69 DCHECK(!is_awaiting_end_ack_);
70 is_awaiting_end_ack_ = true; 70 is_awaiting_end_ack_ = true;
71 Send(new ChildProcessMsg_EndTracing); 71 Send(new ChildProcessMsg_EndTracing);
72 } 72 }
73 73
74 void TraceMessageFilter::SendGetTraceBufferPercentFull() { 74 void TraceMessageFilter::SendGetTraceBufferPercentFull() {
75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
76 DCHECK(!is_awaiting_buffer_percent_full_ack_); 76 DCHECK(!is_awaiting_buffer_percent_full_ack_);
77 is_awaiting_buffer_percent_full_ack_ = true; 77 is_awaiting_buffer_percent_full_ack_ = true;
78 Send(new ChildProcessMsg_GetTraceBufferPercentFull); 78 Send(new ChildProcessMsg_GetTraceBufferPercentFull);
79 } 79 }
80 80
81 void TraceMessageFilter::SendSetWatchEvent(const std::string& category_name,
82 const std::string& event_name) {
83 Send(new ChildProcessMsg_SetWatchEvent(category_name, event_name));
84 }
85
86 void TraceMessageFilter::SendCancelWatchEvent() {
87 Send(new ChildProcessMsg_CancelWatchEvent);
88 }
89
81 TraceMessageFilter::~TraceMessageFilter() {} 90 TraceMessageFilter::~TraceMessageFilter() {}
82 91
83 void TraceMessageFilter::OnChildSupportsTracing() { 92 void TraceMessageFilter::OnChildSupportsTracing() {
84 has_child_ = true; 93 has_child_ = true;
85 TraceControllerImpl::GetInstance()->AddFilter(this); 94 TraceControllerImpl::GetInstance()->AddFilter(this);
86 } 95 }
87 96
88 void TraceMessageFilter::OnEndTracingAck( 97 void TraceMessageFilter::OnEndTracingAck(
89 const std::vector<std::string>& known_categories) { 98 const std::vector<std::string>& known_categories) {
90 // is_awaiting_end_ack_ should always be true here, but check in case the 99 // is_awaiting_end_ack_ should always be true here, but check in case the
91 // child process is compromised. 100 // child process is compromised.
92 if (is_awaiting_end_ack_) { 101 if (is_awaiting_end_ack_) {
93 is_awaiting_end_ack_ = false; 102 is_awaiting_end_ack_ = false;
94 TraceControllerImpl::GetInstance()->OnEndTracingAck(known_categories); 103 TraceControllerImpl::GetInstance()->OnEndTracingAck(known_categories);
95 } else { 104 } else {
96 NOTREACHED(); 105 NOTREACHED();
97 } 106 }
98 } 107 }
99 108
100 void TraceMessageFilter::OnTraceDataCollected(const std::string& data) { 109 void TraceMessageFilter::OnTraceDataCollected(const std::string& data) {
101 scoped_refptr<base::RefCountedString> data_ptr(new base::RefCountedString()); 110 scoped_refptr<base::RefCountedString> data_ptr(new base::RefCountedString());
102 data_ptr->data() = data; 111 data_ptr->data() = data;
103 TraceControllerImpl::GetInstance()->OnTraceDataCollected(data_ptr); 112 TraceControllerImpl::GetInstance()->OnTraceDataCollected(data_ptr);
104 } 113 }
105 114
106 void TraceMessageFilter::OnTraceBufferFull() { 115 void TraceMessageFilter::OnTraceNotification(int notification) {
107 TraceControllerImpl::GetInstance()->OnTraceBufferFull(); 116 TraceControllerImpl::GetInstance()->OnTraceNotification(notification);
108 } 117 }
109 118
110 void TraceMessageFilter::OnTraceBufferPercentFullReply(float percent_full) { 119 void TraceMessageFilter::OnTraceBufferPercentFullReply(float percent_full) {
111 if (is_awaiting_buffer_percent_full_ack_) { 120 if (is_awaiting_buffer_percent_full_ack_) {
112 is_awaiting_buffer_percent_full_ack_ = false; 121 is_awaiting_buffer_percent_full_ack_ = false;
113 TraceControllerImpl::GetInstance()->OnTraceBufferPercentFullReply( 122 TraceControllerImpl::GetInstance()->OnTraceBufferPercentFullReply(
114 percent_full); 123 percent_full);
115 } else { 124 } else {
116 NOTREACHED(); 125 NOTREACHED();
117 } 126 }
118 } 127 }
119 128
OLDNEW
« no previous file with comments | « content/browser/trace_message_filter.h ('k') | content/common/child_process_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698