| 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() {}
|
| +}
|
|
|