| 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 #include "extensions/browser/api/system_info/system_info_api.h" | 5 #include "extensions/browser/api/system_info/system_info_api.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 13 #include "base/profiler/scoped_profile.h" | |
| 14 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 15 #include "base/values.h" | 14 #include "base/values.h" |
| 16 #include "components/storage_monitor/removable_storage_observer.h" | 15 #include "components/storage_monitor/removable_storage_observer.h" |
| 17 #include "components/storage_monitor/storage_info.h" | 16 #include "components/storage_monitor/storage_info.h" |
| 18 #include "components/storage_monitor/storage_monitor.h" | 17 #include "components/storage_monitor/storage_monitor.h" |
| 19 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 20 #include "extensions/browser/api/system_display/display_info_provider.h" | 19 #include "extensions/browser/api/system_display/display_info_provider.h" |
| 21 #include "extensions/browser/api/system_storage/storage_info_provider.h" | 20 #include "extensions/browser/api/system_storage/storage_info_provider.h" |
| 22 #include "extensions/browser/extensions_browser_client.h" | 21 #include "extensions/browser/extensions_browser_client.h" |
| 23 #include "extensions/common/api/system_display.h" | 22 #include "extensions/common/api/system_display.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 } | 230 } |
| 232 | 231 |
| 233 SystemInfoAPI::~SystemInfoAPI() { | 232 SystemInfoAPI::~SystemInfoAPI() { |
| 234 } | 233 } |
| 235 | 234 |
| 236 void SystemInfoAPI::Shutdown() { | 235 void SystemInfoAPI::Shutdown() { |
| 237 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 236 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
| 238 } | 237 } |
| 239 | 238 |
| 240 void SystemInfoAPI::OnListenerAdded(const EventListenerInfo& details) { | 239 void SystemInfoAPI::OnListenerAdded(const EventListenerInfo& details) { |
| 241 // TODO(vadimt): Remove ScopedProfile below once crbug.com/417106 is fixed. | |
| 242 tracked_objects::ScopedProfile tracking_profile( | |
| 243 FROM_HERE_WITH_EXPLICIT_FUNCTION("SystemInfoAPI::OnListenerAdded")); | |
| 244 | |
| 245 if (IsSystemStorageEvent(details.event_name)) { | 240 if (IsSystemStorageEvent(details.event_name)) { |
| 246 StorageMonitor::GetInstance()->EnsureInitialized( | 241 StorageMonitor::GetInstance()->EnsureInitialized( |
| 247 base::Bind(&AddEventListener, details.event_name)); | 242 base::Bind(&AddEventListener, details.event_name)); |
| 248 } else { | 243 } else { |
| 249 AddEventListener(details.event_name); | 244 AddEventListener(details.event_name); |
| 250 } | 245 } |
| 251 } | 246 } |
| 252 | 247 |
| 253 void SystemInfoAPI::OnListenerRemoved(const EventListenerInfo& details) { | 248 void SystemInfoAPI::OnListenerRemoved(const EventListenerInfo& details) { |
| 254 if (IsSystemStorageEvent(details.event_name)) { | 249 if (IsSystemStorageEvent(details.event_name)) { |
| 255 StorageMonitor::GetInstance()->EnsureInitialized( | 250 StorageMonitor::GetInstance()->EnsureInitialized( |
| 256 base::Bind(&RemoveEventListener, details.event_name)); | 251 base::Bind(&RemoveEventListener, details.event_name)); |
| 257 } else { | 252 } else { |
| 258 RemoveEventListener(details.event_name); | 253 RemoveEventListener(details.event_name); |
| 259 } | 254 } |
| 260 } | 255 } |
| 261 | 256 |
| 262 } // namespace extensions | 257 } // namespace extensions |
| OLD | NEW |