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

Issue 11363123: [android_webview] Don't block the IO thread when reading from an InputStream. (Closed)

Created:
8 years, 1 month ago by mkosiba (inactive)
Modified:
8 years, 1 month ago
Reviewers:
joth, benm (inactive)
CC:
chromium-reviews, android-webview-reviews_chromium.org
Visibility:
Public.

Description

[android_webview] Don't block the IO thread when reading from an InputStream. This breaks up the functionality in the AndroidStreamReader..Job into three separate classes, adds native unittests and makes the Job read the InputStream on a background thread. This change adds a separate unittestjava folder because the code under javatests can't be compiled to be a part of a native unittest APK due to resource dependencies. TEST=AndroidWebviewTests,android_webview_unittests BUG=None Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=169274

Patch Set 1 #

Total comments: 1

Patch Set 2 : fix clang error #

Total comments: 24

Patch Set 3 : simplified threading, simplified unittests, moved some classes to browser/ #

Patch Set 4 : remove jobj from browser/input_stream.h #

Total comments: 3

Patch Set 5 : reinterpret_cast->static_cast #

Total comments: 8

Patch Set 6 : rebase #

Patch Set 7 : #

Patch Set 8 : fix double-free #

Total comments: 31

Patch Set 9 : address Joth's comments #

Patch Set 10 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1298 lines, -380 lines) Patch
M android_webview/android_webview.gyp View 1 2 3 4 5 6 7 8 9 2 chunks +5 lines, -0 lines 0 comments Download
M android_webview/android_webview_tests.gypi View 1 2 3 4 5 6 7 8 2 chunks +33 lines, -1 line 0 comments Download
A android_webview/browser/input_stream.h View 1 2 3 4 5 6 7 8 1 chunk +48 lines, -0 lines 0 comments Download
A + android_webview/browser/net/android_stream_reader_url_request_job.h View 1 2 3 4 5 6 7 8 9 4 chunks +27 lines, -12 lines 0 comments Download
A android_webview/browser/net/android_stream_reader_url_request_job.cc View 1 2 3 4 5 6 7 8 9 1 chunk +189 lines, -0 lines 0 comments Download
A android_webview/browser/net/android_stream_reader_url_request_job_unittest.cc View 1 2 3 4 5 6 7 8 9 1 chunk +311 lines, -0 lines 0 comments Download
A android_webview/browser/net/input_stream_reader.h View 1 2 3 4 5 6 7 8 1 chunk +66 lines, -0 lines 0 comments Download
A android_webview/browser/net/input_stream_reader.cc View 1 2 3 4 5 6 7 8 1 chunk +98 lines, -0 lines 0 comments Download
A android_webview/browser/net/input_stream_reader_unittest.cc View 1 2 3 4 5 6 1 chunk +172 lines, -0 lines 0 comments Download
M android_webview/native/android_protocol_handler.cc View 1 2 3 4 5 6 6 chunks +15 lines, -15 lines 0 comments Download
M android_webview/native/android_stream_reader_url_request_job.h View 1 2 1 chunk +0 lines, -85 lines 0 comments Download
M android_webview/native/android_stream_reader_url_request_job.cc View 1 2 1 chunk +0 lines, -240 lines 0 comments Download
D android_webview/native/android_stream_reader_url_request_job_unittests.cc View 1 chunk +0 lines, -13 lines 0 comments Download
M android_webview/native/android_webview_jni_registrar.cc View 1 2 3 4 5 6 3 chunks +2 lines, -3 lines 0 comments Download
A android_webview/native/input_stream_impl.h View 1 2 3 4 5 6 7 8 1 chunk +53 lines, -0 lines 0 comments Download
A android_webview/native/input_stream_impl.cc View 1 2 3 4 5 6 7 8 9 1 chunk +121 lines, -0 lines 0 comments Download
A android_webview/native/input_stream_unittest.cc View 1 2 3 4 5 6 1 chunk +100 lines, -0 lines 0 comments Download
M android_webview/native/intercepted_request_data_impl.h View 2 chunks +4 lines, -2 lines 0 comments Download
M android_webview/native/intercepted_request_data_impl.cc View 1 2 3 chunks +12 lines, -7 lines 0 comments Download
M android_webview/native/webview_native.gyp View 1 2 3 4 5 6 7 8 2 chunks +2 lines, -2 lines 0 comments Download
A android_webview/unittestjava/src/org/chromium/android_webview/unittest/InputStreamUnittest.java View 1 chunk +40 lines, -0 lines 0 comments Download

Messages

