| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 android.os.ParcelFileDescriptor; | 7 import android.os.ParcelFileDescriptor; |
| 8 | 8 |
| 9 import java.io.File; | 9 import java.io.File; |
| 10 import java.io.FileInputStream; | 10 import java.io.FileInputStream; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * Uploads {@code length} bytes from {@code data}, starting from {@code offs
et} | 65 * Uploads {@code length} bytes from {@code data}, starting from {@code offs
et} |
| 66 * @param data Array containing data to upload | 66 * @param data Array containing data to upload |
| 67 * @param offset Offset within data to start with | 67 * @param offset Offset within data to start with |
| 68 * @param length Number of bytes to upload | 68 * @param length Number of bytes to upload |
| 69 * @return A new UploadDataProvider for the given data | 69 * @return A new UploadDataProvider for the given data |
| 70 */ | 70 */ |
| 71 public static UploadDataProvider create(byte[] data, int offset, int length)
{ | 71 public static UploadDataProvider create(byte[] data, int offset, int length)
{ |
| 72 return new ByteBufferUploadProvider(ByteBuffer.wrap(data, offset, length
)); | 72 return new ByteBufferUploadProvider(ByteBuffer.wrap(data, offset, length
).slice()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 /** | 75 /** |
| 76 * Uploads the contents of {@code data} | 76 * Uploads the contents of {@code data} |
| 77 * @param data Array containing data to upload | 77 * @param data Array containing data to upload |
| 78 * @return A new UploadDataProvider for the given data | 78 * @return A new UploadDataProvider for the given data |
| 79 */ | 79 */ |
| 80 public static UploadDataProvider create(byte[] data) { | 80 public static UploadDataProvider create(byte[] data) { |
| 81 return create(data, 0, data.length); | 81 return create(data, 0, data.length); |
| 82 } | 82 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 @Override | 177 @Override |
| 178 public void rewind(UploadDataSink uploadDataSink) { | 178 public void rewind(UploadDataSink uploadDataSink) { |
| 179 mUploadBuffer.position(0); | 179 mUploadBuffer.position(0); |
| 180 uploadDataSink.onRewindSucceeded(); | 180 uploadDataSink.onRewindSucceeded(); |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 | 183 |
| 184 // Prevent instantiation | 184 // Prevent instantiation |
| 185 private UploadDataProviders() {} | 185 private UploadDataProviders() {} |
| 186 } | 186 } |
| OLD | NEW |