Commit bf0c7f9f authored by Michael van Ouwerkerk's avatar Michael van Ouwerkerk Committed by Commit Bot

Register cct module lifecycle state in a synthetic field trial.

In the UMA dashboard we can use this to slice metrics like PrivateMemoryFootprint.

Bug: 882370
Change-Id: I70f07590db3ad183325ed2e4e03fbe680413c937
Reviewed-on: https://chromium-review.googlesource.com/c/1405189Reviewed-by: default avatarAnna Malova <amalova@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Commit-Queue: Michael van Ouwerkerk <mvanouwerkerk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#622056}
parent 93bac2f5
...@@ -115,6 +115,8 @@ public class ModuleLoader { ...@@ -115,6 +115,8 @@ public class ModuleLoader {
return; return;
} }
ModuleMetrics.registerLifecycleState(ModuleMetrics.LifecycleState.NOT_LOADED);
mIsModuleLoading = true; mIsModuleLoading = true;
new LoadClassTask(moduleContext).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new LoadClassTask(moduleContext).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
...@@ -199,6 +201,7 @@ public class ModuleLoader { ...@@ -199,6 +201,7 @@ public class ModuleLoader {
ModuleMetrics.recordDestruction(reason); ModuleMetrics.recordDestruction(reason);
mModuleEntryPoint.onDestroy(); mModuleEntryPoint.onDestroy();
CrashKeys.getInstance().set(CrashKeyIndex.ACTIVE_DYNAMIC_MODULE, null); CrashKeys.getInstance().set(CrashKeyIndex.ACTIVE_DYNAMIC_MODULE, null);
ModuleMetrics.registerLifecycleState(ModuleMetrics.LifecycleState.DESTROYED);
mModuleEntryPoint = null; mModuleEntryPoint = null;
mModuleUnusedTimeMs = -1; mModuleUnusedTimeMs = -1;
} }
...@@ -303,6 +306,8 @@ public class ModuleLoader { ...@@ -303,6 +306,8 @@ public class ModuleLoader {
crashKeys.set(CrashKeyIndex.LOADED_DYNAMIC_MODULE, mModuleId); crashKeys.set(CrashKeyIndex.LOADED_DYNAMIC_MODULE, mModuleId);
crashKeys.set(CrashKeyIndex.ACTIVE_DYNAMIC_MODULE, mModuleId); crashKeys.set(CrashKeyIndex.ACTIVE_DYNAMIC_MODULE, mModuleId);
ModuleMetrics.registerLifecycleState(ModuleMetrics.LifecycleState.INSTANTIATED);
long entryPointInitStartTime = ModuleMetrics.now(); long entryPointInitStartTime = ModuleMetrics.now();
entryPoint.init(moduleHost); entryPoint.init(moduleHost);
ModuleMetrics.recordEntryPointInitTime(entryPointInitStartTime); ModuleMetrics.recordEntryPointInitTime(entryPointInitStartTime);
......
...@@ -6,9 +6,11 @@ package org.chromium.chrome.browser.customtabs.dynamicmodule; ...@@ -6,9 +6,11 @@ package org.chromium.chrome.browser.customtabs.dynamicmodule;
import android.os.SystemClock; import android.os.SystemClock;
import android.support.annotation.IntDef; import android.support.annotation.IntDef;
import android.support.annotation.StringDef;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.browser.metrics.UmaSessionStats;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
...@@ -22,6 +24,11 @@ public final class ModuleMetrics { ...@@ -22,6 +24,11 @@ public final class ModuleMetrics {
private static final String TAG = "ModuleMetrics"; private static final String TAG = "ModuleMetrics";
/**
* The name of the synthetic field trial for registering the module lifecycle state.
*/
private static final String LIFECYCLE_STATE_TRIAL_NAME = "CCTModuleLifecycleState";
/** /**
* Possible results when loading a dynamic module. Keep in sync with the * Possible results when loading a dynamic module. Keep in sync with the
* CustomTabs.DynamicModule.LoadResult enum in histograms.xml. Do not remove * CustomTabs.DynamicModule.LoadResult enum in histograms.xml. Do not remove
...@@ -137,4 +144,25 @@ public final class ModuleMetrics { ...@@ -137,4 +144,25 @@ public final class ModuleMetrics {
"CustomTabs.DynamicModule.EntryPointInitTime", now() - startTime, "CustomTabs.DynamicModule.EntryPointInitTime", now() - startTime,
TimeUnit.MILLISECONDS); TimeUnit.MILLISECONDS);
} }
/**
* Possible lifecycle states for a dynamic module.
*/
@StringDef({LifecycleState.NOT_LOADED, LifecycleState.INSTANTIATED, LifecycleState.DESTROYED})
public @interface LifecycleState {
/** The module has not yet been loaded. */
String NOT_LOADED = "NotLoaded";
/** The module has been loaded and instantiated. */
String INSTANTIATED = "Instantiated";
/** The module instance has been destroyed. */
String DESTROYED = "Destroyed";
}
/**
* Registers the module lifecycle state in a synthetic field trial.
* @param state The module lifecycle state.
*/
public static void registerLifecycleState(@LifecycleState String state) {
UmaSessionStats.registerSyntheticFieldTrial(LIFECYCLE_STATE_TRIAL_NAME, state);
}
} }
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