Alex Vakulenko | a3062c5 | 2014-04-21 17:05:51 -0700 | [diff] [blame] | 1 | // 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 Vakulenko | b3aac25 | 2014-05-07 17:35:24 -0700 | [diff] [blame] | 10 | #include <utility> |
Alex Vakulenko | a3062c5 | 2014-04-21 17:05:51 -0700 | [diff] [blame] | 11 | #include <vector> |
| 12 | |
| 13 | #include <base/basictypes.h> |
| 14 | |
Alex Vakulenko | b3aac25 | 2014-05-07 17:35:24 -0700 | [diff] [blame] | 15 | #include "buffet/error.h" |
| 16 | |
Alex Vakulenko | af23b32 | 2014-05-08 16:25:45 -0700 | [diff] [blame] | 17 | namespace buffet { |
Alex Vakulenko | a3062c5 | 2014-04-21 17:05:51 -0700 | [diff] [blame] | 18 | namespace http { |
| 19 | |
| 20 | typedef std::vector<std::pair<std::string, std::string>> HeaderList; |
| 21 | |
| 22 | class Request; |
| 23 | class Connection; |
| 24 | |
| 25 | /////////////////////////////////////////////////////////////////////////////// |
| 26 | // Transport is a base class for specific implementation of HTTP communication. |
| 27 | // This class (and its underlying implementation) is used by http::Request and |
| 28 | // http::Response classes to provide HTTP functionality to the clients. |
| 29 | /////////////////////////////////////////////////////////////////////////////// |
| 30 | class Transport { |
| 31 | public: |
| 32 | Transport() = default; |
| 33 | virtual ~Transport() = default; |
| 34 | |
| 35 | // Creates a connection object and initializes it with the specified data. |
| 36 | // |transport| is a shared pointer to this transport object instance, |
| 37 | // used to maintain the object alive as long as the connection exists. |
| 38 | virtual std::unique_ptr<Connection> CreateConnection( |
| 39 | std::shared_ptr<Transport> transport, |
| 40 | const std::string& url, |
| 41 | const std::string& method, |
| 42 | const HeaderList& headers, |
| 43 | const std::string& user_agent, |
| 44 | const std::string& referer, |
Alex Vakulenko | b3aac25 | 2014-05-07 17:35:24 -0700 | [diff] [blame] | 45 | ErrorPtr* error) = 0; |
Alex Vakulenko | a3062c5 | 2014-04-21 17:05:51 -0700 | [diff] [blame] | 46 | |
| 47 | private: |
| 48 | DISALLOW_COPY_AND_ASSIGN(Transport); |
| 49 | }; |
| 50 | |
Alex Vakulenko | b3aac25 | 2014-05-07 17:35:24 -0700 | [diff] [blame] | 51 | } // namespace http |
Alex Vakulenko | af23b32 | 2014-05-08 16:25:45 -0700 | [diff] [blame] | 52 | } // namespace buffet |
Alex Vakulenko | a3062c5 | 2014-04-21 17:05:51 -0700 | [diff] [blame] | 53 | |
Alex Vakulenko | b3aac25 | 2014-05-07 17:35:24 -0700 | [diff] [blame] | 54 | #endif // BUFFET_HTTP_TRANSPORT_H_ |