| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
| 10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 11 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/pickle.h" | 14 #include "base/pickle.h" |
| 14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 WriteCompressedLogToFile(compressed_log, log_file_path); | 127 WriteCompressedLogToFile(compressed_log, log_file_path); |
| 127 | 128 |
| 128 base::FilePath log_list_path = | 129 base::FilePath log_list_path = |
| 129 WebRtcLogList::GetWebRtcLogListFileForDirectory( | 130 WebRtcLogList::GetWebRtcLogListFileForDirectory( |
| 130 upload_done_data.log_path); | 131 upload_done_data.log_path); |
| 131 AddLocallyStoredLogInfoToUploadListFile(log_list_path, local_log_id); | 132 AddLocallyStoredLogInfoToUploadListFile(log_list_path, local_log_id); |
| 132 } | 133 } |
| 133 | 134 |
| 134 WebRtcLogUploadDoneData upload_done_data_with_log_id = upload_done_data; | 135 WebRtcLogUploadDoneData upload_done_data_with_log_id = upload_done_data; |
| 135 upload_done_data_with_log_id.local_log_id = local_log_id; | 136 upload_done_data_with_log_id.local_log_id = local_log_id; |
| 136 PrepareMultipartPostData(compressed_log, meta_data.Pass(), | 137 PrepareMultipartPostData(compressed_log, std::move(meta_data), |
| 137 upload_done_data_with_log_id); | 138 upload_done_data_with_log_id); |
| 138 } | 139 } |
| 139 | 140 |
| 140 void WebRtcLogUploader::PrepareMultipartPostData( | 141 void WebRtcLogUploader::PrepareMultipartPostData( |
| 141 const std::string& compressed_log, | 142 const std::string& compressed_log, |
| 142 scoped_ptr<MetaDataMap> meta_data, | 143 scoped_ptr<MetaDataMap> meta_data, |
| 143 const WebRtcLogUploadDoneData& upload_done_data) { | 144 const WebRtcLogUploadDoneData& upload_done_data) { |
| 144 DCHECK(file_thread_checker_.CalledOnValidThread()); | 145 DCHECK(file_thread_checker_.CalledOnValidThread()); |
| 145 DCHECK(!compressed_log.empty()); | 146 DCHECK(!compressed_log.empty()); |
| 146 DCHECK(meta_data.get()); | 147 DCHECK(meta_data.get()); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 if (base::ReadFileToString(meta_path, &meta_data_contents) && | 210 if (base::ReadFileToString(meta_path, &meta_data_contents) && |
| 210 !meta_data_contents.empty()) { | 211 !meta_data_contents.empty()) { |
| 211 base::Pickle pickle(&meta_data_contents[0], meta_data_contents.size()); | 212 base::Pickle pickle(&meta_data_contents[0], meta_data_contents.size()); |
| 212 base::PickleIterator it(pickle); | 213 base::PickleIterator it(pickle); |
| 213 std::string key, value; | 214 std::string key, value; |
| 214 while (it.ReadString(&key) && it.ReadString(&value)) | 215 while (it.ReadString(&key) && it.ReadString(&value)) |
| 215 (*meta_data.get())[key] = value; | 216 (*meta_data.get())[key] = value; |
| 216 } | 217 } |
| 217 } | 218 } |
| 218 | 219 |
| 219 PrepareMultipartPostData(compressed_log, meta_data.Pass(), | 220 PrepareMultipartPostData(compressed_log, std::move(meta_data), |
| 220 upload_data_with_rtp); | 221 upload_data_with_rtp); |
| 221 } | 222 } |
| 222 | 223 |
| 223 void WebRtcLogUploader::LoggingStoppedDoStore( | 224 void WebRtcLogUploader::LoggingStoppedDoStore( |
| 224 const WebRtcLogPaths& log_paths, | 225 const WebRtcLogPaths& log_paths, |
| 225 const std::string& log_id, | 226 const std::string& log_id, |
| 226 scoped_ptr<WebRtcLogBuffer> log_buffer, | 227 scoped_ptr<WebRtcLogBuffer> log_buffer, |
| 227 scoped_ptr<MetaDataMap> meta_data, | 228 scoped_ptr<MetaDataMap> meta_data, |
| 228 const WebRtcLoggingHandlerHost::GenericDoneCallback& done_callback) { | 229 const WebRtcLoggingHandlerHost::GenericDoneCallback& done_callback) { |
| 229 DCHECK(file_thread_checker_.CalledOnValidThread()); | 230 DCHECK(file_thread_checker_.CalledOnValidThread()); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 std::string error_message; | 589 std::string error_message; |
| 589 if (!success) { | 590 if (!success) { |
| 590 error_message = "Uploading failed, response code: " + | 591 error_message = "Uploading failed, response code: " + |
| 591 base::IntToString(response_code); | 592 base::IntToString(response_code); |
| 592 } | 593 } |
| 593 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 594 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 594 base::Bind(upload_done_data.callback, success, | 595 base::Bind(upload_done_data.callback, success, |
| 595 report_id, error_message)); | 596 report_id, error_message)); |
| 596 } | 597 } |
| 597 } | 598 } |
| OLD | NEW |