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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/DeferredStartupHandler.java

Issue 2380133002: Show search engine promo dialog for special locale (Closed)
Patch Set: maria's comment Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser; 5 package org.chromium.chrome.browser;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.Intent; 8 import android.content.Intent;
9 import android.content.SharedPreferences; 9 import android.content.SharedPreferences;
10 import android.content.pm.ResolveInfo; 10 import android.content.pm.ResolveInfo;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 private static class Holder { 70 private static class Holder {
71 private static final DeferredStartupHandler INSTANCE = new DeferredStart upHandler(); 71 private static final DeferredStartupHandler INSTANCE = new DeferredStart upHandler();
72 } 72 }
73 73
74 private boolean mDeferredStartupInitializedForApp; 74 private boolean mDeferredStartupInitializedForApp;
75 private boolean mDeferredStartupCompletedForApp; 75 private boolean mDeferredStartupCompletedForApp;
76 private long mDeferredStartupDuration; 76 private long mDeferredStartupDuration;
77 private long mMaxTaskDuration; 77 private long mMaxTaskDuration;
78 private final Context mAppContext; 78 private final Context mAppContext;
79 private final LocaleManager mLocaleManager;
80 79
81 private final Queue<Runnable> mDeferredTasks; 80 private final Queue<Runnable> mDeferredTasks;
82 81
83 /** 82 /**
84 * This class is an application specific object that handles the deferred st artup. 83 * This class is an application specific object that handles the deferred st artup.
85 * @return The singleton instance of {@link DeferredStartupHandler}. 84 * @return The singleton instance of {@link DeferredStartupHandler}.
86 */ 85 */
87 public static DeferredStartupHandler getInstance() { 86 public static DeferredStartupHandler getInstance() {
88 return Holder.INSTANCE; 87 return Holder.INSTANCE;
89 } 88 }
90 89
91 private DeferredStartupHandler() { 90 private DeferredStartupHandler() {
92 mAppContext = ContextUtils.getApplicationContext(); 91 mAppContext = ContextUtils.getApplicationContext();
93 mDeferredTasks = new LinkedList<>(); 92 mDeferredTasks = new LinkedList<>();
94 mLocaleManager = ((ChromeApplication) mAppContext).createLocaleManager() ;
95 } 93 }
96 94
97 /** 95 /**
98 * Add the idle handler which will run deferred startup tasks in sequence wh en idle. This can 96 * Add the idle handler which will run deferred startup tasks in sequence wh en idle. This can
99 * be called multiple times by different activities to schedule their own de ferred startup 97 * be called multiple times by different activities to schedule their own de ferred startup
100 * tasks. 98 * tasks.
101 */ 99 */
102 public void queueDeferredTasksOnIdleHandler() { 100 public void queueDeferredTasksOnIdleHandler() {
103 mMaxTaskDuration = 0; 101 mMaxTaskDuration = 0;
104 mDeferredStartupDuration = 0; 102 mDeferredStartupDuration = 0;
(...skipping 26 matching lines...) Expand all
131 mDeferredStartupDuration, 129 mDeferredStartupDuration,
132 TimeUnit.MILLISECONDS); 130 TimeUnit.MILLISECONDS);
133 RecordHistogram.recordLongTimesHistogram( 131 RecordHistogram.recordLongTimesHistogram(
134 "UMA.Debug.EnableCrashUpload.DeferredStartUpMaxTaskDuration", 132 "UMA.Debug.EnableCrashUpload.DeferredStartUpMaxTaskDuration",
135 mMaxTaskDuration, 133 mMaxTaskDuration,
136 TimeUnit.MILLISECONDS); 134 TimeUnit.MILLISECONDS);
137 RecordHistogram.recordLongTimesHistogram( 135 RecordHistogram.recordLongTimesHistogram(
138 "UMA.Debug.EnableCrashUpload.DeferredStartUpCompleteTime", 136 "UMA.Debug.EnableCrashUpload.DeferredStartUpCompleteTime",
139 SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime(), 137 SystemClock.uptimeMillis() - UmaUtils.getForegroundStartTime(),
140 TimeUnit.MILLISECONDS); 138 TimeUnit.MILLISECONDS);
141 mLocaleManager.recordStartupMetrics(); 139 LocaleManager.getInstance().recordStartupMetrics();
142 } 140 }
143 141
144 /** 142 /**
145 * Adds a single deferred task to the queue. The caller is responsible for c alling 143 * Adds a single deferred task to the queue. The caller is responsible for c alling
146 * queueDeferredTasksOnIdleHandler after adding tasks. 144 * queueDeferredTasksOnIdleHandler after adding tasks.
147 * 145 *
148 * @param deferredTask The tasks to be run. 146 * @param deferredTask The tasks to be run.
149 */ 147 */
150 public void addDeferredTask(Runnable deferredTask) { 148 public void addDeferredTask(Runnable deferredTask) {
151 ThreadUtils.assertOnUiThread(); 149 ThreadUtils.assertOnUiThread();
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 354 }
357 355
358 /** 356 /**
359 * @return Whether deferred startup has been completed. 357 * @return Whether deferred startup has been completed.
360 */ 358 */
361 @VisibleForTesting 359 @VisibleForTesting
362 public boolean isDeferredStartupCompleteForApp() { 360 public boolean isDeferredStartupCompleteForApp() {
363 return mDeferredStartupCompletedForApp; 361 return mDeferredStartupCompletedForApp;
364 } 362 }
365 } 363 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698