summaryrefslogtreecommitdiff
path: root/chromium/headless/public/headless_devtools_channel.h
blob: 310b7650c5e7fb65a74c3610a63159d1da9ce48f (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
// Copyright 2018 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 HEADLESS_PUBLIC_HEADLESS_DEVTOOLS_CHANNEL_H_
#define HEADLESS_PUBLIC_HEADLESS_DEVTOOLS_CHANNEL_H_

#include <string>

#include "base/containers/span.h"
#include "base/macros.h"
#include "headless/public/headless_export.h"

namespace headless {

// An interface for sending messages to DevTools.
class HEADLESS_EXPORT HeadlessDevToolsChannel {
 public:
  // An interface for receiving messages from DevTools.
  class Client {
   public:
    virtual ~Client() {}
    // Receives an incoming protocol message from DevTools.
    virtual void ReceiveProtocolMessage(base::span<const uint8_t> message) = 0;
    // Notifies about channel being closed from the DevTools side.
    virtual void ChannelClosed() = 0;
  };

  virtual ~HeadlessDevToolsChannel() {}
  // Sets a peer client which receives the messages from DevTools.
  // |client| must outline this channel. Can be switched on and off
  // multiple times.
  virtual void SetClient(Client* client) = 0;
  // Sends an outgoing protocol message to DevTools.
  virtual void SendProtocolMessage(base::span<const uint8_t> message) = 0;
};

}  // namespace headless

#endif  // HEADLESS_PUBLIC_HEADLESS_DEVTOOLS_CHANNEL_H_