Commit cdd539c4 authored by Hokein.Wu@gmail.com's avatar Hokein.Wu@gmail.com

Rename StorageMonitor Initialize function to EnsureInitialized for better understanding.

BUG=None

Review URL: https://chromiumcodereview.appspot.com/16472007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207808 0039d316-1c4b-4281-b951-d872f2087c98
parent 803113d4
......@@ -93,7 +93,7 @@ bool MediaGalleriesGetMediaFileSystemsFunction::RunImpl() {
interactive = params->details->interactive;
}
chrome::StorageMonitor::GetInstance()->Initialize(base::Bind(
chrome::StorageMonitor::GetInstance()->EnsureInitialized(base::Bind(
&MediaGalleriesGetMediaFileSystemsFunction::OnStorageMonitorInit,
this,
interactive));
......
......@@ -128,7 +128,7 @@ void MediaGalleriesPrivateAPI::OnListenerAdded(
// This method is called synchronously with the message handler for the
// JS invocation.
chrome::StorageMonitor::GetInstance()->Initialize(base::Bind(
chrome::StorageMonitor::GetInstance()->EnsureInitialized(base::Bind(
&MediaGalleriesPrivateAPI::MaybeInitializeEventRouterAndTracker,
weak_ptr_factory_.GetWeakPtr()));
}
......@@ -171,7 +171,7 @@ bool MediaGalleriesPrivateAddGalleryWatchFunction::RunImpl() {
AddGalleryWatch::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
chrome::StorageMonitor::GetInstance()->Initialize(base::Bind(
chrome::StorageMonitor::GetInstance()->EnsureInitialized(base::Bind(
&MediaGalleriesPrivateAddGalleryWatchFunction::OnStorageMonitorInit,
this,
params->gallery_id));
......@@ -251,7 +251,7 @@ bool MediaGalleriesPrivateRemoveGalleryWatchFunction::RunImpl() {
RemoveGalleryWatch::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
chrome::StorageMonitor::GetInstance()->Initialize(base::Bind(
chrome::StorageMonitor::GetInstance()->EnsureInitialized(base::Bind(
&MediaGalleriesPrivateRemoveGalleryWatchFunction::OnStorageMonitorInit,
this,
params->gallery_id));
......@@ -298,7 +298,7 @@ bool MediaGalleriesPrivateGetAllGalleryWatchFunction::RunImpl() {
if (!render_view_host() || !render_view_host()->GetProcess())
return false;
chrome::StorageMonitor::GetInstance()->Initialize(base::Bind(
chrome::StorageMonitor::GetInstance()->EnsureInitialized(base::Bind(
&MediaGalleriesPrivateGetAllGalleryWatchFunction::OnStorageMonitorInit,
this));
return true;
......@@ -335,7 +335,7 @@ bool MediaGalleriesPrivateRemoveAllGalleryWatchFunction::RunImpl() {
if (!render_view_host() || !render_view_host()->GetProcess())
return false;
chrome::StorageMonitor::GetInstance()->Initialize(base::Bind(
chrome::StorageMonitor::GetInstance()->EnsureInitialized(base::Bind(
&MediaGalleriesPrivateRemoveAllGalleryWatchFunction::OnStorageMonitorInit,
this));
return true;
......@@ -371,7 +371,7 @@ bool MediaGalleriesPrivateEjectDeviceFunction::RunImpl() {
scoped_ptr<EjectDevice::Params> params(EjectDevice::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
chrome::StorageMonitor::GetInstance()->Initialize(base::Bind(
chrome::StorageMonitor::GetInstance()->EnsureInitialized(base::Bind(
&MediaGalleriesPrivateEjectDeviceFunction::OnStorageMonitorInit,
this,
params->device_id));
......
......@@ -771,7 +771,7 @@ void MediaFileSystemRegistryTest::SetUp() {
monitor_->MarkInitialized();
#endif
base::RunLoop runloop;
monitor_->Initialize(runloop.QuitClosure());
monitor_->EnsureInitialized(runloop.QuitClosure());
runloop.Run();
DeleteContents();
......
......@@ -52,7 +52,7 @@ MediaGalleriesDialogController::MediaGalleriesDialogController(
// Passing unretained pointer is safe, since the dialog controller
// is self-deleting, and so won't be deleted until it can be shown
// and then closed.
StorageMonitor::GetInstance()->Initialize(base::Bind(
StorageMonitor::GetInstance()->EnsureInitialized(base::Bind(
&MediaGalleriesDialogController::OnStorageMonitorInitialized,
base::Unretained(this)));
}
......
......@@ -61,7 +61,7 @@ std::vector<StorageInfo> StorageMonitor::GetAllAvailableStorages() const {
return results;
}
void StorageMonitor::Initialize(base::Closure callback) {
void StorageMonitor::EnsureInitialized(base::Closure callback) {
DCHECK(thread_checker_.CalledOnValidThread());
if (initialized_) {
if (!callback.is_null())
......
......@@ -72,14 +72,14 @@ class StorageMonitor {
// somewhat shorter than a process Singleton.
static StorageMonitor* GetInstance();
// Initialize the storage monitor. The provided callback, if non-null,
// will be called when initialization is complete. If initialization has
// already completed, this callback will be invoked within the calling stack.
// Before the callback is run, calls to |GetAllAvailableStorages| and
// Ensures that the storage monitor is initialized. The provided callback, If
// non-null, will be called when initialization is complete. If initialization
// has already completed, this callback will be invoked within the calling
// stack. Before the callback is run, calls to |GetAllAvailableStorages| and
// |GetStorageInfoForPath| may not return the correct results. In addition,
// registered observers will not be notified on device attachment/detachment.
// Should be invoked on the UI thread; callbacks will be run on the UI thread.
void Initialize(base::Closure callback);
void EnsureInitialized(base::Closure callback);
// Return true if the storage monitor has already been initialized.
bool IsInitialized();
......
......@@ -17,8 +17,8 @@ TEST(StorageMonitorTest, TestInitialize) {
EXPECT_FALSE(monitor.init_called_);
base::WaitableEvent event(false, false);
monitor.Initialize(base::Bind(&base::WaitableEvent::Signal,
base::Unretained(&event)));
monitor.EnsureInitialized(base::Bind(&base::WaitableEvent::Signal,
base::Unretained(&event)));
EXPECT_TRUE(monitor.init_called_);
EXPECT_FALSE(event.IsSignaled());
monitor.MarkInitialized();
......
......@@ -51,7 +51,7 @@ void MediaGalleriesHandler::GetLocalizedValues(DictionaryValue* values) {
}
void MediaGalleriesHandler::InitializePage() {
chrome::StorageMonitor::GetInstance()->Initialize(
chrome::StorageMonitor::GetInstance()->EnsureInitialized(
base::Bind(&MediaGalleriesHandler::InitializeOnStorageMonitorInit,
weak_ptr_factory_.GetWeakPtr()));
}
......@@ -73,7 +73,7 @@ void MediaGalleriesHandler::InitializeOnStorageMonitorInit() {
}
void MediaGalleriesHandler::RegisterMessages() {
chrome::StorageMonitor::GetInstance()->Initialize(
chrome::StorageMonitor::GetInstance()->EnsureInitialized(
base::Bind(&MediaGalleriesHandler::RegisterOnStorageMonitorInit,
weak_ptr_factory_.GetWeakPtr()));
}
......
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