| Index: extensions/browser/api/system_storage/system_storage_api.cc
|
| diff --git a/extensions/browser/api/system_storage/system_storage_api.cc b/extensions/browser/api/system_storage/system_storage_api.cc
|
| index 2629d68f3a5da19c3f144ab4925595301d228066..3bd5ecfa68521df078c83e9011bc3a4523291c69 100644
|
| --- a/extensions/browser/api/system_storage/system_storage_api.cc
|
| +++ b/extensions/browser/api/system_storage/system_storage_api.cc
|
| @@ -20,27 +20,25 @@ SystemStorageGetInfoFunction::SystemStorageGetInfoFunction() {
|
| SystemStorageGetInfoFunction::~SystemStorageGetInfoFunction() {
|
| }
|
|
|
| -bool SystemStorageGetInfoFunction::RunAsync() {
|
| +ExtensionFunction::ResponseAction SystemStorageGetInfoFunction::Run() {
|
| StorageInfoProvider::Get()->StartQueryInfo(base::Bind(
|
| &SystemStorageGetInfoFunction::OnGetStorageInfoCompleted, this));
|
| - return true;
|
| + return RespondLater();
|
| }
|
|
|
| void SystemStorageGetInfoFunction::OnGetStorageInfoCompleted(bool success) {
|
| if (success) {
|
| - results_ = api::system_storage::GetInfo::Results::Create(
|
| - StorageInfoProvider::Get()->storage_unit_info_list());
|
| + Respond(ArgumentList(api::system_storage::GetInfo::Results::Create(
|
| + StorageInfoProvider::Get()->storage_unit_info_list())));
|
| } else {
|
| - SetError("Error occurred when querying storage information.");
|
| + Respond(Error("Error occurred when querying storage information."));
|
| }
|
| -
|
| - SendResponse(success);
|
| }
|
|
|
| SystemStorageEjectDeviceFunction::~SystemStorageEjectDeviceFunction() {
|
| }
|
|
|
| -bool SystemStorageEjectDeviceFunction::RunAsync() {
|
| +ExtensionFunction::ResponseAction SystemStorageEjectDeviceFunction::Run() {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
|
| std::unique_ptr<EjectDevice::Params> params(
|
| @@ -51,7 +49,8 @@ bool SystemStorageEjectDeviceFunction::RunAsync() {
|
| base::Bind(&SystemStorageEjectDeviceFunction::OnStorageMonitorInit,
|
| this,
|
| params->id));
|
| - return true;
|
| + // EnsureInitialized() above can result in synchronous Respond().
|
| + return did_respond() ? AlreadyResponded() : RespondLater();
|
| }
|
|
|
| void SystemStorageEjectDeviceFunction::OnStorageMonitorInit(
|
| @@ -90,9 +89,8 @@ void SystemStorageEjectDeviceFunction::HandleResponse(
|
| result = api::system_storage::EJECT_DEVICE_RESULT_CODE_FAILURE;
|
| }
|
|
|
| - SetResult(base::MakeUnique<base::StringValue>(
|
| - api::system_storage::ToString(result)));
|
| - SendResponse(true);
|
| + Respond(OneArgument(base::MakeUnique<base::StringValue>(
|
| + api::system_storage::ToString(result))));
|
| }
|
|
|
| SystemStorageGetAvailableCapacityFunction::
|
| @@ -103,7 +101,8 @@ SystemStorageGetAvailableCapacityFunction::
|
| ~SystemStorageGetAvailableCapacityFunction() {
|
| }
|
|
|
| -bool SystemStorageGetAvailableCapacityFunction::RunAsync() {
|
| +ExtensionFunction::ResponseAction
|
| +SystemStorageGetAvailableCapacityFunction::Run() {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
|
|
| std::unique_ptr<GetAvailableCapacity::Params> params(
|
| @@ -114,7 +113,7 @@ bool SystemStorageGetAvailableCapacityFunction::RunAsync() {
|
| &SystemStorageGetAvailableCapacityFunction::OnStorageMonitorInit,
|
| this,
|
| params->id));
|
| - return true;
|
| + return RespondLater();
|
| }
|
|
|
| void SystemStorageGetAvailableCapacityFunction::OnStorageMonitorInit(
|
| @@ -139,11 +138,10 @@ void SystemStorageGetAvailableCapacityFunction::OnQueryCompleted(
|
| api::system_storage::StorageAvailableCapacityInfo result;
|
| result.id = transient_id;
|
| result.available_capacity = available_capacity;
|
| - SetResult(result.ToValue());
|
| + Respond(OneArgument(result.ToValue()));
|
| } else {
|
| - SetError("Error occurred when querying available capacity.");
|
| + Respond(Error("Error occurred when querying available capacity."));
|
| }
|
| - SendResponse(success);
|
| }
|
|
|
| } // namespace extensions
|
|
|