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

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

Issue 1928753002: Increase buffer size in CronetFixedModeOutputStream to 16kB (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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.urlconnection; 5 package org.chromium.net.urlconnection;
6 6
7 import org.chromium.base.VisibleForTesting; 7 import org.chromium.base.VisibleForTesting;
8 import org.chromium.net.UploadDataProvider; 8 import org.chromium.net.UploadDataProvider;
9 import org.chromium.net.UploadDataSink; 9 import org.chromium.net.UploadDataSink;
10 10
11 import java.io.IOException; 11 import java.io.IOException;
12 import java.net.HttpRetryException; 12 import java.net.HttpRetryException;
13 import java.net.ProtocolException; 13 import java.net.ProtocolException;
14 import java.nio.ByteBuffer; 14 import java.nio.ByteBuffer;
15 15
16 /** 16 /**
17 * An implementation of {@link java.io.OutputStream} to send data to a server, 17 * An implementation of {@link java.io.OutputStream} to send data to a server,
18 * when {@link CronetHttpURLConnection#setFixedLengthStreamingMode} is used. 18 * when {@link CronetHttpURLConnection#setFixedLengthStreamingMode} is used.
19 * This implementation does not buffer the entire request body in memory. 19 * This implementation does not buffer the entire request body in memory.
20 * It does not support rewind. Note that {@link #write} should only be called 20 * It does not support rewind. Note that {@link #write} should only be called
21 * from the thread on which the {@link #mConnection} is created. 21 * from the thread on which the {@link #mConnection} is created.
22 */ 22 */
23 final class CronetFixedModeOutputStream extends CronetOutputStream { 23 final class CronetFixedModeOutputStream extends CronetOutputStream {
24 // CronetFixedModeOutputStream buffers up to this value and wait for UploadD ataStream 24 // CronetFixedModeOutputStream buffers up to this value and wait for UploadD ataStream
25 // to consume the data. This field is non-final, so it can be changed for te sts. 25 // to consume the data. This field is non-final, so it can be changed for te sts.
26 // Using 2048 bytes is because the internal read buffer is 14520 for QUIC, 26 // Using 16384 bytes is because the internal read buffer is 14520 for QUIC,
27 // 2852 for SPDY, and 16384 for normal stream. If a large value is used 27 // 16384 for SPDY, and 16384 for normal HTTP/1.1 stream.
28 // here, the buffer might not fit the internal buffer and compacting the buf fer
29 // will be costly, see #read method below.
30 @VisibleForTesting 28 @VisibleForTesting
31 private static int sDefaultBufferLength = 2048; 29 private static int sDefaultBufferLength = 16384;
32 private final CronetHttpURLConnection mConnection; 30 private final CronetHttpURLConnection mConnection;
33 private final MessageLoop mMessageLoop; 31 private final MessageLoop mMessageLoop;
34 private final long mContentLength; 32 private final long mContentLength;
35 private final ByteBuffer mBuffer; 33 private final ByteBuffer mBuffer;
36 private final UploadDataProvider mUploadDataProvider = new UploadDataProvide rImpl(); 34 private final UploadDataProvider mUploadDataProvider = new UploadDataProvide rImpl();
37 private long mBytesWritten; 35 private long mBytesWritten;
38 36
39 /** 37 /**
40 * Package protected constructor. 38 * Package protected constructor.
41 * @param connection The CronetHttpURLConnection object. 39 * @param connection The CronetHttpURLConnection object.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 170 }
173 171
174 /** 172 /**
175 * Sets the default buffer length for use in tests. 173 * Sets the default buffer length for use in tests.
176 */ 174 */
177 @VisibleForTesting 175 @VisibleForTesting
178 static void setDefaultBufferLengthForTesting(int length) { 176 static void setDefaultBufferLengthForTesting(int length) {
179 sDefaultBufferLength = length; 177 sDefaultBufferLength = length;
180 } 178 }
181 } 179 }
OLDNEW
« no previous file with comments | « no previous file | components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698