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

Unified Diff: components/cronet/android/java/src/org/chromium/net/urlconnection/CronetChunkedOutputStream.java

Issue 2131323002: [Cronet] Check whether request is done before spinning up message loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comment Created 4 years, 5 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/java/src/org/chromium/net/urlconnection/CronetChunkedOutputStream.java
diff --git a/components/cronet/android/java/src/org/chromium/net/urlconnection/CronetChunkedOutputStream.java b/components/cronet/android/java/src/org/chromium/net/urlconnection/CronetChunkedOutputStream.java
index 1f2c1711f7f01a81735455e18e8fd694bf5c46b6..4c83bfc8fea193d986308ed20cb36fa18b963e73 100644
--- a/components/cronet/android/java/src/org/chromium/net/urlconnection/CronetChunkedOutputStream.java
+++ b/components/cronet/android/java/src/org/chromium/net/urlconnection/CronetChunkedOutputStream.java
@@ -25,7 +25,6 @@ final class CronetChunkedOutputStream extends CronetOutputStream {
private final UploadDataProvider mUploadDataProvider = new UploadDataProviderImpl();
private long mBytesWritten;
private boolean mLastChunk = false;
- private boolean mClosed = false;
/**
* Package protected constructor.
@@ -68,8 +67,10 @@ final class CronetChunkedOutputStream extends CronetOutputStream {
return;
}
int toSend = count;
+ // TODO(xunjieli): refactor commond code with CronetFixedModeOutputStream.
while (toSend > 0) {
if (mBuffer.position() == mBuffer.limit()) {
+ checkNotClosed();
// Wait until buffer is consumed.
mMessageLoop.loop();
}
@@ -82,15 +83,9 @@ final class CronetChunkedOutputStream extends CronetOutputStream {
@Override
public void close() throws IOException {
+ super.close();
// Last chunk is written.
mLastChunk = true;
- mClosed = true;
- }
-
- private void checkNotClosed() throws IOException {
- if (mClosed) {
- throw new IOException("Stream has been closed.");
- }
}
// Below are CronetOutputStream implementations:

Powered by Google App Engine
This is Rietveld 408576698