Chromium Code Reviews| Index: chrome/browser/extensions/api/systeminfo_storage/storage_info_provider.h |
| diff --git a/chrome/browser/extensions/api/systeminfo_storage/storage_info_provider.h b/chrome/browser/extensions/api/systeminfo_storage/storage_info_provider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0cdca956035e46c7e82aa77931f07b69874b493c |
| --- /dev/null |
| +++ b/chrome/browser/extensions/api/systeminfo_storage/storage_info_provider.h |
| @@ -0,0 +1,57 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| +#ifndef CHROME_BROWSER_EXTENSIONS_API_SYSTEMINFO_STORAGE_STORAGE_INFO_PROVIDER_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_API_SYSTEMINFO_STORAGE_STORAGE_INFO_PROVIDER_H_ |
| + |
| +#include "chrome/common/extensions/api/experimental_systeminfo_storage.h" |
| + |
| +namespace extensions { |
| + |
| +using api::experimental_systeminfo_storage::StorageInfo; |
|
James Hawkins
2012/08/09 15:47:34
nit: 'using' is not allowed in headers.
Hongbo Min
2012/08/12 03:31:58
Done.
|
| +using api::experimental_systeminfo_storage::StorageUnitInfo; |
| + |
| +const char kStorageTypeUnknown[] = "unknown"; |
|
James Hawkins
2012/08/09 15:47:34
Any reason this can't be an enum?
Hongbo Min
2012/08/10 02:43:29
It aligns with idl. The enum defined in idl is con
Hongbo Min
2012/08/12 03:31:58
Depends on http://crbug.com/141940
|
| +const char kStorageTypeHardDisk[] = "harddisk"; |
| +const char kStorageTypeUSB[] = "usb"; |
| +const char kStorageTypeMMC[] = "sdcard"; |
| + |
| +class StorageInfoProvider { |
|
James Hawkins
2012/08/09 15:47:34
nit: Document class.
Hongbo Min
2012/08/12 03:31:58
Done.
|
| + public: |
| + // Return a StorageInfoProvider instance. The caller is responsible for |
| + // releasing it |
| + static StorageInfoProvider* Create(); |
|
James Hawkins
2012/08/09 15:47:34
Optional nit: Separate these disparate pieces with
Hongbo Min
2012/08/12 03:31:58
Done.
|
| + virtual ~StorageInfoProvider() {} |
| + // Return true if succeed to get storage information, other return fasle. |
| + // Should be implemented on different platforms |
| + virtual bool GetStorageInfo(StorageInfo* info) = 0; |
| +}; |
| + |
| +// A Mock Implementation for storage info provider |
| +class MockStorageInfoProvider : public StorageInfoProvider { |
|
James Hawkins
2012/08/09 15:47:34
What is this used for?
Hongbo Min
2012/08/12 03:31:58
Done.
|
| + public: |
| + MockStorageInfoProvider() {} |
| + virtual ~MockStorageInfoProvider() {} |
| + virtual bool GetStorageInfo(StorageInfo* info) OVERRIDE; |
| +}; |
| + |
| +bool MockStorageInfoProvider::GetStorageInfo(StorageInfo* info) { |
|
James Hawkins
2012/08/09 15:47:34
Implementations need to move to the source file.
Hongbo Min
2012/08/12 03:31:58
Done.
|
| + if (info == NULL) return false; |
| + linked_ptr<StorageUnitInfo> unit(new StorageUnitInfo()); |
| + unit->id = "0xbeaf"; |
| + unit->type = kStorageTypeUnknown; |
| + unit->capacity = 4098; |
| + unit->available_capacity = 1000; |
| + |
| + info->units.push_back(unit); |
| + return true; |
| +} |
| + |
| +// static |
| +StorageInfoProvider* StorageInfoProvider::Create() { |
| + return new MockStorageInfoProvider(); |
| +} |
| + |
| +} // namespace extensions |
|
James Hawkins
2012/08/09 15:47:34
nit: Two spaces before comments.
Hongbo Min
2012/08/12 03:31:58
Done.
|
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_API_SYSTEMINFO_STORAGE_STORAGE_INFO_PROVIDER_H_ |