blob: 15b0bd68be0fd5a8764eb873c48f75fb7c097842 [file] [log] [blame]
Alex Vakulenkoa3062c52014-04-21 17:05:51 -07001// Copyright 2014 The Chromium OS 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 BUFFET_HTTP_TRANSPORT_H_
6#define BUFFET_HTTP_TRANSPORT_H_
7
8#include <memory>
9#include <string>
Alex Vakulenkob3aac252014-05-07 17:35:24 -070010#include <utility>
Alex Vakulenkoa3062c52014-04-21 17:05:51 -070011#include <vector>
12
13#include <base/basictypes.h>
Alex Vakulenko5f472062014-08-14 17:54:04 -070014#include <chromeos/error.h>
Alex Vakulenkob3aac252014-05-07 17:35:24 -070015
Alex Vakulenkoaf23b322014-05-08 16:25:45 -070016namespace buffet {
Alex Vakulenkoa3062c52014-04-21 17:05:51 -070017namespace http {
18
19typedef std::vector<std::pair<std::string, std::string>> HeaderList;
20
21class Request;
22class Connection;
23
24///////////////////////////////////////////////////////////////////////////////
25// Transport is a base class for specific implementation of HTTP communication.
26// This class (and its underlying implementation) is used by http::Request and
27// http::Response classes to provide HTTP functionality to the clients.
28///////////////////////////////////////////////////////////////////////////////
29class Transport {
30 public:
31 Transport() = default;
32 virtual ~Transport() = default;
33
34 // Creates a connection object and initializes it with the specified data.
35 // |transport| is a shared pointer to this transport object instance,
36 // used to maintain the object alive as long as the connection exists.
37 virtual std::unique_ptr<Connection> CreateConnection(
38 std::shared_ptr<Transport> transport,
39 const std::string& url,
40 const std::string& method,
41 const HeaderList& headers,
42 const std::string& user_agent,
43 const std::string& referer,
Alex Vakulenko5f472062014-08-14 17:54:04 -070044 chromeos::ErrorPtr* error) = 0;
Alex Vakulenkoa3062c52014-04-21 17:05:51 -070045
46 private:
47 DISALLOW_COPY_AND_ASSIGN(Transport);
48};
49
Alex Vakulenkob3aac252014-05-07 17:35:24 -070050} // namespace http
Alex Vakulenkoaf23b322014-05-08 16:25:45 -070051} // namespace buffet
Alex Vakulenkoa3062c52014-04-21 17:05:51 -070052
Alex Vakulenkob3aac252014-05-07 17:35:24 -070053#endif // BUFFET_HTTP_TRANSPORT_H_