Chromium Code Reviews| 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..3e3b90fde0a6210bb49f95e47af9c428ed28fd8d 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,7 @@ bool SystemStorageEjectDeviceFunction::RunAsync() { |
| base::Bind(&SystemStorageEjectDeviceFunction::OnStorageMonitorInit, |
|
Devlin
2017/01/06 15:51:06
can return sync
lazyboy
2017/01/19 03:47:59
Added comment and fixed the issue.
|
| this, |
| params->id)); |
| - return true; |
| + return RespondLater(); |
| } |
| void SystemStorageEjectDeviceFunction::OnStorageMonitorInit( |
| @@ -90,9 +88,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 +100,8 @@ SystemStorageGetAvailableCapacityFunction:: |
| ~SystemStorageGetAvailableCapacityFunction() { |
| } |
| -bool SystemStorageGetAvailableCapacityFunction::RunAsync() { |
| +ExtensionFunction::ResponseAction |
| +SystemStorageGetAvailableCapacityFunction::Run() { |
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| std::unique_ptr<GetAvailableCapacity::Params> params( |
| @@ -114,7 +112,7 @@ bool SystemStorageGetAvailableCapacityFunction::RunAsync() { |
| &SystemStorageGetAvailableCapacityFunction::OnStorageMonitorInit, |
| this, |
| params->id)); |
| - return true; |
| + return RespondLater(); |
| } |
| void SystemStorageGetAvailableCapacityFunction::OnStorageMonitorInit( |
| @@ -139,11 +137,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 |