Commit 71315412 authored by Adam Rice's avatar Adam Rice Committed by Commit Bot

Improve const-correctness for WritableStream classes

Make const accessors return const pointers. Mark more method arguments
as const.

BUG=902633

Change-Id: I4d743be2ab56af4d3a9be493ba4b322d5ef40b41
Reviewed-on: https://chromium-review.googlesource.com/c/1488396Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635920}
parent b1dd9e6c
...@@ -343,7 +343,7 @@ double WritableStreamDefaultController::GetChunkSize( ...@@ -343,7 +343,7 @@ double WritableStreamDefaultController::GetChunkSize(
} }
double WritableStreamDefaultController::GetDesiredSize( double WritableStreamDefaultController::GetDesiredSize(
WritableStreamDefaultController* controller) { const WritableStreamDefaultController* controller) {
// https://streams.spec.whatwg.org/#writable-stream-default-controller-get-desired-size // https://streams.spec.whatwg.org/#writable-stream-default-controller-get-desired-size
// 1. Return controller.[[strategyHWM]] − controller.[[queueTotalSize]]. // 1. Return controller.[[strategyHWM]] − controller.[[queueTotalSize]].
return controller->strategy_high_water_mark_ - return controller->strategy_high_water_mark_ -
...@@ -658,7 +658,7 @@ void WritableStreamDefaultController::ProcessWrite( ...@@ -658,7 +658,7 @@ void WritableStreamDefaultController::ProcessWrite(
} }
bool WritableStreamDefaultController::GetBackpressure( bool WritableStreamDefaultController::GetBackpressure(
WritableStreamDefaultController* controller) { const WritableStreamDefaultController* controller) {
// https://streams.spec.whatwg.org/#writable-stream-default-controller-get-backpressure // https://streams.spec.whatwg.org/#writable-stream-default-controller-get-backpressure
// 1. Let desiredSize be ! WritableStreamDefaultControllerGetDesiredSize( // 1. Let desiredSize be ! WritableStreamDefaultControllerGetDesiredSize(
// controller). // controller).
......
...@@ -73,12 +73,13 @@ class WritableStreamDefaultController final : public ScriptWrappable { ...@@ -73,12 +73,13 @@ class WritableStreamDefaultController final : public ScriptWrappable {
static void Close(ScriptState*, WritableStreamDefaultController*); static void Close(ScriptState*, WritableStreamDefaultController*);
// https://streams.spec.whatwg.org/#writable-stream-default-controller-get-chunk-size // https://streams.spec.whatwg.org/#writable-stream-default-controller-get-chunk-size
// May error the stream as a side-effect.
static double GetChunkSize(ScriptState*, static double GetChunkSize(ScriptState*,
WritableStreamDefaultController*, WritableStreamDefaultController*,
v8::Local<v8::Value> chunk); v8::Local<v8::Value> chunk);
// https://streams.spec.whatwg.org/#writable-stream-default-controller-get-desired-size // https://streams.spec.whatwg.org/#writable-stream-default-controller-get-desired-size
static double GetDesiredSize(WritableStreamDefaultController*); static double GetDesiredSize(const WritableStreamDefaultController*);
// https://streams.spec.whatwg.org/#writable-stream-default-controller-write // https://streams.spec.whatwg.org/#writable-stream-default-controller-write
static void Write(ScriptState*, static void Write(ScriptState*,
...@@ -113,7 +114,7 @@ class WritableStreamDefaultController final : public ScriptWrappable { ...@@ -113,7 +114,7 @@ class WritableStreamDefaultController final : public ScriptWrappable {
v8::Local<v8::Value> chunk); v8::Local<v8::Value> chunk);
// https://streams.spec.whatwg.org/#writable-stream-default-controller-get-backpressure // https://streams.spec.whatwg.org/#writable-stream-default-controller-get-backpressure
static bool GetBackpressure(WritableStreamDefaultController*); static bool GetBackpressure(const WritableStreamDefaultController*);
// https://streams.spec.whatwg.org/#writable-stream-default-controller-error // https://streams.spec.whatwg.org/#writable-stream-default-controller-error
static void Error(ScriptState*, static void Error(ScriptState*,
......
...@@ -77,8 +77,8 @@ class WritableStreamDefaultWriter final : public ScriptWrappable { ...@@ -77,8 +77,8 @@ class WritableStreamDefaultWriter final : public ScriptWrappable {
// not appear in the standard. // not appear in the standard.
// //
StreamPromiseResolver* ClosedPromise() const { return closed_promise_; } StreamPromiseResolver* ClosedPromise() { return closed_promise_; }
StreamPromiseResolver* ReadyPromise() const { return ready_promise_; } StreamPromiseResolver* ReadyPromise() { return ready_promise_; }
void SetReadyPromise(StreamPromiseResolver*); void SetReadyPromise(StreamPromiseResolver*);
......
...@@ -777,7 +777,7 @@ void WritableStreamNative::UpdateBackpressure(ScriptState* script_state, ...@@ -777,7 +777,7 @@ void WritableStreamNative::UpdateBackpressure(ScriptState* script_state,
DCHECK(!CloseQueuedOrInFlight(stream)); DCHECK(!CloseQueuedOrInFlight(stream));
// 3. Let writer be stream.[[writer]]. // 3. Let writer be stream.[[writer]].
const auto writer = stream->writer_; WritableStreamDefaultWriter* writer = stream->writer_;
// 4. If writer is not undefined and backpressure is not // 4. If writer is not undefined and backpressure is not
// stream.[[backpressure]], // stream.[[backpressure]],
......
...@@ -154,7 +154,7 @@ class CORE_EXPORT WritableStreamNative : public WritableStream { ...@@ -154,7 +154,7 @@ class CORE_EXPORT WritableStreamNative : public WritableStream {
bool HasBackpressure() const { return has_backpressure_; } bool HasBackpressure() const { return has_backpressure_; }
StreamPromiseResolver* InFlightWriteRequest() const { const StreamPromiseResolver* InFlightWriteRequest() const {
return in_flight_write_request_; return in_flight_write_request_;
} }
...@@ -164,11 +164,14 @@ class CORE_EXPORT WritableStreamNative : public WritableStream { ...@@ -164,11 +164,14 @@ class CORE_EXPORT WritableStreamNative : public WritableStream {
v8::Local<v8::Value> GetStoredError(v8::Isolate*) const; v8::Local<v8::Value> GetStoredError(v8::Isolate*) const;
WritableStreamDefaultController* Controller() const { WritableStreamDefaultController* Controller() {
return writable_stream_controller_;
}
const WritableStreamDefaultController* Controller() const {
return writable_stream_controller_; return writable_stream_controller_;
} }
WritableStreamDefaultWriter* Writer() const { return writer_; } const WritableStreamDefaultWriter* Writer() const { return writer_; }
void SetCloseRequest(StreamPromiseResolver*); void SetCloseRequest(StreamPromiseResolver*);
void SetController(WritableStreamDefaultController*); void SetController(WritableStreamDefaultController*);
......
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 to comment