| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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_COPRESENCE_PRIVATE_COPRESENCE_PRIVATE_API_
H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_PRIVATE_COPRESENCE_PRIVATE_API_
H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "extensions/browser/browser_context_keyed_api_factory.h" | |
| 12 #include "extensions/browser/extension_function.h" | |
| 13 #include "extensions/browser/extension_function_histogram_value.h" | |
| 14 | |
| 15 namespace audio_modem { | |
| 16 class WhispernetClient; | |
| 17 } | |
| 18 | |
| 19 namespace extensions { | |
| 20 | |
| 21 class CopresencePrivateService final : public BrowserContextKeyedAPI { | |
| 22 public: | |
| 23 explicit CopresencePrivateService(content::BrowserContext* context); | |
| 24 ~CopresencePrivateService() override; | |
| 25 | |
| 26 // Registers a client to receive events from Whispernet. | |
| 27 const std::string | |
| 28 RegisterWhispernetClient(audio_modem::WhispernetClient* client); | |
| 29 | |
| 30 // Gets the whispernet client by ID. | |
| 31 audio_modem::WhispernetClient* GetWhispernetClient(const std::string& id); | |
| 32 | |
| 33 // Called from the whispernet_proxy extension when it has initialized. | |
| 34 void OnWhispernetInitialized(bool success); | |
| 35 | |
| 36 // BrowserContextKeyedAPI implementation. | |
| 37 static BrowserContextKeyedAPIFactory<CopresencePrivateService>* | |
| 38 GetFactoryInstance(); | |
| 39 | |
| 40 private: | |
| 41 friend class BrowserContextKeyedAPIFactory<CopresencePrivateService>; | |
| 42 | |
| 43 // BrowserContextKeyedAPI implementation. | |
| 44 static const bool kServiceRedirectedInIncognito = true; | |
| 45 static const char* service_name() { return "CopresencePrivateService"; } | |
| 46 | |
| 47 bool initialized_; | |
| 48 std::map<std::string, audio_modem::WhispernetClient*> whispernet_clients_; | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(CopresencePrivateService); | |
| 51 }; | |
| 52 | |
| 53 template<> | |
| 54 void BrowserContextKeyedAPIFactory<CopresencePrivateService> | |
| 55 ::DeclareFactoryDependencies(); | |
| 56 | |
| 57 class CopresencePrivateSendFoundFunction : public UIThreadExtensionFunction { | |
| 58 public: | |
| 59 DECLARE_EXTENSION_FUNCTION("copresencePrivate.sendFound", | |
| 60 COPRESENCEPRIVATE_SENDFOUND); | |
| 61 | |
| 62 protected: | |
| 63 ~CopresencePrivateSendFoundFunction() override {} | |
| 64 ExtensionFunction::ResponseAction Run() override; | |
| 65 }; | |
| 66 | |
| 67 class CopresencePrivateSendSamplesFunction : public UIThreadExtensionFunction { | |
| 68 public: | |
| 69 DECLARE_EXTENSION_FUNCTION("copresencePrivate.sendSamples", | |
| 70 COPRESENCEPRIVATE_SENDSAMPLES); | |
| 71 | |
| 72 protected: | |
| 73 ~CopresencePrivateSendSamplesFunction() override {} | |
| 74 ExtensionFunction::ResponseAction Run() override; | |
| 75 }; | |
| 76 | |
| 77 class CopresencePrivateSendDetectFunction : public UIThreadExtensionFunction { | |
| 78 public: | |
| 79 DECLARE_EXTENSION_FUNCTION("copresencePrivate.sendDetect", | |
| 80 COPRESENCEPRIVATE_SENDDETECT); | |
| 81 | |
| 82 protected: | |
| 83 ~CopresencePrivateSendDetectFunction() override {} | |
| 84 ExtensionFunction::ResponseAction Run() override; | |
| 85 }; | |
| 86 | |
| 87 class CopresencePrivateSendInitializedFunction | |
| 88 : public UIThreadExtensionFunction { | |
| 89 public: | |
| 90 DECLARE_EXTENSION_FUNCTION("copresencePrivate.sendInitialized", | |
| 91 COPRESENCEPRIVATE_SENDINITIALIZED); | |
| 92 | |
| 93 protected: | |
| 94 ~CopresencePrivateSendInitializedFunction() override {} | |
| 95 ExtensionFunction::ResponseAction Run() override; | |
| 96 }; | |
| 97 | |
| 98 } // namespace extensions | |
| 99 | |
| 100 #endif // CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_PRIVATE_COPRESENCE_PRIVATE_A
PI_H_ | |
| OLD | NEW |