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

Side by Side Diff: chrome/browser/media/webrtc_event_log_handler.cc

Issue 1855193002: Move the call to enable the WebRTC event log from PeerConnectionFactory to PeerConnection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed review comments. Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/media/webrtc_event_log_handler.h" 5 #include "chrome/browser/media/webrtc_event_log_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 13 matching lines...) Expand all
24 const char WebRtcEventLogHandler::kWebRtcEventLogHandlerKey[] = 24 const char WebRtcEventLogHandler::kWebRtcEventLogHandlerKey[] =
25 "kWebRtcEventLogHandlerKey"; 25 "kWebRtcEventLogHandlerKey";
26 26
27 namespace { 27 namespace {
28 28
29 // Returns a path name to be used as prefix for RTC event log files. 29 // Returns a path name to be used as prefix for RTC event log files.
30 base::FilePath GetWebRtcEventLogPrefixPath(const base::FilePath& directory, 30 base::FilePath GetWebRtcEventLogPrefixPath(const base::FilePath& directory,
31 uint64_t rtc_event_log_id) { 31 uint64_t rtc_event_log_id) {
32 static const char kWebRtcEventLogFilePrefix[] = "WebRtcEventLog."; 32 static const char kWebRtcEventLogFilePrefix[] = "WebRtcEventLog.";
33 return directory.AppendASCII(kWebRtcEventLogFilePrefix + 33 return directory.AppendASCII(kWebRtcEventLogFilePrefix +
34 base::Int64ToString(rtc_event_log_id)); 34 base::Uint64ToString(rtc_event_log_id));
35 } 35 }
36 36
37 } // namespace 37 } // namespace
38 38
39 WebRtcEventLogHandler::WebRtcEventLogHandler(Profile* profile) 39 WebRtcEventLogHandler::WebRtcEventLogHandler(Profile* profile)
40 : profile_(profile), 40 : profile_(profile),
41 is_rtc_event_logging_in_progress_(false),
42 current_rtc_event_log_id_(0) { 41 current_rtc_event_log_id_(0) {
43 DCHECK(profile_); 42 DCHECK(profile_);
44 thread_checker_.DetachFromThread(); 43 thread_checker_.DetachFromThread();
45 } 44 }
46 45
47 WebRtcEventLogHandler::~WebRtcEventLogHandler() {} 46 WebRtcEventLogHandler::~WebRtcEventLogHandler() {}
48 47
49 void WebRtcEventLogHandler::StartWebRtcEventLogging( 48 void WebRtcEventLogHandler::StartWebRtcEventLogging(
50 content::RenderProcessHost* host, 49 content::RenderProcessHost* host,
51 base::TimeDelta delay, 50 base::TimeDelta delay,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 86 }
88 87
89 void WebRtcEventLogHandler::DoStartWebRtcEventLogging( 88 void WebRtcEventLogHandler::DoStartWebRtcEventLogging(
90 content::RenderProcessHost* host, 89 content::RenderProcessHost* host,
91 base::TimeDelta delay, 90 base::TimeDelta delay,
92 const RecordingDoneCallback& callback, 91 const RecordingDoneCallback& callback,
93 const RecordingErrorCallback& error_callback, 92 const RecordingErrorCallback& error_callback,
94 const base::FilePath& log_directory) { 93 const base::FilePath& log_directory) {
95 DCHECK(thread_checker_.CalledOnValidThread()); 94 DCHECK(thread_checker_.CalledOnValidThread());
96 95
97 if (is_rtc_event_logging_in_progress_) { 96 base::FilePath prefix_path =
97 GetWebRtcEventLogPrefixPath(log_directory, ++current_rtc_event_log_id_);
98 if (!host->StartWebRTCEventLog(prefix_path)) {
98 error_callback.Run("RTC event logging already in progress"); 99 error_callback.Run("RTC event logging already in progress");
99 return; 100 return;
100 } 101 }
101 102
102 is_rtc_event_logging_in_progress_ = true;
103 base::FilePath prefix_path =
104 GetWebRtcEventLogPrefixPath(log_directory, ++current_rtc_event_log_id_);
105 host->EnableEventLogRecordings(prefix_path);
106
107 if (delay.is_zero()) { 103 if (delay.is_zero()) {
108 const bool is_stopped = false, is_manual_stop = false; 104 const bool is_stopped = false, is_manual_stop = false;
109 callback.Run(prefix_path.AsUTF8Unsafe(), is_stopped, is_manual_stop); 105 callback.Run(prefix_path.AsUTF8Unsafe(), is_stopped, is_manual_stop);
110 return; 106 return;
111 } 107 }
112 108
113 const bool is_manual_stop = false; 109 const bool is_manual_stop = false;
114 BrowserThread::PostDelayedTask( 110 BrowserThread::PostDelayedTask(
115 BrowserThread::UI, FROM_HERE, 111 BrowserThread::UI, FROM_HERE,
116 base::Bind(&WebRtcEventLogHandler::DoStopWebRtcEventLogging, this, host, 112 base::Bind(&WebRtcEventLogHandler::DoStopWebRtcEventLogging, this, host,
(...skipping 18 matching lines...) Expand all
135 // This could happen in a sequence like: 131 // This could happen in a sequence like:
136 // Start(10); // Start dump 1. Post Stop() to run after 10 seconds. 132 // Start(10); // Start dump 1. Post Stop() to run after 10 seconds.
137 // Stop(); // Manually stop dump 1 before 10 seconds; 133 // Stop(); // Manually stop dump 1 before 10 seconds;
138 // Start(20); // Start dump 2. Posted Stop() for 1 should not stop dump 2. 134 // Start(20); // Start dump 2. Posted Stop() for 1 should not stop dump 2.
139 if (rtc_event_log_id < current_rtc_event_log_id_) { 135 if (rtc_event_log_id < current_rtc_event_log_id_) {
140 const bool is_stopped = false; 136 const bool is_stopped = false;
141 callback.Run(prefix_path.AsUTF8Unsafe(), is_stopped, is_manual_stop); 137 callback.Run(prefix_path.AsUTF8Unsafe(), is_stopped, is_manual_stop);
142 return; 138 return;
143 } 139 }
144 140
145 if (!is_rtc_event_logging_in_progress_) { 141 if (!host->StopWebRTCEventLog()) {
146 error_callback.Run("No RTC event logging in progress"); 142 error_callback.Run("No RTC event logging in progress");
147 return; 143 return;
148 } 144 }
149 145
150 host->DisableEventLogRecordings();
151 is_rtc_event_logging_in_progress_ = false;
152 const bool is_stopped = true; 146 const bool is_stopped = true;
153 callback.Run(prefix_path.AsUTF8Unsafe(), is_stopped, is_manual_stop); 147 callback.Run(prefix_path.AsUTF8Unsafe(), is_stopped, is_manual_stop);
154 } 148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698