Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / extensions / api / webrtc_logging_private / webrtc_logging_private_api.h
blob202c7276aecd1aacd791ccc72178e64248d8ecfc
1 // Copyright 2013 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_WEBRTC_LOGGING_PRIVATE_WEBRTC_LOGGING_PRIVATE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_WEBRTC_LOGGING_PRIVATE_WEBRTC_LOGGING_PRIVATE_API_H_
8 #include "chrome/browser/extensions/chrome_extension_function.h"
9 #if defined(ENABLE_WEBRTC)
10 #include "chrome/browser/media/webrtc_logging_handler_host.h"
11 #endif
12 #include "chrome/common/extensions/api/webrtc_logging_private.h"
14 namespace content {
16 class RenderProcessHost;
20 namespace extensions {
22 class WebrtcLoggingPrivateFunction : public ChromeAsyncExtensionFunction {
23 protected:
24 ~WebrtcLoggingPrivateFunction() override {}
26 #if defined(ENABLE_WEBRTC)
27 // Returns the RenderProcessHost associated with the given |request|
28 // authorized by the |security_origin|. Returns null if unauthorized or
29 // the RPH does not exist.
30 content::RenderProcessHost* RphFromRequest(
31 const api::webrtc_logging_private::RequestInfo& request,
32 const std::string& security_origin);
34 scoped_refptr<WebRtcLoggingHandlerHost> LoggingHandlerFromRequest(
35 const api::webrtc_logging_private::RequestInfo& request,
36 const std::string& security_origin);
37 #endif
40 class WebrtcLoggingPrivateFunctionWithGenericCallback
41 : public WebrtcLoggingPrivateFunction {
42 protected:
43 ~WebrtcLoggingPrivateFunctionWithGenericCallback() override {}
45 #if defined(ENABLE_WEBRTC)
46 // Finds the appropriate logging handler for performing the task and prepares
47 // a generic callback object for when the task is completed.
48 // If the logging handler can't be found for the given request+origin, the
49 // returned ptr will be null.
50 scoped_refptr<WebRtcLoggingHandlerHost> PrepareTask(
51 const api::webrtc_logging_private::RequestInfo& request,
52 const std::string& security_origin,
53 WebRtcLoggingHandlerHost::GenericDoneCallback* callback);
55 // Must be called on UI thread.
56 void FireCallback(bool success, const std::string& error_message);
57 #endif
60 class WebrtcLoggingPrivateFunctionWithUploadCallback
61 : public WebrtcLoggingPrivateFunction {
62 protected:
63 ~WebrtcLoggingPrivateFunctionWithUploadCallback() override {}
65 #if defined(ENABLE_WEBRTC)
66 // Must be called on UI thread.
67 void FireCallback(bool success, const std::string& report_id,
68 const std::string& error_message);
69 #endif
72 class WebrtcLoggingPrivateSetMetaDataFunction
73 : public WebrtcLoggingPrivateFunctionWithGenericCallback {
74 public:
75 DECLARE_EXTENSION_FUNCTION("webrtcLoggingPrivate.setMetaData",
76 WEBRTCLOGGINGPRIVATE_SETMETADATA)
77 WebrtcLoggingPrivateSetMetaDataFunction() {}
79 private:
80 ~WebrtcLoggingPrivateSetMetaDataFunction() override {}
82 // ExtensionFunction overrides.
83 bool RunAsync() override;
86 class WebrtcLoggingPrivateStartFunction
87 : public WebrtcLoggingPrivateFunctionWithGenericCallback {
88 public:
89 DECLARE_EXTENSION_FUNCTION("webrtcLoggingPrivate.start",
90 WEBRTCLOGGINGPRIVATE_START)
91 WebrtcLoggingPrivateStartFunction() {}
93 private:
94 ~WebrtcLoggingPrivateStartFunction() override {}
96 // ExtensionFunction overrides.
97 bool RunAsync() override;
100 class WebrtcLoggingPrivateSetUploadOnRenderCloseFunction
101 : public WebrtcLoggingPrivateFunction {
102 public:
103 DECLARE_EXTENSION_FUNCTION("webrtcLoggingPrivate.setUploadOnRenderClose",
104 WEBRTCLOGGINGPRIVATE_SETUPLOADONRENDERCLOSE)
105 WebrtcLoggingPrivateSetUploadOnRenderCloseFunction() {}
107 private:
108 ~WebrtcLoggingPrivateSetUploadOnRenderCloseFunction() override {}
110 // ExtensionFunction overrides.
111 bool RunAsync() override;
114 class WebrtcLoggingPrivateStopFunction
115 : public WebrtcLoggingPrivateFunctionWithGenericCallback {
116 public:
117 DECLARE_EXTENSION_FUNCTION("webrtcLoggingPrivate.stop",
118 WEBRTCLOGGINGPRIVATE_STOP)
119 WebrtcLoggingPrivateStopFunction() {}
121 private:
122 ~WebrtcLoggingPrivateStopFunction() override {}
124 // ExtensionFunction overrides.
125 bool RunAsync() override;
128 class WebrtcLoggingPrivateStoreFunction
129 : public WebrtcLoggingPrivateFunctionWithGenericCallback {
130 public:
131 DECLARE_EXTENSION_FUNCTION("webrtcLoggingPrivate.store",
132 WEBRTCLOGGINGPRIVATE_STORE)
133 WebrtcLoggingPrivateStoreFunction() {}
135 private:
136 ~WebrtcLoggingPrivateStoreFunction() override {}
138 // ExtensionFunction overrides.
139 bool RunAsync() override;
142 class WebrtcLoggingPrivateUploadStoredFunction
143 : public WebrtcLoggingPrivateFunctionWithUploadCallback {
144 public:
145 DECLARE_EXTENSION_FUNCTION("webrtcLoggingPrivate.uploadStored",
146 WEBRTCLOGGINGPRIVATE_UPLOADSTORED)
147 WebrtcLoggingPrivateUploadStoredFunction() {}
149 private:
150 ~WebrtcLoggingPrivateUploadStoredFunction() override {}
152 // ExtensionFunction overrides.
153 bool RunAsync() override;
156 class WebrtcLoggingPrivateUploadFunction
157 : public WebrtcLoggingPrivateFunctionWithUploadCallback {
158 public:
159 DECLARE_EXTENSION_FUNCTION("webrtcLoggingPrivate.upload",
160 WEBRTCLOGGINGPRIVATE_UPLOAD)
161 WebrtcLoggingPrivateUploadFunction() {}
163 private:
164 ~WebrtcLoggingPrivateUploadFunction() override {}
166 // ExtensionFunction overrides.
167 bool RunAsync() override;
170 class WebrtcLoggingPrivateDiscardFunction
171 : public WebrtcLoggingPrivateFunctionWithGenericCallback {
172 public:
173 DECLARE_EXTENSION_FUNCTION("webrtcLoggingPrivate.discard",
174 WEBRTCLOGGINGPRIVATE_DISCARD)
175 WebrtcLoggingPrivateDiscardFunction() {}
177 private:
178 ~WebrtcLoggingPrivateDiscardFunction() override {}
180 // ExtensionFunction overrides.
181 bool RunAsync() override;
184 class WebrtcLoggingPrivateStartRtpDumpFunction
185 : public WebrtcLoggingPrivateFunctionWithGenericCallback {
186 public:
187 DECLARE_EXTENSION_FUNCTION("webrtcLoggingPrivate.startRtpDump",
188 WEBRTCLOGGINGPRIVATE_STARTRTPDUMP)
189 WebrtcLoggingPrivateStartRtpDumpFunction() {}
191 private:
192 ~WebrtcLoggingPrivateStartRtpDumpFunction() override {}
194 // ExtensionFunction overrides.
195 bool RunAsync() override;
198 class WebrtcLoggingPrivateStopRtpDumpFunction
199 : public WebrtcLoggingPrivateFunctionWithGenericCallback {
200 public:
201 DECLARE_EXTENSION_FUNCTION("webrtcLoggingPrivate.stopRtpDump",
202 WEBRTCLOGGINGPRIVATE_STOPRTPDUMP)
203 WebrtcLoggingPrivateStopRtpDumpFunction() {}
205 private:
206 ~WebrtcLoggingPrivateStopRtpDumpFunction() override {}
208 // ExtensionFunction overrides.
209 bool RunAsync() override;
212 } // namespace extensions
214 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBRTC_LOGGING_PRIVATE_WEBRTC_LOGGING_PRIVATE_API_H_