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_STORAGE_INFO_PROVIDER_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_SYSTEM_STORAGE_STORAGE_INFO_PROVIDER_H_ |
6 #define EXTENSIONS_BROWSER_API_SYSTEM_STORAGE_STORAGE_INFO_PROVIDER_H_ | 6 #define EXTENSIONS_BROWSER_API_SYSTEM_STORAGE_STORAGE_INFO_PROVIDER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 class StorageInfoProvider : public SystemInfoProvider { | 35 class StorageInfoProvider : public SystemInfoProvider { |
36 public: | 36 public: |
37 typedef base::Callback<void(const std::string&, double)> | 37 typedef base::Callback<void(const std::string&, double)> |
38 GetStorageFreeSpaceCallback; | 38 GetStorageFreeSpaceCallback; |
39 | 39 |
40 // Get the single shared instance of StorageInfoProvider. | 40 // Get the single shared instance of StorageInfoProvider. |
41 static StorageInfoProvider* Get(); | 41 static StorageInfoProvider* Get(); |
42 | 42 |
43 // SystemInfoProvider implementations | 43 // SystemInfoProvider implementations |
44 virtual void PrepareQueryOnUIThread() override; | 44 void PrepareQueryOnUIThread() override; |
45 virtual void InitializeProvider( | 45 void InitializeProvider(const base::Closure& do_query_info_callback) override; |
46 const base::Closure& do_query_info_callback) override; | |
47 | 46 |
48 virtual double GetStorageFreeSpaceFromTransientIdOnFileThread( | 47 virtual double GetStorageFreeSpaceFromTransientIdOnFileThread( |
49 const std::string& transient_id); | 48 const std::string& transient_id); |
50 | 49 |
51 const StorageUnitInfoList& storage_unit_info_list() const; | 50 const StorageUnitInfoList& storage_unit_info_list() const; |
52 | 51 |
53 static void InitializeForTesting(scoped_refptr<StorageInfoProvider> provider); | 52 static void InitializeForTesting(scoped_refptr<StorageInfoProvider> provider); |
54 | 53 |
55 protected: | 54 protected: |
56 StorageInfoProvider(); | 55 StorageInfoProvider(); |
57 | 56 |
58 virtual ~StorageInfoProvider(); | 57 ~StorageInfoProvider() override; |
59 | 58 |
60 // Put all available storages' information into |info_|. | 59 // Put all available storages' information into |info_|. |
61 void GetAllStoragesIntoInfoList(); | 60 void GetAllStoragesIntoInfoList(); |
62 | 61 |
63 // The last information filled up by QueryInfo and is accessed on multiple | 62 // The last information filled up by QueryInfo and is accessed on multiple |
64 // threads, but the whole class is being guarded by SystemInfoProvider base | 63 // threads, but the whole class is being guarded by SystemInfoProvider base |
65 // class. | 64 // class. |
66 // | 65 // |
67 // |info_| is accessed on the UI thread while |is_waiting_for_completion_| is | 66 // |info_| is accessed on the UI thread while |is_waiting_for_completion_| is |
68 // false and on the sequenced worker pool while |is_waiting_for_completion_| | 67 // false and on the sequenced worker pool while |is_waiting_for_completion_| |
69 // is true. | 68 // is true. |
70 StorageUnitInfoList info_; | 69 StorageUnitInfoList info_; |
71 | 70 |
72 private: | 71 private: |
73 // SystemInfoProvider implementations. | 72 // SystemInfoProvider implementations. |
74 // Override to query the available capacity of all known storage devices on | 73 // Override to query the available capacity of all known storage devices on |
75 // the blocking pool, including fixed and removable devices. | 74 // the blocking pool, including fixed and removable devices. |
76 virtual bool QueryInfo() override; | 75 bool QueryInfo() override; |
77 | 76 |
78 static base::LazyInstance<scoped_refptr<StorageInfoProvider> > provider_; | 77 static base::LazyInstance<scoped_refptr<StorageInfoProvider> > provider_; |
79 | 78 |
80 DISALLOW_COPY_AND_ASSIGN(StorageInfoProvider); | 79 DISALLOW_COPY_AND_ASSIGN(StorageInfoProvider); |
81 }; | 80 }; |
82 | 81 |
83 } // namespace extensions | 82 } // namespace extensions |
84 | 83 |
85 #endif // EXTENSIONS_BROWSER_API_SYSTEM_STORAGE_STORAGE_INFO_PROVIDER_H_ | 84 #endif // EXTENSIONS_BROWSER_API_SYSTEM_STORAGE_STORAGE_INFO_PROVIDER_H_ |
OLD | NEW |