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

Unified Diff: chrome/browser/background_fetch/background_fetch_client_impl.h

Issue 2777063008: Connect BackgroundFetch to the OfflineItemCollection
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/background_fetch/background_fetch_client_impl.h
diff --git a/chrome/browser/background_fetch/background_fetch_client_impl.h b/chrome/browser/background_fetch/background_fetch_client_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..55b738f32c9bdf6883b454c6e780f2fac78890e3
--- /dev/null
+++ b/chrome/browser/background_fetch/background_fetch_client_impl.h
@@ -0,0 +1,57 @@
+// 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.
+
+#ifndef CHROME_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_IMPL_H_
+#define CHROME_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_IMPL_H_
+
+#include "base/macros.h"
+#include "components/keyed_service/core/keyed_service.h"
+#include "components/offline_items_collection/core/offline_content_provider.h"
+#include "content/public/browser/background_fetch_client.h"
+#include "content/public/browser/background_fetch_delegate.h"
+
+namespace content {
+class BackgroundFetchDelegate;
+} // namespace content
+
+class Profile;
+
+using offline_items_collection::ContentId;
+using offline_items_collection::OfflineItem;
+using offline_items_collection::OfflineContentProvider;
harkness 2017/03/29 08:02:05 I know we don't usually use "using", but is it all
Peter Beverloo 2017/03/29 14:32:12 Wow this is terrible, hehe. Unfortunately we don't
harkness 2017/03/30 12:42:35 Done.
+
+class BackgroundFetchClientImpl : public content::BackgroundFetchClient,
+ public OfflineContentProvider,
+ public KeyedService {
+ public:
+ explicit BackgroundFetchClientImpl(Profile* profile);
+ ~BackgroundFetchClientImpl() override;
+
+ // content::BackgroundFetchClient overrides.
+ void SetDelegate(content::BackgroundFetchDelegate* delegate) override;
+ content::BackgroundFetchDelegate* GetDelegate() const override;
+
+ // components::OfflineContentProvider overrides.
+ bool AreItemsAvailable() override;
+ void OpenItem(const ContentId& id) override;
+ void RemoveItem(const ContentId& id) override;
+ void CancelDownload(const ContentId& id) override;
+ void PauseDownload(const ContentId& id) override;
+ void ResumeDownload(const ContentId& id) override;
+ const OfflineItem* GetItemById(const ContentId& id) override;
+ OfflineContentProvider::OfflineItemList GetAllItems() override;
+ void AddObserver(Observer* observer) override;
+ void RemoveObserver(Observer* observer) override;
+
+ private:
+ // This object is owned by the Profile.
+ Profile* profile_;
+
+ // Guaranteed to outlive this object.
Peter Beverloo 2017/03/29 14:32:12 why?
harkness 2017/03/30 12:42:35 oops, I thought it was when I started, then forgot
+ content::BackgroundFetchDelegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(BackgroundFetchClientImpl);
+};
+
+#endif // CHROME_BROWSER_BACKGROUND_FETCH_BACKGROUND_FETCH_CLIENT_IMPL_H_

Powered by Google App Engine
This is Rietveld 408576698