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

Unified Diff: android_webview/native/android_protocol_handler.cc

Issue 11363123: [android_webview] Don't block the IO thread when reading from an InputStream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang error Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: android_webview/native/android_protocol_handler.cc
diff --git a/android_webview/native/android_protocol_handler.cc b/android_webview/native/android_protocol_handler.cc
index de6059f9df6f8c5f98060423e71b9930db16f1d0..c5b8c5c9dd3890806ed5066165782330c44d7f75 100644
--- a/android_webview/native/android_protocol_handler.cc
+++ b/android_webview/native/android_protocol_handler.cc
@@ -5,6 +5,7 @@
// URL request job for reading from resources and assets.
#include "android_webview/native/android_protocol_handler.h"
+#include "android_webview/native/input_stream.h"
#include "android_webview/common/url_constants.h"
#include "android_webview/native/android_stream_reader_url_request_job.h"
@@ -47,18 +48,18 @@ class AndroidStreamReaderURLRequestJobDelegateImpl
public:
AndroidStreamReaderURLRequestJobDelegateImpl();
- virtual ScopedJavaLocalRef<jobject> OpenInputStream(
+ virtual scoped_ptr<android_webview::InputStream> OpenInputStream(
JNIEnv* env,
net::URLRequest* request) OVERRIDE;
virtual bool GetMimeType(JNIEnv* env,
net::URLRequest* request,
- jobject stream,
+ const android_webview::InputStream& stream,
std::string* mime_type) OVERRIDE;
virtual bool GetCharset(JNIEnv* env,
net::URLRequest* request,
- jobject stream,
+ const android_webview::InputStream& stream,
std::string* charset) OVERRIDE;
virtual ~AndroidStreamReaderURLRequestJobDelegateImpl();
@@ -124,7 +125,7 @@ AndroidStreamReaderURLRequestJobDelegateImpl::
~AndroidStreamReaderURLRequestJobDelegateImpl() {
}
-ScopedJavaLocalRef<jobject>
+scoped_ptr<android_webview::InputStream>
AndroidStreamReaderURLRequestJobDelegateImpl::OpenInputStream(
JNIEnv* env, net::URLRequest* request) {
DCHECK(request);
@@ -142,23 +143,20 @@ AndroidStreamReaderURLRequestJobDelegateImpl::OpenInputStream(
// Check and clear pending exceptions.
if (ClearException(env) || stream.is_null()) {
DLOG(ERROR) << "Unable to open input stream for Android URL";
- return ScopedJavaLocalRef<jobject>(env, NULL);
+ return scoped_ptr<android_webview::InputStream>();
}
- return stream;
+ return make_scoped_ptr(new android_webview::InputStream(stream));
}
bool AndroidStreamReaderURLRequestJobDelegateImpl::GetMimeType(
JNIEnv* env,
net::URLRequest* request,
- jobject stream,
+ const android_webview::InputStream& stream,
std::string* mime_type) {
DCHECK(env);
DCHECK(request);
DCHECK(mime_type);
- if (!stream)
- return false;
-
// Query the mime type from the Java side. It is possible for the query to
// fail, as the mime type cannot be determined for all supported schemes.
ScopedJavaLocalRef<jstring> url =
@@ -167,7 +165,7 @@ bool AndroidStreamReaderURLRequestJobDelegateImpl::GetMimeType(
android_webview::Java_AndroidProtocolHandler_getMimeType(
env,
GetResourceContext(env).obj(),
- stream, url.obj());
+ stream.jobj(), url.obj());
if (ClearException(env) || returned_type.is_null())
return false;
@@ -178,7 +176,7 @@ bool AndroidStreamReaderURLRequestJobDelegateImpl::GetMimeType(
bool AndroidStreamReaderURLRequestJobDelegateImpl::GetCharset(
JNIEnv* env,
net::URLRequest* request,
- jobject stream,
+ const android_webview::InputStream& stream,
std::string* charset) {
// TODO: We should probably be getting this from the managed side.
return false;

Powered by Google App Engine
This is Rietveld 408576698