Commit 6d4924e4 authored by Stephane Zermatten's avatar Stephane Zermatten Committed by Commit Bot

Avoid polluting AA's Dropout metrics when direct actions are used.

AA Dropout metrics don't make much sense when direct actions are used to
trigger scripts.

This change turns them off in a way that keeps the guarantee that
dropouts are tracked if and only if AA_START was recorded, which is done
in the Facade, just before calling Start. In other cases, dropouts are
not measured yet. There should be some separate metrics for tracking
scripts started by direct actions.

Bug: b/138288747
Change-Id: If6792b6173983a289ce08978d52d68bd3c161dfa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1715693
Auto-Submit: Stephane Zermatten <szermatt@chromium.org>
Reviewed-by: default avatarClemens Arbesser <arbesser@google.com>
Commit-Queue: Clemens Arbesser <arbesser@google.com>
Cr-Commit-Position: refs/heads/master@{#680464}
parent 4f1286eb
......@@ -109,7 +109,7 @@ ClientAndroid::ClientAndroid(content::WebContents* web_contents)
}
ClientAndroid::~ClientAndroid() {
if (controller_ != nullptr) {
if (controller_ != nullptr && started_) {
// In the case of an unexpected closing of the activity or tab, controller_
// will not yet have been cleaned up (since that happens when a web
// contents object gets destroyed).
......@@ -131,6 +131,11 @@ bool ClientAndroid::Start(JNIEnv* env,
const JavaParamRef<jobjectArray>& parameter_values,
const JavaParamRef<jobject>& joverlay_coordinator,
jlong jservice) {
// When Start() is called, AA_START should have been measured. From now on,
// the client is responsible for keeping track of dropouts, so that for each
// AA_START there's a corresponding dropout.
started_ = true;
std::unique_ptr<Service> service = nullptr;
if (jservice) {
service.reset(static_cast<Service*>(reinterpret_cast<void*>(jservice)));
......@@ -377,7 +382,8 @@ void ClientAndroid::Shutdown(Metrics::DropOutReason reason) {
if (ui_controller_android_ && ui_controller_android_->IsAttached())
DestroyUI();
Metrics::RecordDropOut(reason);
if (started_)
Metrics::RecordDropOut(reason);
// Delete the controller in a separate task. This avoids tricky ordering
// issues when Shutdown is called from the controller.
......@@ -413,6 +419,7 @@ void ClientAndroid::CreateController(std::unique_ptr<Service> service) {
void ClientAndroid::DestroyController() {
controller_.reset();
started_ = false;
}
bool ClientAndroid::NeedsUI() {
......
......@@ -117,6 +117,9 @@ class ClientAndroid : public Client,
base::android::ScopedJavaGlobalRef<jobject> java_object_;
std::unique_ptr<Controller> controller_;
// True if Start() was called. This turns on the tracking of dropouts.
bool started_ = false;
std::unique_ptr<UiControllerAndroid> ui_controller_android_;
base::OnceCallback<void(bool, const std::string&)>
......
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