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

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: Multiple chunks 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 = (mChunked && mNextRead == mReads.size() - 1);
123 if (mNextRead < mReads.size()) { 123 if (mNextRead < mReads.size()) {
124 if ((byteBuffer.limit() - byteBuffer.position()) 124 if ((byteBuffer.limit() - byteBuffer.position())
125 < mReads.get(mNextRead).length) { 125 < mReads.get(mNextRead).length) {
126 throw new IllegalStateException( 126 throw new IllegalStateException(
127 "Read buffer smaller than expected."); 127 "Read buffer smaller than expected.");
128 } 128 }
129 byteBuffer.put(mReads.get(mNextRead)); 129 byteBuffer.put(mReads.get(mNextRead));
130 ++mNextRead; 130 ++mNextRead;
131 } else if (!finalChunk) { 131 } else {
132 throw new IllegalStateException( 132 throw new IllegalStateException(
133 "Too many reads: " + mNextRead); 133 "Too many reads: " + mNextRead);
134 } 134 }
135 135
136 Runnable completeRunnable = new Runnable() { 136 Runnable completeRunnable = new Runnable() {
137 @Override 137 @Override
138 public void run() { 138 public void run() {
139 mReadPending = false; 139 mReadPending = false;
140 uploadDataSink.onReadSucceeded(finalChunk); 140 uploadDataSink.onReadSucceeded(finalChunk);
141 } 141 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 "Async rewind failure")); 236 "Async rewind failure"));
237 } 237 }
238 }; 238 };
239 mExecutor.execute(errorRunnable); 239 mExecutor.execute(errorRunnable);
240 return true; 240 return true;
241 default: 241 default:
242 return false; 242 return false;
243 } 243 }
244 } 244 }
245 } 245 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698