| 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_PEER_H_ | 5 #ifndef COMPONENTS_CRONET_ANDROID_URL_REQUEST_PEER_H_ |
| 6 #define COMPONENTS_CRONET_ANDROID_URL_REQUEST_PEER_H_ | 6 #define COMPONENTS_CRONET_ANDROID_URL_REQUEST_PEER_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // object. | 30 // object. |
| 31 class URLRequestPeer : public net::URLRequest::Delegate { | 31 class URLRequestPeer : public net::URLRequest::Delegate { |
| 32 public: | 32 public: |
| 33 // The delegate which is called when the request finishes. | 33 // The delegate which is called when the request finishes. |
| 34 class URLRequestPeerDelegate | 34 class URLRequestPeerDelegate |
| 35 : public base::RefCountedThreadSafe<URLRequestPeerDelegate> { | 35 : public base::RefCountedThreadSafe<URLRequestPeerDelegate> { |
| 36 public: | 36 public: |
| 37 virtual void OnResponseStarted(URLRequestPeer* request) = 0; | 37 virtual void OnResponseStarted(URLRequestPeer* request) = 0; |
| 38 virtual void OnBytesRead(URLRequestPeer* request) = 0; | 38 virtual void OnBytesRead(URLRequestPeer* request) = 0; |
| 39 virtual void OnRequestFinished(URLRequestPeer* request) = 0; | 39 virtual void OnRequestFinished(URLRequestPeer* request) = 0; |
| 40 virtual int ReadFromUploadChannel(net::IOBuffer* buf, int buf_length) = 0; |
| 40 | 41 |
| 41 protected: | 42 protected: |
| 42 friend class base::RefCountedThreadSafe<URLRequestPeerDelegate>; | 43 friend class base::RefCountedThreadSafe<URLRequestPeerDelegate>; |
| 43 virtual ~URLRequestPeerDelegate() {} | 44 virtual ~URLRequestPeerDelegate() {} |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 URLRequestPeer(URLRequestContextPeer* context, | 47 URLRequestPeer(URLRequestContextPeer* context, |
| 47 URLRequestPeerDelegate* delegate, | 48 URLRequestPeerDelegate* delegate, |
| 48 GURL url, | 49 GURL url, |
| 49 net::RequestPriority priority); | 50 net::RequestPriority priority); |
| 50 virtual ~URLRequestPeer(); | 51 virtual ~URLRequestPeer(); |
| 51 | 52 |
| 52 // Sets the request method GET, POST etc | 53 // Sets the request method GET, POST etc |
| 53 void SetMethod(const std::string& method); | 54 void SetMethod(const std::string& method); |
| 54 | 55 |
| 55 // Adds a header to the request | 56 // Adds a header to the request |
| 56 void AddHeader(const std::string& name, const std::string& value); | 57 void AddHeader(const std::string& name, const std::string& value); |
| 57 | 58 |
| 58 // Sets the contents of the POST or PUT request | 59 // Sets the contents of the POST or PUT request |
| 59 void SetUploadContent(const char* bytes, int bytes_len); | 60 void SetUploadContent(const char* bytes, int bytes_len); |
| 60 | 61 |
| 61 // Sets the request to streaming upload. | 62 // Sets the request to streaming upload. |
| 62 void SetUploadChannel(JNIEnv* env, jobject content, int64 content_length); | 63 void SetUploadChannel(JNIEnv* env, int64 content_length); |
| 63 | 64 |
| 64 // Starts the request. | 65 // Starts the request. |
| 65 void Start(); | 66 void Start(); |
| 66 | 67 |
| 67 // Cancels the request. | 68 // Cancels the request. |
| 68 void Cancel(); | 69 void Cancel(); |
| 69 | 70 |
| 70 // Releases all resources for the request and deletes the object itself. | 71 // Releases all resources for the request and deletes the object itself. |
| 71 void Destroy(); | 72 void Destroy(); |
| 72 | 73 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 std::string content_type_; | 136 std::string content_type_; |
| 136 bool canceled_; | 137 bool canceled_; |
| 137 int64 expected_size_; | 138 int64 expected_size_; |
| 138 | 139 |
| 139 DISALLOW_COPY_AND_ASSIGN(URLRequestPeer); | 140 DISALLOW_COPY_AND_ASSIGN(URLRequestPeer); |
| 140 }; | 141 }; |
| 141 | 142 |
| 142 } // namespace cronet | 143 } // namespace cronet |
| 143 | 144 |
| 144 #endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_PEER_H_ | 145 #endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_PEER_H_ |
| OLD | NEW |