| 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 #ifndef EXTENSIONS_BROWSER_API_SYSTEM_STORAGE_SYSTEM_STORAGE_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_SYSTEM_STORAGE_SYSTEM_STORAGE_API_H_ |
| 6 #define EXTENSIONS_BROWSER_API_SYSTEM_STORAGE_SYSTEM_STORAGE_API_H_ | 6 #define EXTENSIONS_BROWSER_API_SYSTEM_STORAGE_SYSTEM_STORAGE_API_H_ |
| 7 | 7 |
| 8 #include "components/storage_monitor/storage_monitor.h" | 8 #include "components/storage_monitor/storage_monitor.h" |
| 9 #include "extensions/browser/api/system_storage/storage_info_provider.h" | 9 #include "extensions/browser/api/system_storage/storage_info_provider.h" |
| 10 #include "extensions/browser/extension_function.h" | 10 #include "extensions/browser/extension_function.h" |
| 11 | 11 |
| 12 namespace extensions { | 12 namespace extensions { |
| 13 | 13 |
| 14 // Implementation of the systeminfo.storage.get API. It is an asynchronous | 14 // Implementation of the systeminfo.storage.get API. It is an asynchronous |
| 15 // call relative to browser UI thread. | 15 // call relative to browser UI thread. |
| 16 class SystemStorageGetInfoFunction : public AsyncExtensionFunction { | 16 class SystemStorageGetInfoFunction : public UIThreadExtensionFunction { |
| 17 public: | 17 public: |
| 18 DECLARE_EXTENSION_FUNCTION("system.storage.getInfo", SYSTEM_STORAGE_GETINFO); | 18 DECLARE_EXTENSION_FUNCTION("system.storage.getInfo", SYSTEM_STORAGE_GETINFO); |
| 19 SystemStorageGetInfoFunction(); | 19 SystemStorageGetInfoFunction(); |
| 20 | 20 |
| 21 private: | 21 private: |
| 22 ~SystemStorageGetInfoFunction() override; | 22 ~SystemStorageGetInfoFunction() override; |
| 23 bool RunAsync() override; | 23 |
| 24 // ExtensionFunction: |
| 25 ResponseAction Run() override; |
| 24 | 26 |
| 25 void OnGetStorageInfoCompleted(bool success); | 27 void OnGetStorageInfoCompleted(bool success); |
| 26 }; | 28 }; |
| 27 | 29 |
| 28 class SystemStorageEjectDeviceFunction : public AsyncExtensionFunction { | 30 class SystemStorageEjectDeviceFunction : public UIThreadExtensionFunction { |
| 29 public: | 31 public: |
| 30 DECLARE_EXTENSION_FUNCTION("system.storage.ejectDevice", | 32 DECLARE_EXTENSION_FUNCTION("system.storage.ejectDevice", |
| 31 SYSTEM_STORAGE_EJECTDEVICE); | 33 SYSTEM_STORAGE_EJECTDEVICE); |
| 32 | 34 |
| 33 protected: | 35 protected: |
| 34 ~SystemStorageEjectDeviceFunction() override; | 36 ~SystemStorageEjectDeviceFunction() override; |
| 35 | 37 |
| 36 // AsyncExtensionFunction overrides. | 38 // ExtensionFunction: |
| 37 bool RunAsync() override; | 39 ResponseAction Run() override; |
| 38 | 40 |
| 39 private: | 41 private: |
| 40 void OnStorageMonitorInit(const std::string& transient_device_id); | 42 void OnStorageMonitorInit(const std::string& transient_device_id); |
| 41 | 43 |
| 42 // Eject device request handler. | 44 // Eject device request handler. |
| 43 void HandleResponse(storage_monitor::StorageMonitor::EjectStatus status); | 45 void HandleResponse(storage_monitor::StorageMonitor::EjectStatus status); |
| 44 }; | 46 }; |
| 45 | 47 |
| 46 class SystemStorageGetAvailableCapacityFunction | 48 class SystemStorageGetAvailableCapacityFunction |
| 47 : public AsyncExtensionFunction { | 49 : public UIThreadExtensionFunction { |
| 48 public: | 50 public: |
| 49 DECLARE_EXTENSION_FUNCTION("system.storage.getAvailableCapacity", | 51 DECLARE_EXTENSION_FUNCTION("system.storage.getAvailableCapacity", |
| 50 SYSTEM_STORAGE_GETAVAILABLECAPACITY); | 52 SYSTEM_STORAGE_GETAVAILABLECAPACITY); |
| 51 SystemStorageGetAvailableCapacityFunction(); | 53 SystemStorageGetAvailableCapacityFunction(); |
| 52 | 54 |
| 53 private: | 55 private: |
| 54 void OnStorageMonitorInit(const std::string& transient_id); | 56 void OnStorageMonitorInit(const std::string& transient_id); |
| 55 void OnQueryCompleted(const std::string& transient_id, | 57 void OnQueryCompleted(const std::string& transient_id, |
| 56 double available_capacity); | 58 double available_capacity); |
| 57 ~SystemStorageGetAvailableCapacityFunction() override; | 59 ~SystemStorageGetAvailableCapacityFunction() override; |
| 58 bool RunAsync() override; | 60 |
| 61 // ExtensionFunction: |
| 62 ResponseAction Run() override; |
| 59 }; | 63 }; |
| 60 | 64 |
| 61 } // namespace extensions | 65 } // namespace extensions |
| 62 | 66 |
| 63 #endif // EXTENSIONS_BROWSER_API_SYSTEM_STORAGE_SYSTEM_STORAGE_API_H_ | 67 #endif // EXTENSIONS_BROWSER_API_SYSTEM_STORAGE_SYSTEM_STORAGE_API_H_ |
| OLD | NEW |