Commit 093eb2b7 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Cleanups near callback list uses.

Mostly, converts typedef -> using per style guide. Also uses
CallbackList::CallbackType more (and more systematically), and some
other misc. cleanup like using stl_util.h, explicitly declaring types
more, etc.

Bug: none
Change-Id: I63241972f5bede0c1cdb85ade8a0ba1155979cf9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2354621
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Daniel Rubery <drubery@chromium.org>
Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Reviewed-by: default avatarRyan Sleevi <rsleevi@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarOrin Jaworski <orinj@chromium.org>
Reviewed-by: default avatarJohn Wu <jzw@chromium.org>
Reviewed-by: default avatarAchuith Bhandarkar <achuith@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798656}
parent af2991e7
......@@ -80,14 +80,12 @@ struct AccessibilityStatusEventDetails {
bool enabled;
};
typedef base::RepeatingCallback<void(const AccessibilityStatusEventDetails&)>
AccessibilityStatusCallback;
typedef base::CallbackList<void(const AccessibilityStatusEventDetails&)>
AccessibilityStatusCallbackList;
typedef AccessibilityStatusCallbackList::Subscription
AccessibilityStatusSubscription;
using AccessibilityStatusCallbackList =
base::CallbackList<void(const AccessibilityStatusEventDetails&)>;
using AccessibilityStatusCallback =
AccessibilityStatusCallbackList::CallbackType;
using AccessibilityStatusSubscription =
AccessibilityStatusCallbackList::Subscription;
class AccessibilityPanelWidgetObserver;
......
......@@ -32,8 +32,8 @@ namespace chromeos {
// make a decision.
class AutoEnrollmentController {
public:
typedef base::CallbackList<void(policy::AutoEnrollmentState)>
ProgressCallbackList;
using ProgressCallbackList =
base::CallbackList<void(policy::AutoEnrollmentState)>;
// Parameter values for the kEnterpriseEnableForcedReEnrollment flag.
static const char kForcedReEnrollmentAlways[];
......
......@@ -22,6 +22,7 @@
#include "base/notreached.h"
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
......@@ -104,10 +105,10 @@ class CloudExternalDataManagerBase::Backend {
private:
// List of callbacks to invoke when the attempt to retrieve external data
// referenced by a policy completes successfully or fails permanently.
typedef std::vector<ExternalDataFetcher::FetchCallback> FetchCallbackList;
using FetchCallbackList = std::vector<ExternalDataFetcher::FetchCallback>;
// Map from policy names to the lists of callbacks defined above.
typedef std::map<std::string, FetchCallbackList> FetchCallbackMap;
using FetchCallbackMap = std::map<std::string, FetchCallbackList>;
// Looks up the maximum size that the data referenced by |policy| can have.
size_t GetMaxExternalDataSize(const std::string& policy) const;
......@@ -214,11 +215,9 @@ void CloudExternalDataManagerBase::Backend::OnMetadataUpdated(
// Cancel the external data download.
updater_->CancelExternalDataFetch(policy);
}
for (ExternalDataFetcher::FetchCallback& callback : it->second) {
// Invoke all callbacks for |policy|, indicating permanent failure.
RunCallback(std::move(callback), std::unique_ptr<std::string>(),
base::FilePath());
}
for (ExternalDataFetcher::FetchCallback& callback : it->second)
RunCallback(std::move(callback), nullptr, base::FilePath());
pending_downloads_.erase(it++);
continue;
}
......@@ -244,8 +243,8 @@ bool CloudExternalDataManagerBase::Backend::OnDownloadSuccess(
if (external_data_store_)
file_path = external_data_store_->Store(policy, hash, data);
FetchCallbackList& pending_callbacks = pending_downloads_[policy];
for (ExternalDataFetcher::FetchCallback& callback : pending_callbacks) {
for (ExternalDataFetcher::FetchCallback& callback :
pending_downloads_[policy]) {
RunCallback(std::move(callback), std::make_unique<std::string>(data),
file_path);
}
......@@ -262,22 +261,14 @@ void CloudExternalDataManagerBase::Backend::Fetch(
if (metadata == metadata_.end()) {
// If |policy| does not reference any external data, indicate permanent
// failure.
RunCallback(std::move(callback), std::unique_ptr<std::string>(),
base::FilePath());
return;
}
if (pending_downloads_.find(policy) != pending_downloads_.end()) {
// If a download of the external data referenced by |policy| has already
// been requested, add |callback| to the list of callbacks for |policy| and
// return.
pending_downloads_[policy].push_back(std::move(callback));
RunCallback(std::move(callback), nullptr, base::FilePath());
return;
}
std::unique_ptr<std::string> data(new std::string);
if (external_data_store_) {
base::FilePath file_path =
const bool has_pending_download = base::Contains(pending_downloads_, policy);
if (!has_pending_download && external_data_store_) {
auto data = std::make_unique<std::string>();
const base::FilePath file_path =
external_data_store_->Load(policy, metadata->second.hash,
GetMaxExternalDataSize(policy), data.get());
if (!file_path.empty()) {
......@@ -288,9 +279,8 @@ void CloudExternalDataManagerBase::Backend::Fetch(
}
}
// Request a download of the the external data referenced by |policy| and
// initialize the list of callbacks by adding |callback|.
pending_downloads_[policy].push_back(std::move(callback));
if (!has_pending_download)
StartDownload(policy);
}
......@@ -300,7 +290,7 @@ void CloudExternalDataManagerBase::Backend::FetchAll() {
for (const auto& it : metadata_) {
const std::string& policy = it.first;
std::unique_ptr<std::string> data(new std::string);
if (pending_downloads_.find(policy) != pending_downloads_.end() ||
if (base::Contains(pending_downloads_, policy) ||
(external_data_store_ &&
!external_data_store_
->Load(policy, it.second.hash, GetMaxExternalDataSize(policy),
......@@ -349,7 +339,7 @@ void CloudExternalDataManagerBase::Backend::RunCallback(
void CloudExternalDataManagerBase::Backend::StartDownload(
const std::string& policy) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(pending_downloads_.find(policy) != pending_downloads_.end());
DCHECK(base::Contains(pending_downloads_, policy));
if (!updater_)
return;
......
......@@ -32,7 +32,7 @@ ServerBackedStateKeysBroker::~ServerBackedStateKeysBroker() {
ServerBackedStateKeysBroker::Subscription
ServerBackedStateKeysBroker::RegisterUpdateCallback(
const base::RepeatingClosure& callback) {
const UpdateCallback& callback) {
if (!available())
FetchStateKeys();
return update_callbacks_.Add(callback);
......@@ -80,7 +80,7 @@ void ServerBackedStateKeysBroker::StoreStateKeys(
if (send_notification)
update_callbacks_.Notify();
std::vector<StateKeysCallback> callbacks;
StateKeysCallbackList callbacks;
request_callbacks_.swap(callbacks);
for (auto& callback : callbacks) {
if (!callback.is_null())
......
......@@ -25,10 +25,12 @@ namespace policy {
// register callbacks to invoke when the state keys change.
class ServerBackedStateKeysBroker {
public:
typedef std::unique_ptr<base::CallbackList<void()>::Subscription>
Subscription;
typedef base::OnceCallback<void(const std::vector<std::string>&)>
StateKeysCallback;
using UpdateCallbackList = base::CallbackList<void()>;
using UpdateCallback = UpdateCallbackList::CallbackType;
using Subscription = std::unique_ptr<UpdateCallbackList::Subscription>;
using StateKeysCallback =
base::OnceCallback<void(const std::vector<std::string>&)>;
using StateKeysCallbackList = std::vector<StateKeysCallback>;
ServerBackedStateKeysBroker(
chromeos::SessionManagerClient* session_manager_client);
......@@ -38,7 +40,7 @@ class ServerBackedStateKeysBroker {
// Note that consuming code needs to hold on to the returned Subscription as
// long as it wants to receive the callback. If the state keys haven't been
// requested yet, calling this will also trigger their initial fetch.
Subscription RegisterUpdateCallback(const base::RepeatingClosure& callback);
Subscription RegisterUpdateCallback(const UpdateCallback& callback);
// Requests state keys asynchronously. Invokes the passed callback at most
// once, with the current state keys passed as a parameter to the callback. If
......@@ -80,10 +82,10 @@ class ServerBackedStateKeysBroker {
bool requested_;
// List of callbacks to receive update notifications.
base::CallbackList<void()> update_callbacks_;
UpdateCallbackList update_callbacks_;
// List of pending one-shot state key request callbacks.
std::vector<StateKeysCallback> request_callbacks_;
StateKeysCallbackList request_callbacks_;
base::WeakPtrFactory<ServerBackedStateKeysBroker> weak_factory_{this};
......
......@@ -107,47 +107,34 @@ typedef base::OnceCallback<void(DownloadCheckResult)> CheckDownloadCallback;
typedef base::RepeatingCallback<void(DownloadCheckResult)>
CheckDownloadRepeatingCallback;
// A type of callback run on the main thread when a ClientDownloadRequest has
// Callbacks run on the main thread when a ClientDownloadRequest has
// been formed for a download, or when one has not been formed for a supported
// download.
typedef base::RepeatingCallback<void(download::DownloadItem*,
const ClientDownloadRequest*)>
ClientDownloadRequestCallback;
// A list of ClientDownloadRequest callbacks.
typedef base::CallbackList<void(download::DownloadItem*,
const ClientDownloadRequest*)>
ClientDownloadRequestCallbackList;
// A subscription to a registered ClientDownloadRequest callback.
typedef std::unique_ptr<ClientDownloadRequestCallbackList::Subscription>
ClientDownloadRequestSubscription;
// A type of callback run on the main thread when a NativeFileSystemWriteRequest
// has been formed for a write operation.
typedef base::Callback<void(const ClientDownloadRequest*)>
NativeFileSystemWriteRequestCallback;
// A list of NativeFileSystemWriteRequest callbacks.
typedef base::CallbackList<void(const ClientDownloadRequest*)>
NativeFileSystemWriteRequestCallbackList;
// A subscription to a registered NativeFileSystemWriteRequest callback.
typedef std::unique_ptr<NativeFileSystemWriteRequestCallbackList::Subscription>
NativeFileSystemWriteRequestSubscription;
// A type of callback run on the main thread when a PPAPI
// ClientDownloadRequest has been formed for a download.
typedef base::RepeatingCallback<void(const ClientDownloadRequest*)>
PPAPIDownloadRequestCallback;
// A list of PPAPI ClientDownloadRequest callbacks.
typedef base::CallbackList<void(const ClientDownloadRequest*)>
PPAPIDownloadRequestCallbackList;
// A subscription to a registered PPAPI ClientDownloadRequest callback.
typedef std::unique_ptr<PPAPIDownloadRequestCallbackList::Subscription>
PPAPIDownloadRequestSubscription;
using ClientDownloadRequestCallbackList =
base::CallbackList<void(download::DownloadItem*,
const ClientDownloadRequest*)>;
using ClientDownloadRequestCallback =
ClientDownloadRequestCallbackList::CallbackType;
using ClientDownloadRequestSubscription =
std::unique_ptr<ClientDownloadRequestCallbackList::Subscription>;
// Callbacks run on the main thread when a NativeFileSystemWriteRequest has been
// formed for a write operation.
using NativeFileSystemWriteRequestCallbackList =
base::CallbackList<void(const ClientDownloadRequest*)>;
using NativeFileSystemWriteRequestCallback =
NativeFileSystemWriteRequestCallbackList::CallbackType;
using NativeFileSystemWriteRequestSubscription =
std::unique_ptr<NativeFileSystemWriteRequestCallbackList::Subscription>;
// Callbacks run on the main thread when a PPAPI ClientDownloadRequest has been
// formed for a download.
using PPAPIDownloadRequestCallbackList =
base::CallbackList<void(const ClientDownloadRequest*)>;
using PPAPIDownloadRequestCallback =
PPAPIDownloadRequestCallbackList::CallbackType;
using PPAPIDownloadRequestSubscription =
std::unique_ptr<PPAPIDownloadRequestCallbackList::Subscription>;
void RecordCountOfWhitelistedDownload(WhitelistType type);
......
......@@ -289,7 +289,7 @@ class MockCustomLinksManager : public CustomLinksManager {
class PopularSitesFactoryForTest {
public:
PopularSitesFactoryForTest(
explicit PopularSitesFactoryForTest(
sync_preferences::TestingPrefServiceSyncable* pref_service)
: prefs_(pref_service) {
test_shared_loader_factory_ =
......@@ -423,10 +423,7 @@ class TopSitesCallbackList {
class MostVisitedSitesTest
: public ::testing::TestWithParam<std::tuple<bool, bool>> {
protected:
MostVisitedSitesTest()
: is_custom_links_enabled_(false),
popular_sites_factory_(&pref_service_),
mock_top_sites_(new StrictMock<MockTopSites>()) {
MostVisitedSitesTest() {
MostVisitedSites::RegisterProfilePrefs(pref_service_.registry());
std::vector<base::Feature> enabled_features;
......@@ -548,7 +545,7 @@ class MostVisitedSitesTest
void EnableCustomLinks() { is_custom_links_enabled_ = true; }
bool is_custom_links_enabled_;
bool is_custom_links_enabled_ = false;
base::CallbackList<SuggestionsService::ResponseCallback::RunType>
suggestions_service_callbacks_;
TopSitesCallbackList top_sites_callbacks_;
......@@ -556,8 +553,9 @@ class MostVisitedSitesTest
base::test::SingleThreadTaskEnvironment task_environment_;
data_decoder::test::InProcessDataDecoder in_process_data_decoder_;
sync_preferences::TestingPrefServiceSyncable pref_service_;
PopularSitesFactoryForTest popular_sites_factory_;
scoped_refptr<StrictMock<MockTopSites>> mock_top_sites_;
PopularSitesFactoryForTest popular_sites_factory_{&pref_service_};
scoped_refptr<StrictMock<MockTopSites>> mock_top_sites_ =
base::MakeRefCounted<StrictMock<MockTopSites>>();
StrictMock<MockSuggestionsService> mock_suggestions_service_;
StrictMock<MockMostVisitedSitesObserver> mock_observer_;
std::unique_ptr<MostVisitedSites> most_visited_sites_;
......@@ -1248,7 +1246,7 @@ TEST_P(MostVisitedSitesWithCustomLinksTest,
VerifyAndClearExpectations();
EXPECT_CALL(mock_observer_, OnURLsAvailable(_)).Times(0);
top_sites_callbacks_.ClearAndNotify(
{MakeMostVisitedURL("Site 2", "http://site2/")});
MostVisitedURLList({MakeMostVisitedURL("Site 2", "http://site2/")}));
base::RunLoop().RunUntilIdle();
}
......@@ -1852,10 +1850,10 @@ TEST_P(MostVisitedSitesWithCacheHitTest,
MatchesTile("Site 7", "http://site7/",
TileSource::TOP_SITES))))));
top_sites_callbacks_.ClearAndNotify(
{MakeMostVisitedURL("Site 4", "http://site4/"),
MostVisitedURLList({MakeMostVisitedURL("Site 4", "http://site4/"),
MakeMostVisitedURL("Site 5", "http://site5/"),
MakeMostVisitedURL("Site 6", "http://site6/"),
MakeMostVisitedURL("Site 7", "http://site7/")});
MakeMostVisitedURL("Site 7", "http://site7/")}));
base::RunLoop().RunUntilIdle();
}
......@@ -1954,7 +1952,7 @@ TEST_P(MostVisitedSitesWithEmptyCacheTest,
// Reply from top sites is ignored (i.e. not reported to observer).
top_sites_callbacks_.ClearAndNotify(
{MakeMostVisitedURL("Site 4", "http://site4/")});
MostVisitedURLList({MakeMostVisitedURL("Site 4", "http://site4/")}));
VerifyAndClearExpectations();
// Update by TopSites is also ignored.
......@@ -1980,9 +1978,9 @@ TEST_P(MostVisitedSitesWithEmptyCacheTest,
MatchesTile("Site 3", "http://site3/",
TileSource::TOP_SITES))))));
top_sites_callbacks_.ClearAndNotify(
{MakeMostVisitedURL("Site 1", "http://site1/"),
MostVisitedURLList({MakeMostVisitedURL("Site 1", "http://site1/"),
MakeMostVisitedURL("Site 2", "http://site2/"),
MakeMostVisitedURL("Site 3", "http://site3/")});
MakeMostVisitedURL("Site 3", "http://site3/")}));
base::RunLoop().RunUntilIdle();
}
......@@ -1999,9 +1997,9 @@ TEST_P(MostVisitedSitesWithEmptyCacheTest,
MatchesTile("Site 3", "http://site3/",
TileSource::TOP_SITES))))));
top_sites_callbacks_.ClearAndNotify(
{MakeMostVisitedURL("Site 1", "http://site1/"),
MostVisitedURLList({MakeMostVisitedURL("Site 1", "http://site1/"),
MakeMostVisitedURL("Site 2", "http://site2/"),
MakeMostVisitedURL("Site 3", "http://site3/")});
MakeMostVisitedURL("Site 3", "http://site3/")}));
VerifyAndClearExpectations();
// Reply from suggestions service overrides top sites.
......@@ -2035,9 +2033,9 @@ TEST_P(MostVisitedSitesWithEmptyCacheTest,
MatchesTile("Site 3", "http://site3/",
TileSource::TOP_SITES))))));
top_sites_callbacks_.ClearAndNotify(
{MakeMostVisitedURL("Site 1", "http://site1/"),
MostVisitedURLList({MakeMostVisitedURL("Site 1", "http://site1/"),
MakeMostVisitedURL("Site 2", "http://site2/"),
MakeMostVisitedURL("Site 3", "http://site3/")});
MakeMostVisitedURL("Site 3", "http://site3/")}));
VerifyAndClearExpectations();
// Reply from suggestions service is empty and thus ignored.
......@@ -2057,9 +2055,9 @@ TEST_P(MostVisitedSitesWithEmptyCacheTest, ShouldPropagateUpdateByTopSites) {
MatchesTile("Site 3", "http://site3/",
TileSource::TOP_SITES))))));
top_sites_callbacks_.ClearAndNotify(
{MakeMostVisitedURL("Site 1", "http://site1/"),
MostVisitedURLList({MakeMostVisitedURL("Site 1", "http://site1/"),
MakeMostVisitedURL("Site 2", "http://site2/"),
MakeMostVisitedURL("Site 3", "http://site3/")});
MakeMostVisitedURL("Site 3", "http://site3/")}));
VerifyAndClearExpectations();
// Reply from suggestions service is empty and thus ignored.
......@@ -2105,7 +2103,7 @@ TEST_P(MostVisitedSitesWithEmptyCacheTest,
SectionType::PERSONALIZED, IsEmpty()))));
}
suggestions_service_callbacks_.Notify(SuggestionsProfile());
top_sites_callbacks_.ClearAndNotify(MostVisitedURLList{});
top_sites_callbacks_.ClearAndNotify(MostVisitedURLList());
base::RunLoop().RunUntilIdle();
}
......@@ -2125,9 +2123,9 @@ TEST_P(MostVisitedSitesWithEmptyCacheTest,
suggestions_service_callbacks_.Notify(SuggestionsProfile());
top_sites_callbacks_.ClearAndNotify(
{MakeMostVisitedURL("Site 1", "http://site1/"),
MostVisitedURLList({MakeMostVisitedURL("Site 1", "http://site1/"),
MakeMostVisitedURL("Site 2", "http://site2/"),
MakeMostVisitedURL("Site 3", "http://site3/")});
MakeMostVisitedURL("Site 3", "http://site3/")}));
base::RunLoop().RunUntilIdle();
for (int i = 0; i < 4; ++i) {
......@@ -2137,9 +2135,9 @@ TEST_P(MostVisitedSitesWithEmptyCacheTest,
history::TopSitesObserver::ChangeReason::MOST_VISITED);
EXPECT_FALSE(top_sites_callbacks_.empty());
top_sites_callbacks_.ClearAndNotify(
{MakeMostVisitedURL("Site 1", "http://site1/"),
MostVisitedURLList({MakeMostVisitedURL("Site 1", "http://site1/"),
MakeMostVisitedURL("Site 2", "http://site2/"),
MakeMostVisitedURL("Site 3", "http://site3/")});
MakeMostVisitedURL("Site 3", "http://site3/")}));
base::RunLoop().RunUntilIdle();
}
}
......
......@@ -10,7 +10,8 @@ OmniboxEventGlobalTracker* OmniboxEventGlobalTracker::GetInstance() {
return base::Singleton<OmniboxEventGlobalTracker>::get();
}
std::unique_ptr<base::CallbackList<void(OmniboxLog*)>::Subscription>
std::unique_ptr<
OmniboxEventGlobalTracker::OnURLOpenedCallbackList::Subscription>
OmniboxEventGlobalTracker::RegisterCallback(const OnURLOpenedCallback& cb) {
return on_url_opened_callback_list_.Add(cb);
}
......
......@@ -24,14 +24,15 @@ struct OmniboxLog;
// forwards the event to its registered observers.
class OmniboxEventGlobalTracker {
public:
typedef base::RepeatingCallback<void(OmniboxLog*)> OnURLOpenedCallback;
using OnURLOpenedCallbackList = base::CallbackList<void(OmniboxLog*)>;
using OnURLOpenedCallback = OnURLOpenedCallbackList::CallbackType;
// Returns the instance of OmniboxEventGlobalTracker.
static OmniboxEventGlobalTracker* GetInstance();
// Registers |cb| to be invoked when user open an URL from the omnibox.
std::unique_ptr<base::CallbackList<void(OmniboxLog*)>::Subscription>
RegisterCallback(const OnURLOpenedCallback& cb);
std::unique_ptr<OnURLOpenedCallbackList::Subscription> RegisterCallback(
const OnURLOpenedCallback& cb);
// Called to notify all registered callbacks that an URL was opened from
// the omnibox.
......@@ -46,7 +47,7 @@ class OmniboxEventGlobalTracker {
OmniboxEventGlobalTracker& operator=(const OmniboxEventGlobalTracker&) =
delete;
base::CallbackList<void(OmniboxLog*)> on_url_opened_callback_list_;
OnURLOpenedCallbackList on_url_opened_callback_list_;
};
#endif // COMPONENTS_OMNIBOX_BROWSER_OMNIBOX_EVENT_GLOBAL_TRACKER_H_
......@@ -55,10 +55,9 @@ class TranslateLanguageList {
// pending request.
void SetResourceRequestsAllowed(bool allowed);
typedef base::RepeatingCallback<void(const TranslateEventDetails&)>
EventCallback;
typedef base::CallbackList<void(const TranslateEventDetails&)>
EventCallbackList;
using EventCallbackList =
base::CallbackList<void(const TranslateEventDetails&)>;
using EventCallback = EventCallbackList::CallbackType;
// Registers a callback for translate events related to the language list,
// such as updates and download errors.
......
......@@ -139,16 +139,14 @@ class TranslateManager {
void ReportLanguageDetectionError();
// Callback types for translate errors.
typedef base::RepeatingCallback<void(const TranslateErrorDetails&)>
TranslateErrorCallback;
typedef base::CallbackList<void(const TranslateErrorDetails&)>
TranslateErrorCallbackList;
using TranslateErrorCallbackList =
base::CallbackList<void(const TranslateErrorDetails&)>;
using TranslateErrorCallback = TranslateErrorCallbackList::CallbackType;
// Callback types for translate initialization.
typedef base::RepeatingCallback<void(const TranslateInitDetails&)>
TranslateInitCallback;
typedef base::CallbackList<void(const TranslateInitDetails&)>
TranslateInitCallbackList;
using TranslateInitCallbackList =
base::CallbackList<void(const TranslateInitDetails&)>;
using TranslateInitCallback = TranslateInitCallbackList::CallbackType;
// Registers a callback for translate errors.
static std::unique_ptr<TranslateErrorCallbackList::Subscription>
......
......@@ -93,7 +93,7 @@ class TranslateScript {
base::TimeDelta expiration_delay_;
// The callbacks called when the server sends a response.
typedef std::vector<RequestCallback> RequestCallbackList;
using RequestCallbackList = std::vector<RequestCallback>;
RequestCallbackList callback_list_;
base::WeakPtrFactory<TranslateScript> weak_method_factory_{this};
......
......@@ -49,9 +49,11 @@ const char kChapsPath[] = "libchaps.so";
class ChromeOSUserData {
public:
using SlotReadyCallback = base::OnceCallback<void(ScopedPK11Slot)>;
explicit ChromeOSUserData(ScopedPK11Slot public_slot)
: public_slot_(std::move(public_slot)),
private_slot_initialization_started_(false) {}
: public_slot_(std::move(public_slot)) {}
~ChromeOSUserData() {
if (public_slot_) {
SECStatus status = SECMOD_CloseUserDB(public_slot_.get());
......@@ -65,8 +67,7 @@ class ChromeOSUserData {
: nullptr);
}
ScopedPK11Slot GetPrivateSlot(
base::OnceCallback<void(ScopedPK11Slot)> callback) {
ScopedPK11Slot GetPrivateSlot(SlotReadyCallback callback) {
if (private_slot_)
return ScopedPK11Slot(PK11_ReferenceSlot(private_slot_.get()));
if (!callback.is_null())
......@@ -96,13 +97,14 @@ class ChromeOSUserData {
}
private:
using SlotReadyCallbackList =
std::vector<base::OnceCallback<void(ScopedPK11Slot)>>;
ScopedPK11Slot public_slot_;
ScopedPK11Slot private_slot_;
bool private_slot_initialization_started_;
bool private_slot_initialization_started_ = false;
typedef std::vector<base::OnceCallback<void(ScopedPK11Slot)>>
SlotReadyCallbackList;
SlotReadyCallbackList tpm_ready_callback_list_;
};
......
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