Chromium Code Reviews| Index: android_webview/browser/net/android_stream_reader_url_request_job.h |
| diff --git a/android_webview/browser/net/android_stream_reader_url_request_job.h b/android_webview/browser/net/android_stream_reader_url_request_job.h |
| index e2049edc3b8665a0d31f8ec531493c2648d00f28..86fb83aedb374b29a97cf430a56e5ae6bf48f79c 100644 |
| --- a/android_webview/browser/net/android_stream_reader_url_request_job.h |
| +++ b/android_webview/browser/net/android_stream_reader_url_request_job.h |
| @@ -2,13 +2,15 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_ |
| -#define ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_ |
| +#ifndef ANDROID_WEBVIEW_BROWSER_NET_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_ |
| +#define ANDROID_WEBVIEW_BROWSER_NET_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_ |
| #include <string> |
| #include "base/android/scoped_java_ref.h" |
| +#include "base/callback.h" |
| #include "base/location.h" |
| +#include "base/macros.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/memory/weak_ptr.h" |
| @@ -72,10 +74,24 @@ class AndroidStreamReaderURLRequestJob : public net::URLRequestJob { |
| virtual ~Delegate() {} |
| }; |
| + class DelegateObtainer { |
| + public: |
| + typedef base::Callback<void(scoped_ptr<Delegate>)> Callback; |
| + virtual void ObtainDelegate(net::URLRequest* request, |
| + Callback callback) = 0; |
|
mmenke
2015/10/01 18:34:40
nit: const Callback&
mnaganov (inactive)
2015/10/01 19:51:03
Done.
|
| + |
| + virtual ~DelegateObtainer() {} |
|
mmenke
2015/10/01 18:34:40
nit: Destructors (And constructors) should go bef
mnaganov (inactive)
2015/10/01 19:51:03
Done.
|
| + }; |
| + |
| AndroidStreamReaderURLRequestJob( |
| net::URLRequest* request, |
| net::NetworkDelegate* network_delegate, |
| scoped_ptr<Delegate> delegate); |
| + AndroidStreamReaderURLRequestJob( |
| + net::URLRequest* request, |
| + net::NetworkDelegate* network_delegate, |
| + scoped_ptr<DelegateObtainer> delegate_obtainer, |
| + bool); // resolve ambiguity |
| // URLRequestJob: |
| void Start() override; |
| @@ -100,6 +116,12 @@ class AndroidStreamReaderURLRequestJob : public net::URLRequestJob { |
| CreateStreamReader(android_webview::InputStream* stream); |
| private: |
| + // Used as a callback when obtaining the delegate asynchronously, |
| + // see DelegateObtainer. |
| + void DelegateObtained(scoped_ptr<Delegate> delegate); |
| + // Actual URLRequestJob::Start implementation. |
| + void DoStart(); |
| + |
| void HeadersComplete(int status_code, const std::string& status_text); |
| void OnInputStreamOpened( |
| @@ -111,6 +133,7 @@ class AndroidStreamReaderURLRequestJob : public net::URLRequestJob { |
| net::HttpByteRange byte_range_; |
| scoped_ptr<net::HttpResponseInfo> response_info_; |
| scoped_ptr<Delegate> delegate_; |
| + scoped_ptr<DelegateObtainer> delegate_obtainer_; |
| scoped_refptr<InputStreamReaderWrapper> input_stream_reader_wrapper_; |
| base::ThreadChecker thread_checker_; |
| @@ -121,4 +144,4 @@ class AndroidStreamReaderURLRequestJob : public net::URLRequestJob { |
| } // namespace android_webview |
| -#endif // ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_ |
| +#endif // ANDROID_WEBVIEW_BROWSER_NET_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_ |