Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(836)

Side by Side Diff: chrome/browser/android/offline_pages/evaluation/offline_page_evaluation_bridge.cc

Issue 2506103002: [Offline Pages] Fix test harness not using default policy. (Closed)
Patch Set: Removing useless customized budget. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
56 50
57 void ToJavaOfflinePageList(JNIEnv* env, 51 void ToJavaOfflinePageList(JNIEnv* env,
58 jobject j_result_obj, 52 jobject j_result_obj,
59 const std::vector<OfflinePageItem>& offline_pages) { 53 const std::vector<OfflinePageItem>& offline_pages) {
60 for (const OfflinePageItem& offline_page : offline_pages) { 54 for (const OfflinePageItem& offline_page : offline_pages) {
61 Java_OfflinePageEvaluationBridge_createOfflinePageAndAddToList( 55 Java_OfflinePageEvaluationBridge_createOfflinePageAndAddToList(
62 env, j_result_obj, 56 env, j_result_obj,
63 ConvertUTF8ToJavaString(env, offline_page.url.spec()), 57 ConvertUTF8ToJavaString(env, offline_page.url.spec()),
64 offline_page.offline_id, 58 offline_page.offline_id,
65 ConvertUTF8ToJavaString(env, offline_page.client_id.name_space), 59 ConvertUTF8ToJavaString(env, offline_page.client_id.name_space),
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 157
164 // static 158 // static
165 bool OfflinePageEvaluationBridge::Register(JNIEnv* env) { 159 bool OfflinePageEvaluationBridge::Register(JNIEnv* env) {
166 return RegisterNativesImpl(env); 160 return RegisterNativesImpl(env);
167 } 161 }
168 162
169 // static 163 // static
170 std::unique_ptr<KeyedService> 164 std::unique_ptr<KeyedService>
171 OfflinePageEvaluationBridge::GetTestingRequestCoordinator( 165 OfflinePageEvaluationBridge::GetTestingRequestCoordinator(
172 content::BrowserContext* context) { 166 content::BrowserContext* context) {
173 // Create a new OfflinerPolicy with a larger background processing 167 std::unique_ptr<OfflinerPolicy> policy(new OfflinerPolicy());
174 // budget (3600 sec). Other values are the same with default ones.
175 std::unique_ptr<OfflinerPolicy> policy(new OfflinerPolicy(
176 kPreferUntriedRequest, kPreferEarlierRequest,
177 kPreferRetryCountOverRecency, kMaxStartedTries, kMaxCompletedTries,
178 kImmediateRequestExpirationTimeInSeconds));
179 std::unique_ptr<OfflinerFactory> prerenderer_offliner( 168 std::unique_ptr<OfflinerFactory> prerenderer_offliner(
180 new PrerenderingOfflinerFactory(context)); 169 new PrerenderingOfflinerFactory(context));
181 170
182 scoped_refptr<base::SequencedTaskRunner> background_task_runner = 171 scoped_refptr<base::SequencedTaskRunner> background_task_runner =
183 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( 172 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(
184 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); 173 content::BrowserThread::GetBlockingPool()->GetSequenceToken());
185 Profile* profile = Profile::FromBrowserContext(context); 174 Profile* profile = Profile::FromBrowserContext(context);
186 base::FilePath queue_store_path = 175 base::FilePath queue_store_path =
187 profile->GetPath().Append(chrome::kOfflinePageRequestQueueDirname); 176 profile->GetPath().Append(chrome::kOfflinePageRequestQueueDirname);
188 177
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 328
340 void OfflinePageEvaluationBridge::NotifyIfDoneLoading() const { 329 void OfflinePageEvaluationBridge::NotifyIfDoneLoading() const {
341 if (!offline_page_model_->is_loaded()) 330 if (!offline_page_model_->is_loaded())
342 return; 331 return;
343 JNIEnv* env = base::android::AttachCurrentThread(); 332 JNIEnv* env = base::android::AttachCurrentThread();
344 Java_OfflinePageEvaluationBridge_offlinePageModelLoaded(env, java_ref_); 333 Java_OfflinePageEvaluationBridge_offlinePageModelLoaded(env, java_ref_);
345 } 334 }
346 335
347 } // namespace android 336 } // namespace android
348 } // namespace offline_pages 337 } // namespace offline_pages
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698