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/common/media/webrtc_logging_message_data.h" | 10 #include "chrome/common/media/webrtc_logging_message_data.h" |
11 #include "content/public/browser/browser_message_filter.h" | 11 #include "content/public/browser/browser_message_filter.h" |
12 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
13 | 13 |
14 namespace net { | |
15 class URLRequestContextGetter; | |
16 } // namespace net | |
17 | |
18 class PartialCircularBuffer; | 14 class PartialCircularBuffer; |
19 class Profile; | 15 class Profile; |
20 class RenderProcessHost; | |
21 | 16 |
22 typedef std::map<std::string, std::string> MetaDataMap; | 17 typedef std::map<std::string, std::string> MetaDataMap; |
23 | 18 |
24 // WebRtcLoggingHandlerHost handles operations regarding the WebRTC logging: | 19 // WebRtcLoggingHandlerHost handles operations regarding the WebRTC logging: |
25 // - Opens a shared memory buffer that the handler in the render process | 20 // - Opens a shared memory buffer that the handler in the render process |
26 // writes to. | 21 // writes to. |
27 // - Writes basic machine info to the log. | 22 // - Writes basic machine info to the log. |
28 // - Informs the handler in the render process when to stop logging. | 23 // - Informs the handler in the render process when to stop logging. |
29 // - Closes the shared memory (and thereby discarding it) or triggers uploading | 24 // - Closes the shared memory (and thereby discarding it) or triggers uploading |
30 // of the log. | 25 // of the log. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 116 |
122 // Handles log message requests from renderer process. | 117 // Handles log message requests from renderer process. |
123 void OnAddLogMessages(const std::vector<WebRtcLoggingMessageData>& messages); | 118 void OnAddLogMessages(const std::vector<WebRtcLoggingMessageData>& messages); |
124 void OnLoggingStoppedInRenderer(); | 119 void OnLoggingStoppedInRenderer(); |
125 | 120 |
126 // Handles log message requests from browser process. | 121 // Handles log message requests from browser process. |
127 void AddLogMessageFromBrowser(const WebRtcLoggingMessageData& message); | 122 void AddLogMessageFromBrowser(const WebRtcLoggingMessageData& message); |
128 | 123 |
129 void StartLoggingIfAllowed(); | 124 void StartLoggingIfAllowed(); |
130 void DoStartLogging(); | 125 void DoStartLogging(); |
131 void LogInitialInfoOnFileThread(); | 126 void LogInitialInfoOnBlockingPool(); |
132 void LogInitialInfoOnIOThread(const net::NetworkInterfaceList& network_list); | 127 void LogInitialInfoOnIOThread(const net::NetworkInterfaceList& network_list, |
| 128 const std::string& linux_distro); |
133 void NotifyLoggingStarted(); | 129 void NotifyLoggingStarted(); |
134 | 130 |
135 // Writes a formatted log |message| to the |circular_buffer_|. | 131 // Writes a formatted log |message| to the |circular_buffer_|. |
136 void LogToCircularBuffer(const std::string& message); | 132 void LogToCircularBuffer(const std::string& message); |
137 | 133 |
138 // Gets the log directory path for |profile_| and ensure it exists. Must be | 134 // Gets the log directory path for |profile_| and ensure it exists. Must be |
139 // called on the FILE thread. | 135 // called on the FILE thread. |
140 base::FilePath GetLogDirectoryAndEnsureExists(); | 136 base::FilePath GetLogDirectoryAndEnsureExists(); |
141 | 137 |
142 void TriggerUploadLog(const base::FilePath& log_directory); | 138 void TriggerUploadLog(const base::FilePath& log_directory); |
143 | 139 |
144 void FireGenericDoneCallback(GenericDoneCallback* callback, | 140 void FireGenericDoneCallback(GenericDoneCallback* callback, |
145 bool success, | 141 bool success, |
146 const std::string& error_message); | 142 const std::string& error_message); |
147 | 143 |
148 scoped_ptr<unsigned char[]> log_buffer_; | 144 scoped_ptr<unsigned char[]> log_buffer_; |
149 scoped_ptr<PartialCircularBuffer> circular_buffer_; | 145 scoped_ptr<PartialCircularBuffer> circular_buffer_; |
150 | 146 |
151 // The profile associated with our renderer process. | 147 // The profile associated with our renderer process. |
152 Profile* profile_; | 148 const Profile* const profile_; |
153 | 149 |
154 // These are only accessed on the IO thread, except when in STARTING state. In | 150 // These are only accessed on the IO thread, except when in STARTING state. In |
155 // this state we are protected since entering any function that alters the | 151 // this state we are protected since entering any function that alters the |
156 // state is not allowed. | 152 // state is not allowed. |
157 MetaDataMap meta_data_; | 153 MetaDataMap meta_data_; |
158 | 154 |
159 // These are only accessed on the IO thread. | 155 // These are only accessed on the IO thread. |
160 GenericDoneCallback start_callback_; | 156 GenericDoneCallback start_callback_; |
161 GenericDoneCallback stop_callback_; | 157 GenericDoneCallback stop_callback_; |
162 UploadDoneCallback upload_callback_; | 158 UploadDoneCallback upload_callback_; |
(...skipping 13 matching lines...) Expand all Loading... |
176 base::SharedMemoryHandle foreign_memory_handle_; | 172 base::SharedMemoryHandle foreign_memory_handle_; |
177 | 173 |
178 // The system time in ms when logging is started. Reset when logging_state_ | 174 // The system time in ms when logging is started. Reset when logging_state_ |
179 // changes to STOPPED. | 175 // changes to STOPPED. |
180 base::Time logging_started_time_; | 176 base::Time logging_started_time_; |
181 | 177 |
182 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost); | 178 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost); |
183 }; | 179 }; |
184 | 180 |
185 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ | 181 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ |
OLD | NEW |