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 #include "chrome/browser/android/offline_pages/evaluation/offline_page_evaluatio n_bridge.h" | 5 #include "chrome/browser/android/offline_pages/evaluation/offline_page_evaluatio n_bridge.h" |
6 | 6 |
7 #include "base/android/callback_android.h" | 7 #include "base/android/callback_android.h" |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
40 using base::android::ConvertJavaStringToUTF8; | 40 using base::android::ConvertJavaStringToUTF8; |
41 using base::android::ConvertUTF8ToJavaString; | 41 using base::android::ConvertUTF8ToJavaString; |
42 using base::android::JavaParamRef; | 42 using base::android::JavaParamRef; |
43 using base::android::ScopedJavaGlobalRef; | 43 using base::android::ScopedJavaGlobalRef; |
44 using base::android::ScopedJavaLocalRef; | 44 using base::android::ScopedJavaLocalRef; |
45 | 45 |
46 namespace offline_pages { | 46 namespace offline_pages { |
47 namespace android { | 47 namespace android { |
48 | 48 |
49 namespace { | 49 namespace { |
50 const bool kPreferUntriedRequest = false; | |
51 const bool kPreferEarlierRequest = true; | |
52 const bool kPreferRetryCountOverRecency = false; | |
53 const int kMaxStartedTries = 4; | |
54 const int kMaxCompletedTries = 1; | |
55 const int kImmediateRequestExpirationTimeInSeconds = 3600; | 50 const int kImmediateRequestExpirationTimeInSeconds = 3600; |
56 | 51 |
57 void ToJavaOfflinePageList(JNIEnv* env, | 52 void ToJavaOfflinePageList(JNIEnv* env, |
58 jobject j_result_obj, | 53 jobject j_result_obj, |
59 const std::vector<OfflinePageItem>& offline_pages) { | 54 const std::vector<OfflinePageItem>& offline_pages) { |
60 for (const OfflinePageItem& offline_page : offline_pages) { | 55 for (const OfflinePageItem& offline_page : offline_pages) { |
61 Java_OfflinePageEvaluationBridge_createOfflinePageAndAddToList( | 56 Java_OfflinePageEvaluationBridge_createOfflinePageAndAddToList( |
62 env, j_result_obj, | 57 env, j_result_obj, |
63 ConvertUTF8ToJavaString(env, offline_page.url.spec()), | 58 ConvertUTF8ToJavaString(env, offline_page.url.spec()), |
64 offline_page.offline_id, | 59 offline_page.offline_id, |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 bool OfflinePageEvaluationBridge::Register(JNIEnv* env) { | 160 bool OfflinePageEvaluationBridge::Register(JNIEnv* env) { |
166 return RegisterNativesImpl(env); | 161 return RegisterNativesImpl(env); |
167 } | 162 } |
168 | 163 |
169 // static | 164 // static |
170 std::unique_ptr<KeyedService> | 165 std::unique_ptr<KeyedService> |
171 OfflinePageEvaluationBridge::GetTestingRequestCoordinator( | 166 OfflinePageEvaluationBridge::GetTestingRequestCoordinator( |
172 content::BrowserContext* context) { | 167 content::BrowserContext* context) { |
173 // Create a new OfflinerPolicy with a larger background processing | 168 // Create a new OfflinerPolicy with a larger background processing |
174 // budget (3600 sec). Other values are the same with default ones. | 169 // budget (3600 sec). Other values are the same with default ones. |
170 OfflinerPolicy default_policy; | |
175 std::unique_ptr<OfflinerPolicy> policy(new OfflinerPolicy( | 171 std::unique_ptr<OfflinerPolicy> policy(new OfflinerPolicy( |
176 kPreferUntriedRequest, kPreferEarlierRequest, | 172 default_policy.ShouldPreferUntriedRequests(), |
177 kPreferRetryCountOverRecency, kMaxStartedTries, kMaxCompletedTries, | 173 default_policy.ShouldPreferEarlierRequests(), |
174 default_policy.RetryCountIsMoreImportantThanRecency(), | |
175 default_policy.GetMaxStartedTries(), | |
176 default_policy.GetMaxCompletedTries(), | |
178 kImmediateRequestExpirationTimeInSeconds)); | 177 kImmediateRequestExpirationTimeInSeconds)); |
dougarnett
2016/11/16 20:16:42
I was confused by this name - consider something l
| |
179 std::unique_ptr<OfflinerFactory> prerenderer_offliner( | 178 std::unique_ptr<OfflinerFactory> prerenderer_offliner( |
180 new PrerenderingOfflinerFactory(context)); | 179 new PrerenderingOfflinerFactory(context)); |
181 | 180 |
182 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | 181 scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
183 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 182 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
184 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); | 183 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); |
185 Profile* profile = Profile::FromBrowserContext(context); | 184 Profile* profile = Profile::FromBrowserContext(context); |
186 base::FilePath queue_store_path = | 185 base::FilePath queue_store_path = |
187 profile->GetPath().Append(chrome::kOfflinePageRequestQueueDirname); | 186 profile->GetPath().Append(chrome::kOfflinePageRequestQueueDirname); |
188 | 187 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 | 338 |
340 void OfflinePageEvaluationBridge::NotifyIfDoneLoading() const { | 339 void OfflinePageEvaluationBridge::NotifyIfDoneLoading() const { |
341 if (!offline_page_model_->is_loaded()) | 340 if (!offline_page_model_->is_loaded()) |
342 return; | 341 return; |
343 JNIEnv* env = base::android::AttachCurrentThread(); | 342 JNIEnv* env = base::android::AttachCurrentThread(); |
344 Java_OfflinePageEvaluationBridge_offlinePageModelLoaded(env, java_ref_); | 343 Java_OfflinePageEvaluationBridge_offlinePageModelLoaded(env, java_ref_); |
345 } | 344 } |
346 | 345 |
347 } // namespace android | 346 } // namespace android |
348 } // namespace offline_pages | 347 } // namespace offline_pages |
OLD | NEW |