- add sources.
[platform/framework/web/crosswalk.git] / src / components / tracing / child_trace_message_filter.h
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 COMPONENTS_TRACING_CHILD_TRACE_MESSAGE_FILTER_H_
6 #define COMPONENTS_TRACING_CHILD_TRACE_MESSAGE_FILTER_H_
7
8 #include "base/bind.h"
9 #include "base/memory/ref_counted_memory.h"
10 #include "ipc/ipc_channel_proxy.h"
11
12 namespace base {
13 class MessageLoopProxy;
14 }
15
16 namespace tracing {
17
18 // This class sends and receives trace messages on child processes.
19 class ChildTraceMessageFilter : public IPC::ChannelProxy::MessageFilter {
20  public:
21   explicit ChildTraceMessageFilter(base::MessageLoopProxy* ipc_message_loop);
22
23   // IPC::ChannelProxy::MessageFilter implementation.
24   virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE;
25   virtual void OnFilterRemoved() OVERRIDE;
26   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
27
28  protected:
29   virtual ~ChildTraceMessageFilter();
30
31  private:
32   // Message handlers.
33   void OnBeginTracing(const std::string& category_filter_str,
34                       base::TimeTicks browser_time,
35                       int options,
36                       bool tracing_startup);
37   void OnEndTracing();
38   void OnEnableMonitoring(const std::string& category_filter_str,
39                           base::TimeTicks browser_time,
40                           int options);
41   void OnDisableMonitoring();
42   void OnCaptureMonitoringSnapshot();
43   void OnGetTraceBufferPercentFull();
44   void OnSetWatchEvent(const std::string& category_name,
45                        const std::string& event_name);
46   void OnCancelWatchEvent();
47
48   // Callback from trace subsystem.
49   void OnTraceDataCollected(
50       const scoped_refptr<base::RefCountedString>& events_str_ptr,
51       bool has_more_events);
52
53   void OnMonitoringTraceDataCollected(
54       const scoped_refptr<base::RefCountedString>& events_str_ptr,
55       bool has_more_events);
56
57   void OnTraceNotification(int notification);
58
59   IPC::Channel* channel_;
60   base::MessageLoopProxy* ipc_message_loop_;
61
62   DISALLOW_COPY_AND_ASSIGN(ChildTraceMessageFilter);
63 };
64
65 }  // namespace tracing
66
67 #endif  // COMPONENTS_TRACING_CHILD_TRACE_MESSAGE_FILTER_H_