Commit a8f41a37 authored by Elad Alon's avatar Elad Alon Committed by Commit Bot

Nits to webrtc_event_log_manager.cc/h

Bug: None
Change-Id: I8bed811ba52e7ecf0dd772c0222bc57d8b99f46d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1886821Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Elad Alon <eladalon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710729}
parent 07b7ab6a
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "chrome/browser/media/webrtc/webrtc_event_log_manager.h" #include "chrome/browser/media/webrtc/webrtc_event_log_manager.h"
#include <limits>
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
...@@ -186,6 +188,7 @@ WebRtcEventLogManager::WebRtcEventLogManager() ...@@ -186,6 +188,7 @@ WebRtcEventLogManager::WebRtcEventLogManager()
base::TaskPriority::BEST_EFFORT, base::TaskPriority::BEST_EFFORT,
base::ThreadPolicy::PREFER_BACKGROUND, base::ThreadPolicy::PREFER_BACKGROUND,
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})), base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})),
num_user_blocking_tasks_(0),
remote_logging_feature_enabled_(IsRemoteLoggingFeatureEnabled()), remote_logging_feature_enabled_(IsRemoteLoggingFeatureEnabled()),
local_logs_observer_(nullptr), local_logs_observer_(nullptr),
remote_logs_observer_(nullptr), remote_logs_observer_(nullptr),
...@@ -482,10 +485,10 @@ void WebRtcEventLogManager::ClearCacheForBrowserContext( ...@@ -482,10 +485,10 @@ void WebRtcEventLogManager::ClearCacheForBrowserContext(
const auto browser_context_id = GetBrowserContextId(browser_context); const auto browser_context_id = GetBrowserContextId(browser_context);
DCHECK_NE(browser_context_id, kNullBrowserContextId); DCHECK_NE(browser_context_id, kNullBrowserContextId);
// |task_runner_| is USER_BLOCKING when there are pending tasks to clear the DCHECK_LT(num_user_blocking_tasks_, std::numeric_limits<size_t>::max());
// cache. if (++num_user_blocking_tasks_ == 1) {
++num_pending_clear_cache_;
task_runner_->UpdatePriority(base::TaskPriority::USER_BLOCKING); task_runner_->UpdatePriority(base::TaskPriority::USER_BLOCKING);
}
// |this| is destroyed by ~BrowserProcessImpl(), so base::Unretained(this) // |this| is destroyed by ~BrowserProcessImpl(), so base::Unretained(this)
// will not be dereferenced after destruction. // will not be dereferenced after destruction.
...@@ -951,12 +954,10 @@ void WebRtcEventLogManager::ClearCacheForBrowserContextInternal( ...@@ -951,12 +954,10 @@ void WebRtcEventLogManager::ClearCacheForBrowserContextInternal(
void WebRtcEventLogManager::OnClearCacheForBrowserContextDoneInternal( void WebRtcEventLogManager::OnClearCacheForBrowserContextDoneInternal(
base::OnceClosure reply) { base::OnceClosure reply) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK_GT(num_pending_clear_cache_, 0); DCHECK_GT(num_user_blocking_tasks_, 0u);
// |task_runner_| is BEST_EFFORT when there are no pending tasks to clear the if (--num_user_blocking_tasks_ == 0) {
// cache.
--num_pending_clear_cache_;
if (num_pending_clear_cache_ == 0)
task_runner_->UpdatePriority(base::TaskPriority::BEST_EFFORT); task_runner_->UpdatePriority(base::TaskPriority::BEST_EFFORT);
}
std::move(reply).Run(); std::move(reply).Run();
} }
......
...@@ -368,9 +368,11 @@ class WebRtcEventLogManager final : public content::RenderProcessHostObserver, ...@@ -368,9 +368,11 @@ class WebRtcEventLogManager final : public content::RenderProcessHostObserver,
// tasks are allowed. // tasks are allowed.
scoped_refptr<base::UpdateableSequencedTaskRunner> task_runner_; scoped_refptr<base::UpdateableSequencedTaskRunner> task_runner_;
// The number of pending tasks to clear the cache. The priority of // The number of user-blocking tasks.
// |task_runner_| is increased to USER_BLOCKING when this is non-zero. // The priority of |task_runner_| is increased to USER_BLOCKING when this is
int num_pending_clear_cache_ = 0; // non-zero, and reduced to BEST_EFFORT when zero.
// This object is only to be accessed on the UI thread.
size_t num_user_blocking_tasks_;
// Indicates whether remote-bound logging is generally allowed, although // Indicates whether remote-bound logging is generally allowed, although
// possibly not for all profiles. This makes it possible for remote-bound to // possibly not for all profiles. This makes it possible for remote-bound to
......
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