summaryrefslogtreecommitdiffstats
path: root/components/tracing/child_trace_message_filter.h
blob: e4802ba9fff94b73206ec14d2cdd7289c3407e0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_TRACING_CHILD_TRACE_MESSAGE_FILTER_H_
#define COMPONENTS_TRACING_CHILD_TRACE_MESSAGE_FILTER_H_

#include "ipc/ipc_channel_proxy.h"

namespace base {
class MessageLoopProxy;
}

namespace components {

// This class sends and receives trace messages on child processes.
class ChildTraceMessageFilter : public IPC::ChannelProxy::MessageFilter {
 public:
  explicit ChildTraceMessageFilter(base::MessageLoopProxy* ipc_message_loop);

  // IPC::ChannelProxy::MessageFilter implementation.
  virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
  virtual void OnFilterRemoved() OVERRIDE;
  virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;

 protected:
  virtual ~ChildTraceMessageFilter();

 private:
  // Message handlers.
  void OnBeginTracing(const std::vector<std::string>& included_categories,
                      const std::vector<std::string>& excluded_categories,
                      base::TimeTicks browser_time);
  void OnEndTracing();
  void OnGetTraceBufferPercentFull();
  void OnSetWatchEvent(const std::string& category_name,
                       const std::string& event_name);
  void OnCancelWatchEvent();

  // Callback from trace subsystem.
  void OnTraceDataCollected(
      const scoped_refptr<base::RefCountedString>& events_str_ptr);
  void OnTraceNotification(int notification);

  IPC::Channel* channel_;
  base::MessageLoopProxy* ipc_message_loop_;

  DISALLOW_COPY_AND_ASSIGN(ChildTraceMessageFilter);
};

} // namespace components

#endif  // COMPONENTS_TRACING_CHILD_TRACE_MESSAGE_FILTER_H_