diff --git a/chrome/browser/android/oom_intervention/OWNERS b/chrome/browser/android/oom_intervention/OWNERS new file mode 100644 index 0000000..9c1cfe9 --- /dev/null +++ b/chrome/browser/android/oom_intervention/OWNERS
@@ -0,0 +1,5 @@ +bashi@chromium.org +haraken@chromium.org + +# TEAM: memory-dev@chromium.org +# OS: Android
diff --git a/chrome/browser/android/oom_intervention/oom_intervention_tab_helper.cc b/chrome/browser/android/oom_intervention/oom_intervention_tab_helper.cc index 27d9dedd..b78c601 100644 --- a/chrome/browser/android/oom_intervention/oom_intervention_tab_helper.cc +++ b/chrome/browser/android/oom_intervention/oom_intervention_tab_helper.cc
@@ -29,17 +29,17 @@ // These enums are associated with UMA. Values must be kept in sync with // enums.xml and must not be renumbered/reused. -enum class NearOomMonitoringEndReason { +enum class NearOomDetectionEndReason { OOM_PROTECTED_CRASH = 0, RENDERER_GONE = 1, NAVIGATION = 2, COUNT, }; -void RecordNearOomMonitoringEndReason(NearOomMonitoringEndReason reason) { +void RecordNearOomDetectionEndReason(NearOomDetectionEndReason reason) { UMA_HISTOGRAM_ENUMERATION( - "Memory.Experimental.OomIntervention.NearOomMonitoringEndReason", reason, - NearOomMonitoringEndReason::COUNT); + "Memory.Experimental.OomIntervention.NearOomDetectionEndReason", reason, + NearOomDetectionEndReason::COUNT); } void RecordInterventionUserDecision(bool accepted) { @@ -114,7 +114,7 @@ elapsed_time); ResetInterventionState(); } else { - RecordNearOomMonitoringEndReason(NearOomMonitoringEndReason::RENDERER_GONE); + RecordNearOomDetectionEndReason(NearOomDetectionEndReason::RENDERER_GONE); } } @@ -149,12 +149,12 @@ base::TimeTicks::Now() - near_oom_detected_time_.value(); UMA_HISTOGRAM_MEDIUM_TIMES( "Memory.Experimental.OomIntervention." - "NavigatedAfterDetectionTime", + "NavigationAfterDetectionTime", elapsed_time); ResetInterventionState(); } else { // Monitoring but near-OOM hasn't been detected. - RecordNearOomMonitoringEndReason(NearOomMonitoringEndReason::NAVIGATION); + RecordNearOomDetectionEndReason(NearOomDetectionEndReason::NAVIGATION); } } @@ -192,8 +192,8 @@ } ResetInterventionState(); } else { - RecordNearOomMonitoringEndReason( - NearOomMonitoringEndReason::OOM_PROTECTED_CRASH); + RecordNearOomDetectionEndReason( + NearOomDetectionEndReason::OOM_PROTECTED_CRASH); } }
diff --git a/chrome/browser/chromeos/BUILD.gn b/chrome/browser/chromeos/BUILD.gn index d4d4e67..1d8e30c 100644 --- a/chrome/browser/chromeos/BUILD.gn +++ b/chrome/browser/chromeos/BUILD.gn
@@ -1279,6 +1279,8 @@ "policy/enrollment_status_chromeos.h", "policy/heartbeat_scheduler.cc", "policy/heartbeat_scheduler.h", + "policy/hostname_handler.cc", + "policy/hostname_handler.h", "policy/login_profile_policy_provider.cc", "policy/login_profile_policy_provider.h", "policy/minimum_version_policy_handler.cc", @@ -1897,6 +1899,7 @@ "policy/fake_affiliated_invalidation_service_provider.cc", "policy/fake_affiliated_invalidation_service_provider.h", "policy/heartbeat_scheduler_unittest.cc", + "policy/hostname_handler_unittest.cc", "policy/network_configuration_updater_unittest.cc", "policy/off_hours/device_off_hours_controller_unittest.cc", "policy/off_hours/off_hours_interval_unittest.cc",
diff --git a/chrome/browser/chromeos/policy/browser_policy_connector_chromeos.cc b/chrome/browser/chromeos/policy/browser_policy_connector_chromeos.cc index cc4bd3d..bf1d022a 100644 --- a/chrome/browser/chromeos/policy/browser_policy_connector_chromeos.cc +++ b/chrome/browser/chromeos/policy/browser_policy_connector_chromeos.cc
@@ -31,6 +31,7 @@ #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" #include "chrome/browser/chromeos/policy/device_network_configuration_updater.h" #include "chrome/browser/chromeos/policy/enrollment_config.h" +#include "chrome/browser/chromeos/policy/hostname_handler.h" #include "chrome/browser/chromeos/policy/minimum_version_policy_handler.h" #include "chrome/browser/chromeos/policy/remote_commands/affiliated_remote_commands_invalidator.h" #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" @@ -204,6 +205,9 @@ bluetooth_policy_handler_ = std::make_unique<BluetoothPolicyHandler>(chromeos::CrosSettings::Get()); + hostname_handler_ = + std::make_unique<HostnameHandler>(chromeos::CrosSettings::Get()); + minimum_version_policy_handler_ = std::make_unique<MinimumVersionPolicyHandler>( chromeos::CrosSettings::Get()); @@ -230,6 +234,9 @@ if (device_cloud_policy_manager_) device_cloud_policy_manager_->RemoveDeviceCloudPolicyManagerObserver(this); + if (hostname_handler_) + hostname_handler_->Shutdown(); + ChromeBrowserPolicyConnector::Shutdown(); }
diff --git a/chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h b/chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h index 59ce633..845ccaaa 100644 --- a/chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h +++ b/chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h
@@ -35,14 +35,15 @@ namespace policy { +class ActiveDirectoryPolicyManager; class AffiliatedCloudPolicyInvalidator; class AffiliatedInvalidationServiceProvider; class AffiliatedRemoteCommandsInvalidator; class BluetoothPolicyHandler; -class ActiveDirectoryPolicyManager; class DeviceCloudPolicyInitializer; class DeviceLocalAccountPolicyService; struct EnrollmentConfig; +class HostnameHandler; class MinimumVersionPolicyHandler; class NetworkConfigurationUpdater; class ProxyPolicyProvider; @@ -203,7 +204,7 @@ device_remote_commands_invalidator_; std::unique_ptr<BluetoothPolicyHandler> bluetooth_policy_handler_; - + std::unique_ptr<HostnameHandler> hostname_handler_; std::unique_ptr<MinimumVersionPolicyHandler> minimum_version_policy_handler_; // This policy provider is used on Chrome OS to feed user policy into the
diff --git a/chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc b/chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc index b01c0a4..96fa827 100644 --- a/chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc +++ b/chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc
@@ -440,6 +440,14 @@ POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, base::MakeUnique<base::Value>(config), nullptr); } + + if (policy.has_network_hostname() && + policy.network_hostname().has_device_hostname_template()) { + std::string hostname(policy.network_hostname().device_hostname_template()); + policies->Set(key::kDeviceHostnameTemplate, POLICY_LEVEL_MANDATORY, + POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, + base::MakeUnique<base::Value>(hostname), nullptr); + } } void DecodeReportingPolicies(const em::ChromeDeviceSettingsProto& policy,
diff --git a/chrome/browser/chromeos/policy/hostname_handler.cc b/chrome/browser/chromeos/policy/hostname_handler.cc new file mode 100644 index 0000000..10a62d1 --- /dev/null +++ b/chrome/browser/chromeos/policy/hostname_handler.cc
@@ -0,0 +1,127 @@ +// Copyright 2017 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 "chrome/browser/chromeos/policy/hostname_handler.h" + +#include "base/bind.h" +#include "base/strings/string_util.h" +#include "chrome/browser/browser_process.h" +#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" +#include "chromeos/network/device_state.h" +#include "chromeos/network/network_handler.h" +#include "chromeos/network/network_state.h" +#include "chromeos/network/network_state_handler.h" +#include "chromeos/settings/cros_settings_names.h" +#include "chromeos/settings/cros_settings_provider.h" +#include "chromeos/system/statistics_provider.h" + +namespace { + +constexpr char kAssetIDPlaceholder[] = "${ASSET_ID}"; +constexpr char kSerialNumPlaceholder[] = "${SERIAL_NUM}"; +constexpr char kMACAddressPlaceholder[] = "${MAC_ADDR}"; + +// As per RFC 1035, hostname should be 63 characters or less. +const int kMaxHostnameLength = 63; + +bool inline IsValidHostnameCharacter(char c) { + return base::IsAsciiAlpha(c) || base::IsAsciiDigit(c) || c == '_' || c == '-'; +} + +bool IsValidHostname(const std::string& hostname) { + if ((hostname.size() > kMaxHostnameLength) || (hostname.size() == 0)) + return false; + if (hostname[0] == '-') + return false; // '-' is not valid for the first char + for (const char& c : hostname) { + if (!IsValidHostnameCharacter(c)) + return false; + } + return true; +} + +} // namespace + +namespace policy { + +HostnameHandler::HostnameHandler(chromeos::CrosSettings* cros_settings) + : cros_settings_(cros_settings), weak_factory_(this) { + policy_subscription_ = cros_settings_->AddSettingsObserver( + chromeos::kDeviceHostnameTemplate, + base::BindRepeating(&HostnameHandler::OnDeviceHostnamePropertyChanged, + weak_factory_.GetWeakPtr())); + chromeos::NetworkHandler::Get()->network_state_handler()->AddObserver( + this, FROM_HERE); + + // Fire it once so we're sure we get an invocation on startup. + OnDeviceHostnamePropertyChanged(); +} + +HostnameHandler::~HostnameHandler() {} + +void HostnameHandler::Shutdown() { + if (chromeos::NetworkHandler::IsInitialized()) { + chromeos::NetworkHandler::Get()->network_state_handler()->RemoveObserver( + this, FROM_HERE); + } +} + +// static +std::string HostnameHandler::FormatHostname(const std::string& name_template, + const std::string& asset_id, + const std::string& serial, + const std::string& mac) { + std::string result = name_template; + base::ReplaceSubstringsAfterOffset(&result, 0, kAssetIDPlaceholder, asset_id); + base::ReplaceSubstringsAfterOffset(&result, 0, kSerialNumPlaceholder, serial); + base::ReplaceSubstringsAfterOffset(&result, 0, kMACAddressPlaceholder, mac); + + if (!IsValidHostname(result)) + return std::string(); + return result; +} + +void HostnameHandler::DefaultNetworkChanged( + const chromeos::NetworkState* network) { + OnDeviceHostnamePropertyChanged(); +} + +void HostnameHandler::OnDeviceHostnamePropertyChanged() { + chromeos::CrosSettingsProvider::TrustedStatus status = + cros_settings_->PrepareTrustedValues( + base::BindRepeating(&HostnameHandler::OnDeviceHostnamePropertyChanged, + weak_factory_.GetWeakPtr())); + if (status != chromeos::CrosSettingsProvider::TRUSTED) + return; + + std::string hostname_template; + cros_settings_->GetString(chromeos::kDeviceHostnameTemplate, + &hostname_template); + + const std::string serial = chromeos::system::StatisticsProvider::GetInstance() + ->GetEnterpriseMachineID(); + + const std::string asset_id = g_browser_process->platform_part() + ->browser_policy_connector_chromeos() + ->GetDeviceAssetID(); + + chromeos::NetworkStateHandler* handler = + chromeos::NetworkHandler::Get()->network_state_handler(); + + std::string mac = "MAC_unknown"; + const chromeos::NetworkState* network = handler->DefaultNetwork(); + if (network) { + const chromeos::DeviceState* device = + handler->GetDeviceState(network->device_path()); + if (device) { + mac = device->mac_address(); + base::ReplaceSubstringsAfterOffset(&mac, 0, ":", ""); + } + } + + handler->SetHostname( + FormatHostname(hostname_template, asset_id, serial, mac)); +} + +} // namespace policy
diff --git a/chrome/browser/chromeos/policy/hostname_handler.h b/chrome/browser/chromeos/policy/hostname_handler.h new file mode 100644 index 0000000..74c580a --- /dev/null +++ b/chrome/browser/chromeos/policy/hostname_handler.h
@@ -0,0 +1,54 @@ +// 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 CHROME_BROWSER_CHROMEOS_POLICY_HOSTNAME_HANDLER_H_ +#define CHROME_BROWSER_CHROMEOS_POLICY_HOSTNAME_HANDLER_H_ + +#include <memory> + +#include "base/macros.h" +#include "base/memory/ref_counted.h" +#include "base/memory/weak_ptr.h" +#include "chrome/browser/chromeos/settings/cros_settings.h" +#include "chromeos/network/network_state_handler_observer.h" + +namespace policy { + +// This class observes the device setting |DeviceHostname|, and calls +// NetworkStateHandler::SetHostname() appropriately based on the value of that +// setting. +class HostnameHandler : public chromeos::NetworkStateHandlerObserver { + public: + explicit HostnameHandler(chromeos::CrosSettings* cros_settings); + ~HostnameHandler() override; + + // NetworkStateHandlerObserver overrides + void DefaultNetworkChanged(const chromeos::NetworkState* network) override; + + void Shutdown(); + + private: + friend class HostnameHandlerTest; + + // Uses template to build a hostname. Returns valid hostname (after parameter + // substitution) or empty string, if substitution result is not a valid + // hostname. + static std::string FormatHostname(const std::string& name_template, + const std::string& asset_id, + const std::string& serial, + const std::string& mac); + + void OnDeviceHostnamePropertyChanged(); + + chromeos::CrosSettings* cros_settings_; + std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> + policy_subscription_; + base::WeakPtrFactory<HostnameHandler> weak_factory_; + + DISALLOW_COPY_AND_ASSIGN(HostnameHandler); +}; + +} // namespace policy + +#endif // CHROME_BROWSER_CHROMEOS_POLICY_HOSTNAME_HANDLER_H_
diff --git a/chrome/browser/chromeos/policy/hostname_handler_unittest.cc b/chrome/browser/chromeos/policy/hostname_handler_unittest.cc new file mode 100644 index 0000000..06dc55f --- /dev/null +++ b/chrome/browser/chromeos/policy/hostname_handler_unittest.cc
@@ -0,0 +1,83 @@ +// Copyright 2017 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 "chrome/browser/chromeos/policy/hostname_handler.h" + +#include "testing/gtest/include/gtest/gtest.h" + +namespace policy { + +class HostnameHandlerTest : public testing::Test { + public: + HostnameHandlerTest() {} + + void formatAndAssert(const std::string& expected, + const std::string& name_template, + const std::string& asset_id, + const std::string& serial, + const std::string& mac) { + auto result = + HostnameHandler::FormatHostname(name_template, asset_id, serial, mac); + ASSERT_EQ(expected, result); + } +}; + +TEST_F(HostnameHandlerTest, Basic) { + formatAndAssert("name", "name", "asset123", "SER1AL123", "0000deadbeef"); +} + +TEST_F(HostnameHandlerTest, SubstituteValidAssetId) { + formatAndAssert("chromebook-asset123", "chromebook-${ASSET_ID}", "asset123", + "SER1AL123", "0000deadbeef"); +} + +TEST_F(HostnameHandlerTest, SubstituteValidSerial) { + formatAndAssert("chromebook-SER1AL123", "chromebook-${SERIAL_NUM}", + "asset123", "SER1AL123", "0000deadbeef"); +} + +TEST_F(HostnameHandlerTest, SubstituteValidMAC) { + formatAndAssert("chromebook-0000deadbeef", "chromebook-${MAC_ADDR}", + "asset123", "SER1AL123", "0000deadbeef"); +} + +TEST_F(HostnameHandlerTest, MixedSubstitution) { + formatAndAssert("chromebook-0000deadbeef-SER1AL123-asset123", + "chromebook-${MAC_ADDR}-${SERIAL_NUM}-${ASSET_ID}", + "asset123", "SER1AL123", "0000deadbeef"); +} + +TEST_F(HostnameHandlerTest, MultipleSubstitution) { + formatAndAssert("chromebook-asset123-asset123-asset123", + "chromebook-${ASSET_ID}-${ASSET_ID}-${ASSET_ID}", "asset123", + "SER1AL123", "0000deadbeef"); +} + +TEST_F(HostnameHandlerTest, SubstituteInvalidSerial) { + formatAndAssert("", "chromebook-${SERIAL_NUM}", "asset123", "Serial number", + "0000deadbeef"); +} + +TEST_F(HostnameHandlerTest, IncorrectTemplateVariable) { + formatAndAssert("", "chromebook-${SERIAL_NUMBER}", "asset123", "SERIAL123", + "0000deadbeef"); +} + +TEST_F(HostnameHandlerTest, InvalidFirstCharacter) { + formatAndAssert("", "-somename", "asset123", "Serial number", "0000deadbeef"); +} + +TEST_F(HostnameHandlerTest, HostnameTooLong) { + formatAndAssert("", "${ASSET_ID}${ASSET_ID}${ASSET_ID}", + "1234567890123456789012345678901", "serial", "0000deadbeef"); +} + +TEST_F(HostnameHandlerTest, HostnameExactly63Chars) { + formatAndAssert( + "1234567890123456789012345678901-1234567890123456789012345678901", + "${ASSET_ID}-${ASSET_ID}", "1234567890123456789012345678901", "serial", + "0000deadbeef"); +} + +} // namespace policy
diff --git a/chrome/browser/chromeos/settings/device_settings_provider.cc b/chrome/browser/chromeos/settings/device_settings_provider.cc index 682ee3d..6edcc52 100644 --- a/chrome/browser/chromeos/settings/device_settings_provider.cc +++ b/chrome/browser/chromeos/settings/device_settings_provider.cc
@@ -67,6 +67,7 @@ kDeviceDisabled, kDeviceDisabledMessage, kDeviceEnrollmentIdNeeded, + kDeviceHostnameTemplate, kDeviceLoginScreenAppInstallList, kDeviceLoginScreenInputMethods, kDeviceLoginScreenLocales, @@ -625,6 +626,15 @@ base::MakeUnique<base::Value>(container.unaffiliated_arc_allowed())); } } + + if (policy.has_network_hostname()) { + const em::NetworkHostnameProto& container(policy.network_hostname()); + if (container.has_device_hostname_template() && + !container.device_hostname_template().empty()) { + new_values_cache->SetString(kDeviceHostnameTemplate, + container.device_hostname_template()); + } + } } void DecodeLogUploadPolicies(const em::ChromeDeviceSettingsProto& policy,
diff --git a/chrome/browser/chromeos/settings/device_settings_provider_unittest.cc b/chrome/browser/chromeos/settings/device_settings_provider_unittest.cc index 3c80669..cab5254e 100644 --- a/chrome/browser/chromeos/settings/device_settings_provider_unittest.cc +++ b/chrome/browser/chromeos/settings/device_settings_provider_unittest.cc
@@ -183,6 +183,15 @@ EXPECT_EQ(expected_enabled_value, *provider_->Get(kSystemLogUploadEnabled)); } + void VerifyPolicyValue(const char* policy_key, + const base::Value* const ptr_to_expected_value) { + // The pointer might be null, so check before dereferencing. + if (ptr_to_expected_value) + EXPECT_EQ(*ptr_to_expected_value, *provider_->Get(policy_key)); + else + EXPECT_EQ(nullptr, provider_->Get(policy_key)); + } + // Helper routine to set LoginScreenDomainAutoComplete policy. void SetDomainAutoComplete(const std::string& domain) { EXPECT_CALL(*this, SettingChanged(_)).Times(AtLeast(1)); @@ -198,13 +207,20 @@ // Helper routine to check value of the LoginScreenDomainAutoComplete policy. void VerifyDomainAutoComplete( const base::Value* const ptr_to_expected_value) { - // The pointer might be null, so check before dereferencing. - if (ptr_to_expected_value) - EXPECT_EQ(*ptr_to_expected_value, - *provider_->Get(kAccountsPrefLoginScreenDomainAutoComplete)); - else - EXPECT_EQ(ptr_to_expected_value, - provider_->Get(kAccountsPrefLoginScreenDomainAutoComplete)); + VerifyPolicyValue(kAccountsPrefLoginScreenDomainAutoComplete, + ptr_to_expected_value); + } + + // Helper routine to set HostnameTemplate policy. + void SetHostnameTemplate(const std::string& hostname_template) { + EXPECT_CALL(*this, SettingChanged(_)).Times(AtLeast(1)); + em::NetworkHostnameProto* proto = + device_policy_.payload().mutable_network_hostname(); + proto->set_device_hostname_template(hostname_template); + device_policy_.Build(); + session_manager_client_.set_device_policy(device_policy_.GetBlob()); + ReloadDeviceSettings(); + Mock::VerifyAndClearExpectations(this); } ScopedTestingLocalState local_state_; @@ -525,6 +541,21 @@ VerifyDomainAutoComplete(&domain_value); } +TEST_F(DeviceSettingsProviderTest, DecodeHostnameTemplate) { + // By default DeviceHostnameTemplate policy should not be set. + VerifyPolicyValue(kDeviceHostnameTemplate, nullptr); + + // Empty string means that the policy is not set. + SetHostnameTemplate(""); + VerifyPolicyValue(kDeviceHostnameTemplate, nullptr); + + // Check some meaningful value. Policy should be set. + const std::string hostname_template = "chromebook-${ASSET_ID}"; + const base::Value template_value(hostname_template); + SetHostnameTemplate(hostname_template); + VerifyPolicyValue(kDeviceHostnameTemplate, &template_value); +} + TEST_F(DeviceSettingsProviderTest, DecodeLogUploadSettings) { SetLogUploadSettings(true); VerifyLogUploadSettings(true);
diff --git a/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc b/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc index d49c1645..a213678d 100644 --- a/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc +++ b/chrome/browser/content_settings/content_settings_pref_provider_unittest.cc
@@ -345,39 +345,6 @@ pref_content_settings_provider.ShutdownOnUIThread(); } -#if BUILDFLAG(ENABLE_PLUGINS) -TEST_F(PrefProviderTest, ResourceIdentifier) { - TestingProfile testing_profile; - PrefProvider pref_content_settings_provider(testing_profile.GetPrefs(), - false /* incognito */, - true /* store_last_modified */); - - GURL host("http://example.com/"); - ContentSettingsPattern pattern = - ContentSettingsPattern::FromString("[*.]example.com"); - std::string resource1("someplugin"); - std::string resource2("otherplugin"); - - EXPECT_EQ(CONTENT_SETTING_DEFAULT, - TestUtils::GetContentSetting(&pref_content_settings_provider, host, - host, CONTENT_SETTINGS_TYPE_PLUGINS, - resource1, false)); - pref_content_settings_provider.SetWebsiteSetting( - pattern, pattern, CONTENT_SETTINGS_TYPE_PLUGINS, resource1, - new base::Value(CONTENT_SETTING_BLOCK)); - EXPECT_EQ(CONTENT_SETTING_BLOCK, - TestUtils::GetContentSetting(&pref_content_settings_provider, host, - host, CONTENT_SETTINGS_TYPE_PLUGINS, - resource1, false)); - EXPECT_EQ(CONTENT_SETTING_DEFAULT, - TestUtils::GetContentSetting(&pref_content_settings_provider, host, - host, CONTENT_SETTINGS_TYPE_PLUGINS, - resource2, false)); - - pref_content_settings_provider.ShutdownOnUIThread(); -} -#endif - // http://crosbug.com/17760 TEST_F(PrefProviderTest, Deadlock) { sync_preferences::TestingPrefServiceSyncable prefs; @@ -477,7 +444,6 @@ ContentSettingsPattern wildcard = ContentSettingsPattern::FromString("*"); std::unique_ptr<base::Value> value(new base::Value(CONTENT_SETTING_ALLOW)); - ResourceIdentifier res_id("abcde"); PrefProvider provider(&prefs, false /* incognito */, true /* store_last_modified */); @@ -494,11 +460,7 @@ #if BUILDFLAG(ENABLE_PLUGINS) // Non-empty pattern, plugins, non-empty resource identifier. provider.SetWebsiteSetting(pattern, wildcard, CONTENT_SETTINGS_TYPE_PLUGINS, - res_id, value->DeepCopy()); - - // Empty pattern, plugins, non-empty resource identifier. - provider.SetWebsiteSetting(wildcard, wildcard, CONTENT_SETTINGS_TYPE_PLUGINS, - res_id, value->DeepCopy()); + ResourceIdentifier(), value->DeepCopy()); #endif // Non-empty pattern, syncable, empty resource identifier. provider.SetWebsiteSetting(pattern, wildcard, CONTENT_SETTINGS_TYPE_COOKIES,
diff --git a/chrome/browser/plugins/plugin_info_host_impl_unittest.cc b/chrome/browser/plugins/plugin_info_host_impl_unittest.cc index 911ffc2..c3298c3 100644 --- a/chrome/browser/plugins/plugin_info_host_impl_unittest.cc +++ b/chrome/browser/plugins/plugin_info_host_impl_unittest.cc
@@ -324,37 +324,20 @@ host, GURL(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string(), CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); - // Allow plugin "foo" on all sites. - map->SetContentSettingCustomScope( - ContentSettingsPattern::Wildcard(), ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_PLUGINS, "foo", CONTENT_SETTING_ALLOW); - GURL unmatched_host("https://www.google.com"); - ASSERT_EQ( + EXPECT_EQ( CONTENT_SETTING_BLOCK, map->GetContentSetting(unmatched_host, unmatched_host, CONTENT_SETTINGS_TYPE_PLUGINS, std::string())); - ASSERT_EQ(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, + EXPECT_EQ(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, map->GetContentSetting(host, host, CONTENT_SETTINGS_TYPE_PLUGINS, std::string())); - ASSERT_EQ( - CONTENT_SETTING_ALLOW, - map->GetContentSetting(host, host, CONTENT_SETTINGS_TYPE_PLUGINS, "foo")); - ASSERT_EQ( - CONTENT_SETTING_DEFAULT, - map->GetContentSetting(host, host, CONTENT_SETTINGS_TYPE_PLUGINS, "bar")); - // "foo" is allowed everywhere. - VerifyPluginContentSetting(host, "foo", CONTENT_SETTING_ALLOW, false, false); - - // There is no specific content setting for "bar", so the general setting - // for example.com applies. - VerifyPluginContentSetting( - host, "bar", CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, false, false); - - // Otherwise, use the default. - VerifyPluginContentSetting(unmatched_host, "bar", CONTENT_SETTING_BLOCK, true, + VerifyPluginContentSetting(host, std::string(), + CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, false, false); + VerifyPluginContentSetting(unmatched_host, std::string(), + CONTENT_SETTING_BLOCK, false, false); // Block plugins via policy. sync_preferences::TestingPrefServiceSyncable* prefs = @@ -363,8 +346,8 @@ base::MakeUnique<base::Value>(CONTENT_SETTING_BLOCK)); // All plugins should be blocked now. - VerifyPluginContentSetting(host, "foo", CONTENT_SETTING_BLOCK, true, true); - VerifyPluginContentSetting(host, "bar", CONTENT_SETTING_BLOCK, true, true); - VerifyPluginContentSetting(unmatched_host, "bar", CONTENT_SETTING_BLOCK, true, + VerifyPluginContentSetting(host, std::string(), CONTENT_SETTING_BLOCK, true, true); + VerifyPluginContentSetting(unmatched_host, std::string(), + CONTENT_SETTING_BLOCK, true, true); }
diff --git a/chrome/test/data/policy/policy_test_cases.json b/chrome/test/data/policy/policy_test_cases.json index 4a9ff34..9c24297 100644 --- a/chrome/test/data/policy/policy_test_cases.json +++ b/chrome/test/data/policy/policy_test_cases.json
@@ -3433,6 +3433,16 @@ ] }, + "DeviceHostnameTemplate": { + "os": ["chromeos"], + "test_policy": { + "DeviceHostnameTemplate": "chromebook-${ASSET_ID}" + }, + "pref_mappings": [ + { "pref": "cros.network.hostname_template" } + ] + }, + "----- Chrome Frame policies -------------------------------------------": {}, "ChromeFrameRendererSettings": {
diff --git a/chromeos/network/network_state_handler.cc b/chromeos/network/network_state_handler.cc index 2ba46a0..9ab391da 100644 --- a/chromeos/network/network_state_handler.cc +++ b/chromeos/network/network_state_handler.cc
@@ -935,6 +935,11 @@ shill_property_handler_->SetWakeOnLanEnabled(enabled); } +void NetworkStateHandler::SetHostname(const std::string& hostname) { + NET_LOG_EVENT("SetHostname", hostname); + shill_property_handler_->SetHostname(hostname); +} + void NetworkStateHandler::SetNetworkThrottlingStatus( bool enabled, uint32_t upload_rate_kbits,
diff --git a/chromeos/network/network_state_handler.h b/chromeos/network/network_state_handler.h index f77724e..cfb6e212 100644 --- a/chromeos/network/network_state_handler.h +++ b/chromeos/network/network_state_handler.h
@@ -318,6 +318,10 @@ // only set it. void SetWakeOnLanEnabled(bool enabled); + // Sets the HostName property. Note: we do not track this property, we + // only set it. + void SetHostname(const std::string& hostname); + // Enable or disable network bandwidth throttling, on all interfaces on the // system. If |enabled| is true, |upload_rate_kbits| and |download_rate_kbits| // are the desired rates (in kbits/s) to throttle to. If |enabled| is false,
diff --git a/chromeos/network/shill_property_handler.cc b/chromeos/network/shill_property_handler.cc index ec1f157..300c222 100644 --- a/chromeos/network/shill_property_handler.cc +++ b/chromeos/network/shill_property_handler.cc
@@ -229,6 +229,15 @@ network_handler::ErrorCallback())); } +void ShillPropertyHandler::SetHostname(const std::string& hostname) { + base::Value value(hostname); + shill_manager_->SetProperty( + shill::kHostNameProperty, value, base::BindRepeating(&base::DoNothing), + base::BindRepeating(&network_handler::ShillErrorCallbackFunction, + "SetHostname Failed", "Manager", + network_handler::ErrorCallback())); +} + void ShillPropertyHandler::SetNetworkThrottlingStatus( bool throttling_enabled, uint32_t upload_rate_kbits,
diff --git a/chromeos/network/shill_property_handler.h b/chromeos/network/shill_property_handler.h index 605ba1e..4a0569ee 100644 --- a/chromeos/network/shill_property_handler.h +++ b/chromeos/network/shill_property_handler.h
@@ -139,6 +139,10 @@ // only set it. void SetWakeOnLanEnabled(bool enabled); + // Sets the HostName property. Note: we do not track this property, we + // only set it. + void SetHostname(const std::string& hostname); + // Calls shill to enable/disable network bandwidth throttling. If |enabled| // is true, |upload_rate_kbits| and |download_rate_kbits| specify the rate // in kbits/s to throttle to. If |enabled| is false, throttling is disabled
diff --git a/chromeos/settings/cros_settings_names.cc b/chromeos/settings/cros_settings_names.cc index 4a6ab48..687a1b5 100644 --- a/chromeos/settings/cros_settings_names.cc +++ b/chromeos/settings/cros_settings_names.cc
@@ -302,4 +302,12 @@ // use ARC. const char kUnaffiliatedArcAllowed[] = "cros.device.unaffiliated_arc_allowed"; +// String that is used as a template for generating device hostname (that is +// used in DHCP requests). +// If the string contains either ASSET_ID, SERIAL_NUM or MAC_ADDR values, +// they will be substituted for real values. +// If the string is empty or blank, or the resulting hostname is not valid +// as per RFC 1035, then no hostname will be used. +const char kDeviceHostnameTemplate[] = "cros.network.hostname_template"; + } // namespace chromeos
diff --git a/chromeos/settings/cros_settings_names.h b/chromeos/settings/cros_settings_names.h index 6dfdf26f..275753e 100644 --- a/chromeos/settings/cros_settings_names.h +++ b/chromeos/settings/cros_settings_names.h
@@ -139,6 +139,8 @@ CHROMEOS_EXPORT extern const char kUnaffiliatedArcAllowed[]; +CHROMEOS_EXPORT extern const char kDeviceHostnameTemplate[]; + } // namespace chromeos #endif // CHROMEOS_SETTINGS_CROS_SETTINGS_NAMES_H_
diff --git a/components/content_settings/core/browser/content_settings_pref.cc b/components/content_settings/core/browser/content_settings_pref.cc index e791367..af2021a 100644 --- a/components/content_settings/core/browser/content_settings_pref.cc +++ b/components/content_settings/core/browser/content_settings_pref.cc
@@ -118,8 +118,12 @@ DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(prefs_); DCHECK(primary_pattern != ContentSettingsPattern::Wildcard() || - secondary_pattern != ContentSettingsPattern::Wildcard() || - !resource_identifier.empty()); + secondary_pattern != ContentSettingsPattern::Wildcard()); + + // Resource Identifiers have been supported by the API but never used by any + // users of the API. + // TODO(crbug.com/754178): remove |resource_identifier| from the API. + DCHECK(resource_identifier.empty()); // At this point take the ownership of the |in_value|. std::unique_ptr<base::Value> value(in_value); @@ -273,6 +277,11 @@ const base::DictionaryValue* resource_dictionary = nullptr; if (settings_dictionary->GetDictionary( kPerResourceIdentifierPrefName, &resource_dictionary)) { + // Resource Identifiers have been supported by the API but never used by + // any users of the API. + // TODO(crbug.com/754178): remove |resource_identifier| from the API. + NOTREACHED(); + base::Time last_modified = GetTimeStamp(settings_dictionary); for (base::DictionaryValue::Iterator j(*resource_dictionary); !j.IsAtEnd();
diff --git a/components/policy/proto/chrome_device_policy.proto b/components/policy/proto/chrome_device_policy.proto index 37e535a..385aa70 100644 --- a/components/policy/proto/chrome_device_policy.proto +++ b/components/policy/proto/chrome_device_policy.proto
@@ -89,6 +89,14 @@ optional string open_network_configuration = 1; } +message NetworkHostnameProto { + // The device hostname template. It might contain following + // patterns that would be substituted by the device: + // ASSET_ID, SERIAL_NUM, MAC_ADDR, and string after substitution should + // be a valid hostname. + optional string device_hostname_template = 1; +} + // Policies to turn on portions of the device status reports. message DeviceReportingProto { optional bool report_version_info = 1 [default = true]; @@ -1034,4 +1042,5 @@ optional DeviceLoginScreenAutoSelectCertificateForUrls device_login_screen_auto_select_certificate_for_urls = 62; optional UnaffiliatedArcAllowedProto unaffiliated_arc_allowed = 63; + optional NetworkHostnameProto network_hostname = 64; }
diff --git a/components/policy/resources/policy_templates.json b/components/policy/resources/policy_templates.json index 85711d4..5a47062 100644 --- a/components/policy/resources/policy_templates.json +++ b/components/policy/resources/policy_templates.json
@@ -146,7 +146,7 @@ # persistent IDs for all fields (but not for groups!) are needed. These are # specified by the 'id' keys of each policy. NEVER CHANGE EXISTING IDs, # because doing so would break the deployed wire format! -# For your editing convenience: highest ID currently used: 402 +# For your editing convenience: highest ID currently used: 403 # And don't forget to also update the EnterprisePolicies enum of # histograms.xml (run 'python tools/metrics/histograms/update_policies.py'). # @@ -10767,7 +10767,30 @@ If you do not set this policy, <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> will use its usual default directory (platform-specific). See https://www.chromium.org/administrators/policy-list-3/user-data-directory-variables for a list of variables that can be used.''', - } + }, + { + 'name': 'DeviceHostnameTemplate', + 'type': 'string', + 'schema': { 'type': 'string' }, + 'supported_on': ['chrome_os:64-'], + 'device_only': True, + 'future': True, + 'features': { + 'dynamic_refresh': True, + 'per_profile': False, + }, + 'example_value': 'chromebook-${ASSET_ID}', + 'id': 403, + 'caption': '''Device network hostname''', + 'tags': [], + 'desc': '''Determine the hostname of the device used in DHCP requests. + + If this policy is set to a non empty string, that string will be used as the device hostname during DHCP request. + + The string can contain variables ${ASSET_ID}, ${SERIAL_NUM}, ${MAC_ADDR} that would be replaced with values on the device before using as a hostname. Resulting substitution should be a valid hostname (per RFC 1035, section 3.1). + + If this policy is not set, or the value after substitution is not a valid hostname, no hostname will be set in DHCP request. ''' + }, ], 'messages': { # Messages that are not associated to any policies.
diff --git a/components/prefs/pref_service.cc b/components/prefs/pref_service.cc index c4b27676..e094a76 100644 --- a/components/prefs/pref_service.cc +++ b/components/prefs/pref_service.cc
@@ -59,15 +59,15 @@ } // namespace PrefService::PrefService( - PrefNotifierImpl* pref_notifier, - PrefValueStore* pref_value_store, + std::unique_ptr<PrefNotifierImpl> pref_notifier, + std::unique_ptr<PrefValueStore> pref_value_store, PersistentPrefStore* user_prefs, PrefRegistry* pref_registry, base::Callback<void(PersistentPrefStore::PrefReadError)> read_error_callback, bool async) - : pref_notifier_(pref_notifier), - pref_value_store_(pref_value_store), + : pref_notifier_(std::move(pref_notifier)), + pref_value_store_(std::move(pref_value_store)), pref_registry_(pref_registry), user_pref_store_(user_prefs), read_error_callback_(read_error_callback) {
diff --git a/components/prefs/pref_service.h b/components/prefs/pref_service.h index 665905ce..2b46b19 100644 --- a/components/prefs/pref_service.h +++ b/components/prefs/pref_service.h
@@ -163,14 +163,13 @@ // You may wish to use PrefServiceFactory or one of its subclasses // for simplified construction. - PrefService( - PrefNotifierImpl* pref_notifier, - PrefValueStore* pref_value_store, - PersistentPrefStore* user_prefs, - PrefRegistry* pref_registry, - base::Callback<void(PersistentPrefStore::PrefReadError)> - read_error_callback, - bool async); + PrefService(std::unique_ptr<PrefNotifierImpl> pref_notifier, + std::unique_ptr<PrefValueStore> pref_value_store, + PersistentPrefStore* user_prefs, + PrefRegistry* pref_registry, + base::Callback<void(PersistentPrefStore::PrefReadError)> + read_error_callback, + bool async); virtual ~PrefService(); // Lands pending writes to disk. This should only be used if we need to save
diff --git a/components/prefs/pref_service_factory.cc b/components/prefs/pref_service_factory.cc index e9dc7e4..b7b0edd 100644 --- a/components/prefs/pref_service_factory.cc +++ b/components/prefs/pref_service_factory.cc
@@ -4,6 +4,8 @@ #include "components/prefs/pref_service_factory.h" +#include <memory> + #include "base/bind.h" #include "base/sequenced_task_runner.h" #include "components/prefs/default_pref_store.h" @@ -22,13 +24,7 @@ } // namespace PrefServiceFactory::PrefServiceFactory() - : managed_prefs_(nullptr), - supervised_user_prefs_(nullptr), - extension_prefs_(nullptr), - command_line_prefs_(nullptr), - user_prefs_(nullptr), - recommended_prefs_(nullptr), - read_error_callback_(base::Bind(&DoNothingHandleReadError)), + : read_error_callback_(base::Bind(&DoNothingHandleReadError)), async_(false) {} PrefServiceFactory::~PrefServiceFactory() {} @@ -37,20 +33,19 @@ const base::FilePath& prefs_file, base::SequencedTaskRunner* task_runner) { user_prefs_ = - new JsonPrefStore(prefs_file, task_runner, std::unique_ptr<PrefFilter>()); + base::MakeRefCounted<JsonPrefStore>(prefs_file, task_runner, nullptr); } std::unique_ptr<PrefService> PrefServiceFactory::Create( PrefRegistry* pref_registry, std::unique_ptr<PrefValueStore::Delegate> delegate) { - PrefNotifierImpl* pref_notifier = new PrefNotifierImpl(); - std::unique_ptr<PrefService> pref_service(new PrefService( - pref_notifier, - new PrefValueStore(managed_prefs_.get(), supervised_user_prefs_.get(), - extension_prefs_.get(), command_line_prefs_.get(), - user_prefs_.get(), recommended_prefs_.get(), - pref_registry->defaults().get(), pref_notifier, - std::move(delegate)), - user_prefs_.get(), pref_registry, read_error_callback_, async_)); - return pref_service; + auto pref_notifier = std::make_unique<PrefNotifierImpl>(); + auto pref_value_store = std::make_unique<PrefValueStore>( + managed_prefs_.get(), supervised_user_prefs_.get(), + extension_prefs_.get(), command_line_prefs_.get(), user_prefs_.get(), + recommended_prefs_.get(), pref_registry->defaults().get(), + pref_notifier.get(), std::move(delegate)); + return std::make_unique<PrefService>( + std::move(pref_notifier), std::move(pref_value_store), user_prefs_.get(), + pref_registry, read_error_callback_, async_); }
diff --git a/components/prefs/pref_service_factory.h b/components/prefs/pref_service_factory.h index 07212bc..11b983a 100644 --- a/components/prefs/pref_service_factory.h +++ b/components/prefs/pref_service_factory.h
@@ -28,26 +28,28 @@ virtual ~PrefServiceFactory(); // Functions for setting the various parameters of the PrefService to build. - void set_managed_prefs(const scoped_refptr<PrefStore>& managed_prefs) { - managed_prefs_ = managed_prefs; + void set_managed_prefs(scoped_refptr<PrefStore> prefs) { + managed_prefs_.swap(prefs); } - void set_supervised_user_prefs( - const scoped_refptr<PrefStore>& supervised_user_prefs) { - supervised_user_prefs_ = supervised_user_prefs; + + void set_supervised_user_prefs(scoped_refptr<PrefStore> prefs) { + supervised_user_prefs_.swap(prefs); } - void set_extension_prefs(const scoped_refptr<PrefStore>& extension_prefs) { - extension_prefs_ = extension_prefs; + + void set_extension_prefs(scoped_refptr<PrefStore> prefs) { + extension_prefs_.swap(prefs); } - void set_command_line_prefs( - const scoped_refptr<PrefStore>& command_line_prefs) { - command_line_prefs_ = command_line_prefs; + + void set_command_line_prefs(scoped_refptr<PrefStore> prefs) { + command_line_prefs_.swap(prefs); } - void set_user_prefs(const scoped_refptr<PersistentPrefStore>& user_prefs) { - user_prefs_ = user_prefs; + + void set_user_prefs(scoped_refptr<PersistentPrefStore> prefs) { + user_prefs_.swap(prefs); } - void set_recommended_prefs( - const scoped_refptr<PrefStore>& recommended_prefs) { - recommended_prefs_ = recommended_prefs; + + void set_recommended_prefs(scoped_refptr<PrefStore> prefs) { + recommended_prefs_.swap(prefs); } // Sets up error callback for the PrefService. A do-nothing default
diff --git a/components/prefs/pref_value_store.cc b/components/prefs/pref_value_store.cc index 3b80325..8f9e704 100644 --- a/components/prefs/pref_value_store.cc +++ b/components/prefs/pref_value_store.cc
@@ -76,7 +76,7 @@ PrefValueStore::~PrefValueStore() {} -PrefValueStore* PrefValueStore::CloneAndSpecialize( +std::unique_ptr<PrefValueStore> PrefValueStore::CloneAndSpecialize( PrefStore* managed_prefs, PrefStore* supervised_user_prefs, PrefStore* extension_prefs, @@ -102,10 +102,10 @@ if (!default_prefs) default_prefs = GetPrefStore(DEFAULT_STORE); - return new PrefValueStore(managed_prefs, supervised_user_prefs, - extension_prefs, command_line_prefs, user_prefs, - recommended_prefs, default_prefs, pref_notifier, - std::move(delegate)); + return std::make_unique<PrefValueStore>( + managed_prefs, supervised_user_prefs, extension_prefs, command_line_prefs, + user_prefs, recommended_prefs, default_prefs, pref_notifier, + std::move(delegate)); } void PrefValueStore::set_callback(const PrefChangedCallback& callback) {
diff --git a/components/prefs/pref_value_store.h b/components/prefs/pref_value_store.h index 3895fa790..4181d11 100644 --- a/components/prefs/pref_value_store.h +++ b/components/prefs/pref_value_store.h
@@ -6,6 +6,7 @@ #define COMPONENTS_PREFS_PREF_VALUE_STORE_H_ #include <map> +#include <memory> #include <string> #include <type_traits> #include <vector> @@ -115,7 +116,7 @@ // by the parameters passed, if unequal NULL. // // The new PrefValueStore is passed the |delegate| in its constructor. - PrefValueStore* CloneAndSpecialize( + std::unique_ptr<PrefValueStore> CloneAndSpecialize( PrefStore* managed_prefs, PrefStore* supervised_user_prefs, PrefStore* extension_prefs,
diff --git a/components/prefs/testing_pref_service.cc b/components/prefs/testing_pref_service.cc index 91df4e9..aa6582d 100644 --- a/components/prefs/testing_pref_service.cc +++ b/components/prefs/testing_pref_service.cc
@@ -4,6 +4,8 @@ #include "components/prefs/testing_pref_service.h" +#include <memory> + #include "base/bind.h" #include "base/compiler_specific.h" #include "components/prefs/default_pref_store.h" @@ -21,15 +23,15 @@ PrefRegistry* pref_registry, PrefNotifierImpl* pref_notifier) : PrefService( - pref_notifier, - new PrefValueStore(managed_prefs, - nullptr, - extension_prefs, - nullptr, - user_prefs, - recommended_prefs, - pref_registry->defaults().get(), - pref_notifier), + std::unique_ptr<PrefNotifierImpl>(pref_notifier), + std::make_unique<PrefValueStore>(managed_prefs, + nullptr, + extension_prefs, + nullptr, + user_prefs, + recommended_prefs, + pref_registry->defaults().get(), + pref_notifier), user_prefs, pref_registry, base::Bind(&TestingPrefServiceBase<PrefService,
diff --git a/components/prefs/testing_pref_service.h b/components/prefs/testing_pref_service.h index 5378968d..65f008b8 100644 --- a/components/prefs/testing_pref_service.h +++ b/components/prefs/testing_pref_service.h
@@ -29,16 +29,16 @@ public: virtual ~TestingPrefServiceBase(); - // Read the value of a preference from the managed layer. Returns NULL if the + // Reads the value of a preference from the managed layer. Returns NULL if the // preference is not defined at the managed layer. const base::Value* GetManagedPref(const std::string& path) const; - // Set a preference on the managed layer and fire observers if the preference - // changed. + // Sets a preference on the managed layer and fires observers if the + // preference changed. void SetManagedPref(const std::string& path, std::unique_ptr<base::Value> value); - // Clear the preference on the managed layer and fire observers if the + // Clears the preference on the managed layer and fire observers if the // preference has been defined previously. void RemoveManagedPref(const std::string& path);
diff --git a/components/sync_preferences/pref_service_syncable.cc b/components/sync_preferences/pref_service_syncable.cc index 021e3bb..c132e1e 100644 --- a/components/sync_preferences/pref_service_syncable.cc +++ b/components/sync_preferences/pref_service_syncable.cc
@@ -4,6 +4,8 @@ #include "components/sync_preferences/pref_service_syncable.h" +#include <utility> + #include "base/bind.h" #include "base/callback.h" #include "base/files/file_path.h" @@ -26,16 +28,16 @@ namespace sync_preferences { PrefServiceSyncable::PrefServiceSyncable( - PrefNotifierImpl* pref_notifier, - PrefValueStore* pref_value_store, + std::unique_ptr<PrefNotifierImpl> pref_notifier, + std::unique_ptr<PrefValueStore> pref_value_store, PersistentPrefStore* user_prefs, user_prefs::PrefRegistrySyncable* pref_registry, const PrefModelAssociatorClient* pref_model_associator_client, base::Callback<void(PersistentPrefStore::PrefReadError)> read_error_callback, bool async) - : PrefService(pref_notifier, - pref_value_store, + : PrefService(std::move(pref_notifier), + std::move(pref_value_store), user_prefs, pref_registry, read_error_callback, @@ -48,7 +50,7 @@ priority_pref_sync_associator_.SetPrefService(this); // Let PrefModelAssociators know about changes to preference values. - pref_value_store->set_callback(base::Bind( + pref_value_store_->set_callback(base::Bind( &PrefServiceSyncable::ProcessPrefChange, base::Unretained(this))); // Add already-registered syncable preferences to PrefModelAssociator. @@ -78,7 +80,7 @@ const std::vector<const char*>& overlay_pref_names, std::unique_ptr<PrefValueStore::Delegate> delegate) { pref_service_forked_ = true; - PrefNotifierImpl* pref_notifier = new PrefNotifierImpl(); + auto pref_notifier = std::make_unique<PrefNotifierImpl>(); scoped_refptr<user_prefs::PrefRegistrySyncable> forked_registry = static_cast<user_prefs::PrefRegistrySyncable*>(pref_registry_.get()) @@ -96,16 +98,17 @@ for (const char* overlay_pref_name : overlay_pref_names) incognito_pref_store->RegisterOverlayPref(overlay_pref_name); + auto pref_value_store = pref_value_store_->CloneAndSpecialize( + nullptr, // managed + nullptr, // supervised_user + incognito_extension_pref_store, + nullptr, // command_line_prefs + incognito_pref_store.get(), + nullptr, // recommended + forked_registry->defaults().get(), pref_notifier.get(), + std::move(delegate)); PrefServiceSyncable* incognito_service = new PrefServiceSyncable( - pref_notifier, - pref_value_store_->CloneAndSpecialize(nullptr, // managed - nullptr, // supervised_user - incognito_extension_pref_store, - nullptr, // command_line_prefs - incognito_pref_store.get(), - nullptr, // recommended - forked_registry->defaults().get(), - pref_notifier, std::move(delegate)), + std::move(pref_notifier), std::move(pref_value_store), incognito_pref_store.get(), forked_registry.get(), pref_sync_associator_.client(), read_error_callback_, false); return incognito_service;
diff --git a/components/sync_preferences/pref_service_syncable.h b/components/sync_preferences/pref_service_syncable.h index 21f58b9..7a2c9f0 100644 --- a/components/sync_preferences/pref_service_syncable.h +++ b/components/sync_preferences/pref_service_syncable.h
@@ -7,6 +7,7 @@ #include <stdint.h> +#include <memory> #include <string> #include <vector> @@ -35,8 +36,8 @@ // You may wish to use PrefServiceFactory or one of its subclasses // for simplified construction. PrefServiceSyncable( - PrefNotifierImpl* pref_notifier, - PrefValueStore* pref_value_store, + std::unique_ptr<PrefNotifierImpl> pref_notifier, + std::unique_ptr<PrefValueStore> pref_value_store, PersistentPrefStore* user_prefs, user_prefs::PrefRegistrySyncable* pref_registry, const PrefModelAssociatorClient* pref_model_associato_client,
diff --git a/components/sync_preferences/pref_service_syncable_factory.cc b/components/sync_preferences/pref_service_syncable_factory.cc index 516415a..3b12290d 100644 --- a/components/sync_preferences/pref_service_syncable_factory.cc +++ b/components/sync_preferences/pref_service_syncable_factory.cc
@@ -4,6 +4,8 @@ #include "components/sync_preferences/pref_service_syncable_factory.h" +#include <memory> + #include "base/trace_event/trace_event.h" #include "build/build_config.h" #include "components/pref_registry/pref_registry_syncable.h" @@ -56,18 +58,16 @@ user_prefs::PrefRegistrySyncable* pref_registry, std::unique_ptr<PrefValueStore::Delegate> delegate) { TRACE_EVENT0("browser", "PrefServiceSyncableFactory::CreateSyncable"); - PrefNotifierImpl* pref_notifier = new PrefNotifierImpl(); - - std::unique_ptr<PrefServiceSyncable> pref_service(new PrefServiceSyncable( - pref_notifier, - new PrefValueStore(managed_prefs_.get(), supervised_user_prefs_.get(), - extension_prefs_.get(), command_line_prefs_.get(), - user_prefs_.get(), recommended_prefs_.get(), - pref_registry->defaults().get(), pref_notifier, - std::move(delegate)), - user_prefs_.get(), pref_registry, pref_model_associator_client_, - read_error_callback_, async_)); - return pref_service; + auto pref_notifier = std::make_unique<PrefNotifierImpl>(); + auto pref_value_store = std::make_unique<PrefValueStore>( + managed_prefs_.get(), supervised_user_prefs_.get(), + extension_prefs_.get(), command_line_prefs_.get(), user_prefs_.get(), + recommended_prefs_.get(), pref_registry->defaults().get(), + pref_notifier.get(), std::move(delegate)); + return std::make_unique<PrefServiceSyncable>( + std::move(pref_notifier), std::move(pref_value_store), user_prefs_.get(), + pref_registry, pref_model_associator_client_, read_error_callback_, + async_); } } // namespace sync_preferences
diff --git a/components/sync_preferences/testing_pref_service_syncable.cc b/components/sync_preferences/testing_pref_service_syncable.cc index e1598e9..92fa102 100644 --- a/components/sync_preferences/testing_pref_service_syncable.cc +++ b/components/sync_preferences/testing_pref_service_syncable.cc
@@ -20,15 +20,15 @@ user_prefs::PrefRegistrySyncable* pref_registry, PrefNotifierImpl* pref_notifier) : sync_preferences::PrefServiceSyncable( - pref_notifier, - new PrefValueStore(managed_prefs, - nullptr, // supervised_user_prefs - extension_prefs, // extension_prefs - nullptr, // command_line_prefs - user_prefs, - recommended_prefs, - pref_registry->defaults().get(), - pref_notifier), + std::unique_ptr<PrefNotifierImpl>(pref_notifier), + std::make_unique<PrefValueStore>(managed_prefs, + nullptr, // supervised_user_prefs + extension_prefs, // extension_prefs + nullptr, // command_line_prefs + user_prefs, + recommended_prefs, + pref_registry->defaults().get(), + pref_notifier), user_prefs, pref_registry, nullptr, // pref_model_associator_client
diff --git a/net/ntlm/ntlm_buffer_reader.cc b/net/ntlm/ntlm_buffer_reader.cc index b23e38b..8bba339 100644 --- a/net/ntlm/ntlm_buffer_reader.cc +++ b/net/ntlm/ntlm_buffer_reader.cc
@@ -25,7 +25,7 @@ : NtlmBufferReader( base::StringPiece(reinterpret_cast<const char*>(ptr), len)) {} -NtlmBufferReader::~NtlmBufferReader() {} +NtlmBufferReader::~NtlmBufferReader() = default; bool NtlmBufferReader::CanRead(size_t len) const { return CanReadFrom(GetCursor(), len);
diff --git a/net/ntlm/ntlm_buffer_writer.cc b/net/ntlm/ntlm_buffer_writer.cc index da6bc773..300812b 100644 --- a/net/ntlm/ntlm_buffer_writer.cc +++ b/net/ntlm/ntlm_buffer_writer.cc
@@ -18,7 +18,7 @@ NtlmBufferWriter::NtlmBufferWriter(size_t buffer_len) : buffer_(buffer_len, 0), cursor_(0) {} -NtlmBufferWriter::~NtlmBufferWriter() {} +NtlmBufferWriter::~NtlmBufferWriter() = default; bool NtlmBufferWriter::CanWrite(size_t len) const { if (!GetBufferPtr())
diff --git a/net/ntlm/ntlm_client.cc b/net/ntlm/ntlm_client.cc index a034fd37..f8e12f5 100644 --- a/net/ntlm/ntlm_client.cc +++ b/net/ntlm/ntlm_client.cc
@@ -144,7 +144,7 @@ GenerateNegotiateMessage(); } -NtlmClient::~NtlmClient() {} +NtlmClient::~NtlmClient() = default; Buffer NtlmClient::GetNegotiateMessage() const { return negotiate_message_;
diff --git a/net/proxy/dhcp_proxy_script_fetcher.cc b/net/proxy/dhcp_proxy_script_fetcher.cc index 839c59b..71a32c2 100644 --- a/net/proxy/dhcp_proxy_script_fetcher.cc +++ b/net/proxy/dhcp_proxy_script_fetcher.cc
@@ -12,13 +12,13 @@ return std::string(); } -DhcpProxyScriptFetcher::DhcpProxyScriptFetcher() {} +DhcpProxyScriptFetcher::DhcpProxyScriptFetcher() = default; -DhcpProxyScriptFetcher::~DhcpProxyScriptFetcher() {} +DhcpProxyScriptFetcher::~DhcpProxyScriptFetcher() = default; -DoNothingDhcpProxyScriptFetcher::DoNothingDhcpProxyScriptFetcher() {} +DoNothingDhcpProxyScriptFetcher::DoNothingDhcpProxyScriptFetcher() = default; -DoNothingDhcpProxyScriptFetcher::~DoNothingDhcpProxyScriptFetcher() {} +DoNothingDhcpProxyScriptFetcher::~DoNothingDhcpProxyScriptFetcher() = default; int DoNothingDhcpProxyScriptFetcher::Fetch( base::string16* utf16_text, const CompletionCallback& callback) {
diff --git a/net/proxy/dhcp_proxy_script_fetcher_factory.cc b/net/proxy/dhcp_proxy_script_fetcher_factory.cc index 0590690..b0188ea 100644 --- a/net/proxy/dhcp_proxy_script_fetcher_factory.cc +++ b/net/proxy/dhcp_proxy_script_fetcher_factory.cc
@@ -13,9 +13,9 @@ namespace net { -DhcpProxyScriptFetcherFactory::DhcpProxyScriptFetcherFactory() {} +DhcpProxyScriptFetcherFactory::DhcpProxyScriptFetcherFactory() = default; -DhcpProxyScriptFetcherFactory::~DhcpProxyScriptFetcherFactory() {} +DhcpProxyScriptFetcherFactory::~DhcpProxyScriptFetcherFactory() = default; std::unique_ptr<DhcpProxyScriptFetcher> DhcpProxyScriptFetcherFactory::Create( URLRequestContext* context) {
diff --git a/net/proxy/mock_proxy_resolver.cc b/net/proxy/mock_proxy_resolver.cc index 2d6889d05..0daea49 100644 --- a/net/proxy/mock_proxy_resolver.cc +++ b/net/proxy/mock_proxy_resolver.cc
@@ -31,7 +31,7 @@ const CompletionCallback& callback) : resolver_(resolver), url_(url), results_(results), callback_(callback) {} -MockAsyncProxyResolver::Job::~Job() {} +MockAsyncProxyResolver::Job::~Job() = default; void MockAsyncProxyResolver::Job::CompleteNow(int rv) { CompletionCallback callback = callback_; @@ -41,7 +41,7 @@ callback.Run(rv); } -MockAsyncProxyResolver::~MockAsyncProxyResolver() {} +MockAsyncProxyResolver::~MockAsyncProxyResolver() = default; int MockAsyncProxyResolver::GetProxyForURL( const GURL& url, @@ -77,8 +77,7 @@ pending_jobs_.erase(it); } -MockAsyncProxyResolver::MockAsyncProxyResolver() { -} +MockAsyncProxyResolver::MockAsyncProxyResolver() = default; MockAsyncProxyResolverFactory::Request::Request( MockAsyncProxyResolverFactory* factory, @@ -90,8 +89,7 @@ resolver_(resolver), callback_(callback) {} -MockAsyncProxyResolverFactory::Request::~Request() { -} +MockAsyncProxyResolverFactory::Request::~Request() = default; void MockAsyncProxyResolverFactory::Request::CompleteNow( int rv,
diff --git a/net/proxy/mock_proxy_script_fetcher.cc b/net/proxy/mock_proxy_script_fetcher.cc index e07bde57..8e0d3dd 100644 --- a/net/proxy/mock_proxy_script_fetcher.cc +++ b/net/proxy/mock_proxy_script_fetcher.cc
@@ -18,7 +18,7 @@ waiting_for_fetch_(false), is_shutdown_(false) {} -MockProxyScriptFetcher::~MockProxyScriptFetcher() {} +MockProxyScriptFetcher::~MockProxyScriptFetcher() = default; // ProxyScriptFetcher implementation. int MockProxyScriptFetcher::Fetch(const GURL& url, base::string16* text,
diff --git a/net/proxy/multi_threaded_proxy_resolver.cc b/net/proxy/multi_threaded_proxy_resolver.cc index 4edab19ff..a50b3f9 100644 --- a/net/proxy/multi_threaded_proxy_resolver.cc +++ b/net/proxy/multi_threaded_proxy_resolver.cc
@@ -224,7 +224,7 @@ friend class base::RefCountedThreadSafe<Job>; - virtual ~Job() {} + virtual ~Job() = default; private: const Type type_; @@ -270,7 +270,7 @@ } protected: - ~CreateResolverJob() override {} + ~CreateResolverJob() override = default; private: // Runs the completion callback on the origin thread. @@ -338,7 +338,7 @@ } protected: - ~GetProxyForURLJob() override {} + ~GetProxyForURLJob() override = default; private: // Runs the completion callback on the origin thread.
diff --git a/net/proxy/multi_threaded_proxy_resolver_unittest.cc b/net/proxy/multi_threaded_proxy_resolver_unittest.cc index 59524eb..8cc5bb6 100644 --- a/net/proxy/multi_threaded_proxy_resolver_unittest.cc +++ b/net/proxy/multi_threaded_proxy_resolver_unittest.cc
@@ -142,7 +142,7 @@ public: BlockableProxyResolverFactory() : ProxyResolverFactory(false) {} - ~BlockableProxyResolverFactory() override {} + ~BlockableProxyResolverFactory() override = default; int CreateProxyResolver( const scoped_refptr<ProxyResolverScriptData>& script_data,
diff --git a/net/proxy/network_delegate_error_observer.cc b/net/proxy/network_delegate_error_observer.cc index e51b3999..6fe0aaa 100644 --- a/net/proxy/network_delegate_error_observer.cc +++ b/net/proxy/network_delegate_error_observer.cc
@@ -43,8 +43,7 @@ DCHECK(origin_runner); } -NetworkDelegateErrorObserver::Core::~Core() {} - +NetworkDelegateErrorObserver::Core::~Core() = default; void NetworkDelegateErrorObserver::Core::NotifyPACScriptError( int line_number,
diff --git a/net/proxy/network_delegate_error_observer_unittest.cc b/net/proxy/network_delegate_error_observer_unittest.cc index 3055340..8a6fe3c 100644 --- a/net/proxy/network_delegate_error_observer_unittest.cc +++ b/net/proxy/network_delegate_error_observer_unittest.cc
@@ -22,7 +22,7 @@ class TestNetworkDelegate : public NetworkDelegateImpl { public: TestNetworkDelegate() : got_pac_error_(false) {} - ~TestNetworkDelegate() override {} + ~TestNetworkDelegate() override = default; bool got_pac_error() const { return got_pac_error_; }
diff --git a/net/proxy/polling_proxy_config_service.cc b/net/proxy/polling_proxy_config_service.cc index 0208979c..7a78400 100644 --- a/net/proxy/polling_proxy_config_service.cc +++ b/net/proxy/polling_proxy_config_service.cc
@@ -98,7 +98,7 @@ private: friend class base::RefCountedThreadSafe<Core>; - ~Core() {} + ~Core() = default; void PollAsync(GetConfigFunction func) { ProxyConfig config;
diff --git a/net/proxy/proxy_bypass_rules.cc b/net/proxy/proxy_bypass_rules.cc index 2d22ae9..dddfe43 100644 --- a/net/proxy/proxy_bypass_rules.cc +++ b/net/proxy/proxy_bypass_rules.cc
@@ -136,18 +136,15 @@ } // namespace -ProxyBypassRules::Rule::Rule() { -} +ProxyBypassRules::Rule::Rule() = default; -ProxyBypassRules::Rule::~Rule() { -} +ProxyBypassRules::Rule::~Rule() = default; bool ProxyBypassRules::Rule::Equals(const Rule& rule) const { return ToString() == rule.ToString(); } -ProxyBypassRules::ProxyBypassRules() { -} +ProxyBypassRules::ProxyBypassRules() = default; ProxyBypassRules::ProxyBypassRules(const ProxyBypassRules& rhs) { AssignFrom(rhs);
diff --git a/net/proxy/proxy_config.cc b/net/proxy/proxy_config.cc index 87e17d8..1f4ae8b1 100644 --- a/net/proxy/proxy_config.cc +++ b/net/proxy/proxy_config.cc
@@ -45,8 +45,7 @@ ProxyConfig::ProxyRules::ProxyRules(const ProxyRules& other) = default; -ProxyConfig::ProxyRules::~ProxyRules() { -} +ProxyConfig::ProxyRules::~ProxyRules() = default; void ProxyConfig::ProxyRules::Apply(const GURL& url, ProxyInfo* result) const { if (empty()) { @@ -198,8 +197,7 @@ ProxyConfig::ProxyConfig(const ProxyConfig& config) = default; -ProxyConfig::~ProxyConfig() { -} +ProxyConfig::~ProxyConfig() = default; ProxyConfig& ProxyConfig::operator=(const ProxyConfig& config) = default;
diff --git a/net/proxy/proxy_config_service_fixed.cc b/net/proxy/proxy_config_service_fixed.cc index 3081ea5..ebcdbd3 100644 --- a/net/proxy/proxy_config_service_fixed.cc +++ b/net/proxy/proxy_config_service_fixed.cc
@@ -10,7 +10,7 @@ : pc_(pc) { } -ProxyConfigServiceFixed::~ProxyConfigServiceFixed() {} +ProxyConfigServiceFixed::~ProxyConfigServiceFixed() = default; ProxyConfigService::ConfigAvailability ProxyConfigServiceFixed::GetLatestProxyConfig(ProxyConfig* config) {
diff --git a/net/proxy/proxy_config_service_linux.cc b/net/proxy/proxy_config_service_linux.cc index a28ed5b4..14e24fa 100644 --- a/net/proxy/proxy_config_service_linux.cc +++ b/net/proxy/proxy_config_service_linux.cc
@@ -94,8 +94,7 @@ } // namespace -ProxyConfigServiceLinux::Delegate::~Delegate() { -} +ProxyConfigServiceLinux::Delegate::~Delegate() = default; bool ProxyConfigServiceLinux::Delegate::GetProxyFromEnvVarForScheme( base::StringPiece variable,
diff --git a/net/proxy/proxy_info.cc b/net/proxy/proxy_info.cc index 642a421..ced7ee79 100644 --- a/net/proxy/proxy_info.cc +++ b/net/proxy/proxy_info.cc
@@ -17,8 +17,7 @@ ProxyInfo::ProxyInfo(const ProxyInfo& other) = default; -ProxyInfo::~ProxyInfo() { -} +ProxyInfo::~ProxyInfo() = default; void ProxyInfo::Use(const ProxyInfo& other) { proxy_resolve_start_time_ = other.proxy_resolve_start_time_;
diff --git a/net/proxy/proxy_list.cc b/net/proxy/proxy_list.cc index 2f65c72..9eefac04 100644 --- a/net/proxy/proxy_list.cc +++ b/net/proxy/proxy_list.cc
@@ -19,13 +19,11 @@ namespace net { -ProxyList::ProxyList() { -} +ProxyList::ProxyList() = default; ProxyList::ProxyList(const ProxyList& other) = default; -ProxyList::~ProxyList() { -} +ProxyList::~ProxyList() = default; void ProxyList::Set(const std::string& proxy_uri_list) { proxies_.clear();
diff --git a/net/proxy/proxy_resolver_factory.cc b/net/proxy/proxy_resolver_factory.cc index fc7173e9..9e88ff4 100644 --- a/net/proxy/proxy_resolver_factory.cc +++ b/net/proxy/proxy_resolver_factory.cc
@@ -13,7 +13,6 @@ : expects_pac_bytes_(expects_pac_bytes) { } -ProxyResolverFactory::~ProxyResolverFactory() { -} +ProxyResolverFactory::~ProxyResolverFactory() = default; } // namespace net
diff --git a/net/proxy/proxy_resolver_script_data.cc b/net/proxy/proxy_resolver_script_data.cc index 8c4fd31..d620955 100644 --- a/net/proxy/proxy_resolver_script_data.cc +++ b/net/proxy/proxy_resolver_script_data.cc
@@ -71,6 +71,6 @@ utf16_(utf16) { } -ProxyResolverScriptData::~ProxyResolverScriptData() {} +ProxyResolverScriptData::~ProxyResolverScriptData() = default; } // namespace net
diff --git a/net/proxy/proxy_resolver_v8.cc b/net/proxy/proxy_resolver_v8.cc index c26ecff..265aa69 100644 --- a/net/proxy/proxy_resolver_v8.cc +++ b/net/proxy/proxy_resolver_v8.cc
@@ -855,7 +855,7 @@ DCHECK(context_); } -ProxyResolverV8::~ProxyResolverV8() {} +ProxyResolverV8::~ProxyResolverV8() = default; int ProxyResolverV8::GetProxyForURL(const GURL& query_url, ProxyInfo* results,
diff --git a/net/proxy/proxy_script_decider_unittest.cc b/net/proxy/proxy_script_decider_unittest.cc index 1a2a368..15c5d0f 100644 --- a/net/proxy/proxy_script_decider_unittest.cc +++ b/net/proxy/proxy_script_decider_unittest.cc
@@ -162,9 +162,9 @@ DISALLOW_COPY_AND_ASSIGN(MockDhcpProxyScriptFetcher); }; -MockDhcpProxyScriptFetcher::MockDhcpProxyScriptFetcher() { } +MockDhcpProxyScriptFetcher::MockDhcpProxyScriptFetcher() = default; -MockDhcpProxyScriptFetcher::~MockDhcpProxyScriptFetcher() { } +MockDhcpProxyScriptFetcher::~MockDhcpProxyScriptFetcher() = default; int MockDhcpProxyScriptFetcher::Fetch(base::string16* utf16_text, const CompletionCallback& callback) { @@ -756,8 +756,8 @@ : public DhcpProxyScriptFetcher, public base::SupportsWeakPtr<AsyncFailDhcpFetcher> { public: - AsyncFailDhcpFetcher() {} - ~AsyncFailDhcpFetcher() override {} + AsyncFailDhcpFetcher() = default; + ~AsyncFailDhcpFetcher() override = default; int Fetch(base::string16* utf16_text, const CompletionCallback& callback) override {
diff --git a/net/proxy/proxy_script_fetcher_impl_unittest.cc b/net/proxy/proxy_script_fetcher_impl_unittest.cc index c7d1f53..c8d1045 100644 --- a/net/proxy/proxy_script_fetcher_impl_unittest.cc +++ b/net/proxy/proxy_script_fetcher_impl_unittest.cc
@@ -140,8 +140,8 @@ class BasicNetworkDelegate : public NetworkDelegateImpl { public: - BasicNetworkDelegate() {} - ~BasicNetworkDelegate() override {} + BasicNetworkDelegate() = default; + ~BasicNetworkDelegate() override = default; private: int OnBeforeURLRequest(URLRequest* request,
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc index 0503ae9..d419f77 100644 --- a/net/proxy/proxy_service.cc +++ b/net/proxy/proxy_service.cc
@@ -125,7 +125,7 @@ // TODO(eroman): Figure out what Internet Explorer does. class DefaultPollPolicy : public ProxyService::PacPollPolicy { public: - DefaultPollPolicy() {} + DefaultPollPolicy() = default; Mode GetNextDelay(int initial_error, TimeDelta current_delay, @@ -180,7 +180,7 @@ // Proxy resolver that fails every time. class ProxyResolverNull : public ProxyResolver { public: - ProxyResolverNull() {} + ProxyResolverNull() = default; // ProxyResolver implementation. int GetProxyForURL(const GURL& url, @@ -322,8 +322,8 @@ #if defined(OS_CHROMEOS) class UnsetProxyConfigService : public ProxyConfigService { public: - UnsetProxyConfigService() {} - ~UnsetProxyConfigService() override {} + UnsetProxyConfigService() = default; + ~UnsetProxyConfigService() override = default; void AddObserver(Observer* observer) override {} void RemoveObserver(Observer* observer) override {} @@ -894,7 +894,7 @@ private: friend class base::RefCounted<ProxyService::PacRequest>; - ~PacRequest() {} + ~PacRequest() = default; // Callback for when the ProxyResolver request has completed. void QueryComplete(int result_code) {
diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc index 6a423fe..06e080c 100644 --- a/net/proxy/proxy_service_unittest.cc +++ b/net/proxy/proxy_service_unittest.cc
@@ -51,7 +51,7 @@ // This polling policy will decide to poll every 1 ms. class ImmediatePollPolicy : public ProxyService::PacPollPolicy { public: - ImmediatePollPolicy() {} + ImmediatePollPolicy() = default; Mode GetNextDelay(int error, base::TimeDelta current_delay, @@ -68,7 +68,7 @@ // will never trigger a poll class NeverPollPolicy : public ProxyService::PacPollPolicy { public: - NeverPollPolicy() {} + NeverPollPolicy() = default; Mode GetNextDelay(int error, base::TimeDelta current_delay, @@ -84,7 +84,7 @@ // This polling policy starts a poll immediately after network activity. class ImmediateAfterActivityPollPolicy : public ProxyService::PacPollPolicy { public: - ImmediateAfterActivityPollPolicy() {} + ImmediateAfterActivityPollPolicy() = default; Mode GetNextDelay(int error, base::TimeDelta current_delay,
diff --git a/services/preferences/pref_store_consistency_unittest.cc b/services/preferences/pref_store_consistency_unittest.cc index 74ebab6..6a1ad23 100644 --- a/services/preferences/pref_store_consistency_unittest.cc +++ b/services/preferences/pref_store_consistency_unittest.cc
@@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <memory> #include <utility> #include "base/containers/circular_deque.h" @@ -68,17 +69,18 @@ pref_store_client_ = base::MakeRefCounted<PersistentPrefStoreClient>(std::move(connection)); - PrefNotifierImpl* pref_notifier = new PrefNotifierImpl(); + auto pref_notifier = std::make_unique<PrefNotifierImpl>(); auto pref_registry = base::MakeRefCounted<PrefRegistrySimple>(); pref_registry->RegisterIntegerPref(kKey, kInitialValue); pref_registry->RegisterIntegerPref(kOtherKey, kInitialValue); pref_registry->RegisterDictionaryPref(kDictionaryKey); - auto* pref_value_store = new PrefValueStore( + auto pref_value_store = std::make_unique<PrefValueStore>( nullptr, nullptr, nullptr, nullptr, pref_store_client_.get(), nullptr, - pref_registry->defaults().get(), pref_notifier); - pref_service_ = std::make_unique<::PrefService>( - pref_notifier, pref_value_store, pref_store_client_.get(), - pref_registry.get(), base::Bind(&DoNothingHandleReadError), true); + pref_registry->defaults().get(), pref_notifier.get()); + pref_service_ = std::make_unique<PrefService>( + std::move(pref_notifier), std::move(pref_value_store), + pref_store_client_.get(), pref_registry.get(), + base::Bind(&DoNothingHandleReadError), true); } ~PrefServiceConnection() override {
diff --git a/services/preferences/public/cpp/in_process_service_factory.cc b/services/preferences/public/cpp/in_process_service_factory.cc index 4a3286b3..2a6eb05 100644 --- a/services/preferences/public/cpp/in_process_service_factory.cc +++ b/services/preferences/public/cpp/in_process_service_factory.cc
@@ -39,7 +39,7 @@ PrefStore* user_prefs, PrefStore* recommended_prefs, PrefStore* default_prefs, - PrefNotifier* pref_notifier) override { + PrefNotifier* /*pref_notifier*/) override { if (!factory_) return;
diff --git a/services/preferences/public/cpp/pref_service_factory.cc b/services/preferences/public/cpp/pref_service_factory.cc index 760c330..0198885 100644 --- a/services/preferences/public/cpp/pref_service_factory.cc +++ b/services/preferences/public/cpp/pref_service_factory.cc
@@ -4,6 +4,9 @@ #include "services/preferences/public/cpp/pref_service_factory.h" +#include <memory> +#include <utility> + #include "base/callback_helpers.h" #include "components/prefs/overlay_user_pref_store.h" #include "components/prefs/persistent_pref_store.h" @@ -108,14 +111,16 @@ } persistent_pref_store = overlay_pref_store; } - PrefNotifierImpl* pref_notifier = new PrefNotifierImpl(); - auto* pref_value_store = new PrefValueStore( + auto pref_notifier = std::make_unique<PrefNotifierImpl>(); + auto pref_value_store = std::make_unique<PrefValueStore>( managed_prefs.get(), supervised_user_prefs.get(), extension_prefs.get(), command_line_prefs.get(), persistent_pref_store.get(), - recommended_prefs.get(), pref_registry->defaults().get(), pref_notifier); + recommended_prefs.get(), pref_registry->defaults().get(), + pref_notifier.get()); auto pref_service = std::make_unique<PrefService>( - pref_notifier, pref_value_store, persistent_pref_store.get(), - pref_registry.get(), base::Bind(&DoNothingHandleReadError), true); + std::move(pref_notifier), std::move(pref_value_store), + persistent_pref_store.get(), pref_registry.get(), + base::Bind(&DoNothingHandleReadError), true); switch (pref_service->GetAllPrefStoresInitializationStatus()) { case PrefService::INITIALIZATION_STATUS_WAITING: pref_service->AddPrefInitObserver(base::Bind(&OnPrefServiceInit,
diff --git a/services/preferences/public/cpp/tests/persistent_pref_store_client_unittest.cc b/services/preferences/public/cpp/tests/persistent_pref_store_client_unittest.cc index ca70b8f..45690aa 100644 --- a/services/preferences/public/cpp/tests/persistent_pref_store_client_unittest.cc +++ b/services/preferences/public/cpp/tests/persistent_pref_store_client_unittest.cc
@@ -4,6 +4,7 @@ #include "services/preferences/public/cpp/persistent_pref_store_client.h" +#include <memory> #include <utility> #include "base/macros.h" @@ -49,11 +50,12 @@ auto pref_registry = base::MakeRefCounted<PrefRegistrySimple>(); pref_registry->RegisterDictionaryPref(kDictionaryKey); pref_registry->RegisterDictionaryPref(kUninitializedDictionaryKey); - PrefNotifierImpl* pref_notifier = new PrefNotifierImpl; + auto pref_notifier = std::make_unique<PrefNotifierImpl>(); + auto pref_value_store = std::make_unique<PrefValueStore>( + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + pref_notifier.get()); pref_service_ = std::make_unique<PrefService>( - pref_notifier, - new PrefValueStore(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, - nullptr, pref_notifier), + std::move(pref_notifier), std::move(pref_value_store), persistent_pref_store_client.get(), pref_registry.get(), base::Bind(&DoNothingWithReadError), false); }
diff --git a/third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG b/third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG index c8be4e2..9e837d25 100644 --- a/third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG +++ b/third_party/WebKit/LayoutTests/FlagExpectations/enable-blink-features=LayoutNG
@@ -4491,13 +4491,13 @@ crbug.com/591099 fast/multicol/balance-float-in-inline.html [ Failure ] crbug.com/591099 fast/multicol/balance-float-with-margin-top-and-line-after-break-2.html [ Failure ] crbug.com/591099 fast/multicol/balance-float-with-margin-top-and-line-after-break-3.html [ Failure ] -crbug.com/591099 fast/multicol/balance-float-with-margin-top-and-line-after-break.html [ Crash ] +crbug.com/591099 fast/multicol/balance-float-with-margin-top-and-line-after-break.html [ Failure ] crbug.com/591099 fast/multicol/balance-float-with-margin-top-and-line-before-break.html [ Failure ] crbug.com/591099 fast/multicol/balance-floats.html [ Failure ] crbug.com/591099 fast/multicol/balance-line-overflow.html [ Failure ] crbug.com/591099 fast/multicol/balance-line-underflow-2.html [ Failure ] crbug.com/591099 fast/multicol/balance-repeating-table-headers.html [ Failure ] -crbug.com/591099 fast/multicol/balance-short-trailing-empty-block.html [ Crash ] +crbug.com/591099 fast/multicol/balance-short-trailing-empty-block.html [ Failure ] crbug.com/591099 fast/multicol/balance-table-with-border-spacing.html [ Failure ] crbug.com/591099 fast/multicol/balance-trailing-border-after-break.html [ Failure ] crbug.com/591099 fast/multicol/balance-trailing-border.html [ Crash ] @@ -4513,7 +4513,7 @@ crbug.com/591099 fast/multicol/caret-range-outside-columns.html [ Failure ] crbug.com/591099 fast/multicol/client-rect-after-spanner.html [ Crash ] crbug.com/591099 fast/multicol/client-rect-nested.html [ Failure ] -crbug.com/591099 fast/multicol/client-rects-crossing-boundaries-nested.html [ Crash ] +crbug.com/591099 fast/multicol/client-rects-crossing-boundaries-nested.html [ Failure ] crbug.com/591099 fast/multicol/client-rects-crossing-boundaries.html [ Failure ] crbug.com/591099 fast/multicol/client-rects-rtl.html [ Failure ] crbug.com/591099 fast/multicol/client-rects.html [ Failure ] @@ -4522,16 +4522,15 @@ crbug.com/591099 fast/multicol/column-rules.html [ Failure ] crbug.com/591099 fast/multicol/columns-shorthand-parsing.html [ Failure ] crbug.com/591099 fast/multicol/composited-inner-multicol.html [ Failure ] -crbug.com/591099 fast/multicol/composited-layer-multiple-fragments-translated.html [ Crash ] +crbug.com/591099 fast/multicol/composited-layer-multiple-fragments-translated.html [ Failure ] crbug.com/591099 fast/multicol/composited-layer.html [ Failure ] crbug.com/591099 fast/multicol/composited-opacity-2nd-and-3rd-column.html [ Crash Failure ] crbug.com/591099 fast/multicol/composited-relpos-clipped.html [ Crash Failure ] crbug.com/591099 fast/multicol/composited-relpos-overlapping-will-change.html [ Crash Failure ] crbug.com/591099 fast/multicol/composited-relpos-resize.html [ Crash Failure ] crbug.com/591099 fast/multicol/composited-relpos.html [ Crash Failure ] -crbug.com/591099 fast/multicol/composited-with-child-layer-in-next-column.html [ Crash ] +crbug.com/591099 fast/multicol/composited-with-child-layer-in-next-column.html [ Failure ] crbug.com/591099 fast/multicol/composited-with-overflow-in-next-column.html [ Crash Failure ] -crbug.com/591099 fast/multicol/cssom-view.html [ Failure ] crbug.com/591099 fast/multicol/doubly-nested-with-top-padding-crossing-row-boundaries.html [ Failure ] crbug.com/591099 fast/multicol/dynamic/abspos-becomes-spanner.html [ Crash Failure ] crbug.com/591099 fast/multicol/dynamic/abspos-multicol-with-spanner-becomes-spanner.html [ Crash ] @@ -4548,6 +4547,7 @@ crbug.com/591099 fast/multicol/dynamic/insert-spanner-after-content.html [ Failure ] crbug.com/591099 fast/multicol/dynamic/insert-spanner-after-spanner-before-content.html [ Crash ] crbug.com/591099 fast/multicol/dynamic/insert-spanner-before-content.html [ Failure ] +crbug.com/591099 fast/multicol/dynamic/insert-spanner-between-out-of-flow.html [ Failure ] crbug.com/591099 fast/multicol/dynamic/insert-spanner-into-content.html [ Crash ] crbug.com/591099 fast/multicol/dynamic/insert-spanner-into-stf-constrained-width.html [ Failure ] crbug.com/591099 fast/multicol/dynamic/insert-spanner-into-stf-unconstrained-width.html [ Failure ] @@ -4569,19 +4569,16 @@ crbug.com/591099 fast/multicol/dynamic/remove-block-from-content-after-spanner.html [ Failure ] crbug.com/591099 fast/multicol/dynamic/remove-block-from-content-before-spanner.html [ Failure ] crbug.com/591099 fast/multicol/dynamic/remove-block-from-content-between-spanners.html [ Failure ] -crbug.com/591099 fast/multicol/dynamic/remove-column-content-next-to-abspos-between-spanners.html [ Crash ] +crbug.com/591099 fast/multicol/dynamic/remove-column-content-next-to-abspos-between-spanners.html [ Failure ] crbug.com/591099 fast/multicol/dynamic/remove-spanner-after-content.html [ Failure ] -crbug.com/591099 fast/multicol/dynamic/remove-spanner-in-content.html [ Crash ] +crbug.com/591099 fast/multicol/dynamic/remove-spanner-in-content.html [ Failure ] crbug.com/591099 fast/multicol/dynamic/spanner-after-content-becomes-regular-block.html [ Failure ] crbug.com/591099 fast/multicol/dynamic/spanner-ancestor-becomes-spanner.html [ Crash ] crbug.com/591099 fast/multicol/dynamic/spanner-becomes-float.html [ Failure ] crbug.com/591099 fast/multicol/dynamic/spanner-before-content-becomes-regular-block.html [ Failure ] crbug.com/591099 fast/multicol/dynamic/spanner-in-content-becomes-regular-block.html [ Failure ] crbug.com/591099 fast/multicol/dynamic/static-becomes-relpos-has-abspos.html [ Crash ] -crbug.com/591099 fast/multicol/event-offset-complex-tree.html [ Crash ] crbug.com/591099 fast/multicol/event-offset-in-nested.html [ Failure ] -crbug.com/591099 fast/multicol/event-offset.html [ Failure ] -crbug.com/591099 fast/multicol/filter-in-second-column.html [ Failure ] crbug.com/591099 fast/multicol/first-line-in-block-below-next-column-top.html [ Failure ] crbug.com/591099 fast/multicol/first-line-in-block-with-padding-exact-fit.html [ Failure ] crbug.com/591099 fast/multicol/first-line-in-block-with-padding.html [ Failure ] @@ -4591,7 +4588,6 @@ crbug.com/591099 fast/multicol/fixedpos-in-transform-at-column-boundary.html [ Failure ] crbug.com/591099 fast/multicol/flexbox-starts-at-column-boundary-with-block.html [ Failure ] crbug.com/591099 fast/multicol/flexbox-starts-at-column-boundary.html [ Failure ] -crbug.com/591099 fast/multicol/flexbox-with-overflow-auto-child-crash.html [ Failure ] crbug.com/591099 fast/multicol/flexbox.html [ Failure ] crbug.com/591099 fast/multicol/flipped-blocks-border-after.html [ Failure ] crbug.com/591099 fast/multicol/flipped-blocks-hit-test.html [ Failure ] @@ -4614,11 +4610,10 @@ crbug.com/591099 fast/multicol/forced-break-after-block-with-spanner.html [ Crash ] crbug.com/591099 fast/multicol/forced-break-after-empty-block-after-spanner.html [ Crash ] crbug.com/591099 fast/multicol/forced-break-after-last-block-before-spanner.html [ Crash ] -crbug.com/591099 fast/multicol/forced-break-before-complex-margin-collapsing.html [ Crash ] +crbug.com/591099 fast/multicol/forced-break-before-complex-margin-collapsing.html [ Failure ] crbug.com/591099 fast/multicol/forced-break-in-nested-columns.html [ Failure ] crbug.com/591099 fast/multicol/forced-break-too-short-column.html [ Failure ] -crbug.com/591099 fast/multicol/foreignObject.html [ Failure ] -crbug.com/591099 fast/multicol/hit-test-above-or-below.html [ Crash ] +crbug.com/591099 fast/multicol/hit-test-above-or-below.html [ Failure ] crbug.com/591099 fast/multicol/hit-test-end-of-column-with-line-height.html [ Failure ] crbug.com/591099 fast/multicol/hit-test-end-of-column.html [ Failure ] crbug.com/591099 fast/multicol/hit-test-gap-between-pages-flipped.html [ Failure ] @@ -4632,8 +4627,6 @@ crbug.com/591099 fast/multicol/line-pushed-down-by-float.html [ Failure ] crbug.com/591099 fast/multicol/line-too-tall-for-second-outer-row.html [ Failure ] crbug.com/591099 fast/multicol/many-lines-overflow-in-single-row-inner.html [ Failure ] -crbug.com/591099 fast/multicol/margin-collapse.html [ Crash ] -crbug.com/591099 fast/multicol/min-height-less-than-content.html [ Failure ] crbug.com/591099 fast/multicol/mixed-opacity-test.html [ Failure ] crbug.com/591099 fast/multicol/mixed-positioning-stacking-order.html [ Crash Failure ] crbug.com/591099 fast/multicol/multicol-with-child-renderLayer-for-input.html [ Failure ] @@ -4643,7 +4636,7 @@ crbug.com/591099 fast/multicol/nested-auto-height.html [ Failure ] crbug.com/591099 fast/multicol/nested-balanced-inner-column-count-1-with-forced-break.html [ Failure ] crbug.com/591099 fast/multicol/nested-balanced-inner-with-many-breaks-2.html [ Failure ] -crbug.com/591099 fast/multicol/nested-balanced-inner-with-many-breaks.html [ Crash ] +crbug.com/591099 fast/multicol/nested-balanced-inner-with-many-breaks.html [ Failure ] crbug.com/591099 fast/multicol/nested-balanced-with-strut-before-first-line.html [ Failure ] crbug.com/591099 fast/multicol/nested-balancing-with-line-at-exact-top.html [ Failure ] crbug.com/591099 fast/multicol/nested-balancing-with-lines-and-space-left-in-previous-row.html [ Failure ] @@ -4655,7 +4648,7 @@ crbug.com/591099 fast/multicol/nested-short-first-row-unsplittable-block.html [ Failure ] crbug.com/591099 fast/multicol/nested-uneven-inner-column-height.html [ Failure ] crbug.com/591099 fast/multicol/nested-with-clipped-first-column.html [ Failure ] -crbug.com/591099 fast/multicol/nested-with-forced-breaks-in-eariler-rows.html [ Crash ] +crbug.com/591099 fast/multicol/nested-with-forced-breaks-in-eariler-rows.html [ Failure ] crbug.com/591099 fast/multicol/nested-with-padding.html [ Failure ] crbug.com/591099 fast/multicol/nested-with-single-empty-block.html [ Failure ] crbug.com/591099 fast/multicol/nested-with-single-tall-line.html [ Failure ] @@ -4675,7 +4668,6 @@ crbug.com/591099 fast/multicol/newmulticol/breaks-2-columns-3.html [ Failure ] crbug.com/591099 fast/multicol/newmulticol/breaks-3-columns-3.html [ Failure ] crbug.com/591099 fast/multicol/newmulticol/fixed-height-fill-balance-2.html [ Failure ] -crbug.com/591099 fast/multicol/newmulticol/fixed-height-fill-balance.html [ Failure ] crbug.com/591099 fast/multicol/newmulticol/hide-box-vertical-lr.html [ Failure ] crbug.com/591099 fast/multicol/newmulticol/hide-box-vertical-rl.html [ Failure ] crbug.com/591099 fast/multicol/newmulticol/list-item.html [ Failure ] @@ -4703,7 +4695,6 @@ crbug.com/591099 fast/multicol/relayout-and-push-float.html [ Failure ] crbug.com/591099 fast/multicol/renderer-positioned-assert-crash.html [ Failure ] crbug.com/591099 fast/multicol/rule-in-nested-with-too-tall-line.html [ Failure ] -crbug.com/591099 fast/multicol/scrollable-basic.html [ Failure ] crbug.com/591099 fast/multicol/scrolling-overflow.html [ Failure ] crbug.com/591099 fast/multicol/shadow-breaking.html [ Failure ] crbug.com/591099 fast/multicol/single-line.html [ Failure ] @@ -4726,7 +4717,7 @@ crbug.com/591099 fast/multicol/span/change-spanner-margins.html [ Crash ] crbug.com/591099 fast/multicol/span/clone-anonymous-block-non-inline-child-crash.html [ Crash ] crbug.com/591099 fast/multicol/span/empty-block-between-spanners-with-margins.html [ Failure ] -crbug.com/591099 fast/multicol/span/empty-spanner-between-spanners-with-margins.html [ Crash ] +crbug.com/591099 fast/multicol/span/empty-spanner-between-spanners-with-margins.html [ Failure ] crbug.com/591099 fast/multicol/span/fill-after-spanner-exact-fit.html [ Crash ] crbug.com/591099 fast/multicol/span/fill-after-spanner-extra-height.html [ Crash ] crbug.com/591099 fast/multicol/span/float.html [ Failure ] @@ -4778,7 +4769,7 @@ crbug.com/591099 fast/multicol/span/vertical-lr.html [ Crash ] crbug.com/591099 fast/multicol/span/vertical-rl.html [ Crash ] crbug.com/591099 fast/multicol/span/with-border.html [ Crash ] -crbug.com/591099 fast/multicol/static-child-becomes-fixedpos.html [ Crash ] +crbug.com/591099 fast/multicol/static-child-becomes-fixedpos.html [ Failure ] crbug.com/591099 fast/multicol/table-caption-and-cells-fixed-width.html [ Failure ] crbug.com/591099 fast/multicol/table-caption-and-cells.html [ Failure ] crbug.com/591099 fast/multicol/table-caption-with-block.html [ Failure ] @@ -4790,11 +4781,10 @@ crbug.com/591099 fast/multicol/text-shadow-at-column-boundaries.html [ Failure Pass ] crbug.com/591099 fast/multicol/three-inner-rows.html [ Failure ] crbug.com/591099 fast/multicol/transform-inside-opacity.html [ Failure ] -crbug.com/591099 fast/multicol/unbreakable-block-too-tall-at-column-start.html [ Failure ] -crbug.com/591099 fast/multicol/unforced-break-after-complex-margin-collapsing.html [ Crash ] +crbug.com/591099 fast/multicol/unforced-break-after-complex-margin-collapsing.html [ Failure ] crbug.com/591099 fast/multicol/unsplittable-inline-block.html [ Failure ] crbug.com/591099 fast/multicol/vertical-lr/abspos-auto-position-on-line.html [ Crash Failure ] -crbug.com/591099 fast/multicol/vertical-lr/balancing/balance-short-trailing-empty-block.html [ Crash ] +crbug.com/591099 fast/multicol/vertical-lr/balancing/balance-short-trailing-empty-block.html [ Failure ] crbug.com/591099 fast/multicol/vertical-lr/balancing/balance-trailing-border-after-break.html [ Failure ] crbug.com/591099 fast/multicol/vertical-lr/balancing/balance-trailing-border.html [ Crash ] crbug.com/591099 fast/multicol/vertical-lr/balancing/balance-unbreakable.html [ Failure ] @@ -4804,7 +4794,7 @@ crbug.com/591099 fast/multicol/vertical-lr/caret-range-outside-columns-rtl.html [ Failure Timeout ] crbug.com/591099 fast/multicol/vertical-lr/caret-range-outside-columns.html [ Failure ] crbug.com/591099 fast/multicol/vertical-lr/client-rect-after-spanner.html [ Crash ] -crbug.com/591099 fast/multicol/vertical-lr/client-rects-crossing-boundaries-nested.html [ Crash ] +crbug.com/591099 fast/multicol/vertical-lr/client-rects-crossing-boundaries-nested.html [ Failure ] crbug.com/591099 fast/multicol/vertical-lr/column-break-with-balancing.html [ Failure ] crbug.com/591099 fast/multicol/vertical-lr/column-count-with-rules.html [ Failure ] crbug.com/591099 fast/multicol/vertical-lr/column-rules.html [ Failure ] @@ -4822,7 +4812,7 @@ crbug.com/591099 fast/multicol/vertical-lr/offset-top-and-left-nested.html [ Failure ] crbug.com/591099 fast/multicol/vertical-lr/unsplittable-inline-block.html [ Failure ] crbug.com/591099 fast/multicol/vertical-rl/abspos-auto-position-on-line.html [ Crash Failure ] -crbug.com/591099 fast/multicol/vertical-rl/balancing/balance-short-trailing-empty-block.html [ Crash ] +crbug.com/591099 fast/multicol/vertical-rl/balancing/balance-short-trailing-empty-block.html [ Failure ] crbug.com/591099 fast/multicol/vertical-rl/balancing/balance-trailing-border-after-break.html [ Failure ] crbug.com/591099 fast/multicol/vertical-rl/balancing/balance-trailing-border.html [ Crash ] crbug.com/591099 fast/multicol/vertical-rl/balancing/balance-unbreakable.html [ Failure ] @@ -4832,7 +4822,7 @@ crbug.com/591099 fast/multicol/vertical-rl/caret-range-outside-columns-rtl.html [ Failure ] crbug.com/591099 fast/multicol/vertical-rl/caret-range-outside-columns.html [ Failure ] crbug.com/591099 fast/multicol/vertical-rl/client-rect-after-spanner.html [ Crash ] -crbug.com/591099 fast/multicol/vertical-rl/client-rects-crossing-boundaries-nested.html [ Crash ] +crbug.com/591099 fast/multicol/vertical-rl/client-rects-crossing-boundaries-nested.html [ Failure ] crbug.com/591099 fast/multicol/vertical-rl/column-break-with-balancing.html [ Failure ] crbug.com/591099 fast/multicol/vertical-rl/column-count-with-rules.html [ Failure ] crbug.com/591099 fast/multicol/vertical-rl/column-rules.html [ Failure ] @@ -4931,10 +4921,7 @@ crbug.com/591099 external/wpt/css/CSS2/normal-flow/inline-replaced-height-005.xht [ Failure ] crbug.com/591099 external/wpt/css/CSS2/normal-flow/inline-replaced-height-007.xht [ Failure ] crbug.com/591099 external/wpt/css/CSS2/positioning/absolute-replaced-height-001.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-display/display-contents-dynamic-multicol-001-inline.html [ Failure ] -crbug.com/591099 external/wpt/css/css-display/display-contents-dynamic-multicol-001-none.html [ Failure ] crbug.com/591099 external/wpt/css/css-display/display-contents-dynamic-table-002-none.html [ Crash ] -crbug.com/591099 external/wpt/css/css-display/display-contents-multicol-001.html [ Failure ] crbug.com/591099 external/wpt/css/css-display/display-contents-replaced-001.html [ Crash ] crbug.com/591099 external/wpt/css/css-flexbox/flexbox_columns-flexitems-2.html [ Failure ] crbug.com/591099 external/wpt/css/css-flexbox/flexbox_columns-flexitems.html [ Failure ] @@ -5136,7 +5123,6 @@ crbug.com/591099 fast/block/positioning/complex-positioned-movement-inline-ancestor.html [ Crash ] crbug.com/591099 fast/block/positioning/complex-positioned-movement-inline.html [ Crash ] crbug.com/591099 fast/block/positioning/insert-positioned-in-anonymous-crash.html [ Crash ] -crbug.com/591099 fast/block/positioning/offsetLeft-offsetTop-multicolumn.html [ Crash ] crbug.com/591099 fast/block/positioning/positioned-movement-layout-when-height-changes.html [ Crash ] crbug.com/591099 fast/block/positioning/removing-inside-relpositioned-inline-crash.html [ Crash ] crbug.com/591099 fast/box-sizing/replaced.html [ Failure ] @@ -5174,7 +5160,6 @@ crbug.com/591099 fast/dynamic/continuation-detach-crash.html [ Crash ] crbug.com/591099 fast/dynamic/static-to-relative-with-absolute-child.html [ Crash ] crbug.com/591099 fast/events/mouse-relative-position.html [ Failure ] -crbug.com/591099 fast/events/offsetX-offsetY.html [ Failure ] crbug.com/591099 fast/events/tabindex-focus-blur-all.html [ Crash ] crbug.com/591099 fast/events/touch/touch-action-range-input-crash.html [ Crash ] crbug.com/591099 fast/events/touch/touch-handler-assert-input-range.html [ Crash ] @@ -5237,13 +5222,10 @@ crbug.com/591099 fast/loader/javascript-url-iframe-crash.html [ Crash ] crbug.com/591099 fast/media/mq-display-mode-fullscreen.html [ Crash ] crbug.com/591099 fast/multicol/anonymous-block-split-crash.html [ Crash ] -crbug.com/591099 fast/multicol/auto-height-forced-break-complex-margin-collapsing.html [ Failure ] crbug.com/591099 fast/multicol/break-after-empty-set-crash.html [ Crash ] -crbug.com/591099 fast/multicol/change-block-child-height.html [ Crash ] crbug.com/591099 fast/multicol/clone-block-children-inline-mismatch-crash.html [ Crash ] crbug.com/591099 fast/multicol/composited-relpos-in-clipped.html [ Pass ] crbug.com/591099 fast/multicol/constrained-content-height-with-overflow-crash.html [ Crash ] -crbug.com/591099 fast/multicol/doubly-nested-with-increasing-row-heights-crash.html [ Crash ] crbug.com/591099 fast/multicol/dynamic/block-with-spanner-and-inline-and-table-column.html [ Crash ] crbug.com/591099 fast/multicol/dynamic/former-spanner-in-float-in-continuation-crash.html [ Crash ] crbug.com/591099 fast/multicol/dynamic/insert-block-into-inline-beside-ex-spanner-table-column.html [ Crash ] @@ -5251,9 +5233,7 @@ crbug.com/591099 fast/multicol/dynamic/insert-float-before-content-in-spanner.html [ Failure ] crbug.com/591099 fast/multicol/dynamic/insert-spanner-after-abspos-subtree-crash.html [ Crash ] crbug.com/591099 fast/multicol/dynamic/insert-spanner-after-inner-multicol-crash.html [ Crash ] -crbug.com/591099 fast/multicol/dynamic/insert-spanner-between-out-of-flow.html [ Pass ] crbug.com/591099 fast/multicol/dynamic/relayout-abspos-in-relpos-spanner.html [ Failure Pass ] -crbug.com/591099 fast/multicol/dynamic/remove-inline-and-spanner-after-spanner-foreignObject.html [ Crash ] crbug.com/591099 fast/multicol/dynamic/remove-spanner-in-empty-nested-block-crash.html [ Crash ] crbug.com/591099 fast/multicol/dynamic/spanner-becomes-abspos-crash.html [ Crash ] crbug.com/591099 fast/multicol/dynamic/spanner-becomes-regular-block.html [ Crash ] @@ -5311,16 +5291,12 @@ crbug.com/591099 external/wpt/css/css-multicol/multicol-gap-large-002.xht [ Failure ] crbug.com/591099 external/wpt/css/css-multicol/multicol-gap-negative-001.xht [ Failure ] crbug.com/591099 external/wpt/css/css-multicol/multicol-height-001.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-multicol/multicol-inherit-001.xht [ Failure ] crbug.com/591099 external/wpt/css/css-multicol/multicol-inherit-002.xht [ Failure ] crbug.com/591099 external/wpt/css/css-multicol/multicol-inherit-003.xht [ Failure ] crbug.com/591099 external/wpt/css/css-multicol/multicol-list-item-001.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-multicol/multicol-margin-001.xht [ Failure ] crbug.com/591099 external/wpt/css/css-multicol/multicol-margin-002.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-multicol/multicol-margin-child-001.xht [ Failure ] crbug.com/591099 external/wpt/css/css-multicol/multicol-nested-002.xht [ Failure ] crbug.com/591099 external/wpt/css/css-multicol/multicol-nested-005.xht [ Failure ] -crbug.com/591099 external/wpt/css/css-multicol/multicol-nested-margin-001.xht [ Failure ] crbug.com/591099 external/wpt/css/css-multicol/multicol-nested-margin-002.xht [ Failure ] crbug.com/591099 external/wpt/css/css-multicol/multicol-nested-margin-003.xht [ Failure ] crbug.com/591099 external/wpt/css/css-multicol/multicol-nested-margin-004.xht [ Failure ] @@ -5381,8 +5357,6 @@ crbug.com/591099 external/wpt/websockets/opening-handshake/005.html [ Pass ] crbug.com/591099 fast/multicol/input-with-overflow-second-column.html [ Failure ] crbug.com/591099 fast/multicol/large-padding-crash.html [ Crash ] -crbug.com/591099 fast/multicol/margin-bottom-and-break-after.html [ Crash ] -crbug.com/591099 fast/multicol/min-height-much-greater-than-content.html [ Failure ] crbug.com/591099 fast/multicol/mixed-opacity-fixed-test.html [ Pass ] crbug.com/591099 fast/multicol/multicol-on-root-element-quirks.html [ Pass ] crbug.com/591099 fast/multicol/negative-margins-crash.html [ Crash ] @@ -5410,8 +5384,6 @@ crbug.com/591099 fast/multicol/span/remove-spanner-under-relative-position.html [ Crash ] crbug.com/591099 fast/multicol/span/runin-continuation-crash.html [ Crash ] crbug.com/591099 fast/multicol/span/spanner-after-negative-margin-bottom-crash-2.html [ Crash ] -crbug.com/591099 fast/multicol/span/spanner-after-negative-margin-bottom-crash.html [ Crash ] -crbug.com/591099 fast/multicol/triply-nested-with-padding-crash.html [ Crash ] crbug.com/591099 fast/overflow/overflow-visible-should-ignore-scroll.html [ Failure ] crbug.com/591099 fast/pagination/div-x-vertical-lr-ltr.html [ Failure ] crbug.com/591099 fast/pagination/div-x-vertical-lr-rtl.html [ Failure ] @@ -6029,7 +6001,6 @@ crbug.com/591099 fragmentation/class-c-break-after-clearance.html [ Failure ] crbug.com/591099 fragmentation/collapsing-class-a-breakpoints.html [ Failure ] crbug.com/591099 fragmentation/column-fill-auto-child.html [ Failure ] -crbug.com/591099 fragmentation/first-child-large-top-margin.html [ Crash ] crbug.com/591099 fragmentation/float-after-forced-break.html [ Failure ] crbug.com/591099 fragmentation/float-margin-top.html [ Failure ] crbug.com/591099 fragmentation/float-pushed-to-next-fragmentainer-by-floats.html [ Failure ] @@ -6040,8 +6011,6 @@ crbug.com/591099 fragmentation/fragmented-table-cell.html [ Failure ] crbug.com/591099 fragmentation/fragmented-table-with-fixed-height.html [ Failure ] crbug.com/591099 fragmentation/image-block-as-first-child.html [ Failure ] -crbug.com/591099 fragmentation/margin-bottom-at-top-of-fragmentainer.html [ Crash ] -crbug.com/591099 fragmentation/margin-top-at-top-of-fragmentainer.html [ Crash ] crbug.com/591099 fragmentation/multi-line-cells-paginated.html [ Failure ] crbug.com/591099 fragmentation/multi-line-cells.html [ Failure ] crbug.com/591099 fragmentation/nested-repeating-thead-2.html [ Failure ] @@ -6067,10 +6036,7 @@ crbug.com/591099 fragmentation/single-line-cells-multiple-tables-caption-repeating-thead-tfoot-with-border-spacing-at-top-of-row-3.html [ Failure ] crbug.com/591099 fragmentation/single-line-cells-multiple-tables-caption-repeating-thead-tfoot-with-border-spacing-at-top-of-row-4.html [ Failure ] crbug.com/591099 fragmentation/single-line-cells-multiple-tables-caption-repeating-thead-tfoot-with-border-spacing-at-top-of-row.html [ Failure ] -crbug.com/591099 fragmentation/single-line-cells-multiple-tables-caption-repeating-thead-with-border-spacing-at-top-of-row-2.html [ Failure ] crbug.com/591099 fragmentation/single-line-cells-multiple-tables-caption-repeating-thead-with-border-spacing-at-top-of-row-3.html [ Failure Pass ] -crbug.com/591099 fragmentation/single-line-cells-multiple-tables-caption-repeating-thead-with-border-spacing-at-top-of-row.html [ Failure ] -crbug.com/591099 fragmentation/single-line-cells-multiple-tables-repeating-thead-with-border-spacing-at-top-of-row.html [ Failure ] crbug.com/591099 fragmentation/single-line-cells-nested-repeating-thead-2.html [ Failure ] crbug.com/591099 fragmentation/single-line-cells-nested-repeating-thead-3.html [ Failure ] crbug.com/591099 fragmentation/single-line-cells-nested-repeating-thead-4.html [ Failure ] @@ -6959,7 +6925,7 @@ crbug.com/591099 paint/invalidation/multicol/multicol-with-block.html [ Failure ] crbug.com/591099 paint/invalidation/multicol/multicol-with-inline.html [ Failure ] crbug.com/591099 paint/invalidation/multicol/multicol-with-overflowing-block-rl.html [ Failure ] -crbug.com/591099 paint/invalidation/multicol/multicol-with-relpos.html [ Crash ] +crbug.com/591099 paint/invalidation/multicol/multicol-with-relpos.html [ Failure ] crbug.com/591099 paint/invalidation/multicol/multicol-with-text.html [ Failure ] crbug.com/591099 paint/invalidation/non-text-link-invalidation-optimization.html [ Failure ] crbug.com/591099 paint/invalidation/offset-change-wrong-invalidation-with-float.html [ Failure ] @@ -8825,7 +8791,7 @@ crbug.com/591099 virtual/spv175/paint/invalidation/multicol/multicol-with-abspos.html [ Failure ] crbug.com/591099 virtual/spv175/paint/invalidation/multicol/multicol-with-block.html [ Failure ] crbug.com/591099 virtual/spv175/paint/invalidation/multicol/multicol-with-inline.html [ Failure ] -crbug.com/591099 virtual/spv175/paint/invalidation/multicol/multicol-with-relpos.html [ Crash ] +crbug.com/591099 virtual/spv175/paint/invalidation/multicol/multicol-with-relpos.html [ Failure ] crbug.com/591099 virtual/spv175/paint/invalidation/multicol/multicol-with-text.html [ Failure ] crbug.com/591099 virtual/spv175/paint/invalidation/non-text-link-invalidation-optimization.html [ Failure ] crbug.com/591099 virtual/spv175/paint/invalidation/outline/border-outline-0.html [ Failure ]
diff --git a/third_party/WebKit/LayoutTests/FlagExpectations/root-layer-scrolls b/third_party/WebKit/LayoutTests/FlagExpectations/root-layer-scrolls index 4928288..88ff6ab1 100644 --- a/third_party/WebKit/LayoutTests/FlagExpectations/root-layer-scrolls +++ b/third_party/WebKit/LayoutTests/FlagExpectations/root-layer-scrolls
@@ -9,10 +9,7 @@ crbug.com/417782 fast/dom/scroll-reveal-left-overflow.html [ Failure ] crbug.com/417782 fast/dom/scroll-reveal-top-overflow.html [ Failure ] crbug.com/417782 fast/events/clientXY-in-zoom-and-scroll.html [ Failure ] -crbug.com/417782 fast/events/pointerevents/pointer-event-mouse-coords-in-zoom-and-scroll.html [ Failure ] crbug.com/417782 fast/events/scale-and-scroll-iframe-window.html [ Failure ] -crbug.com/417782 fast/events/touch/gesture/gesture-tap-frame-scrolled.html [ Failure ] -crbug.com/417782 fast/events/touch/gesture/gesture-tap-scrolled.html [ Failure ] crbug.com/417782 fast/events/touch/touch-coords-in-zoom-and-scroll.html [ Failure ] crbug.com/417782 fast/events/touch/touch-fractional-coordinates.html [ Failure ] crbug.com/417782 fast/events/touch/touch-inside-iframe-scrolled.html [ Failure ] @@ -66,14 +63,10 @@ crbug.com/417782 virtual/mouseevent_fractional/fast/events/pointerevents/pointer-event-mouse-coords-in-zoom-and-scroll.html [ Failure ] crbug.com/417782 virtual/mouseevent_fractional/fast/events/pointerevents/pointer-event-pen-coords-in-zoom-and-scroll.html [ Failure ] crbug.com/417782 virtual/mouseevent_fractional/fast/events/scale-and-scroll-iframe-window.html [ Failure ] -crbug.com/417782 virtual/mouseevent_fractional/fast/events/touch/gesture/gesture-tap-frame-scrolled.html [ Failure ] -crbug.com/417782 virtual/mouseevent_fractional/fast/events/touch/gesture/gesture-tap-scrolled.html [ Failure ] crbug.com/417782 virtual/mouseevent_fractional/fast/events/touch/touch-coords-in-zoom-and-scroll.html [ Failure ] crbug.com/417782 virtual/mouseevent_fractional/fast/events/touch/touch-fractional-coordinates.html [ Failure ] crbug.com/417782 virtual/mouseevent_fractional/fast/events/touch/touch-inside-iframe-scrolled.html [ Failure ] crbug.com/417782 virtual/scroll_customization/fast/events/touch/compositor-touch-hit-rects-iframes.html [ Failure ] -crbug.com/417782 virtual/scroll_customization/fast/events/touch/gesture/gesture-tap-frame-scrolled.html [ Failure ] -crbug.com/417782 virtual/scroll_customization/fast/events/touch/gesture/gesture-tap-scrolled.html [ Failure ] crbug.com/417782 virtual/scroll_customization/fast/events/touch/touch-coords-in-zoom-and-scroll.html [ Failure ] crbug.com/417782 virtual/scroll_customization/fast/events/touch/touch-fractional-coordinates.html [ Failure ] crbug.com/417782 virtual/scroll_customization/fast/events/touch/touch-inside-iframe-scrolled.html [ Failure ] @@ -86,9 +79,6 @@ crbug.com/417782 virtual/threaded/http/tests/devtools/tracing/timeline-paint/timeline-paint.js [ Failure ] # Tests known to be flaky -crbug.com/417782 virtual/mouseevent_fractional/fast/events/mouse-coords-in-zoom-and-scroll.html [ Failure Timeout ] -crbug.com/417782 virtual/mouseevent_fractional/fast/events/mouse-right-coords-in-zoom-and-scroll-right.html [ Failure Timeout ] -crbug.com/417782 fast/events/pointerevents/pointer-event-pen-coords-in-zoom-and-scroll.html [ Failure Timeout ] crbug.com/786117 [ Linux ] plugins/mouse-events-fixedpos.html [ Pass Crash ] crbug.com/417782 virtual/mojo-loading/http/tests/devtools/tracing/scroll-invalidations.html [ Crash Failure ]
diff --git a/third_party/WebKit/LayoutTests/fast/events/clientXY-in-zoom-and-scroll-expected.txt b/third_party/WebKit/LayoutTests/fast/events/clientXY-in-zoom-and-scroll-expected.txt index 586881e0..fde498e8 100644 --- a/third_party/WebKit/LayoutTests/fast/events/clientXY-in-zoom-and-scroll-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/events/clientXY-in-zoom-and-scroll-expected.txt
@@ -21,6 +21,12 @@ PASS event.clientY is 83 PASS event.pageX is 133 PASS event.pageY is 133 + +RTL and scrolled +PASS event.clientX is 100 +PASS event.clientY is 100 +PASS event.pageX is 50 +PASS event.pageY is 150 PASS successfullyParsed is true TEST COMPLETE
diff --git a/third_party/WebKit/LayoutTests/fast/events/clientXY-in-zoom-and-scroll.html b/third_party/WebKit/LayoutTests/fast/events/clientXY-in-zoom-and-scroll.html index f1910736..2dbe9fae 100644 --- a/third_party/WebKit/LayoutTests/fast/events/clientXY-in-zoom-and-scroll.html +++ b/third_party/WebKit/LayoutTests/fast/events/clientXY-in-zoom-and-scroll.html
@@ -110,6 +110,24 @@ scrollPage(0, 0); window.removeEventListener("click", zoomedAndScrolled, false); + // RTL. + function rtlAndScrolled(e) + { + event = e; + debug("\nRTL and scrolled"); + shouldBe("event.clientX", "100"); + shouldBe("event.clientY", "100"); + shouldBe("event.pageX", "50"); + shouldBe("event.pageY", "150"); + } + window.addEventListener("click", rtlAndScrolled, false); + document.documentElement.dir = "rtl"; + scrollPage(-50, 50); + sendClick(); + scrollPage(0, 0); + document.documentElement.dir = ""; + window.removeEventListener("click", rtlAndScrolled, false); + if (window.testRunner) { var area = document.getElementById('testArea'); area.parentNode.removeChild(area);
diff --git a/third_party/WebKit/Source/core/dom/ContainerNode.cpp b/third_party/WebKit/Source/core/dom/ContainerNode.cpp index 7985ffd..d9b6b07 100644 --- a/third_party/WebKit/Source/core/dom/ContainerNode.cpp +++ b/third_party/WebKit/Source/core/dom/ContainerNode.cpp
@@ -1482,6 +1482,13 @@ } } +void ContainerNode::RecalcDescendantStylesForReattach() { + for (Node* child = lastChild(); child; child = child->previousSibling()) { + if (child->IsElementNode()) + ToElement(child)->RecalcStyleForReattach(); + } +} + void ContainerNode::RebuildLayoutTreeForChild( Node* child, WhitespaceAttacher& whitespace_attacher) {
diff --git a/third_party/WebKit/Source/core/dom/ContainerNode.h b/third_party/WebKit/Source/core/dom/ContainerNode.h index 41a595d4..9fca8bf 100644 --- a/third_party/WebKit/Source/core/dom/ContainerNode.h +++ b/third_party/WebKit/Source/core/dom/ContainerNode.h
@@ -261,6 +261,7 @@ Node* node_before_change, Node* node_after_change); void RecalcDescendantStyles(StyleRecalcChange); + void RecalcDescendantStylesForReattach(); void RebuildChildrenLayoutTrees(WhitespaceAttacher&); void RebuildLayoutTreeForChild(Node* child, WhitespaceAttacher&); void RebuildNonDistributedChildren();
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp index 3d35a5a1..d917bde 100644 --- a/third_party/WebKit/Source/core/dom/Document.cpp +++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -3088,6 +3088,10 @@ void Document::WillInsertBody() { if (GetFrame()) GetFrame()->Client()->DispatchWillInsertBody(); + + if (auto* loader = Loader()) + loader->Fetcher()->LoosenLoadThrottlingPolicy(); + // If we get to the <body> try to resume commits since we should have content // to paint now. // TODO(esprehn): Is this really optimal? We might start producing frames
diff --git a/third_party/WebKit/Source/core/dom/Element.cpp b/third_party/WebKit/Source/core/dom/Element.cpp index 1877eb602..736b0cd 100644 --- a/third_party/WebKit/Source/core/dom/Element.cpp +++ b/third_party/WebKit/Source/core/dom/Element.cpp
@@ -1835,6 +1835,7 @@ } if (!IsActiveSlotOrActiveV0InsertionPoint()) { + context.resolved_style = GetNonAttachedStyle(); LayoutTreeBuilderForElement builder(*this, context.resolved_style); builder.CreateLayoutObjectIfNeeded(); @@ -1844,8 +1845,6 @@ } } - AddCallbackSelectors(); - if (HasRareData() && !GetLayoutObject() && !GetElementRareData()->GetComputedStyle()) { if (ElementAnimations* element_animations = @@ -1865,6 +1864,7 @@ children_context.previous_in_flow = nullptr; children_context.use_previous_in_flow = true; + ClearNeedsReattachLayoutTree(); CreateAndAttachPseudoElementIfNeeded(kPseudoIdBefore, children_context); // When a shadow root exists, it does the work of attaching the children. @@ -1872,6 +1872,7 @@ shadow->Attach(children_context); ContainerNode::AttachLayoutTree(children_context); + AddCallbackSelectors(); CreateAndAttachPseudoElementIfNeeded(kPseudoIdAfter, children_context); CreateAndAttachPseudoElementIfNeeded(kPseudoIdBackdrop, children_context); @@ -2136,8 +2137,12 @@ } if (local_change == kReattach) { - SetNonAttachedStyle(std::move(new_style)); + SetNonAttachedStyle(new_style); SetNeedsReattachLayoutTree(); + if (LayoutObjectIsNeeded(*new_style) || + ShouldStoreNonLayoutObjectComputedStyle(*new_style)) { + RecalcShadowIncludingDescendantStylesForReattach(); + } return kReattach; } @@ -2186,6 +2191,33 @@ return local_change; } +void Element::RecalcStyleForReattach() { + scoped_refptr<ComputedStyle> non_attached_style = StyleForLayoutObject(); + SetNonAttachedStyle(non_attached_style); + SetNeedsReattachLayoutTree(); + if (LayoutObjectIsNeeded(*non_attached_style) || + ShouldStoreNonLayoutObjectComputedStyle(*non_attached_style)) { + RecalcShadowIncludingDescendantStylesForReattach(); + } +} + +void Element::RecalcShadowIncludingDescendantStylesForReattach() { + if (!ChildrenCanHaveStyle()) + return; + if (HasCustomStyleCallbacks()) + return; + SelectorFilterParentScope filterScope(*this); + RecalcShadowRootStylesForReattach(); + RecalcDescendantStylesForReattach(); +} + +void Element::RecalcShadowRootStylesForReattach() { + for (ShadowRoot* root = YoungestShadowRoot(); root; + root = root->OlderShadowRoot()) { + root->RecalcStylesForReattach(); + } +} + void Element::RebuildLayoutTree(WhitespaceAttacher& whitespace_attacher) { DCHECK(InActiveDocument()); DCHECK(parentNode()); @@ -2194,7 +2226,6 @@ AttachContext reattach_context; reattach_context.resolved_style = GetNonAttachedStyle(); ReattachLayoutTree(reattach_context); - SetNonAttachedStyle(nullptr); whitespace_attacher.DidReattachElement(this, reattach_context.previous_in_flow); } else { @@ -3487,6 +3518,9 @@ } const ComputedStyle* Element::NonLayoutObjectComputedStyle() const { + if (NeedsReattachLayoutTree()) + return GetNonAttachedStyle(); + if (!HasRareData()) return nullptr; @@ -3502,7 +3536,7 @@ bool Element::ShouldStoreNonLayoutObjectComputedStyle( const ComputedStyle& style) const { #if DCHECK_IS_ON() - if (style.Display() == EDisplay::kContents) + if (style.Display() == EDisplay::kContents && !NeedsReattachLayoutTree()) DCHECK(!GetLayoutObject() || IsPseudoElement()); #endif
diff --git a/third_party/WebKit/Source/core/dom/Element.h b/third_party/WebKit/Source/core/dom/Element.h index 9f84577..acfccbd 100644 --- a/third_party/WebKit/Source/core/dom/Element.h +++ b/third_party/WebKit/Source/core/dom/Element.h
@@ -460,6 +460,7 @@ virtual LayoutObject* CreateLayoutObject(const ComputedStyle&); virtual bool LayoutObjectIsNeeded(const ComputedStyle&); void RecalcStyle(StyleRecalcChange); + void RecalcStyleForReattach(); bool NeedsRebuildLayoutTree( const WhitespaceAttacher& whitespace_attacher) const { return NeedsReattachLayoutTree() || ChildNeedsReattachLayoutTree() || @@ -872,6 +873,8 @@ // TODO(tkent): Rename this to isFocusableStyle. virtual bool LayoutObjectIsFocusable() const; + virtual bool ChildrenCanHaveStyle() const { return true; } + // classAttributeChanged() exists to share code between // parseAttribute (called via setAttribute()) and // svgAttributeChanged (called when element.className.baseValue is set) @@ -922,6 +925,10 @@ scoped_refptr<ComputedStyle> PropagateInheritedProperties(StyleRecalcChange); StyleRecalcChange RecalcOwnStyle(StyleRecalcChange); + void RecalcOwnStyleForReattach(); + void RecalcShadowIncludingDescendantStylesForReattach(); + void RecalcShadowRootStylesForReattach(); + void RebuildPseudoElementLayoutTree(PseudoId, WhitespaceAttacher&); void RebuildShadowRootLayoutTree(WhitespaceAttacher&); inline void CheckForEmptyStyleChange();
diff --git a/third_party/WebKit/Source/core/dom/LayoutTreeBuilder.cpp b/third_party/WebKit/Source/core/dom/LayoutTreeBuilder.cpp index d918d3c..e5ccc5b4 100644 --- a/third_party/WebKit/Source/core/dom/LayoutTreeBuilder.cpp +++ b/third_party/WebKit/Source/core/dom/LayoutTreeBuilder.cpp
@@ -100,6 +100,8 @@ ComputedStyle& LayoutTreeBuilderForElement::Style() const { if (!style_) + style_ = node_->GetNonAttachedStyle(); + if (!style_) style_ = node_->StyleForLayoutObject(); return *style_; }
diff --git a/third_party/WebKit/Source/core/dom/Node.cpp b/third_party/WebKit/Source/core/dom/Node.cpp index e928ec39..8150288 100644 --- a/third_party/WebKit/Source/core/dom/Node.cpp +++ b/third_party/WebKit/Source/core/dom/Node.cpp
@@ -1069,6 +1069,7 @@ ClearNeedsStyleRecalc(); ClearNeedsReattachLayoutTree(); + SetNonAttachedStyle(nullptr); if (AXObjectCache* cache = GetDocument().GetOrCreateAXObjectCache()) cache->UpdateCacheAfterNodeIsAttached(this);
diff --git a/third_party/WebKit/Source/core/dom/NodeComputedStyle.h b/third_party/WebKit/Source/core/dom/NodeComputedStyle.h index 5bf0479..63876a15 100644 --- a/third_party/WebKit/Source/core/dom/NodeComputedStyle.h +++ b/third_party/WebKit/Source/core/dom/NodeComputedStyle.h
@@ -38,6 +38,9 @@ } inline ComputedStyle* Node::MutableComputedStyle() const { + if (NeedsReattachLayoutTree()) + return GetNonAttachedStyle(); + if (LayoutObject* layout_object = GetLayoutObject()) return layout_object->MutableStyle();
diff --git a/third_party/WebKit/Source/core/dom/ShadowRoot.cpp b/third_party/WebKit/Source/core/dom/ShadowRoot.cpp index 9d4049b..52fe48d1 100644 --- a/third_party/WebKit/Source/core/dom/ShadowRoot.cpp +++ b/third_party/WebKit/Source/core/dom/ShadowRoot.cpp
@@ -171,6 +171,12 @@ ClearChildNeedsStyleRecalc(); } +void ShadowRoot::RecalcStylesForReattach() { + // ShadowRoot doesn't support custom callbacks. + DCHECK(!HasCustomStyleCallbacks()); + RecalcDescendantStylesForReattach(); +} + void ShadowRoot::RebuildLayoutTree(WhitespaceAttacher& whitespace_attacher) { ClearNeedsReattachLayoutTree(); RebuildChildrenLayoutTrees(whitespace_attacher);
diff --git a/third_party/WebKit/Source/core/dom/ShadowRoot.h b/third_party/WebKit/Source/core/dom/ShadowRoot.h index 2764ed7..a74c9da 100644 --- a/third_party/WebKit/Source/core/dom/ShadowRoot.h +++ b/third_party/WebKit/Source/core/dom/ShadowRoot.h
@@ -127,6 +127,7 @@ unsigned ChildShadowRootCount() const { return child_shadow_root_count_; } void RecalcStyle(StyleRecalcChange); + void RecalcStylesForReattach(); void RebuildLayoutTree(WhitespaceAttacher&); void RegisterScopedHTMLStyleChild();
diff --git a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp index 9150a395..eddb870c2 100644 --- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp +++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
@@ -361,18 +361,18 @@ // would fire in the middle of Document::setFocusedNode(). for (const Node& ancestor : NodeTraversal::InclusiveAncestorsOf(node)) { - if ((ancestor.IsHTMLElement() || ancestor.IsDocumentNode()) && - ancestor.GetLayoutObject()) { - switch (ancestor.GetLayoutObject()->Style()->UserModify()) { - case EUserModify::kReadOnly: - return false; - case EUserModify::kReadWrite: - return true; - case EUserModify::kReadWritePlaintextOnly: - return editable_level != kRichlyEditable; - } - NOTREACHED(); - return false; + if (!(ancestor.IsHTMLElement() || ancestor.IsDocumentNode())) + continue; + const ComputedStyle* style = ancestor.GetComputedStyle(); + if (!style) + continue; + switch (style->UserModify()) { + case EUserModify::kReadOnly: + return false; + case EUserModify::kReadWrite: + return true; + case EUserModify::kReadWritePlaintextOnly: + return editable_level != kRichlyEditable; } }
diff --git a/third_party/WebKit/Source/core/events/MouseEvent.cpp b/third_party/WebKit/Source/core/events/MouseEvent.cpp index bda972ff..69bfc27 100644 --- a/third_party/WebKit/Source/core/events/MouseEvent.cpp +++ b/third_party/WebKit/Source/core/events/MouseEvent.cpp
@@ -29,6 +29,7 @@ #include "core/frame/LocalFrameView.h" #include "core/input/InputDeviceCapabilities.h" #include "core/layout/LayoutObject.h" +#include "core/layout/api/LayoutViewItem.h" #include "core/paint/PaintLayer.h" #include "core/svg/SVGElement.h" #include "platform/bindings/DOMWrapperWorld.h" @@ -45,12 +46,13 @@ LocalFrame* frame = ToLocalDOMWindow(abstract_view)->GetFrame(); if (!frame) return DoubleSize(); - LocalFrameView* frame_view = frame->View(); - if (!frame_view) + ScrollableArea* scrollable_area = + frame->View()->LayoutViewportScrollableArea(); + if (!scrollable_area) return DoubleSize(); float scale_factor = frame->PageZoomFactor(); - return DoubleSize(frame_view->ScrollX() / scale_factor, - frame_view->ScrollY() / scale_factor); + return DoubleSize(scrollable_area->ScrollOffsetInt().Width() / scale_factor, + scrollable_area->ScrollOffsetInt().Height() / scale_factor); } float PageZoomFactor(const UIEvent* event) { @@ -267,15 +269,13 @@ ? ToLocalDOMWindow(view())->GetFrame() : nullptr; if (frame && HasPosition()) { + scroll_offset = ContentsScrollOffset(view()); if (LocalFrameView* frame_view = frame->View()) { adjusted_page_location = - frame_view->RootFrameToContents(FloatPoint(window_x, window_y)); - scroll_offset = frame_view->GetScrollOffset(); + frame_view->RootFrameToDocument(FloatPoint(window_x, window_y)); float scale_factor = 1 / frame->PageZoomFactor(); - if (scale_factor != 1.0f) { + if (scale_factor != 1.0f) adjusted_page_location.Scale(scale_factor, scale_factor); - scroll_offset.Scale(scale_factor, scale_factor); - } } } @@ -485,8 +485,16 @@ } void MouseEvent::ComputePageLocation() { + LocalFrame* frame = view() && view()->IsLocalDOMWindow() + ? ToLocalDOMWindow(view())->GetFrame() + : nullptr; + if (frame && frame->View()) + absolute_location_ = frame->View()->DocumentToAbsolute(page_location_); + else + absolute_location_ = page_location_; + float scale_factor = PageZoomFactor(this); - absolute_location_ = page_location_.ScaledBy(scale_factor); + absolute_location_.Scale(scale_factor, scale_factor); } void MouseEvent::ReceivedTarget() {
diff --git a/third_party/WebKit/Source/core/exported/WebFrameTest.cpp b/third_party/WebKit/Source/core/exported/WebFrameTest.cpp index 35b83f8..318b935 100644 --- a/third_party/WebKit/Source/core/exported/WebFrameTest.cpp +++ b/third_party/WebKit/Source/core/exported/WebFrameTest.cpp
@@ -2992,7 +2992,7 @@ // The styleForElementCount() should match the number of elements for a single // pass of computed styles construction for the document. - EXPECT_EQ(10u, document->GetStyleEngine().StyleForElementCount()); + EXPECT_EQ(8u, document->GetStyleEngine().StyleForElementCount()); EXPECT_EQ(Color(0, 128, 0), document->body()->GetComputedStyle()->VisitedDependentColor( CSSPropertyColor));
diff --git a/third_party/WebKit/Source/core/frame/LocalFrameView.cpp b/third_party/WebKit/Source/core/frame/LocalFrameView.cpp index f643f26..ae495671 100644 --- a/third_party/WebKit/Source/core/frame/LocalFrameView.cpp +++ b/third_party/WebKit/Source/core/frame/LocalFrameView.cpp
@@ -3717,11 +3717,25 @@ } IntRect LocalFrameView::RootFrameToDocument(const IntRect& rect_in_root_frame) { - IntRect local_rect = ConvertFromRootFrame(rect_in_root_frame); - local_rect.Move(LayoutViewportScrollableArea()->ScrollOffsetInt()); + IntPoint offset = + FlooredIntPoint(RootFrameToDocument(rect_in_root_frame.Location())); + IntRect local_rect = rect_in_root_frame; + local_rect.SetLocation(offset); return local_rect; } +FloatPoint LocalFrameView::RootFrameToDocument( + const FloatPoint& point_in_root_frame) { + FloatPoint local_frame = ConvertFromRootFrame(point_in_root_frame); + return local_frame + LayoutViewportScrollableArea()->GetScrollOffset(); +} + +DoublePoint LocalFrameView::DocumentToAbsolute( + const DoublePoint& point_in_document) const { + return point_in_document - + GetLayoutViewItem().GetScrollableArea()->GetScrollOffset(); +} + IntRect LocalFrameView::ConvertToContainingEmbeddedContentView( const IntRect& local_rect) const { if (LocalFrameView* parent = ParentFrameView()) {
diff --git a/third_party/WebKit/Source/core/frame/LocalFrameView.h b/third_party/WebKit/Source/core/frame/LocalFrameView.h index c4877c6..1fb119b 100644 --- a/third_party/WebKit/Source/core/frame/LocalFrameView.h +++ b/third_party/WebKit/Source/core/frame/LocalFrameView.h
@@ -698,6 +698,8 @@ // coordinates". https://crbug.com/417782. IntRect AbsoluteToRootFrame(const IntRect&) const; IntRect RootFrameToDocument(const IntRect&); + FloatPoint RootFrameToDocument(const FloatPoint&); + DoublePoint DocumentToAbsolute(const DoublePoint&) const; // Handles painting of the contents of the view as well as the scrollbars. void Paint(GraphicsContext&,
diff --git a/third_party/WebKit/Source/core/html/HTMLEmbedElement.cpp b/third_party/WebKit/Source/core/html/HTMLEmbedElement.cpp index d17e6cb7..3104764 100644 --- a/third_party/WebKit/Source/core/html/HTMLEmbedElement.cpp +++ b/third_party/WebKit/Source/core/html/HTMLEmbedElement.cpp
@@ -198,10 +198,8 @@ // fallback content. ContainerNode* p = parentNode(); if (auto* object = ToHTMLObjectElementOrNull(p)) { - DCHECK(p->GetLayoutObject()); if (!object->WillUseFallbackContentAtLayout() && !object->UseFallbackContent()) { - DCHECK(!p->GetLayoutObject()->IsEmbeddedObject()); return false; } }
diff --git a/third_party/WebKit/Source/core/html/HTMLObjectElement.h b/third_party/WebKit/Source/core/html/HTMLObjectElement.h index 6b2f3f8..6c613234 100644 --- a/third_party/WebKit/Source/core/html/HTMLObjectElement.h +++ b/third_party/WebKit/Source/core/html/HTMLObjectElement.h
@@ -63,6 +63,8 @@ bool IsEnumeratable() const override { return true; } bool IsInteractiveContent() const override; + bool ChildrenCanHaveStyle() const { return WillUseFallbackContentAtLayout(); } + // Implementations of constraint validation API. // Note that the object elements are always barred from constraint validation. String validationMessage() const override { return String(); }
diff --git a/third_party/WebKit/Source/core/html/forms/HTMLOptionElement.cpp b/third_party/WebKit/Source/core/html/forms/HTMLOptionElement.cpp index ed7df96..e1261dc 100644 --- a/third_party/WebKit/Source/core/html/forms/HTMLOptionElement.cpp +++ b/third_party/WebKit/Source/core/html/forms/HTMLOptionElement.cpp
@@ -88,12 +88,10 @@ void HTMLOptionElement::AttachLayoutTree(AttachContext& context) { AttachContext option_context(context); - scoped_refptr<ComputedStyle> resolved_style; if (!context.resolved_style && ParentComputedStyle()) { if (HTMLSelectElement* select = OwnerSelectElement()) select->UpdateListOnLayoutObject(); - resolved_style = OriginalStyleForLayoutObject(); - option_context.resolved_style = resolved_style.get(); + SetNonAttachedStyle(OriginalStyleForLayoutObject()); } HTMLElement::AttachLayoutTree(option_context); }
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc index af67439..48c7c3e 100644 --- a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc +++ b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc
@@ -1106,7 +1106,20 @@ "block_size for this fragment smaller than zero."; LayoutUnit space_left = FragmentainerSpaceAvailable(); - DCHECK_GE(space_left, LayoutUnit()); + + if (space_left <= LayoutUnit()) { + // The amount of space available may be zero, or even negative, if the + // border-start edge of this block starts exactly at, or even after the + // fragmentainer boundary. We're going to need a break before this block, + // because no part of it fits in the current fragmentainer. Due to margin + // collapsing with children, this situation is something that we cannot + // always detect prior to layout. The fragment produced by this algorithm is + // going to be thrown away. The parent layout algorithm will eventually + // detect that there's no room for a fragment for this node, and drop the + // fragment on the floor. Therefore it doesn't matter how we set up the + // container builder, so just return. + return; + } if (container_builder_.DidBreak()) { // One of our children broke. Even if we fit within the remaining space we @@ -1152,7 +1165,9 @@ // The remaining part of the fragmentainer (the unusable space for child // content, due to the break) should still be occupied by this container. - intrinsic_block_size_ = FragmentainerSpaceAvailable(); + // TODO(mstensho): Figure out if we really need to <0 here. It doesn't seem + // right to have negative available space. + intrinsic_block_size_ = FragmentainerSpaceAvailable().ClampNegativeToZero(); // Drop the fragment on the floor and retry at the start of the next // fragmentainer. container_builder_.AddBreakBeforeChild(child); @@ -1164,12 +1179,9 @@ NGLayoutInputNode child, const NGPhysicalFragment& physical_fragment, LayoutUnit block_offset) const { - const auto* token = physical_fragment.BreakToken(); - if (!token || token->IsFinished()) + if (!container_builder_.BfcOffset().has_value()) return false; - // TODO(mstensho): There are other break-inside values to consider here. - if (child.Style().BreakInside() != EBreakInside::kAvoid) - return false; + // If we haven't used any space at all in the fragmentainer yet, we cannot // break, or there'd be no progress. We'd end up creating an infinite number // of fragmentainers without putting any content into them. @@ -1177,6 +1189,23 @@ if (space_left >= ConstraintSpace().FragmentainerBlockSize()) return false; + // If the block offset is past the fragmentainer boundary (or exactly at the + // boundary), no part of the fragment is going to fit in the current + // fragmentainer. Fragments may be pushed past the fragmentainer boundary by + // margins. + // TODO(mstensho): The inline check here shouldn't be necessary, but + // it's needed as long as we don't support breaking between line + // boxes. + if (space_left <= LayoutUnit() && !child.IsInline()) + return true; + + const auto* token = physical_fragment.BreakToken(); + if (!token || token->IsFinished()) + return false; + // TODO(mstensho): There are other break-inside values to consider here. + if (child.Style().BreakInside() != EBreakInside::kAvoid) + return false; + // The child broke, and we're not at the start of a fragmentainer, and we're // supposed to avoid breaking inside the child. DCHECK(IsFirstFragment(ConstraintSpace(), physical_fragment));
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_column_layout_algorithm_test.cc b/third_party/WebKit/Source/core/layout/ng/ng_column_layout_algorithm_test.cc index 8b56275..544eb35 100644 --- a/third_party/WebKit/Source/core/layout/ng/ng_column_layout_algorithm_test.cc +++ b/third_party/WebKit/Source/core/layout/ng/ng_column_layout_algorithm_test.cc
@@ -603,7 +603,6 @@ offset:0,0 size:320x100 offset:0,0 size:100x100 offset:0,0 size:50x100 - offset:0,100 size:60x0 offset:110,0 size:100x100 offset:0,0 size:60x100 )DUMP"; @@ -800,6 +799,144 @@ EXPECT_EQ(expectation, dump); } +TEST_F(NGColumnLayoutAlgorithmTest, MarginTopPastEndOfFragmentainer) { + // A block whose border box would start past the end of the current + // fragmentainer should start exactly at the start of the next fragmentainer, + // discarding what's left of the margin. + // https://www.w3.org/TR/css-break-3/#break-margins + SetBodyInnerHTML(R"HTML( + <style> + #parent { + columns: 3; + column-fill: auto; + column-gap: 10px; + width: 320px; + height: 100px; + } + </style> + <div id="container"> + <div id="parent"> + <div style="height:90px;"></div> + <div style="margin-top:20px; width:20px; height:20px;"></div> + </div> + </div> + )HTML"); + + String dump = DumpFragmentTree(GetElementById("container")); + String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::. + offset:unplaced size:1000x100 + offset:0,0 size:320x100 + offset:0,0 size:100x100 + offset:0,0 size:100x90 + offset:110,0 size:100x20 + offset:0,0 size:20x20 +)DUMP"; + EXPECT_EQ(expectation, dump); +} + +TEST_F(NGColumnLayoutAlgorithmTest, MarginBottomPastEndOfFragmentainer) { + // A block whose border box would start past the end of the current + // fragmentainer should start exactly at the start of the next fragmentainer, + // discarding what's left of the margin. + // https://www.w3.org/TR/css-break-3/#break-margins + SetBodyInnerHTML(R"HTML( + <style> + #parent { + columns: 3; + column-fill: auto; + column-gap: 10px; + width: 320px; + height: 100px; + } + </style> + <div id="container"> + <div id="parent"> + <div style="margin-bottom:20px; height:90px;"></div> + <div style="width:20px; height:20px;"></div> + </div> + </div> + )HTML"); + + String dump = DumpFragmentTree(GetElementById("container")); + String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::. + offset:unplaced size:1000x100 + offset:0,0 size:320x100 + offset:0,0 size:100x100 + offset:0,0 size:100x90 + offset:110,0 size:100x20 + offset:0,0 size:20x20 +)DUMP"; + EXPECT_EQ(expectation, dump); +} + +TEST_F(NGColumnLayoutAlgorithmTest, MarginTopAtEndOfFragmentainer) { + // A block whose border box is flush with the end of the fragmentainer + // shouldn't produce an empty fragment there - only one fragment in the next + // fragmentainer. + SetBodyInnerHTML(R"HTML( + <style> + #parent { + columns: 3; + column-fill: auto; + column-gap: 10px; + width: 320px; + height: 100px; + } + </style> + <div id="container"> + <div id="parent"> + <div style="height:90px;"></div> + <div style="margin-top:10px; width:20px; height:20px;"></div> + </div> + </div> + )HTML"); + + String dump = DumpFragmentTree(GetElementById("container")); + String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::. + offset:unplaced size:1000x100 + offset:0,0 size:320x100 + offset:0,0 size:100x100 + offset:0,0 size:100x90 + offset:110,0 size:100x20 + offset:0,0 size:20x20 +)DUMP"; + EXPECT_EQ(expectation, dump); +} + +TEST_F(NGColumnLayoutAlgorithmTest, MarginBottomAtEndOfFragmentainer) { + // A block whose border box is flush with the end of the fragmentainer + // shouldn't produce an empty fragment there - only one fragment in the next + // fragmentainer. + SetBodyInnerHTML(R"HTML( + <style> + #parent { + columns: 3; + column-fill: auto; + column-gap: 10px; + width: 320px; + height: 100px; + } + </style> + <div id="container"> + <div id="parent"> + <div style="margin-bottom:10px; height:90px;"></div> + <div style="width:20px; height:20px;"></div> + </div> + </div> + )HTML"); + + String dump = DumpFragmentTree(GetElementById("container")); + String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::. + offset:unplaced size:1000x100 + offset:0,0 size:320x100 + offset:0,0 size:100x100 + offset:0,0 size:100x90 + offset:110,0 size:100x20 + offset:0,0 size:20x20 +)DUMP"; + EXPECT_EQ(expectation, dump); +} + TEST_F(NGColumnLayoutAlgorithmTest, BorderAndPadding) { SetBodyInnerHTML(R"HTML( <style>
diff --git a/third_party/WebKit/Source/core/loader/FrameFetchContext.h b/third_party/WebKit/Source/core/loader/FrameFetchContext.h index 7d42910..76e90d7e 100644 --- a/third_party/WebKit/Source/core/loader/FrameFetchContext.h +++ b/third_party/WebKit/Source/core/loader/FrameFetchContext.h
@@ -157,6 +157,13 @@ const ResourceRequest&, scoped_refptr<WebTaskRunner>) override; + ResourceLoadScheduler::ThrottlingPolicy InitialLoadThrottlingPolicy() + const override { + // Frame loading should normally start with |kTight| throttling, as the + // frame will be in layout-blocking state until the <body> tag is inserted. + return ResourceLoadScheduler::ThrottlingPolicy::kTight; + } + bool IsDetached() const override { return frozen_state_; } FetchContext* Detach() override;
diff --git a/third_party/WebKit/Source/platform/loader/fetch/FetchContext.h b/third_party/WebKit/Source/platform/loader/fetch/FetchContext.h index ea4af7c..32852f2c 100644 --- a/third_party/WebKit/Source/platform/loader/fetch/FetchContext.h +++ b/third_party/WebKit/Source/platform/loader/fetch/FetchContext.h
@@ -38,6 +38,7 @@ #include "platform/loader/fetch/FetchParameters.h" #include "platform/loader/fetch/Resource.h" #include "platform/loader/fetch/ResourceLoadPriority.h" +#include "platform/loader/fetch/ResourceLoadScheduler.h" #include "platform/loader/fetch/ResourceRequest.h" #include "platform/network/ContentSecurityPolicyParsers.h" #include "platform/weborigin/SecurityViolationReportingPolicy.h" @@ -234,6 +235,13 @@ return nullptr; } + // Returns the initial throttling policy used by the associated + // ResourceLoadScheduler. + virtual ResourceLoadScheduler::ThrottlingPolicy InitialLoadThrottlingPolicy() + const { + return ResourceLoadScheduler::ThrottlingPolicy::kNormal; + } + virtual bool IsDetached() const { return false; } // Obtains WebFrameScheduler instance that is used in the attached frame.
diff --git a/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.h b/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.h index 304f0930..a7bfaad1 100644 --- a/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.h +++ b/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.h
@@ -37,7 +37,6 @@ #include "platform/loader/fetch/Resource.h" #include "platform/loader/fetch/ResourceError.h" #include "platform/loader/fetch/ResourceLoadPriority.h" -#include "platform/loader/fetch/ResourceLoadScheduler.h" #include "platform/loader/fetch/ResourceLoaderOptions.h" #include "platform/loader/fetch/SubstituteData.h" #include "platform/wtf/HashMap.h" @@ -152,6 +151,7 @@ void RemovePreload(Resource*); + void LoosenLoadThrottlingPolicy() { scheduler_->LoosenThrottlingPolicy(); } void OnNetworkQuiet() { scheduler_->OnNetworkQuiet(); } // Workaround for https://crbug.com/666214.
diff --git a/third_party/WebKit/Source/platform/loader/fetch/ResourceLoadScheduler.cpp b/third_party/WebKit/Source/platform/loader/fetch/ResourceLoadScheduler.cpp index e36a0f5..49f531e 100644 --- a/third_party/WebKit/Source/platform/loader/fetch/ResourceLoadScheduler.cpp +++ b/third_party/WebKit/Source/platform/loader/fetch/ResourceLoadScheduler.cpp
@@ -7,7 +7,9 @@ #include "base/metrics/field_trial_params.h" #include "base/strings/string_number_conversions.h" #include "platform/Histogram.h" +#include "platform/loader/fetch/FetchContext.h" #include "platform/runtime_enabled_features.h" +#include "public/platform/Platform.h" namespace blink { @@ -330,11 +332,19 @@ if (!scheduler) return; + if (Platform::Current()->IsRendererSideResourceSchedulerEnabled()) + policy_ = context->InitialLoadThrottlingPolicy(); + is_enabled_ = true; scheduler->AddThrottlingObserver(WebFrameScheduler::ObserverType::kLoader, this); } +ResourceLoadScheduler* ResourceLoadScheduler::Create(FetchContext* context) { + return new ResourceLoadScheduler(context ? context + : &FetchContext::NullInstance()); +} + ResourceLoadScheduler::~ResourceLoadScheduler() = default; void ResourceLoadScheduler::Trace(blink::Visitor* visitor) { @@ -342,6 +352,17 @@ visitor->Trace(context_); } +void ResourceLoadScheduler::LoosenThrottlingPolicy() { + switch (policy_) { + case ThrottlingPolicy::kTight: + break; + case ThrottlingPolicy::kNormal: + return; + } + policy_ = ThrottlingPolicy::kNormal; + MaybeRun(); +} + void ResourceLoadScheduler::Shutdown() { // Do nothing if the feature is not enabled, or Shutdown() was already called. if (is_shutdown_) @@ -405,12 +426,6 @@ client_it->value->priority = priority; client_it->value->intra_priority = intra_priority; - if (!IsThrottablePriority(priority)) { - ResourceLoadSchedulerClient* client = client_it->value->client; - pending_request_map_.erase(client_it); - Run(client_id, client); - return; - } pending_requests_.emplace(client_id, priority, intra_priority); MaybeRun(); } @@ -447,8 +462,11 @@ return false; } -void ResourceLoadScheduler::SetOutstandingLimitForTesting(size_t limit) { - SetOutstandingLimitAndMaybeRun(limit); +void ResourceLoadScheduler::SetOutstandingLimitForTesting(size_t tight_limit, + size_t limit) { + tight_outstanding_limit_ = tight_limit; + outstanding_limit_ = limit; + MaybeRun(); } void ResourceLoadScheduler::OnNetworkQuiet() { @@ -525,7 +543,14 @@ } } - return priority < ResourceLoadPriority::kMedium; + switch (policy_) { + case ThrottlingPolicy::kTight: + return priority < ResourceLoadPriority::kHigh; + case ThrottlingPolicy::kNormal: + return priority < ResourceLoadPriority::kMedium; + } + NOTREACHED(); + return true; } void ResourceLoadScheduler::OnThrottlingStateChanged( @@ -570,8 +595,23 @@ return; while (!pending_requests_.empty()) { - if (running_requests_.size() >= outstanding_limit_) - return; + bool has_enough_running_requets = false; + + switch (policy_) { + case ThrottlingPolicy::kTight: + if (running_requests_.size() >= tight_outstanding_limit_) + has_enough_running_requets = true; + break; + case ThrottlingPolicy::kNormal: + if (running_requests_.size() >= outstanding_limit_) + has_enough_running_requets = true; + break; + } + if (IsThrottablePriority(pending_requests_.begin()->priority) && + has_enough_running_requets) { + break; + } + ClientId id = pending_requests_.begin()->client_id; pending_requests_.erase(pending_requests_.begin()); auto found = pending_request_map_.find(id);
diff --git a/third_party/WebKit/Source/platform/loader/fetch/ResourceLoadScheduler.h b/third_party/WebKit/Source/platform/loader/fetch/ResourceLoadScheduler.h index 986b7620..ffde116 100644 --- a/third_party/WebKit/Source/platform/loader/fetch/ResourceLoadScheduler.h +++ b/third_party/WebKit/Source/platform/loader/fetch/ResourceLoadScheduler.h
@@ -9,13 +9,14 @@ #include "platform/WebFrameScheduler.h" #include "platform/heap/GarbageCollected.h" #include "platform/heap/HeapAllocator.h" -#include "platform/loader/fetch/FetchContext.h" #include "platform/loader/fetch/Resource.h" #include "platform/loader/fetch/ResourceLoaderOptions.h" #include "platform/wtf/HashSet.h" namespace blink { +class FetchContext; + // Client interface to use the throttling/scheduling functionality that // ResourceLoadScheduler provides. class PLATFORM_EXPORT ResourceLoadSchedulerClient @@ -34,6 +35,9 @@ // in-flight requests that are granted but are not released (by Release()) yet. // Note: If FetchContext can not provide a WebFrameScheduler, throttling and // scheduling functionalities will be completely disabled. +// +// TODO(yhirano): Provide the general algorithm and running experiments +// information. class PLATFORM_EXPORT ResourceLoadScheduler final : public GarbageCollectedFinalized<ResourceLoadScheduler>, public WebFrameScheduler::Observer { @@ -85,6 +89,12 @@ int64_t decoded_body_length_ = 0; }; + // ResourceLoadScheduler has two policies: |kTight| and |kNormal|. Currently + // this is used to support aggressive throttling while the corresponding frame + // is in layout-blocking phase. There is only one state transition, + // |kTight| => |kNormal|, which is done by |LoosenThrottlingPolicy|. + enum class ThrottlingPolicy { kTight, kNormal }; + // Returned on Request(). Caller should need to return it via Release(). using ClientId = uint64_t; @@ -93,13 +103,16 @@ static constexpr size_t kOutstandingUnlimited = std::numeric_limits<size_t>::max(); - static ResourceLoadScheduler* Create(FetchContext* context = nullptr) { - return new ResourceLoadScheduler(context ? context - : &FetchContext::NullInstance()); - } + static ResourceLoadScheduler* Create(FetchContext* = nullptr); ~ResourceLoadScheduler(); + void Trace(blink::Visitor*); + // Changes the policy from |kTight| to |kNormal|. This function can be called + // multiple times, and does nothing when the scheduler is already working with + // the normal policy. This function may initiate a new resource loading. + void LoosenThrottlingPolicy(); + // Stops all operations including observing throttling signals. // ResourceLoadSchedulerClient::Run() will not be called once this method is // called. This method can be called multiple times safely. @@ -127,7 +140,10 @@ bool Release(ClientId, ReleaseOption, const TrafficReportHints&); // Sets outstanding limit for testing. - void SetOutstandingLimitForTesting(size_t limit); + void SetOutstandingLimitForTesting(size_t limit) { + SetOutstandingLimitForTesting(limit, limit); + } + void SetOutstandingLimitForTesting(size_t tight_limit, size_t limit); void OnNetworkQuiet(); @@ -200,9 +216,14 @@ // Can be modified by field trial flags or for testing. bool is_enabled_ = false; - // Outstanding limit. 0u means unlimited. + ThrottlingPolicy policy_ = ThrottlingPolicy::kNormal; + + // Used to limit outstanding requests when |policy_| is kTight. + size_t tight_outstanding_limit_ = kOutstandingUnlimited; + // TODO(crbug.com/735410): If this throttling is enabled always, it makes some // tests fail. + // Used to limit outstanding requests when |policy_| is kNormal. size_t outstanding_limit_ = kOutstandingUnlimited; // Outstanding limit for throttled frames. Managed via the field trial.
diff --git a/third_party/WebKit/Source/platform/loader/fetch/ResourceLoadSchedulerTest.cpp b/third_party/WebKit/Source/platform/loader/fetch/ResourceLoadSchedulerTest.cpp index c6c14daf..c10040f 100644 --- a/third_party/WebKit/Source/platform/loader/fetch/ResourceLoadSchedulerTest.cpp +++ b/third_party/WebKit/Source/platform/loader/fetch/ResourceLoadSchedulerTest.cpp
@@ -286,21 +286,21 @@ ResourceLoadScheduler::ClientId id1 = ResourceLoadScheduler::kInvalidClientId; scheduler()->Request(client1, ThrottleOption::kCanBeThrottled, - ResourceLoadPriority::kLow, 0 /* intra_priority */, + ResourceLoadPriority::kLowest, 10 /* intra_priority */, &id1); EXPECT_NE(ResourceLoadScheduler::kInvalidClientId, id1); MockClient* client2 = new MockClient; ResourceLoadScheduler::ClientId id2 = ResourceLoadScheduler::kInvalidClientId; scheduler()->Request(client2, ThrottleOption::kCanBeThrottled, - ResourceLoadPriority::kMedium, 0 /* intra_priority */, + ResourceLoadPriority::kLow, 1 /* intra_priority */, &id2); EXPECT_NE(ResourceLoadScheduler::kInvalidClientId, id2); MockClient* client3 = new MockClient; ResourceLoadScheduler::ClientId id3 = ResourceLoadScheduler::kInvalidClientId; scheduler()->Request(client3, ThrottleOption::kCanBeThrottled, - ResourceLoadPriority::kHigh, 0 /* intra_priority */, + ResourceLoadPriority::kLow, 3 /* intra_priority */, &id3); EXPECT_NE(ResourceLoadScheduler::kInvalidClientId, id3); @@ -403,6 +403,16 @@ EXPECT_TRUE( scheduler()->IsThrottablePriority(ResourceLoadPriority::kVeryLow)); EXPECT_TRUE(scheduler()->IsThrottablePriority(ResourceLoadPriority::kLow)); + EXPECT_TRUE(scheduler()->IsThrottablePriority(ResourceLoadPriority::kMedium)); + EXPECT_FALSE(scheduler()->IsThrottablePriority(ResourceLoadPriority::kHigh)); + EXPECT_FALSE( + scheduler()->IsThrottablePriority(ResourceLoadPriority::kVeryHigh)); + + scheduler()->LoosenThrottlingPolicy(); + + EXPECT_TRUE( + scheduler()->IsThrottablePriority(ResourceLoadPriority::kVeryLow)); + EXPECT_TRUE(scheduler()->IsThrottablePriority(ResourceLoadPriority::kLow)); EXPECT_FALSE( scheduler()->IsThrottablePriority(ResourceLoadPriority::kMedium)); EXPECT_FALSE(scheduler()->IsThrottablePriority(ResourceLoadPriority::kHigh)); @@ -411,6 +421,8 @@ } TEST_F(RendererSideResourceSchedulerTest, SetPriority) { + // Start with the normal scheduling policy. + scheduler()->LoosenThrottlingPolicy(); // Push three requests. MockClient* client1 = new MockClient; @@ -470,5 +482,90 @@ ResourceLoadScheduler::TrafficReportHints::InvalidInstance())); } +TEST_F(RendererSideResourceSchedulerTest, LoosenThrottlingPolicy) { + MockClient* client1 = new MockClient; + + scheduler()->SetOutstandingLimitForTesting(0, 0); + + ResourceLoadScheduler::ClientId id1 = ResourceLoadScheduler::kInvalidClientId; + scheduler()->Request(client1, ThrottleOption::kCanBeThrottled, + ResourceLoadPriority::kLowest, 0 /* intra_priority */, + &id1); + EXPECT_NE(ResourceLoadScheduler::kInvalidClientId, id1); + + MockClient* client2 = new MockClient; + ResourceLoadScheduler::ClientId id2 = ResourceLoadScheduler::kInvalidClientId; + scheduler()->Request(client2, ThrottleOption::kCanBeThrottled, + ResourceLoadPriority::kLowest, 0 /* intra_priority */, + &id2); + EXPECT_NE(ResourceLoadScheduler::kInvalidClientId, id2); + + MockClient* client3 = new MockClient; + ResourceLoadScheduler::ClientId id3 = ResourceLoadScheduler::kInvalidClientId; + scheduler()->Request(client3, ThrottleOption::kCanBeThrottled, + ResourceLoadPriority::kLowest, 0 /* intra_priority */, + &id3); + EXPECT_NE(ResourceLoadScheduler::kInvalidClientId, id3); + + MockClient* client4 = new MockClient; + ResourceLoadScheduler::ClientId id4 = ResourceLoadScheduler::kInvalidClientId; + scheduler()->Request(client4, ThrottleOption::kCanBeThrottled, + ResourceLoadPriority::kLowest, 0 /* intra_priority */, + &id4); + EXPECT_NE(ResourceLoadScheduler::kInvalidClientId, id4); + + scheduler()->SetPriority(id2, ResourceLoadPriority::kLow, 0); + scheduler()->SetPriority(id3, ResourceLoadPriority::kLow, 0); + scheduler()->SetPriority(id4, ResourceLoadPriority::kMedium, 0); + + // As the policy is |kTight|, |kMedium| is throttled. + EXPECT_FALSE(client1->WasRan()); + EXPECT_FALSE(client2->WasRan()); + EXPECT_FALSE(client3->WasRan()); + EXPECT_FALSE(client4->WasRan()); + + scheduler()->SetOutstandingLimitForTesting(0, 2); + + // MockFetchContext's initial scheduling policy is |kTight|, setting the + // outstanding limit for the normal mode doesn't take effect. + EXPECT_FALSE(client1->WasRan()); + EXPECT_FALSE(client2->WasRan()); + EXPECT_FALSE(client3->WasRan()); + EXPECT_FALSE(client4->WasRan()); + + // Now let's tighten the limit again. + scheduler()->SetOutstandingLimitForTesting(0, 0); + + // ...and change the scheduling policy to |kNormal|, where priority >= + // |kMedium| requests are not throttled. + scheduler()->LoosenThrottlingPolicy(); + + EXPECT_FALSE(client1->WasRan()); + EXPECT_FALSE(client2->WasRan()); + EXPECT_FALSE(client3->WasRan()); + EXPECT_TRUE(client4->WasRan()); + + scheduler()->SetOutstandingLimitForTesting(0, 2); + + EXPECT_FALSE(client1->WasRan()); + EXPECT_TRUE(client2->WasRan()); + EXPECT_FALSE(client3->WasRan()); + EXPECT_TRUE(client4->WasRan()); + + // Release all. + EXPECT_TRUE(scheduler()->Release( + id3, ResourceLoadScheduler::ReleaseOption::kReleaseOnly, + ResourceLoadScheduler::TrafficReportHints::InvalidInstance())); + EXPECT_TRUE(scheduler()->Release( + id4, ResourceLoadScheduler::ReleaseOption::kReleaseOnly, + ResourceLoadScheduler::TrafficReportHints::InvalidInstance())); + EXPECT_TRUE(scheduler()->Release( + id2, ResourceLoadScheduler::ReleaseOption::kReleaseOnly, + ResourceLoadScheduler::TrafficReportHints::InvalidInstance())); + EXPECT_TRUE(scheduler()->Release( + id1, ResourceLoadScheduler::ReleaseOption::kReleaseOnly, + ResourceLoadScheduler::TrafficReportHints::InvalidInstance())); +} + } // namespace } // namespace blink
diff --git a/third_party/WebKit/Source/platform/loader/testing/MockFetchContext.h b/third_party/WebKit/Source/platform/loader/testing/MockFetchContext.h index 643c4b6..ab12c7e 100644 --- a/third_party/WebKit/Source/platform/loader/testing/MockFetchContext.h +++ b/third_party/WebKit/Source/platform/loader/testing/MockFetchContext.h
@@ -96,6 +96,11 @@ return url_loader_factory_->CreateURLLoader(wrapped, task_runner); } + ResourceLoadScheduler::ThrottlingPolicy InitialLoadThrottlingPolicy() + const override { + return ResourceLoadScheduler::ThrottlingPolicy::kTight; + } + WebFrameScheduler* GetFrameScheduler() override { return frame_scheduler_.get(); }
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index 4982970f..9e46ec2 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -12020,6 +12020,7 @@ <int value="400" label="UnsafelyTreatInsecureOriginAsSecure"/> <int value="401" label="DefaultDownloadDirectory"/> <int value="402" label="SecurityKeyPermitAttestation"/> + <int value="403" label="NetworkHostname"/> </enum> <enum name="EnterprisePolicyInvalidations">
diff --git a/ui/events/blink/blink_event_util.cc b/ui/events/blink/blink_event_util.cc index 83727f7..bf500b4 100644 --- a/ui/events/blink/blink_event_util.cc +++ b/ui/events/blink/blink_event_util.cc
@@ -1079,6 +1079,8 @@ flags |= EF_CONTROL_DOWN; if (modifiers & blink::WebInputEvent::kAltKey) flags |= EF_ALT_DOWN; + if (modifiers & blink::WebInputEvent::kAltGrKey) + flags |= EF_ALTGR_DOWN; if (modifiers & blink::WebInputEvent::kMetaKey) flags |= EF_COMMAND_DOWN; if (modifiers & blink::WebInputEvent::kCapsLockOn)
diff --git a/ui/events/blink/blink_event_util_unittest.cc b/ui/events/blink/blink_event_util_unittest.cc index 7ed45ce..d895b48 100644 --- a/ui/events/blink/blink_event_util_unittest.cc +++ b/ui/events/blink/blink_event_util_unittest.cc
@@ -221,4 +221,35 @@ EXPECT_FALSE(CanCoalesce(event_to_be_coalesced, coalesced_event)); } +TEST(BlinkEventUtilTest, WebEventModifersAndEventFlags) { + using WebInputEvent = blink::WebInputEvent; + constexpr int kWebEventModifiersToTest[] = {WebInputEvent::kShiftKey, + WebInputEvent::kControlKey, + WebInputEvent::kAltKey, + WebInputEvent::kAltGrKey, + WebInputEvent::kMetaKey, + WebInputEvent::kCapsLockOn, + WebInputEvent::kNumLockOn, + WebInputEvent::kScrollLockOn, + WebInputEvent::kLeftButtonDown, + WebInputEvent::kMiddleButtonDown, + WebInputEvent::kRightButtonDown, + WebInputEvent::kBackButtonDown, + WebInputEvent::kForwardButtonDown, + WebInputEvent::kIsAutoRepeat}; + // For each WebEventModifier value, test that it maps to a unique ui::Event + // flag, and that the flag correctly maps back to the WebEventModifier. + int event_flags = 0; + for (int event_modifier : kWebEventModifiersToTest) { + int event_flag = WebEventModifiersToEventFlags(event_modifier); + + // |event_flag| must be unique. + EXPECT_EQ(event_flags & event_flag, 0); + event_flags |= event_flag; + + // |event_flag| must map to |event_modifier|. + EXPECT_EQ(EventFlagsToWebEventModifiers(event_flag), event_modifier); + } +} + } // namespace ui