Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_MEDIA_WEBRTC_LOG_UPLOADER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_WEBRTC_LOG_UPLOADER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_WEBRTC_LOG_UPLOADER_H_ | 6 #define CHROME_BROWSER_MEDIA_WEBRTC_LOG_UPLOADER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 #include "chrome/browser/media/webrtc_logging_handler_host.h" | 15 #include "chrome/browser/media/webrtc_logging_handler_host.h" |
| 16 #include "net/url_request/url_fetcher_delegate.h" | 16 #include "net/url_request/url_fetcher_delegate.h" |
| 17 | 17 |
| 18 class Profile; | 18 class Profile; |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 class SharedMemory; | 21 class SharedMemory; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace net { | 24 namespace net { |
| 25 class URLFetcher; | 25 class URLFetcher; |
| 26 } | 26 } |
| 27 | 27 |
| 28 typedef struct z_stream_s z_stream; | 28 typedef struct z_stream_s z_stream; |
| 29 | 29 |
| 30 struct WebRtcRtpDumpDescription { | |
| 31 WebRtcRtpDumpDescription(const std::string& name, const base::FilePath& path); | |
| 32 | |
| 33 std::string name; | |
|
tommi (sloooow) - chröme
2014/05/13 15:19:55
can these members be const?
jiayl
2014/05/13 21:48:17
The assignment operator (required to use with std:
| |
| 34 base::FilePath path; | |
| 35 }; | |
| 36 | |
| 30 // Used when uploading is done to perform post-upload actions. |log_path| is | 37 // Used when uploading is done to perform post-upload actions. |log_path| is |
| 31 // also used pre-upload. | 38 // also used pre-upload. |
| 32 struct WebRtcLogUploadDoneData { | 39 struct WebRtcLogUploadDoneData { |
| 33 WebRtcLogUploadDoneData(); | 40 WebRtcLogUploadDoneData(); |
| 34 ~WebRtcLogUploadDoneData(); | 41 ~WebRtcLogUploadDoneData(); |
| 35 | 42 |
| 36 base::FilePath log_path; | 43 base::FilePath log_path; |
| 44 std::vector<WebRtcRtpDumpDescription> rtp_dumps; | |
| 37 WebRtcLoggingHandlerHost::UploadDoneCallback callback; | 45 WebRtcLoggingHandlerHost::UploadDoneCallback callback; |
| 38 scoped_refptr<WebRtcLoggingHandlerHost> host; | 46 scoped_refptr<WebRtcLoggingHandlerHost> host; |
| 39 std::string local_log_id; | 47 std::string local_log_id; |
| 40 }; | 48 }; |
| 41 | 49 |
| 42 // WebRtcLogUploader uploads WebRTC logs, keeps count of how many logs have | 50 // WebRtcLogUploader uploads WebRTC logs, keeps count of how many logs have |
| 43 // been started and denies further logs if a limit is reached. It also adds | 51 // been started and denies further logs if a limit is reached. It also adds |
| 44 // the timestamp and report ID of the uploded log to a text file. There must | 52 // the timestamp and report ID of the uploded log to a text file. There must |
| 45 // only be one object of this type. | 53 // only be one object of this type. |
| 46 class WebRtcLogUploader : public net::URLFetcherDelegate { | 54 class WebRtcLogUploader : public net::URLFetcherDelegate { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 private: | 100 private: |
| 93 FRIEND_TEST_ALL_PREFIXES(WebRtcLogUploaderTest, | 101 FRIEND_TEST_ALL_PREFIXES(WebRtcLogUploaderTest, |
| 94 AddLocallyStoredLogInfoToUploadListFile); | 102 AddLocallyStoredLogInfoToUploadListFile); |
| 95 FRIEND_TEST_ALL_PREFIXES(WebRtcLogUploaderTest, | 103 FRIEND_TEST_ALL_PREFIXES(WebRtcLogUploaderTest, |
| 96 AddUploadedLogInfoToUploadListFile); | 104 AddUploadedLogInfoToUploadListFile); |
| 97 | 105 |
| 98 // Sets up a multipart body to be uploaded. The body is produced according | 106 // Sets up a multipart body to be uploaded. The body is produced according |
| 99 // to RFC 2046. | 107 // to RFC 2046. |
| 100 void SetupMultipart(std::string* post_data, | 108 void SetupMultipart(std::string* post_data, |
| 101 const std::vector<uint8>& compressed_log, | 109 const std::vector<uint8>& compressed_log, |
| 110 const std::vector<WebRtcRtpDumpDescription>& rtp_dumps, | |
| 102 const std::map<std::string, std::string>& meta_data); | 111 const std::map<std::string, std::string>& meta_data); |
| 103 | 112 |
| 104 // Adds |compressed_log| to |post_data|. | |
| 105 void AddLogData(std::string* post_data, | |
| 106 const std::vector<uint8>& compressed_log); | |
| 107 | |
| 108 void CompressLog(std::vector<uint8>* compressed_log, | 113 void CompressLog(std::vector<uint8>* compressed_log, |
| 109 uint8* input, | 114 uint8* input, |
| 110 uint32 input_size); | 115 uint32 input_size); |
| 111 | 116 |
| 112 void ResizeForNextOutput(std::vector<uint8>* compressed_log, | 117 void ResizeForNextOutput(std::vector<uint8>* compressed_log, |
| 113 z_stream* stream); | 118 z_stream* stream); |
| 114 | 119 |
| 115 void CreateAndStartURLFetcher( | 120 void CreateAndStartURLFetcher( |
| 116 const WebRtcLogUploadDoneData& upload_done_data, | 121 const WebRtcLogUploadDoneData& upload_done_data, |
| 117 scoped_ptr<std::string> post_data); | 122 scoped_ptr<std::string> post_data); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 // Only accessed on the UI thread. | 174 // Only accessed on the UI thread. |
| 170 UploadDoneDataMap upload_done_data_; | 175 UploadDoneDataMap upload_done_data_; |
| 171 | 176 |
| 172 // When shutting down, don't create new URLFetchers. | 177 // When shutting down, don't create new URLFetchers. |
| 173 bool shutting_down_; | 178 bool shutting_down_; |
| 174 | 179 |
| 175 DISALLOW_COPY_AND_ASSIGN(WebRtcLogUploader); | 180 DISALLOW_COPY_AND_ASSIGN(WebRtcLogUploader); |
| 176 }; | 181 }; |
| 177 | 182 |
| 178 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOG_UPLOADER_H_ | 183 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOG_UPLOADER_H_ |
| OLD | NEW |