OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_CAST_DEVICES_PRIVATE_CAST_DEVICES_PRIVATE_ API_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_API_CAST_DEVICES_PRIVATE_CAST_DEVICES_PRIVATE_ API_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "ash/cast_config_delegate.h" | |
11 #include "base/callback_list.h" | |
12 #include "extensions/browser/browser_context_keyed_api_factory.h" | |
13 #include "extensions/browser/extension_function.h" | |
14 | |
15 namespace extensions { | |
16 | |
17 class CastDeviceUpdateListeners : public BrowserContextKeyedAPI { | |
18 public: | |
19 explicit CastDeviceUpdateListeners(content::BrowserContext* context); | |
20 ~CastDeviceUpdateListeners() override; | |
21 | |
Ken Rockot(use gerrit already)
2015/08/14 23:20:09
Since it seems like this will be fine if created o
jdufault
2015/08/15 00:04:52
Done.
| |
22 // Fetch an instance for the given context. | |
23 static CastDeviceUpdateListeners* Get(content::BrowserContext* context); | |
24 | |
25 // Register a function that will be invoked only when a new device update is | |
26 // available. | |
27 ash::CastConfigDelegate::DeviceUpdateSubscription RegisterCallback( | |
28 const ash::CastConfigDelegate::ReceiversAndActivitesCallback& callback); | |
29 | |
30 // BrowserContextKeyedAPI implementation: | |
31 static BrowserContextKeyedAPIFactory<CastDeviceUpdateListeners>* | |
32 GetFactoryInstance(); | |
33 | |
34 private: | |
35 friend class CastDevicesPrivateUpdateDevicesFunction; // For NotifyCallbacks. | |
36 void NotifyCallbacks( | |
37 const std::vector<ash::CastConfigDelegate::ReceiverAndActivity>& devices); | |
38 | |
39 base::CallbackList<void( | |
40 const std::vector<ash::CastConfigDelegate::ReceiverAndActivity>&)> | |
41 callback_list_; | |
42 | |
43 friend class BrowserContextKeyedAPIFactory<CastDeviceUpdateListeners>; | |
44 | |
45 // BrowserContextKeyedAPI implementation: | |
46 static const char* service_name() { return "CastDeviceUpdateListeners"; } | |
47 | |
48 DISALLOW_COPY_AND_ASSIGN(CastDeviceUpdateListeners); | |
49 }; | |
50 | |
51 // static void updateDeviceState(ReceiverActivity[] devices); | |
52 class CastDevicesPrivateUpdateDevicesFunction : public AsyncExtensionFunction { | |
Ken Rockot(use gerrit already)
2015/08/14 23:20:09
It's preferable for new code to inherit UIThreadEx
jdufault
2015/08/15 00:04:52
Done.
| |
53 public: | |
54 CastDevicesPrivateUpdateDevicesFunction(); | |
55 | |
56 private: | |
57 ~CastDevicesPrivateUpdateDevicesFunction() override; | |
58 | |
59 // ExtensionFunction: | |
60 bool RunAsync() override; | |
61 | |
62 DECLARE_EXTENSION_FUNCTION("cast.devicesPrivate.updateDevices", | |
63 CASTDEVICESPRIVATE_UPDATEDEVICES); | |
64 DISALLOW_COPY_AND_ASSIGN(CastDevicesPrivateUpdateDevicesFunction); | |
65 }; | |
66 | |
67 } // namespace extensions | |
68 | |
69 #endif // CHROME_BROWSER_EXTENSIONS_API_CAST_DEVICES_PRIVATE_CAST_DEVICES_PRIVA TE_API_H_ | |
OLD | NEW |