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

Unified Diff: chrome/browser/android/offline_pages/background_scheduler_bridge.cc

Issue 2697493002: [Offline pages] Implementation of OfflineBackgroundTask using background_task_scheduler (Closed)
Patch Set: Addressing more feedback Created 3 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/offline_pages/background_scheduler_bridge.cc
diff --git a/chrome/browser/android/offline_pages/background_scheduler_bridge.cc b/chrome/browser/android/offline_pages/background_scheduler_bridge.cc
index 41810ac56ae9c7dbeaec465750b350f34e209bbb..91e52d5bd39b2d713b1cfef9e5bf19c2f3ed816c 100644
--- a/chrome/browser/android/offline_pages/background_scheduler_bridge.cc
+++ b/chrome/browser/android/offline_pages/background_scheduler_bridge.cc
@@ -2,14 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/browser/android/offline_pages/background_scheduler_bridge.h"
#include "base/android/callback_android.h"
#include "base/android/scoped_java_ref.h"
-#include "chrome/browser/android/offline_pages/background_scheduler_bridge.h"
#include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
#include "chrome/browser/android/offline_pages/request_coordinator_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "components/offline_pages/core/background/device_conditions.h"
+#include "components/offline_pages/core/background/offliner.h"
#include "components/offline_pages/core/background/request_coordinator.h"
#include "jni/BackgroundSchedulerBridge_jni.h"
@@ -56,6 +57,19 @@ static jboolean StartScheduledProcessing(
device_conditions, base::Bind(&ProcessingDoneCallback, j_callback_ref));
}
+// JNI call to stop request processing in scheduled mode.
+static void StopScheduledProcessing(JNIEnv* env,
+ const JavaParamRef<jclass>& jcaller) {
+ Profile* profile = ProfileManager::GetLastUsedProfile();
+ RequestCoordinator* coordinator =
+ RequestCoordinatorFactory::GetInstance()->GetForBrowserContext(profile);
+ DVLOG(2) << "resource_coordinator: " << coordinator;
+ if (!coordinator)
+ return;
+ coordinator->StopProcessing(
+ Offliner::RequestStatus::BACKGROUND_SCHEDULER_CANCELED);
+}
+
BackgroundSchedulerBridge::BackgroundSchedulerBridge() = default;
BackgroundSchedulerBridge::~BackgroundSchedulerBridge() = default;

Powered by Google App Engine
This is Rietveld 408576698