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_LOGGING_HANDLER_HOST_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ |
| 6 #define CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ | 6 #define CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 10 #include "chrome/browser/media/webrtc_rtp_dump_handler.h" | |
| 10 #include "chrome/common/media/webrtc_logging_message_data.h" | 11 #include "chrome/common/media/webrtc_logging_message_data.h" |
| 11 #include "content/public/browser/browser_message_filter.h" | 12 #include "content/public/browser/browser_message_filter.h" |
| 12 #include "net/base/net_util.h" | 13 #include "net/base/net_util.h" |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 class URLRequestContextGetter; | 16 class URLRequestContextGetter; |
| 16 } // namespace net | 17 } // namespace net |
| 17 | 18 |
| 18 class PartialCircularBuffer; | 19 class PartialCircularBuffer; |
| 19 class Profile; | 20 class Profile; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 44 void SetMetaData(const MetaDataMap& meta_data, | 45 void SetMetaData(const MetaDataMap& meta_data, |
| 45 const GenericDoneCallback& callback); | 46 const GenericDoneCallback& callback); |
| 46 | 47 |
| 47 // Opens a log and starts logging. Must be called on the IO thread. | 48 // Opens a log and starts logging. Must be called on the IO thread. |
| 48 void StartLogging(const GenericDoneCallback& callback); | 49 void StartLogging(const GenericDoneCallback& callback); |
| 49 | 50 |
| 50 // Stops logging. Log will remain open until UploadLog or DiscardLog is | 51 // Stops logging. Log will remain open until UploadLog or DiscardLog is |
| 51 // called. Must be called on the IO thread. | 52 // called. Must be called on the IO thread. |
| 52 void StopLogging(const GenericDoneCallback& callback); | 53 void StopLogging(const GenericDoneCallback& callback); |
| 53 | 54 |
| 54 // Uploads the log and discards the local copy. May only be called after | 55 // Uploads the log and the RTP dumps. Discards the local copy. May only be |
| 55 // logging has stopped. Must be called on the IO thread. | 56 // called after logging has stopped. Must be called on the IO thread. |
| 56 void UploadLog(const UploadDoneCallback& callback); | 57 void UploadLog(const UploadDoneCallback& callback); |
| 57 | 58 |
| 58 // Called by WebRtcLogUploader when uploading has finished. Must be called on | 59 // Called by WebRtcLogUploader when uploading has finished. Must be called on |
| 59 // the IO thread. | 60 // the IO thread. |
| 60 void UploadLogDone(); | 61 void UploadLogDone(); |
| 61 | 62 |
| 62 // Discards the log. May only be called after logging has stopped. Must be | 63 // Discards the log and the RTP dumps. May only be called after logging has |
| 63 // called on the IO thread. | 64 // stopped. Must be called on the IO thread. |
| 64 void DiscardLog(const GenericDoneCallback& callback); | 65 void DiscardLog(const GenericDoneCallback& callback); |
| 65 | 66 |
| 66 // Adds a message to the log. | 67 // Adds a message to the log. |
| 67 void LogMessage(const std::string& message); | 68 void LogMessage(const std::string& message); |
| 68 | 69 |
| 69 // May be called on any thread. |upload_log_on_render_close_| is used | 70 // May be called on any thread. |upload_log_on_render_close_| is used |
| 70 // for decision making and it's OK if it changes before the execution based | 71 // for decision making and it's OK if it changes before the execution based |
| 71 // on that decision has finished. | 72 // on that decision has finished. |
| 72 void set_upload_log_on_render_close(bool should_upload) { | 73 void set_upload_log_on_render_close(bool should_upload) { |
| 73 upload_log_on_render_close_ = should_upload; | 74 upload_log_on_render_close_ = should_upload; |
| 74 } | 75 } |
| 75 | 76 |
| 76 // Starts dumping the RTP headers for the specified direction. Must be called | 77 // Starts dumping the RTP headers for the specified direction. Must be called |
| 77 // on the IO thread. |incoming| and |outgoing| specifies which direction(s) of | 78 // on the IO thread. |incoming| and |outgoing| specifies which direction(s) of |
| 78 // RTP packets should be dumped. |callback| will be called when starting the | 79 // RTP packets should be dumped. |callback| will be called when starting the |
| 79 // dump is done. | 80 // dump is done. |
| 80 void StartRtpDump(bool incoming, | 81 void StartRtpDump(bool incoming, |
| 81 bool outgoing, | 82 bool outgoing, |
| 82 const GenericDoneCallback& callback); | 83 const GenericDoneCallback& callback); |
| 83 | 84 |
| 84 // Stops dumping the RTP headers for the specified direction. Must be called | 85 // Stops dumping the RTP headers for the specified direction. Must be called |
| 85 // on the IO thread. |incoming| and |outgoing| specifies which direction(s) of | 86 // on the IO thread. |incoming| and |outgoing| specifies which direction(s) of |
| 86 // RTP packet dumping should be stopped. |callback| will be called when | 87 // RTP packet dumping should be stopped. |callback| will be called when |
| 87 // stopping the dump is done. | 88 // stopping the dump is done. |
| 88 void StopRtpDump(bool incoming, | 89 void StopRtpDump(bool incoming, |
| 89 bool outgoing, | 90 bool outgoing, |
| 90 const GenericDoneCallback& callback); | 91 const GenericDoneCallback& callback); |
| 91 | 92 |
| 93 // Called when a RTP packet is sent or received. Can be called on any thread. | |
|
Henrik Grunell
2014/05/13 09:12:31
Nit: an RTP packet.
jiayl
2014/05/13 21:48:17
Done.
| |
| 94 void OnRtpPacket(const uint8* packet_header, | |
| 95 size_t header_length, | |
| 96 size_t packet_length, | |
| 97 bool incoming); | |
| 98 | |
| 92 private: | 99 private: |
| 93 // States used for protecting from function calls made at non-allowed points | 100 // States used for protecting from function calls made at non-allowed points |
| 94 // in time. For example, StartLogging() is only allowed in CLOSED state. | 101 // in time. For example, StartLogging() is only allowed in CLOSED state. |
| 95 // Transitions: SetMetaData(): CLOSED -> CLOSED. | 102 // Transitions: SetMetaData(): CLOSED -> CLOSED. |
| 96 // StartLogging(): CLOSED -> STARTING. | 103 // StartLogging(): CLOSED -> STARTING. |
| 97 // Start done: STARTING -> STARTED. | 104 // Start done: STARTING -> STARTED. |
| 98 // StopLogging(): STARTED -> STOPPING. | 105 // StopLogging(): STARTED -> STOPPING. |
| 99 // Stop done: STOPPING -> STOPPED. | 106 // Stop done: STOPPING -> STOPPED. |
| 100 // UploadLog(): STOPPED -> UPLOADING. | 107 // UploadLog(): STOPPED -> UPLOADING. |
| 101 // Upload done: UPLOADING -> CLOSED. | 108 // Upload done: UPLOADING -> CLOSED. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 void LogInitialInfoOnIOThread(const net::NetworkInterfaceList& network_list); | 140 void LogInitialInfoOnIOThread(const net::NetworkInterfaceList& network_list); |
| 134 void NotifyLoggingStarted(); | 141 void NotifyLoggingStarted(); |
| 135 | 142 |
| 136 // Writes a formatted log |message| to the |circular_buffer_|. | 143 // Writes a formatted log |message| to the |circular_buffer_|. |
| 137 void LogToCircularBuffer(const std::string& message); | 144 void LogToCircularBuffer(const std::string& message); |
| 138 | 145 |
| 139 // Gets the log directory path for |profile_| and ensure it exists. Must be | 146 // Gets the log directory path for |profile_| and ensure it exists. Must be |
| 140 // called on the FILE thread. | 147 // called on the FILE thread. |
| 141 base::FilePath GetLogDirectoryAndEnsureExists(); | 148 base::FilePath GetLogDirectoryAndEnsureExists(); |
| 142 | 149 |
| 143 void TriggerUploadLog(const base::FilePath& log_directory); | 150 void TriggerUploadLogAndRtpDump(const base::FilePath& log_directory); |
|
Henrik Grunell
2014/05/13 09:12:31
Maybe just TriggerUpload?
jiayl
2014/05/13 21:48:17
Done.
| |
| 144 | 151 |
| 145 void FireGenericDoneCallback(GenericDoneCallback* callback, | 152 void FireGenericDoneCallback(GenericDoneCallback* callback, |
| 146 bool success, | 153 bool success, |
| 147 const std::string& error_message); | 154 const std::string& error_message); |
| 148 | 155 |
| 156 void CreateRtpDumpHandlerAndStart(bool incoming, | |
|
Henrik Grunell
2014/05/13 09:12:31
I think comments on all added functions are good.
jiayl
2014/05/13 21:48:17
Done.
| |
| 157 bool outgoing, | |
| 158 GenericDoneCallback callback, | |
| 159 const base::FilePath& dump_dir); | |
| 160 | |
| 161 void DoUpload(const base::FilePath& log_directory, | |
|
Henrik Grunell
2014/05/13 09:12:31
What will this upload? Can the name be changed to
jiayl
2014/05/13 21:48:17
Done.
| |
| 162 const WebRtcRtpDumpHandler::ReleasedDumps& rtp_dumps); | |
| 163 | |
| 164 void DumpRtpPacketOnIOThread(scoped_ptr<uint8[]> packet_header, | |
| 165 size_t header_length, | |
| 166 size_t packet_length, | |
| 167 bool incoming); | |
| 168 | |
| 149 scoped_ptr<unsigned char[]> log_buffer_; | 169 scoped_ptr<unsigned char[]> log_buffer_; |
| 150 scoped_ptr<PartialCircularBuffer> circular_buffer_; | 170 scoped_ptr<PartialCircularBuffer> circular_buffer_; |
| 151 | 171 |
| 152 // The profile associated with our renderer process. | 172 // The profile associated with our renderer process. |
| 153 Profile* profile_; | 173 Profile* profile_; |
| 154 | 174 |
| 155 // These are only accessed on the IO thread, except when in STARTING state. In | 175 // These are only accessed on the IO thread, except when in STARTING state. In |
| 156 // this state we are protected since entering any function that alters the | 176 // this state we are protected since entering any function that alters the |
| 157 // state is not allowed. | 177 // state is not allowed. |
| 158 MetaDataMap meta_data_; | 178 MetaDataMap meta_data_; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 173 | 193 |
| 174 // This is the handle to be passed to the render process. It's stored so that | 194 // This is the handle to be passed to the render process. It's stored so that |
| 175 // it doesn't have to be passed on when posting messages between threads. | 195 // it doesn't have to be passed on when posting messages between threads. |
| 176 // It's only accessed on the IO thread. | 196 // It's only accessed on the IO thread. |
| 177 base::SharedMemoryHandle foreign_memory_handle_; | 197 base::SharedMemoryHandle foreign_memory_handle_; |
| 178 | 198 |
| 179 // The system time in ms when logging is started. Reset when logging_state_ | 199 // The system time in ms when logging is started. Reset when logging_state_ |
| 180 // changes to STOPPED. | 200 // changes to STOPPED. |
| 181 base::Time logging_started_time_; | 201 base::Time logging_started_time_; |
| 182 | 202 |
| 203 scoped_ptr<WebRtcRtpDumpHandler> rtp_dump_handler_; | |
|
Henrik Grunell
2014/05/13 09:12:31
Add comment.
jiayl
2014/05/13 21:48:17
Done.
| |
| 204 | |
| 183 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost); | 205 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost); |
| 184 }; | 206 }; |
| 185 | 207 |
| 186 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ | 208 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ |
| OLD | NEW |