Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: components/cronet/android/cronet_url_request_adapter.h

Issue 849903002: [Cronet] Upload support for async APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move delegate destructor to implementation file to avoid chromium style error Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_CRONET_URL_REQUEST_ADAPTER_H_ 5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_ADAPTER_H_
6 #define COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_ADAPTER_H_ 6 #define COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_ADAPTER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "net/base/request_priority.h" 14 #include "net/base/request_priority.h"
15 #include "net/http/http_request_headers.h" 15 #include "net/http/http_request_headers.h"
16 #include "net/url_request/url_request.h" 16 #include "net/url_request/url_request.h"
17 #include "url/gurl.h" 17 #include "url/gurl.h"
18 18
19 namespace base { 19 namespace base {
20 class SingleThreadTaskRunner; 20 class SingleThreadTaskRunner;
21 } // namespace base 21 } // namespace base
22 22
23 namespace net { 23 namespace net {
24 class GrowableIOBuffer; 24 class GrowableIOBuffer;
25 class HttpResponseHeaders; 25 class HttpResponseHeaders;
26 class UploadDataStream;
26 } // namespace net 27 } // namespace net
27 28
28 namespace cronet { 29 namespace cronet {
29 30
30 class CronetURLRequestContextAdapter; 31 class CronetURLRequestContextAdapter;
31 32
32 // An adapter from the JNI CronetUrlRequest object to the Chromium URLRequest. 33 // An adapter from the JNI CronetUrlRequest object to the Chromium URLRequest.
33 // Created and configured from random thread. Start is posted to network 34 // Created and configured from random thread. Start is posted to network
34 // thread and all callbacks into CronetURLRequestAdapterDelegate are done on 35 // thread and all callbacks into CronetURLRequestAdapterDelegate are done on
35 // network thread. Each delegate callback is expected to initiate next step like 36 // network thread. Each delegate callback is expected to initiate next step like
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // Methods called prior to Start are never called on network thread. 74 // Methods called prior to Start are never called on network thread.
74 75
75 // Sets the request method GET, POST etc. 76 // Sets the request method GET, POST etc.
76 void set_method(const std::string& method) { 77 void set_method(const std::string& method) {
77 initial_method_ = method; 78 initial_method_ = method;
78 } 79 }
79 80
80 // Adds a header to the request before it starts. 81 // Adds a header to the request before it starts.
81 void AddRequestHeader(const std::string& name, const std::string& value); 82 void AddRequestHeader(const std::string& name, const std::string& value);
82 83
84 // Adds a request body to the request before it starts.
85 void SetUpload(scoped_ptr<net::UploadDataStream> upload);
86
83 // Methods called on any thread. 87 // Methods called on any thread.
84 88
85 // Posts tasks to network thread. 89 // Posts tasks to network thread.
86 void PostTaskToNetworkThread(const tracked_objects::Location& from_here, 90 void PostTaskToNetworkThread(const tracked_objects::Location& from_here,
87 const base::Closure& task); 91 const base::Closure& task);
88 92
89 // Returns true if called on network thread. 93 // Returns true if called on network thread.
90 bool IsOnNetworkThread() const; 94 bool IsOnNetworkThread() const;
91 95
92 // Methods called only on network thread. 96 // Methods called only on network thread.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 bool MaybeReportError(net::URLRequest* request) const; 142 bool MaybeReportError(net::URLRequest* request) const;
139 143
140 CronetURLRequestContextAdapter* context_; 144 CronetURLRequestContextAdapter* context_;
141 scoped_ptr<CronetURLRequestAdapterDelegate> delegate_; 145 scoped_ptr<CronetURLRequestAdapterDelegate> delegate_;
142 146
143 const GURL initial_url_; 147 const GURL initial_url_;
144 const net::RequestPriority initial_priority_; 148 const net::RequestPriority initial_priority_;
145 std::string initial_method_; 149 std::string initial_method_;
146 int load_flags_; 150 int load_flags_;
147 net::HttpRequestHeaders initial_request_headers_; 151 net::HttpRequestHeaders initial_request_headers_;
152 scoped_ptr<net::UploadDataStream> upload_;
148 153
149 scoped_refptr<net::IOBufferWithSize> read_buffer_; 154 scoped_refptr<net::IOBufferWithSize> read_buffer_;
150 scoped_ptr<net::URLRequest> url_request_; 155 scoped_ptr<net::URLRequest> url_request_;
151 156
152 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestAdapter); 157 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestAdapter);
153 }; 158 };
154 159
155 } // namespace cronet 160 } // namespace cronet
156 161
157 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_ADAPTER_H_ 162 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698