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

Side by Side Diff: chrome/browser/background_fetch/background_fetch_client_impl.cc

Issue 2777063008: Connect BackgroundFetch to the OfflineItemCollection
Patch Set: 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 <string>
6
7 #include "chrome/browser/background_fetch/background_fetch_client_impl.h"
8
9 #include "chrome/browser/offline_items_collection/offline_content_aggregator_fac tory.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "components/offline_items_collection/core/offline_content_aggregator.h"
12 #include "components/offline_items_collection/core/offline_item.h"
13
14 namespace {
15
16 const char kBackgroundFetchProvider[] = "BackgroundFetchProvider";
Peter Beverloo 2017/03/29 14:32:12 Please check with David to see what sort of string
harkness 2017/03/30 12:42:35 Done.
17
18 } // namespace
19
20 BackgroundFetchClientImpl::BackgroundFetchClientImpl(Profile* profile)
21 : profile_(profile) {
22 DCHECK(profile_);
23 offline_items_collection::OfflineContentAggregator* aggregator =
24 offline_items_collection::OfflineContentAggregatorFactory::
25 GetForBrowserContext(profile_);
26 if (!aggregator)
27 return;
28 aggregator->RegisterProvider(kBackgroundFetchProvider, this);
29 }
30
31 BackgroundFetchClientImpl::~BackgroundFetchClientImpl() {
32 offline_items_collection::OfflineContentAggregator* aggregator =
33 offline_items_collection::OfflineContentAggregatorFactory::
34 GetForBrowserContext(profile_);
35 if (!aggregator)
36 return;
37 aggregator->UnregisterProvider(kBackgroundFetchProvider);
38 }
39
40 void BackgroundFetchClientImpl::SetDelegate(
41 content::BackgroundFetchDelegate* delegate) {
42 delegate_ = delegate;
43 }
44
45 content::BackgroundFetchDelegate* BackgroundFetchClientImpl::GetDelegate()
46 const {
47 return delegate_;
48 }
49
50 void BackgroundFetchClientImpl::CancelDownload(const ContentId& id) {
51 if (id.name_space != kBackgroundFetchProvider)
52 return;
Peter Beverloo 2017/03/29 14:59:49 These should be DCHECK_EQs. (The OCA only forwards
harkness 2017/03/30 12:42:34 Done.
53
54 if (!delegate_)
55 return;
56
57 delegate_->CancelDownload(id.id);
Peter Beverloo 2017/03/29 14:32:12 I realize this will make it even longer, but unles
harkness 2017/03/30 12:42:34 Done.
58 }
59
60 void BackgroundFetchClientImpl::PauseDownload(const ContentId& id) {
61 if (id.name_space != kBackgroundFetchProvider)
62 return;
63
64 if (!delegate_)
65 return;
66
67 delegate_->PauseDownload(id.id);
68 }
69
70 void BackgroundFetchClientImpl::ResumeDownload(const ContentId& id) {
71 if (id.name_space != kBackgroundFetchProvider)
72 return;
73
74 if (!delegate_)
75 return;
76
77 delegate_->ResumeDownload(id.id);
78 }
79
80 // Not yet implemented.
Peter Beverloo 2017/03/29 14:32:12 Will this be included in this CL? It would still b
harkness 2017/03/30 12:42:34 Done.
81 bool BackgroundFetchClientImpl::AreItemsAvailable() {
82 return false;
83 }
Peter Beverloo 2017/03/29 14:32:12 micro nit: blank lines between the methods
harkness 2017/03/30 12:42:35 Done.
84 void BackgroundFetchClientImpl::OpenItem(const ContentId& id) {}
85 void BackgroundFetchClientImpl::RemoveItem(const ContentId& id) {}
86 void BackgroundFetchClientImpl::AddObserver(Observer* observer) {}
87 void BackgroundFetchClientImpl::RemoveObserver(Observer* observer) {}
88 const OfflineItem* BackgroundFetchClientImpl::GetItemById(const ContentId& id) {
89 return nullptr;
90 }
91 OfflineContentProvider::OfflineItemList
92 BackgroundFetchClientImpl::GetAllItems() {
93 return OfflineContentProvider::OfflineItemList();
94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698