summaryrefslogtreecommitdiffstats
path: root/blimp/net/blimp_transport.h
blob: 8deabd5a5d5f92214cd89c8891443eac3b0f6372 (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
// Copyright 2015 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 BLIMP_NET_BLIMP_TRANSPORT_H_
#define BLIMP_NET_BLIMP_TRANSPORT_H_

#include <string>

#include "base/memory/scoped_ptr.h"
#include "net/base/completion_callback.h"

namespace blimp {

class BlimpConnection;

// An interface which encapsulates the transport-specific code for
// establishing network connections between the client and engine.
// Subclasses of BlimpTransport are responsible for defining their own
// methods for receiving connection arguments.
class BlimpTransport {
 public:
  virtual ~BlimpTransport() {}

  // Initiate or listen for a connection.
  //
  // |callback| will be invoked with the connection outcome:
  //   * net::OK if a connection is established successful, the BlimpConnection
  //     can be taken by calling TakeConnection().
  //   * net::ERR_IO_PENDING will never be the outcome
  //   * Other error code indicates no connection was established.
  virtual void Connect(const net::CompletionCallback& callback) = 0;

  // Returns the connection object after a successful Connect().
  virtual scoped_ptr<BlimpConnection> TakeConnection() = 0;

  // Gets transport name, e.g. "TCP", "SSL", "mock", etc.
  virtual const char* GetName() const = 0;
};

}  // namespace blimp

#endif  // BLIMP_NET_BLIMP_TRANSPORT_H_