• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CHILD_HISTOGRAM_MESSAGE_FILTER_H_
6 #define CONTENT_CHILD_HISTOGRAM_MESSAGE_FILTER_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "ipc/message_filter.h"
14 
15 namespace base {
16 class HistogramDeltaSerialization;
17 class MessageLoopProxy;
18 }  // namespace base
19 
20 namespace content {
21 
22 class ChildHistogramMessageFilter : public IPC::MessageFilter {
23  public:
24   ChildHistogramMessageFilter();
25 
26   // IPC::MessageFilter implementation.
27   virtual void OnFilterAdded(IPC::Sender* sender) OVERRIDE;
28   virtual void OnFilterRemoved() OVERRIDE;
29   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
30 
31   void SendHistograms(int sequence_number);
32 
33  private:
34   typedef std::vector<std::string> HistogramPickledList;
35 
36   virtual ~ChildHistogramMessageFilter();
37 
38   // Message handlers.
39   virtual void OnGetChildHistogramData(int sequence_number);
40 
41   // Extract snapshot data and then send it off the the Browser process.
42   // Send only a delta to what we have already sent.
43   void UploadAllHistograms(int sequence_number);
44 
45   IPC::Sender* sender_;
46 
47   scoped_refptr<base::MessageLoopProxy> io_message_loop_;
48 
49   // Prepares histogram deltas for transmission.
50   scoped_ptr<base::HistogramDeltaSerialization> histogram_delta_serialization_;
51 
52   DISALLOW_COPY_AND_ASSIGN(ChildHistogramMessageFilter);
53 };
54 
55 }  // namespace content
56 
57 #endif  // CONTENT_CHILD_HISTOGRAM_MESSAGE_FILTER_H_
58