Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.ntp; | 5 package org.chromium.chrome.browser.ntp; |
| 6 | 6 |
| 7 import org.chromium.base.metrics.RecordHistogram; | 7 import org.chromium.base.metrics.RecordHistogram; |
| 8 import org.chromium.chrome.browser.ntp.LogoBridge.Logo; | 8 import org.chromium.chrome.browser.ntp.LogoBridge.Logo; |
| 9 import org.chromium.chrome.browser.ntp.LogoBridge.LogoObserver; | 9 import org.chromium.chrome.browser.ntp.LogoBridge.LogoObserver; |
| 10 import org.chromium.chrome.browser.tab.Tab; | 10 import org.chromium.chrome.browser.tab.Tab; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 private static final int CTA_IMAGE_CLICKED = 1; | 31 private static final int CTA_IMAGE_CLICKED = 1; |
| 32 private static final int ANIMATED_LOGO_CLICKED = 2; | 32 private static final int ANIMATED_LOGO_CLICKED = 2; |
| 33 | 33 |
| 34 private final Tab mTab; | 34 private final Tab mTab; |
| 35 private LogoView mLogoView; | 35 private LogoView mLogoView; |
| 36 | 36 |
| 37 private LogoBridge mLogoBridge; | 37 private LogoBridge mLogoBridge; |
| 38 private String mOnLogoClickUrl; | 38 private String mOnLogoClickUrl; |
| 39 private String mAnimatedLogoUrl; | 39 private String mAnimatedLogoUrl; |
| 40 | 40 |
| 41 private boolean mHasRecordedLoadTime; | 41 private boolean mShouldRecordLoadTime; |
|
Bernhard Bauer
2017/04/28 10:13:28
Initialize this here?
fhorschig
2017/04/28 12:36:51
Done.
Just out of curiosity: Shouldn't the code s
| |
| 42 | 42 |
| 43 private boolean mIsDestroyed; | 43 private boolean mIsDestroyed; |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * Construct a new {@link LogoDelegateImpl}. | 46 * Construct a new {@link LogoDelegateImpl}. |
| 47 * @param tab The tab showing the logo view. | 47 * @param tab The tab showing the logo view. |
| 48 * @param logoView The view that shows the search provider logo. | 48 * @param logoView The view that shows the search provider logo. |
| 49 */ | 49 */ |
| 50 public LogoDelegateImpl(Tab tab, LogoView logoView) { | 50 public LogoDelegateImpl(Tab tab, LogoView logoView) { |
| 51 mTab = tab; | 51 mTab = tab; |
| 52 mLogoView = logoView; | 52 mLogoView = logoView; |
| 53 mLogoBridge = new LogoBridge(tab.getProfile()); | 53 mLogoBridge = new LogoBridge(tab.getProfile()); |
| 54 mShouldRecordLoadTime = true; | |
| 54 } | 55 } |
| 55 | 56 |
| 56 @Override | 57 @Override |
| 57 public void destroy() { | 58 public void destroy() { |
| 58 mIsDestroyed = true; | 59 mIsDestroyed = true; |
| 59 } | 60 } |
| 60 | 61 |
| 61 @Override | 62 @Override |
| 62 public void onLogoClicked(boolean isAnimatedLogoShowing) { | 63 public void onLogoClicked(boolean isAnimatedLogoShowing) { |
| 63 if (mIsDestroyed) return; | 64 if (mIsDestroyed) return; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 87 | 88 |
| 88 LogoObserver wrapperCallback = new LogoObserver() { | 89 LogoObserver wrapperCallback = new LogoObserver() { |
| 89 @Override | 90 @Override |
| 90 public void onLogoAvailable(Logo logo, boolean fromCache) { | 91 public void onLogoAvailable(Logo logo, boolean fromCache) { |
| 91 if (mIsDestroyed) return; | 92 if (mIsDestroyed) return; |
| 92 mOnLogoClickUrl = logo != null ? logo.onClickUrl : null; | 93 mOnLogoClickUrl = logo != null ? logo.onClickUrl : null; |
| 93 mAnimatedLogoUrl = logo != null ? logo.animatedLogoUrl : null; | 94 mAnimatedLogoUrl = logo != null ? logo.animatedLogoUrl : null; |
| 94 if (logo != null) { | 95 if (logo != null) { |
| 95 RecordHistogram.recordSparseSlowlyHistogram(LOGO_SHOWN_UMA_N AME, | 96 RecordHistogram.recordSparseSlowlyHistogram(LOGO_SHOWN_UMA_N AME, |
| 96 logo.animatedLogoUrl == null ? STATIC_LOGO_SHOWN : C TA_IMAGE_SHOWN); | 97 logo.animatedLogoUrl == null ? STATIC_LOGO_SHOWN : C TA_IMAGE_SHOWN); |
| 97 if (!mHasRecordedLoadTime) { | 98 if (mShouldRecordLoadTime) { |
| 98 long loadTime = System.currentTimeMillis() - loadTimeSta rt; | 99 long loadTime = System.currentTimeMillis() - loadTimeSta rt; |
| 99 RecordHistogram.recordMediumTimesHistogram( | 100 RecordHistogram.recordMediumTimesHistogram( |
| 100 LOGO_SHOWN_TIME_UMA_NAME, loadTime, TimeUnit.MIL LISECONDS); | 101 LOGO_SHOWN_TIME_UMA_NAME, loadTime, TimeUnit.MIL LISECONDS); |
| 101 mHasRecordedLoadTime = true; | |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 // If we haven't received a logo on demand, don't wait for rando m refreshes. | |
|
tschumann
2017/04/27 11:52:08
nit: this comment implies that the first call of t
fhorschig
2017/04/27 11:55:42
It is guaranteed. Added that.
Marc Treib
2017/04/27 11:56:09
It's not really guaranteed, but it doesn't really
fhorschig
2017/04/27 12:12:20
Done. (Sorry, I updated the wrong comment before.
| |
| 105 mShouldRecordLoadTime = false; | |
| 104 logoObserver.onLogoAvailable(logo, fromCache); | 106 logoObserver.onLogoAvailable(logo, fromCache); |
| 105 } | 107 } |
| 106 }; | 108 }; |
| 107 | 109 |
| 108 mLogoBridge.getCurrentLogo(wrapperCallback); | 110 mLogoBridge.getCurrentLogo(wrapperCallback); |
| 109 } | 111 } |
| 110 } | 112 } |
| OLD | NEW |