| 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 #include <stdint.h> |
| 10 | 10 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // Returns a pointer to the downloaded data. | 117 // Returns a pointer to the downloaded data. |
| 118 unsigned char* Data() const; | 118 unsigned char* Data() const; |
| 119 | 119 |
| 120 // Get NPN or ALPN Negotiated Protocol (if any) from HttpResponseInfo. | 120 // Get NPN or ALPN Negotiated Protocol (if any) from HttpResponseInfo. |
| 121 std::string GetNegotiatedProtocol() const; | 121 std::string GetNegotiatedProtocol() const; |
| 122 | 122 |
| 123 // Returns whether the response is serviced from cache. | 123 // Returns whether the response is serviced from cache. |
| 124 bool GetWasCached() const; | 124 bool GetWasCached() const; |
| 125 | 125 |
| 126 // net::URLRequest::Delegate implementation: | 126 // net::URLRequest::Delegate implementation: |
| 127 void OnResponseStarted(net::URLRequest* request) override; | 127 void OnResponseStarted(net::URLRequest* request, int net_error) override; |
| 128 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; | 128 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; |
| 129 void OnReceivedRedirect(net::URLRequest* request, | 129 void OnReceivedRedirect(net::URLRequest* request, |
| 130 const net::RedirectInfo& redirect_info, | 130 const net::RedirectInfo& redirect_info, |
| 131 bool* defer_redirect) override; | 131 bool* defer_redirect) override; |
| 132 | 132 |
| 133 bool OnNetworkThread() const; | 133 bool OnNetworkThread() const; |
| 134 | 134 |
| 135 private: | 135 private: |
| 136 static void OnDestroyRequest(URLRequestAdapter* self); | 136 static void OnDestroyRequest(URLRequestAdapter* self); |
| 137 | 137 |
| 138 void OnInitiateConnection(); | 138 void OnInitiateConnection(); |
| 139 void OnCancelRequest(); | 139 void OnCancelRequest(); |
| 140 void OnRequestSucceeded(); | 140 void OnRequestSucceeded(); |
| 141 void OnRequestFailed(); | 141 void OnRequestFailed(int net_error); |
| 142 void OnRequestCompleted(); | 142 void OnRequestCompleted(); |
| 143 void OnAppendChunk(const std::unique_ptr<char[]> bytes, | 143 void OnAppendChunk(const std::unique_ptr<char[]> bytes, |
| 144 int bytes_len, | 144 int bytes_len, |
| 145 bool is_last_chunk); | 145 bool is_last_chunk); |
| 146 | 146 |
| 147 void Read(); | 147 void Read(); |
| 148 | 148 |
| 149 // Handles synchronous or asynchronous read result, calls |delegate_| with | 149 // Handles synchronous or asynchronous read result, calls |delegate_| with |
| 150 // bytes read and returns true unless request has succeeded or failed. | 150 // bytes read and returns true unless request has succeeded or failed. |
| 151 bool HandleReadResult(int bytes_read); | 151 bool HandleReadResult(int bytes_read); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 170 bool chunked_upload_; | 170 bool chunked_upload_; |
| 171 // Indicates whether redirect has been disabled. | 171 // Indicates whether redirect has been disabled. |
| 172 bool disable_redirect_; | 172 bool disable_redirect_; |
| 173 | 173 |
| 174 DISALLOW_COPY_AND_ASSIGN(URLRequestAdapter); | 174 DISALLOW_COPY_AND_ASSIGN(URLRequestAdapter); |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 } // namespace cronet | 177 } // namespace cronet |
| 178 | 178 |
| 179 #endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_ADAPTER_H_ | 179 #endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_ADAPTER_H_ |
| OLD | NEW |