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(
}
void QuicChromiumClientSession::OnNetworkConnected(
NetworkChangeNotifier::NetworkHandle network,
const NetLogWithSource& net_log) {
DCHECK(migrate_session_on_network_change_v2_);
NetworkChangeNotifier::NetworkHandle network) {
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);
}
if (!migrate_session_on_network_change_v2_)
return;
net_log_.AddEventWithInt64Params(
NetLogEventType::QUIC_CONNECTION_MIGRATION_ON_NETWORK_CONNECTED,
"connected_network", network);
......@@ -2101,15 +2109,8 @@ void QuicChromiumClientSession::OnNetworkConnected(
if (!wait_for_new_network_ && !connection()->IsPathDegrading())
return;
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);
if (connection()->IsPathDegrading())
current_migration_cause_ = NEW_NETWORK_CONNECTED_POST_PATH_DEGRADING;
}
if (wait_for_new_network_) {
wait_for_new_network_ = false;
......@@ -2126,13 +2127,13 @@ void QuicChromiumClientSession::OnNetworkConnected(
}
void QuicChromiumClientSession::OnNetworkDisconnectedV2(
NetworkChangeNotifier::NetworkHandle disconnected_network,
const NetLogWithSource& migration_net_log) {
DCHECK(migrate_session_on_network_change_v2_);
NetworkChangeNotifier::NetworkHandle disconnected_network) {
LogMetricsOnNetworkDisconnected();
if (!migrate_session_on_network_change_v2_)
return;
net_log_.AddEventWithInt64Params(
NetLogEventType::QUIC_CONNECTION_MIGRATION_ON_NETWORK_DISCONNECTED,
"disconnected_network", disconnected_network);
LogMetricsOnNetworkDisconnected();
// Stop probing the disconnected network if there is one.
probing_manager_.CancelProbing(disconnected_network, peer_address());
......
......@@ -617,14 +617,12 @@ class NET_EXPORT_PRIVATE QuicChromiumClientSession
// Called when NetworkChangeNotifier notifies observers of a newly
// connected network. Migrates this session to the newly connected
// network if the session has a pending migration.
void OnNetworkConnected(NetworkChangeNotifier::NetworkHandle network,
const NetLogWithSource& net_log);
void OnNetworkConnected(NetworkChangeNotifier::NetworkHandle network);
// Called when NetworkChangeNotifier broadcasts to observers of
// |disconnected_network|.
void OnNetworkDisconnectedV2(
NetworkChangeNotifier::NetworkHandle disconnected_network,
const NetLogWithSource& migration_net_log);
NetworkChangeNotifier::NetworkHandle disconnected_network);
// Called when NetworkChangeNotifier broadcats to observers of a new default
// network. Migrates this session to |new_network| if appropriate.
......
......@@ -1600,34 +1600,39 @@ void QuicStreamFactory::OnIPAddressChanged() {
void QuicStreamFactory::OnNetworkConnected(NetworkHandle network) {
LogPlatformNotificationInHistogram(NETWORK_CONNECTED);
if (!params_.migrate_sessions_on_network_change_v2)
return;
ScopedConnectionMigrationEventLog scoped_event_log(net_log_,
"OnNetworkConnected");
if (params_.migrate_sessions_on_network_change_v2) {
// TODO(crbug.com/1090018): clean up the scoped netlog which is no
// longer needed.
ScopedConnectionMigrationEventLog scoped_event_log(net_log_,
"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();
// Sessions may be deleted while iterating through the map.
while (it != all_sessions_.end()) {
QuicChromiumClientSession* session = it->first;
++it;
session->OnNetworkConnected(network, scoped_event_log.net_log());
session->OnNetworkConnected(network);
}
}
void QuicStreamFactory::OnNetworkDisconnected(NetworkHandle network) {
LogPlatformNotificationInHistogram(NETWORK_DISCONNECTED);
if (!params_.migrate_sessions_on_network_change_v2)
return;
ScopedConnectionMigrationEventLog scoped_event_log(net_log_,
"OnNetworkDisconnected");
if (params_.migrate_sessions_on_network_change_v2) {
// TODO(crbug.com/1090018): clean up the scoped netlog which is no
// longer needed.
ScopedConnectionMigrationEventLog scoped_event_log(net_log_,
"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();
// Sessions may be deleted while iterating through the map.
while (it != all_sessions_.end()) {
QuicChromiumClientSession* session = it->first;
++it;
session->OnNetworkDisconnectedV2(/*disconnected_network*/ network,
scoped_event_log.net_log());
session->OnNetworkDisconnectedV2(/*disconnected_network*/ network);
}
}
......@@ -1652,6 +1657,8 @@ void QuicStreamFactory::OnNetworkMadeDefault(NetworkHandle network) {
DCHECK_NE(NetworkChangeNotifier::kInvalidNetworkHandle, network);
default_network_ = network;
// TODO(crbug.com/1090018): clean up the scoped netlog which is no
// longer needed.
ScopedConnectionMigrationEventLog scoped_event_log(net_log_,
"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