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/common/media/webrtc_logging_messages.h" | |
| 10 #include "content/public/browser/browser_message_filter.h" | 11 #include "content/public/browser/browser_message_filter.h" |
| 11 #include "net/base/net_util.h" | 12 #include "net/base/net_util.h" |
| 12 | 13 |
| 13 namespace net { | 14 namespace net { |
| 14 class URLRequestContextGetter; | 15 class URLRequestContextGetter; |
| 15 } // namespace net | 16 } // namespace net |
| 16 | 17 |
| 17 class PartialCircularBuffer; | 18 class PartialCircularBuffer; |
| 18 class Profile; | 19 class Profile; |
| 19 class RenderProcessHost; | 20 class RenderProcessHost; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 | 98 |
| 98 virtual ~WebRtcLoggingHandlerHost(); | 99 virtual ~WebRtcLoggingHandlerHost(); |
| 99 | 100 |
| 100 // BrowserMessageFilter implementation. | 101 // BrowserMessageFilter implementation. |
| 101 virtual void OnChannelClosing() OVERRIDE; | 102 virtual void OnChannelClosing() OVERRIDE; |
| 102 virtual void OnDestruct() const OVERRIDE; | 103 virtual void OnDestruct() const OVERRIDE; |
| 103 virtual bool OnMessageReceived(const IPC::Message& message, | 104 virtual bool OnMessageReceived(const IPC::Message& message, |
| 104 bool* message_was_ok) OVERRIDE; | 105 bool* message_was_ok) OVERRIDE; |
| 105 | 106 |
| 106 // Handles log message requests from renderer process. | 107 // Handles log message requests from renderer process. |
| 107 void OnAddLogMessage(const std::string& message); | 108 void OnAddLogMessages(const std::vector<WebRtcLoggingMessage>& messages); |
| 108 void OnLoggingStoppedInRenderer(); | 109 void OnLoggingStoppedInRenderer(); |
| 109 | 110 |
| 110 // Handles log message requests from browser process. | 111 // Handles log message requests from browser process. |
| 111 void AddLogMessageFromBrowser(const std::string& message); | 112 void AddLogMessageFromBrowser(const base::Time& timestamp, |
|
dcheng
2014/04/02 01:20:00
Minor nit: it's preferred to pass base::Time by va
| |
| 113 const std::string& message); | |
| 112 | 114 |
| 113 void StartLoggingIfAllowed(); | 115 void StartLoggingIfAllowed(); |
| 114 void DoStartLogging(); | 116 void DoStartLogging(); |
| 115 void LogInitialInfoOnFileThread(); | 117 void LogInitialInfoOnFileThread(); |
| 116 void LogInitialInfoOnIOThread(const net::NetworkInterfaceList& network_list); | 118 void LogInitialInfoOnIOThread(const net::NetworkInterfaceList& network_list); |
| 117 void NotifyLoggingStarted(); | 119 void NotifyLoggingStarted(); |
| 118 | 120 |
| 119 // Writes a formatted log |message| to the |circular_buffer_|. | 121 // Writes a formatted log |message| to the |circular_buffer_|. |
| 120 void LogToCircularBuffer(const std::string& message); | 122 void LogToCircularBuffer(const std::string& message); |
| 121 | 123 |
| 122 // Gets the log directory path for |profile_| and ensure it exists. Must be | 124 // Gets the log directory path for |profile_| and ensure it exists. Must be |
| 123 // called on the FILE thread. | 125 // called on the FILE thread. |
| 124 base::FilePath GetLogDirectoryAndEnsureExists(); | 126 base::FilePath GetLogDirectoryAndEnsureExists(); |
| 125 | 127 |
| 126 void TriggerUploadLog(const base::FilePath& log_directory); | 128 void TriggerUploadLog(const base::FilePath& log_directory); |
| 127 | 129 |
| 128 void FireGenericDoneCallback(GenericDoneCallback* callback, | 130 void FireGenericDoneCallback(GenericDoneCallback* callback, |
| 129 bool success, | 131 bool success, |
| 130 const std::string& error_message); | 132 const std::string& error_message); |
| 131 | 133 |
| 134 std::string FormatMessageWithTimestamp(const base::Time& timestamp, | |
| 135 const std::string& message); | |
| 136 | |
| 132 scoped_ptr<unsigned char[]> log_buffer_; | 137 scoped_ptr<unsigned char[]> log_buffer_; |
| 133 scoped_ptr<PartialCircularBuffer> circular_buffer_; | 138 scoped_ptr<PartialCircularBuffer> circular_buffer_; |
| 134 | 139 |
| 135 // The profile associated with our renderer process. | 140 // The profile associated with our renderer process. |
| 136 Profile* profile_; | 141 Profile* profile_; |
| 137 | 142 |
| 138 // These are only accessed on the IO thread, except when in STARTING state. In | 143 // These are only accessed on the IO thread, except when in STARTING state. In |
| 139 // this state we are protected since entering any function that alters the | 144 // this state we are protected since entering any function that alters the |
| 140 // state is not allowed. | 145 // state is not allowed. |
| 141 MetaDataMap meta_data_; | 146 MetaDataMap meta_data_; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 152 LoggingState logging_state_; | 157 LoggingState logging_state_; |
| 153 | 158 |
| 154 // Only accessed on the IO thread. | 159 // Only accessed on the IO thread. |
| 155 bool upload_log_on_render_close_; | 160 bool upload_log_on_render_close_; |
| 156 | 161 |
| 157 // This is the handle to be passed to the render process. It's stored so that | 162 // This is the handle to be passed to the render process. It's stored so that |
| 158 // it doesn't have to be passed on when posting messages between threads. | 163 // it doesn't have to be passed on when posting messages between threads. |
| 159 // It's only accessed on the IO thread. | 164 // It's only accessed on the IO thread. |
| 160 base::SharedMemoryHandle foreign_memory_handle_; | 165 base::SharedMemoryHandle foreign_memory_handle_; |
| 161 | 166 |
| 167 // The system time in ms when logging is started. Reset when logging_state_ | |
| 168 // changes to STOPPED. | |
| 169 base::Time logging_started_time_; | |
| 170 | |
| 162 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost); | 171 DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost); |
| 163 }; | 172 }; |
| 164 | 173 |
| 165 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ | 174 #endif // CHROME_BROWSER_MEDIA_WEBRTC_LOGGING_HANDLER_HOST_H_ |
| OLD | NEW |