OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 package org.chromium.chrome.browser.offlinepages; | |
6 | |
7 import android.content.Context; | |
8 import android.os.Bundle; | |
9 | |
10 /** | |
11 * Handles servicing of background offlining requests coming via the GcmNetworkM anager. | |
12 */ | |
13 public class BackgroundTask implements BackgroundSchedulerBridge.ProcessingDoneC allback { | |
14 private static final String TAG = "BackgroundTask"; | |
15 /** | |
16 * Triggers processing of background offlining requests. This is called whe n | |
17 * system conditions are appropriate for background offlining, typically fro m the | |
18 * GcmTaskService onRunTask() method. In response, we will start the | |
19 * task processing by passing the call along to the C++ RequestCoordinator. | |
20 * | |
21 * @returns true for success | |
22 */ | |
23 public boolean processBackgroundRequests(Context context, Bundle bundle) { | |
24 // TODO(petewil): Nothing is holding the Wake Lock. We need some soluti on to | |
25 // keep hold of it. Options discussed so far are having a fresh set of functions | |
26 // to grab and release a countdown latch, or holding onto the wake lock ourselves, | |
27 // or grabbing the wake lock and then starting chrome and running startP rocessing | |
28 // on the UI thread. | |
29 | |
30 // TODO(petewil): Decode the TriggerConditions from the bundle. | |
31 | |
32 // Pass the activation on to the bridge to the C++ RequestCoordinator. | |
33 BackgroundSchedulerBridge.startProcessing(context, this); | |
Bernhard Bauer
2016/05/26 11:17:44
Do you actually need to pass the context to the na
Pete Williamson
2016/05/26 17:02:45
Right, I actually need the profile. I removed the
| |
34 | |
35 // Gather UMA data to measure how often the user's machine is amenable t o background | |
36 // loading when we wake to do a task. | |
37 OfflinePageUtils.recordWakeupUMA(context); | |
38 | |
39 return true; | |
40 } | |
41 | |
42 /** | |
43 * Callback function which indicates completion of background work. | |
44 * @param result - true if work was actually done (used for UMA). | |
45 */ | |
46 public void onProcessingDone(boolean result) { | |
47 | |
48 } | |
49 } | |
OLD | NEW |