| Index: remoting/android/java/src/org/chromium/chromoting/CapabilityManager.java
|
| diff --git a/remoting/android/java/src/org/chromium/chromoting/CapabilityManager.java b/remoting/android/java/src/org/chromium/chromoting/CapabilityManager.java
|
| index 0a551bf4eb1bc9b0959d7f97f89c2e64f78d158d..e332e839de8d1cccaf091c5b2d03b05d72602783 100644
|
| --- a/remoting/android/java/src/org/chromium/chromoting/CapabilityManager.java
|
| +++ b/remoting/android/java/src/org/chromium/chromoting/CapabilityManager.java
|
| @@ -21,6 +21,10 @@
|
| * The CapabilityManager mirrors how the Chromoting host handles extension messages. For each
|
| * incoming extension message, runs through a list of HostExtensionSession objects, giving each one
|
| * a chance to handle the message.
|
| + *
|
| + * The CapabilityManager is a singleton class so we can manage client extensions on an application
|
| + * level. The singleton object may be used from multiple Activities, thus allowing it to support
|
| + * different capabilities at different stages of the application.
|
| */
|
| public class CapabilityManager {
|
| /** Used to allow objects to receive notifications when the host capabilites are received. */
|
| @@ -46,6 +50,12 @@
|
|
|
| private static final String TAG = "Chromoting";
|
|
|
| + /** Lazily-initialized singleton object that can be used from different Activities. */
|
| + private static CapabilityManager sInstance;
|
| +
|
| + /** Protects access to |sInstance|. */
|
| + private static final Object sInstanceLock = new Object();
|
| +
|
| /** List of all capabilities that are supported by the application. */
|
| private List<String> mLocalCapabilities;
|
|
|
| @@ -58,7 +68,7 @@
|
| /** Maintains a list of listeners to notify when host capabilities are received. */
|
| private List<CapabilitiesChangedListener> mCapabilitiesChangedListeners;
|
|
|
| - public CapabilityManager() {
|
| + private CapabilityManager() {
|
| mLocalCapabilities = new ArrayList<String>();
|
| mClientExtensions = new ArrayList<ClientExtension>();
|
|
|
| @@ -66,6 +76,18 @@
|
| mLocalCapabilities.add(Capabilities.TOUCH_CAPABILITY);
|
|
|
| mCapabilitiesChangedListeners = new ArrayList<CapabilitiesChangedListener>();
|
| + }
|
| +
|
| + /**
|
| + * Returns the singleton object. Thread-safe.
|
| + */
|
| + public static CapabilityManager getInstance() {
|
| + synchronized (sInstanceLock) {
|
| + if (sInstance == null) {
|
| + sInstance = new CapabilityManager();
|
| + }
|
| + return sInstance;
|
| + }
|
| }
|
|
|
| /**
|
|
|