Commit 09aa7228 authored by Darin Fisher's avatar Darin Fisher Committed by Commit Bot

Switch WebRtcLoggingHandlerHost back to being ref-counted.

This change reverts WebRtcLoggingHandlerHost to being a ref-counted
class so its lifetime can be extended via PostTask. This allows the
class to finish its work after the tab or window is closed.

As part of this change, WebRtcLoggingHandlerHost is renamed to
WebRtcLoggingController since it is no longer a legacy IPC "host"
class. This new name better reflects its role in being the main class
used to control webrtc logging from the browser-side.

Bug: 989458
Change-Id: I9cbac4c93278e597e7a782cd79eb34550ded1c7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1774052
Commit-Queue: Tommi <tommi@chromium.org>
Reviewed-by: default avatarTommi <tommi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691553}
parent 44450c79
...@@ -752,8 +752,8 @@ jumbo_split_static_library("browser") { ...@@ -752,8 +752,8 @@ jumbo_split_static_library("browser") {
"media/webrtc/webrtc_log_uploader.h", "media/webrtc/webrtc_log_uploader.h",
"media/webrtc/webrtc_log_util.cc", "media/webrtc/webrtc_log_util.cc",
"media/webrtc/webrtc_log_util.h", "media/webrtc/webrtc_log_util.h",
"media/webrtc/webrtc_logging_handler_host.cc", "media/webrtc/webrtc_logging_controller.cc",
"media/webrtc/webrtc_logging_handler_host.h", "media/webrtc/webrtc_logging_controller.h",
"media/webrtc/webrtc_rtp_dump_handler.cc", "media/webrtc/webrtc_rtp_dump_handler.cc",
"media/webrtc/webrtc_rtp_dump_handler.h", "media/webrtc/webrtc_rtp_dump_handler.h",
"media/webrtc/webrtc_rtp_dump_writer.cc", "media/webrtc/webrtc_rtp_dump_writer.cc",
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
#include "chrome/browser/media/router/presentation/receiver_presentation_service_delegate_impl.h" #include "chrome/browser/media/router/presentation/receiver_presentation_service_delegate_impl.h"
#include "chrome/browser/media/webrtc/audio_debug_recordings_handler.h" #include "chrome/browser/media/webrtc/audio_debug_recordings_handler.h"
#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
#include "chrome/browser/media/webrtc/webrtc_logging_handler_host.h" #include "chrome/browser/media/webrtc/webrtc_logging_controller.h"
#include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h"
#include "chrome/browser/metrics/chrome_feature_list_creator.h" #include "chrome/browser/metrics/chrome_feature_list_creator.h"
#include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
...@@ -1388,7 +1388,7 @@ void ChromeContentBrowserClient::RenderProcessWillLaunch( ...@@ -1388,7 +1388,7 @@ void ChromeContentBrowserClient::RenderProcessWillLaunch(
host->AddFilter(new prerender::PrerenderMessageFilter(id, profile)); host->AddFilter(new prerender::PrerenderMessageFilter(id, profile));
host->AddFilter(new TtsMessageFilter(host->GetBrowserContext())); host->AddFilter(new TtsMessageFilter(host->GetBrowserContext()));
WebRtcLoggingHandlerHost::AttachToRenderProcessHost( WebRtcLoggingController::AttachToRenderProcessHost(
host, g_browser_process->webrtc_log_uploader()); host, g_browser_process->webrtc_log_uploader());
// The audio manager outlives the host, so it's safe to hand a raw pointer to // The audio manager outlives the host, so it's safe to hand a raw pointer to
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "chrome/browser/extensions/chrome_extension_function.h" #include "chrome/browser/extensions/chrome_extension_function.h"
#include "chrome/browser/media/webrtc/audio_debug_recordings_handler.h" #include "chrome/browser/media/webrtc/audio_debug_recordings_handler.h"
#include "chrome/browser/media/webrtc/webrtc_logging_handler_host.h" #include "chrome/browser/media/webrtc/webrtc_logging_controller.h"
#include "chrome/common/extensions/api/webrtc_logging_private.h" #include "chrome/common/extensions/api/webrtc_logging_private.h"
#include "media/media_buildflags.h" #include "media/media_buildflags.h"
...@@ -32,7 +32,7 @@ class WebrtcLoggingPrivateFunction : public ChromeAsyncExtensionFunction { ...@@ -32,7 +32,7 @@ class WebrtcLoggingPrivateFunction : public ChromeAsyncExtensionFunction {
const api::webrtc_logging_private::RequestInfo& request, const api::webrtc_logging_private::RequestInfo& request,
const std::string& security_origin); const std::string& security_origin);
WebRtcLoggingHandlerHost* LoggingHandlerFromRequest( WebRtcLoggingController* LoggingControllerFromRequest(
const api::webrtc_logging_private::RequestInfo& request, const api::webrtc_logging_private::RequestInfo& request,
const std::string& security_origin); const std::string& security_origin);
}; };
...@@ -42,14 +42,14 @@ class WebrtcLoggingPrivateFunctionWithGenericCallback ...@@ -42,14 +42,14 @@ class WebrtcLoggingPrivateFunctionWithGenericCallback
protected: protected:
~WebrtcLoggingPrivateFunctionWithGenericCallback() override {} ~WebrtcLoggingPrivateFunctionWithGenericCallback() override {}
// Finds the appropriate logging handler for performing the task and prepares // Finds the appropriate logging controller for performing the task and
// a generic callback object for when the task is completed. // prepares a generic callback object for when the task is completed. If the
// If the logging handler can't be found for the given request+origin, the // logging controller can't be found for the given request+origin, the
// returned ptr will be null. // returned ptr will be null.
WebRtcLoggingHandlerHost* PrepareTask( WebRtcLoggingController* PrepareTask(
const api::webrtc_logging_private::RequestInfo& request, const api::webrtc_logging_private::RequestInfo& request,
const std::string& security_origin, const std::string& security_origin,
WebRtcLoggingHandlerHost::GenericDoneCallback* callback); WebRtcLoggingController::GenericDoneCallback* callback);
// Must be called on UI thread. // Must be called on UI thread.
void FireCallback(bool success, const std::string& error_message); void FireCallback(bool success, const std::string& error_message);
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_MEDIA_WEBRTC_WEBRTC_LOGGING_HANDLER_HOST_H_ #ifndef CHROME_BROWSER_MEDIA_WEBRTC_WEBRTC_LOGGING_CONTROLLER_H_
#define CHROME_BROWSER_MEDIA_WEBRTC_WEBRTC_LOGGING_HANDLER_HOST_H_ #define CHROME_BROWSER_MEDIA_WEBRTC_WEBRTC_LOGGING_CONTROLLER_H_
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/ref_counted.h"
#include "base/supports_user_data.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/media/webrtc/rtp_dump_type.h" #include "chrome/browser/media/webrtc/rtp_dump_type.h"
#include "chrome/browser/media/webrtc/webrtc_log_uploader.h" #include "chrome/browser/media/webrtc/webrtc_log_uploader.h"
...@@ -32,7 +31,7 @@ namespace content { ...@@ -32,7 +31,7 @@ namespace content {
class BrowserContext; class BrowserContext;
} // namespace content } // namespace content
// WebRtcLoggingHandlerHost handles operations regarding the WebRTC logging: // WebRtcLoggingController handles operations regarding the WebRTC logging:
// - Opens a connection to a WebRtcLoggingAgent that runs in the render process // - Opens a connection to a WebRtcLoggingAgent that runs in the render process
// and generates log messages. // and generates log messages.
// - Writes basic machine info to the log. // - Writes basic machine info to the log.
...@@ -41,8 +40,9 @@ class BrowserContext; ...@@ -41,8 +40,9 @@ class BrowserContext;
// or triggers uploading of the log. // or triggers uploading of the log.
// - Detects when the agent (e.g., because of a tab closure or crash) is going // - Detects when the agent (e.g., because of a tab closure or crash) is going
// away and possibly triggers uploading the log. // away and possibly triggers uploading the log.
class WebRtcLoggingHandlerHost : public base::SupportsUserData::Data, class WebRtcLoggingController
public chrome::mojom::WebRtcLoggingClient { : public base::RefCounted<WebRtcLoggingController>,
public chrome::mojom::WebRtcLoggingClient {
public: public:
typedef WebRtcLogUploader::GenericDoneCallback GenericDoneCallback; typedef WebRtcLogUploader::GenericDoneCallback GenericDoneCallback;
typedef WebRtcLogUploader::UploadDoneCallback UploadDoneCallback; typedef WebRtcLogUploader::UploadDoneCallback UploadDoneCallback;
...@@ -59,7 +59,7 @@ class WebRtcLoggingHandlerHost : public base::SupportsUserData::Data, ...@@ -59,7 +59,7 @@ class WebRtcLoggingHandlerHost : public base::SupportsUserData::Data,
static void AttachToRenderProcessHost(content::RenderProcessHost* host, static void AttachToRenderProcessHost(content::RenderProcessHost* host,
WebRtcLogUploader* log_uploader); WebRtcLogUploader* log_uploader);
static WebRtcLoggingHandlerHost* FromRenderProcessHost( static WebRtcLoggingController* FromRenderProcessHost(
content::RenderProcessHost* host); content::RenderProcessHost* host);
// Sets meta data that will be uploaded along with the log and also written // Sets meta data that will be uploaded along with the log and also written
...@@ -143,16 +143,18 @@ class WebRtcLoggingHandlerHost : public base::SupportsUserData::Data, ...@@ -143,16 +143,18 @@ class WebRtcLoggingHandlerHost : public base::SupportsUserData::Data,
void OnStopped() override; void OnStopped() override;
private: private:
WebRtcLoggingHandlerHost(int render_process_id, friend class base::RefCounted<WebRtcLoggingController>;
content::BrowserContext* browser_context,
WebRtcLogUploader* log_uploader); WebRtcLoggingController(int render_process_id,
~WebRtcLoggingHandlerHost() override; content::BrowserContext* browser_context,
WebRtcLogUploader* log_uploader);
~WebRtcLoggingController() override;
void OnAgentDisconnected(); void OnAgentDisconnected();
// Called after stopping RTP dumps. // Called after stopping RTP dumps.
void StoreLogContinue(const std::string& log_id, void StoreLogContinue(const std::string& log_id,
const GenericDoneCallback& callback); const GenericDoneCallback& callback);
// Writes a formatted log |message| to the |circular_buffer_|. // Writes a formatted log |message| to the |circular_buffer_|.
void LogToCircularBuffer(const std::string& message); void LogToCircularBuffer(const std::string& message);
...@@ -182,7 +184,7 @@ class WebRtcLoggingHandlerHost : public base::SupportsUserData::Data, ...@@ -182,7 +184,7 @@ class WebRtcLoggingHandlerHost : public base::SupportsUserData::Data,
bool ReleaseRtpDumps(WebRtcLogPaths* log_paths); bool ReleaseRtpDumps(WebRtcLogPaths* log_paths);
void FireGenericDoneCallback( void FireGenericDoneCallback(
const WebRtcLoggingHandlerHost::GenericDoneCallback& callback, const WebRtcLoggingController::GenericDoneCallback& callback,
bool success, bool success,
const std::string& error_message); const std::string& error_message);
...@@ -234,9 +236,7 @@ class WebRtcLoggingHandlerHost : public base::SupportsUserData::Data, ...@@ -234,9 +236,7 @@ class WebRtcLoggingHandlerHost : public base::SupportsUserData::Data,
// the empty string. // the empty string.
int web_app_id_ = 0; int web_app_id_ = 0;
base::WeakPtrFactory<WebRtcLoggingHandlerHost> weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingController);
DISALLOW_COPY_AND_ASSIGN(WebRtcLoggingHandlerHost);
}; };
#endif // CHROME_BROWSER_MEDIA_WEBRTC_WEBRTC_LOGGING_HANDLER_HOST_H_ #endif // CHROME_BROWSER_MEDIA_WEBRTC_WEBRTC_LOGGING_CONTROLLER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment