Java Code Examples for org.chromium.base.metrics.RecordHistogram#recordTimesHistogram()
The following examples show how to use
org.chromium.base.metrics.RecordHistogram#recordTimesHistogram() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NewTabPage.java From 365browser with Apache License 2.0 | 6 votes |
@Override public void onLoadingComplete(Tile[] items) { if (mIsDestroyed) return; super.onLoadingComplete(items); long loadTimeMs = (System.nanoTime() - mConstructedTimeNs) / 1000000; RecordHistogram.recordTimesHistogram( "Tab.NewTabOnload", loadTimeMs, TimeUnit.MILLISECONDS); mIsLoaded = true; StartupMetrics.getInstance().recordOpenedNTP(); NewTabPageUma.recordNTPImpression(NewTabPageUma.NTP_IMPRESSION_REGULAR); // If not visible when loading completes, wait until onShown is received. if (!mTab.isHidden()) recordNTPShown(); if (isNtpOfflinePagesEnabled()) { final int maxNumTiles = 12; for (int i = 0; i < items.length; i++) { if (items[i].isOfflineAvailable()) { RecordHistogram.recordEnumeratedHistogram( "NewTabPage.TileOfflineAvailable", i, maxNumTiles); } } } SyncSessionsMetrics.recordYoungestForeignTabAgeOnNTP(); }
Example 2
Source File: ToolbarManager.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Handle all necessary tasks that can be delayed until initialization completes. * @param activityCreationTimeMs The time of creation for the activity this toolbar belongs to. * @param activityName Simple class name for the activity this toolbar belongs to. */ public void onDeferredStartup(final long activityCreationTimeMs, final String activityName) { // Record startup performance statistics long elapsedTime = SystemClock.elapsedRealtime() - activityCreationTimeMs; if (elapsedTime < RECORD_UMA_PERFORMANCE_METRICS_DELAY_MS) { ThreadUtils.postOnUiThreadDelayed(new Runnable() { @Override public void run() { onDeferredStartup(activityCreationTimeMs, activityName); } }, RECORD_UMA_PERFORMANCE_METRICS_DELAY_MS - elapsedTime); } RecordHistogram.recordTimesHistogram("MobileStartup.ToolbarFirstDrawTime." + activityName, mToolbar.getFirstDrawTime() - activityCreationTimeMs, TimeUnit.MILLISECONDS); long firstFocusTime = mToolbar.getLocationBar().getFirstUrlBarFocusTime(); if (firstFocusTime != 0) { RecordHistogram.recordCustomTimesHistogram( "MobileStartup.ToolbarFirstFocusTime." + activityName, firstFocusTime - activityCreationTimeMs, MIN_FOCUS_TIME_FOR_UMA_HISTOGRAM_MS, MAX_FOCUS_TIME_FOR_UMA_HISTOGRAM_MS, TimeUnit.MILLISECONDS, 50); } }
Example 3
Source File: WebappDirectoryManager.java From 365browser with Apache License 2.0 | 6 votes |
/** * Returns the directory for a web app, creating it if necessary. * @param webappId ID for the web app. Used as a subdirectory name. * @return File for storing information about the web app. */ File getWebappDirectory(Context context, String webappId) { // Temporarily allowing disk access while fixing. TODO: http://crbug.com/525781 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); try { long time = SystemClock.elapsedRealtime(); File webappDirectory = new File(getBaseWebappDirectory(context), webappId); if (!webappDirectory.exists() && !webappDirectory.mkdir()) { Log.e(TAG, "Failed to create web app directory."); } RecordHistogram.recordTimesHistogram("Android.StrictMode.WebappDir", SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS); return webappDirectory; } finally { StrictMode.setThreadPolicy(oldPolicy); } }
Example 4
Source File: WebappDirectoryManager.java From delion with Apache License 2.0 | 6 votes |
/** * Returns the directory for a web app, creating it if necessary. * @param webappId ID for the web app. Used as a subdirectory name. * @return File for storing information about the web app. */ File getWebappDirectory(Context context, String webappId) { // Temporarily allowing disk access while fixing. TODO: http://crbug.com/525781 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); StrictMode.allowThreadDiskWrites(); try { long time = SystemClock.elapsedRealtime(); File webappDirectory = new File(getBaseWebappDirectory(context), webappId); if (!webappDirectory.exists() && !webappDirectory.mkdir()) { Log.e(TAG, "Failed to create web app directory."); } RecordHistogram.recordTimesHistogram("Android.StrictMode.WebappDir", SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS); return webappDirectory; } finally { StrictMode.setThreadPolicy(oldPolicy); } }
Example 5
Source File: AccountSigninView.java From 365browser with Apache License 2.0 | 6 votes |
private void showConfirmSigninPagePreviousAccountCheck(long seedingStartTime) { RecordHistogram.recordTimesHistogram("Signin.AndroidAccountSigninViewSeedingTime", SystemClock.elapsedRealtime() - seedingStartTime, TimeUnit.MILLISECONDS); String accountName = getSelectedAccountName(); ConfirmSyncDataStateMachine.run(PrefServiceBridge.getInstance().getSyncLastAccountName(), accountName, ImportSyncType.PREVIOUS_DATA_FOUND, mDelegate.getFragmentManager(), getContext(), new ConfirmImportSyncDataDialog.Listener() { @Override public void onConfirm(boolean wipeData) { SigninManager.wipeSyncUserDataIfRequired(wipeData) .then(new Callback<Void>() { @Override public void onResult(Void v) { showConfirmSigninPage(); } }); } @Override public void onCancel() { setButtonsEnabled(true); } }); }
Example 6
Source File: ChromeActivity.java From delion with Apache License 2.0 | 6 votes |
/** * All deferred startup tasks that require the activity rather than the app should go here. */ private void onDeferredStartupForActivity() { BeamController.registerForBeam(this, new BeamProvider() { @Override public String getTabUrlForBeam() { if (isOverlayVisible()) return null; if (getActivityTab() == null) return null; return getActivityTab().getUrl(); } }); UpdateMenuItemHelper.getInstance().checkForUpdateOnBackgroundThread(this); if (mToolbarManager != null) { String simpleName = getClass().getSimpleName(); RecordHistogram.recordTimesHistogram("MobileStartup.ToolbarInflationTime." + simpleName, mInflateInitialLayoutDurationMs, TimeUnit.MILLISECONDS); mToolbarManager.onDeferredStartup(getOnCreateTimestampMs(), simpleName); } if (MultiWindowUtils.getInstance().isInMultiWindowMode(this)) { onDeferredStartupForMultiWindowMode(); } }
Example 7
Source File: WebappActivity.java From 365browser with Apache License 2.0 | 5 votes |
@Override protected void recordIntentToCreationTime(long timeMs) { super.recordIntentToCreationTime(timeMs); RecordHistogram.recordTimesHistogram( "MobileStartup.IntentToCreationTime.WebApp", timeMs, TimeUnit.MILLISECONDS); }
Example 8
Source File: WebApkActivity.java From 365browser with Apache License 2.0 | 5 votes |
@Override protected void recordIntentToCreationTime(long timeMs) { super.recordIntentToCreationTime(timeMs); RecordHistogram.recordTimesHistogram( "MobileStartup.IntentToCreationTime.WebApk", timeMs, TimeUnit.MILLISECONDS); }
Example 9
Source File: ContextualSearchUma.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Logs the duration of a Contextual Search panel being viewed by the user. * @param wereResultsSeen Whether search results were seen. * @param isChained Whether the Contextual Search ended with the start of another. * @param durationMs The duration of the contextual search in milliseconds. */ public static void logDuration(boolean wereResultsSeen, boolean isChained, long durationMs) { if (wereResultsSeen) { RecordHistogram.recordTimesHistogram("Search.ContextualSearchDurationSeen", durationMs, TimeUnit.MILLISECONDS); } else if (isChained) { RecordHistogram.recordTimesHistogram("Search.ContextualSearchDurationUnseenChained", durationMs, TimeUnit.MILLISECONDS); } else { RecordHistogram.recordTimesHistogram("Search.ContextualSearchDurationUnseen", durationMs, TimeUnit.MILLISECONDS); } }
Example 10
Source File: PhysicalWebUma.java From AndroidChromium with Apache License 2.0 | 5 votes |
private void uploadTimes(final String key, final TimeUnit tu) { String jsonTimesStr = mPrefs.getString(key, "[]"); removePref(key); Long[] times = parseJsonLongArray(jsonTimesStr); if (times == null) { Log.e(TAG, "Error reporting " + key + " with values: " + jsonTimesStr); return; } for (Long time : times) { RecordHistogram.recordTimesHistogram(key, time, TimeUnit.MILLISECONDS); } }
Example 11
Source File: PhysicalWebUma.java From 365browser with Apache License 2.0 | 5 votes |
private void uploadTimes(final String key, final TimeUnit tu) { String jsonTimesStr = mPrefs.getString(key, "[]"); removePref(key); Long[] times = parseJsonLongArray(jsonTimesStr); if (times == null) { Log.e(TAG, "Error reporting " + key + " with values: " + jsonTimesStr); return; } for (Long time : times) { RecordHistogram.recordTimesHistogram(key, time, TimeUnit.MILLISECONDS); } }
Example 12
Source File: ExternalNavigationHandler.java From delion with Apache License 2.0 | 5 votes |
/** * Determines whether the URL needs to be sent as an intent to the system, * and sends it, if appropriate. * @return Whether the URL generated an intent, caused a navigation in * current tab, or wasn't handled at all. */ public OverrideUrlLoadingResult shouldOverrideUrlLoading(ExternalNavigationParams params) { Intent intent; // Perform generic parsing of the URI to turn it into an Intent. try { intent = Intent.parseUri(params.getUrl(), Intent.URI_INTENT_SCHEME); } catch (Exception ex) { Log.w(TAG, "Bad URI %s", params.getUrl(), ex); return OverrideUrlLoadingResult.NO_OVERRIDE; } boolean hasBrowserFallbackUrl = false; String browserFallbackUrl = IntentUtils.safeGetStringExtra(intent, EXTRA_BROWSER_FALLBACK_URL); if (browserFallbackUrl != null && UrlUtilities.isValidForIntentFallbackNavigation(browserFallbackUrl)) { hasBrowserFallbackUrl = true; } else { browserFallbackUrl = null; } long time = SystemClock.elapsedRealtime(); OverrideUrlLoadingResult result = shouldOverrideUrlLoadingInternal( params, intent, hasBrowserFallbackUrl, browserFallbackUrl); RecordHistogram.recordTimesHistogram("Android.StrictMode.OverrideUrlLoadingTime", SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS); if (result == OverrideUrlLoadingResult.NO_OVERRIDE && hasBrowserFallbackUrl && (params.getRedirectHandler() == null // For instance, if this is a chained fallback URL, we ignore it. || !params.getRedirectHandler().shouldNotOverrideUrlLoading())) { return clobberCurrentTabWithFallbackUrl(browserFallbackUrl, params); } return result; }
Example 13
Source File: CustomTabActivity.java From 365browser with Apache License 2.0 | 5 votes |
@Override protected void recordIntentToCreationTime(long timeMs) { super.recordIntentToCreationTime(timeMs); RecordHistogram.recordTimesHistogram( "MobileStartup.IntentToCreationTime.CustomTabs", timeMs, TimeUnit.MILLISECONDS); }
Example 14
Source File: ContextualSearchUma.java From 365browser with Apache License 2.0 | 5 votes |
/** * Logs the duration of a Contextual Search panel being viewed by the user. * @param wereResultsSeen Whether search results were seen. * @param isChained Whether the Contextual Search ended with the start of another. * @param durationMs The duration of the contextual search in milliseconds. */ public static void logDuration(boolean wereResultsSeen, boolean isChained, long durationMs) { if (wereResultsSeen) { RecordHistogram.recordTimesHistogram("Search.ContextualSearchDurationSeen", durationMs, TimeUnit.MILLISECONDS); } else if (isChained) { RecordHistogram.recordTimesHistogram("Search.ContextualSearchDurationUnseenChained", durationMs, TimeUnit.MILLISECONDS); } else { RecordHistogram.recordTimesHistogram("Search.ContextualSearchDurationUnseen", durationMs, TimeUnit.MILLISECONDS); } }
Example 15
Source File: ExternalNavigationHandler.java From 365browser with Apache License 2.0 | 5 votes |
/** * Determines whether the URL needs to be sent as an intent to the system, * and sends it, if appropriate. * @return Whether the URL generated an intent, caused a navigation in * current tab, or wasn't handled at all. */ public OverrideUrlLoadingResult shouldOverrideUrlLoading(ExternalNavigationParams params) { if (DEBUG) Log.i(TAG, "shouldOverrideUrlLoading called on " + params.getUrl()); Intent intent; // Perform generic parsing of the URI to turn it into an Intent. try { intent = Intent.parseUri(params.getUrl(), Intent.URI_INTENT_SCHEME); } catch (Exception ex) { Log.w(TAG, "Bad URI %s", params.getUrl(), ex); return OverrideUrlLoadingResult.NO_OVERRIDE; } boolean hasBrowserFallbackUrl = false; String browserFallbackUrl = IntentUtils.safeGetStringExtra(intent, EXTRA_BROWSER_FALLBACK_URL); if (browserFallbackUrl != null && UrlUtilities.isValidForIntentFallbackNavigation(browserFallbackUrl)) { hasBrowserFallbackUrl = true; } else { browserFallbackUrl = null; } long time = SystemClock.elapsedRealtime(); OverrideUrlLoadingResult result = shouldOverrideUrlLoadingInternal( params, intent, hasBrowserFallbackUrl, browserFallbackUrl); RecordHistogram.recordTimesHistogram("Android.StrictMode.OverrideUrlLoadingTime", SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS); if (result == OverrideUrlLoadingResult.NO_OVERRIDE && hasBrowserFallbackUrl && (params.getRedirectHandler() == null // For instance, if this is a chained fallback URL, we ignore it. || !params.getRedirectHandler().shouldNotOverrideUrlLoading())) { return clobberCurrentTabWithFallbackUrl(browserFallbackUrl, params); } return result; }
Example 16
Source File: ExternalNavigationHandler.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Determines whether the URL needs to be sent as an intent to the system, * and sends it, if appropriate. * @return Whether the URL generated an intent, caused a navigation in * current tab, or wasn't handled at all. */ public OverrideUrlLoadingResult shouldOverrideUrlLoading(ExternalNavigationParams params) { Intent intent; // Perform generic parsing of the URI to turn it into an Intent. try { intent = Intent.parseUri(params.getUrl(), Intent.URI_INTENT_SCHEME); } catch (Exception ex) { Log.w(TAG, "Bad URI %s", params.getUrl(), ex); return OverrideUrlLoadingResult.NO_OVERRIDE; } boolean hasBrowserFallbackUrl = false; String browserFallbackUrl = IntentUtils.safeGetStringExtra(intent, EXTRA_BROWSER_FALLBACK_URL); if (browserFallbackUrl != null && UrlUtilities.isValidForIntentFallbackNavigation(browserFallbackUrl)) { hasBrowserFallbackUrl = true; } else { browserFallbackUrl = null; } long time = SystemClock.elapsedRealtime(); OverrideUrlLoadingResult result = shouldOverrideUrlLoadingInternal( params, intent, hasBrowserFallbackUrl, browserFallbackUrl); RecordHistogram.recordTimesHistogram("Android.StrictMode.OverrideUrlLoadingTime", SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS); if (result == OverrideUrlLoadingResult.NO_OVERRIDE && hasBrowserFallbackUrl && (params.getRedirectHandler() == null // For instance, if this is a chained fallback URL, we ignore it. || !params.getRedirectHandler().shouldNotOverrideUrlLoading())) { return clobberCurrentTabWithFallbackUrl(browserFallbackUrl, params); } return result; }
Example 17
Source File: ChromeActivity.java From 365browser with Apache License 2.0 | 4 votes |
/** * Records the time it takes from creating an intent for {@link ChromeActivity} to activity * creation, including time spent in the framework. * @param timeMs The time from creating an intent to activity creation. */ @CallSuper protected void recordIntentToCreationTime(long timeMs) { RecordHistogram.recordTimesHistogram( "MobileStartup.IntentToCreationTime", timeMs, TimeUnit.MILLISECONDS); }
Example 18
Source File: TabPersistentStore.java From delion with Apache License 2.0 | 4 votes |
private void logExecutionTime(String name, long time) { if (LibraryLoader.isInitialized()) { RecordHistogram.recordTimesHistogram("Android.StrictMode.TabPersistentStore." + name, SystemClock.uptimeMillis() - time, TimeUnit.MILLISECONDS); } }
Example 19
Source File: CustomNotificationBuilder.java From delion with Apache License 2.0 | 4 votes |
@Override public Notification build() { // A note about RemoteViews and updating notifications. When a notification is passed to the // {@code NotificationManager} with the same tag and id as a previous notification, an // in-place update will be performed. In that case, the actions of all new // {@link RemoteViews} will be applied to the views of the old notification. This is safe // for actions that overwrite old values such as setting the text of a {@code TextView}, but // care must be taken for additive actions. Especially in the case of // {@link RemoteViews#addView} the result could be to append new views below stale ones. In // that case {@link RemoteViews#removeAllViews} must be called before adding new ones. RemoteViews compactView = new RemoteViews(mContext.getPackageName(), R.layout.web_notification); RemoteViews bigView = new RemoteViews(mContext.getPackageName(), R.layout.web_notification_big); float fontScale = mContext.getResources().getConfiguration().fontScale; bigView.setInt(R.id.body, "setMaxLines", calculateMaxBodyLines(fontScale)); int scaledPadding = calculateScaledPadding(fontScale, mContext.getResources().getDisplayMetrics()); String formattedTime = ""; // Temporarily allowing disk access. TODO: Fix. See http://crbug.com/577185 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); StrictMode.allowThreadDiskWrites(); try { long time = SystemClock.elapsedRealtime(); formattedTime = DateFormat.getTimeFormat(mContext).format(new Date()); RecordHistogram.recordTimesHistogram("Android.StrictMode.NotificationUIBuildTime", SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS); } finally { StrictMode.setThreadPolicy(oldPolicy); } for (RemoteViews view : new RemoteViews[] {compactView, bigView}) { view.setTextViewText(R.id.time, formattedTime); view.setTextViewText(R.id.title, mTitle); view.setTextViewText(R.id.body, mBody); view.setTextViewText(R.id.origin, mOrigin); view.setImageViewBitmap(R.id.icon, mLargeIcon); view.setViewPadding(R.id.title, 0, scaledPadding, 0, 0); view.setViewPadding(R.id.body_container, 0, scaledPadding, 0, scaledPadding); addWorkProfileBadge(view); int smallIconId = useMaterial() ? R.id.small_icon_overlay : R.id.small_icon_footer; view.setViewVisibility(smallIconId, View.VISIBLE); if (mSmallIconBitmap != null) { view.setImageViewBitmap(smallIconId, mSmallIconBitmap); } else { view.setImageViewResource(smallIconId, mSmallIconId); } } addActionButtons(bigView); configureSettingsButton(bigView); // Note: this is not a NotificationCompat builder so be mindful of the // API level of methods you call on the builder. Notification.Builder builder = new Notification.Builder(mContext); builder.setTicker(mTickerText); builder.setContentIntent(mContentIntent); builder.setDeleteIntent(mDeleteIntent); builder.setDefaults(mDefaults); builder.setVibrate(mVibratePattern); builder.setWhen(mTimestamp); builder.setOnlyAlertOnce(!mRenotify); builder.setContent(compactView); // Some things are duplicated in the builder to ensure the notification shows correctly on // Wear devices and custom lock screens. builder.setContentTitle(mTitle); builder.setContentText(mBody); builder.setSubText(mOrigin); builder.setLargeIcon(mLargeIcon); setSmallIconOnBuilder(builder, mSmallIconId, mSmallIconBitmap); for (Action action : mActions) { addActionToBuilder(builder, action); } if (mSettingsAction != null) { addActionToBuilder(builder, mSettingsAction); } Notification notification = builder.build(); notification.bigContentView = bigView; return notification; }
Example 20
Source File: SupervisedUserContentProvider.java From 365browser with Apache License 2.0 | 4 votes |
@Override protected WebRestrictionsResult shouldProceed(String callingPackage, final String url) { // This will be called on multiple threads (but never the UI thread), // see http://developer.android.com/guide/components/processes-and-threads.html#ThreadSafe. // The reply comes back on a different thread (possibly the UI thread) some time later. // As such it needs to correctly match the replies to the calls. It does this by creating a // reply object for each query, and passing this through the callback structure. The reply // object also handles waiting for the reply. long startTimeMs = SystemClock.elapsedRealtime(); if (requestIsWhitelisted(callingPackage, url)) { return new WebRestrictionsResult(true, null, null); } final long contentProvider = getSupervisedUserContentProvider(); if (contentProvider == 0) { return new WebRestrictionsResult( false, new int[] {FilteringBehaviorReason.NOT_SIGNED_IN}, null); } final SupervisedUserQueryReply queryReply = new SupervisedUserQueryReply(); ThreadUtils.runOnUiThread(new Runnable() { @Override public void run() { nativeShouldProceed(contentProvider, queryReply, url); } }); try { // This will block until an onQueryComplete call on a different thread adds // something to the queue. WebRestrictionsResult result = queryReply.getResult(); String histogramName = mChromeAlreadyStarted ? "SupervisedUserContentProvider.ChromeStartedRequestTime" : "SupervisedUserContentProvider.ChromeNotStartedRequestTime"; RecordHistogram.recordTimesHistogram(histogramName, SystemClock.elapsedRealtime() - startTimeMs, TimeUnit.MILLISECONDS); RecordHistogram.recordBooleanHistogram( "SupervisedUserContentProvider.RequestTimedOut", result == null); if (result == null) return new WebRestrictionsResult(false, null, null); return result; } catch (InterruptedException e) { return new WebRestrictionsResult(false, null, null); } }