Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1849)

Unified Diff: content/browser/renderer_host/media/webrtc_logging_handler_host.cc

Issue 14329020: Implementing uploading of a WebRTC diagnostic log. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review, added url and app session id, rebase Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/media/webrtc_logging_handler_host.cc
diff --git a/content/browser/renderer_host/media/webrtc_logging_handler_host.cc b/content/browser/renderer_host/media/webrtc_logging_handler_host.cc
index 10e2101c80590cd4d69afe0697c576a3c96b13c7..02d1c56c286a419e7e5725fb40dabe41a7ddf21d 100644
--- a/content/browser/renderer_host/media/webrtc_logging_handler_host.cc
+++ b/content/browser/renderer_host/media/webrtc_logging_handler_host.cc
@@ -6,7 +6,11 @@
#include "base/bind.h"
#include "base/logging.h"
+#include "base/shared_memory.h"
#include "content/common/media/webrtc_logging_messages.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/render_process_host.h"
namespace content {
@@ -16,13 +20,14 @@ const size_t kWebRtcLogSize = 1 * 1024 * 1024; // 1 MB
const size_t kWebRtcLogSize = 6 * 1024 * 1024; // 6 MB
#endif
-WebRtcLoggingHandlerHost::WebRtcLoggingHandlerHost() {
-}
+WebRtcLoggingHandlerHost::WebRtcLoggingHandlerHost(
+ RenderProcessHost* render_process_host)
+ : render_process_host_(render_process_host) {}
-WebRtcLoggingHandlerHost::~WebRtcLoggingHandlerHost() {
-}
+WebRtcLoggingHandlerHost::~WebRtcLoggingHandlerHost() {}
void WebRtcLoggingHandlerHost::OnChannelClosing() {
+ UploadLog();
BrowserMessageFilter::OnChannelClosing();
}
@@ -45,24 +50,56 @@ bool WebRtcLoggingHandlerHost::OnMessageReceived(const IPC::Message& message,
void WebRtcLoggingHandlerHost::OnOpenLog(const std::string& app_session_id,
const std::string& app_url) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- DCHECK(!base::SharedMemory::IsHandleValid(shared_memory_.handle()));
+ app_session_id_ = app_session_id;
+ app_url_ = app_url;
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
+ &WebRtcLoggingHandlerHost::OpenLogIfAllowed, this));
+}
+
+void WebRtcLoggingHandlerHost::OpenLogIfAllowed() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (!GetContentClient()->browser()->IsWebRtcLoggingAllowed())
+ return;
+
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind(
+ &WebRtcLoggingHandlerHost::DoOpenLog, this));
+}
- if (!shared_memory_.CreateAndMapAnonymous(kWebRtcLogSize)) {
+void WebRtcLoggingHandlerHost::DoOpenLog() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK(!shared_memory_);
+
+ shared_memory_.reset(new base::SharedMemory());
+
+ if (!shared_memory_->CreateAndMapAnonymous(kWebRtcLogSize)) {
DLOG(ERROR) << "Failed to create shared memory.";
Send(new WebRtcLoggingMsg_OpenLogFailed());
return;
}
base::SharedMemoryHandle foreign_memory_handle;
- if (!shared_memory_.ShareToProcess(peer_handle(),
+ if (!shared_memory_->ShareToProcess(peer_handle(),
&foreign_memory_handle)) {
Send(new WebRtcLoggingMsg_OpenLogFailed());
return;
}
- app_session_id_ = app_session_id;
- app_url_ = app_url;
Send(new WebRtcLoggingMsg_LogOpened(foreign_memory_handle, kWebRtcLogSize));
}
+void WebRtcLoggingHandlerHost::UploadLog() {
+ if (!shared_memory_)
+ return;
+
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
+ &ContentBrowserClient::UploadWebRtcLog,
+ base::Unretained(GetContentClient()->browser()),
+ render_process_host_->GetBrowserContext(),
+ Passed(&shared_memory_),
+ kWebRtcLogSize,
+ app_session_id_,
+ app_url_));
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698