OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_CRONET_ANDROID_URL_REQUEST_ADAPTER_H_ | 5 #ifndef COMPONENTS_CRONET_ANDROID_URL_REQUEST_ADAPTER_H_ |
6 #define COMPONENTS_CRONET_ANDROID_URL_REQUEST_ADAPTER_H_ | 6 #define COMPONENTS_CRONET_ANDROID_URL_REQUEST_ADAPTER_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <stdint.h> |
9 | 10 |
10 #include <string> | 11 #include <string> |
11 | 12 |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "net/base/request_priority.h" | 16 #include "net/base/request_priority.h" |
16 #include "net/http/http_request_headers.h" | 17 #include "net/http/http_request_headers.h" |
17 #include "net/url_request/url_request.h" | 18 #include "net/url_request/url_request.h" |
18 | 19 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // Sets the request method GET, POST etc | 55 // Sets the request method GET, POST etc |
55 void SetMethod(const std::string& method); | 56 void SetMethod(const std::string& method); |
56 | 57 |
57 // Adds a header to the request | 58 // Adds a header to the request |
58 void AddHeader(const std::string& name, const std::string& value); | 59 void AddHeader(const std::string& name, const std::string& value); |
59 | 60 |
60 // Sets the contents of the POST or PUT request | 61 // Sets the contents of the POST or PUT request |
61 void SetUploadContent(const char* bytes, int bytes_len); | 62 void SetUploadContent(const char* bytes, int bytes_len); |
62 | 63 |
63 // Sets the request to streaming upload. | 64 // Sets the request to streaming upload. |
64 void SetUploadChannel(JNIEnv* env, int64 content_length); | 65 void SetUploadChannel(JNIEnv* env, int64_t content_length); |
65 | 66 |
66 // Disables redirect. Note that redirect is enabled by default. | 67 // Disables redirect. Note that redirect is enabled by default. |
67 void DisableRedirects(); | 68 void DisableRedirects(); |
68 | 69 |
69 // Indicates that the request body will be streamed by calling AppendChunk() | 70 // Indicates that the request body will be streamed by calling AppendChunk() |
70 // repeatedly. This must be called before Start(). | 71 // repeatedly. This must be called before Start(). |
71 void EnableChunkedUpload(); | 72 void EnableChunkedUpload(); |
72 | 73 |
73 // Appends a chunk to the POST body. | 74 // Appends a chunk to the POST body. |
74 // This must be called after EnableChunkedUpload() and Start(). | 75 // This must be called after EnableChunkedUpload() and Start(). |
(...skipping 19 matching lines...) Expand all Loading... |
94 int http_status_code() const { | 95 int http_status_code() const { |
95 return http_status_code_; | 96 return http_status_code_; |
96 }; | 97 }; |
97 | 98 |
98 // Returns the HTTP status text of the normalized status line. | 99 // Returns the HTTP status text of the normalized status line. |
99 const std::string& http_status_text() const { | 100 const std::string& http_status_text() const { |
100 return http_status_text_; | 101 return http_status_text_; |
101 } | 102 } |
102 | 103 |
103 // Returns the value of the content-length response header. | 104 // Returns the value of the content-length response header. |
104 int64 content_length() const { return expected_size_; } | 105 int64_t content_length() const { return expected_size_; } |
105 | 106 |
106 // Returns the value of the content-type response header. | 107 // Returns the value of the content-type response header. |
107 std::string content_type() const { return content_type_; } | 108 std::string content_type() const { return content_type_; } |
108 | 109 |
109 // Returns the value of the specified response header. | 110 // Returns the value of the specified response header. |
110 std::string GetHeader(const std::string& name) const; | 111 std::string GetHeader(const std::string& name) const; |
111 | 112 |
112 // Get all response headers, as a HttpResponseHeaders object. | 113 // Get all response headers, as a HttpResponseHeaders object. |
113 net::HttpResponseHeaders* GetResponseHeaders() const; | 114 net::HttpResponseHeaders* GetResponseHeaders() const; |
114 | 115 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 net::HttpRequestHeaders headers_; | 156 net::HttpRequestHeaders headers_; |
156 scoped_ptr<net::URLRequest> url_request_; | 157 scoped_ptr<net::URLRequest> url_request_; |
157 scoped_ptr<net::UploadDataStream> upload_data_stream_; | 158 scoped_ptr<net::UploadDataStream> upload_data_stream_; |
158 scoped_refptr<net::IOBufferWithSize> read_buffer_; | 159 scoped_refptr<net::IOBufferWithSize> read_buffer_; |
159 int total_bytes_read_; | 160 int total_bytes_read_; |
160 int error_code_; | 161 int error_code_; |
161 int http_status_code_; | 162 int http_status_code_; |
162 std::string http_status_text_; | 163 std::string http_status_text_; |
163 std::string content_type_; | 164 std::string content_type_; |
164 bool canceled_; | 165 bool canceled_; |
165 int64 expected_size_; | 166 int64_t expected_size_; |
166 bool chunked_upload_; | 167 bool chunked_upload_; |
167 // Indicates whether redirect has been disabled. | 168 // Indicates whether redirect has been disabled. |
168 bool disable_redirect_; | 169 bool disable_redirect_; |
169 | 170 |
170 DISALLOW_COPY_AND_ASSIGN(URLRequestAdapter); | 171 DISALLOW_COPY_AND_ASSIGN(URLRequestAdapter); |
171 }; | 172 }; |
172 | 173 |
173 } // namespace cronet | 174 } // namespace cronet |
174 | 175 |
175 #endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_ADAPTER_H_ | 176 #endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_ADAPTER_H_ |
OLD | NEW |