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

Unified Diff: components/cronet/android/api/src/org/chromium/net/JavaUrlRequest.java

Issue 2283513002: [Cronet] JavaUrlRequest - Don't call close() on a user thread - it can do I/O. (Closed)
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/cronet/android/api/src/org/chromium/net/JavaUrlRequest.java
diff --git a/components/cronet/android/api/src/org/chromium/net/JavaUrlRequest.java b/components/cronet/android/api/src/org/chromium/net/JavaUrlRequest.java
index fe562799cda82ac2dda37922425f7e4ca9ba1ad6..aafc1309d01d96f7c2d6c81036f8287fb58a38d2 100644
--- a/components/cronet/android/api/src/org/chromium/net/JavaUrlRequest.java
+++ b/components/cronet/android/api/src/org/chromium/net/JavaUrlRequest.java
@@ -799,7 +799,7 @@ final class JavaUrlRequest implements UrlRequest {
}
void onCanceled(final UrlResponseInfo info) {
- closeQuietly(mResponseChannel);
+ closeResponseChannel();
mef 2016/08/25 22:23:54 would it make sense to just call closeQuietly from
Charles 2016/08/26 15:58:19 No, because then we'd be doing I/O on the user's e
mef 2016/08/26 16:14:11 Oh, I see. I've missed that those are different ex
mUserExecutor.execute(new Runnable() {
@Override
public void run() {
@@ -826,7 +826,7 @@ final class JavaUrlRequest implements UrlRequest {
}
void onFailed(final UrlResponseInfo urlResponseInfo, final UrlRequestException e) {
- closeQuietly(mResponseChannel);
+ closeResponseChannel();
mUserExecutor.execute(new Runnable() {
@Override
public void run() {
@@ -840,14 +840,21 @@ final class JavaUrlRequest implements UrlRequest {
}
}
- private static void closeQuietly(Closeable closeable) {
+ private void closeResponseChannel() {
+ final Closeable closeable = mResponseChannel;
if (closeable == null) {
return;
}
- try {
- closeable.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
+ mResponseChannel = null;
+ mExecutor.execute(new Runnable() {
mef 2016/08/26 16:14:11 what if mExecutor rejects execution?
Charles 2016/08/26 18:15:51 It can't, we use an unbounded thread pool that's n
+ @Override
+ public void run() {
+ try {
+ closeable.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ });
}
}

Powered by Google App Engine
This is Rietveld 408576698