Convert CallbackList::Subscription to a standalone class.
Bug: 1103086
AX-Relnotes: n/a.
TBR: pinkerton
Change-Id: I3b241eb7234727f314dd85d1bdbb3a41ceca5938
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2522860
Reviewed-by: Peter Kasting <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: danakj <[email protected]>
Commit-Queue: Peter Kasting <[email protected]>
Auto-Submit: Peter Kasting <[email protected]>
Cr-Commit-Position: refs/heads/master@{#830015}
diff --git a/content/browser/host_zoom_map_impl.cc b/content/browser/host_zoom_map_impl.cc
index abf19eb9..9332680 100644
--- a/content/browser/host_zoom_map_impl.cc
+++ b/content/browser/host_zoom_map_impl.cc
@@ -331,8 +331,7 @@
}
}
-std::unique_ptr<HostZoomMap::Subscription>
-HostZoomMapImpl::AddZoomLevelChangedCallback(
+base::CallbackListSubscription HostZoomMapImpl::AddZoomLevelChangedCallback(
ZoomLevelChangedCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
return zoom_level_changed_callbacks_.Add(std::move(callback));
diff --git a/content/browser/host_zoom_map_impl.h b/content/browser/host_zoom_map_impl.h
index 6fe489bf..fb2d6c1 100644
--- a/content/browser/host_zoom_map_impl.h
+++ b/content/browser/host_zoom_map_impl.h
@@ -54,7 +54,7 @@
int render_view_id) override;
double GetDefaultZoomLevel() override;
void SetDefaultZoomLevel(double level) override;
- std::unique_ptr<Subscription> AddZoomLevelChangedCallback(
+ base::CallbackListSubscription AddZoomLevelChangedCallback(
ZoomLevelChangedCallback callback) override;
// Returns the current zoom level for the specified WebContents. This may
diff --git a/content/browser/network_service_instance_impl.cc b/content/browser/network_service_instance_impl.cc
index 9358b38..5675cc8 100644
--- a/content/browser/network_service_instance_impl.cc
+++ b/content/browser/network_service_instance_impl.cc
@@ -397,8 +397,8 @@
return g_network_service_remote->get();
}
-std::unique_ptr<base::CallbackList<void()>::Subscription>
-RegisterNetworkServiceCrashHandler(base::RepeatingClosure handler) {
+base::CallbackListSubscription RegisterNetworkServiceCrashHandler(
+ base::RepeatingClosure handler) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!handler.is_null());
diff --git a/content/browser/network_service_instance_impl.h b/content/browser/network_service_instance_impl.h
index b02875a..e590832 100644
--- a/content/browser/network_service_instance_impl.h
+++ b/content/browser/network_service_instance_impl.h
@@ -24,7 +24,7 @@
// mojo::Remote<URLLoaderFactory>).
//
// Can only be called on the UI thread. No-op if NetworkService is disabled.
-CONTENT_EXPORT std::unique_ptr<base::CallbackList<void()>::Subscription>
+CONTENT_EXPORT base::CallbackListSubscription
RegisterNetworkServiceCrashHandler(base::RepeatingClosure handler);
// Corresponds to the "NetworkServiceAvailability" histogram enumeration type in
diff --git a/content/browser/network_service_restart_browsertest.cc b/content/browser/network_service_restart_browsertest.cc
index e361b3c..412cbcc 100644
--- a/content/browser/network_service_restart_browsertest.cc
+++ b/content/browser/network_service_restart_browsertest.cc
@@ -357,10 +357,12 @@
// Register 2 crash handlers.
int counter1 = 0;
int counter2 = 0;
- auto handler1 = RegisterNetworkServiceCrashHandler(
- base::BindRepeating(&IncrementInt, base::Unretained(&counter1)));
- auto handler2 = RegisterNetworkServiceCrashHandler(
- base::BindRepeating(&IncrementInt, base::Unretained(&counter2)));
+ base::CallbackListSubscription subscription1 =
+ RegisterNetworkServiceCrashHandler(
+ base::BindRepeating(&IncrementInt, base::Unretained(&counter1)));
+ base::CallbackListSubscription subscription2 =
+ RegisterNetworkServiceCrashHandler(
+ base::BindRepeating(&IncrementInt, base::Unretained(&counter2)));
// Crash the NetworkService process.
SimulateNetworkServiceCrash();
@@ -381,7 +383,7 @@
EXPECT_TRUE(network_context.is_bound());
// Unregister one of the handlers.
- handler2.reset();
+ subscription2 = {};
// Crash the NetworkService process.
SimulateNetworkServiceCrash();
diff --git a/content/browser/renderer_host/navigation_request.cc b/content/browser/renderer_host/navigation_request.cc
index 34667f7..763384c 100644
--- a/content/browser/renderer_host/navigation_request.cc
+++ b/content/browser/renderer_host/navigation_request.cc
@@ -4549,7 +4549,7 @@
void NavigationRequest::StopCommitTimeout() {
commit_timeout_timer_.Stop();
- render_process_blocked_state_changed_subscription_.reset();
+ render_process_blocked_state_changed_subscription_ = {};
GetRenderFrameHost()->GetRenderWidgetHost()->RendererIsResponsive();
}
@@ -4599,7 +4599,7 @@
UMA_HISTOGRAM_BOOLEAN("Navigation.CommitTimeout.IsMainFrame",
frame_tree_node_->IsMainFrame());
base::UmaHistogramSparse("Navigation.CommitTimeout.ErrorCode", -net_error_);
- render_process_blocked_state_changed_subscription_.reset();
+ render_process_blocked_state_changed_subscription_ = {};
GetRenderFrameHost()->GetRenderWidgetHost()->RendererIsUnresponsive(
base::BindRepeating(&NavigationRequest::RestartCommitTimeout,
weak_factory_.GetWeakPtr()));
diff --git a/content/browser/renderer_host/navigation_request.h b/content/browser/renderer_host/navigation_request.h
index 25efdfcc..f398fd05 100644
--- a/content/browser/renderer_host/navigation_request.h
+++ b/content/browser/renderer_host/navigation_request.h
@@ -1382,10 +1382,7 @@
// Timer for detecting an unexpectedly long time to commit a navigation.
base::OneShotTimer commit_timeout_timer_;
- // The subscription to the notification of the changing of the render
- // process's blocked state.
- std::unique_ptr<
- RenderProcessHost::BlockStateChangedCallbackList::Subscription>
+ base::CallbackListSubscription
render_process_blocked_state_changed_subscription_;
// The headers used for the request. The value of this comes from
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index c695b50..460905c8 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -681,8 +681,7 @@
return spare_render_process_host_;
}
- std::unique_ptr<base::CallbackList<void(RenderProcessHost*)>::Subscription>
- RegisterSpareRenderProcessHostChangedCallback(
+ base::CallbackListSubscription RegisterSpareRenderProcessHostChangedCallback(
const base::RepeatingCallback<void(RenderProcessHost*)>& cb) {
// Do an initial notification, as the subscriber will need to know what the
// current spare host is.
@@ -1178,10 +1177,9 @@
process->CleanupNetworkServicePluginExceptionsUponDestruction();
- static base::NoDestructor<
- std::unique_ptr<base::CallbackList<void()>::Subscription>>
+ static base::NoDestructor<base::CallbackListSubscription>
s_crash_handler_subscription;
- if (!*s_crash_handler_subscription) {
+ if (!(*s_crash_handler_subscription)) {
*s_crash_handler_subscription = RegisterNetworkServiceCrashHandler(
base::BindRepeating(&OnNetworkServiceCrashRestorePluginExceptions));
}
@@ -3056,7 +3054,7 @@
}
// static
-std::unique_ptr<base::CallbackList<void(RenderProcessHost*)>::Subscription>
+base::CallbackListSubscription
RenderProcessHost::RegisterSpareRenderProcessHostChangedCallback(
const base::RepeatingCallback<void(RenderProcessHost*)>& cb) {
return SpareRenderProcessHostManager::GetInstance()
@@ -3709,7 +3707,7 @@
return is_blocked_;
}
-std::unique_ptr<RenderProcessHost::BlockStateChangedCallbackList::Subscription>
+base::CallbackListSubscription
RenderProcessHostImpl::RegisterBlockStateChangedCallback(
const BlockStateChangedCallback& cb) {
return blocked_state_changed_callback_list_.Add(cb);
diff --git a/content/browser/renderer_host/render_process_host_impl.h b/content/browser/renderer_host/render_process_host_impl.h
index 8a2dea9..379f466 100644
--- a/content/browser/renderer_host/render_process_host_impl.h
+++ b/content/browser/renderer_host/render_process_host_impl.h
@@ -202,8 +202,7 @@
bool IsInitializedAndNotDead() override;
void SetBlocked(bool blocked) override;
bool IsBlocked() override;
- std::unique_ptr<base::CallbackList<void(bool)>::Subscription>
- RegisterBlockStateChangedCallback(
+ base::CallbackListSubscription RegisterBlockStateChangedCallback(
const BlockStateChangedCallback& cb) override;
void Cleanup() override;
void AddPendingView() override;
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index af1607c..7378a52 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -2189,7 +2189,7 @@
// on the renderer to delete Popup widgets.
blink_popup_widget_host_receiver_.reset();
- render_process_blocked_state_changed_subscription_.reset();
+ render_process_blocked_state_changed_subscription_ = {};
pending_show_closure_.Reset();
GetProcess()->RemovePriorityClient(this);
GetProcess()->RemoveObserver(this);
diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h
index fba8cc5..32191b4 100644
--- a/content/browser/renderer_host/render_widget_host_impl.h
+++ b/content/browser/renderer_host/render_widget_host_impl.h
@@ -1235,8 +1235,7 @@
base::OneShotTimer input_event_ack_timeout_;
- std::unique_ptr<
- RenderProcessHost::BlockStateChangedCallbackList::Subscription>
+ base::CallbackListSubscription
render_process_blocked_state_changed_subscription_;
std::unique_ptr<TimeoutMonitor> new_content_rendering_timeout_;