mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Fix tests to actually check session durations and delays.
PiperOrigin-RevId: 849273112
This commit is contained in:
committed by
Copybara-Service
parent
34e9326311
commit
da41bcd194
@@ -68,9 +68,11 @@ cc_test(
|
||||
"//internal/platform:base",
|
||||
"//internal/platform:error_code_recorder",
|
||||
"//internal/platform:logging",
|
||||
"//internal/platform:test_util",
|
||||
"//internal/platform:types",
|
||||
"//internal/platform/implementation/g3", # build_cleaner: keep
|
||||
"//internal/proto/analytics:connections_log_cc_proto",
|
||||
"//internal/test",
|
||||
"//net/proto2/contrib/parse_proto:parse_text_proto",
|
||||
"//proto:connections_enums_cc_proto",
|
||||
"@com_github_protobuf_matchers//protobuf-matchers",
|
||||
|
||||
@@ -162,20 +162,12 @@ OperationResultCategory ConvertToOperationResultCategory(
|
||||
}
|
||||
} // namespace
|
||||
|
||||
AnalyticsRecorder::AnalyticsRecorder(EventLogger *event_logger)
|
||||
AnalyticsRecorder::AnalyticsRecorder(EventLogger* event_logger)
|
||||
: event_logger_(event_logger) {
|
||||
VLOG(1) << "Start AnalyticsRecorder ctor event_logger_=" << event_logger_;
|
||||
LogStartSession();
|
||||
}
|
||||
|
||||
AnalyticsRecorder::AnalyticsRecorder(EventLogger *event_logger,
|
||||
bool no_record_time_millis)
|
||||
: event_logger_(event_logger),
|
||||
no_record_time_millis_(no_record_time_millis) {
|
||||
LOG(INFO) << "Start AnalyticsRecorder ctor event_logger_=" << event_logger_;
|
||||
LogStartSession();
|
||||
}
|
||||
|
||||
AnalyticsRecorder::~AnalyticsRecorder() = default;
|
||||
|
||||
bool AnalyticsRecorder::IsSessionLogged() {
|
||||
@@ -184,9 +176,9 @@ bool AnalyticsRecorder::IsSessionLogged() {
|
||||
}
|
||||
|
||||
int AnalyticsRecorder::GetLatestUpdateIndexLocked(
|
||||
const std::vector<ConnectionsLog::OperationResultWithMedium> &list) {
|
||||
const std::vector<ConnectionsLog::OperationResultWithMedium>& list) {
|
||||
int latest_update_index = 0;
|
||||
for (const auto &operation_result_with_medium : list) {
|
||||
for (const auto& operation_result_with_medium : list) {
|
||||
if (operation_result_with_medium.update_index() > latest_update_index) {
|
||||
latest_update_index = operation_result_with_medium.update_index();
|
||||
}
|
||||
@@ -195,8 +187,8 @@ int AnalyticsRecorder::GetLatestUpdateIndexLocked(
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnStartAdvertising(
|
||||
connections::Strategy strategy, const std::vector<Medium> &mediums,
|
||||
AdvertisingMetadataParams *advertising_metadata_params) {
|
||||
connections::Strategy strategy, const std::vector<Medium>& mediums,
|
||||
AdvertisingMetadataParams* advertising_metadata_params) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnStartAdvertising")) {
|
||||
return;
|
||||
@@ -225,7 +217,7 @@ void AnalyticsRecorder::OnStartAdvertising(
|
||||
RepeatedFieldBackInserter(
|
||||
current_advertising_phase_->mutable_adv_dis_result()));
|
||||
}
|
||||
auto *advertising_metadata =
|
||||
auto* advertising_metadata =
|
||||
current_advertising_phase_->mutable_advertising_metadata();
|
||||
advertising_metadata->set_supports_extended_ble_advertisements(
|
||||
advertising_metadata_params->is_extended_advertisement_supported);
|
||||
@@ -257,8 +249,8 @@ int AnalyticsRecorder::GetNextAdvertisingUpdateIndex() {
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnStartDiscovery(
|
||||
connections::Strategy strategy, const std::vector<Medium> &mediums,
|
||||
DiscoveryMetadataParams *discovery_metadata_params) {
|
||||
connections::Strategy strategy, const std::vector<Medium>& mediums,
|
||||
DiscoveryMetadataParams* discovery_metadata_params) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnStartDiscovery")) {
|
||||
return;
|
||||
@@ -287,7 +279,7 @@ void AnalyticsRecorder::OnStartDiscovery(
|
||||
RepeatedFieldBackInserter(
|
||||
current_discovery_phase_->mutable_adv_dis_result()));
|
||||
}
|
||||
auto *discovery_metadata =
|
||||
auto* discovery_metadata =
|
||||
current_discovery_phase_->mutable_discovery_metadata();
|
||||
discovery_metadata->set_supports_extended_ble_advertisements(
|
||||
discovery_metadata_params->is_extended_advertisement_supported);
|
||||
@@ -347,17 +339,15 @@ void AnalyticsRecorder::OnEndpointFound(Medium medium) {
|
||||
"current_discovery_phase_";
|
||||
return;
|
||||
}
|
||||
ConnectionsLog::DiscoveredEndpoint *discovered_endpoint =
|
||||
ConnectionsLog::DiscoveredEndpoint* discovered_endpoint =
|
||||
current_discovery_phase_->add_discovered_endpoint();
|
||||
discovered_endpoint->set_medium(medium);
|
||||
if (!no_record_time_millis_) {
|
||||
discovered_endpoint->set_latency_millis(absl::ToInt64Milliseconds(
|
||||
SystemClock::ElapsedRealtime() - started_discovery_phase_time_));
|
||||
}
|
||||
discovered_endpoint->set_latency_millis(absl::ToInt64Milliseconds(
|
||||
SystemClock::ElapsedRealtime() - started_discovery_phase_time_));
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnRequestConnection(
|
||||
const connections::Strategy &strategy, const std::string &endpoint_id) {
|
||||
const connections::Strategy& strategy, const std::string& endpoint_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("onRequestConnection")) {
|
||||
return;
|
||||
@@ -370,7 +360,7 @@ void AnalyticsRecorder::OnRequestConnection(
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnConnectionRequestReceived(
|
||||
const std::string &remote_endpoint_id) {
|
||||
const std::string& remote_endpoint_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnConnectionRequestReceived")) {
|
||||
return;
|
||||
@@ -378,17 +368,15 @@ void AnalyticsRecorder::OnConnectionRequestReceived(
|
||||
absl::Time current_time = SystemClock::ElapsedRealtime();
|
||||
auto connection_request =
|
||||
std::make_unique<ConnectionsLog::ConnectionRequest>();
|
||||
if (!no_record_time_millis_) {
|
||||
connection_request->set_duration_millis(absl::ToUnixMillis(current_time));
|
||||
connection_request->set_request_delay_millis(absl::ToInt64Milliseconds(
|
||||
current_time - started_advertising_phase_time_));
|
||||
}
|
||||
connection_request->set_duration_millis(absl::ToUnixMillis(current_time));
|
||||
connection_request->set_request_delay_millis(absl::ToInt64Milliseconds(
|
||||
current_time - started_advertising_phase_time_));
|
||||
incoming_connection_requests_.insert(
|
||||
{remote_endpoint_id, std::move(connection_request)});
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnConnectionRequestSent(
|
||||
const std::string &remote_endpoint_id) {
|
||||
const std::string& remote_endpoint_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnConnectionRequestSent")) {
|
||||
return;
|
||||
@@ -396,17 +384,15 @@ void AnalyticsRecorder::OnConnectionRequestSent(
|
||||
absl::Time current_time = SystemClock::ElapsedRealtime();
|
||||
auto connection_request =
|
||||
std::make_unique<ConnectionsLog::ConnectionRequest>();
|
||||
if (!no_record_time_millis_) {
|
||||
connection_request->set_duration_millis(absl::ToUnixMillis(current_time));
|
||||
connection_request->set_request_delay_millis(absl::ToInt64Milliseconds(
|
||||
current_time - started_discovery_phase_time_));
|
||||
}
|
||||
connection_request->set_duration_millis(absl::ToUnixMillis(current_time));
|
||||
connection_request->set_request_delay_millis(
|
||||
absl::ToInt64Milliseconds(current_time - started_discovery_phase_time_));
|
||||
outgoing_connection_requests_.insert(
|
||||
{remote_endpoint_id, std::move(connection_request)});
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnRemoteEndpointAccepted(
|
||||
const std::string &remote_endpoint_id) {
|
||||
const std::string& remote_endpoint_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnRemoteEndpointAccepted")) {
|
||||
return;
|
||||
@@ -415,7 +401,7 @@ void AnalyticsRecorder::OnRemoteEndpointAccepted(
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnLocalEndpointAccepted(
|
||||
const std::string &remote_endpoint_id) {
|
||||
const std::string& remote_endpoint_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnLocalEndpointAccepted")) {
|
||||
return;
|
||||
@@ -424,7 +410,7 @@ void AnalyticsRecorder::OnLocalEndpointAccepted(
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnRemoteEndpointRejected(
|
||||
const std::string &remote_endpoint_id) {
|
||||
const std::string& remote_endpoint_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnRemoteEndpointRejected")) {
|
||||
return;
|
||||
@@ -433,7 +419,7 @@ void AnalyticsRecorder::OnRemoteEndpointRejected(
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnLocalEndpointRejected(
|
||||
const std::string &remote_endpoint_id) {
|
||||
const std::string& remote_endpoint_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnLocalEndpointRejected")) {
|
||||
return;
|
||||
@@ -443,8 +429,8 @@ void AnalyticsRecorder::OnLocalEndpointRejected(
|
||||
|
||||
void AnalyticsRecorder::OnIncomingConnectionAttempt(
|
||||
ConnectionAttemptType type, Medium medium, ConnectionAttemptResult result,
|
||||
absl::Duration duration, const std::string &connection_token,
|
||||
ConnectionAttemptMetadataParams *connection_attempt_metadata_params) {
|
||||
absl::Duration duration, const std::string& connection_token,
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnIncomingConnectionAttempt")) {
|
||||
return;
|
||||
@@ -468,21 +454,18 @@ void AnalyticsRecorder::OnIncomingConnectionAttemptLocked(
|
||||
location::nearby::proto::connections::ConnectionAttemptType type,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptResult result,
|
||||
absl::Duration duration, const std::string &connection_token,
|
||||
ConnectionAttemptMetadataParams *connection_attempt_metadata_params) {
|
||||
auto *connection_attempt =
|
||||
absl::Duration duration, const std::string& connection_token,
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params) {
|
||||
auto* connection_attempt =
|
||||
current_strategy_session_->add_connection_attempt();
|
||||
if (!no_record_time_millis_) {
|
||||
connection_attempt->set_duration_millis(
|
||||
absl::ToInt64Milliseconds(duration));
|
||||
}
|
||||
connection_attempt->set_duration_millis(absl::ToInt64Milliseconds(duration));
|
||||
connection_attempt->set_type(type);
|
||||
connection_attempt->set_direction(INCOMING);
|
||||
connection_attempt->set_medium(medium);
|
||||
connection_attempt->set_attempt_result(result);
|
||||
connection_attempt->set_connection_token(connection_token);
|
||||
|
||||
auto *connection_attempt_metadata =
|
||||
auto* connection_attempt_metadata =
|
||||
connection_attempt->mutable_connection_attempt_metadata();
|
||||
connection_attempt_metadata->set_technology(
|
||||
connection_attempt_metadata_params->technology);
|
||||
@@ -520,10 +503,10 @@ void AnalyticsRecorder::OnIncomingConnectionAttemptLocked(
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnOutgoingConnectionAttempt(
|
||||
const std::string &remote_endpoint_id, ConnectionAttemptType type,
|
||||
const std::string& remote_endpoint_id, ConnectionAttemptType type,
|
||||
Medium medium, ConnectionAttemptResult result, absl::Duration duration,
|
||||
const std::string &connection_token,
|
||||
ConnectionAttemptMetadataParams *connection_attempt_metadata_params) {
|
||||
const std::string& connection_token,
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnOutgoingConnectionAttempt")) {
|
||||
return;
|
||||
@@ -554,23 +537,20 @@ void AnalyticsRecorder::OnOutgoingConnectionAttempt(
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnOutgoingConnectionAttemptLocked(
|
||||
const std::string &remote_endpoint_id, ConnectionAttemptType type,
|
||||
const std::string& remote_endpoint_id, ConnectionAttemptType type,
|
||||
Medium medium, ConnectionAttemptResult result, absl::Duration duration,
|
||||
const std::string &connection_token,
|
||||
ConnectionAttemptMetadataParams *connection_attempt_metadata_params) {
|
||||
auto *connection_attempt =
|
||||
const std::string& connection_token,
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params) {
|
||||
auto* connection_attempt =
|
||||
current_strategy_session_->add_connection_attempt();
|
||||
if (!no_record_time_millis_) {
|
||||
connection_attempt->set_duration_millis(
|
||||
absl::ToInt64Milliseconds(duration));
|
||||
}
|
||||
connection_attempt->set_duration_millis(absl::ToInt64Milliseconds(duration));
|
||||
connection_attempt->set_type(type);
|
||||
connection_attempt->set_direction(OUTGOING);
|
||||
connection_attempt->set_medium(medium);
|
||||
connection_attempt->set_attempt_result(result);
|
||||
connection_attempt->set_connection_token(connection_token);
|
||||
|
||||
auto *connection_attempt_metadata =
|
||||
auto* connection_attempt_metadata =
|
||||
connection_attempt->mutable_connection_attempt_metadata();
|
||||
connection_attempt_metadata->set_technology(
|
||||
connection_attempt_metadata_params->technology);
|
||||
@@ -613,7 +593,7 @@ void AnalyticsRecorder::OnOutgoingConnectionAttemptLocked(
|
||||
// ConnectionRequest that, since the ConnectionAttempt has failed, will
|
||||
// never be delivered to the advertiser.
|
||||
auto pair = outgoing_connection_requests_.extract(it);
|
||||
std::unique_ptr<ConnectionsLog::ConnectionRequest> &connection_request =
|
||||
std::unique_ptr<ConnectionsLog::ConnectionRequest>& connection_request =
|
||||
pair.mapped();
|
||||
connection_request->set_local_response(NOT_SENT);
|
||||
connection_request->set_remote_response(NOT_SENT);
|
||||
@@ -623,24 +603,24 @@ void AnalyticsRecorder::OnOutgoingConnectionAttemptLocked(
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnConnectionEstablished(
|
||||
const std::string &endpoint_id, Medium medium,
|
||||
const std::string &connection_token) {
|
||||
const std::string& endpoint_id, Medium medium,
|
||||
const std::string& connection_token) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnConnectionEstablished")) {
|
||||
return;
|
||||
}
|
||||
auto it = active_connections_.find(endpoint_id);
|
||||
if (it != active_connections_.end()) {
|
||||
const std::unique_ptr<LogicalConnection> &logical_connection = it->second;
|
||||
const std::unique_ptr<LogicalConnection>& logical_connection = it->second;
|
||||
logical_connection->PhysicalConnectionEstablished(medium, connection_token);
|
||||
} else {
|
||||
active_connections_.insert(
|
||||
{endpoint_id, std::make_unique<LogicalConnection>(
|
||||
medium, connection_token, no_record_time_millis_)});
|
||||
{endpoint_id,
|
||||
std::make_unique<LogicalConnection>(medium, connection_token)});
|
||||
}
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnConnectionClosed(const std::string &endpoint_id,
|
||||
void AnalyticsRecorder::OnConnectionClosed(const std::string& endpoint_id,
|
||||
Medium medium,
|
||||
DisconnectionReason reason,
|
||||
SafeDisconnectionResult result) {
|
||||
@@ -665,14 +645,14 @@ void AnalyticsRecorder::OnConnectionClosed(const std::string &endpoint_id,
|
||||
if (it == active_connections_.end()) {
|
||||
return;
|
||||
}
|
||||
const std::unique_ptr<LogicalConnection> &logical_connection = it->second;
|
||||
const std::unique_ptr<LogicalConnection>& logical_connection = it->second;
|
||||
logical_connection->PhysicalConnectionClosed(medium, reason, result);
|
||||
if (reason != UPGRADED) {
|
||||
// Unless this is an upgraded connection, remove this from our active
|
||||
// connections. Any future communication with an endpoint will need to be
|
||||
// re-established with a new ConnectionRequest.
|
||||
auto pair = active_connections_.extract(it);
|
||||
std::unique_ptr<LogicalConnection> &logical_connection = pair.mapped();
|
||||
std::unique_ptr<LogicalConnection>& logical_connection = pair.mapped();
|
||||
|
||||
absl::c_copy(
|
||||
logical_connection->GetEstablisedConnections(),
|
||||
@@ -682,7 +662,7 @@ void AnalyticsRecorder::OnConnectionClosed(const std::string &endpoint_id,
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnIncomingPayloadStarted(
|
||||
const std::string &endpoint_id, std::int64_t payload_id,
|
||||
const std::string& endpoint_id, std::int64_t payload_id,
|
||||
connections::PayloadType type, std::int64_t total_size_bytes) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnIncomingPayloadStarted")) {
|
||||
@@ -692,12 +672,12 @@ void AnalyticsRecorder::OnIncomingPayloadStarted(
|
||||
if (it == active_connections_.end()) {
|
||||
return;
|
||||
}
|
||||
const std::unique_ptr<LogicalConnection> &logical_connection = it->second;
|
||||
const std::unique_ptr<LogicalConnection>& logical_connection = it->second;
|
||||
logical_connection->IncomingPayloadStarted(
|
||||
payload_id, PayloadTypeToProtoPayloadType(type), total_size_bytes);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnPayloadChunkReceived(const std::string &endpoint_id,
|
||||
void AnalyticsRecorder::OnPayloadChunkReceived(const std::string& endpoint_id,
|
||||
std::int64_t payload_id,
|
||||
std::int64_t chunk_size_bytes) {
|
||||
MutexLock lock(&mutex_);
|
||||
@@ -708,12 +688,12 @@ void AnalyticsRecorder::OnPayloadChunkReceived(const std::string &endpoint_id,
|
||||
if (it == active_connections_.end()) {
|
||||
return;
|
||||
}
|
||||
const std::unique_ptr<LogicalConnection> &logical_connection = it->second;
|
||||
const std::unique_ptr<LogicalConnection>& logical_connection = it->second;
|
||||
logical_connection->ChunkReceived(payload_id, chunk_size_bytes);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnIncomingPayloadDone(
|
||||
const std::string &endpoint_id, std::int64_t payload_id,
|
||||
const std::string& endpoint_id, std::int64_t payload_id,
|
||||
PayloadStatus status, OperationResultCode operation_result_code) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnIncomingPayloadDone")) {
|
||||
@@ -723,30 +703,30 @@ void AnalyticsRecorder::OnIncomingPayloadDone(
|
||||
if (it == active_connections_.end()) {
|
||||
return;
|
||||
}
|
||||
const std::unique_ptr<LogicalConnection> &logical_connection = it->second;
|
||||
const std::unique_ptr<LogicalConnection>& logical_connection = it->second;
|
||||
logical_connection->IncomingPayloadDone(payload_id, status,
|
||||
operation_result_code);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnOutgoingPayloadStarted(
|
||||
const std::vector<std::string> &endpoint_ids, std::int64_t payload_id,
|
||||
const std::vector<std::string>& endpoint_ids, std::int64_t payload_id,
|
||||
connections::PayloadType type, std::int64_t total_size_bytes) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnOutgoingPayloadStarted")) {
|
||||
return;
|
||||
}
|
||||
for (const auto &endpoint_id : endpoint_ids) {
|
||||
for (const auto& endpoint_id : endpoint_ids) {
|
||||
auto it = active_connections_.find(endpoint_id);
|
||||
if (it == active_connections_.end()) {
|
||||
continue;
|
||||
}
|
||||
const std::unique_ptr<LogicalConnection> &logical_connection = it->second;
|
||||
const std::unique_ptr<LogicalConnection>& logical_connection = it->second;
|
||||
logical_connection->OutgoingPayloadStarted(
|
||||
payload_id, PayloadTypeToProtoPayloadType(type), total_size_bytes);
|
||||
}
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnPayloadChunkSent(const std::string &endpoint_id,
|
||||
void AnalyticsRecorder::OnPayloadChunkSent(const std::string& endpoint_id,
|
||||
std::int64_t payload_id,
|
||||
std::int64_t chunk_size_bytes) {
|
||||
MutexLock lock(&mutex_);
|
||||
@@ -757,12 +737,12 @@ void AnalyticsRecorder::OnPayloadChunkSent(const std::string &endpoint_id,
|
||||
if (it == active_connections_.end()) {
|
||||
return;
|
||||
}
|
||||
const std::unique_ptr<LogicalConnection> &logical_connection = it->second;
|
||||
const std::unique_ptr<LogicalConnection>& logical_connection = it->second;
|
||||
logical_connection->ChunkSent(payload_id, chunk_size_bytes);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnOutgoingPayloadDone(
|
||||
const std::string &endpoint_id, std::int64_t payload_id,
|
||||
const std::string& endpoint_id, std::int64_t payload_id,
|
||||
PayloadStatus status, OperationResultCode operation_result_code) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnOutgoingPayloadDone")) {
|
||||
@@ -773,24 +753,22 @@ void AnalyticsRecorder::OnOutgoingPayloadDone(
|
||||
return;
|
||||
}
|
||||
|
||||
const std::unique_ptr<LogicalConnection> &logical_connection = it->second;
|
||||
const std::unique_ptr<LogicalConnection>& logical_connection = it->second;
|
||||
logical_connection->OutgoingPayloadDone(payload_id, status,
|
||||
operation_result_code);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnBandwidthUpgradeStarted(
|
||||
const std::string &endpoint_id, Medium from_medium, Medium to_medium,
|
||||
ConnectionAttemptDirection direction, const std::string &connection_token) {
|
||||
const std::string& endpoint_id, Medium from_medium, Medium to_medium,
|
||||
ConnectionAttemptDirection direction, const std::string& connection_token) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnBandwidthUpgradeStarted")) {
|
||||
return;
|
||||
}
|
||||
auto bandwidth_upgrade_attempt =
|
||||
std::make_unique<ConnectionsLog::BandwidthUpgradeAttempt>();
|
||||
if (!no_record_time_millis_) {
|
||||
bandwidth_upgrade_attempt->set_duration_millis(
|
||||
absl::ToUnixMillis(SystemClock::ElapsedRealtime()));
|
||||
}
|
||||
bandwidth_upgrade_attempt->set_duration_millis(
|
||||
absl::ToUnixMillis(SystemClock::ElapsedRealtime()));
|
||||
bandwidth_upgrade_attempt->set_from_medium(from_medium);
|
||||
bandwidth_upgrade_attempt->set_to_medium(to_medium);
|
||||
bandwidth_upgrade_attempt->set_direction(direction);
|
||||
@@ -800,7 +778,7 @@ void AnalyticsRecorder::OnBandwidthUpgradeStarted(
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnBandwidthUpgradeError(
|
||||
const std::string &endpoint_id, BandwidthUpgradeResult result,
|
||||
const std::string& endpoint_id, BandwidthUpgradeResult result,
|
||||
BandwidthUpgradeErrorStage error_stage,
|
||||
OperationResultCode operation_result_code) {
|
||||
MutexLock lock(&mutex_);
|
||||
@@ -817,7 +795,7 @@ void AnalyticsRecorder::OnBandwidthUpgradeError(
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnBandwidthUpgradeSuccess(
|
||||
const std::string &endpoint_id) {
|
||||
const std::string& endpoint_id) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnBandwidthUpgradeSuccess")) {
|
||||
return;
|
||||
@@ -827,7 +805,7 @@ void AnalyticsRecorder::OnBandwidthUpgradeSuccess(
|
||||
OperationResultCode::DETAIL_SUCCESS);
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::OnErrorCode(const ErrorCodeParams ¶ms) {
|
||||
void AnalyticsRecorder::OnErrorCode(const ErrorCodeParams& params) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (!CanRecordAnalyticsLocked("OnErrorCode")) {
|
||||
return;
|
||||
@@ -912,10 +890,8 @@ void AnalyticsRecorder::LogSession() {
|
||||
return;
|
||||
}
|
||||
FinishStrategySessionLocked();
|
||||
if (!no_record_time_millis_) {
|
||||
client_session_->set_duration_millis(absl::ToInt64Milliseconds(
|
||||
SystemClock::ElapsedRealtime() - started_client_session_time_));
|
||||
}
|
||||
client_session_->set_duration_millis(absl::ToInt64Milliseconds(
|
||||
SystemClock::ElapsedRealtime() - started_client_session_time_));
|
||||
LogClientSessionLocked();
|
||||
LogEvent(STOP_CLIENT_SESSION);
|
||||
start_client_session_was_logged_ = false;
|
||||
@@ -926,8 +902,8 @@ std::unique_ptr<AdvertisingMetadataParams>
|
||||
AnalyticsRecorder::BuildAdvertisingMetadataParams(
|
||||
bool is_extended_advertisement_supported, int connected_ap_frequency,
|
||||
bool is_nfc_available,
|
||||
const std::vector<ConnectionsLog::OperationResultWithMedium>
|
||||
&operation_result_with_mediums) {
|
||||
const std::vector<ConnectionsLog::OperationResultWithMedium>&
|
||||
operation_result_with_mediums) {
|
||||
auto params = std::make_unique<AdvertisingMetadataParams>();
|
||||
params->is_extended_advertisement_supported =
|
||||
is_extended_advertisement_supported;
|
||||
@@ -942,8 +918,8 @@ std::unique_ptr<DiscoveryMetadataParams>
|
||||
AnalyticsRecorder::BuildDiscoveryMetadataParams(
|
||||
bool is_extended_advertisement_supported, int connected_ap_frequency,
|
||||
bool is_nfc_available,
|
||||
const std::vector<ConnectionsLog::OperationResultWithMedium>
|
||||
&operation_result_with_mediums) {
|
||||
const std::vector<ConnectionsLog::OperationResultWithMedium>&
|
||||
operation_result_with_mediums) {
|
||||
auto params = std::make_unique<DiscoveryMetadataParams>();
|
||||
params->is_extended_advertisement_supported =
|
||||
is_extended_advertisement_supported;
|
||||
@@ -957,8 +933,8 @@ AnalyticsRecorder::BuildDiscoveryMetadataParams(
|
||||
std::unique_ptr<ConnectionAttemptMetadataParams>
|
||||
AnalyticsRecorder::BuildConnectionAttemptMetadataParams(
|
||||
ConnectionTechnology technology, ConnectionBand band, int frequency,
|
||||
int try_count, const std::string &network_operator,
|
||||
const std::string &country_code, bool is_tdls_used,
|
||||
int try_count, const std::string& network_operator,
|
||||
const std::string& country_code, bool is_tdls_used,
|
||||
bool wifi_hotspot_enabled, int max_wifi_tx_speed, int max_wifi_rx_speed,
|
||||
int channel_width, OperationResultCode operation_result_code) {
|
||||
auto params = std::make_unique<ConnectionAttemptMetadataParams>();
|
||||
@@ -1091,8 +1067,7 @@ void AnalyticsRecorder::RecordAdvertisingPhaseDurationAndReasonLocked(
|
||||
"null current_advertising_phase_";
|
||||
return;
|
||||
}
|
||||
if (!current_advertising_phase_->has_duration_millis() &&
|
||||
!no_record_time_millis_) {
|
||||
if (!current_advertising_phase_->has_duration_millis()) {
|
||||
current_advertising_phase_->set_duration_millis(absl::ToInt64Milliseconds(
|
||||
SystemClock::ElapsedRealtime() - started_advertising_phase_time_));
|
||||
}
|
||||
@@ -1105,11 +1080,11 @@ void AnalyticsRecorder::RecordAdvertisingPhaseDurationAndReasonLocked(
|
||||
|
||||
void AnalyticsRecorder::FinishAdvertisingPhaseLocked() {
|
||||
if (current_advertising_phase_ != nullptr) {
|
||||
for (const auto &item : incoming_connection_requests_) {
|
||||
for (const auto& item : incoming_connection_requests_) {
|
||||
// ConnectionRequests still pending have been ignored by the local or
|
||||
// remote (or both) endpoints.
|
||||
const std::unique_ptr<ConnectionsLog::ConnectionRequest>
|
||||
&connection_request = item.second;
|
||||
const std::unique_ptr<ConnectionsLog::ConnectionRequest>&
|
||||
connection_request = item.second;
|
||||
MarkConnectionRequestIgnoredLocked(connection_request.get());
|
||||
UpdateAdvertiserConnectionRequestLocked(connection_request.get());
|
||||
}
|
||||
@@ -1132,8 +1107,7 @@ void AnalyticsRecorder::RecordDiscoveryPhaseDurationAndReasonLocked(
|
||||
"null current_discovery_phase_";
|
||||
return;
|
||||
}
|
||||
if (!current_discovery_phase_->has_duration_millis() &&
|
||||
!no_record_time_millis_) {
|
||||
if (!current_discovery_phase_->has_duration_millis()) {
|
||||
current_discovery_phase_->set_duration_millis(absl::ToInt64Milliseconds(
|
||||
SystemClock::ElapsedRealtime() - started_discovery_phase_time_));
|
||||
}
|
||||
@@ -1147,11 +1121,11 @@ void AnalyticsRecorder::RecordDiscoveryPhaseDurationAndReasonLocked(
|
||||
|
||||
void AnalyticsRecorder::FinishDiscoveryPhaseLocked() {
|
||||
if (current_discovery_phase_ != nullptr) {
|
||||
for (const auto &item : outgoing_connection_requests_) {
|
||||
for (const auto& item : outgoing_connection_requests_) {
|
||||
// ConnectionRequests still pending have been ignored by the local or
|
||||
// remote (or both) endpoints.
|
||||
const std::unique_ptr<ConnectionsLog::ConnectionRequest>
|
||||
&connection_request = item.second;
|
||||
const std::unique_ptr<ConnectionsLog::ConnectionRequest>&
|
||||
connection_request = item.second;
|
||||
MarkConnectionRequestIgnoredLocked(connection_request.get());
|
||||
UpdateDiscovererConnectionRequestLocked(connection_request.get());
|
||||
}
|
||||
@@ -1168,18 +1142,16 @@ void AnalyticsRecorder::FinishDiscoveryPhaseLocked() {
|
||||
}
|
||||
|
||||
bool AnalyticsRecorder::UpdateAdvertiserConnectionRequestLocked(
|
||||
ConnectionsLog::ConnectionRequest *request) {
|
||||
ConnectionsLog::ConnectionRequest* request) {
|
||||
if (current_advertising_phase_ == nullptr) {
|
||||
LOG(INFO) << "Unable to record advertiser connection request due to null "
|
||||
"current_advertising_phase_";
|
||||
return false;
|
||||
}
|
||||
if (BothEndpointsRespondedLocked(request)) {
|
||||
if (!no_record_time_millis_) {
|
||||
request->set_duration_millis(
|
||||
absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
|
||||
request->duration_millis());
|
||||
}
|
||||
request->set_duration_millis(
|
||||
absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
|
||||
request->duration_millis());
|
||||
*current_advertising_phase_->add_received_connection_request() = *request;
|
||||
return true;
|
||||
}
|
||||
@@ -1187,7 +1159,7 @@ bool AnalyticsRecorder::UpdateAdvertiserConnectionRequestLocked(
|
||||
}
|
||||
|
||||
bool AnalyticsRecorder::UpdateDiscovererConnectionRequestLocked(
|
||||
ConnectionsLog::ConnectionRequest *request) {
|
||||
ConnectionsLog::ConnectionRequest* request) {
|
||||
if (current_discovery_phase_ == nullptr) {
|
||||
LOG(INFO) << "Unable to record discoverer connection request due "
|
||||
"to null current_discovery_phase_.";
|
||||
@@ -1195,11 +1167,9 @@ bool AnalyticsRecorder::UpdateDiscovererConnectionRequestLocked(
|
||||
}
|
||||
if (BothEndpointsRespondedLocked(request) ||
|
||||
request->local_response() == NOT_SENT) {
|
||||
if (!no_record_time_millis_) {
|
||||
request->set_duration_millis(
|
||||
absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
|
||||
request->duration_millis());
|
||||
}
|
||||
request->set_duration_millis(
|
||||
absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
|
||||
request->duration_millis());
|
||||
*current_discovery_phase_->add_sent_connection_request() = *request;
|
||||
return true;
|
||||
}
|
||||
@@ -1207,15 +1177,15 @@ bool AnalyticsRecorder::UpdateDiscovererConnectionRequestLocked(
|
||||
}
|
||||
|
||||
bool AnalyticsRecorder::BothEndpointsRespondedLocked(
|
||||
ConnectionsLog::ConnectionRequest *request) {
|
||||
ConnectionsLog::ConnectionRequest* request) {
|
||||
return request->has_local_response() && request->has_remote_response();
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::LocalEndpointRespondedLocked(
|
||||
const std::string &remote_endpoint_id, ConnectionRequestResponse response) {
|
||||
const std::string& remote_endpoint_id, ConnectionRequestResponse response) {
|
||||
auto out = outgoing_connection_requests_.find(remote_endpoint_id);
|
||||
if (out != outgoing_connection_requests_.end()) {
|
||||
ConnectionsLog::ConnectionRequest *connection_request = out->second.get();
|
||||
ConnectionsLog::ConnectionRequest* connection_request = out->second.get();
|
||||
connection_request->set_local_response(response);
|
||||
if (UpdateDiscovererConnectionRequestLocked(connection_request)) {
|
||||
outgoing_connection_requests_.erase(out);
|
||||
@@ -1223,7 +1193,7 @@ void AnalyticsRecorder::LocalEndpointRespondedLocked(
|
||||
}
|
||||
auto in = incoming_connection_requests_.find(remote_endpoint_id);
|
||||
if (in != incoming_connection_requests_.end()) {
|
||||
ConnectionsLog::ConnectionRequest *connection_request = in->second.get();
|
||||
ConnectionsLog::ConnectionRequest* connection_request = in->second.get();
|
||||
connection_request->set_local_response(response);
|
||||
if (UpdateAdvertiserConnectionRequestLocked(connection_request)) {
|
||||
incoming_connection_requests_.erase(in);
|
||||
@@ -1232,10 +1202,10 @@ void AnalyticsRecorder::LocalEndpointRespondedLocked(
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::RemoteEndpointRespondedLocked(
|
||||
const std::string &remote_endpoint_id, ConnectionRequestResponse response) {
|
||||
const std::string& remote_endpoint_id, ConnectionRequestResponse response) {
|
||||
auto out = outgoing_connection_requests_.find(remote_endpoint_id);
|
||||
if (out != outgoing_connection_requests_.end()) {
|
||||
ConnectionsLog::ConnectionRequest *connection_request = out->second.get();
|
||||
ConnectionsLog::ConnectionRequest* connection_request = out->second.get();
|
||||
connection_request->set_remote_response(response);
|
||||
if (UpdateDiscovererConnectionRequestLocked(connection_request)) {
|
||||
outgoing_connection_requests_.erase(out);
|
||||
@@ -1243,7 +1213,7 @@ void AnalyticsRecorder::RemoteEndpointRespondedLocked(
|
||||
}
|
||||
auto in = incoming_connection_requests_.find(remote_endpoint_id);
|
||||
if (in != incoming_connection_requests_.end()) {
|
||||
ConnectionsLog::ConnectionRequest *connection_request = in->second.get();
|
||||
ConnectionsLog::ConnectionRequest* connection_request = in->second.get();
|
||||
connection_request->set_remote_response(response);
|
||||
if (UpdateAdvertiserConnectionRequestLocked(connection_request)) {
|
||||
incoming_connection_requests_.erase(in);
|
||||
@@ -1252,7 +1222,7 @@ void AnalyticsRecorder::RemoteEndpointRespondedLocked(
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::MarkConnectionRequestIgnoredLocked(
|
||||
ConnectionsLog::ConnectionRequest *request) {
|
||||
ConnectionsLog::ConnectionRequest* request) {
|
||||
if (!request->has_local_response()) {
|
||||
request->set_local_response(IGNORED);
|
||||
}
|
||||
@@ -1263,13 +1233,13 @@ void AnalyticsRecorder::MarkConnectionRequestIgnoredLocked(
|
||||
|
||||
bool AnalyticsRecorder::ConnectionAttemptResultCodeExistedLocked(
|
||||
Medium medium, ConnectionAttemptDirection direction,
|
||||
const std::string &connection_token, ConnectionAttemptType type,
|
||||
const std::string& connection_token, ConnectionAttemptType type,
|
||||
OperationResultCode operation_result_code) {
|
||||
if (current_strategy_session_ == nullptr ||
|
||||
current_strategy_session_->connection_attempt_size() == 0) {
|
||||
return false;
|
||||
}
|
||||
for (auto &connection_attempt :
|
||||
for (auto& connection_attempt :
|
||||
current_strategy_session_->connection_attempt()) {
|
||||
if (connection_attempt.medium() == medium &&
|
||||
connection_attempt.direction() == direction &&
|
||||
@@ -1288,7 +1258,7 @@ bool AnalyticsRecorder::ConnectionAttemptResultCodeExistedLocked(
|
||||
// stage and result code, we'll drop the duplicate logs for preventing the waste
|
||||
// of log storage space
|
||||
bool AnalyticsRecorder::EraseIfBandwidthUpgradeRecordExistedLocked(
|
||||
const std::string &endpoint_id, BandwidthUpgradeResult result,
|
||||
const std::string& endpoint_id, BandwidthUpgradeResult result,
|
||||
BandwidthUpgradeErrorStage error_stage,
|
||||
OperationResultCode operation_result_code) {
|
||||
if (current_strategy_session_ == nullptr) {
|
||||
@@ -1296,8 +1266,8 @@ bool AnalyticsRecorder::EraseIfBandwidthUpgradeRecordExistedLocked(
|
||||
}
|
||||
auto it = bandwidth_upgrade_attempts_.find(endpoint_id);
|
||||
if (it != bandwidth_upgrade_attempts_.end()) {
|
||||
ConnectionsLog::BandwidthUpgradeAttempt *attempt = it->second.get();
|
||||
for (auto &existing_attempt :
|
||||
ConnectionsLog::BandwidthUpgradeAttempt* attempt = it->second.get();
|
||||
for (auto& existing_attempt :
|
||||
current_strategy_session_->upgrade_attempt()) {
|
||||
if (attempt->from_medium() == existing_attempt.from_medium() &&
|
||||
attempt->to_medium() == existing_attempt.to_medium() &&
|
||||
@@ -1314,7 +1284,7 @@ bool AnalyticsRecorder::EraseIfBandwidthUpgradeRecordExistedLocked(
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::FinishUpgradeAttemptLocked(
|
||||
const std::string &endpoint_id, BandwidthUpgradeResult result,
|
||||
const std::string& endpoint_id, BandwidthUpgradeResult result,
|
||||
BandwidthUpgradeErrorStage error_stage,
|
||||
OperationResultCode operation_result_code, bool erase_item) {
|
||||
if (current_strategy_session_ == nullptr) {
|
||||
@@ -1325,12 +1295,10 @@ void AnalyticsRecorder::FinishUpgradeAttemptLocked(
|
||||
// Add the BandwidthUpgradeAttempt in the current StrategySession.
|
||||
auto it = bandwidth_upgrade_attempts_.find(endpoint_id);
|
||||
if (it != bandwidth_upgrade_attempts_.end()) {
|
||||
ConnectionsLog::BandwidthUpgradeAttempt *attempt = it->second.get();
|
||||
if (!no_record_time_millis_) {
|
||||
attempt->set_duration_millis(
|
||||
absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
|
||||
attempt->duration_millis());
|
||||
}
|
||||
ConnectionsLog::BandwidthUpgradeAttempt* attempt = it->second.get();
|
||||
attempt->set_duration_millis(
|
||||
absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
|
||||
attempt->duration_millis());
|
||||
attempt->set_error_stage(error_stage);
|
||||
attempt->set_upgrade_result(result);
|
||||
|
||||
@@ -1353,8 +1321,8 @@ void AnalyticsRecorder::FinishStrategySessionLocked() {
|
||||
FinishDiscoveryPhaseLocked();
|
||||
|
||||
// Finish any unfinished LogicalConnections.
|
||||
for (const auto &item : active_connections_) {
|
||||
const std::unique_ptr<LogicalConnection> &logical_connection =
|
||||
for (const auto& item : active_connections_) {
|
||||
const std::unique_ptr<LogicalConnection>& logical_connection =
|
||||
item.second;
|
||||
logical_connection->CloseAllPhysicalConnections();
|
||||
absl::c_copy(
|
||||
@@ -1365,7 +1333,7 @@ void AnalyticsRecorder::FinishStrategySessionLocked() {
|
||||
active_connections_.clear();
|
||||
|
||||
// Finish any pending upgrade attempts.
|
||||
for (const auto &item : bandwidth_upgrade_attempts_) {
|
||||
for (const auto& item : bandwidth_upgrade_attempts_) {
|
||||
FinishUpgradeAttemptLocked(
|
||||
item.first, UNFINISHED_ERROR, UPGRADE_UNFINISHED,
|
||||
OperationResultCode::DEVICE_STATE_ERROR_UNFINISHED_UPGRADE_ATTEMPTS,
|
||||
@@ -1375,11 +1343,8 @@ void AnalyticsRecorder::FinishStrategySessionLocked() {
|
||||
|
||||
// Add the StrategySession in ClientSession
|
||||
if (current_strategy_session_ != nullptr) {
|
||||
if (!no_record_time_millis_) {
|
||||
current_strategy_session_->set_duration_millis(
|
||||
absl::ToInt64Milliseconds(SystemClock::ElapsedRealtime() -
|
||||
started_strategy_session_time_));
|
||||
}
|
||||
current_strategy_session_->set_duration_millis(absl::ToInt64Milliseconds(
|
||||
SystemClock::ElapsedRealtime() - started_strategy_session_time_));
|
||||
*client_session_->add_strategy_session() =
|
||||
*std::move(current_strategy_session_);
|
||||
}
|
||||
@@ -1427,10 +1392,8 @@ void AnalyticsRecorder::PendingPayload::AddChunk(
|
||||
ConnectionsLog::Payload AnalyticsRecorder::PendingPayload::GetProtoPayload(
|
||||
PayloadStatus status) {
|
||||
ConnectionsLog::Payload payload;
|
||||
if (!no_record_time_millis_) {
|
||||
payload.set_duration_millis(absl::ToInt64Milliseconds(
|
||||
SystemClock::ElapsedRealtime() - start_time_));
|
||||
}
|
||||
payload.set_duration_millis(
|
||||
absl::ToInt64Milliseconds(SystemClock::ElapsedRealtime() - start_time_));
|
||||
payload.set_type(type_);
|
||||
payload.set_total_size_bytes(total_size_bytes_);
|
||||
payload.set_num_bytes_transferred(num_bytes_transferred_);
|
||||
@@ -1448,7 +1411,7 @@ ConnectionsLog::Payload AnalyticsRecorder::PendingPayload::GetProtoPayload(
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::LogicalConnection::PhysicalConnectionEstablished(
|
||||
Medium medium, const std::string &connection_token) {
|
||||
Medium medium, const std::string& connection_token) {
|
||||
if (current_medium_ != UNKNOWN_MEDIUM) {
|
||||
LOG(WARNING) << "Unexpected call to PhysicalConnectionEstablished while "
|
||||
"AnalyticsRecorder still has an active current medium.";
|
||||
@@ -1457,10 +1420,8 @@ void AnalyticsRecorder::LogicalConnection::PhysicalConnectionEstablished(
|
||||
auto established_connection =
|
||||
std::make_unique<ConnectionsLog::EstablishedConnection>();
|
||||
established_connection->set_medium(medium);
|
||||
if (!no_record_time_millis_) {
|
||||
established_connection->set_duration_millis(
|
||||
absl::ToUnixMillis(SystemClock::ElapsedRealtime()));
|
||||
}
|
||||
established_connection->set_duration_millis(
|
||||
absl::ToUnixMillis(SystemClock::ElapsedRealtime()));
|
||||
established_connection->set_connection_token(connection_token);
|
||||
|
||||
auto operation_result_proto =
|
||||
@@ -1496,7 +1457,7 @@ void AnalyticsRecorder::LogicalConnection::PhysicalConnectionClosed(
|
||||
" opened.";
|
||||
return;
|
||||
}
|
||||
ConnectionsLog::EstablishedConnection *established_connection =
|
||||
ConnectionsLog::EstablishedConnection* established_connection =
|
||||
it->second.get();
|
||||
if (established_connection->has_disconnection_reason()) {
|
||||
LOG(WARNING) << "Unexpected call to physicalConnectionClosed() for medium "
|
||||
@@ -1516,8 +1477,8 @@ void AnalyticsRecorder::LogicalConnection::PhysicalConnectionClosed(
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::LogicalConnection::CloseAllPhysicalConnections() {
|
||||
for (const auto &physical_connection : physical_connections_) {
|
||||
ConnectionsLog::EstablishedConnection *established_connection =
|
||||
for (const auto& physical_connection : physical_connections_) {
|
||||
ConnectionsLog::EstablishedConnection* established_connection =
|
||||
physical_connection.second.get();
|
||||
if (!established_connection->has_disconnection_reason()) {
|
||||
FinishPhysicalConnection(
|
||||
@@ -1539,10 +1500,10 @@ AnalyticsRecorder::LogicalConnection::GetEstablisedConnections() {
|
||||
}
|
||||
std::transform(physical_connections_.begin(), physical_connections_.end(),
|
||||
std::back_inserter(established_connections),
|
||||
[](auto &kv) { return *kv.second; });
|
||||
[](auto& kv) { return *kv.second; });
|
||||
physical_connections_.clear();
|
||||
|
||||
for (auto &established_connection : established_connections) {
|
||||
for (auto& established_connection : established_connections) {
|
||||
if (absl::Milliseconds(established_connection.duration_millis()) >=
|
||||
kConnectionTokenMaxLife) {
|
||||
LOG(INFO) << "connection token exceed TTL, drop token.";
|
||||
@@ -1556,8 +1517,7 @@ AnalyticsRecorder::LogicalConnection::GetEstablisedConnections() {
|
||||
void AnalyticsRecorder::LogicalConnection::IncomingPayloadStarted(
|
||||
std::int64_t payload_id, PayloadType type, std::int64_t total_size_bytes) {
|
||||
incoming_payloads_.insert(
|
||||
{payload_id, std::make_unique<PendingPayload>(type, total_size_bytes,
|
||||
no_record_time_millis_)});
|
||||
{payload_id, std::make_unique<PendingPayload>(type, total_size_bytes)});
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::LogicalConnection::ChunkReceived(
|
||||
@@ -1566,7 +1526,7 @@ void AnalyticsRecorder::LogicalConnection::ChunkReceived(
|
||||
if (it == incoming_payloads_.end()) {
|
||||
return;
|
||||
}
|
||||
PendingPayload *pending_payload = it->second.get();
|
||||
PendingPayload* pending_payload = it->second.get();
|
||||
pending_payload->AddChunk(size_bytes);
|
||||
}
|
||||
|
||||
@@ -1580,8 +1540,8 @@ void AnalyticsRecorder::LogicalConnection::IncomingPayloadDone(
|
||||
}
|
||||
auto it = physical_connections_.find(current_medium_);
|
||||
if (it != physical_connections_.end()) {
|
||||
const std::unique_ptr<ConnectionsLog::EstablishedConnection>
|
||||
&established_connection = it->second;
|
||||
const std::unique_ptr<ConnectionsLog::EstablishedConnection>&
|
||||
established_connection = it->second;
|
||||
auto it = incoming_payloads_.find(payload_id);
|
||||
if (it != incoming_payloads_.end()) {
|
||||
it->second->SetOperationResultCode(operation_result_code);
|
||||
@@ -1595,8 +1555,7 @@ void AnalyticsRecorder::LogicalConnection::IncomingPayloadDone(
|
||||
void AnalyticsRecorder::LogicalConnection::OutgoingPayloadStarted(
|
||||
std::int64_t payload_id, PayloadType type, std::int64_t total_size_bytes) {
|
||||
outgoing_payloads_.insert(
|
||||
{payload_id, std::make_unique<PendingPayload>(type, total_size_bytes,
|
||||
no_record_time_millis_)});
|
||||
{payload_id, std::make_unique<PendingPayload>(type, total_size_bytes)});
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::LogicalConnection::ChunkSent(std::int64_t payload_id,
|
||||
@@ -1605,7 +1564,7 @@ void AnalyticsRecorder::LogicalConnection::ChunkSent(std::int64_t payload_id,
|
||||
if (it == outgoing_payloads_.end()) {
|
||||
return;
|
||||
}
|
||||
PendingPayload *payload = it->second.get();
|
||||
PendingPayload* payload = it->second.get();
|
||||
payload->AddChunk(size_bytes);
|
||||
}
|
||||
|
||||
@@ -1619,8 +1578,8 @@ void AnalyticsRecorder::LogicalConnection::OutgoingPayloadDone(
|
||||
}
|
||||
auto it = physical_connections_.find(current_medium_);
|
||||
if (it != physical_connections_.end()) {
|
||||
const std::unique_ptr<ConnectionsLog::EstablishedConnection>
|
||||
&established_connection = it->second;
|
||||
const std::unique_ptr<ConnectionsLog::EstablishedConnection>&
|
||||
established_connection = it->second;
|
||||
auto it = outgoing_payloads_.find(payload_id);
|
||||
if (it != outgoing_payloads_.end()) {
|
||||
it->second->SetOperationResultCode(operation_result_code);
|
||||
@@ -1632,15 +1591,13 @@ void AnalyticsRecorder::LogicalConnection::OutgoingPayloadDone(
|
||||
}
|
||||
|
||||
void AnalyticsRecorder::LogicalConnection::FinishPhysicalConnection(
|
||||
ConnectionsLog::EstablishedConnection *established_connection,
|
||||
ConnectionsLog::EstablishedConnection* established_connection,
|
||||
DisconnectionReason reason, SafeDisconnectionResult result) {
|
||||
established_connection->set_disconnection_reason(reason);
|
||||
established_connection->set_safe_disconnection_result(result);
|
||||
if (!no_record_time_millis_) {
|
||||
established_connection->set_duration_millis(
|
||||
absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
|
||||
established_connection->duration_millis());
|
||||
}
|
||||
established_connection->set_duration_millis(
|
||||
absl::ToUnixMillis(SystemClock::ElapsedRealtime()) -
|
||||
established_connection->duration_millis());
|
||||
|
||||
// Add any not-yet-finished payloads to this EstablishedConnection.
|
||||
std::vector<ConnectionsLog::Payload> in_payloads =
|
||||
@@ -1657,8 +1614,8 @@ void AnalyticsRecorder::LogicalConnection::FinishPhysicalConnection(
|
||||
|
||||
std::vector<ConnectionsLog::Payload>
|
||||
AnalyticsRecorder::LogicalConnection::ResolvePendingPayloads(
|
||||
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>
|
||||
&pending_payloads,
|
||||
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>&
|
||||
pending_payloads,
|
||||
DisconnectionReason reason) {
|
||||
std::vector<ConnectionsLog::Payload> completed_payloads;
|
||||
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>
|
||||
@@ -1668,8 +1625,8 @@ AnalyticsRecorder::LogicalConnection::ResolvePendingPayloads(
|
||||
|
||||
OperationResultCode operation_result_code =
|
||||
GetPendingPayloadResultCodeFromReason(reason);
|
||||
for (const auto &item : pending_payloads) {
|
||||
const std::unique_ptr<PendingPayload> &pending_payload = item.second;
|
||||
for (const auto& item : pending_payloads) {
|
||||
const std::unique_ptr<PendingPayload>& pending_payload = item.second;
|
||||
pending_payload->SetOperationResultCode(operation_result_code);
|
||||
ConnectionsLog::Payload proto_payload =
|
||||
pending_payload->GetProtoPayload(status);
|
||||
@@ -1677,9 +1634,9 @@ AnalyticsRecorder::LogicalConnection::ResolvePendingPayloads(
|
||||
if (reason == UPGRADED) {
|
||||
upgraded_payloads.insert(
|
||||
{item.first,
|
||||
std::make_unique<PendingPayload>(
|
||||
pending_payload->type(), pending_payload->total_size_bytes(),
|
||||
no_record_time_millis_, operation_result_code)});
|
||||
std::make_unique<PendingPayload>(pending_payload->type(),
|
||||
pending_payload->total_size_bytes(),
|
||||
operation_result_code)});
|
||||
}
|
||||
}
|
||||
pending_payloads.clear();
|
||||
|
||||
@@ -42,17 +42,14 @@ namespace analytics {
|
||||
|
||||
class AnalyticsRecorder {
|
||||
public:
|
||||
explicit AnalyticsRecorder(::nearby::analytics::EventLogger *event_logger);
|
||||
// For testing only.
|
||||
AnalyticsRecorder(::nearby::analytics::EventLogger *event_logger,
|
||||
bool no_record_time_millis);
|
||||
explicit AnalyticsRecorder(::nearby::analytics::EventLogger* event_logger);
|
||||
virtual ~AnalyticsRecorder();
|
||||
|
||||
// Advertising phase
|
||||
void OnStartAdvertising(
|
||||
connections::Strategy strategy,
|
||||
const std::vector<location::nearby::proto::connections::Medium> &mediums,
|
||||
AdvertisingMetadataParams *advertising_metadata_params)
|
||||
const std::vector<location::nearby::proto::connections::Medium>& mediums,
|
||||
AdvertisingMetadataParams* advertising_metadata_params)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnStopAdvertising() ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
@@ -70,8 +67,8 @@ class AnalyticsRecorder {
|
||||
// Discovery phase
|
||||
void OnStartDiscovery(
|
||||
connections::Strategy strategy,
|
||||
const std::vector<location::nearby::proto::connections::Medium> &mediums,
|
||||
DiscoveryMetadataParams *discovery_metadata_params)
|
||||
const std::vector<location::nearby::proto::connections::Medium>& mediums,
|
||||
DiscoveryMetadataParams* discovery_metadata_params)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnStopDiscovery() ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
@@ -84,21 +81,21 @@ class AnalyticsRecorder {
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
// Connection request
|
||||
void OnRequestConnection(const connections::Strategy &strategy,
|
||||
const std::string &endpoint_id)
|
||||
void OnRequestConnection(const connections::Strategy& strategy,
|
||||
const std::string& endpoint_id)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
void OnConnectionRequestReceived(const std::string &remote_endpoint_id)
|
||||
void OnConnectionRequestReceived(const std::string& remote_endpoint_id)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnConnectionRequestSent(const std::string &remote_endpoint_id)
|
||||
void OnConnectionRequestSent(const std::string& remote_endpoint_id)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnRemoteEndpointAccepted(const std::string &remote_endpoint_id)
|
||||
void OnRemoteEndpointAccepted(const std::string& remote_endpoint_id)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnLocalEndpointAccepted(const std::string &remote_endpoint_id)
|
||||
void OnLocalEndpointAccepted(const std::string& remote_endpoint_id)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnRemoteEndpointRejected(const std::string &remote_endpoint_id)
|
||||
void OnRemoteEndpointRejected(const std::string& remote_endpoint_id)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnLocalEndpointRejected(const std::string &remote_endpoint_id)
|
||||
void OnLocalEndpointRejected(const std::string& remote_endpoint_id)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
// Connection attempt
|
||||
@@ -108,39 +105,39 @@ class AnalyticsRecorder {
|
||||
location::nearby::proto::connections::ConnectionAttemptType type,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptResult result,
|
||||
absl::Duration duration, const std::string &connection_token,
|
||||
ConnectionAttemptMetadataParams *connection_attempt_metadata_params)
|
||||
absl::Duration duration, const std::string& connection_token,
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
// Records an attempt with meta data at establishing an outgoing physical
|
||||
// connection.
|
||||
void OnOutgoingConnectionAttempt(
|
||||
const std::string &remote_endpoint_id,
|
||||
const std::string& remote_endpoint_id,
|
||||
location::nearby::proto::connections::ConnectionAttemptType type,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptResult result,
|
||||
absl::Duration duration, const std::string &connection_token,
|
||||
ConnectionAttemptMetadataParams *connection_attempt_metadata_params)
|
||||
absl::Duration duration, const std::string& connection_token,
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
static std::unique_ptr<AdvertisingMetadataParams>
|
||||
BuildAdvertisingMetadataParams(
|
||||
bool is_extended_advertisement_supported = false,
|
||||
int connected_ap_frequency = 0, bool is_nfc_available = false,
|
||||
const std::vector<location::nearby::analytics::proto::ConnectionsLog::
|
||||
OperationResultWithMedium>
|
||||
&operation_result_with_mediums = {});
|
||||
OperationResultWithMedium>&
|
||||
operation_result_with_mediums = {});
|
||||
static std::unique_ptr<DiscoveryMetadataParams> BuildDiscoveryMetadataParams(
|
||||
bool is_extended_advertisement_supported = false,
|
||||
int connected_ap_frequency = 0, bool is_nfc_available = false,
|
||||
const std::vector<location::nearby::analytics::proto::ConnectionsLog::
|
||||
OperationResultWithMedium>
|
||||
&operation_result_with_mediums = {});
|
||||
OperationResultWithMedium>&
|
||||
operation_result_with_mediums = {});
|
||||
|
||||
static std::unique_ptr<ConnectionAttemptMetadataParams>
|
||||
BuildConnectionAttemptMetadataParams(
|
||||
location::nearby::proto::connections::ConnectionTechnology technology,
|
||||
location::nearby::proto::connections::ConnectionBand band, int frequency,
|
||||
int try_count, const std::string &network_operator = {},
|
||||
const std::string &country_code = {}, bool is_tdls_used = false,
|
||||
int try_count, const std::string& network_operator = {},
|
||||
const std::string& country_code = {}, bool is_tdls_used = false,
|
||||
bool wifi_hotspot_enabled = false, int max_wifi_tx_speed = 0,
|
||||
int max_wifi_rx_speed = 0, int channel_width = -1,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
@@ -152,11 +149,11 @@ class AnalyticsRecorder {
|
||||
|
||||
// Connection establishedSafeDisconnectionResult
|
||||
void OnConnectionEstablished(
|
||||
const std::string &endpoint_id,
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
const std::string &connection_token) ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
const std::string& connection_token) ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnConnectionClosed(
|
||||
const std::string &endpoint_id,
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::DisconnectionReason reason,
|
||||
location::nearby::analytics::proto::ConnectionsLog::
|
||||
@@ -164,55 +161,55 @@ class AnalyticsRecorder {
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
// Payload
|
||||
void OnIncomingPayloadStarted(const std::string &endpoint_id,
|
||||
void OnIncomingPayloadStarted(const std::string& endpoint_id,
|
||||
std::int64_t payload_id,
|
||||
connections::PayloadType type,
|
||||
std::int64_t total_size_bytes)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnPayloadChunkReceived(const std::string &endpoint_id,
|
||||
void OnPayloadChunkReceived(const std::string& endpoint_id,
|
||||
std::int64_t payload_id,
|
||||
std::int64_t chunk_size_bytes)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnIncomingPayloadDone(
|
||||
const std::string &endpoint_id, std::int64_t payload_id,
|
||||
const std::string& endpoint_id, std::int64_t payload_id,
|
||||
location::nearby::proto::connections::PayloadStatus status,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code) ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnOutgoingPayloadStarted(const std::vector<std::string> &endpoint_ids,
|
||||
void OnOutgoingPayloadStarted(const std::vector<std::string>& endpoint_ids,
|
||||
std::int64_t payload_id,
|
||||
connections::PayloadType type,
|
||||
std::int64_t total_size_bytes)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnPayloadChunkSent(const std::string &endpoint_id,
|
||||
void OnPayloadChunkSent(const std::string& endpoint_id,
|
||||
std::int64_t payload_id,
|
||||
std::int64_t chunk_size_bytes)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnOutgoingPayloadDone(
|
||||
const std::string &endpoint_id, std::int64_t payload_id,
|
||||
const std::string& endpoint_id, std::int64_t payload_id,
|
||||
location::nearby::proto::connections::PayloadStatus status,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code) ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
// BandwidthUpgrade
|
||||
void OnBandwidthUpgradeStarted(
|
||||
const std::string &endpoint_id,
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::Medium from_medium,
|
||||
location::nearby::proto::connections::Medium to_medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptDirection
|
||||
direction,
|
||||
const std::string &connection_token) ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
const std::string& connection_token) ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnBandwidthUpgradeError(
|
||||
const std::string &endpoint_id,
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::BandwidthUpgradeResult result,
|
||||
location::nearby::proto::connections::BandwidthUpgradeErrorStage
|
||||
error_stage,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code) ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
void OnBandwidthUpgradeSuccess(const std::string &endpoint_id)
|
||||
void OnBandwidthUpgradeSuccess(const std::string& endpoint_id)
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
// Error Code
|
||||
void OnErrorCode(const ErrorCodeParams ¶ms);
|
||||
void OnErrorCode(const ErrorCodeParams& params);
|
||||
|
||||
// Log the start client session event with start client session logging
|
||||
// resources setup (e.g. client_session_, started_client_session_time_)
|
||||
@@ -238,12 +235,12 @@ class AnalyticsRecorder {
|
||||
class PendingPayload {
|
||||
public:
|
||||
PendingPayload(location::nearby::proto::connections::PayloadType type,
|
||||
std::int64_t total_size_bytes, bool no_record_time_millis)
|
||||
: PendingPayload(type, total_size_bytes, no_record_time_millis,
|
||||
std::int64_t total_size_bytes)
|
||||
: PendingPayload(type, total_size_bytes,
|
||||
location::nearby::proto::connections::
|
||||
OperationResultCode::DETAIL_UNKNOWN) {}
|
||||
PendingPayload(location::nearby::proto::connections::PayloadType type,
|
||||
std::int64_t total_size_bytes, bool no_record_time_millis,
|
||||
std::int64_t total_size_bytes,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code)
|
||||
: start_time_(SystemClock::ElapsedRealtime()),
|
||||
@@ -251,8 +248,7 @@ class AnalyticsRecorder {
|
||||
total_size_bytes_(total_size_bytes),
|
||||
num_bytes_transferred_(0),
|
||||
num_chunks_(0),
|
||||
operation_result_code_(operation_result_code),
|
||||
no_record_time_millis_(no_record_time_millis) {}
|
||||
operation_result_code_(operation_result_code) {}
|
||||
~PendingPayload() = default;
|
||||
|
||||
void AddChunk(std::int64_t chunk_size_bytes);
|
||||
@@ -281,31 +277,28 @@ class AnalyticsRecorder {
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code_ = location::nearby::proto::connections::
|
||||
OperationResultCode::DETAIL_UNKNOWN;
|
||||
// For testing only.
|
||||
bool no_record_time_millis_ = false;
|
||||
};
|
||||
|
||||
class LogicalConnection {
|
||||
public:
|
||||
LogicalConnection(
|
||||
location::nearby::proto::connections::Medium initial_medium,
|
||||
const std::string &connection_token, bool no_record_time_millis)
|
||||
: no_record_time_millis_(no_record_time_millis) {
|
||||
const std::string& connection_token) {
|
||||
PhysicalConnectionEstablished(initial_medium, connection_token);
|
||||
}
|
||||
LogicalConnection(const LogicalConnection &) = delete;
|
||||
LogicalConnection(LogicalConnection &&other)
|
||||
LogicalConnection(const LogicalConnection&) = delete;
|
||||
LogicalConnection(LogicalConnection&& other)
|
||||
: current_medium_(std::move(other.current_medium_)),
|
||||
physical_connections_(std::move(other.physical_connections_)),
|
||||
incoming_payloads_(std::move(other.incoming_payloads_)),
|
||||
outgoing_payloads_(std::move(other.outgoing_payloads_)) {}
|
||||
LogicalConnection &operator=(const LogicalConnection &) = delete;
|
||||
LogicalConnection &&operator=(LogicalConnection &&) = delete;
|
||||
LogicalConnection& operator=(const LogicalConnection&) = delete;
|
||||
LogicalConnection&& operator=(LogicalConnection&&) = delete;
|
||||
~LogicalConnection() = default;
|
||||
|
||||
void PhysicalConnectionEstablished(
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
const std::string &connection_token);
|
||||
const std::string& connection_token);
|
||||
void PhysicalConnectionClosed(
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::DisconnectionReason reason,
|
||||
@@ -341,14 +334,14 @@ class AnalyticsRecorder {
|
||||
private:
|
||||
void FinishPhysicalConnection(
|
||||
location::nearby::analytics::proto::ConnectionsLog::
|
||||
EstablishedConnection *established_connection,
|
||||
EstablishedConnection* established_connection,
|
||||
location::nearby::proto::connections::DisconnectionReason reason,
|
||||
location::nearby::analytics::proto::ConnectionsLog::
|
||||
EstablishedConnection::SafeDisconnectionResult result);
|
||||
std::vector<location::nearby::analytics::proto::ConnectionsLog::Payload>
|
||||
ResolvePendingPayloads(
|
||||
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>
|
||||
&pending_payloads,
|
||||
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>&
|
||||
pending_payloads,
|
||||
location::nearby::proto::connections::DisconnectionReason reason);
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
GetPendingPayloadResultCodeFromReason(
|
||||
@@ -364,8 +357,6 @@ class AnalyticsRecorder {
|
||||
incoming_payloads_;
|
||||
absl::btree_map<std::int64_t, std::unique_ptr<PendingPayload>>
|
||||
outgoing_payloads_;
|
||||
// For testing only.
|
||||
bool no_record_time_millis_ = false;
|
||||
};
|
||||
|
||||
bool CanRecordAnalyticsLocked(absl::string_view method_name)
|
||||
@@ -388,57 +379,57 @@ class AnalyticsRecorder {
|
||||
ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void FinishDiscoveryPhaseLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
bool UpdateAdvertiserConnectionRequestLocked(
|
||||
location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest
|
||||
*request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest*
|
||||
request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
bool UpdateDiscovererConnectionRequestLocked(
|
||||
location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest
|
||||
*request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest*
|
||||
request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
bool BothEndpointsRespondedLocked(
|
||||
location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest
|
||||
*request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest*
|
||||
request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void LocalEndpointRespondedLocked(
|
||||
const std::string &remote_endpoint_id,
|
||||
const std::string& remote_endpoint_id,
|
||||
location::nearby::proto::connections::ConnectionRequestResponse response)
|
||||
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
void RemoteEndpointRespondedLocked(
|
||||
const std::string &remote_endpoint_id,
|
||||
const std::string& remote_endpoint_id,
|
||||
location::nearby::proto::connections::ConnectionRequestResponse response)
|
||||
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
void MarkConnectionRequestIgnoredLocked(
|
||||
location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest
|
||||
*request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
location::nearby::analytics::proto::ConnectionsLog::ConnectionRequest*
|
||||
request) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void OnIncomingConnectionAttemptLocked(
|
||||
location::nearby::proto::connections::ConnectionAttemptType type,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptResult result,
|
||||
absl::Duration duration, const std::string &connection_token,
|
||||
ConnectionAttemptMetadataParams *connection_attempt_metadata_params)
|
||||
absl::Duration duration, const std::string& connection_token,
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
|
||||
ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void OnOutgoingConnectionAttemptLocked(
|
||||
const std::string &remote_endpoint_id,
|
||||
const std::string& remote_endpoint_id,
|
||||
location::nearby::proto::connections::ConnectionAttemptType type,
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptResult result,
|
||||
absl::Duration duration, const std::string &connection_token,
|
||||
ConnectionAttemptMetadataParams *connection_attempt_metadata_params)
|
||||
absl::Duration duration, const std::string& connection_token,
|
||||
ConnectionAttemptMetadataParams* connection_attempt_metadata_params)
|
||||
ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
bool ConnectionAttemptResultCodeExistedLocked(
|
||||
location::nearby::proto::connections::Medium medium,
|
||||
location::nearby::proto::connections::ConnectionAttemptDirection
|
||||
direction,
|
||||
const std::string &connection_token,
|
||||
const std::string& connection_token,
|
||||
location::nearby::proto::connections::ConnectionAttemptType type,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
bool EraseIfBandwidthUpgradeRecordExistedLocked(
|
||||
const std::string &endpoint_id,
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::BandwidthUpgradeResult result,
|
||||
location::nearby::proto::connections::BandwidthUpgradeErrorStage
|
||||
error_stage,
|
||||
location::nearby::proto::connections::OperationResultCode
|
||||
operation_result_code) ABSL_SHARED_LOCKS_REQUIRED(mutex_);
|
||||
void FinishUpgradeAttemptLocked(
|
||||
const std::string &endpoint_id,
|
||||
const std::string& endpoint_id,
|
||||
location::nearby::proto::connections::BandwidthUpgradeResult result,
|
||||
location::nearby::proto::connections::BandwidthUpgradeErrorStage
|
||||
error_stage,
|
||||
@@ -449,7 +440,7 @@ class AnalyticsRecorder {
|
||||
|
||||
int GetLatestUpdateIndexLocked(
|
||||
const std::vector<location::nearby::analytics::proto::ConnectionsLog::
|
||||
OperationResultWithMedium> &list)
|
||||
OperationResultWithMedium>& list)
|
||||
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
|
||||
|
||||
location::nearby::proto::connections::ConnectionsStrategy
|
||||
@@ -459,14 +450,11 @@ class AnalyticsRecorder {
|
||||
|
||||
// Not owned by AnalyticsRecorder. Pointer must refer to a valid object
|
||||
// that outlives the one constructed.
|
||||
::nearby::analytics::EventLogger *event_logger_;
|
||||
::nearby::analytics::EventLogger* event_logger_;
|
||||
|
||||
// Protects all sub-protos reading and writing in ConnectionLog.
|
||||
Mutex mutex_;
|
||||
|
||||
// For testing only.
|
||||
bool no_record_time_millis_ = false;
|
||||
|
||||
// ClientSession
|
||||
std::unique_ptr<
|
||||
location::nearby::analytics::proto::ConnectionsLog::ClientSession>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,7 @@
|
||||
#ifndef PLATFORM_API_SYSTEM_CLOCK_H_
|
||||
#define PLATFORM_API_SYSTEM_CLOCK_H_
|
||||
|
||||
#include "absl/time/clock.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "internal/platform/exception.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#define PLATFORM_IMPL_WINDOWS_SYSTEM_CLOCK_H_
|
||||
|
||||
#include "internal/platform/implementation/system_clock.h"
|
||||
#include "absl/time/clock.h"
|
||||
#include "absl/time/time.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user