| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/android/precache/precache_launcher.h" | 5 #include "chrome/browser/android/precache/precache_launcher.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_weak_ref.h" | 10 #include "base/android/jni_weak_ref.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 void PrecacheLauncher::Cancel(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 70 void PrecacheLauncher::Cancel(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 71 Profile* profile = GetProfile(); | 71 Profile* profile = GetProfile(); |
| 72 PrecacheManager* precache_manager = GetPrecacheManager(profile); | 72 PrecacheManager* precache_manager = GetPrecacheManager(profile); |
| 73 | 73 |
| 74 precache_manager->CancelPrecaching(); | 74 precache_manager->CancelPrecaching(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void PrecacheLauncher::OnPrecacheCompleted(bool try_again_soon) { | 77 void PrecacheLauncher::OnPrecacheCompleted(bool try_again_soon) { |
| 78 JNIEnv* env = AttachCurrentThread(); | 78 JNIEnv* env = AttachCurrentThread(); |
| 79 Java_PrecacheLauncher_onPrecacheCompletedCallback( | 79 Java_PrecacheLauncher_onPrecacheCompletedCallback( |
| 80 env, weak_java_precache_launcher_.get(env).obj(), | 80 env, weak_java_precache_launcher_.get(env), |
| 81 try_again_soon ? JNI_TRUE : JNI_FALSE); | 81 try_again_soon ? JNI_TRUE : JNI_FALSE); |
| 82 } | 82 } |
| 83 | 83 |
| 84 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 84 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 85 return reinterpret_cast<intptr_t>(new PrecacheLauncher(env, obj)); | 85 return reinterpret_cast<intptr_t>(new PrecacheLauncher(env, obj)); |
| 86 } | 86 } |
| 87 | 87 |
| 88 // Must be run on the UI thread. | 88 // Must be run on the UI thread. |
| 89 static jboolean ShouldRun(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 89 static jboolean ShouldRun(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 90 Profile* profile = GetProfile(); | 90 Profile* profile = GetProfile(); |
| 91 PrecacheManager* precache_manager = GetPrecacheManager(profile); | 91 PrecacheManager* precache_manager = GetPrecacheManager(profile); |
| 92 return precache_manager && (precache_manager->IsInExperimentGroup() || | 92 return precache_manager && (precache_manager->IsInExperimentGroup() || |
| 93 precache_manager->IsInControlGroup()); | 93 precache_manager->IsInControlGroup()); |
| 94 } | 94 } |
| 95 | 95 |
| 96 bool RegisterPrecacheLauncher(JNIEnv* env) { | 96 bool RegisterPrecacheLauncher(JNIEnv* env) { |
| 97 return RegisterNativesImpl(env); | 97 return RegisterNativesImpl(env); |
| 98 } | 98 } |
| OLD | NEW |