Commit cf1dc184 authored by Zhongyi Shi's avatar Zhongyi Shi Committed by Commit Bot

Always broadcast network events to QUIC session to collect data.

Bug: 1088100, 1090018
Change-Id: Ie25ffdecabb2bbaa242379b45f28debb0b10c1fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2223013
Commit-Queue: Zhongyi Shi <zhongyi@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#773874}
parent 836b46c5
...@@ -2090,9 +2090,17 @@ bool QuicChromiumClientSession::OnSendConnectivityProbingPacket( ...@@ -2090,9 +2090,17 @@ bool QuicChromiumClientSession::OnSendConnectivityProbingPacket(
} }
void QuicChromiumClientSession::OnNetworkConnected( void QuicChromiumClientSession::OnNetworkConnected(
NetworkChangeNotifier::NetworkHandle network, NetworkChangeNotifier::NetworkHandle network) {
const NetLogWithSource& net_log) { if (connection()->IsPathDegrading()) {
DCHECK(migrate_session_on_network_change_v2_); base::TimeDelta duration =
tick_clock_->NowTicks() - most_recent_path_degrading_timestamp_;
UMA_HISTOGRAM_CUSTOM_TIMES("Net.QuicNetworkDegradingDurationTillConnected",
duration, base::TimeDelta::FromMilliseconds(1),
base::TimeDelta::FromMinutes(10), 50);
}
if (!migrate_session_on_network_change_v2_)
return;
net_log_.AddEventWithInt64Params( net_log_.AddEventWithInt64Params(
NetLogEventType::QUIC_CONNECTION_MIGRATION_ON_NETWORK_CONNECTED, NetLogEventType::QUIC_CONNECTION_MIGRATION_ON_NETWORK_CONNECTED,
"connected_network", network); "connected_network", network);
...@@ -2101,15 +2109,8 @@ void QuicChromiumClientSession::OnNetworkConnected( ...@@ -2101,15 +2109,8 @@ void QuicChromiumClientSession::OnNetworkConnected(
if (!wait_for_new_network_ && !connection()->IsPathDegrading()) if (!wait_for_new_network_ && !connection()->IsPathDegrading())
return; return;
if (connection()->IsPathDegrading()) { if (connection()->IsPathDegrading())
base::TimeDelta duration =
tick_clock_->NowTicks() - most_recent_path_degrading_timestamp_;
UMA_HISTOGRAM_CUSTOM_TIMES("Net.QuicNetworkDegradingDurationTillConnected",
duration, base::TimeDelta::FromMilliseconds(1),
base::TimeDelta::FromMinutes(10), 50);
current_migration_cause_ = NEW_NETWORK_CONNECTED_POST_PATH_DEGRADING; current_migration_cause_ = NEW_NETWORK_CONNECTED_POST_PATH_DEGRADING;
}
if (wait_for_new_network_) { if (wait_for_new_network_) {
wait_for_new_network_ = false; wait_for_new_network_ = false;
...@@ -2126,13 +2127,13 @@ void QuicChromiumClientSession::OnNetworkConnected( ...@@ -2126,13 +2127,13 @@ void QuicChromiumClientSession::OnNetworkConnected(
} }
void QuicChromiumClientSession::OnNetworkDisconnectedV2( void QuicChromiumClientSession::OnNetworkDisconnectedV2(
NetworkChangeNotifier::NetworkHandle disconnected_network, NetworkChangeNotifier::NetworkHandle disconnected_network) {
const NetLogWithSource& migration_net_log) { LogMetricsOnNetworkDisconnected();
DCHECK(migrate_session_on_network_change_v2_); if (!migrate_session_on_network_change_v2_)
return;
net_log_.AddEventWithInt64Params( net_log_.AddEventWithInt64Params(
NetLogEventType::QUIC_CONNECTION_MIGRATION_ON_NETWORK_DISCONNECTED, NetLogEventType::QUIC_CONNECTION_MIGRATION_ON_NETWORK_DISCONNECTED,
"disconnected_network", disconnected_network); "disconnected_network", disconnected_network);
LogMetricsOnNetworkDisconnected();
// Stop probing the disconnected network if there is one. // Stop probing the disconnected network if there is one.
probing_manager_.CancelProbing(disconnected_network, peer_address()); probing_manager_.CancelProbing(disconnected_network, peer_address());
......
...@@ -617,14 +617,12 @@ class NET_EXPORT_PRIVATE QuicChromiumClientSession ...@@ -617,14 +617,12 @@ class NET_EXPORT_PRIVATE QuicChromiumClientSession
// Called when NetworkChangeNotifier notifies observers of a newly // Called when NetworkChangeNotifier notifies observers of a newly
// connected network. Migrates this session to the newly connected // connected network. Migrates this session to the newly connected
// network if the session has a pending migration. // network if the session has a pending migration.
void OnNetworkConnected(NetworkChangeNotifier::NetworkHandle network, void OnNetworkConnected(NetworkChangeNotifier::NetworkHandle network);
const NetLogWithSource& net_log);
// Called when NetworkChangeNotifier broadcasts to observers of // Called when NetworkChangeNotifier broadcasts to observers of
// |disconnected_network|. // |disconnected_network|.
void OnNetworkDisconnectedV2( void OnNetworkDisconnectedV2(
NetworkChangeNotifier::NetworkHandle disconnected_network, NetworkChangeNotifier::NetworkHandle disconnected_network);
const NetLogWithSource& migration_net_log);
// Called when NetworkChangeNotifier broadcats to observers of a new default // Called when NetworkChangeNotifier broadcats to observers of a new default
// network. Migrates this session to |new_network| if appropriate. // network. Migrates this session to |new_network| if appropriate.
......
...@@ -1600,34 +1600,39 @@ void QuicStreamFactory::OnIPAddressChanged() { ...@@ -1600,34 +1600,39 @@ void QuicStreamFactory::OnIPAddressChanged() {
void QuicStreamFactory::OnNetworkConnected(NetworkHandle network) { void QuicStreamFactory::OnNetworkConnected(NetworkHandle network) {
LogPlatformNotificationInHistogram(NETWORK_CONNECTED); LogPlatformNotificationInHistogram(NETWORK_CONNECTED);
if (!params_.migrate_sessions_on_network_change_v2) if (params_.migrate_sessions_on_network_change_v2) {
return; // TODO(crbug.com/1090018): clean up the scoped netlog which is no
// longer needed.
ScopedConnectionMigrationEventLog scoped_event_log(net_log_, ScopedConnectionMigrationEventLog scoped_event_log(net_log_,
"OnNetworkConnected"); "OnNetworkConnected");
}
// Broadcast network connected to all sessions.
// If migration is not turned on, session will not migrate but collect data.
auto it = all_sessions_.begin(); auto it = all_sessions_.begin();
// Sessions may be deleted while iterating through the map. // Sessions may be deleted while iterating through the map.
while (it != all_sessions_.end()) { while (it != all_sessions_.end()) {
QuicChromiumClientSession* session = it->first; QuicChromiumClientSession* session = it->first;
++it; ++it;
session->OnNetworkConnected(network, scoped_event_log.net_log()); session->OnNetworkConnected(network);
} }
} }
void QuicStreamFactory::OnNetworkDisconnected(NetworkHandle network) { void QuicStreamFactory::OnNetworkDisconnected(NetworkHandle network) {
LogPlatformNotificationInHistogram(NETWORK_DISCONNECTED); LogPlatformNotificationInHistogram(NETWORK_DISCONNECTED);
if (!params_.migrate_sessions_on_network_change_v2) if (params_.migrate_sessions_on_network_change_v2) {
return; // TODO(crbug.com/1090018): clean up the scoped netlog which is no
// longer needed.
ScopedConnectionMigrationEventLog scoped_event_log(net_log_, ScopedConnectionMigrationEventLog scoped_event_log(net_log_,
"OnNetworkDisconnected"); "OnNetworkDisconnected");
}
// Broadcast network disconnected to all sessions.
// If migration is not turned on, session will not migrate but collect data.
auto it = all_sessions_.begin(); auto it = all_sessions_.begin();
// Sessions may be deleted while iterating through the map. // Sessions may be deleted while iterating through the map.
while (it != all_sessions_.end()) { while (it != all_sessions_.end()) {
QuicChromiumClientSession* session = it->first; QuicChromiumClientSession* session = it->first;
++it; ++it;
session->OnNetworkDisconnectedV2(/*disconnected_network*/ network, session->OnNetworkDisconnectedV2(/*disconnected_network*/ network);
scoped_event_log.net_log());
} }
} }
...@@ -1652,6 +1657,8 @@ void QuicStreamFactory::OnNetworkMadeDefault(NetworkHandle network) { ...@@ -1652,6 +1657,8 @@ void QuicStreamFactory::OnNetworkMadeDefault(NetworkHandle network) {
DCHECK_NE(NetworkChangeNotifier::kInvalidNetworkHandle, network); DCHECK_NE(NetworkChangeNotifier::kInvalidNetworkHandle, network);
default_network_ = network; default_network_ = network;
// TODO(crbug.com/1090018): clean up the scoped netlog which is no
// longer needed.
ScopedConnectionMigrationEventLog scoped_event_log(net_log_, ScopedConnectionMigrationEventLog scoped_event_log(net_log_,
"OnNetworkMadeDefault"); "OnNetworkMadeDefault");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment