OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_pr
ivate_api.h" | 7 #include "chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_pr
ivate_api.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 namespace extensions { | 23 namespace extensions { |
24 | 24 |
25 namespace SetMetaData = api::webrtc_logging_private::SetMetaData; | 25 namespace SetMetaData = api::webrtc_logging_private::SetMetaData; |
26 namespace Start = api::webrtc_logging_private::Start; | 26 namespace Start = api::webrtc_logging_private::Start; |
27 namespace SetUploadOnRenderClose = | 27 namespace SetUploadOnRenderClose = |
28 api::webrtc_logging_private::SetUploadOnRenderClose; | 28 api::webrtc_logging_private::SetUploadOnRenderClose; |
29 namespace Stop = api::webrtc_logging_private::Stop; | 29 namespace Stop = api::webrtc_logging_private::Stop; |
30 namespace Upload = api::webrtc_logging_private::Upload; | 30 namespace Upload = api::webrtc_logging_private::Upload; |
31 namespace Discard = api::webrtc_logging_private::Discard; | 31 namespace Discard = api::webrtc_logging_private::Discard; |
| 32 namespace StartRtpDump = api::webrtc_logging_private::StartRtpDump; |
| 33 namespace StopRtpDump = api::webrtc_logging_private::StopRtpDump; |
32 | 34 |
33 using api::webrtc_logging_private::MetaDataEntry; | 35 using api::webrtc_logging_private::MetaDataEntry; |
34 | 36 |
35 content::RenderProcessHost* | 37 content::RenderProcessHost* |
36 WebrtcLoggingPrivateTabIdFunction::RphFromTabIdAndSecurityOrigin( | 38 WebrtcLoggingPrivateTabIdFunction::RphFromTabIdAndSecurityOrigin( |
37 int tab_id, const std::string& security_origin) { | 39 int tab_id, const std::string& security_origin) { |
38 content::WebContents* contents = NULL; | 40 content::WebContents* contents = NULL; |
39 if (!ExtensionTabUtil::GetTabById( | 41 if (!ExtensionTabUtil::GetTabById( |
40 tab_id, GetProfile(), true, NULL, NULL, &contents, NULL)) { | 42 tab_id, GetProfile(), true, NULL, NULL, &contents, NULL)) { |
41 error_ = extensions::ErrorUtils::FormatErrorMessage( | 43 error_ = extensions::ErrorUtils::FormatErrorMessage( |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 } | 262 } |
261 | 263 |
262 void WebrtcLoggingPrivateDiscardFunction::DiscardCallback( | 264 void WebrtcLoggingPrivateDiscardFunction::DiscardCallback( |
263 bool success, const std::string& error_message) { | 265 bool success, const std::string& error_message) { |
264 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 266 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
265 if (!success) | 267 if (!success) |
266 SetError(error_message); | 268 SetError(error_message); |
267 SendResponse(success); | 269 SendResponse(success); |
268 } | 270 } |
269 | 271 |
| 272 WebrtcLoggingPrivateStartRtpDumpFunction:: |
| 273 WebrtcLoggingPrivateStartRtpDumpFunction() {} |
| 274 |
| 275 WebrtcLoggingPrivateStartRtpDumpFunction:: |
| 276 ~WebrtcLoggingPrivateStartRtpDumpFunction() {} |
| 277 |
| 278 bool WebrtcLoggingPrivateStartRtpDumpFunction::RunAsync() { |
| 279 scoped_ptr<StartRtpDump::Params> params(StartRtpDump::Params::Create(*args_)); |
| 280 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 281 |
| 282 content::RenderProcessHost* host = |
| 283 RphFromTabIdAndSecurityOrigin(params->tab_id, params->security_origin); |
| 284 if (!host) |
| 285 return false; |
| 286 |
| 287 scoped_refptr<WebRtcLoggingHandlerHost> webrtc_logging_handler_host( |
| 288 base::UserDataAdapter<WebRtcLoggingHandlerHost>::Get(host, host)); |
| 289 |
| 290 WebRtcLoggingHandlerHost::GenericDoneCallback callback = base::Bind( |
| 291 &WebrtcLoggingPrivateStartRtpDumpFunction::StartRtpDumpCallback, this); |
| 292 |
| 293 BrowserThread::PostTask(BrowserThread::IO, |
| 294 FROM_HERE, |
| 295 base::Bind(&WebRtcLoggingHandlerHost::StartRtpDump, |
| 296 webrtc_logging_handler_host, |
| 297 params->incoming, |
| 298 params->outgoing, |
| 299 callback)); |
| 300 |
| 301 return true; |
| 302 } |
| 303 |
| 304 void WebrtcLoggingPrivateStartRtpDumpFunction::StartRtpDumpCallback( |
| 305 bool success, |
| 306 const std::string& error_message) { |
| 307 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 308 if (!success) |
| 309 SetError(error_message); |
| 310 SendResponse(success); |
| 311 } |
| 312 |
| 313 WebrtcLoggingPrivateStopRtpDumpFunction:: |
| 314 WebrtcLoggingPrivateStopRtpDumpFunction() {} |
| 315 |
| 316 WebrtcLoggingPrivateStopRtpDumpFunction:: |
| 317 ~WebrtcLoggingPrivateStopRtpDumpFunction() {} |
| 318 |
| 319 bool WebrtcLoggingPrivateStopRtpDumpFunction::RunAsync() { |
| 320 scoped_ptr<StopRtpDump::Params> params(StopRtpDump::Params::Create(*args_)); |
| 321 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 322 |
| 323 content::RenderProcessHost* host = |
| 324 RphFromTabIdAndSecurityOrigin(params->tab_id, params->security_origin); |
| 325 if (!host) |
| 326 return false; |
| 327 |
| 328 scoped_refptr<WebRtcLoggingHandlerHost> webrtc_logging_handler_host( |
| 329 base::UserDataAdapter<WebRtcLoggingHandlerHost>::Get(host, host)); |
| 330 |
| 331 WebRtcLoggingHandlerHost::GenericDoneCallback callback = base::Bind( |
| 332 &WebrtcLoggingPrivateStopRtpDumpFunction::StopRtpDumpCallback, this); |
| 333 |
| 334 BrowserThread::PostTask(BrowserThread::IO, |
| 335 FROM_HERE, |
| 336 base::Bind(&WebRtcLoggingHandlerHost::StopRtpDump, |
| 337 webrtc_logging_handler_host, |
| 338 params->incoming, |
| 339 params->outgoing, |
| 340 callback)); |
| 341 |
| 342 return true; |
| 343 } |
| 344 |
| 345 void WebrtcLoggingPrivateStopRtpDumpFunction::StopRtpDumpCallback( |
| 346 bool success, |
| 347 const std::string& error_message) { |
| 348 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 349 if (!success) |
| 350 SetError(error_message); |
| 351 SendResponse(success); |
| 352 } |
| 353 |
270 } // namespace extensions | 354 } // namespace extensions |
OLD | NEW |