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

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

Issue 2137163002: Remove unnecessary loop and quit in CronetChunkedOutputStream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 package org.chromium.net.urlconnection; 5 package org.chromium.net.urlconnection;
6 6
7 import org.chromium.net.UploadDataProvider; 7 import org.chromium.net.UploadDataProvider;
8 import org.chromium.net.UploadDataSink; 8 import org.chromium.net.UploadDataSink;
9 9
10 import java.io.IOException; 10 import java.io.IOException;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 int sent = Math.min(toSend, mBuffer.limit() - mBuffer.position()); 76 int sent = Math.min(toSend, mBuffer.limit() - mBuffer.position());
77 mBuffer.put(buffer, offset + count - toSend, sent); 77 mBuffer.put(buffer, offset + count - toSend, sent);
78 toSend -= sent; 78 toSend -= sent;
79 } 79 }
80 mBytesWritten += count; 80 mBytesWritten += count;
81 } 81 }
82 82
83 @Override 83 @Override
84 public void close() throws IOException { 84 public void close() throws IOException {
85 if (!mLastChunk) { 85 // Last chunk is written.
86 // Write last chunk. 86 mLastChunk = true;
87 mLastChunk = true;
88 mMessageLoop.loop();
89 }
90 mClosed = true; 87 mClosed = true;
91 } 88 }
92 89
93 private void checkNotClosed() throws IOException { 90 private void checkNotClosed() throws IOException {
94 if (mClosed) { 91 if (mClosed) {
95 throw new IOException("Stream has been closed."); 92 throw new IOException("Stream has been closed.");
96 } 93 }
97 } 94 }
98 95
99 // Below are CronetOutputStream implementations: 96 // Below are CronetOutputStream implementations:
(...skipping 30 matching lines...) Expand all
130 // Move remaining buffer to the head of the buffer for use in th e 127 // Move remaining buffer to the head of the buffer for use in th e
131 // next read call. 128 // next read call.
132 mBuffer.compact(); 129 mBuffer.compact();
133 uploadDataSink.onReadSucceeded(false); 130 uploadDataSink.onReadSucceeded(false);
134 } else { 131 } else {
135 // byteBuffer has enough capacity to hold the content of mBuffer . 132 // byteBuffer has enough capacity to hold the content of mBuffer .
136 mBuffer.flip(); 133 mBuffer.flip();
137 byteBuffer.put(mBuffer); 134 byteBuffer.put(mBuffer);
138 // Reuse this buffer. 135 // Reuse this buffer.
139 mBuffer.clear(); 136 mBuffer.clear();
140 // Quit message loop so embedder can write more data.
141 mMessageLoop.quit();
142 uploadDataSink.onReadSucceeded(mLastChunk); 137 uploadDataSink.onReadSucceeded(mLastChunk);
138 if (!mLastChunk) {
139 // Quit message loop so embedder can write more data.
140 mMessageLoop.quit();
141 }
143 } 142 }
144 } 143 }
145 144
146 @Override 145 @Override
147 public void rewind(UploadDataSink uploadDataSink) { 146 public void rewind(UploadDataSink uploadDataSink) {
148 uploadDataSink.onRewindError( 147 uploadDataSink.onRewindError(
149 new HttpRetryException("Cannot retry streamed Http body", -1 )); 148 new HttpRetryException("Cannot retry streamed Http body", -1 ));
150 } 149 }
151 } 150 }
152 } 151 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698