forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use frame associated URLLoaderFactory in PrepareFrameAndViewForPrint
In order to deprecate Platform::CreateDefaultURLLoaderFactory, this change removes its call from PrepareFrameAndViewForPrint instead of Platform::CreateDefaultURLLoaderFactory, use the RenderFrameImpl::CreateURLLoaderFactory. Bug: 891872 Change-Id: I128348c2ee284ddc27b17b4bdc9bf6f3bdc82608 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2043615 Reviewed-by: Kent Tamura <tkent@chromium.org> Reviewed-by: Matt Falkenhagen <falken@chromium.org> Reviewed-by: Steven Holte <holte@chromium.org> Reviewed-by: Wei Li <weili@chromium.org> Reviewed-by: Łukasz Anforowicz <lukasza@chromium.org> Commit-Queue: Yutaka Hirano <yhirano@chromium.org> Cr-Commit-Position: refs/heads/master@{#747226}
- Loading branch information
1 parent
14a6938
commit c45e93c
Showing
9 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
third_party/blink/public/platform/web_failing_url_loader_factory.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_FAILING_URL_LOADER_FACTORY_H_ | ||
#define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_FAILING_URL_LOADER_FACTORY_H_ | ||
|
||
#include "third_party/blink/public/platform/web_common.h" | ||
#include "third_party/blink/public/platform/web_url_loader_factory.h" | ||
|
||
namespace blink { | ||
|
||
// A WebURLLoaderFactory implementation that creates WebURLLoaders that | ||
// always fail loading. | ||
class BLINK_PLATFORM_EXPORT WebFailingURLLoaderFactory final | ||
: public WebURLLoaderFactory { | ||
public: | ||
WebFailingURLLoaderFactory() = default; | ||
~WebFailingURLLoaderFactory() override = default; | ||
|
||
std::unique_ptr<WebURLLoader> CreateURLLoader( | ||
const WebURLRequest&, | ||
std::unique_ptr<scheduler::WebResourceLoadingTaskRunnerHandle>) override; | ||
}; | ||
|
||
} // namespace blink | ||
|
||
#endif // THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_FAILING_URL_LOADER_FACTORY_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
third_party/blink/renderer/platform/exported/web_failing_url_loader_factory.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "third_party/blink/public/platform/web_failing_url_loader_factory.h" | ||
|
||
#include <memory> | ||
|
||
#include "base/memory/ref_counted.h" | ||
#include "base/memory/weak_ptr.h" | ||
#include "base/single_thread_task_runner.h" | ||
#include "services/network/public/cpp/resource_request.h" | ||
#include "third_party/blink/public/platform/scheduler/web_resource_loading_task_runner_handle.h" | ||
#include "third_party/blink/public/platform/web_url_error.h" | ||
#include "third_party/blink/public/platform/web_url_loader.h" | ||
#include "third_party/blink/public/platform/web_url_loader_client.h" | ||
#include "third_party/blink/renderer/platform/loader/fetch/resource_error.h" | ||
#include "third_party/blink/renderer/platform/weborigin/kurl.h" | ||
|
||
namespace blink { | ||
|
||
namespace { | ||
|
||
// A WebURLLoader which always fails loading. | ||
class FailingLoader final : public WebURLLoader { | ||
public: | ||
explicit FailingLoader( | ||
std::unique_ptr<scheduler::WebResourceLoadingTaskRunnerHandle> | ||
task_runner_handle) | ||
: task_runner_handle_(std::move(task_runner_handle)) {} | ||
~FailingLoader() override = default; | ||
|
||
// WebURLLoader implementation: | ||
void LoadSynchronously( | ||
std::unique_ptr<network::ResourceRequest> request, | ||
scoped_refptr<WebURLRequest::ExtraData> request_extra_data, | ||
int requestor_id, | ||
bool download_to_network_cache_only, | ||
bool pass_response_pipe_to_client, | ||
bool no_mime_sniffing, | ||
base::TimeDelta timeout_interval, | ||
WebURLLoaderClient*, | ||
WebURLResponse&, | ||
base::Optional<WebURLError>& error, | ||
WebData&, | ||
int64_t& encoded_data_length, | ||
int64_t& encoded_body_length, | ||
WebBlobInfo& downloaded_blob) override { | ||
error = ResourceError::Failure(KURL(request->url)); | ||
} | ||
void LoadAsynchronously( | ||
std::unique_ptr<network::ResourceRequest> request, | ||
scoped_refptr<WebURLRequest::ExtraData> request_extra_data, | ||
int requestor_id, | ||
bool download_to_network_cache_only, | ||
bool no_mime_sniffing, | ||
WebURLLoaderClient* client) override { | ||
GetTaskRunner()->PostTask( | ||
FROM_HERE, WTF::Bind(&FailingLoader::Fail, weak_factory_.GetWeakPtr(), | ||
KURL(request->url), WTF::Unretained(client))); | ||
} | ||
void SetDefersLoading(bool) override {} | ||
void DidChangePriority(WebURLRequest::Priority, int) override {} | ||
scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() override { | ||
return task_runner_handle_->GetTaskRunner(); | ||
} | ||
|
||
private: | ||
void Fail(const KURL& url, WebURLLoaderClient* client) { | ||
client->DidFail(ResourceError::Failure(url), 0, 0, 0); | ||
} | ||
|
||
const std::unique_ptr<scheduler::WebResourceLoadingTaskRunnerHandle> | ||
task_runner_handle_; | ||
|
||
// This must be the last member. | ||
base::WeakPtrFactory<FailingLoader> weak_factory_{this}; | ||
}; | ||
|
||
} // namespace | ||
|
||
std::unique_ptr<WebURLLoader> WebFailingURLLoaderFactory::CreateURLLoader( | ||
const WebURLRequest&, | ||
std::unique_ptr<scheduler::WebResourceLoadingTaskRunnerHandle> handle) { | ||
return std::make_unique<FailingLoader>(std::move(handle)); | ||
} | ||
|
||
} // namespace blink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters