HttpStreamPool: Add InFlightAttempt::GetInfoAsValue()
To shorten AttemptManager::GetInfoAsValue() and include more information. Also check `start_time_` is valid because there is no guarantee that Start() is already called. Bug: 346835898 Change-Id: I8a9c15deb9b1b76f9249092579fe7c081f02a1de Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6075643 Commit-Queue: Kenichi Ishibashi <bashi@chromium.org> Reviewed-by: mmenke <mmenke@chromium.org> Cr-Commit-Position: refs/heads/main@{#1395185}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
1013f3c6b5
commit
f29c41bada
@ -138,12 +138,36 @@ class HttpStreamPool::AttemptManager::InFlightAttempt
|
||||
return manager_->GetSSLConfig(this);
|
||||
}
|
||||
|
||||
bool IsWaitingSSLConfig() { return !ssl_config_waiting_callback_.is_null(); }
|
||||
bool IsWaitingSSLConfig() const {
|
||||
return !ssl_config_waiting_callback_.is_null();
|
||||
}
|
||||
|
||||
CompletionOnceCallback TakeSSLConfigWaitingCallback() {
|
||||
return std::move(ssl_config_waiting_callback_);
|
||||
}
|
||||
|
||||
base::Value::Dict GetInfoAsValue() const {
|
||||
base::Value::Dict dict;
|
||||
if (attempt_) {
|
||||
dict.Set("attempt_state", attempt_->GetInfoAsValue());
|
||||
dict.Set("ip_endpoint", attempt_->ip_endpoint().ToString());
|
||||
}
|
||||
dict.Set("is_slow", is_slow_);
|
||||
dict.Set("is_aborted", is_aborted_);
|
||||
dict.Set("started", !start_time_.is_null());
|
||||
if (!start_time_.is_null()) {
|
||||
base::TimeDelta elapsed = base::TimeTicks::Now() - start_time_;
|
||||
dict.Set("elapsed_ms", static_cast<int>(elapsed.InMilliseconds()));
|
||||
}
|
||||
if (result_.has_value()) {
|
||||
dict.Set("result", *result_);
|
||||
}
|
||||
if (cancel_reason_.has_value()) {
|
||||
dict.Set("cancel_reason", static_cast<int>(*cancel_reason_));
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
private:
|
||||
const raw_ptr<AttemptManager> manager_;
|
||||
std::unique_ptr<StreamAttempt> attempt_;
|
||||
@ -153,7 +177,10 @@ class HttpStreamPool::AttemptManager::InFlightAttempt
|
||||
// Timer to start a next attempt. When fired, `this` is treated as a slow
|
||||
// attempt but `this` is not timed out yet.
|
||||
base::OneShotTimer slow_timer_;
|
||||
// Set to true when `slow_timer_` is fired. See the comment of `slow_timer_`.
|
||||
bool is_slow_ = false;
|
||||
// Set to true when `this` and `attempt_` should abort. Currently used to
|
||||
// handle ECH failure.
|
||||
bool is_aborted_ = false;
|
||||
CompletionOnceCallback ssl_config_waiting_callback_;
|
||||
};
|
||||
@ -728,19 +755,7 @@ base::Value::Dict HttpStreamPool::AttemptManager::GetInfoAsValue() {
|
||||
if (entry->IsWaitingSSLConfig()) {
|
||||
++ssl_config_num_waiting_callbacks;
|
||||
}
|
||||
|
||||
base::Value::Dict attempt_dict;
|
||||
if (entry->attempt()) {
|
||||
attempt_dict.Set("attempt_state", entry->attempt()->GetInfoAsValue());
|
||||
attempt_dict.Set("ip_endpoint",
|
||||
entry->attempt()->ip_endpoint().ToString());
|
||||
}
|
||||
attempt_dict.Set("is_slow", entry->is_slow());
|
||||
attempt_dict.Set("is_aborted", entry->is_aborted());
|
||||
base::TimeDelta elapsed = base::TimeTicks::Now() - entry->start_time();
|
||||
attempt_dict.Set("elapsed_ms",
|
||||
static_cast<int>(elapsed.InMilliseconds()));
|
||||
in_flight_attempts.Append(std::move(attempt_dict));
|
||||
in_flight_attempts.Append(entry->GetInfoAsValue());
|
||||
}
|
||||
dict.Set("in_flight_attempts", std::move(in_flight_attempts));
|
||||
}
|
||||
|
Reference in New Issue
Block a user