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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/download/items/OfflineContentAggregatorNotificationBridgeUiFactory.java

Issue 2771803004: Glue OfflineContentProvider to the download service (Closed)
Patch Set: Fixing test failure 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/android/java/src/org/chromium/chrome/browser/download/items/OfflineContentAggregatorNotificationBridgeUiFactory.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/items/OfflineContentAggregatorNotificationBridgeUiFactory.java b/chrome/android/java/src/org/chromium/chrome/browser/download/items/OfflineContentAggregatorNotificationBridgeUiFactory.java
new file mode 100644
index 0000000000000000000000000000000000000000..c8bf22ff32f484c60c34312e77501c5118d5c417
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/items/OfflineContentAggregatorNotificationBridgeUiFactory.java
@@ -0,0 +1,47 @@
+// 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.
+
+package org.chromium.chrome.browser.download.items;
+
+import org.chromium.base.ThreadUtils;
+import org.chromium.chrome.browser.profiles.Profile;
+import org.chromium.components.offline_items_collection.OfflineContentProvider;
+
+/**
+ * A factory meant to hold a singleton bridge between the notification UI and an
+ * {@link OfflineContentProvider}.
+ */
+public class OfflineContentAggregatorNotificationBridgeUiFactory {
+ private static OfflineContentAggregatorNotificationBridgeUi sBridgeUi;
+
+ /**
+ * @return An {@link OfflineContentAggregatorNotificationBridgeUi} instance singleton. If one
+ * is not available this will create a new one.
+ */
+ public static OfflineContentAggregatorNotificationBridgeUi instance() {
+ ThreadUtils.assertOnUiThread();
+ if (sBridgeUi == null) {
+ Profile profile = Profile.getLastUsedProfile();
+ OfflineContentProvider provider = OfflineContentAggregatorFactory.forProfile(profile);
+
+ sBridgeUi = new OfflineContentAggregatorNotificationBridgeUi(provider);
+ }
+
+ return sBridgeUi;
+ }
+
+ /**
+ * Destroys the internal singleton for {@link OfflineContentAggregatorNotificationBridgeUi} if
+ * one exists.
+ */
+ public static void destroy() {
+ ThreadUtils.assertOnUiThread();
+ if (sBridgeUi == null) return;
+
+ sBridgeUi.destroy();
+ sBridgeUi = null;
+ }
+
+ private OfflineContentAggregatorNotificationBridgeUiFactory() {}
+}

Powered by Google App Engine
This is Rietveld 408576698