Commit d8c68177 authored by Arthur Hemery's avatar Arthur Hemery Committed by Commit Bot

WebDocumentLoader::ExtraData now std::moved.

WebDocumentLoader::ExtraData was passed via raw pointers. Converting it
to explicitly state ownership through std::unique_ptr.

A comment stated in the code that this is not OK, but I think the
comment is outdated since we don't support direct WebKit embedding
anymore.

Bug: 789577
Change-Id: Id5777b38e7d01ff7086eb6e725710903a691409d
Reviewed-on: https://chromium-review.googlesource.com/1118379
Commit-Queue: Arthur Hemery <ahemery@chromium.org>
Reviewed-by: default avatarCamille Lamy <clamy@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571877}
parent aa393726
......@@ -804,8 +804,9 @@ blink::mojom::BlobURLTokenPtrInfo CloneBlobURLToken(
// Creates a fully functional DocumentState in the case where we do not have
// pending_navigation_params_ available in the RenderFrameImpl.
DocumentState* BuildDocumentState() {
DocumentState* document_state = new DocumentState();
std::unique_ptr<DocumentState> BuildDocumentState() {
std::unique_ptr<DocumentState> document_state =
std::make_unique<DocumentState>();
document_state->set_navigation_state(
NavigationStateImpl::CreateContentInitiated());
return document_state;
......@@ -813,11 +814,11 @@ DocumentState* BuildDocumentState() {
// Creates a fully functional DocumentState in the case where we have
// pending_navigation_params_ available in the RenderFrameImpl.
DocumentState* BuildDocumentStateFromPending(
std::unique_ptr<DocumentState> BuildDocumentStateFromPending(
PendingNavigationParams* pending_navigation_params) {
DocumentState* document_state = new DocumentState();
std::unique_ptr<DocumentState> document_state(new DocumentState());
InternalDocumentStateData* internal_data =
InternalDocumentStateData::FromDocumentState(document_state);
InternalDocumentStateData::FromDocumentState(document_state.get());
const CommonNavigationParams& common_params =
pending_navigation_params->common_params;
......@@ -3930,14 +3931,14 @@ void RenderFrameImpl::DidCreateDocumentLoader(
bool has_pending_params = pending_navigation_params.get();
DCHECK(!DocumentState::FromDocumentLoader(document_loader));
DocumentState* document_state = nullptr;
std::unique_ptr<DocumentState> document_state;
if (has_pending_params) {
document_state =
BuildDocumentStateFromPending(pending_navigation_params.get());
} else {
document_state = BuildDocumentState();
}
document_loader->SetExtraData(document_state);
document_loader->SetExtraData(std::move(document_state));
// Set the navigation start time in blink.
document_loader->SetNavigationStartTime(
......
......@@ -100,12 +100,10 @@ class BLINK_EXPORT WebDocumentLoader {
// The type of navigation that triggered the creation of this datasource.
virtual WebNavigationType GetNavigationType() const = 0;
// Extra data associated with this datasource. If non-null, the extra
// data pointer will be deleted when the datasource is destroyed.
// Setting the extra data pointer will cause any existing non-null
// extra data pointer to be deleted.
// Extra data associated with this DocumentLoader.
// Setting extra data will cause any existing extra data to be deleted.
virtual ExtraData* GetExtraData() const = 0;
virtual void SetExtraData(ExtraData*) = 0;
virtual void SetExtraData(std::unique_ptr<ExtraData>) = 0;
// Sets the navigation start time for this datasource. Ordinarily,
// navigation start is determined in WebCore. But, in some situations,
......
......@@ -118,10 +118,9 @@ WebDocumentLoader::ExtraData* WebDocumentLoaderImpl::GetExtraData() const {
return extra_data_.get();
}
void WebDocumentLoaderImpl::SetExtraData(ExtraData* extra_data) {
// extraData can't be a std::unique_ptr because setExtraData is a WebKit API
// function.
extra_data_ = base::WrapUnique(extra_data);
void WebDocumentLoaderImpl::SetExtraData(
std::unique_ptr<ExtraData> extra_data) {
extra_data_ = std::move(extra_data);
}
void WebDocumentLoaderImpl::SetNavigationStartTime(
......
......@@ -72,7 +72,7 @@ class CORE_EXPORT WebDocumentLoaderImpl final : public DocumentLoader,
bool ReplacesCurrentHistoryItem() const override;
WebNavigationType GetNavigationType() const override;
ExtraData* GetExtraData() const override;
void SetExtraData(ExtraData*) override;
void SetExtraData(std::unique_ptr<ExtraData>) override;
void SetNavigationStartTime(base::TimeTicks) override;
void UpdateNavigation(base::TimeTicks redirect_start_time,
base::TimeTicks redirect_end_time,
......
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