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

Side by Side Diff: chrome/browser/android/offline_pages/prefetch/prefetch_background_task.cc

Issue 2879013002: Create skeleton for the Prefetching store and initial pipeline step. (Closed)
Patch Set: Made construction params a cost&. Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/offline_pages/prefetch/prefetch_service_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/prefetch/prefetch_background_task .h" 5 #include "chrome/browser/android/offline_pages/prefetch/prefetch_background_task .h"
6 6
7 #include "chrome/browser/offline_pages/prefetch/prefetch_service_factory.h" 7 #include "chrome/browser/offline_pages/prefetch/prefetch_service_factory.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/profiles/profile_android.h" 9 #include "chrome/browser/profiles/profile_android.h"
10 #include "components/offline_pages/core/prefetch/prefetch_service.h" 10 #include "components/offline_pages/core/prefetch/prefetch_service.h"
(...skipping 12 matching lines...) Expand all
23 const JavaParamRef<jobject>& jcaller, 23 const JavaParamRef<jobject>& jcaller,
24 const JavaParamRef<jobject>& jprofile) { 24 const JavaParamRef<jobject>& jprofile) {
25 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile); 25 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile);
26 DCHECK(profile); 26 DCHECK(profile);
27 27
28 PrefetchService* prefetch_service = 28 PrefetchService* prefetch_service =
29 PrefetchServiceFactory::GetForBrowserContext(profile); 29 PrefetchServiceFactory::GetForBrowserContext(profile);
30 if (!prefetch_service) 30 if (!prefetch_service)
31 return false; 31 return false;
32 32
33 prefetch_service->GetDispatcher()->BeginBackgroundTask( 33 prefetch_service->GetPrefetchDispatcher()->BeginBackgroundTask(
34 base::MakeUnique<PrefetchBackgroundTask>(env, jcaller, prefetch_service)); 34 base::MakeUnique<PrefetchBackgroundTask>(env, jcaller, prefetch_service));
35 return true; 35 return true;
36 } 36 }
37 37
38 } // namespace prefetch 38 } // namespace prefetch
39 39
40 // static 40 // static
41 void PrefetchBackgroundTask::Schedule() { 41 void PrefetchBackgroundTask::Schedule() {
42 JNIEnv* env = base::android::AttachCurrentThread(); 42 JNIEnv* env = base::android::AttachCurrentThread();
43 return prefetch::Java_PrefetchBackgroundTask_scheduleTask(env); 43 return prefetch::Java_PrefetchBackgroundTask_scheduleTask(env);
(...skipping 18 matching lines...) Expand all
62 62
63 PrefetchBackgroundTask::~PrefetchBackgroundTask() { 63 PrefetchBackgroundTask::~PrefetchBackgroundTask() {
64 JNIEnv* env = base::android::AttachCurrentThread(); 64 JNIEnv* env = base::android::AttachCurrentThread();
65 prefetch::Java_PrefetchBackgroundTask_doneProcessing( 65 prefetch::Java_PrefetchBackgroundTask_doneProcessing(
66 env, java_prefetch_background_task_.obj(), needs_reschedule_); 66 env, java_prefetch_background_task_.obj(), needs_reschedule_);
67 } 67 }
68 68
69 bool PrefetchBackgroundTask::OnStopTask(JNIEnv* env, 69 bool PrefetchBackgroundTask::OnStopTask(JNIEnv* env,
70 const JavaParamRef<jobject>& jcaller) { 70 const JavaParamRef<jobject>& jcaller) {
71 DCHECK(jcaller.obj() == java_prefetch_background_task_.obj()); 71 DCHECK(jcaller.obj() == java_prefetch_background_task_.obj());
72 service_->GetDispatcher()->StopBackgroundTask(this); 72 service_->GetPrefetchDispatcher()->StopBackgroundTask(this);
73 return needs_reschedule_; 73 return needs_reschedule_;
74 } 74 }
75 75
76 void PrefetchBackgroundTask::SetNeedsReschedule(bool reschedule) { 76 void PrefetchBackgroundTask::SetNeedsReschedule(bool reschedule) {
77 needs_reschedule_ = reschedule; 77 needs_reschedule_ = reschedule;
78 } 78 }
79 79
80 bool RegisterPrefetchBackgroundTask(JNIEnv* env) { 80 bool RegisterPrefetchBackgroundTask(JNIEnv* env) {
81 return prefetch::RegisterNativesImpl(env); 81 return prefetch::RegisterNativesImpl(env);
82 } 82 }
83 83
84 } // namespace offline_pages 84 } // namespace offline_pages
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/offline_pages/prefetch/prefetch_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698