Commit a34a0b1a authored by Junbo Ke's avatar Junbo Ke Committed by Commit Bot

[chromecast] Create Cast implementation of network::URLLoaderThrottle.

Bug: b/120907590
Test: Manual
Change-Id: I922288b91c476d8107fa4188a42e551da4716f33
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1531465
Commit-Queue: Junbo Ke <juke@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644469}
parent 50d39d13
...@@ -11,6 +11,8 @@ cast_source_set("common") { ...@@ -11,6 +11,8 @@ cast_source_set("common") {
"cast_content_client.h", "cast_content_client.h",
"cast_resource_delegate.cc", "cast_resource_delegate.cc",
"cast_resource_delegate.h", "cast_resource_delegate.h",
"cast_url_loader_throttle.cc",
"cast_url_loader_throttle.h",
"global_descriptors.h", "global_descriptors.h",
] ]
...@@ -21,6 +23,8 @@ cast_source_set("common") { ...@@ -21,6 +23,8 @@ cast_source_set("common") {
"//chromecast/base:cast_version", "//chromecast/base:cast_version",
"//chromecast/common/media", "//chromecast/common/media",
"//content/public/common", "//content/public/common",
"//net",
"//services/network/public/cpp:cpp",
"//ui/base", "//ui/base",
"//ui/gfx", "//ui/gfx",
"//url:url", "//url:url",
......
...@@ -8,6 +8,7 @@ include_rules = [ ...@@ -8,6 +8,7 @@ include_rules = [
"+extensions/shell/grit", "+extensions/shell/grit",
"+mojo/public/cpp/bindings", "+mojo/public/cpp/bindings",
"+services/service_manager/public/cpp", "+services/service_manager/public/cpp",
"+services/network/public/cpp",
"+ui/accessibility", "+ui/accessibility",
"+ui/base", "+ui/base",
"+ui/gfx", "+ui/gfx",
......
// Copyright 2019 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 "chromecast/common/cast_url_loader_throttle.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/resource_response.h"
namespace chromecast {
CastURLLoaderThrottle::CastURLLoaderThrottle() = default;
CastURLLoaderThrottle::~CastURLLoaderThrottle() = default;
void CastURLLoaderThrottle::DetachFromCurrentSequence() {}
void CastURLLoaderThrottle::WillStartRequest(
network::ResourceRequest* /* request */,
bool* defer) {}
} // namespace chromecast
// Copyright 2019 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 CHROMECAST_COMMON_CAST_URL_LOADER_THROTTLE_H_
#define CHROMECAST_COMMON_CAST_URL_LOADER_THROTTLE_H_
#include "base/macros.h"
#include "content/public/common/url_loader_throttle.h"
namespace chromecast {
class CastURLLoaderThrottle : public content::URLLoaderThrottle {
public:
CastURLLoaderThrottle();
~CastURLLoaderThrottle() override;
// content::URLLoaderThrottle implementation:
void DetachFromCurrentSequence() override;
void WillStartRequest(network::ResourceRequest* request,
bool* defer) override;
private:
DISALLOW_COPY_AND_ASSIGN(CastURLLoaderThrottle);
};
} // namespace chromecast
#endif // CHROMECAST_COMMON_CAST_URL_LOADER_THROTTLE_H_
...@@ -30,6 +30,8 @@ cast_source_set("renderer") { ...@@ -30,6 +30,8 @@ cast_source_set("renderer") {
"cast_content_renderer_client.h", "cast_content_renderer_client.h",
"cast_media_playback_options.cc", "cast_media_playback_options.cc",
"cast_media_playback_options.h", "cast_media_playback_options.h",
"cast_url_loader_throttle_provider.cc",
"cast_url_loader_throttle_provider.h",
] ]
public_deps = [ public_deps = [
...@@ -54,6 +56,7 @@ cast_source_set("renderer") { ...@@ -54,6 +56,7 @@ cast_source_set("renderer") {
"//crypto", "//crypto",
"//ipc", "//ipc",
"//media", "//media",
"//services/network/public/cpp:cpp",
"//services/service_manager/public/cpp", "//services/service_manager/public/cpp",
] ]
......
...@@ -13,6 +13,7 @@ include_rules = [ ...@@ -13,6 +13,7 @@ include_rules = [
"+media/media_buildflags.h", "+media/media_buildflags.h",
"+media/renderers", "+media/renderers",
"+mojo/public", "+mojo/public",
"+services/network/public/cpp",
"+services/service_manager/public", "+services/service_manager/public",
"+third_party/blink/public", "+third_party/blink/public",
] ]
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "chromecast/media/base/supported_codec_profile_levels_memo.h" #include "chromecast/media/base/supported_codec_profile_levels_memo.h"
#include "chromecast/public/media/media_capabilities_shlib.h" #include "chromecast/public/media/media_capabilities_shlib.h"
#include "chromecast/renderer/cast_media_playback_options.h" #include "chromecast/renderer/cast_media_playback_options.h"
#include "chromecast/renderer/cast_url_loader_throttle_provider.h"
#include "chromecast/renderer/media/key_systems_cast.h" #include "chromecast/renderer/media/key_systems_cast.h"
#include "chromecast/renderer/media/media_caps_observer_impl.h" #include "chromecast/renderer/media/media_caps_observer_impl.h"
#include "components/network_hints/renderer/prescient_networking_dispatcher.h" #include "components/network_hints/renderer/prescient_networking_dispatcher.h"
...@@ -297,5 +298,11 @@ void CastContentRendererClient::OnSupportedBitstreamAudioCodecsChanged( ...@@ -297,5 +298,11 @@ void CastContentRendererClient::OnSupportedBitstreamAudioCodecsChanged(
supported_bitstream_audio_codecs_ = codecs; supported_bitstream_audio_codecs_ = codecs;
} }
std::unique_ptr<content::URLLoaderThrottleProvider>
CastContentRendererClient::CreateURLLoaderThrottleProvider(
content::URLLoaderThrottleProviderType type) {
return std::make_unique<CastURLLoaderThrottleProvider>(type);
}
} // namespace shell } // namespace shell
} // namespace chromecast } // namespace chromecast
...@@ -68,6 +68,9 @@ class CastContentRendererClient ...@@ -68,6 +68,9 @@ class CastContentRendererClient
base::OnceClosure closure) override; base::OnceClosure closure) override;
bool IsIdleMediaSuspendEnabled() override; bool IsIdleMediaSuspendEnabled() override;
void SetRuntimeFeaturesDefaultsBeforeBlinkInitialization() override; void SetRuntimeFeaturesDefaultsBeforeBlinkInitialization() override;
std::unique_ptr<content::URLLoaderThrottleProvider>
CreateURLLoaderThrottleProvider(
content::URLLoaderThrottleProviderType type) override;
protected: protected:
CastContentRendererClient(); CastContentRendererClient();
......
// Copyright 2019 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 "chromecast/renderer/cast_url_loader_throttle_provider.h"
#include "base/feature_list.h"
#include "chromecast/common/cast_url_loader_throttle.h"
#include "content/public/common/url_loader_throttle.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h"
#include "services/network/public/cpp/features.h"
namespace chromecast {
CastURLLoaderThrottleProvider::CastURLLoaderThrottleProvider(
content::URLLoaderThrottleProviderType type)
: type_(type) {
DETACH_FROM_THREAD(thread_checker_);
}
CastURLLoaderThrottleProvider::~CastURLLoaderThrottleProvider() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
}
CastURLLoaderThrottleProvider::CastURLLoaderThrottleProvider(
const chromecast::CastURLLoaderThrottleProvider& other)
: type_(other.type_) {
DETACH_FROM_THREAD(thread_checker_);
}
std::unique_ptr<content::URLLoaderThrottleProvider>
CastURLLoaderThrottleProvider::Clone() {
return base::WrapUnique(new CastURLLoaderThrottleProvider(*this));
}
std::vector<std::unique_ptr<content::URLLoaderThrottle>>
CastURLLoaderThrottleProvider::CreateThrottles(
int render_frame_id,
const blink::WebURLRequest& request,
content::ResourceType resource_type) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
std::vector<std::unique_ptr<content::URLLoaderThrottle>> throttles;
return throttles;
}
void CastURLLoaderThrottleProvider::SetOnline(bool is_online) {}
} // namespace chromecast
\ No newline at end of file
// Copyright 2019 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 CHROMECAST_RENDERER_CAST_URL_LOADER_THROTTLE_PROVIDER_H_
#define CHROMECAST_RENDERER_CAST_URL_LOADER_THROTTLE_PROVIDER_H_
#include "base/macros.h"
#include "base/threading/thread_checker.h"
#include "content/public/renderer/url_loader_throttle_provider.h"
namespace chromecast {
class CastURLLoaderThrottleProvider
: public content::URLLoaderThrottleProvider {
public:
explicit CastURLLoaderThrottleProvider(
content::URLLoaderThrottleProviderType type);
~CastURLLoaderThrottleProvider() override;
// content::URLLoaderThrottleProvider implementation:
std::unique_ptr<content::URLLoaderThrottleProvider> Clone() override;
std::vector<std::unique_ptr<content::URLLoaderThrottle>> CreateThrottles(
int render_frame_id,
const blink::WebURLRequest& request,
content::ResourceType resource_type) override;
void SetOnline(bool is_online) override;
private:
// This copy constructor works in conjunction with Clone(), not intended for
// general use.
CastURLLoaderThrottleProvider(const CastURLLoaderThrottleProvider& other);
content::URLLoaderThrottleProviderType type_;
THREAD_CHECKER(thread_checker_);
DISALLOW_ASSIGN(CastURLLoaderThrottleProvider);
};
} // namespace chromecast
#endif // CHROMECAST_RENDERER_CAST_URL_LOADER_THROTTLE_PROVIDER_H_
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