Chromium Code Reviews| 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..3f6cbbb2f995c54c32c0a1e4c02bce3b35270168 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() {} |
| @@ -139,7 +178,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); |
|
Henrik Grunell
2014/05/13 09:12:31
|upload_done_data| contains info that's needed aft
jiayl
2014/05/13 21:48:17
The dump paths are needed to add them to the chrom
Henrik Grunell
2014/05/14 12:14:12
Ah, right, it's the path and not the actual data i
|
| // 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 +221,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 +258,23 @@ 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. |
| + // TODO(jiayl): adds the RTP dump records to chrome://webrtc-logs. |
| + for (std::vector<WebRtcRtpDumpDescription>::const_iterator it = |
| + rtp_dumps.begin(); |
| + it != rtp_dumps.end(); |
| + ++it) { |
| + if (it->path.empty() || !base::PathExists(it->path)) |
| + break; |
|
Henrik Grunell
2014/05/13 09:12:31
Maybe log a warning?
jiayl
2014/05/13 21:48:17
Done. Also changed RtpDumpHandler and RtpDumpWrite
|
| + |
| + 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, |