Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java

Issue 2847263003: Add tests to make sure closed CCT activities are not leaked. (Closed)
Patch Set: Revert debugging Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java
index 411f44b825cdbaa06ac749306e49aceb50b9b693..c63bd7d7f7aa65ebad23244c42ea2247bd614732 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java
@@ -172,6 +172,8 @@ public class ToolbarManager implements ToolbarTabController, UrlFocusChangeListe
private boolean mShouldUpdateTabCount = true;
private boolean mShouldUpdateToolbarPrimaryColor = true;
+ private Runnable mDeferredStartupRunnable;
+
/**
* Creates a ToolbarManager object.
*
@@ -822,6 +824,12 @@ public class ToolbarManager implements ToolbarTabController, UrlFocusChangeListe
if (currentTab != null) currentTab.removeObserver(mTabObserver);
mFindToolbarObservers.clear();
mToolbar.destroy();
+ if (mDeferredStartupRunnable != null) {
+ // Run the runnable now, because there won't be any new data in the future.
+ ThreadUtils.getUiThreadHandler().removeCallbacks(mDeferredStartupRunnable);
+ mDeferredStartupRunnable.run();
+ mDeferredStartupRunnable = null;
+ }
}
/**
@@ -1120,13 +1128,17 @@ public class ToolbarManager implements ToolbarTabController, UrlFocusChangeListe
final String activityName) {
// Record startup performance statistics
long elapsedTime = SystemClock.elapsedRealtime() - activityCreationTimeMs;
- if (elapsedTime < RECORD_UMA_PERFORMANCE_METRICS_DELAY_MS) {
- ThreadUtils.postOnUiThreadDelayed(new Runnable() {
+ if (elapsedTime < RECORD_UMA_PERFORMANCE_METRICS_DELAY_MS
+ && mDeferredStartupRunnable == null) {
+ mDeferredStartupRunnable = new Runnable() {
@Override
public void run() {
onDeferredStartup(activityCreationTimeMs, activityName);
+ mDeferredStartupRunnable = null;
}
- }, RECORD_UMA_PERFORMANCE_METRICS_DELAY_MS - elapsedTime);
+ };
+ ThreadUtils.postOnUiThreadDelayed(mDeferredStartupRunnable,
+ RECORD_UMA_PERFORMANCE_METRICS_DELAY_MS - elapsedTime);
}
RecordHistogram.recordTimesHistogram("MobileStartup.ToolbarFirstDrawTime." + activityName,
mToolbar.getFirstDrawTime() - activityCreationTimeMs, TimeUnit.MILLISECONDS);

Powered by Google App Engine
This is Rietveld 408576698