Chromium Code Reviews| 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 a35bf3e5bf84696cd44d1fd125514162cc74d177..39196c3fcf7bda9fa85a743942c3d230ef5a26a3 100644 |
| --- a/chrome/browser/media/webrtc_logging_handler_host.h |
| +++ b/chrome/browser/media/webrtc_logging_handler_host.h |
| @@ -22,9 +22,64 @@ class RenderProcessHost; |
| // the log. |
| class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter { |
| public: |
| + typedef base::Callback<void(bool, std::string)> GenericDoneCallback; |
| + typedef base::Callback<void(bool, std::string, std::string)> |
| + UploadDoneCallback; |
| + |
| WebRtcLoggingHandlerHost(); |
| + // Sets meta data that will be uploaded along with the log and also written |
| + // in the beginning of the log. Must be called on the IO thread before calling |
| + // StartLogging. |
| + void SetMetaData(const std::map<std::string, std::string>& meta_data, |
| + const GenericDoneCallback& callback); |
| + |
| + // Opens a log and starts logging. Must be called on the IO thread. |
| + void StartLogging(const std::string& app_url, |
| + const GenericDoneCallback& callback); |
| + |
| + // Stops logging. Log will remain open until UploadLog or DiscardLog is |
| + // called. Must be called on the IO thread. |
| + void StopLogging(const GenericDoneCallback& callback); |
| + |
| + // Uploads the log and discards the local copy. May only be called after |
| + // logging has stopped. Must be called on the IO thread. |
| + void UploadLog(const UploadDoneCallback& callback); |
| + |
| + // Called by WebRtcLogUploader when uploading has finished. Must be called on |
| + // the IO thread. |
| + void UploadLogDone(); |
| + |
| + // Discards the log. May only be called after logging has stopped. Must be |
| + // called on the IO thread. |
| + void DiscardLog(const GenericDoneCallback& callback); |
| + |
| + // 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. |
| + void set_upload_log_on_render_close(bool should_upload) { |
| + upload_log_on_render_close_ = should_upload; |
| + } |
| + |
| private: |
| + // States used for protecting from function calls made at non-allowed points |
|
Jói
2013/09/27 14:39:53
I <3 DFMSs!
Henrik Grunell
2013/10/02 12:47:18
Happy to hear. :)
|
| + // in time. For example, OpenLog() is only allowed in CLOSED state. |
| + // Transitions: OpenLog(): CLOSED -> STARTING. |
|
Jói
2013/09/27 14:39:53
Missing transition: SetMetaData(): CLOSED -> CLOSE
Henrik Grunell
2013/10/02 12:47:18
Done. Also updated the function and state names in
|
| + // Open done: STARTING -> OPEN_STARTED. |
| + // CloseLog(): OPEN_STARTED -> STOPPING. |
| + // Close done: STOPPING -> OPEN_STOPPED. |
| + // UploadLog(): OPEN_STOPPED -> UPLOADING. |
| + // Upload done: UPLOADING -> CLOSED. |
| + // DiscardLog(): OPEN_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. |
| + UPLOADING // Uploading log is in progress. |
| + }; |
| + |
| friend class content::BrowserThread; |
| friend class base::DeleteHelper<WebRtcLoggingHandlerHost>; |
| @@ -36,20 +91,43 @@ class WebRtcLoggingHandlerHost : public content::BrowserMessageFilter { |
| virtual bool OnMessageReceived(const IPC::Message& message, |
| bool* message_was_ok) OVERRIDE; |
| - void OnOpenLog(const std::string& app_session_id, const std::string& app_url); |
| + void OnLoggingStoppedInRenderer(); |
| - void OpenLogIfAllowed(); |
| - void DoOpenLog(); |
| + void StartLoggingIfAllowed(); |
| + void DoStartLogging(); |
| void LogMachineInfo(); |
| - void NotifyLogOpened(); |
| + void NotifyLoggingStarted(); |
| - void UploadLog(); |
| + void TriggerUploadLog(); |
| + |
| + void FireGenericDoneCallback(GenericDoneCallback* callback, |
| + bool success, |
| + const std::string& error_message); |
| scoped_refptr<net::URLRequestContextGetter> system_request_context_; |
| scoped_ptr<base::SharedMemory> shared_memory_; |
| - std::string app_session_id_; |
| + |
| + // 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::map<std::string, std::string> meta_data_; |
| + // TODO(grunell): Remove (let the meta data contains the url)? |
| std::string app_url_; |
| + // These are only accessed on the IO thread. |
| + GenericDoneCallback start_callback_; |
| + GenericDoneCallback stop_callback_; |
| + UploadDoneCallback upload_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. |