Skip to content

Commit

Permalink
Clean up Guava usage (CountingOutputStream) (facebook#43942)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#43942

Move the counting inline to remove its only usage

Changelog: [Internal]

Reviewed By: zeyap

Differential Revision: D55802174
  • Loading branch information
Thomas Nardone authored and facebook-github-bot committed Apr 22, 2024
1 parent 21795ad commit f49bc8d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 60 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 @@ -48,16 +49,20 @@ internal class ProgressRequestBody(

private fun outputStreamSink(sink: BufferedSink): Sink =
Okio.sink(
object : CountingOutputStream(sink.outputStream()) {
object : FilterOutputStream(sink.outputStream()) {
private var count = 0L

@Throws(IOException::class)
override fun write(b: ByteArray, off: Int, len: Int) {
super.write(b, off, len)
count += len.toLong()
sendProgressUpdate()
}

@Throws(IOException::class)
override fun write(b: Int) {
super.write(b)
count++
sendProgressUpdate()
}

Expand Down

0 comments on commit f49bc8d

Please sign in to comment.