| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.engagement; | 5 package org.chromium.chrome.browser.engagement; |
| 6 | 6 |
| 7 import org.chromium.base.ThreadUtils; | 7 import org.chromium.base.ThreadUtils; |
| 8 import org.chromium.base.annotations.CalledByNative; | 8 import org.chromium.base.annotations.CalledByNative; |
| 9 | 9 |
| 10 import org.chromium.chrome.browser.profiles.Profile; | 10 import org.chromium.chrome.browser.profiles.Profile; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 public double getScore(String url) { | 36 public double getScore(String url) { |
| 37 assert ThreadUtils.runningOnUiThread(); | 37 assert ThreadUtils.runningOnUiThread(); |
| 38 if (mNativePointer == 0) return 0.0; | 38 if (mNativePointer == 0) return 0.0; |
| 39 return nativeGetScore(mNativePointer, url); | 39 return nativeGetScore(mNativePointer, url); |
| 40 } | 40 } |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * Sets the provided URL to have the provided engagement score. | 43 * Sets the provided URL to have the provided engagement score. |
| 44 * Must be called on the UI thread. | 44 * Must be called on the UI thread. |
| 45 */ | 45 */ |
| 46 public void resetScoreForUrl(String url, double score) { | 46 public void resetBaseScoreForUrl(String url, double score) { |
| 47 assert ThreadUtils.runningOnUiThread(); | 47 assert ThreadUtils.runningOnUiThread(); |
| 48 if (mNativePointer == 0) return; | 48 if (mNativePointer == 0) return; |
| 49 nativeResetScoreForURL(mNativePointer, url, score); | 49 nativeResetBaseScoreForURL(mNativePointer, url, score); |
| 50 } | 50 } |
| 51 | 51 |
| 52 @CalledByNative | 52 @CalledByNative |
| 53 private static SiteEngagementService create(long nativePointer) { | 53 private static SiteEngagementService create(long nativePointer) { |
| 54 return new SiteEngagementService(nativePointer); | 54 return new SiteEngagementService(nativePointer); |
| 55 } | 55 } |
| 56 | 56 |
| 57 /** This object may only be created via the static getForProfile method. */ | 57 /** This object may only be created via the static getForProfile method. */ |
| 58 private SiteEngagementService(long nativePointer) { | 58 private SiteEngagementService(long nativePointer) { |
| 59 mNativePointer = nativePointer; | 59 mNativePointer = nativePointer; |
| 60 } | 60 } |
| 61 | 61 |
| 62 @CalledByNative | 62 @CalledByNative |
| 63 private void onNativeDestroyed() { | 63 private void onNativeDestroyed() { |
| 64 mNativePointer = 0; | 64 mNativePointer = 0; |
| 65 } | 65 } |
| 66 | 66 |
| 67 private static native SiteEngagementService nativeSiteEngagementServiceForPr
ofile( | 67 private static native SiteEngagementService nativeSiteEngagementServiceForPr
ofile( |
| 68 Profile profile); | 68 Profile profile); |
| 69 private native double nativeGetScore(long nativeSiteEngagementServiceAndroid
, String url); | 69 private native double nativeGetScore(long nativeSiteEngagementServiceAndroid
, String url); |
| 70 private native void nativeResetScoreForURL( | 70 private native void nativeResetBaseScoreForURL( |
| 71 long nativeSiteEngagementServiceAndroid, String url, double score); | 71 long nativeSiteEngagementServiceAndroid, String url, double score); |
| 72 } | 72 } |
| OLD | NEW |