Skip to content

Commit

Permalink
Remove deprecated DISALLOW_ macros from /third_party/blink/renderer/c…
Browse files Browse the repository at this point in the history
…ore/fetch

Macros such as DISALLOW_COPY_AND_ASSIGN() are deprecated since r711900
per style arbitration [1]. This commit replaces the macros with deleted
constructors and methods, which is preferred by the Google C++ Style
Guide [2][3].

Also remove unneeded "base/macros.h" #includes when possible.

[1]: https://groups.google.com/a/chromium.org/g/cxx/c/qwH2hxaEjac/m/TUKq6eqfCwAJ
[2]: https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++-dos-and-donts.md#explicitly-declare-class-copyability_movability
[3]: https://google.github.io/styleguide/cppguide.html#Copyable_Movable_Types

This CL was uploaded by git cl split.

R=yhirano@chromium.org

Bug: 1010217
Change-Id: Ibfdaea73fc89a6a5a1e407d4b69c6720fc8f2c9d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2958472
Auto-Submit: Timothy Gu <timothygu@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#891979}
  • Loading branch information
TimothyGu authored and Chromium LUCI CQ committed Jun 14, 2021
1 parent c56af53 commit c615b59
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 24 deletions.
19 changes: 13 additions & 6 deletions third_party/blink/renderer/core/fetch/body.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class BodyConsumerBase : public GarbageCollected<BodyConsumerBase>,
: resolver_(resolver),
task_runner_(ExecutionContext::From(resolver_->GetScriptState())
->GetTaskRunner(TaskType::kNetworking)) {}
BodyConsumerBase(const BodyConsumerBase&) = delete;
BodyConsumerBase& operator=(const BodyConsumerBase&) = delete;

ScriptPromiseResolver* Resolver() { return resolver_; }
void DidFetchDataLoadFailed() override {
ScriptState::Scope scope(Resolver()->GetScriptState());
Expand Down Expand Up @@ -75,37 +78,40 @@ class BodyConsumerBase : public GarbageCollected<BodyConsumerBase>,

const Member<ScriptPromiseResolver> resolver_;
const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
DISALLOW_COPY_AND_ASSIGN(BodyConsumerBase);
};

class BodyBlobConsumer final : public BodyConsumerBase {
public:
explicit BodyBlobConsumer(ScriptPromiseResolver* resolver)
: BodyConsumerBase(resolver) {}
BodyBlobConsumer(const BodyBlobConsumer&) = delete;
BodyBlobConsumer& operator=(const BodyBlobConsumer&) = delete;

void DidFetchDataLoadedBlobHandle(
scoped_refptr<BlobDataHandle> blob_data_handle) override {
ResolveLater(WrapPersistent(
MakeGarbageCollected<Blob>(std::move(blob_data_handle))));
}
DISALLOW_COPY_AND_ASSIGN(BodyBlobConsumer);
};

class BodyArrayBufferConsumer final : public BodyConsumerBase {
public:
explicit BodyArrayBufferConsumer(ScriptPromiseResolver* resolver)
: BodyConsumerBase(resolver) {}
BodyArrayBufferConsumer(const BodyArrayBufferConsumer&) = delete;
BodyArrayBufferConsumer& operator=(const BodyArrayBufferConsumer&) = delete;

void DidFetchDataLoadedArrayBuffer(DOMArrayBuffer* array_buffer) override {
ResolveLater(WrapPersistent(array_buffer));
}
DISALLOW_COPY_AND_ASSIGN(BodyArrayBufferConsumer);
};

