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" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/precache/precache_manager_factory.h" | 14 #include "chrome/browser/precache/precache_manager_factory.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "components/precache/content/precache_manager.h" | 17 #include "components/precache/content/precache_manager.h" |
18 #include "components/prefs/pref_service.h" | 18 #include "components/prefs/pref_service.h" |
19 #include "jni/PrecacheLauncher_jni.h" | 19 #include "jni/PrecacheLauncher_jni.h" |
20 | 20 |
21 using base::android::AttachCurrentThread; | 21 using base::android::AttachCurrentThread; |
| 22 using base::android::JavaParamRef; |
22 using precache::PrecacheManager; | 23 using precache::PrecacheManager; |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 // Get the profile that should be used for precaching. | 27 // Get the profile that should be used for precaching. |
27 Profile* GetProfile() { | 28 Profile* GetProfile() { |
28 Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile() | 29 Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile() |
29 ->GetOriginalProfile(); | 30 ->GetOriginalProfile(); |
30 DCHECK(profile); | 31 DCHECK(profile); |
31 DCHECK(g_browser_process->profile_manager()->IsValidProfile(profile)); | 32 DCHECK(g_browser_process->profile_manager()->IsValidProfile(profile)); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 static jboolean ShouldRun(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 89 static jboolean ShouldRun(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
89 Profile* profile = GetProfile(); | 90 Profile* profile = GetProfile(); |
90 PrecacheManager* precache_manager = GetPrecacheManager(profile); | 91 PrecacheManager* precache_manager = GetPrecacheManager(profile); |
91 return precache_manager && (precache_manager->IsInExperimentGroup() || | 92 return precache_manager && (precache_manager->IsInExperimentGroup() || |
92 precache_manager->IsInControlGroup()); | 93 precache_manager->IsInControlGroup()); |
93 } | 94 } |
94 | 95 |
95 bool RegisterPrecacheLauncher(JNIEnv* env) { | 96 bool RegisterPrecacheLauncher(JNIEnv* env) { |
96 return RegisterNativesImpl(env); | 97 return RegisterNativesImpl(env); |
97 } | 98 } |
OLD | NEW |