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

Side by Side Diff: android_webview/native/android_stream_reader_url_request_job.h

Issue 11147021: [Android] Make AndroidStreamReaderURLRequestJob to start loading asynchronously. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | android_webview/native/android_stream_reader_url_request_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/android/scoped_java_ref.h" 8 #include "base/android/scoped_java_ref.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
10 #include "base/threading/non_thread_safe.h" 11 #include "base/threading/non_thread_safe.h"
11 #include "net/http/http_byte_range.h" 12 #include "net/http/http_byte_range.h"
12 #include "net/url_request/url_request_job.h" 13 #include "net/url_request/url_request_job.h"
13 14
14 namespace net { 15 namespace net {
15 class URLRequest; 16 class URLRequest;
16 } 17 }
17 18
18 // A request job that reads data from a Java InputStream. 19 // A request job that reads data from a Java InputStream.
19 class AndroidStreamReaderURLRequestJob : public net::URLRequestJob { 20 class AndroidStreamReaderURLRequestJob : public net::URLRequestJob {
(...skipping 16 matching lines...) Expand all
36 37
37 virtual bool GetCharset( 38 virtual bool GetCharset(
38 JNIEnv* env, 39 JNIEnv* env,
39 net::URLRequest* request, 40 net::URLRequest* request,
40 jobject stream, 41 jobject stream,
41 std::string* charset) = 0; 42 std::string* charset) = 0;
42 43
43 virtual ~Delegate() {} 44 virtual ~Delegate() {}
44 }; 45 };
45 46
46 explicit AndroidStreamReaderURLRequestJob( 47 AndroidStreamReaderURLRequestJob(
47 net::URLRequest* request, 48 net::URLRequest* request,
48 net::NetworkDelegate* network_delegate, 49 net::NetworkDelegate* network_delegate,
49 scoped_ptr<Delegate> delegate); 50 scoped_ptr<Delegate> delegate);
50 51
51 // URLRequestJob: 52 // URLRequestJob:
52 virtual void Start() OVERRIDE; 53 virtual void Start() OVERRIDE;
53 virtual bool ReadRawData(net::IOBuffer* buf, 54 virtual bool ReadRawData(net::IOBuffer* buf,
54 int buf_size, 55 int buf_size,
55 int* bytes_read) OVERRIDE; 56 int* bytes_read) OVERRIDE;
56 virtual void SetExtraRequestHeaders( 57 virtual void SetExtraRequestHeaders(
57 const net::HttpRequestHeaders& headers) OVERRIDE; 58 const net::HttpRequestHeaders& headers) OVERRIDE;
58 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; 59 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE;
59 virtual bool GetCharset(std::string* charset) OVERRIDE; 60 virtual bool GetCharset(std::string* charset) OVERRIDE;
60 61
61 protected: 62 protected:
62 virtual ~AndroidStreamReaderURLRequestJob(); 63 virtual ~AndroidStreamReaderURLRequestJob();
63 64
64 private: 65 private:
65 // Verify the requested range against the stream size. 66 // Verify the requested range against the stream size.
66 bool VerifyRequestedRange(JNIEnv* env); 67 bool VerifyRequestedRange(JNIEnv* env);
67 68
68 // Skip to the first byte of the requested read range. 69 // Skip to the first byte of the requested read range.
69 bool SkipToRequestedRange(JNIEnv* env); 70 bool SkipToRequestedRange(JNIEnv* env);
70 71
72 void StartAsync();
73
71 net::HttpByteRange byte_range_; 74 net::HttpByteRange byte_range_;
72 scoped_ptr<Delegate> delegate_; 75 scoped_ptr<Delegate> delegate_;
73 base::android::ScopedJavaGlobalRef<jobject> stream_; 76 base::android::ScopedJavaGlobalRef<jobject> stream_;
74 base::android::ScopedJavaGlobalRef<jbyteArray> buffer_; 77 base::android::ScopedJavaGlobalRef<jbyteArray> buffer_;
78 base::WeakPtrFactory<AndroidStreamReaderURLRequestJob> weak_factory_;
joth 2012/10/15 17:01:46 net::URLRequestJob is refcounted, so it feels like
mnaganov (inactive) 2012/10/15 17:18:25 I was following the practice that the majority of
mkosiba (inactive) 2012/10/15 17:24:03 hmm.. all of the other URLRequestJob impls use a w
75 79
76 DISALLOW_COPY_AND_ASSIGN(AndroidStreamReaderURLRequestJob); 80 DISALLOW_COPY_AND_ASSIGN(AndroidStreamReaderURLRequestJob);
77 }; 81 };
78 82
79 bool RegisterAndroidStreamReaderUrlRequestJob(JNIEnv* env); 83 bool RegisterAndroidStreamReaderUrlRequestJob(JNIEnv* env);
80 84
81 #endif // ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_ 85 #endif // ANDROID_WEBVIEW_NATIVE_ANDROID_STREAM_READER_URL_REQUEST_JOB_H_
OLDNEW
« no previous file with comments | « no previous file | android_webview/native/android_stream_reader_url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698