diff options
Diffstat (limited to 'chromium/components')
6 files changed, 112 insertions, 43 deletions
diff --git a/chromium/components/arc/mojom/net.mojom b/chromium/components/arc/mojom/net.mojom index edcf9430f27..1a6c23ce47c 100644 --- a/chromium/components/arc/mojom/net.mojom +++ b/chromium/components/arc/mojom/net.mojom @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Next MinVersion: 12 +// Next MinVersion: 13 // This file defines the mojo interface between the ARC networking stack and // Chrome OS. There are three different groups of interactions: @@ -210,6 +210,9 @@ struct NetworkConfiguration { // True if this network is the host default network. [MinVersion=11] bool is_default_network; + + // The name of the shill service associated with this network connection. + [MinVersion=12] string? service_name; }; // Describes a Wifi network configuration that ARC has requested the host to diff --git a/chromium/components/arc/net/arc_net_host_impl.cc b/chromium/components/arc/net/arc_net_host_impl.cc index 126e9b753e0..d4a4843fed0 100644 --- a/chromium/components/arc/net/arc_net_host_impl.cc +++ b/chromium/components/arc/net/arc_net_host_impl.cc @@ -37,6 +37,10 @@ namespace { constexpr int kGetNetworksListLimit = 100; +// Delay in millisecond before asking for a network property update when no IP +// configuration can be retrieved for a network. +constexpr base::TimeDelta kNetworkPropertyUpdateDelay = + base::TimeDelta::FromMilliseconds(5000); chromeos::NetworkStateHandler* GetStateHandler() { return chromeos::NetworkHandler::Get()->network_state_handler(); @@ -173,6 +177,13 @@ arc::mojom::IPConfigurationPtr TranslateONCIPConfig( return configuration; } +// Returns true if the IP configuration is valid enough for ARC. Empty IP +// config objects can be generated when IPv4 DHCP or IPv6 autoconf has not +// completed yet. +bool IsValidIPConfiguration(const arc::mojom::IPConfiguration& ip_config) { + return !ip_config.ip_address.empty() && !ip_config.gateway.empty(); +} + // Returns an IPConfiguration vector from the IPConfigs ONC property, which may // include multiple IP configurations (e.g. IPv4 and IPv6). std::vector<arc::mojom::IPConfigurationPtr> IPConfigurationsFromONCIPConfigs( @@ -184,7 +195,7 @@ std::vector<arc::mojom::IPConfigurationPtr> IPConfigurationsFromONCIPConfigs( std::vector<arc::mojom::IPConfigurationPtr> result; for (const auto& entry : ip_config_list->GetList()) { arc::mojom::IPConfigurationPtr config = TranslateONCIPConfig(&entry); - if (config) + if (config && IsValidIPConfiguration(*config)) result.push_back(std::move(config)); } return result; @@ -199,7 +210,7 @@ std::vector<arc::mojom::IPConfigurationPtr> IPConfigurationsFromONCProperty( if (!ip_dict) return {}; arc::mojom::IPConfigurationPtr config = TranslateONCIPConfig(ip_dict); - if (!config) + if (!config || !IsValidIPConfiguration(*config)) return {}; std::vector<arc::mojom::IPConfigurationPtr> result; result.push_back(std::move(config)); @@ -279,10 +290,6 @@ void AddDeviceProperties(arc::mojom::NetworkConfiguration* network, network->network_interface = device->interface(); - // IP configurations were already obtained through cached ONC properties. - if (network->ip_configs) - return; - std::vector<arc::mojom::IPConfigurationPtr> ip_configs; for (const auto& kv : device->ip_configs()) { auto ip_config = arc::mojom::IPConfiguration::New(); @@ -312,10 +319,14 @@ void AddDeviceProperties(arc::mojom::NetworkConfiguration* network, ip_config->name_servers.push_back(dns); } } - ip_configs.push_back(std::move(ip_config)); + if (IsValidIPConfiguration(*ip_config)) + ip_configs.push_back(std::move(ip_config)); } - network->ip_configs = std::move(ip_configs); + // If the DeviceState had any IP configuration, always use them and ignore + // any other IP configuration previously obtained through NetworkState. + if (!ip_configs.empty()) + network->ip_configs = std::move(ip_configs); } arc::mojom::NetworkConfigurationPtr TranslateONCConfiguration( @@ -342,8 +353,7 @@ arc::mojom::NetworkConfigurationPtr TranslateONCConfiguration( ip_configs = IPConfigurationsFromONCProperty( dict, onc::network_config::kSavedIPConfig); } - if (!ip_configs.empty()) - mojo->ip_configs = std::move(ip_configs); + mojo->ip_configs = std::move(ip_configs); mojo->guid = GetStringFromONCDictionary(dict, onc::network_config::kGUID, true /* required */); @@ -402,6 +412,7 @@ std::vector<arc::mojom::NetworkConfigurationPtr> TranslateNetworkStates( state, chromeos::network_util::TranslateNetworkStateToONC(state).get()); network->is_default_network = (network_path == GetStateHandler()->default_network_path()); + network->service_name = network_path; networks.push_back(std::move(network)); } return networks; @@ -863,15 +874,14 @@ void ArcNetHostImpl::UpdateDefaultNetwork() { void ArcNetHostImpl::DefaultNetworkChanged( const chromeos::NetworkState* network) { UpdateDefaultNetwork(); + UpdateActiveNetworks(); +} - // If the the default network switched between two networks, also send an - // ActiveNetworkChanged notification to let ARC observe the switch. +void ArcNetHostImpl::UpdateActiveNetworks() { chromeos::NetworkStateHandler::NetworkStateList network_states; GetStateHandler()->GetActiveNetworkListByType( chromeos::NetworkTypePattern::Default(), &network_states); - if (network_states.size() > 1) { - ActiveNetworksChanged(network_states); - } + ActiveNetworksChanged(network_states); } void ArcNetHostImpl::DeviceListChanged() { @@ -1100,15 +1110,49 @@ void ArcNetHostImpl::ActiveNetworksChanged( std::vector<arc::mojom::NetworkConfigurationPtr> network_configurations = TranslateNetworkStates(arc_vpn_service_path_, active_networks); + + // A newly connected network may not immediately have any usable IP config + // object if IPv4 dhcp or IPv6 autoconf have not completed yet. Schedule + // with a few seconds delay a forced property update for that service to + // ensure the IP configuration is sent to ARC. Ensure that at most one such + // request is scheduled for a given service. + for (const auto& network : network_configurations) { + if (!network->ip_configs->empty()) + continue; + + if (!network->service_name) + continue; + + const std::string& path = network->service_name.value(); + if (pending_service_property_requests_.insert(path).second) { + LOG(WARNING) << "No IP configuration for " << path; + // TODO(hugobenichi): add exponential backoff for the case when IP + // configuration stays unavailable. + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, + base::BindOnce(&ArcNetHostImpl::RequestUpdateForNetwork, + weak_factory_.GetWeakPtr(), path), + kNetworkPropertyUpdateDelay); + } + } + net_instance->ActiveNetworksChanged(std::move(network_configurations)); } +void ArcNetHostImpl::RequestUpdateForNetwork(const std::string& service_path) { + // TODO(hugobenichi): skip the request if the IP configuration for this + // service has been received since then and ARC has been notified about it. + pending_service_property_requests_.erase(service_path); + GetStateHandler()->RequestUpdateForNetwork(service_path); +} + void ArcNetHostImpl::NetworkListChanged() { // This is invoked any time the list of services is reordered or changed. // During the transition when a new service comes online, it will // temporarily be ranked below "inferior" services. This callback // informs us that shill's ordering has been updated. UpdateDefaultNetwork(); + UpdateActiveNetworks(); } void ArcNetHostImpl::OnShuttingDown() { diff --git a/chromium/components/arc/net/arc_net_host_impl.h b/chromium/components/arc/net/arc_net_host_impl.h index 815c8ba7a20..63e2f63455b 100644 --- a/chromium/components/arc/net/arc_net_host_impl.h +++ b/chromium/components/arc/net/arc_net_host_impl.h @@ -7,6 +7,7 @@ #include <stdint.h> #include <memory> +#include <set> #include <string> #include <vector> @@ -107,6 +108,7 @@ class ArcNetHostImpl : public KeyedService, private: const chromeos::NetworkState* GetDefaultNetworkFromChrome(); void UpdateDefaultNetwork(); + void UpdateActiveNetworks(); void DefaultNetworkSuccessCallback(const std::string& service_path, const base::DictionaryValue& dictionary); @@ -151,11 +153,17 @@ class ArcNetHostImpl : public KeyedService, const std::string& error_name, std::unique_ptr<base::DictionaryValue> error_data); + // Request properties of the Service corresponding to |service_path|. + void RequestUpdateForNetwork(const std::string& service_path); + ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager. // True if the chrome::NetworkStateHandler is currently being observed for // state changes. bool observing_network_state_ = false; + // Contains all service paths for which a property update request is + // currently scheduled. + std::set<std::string> pending_service_property_requests_; std::string cached_service_path_; std::string cached_guid_; diff --git a/chromium/components/performance_manager/performance_manager_impl.cc b/chromium/components/performance_manager/performance_manager_impl.cc index c3cbf5ceecc..cf9565ede7f 100644 --- a/chromium/components/performance_manager/performance_manager_impl.cc +++ b/chromium/components/performance_manager/performance_manager_impl.cc @@ -141,11 +141,20 @@ std::unique_ptr<WorkerNodeImpl> PerformanceManagerImpl::CreateWorkerNode( worker_type, process_node, url, dev_tools_token); } +void PerformanceManagerImpl::DeleteNode(std::unique_ptr<NodeBase> node) { + GetTaskRunner()->PostTask( + FROM_HERE, base::BindOnce(&PerformanceManagerImpl::DeleteNodeImpl, + base::Unretained(this), node.release())); +} + void PerformanceManagerImpl::BatchDeleteNodes( std::vector<std::unique_ptr<NodeBase>> nodes) { + // Move the nodes vector to the heap. + auto nodes_ptr = std::make_unique<std::vector<std::unique_ptr<NodeBase>>>( + std::move(nodes)); GetTaskRunner()->PostTask( FROM_HERE, base::BindOnce(&PerformanceManagerImpl::BatchDeleteNodesImpl, - base::Unretained(this), std::move(nodes))); + base::Unretained(this), nodes_ptr.release())); } PerformanceManagerImpl::PerformanceManagerImpl() { @@ -182,15 +191,12 @@ std::unique_ptr<NodeType> PerformanceManagerImpl::CreateNodeImpl( return new_node; } -void PerformanceManagerImpl::PostDeleteNode(std::unique_ptr<NodeBase> node) { - GetTaskRunner()->PostTask( - FROM_HERE, base::BindOnce(&PerformanceManagerImpl::DeleteNodeImpl, - base::Unretained(this), std::move(node))); -} - -void PerformanceManagerImpl::DeleteNodeImpl(std::unique_ptr<NodeBase> node) { +void PerformanceManagerImpl::DeleteNodeImpl(NodeBase* node_ptr) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + // Must be done first to avoid leaking |node_ptr|. + std::unique_ptr<NodeBase> node(node_ptr); + graph_.RemoveNode(node.get()); } @@ -208,15 +214,18 @@ void RemoveFrameAndChildrenFromGraph(FrameNodeImpl* frame_node) { } // namespace void PerformanceManagerImpl::BatchDeleteNodesImpl( - std::vector<std::unique_ptr<NodeBase>> nodes) { + std::vector<std::unique_ptr<NodeBase>>* nodes_ptr) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + // Must be done first to avoid leaking |nodes_ptr|. + std::unique_ptr<std::vector<std::unique_ptr<NodeBase>>> nodes(nodes_ptr); + base::flat_set<ProcessNodeImpl*> process_nodes; - for (auto it = nodes.begin(); it != nodes.end(); ++it) { - switch ((*it)->type()) { + for (const auto& node : *nodes) { + switch (node->type()) { case PageNodeImpl::Type(): { - auto* page_node = PageNodeImpl::FromNodeBase(it->get()); + auto* page_node = PageNodeImpl::FromNodeBase(node.get()); // Delete the main frame nodes until no more exist. while (!page_node->main_frame_nodes().empty()) @@ -229,14 +238,14 @@ void PerformanceManagerImpl::BatchDeleteNodesImpl( case ProcessNodeImpl::Type(): { // Keep track of the process nodes for removing once all frames nodes // are removed. - auto* process_node = ProcessNodeImpl::FromNodeBase(it->get()); + auto* process_node = ProcessNodeImpl::FromNodeBase(node.get()); process_nodes.insert(process_node); break; } case FrameNodeImpl::Type(): break; case WorkerNodeImpl::Type(): { - auto* worker_node = WorkerNodeImpl::FromNodeBase(it->get()); + auto* worker_node = WorkerNodeImpl::FromNodeBase(node.get()); graph_.RemoveNode(worker_node); break; } diff --git a/chromium/components/performance_manager/performance_manager_impl.h b/chromium/components/performance_manager/performance_manager_impl.h index da7f2f9a0ee..54dcebdd437 100644 --- a/chromium/components/performance_manager/performance_manager_impl.h +++ b/chromium/components/performance_manager/performance_manager_impl.h @@ -102,8 +102,7 @@ class PerformanceManagerImpl : public PerformanceManager { // Destroys a node returned from the creation functions above. // May be called from any sequence. - template <typename NodeType> - void DeleteNode(std::unique_ptr<NodeType> node); + void DeleteNode(std::unique_ptr<NodeBase> node); // Each node in |nodes| must have been returned from one of the creation // functions above. This function takes care of removing them from the graph @@ -130,9 +129,14 @@ class PerformanceManagerImpl : public PerformanceManager { base::OnceCallback<void(NodeType*)> creation_callback, Args&&... constructor_args); - void PostDeleteNode(std::unique_ptr<NodeBase> node); - void DeleteNodeImpl(std::unique_ptr<NodeBase> node); - void BatchDeleteNodesImpl(std::vector<std::unique_ptr<NodeBase>> nodes); + // Helper functions that removes a node/vector of nodes from the graph on the + // PM sequence and deletes them. + // + // Note that this function has similar semantics to + // SequencedTaskRunner::DeleteSoon(). The node/vector of nodes is passed via a + // regular pointer so that they are not deleted if the task is not executed. + void DeleteNodeImpl(NodeBase* node_ptr); + void BatchDeleteNodesImpl(std::vector<std::unique_ptr<NodeBase>>* nodes_ptr); void OnStartImpl(GraphImplCallback graph_callback); static void RunCallbackWithGraphImpl(GraphImplCallback graph_callback); @@ -149,11 +153,6 @@ class PerformanceManagerImpl : public PerformanceManager { DISALLOW_COPY_AND_ASSIGN(PerformanceManagerImpl); }; -template <typename NodeType> -void PerformanceManagerImpl::DeleteNode(std::unique_ptr<NodeType> node) { - PostDeleteNode(std::move(node)); -} - template <typename TaskReturnType> void PerformanceManagerImpl::CallOnGraphAndReplyWithResult( const base::Location& from_here, diff --git a/chromium/components/viz/service/display/surface_aggregator.cc b/chromium/components/viz/service/display/surface_aggregator.cc index 8a9da59ee76..a134ca8d79d 100644 --- a/chromium/components/viz/service/display/surface_aggregator.cc +++ b/chromium/components/viz/service/display/surface_aggregator.cc @@ -861,14 +861,20 @@ void SurfaceAggregator::AddDisplayTransformPass() { display_transform_render_pass_id_ = next_render_pass_id_++; auto display_transform_pass = RenderPass::Create(1, 1); - display_transform_pass->SetNew( + display_transform_pass->SetAll( display_transform_render_pass_id_, cc::MathUtil::MapEnclosedRectWith2dAxisAlignedTransform( root_surface_transform_, root_render_pass->output_rect), cc::MathUtil::MapEnclosedRectWith2dAxisAlignedTransform( root_surface_transform_, root_render_pass->damage_rect), - gfx::Transform()); - display_transform_pass->color_space = root_render_pass->color_space; + gfx::Transform(), + /*filters=*/cc::FilterOperations(), + /*backdrop_filters=*/cc::FilterOperations(), + /*backdrop_filter_bounds=*/gfx::RRectF(), root_render_pass->color_space, + root_render_pass->has_transparent_background, + /*cache_render_pass=*/false, + /*has_damage_from_contributing_content=*/false, + /*generate_mipmap=*/false); bool are_contents_opaque = true; for (const auto* sqs : root_render_pass->shared_quad_state_list) { |