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

Side by Side Diff: content/browser/background_fetch/background_fetch_client_proxy.cc

Issue 2777063008: Connect BackgroundFetch to the OfflineItemCollection
Patch Set: Fixed incognito check and added tests Created 3 years, 8 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/background_fetch/background_fetch_client_proxy.h"
6
7 #include "content/browser/background_fetch/background_fetch_context.h"
8 #include "content/browser/background_fetch/background_fetch_registration_id.h"
9 #include "content/public/browser/browser_thread.h"
10
11 namespace content {
12
13 BackgroundFetchClientProxy::BackgroundFetchClientProxy(
14 BackgroundFetchContext* background_fetch_context)
15 : background_fetch_context_(background_fetch_context) {
16 DCHECK(background_fetch_context);
17 }
18
19 BackgroundFetchClientProxy::~BackgroundFetchClientProxy() = default;
20
21 void BackgroundFetchClientProxy::CleanupAllTasks() {
22 DCHECK_CURRENTLY_ON(BrowserThread::UI);
23 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
24 base::Bind(&BackgroundFetchContext::CleanupAllTasks,
25 background_fetch_context_));
26 }
27
28 void BackgroundFetchClientProxy::CancelDownload(
29 const std::string& registration_id) {
30 DCHECK_CURRENTLY_ON(BrowserThread::UI);
31 BackgroundFetchRegistrationId deserialized_id;
32 if (!BackgroundFetchRegistrationId::Deserialize(registration_id,
33 &deserialized_id)) {
34 LOG(ERROR) << "Unable to deserialize registration_id from embedder.";
35 return;
36 }
37
38 BrowserThread::PostTask(
39 BrowserThread::IO, FROM_HERE,
40 base::Bind(&BackgroundFetchContext::CancelFetch,
41 background_fetch_context_, deserialized_id));
42 }
43
44 void BackgroundFetchClientProxy::PauseDownload(
45 const std::string& registration_id) {
46 DCHECK_CURRENTLY_ON(BrowserThread::UI);
47 BackgroundFetchRegistrationId deserialized_id;
48 if (!BackgroundFetchRegistrationId::Deserialize(registration_id,
49 &deserialized_id)) {
50 LOG(ERROR) << "Unable to deserialize registration_id from embedder.";
51 return;
52 }
53
54 BrowserThread::PostTask(
55 BrowserThread::IO, FROM_HERE,
56 base::Bind(&BackgroundFetchContext::PauseFetch, background_fetch_context_,
57 deserialized_id));
58 }
59
60 void BackgroundFetchClientProxy::ResumeDownload(
61 const std::string& registration_id) {
62 DCHECK_CURRENTLY_ON(BrowserThread::UI);
63 BackgroundFetchRegistrationId deserialized_id;
64 if (!BackgroundFetchRegistrationId::Deserialize(registration_id,
65 &deserialized_id)) {
66 LOG(ERROR) << "Unable to deserialize registration_id from embedder.";
67 return;
68 }
69
70 BrowserThread::PostTask(
71 BrowserThread::IO, FROM_HERE,
72 base::Bind(&BackgroundFetchContext::ResumeFetch,
73 background_fetch_context_, deserialized_id));
74 }
75
76 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698