Total messages: 14 (0 generated)
mkosiba (inactive)
8 years, 1 month ago (2012-11-07 16:12:03 UTC) #1
joth
I didn't read every line in massive detail, but got some more general thoughts on ...
8 years, 1 month ago (2012-11-07 16:55:38 UTC) #2
benm (inactive)
http://codereview.chromium.org/11363123/diff/19/android_webview/native/android_stream_reader_url_request_job.cc File android_webview/native/android_stream_reader_url_request_job.cc (right): http://codereview.chromium.org/11363123/diff/19/android_webview/native/android_stream_reader_url_request_job.cc#newcode127 android_webview/native/android_stream_reader_url_request_job.cc:127: void AndroidStreamReaderURLRequestJob::OnReaderReadCompleted( Please add a comment to explain the ...
8 years, 1 month ago (2012-11-15 17:39:01 UTC) #3
mkosiba (inactive)
new version out. http://codereview.chromium.org/11363123/diff/19/android_webview/native/android_stream_reader_url_request_job.cc File android_webview/native/android_stream_reader_url_request_job.cc (right): http://codereview.chromium.org/11363123/diff/19/android_webview/native/android_stream_reader_url_request_job.cc#newcode8 android_webview/native/android_stream_reader_url_request_job.cc:8: #include "android_webview/native/input_stream_reader.h" On 2012/11/07 16:55:38, joth ...
8 years, 1 month ago (2012-11-15 19:18:50 UTC) #4
joth
http://codereview.chromium.org/11363123/diff/13002/android_webview/native/input_stream_impl.cc File android_webview/native/input_stream_impl.cc (right): http://codereview.chromium.org/11363123/diff/13002/android_webview/native/input_stream_impl.cc#newcode33 android_webview/native/input_stream_impl.cc:33: return reinterpret_cast<const InputStreamImpl*>(input_stream); On 2012/11/15 19:18:51, Martin Kosiba wrote: ...
8 years, 1 month ago (2012-11-15 20:04:26 UTC) #5
mkosiba (inactive)
https://chromiumcodereview.appspot.com/11363123/diff/13002/android_webview/native/input_stream_impl.cc File android_webview/native/input_stream_impl.cc (right): https://chromiumcodereview.appspot.com/11363123/diff/13002/android_webview/native/input_stream_impl.cc#newcode33 android_webview/native/input_stream_impl.cc:33: return reinterpret_cast<const InputStreamImpl*>(input_stream); On 2012/11/15 20:04:26, joth wrote: > ...
8 years, 1 month ago (2012-11-16 14:47:01 UTC) #6
benm (inactive)
http://codereview.chromium.org/11363123/diff/21001/android_webview/browser/input_stream.h File android_webview/browser/input_stream.h (right): http://codereview.chromium.org/11363123/diff/21001/android_webview/browser/input_stream.h#newcode39 android_webview/browser/input_stream.h:39: virtual bool Read(JNIEnv* env, would be nice to eliminate ...
8 years, 1 month ago (2012-11-16 15:43:19 UTC) #7
mkosiba (inactive)
https://chromiumcodereview.appspot.com/11363123/diff/21001/android_webview/browser/input_stream.h File android_webview/browser/input_stream.h (right): https://chromiumcodereview.appspot.com/11363123/diff/21001/android_webview/browser/input_stream.h#newcode39 android_webview/browser/input_stream.h:39: virtual bool Read(JNIEnv* env, On 2012/11/16 15:43:20, benm wrote: ...
8 years, 1 month ago (2012-11-19 15:29:33 UTC) #8
mkosiba (inactive)
ok, so looks like the latest patch fixes the double-free in unittests - care to ...
8 years, 1 month ago (2012-11-20 10:49:11 UTC) #9
joth
lgtm. just nits https://codereview.chromium.org/11363123/diff/12025/android_webview/browser/input_stream.h File android_webview/browser/input_stream.h (right): https://codereview.chromium.org/11363123/diff/12025/android_webview/browser/input_stream.h#newcode16 android_webview/browser/input_stream.h:16: class InputStream { nit: comment it's ...
8 years, 1 month ago (2012-11-20 20:46:34 UTC) #10
mkosiba (inactive)
https://codereview.chromium.org/11363123/diff/12025/android_webview/browser/input_stream.h File android_webview/browser/input_stream.h (right): https://codereview.chromium.org/11363123/diff/12025/android_webview/browser/input_stream.h#newcode16 android_webview/browser/input_stream.h:16: class InputStream { On 2012/11/20 20:46:35, joth wrote: > ...
8 years, 1 month ago (2012-11-21 15:19:47 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/mkosiba@chromium.org/11363123/11025
8 years, 1 month ago (2012-11-21 18:19:57 UTC) #12
commit-bot: I haz the power
Presubmit check for 11363123-11025 failed and returned exit status 1. Running presubmit commit checks ...
8 years, 1 month ago (2012-11-21 18:20:18 UTC) #13
joth
8 years, 1 month ago (2012-11-21 21:11:00 UTC) #14
https://codereview.chromium.org/11363123/diff/12025/android_webview/browser/n...
File android_webview/browser/net/android_stream_reader_url_request_job.h
(right):

https://codereview.chromium.org/11363123/diff/12025/android_webview/browser/n...
android_webview/browser/net/android_stream_reader_url_request_job.h:81: virtual
android_webview::InputStreamReader*
On 2012/11/21 15:19:47, Martin Kosiba wrote:
> On 2012/11/20 20:46:35, joth wrote:
> > comment ownership is not returned. (I come from a world where CreateXxx
always
> > returned ownership. maybe use a different method name if you think of one).
> 
> umm.. why do you think ownership is not returned? this is a regular factory
> method (in the sense that the caller must take ownership of the result), the
> fact that the caller is the same class as the method is implemented shouldn't
> matter.

I've become too used to see scoped_ptr to indicate ownership transfer; forgot
all about refcounted. (also the scoped members below confused me into thinking
ownership was retained)

- could comment why this is virtual; seems it could be static. (or indeed, why
it exists at all)
- could return scoped_refptr<> to be super clear. (until recently it was
unadvised to do that due to the implicit conversion to T*, but now that's going 
I think it makes a lot of sense to return the full owning type and makes it
nicely consistent with contemporary scoped_ptr usage patterns.)

Powered by Google App Engine
This is Rietveld 408576698