| Index: chrome/browser/background_fetch/background_fetch_client_impl.cc
|
| diff --git a/chrome/browser/background_fetch/background_fetch_client_impl.cc b/chrome/browser/background_fetch/background_fetch_client_impl.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..563f0b496085436df2c1367ad326fe635c066b97
|
| --- /dev/null
|
| +++ b/chrome/browser/background_fetch/background_fetch_client_impl.cc
|
| @@ -0,0 +1,109 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include <string>
|
| +
|
| +#include "chrome/browser/background_fetch/background_fetch_client_impl.h"
|
| +
|
| +#include "chrome/browser/offline_items_collection/offline_content_aggregator_factory.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "components/offline_items_collection/core/offline_content_aggregator.h"
|
| +#include "components/offline_items_collection/core/offline_item.h"
|
| +
|
| +namespace {
|
| +
|
| +const char kBackgroundFetchNamespace[] = "BackgroundFetchNamespace";
|
| +
|
| +} // namespace
|
| +
|
| +using offline_items_collection::ContentId;
|
| +using offline_items_collection::OfflineContentAggregator;
|
| +using offline_items_collection::OfflineContentAggregatorFactory;
|
| +using offline_items_collection::OfflineContentProvider;
|
| +using offline_items_collection::OfflineItem;
|
| +
|
| +BackgroundFetchClientImpl::BackgroundFetchClientImpl(Profile* profile)
|
| + : profile_(profile) {
|
| + DCHECK(profile_);
|
| + OfflineContentAggregator* aggregator =
|
| + OfflineContentAggregatorFactory::GetForBrowserContext(profile_);
|
| + if (!aggregator)
|
| + return;
|
| + aggregator->RegisterProvider(kBackgroundFetchNamespace, this);
|
| +}
|
| +
|
| +BackgroundFetchClientImpl::~BackgroundFetchClientImpl() = default;
|
| +
|
| +void BackgroundFetchClientImpl::Shutdown() {
|
| + OfflineContentAggregator* aggregator =
|
| + OfflineContentAggregatorFactory::GetForBrowserContext(profile_);
|
| + if (!aggregator)
|
| + return;
|
| + aggregator->UnregisterProvider(kBackgroundFetchNamespace);
|
| +}
|
| +
|
| +void BackgroundFetchClientImpl::SetDelegate(
|
| + content::BackgroundFetchClient::Delegate* delegate) {
|
| + delegate_ = delegate;
|
| +}
|
| +
|
| +void BackgroundFetchClientImpl::CancelDownload(const ContentId& content_id) {
|
| + DCHECK_EQ(content_id.name_space, kBackgroundFetchNamespace);
|
| +
|
| + if (!delegate_)
|
| + return;
|
| +
|
| + delegate_->CancelDownload(content_id.id);
|
| +}
|
| +
|
| +void BackgroundFetchClientImpl::PauseDownload(const ContentId& content_id) {
|
| + DCHECK_EQ(content_id.name_space, kBackgroundFetchNamespace);
|
| +
|
| + if (!delegate_)
|
| + return;
|
| +
|
| + delegate_->PauseDownload(content_id.id);
|
| +}
|
| +
|
| +void BackgroundFetchClientImpl::ResumeDownload(const ContentId& content_id) {
|
| + DCHECK_EQ(content_id.name_space, kBackgroundFetchNamespace);
|
| +
|
| + if (!delegate_)
|
| + return;
|
| +
|
| + delegate_->ResumeDownload(content_id.id);
|
| +}
|
| +
|
| +void BackgroundFetchClientImpl::OpenItem(const ContentId& content_id) {
|
| + // TODO(harkness): Add another call to BackgroundFetchClient::Delegate and
|
| + // plumb this to 'onclickevent' to the ServiceWorker.
|
| +}
|
| +
|
| +void BackgroundFetchClientImpl::AddObserver(Observer* observer) {
|
| + // TODO(harkness): Add a path for the OfflineContentProvider to observe
|
| + // changes in available BackgroundFetch items.
|
| +}
|
| +
|
| +void BackgroundFetchClientImpl::RemoveObserver(Observer* observer) {}
|
| +
|
| +bool BackgroundFetchClientImpl::AreItemsAvailable() {
|
| + // TODO(harkness): Follow up with dtrainor about what action to take for this.
|
| + return false;
|
| +}
|
| +
|
| +void BackgroundFetchClientImpl::RemoveItem(const ContentId& content_id) {
|
| + // TODO(harkness): Follow up with dtrainor about what action to take for this.
|
| +}
|
| +
|
| +const OfflineItem* BackgroundFetchClientImpl::GetItemById(
|
| + const ContentId& content_id) {
|
| + // TODO(harkness): Follow up with dtrainor about what action to take for this.
|
| + return nullptr;
|
| +}
|
| +
|
| +OfflineContentProvider::OfflineItemList
|
| +BackgroundFetchClientImpl::GetAllItems() {
|
| + // TODO(harkness): Follow up with dtrainor about what action to take for this.
|
| + return OfflineContentProvider::OfflineItemList();
|
| +}
|
|
|