summaryrefslogtreecommitdiffstats
path: root/content/shell/renderer/ipc_echo.h
blob: ab4c21e09ff6e8bf2aa027a1079e46bebf88e626 (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
54
55
56
// Copyright 2014 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 CONTENT_SHELL_RENDERER_IPC_ECHO_H_
#define CONTENT_SHELL_RENDERER_IPC_ECHO_H_

#include <utility>
#include <vector>
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "third_party/WebKit/public/web/WebDocument.h"

namespace blink {
class WebFrame;
}

namespace IPC {
class Sender;
}

namespace content {

// This class is for writing micro benchmarks exercising underlying
// IPC::Channel using HTML and JavaScript.
//
// TODO(morrita): The benchmark effort tries to makesure that
// IPC::ChannelMojo is as performant as native IPC::Channel
// implementations. Currently IPC::ChannelMojo is hidden behind
// "--enable-renderer-mojo-channel". Once it is turned on by default.
// we no longer need this class and should remove it.
class IPCEcho : public base::SupportsWeakPtr<IPCEcho> {
 public:
  IPCEcho(blink::WebDocument document, IPC::Sender* sender, int routing_id);
  ~IPCEcho();

  void RequestEcho(int id, int size);
  void DidRespondEcho(int id, int size);
  void Install(blink::WebFrame*);

  int last_echo_id() const { return last_echo_id_; }
  int last_echo_size() const { return last_echo_size_; }

  blink::WebDocument document_;
  IPC::Sender* sender_;
  int routing_id_;
  int last_echo_id_;
  int last_echo_size_;

  base::WeakPtrFactory<IPCEcho> weak_factory_;

};

}  // namespace content

#endif  // CONTENT_SHELL_RENDERER_IPC_ECHO_H_