trace_message_filter.h revision 4e180b6a0b4720a9b8e9e959a882386f690f08ff
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 3// found in the LICENSE file. 4 5#ifndef CONTENT_BROWSER_TRACING_TRACE_MESSAGE_FILTER_H_ 6#define CONTENT_BROWSER_TRACING_TRACE_MESSAGE_FILTER_H_ 7 8#include <string> 9#include <vector> 10 11#include "base/debug/trace_event.h" 12#include "content/public/browser/browser_message_filter.h" 13 14namespace content { 15 16// This class sends and receives trace messages on the browser process. 17// See also: tracing_controller.h 18// See also: child_trace_message_filter.h 19class TraceMessageFilter : public BrowserMessageFilter { 20 public: 21 TraceMessageFilter(); 22 23 // BrowserMessageFilter implementation. 24 virtual void OnChannelClosing() OVERRIDE; 25 virtual bool OnMessageReceived(const IPC::Message& message, 26 bool* message_was_ok) OVERRIDE; 27 28 void SendBeginTracing(const std::string& category_filter_str, 29 base::debug::TraceLog::Options options); 30 void SendEndTracing(); 31 void SendEnableMonitoring(const std::string& category_filter_str, 32 base::debug::TraceLog::Options options); 33 void SendDisableMonitoring(); 34 void SendCaptureMonitoringSnapshot(); 35 void SendGetTraceBufferPercentFull(); 36 void SendSetWatchEvent(const std::string& category_name, 37 const std::string& event_name); 38 void SendCancelWatchEvent(); 39 40 protected: 41 virtual ~TraceMessageFilter(); 42 43 private: 44 // Message handlers. 45 void OnChildSupportsTracing(); 46 void OnEndTracingAck(const std::vector<std::string>& known_categories); 47 void OnCaptureMonitoringSnapshotAcked(); 48 void OnTraceNotification(int notification); 49 void OnTraceBufferPercentFullReply(float percent_full); 50 void OnTraceDataCollected(const std::string& data); 51 void OnMonitoringTraceDataCollected(const std::string& data); 52 53 // ChildTraceMessageFilter exists: 54 bool has_child_; 55 56 // Awaiting ack for previously sent SendEndTracing 57 bool is_awaiting_end_ack_; 58 // Awaiting ack for previously sent SendCaptureMonitoringSnapshot 59 bool is_awaiting_capture_monitoring_snapshot_ack_; 60 // Awaiting ack for previously sent SendGetTraceBufferPercentFull 61 bool is_awaiting_buffer_percent_full_ack_; 62 63 DISALLOW_COPY_AND_ASSIGN(TraceMessageFilter); 64}; 65 66} // namespace content 67 68#endif // CONTENT_BROWSER_TRACING_TRACE_MESSAGE_FILTER_H_ 69