class BodyFormDataConsumer final : public BodyConsumerBase {
public:
explicit BodyFormDataConsumer(ScriptPromiseResolver* resolver)
: BodyConsumerBase(resolver) {}
BodyFormDataConsumer(const BodyFormDataConsumer&) = delete;
BodyFormDataConsumer& operator=(const BodyFormDataConsumer&) = delete;

void DidFetchDataLoadedFormData(FormData* formData) override {
ResolveLater(WrapPersistent(formData));
Expand All @@ -117,24 +123,26 @@ class BodyFormDataConsumer final : public BodyConsumerBase {
formData->append(pair.first, pair.second);
DidFetchDataLoadedFormData(formData);
}
DISALLOW_COPY_AND_ASSIGN(BodyFormDataConsumer);
};

class BodyTextConsumer final : public BodyConsumerBase {
public:
explicit BodyTextConsumer(ScriptPromiseResolver* resolver)
: BodyConsumerBase(resolver) {}
BodyTextConsumer(const BodyTextConsumer&) = delete;
BodyTextConsumer& operator=(const BodyTextConsumer&) = delete;

void DidFetchDataLoadedString(const String& string) override {
ResolveLater(string);
}
DISALLOW_COPY_AND_ASSIGN(BodyTextConsumer);
};

class BodyJsonConsumer final : public BodyConsumerBase {
public:
explicit BodyJsonConsumer(ScriptPromiseResolver* resolver)
: BodyConsumerBase(resolver) {}
BodyJsonConsumer(const BodyJsonConsumer&) = delete;
BodyJsonConsumer& operator=(const BodyJsonConsumer&) = delete;

void DidFetchDataLoadedString(const String& string) override {
if (!Resolver()->GetExecutionContext() ||
Expand All @@ -153,7 +161,6 @@ class BodyJsonConsumer final : public BodyConsumerBase {
} else
Resolver()->Reject(trycatch.Exception());
}
DISALLOW_COPY_AND_ASSIGN(BodyJsonConsumer);
};

} // namespace
Expand Down
3 changes: 2 additions & 1 deletion third_party/blink/renderer/core/fetch/body.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class ScriptState;
class CORE_EXPORT Body : public ExecutionContextClient {
public:
explicit Body(ExecutionContext*);
Body(const Body&) = delete;
Body& operator=(const Body&) = delete;

ScriptPromise arrayBuffer(ScriptState*, ExceptionState&);
ScriptPromise blob(ScriptState*, ExceptionState&);
Expand Down Expand Up @@ -65,7 +67,6 @@ class CORE_EXPORT Body : public ExecutionContextClient {
// an exception if consumption cannot proceed. The caller must check
// |exception_state| on return.
void RejectInvalidConsumption(ExceptionState& exception_state) const;
DISALLOW_COPY_AND_ASSIGN(Body);
};

} // namespace blink
Expand Down
3 changes: 2 additions & 1 deletion third_party/blink/renderer/core/fetch/body_stream_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class BodyStreamBuffer::LoaderClient final
: ExecutionContextLifecycleObserver(execution_context),
buffer_(buffer),
client_(client) {}
LoaderClient(const LoaderClient&) = delete;
LoaderClient& operator=(const LoaderClient&) = delete;

void DidFetchDataLoadedBlobHandle(
scoped_refptr<BlobDataHandle> blob_data_handle) override {
Expand Down Expand Up @@ -95,7 +97,6 @@ class BodyStreamBuffer::LoaderClient final

Member<BodyStreamBuffer> buffer_;
Member<FetchDataLoader::Client> client_;
DISALLOW_COPY_AND_ASSIGN(LoaderClient);
};

// Use a Create() method to split construction from initialisation.
Expand Down
5 changes: 3 additions & 2 deletions third_party/blink/renderer/core/fetch/body_stream_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class CORE_EXPORT BodyStreamBuffer final : public UnderlyingSourceBase,
ScriptCachedMetadataHandler* cached_metadata_handler,
scoped_refptr<BlobDataHandle> side_data_blob = nullptr);

BodyStreamBuffer(const BodyStreamBuffer&) = delete;
BodyStreamBuffer& operator=(const BodyStreamBuffer&) = delete;

ReadableStream* Stream() { return stream_; }

// Callable only when neither locked nor disturbed.
Expand Down Expand Up @@ -155,8 +158,6 @@ class CORE_EXPORT BodyStreamBuffer final : public UnderlyingSourceBase,

// TODO(ricea): Remove remaining uses of |stream_broken_|.
bool stream_broken_ = false;

DISALLOW_COPY_AND_ASSIGN(BodyStreamBuffer);
};

} // namespace blink
Expand Down
5 changes: 2 additions & 3 deletions third_party/blink/renderer/core/fetch/fetch_request_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FETCH_FETCH_REQUEST_DATA_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_FETCH_FETCH_REQUEST_DATA_H_

#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "base/unguessable_token.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
Expand Down Expand Up @@ -46,6 +45,8 @@ class CORE_EXPORT FetchRequestData final
FetchRequestData* Pass(ScriptState*);

explicit FetchRequestData(ExecutionContext* execution_context);
FetchRequestData(const FetchRequestData&) = delete;
FetchRequestData& operator=(const FetchRequestData&) = delete;
~FetchRequestData();

void SetMethod(AtomicString method) { method_ = method; }
Expand Down Expand Up @@ -183,8 +184,6 @@ class CORE_EXPORT FetchRequestData final
base::UnguessableToken window_id_;
Member<ExecutionContext> execution_context_;
bool allow_http1_for_streaming_upload_ = false;

DISALLOW_COPY_AND_ASSIGN(FetchRequestData);
};

} // namespace blink
Expand Down
5 changes: 2 additions & 3 deletions third_party/blink/renderer/core/fetch/fetch_response_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <memory>

#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "net/http/http_response_info.h"
#include "services/network/public/mojom/fetch_api.mojom-blink-forward.h"
Expand Down Expand Up @@ -48,6 +47,8 @@ class CORE_EXPORT FetchResponseData final
network::mojom::FetchResponseSource,
uint16_t,
AtomicString);
FetchResponseData(const FetchResponseData&) = delete;
FetchResponseData& operator=(const FetchResponseData&) = delete;

