Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / extensions / browser / api / system_storage / system_storage_api.h
blob914e8a228ab91477063ba659c8a0169f392ebbfe
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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_API_SYSTEM_STORAGE_SYSTEM_STORAGE_API_H_
6 #define EXTENSIONS_BROWSER_API_SYSTEM_STORAGE_SYSTEM_STORAGE_API_H_
8 #include "components/storage_monitor/storage_monitor.h"
9 #include "extensions/browser/api/system_storage/storage_info_provider.h"
10 #include "extensions/browser/extension_function.h"
12 namespace extensions {
14 // Implementation of the systeminfo.storage.get API. It is an asynchronous
15 // call relative to browser UI thread.
16 class SystemStorageGetInfoFunction : public AsyncExtensionFunction {
17 public:
18 DECLARE_EXTENSION_FUNCTION("system.storage.getInfo", SYSTEM_STORAGE_GETINFO);
19 SystemStorageGetInfoFunction();
21 private:
22 ~SystemStorageGetInfoFunction() override;
23 bool RunAsync() override;
25 void OnGetStorageInfoCompleted(bool success);
28 class SystemStorageEjectDeviceFunction : public AsyncExtensionFunction {
29 public:
30 DECLARE_EXTENSION_FUNCTION("system.storage.ejectDevice",
31 SYSTEM_STORAGE_EJECTDEVICE);
33 protected:
34 ~SystemStorageEjectDeviceFunction() override;
36 // AsyncExtensionFunction overrides.
37 bool RunAsync() override;
39 private:
40 void OnStorageMonitorInit(const std::string& transient_device_id);
42 // Eject device request handler.
43 void HandleResponse(storage_monitor::StorageMonitor::EjectStatus status);
46 class SystemStorageGetAvailableCapacityFunction
47 : public AsyncExtensionFunction {
48 public:
49 DECLARE_EXTENSION_FUNCTION("system.storage.getAvailableCapacity",
50 SYSTEM_STORAGE_GETAVAILABLECAPACITY);
51 SystemStorageGetAvailableCapacityFunction();
53 private:
54 void OnStorageMonitorInit(const std::string& transient_id);
55 void OnQueryCompleted(const std::string& transient_id,
56 double available_capacity);
57 ~SystemStorageGetAvailableCapacityFunction() override;
58 bool RunAsync() override;
61 } // namespace extensions
63 #endif // EXTENSIONS_BROWSER_API_SYSTEM_STORAGE_SYSTEM_STORAGE_API_H_