Commit d7b8b011 authored by Yutaka Hirano's avatar Yutaka Hirano Committed by Commit Bot

Remove WebURLResponse::ResourceResponseContainer

It's needed to workaround the DISALLOW_NEW_EXCEPT_PLACEMENT_NEW
annotation for ResourceResponse, which is unproductive.

This CL also adds some const qualifiers to express invariants.

Bug: 570946
Change-Id: I05a13178253b66267ea91652f2f32636df98cbbb
Reviewed-on: https://chromium-review.googlesource.com/1122142Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572023}
parent c4a57e47
...@@ -305,15 +305,13 @@ class WebURLResponse { ...@@ -305,15 +305,13 @@ class WebURLResponse {
#endif #endif
private: private:
struct ResourceResponseContainer;
// If this instance owns a ResourceResponse then |owned_resource_response_| // If this instance owns a ResourceResponse then |owned_resource_response_|
// is non-null and |resource_response_| points to the ResourceResponse // is non-null and |resource_response_| points to the ResourceResponse
// instance it contains. // instance it contains.
std::unique_ptr<ResourceResponseContainer> owned_resource_response_; const std::unique_ptr<ResourceResponse> owned_resource_response_;
// Should never be null. // Should never be null.
ResourceResponse* resource_response_; ResourceResponse* const resource_response_;
}; };
} // namespace blink } // namespace blink
......
...@@ -70,28 +70,16 @@ class URLResponseExtraDataContainer : public ResourceResponse::ExtraData { ...@@ -70,28 +70,16 @@ class URLResponseExtraDataContainer : public ResourceResponse::ExtraData {
} // namespace } // namespace
// The purpose of this struct is to permit allocating a ResourceResponse on the
// heap, which is otherwise disallowed by the DISALLOW_NEW_EXCEPT_PLACEMENT_NEW
// annotation on ResourceResponse.
struct WebURLResponse::ResourceResponseContainer {
ResourceResponseContainer() = default;
explicit ResourceResponseContainer(const ResourceResponse& r)
: resource_response(r) {}
ResourceResponse resource_response;
};
WebURLResponse::~WebURLResponse() = default; WebURLResponse::~WebURLResponse() = default;
WebURLResponse::WebURLResponse() WebURLResponse::WebURLResponse()
: owned_resource_response_(new ResourceResponseContainer()), : owned_resource_response_(std::make_unique<ResourceResponse>()),
resource_response_(&owned_resource_response_->resource_response) {} resource_response_(owned_resource_response_.get()) {}
WebURLResponse::WebURLResponse(const WebURLResponse& r) WebURLResponse::WebURLResponse(const WebURLResponse& r)
: owned_resource_response_( : owned_resource_response_(
new ResourceResponseContainer(*r.resource_response_)), std::make_unique<ResourceResponse>(*r.resource_response_)),
resource_response_(&owned_resource_response_->resource_response) {} resource_response_(owned_resource_response_.get()) {}
WebURLResponse::WebURLResponse(const WebURL& url) : WebURLResponse() { WebURLResponse::WebURLResponse(const WebURL& url) : WebURLResponse() {
SetURL(url); SetURL(url);
......
...@@ -61,8 +61,6 @@ struct CrossThreadResourceResponseData; ...@@ -61,8 +61,6 @@ struct CrossThreadResourceResponseData;
// member variable to this class, do not forget to add the corresponding // member variable to this class, do not forget to add the corresponding
// one in CrossThreadResourceResponseData and write copying logic. // one in CrossThreadResourceResponseData and write copying logic.
class PLATFORM_EXPORT ResourceResponse final { class PLATFORM_EXPORT ResourceResponse final {
DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
public: public:
enum HTTPVersion : uint8_t { enum HTTPVersion : uint8_t {
kHTTPVersionUnknown, kHTTPVersionUnknown,
......
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