@@ -815,27 +815,32 @@ void Session::SetDownloadPath(const base::FilePath& path) {
815815}
816816
817817void Session::EnableNetworkEmulation (const gin_helper::Dictionary& options) {
818- auto conditions = network::mojom::NetworkConditions::New ();
819-
820- options.Get (" offline" , &conditions->offline );
821- options.Get (" downloadThroughput" , &conditions->download_throughput );
822- options.Get (" uploadThroughput" , &conditions->upload_throughput );
818+ std::vector<network::mojom::MatchedNetworkConditionsPtr> matched_conditions;
819+ network::mojom::MatchedNetworkConditionsPtr network_conditions =
820+ network::mojom::MatchedNetworkConditions::New ();
821+ options.Get (" offline" , &network_conditions->conditions ->offline );
822+ options.Get (" downloadThroughput" ,
823+ &network_conditions->conditions ->download_throughput );
824+ options.Get (" uploadThroughput" ,
825+ &network_conditions->conditions ->upload_throughput );
823826 double latency = 0.0 ;
824827 if (options.Get (" latency" , &latency) && latency) {
825- conditions->latency = base::Milliseconds (latency);
828+ network_conditions-> conditions ->latency = base::Milliseconds (latency);
826829 }
830+ matched_conditions.emplace_back (std::move (network_conditions));
827831
828832 auto * network_context =
829833 browser_context_->GetDefaultStoragePartition ()->GetNetworkContext ();
830834 network_context->SetNetworkConditions (network_emulation_token_,
831- std::move (conditions ));
835+ std::move (matched_conditions ));
832836}
833837
834838void Session::DisableNetworkEmulation () {
835839 auto * network_context =
836840 browser_context_->GetDefaultStoragePartition ()->GetNetworkContext ();
837- network_context->SetNetworkConditions (
838- network_emulation_token_, network::mojom::NetworkConditions::New ());
841+ std::vector<network::mojom::MatchedNetworkConditionsPtr> network_conditions;
842+ network_context->SetNetworkConditions (network_emulation_token_,
843+ std::move (network_conditions));
839844}
840845
841846void Session::SetCertVerifyProc (v8::Local<v8::Value> val,
0 commit comments