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