Commit 1cd81f16 authored by Eugene But's avatar Eugene But Committed by Commit Bot

[Breadcrumbs] Improve WebStateActivatedAt logging

Use the following format:
Switch [from Tab<id>] [to Tab<id> at 0]

Old example:
Activated Tab1 for user action Tab-1 at -1

New example of the same log:
Switch to Tab1 at 0 #user-action

Do not log events unless WebState activation was
triggered by tab switch (the rest of activation reasons
are covered by other WebStateListObserver callbacks).

Bug: 1046231
Change-Id: I1c8657de6813bc62a719fed7add55211f9e6ffeb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2084151Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746919}
parent 15468aa5
...@@ -114,34 +114,24 @@ void BreadcrumbManagerBrowserAgent::WebStateActivatedAt( ...@@ -114,34 +114,24 @@ void BreadcrumbManagerBrowserAgent::WebStateActivatedAt(
web::WebState* new_web_state, web::WebState* new_web_state,
int active_index, int active_index,
int reason) { int reason) {
int old_web_state_id = -1; if (!(reason & WebStateListObserver::CHANGE_REASON_ACTIVATED)) {
return;
}
std::vector<std::string> event = {"Switch"};
if (old_web_state) { if (old_web_state) {
old_web_state_id = event.push_back(base::StringPrintf(
BreadcrumbManagerTabHelper::FromWebState(old_web_state)->GetUniqueId(); "from Tab%d", BreadcrumbManagerTabHelper::FromWebState(old_web_state)
->GetUniqueId()));
} }
int new_web_state_id = -1;
if (new_web_state) { if (new_web_state) {
new_web_state_id = event.push_back(base::StringPrintf(
BreadcrumbManagerTabHelper::FromWebState(new_web_state)->GetUniqueId(); "to Tab%d at %d",
BreadcrumbManagerTabHelper::FromWebState(new_web_state)->GetUniqueId(),
active_index));
} }
const char* change_reason_string = nullptr; LogEvent(base::JoinString(event, " "));
switch (reason) {
case WebStateListObserver::ChangeReason::CHANGE_REASON_NONE:
change_reason_string = "with";
break;
case WebStateListObserver::ChangeReason::CHANGE_REASON_REPLACED:
change_reason_string = "replaced";
break;
case WebStateListObserver::ChangeReason::CHANGE_REASON_ACTIVATED:
case WebStateListObserver::ChangeReason::CHANGE_REASON_CLOSED:
case WebStateListObserver::ChangeReason::CHANGE_REASON_INSERTED:
change_reason_string = "for user action";
break;
}
LogEvent(base::StringPrintf("Activated Tab%d %s Tab%d at %d",
old_web_state_id, change_reason_string,
new_web_state_id, active_index));
} }
void BreadcrumbManagerBrowserAgent::WillBeginBatchOperation( void BreadcrumbManagerBrowserAgent::WillBeginBatchOperation(
......
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