Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 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. | |
| 4 #ifndef CHROME_BROWSER_EXTENSIONS_API_SYSTEMINFO_STORAGE_STORAGE_INFO_PROVIDER_H _ | |
| 5 #define CHROME_BROWSER_EXTENSIONS_API_SYSTEMINFO_STORAGE_STORAGE_INFO_PROVIDER_H _ | |
| 6 | |
| 7 #include "chrome/common/extensions/api/experimental_systeminfo_storage.h" | |
| 8 | |
| 9 namespace extensions { | |
| 10 | |
| 11 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.
| |
| 12 using api::experimental_systeminfo_storage::StorageUnitInfo; | |
| 13 | |
| 14 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
| |
| 15 const char kStorageTypeHardDisk[] = "harddisk"; | |
| 16 const char kStorageTypeUSB[] = "usb"; | |
| 17 const char kStorageTypeMMC[] = "sdcard"; | |
| 18 | |
| 19 class StorageInfoProvider { | |
|
James Hawkins
2012/08/09 15:47:34
nit: Document class.
Hongbo Min
2012/08/12 03:31:58
Done.
| |
| 20 public: | |
| 21 // Return a StorageInfoProvider instance. The caller is responsible for | |
| 22 // releasing it | |
| 23 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.
| |
| 24 virtual ~StorageInfoProvider() {} | |
| 25 // Return true if succeed to get storage information, other return fasle. | |
| 26 // Should be implemented on different platforms | |
| 27 virtual bool GetStorageInfo(StorageInfo* info) = 0; | |
| 28 }; | |
| 29 | |
| 30 // A Mock Implementation for storage info provider | |
| 31 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.
| |
| 32 public: | |
| 33 MockStorageInfoProvider() {} | |
| 34 virtual ~MockStorageInfoProvider() {} | |
| 35 virtual bool GetStorageInfo(StorageInfo* info) OVERRIDE; | |
| 36 }; | |
| 37 | |
| 38 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.
| |
| 39 if (info == NULL) return false; | |
| 40 linked_ptr<StorageUnitInfo> unit(new StorageUnitInfo()); | |
| 41 unit->id = "0xbeaf"; | |
| 42 unit->type = kStorageTypeUnknown; | |
| 43 unit->capacity = 4098; | |
| 44 unit->available_capacity = 1000; | |
| 45 | |
| 46 info->units.push_back(unit); | |
| 47 return true; | |
| 48 } | |
| 49 | |
| 50 // static | |
| 51 StorageInfoProvider* StorageInfoProvider::Create() { | |
| 52 return new MockStorageInfoProvider(); | |
| 53 } | |
| 54 | |
| 55 } // namespace extensions | |
|
James Hawkins
2012/08/09 15:47:34
nit: Two spaces before comments.
Hongbo Min
2012/08/12 03:31:58
Done.
| |
| 56 | |
| 57 #endif // CHROME_BROWSER_EXTENSIONS_API_SYSTEMINFO_STORAGE_STORAGE_INFO_PROVIDE R_H_ | |
| OLD | NEW |