// Copyright 2013 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef EXTENSIONS_BROWSER_API_SYSTEM_INFO_SYSTEM_INFO_PROVIDER_H_ #define EXTENSIONS_BROWSER_API_SYSTEM_INFO_SYSTEM_INFO_PROVIDER_H_ #include "base/containers/queue.h" #include "base/functional/bind.h" #include "base/functional/callback.h" #include "base/memory/ref_counted.h" namespace base { class SequencedTaskRunner; } namespace storage_monitor { class StorageInfo; } namespace extensions { namespace api { namespace system_storage { struct StorageUnitInfo; } // namespace system_storage } // namespace api namespace systeminfo { // Build StorageUnitInfo struct from StorageInfo instance. The |unit| // parameter is the output value. void BuildStorageUnitInfo(const storage_monitor::StorageInfo& info, api::system_storage::StorageUnitInfo* unit); } // namespace systeminfo // An abstract base class for all kinds of system information providers. Each // kind of SystemInfoProvider is a single shared instance. It is created if // needed, and destroyed at exit time. This is done via LazyInstance and // scoped_refptr. // // The SystemInfoProvider is designed to query system information on the worker // pool. It also maintains a queue of callbacks on the UI thread which are // waiting for the completion of querying operation. Once the query operation // is completed, all pending callbacks in the queue get called on the UI // thread. In this way, it avoids frequent querying operation in case of lots // of query requests, e.g. calling systemInfo.cpu.get repeatedly in an // extension process. // // Each kind of SystemInfoProvider should satisfy an API query in a subclass on // the blocking pool. class SystemInfoProvider : public base::RefCountedThreadSafe<SystemInfoProvider> { … }; } // namespace extensions #endif // EXTENSIONS_BROWSER_API_SYSTEM_INFO_SYSTEM_INFO_PROVIDER_H_