OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_ | 5 #ifndef ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_ |
6 #define ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_ | 6 #define ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 // A request job that reads data from a Java InputStream. | 35 // A request job that reads data from a Java InputStream. |
36 class AndroidStreamReaderURLRequestJob : public net::URLRequestJob { | 36 class AndroidStreamReaderURLRequestJob : public net::URLRequestJob { |
37 public: | 37 public: |
38 /* | 38 /* |
39 * We use a delegate so that we can share code for this job in slightly | 39 * We use a delegate so that we can share code for this job in slightly |
40 * different contexts. | 40 * different contexts. |
41 */ | 41 */ |
42 class Delegate { | 42 class Delegate { |
43 public: | 43 public: |
| 44 // Called from the IO thread when the Job is about to start. |
| 45 virtual void OnStart() = 0; |
| 46 |
44 // This method is called from a worker thread, not from the IO thread. | 47 // This method is called from a worker thread, not from the IO thread. |
45 virtual scoped_ptr<android_webview::InputStream> OpenInputStream( | 48 virtual scoped_ptr<android_webview::InputStream> OpenInputStream( |
46 JNIEnv* env, | 49 JNIEnv* env, |
47 const GURL& url) = 0; | 50 const GURL& url) = 0; |
48 | 51 |
49 // This method is called on the Job's thread if the result of calling | 52 // This method is called on the Job's thread if the result of calling |
50 // OpenInputStream was null. | 53 // OpenInputStream was null. |
51 // Setting the |restart| parameter to true will cause the request to be | 54 // Setting the |restart| parameter to true will cause the request to be |
52 // restarted with a new job. | 55 // restarted with a new job. |
53 virtual void OnInputStreamOpenFailed( | 56 virtual void OnInputStreamOpenFailed( |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 scoped_ptr<net::HttpResponseInfo> response_info_; | 115 scoped_ptr<net::HttpResponseInfo> response_info_; |
113 scoped_ptr<Delegate> delegate_; | 116 scoped_ptr<Delegate> delegate_; |
114 scoped_refptr<InputStreamReaderWrapper> input_stream_reader_wrapper_; | 117 scoped_refptr<InputStreamReaderWrapper> input_stream_reader_wrapper_; |
115 base::WeakPtrFactory<AndroidStreamReaderURLRequestJob> weak_factory_; | 118 base::WeakPtrFactory<AndroidStreamReaderURLRequestJob> weak_factory_; |
116 base::ThreadChecker thread_checker_; | 119 base::ThreadChecker thread_checker_; |
117 | 120 |
118 DISALLOW_COPY_AND_ASSIGN(AndroidStreamReaderURLRequestJob); | 121 DISALLOW_COPY_AND_ASSIGN(AndroidStreamReaderURLRequestJob); |
119 }; | 122 }; |
120 | 123 |
121 #endif // ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_ | 124 #endif // ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_ |
OLD | NEW |