Skip to content

Commit

Permalink
Remove CountingOutputStream (facebook#49275)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#49275

This is a copied guava class and is only used in one spot.  Remove it and just count directly in ProgressRequestBody.

Changelog: [Internal]

Reviewed By: Abbondanzo

Differential Revision: D69323277

fbshipit-source-id: 5260004a4431f03733882b6ee83a341d8bf29bb0
  • Loading branch information
javache authored and facebook-github-bot committed Feb 12, 2025
1 parent 2b30aa5 commit 403719c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 196 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package com.facebook.react.modules.network;

import java.io.FilterOutputStream;
import java.io.IOException;
import okhttp3.MediaType;
import okhttp3.RequestBody;
Expand Down Expand Up @@ -55,21 +56,25 @@ public void writeTo(BufferedSink sink) throws IOException {

private Sink outputStreamSink(BufferedSink sink) {
return Okio.sink(
new CountingOutputStream(sink.outputStream()) {
new FilterOutputStream(sink.outputStream()) {
private long mCount = 0;

@Override
public void write(byte[] data, int offset, int byteCount) throws IOException {
super.write(data, offset, byteCount);
mCount += byteCount;
sendProgressUpdate();
}

@Override
public void write(int data) throws IOException {
super.write(data);
mCount++;
sendProgressUpdate();
}

private void sendProgressUpdate() throws IOException {
long bytesWritten = getCount();
long bytesWritten = mCount;
long contentLength = contentLength();
mProgressListener.onProgress(
bytesWritten, contentLength, bytesWritten == contentLength);
Expand Down

This file was deleted.

0 comments on commit 403719c

Please sign in to comment.