| 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 "chrome/browser/media/webrtc_log_uploader.h" | 5 #include "chrome/browser/media/webrtc_log_uploader.h" |
| 6 | 6 |
| 7 #include "base/files/file_enumerator.h" | 7 #include "base/files/file_enumerator.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 .AddExtension(FILE_PATH_LITERAL(".rtp_out")); | 239 .AddExtension(FILE_PATH_LITERAL(".rtp_out")); |
| 240 | 240 |
| 241 scoped_ptr<MetaDataMap> meta_data(new MetaDataMap()); | 241 scoped_ptr<MetaDataMap> meta_data(new MetaDataMap()); |
| 242 { | 242 { |
| 243 std::string meta_data_contents; | 243 std::string meta_data_contents; |
| 244 base::FilePath meta_path = | 244 base::FilePath meta_path = |
| 245 upload_data.log_path.AppendASCII(upload_data.local_log_id) | 245 upload_data.log_path.AppendASCII(upload_data.local_log_id) |
| 246 .AddExtension(FILE_PATH_LITERAL(".meta")); | 246 .AddExtension(FILE_PATH_LITERAL(".meta")); |
| 247 if (base::ReadFileToString(meta_path, &meta_data_contents) && | 247 if (base::ReadFileToString(meta_path, &meta_data_contents) && |
| 248 !meta_data_contents.empty()) { | 248 !meta_data_contents.empty()) { |
| 249 Pickle pickle(&meta_data_contents[0], meta_data_contents.size()); | 249 base::Pickle pickle(&meta_data_contents[0], meta_data_contents.size()); |
| 250 PickleIterator it(pickle); | 250 base::PickleIterator it(pickle); |
| 251 std::string key, value; | 251 std::string key, value; |
| 252 while (it.ReadString(&key) && it.ReadString(&value)) | 252 while (it.ReadString(&key) && it.ReadString(&value)) |
| 253 (*meta_data.get())[key] = value; | 253 (*meta_data.get())[key] = value; |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 | 256 |
| 257 UploadCompressedLog(compressed_log, meta_data.Pass(), upload_data_with_rtp); | 257 UploadCompressedLog(compressed_log, meta_data.Pass(), upload_data_with_rtp); |
| 258 } | 258 } |
| 259 | 259 |
| 260 void WebRtcLogUploader::LoggingStoppedDoStore( | 260 void WebRtcLogUploader::LoggingStoppedDoStore( |
| (...skipping 28 matching lines...) Expand all Loading... |
| 289 base::Move(log_paths.incoming_rtp_dump, rtp_path); | 289 base::Move(log_paths.incoming_rtp_dump, rtp_path); |
| 290 } | 290 } |
| 291 | 291 |
| 292 if (!log_paths.outgoing_rtp_dump.empty()) { | 292 if (!log_paths.outgoing_rtp_dump.empty()) { |
| 293 base::FilePath rtp_path = log_paths.log_path.AppendASCII(log_id) | 293 base::FilePath rtp_path = log_paths.log_path.AppendASCII(log_id) |
| 294 .AddExtension(FILE_PATH_LITERAL(".rtp_out")); | 294 .AddExtension(FILE_PATH_LITERAL(".rtp_out")); |
| 295 base::Move(log_paths.outgoing_rtp_dump, rtp_path); | 295 base::Move(log_paths.outgoing_rtp_dump, rtp_path); |
| 296 } | 296 } |
| 297 | 297 |
| 298 if (meta_data.get() && !meta_data->empty()) { | 298 if (meta_data.get() && !meta_data->empty()) { |
| 299 Pickle pickle; | 299 base::Pickle pickle; |
| 300 for (const auto& it : *meta_data.get()) { | 300 for (const auto& it : *meta_data.get()) { |
| 301 pickle.WriteString(it.first); | 301 pickle.WriteString(it.first); |
| 302 pickle.WriteString(it.second); | 302 pickle.WriteString(it.second); |
| 303 } | 303 } |
| 304 base::FilePath meta_path = log_paths.log_path.AppendASCII(log_id) | 304 base::FilePath meta_path = log_paths.log_path.AppendASCII(log_id) |
| 305 .AddExtension(FILE_PATH_LITERAL(".meta")); | 305 .AddExtension(FILE_PATH_LITERAL(".meta")); |
| 306 base::WriteFile(meta_path, static_cast<const char*>(pickle.data()), | 306 base::WriteFile(meta_path, static_cast<const char*>(pickle.data()), |
| 307 pickle.size()); | 307 pickle.size()); |
| 308 } | 308 } |
| 309 | 309 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 if (!success) { | 565 if (!success) { |
| 566 error_message = "Uploading failed, response code: " + | 566 error_message = "Uploading failed, response code: " + |
| 567 base::IntToString(response_code); | 567 base::IntToString(response_code); |
| 568 } | 568 } |
| 569 content::BrowserThread::PostTask( | 569 content::BrowserThread::PostTask( |
| 570 content::BrowserThread::UI, FROM_HERE, | 570 content::BrowserThread::UI, FROM_HERE, |
| 571 base::Bind(upload_done_data.callback, success, report_id, | 571 base::Bind(upload_done_data.callback, success, report_id, |
| 572 error_message)); | 572 error_message)); |
| 573 } | 573 } |
| 574 } | 574 } |
| OLD | NEW |