| Index: chrome/browser/media/webrtc_logging_handler_host.h
|
| diff --git a/chrome/browser/media/webrtc_logging_handler_host.h b/chrome/browser/media/webrtc_logging_handler_host.h
|
| index f55ee84bf8aa7a7603f2f82335e3b1c8a5a424c2..8c7be61ff2909a6017ef9b9193e1d9e002750697 100644
|
| --- a/chrome/browser/media/webrtc_logging_handler_host.h
|
| +++ b/chrome/browser/media/webrtc_logging_handler_host.h
|
| @@ -12,31 +12,18 @@
|
| #include <string>
|
| #include <vector>
|
|
|
| +#include "base/callback.h"
|
| #include "base/macros.h"
|
| -#include "base/memory/shared_memory.h"
|
| #include "build/build_config.h"
|
| #include "chrome/browser/media/rtp_dump_type.h"
|
| #include "chrome/browser/media/webrtc_rtp_dump_handler.h"
|
| -#include "chrome/common/media/webrtc_logging_message_data.h"
|
| -#include "chrome/common/partial_circular_buffer.h"
|
| +#include "chrome/browser/media/webrtc_text_log_handler.h"
|
| #include "content/public/browser/browser_message_filter.h"
|
| #include "content/public/browser/render_process_host.h"
|
| -#include "net/base/network_interfaces.h"
|
| -
|
| -namespace net {
|
| -class URLRequestContextGetter;
|
| -} // namespace net
|
|
|
| class Profile;
|
| class WebRtcLogUploader;
|
|
|
| -#if defined(OS_ANDROID)
|
| -const size_t kWebRtcLogSize = 1 * 1024 * 1024; // 1 MB
|
| -#else
|
| -const size_t kWebRtcLogSize = 6 * 1024 * 1024; // 6 MB
|
| -#endif
|
| -
|
| -typedef std::map<std::string, std::string> MetaDataMap;
|
|
|
| struct WebRtcLogPaths {
|
| base::FilePath log_path; // todo: rename to directory.
|
| @@ -44,32 +31,7 @@ struct WebRtcLogPaths {
|
| base::FilePath outgoing_rtp_dump;
|
| };
|
|
|
| -class WebRtcLogBuffer {
|
| - public:
|
| - WebRtcLogBuffer();
|
| - ~WebRtcLogBuffer();
|
| -
|
| - void Log(const std::string& message);
|
| -
|
| - // Returns a circular buffer instance for reading the internal log buffer.
|
| - // Must only be called after the log has been marked as complete
|
| - // (see SetComplete) and the caller must ensure that the WebRtcLogBuffer
|
| - // instance remains in scope for the lifetime of the returned circular buffer.
|
| - PartialCircularBuffer Read();
|
| -
|
| - // Switches the buffer to read-only mode, where access to the internal
|
| - // buffer is allowed from different threads than were used to contribute
|
| - // to the log. Calls to Log() won't be allowed after calling
|
| - // SetComplete() and the call to SetComplete() must be done on the same
|
| - // thread as constructed the buffer and calls Log().
|
| - void SetComplete();
|
| -
|
| - private:
|
| - base::ThreadChecker thread_checker_;
|
| - uint8_t buffer_[kWebRtcLogSize];
|
| - PartialCircularBuffer circular_;
|
| - bool read_only_;
|
| -};
|
| +typedef std::map<std::string, std::string> MetaDataMap;
|
|
|
| // WebRtcLoggingHandlerHost handles operations regarding the WebRTC logging:
|
| // - Opens a shared memory buffer that the handler in the render process
|
| @@ -106,8 +68,8 @@ class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter {
|
| // called. Must be called on the IO thread.
|
| void StopLogging(const GenericDoneCallback& callback);
|
|
|
| - // Uploads the log and the RTP dumps. Discards the local copy. May only be
|
| - // called after logging has stopped. Must be called on the IO thread.
|
| + // Uploads the text log and the RTP dumps. Discards the local copy. May only
|
| + // be called after text logging has stopped. Must be called on the IO thread.
|
| void UploadLog(const UploadDoneCallback& callback);
|
|
|
| // Uploads a log that was previously saved via a call to StoreLog().
|
| @@ -126,10 +88,6 @@ class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter {
|
| // Stores the log locally using a hash of log_id + security origin.
|
| void StoreLog(const std::string& log_id, const GenericDoneCallback& callback);
|
|
|
| - // Adds a message to the log.
|
| - // This method must be called on the IO thread.
|
| - void LogMessage(const std::string& message);
|
| -
|
| // May be called on any thread. |upload_log_on_render_close_| is used
|
| // for decision making and it's OK if it changes before the execution based
|
| // on that decision has finished.
|
| @@ -160,24 +118,6 @@ class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter {
|
| bool incoming);
|
|
|
| private:
|
| - // States used for protecting from function calls made at non-allowed points
|
| - // in time. For example, StartLogging() is only allowed in CLOSED state.
|
| - // Transitions: SetMetaData(): CLOSED -> CLOSED.
|
| - // StartLogging(): CLOSED -> STARTING.
|
| - // Start done: STARTING -> STARTED.
|
| - // StopLogging(): STARTED -> STOPPING.
|
| - // Stop done: STOPPING -> STOPPED.
|
| - // UploadLog(): STOPPED -> UPLOADING.
|
| - // Upload done: UPLOADING -> CLOSED.
|
| - // DiscardLog(): STOPPED -> CLOSED.
|
| - enum LoggingState {
|
| - CLOSED, // Logging not started, no log in memory.
|
| - STARTING, // Start logging is in progress.
|
| - STARTED, // Logging started.
|
| - STOPPING, // Stop logging is in progress.
|
| - STOPPED, // Logging has been stopped, log still open in memory.
|
| - };
|
| -
|
| friend class content::BrowserThread;
|
| friend class base::DeleteHelper<WebRtcLoggingHandlerHost>;
|
|
|
| @@ -192,13 +132,6 @@ class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter {
|
| void OnAddLogMessages(const std::vector<WebRtcLoggingMessageData>& messages);
|
| void OnLoggingStoppedInRenderer();
|
|
|
| - void LogInitialInfoOnFileThread(const GenericDoneCallback& callback);
|
| - void LogInitialInfoOnIOThread(const net::NetworkInterfaceList& network_list,
|
| - const GenericDoneCallback& callback);
|
| -
|
| - void EnableBrowserProcessLoggingOnUIThread();
|
| - void DisableBrowserProcessLoggingOnUIThread();
|
| -
|
| // Called after stopping RTP dumps.
|
| void StoreLogContinue(const std::string& log_id,
|
| const GenericDoneCallback& callback);
|
| @@ -248,36 +181,18 @@ class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter {
|
| bool success,
|
| const std::string& error_message);
|
|
|
| - std::unique_ptr<WebRtcLogBuffer> log_buffer_;
|
| + // The render process ID this object belongs to.
|
| + int render_process_id_;
|
|
|
| // The profile associated with our renderer process.
|
| Profile* const profile_;
|
|
|
| - // These are only accessed on the IO thread, except when in STARTING state. In
|
| - // this state we are protected since entering any function that alters the
|
| - // state is not allowed.
|
| - std::unique_ptr<MetaDataMap> meta_data_;
|
| -
|
| - // These are only accessed on the IO thread.
|
| - GenericDoneCallback stop_callback_;
|
| -
|
| - // Only accessed on the IO thread, except when in STARTING, STOPPING or
|
| - // UPLOADING state if the action fails and the state must be reset. In these
|
| - // states however, we are protected since entering any function that alters
|
| - // the state is not allowed.
|
| - LoggingState logging_state_;
|
| -
|
| // Only accessed on the IO thread.
|
| bool upload_log_on_render_close_;
|
|
|
| - // This is the handle to be passed to the render process. It's stored so that
|
| - // it doesn't have to be passed on when posting messages between threads.
|
| - // It's only accessed on the IO thread.
|
| - base::SharedMemoryHandle foreign_memory_handle_;
|
| -
|
| - // The system time in ms when logging is started. Reset when logging_state_
|
| - // changes to STOPPED.
|
| - base::Time logging_started_time_;
|
| + // The text log handler owns the WebRtcLogBuffer object and keeps track of
|
| + // the logging state. It is a scoped_refptr to allow posting tasks.
|
| + scoped_refptr<WebRtcTextLogHandler> text_log_handler_;
|
|
|
| // The RTP dump handler responsible for creating the RTP header dump files.
|
| std::unique_ptr<WebRtcRtpDumpHandler> rtp_dump_handler_;
|
| @@ -289,8 +204,6 @@ class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter {
|
| // Ownership lies with the browser process.
|
| WebRtcLogUploader* const log_uploader_;
|
|
|
| - // The render process ID this object belongs to.
|
| - int render_process_id_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost);
|
| };
|
|
|