| 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 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 // Adds a header to the request | 56 // Adds a header to the request |
| 57 void AddHeader(const std::string& name, const std::string& value); | 57 void AddHeader(const std::string& name, const std::string& value); |
| 58 | 58 |
| 59 // Sets the contents of the POST or PUT request | 59 // Sets the contents of the POST or PUT request |
| 60 void SetUploadContent(const char* bytes, int bytes_len); | 60 void SetUploadContent(const char* bytes, int bytes_len); |
| 61 | 61 |
| 62 // Sets the request to streaming upload. | 62 // Sets the request to streaming upload. |
| 63 void SetUploadChannel(JNIEnv* env, int64 content_length); | 63 void SetUploadChannel(JNIEnv* env, int64 content_length); |
| 64 | 64 |
| 65 // Indicates that the request body will be streamed by calling AppendChunk() |
| 66 // repeatedly. This must be called before Start(). |
| 67 void EnableChunkedUpload(); |
| 68 |
| 69 // Appends a chunk to the POST body. |
| 70 // This must be called after EnableChunkedUpload() and Start(). |
| 71 void AppendChunk(const char* bytes, int bytes_len, bool is_last_chunk); |
| 72 |
| 65 // Starts the request. | 73 // Starts the request. |
| 66 void Start(); | 74 void Start(); |
| 67 | 75 |
| 68 // Cancels the request. | 76 // Cancels the request. |
| 69 void Cancel(); | 77 void Cancel(); |
| 70 | 78 |
| 71 // Releases all resources for the request and deletes the object itself. | 79 // Releases all resources for the request and deletes the object itself. |
| 72 void Destroy(); | 80 void Destroy(); |
| 73 | 81 |
| 74 // Returns the URL of the request. | 82 // Returns the URL of the request. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 private: | 117 private: |
| 110 static void OnDestroyRequest(URLRequestAdapter* self); | 118 static void OnDestroyRequest(URLRequestAdapter* self); |
| 111 | 119 |
| 112 void OnInitiateConnection(); | 120 void OnInitiateConnection(); |
| 113 void OnCancelRequest(); | 121 void OnCancelRequest(); |
| 114 void OnRequestSucceeded(); | 122 void OnRequestSucceeded(); |
| 115 void OnRequestFailed(); | 123 void OnRequestFailed(); |
| 116 void OnRequestCompleted(); | 124 void OnRequestCompleted(); |
| 117 void OnRequestCanceled(); | 125 void OnRequestCanceled(); |
| 118 void OnBytesRead(int bytes_read); | 126 void OnBytesRead(int bytes_read); |
| 119 void OnAppendChunk(const char* bytes, int bytes_len, bool is_last_chunk); | 127 void OnAppendChunk(const scoped_ptr<char[]> bytes, int bytes_len, |
| 128 bool is_last_chunk); |
| 120 | 129 |
| 121 void Read(); | 130 void Read(); |
| 122 | 131 |
| 123 URLRequestContextAdapter* context_; | 132 URLRequestContextAdapter* context_; |
| 124 scoped_refptr<URLRequestAdapterDelegate> delegate_; | 133 scoped_refptr<URLRequestAdapterDelegate> delegate_; |
| 125 GURL url_; | 134 GURL url_; |
| 126 net::RequestPriority priority_; | 135 net::RequestPriority priority_; |
| 127 std::string method_; | 136 std::string method_; |
| 128 net::HttpRequestHeaders headers_; | 137 net::HttpRequestHeaders headers_; |
| 129 net::URLRequest* url_request_; | 138 net::URLRequest* url_request_; |
| 130 scoped_ptr<net::UploadDataStream> upload_data_stream_; | 139 scoped_ptr<net::UploadDataStream> upload_data_stream_; |
| 131 scoped_refptr<net::GrowableIOBuffer> read_buffer_; | 140 scoped_refptr<net::GrowableIOBuffer> read_buffer_; |
| 132 int bytes_read_; | 141 int bytes_read_; |
| 133 int total_bytes_read_; | 142 int total_bytes_read_; |
| 134 int error_code_; | 143 int error_code_; |
| 135 int http_status_code_; | 144 int http_status_code_; |
| 136 std::string content_type_; | 145 std::string content_type_; |
| 137 bool canceled_; | 146 bool canceled_; |
| 138 int64 expected_size_; | 147 int64 expected_size_; |
| 148 bool chunked_upload_; |
| 139 | 149 |
| 140 DISALLOW_COPY_AND_ASSIGN(URLRequestAdapter); | 150 DISALLOW_COPY_AND_ASSIGN(URLRequestAdapter); |
| 141 }; | 151 }; |
| 142 | 152 |
| 143 } // namespace cronet | 153 } // namespace cronet |
| 144 | 154 |
| 145 #endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_ADAPTER_H_ | 155 #endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_ADAPTER_H_ |
| OLD | NEW |