Index: chrome/browser/extensions/api/cast_devices_private/cast_devices_private_api.h |
diff --git a/chrome/browser/extensions/api/cast_devices_private/cast_devices_private_api.h b/chrome/browser/extensions/api/cast_devices_private/cast_devices_private_api.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f2e32cd54ec5c02b3edf504ca18059fa745ba5df |
--- /dev/null |
+++ b/chrome/browser/extensions/api/cast_devices_private/cast_devices_private_api.h |
@@ -0,0 +1,71 @@ |
+// Copyright 2015 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_EXTENSIONS_API_CAST_DEVICES_PRIVATE_CAST_DEVICES_PRIVATE_API_H_ |
+#define CHROME_BROWSER_EXTENSIONS_API_CAST_DEVICES_PRIVATE_CAST_DEVICES_PRIVATE_API_H_ |
+ |
+#include <vector> |
+ |
+#include "ash/cast_config_delegate.h" |
+#include "base/callback_list.h" |
+#include "extensions/browser/browser_context_keyed_api_factory.h" |
+#include "extensions/browser/extension_function.h" |
+ |
+namespace extensions { |
+ |
+class CastDeviceUpdateListeners : public BrowserContextKeyedAPI { |
+ public: |
+ explicit CastDeviceUpdateListeners(content::BrowserContext* context); |
+ ~CastDeviceUpdateListeners() override; |
+ |
+ // Fetch an instance for the given context. |
+ static CastDeviceUpdateListeners* Get(content::BrowserContext* context); |
+ |
+ // Register a function that will be invoked only when a new device update is |
+ // available. |
+ ash::CastConfigDelegate::DeviceUpdateSubscription RegisterCallback( |
+ const ash::CastConfigDelegate::ReceiversAndActivitesCallback& callback); |
+ |
+ // BrowserContextKeyedAPI implementation: |
+ static BrowserContextKeyedAPIFactory<CastDeviceUpdateListeners>* |
+ GetFactoryInstance(); |
+ static const bool kServiceIsCreatedWithBrowserContext = false; |
+ |
+ private: |
+ friend class CastDevicesPrivateUpdateDevicesFunction; // For NotifyCallbacks. |
+ void NotifyCallbacks( |
+ const std::vector<ash::CastConfigDelegate::ReceiverAndActivity>& devices); |
achuithb
2015/08/18 06:19:31
How about in the private part of this class:
using
jdufault
2015/08/18 19:53:01
Done.
|
+ |
+ base::CallbackList<void( |
+ const std::vector<ash::CastConfigDelegate::ReceiverAndActivity>&)> |
+ callback_list_; |
+ |
+ friend class BrowserContextKeyedAPIFactory<CastDeviceUpdateListeners>; |
+ |
+ // BrowserContextKeyedAPI implementation: |
+ static const char* service_name() { return "CastDeviceUpdateListeners"; } |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CastDeviceUpdateListeners); |
+}; |
+ |
+// static void updateDeviceState(ReceiverActivity[] devices); |
+class CastDevicesPrivateUpdateDevicesFunction : |
+ public UIThreadExtensionFunction { |
+ public: |
+ CastDevicesPrivateUpdateDevicesFunction(); |
+ |
+ private: |
+ ~CastDevicesPrivateUpdateDevicesFunction() override; |
+ |
+ // ExtensionFunction: |
+ ResponseAction Run() override; |
+ |
+ DECLARE_EXTENSION_FUNCTION("cast.devicesPrivate.updateDevices", |
+ CASTDEVICESPRIVATE_UPDATEDEVICES); |
+ DISALLOW_COPY_AND_ASSIGN(CastDevicesPrivateUpdateDevicesFunction); |
+}; |
+ |
+} // namespace extensions |
+ |
+#endif // CHROME_BROWSER_EXTENSIONS_API_CAST_DEVICES_PRIVATE_CAST_DEVICES_PRIVATE_API_H_ |