Commit 2836e396 authored by DimanNe's avatar DimanNe Committed by Commit Bot

Return unique_ptr from WebLocalFrame::CreateAssociatedURLLoader

Return std::unique_ptr<WebAssociatedURLLoader> instead of raw pointer
from WebLocalFrame::CreateAssociatedURLLoader()

R=kmoon@chromium.org

Bug: 1127146
Change-Id: Iac86abe5d0e41468a9d1fb2dd610f2c5278da9ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2500843Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarK. Moon <kmoon@chromium.org>
Commit-Queue: K. Moon <kmoon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821912}
parent 006506a1
...@@ -318,7 +318,7 @@ class ManifestServiceProxy : public ManifestServiceChannel::Delegate { ...@@ -318,7 +318,7 @@ class ManifestServiceProxy : public ManifestServiceChannel::Delegate {
DISALLOW_COPY_AND_ASSIGN(ManifestServiceProxy); DISALLOW_COPY_AND_ASSIGN(ManifestServiceProxy);
}; };
blink::WebAssociatedURLLoader* CreateAssociatedURLLoader( std::unique_ptr<blink::WebAssociatedURLLoader> CreateAssociatedURLLoader(
const blink::WebDocument& document, const blink::WebDocument& document,
const GURL& gurl) { const GURL& gurl) {
blink::WebAssociatedURLLoaderOptions options; blink::WebAssociatedURLLoaderOptions options;
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/field_trial_params.h" #include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_functions.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
...@@ -118,7 +117,7 @@ class FrameFetchContext : public media::ResourceFetchContext { ...@@ -118,7 +117,7 @@ class FrameFetchContext : public media::ResourceFetchContext {
// media::ResourceFetchContext implementation. // media::ResourceFetchContext implementation.
std::unique_ptr<blink::WebAssociatedURLLoader> CreateUrlLoader( std::unique_ptr<blink::WebAssociatedURLLoader> CreateUrlLoader(
const blink::WebAssociatedURLLoaderOptions& options) override { const blink::WebAssociatedURLLoaderOptions& options) override {
return base::WrapUnique(frame_->CreateAssociatedURLLoader(options)); return frame_->CreateAssociatedURLLoader(options);
} }
private: private:
......
...@@ -300,7 +300,7 @@ int32_t PepperURLLoaderHost::InternalOnHostMsgOpen( ...@@ -300,7 +300,7 @@ int32_t PepperURLLoaderHost::InternalOnHostMsgOpen(
} }
} }
loader_.reset(frame->CreateAssociatedURLLoader(options)); loader_ = frame->CreateAssociatedURLLoader(options);
if (!loader_.get()) if (!loader_.get())
return PP_ERROR_FAILED; return PP_ERROR_FAILED;
......
...@@ -354,7 +354,7 @@ void MimeHandlerViewContainer::SendResourceRequest() { ...@@ -354,7 +354,7 @@ void MimeHandlerViewContainer::SendResourceRequest() {
blink::WebAssociatedURLLoaderOptions options; blink::WebAssociatedURLLoaderOptions options;
DCHECK(!loader_); DCHECK(!loader_);
loader_.reset(frame->CreateAssociatedURLLoader(options)); loader_ = frame->CreateAssociatedURLLoader(options);
// The embedded plugin is allowed to be cross-origin and we should always // The embedded plugin is allowed to be cross-origin and we should always
// send credentials/cookies with the request. So, use the default mode // send credentials/cookies with the request. So, use the default mode
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <vector> #include <vector>
#include "base/check_op.h" #include "base/check_op.h"
#include "base/memory/ptr_util.h"
#include "base/notreached.h" #include "base/notreached.h"
#include "base/thread_annotations.h" #include "base/thread_annotations.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
...@@ -320,11 +319,9 @@ void PdfViewWebPlugin::SetReferrerForRequest( ...@@ -320,11 +319,9 @@ void PdfViewWebPlugin::SetReferrerForRequest(
std::unique_ptr<blink::WebAssociatedURLLoader> std::unique_ptr<blink::WebAssociatedURLLoader>
PdfViewWebPlugin::CreateAssociatedURLLoader( PdfViewWebPlugin::CreateAssociatedURLLoader(
const blink::WebAssociatedURLLoaderOptions& options) { const blink::WebAssociatedURLLoaderOptions& options) {
// TODO(crbug.com/1127146): blink::WebLocalFrame::CreateAssociatedURLLoader()
// really should return a std::unique_ptr instead.
DCHECK(IsValid()); DCHECK(IsValid());
return base::WrapUnique( return container_->GetDocument().GetFrame()->CreateAssociatedURLLoader(
container_->GetDocument().GetFrame()->CreateAssociatedURLLoader(options)); options);
} }
base::WeakPtr<PdfViewPluginBase> PdfViewWebPlugin::GetWeakPtr() { base::WeakPtr<PdfViewPluginBase> PdfViewWebPlugin::GetWeakPtr() {
......
...@@ -631,7 +631,7 @@ class WebLocalFrame : public WebFrame { ...@@ -631,7 +631,7 @@ class WebLocalFrame : public WebFrame {
// loader will, for example, be cancelled when StopLoading is called. // loader will, for example, be cancelled when StopLoading is called.
// //
// FIXME: StopLoading does not yet cancel an associated loader!! // FIXME: StopLoading does not yet cancel an associated loader!!
virtual WebAssociatedURLLoader* CreateAssociatedURLLoader( virtual std::unique_ptr<WebAssociatedURLLoader> CreateAssociatedURLLoader(
const WebAssociatedURLLoaderOptions&) = 0; const WebAssociatedURLLoaderOptions&) = 0;
// This API is deprecated and only required by PepperURLLoaderHost::Close() // This API is deprecated and only required by PepperURLLoaderHost::Close()
......
...@@ -1073,9 +1073,11 @@ void WebLocalFrameImpl::SetReferrerForRequest(WebURLRequest& request, ...@@ -1073,9 +1073,11 @@ void WebLocalFrameImpl::SetReferrerForRequest(WebURLRequest& request,
resource_request.SetReferrerString(referrer); resource_request.SetReferrerString(referrer);
} }
WebAssociatedURLLoader* WebLocalFrameImpl::CreateAssociatedURLLoader( std::unique_ptr<WebAssociatedURLLoader>
WebLocalFrameImpl::CreateAssociatedURLLoader(
const WebAssociatedURLLoaderOptions& options) { const WebAssociatedURLLoaderOptions& options) {
return new WebAssociatedURLLoaderImpl(GetFrame()->DomWindow(), options); return std::make_unique<WebAssociatedURLLoaderImpl>(GetFrame()->DomWindow(),
options);
} }
void WebLocalFrameImpl::DeprecatedStopLoading() { void WebLocalFrameImpl::DeprecatedStopLoading() {
......
...@@ -270,7 +270,7 @@ class CORE_EXPORT WebLocalFrameImpl final ...@@ -270,7 +270,7 @@ class CORE_EXPORT WebLocalFrameImpl final
scheduler::WebAgentGroupScheduler* GetAgentGroupScheduler() const override; scheduler::WebAgentGroupScheduler* GetAgentGroupScheduler() const override;
scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner(TaskType) override; scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner(TaskType) override;
WebInputMethodController* GetInputMethodController() override; WebInputMethodController* GetInputMethodController() override;
WebAssociatedURLLoader* CreateAssociatedURLLoader( std::unique_ptr<WebAssociatedURLLoader> CreateAssociatedURLLoader(
const WebAssociatedURLLoaderOptions&) override; const WebAssociatedURLLoaderOptions&) override;
void DeprecatedStopLoading() override; void DeprecatedStopLoading() override;
WebSize GetScrollOffset() const override; WebSize GetScrollOffset() const override;
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include <memory> #include <memory>
#include "base/memory/ptr_util.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -119,7 +118,7 @@ class WebAssociatedURLLoaderTest : public testing::Test, ...@@ -119,7 +118,7 @@ class WebAssociatedURLLoaderTest : public testing::Test,
std::unique_ptr<WebAssociatedURLLoader> CreateAssociatedURLLoader( std::unique_ptr<WebAssociatedURLLoader> CreateAssociatedURLLoader(
const WebAssociatedURLLoaderOptions options = const WebAssociatedURLLoaderOptions options =
WebAssociatedURLLoaderOptions()) { WebAssociatedURLLoaderOptions()) {
return base::WrapUnique(MainFrame()->CreateAssociatedURLLoader(options)); return MainFrame()->CreateAssociatedURLLoader(options);
} }
// WebAssociatedURLLoaderClient implementation. // WebAssociatedURLLoaderClient implementation.
......
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