FetchResponseData* CreateBasicFilteredResponse() const;
FetchResponseData* CreateCorsFilteredResponse(
Expand Down Expand Up @@ -178,8 +179,6 @@ class CORE_EXPORT FetchResponseData final
// algorithm.
// See: https://fetch.spec.whatwg.org/#concept-http-network-fetch
bool request_include_credentials_ = true;

DISALLOW_COPY_AND_ASSIGN(FetchResponseData);
};

} // namespace blink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class SimpleDataPipeGetter : public network::mojom::blink::DataPipeGetter {
&SimpleDataPipeGetter::OnMojoDisconnect, WTF::Unretained(this)));
receivers_.Add(this, std::move(receiver));
}
SimpleDataPipeGetter(const SimpleDataPipeGetter&) = delete;
SimpleDataPipeGetter& operator=(const SimpleDataPipeGetter&) = delete;
~SimpleDataPipeGetter() override = default;

// network::mojom::DataPipeGetter implementation:
Expand All @@ -70,8 +72,6 @@ class SimpleDataPipeGetter : public network::mojom::blink::DataPipeGetter {
private:
String str_;
mojo::ReceiverSet<network::mojom::blink::DataPipeGetter> receivers_;

DISALLOW_COPY_AND_ASSIGN(SimpleDataPipeGetter);
};

scoped_refptr<EncodedFormData> ComplexFormData() {
Expand Down
5 changes: 2 additions & 3 deletions third_party/blink/renderer/core/fetch/multipart_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FETCH_MULTIPART_PARSER_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_FETCH_MULTIPART_PARSER_H_

#include "base/macros.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/network/http_header_map.h"
Expand Down Expand Up @@ -43,6 +42,8 @@ class CORE_EXPORT MultipartParser final
};

MultipartParser(Vector<char> boundary, Client*);
MultipartParser(const MultipartParser&) = delete;
MultipartParser& operator=(const MultipartParser&) = delete;
bool AppendData(const char* bytes, size_t);
void Cancel();
bool Finish();
Expand Down Expand Up @@ -107,8 +108,6 @@ class CORE_EXPORT MultipartParser final
kCancelled,
kFinished
} state_;

DISALLOW_COPY_AND_ASSIGN(MultipartParser);
};

} // namespace blink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class ScriptState;
class CORE_EXPORT ReadableStreamBytesConsumer final : public BytesConsumer {
public:
ReadableStreamBytesConsumer(ScriptState*, ReadableStream*);
ReadableStreamBytesConsumer(const ReadableStreamBytesConsumer&) = delete;
ReadableStreamBytesConsumer& operator=(const ReadableStreamBytesConsumer&) =
delete;
~ReadableStreamBytesConsumer() override;

Result BeginRead(const char** buffer, size_t* available) override;
Expand Down Expand Up @@ -56,7 +59,6 @@ class CORE_EXPORT ReadableStreamBytesConsumer final : public BytesConsumer {
size_t pending_offset_ = 0;
PublicState state_ = PublicState::kReadableOrWaiting;
bool is_reading_ = false;
DISALLOW_COPY_AND_ASSIGN(ReadableStreamBytesConsumer);
};

} // namespace blink
Expand Down
3 changes: 2 additions & 1 deletion third_party/blink/renderer/core/fetch/request.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class CORE_EXPORT Request final : public ScriptWrappable,

Request(ScriptState*, FetchRequestData*, Headers*, AbortSignal*);
Request(ScriptState*, FetchRequestData*);
Request(const Request&) = delete;
Request& operator=(const Request&) = delete;

static absl::optional<network::mojom::CredentialsMode> ParseCredentialsMode(
const String& credentials_mode);
Expand Down Expand Up @@ -116,7 +118,6 @@ class CORE_EXPORT Request final : public ScriptWrappable,
const Member<FetchRequestData> request_;
const Member<Headers> headers_;
const Member<AbortSignal> signal_;
DISALLOW_COPY_AND_ASSIGN(Request);
};

} // namespace blink
Expand Down
3 changes: 2 additions & 1 deletion third_party/blink/renderer/core/fetch/response.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class CORE_EXPORT Response final : public ScriptWrappable,
explicit Response(ExecutionContext*);
Response(ExecutionContext*, FetchResponseData*);
Response(ExecutionContext*, FetchResponseData*, Headers*);
Response(const Response&) = delete;
Response& operator=(const Response&) = delete;

const FetchResponseData* GetResponse() const { return response_; }

Expand Down Expand Up @@ -128,7 +130,6 @@ class CORE_EXPORT Response final : public ScriptWrappable,
private:
const Member<FetchResponseData> response_;
const Member<Headers> headers_;
DISALLOW_COPY_AND_ASSIGN(Response);
};

} // namespace blink
Expand Down

0 comments on commit c615b59

Please sign in to comment.