• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// This file is generated by FrontendChannel_h.template.
2
3// Copyright 2016 The Chromium Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style license that can be
5// found in the LICENSE file.
6
7#ifndef {{"_".join(config.protocol.namespace)}}_FrontendChannel_h
8#define {{"_".join(config.protocol.namespace)}}_FrontendChannel_h
9
10{% for namespace in config.protocol.namespace %}
11namespace {{namespace}} {
12{% endfor %}
13
14class {{config.lib.export_macro}} Serializable {
15public:
16    ProtocolMessage serialize(bool binary) {
17      if (binary)
18        return StringUtil::binaryToMessage(serializeToBinary());
19      else
20        return StringUtil::jsonToMessage(serializeToJSON());
21    }
22    virtual String serializeToJSON() = 0;
23    virtual std::vector<uint8_t> serializeToBinary() = 0;
24    virtual ~Serializable() = default;
25};
26
27class {{config.lib.export_macro}} FrontendChannel {
28public:
29    virtual ~FrontendChannel() { }
30    virtual void sendProtocolResponse(int callId, std::unique_ptr<Serializable> message) = 0;
31    virtual void sendProtocolNotification(std::unique_ptr<Serializable> message) = 0;
32    virtual void fallThrough(int callId, const String& method, const ProtocolMessage& message) = 0;
33    virtual void flushProtocolNotifications() = 0;
34};
35
36{% for namespace in config.protocol.namespace %}
37} // namespace {{namespace}}
38{% endfor %}
39
40#endif // !defined({{"_".join(config.protocol.namespace)}}_FrontendChannel_h)
41