Index: chrome/browser/media/webrtc_log_uploader.cc |
diff --git a/chrome/browser/media/webrtc_log_uploader.cc b/chrome/browser/media/webrtc_log_uploader.cc |
index cbe8424b46e0d06d5e54dd0a737e702323ee3ed2..3005a41db764296dbe9c01facebdfcee54f58aba 100644 |
--- a/chrome/browser/media/webrtc_log_uploader.cc |
+++ b/chrome/browser/media/webrtc_log_uploader.cc |
@@ -36,8 +36,47 @@ const char kMultipartBoundary[] = |
const int kHttpResponseOk = 200; |
+// Adds the header section for a gzip file to the multipart |post_data|. |
+void AddMultipartFileContentHeader(std::string* post_data, |
+ const std::string& content_name, |
+ const std::string& file_name) { |
+ post_data->append("--"); |
+ post_data->append(kMultipartBoundary); |
+ post_data->append("\r\n"); |
+ post_data->append("Content-Disposition: form-data; name=\""); |
+ post_data->append(content_name); |
+ post_data->append("\""); |
+ post_data->append("; filename=\""); |
+ post_data->append(file_name); |
+ post_data->append("\"\r\n"); |
+ post_data->append("Content-Type: application/gzip\r\n\r\n"); |
+} |
+ |
+// Adds |compressed_log| to |post_data|. |
+void AddLogData(std::string* post_data, |
+ const std::vector<uint8>& compressed_log) { |
+ AddMultipartFileContentHeader(post_data, "webrtc_log", "webrtc_log.gz"); |
+ post_data->append(reinterpret_cast<const char*>(&compressed_log[0]), |
+ compressed_log.size()); |
+ post_data->append("\r\n"); |
+} |
+ |
+// Adds the RTP dump data to |post_data|. |
+void AddRtpDumpData(std::string* post_data, |
+ const std::string& name, |
+ const std::string& dump_data) { |
+ AddMultipartFileContentHeader(post_data, name, name + ".gz"); |
+ post_data->append(dump_data.data(), dump_data.size()); |
+ post_data->append("\r\n"); |
+} |
+ |
} // namespace |
+WebRtcRtpDumpDescription::WebRtcRtpDumpDescription(const std::string& name, |
+ const base::FilePath& path) |
+ : name(name), path(path) { |
+} |
+ |
WebRtcLogUploadDoneData::WebRtcLogUploadDoneData() {} |
WebRtcLogUploadDoneData::~WebRtcLogUploadDoneData() {} |
@@ -69,6 +108,7 @@ void WebRtcLogUploader::OnURLFetchComplete( |
if (response_code == kHttpResponseOk && |
source->GetResponseAsString(&report_id) && |
!it->second.log_path.empty()) { |
+ // TODO(jiayl): adds the RTP dump records to chrome://webrtc-logs. |
base::FilePath log_list_path = |
WebRtcLogList::GetWebRtcLogListFileForDirectory(it->second.log_path); |
content::BrowserThread::PostTask( |
@@ -139,7 +179,8 @@ void WebRtcLogUploader::LoggingStoppedDoUpload( |
upload_done_data_with_log_id.local_log_id = local_log_id; |
scoped_ptr<std::string> post_data(new std::string()); |
- SetupMultipart(post_data.get(), compressed_log, meta_data); |
+ SetupMultipart( |
+ post_data.get(), compressed_log, upload_done_data.rtp_dumps, meta_data); |
// If a test has set the test string pointer, write to it and skip uploading. |
// Still fire the upload callback so that we can run an extension API test |
@@ -181,6 +222,7 @@ void WebRtcLogUploader::StartShutdown() { |
void WebRtcLogUploader::SetupMultipart( |
std::string* post_data, |
const std::vector<uint8>& compressed_log, |
+ const std::vector<WebRtcRtpDumpDescription>& rtp_dumps, |
const std::map<std::string, std::string>& meta_data) { |
#if defined(OS_WIN) |
const char product[] = "Chrome"; |
@@ -217,20 +259,24 @@ void WebRtcLogUploader::SetupMultipart( |
} |
AddLogData(post_data, compressed_log); |
- net::AddMultipartFinalDelimiterForUpload(kMultipartBoundary, post_data); |
-} |
-void WebRtcLogUploader::AddLogData(std::string* post_data, |
- const std::vector<uint8>& compressed_log) { |
- post_data->append("--"); |
- post_data->append(kMultipartBoundary); |
- post_data->append("\r\n"); |
- post_data->append("Content-Disposition: form-data; name=\"webrtc_log\""); |
- post_data->append("; filename=\"webrtc_log.gz\"\r\n"); |
- post_data->append("Content-Type: application/gzip\r\n\r\n"); |
- post_data->append(reinterpret_cast<const char*>(&compressed_log[0]), |
- compressed_log.size()); |
- post_data->append("\r\n"); |
+ // Add the rtp dumps if any. |
+ for (std::vector<WebRtcRtpDumpDescription>::const_iterator it = |
+ rtp_dumps.begin(); |
+ it != rtp_dumps.end(); |
+ ++it) { |
+ if (it->path.empty() || !base::PathExists(it->path)) { |
+ LOG(WARNING) << "Unexpected empty RTP dump."; |
+ break; |
+ } |
+ |
+ std::string dump_data; |
+ if (base::ReadFileToString(it->path, &dump_data)) { |
+ AddRtpDumpData(post_data, it->name, dump_data); |
+ } |
+ } |
+ |
+ net::AddMultipartFinalDelimiterForUpload(kMultipartBoundary, post_data); |
} |
void WebRtcLogUploader::CompressLog(std::vector<uint8>* compressed_log, |