diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-13 15:05:36 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-14 10:33:47 +0000 |
commit | e684a3455bcc29a6e3e66a004e352dea4e1141e7 (patch) | |
tree | d55b4003bde34d7d05f558f02cfd82b2a66a7aac /chromium/content/child | |
parent | 2b94bfe47ccb6c08047959d1c26e392919550e86 (diff) | |
download | qtwebengine-chromium-e684a3455bcc29a6e3e66a004e352dea4e1141e7.tar.gz |
BASELINE: Update Chromium to 72.0.3626.110 and Ninja to 1.9.0
Change-Id: Ic57220b00ecc929a893c91f5cc552f5d3e99e922
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/content/child')
17 files changed, 164 insertions, 528 deletions
diff --git a/chromium/content/child/BUILD.gn b/chromium/content/child/BUILD.gn index ac7667c09cf..0383a74b5ed 100644 --- a/chromium/content/child/BUILD.gn +++ b/chromium/content/child/BUILD.gn @@ -61,10 +61,6 @@ target(link_target_type, "child") { "font_warmup_win.h", "image_decoder.cc", "image_decoder.h", - "memory/child_memory_coordinator_impl.cc", - "memory/child_memory_coordinator_impl.h", - "memory/child_memory_coordinator_impl_android.cc", - "memory/child_memory_coordinator_impl_android.h", "runtime_features.cc", "runtime_features.h", "scoped_child_process_reference.cc", diff --git a/chromium/content/child/blink_platform_impl.cc b/chromium/content/child/blink_platform_impl.cc index 1f0bfd3cc8f..7b3fab6f62c 100644 --- a/chromium/content/child/blink_platform_impl.cc +++ b/chromium/content/child/blink_platform_impl.cc @@ -23,7 +23,7 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/synchronization/lock.h" -#include "base/sys_info.h" +#include "base/system/sys_info.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" #include "base/trace_event/memory_allocator_dump_guid.h" @@ -41,7 +41,6 @@ #include "content/public/common/service_names.mojom.h" #include "net/base/net_errors.h" #include "services/network/public/cpp/features.h" -#include "third_party/blink/public/platform/scheduler/child/webthread_base.h" #include "third_party/blink/public/platform/web_data.h" #include "third_party/blink/public/platform/web_float_point.h" #include "third_party/blink/public/platform/web_security_origin.h" @@ -49,7 +48,6 @@ #include "third_party/blink/public/platform/web_url.h" #include "third_party/blink/public/resources/grit/blink_image_resources.h" #include "third_party/blink/public/resources/grit/blink_resources.h" -#include "third_party/blink/public/resources/grit/media_controls_resources.h" #include "third_party/zlib/google/compression_utils.h" #include "ui/base/layout.h" #include "ui/events/gestures/blink/web_gesture_curve_impl.h" @@ -423,21 +421,21 @@ const DataResource kDataResources[] = { {"view-source.css", IDR_UASTYLE_VIEW_SOURCE_CSS, ui::SCALE_FACTOR_NONE, true}, // Not limited to Android since it's used for mobile layouts in inspector. - {"themeChromiumAndroid.css", IDR_UASTYLE_THEME_CHROMIUM_ANDROID_CSS, + {"android.css", IDR_UASTYLE_THEME_CHROMIUM_ANDROID_CSS, ui::SCALE_FACTOR_NONE, true}, // Not limited to Android since it's used for mobile layouts in inspector. {"fullscreenAndroid.css", IDR_UASTYLE_FULLSCREEN_ANDROID_CSS, ui::SCALE_FACTOR_NONE, true}, // Not limited to Linux since it's used for mobile layouts in inspector. - {"themeChromiumLinux.css", IDR_UASTYLE_THEME_CHROMIUM_LINUX_CSS, + {"linux.css", IDR_UASTYLE_THEME_CHROMIUM_LINUX_CSS, ui::SCALE_FACTOR_NONE, true}, - {"themeInputMultipleFields.css", + {"input_multiple_fields.css", IDR_UASTYLE_THEME_INPUT_MULTIPLE_FIELDS_CSS, ui::SCALE_FACTOR_NONE, true}, #if defined(OS_MACOSX) - {"themeMac.css", IDR_UASTYLE_THEME_MAC_CSS, ui::SCALE_FACTOR_NONE, true}, + {"mac.css", IDR_UASTYLE_THEME_MAC_CSS, ui::SCALE_FACTOR_NONE, true}, #endif - {"themeWin.css", IDR_UASTYLE_THEME_WIN_CSS, ui::SCALE_FACTOR_NONE, true}, - {"themeWinQuirks.css", IDR_UASTYLE_THEME_WIN_QUIRKS_CSS, + {"win.css", IDR_UASTYLE_THEME_WIN_CSS, ui::SCALE_FACTOR_NONE, true}, + {"win_quirks.css", IDR_UASTYLE_THEME_WIN_QUIRKS_CSS, ui::SCALE_FACTOR_NONE, true}, {"svg.css", IDR_UASTYLE_SVG_CSS, ui::SCALE_FACTOR_NONE, true}, {"mathml.css", IDR_UASTYLE_MATHML_CSS, ui::SCALE_FACTOR_NONE, true}, diff --git a/chromium/content/child/child_process.h b/chromium/content/child/child_process.h index 11c5e200aaf..ff74b6191e4 100644 --- a/chromium/content/child/child_process.h +++ b/chromium/content/child/child_process.h @@ -54,7 +54,6 @@ class CONTENT_EXPORT ChildProcess { // Takes ownership of the pointer. void set_main_thread(ChildThreadImpl* thread); - base::MessageLoop* io_message_loop() { return io_thread_.message_loop(); } base::SingleThreadTaskRunner* io_task_runner() { return io_thread_.task_runner().get(); } diff --git a/chromium/content/child/child_process_sandbox_support_impl_mac.cc b/chromium/content/child/child_process_sandbox_support_impl_mac.cc index 0cd80ca28be..11b848fdeb9 100644 --- a/chromium/content/child/child_process_sandbox_support_impl_mac.cc +++ b/chromium/content/child/child_process_sandbox_support_impl_mac.cc @@ -12,17 +12,31 @@ #include "base/strings/sys_string_conversions.h" #include "content/common/mac/font_loader.h" #include "content/public/child/child_thread.h" +#include "content/public/common/service_names.mojom.h" #include "mojo/public/cpp/system/buffer.h" +#include "services/service_manager/public/cpp/connector.h" namespace content { -bool LoadFont(CTFontRef font, CGFontRef* out, uint32_t* font_id) { +WebSandboxSupportMac::WebSandboxSupportMac( + service_manager::Connector* connector) { + connector->BindInterface(content::mojom::kBrowserServiceName, + mojo::MakeRequest(&sandbox_support_)); + sandbox_support_->GetSystemColors(base::BindOnce( + &WebSandboxSupportMac::OnGotSystemColors, base::Unretained(this))); +} + +WebSandboxSupportMac::~WebSandboxSupportMac() = default; + +bool WebSandboxSupportMac::LoadFont(CTFontRef font, + CGFontRef* out, + uint32_t* font_id) { base::ScopedCFTypeRef<CFStringRef> name_ref(CTFontCopyPostScriptName(font)); base::string16 font_name = SysCFStringRefToUTF16(name_ref); float font_point_size = CTFontGetSize(font); mojo::ScopedSharedBufferHandle font_data; - bool success = content::ChildThread::Get()->LoadFont( - font_name, font_point_size, &font_data, font_id) && + bool success = sandbox_support_->LoadFont(font_name, font_point_size, + &font_data, font_id) && *font_id > 0 && font_data.is_valid(); if (!success) { DLOG(ERROR) << "Bad response from LoadFont() for " << font_name; @@ -42,4 +56,19 @@ bool LoadFont(CTFontRef font, CGFontRef* out, uint32_t* font_id) { std::move(font_data), static_cast<uint32_t>(font_data_size), out); } +SkColor WebSandboxSupportMac::GetSystemColor(blink::MacSystemColorID color_id) { + if (!color_map_.IsValid()) { + DLOG(ERROR) << "GetSystemColor does not have a valid color_map_"; + return SK_ColorMAGENTA; + } + base::span<const SkColor> color_map = + color_map_.GetMemoryAsSpan<SkColor>(blink::kMacSystemColorIDCount); + return color_map[static_cast<size_t>(color_id)]; +} + +void WebSandboxSupportMac::OnGotSystemColors( + base::ReadOnlySharedMemoryRegion region) { + color_map_ = region.Map(); +} + } // namespace content diff --git a/chromium/content/child/child_process_sandbox_support_impl_mac.h b/chromium/content/child/child_process_sandbox_support_impl_mac.h index 53cdad1d52b..b9e53e178ad 100644 --- a/chromium/content/child/child_process_sandbox_support_impl_mac.h +++ b/chromium/content/child/child_process_sandbox_support_impl_mac.h @@ -7,11 +7,37 @@ #include <CoreText/CoreText.h> +#include "base/memory/read_only_shared_memory_region.h" +#include "base/memory/shared_memory_mapping.h" +#include "content/common/sandbox_support_mac.mojom.h" +#include "third_party/blink/public/platform/mac/web_sandbox_support.h" + +namespace service_manager { +class Connector; +} + namespace content { -// Load a font specified by |font| into |out| through communicating -// with browser. -bool LoadFont(CTFontRef font, CGFontRef* out, uint32_t* font_id); +// Implementation of the interface used by Blink to upcall to the privileged +// process (browser) for handling requests for data that are not allowed within +// the sandbox. +class WebSandboxSupportMac : public blink::WebSandboxSupport { + public: + explicit WebSandboxSupportMac(service_manager::Connector* connector); + ~WebSandboxSupportMac() override; + + // blink::WebSandboxSupport: + bool LoadFont(CTFontRef font, CGFontRef* out, uint32_t* font_id) override; + SkColor GetSystemColor(blink::MacSystemColorID color_id) override; + + private: + void OnGotSystemColors(base::ReadOnlySharedMemoryRegion region); + + mojom::SandboxSupportMacPtr sandbox_support_; + base::ReadOnlySharedMemoryMapping color_map_; + + DISALLOW_COPY_AND_ASSIGN(WebSandboxSupportMac); +}; }; // namespace content diff --git a/chromium/content/child/child_thread_impl.cc b/chromium/content/child/child_thread_impl.cc index 85a0d8f9710..08dc17945bd 100644 --- a/chromium/content/child/child_thread_impl.cc +++ b/chromium/content/child/child_thread_impl.cc @@ -551,20 +551,6 @@ void ChildThreadImpl::Init(const Options& options) { field_trial_syncer_->InitFieldTrialObserving( *base::CommandLine::ForCurrentProcess()); } - - if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) { - // Disable MemoryPressureListener when memory coordinator is enabled. - base::MemoryPressureListener::SetNotificationsSuppressed(true); - - // TODO(bashi): Revisit how to manage the lifetime of - // ChildMemoryCoordinatorImpl. - // https://codereview.chromium.org/2094583002/#msg52 - mojom::MemoryCoordinatorHandlePtr parent_coordinator; - GetConnector()->BindInterface(mojom::kBrowserServiceName, - mojo::MakeRequest(&parent_coordinator)); - memory_coordinator_ = - CreateChildMemoryCoordinator(std::move(parent_coordinator), this); - } } void ChildThreadImpl::InitTracing() { @@ -652,22 +638,6 @@ mojom::FontCacheWin* ChildThreadImpl::GetFontCacheWin() { } return font_cache_win_ptr_.get(); } -#elif defined(OS_MACOSX) -bool ChildThreadImpl::LoadFont(const base::string16& font_name, - float font_point_size, - mojo::ScopedSharedBufferHandle* out_font_data, - uint32_t* out_font_id) { - return GetFontLoaderMac()->LoadFont(font_name, font_point_size, out_font_data, - out_font_id); -} - -mojom::FontLoaderMac* ChildThreadImpl::GetFontLoaderMac() { - if (!font_loader_mac_ptr_) { - GetConnector()->BindInterface(mojom::kBrowserServiceName, - &font_loader_mac_ptr_); - } - return font_loader_mac_ptr_.get(); -} #endif void ChildThreadImpl::RecordAction(const base::UserMetricsAction& action) { @@ -743,9 +713,13 @@ void ChildThreadImpl::OnAssociatedInterfaceRequest( void ChildThreadImpl::StartServiceManagerConnection() { DCHECK(service_manager_connection_); - service_manager_connection_->Start(); GetContentClient()->OnServiceManagerConnected( service_manager_connection_.get()); + + // NOTE: You must register any ConnectionFilter instances on + // |service_manager_connection_| *before* this call to |Start()|, otherwise + // incoming interface requests may race with the registration. + service_manager_connection_->Start(); } bool ChildThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { diff --git a/chromium/content/child/child_thread_impl.h b/chromium/content/child/child_thread_impl.h index 71c3eb0a81b..249b5b3f20c 100644 --- a/chromium/content/child/child_thread_impl.h +++ b/chromium/content/child/child_thread_impl.h @@ -20,7 +20,6 @@ #include "base/single_thread_task_runner.h" #include "build/build_config.h" #include "components/variations/child_process_field_trial_syncer.h" -#include "content/child/memory/child_memory_coordinator_impl.h" #include "content/common/associated_interfaces.mojom.h" #include "content/common/child_control.mojom.h" #include "content/common/content_export.h" @@ -36,8 +35,6 @@ #if defined(OS_WIN) #include "content/public/common/font_cache_win.mojom.h" -#elif defined(OS_MACOSX) -#include "content/common/font_loader_mac.mojom.h" #endif namespace IPC { @@ -62,7 +59,6 @@ class CONTENT_EXPORT ChildThreadImpl : public IPC::Listener, virtual public ChildThread, private base::FieldTrialList::Observer, - public ChildMemoryCoordinatorDelegate, public mojom::RouteProvider, public blink::mojom::AssociatedInterfaceProvider, public mojom::ChildControl { @@ -91,11 +87,6 @@ class CONTENT_EXPORT ChildThreadImpl #if defined(OS_WIN) void PreCacheFont(const LOGFONT& log_font) override; void ReleaseCachedFonts() override; -#elif defined(OS_MACOSX) - bool LoadFont(const base::string16& font_name, - float font_point_size, - mojo::ScopedSharedBufferHandle* out_font_data, - uint32_t* out_font_id) override; #endif void RecordAction(const base::UserMetricsAction& action) override; void RecordComputedAction(const std::string& action) override; @@ -109,9 +100,6 @@ class CONTENT_EXPORT ChildThreadImpl void OnFieldTrialGroupFinalized(const std::string& trial_name, const std::string& group_name) override; - // ChildMemoryCoordinatorDelegate implementation. - void OnTrimMemoryImmediately() override {} - IPC::SyncChannel* channel() { return channel_.get(); } IPC::MessageRouter* GetRouter(); @@ -178,10 +166,6 @@ class CONTENT_EXPORT ChildThreadImpl bool IsInBrowserProcess() const; -#if defined(OS_MACOSX) - virtual mojom::FontLoaderMac* GetFontLoaderMac(); -#endif - private: class ChildThreadMessageRouter : public IPC::MessageRouter { public: @@ -233,8 +217,6 @@ class CONTENT_EXPORT ChildThreadImpl mojom::RouteProviderAssociatedPtr remote_route_provider_; #if defined(OS_WIN) mojom::FontCacheWinPtr font_cache_win_ptr_; -#elif defined(OS_MACOSX) - mojom::FontLoaderMacPtr font_loader_mac_ptr_; #endif std::unique_ptr<IPC::SyncChannel> channel_; @@ -266,8 +248,6 @@ class CONTENT_EXPORT ChildThreadImpl std::unique_ptr<variations::ChildProcessFieldTrialSyncer> field_trial_syncer_; - std::unique_ptr<ChildMemoryCoordinatorImpl> memory_coordinator_; - std::unique_ptr<base::WeakPtrFactory<ChildThreadImpl>> channel_connected_factory_; diff --git a/chromium/content/child/field_trial.cc b/chromium/content/child/field_trial.cc index b33c04ffa4c..26b6e3e113e 100644 --- a/chromium/content/child/field_trial.cc +++ b/chromium/content/child/field_trial.cc @@ -33,7 +33,7 @@ void InitializeFieldTrialAndFeatureList() { // Ensure any field trials in browser are reflected into the child // process. -#if defined(OS_WIN) +#if defined(OS_WIN) || defined(OS_MACOSX) base::FieldTrialList::CreateTrialsFromCommandLine( command_line, switches::kFieldTrialHandle, -1); #elif defined(OS_POSIX) || defined(OS_FUCHSIA) diff --git a/chromium/content/child/memory/child_memory_coordinator_impl.cc b/chromium/content/child/memory/child_memory_coordinator_impl.cc deleted file mode 100644 index ecf9542fc7d..00000000000 --- a/chromium/content/child/memory/child_memory_coordinator_impl.cc +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2016 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 "content/child/memory/child_memory_coordinator_impl.h" - -#include "base/lazy_instance.h" -#include "base/memory/memory_coordinator_client_registry.h" -#include "base/memory/ptr_util.h" -#include "base/synchronization/lock.h" -#include "base/trace_event/trace_event.h" - -namespace content { - -namespace { - -base::LazyInstance<base::Lock>::Leaky g_lock = LAZY_INSTANCE_INITIALIZER; -ChildMemoryCoordinatorImpl* g_child_memory_coordinator = nullptr; - -base::MemoryState ToBaseMemoryState(mojom::MemoryState state) { - switch (state) { - case mojom::MemoryState::UNKNOWN: - return base::MemoryState::UNKNOWN; - case mojom::MemoryState::NORMAL: - return base::MemoryState::NORMAL; - case mojom::MemoryState::THROTTLED: - return base::MemoryState::THROTTLED; - case mojom::MemoryState::SUSPENDED: - return base::MemoryState::SUSPENDED; - default: - NOTREACHED(); - return base::MemoryState::UNKNOWN; - } -} - -} // namespace - -// static -ChildMemoryCoordinatorImpl* ChildMemoryCoordinatorImpl::GetInstance() { - base::AutoLock lock(*g_lock.Pointer()); - return g_child_memory_coordinator; -} - -ChildMemoryCoordinatorImpl::ChildMemoryCoordinatorImpl( - mojom::MemoryCoordinatorHandlePtr parent, - ChildMemoryCoordinatorDelegate* delegate) - : binding_(this), parent_(std::move(parent)), delegate_(delegate) { - base::AutoLock lock(*g_lock.Pointer()); - DCHECK(delegate_); - DCHECK(!g_child_memory_coordinator); - g_child_memory_coordinator = this; - mojom::ChildMemoryCoordinatorPtr child; - binding_.Bind(mojo::MakeRequest(&child)); - parent_->AddChild(std::move(child)); - base::MemoryCoordinatorProxy::SetMemoryCoordinator(this); -} - -ChildMemoryCoordinatorImpl::~ChildMemoryCoordinatorImpl() { - base::AutoLock lock(*g_lock.Pointer()); - base::MemoryCoordinatorProxy::SetMemoryCoordinator(nullptr); - DCHECK(g_child_memory_coordinator == this); - g_child_memory_coordinator = nullptr; -} - -base::MemoryState ChildMemoryCoordinatorImpl::GetCurrentMemoryState() const { - return current_state_; -} - -void ChildMemoryCoordinatorImpl::PurgeMemory() { - TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("memory_coordinator"), - "ChildMemoryCoordinatorImpl::PurgeMemory"); - base::MemoryCoordinatorClientRegistry::GetInstance()->PurgeMemory(); -} - -void ChildMemoryCoordinatorImpl::OnStateChange(mojom::MemoryState state) { - current_state_ = ToBaseMemoryState(state); - TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("memory_coordinator"), - "ChildMemoryCoordinatorImpl::OnStateChange", "state", - MemoryStateToString(current_state_)); - base::MemoryCoordinatorClientRegistry::GetInstance()->Notify(current_state_); -} - -#if !defined(OS_ANDROID) -std::unique_ptr<ChildMemoryCoordinatorImpl> CreateChildMemoryCoordinator( - mojom::MemoryCoordinatorHandlePtr parent, - ChildMemoryCoordinatorDelegate* delegate) { - return base::WrapUnique( - new ChildMemoryCoordinatorImpl(std::move(parent), delegate)); -} -#endif - -} // namespace content diff --git a/chromium/content/child/memory/child_memory_coordinator_impl.h b/chromium/content/child/memory/child_memory_coordinator_impl.h deleted file mode 100644 index 716875f432b..00000000000 --- a/chromium/content/child/memory/child_memory_coordinator_impl.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2016 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 CONTENT_CHILD_MEMORY_CHILD_MEMORY_COORDINATOR_IMPL_H_ -#define CONTENT_CHILD_MEMORY_CHILD_MEMORY_COORDINATOR_IMPL_H_ - -#include "base/compiler_specific.h" -#include "base/memory/memory_coordinator_client.h" -#include "base/memory/memory_coordinator_proxy.h" -#include "content/common/child_memory_coordinator.mojom.h" -#include "content/common/content_export.h" -#include "content/common/memory_coordinator.mojom.h" -#include "mojo/public/cpp/bindings/binding.h" - -namespace content { - -class CONTENT_EXPORT ChildMemoryCoordinatorDelegate { - public: - virtual ~ChildMemoryCoordinatorDelegate() {} - - // Called when the system requests immediate actions to free memory. - virtual void OnTrimMemoryImmediately() = 0; -}; - -// ChildMemoryCoordinatorImpl is the implementation of ChildMemoryCoordinator. -// It lives in child processes and is responsible for dispatching memory events -// to its clients. -class CONTENT_EXPORT ChildMemoryCoordinatorImpl - : base::MemoryCoordinator, - public mojom::ChildMemoryCoordinator { - public: - // Returns the instance of ChildMemoryCoordinatorImpl. Could be nullptr. - static ChildMemoryCoordinatorImpl* GetInstance(); - - ChildMemoryCoordinatorImpl(mojom::MemoryCoordinatorHandlePtr parent, - ChildMemoryCoordinatorDelegate* delegate); - ~ChildMemoryCoordinatorImpl() override; - - // base::MemoryCoordinator implementations: - base::MemoryState GetCurrentMemoryState() const override; - - // mojom::ChildMemoryCoordinator implementations: - void OnStateChange(mojom::MemoryState state) override; - void PurgeMemory() override; - - protected: - ChildMemoryCoordinatorDelegate* delegate() { return delegate_; } - - private: - friend class ChildMemoryCoordinatorImplTest; - - mojo::Binding<mojom::ChildMemoryCoordinator> binding_; - base::MemoryState current_state_ = base::MemoryState::NORMAL; - mojom::MemoryCoordinatorHandlePtr parent_; - ChildMemoryCoordinatorDelegate* delegate_; - - DISALLOW_COPY_AND_ASSIGN(ChildMemoryCoordinatorImpl); -}; - -// Factory function for creating a ChildMemoryCoordinator for the current -// platform. Doesn't take the ownership of |delegate|. -CONTENT_EXPORT std::unique_ptr<ChildMemoryCoordinatorImpl> -CreateChildMemoryCoordinator(mojom::MemoryCoordinatorHandlePtr parent, - ChildMemoryCoordinatorDelegate* delegate); - -} // namespace content - -#endif // CONTENT_CHILD_MEMORY_CHILD_MEMORY_COORDINATOR_IMPL_H_ diff --git a/chromium/content/child/memory/child_memory_coordinator_impl_android.cc b/chromium/content/child/memory/child_memory_coordinator_impl_android.cc deleted file mode 100644 index 4c4efeff37a..00000000000 --- a/chromium/content/child/memory/child_memory_coordinator_impl_android.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 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 "base/memory/ptr_util.h" -#include "content/child/memory/child_memory_coordinator_impl_android.h" - -namespace content { - -ChildMemoryCoordinatorImplAndroid::ChildMemoryCoordinatorImplAndroid( - mojom::MemoryCoordinatorHandlePtr parent, - ChildMemoryCoordinatorDelegate* delegate) - : ChildMemoryCoordinatorImpl(std::move(parent), delegate) {} - -ChildMemoryCoordinatorImplAndroid::~ChildMemoryCoordinatorImplAndroid() {} - -void ChildMemoryCoordinatorImplAndroid::OnTrimMemory(int level) { - // TODO(bashi): Compare |level| with levels defined in - // ComponentCallbacks2 when JNI bindings are implemented. - delegate()->OnTrimMemoryImmediately(); -} - -std::unique_ptr<ChildMemoryCoordinatorImpl> CreateChildMemoryCoordinator( - mojom::MemoryCoordinatorHandlePtr parent, - ChildMemoryCoordinatorDelegate* delegate) { - return base::WrapUnique( - new ChildMemoryCoordinatorImplAndroid(std::move(parent), delegate)); -} - -} // namespace content diff --git a/chromium/content/child/memory/child_memory_coordinator_impl_android.h b/chromium/content/child/memory/child_memory_coordinator_impl_android.h deleted file mode 100644 index 886e66f7d91..00000000000 --- a/chromium/content/child/memory/child_memory_coordinator_impl_android.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 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 CONTENT_CHILD_MEMORY_CHILD_MEMORY_COORDINATOR_IMPL_ANDROID_H_ -#define CONTENT_CHILD_MEMORY_CHILD_MEMORY_COORDINATOR_IMPL_ANDROID_H_ - -#include "content/child/memory/child_memory_coordinator_impl.h" - -namespace content { - -class CONTENT_EXPORT ChildMemoryCoordinatorImplAndroid - : public ChildMemoryCoordinatorImpl { - public: - ChildMemoryCoordinatorImplAndroid(mojom::MemoryCoordinatorHandlePtr parent, - ChildMemoryCoordinatorDelegate* delegate); - ~ChildMemoryCoordinatorImplAndroid() override; - - // TODO(bashi): Add JNI bindings to listen to OnTrimMemory() - - // Android's ComponentCallback2.onTrimMemory() implementation. - void OnTrimMemory(int level); - - private: - DISALLOW_COPY_AND_ASSIGN(ChildMemoryCoordinatorImplAndroid); -}; - -} // namespace content - -#endif // CONTENT_CHILD_MEMORY_CHILD_MEMORY_COORDINATOR_IMPL_ANDROID_H_ diff --git a/chromium/content/child/memory/child_memory_coordinator_impl_unittest.cc b/chromium/content/child/memory/child_memory_coordinator_impl_unittest.cc deleted file mode 100644 index 842ac14d5e8..00000000000 --- a/chromium/content/child/memory/child_memory_coordinator_impl_unittest.cc +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright 2016 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 "content/child/memory/child_memory_coordinator_impl.h" - -#if defined(OS_ANDROID) -#include "content/child/memory/child_memory_coordinator_impl_android.h" -#endif // defined(OS_ANDROID) - -#include <memory> - -#include "base/memory/memory_coordinator_client_registry.h" -#include "base/run_loop.h" -#include "base/test/scoped_task_environment.h" -#include "base/threading/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace content { - -class MockMemoryCoordinatorHandle : public mojom::MemoryCoordinatorHandle { - public: - MockMemoryCoordinatorHandle() : binding_(this) {} - - void AddChild(mojom::ChildMemoryCoordinatorPtr child) override { - child_ = std::move(child); - } - - mojom::MemoryCoordinatorHandlePtr Bind() { - DCHECK(!binding_.is_bound()); - mojom::MemoryCoordinatorHandlePtr handle; - binding_.Bind(mojo::MakeRequest(&handle)); - return handle; - } - - mojom::ChildMemoryCoordinatorPtr& child() { return child_; } - - private: - mojo::Binding<mojom::MemoryCoordinatorHandle> binding_; - mojom::ChildMemoryCoordinatorPtr child_ = nullptr; -}; - -class ChildMemoryCoordinatorImplTest : public testing::Test, - public ChildMemoryCoordinatorDelegate { - public: - ChildMemoryCoordinatorImplTest() - : task_environment_(new base::test::ScopedTaskEnvironment) { - auto parent = coordinator_handle_.Bind(); - coordinator_impl_ = CreateChildMemoryCoordinator(std::move(parent), this); - // Needs to run loop to initalize mojo pointers including |child_| in - // MockMemoryCoordinatorHandle. - base::RunLoop loop; - loop.RunUntilIdle(); - } - - void RegisterClient(base::MemoryCoordinatorClient* client) { - base::MemoryCoordinatorClientRegistry::GetInstance()->Register(client); - } - - void UnregisterClient(base::MemoryCoordinatorClient* client) { - base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(client); - } - - mojom::ChildMemoryCoordinatorPtr& coordinator() { - return coordinator_handle_.child(); - } - - ChildMemoryCoordinatorImpl& coordinator_impl() { - return *coordinator_impl_.get(); - } - - void ChangeState(mojom::MemoryState state) { - base::RunLoop loop; - coordinator()->OnStateChange(state); - loop.RunUntilIdle(); - } - - // ChildMemoryCoordinatorDelegate implementation: - void OnTrimMemoryImmediately() override { - on_trim_memory_called_ = true; - } - - protected: - bool on_trim_memory_called_ = false; - - private: - std::unique_ptr<base::test::ScopedTaskEnvironment> task_environment_; - MockMemoryCoordinatorHandle coordinator_handle_; - std::unique_ptr<ChildMemoryCoordinatorImpl> coordinator_impl_; - - DISALLOW_COPY_AND_ASSIGN(ChildMemoryCoordinatorImplTest); -}; - -namespace { - -class MockMemoryCoordinatorClient final : public base::MemoryCoordinatorClient { -public: - void OnMemoryStateChange(base::MemoryState state) override { - last_state_ = state; - } - - base::MemoryState last_state() const { return last_state_; } - - private: - base::MemoryState last_state_ = base::MemoryState::UNKNOWN; -}; - -class MemoryCoordinatorTestThread : public base::Thread, - public base::MemoryCoordinatorClient { - public: - MemoryCoordinatorTestThread( - const std::string& name) - : Thread(name) {} - ~MemoryCoordinatorTestThread() override { Stop(); } - - void Init() override { - base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this); - } - - void OnMemoryStateChange(base::MemoryState state) override { - EXPECT_EQ(message_loop(), base::MessageLoop::current()); - last_state_ = state; - } - - void CheckLastState(base::MemoryState state) { - task_runner()->PostTask( - FROM_HERE, - base::BindOnce(&MemoryCoordinatorTestThread::CheckLastStateInternal, - base::Unretained(this), state)); - } - - private: - void CheckLastStateInternal(base::MemoryState state) { - base::RunLoop loop; - loop.RunUntilIdle(); - EXPECT_EQ(state, last_state_); - } - - base::MemoryState last_state_ = base::MemoryState::UNKNOWN; -}; - -TEST_F(ChildMemoryCoordinatorImplTest, SingleClient) { - auto* memory_coordinator_proxy = base::MemoryCoordinatorProxy::GetInstance(); - MockMemoryCoordinatorClient client; - RegisterClient(&client); - - ChangeState(mojom::MemoryState::THROTTLED); - EXPECT_EQ(base::MemoryState::THROTTLED, client.last_state()); - EXPECT_EQ(base::MemoryState::THROTTLED, - memory_coordinator_proxy->GetCurrentMemoryState()); - - ChangeState(mojom::MemoryState::NORMAL); - EXPECT_EQ(base::MemoryState::NORMAL, client.last_state()); - EXPECT_EQ(base::MemoryState::NORMAL, - memory_coordinator_proxy->GetCurrentMemoryState()); - - UnregisterClient(&client); - ChangeState(mojom::MemoryState::THROTTLED); - EXPECT_TRUE(base::MemoryState::THROTTLED != client.last_state()); - EXPECT_EQ(base::MemoryState::THROTTLED, - memory_coordinator_proxy->GetCurrentMemoryState()); -} - -TEST_F(ChildMemoryCoordinatorImplTest, MultipleClients) { - MemoryCoordinatorTestThread t1("thread 1"); - MemoryCoordinatorTestThread t2("thread 2"); - - t1.StartAndWaitForTesting(); - t2.StartAndWaitForTesting(); - - ChangeState(mojom::MemoryState::THROTTLED); - t1.CheckLastState(base::MemoryState::THROTTLED); - t2.CheckLastState(base::MemoryState::THROTTLED); - - ChangeState(mojom::MemoryState::NORMAL); - t1.CheckLastState(base::MemoryState::NORMAL); - t2.CheckLastState(base::MemoryState::NORMAL); - - t1.Stop(); - t2.Stop(); -} - -#if defined(OS_ANDROID) -TEST_F(ChildMemoryCoordinatorImplTest, OnTrimMemoryImmediately) { - // TRIM_MEMORY_COMPLETE defined in ComponentCallbacks2. - static const int kTrimMemoryComplete = 80; - - ChildMemoryCoordinatorImplAndroid& coordinator_android = - static_cast<ChildMemoryCoordinatorImplAndroid&>(coordinator_impl()); - coordinator_android.OnTrimMemory(kTrimMemoryComplete); - EXPECT_EQ(true, on_trim_memory_called_); -} -#endif // defined(OS_ANDROID) - -} // namespace - -} // namespace content diff --git a/chromium/content/child/runtime_features.cc b/chromium/content/child/runtime_features.cc index 7eecb0391ee..8582b5af86d 100644 --- a/chromium/content/child/runtime_features.cc +++ b/chromium/content/child/runtime_features.cc @@ -11,6 +11,7 @@ #include "base/metrics/field_trial.h" #include "base/metrics/field_trial_params.h" #include "base/strings/string_util.h" +#include "base/task/task_features.h" #include "build/build_config.h" #include "content/common/content_switches_internal.h" #include "content/public/common/content_features.h" @@ -117,8 +118,12 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( if (!base::FeatureList::IsEnabled(features::kWebUsb)) WebRuntimeFeatures::EnableWebUsb(false); - if (base::FeatureList::IsEnabled(features::kBlinkHeapIncrementalMarking)) - WebRuntimeFeatures::EnableBlinkHeapIncrementalMarking(true); + WebRuntimeFeatures::EnableBlinkHeapIncrementalMarking( + base::FeatureList::IsEnabled(features::kBlinkHeapIncrementalMarking)); + + WebRuntimeFeatures::EnableBlinkHeapUnifiedGarbageCollection( + base::FeatureList::IsEnabled( + features::kBlinkHeapUnifiedGarbageCollection)); if (base::FeatureList::IsEnabled(features::kBloatedRendererDetection)) WebRuntimeFeatures::EnableBloatedRendererDetection(true); @@ -143,8 +148,14 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( if (command_line.HasSwitch(switches::kDisableSharedWorkers)) WebRuntimeFeatures::EnableSharedWorker(false); - if (command_line.HasSwitch(switches::kDisableSpeechAPI)) - WebRuntimeFeatures::EnableScriptedSpeech(false); + if (command_line.HasSwitch(switches::kDisableSpeechAPI)) { + WebRuntimeFeatures::EnableScriptedSpeechRecognition(false); + WebRuntimeFeatures::EnableScriptedSpeechSynthesis(false); + } + + if (command_line.HasSwitch(switches::kDisableSpeechSynthesisAPI)) { + WebRuntimeFeatures::EnableScriptedSpeechSynthesis(false); + } if (command_line.HasSwitch(switches::kDisableFileSystem)) WebRuntimeFeatures::EnableFileSystem(false); @@ -245,18 +256,23 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( base::FeatureList::IsEnabled(features::kSecMetadata) || enableExperimentalWebPlatformFeatures); + WebRuntimeFeatures::EnableUserActivationSameOriginVisibility( + base::FeatureList::IsEnabled( + features::kUserActivationSameOriginVisibility)); + WebRuntimeFeatures::EnableUserActivationV2( base::FeatureList::IsEnabled(features::kUserActivationV2)); if (base::FeatureList::IsEnabled(features::kScrollAnchorSerialization)) WebRuntimeFeatures::EnableScrollAnchorSerialization(true); - WebRuntimeFeatures::EnableFeatureFromString( - "BlinkGenPropertyTrees", - command_line.HasSwitch(switches::kEnableBlinkGenPropertyTrees)); + if (base::FeatureList::IsEnabled(blink::features::kBlinkGenPropertyTrees) || + command_line.HasSwitch(switches::kEnableBlinkGenPropertyTrees)) { + WebRuntimeFeatures::EnableFeatureFromString("BlinkGenPropertyTrees", true); + } if (command_line.HasSwitch(switches::kEnableSlimmingPaintV2)) - WebRuntimeFeatures::EnableSlimmingPaintV2(true); + WebRuntimeFeatures::EnableFeatureFromString("SlimmingPaintV2", true); WebRuntimeFeatures::EnablePassiveDocumentEventListeners( base::FeatureList::IsEnabled(features::kPassiveDocumentEventListeners)); @@ -309,10 +325,6 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( if (base::FeatureList::IsEnabled(features::kServiceWorkerPaymentApps)) WebRuntimeFeatures::EnablePaymentApp(true); - WebRuntimeFeatures::EnableServiceWorkerScriptFullCodeCache( - base::FeatureList::IsEnabled( - features::kServiceWorkerScriptFullCodeCache)); - WebRuntimeFeatures::EnableNetworkService( base::FeatureList::IsEnabled(network::features::kNetworkService)); @@ -341,8 +353,8 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( if (base::FeatureList::IsEnabled(features::kGenericSensorExtraClasses)) WebRuntimeFeatures::EnableGenericSensorExtraClasses(true); - if (base::FeatureList::IsEnabled(network::features::kOutOfBlinkCORS)) - WebRuntimeFeatures::EnableOutOfBlinkCORS(true); + if (base::FeatureList::IsEnabled(network::features::kOutOfBlinkCors)) + WebRuntimeFeatures::EnableOutOfBlinkCors(true); WebRuntimeFeatures::EnableMediaCastOverlayButton( base::FeatureList::IsEnabled(media::kMediaCastOverlayButton)); @@ -407,6 +419,12 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( WebRuntimeFeatures::EnableScheduledScriptStreaming( base::FeatureList::IsEnabled(features::kScheduledScriptStreaming)); + WebRuntimeFeatures::EnableScriptStreamingOnPreload( + base::FeatureList::IsEnabled(features::kScriptStreamingOnPreload)); + + WebRuntimeFeatures::EnableMergeBlockingNonBlockingPools( + base::FeatureList::IsEnabled(base::kMergeBlockingNonBlockingPools)); + if (base::FeatureList::IsEnabled(features::kLazyFrameLoading)) WebRuntimeFeatures::EnableLazyFrameLoading(true); if (base::FeatureList::IsEnabled(features::kLazyFrameVisibleLoadTimeMetrics)) @@ -416,15 +434,18 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( if (base::FeatureList::IsEnabled(features::kLazyImageVisibleLoadTimeMetrics)) WebRuntimeFeatures::EnableLazyImageVisibleLoadTimeMetrics(true); + WebRuntimeFeatures::EnableRestrictLazyFrameLoadingToDataSaver( + base::GetFieldTrialParamByFeatureAsBool( + features::kLazyFrameLoading, + "restrict-lazy-load-frames-to-data-saver-only", false)); + WebRuntimeFeatures::EnableRestrictLazyImageLoadingToDataSaver( + base::GetFieldTrialParamByFeatureAsBool( + features::kLazyFrameLoading, + "restrict-lazy-load-images-to-data-saver-only", false)); + WebRuntimeFeatures::EnableV8ContextSnapshot( base::FeatureList::IsEnabled(features::kV8ContextSnapshot)); - WebRuntimeFeatures::EnablePWAFullCodeCache( - base::FeatureList::IsEnabled(features::kPWAFullCodeCache)); - - WebRuntimeFeatures::EnableRequireCSSExtensionForFile( - base::FeatureList::IsEnabled(features::kRequireCSSExtensionForFile)); - WebRuntimeFeatures::EnablePictureInPicture( base::FeatureList::IsEnabled(media::kPictureInPicture)); @@ -433,6 +454,8 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( WebRuntimeFeatures::EnableIsolatedCodeCache( base::FeatureList::IsEnabled(net::features::kIsolatedCodeCache)); + WebRuntimeFeatures::EnableWasmCodeCache( + base::FeatureList::IsEnabled(blink::features::kWasmCodeCache)); if (base::FeatureList::IsEnabled(features::kSignedHTTPExchange)) { WebRuntimeFeatures::EnableSignedHTTPExchange(true); @@ -440,9 +463,6 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( WebRuntimeFeatures::EnablePreloadImageSrcSetEnabled(true); } - WebRuntimeFeatures::EnableNestedWorkers( - base::FeatureList::IsEnabled(blink::features::kNestedWorkers)); - if (base::FeatureList::IsEnabled( features::kExperimentalProductivityFeatures)) { WebRuntimeFeatures::EnableExperimentalProductivityFeatures(true); @@ -453,7 +473,8 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( #if defined(OS_ANDROID) if (base::FeatureList::IsEnabled(features::kDisplayCutoutAPI) && - base::android::BuildInfo::GetInstance()->is_at_least_p()) { + base::android::BuildInfo::GetInstance()->sdk_int() >= + base::android::SDK_VERSION_P) { // Display Cutout is limited to Android P+. WebRuntimeFeatures::EnableDisplayCutoutAPI(true); } @@ -495,9 +516,19 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( WebRuntimeFeatures::EnablePortals( base::FeatureList::IsEnabled(blink::features::kPortals)); + WebRuntimeFeatures::EnableImplicitRootScroller( + base::FeatureList::IsEnabled(blink::features::kImplicitRootScroller)); + if (!base::FeatureList::IsEnabled(features::kBackgroundFetch)) WebRuntimeFeatures::EnableBackgroundFetch(false); + WebRuntimeFeatures::EnableBackgroundFetchAccessActiveFetches( + base::FeatureList::IsEnabled( + features::kBackgroundFetchAccessActiveFetches)); + + WebRuntimeFeatures::EnableBackgroundFetchUploads( + base::FeatureList::IsEnabled(features::kBackgroundFetchUploads)); + WebRuntimeFeatures::EnableNoHoverAfterLayoutChange( base::FeatureList::IsEnabled(features::kNoHoverAfterLayoutChange)); @@ -505,8 +536,15 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( base::FeatureList::IsEnabled(blink::features::kJankTracking) || enableExperimentalWebPlatformFeatures); + WebRuntimeFeatures::EnableFirstContentfulPaintPlusPlus( + base::FeatureList::IsEnabled( + blink::features::kFirstContentfulPaintPlusPlus)); + WebRuntimeFeatures::EnableNoHoverDuringScroll( base::FeatureList::IsEnabled(features::kNoHoverDuringScroll)); + + WebRuntimeFeatures::EnableGetDisplayMedia( + base::FeatureList::IsEnabled(blink::features::kRTCGetDisplayMedia)); } } // namespace content diff --git a/chromium/content/child/service_factory.cc b/chromium/content/child/service_factory.cc index 1c1361d759f..e0978d26123 100644 --- a/chromium/content/child/service_factory.cc +++ b/chromium/content/child/service_factory.cc @@ -8,13 +8,21 @@ #include "base/bind.h" #include "content/public/common/content_client.h" -#include "services/service_manager/embedder/embedded_service_runner.h" +#include "services/service_manager/public/cpp/embedded_service_runner.h" namespace content { ServiceFactory::ServiceFactory() {} ServiceFactory::~ServiceFactory() {} +void ServiceFactory::RegisterServices(ServiceMap* service) {} + +bool ServiceFactory::HandleServiceRequest( + const std::string& name, + service_manager::mojom::ServiceRequest request) { + return false; +} + void ServiceFactory::CreateService( service_manager::mojom::ServiceRequest request, const std::string& name, @@ -36,17 +44,20 @@ void ServiceFactory::CreateService( } auto it = services_.find(name); - if (it == services_.end()) { - // DCHECK in developer builds to make these errors easier to identify. - // Otherwise they result only in cryptic browser error messages. - NOTREACHED() << "Unable to start service \"" << name << "\". Did you " - << "forget to register the service in the utility process's" - << "ServiceFactory?"; - OnLoadFailed(); + if (it != services_.end()) { + it->second->BindServiceRequest(std::move(request)); return; } - it->second->BindServiceRequest(std::move(request)); + if (HandleServiceRequest(name, std::move(request))) + return; + + // DCHECK in developer builds to make these errors easier to identify. + // Otherwise they result only in cryptic browser error messages. + NOTREACHED() << "Unable to start service \"" << name << "\". Did you " + << "forget to register the service in the utility process's" + << "ServiceFactory?"; + OnLoadFailed(); } } // namespace content diff --git a/chromium/content/child/service_factory.h b/chromium/content/child/service_factory.h index b631d000c77..060ac5dcbca 100644 --- a/chromium/content/child/service_factory.h +++ b/chromium/content/child/service_factory.h @@ -9,7 +9,7 @@ #include <memory> #include "base/macros.h" -#include "services/service_manager/embedder/embedded_service_info.h" +#include "services/service_manager/public/cpp/embedded_service_info.h" #include "services/service_manager/public/mojom/service.mojom.h" #include "services/service_manager/public/mojom/service_factory.mojom.h" @@ -29,7 +29,10 @@ class ServiceFactory : public service_manager::mojom::ServiceFactory { ServiceFactory(); ~ServiceFactory() override; - virtual void RegisterServices(ServiceMap* services) = 0; + virtual void RegisterServices(ServiceMap* services); + virtual bool HandleServiceRequest( + const std::string& name, + service_manager::mojom::ServiceRequest request); virtual void OnServiceQuit() {} // service_manager::mojom::ServiceFactory: diff --git a/chromium/content/child/webthemeengine_impl_android.cc b/chromium/content/child/webthemeengine_impl_android.cc index 74efb5d67fe..f4602f53b19 100644 --- a/chromium/content/child/webthemeengine_impl_android.cc +++ b/chromium/content/child/webthemeengine_impl_android.cc @@ -5,7 +5,7 @@ #include "content/child/webthemeengine_impl_android.h" #include "base/logging.h" -#include "base/sys_info.h" +#include "base/system/sys_info.h" #include "skia/ext/platform_canvas.h" #include "third_party/blink/public/platform/web_rect.h" #include "third_party/blink/public/platform/web_size.h" @@ -168,8 +168,8 @@ static void GetNativeThemeExtraParams( blink::WebSize WebThemeEngineImpl::GetSize(WebThemeEngine::Part part) { switch (part) { - case ui::NativeTheme::kScrollbarHorizontalThumb: - case ui::NativeTheme::kScrollbarVerticalThumb: { + case WebThemeEngine::kPartScrollbarHorizontalThumb: + case WebThemeEngine::kPartScrollbarVerticalThumb: { // Minimum length for scrollbar thumb is the scrollbar thickness. ScrollbarStyle style; GetOverlayScrollbarStyle(&style); |