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

Side by Side Diff: components/cronet/android/test/javatests/src/org/chromium/net/TestDataProvider.java

Issue 948503004: [Cronet] Enable chunked upload in CronetUrlRequest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix final chunk in TestDataProvider Created 5 years, 9 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
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; 5 package org.chromium.net;
6 6
7 import java.io.IOException; 7 import java.io.IOException;
8 import java.nio.ByteBuffer; 8 import java.nio.ByteBuffer;
9 import java.util.ArrayList; 9 import java.util.ArrayList;
10 import java.util.concurrent.Executor; 10 import java.util.concurrent.Executor;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 assertIdle(); 112 assertIdle();
113 113
114 if (maybeFailRead(currentReadCall, uploadDataSink)) { 114 if (maybeFailRead(currentReadCall, uploadDataSink)) {
115 mFailed = true; 115 mFailed = true;
116 return; 116 return;
117 } 117 }
118 118
119 mReadPending = true; 119 mReadPending = true;
120 mStarted = true; 120 mStarted = true;
121 121
122 final boolean finalChunk = (mChunked && mNextRead == mReads.size()); 122 final boolean finalChunk =
123 (mChunked && ((mNextRead == mReads.size() - 1 && mReads.get(mNex tRead).length == 0)
124 || mNextRead == mReads.size()));
mmenke 2015/02/26 22:30:19 This should actually just be: final boolean final
xunjieli 2015/02/26 22:53:53 I see. That totally makes sense. Was a little conf
123 if (mNextRead < mReads.size()) { 125 if (mNextRead < mReads.size()) {
124 if ((byteBuffer.limit() - byteBuffer.position()) 126 if ((byteBuffer.limit() - byteBuffer.position())
125 < mReads.get(mNextRead).length) { 127 < mReads.get(mNextRead).length) {
126 throw new IllegalStateException( 128 throw new IllegalStateException(
127 "Read buffer smaller than expected."); 129 "Read buffer smaller than expected.");
128 } 130 }
129 byteBuffer.put(mReads.get(mNextRead)); 131 byteBuffer.put(mReads.get(mNextRead));
130 ++mNextRead; 132 ++mNextRead;
131 } else if (!finalChunk) { 133 } else if (!finalChunk) {
132 throw new IllegalStateException( 134 throw new IllegalStateException(
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 "Async rewind failure")); 238 "Async rewind failure"));
237 } 239 }
238 }; 240 };
239 mExecutor.execute(errorRunnable); 241 mExecutor.execute(errorRunnable);
240 return true; 242 return true;
241 default: 243 default:
242 return false; 244 return false;
243 } 245 }
244 } 246 }
245 } 247 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698