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

Side by Side Diff: chrome/browser/android/offline_pages/background_scheduler_bridge.cc

Issue 2572503002: [OfflinePages] Renames StartProcessing to StartScheduledProcessing (Closed)
Patch Set: Fixed junit change Created 4 years 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
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 "base/android/callback_android.h" 5 #include "base/android/callback_android.h"
6 #include "base/android/scoped_java_ref.h" 6 #include "base/android/scoped_java_ref.h"
7 #include "chrome/browser/android/offline_pages/background_scheduler_bridge.h" 7 #include "chrome/browser/android/offline_pages/background_scheduler_bridge.h"
8 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 8 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
9 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" 9 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 12 matching lines...) Expand all
23 namespace { 23 namespace {
24 24
25 // C++ callback that delegates to Java callback. 25 // C++ callback that delegates to Java callback.
26 void ProcessingDoneCallback( 26 void ProcessingDoneCallback(
27 const ScopedJavaGlobalRef<jobject>& j_callback_obj, bool result) { 27 const ScopedJavaGlobalRef<jobject>& j_callback_obj, bool result) {
28 base::android::RunCallbackAndroid(j_callback_obj, result); 28 base::android::RunCallbackAndroid(j_callback_obj, result);
29 } 29 }
30 30
31 } // namespace 31 } // namespace
32 32
33 // JNI call to start request processing. 33 // JNI call to start request processing in scheduled mode.
34 static jboolean StartProcessing(JNIEnv* env, 34 static jboolean StartScheduledProcessing(
35 const JavaParamRef<jclass>& jcaller, 35 JNIEnv* env,
36 const jboolean j_power_connected, 36 const JavaParamRef<jclass>& jcaller,
37 const jint j_battery_percentage, 37 const jboolean j_power_connected,
38 const jint j_net_connection_type, 38 const jint j_battery_percentage,
39 const JavaParamRef<jobject>& j_callback_obj) { 39 const jint j_net_connection_type,
40 const JavaParamRef<jobject>& j_callback_obj) {
40 ScopedJavaGlobalRef<jobject> j_callback_ref; 41 ScopedJavaGlobalRef<jobject> j_callback_ref;
41 j_callback_ref.Reset(env, j_callback_obj); 42 j_callback_ref.Reset(env, j_callback_obj);
42 43
43 // Lookup/create RequestCoordinator KeyedService and call StartProcessing on 44 // Lookup/create RequestCoordinator KeyedService and call
44 // it with bound j_callback_obj. 45 // StartScheduledProcessing on it with bound j_callback_obj.
45 Profile* profile = ProfileManager::GetLastUsedProfile(); 46 Profile* profile = ProfileManager::GetLastUsedProfile();
46 RequestCoordinator* coordinator = 47 RequestCoordinator* coordinator =
47 RequestCoordinatorFactory::GetInstance()-> 48 RequestCoordinatorFactory::GetInstance()->
48 GetForBrowserContext(profile); 49 GetForBrowserContext(profile);
49 DVLOG(2) << "resource_coordinator: " << coordinator; 50 DVLOG(2) << "resource_coordinator: " << coordinator;
50 DeviceConditions device_conditions( 51 DeviceConditions device_conditions(
51 j_power_connected, j_battery_percentage, 52 j_power_connected, j_battery_percentage,
52 static_cast<net::NetworkChangeNotifier::ConnectionType>( 53 static_cast<net::NetworkChangeNotifier::ConnectionType>(
53 j_net_connection_type)); 54 j_net_connection_type));
54 return coordinator->StartProcessing( 55 return coordinator->StartScheduledProcessing(
55 device_conditions, base::Bind(&ProcessingDoneCallback, j_callback_ref)); 56 device_conditions, base::Bind(&ProcessingDoneCallback, j_callback_ref));
56 } 57 }
57 58
58 void BackgroundSchedulerBridge::Schedule( 59 void BackgroundSchedulerBridge::Schedule(
59 const TriggerConditions& trigger_conditions) { 60 const TriggerConditions& trigger_conditions) {
60 JNIEnv* env = base::android::AttachCurrentThread(); 61 JNIEnv* env = base::android::AttachCurrentThread();
61 ScopedJavaLocalRef<jobject> j_conditions = 62 ScopedJavaLocalRef<jobject> j_conditions =
62 CreateTriggerConditions(env, trigger_conditions.require_power_connected, 63 CreateTriggerConditions(env, trigger_conditions.require_power_connected,
63 trigger_conditions.minimum_battery_percentage, 64 trigger_conditions.minimum_battery_percentage,
64 trigger_conditions.require_unmetered_network); 65 trigger_conditions.require_unmetered_network);
(...skipping 25 matching lines...) Expand all
90 env, require_power_connected, minimum_battery_percentage, 91 env, require_power_connected, minimum_battery_percentage,
91 require_unmetered_network); 92 require_unmetered_network);
92 } 93 }
93 94
94 bool RegisterBackgroundSchedulerBridge(JNIEnv* env) { 95 bool RegisterBackgroundSchedulerBridge(JNIEnv* env) {
95 return RegisterNativesImpl(env); 96 return RegisterNativesImpl(env);
96 } 97 }
97 98
98 } // namespace android 99 } // namespace android
99 } // namespace offline_pages 100 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698