Commit 01b69854 by sammon Committed by Oliver Woodman

Refactoring DataSpec constructor calls to use DataSpec.withUri() and DataSpec.subrange().

This reduces the number of calls to the DataSpec constructor and minimizes the number of files that need to be updated when adding a new DataSpec parameter (ex: followup []

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=205719005
parent 61b838f4
......@@ -622,15 +622,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
request.followRedirect();
} else {
currentUrlRequest.cancel();
DataSpec redirectUrlDataSpec =
new DataSpec(
Uri.parse(newLocationUrl),
currentDataSpec.postBody,
currentDataSpec.absoluteStreamPosition,
currentDataSpec.position,
currentDataSpec.length,
currentDataSpec.key,
currentDataSpec.flags);
DataSpec redirectUrlDataSpec = currentDataSpec.withUri(Uri.parse(newLocationUrl));
UrlRequest.Builder requestBuilder;
try {
requestBuilder = buildRequestBuilder(redirectUrlDataSpec);
......
......@@ -56,14 +56,7 @@ public final class TeeDataSource implements DataSource {
}
if (dataSpec.length == C.LENGTH_UNSET && bytesRemaining != C.LENGTH_UNSET) {
// Reconstruct dataSpec in order to provide the resolved length to the sink.
dataSpec =
new DataSpec(
dataSpec.uri,
dataSpec.absoluteStreamPosition,
dataSpec.position,
bytesRemaining,
dataSpec.key,
dataSpec.flags);
dataSpec = dataSpec.subrange(0, bytesRemaining);
}
dataSinkNeedsClosing = true;
dataSink.open(dataSpec);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment