| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_API_RESOURCE_MANAGER_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ |
| 6 #define EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ | 6 #define EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/scoped_observer.h" | 14 #include "base/scoped_observer.h" |
| 15 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
| 16 #include "components/keyed_service/core/keyed_service.h" | 16 #include "components/keyed_service/core/keyed_service.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
| 21 #include "extensions/browser/browser_context_keyed_api_factory.h" | 21 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 22 #include "extensions/browser/extension_host.h" | 22 #include "extensions/browser/extension_host.h" |
| 23 #include "extensions/browser/extension_registry.h" | 23 #include "extensions/browser/extension_registry.h" |
| 24 #include "extensions/browser/extension_registry_observer.h" | 24 #include "extensions/browser/extension_registry_observer.h" |
| 25 #include "extensions/browser/notification_types.h" | 25 #include "extensions/browser/notification_types.h" |
| 26 #include "extensions/common/extension.h" | 26 #include "extensions/common/extension.h" |
| 27 | 27 |
| 28 namespace extensions { | 28 namespace extensions { |
| 29 | 29 |
| 30 namespace api { | 30 namespace core_api { |
| 31 class BluetoothSocketApiFunction; | 31 class BluetoothSocketApiFunction; |
| 32 class BluetoothSocketEventDispatcher; | 32 class BluetoothSocketEventDispatcher; |
| 33 } | |
| 34 | |
| 35 namespace core_api { | |
| 36 class SerialEventDispatcher; | 33 class SerialEventDispatcher; |
| 37 class TCPServerSocketEventDispatcher; | 34 class TCPServerSocketEventDispatcher; |
| 38 class TCPSocketEventDispatcher; | 35 class TCPSocketEventDispatcher; |
| 39 class UDPSocketEventDispatcher; | 36 class UDPSocketEventDispatcher; |
| 40 } | 37 } |
| 41 | 38 |
| 42 template <typename T> | 39 template <typename T> |
| 43 struct NamedThreadTraits { | 40 struct NamedThreadTraits { |
| 44 static bool IsCalledOnValidThread() { | 41 static bool IsCalledOnValidThread() { |
| 45 return content::BrowserThread::CurrentlyOn(T::kThreadId); | 42 return content::BrowserThread::CurrentlyOn(T::kThreadId); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 content::BrowserContext* browser_context, | 194 content::BrowserContext* browser_context, |
| 198 const Extension* extension, | 195 const Extension* extension, |
| 199 UnloadedExtensionInfo::Reason reason) OVERRIDE { | 196 UnloadedExtensionInfo::Reason reason) OVERRIDE { |
| 200 data_->InitiateExtensionUnloadedCleanup(extension->id()); | 197 data_->InitiateExtensionUnloadedCleanup(extension->id()); |
| 201 } | 198 } |
| 202 | 199 |
| 203 private: | 200 private: |
| 204 // TODO(rockot): ApiResourceData could be moved out of ApiResourceManager and | 201 // TODO(rockot): ApiResourceData could be moved out of ApiResourceManager and |
| 205 // we could avoid maintaining a friends list here. | 202 // we could avoid maintaining a friends list here. |
| 206 friend class BluetoothAPI; | 203 friend class BluetoothAPI; |
| 207 friend class api::BluetoothSocketApiFunction; | 204 friend class core_api::BluetoothSocketApiFunction; |
| 208 friend class api::BluetoothSocketEventDispatcher; | 205 friend class core_api::BluetoothSocketEventDispatcher; |
| 209 friend class core_api::SerialEventDispatcher; | 206 friend class core_api::SerialEventDispatcher; |
| 210 friend class core_api::TCPServerSocketEventDispatcher; | 207 friend class core_api::TCPServerSocketEventDispatcher; |
| 211 friend class core_api::TCPSocketEventDispatcher; | 208 friend class core_api::TCPSocketEventDispatcher; |
| 212 friend class core_api::UDPSocketEventDispatcher; | 209 friend class core_api::UDPSocketEventDispatcher; |
| 213 friend class BrowserContextKeyedAPIFactory<ApiResourceManager<T> >; | 210 friend class BrowserContextKeyedAPIFactory<ApiResourceManager<T> >; |
| 214 | 211 |
| 215 static const bool kServiceHasOwnInstanceInIncognito = true; | 212 static const bool kServiceHasOwnInstanceInIncognito = true; |
| 216 static const bool kServiceIsNULLWhileTesting = true; | 213 static const bool kServiceIsNULLWhileTesting = true; |
| 217 | 214 |
| 218 // ApiResourceData class handles resource bookkeeping on a thread | 215 // ApiResourceData class handles resource bookkeeping on a thread |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 ->GetSequencedTaskRunnerWithShutdownBehavior( | 462 ->GetSequencedTaskRunnerWithShutdownBehavior( |
| 466 content::BrowserThread::GetBlockingPool()->GetNamedSequenceToken( | 463 content::BrowserThread::GetBlockingPool()->GetNamedSequenceToken( |
| 467 T::kSequenceToken), | 464 T::kSequenceToken), |
| 468 T::kShutdownBehavior); | 465 T::kShutdownBehavior); |
| 469 } | 466 } |
| 470 }; | 467 }; |
| 471 | 468 |
| 472 } // namespace extensions | 469 } // namespace extensions |
| 473 | 470 |
| 474 #endif // EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ | 471 #endif // EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ |
| OLD | NEW |