Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / extensions / api / copresence_private / copresence_private_api.h
blob3be29040c1905b8eb9c581c08ebae68a08db6b0f
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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_PRIVATE_COPRESENCE_PRIVATE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_PRIVATE_COPRESENCE_PRIVATE_API_H_
8 #include <string>
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"
15 namespace audio_modem {
16 class WhispernetClient;
19 namespace extensions {
21 class CopresencePrivateService final : public BrowserContextKeyedAPI {
22 public:
23 explicit CopresencePrivateService(content::BrowserContext* context);
24 ~CopresencePrivateService() override;
26 // Registers a client to receive events from Whispernet.
27 const std::string
28 RegisterWhispernetClient(audio_modem::WhispernetClient* client);
30 // Gets the whispernet client by ID.
31 audio_modem::WhispernetClient* GetWhispernetClient(const std::string& id);
33 // Called from the whispernet_proxy extension when it has initialized.
34 void OnWhispernetInitialized(bool success);
36 // BrowserContextKeyedAPI implementation.
37 static BrowserContextKeyedAPIFactory<CopresencePrivateService>*
38 GetFactoryInstance();
40 private:
41 friend class BrowserContextKeyedAPIFactory<CopresencePrivateService>;
43 // BrowserContextKeyedAPI implementation.
44 static const bool kServiceRedirectedInIncognito = true;
45 static const char* service_name() { return "CopresencePrivateService"; }
47 bool initialized_;
48 std::map<std::string, audio_modem::WhispernetClient*> whispernet_clients_;
50 DISALLOW_COPY_AND_ASSIGN(CopresencePrivateService);
53 template<>
54 void BrowserContextKeyedAPIFactory<CopresencePrivateService>
55 ::DeclareFactoryDependencies();
57 class CopresencePrivateSendFoundFunction : public UIThreadExtensionFunction {
58 public:
59 DECLARE_EXTENSION_FUNCTION("copresencePrivate.sendFound",
60 COPRESENCEPRIVATE_SENDFOUND);
62 protected:
63 ~CopresencePrivateSendFoundFunction() override {}
64 ExtensionFunction::ResponseAction Run() override;
67 class CopresencePrivateSendSamplesFunction : public UIThreadExtensionFunction {
68 public:
69 DECLARE_EXTENSION_FUNCTION("copresencePrivate.sendSamples",
70 COPRESENCEPRIVATE_SENDSAMPLES);
72 protected:
73 ~CopresencePrivateSendSamplesFunction() override {}
74 ExtensionFunction::ResponseAction Run() override;
77 class CopresencePrivateSendDetectFunction : public UIThreadExtensionFunction {
78 public:
79 DECLARE_EXTENSION_FUNCTION("copresencePrivate.sendDetect",
80 COPRESENCEPRIVATE_SENDDETECT);
82 protected:
83 ~CopresencePrivateSendDetectFunction() override {}
84 ExtensionFunction::ResponseAction Run() override;
87 class CopresencePrivateSendInitializedFunction
88 : public UIThreadExtensionFunction {
89 public:
90 DECLARE_EXTENSION_FUNCTION("copresencePrivate.sendInitialized",
91 COPRESENCEPRIVATE_SENDINITIALIZED);
93 protected:
94 ~CopresencePrivateSendInitializedFunction() override {}
95 ExtensionFunction::ResponseAction Run() override;
98 } // namespace extensions
100 #endif // CHROME_BROWSER_EXTENSIONS_API_COPRESENCE_PRIVATE_COPRESENCE_PRIVATE_API_H_