OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/system_storage/system_storage_api.h" | 5 #include "chrome/browser/extensions/api/system_storage/system_storage_api.h" |
6 | 6 |
7 using storage_monitor::StorageMonitor; | 7 using storage_monitor::StorageMonitor; |
8 | 8 |
9 namespace extensions { | 9 namespace extensions { |
10 | 10 |
11 using api::system_storage::StorageUnitInfo; | 11 using api::system_storage::StorageUnitInfo; |
12 namespace EjectDevice = api::system_storage::EjectDevice; | 12 namespace EjectDevice = api::system_storage::EjectDevice; |
13 namespace GetAvailableCapacity = api::system_storage::GetAvailableCapacity; | 13 namespace GetAvailableCapacity = api::system_storage::GetAvailableCapacity; |
14 | 14 |
15 SystemStorageGetInfoFunction::SystemStorageGetInfoFunction() { | 15 SystemStorageGetInfoFunction::SystemStorageGetInfoFunction() { |
16 } | 16 } |
17 | 17 |
18 SystemStorageGetInfoFunction::~SystemStorageGetInfoFunction() { | 18 SystemStorageGetInfoFunction::~SystemStorageGetInfoFunction() { |
19 } | 19 } |
20 | 20 |
21 bool SystemStorageGetInfoFunction::RunImpl() { | 21 bool SystemStorageGetInfoFunction::RunAsync() { |
22 StorageInfoProvider::Get()->StartQueryInfo( | 22 StorageInfoProvider::Get()->StartQueryInfo( |
23 base::Bind(&SystemStorageGetInfoFunction::OnGetStorageInfoCompleted, | 23 base::Bind(&SystemStorageGetInfoFunction::OnGetStorageInfoCompleted, |
24 this)); | 24 this)); |
25 return true; | 25 return true; |
26 } | 26 } |
27 | 27 |
28 void SystemStorageGetInfoFunction::OnGetStorageInfoCompleted(bool success) { | 28 void SystemStorageGetInfoFunction::OnGetStorageInfoCompleted(bool success) { |
29 if (success) { | 29 if (success) { |
30 results_ = api::system_storage::GetInfo::Results::Create( | 30 results_ = api::system_storage::GetInfo::Results::Create( |
31 StorageInfoProvider::Get()->storage_unit_info_list()); | 31 StorageInfoProvider::Get()->storage_unit_info_list()); |
32 } else { | 32 } else { |
33 SetError("Error occurred when querying storage information."); | 33 SetError("Error occurred when querying storage information."); |
34 } | 34 } |
35 | 35 |
36 SendResponse(success); | 36 SendResponse(success); |
37 } | 37 } |
38 | 38 |
39 SystemStorageEjectDeviceFunction::~SystemStorageEjectDeviceFunction() { | 39 SystemStorageEjectDeviceFunction::~SystemStorageEjectDeviceFunction() { |
40 } | 40 } |
41 | 41 |
42 bool SystemStorageEjectDeviceFunction::RunImpl() { | 42 bool SystemStorageEjectDeviceFunction::RunAsync() { |
43 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 43 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
44 | 44 |
45 scoped_ptr<EjectDevice::Params> params(EjectDevice::Params::Create(*args_)); | 45 scoped_ptr<EjectDevice::Params> params(EjectDevice::Params::Create(*args_)); |
46 EXTENSION_FUNCTION_VALIDATE(params.get()); | 46 EXTENSION_FUNCTION_VALIDATE(params.get()); |
47 | 47 |
48 StorageMonitor::GetInstance()->EnsureInitialized(base::Bind( | 48 StorageMonitor::GetInstance()->EnsureInitialized(base::Bind( |
49 &SystemStorageEjectDeviceFunction::OnStorageMonitorInit, | 49 &SystemStorageEjectDeviceFunction::OnStorageMonitorInit, |
50 this, | 50 this, |
51 params->id)); | 51 params->id)); |
52 return true; | 52 return true; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 96 } |
97 | 97 |
98 SystemStorageGetAvailableCapacityFunction:: | 98 SystemStorageGetAvailableCapacityFunction:: |
99 SystemStorageGetAvailableCapacityFunction() { | 99 SystemStorageGetAvailableCapacityFunction() { |
100 } | 100 } |
101 | 101 |
102 SystemStorageGetAvailableCapacityFunction:: | 102 SystemStorageGetAvailableCapacityFunction:: |
103 ~SystemStorageGetAvailableCapacityFunction() { | 103 ~SystemStorageGetAvailableCapacityFunction() { |
104 } | 104 } |
105 | 105 |
106 bool SystemStorageGetAvailableCapacityFunction::RunImpl() { | 106 bool SystemStorageGetAvailableCapacityFunction::RunAsync() { |
107 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 107 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
108 | 108 |
109 scoped_ptr<GetAvailableCapacity::Params> params( | 109 scoped_ptr<GetAvailableCapacity::Params> params( |
110 GetAvailableCapacity::Params::Create(*args_)); | 110 GetAvailableCapacity::Params::Create(*args_)); |
111 EXTENSION_FUNCTION_VALIDATE(params.get()); | 111 EXTENSION_FUNCTION_VALIDATE(params.get()); |
112 | 112 |
113 StorageMonitor::GetInstance()->EnsureInitialized(base::Bind( | 113 StorageMonitor::GetInstance()->EnsureInitialized(base::Bind( |
114 &SystemStorageGetAvailableCapacityFunction::OnStorageMonitorInit, | 114 &SystemStorageGetAvailableCapacityFunction::OnStorageMonitorInit, |
115 this, | 115 this, |
116 params->id)); | 116 params->id)); |
(...skipping 21 matching lines...) Expand all Loading... |
138 result.id = transient_id; | 138 result.id = transient_id; |
139 result.available_capacity = available_capacity; | 139 result.available_capacity = available_capacity; |
140 SetResult(result.ToValue().release()); | 140 SetResult(result.ToValue().release()); |
141 } else { | 141 } else { |
142 SetError("Error occurred when querying available capacity."); | 142 SetError("Error occurred when querying available capacity."); |
143 } | 143 } |
144 SendResponse(success); | 144 SendResponse(success); |
145 } | 145 } |
146 | 146 |
147 } // namespace extensions | 147 } // namespace extensions |
OLD | NEW |