Commit 0347ae6c authored by David Bokan's avatar David Bokan Committed by Chromium LUCI CQ

Convert LogSourceResource to OnceClosure

This class keeps a callback that's called only when it's destructed so
it can only ever be called once. Hence, it should be a OnceClosure.

Bug: 1152268
Change-Id: I39188310b5b2f61547b983ca1d20ab9c1581b505
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2601068Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839755}
parent fe1589f8
......@@ -223,7 +223,7 @@ LogSourceAccessManager::ResourceId LogSourceAccessManager::CreateResource(
// passed in as part of a callback.
resource_manager->Get(extension_id, resource_id)
->set_unregister_callback(
base::Bind(&LogSourceAccessManager::RemoveHandle,
base::BindOnce(&LogSourceAccessManager::RemoveHandle,
weak_factory_.GetWeakPtr(), resource_id));
open_handles_.emplace(
......
......@@ -27,7 +27,7 @@ LogSourceResource::LogSourceResource(
LogSourceResource::~LogSourceResource() {
if (!unregister_callback_.is_null())
unregister_callback_.Run();
std::move(unregister_callback_).Run();
}
} // namespace extensions
......@@ -31,8 +31,8 @@ class LogSourceResource : public ApiResource {
system_logs::SystemLogsSource* GetLogSource() const { return source_.get(); }
void set_unregister_callback(const base::Closure& unregister_callback) {
unregister_callback_ = unregister_callback;
void set_unregister_callback(base::OnceClosure unregister_callback) {
unregister_callback_ = std::move(unregister_callback);
}
private:
......@@ -43,7 +43,7 @@ class LogSourceResource : public ApiResource {
// This unregisters the LogSourceResource from a LogSourceAccessManager when
// this resource is cleaned up.
base::Closure unregister_callback_;
base::OnceClosure unregister_callback_;
DISALLOW_COPY_AND_ASSIGN(LogSourceResource);
};
......
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