#include "extensions/browser/api/system_info/system_info_api.h"
#include <stdint.h>
#include <memory>
#include <utility>
#include "base/containers/flat_set.h"
#include "base/functional/bind.h"
#include "base/lazy_instance.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/singleton.h"
#include "base/values.h"
#include "components/storage_monitor/removable_storage_observer.h"
#include "components/storage_monitor/storage_info.h"
#include "components/storage_monitor/storage_monitor.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/api/system_display/display_info_provider.h"
#include "extensions/browser/api/system_info/system_info_provider.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/common/api/system_display.h"
#include "extensions/common/api/system_storage.h"
namespace extensions {
StorageUnitInfo;
BrowserThread;
StorageMonitor;
system_display;
system_storage;
namespace {
class SystemInfoEventRouter : public storage_monitor::RemovableStorageObserver { … };
static base::LazyInstance<SystemInfoEventRouter>::Leaky
g_system_info_event_router = …;
SystemInfoEventRouter* SystemInfoEventRouter::GetInstance() { … }
SystemInfoEventRouter::SystemInfoEventRouter() = default;
SystemInfoEventRouter::~SystemInfoEventRouter() { … }
void SystemInfoEventRouter::CheckForDisplayListeners(
content::BrowserContext* context) { … }
void SystemInfoEventRouter::CheckForStorageListeners(
content::BrowserContext* context) { … }
void SystemInfoEventRouter::ShutdownForContext(
content::BrowserContext* context) { … }
void SystemInfoEventRouter::StartOrStopDisplayEventDispatcherIfNecessary() { … }
void SystemInfoEventRouter::StartOrStopStorageEventDispatcherIfNecessary() { … }
void SystemInfoEventRouter::OnRemovableStorageAttached(
const storage_monitor::StorageInfo& info) { … }
void SystemInfoEventRouter::OnRemovableStorageDetached(
const storage_monitor::StorageInfo& info) { … }
void SystemInfoEventRouter::DispatchEvent(
events::HistogramValue histogram_value,
const std::string& event_name,
base::Value::List args) const { … }
void HandleListenerAddedOrRemoved(content::BrowserContext* context,
const std::string& event_name) { … }
}
static base::LazyInstance<
BrowserContextKeyedAPIFactory<SystemInfoAPI>>::DestructorAtExit g_factory = …;
BrowserContextKeyedAPIFactory<SystemInfoAPI>*
SystemInfoAPI::GetFactoryInstance() { … }
SystemInfoAPI::SystemInfoAPI(content::BrowserContext* context)
: … { … }
SystemInfoAPI::~SystemInfoAPI() = default;
void SystemInfoAPI::Shutdown() { … }
void SystemInfoAPI::OnListenerAdded(const EventListenerInfo& details) { … }
void SystemInfoAPI::OnListenerRemoved(const EventListenerInfo& details) { … }
}