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/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.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 "extensions/browser/browser_context_keyed_api_factory.h" | 18 #include "extensions/browser/browser_context_keyed_api_factory.h" |
19 #include "extensions/browser/extension_registry.h" | 19 #include "extensions/browser/extension_registry.h" |
20 #include "extensions/browser/extension_registry_observer.h" | 20 #include "extensions/browser/extension_registry_observer.h" |
21 #include "extensions/browser/process_manager.h" | 21 #include "extensions/browser/process_manager.h" |
22 #include "extensions/browser/process_manager_observer.h" | 22 #include "extensions/browser/process_manager_observer.h" |
23 #include "extensions/common/extension.h" | 23 #include "extensions/common/extension.h" |
24 | 24 |
25 namespace extensions { | 25 namespace extensions { |
26 | 26 |
27 namespace core_api { | 27 namespace api { |
28 class BluetoothSocketApiFunction; | 28 class BluetoothSocketApiFunction; |
29 class BluetoothSocketEventDispatcher; | 29 class BluetoothSocketEventDispatcher; |
30 class SerialEventDispatcher; | 30 class SerialEventDispatcher; |
31 class TCPServerSocketEventDispatcher; | 31 class TCPServerSocketEventDispatcher; |
32 class TCPSocketEventDispatcher; | 32 class TCPSocketEventDispatcher; |
33 class UDPSocketEventDispatcher; | 33 class UDPSocketEventDispatcher; |
34 } | 34 } |
35 | 35 |
36 template <typename T> | 36 template <typename T> |
37 struct NamedThreadTraits { | 37 struct NamedThreadTraits { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 void OnExtensionUnloaded(content::BrowserContext* browser_context, | 185 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
186 const Extension* extension, | 186 const Extension* extension, |
187 UnloadedExtensionInfo::Reason reason) override { | 187 UnloadedExtensionInfo::Reason reason) override { |
188 data_->InitiateExtensionUnloadedCleanup(extension->id()); | 188 data_->InitiateExtensionUnloadedCleanup(extension->id()); |
189 } | 189 } |
190 | 190 |
191 private: | 191 private: |
192 // TODO(rockot): ApiResourceData could be moved out of ApiResourceManager and | 192 // TODO(rockot): ApiResourceData could be moved out of ApiResourceManager and |
193 // we could avoid maintaining a friends list here. | 193 // we could avoid maintaining a friends list here. |
194 friend class BluetoothAPI; | 194 friend class BluetoothAPI; |
195 friend class core_api::BluetoothSocketApiFunction; | 195 friend class api::BluetoothSocketApiFunction; |
196 friend class core_api::BluetoothSocketEventDispatcher; | 196 friend class api::BluetoothSocketEventDispatcher; |
197 friend class core_api::SerialEventDispatcher; | 197 friend class api::SerialEventDispatcher; |
198 friend class core_api::TCPServerSocketEventDispatcher; | 198 friend class api::TCPServerSocketEventDispatcher; |
199 friend class core_api::TCPSocketEventDispatcher; | 199 friend class api::TCPSocketEventDispatcher; |
200 friend class core_api::UDPSocketEventDispatcher; | 200 friend class api::UDPSocketEventDispatcher; |
201 friend class BrowserContextKeyedAPIFactory<ApiResourceManager<T> >; | 201 friend class BrowserContextKeyedAPIFactory<ApiResourceManager<T> >; |
202 | 202 |
203 static const bool kServiceHasOwnInstanceInIncognito = true; | 203 static const bool kServiceHasOwnInstanceInIncognito = true; |
204 static const bool kServiceIsNULLWhileTesting = true; | 204 static const bool kServiceIsNULLWhileTesting = true; |
205 | 205 |
206 // ApiResourceData class handles resource bookkeeping on a thread | 206 // ApiResourceData class handles resource bookkeeping on a thread |
207 // where resource lifetime is handled. | 207 // where resource lifetime is handled. |
208 class ApiResourceData : public base::RefCountedThreadSafe<ApiResourceData> { | 208 class ApiResourceData : public base::RefCountedThreadSafe<ApiResourceData> { |
209 public: | 209 public: |
210 typedef std::map<int, linked_ptr<T> > ApiResourceMap; | 210 typedef std::map<int, linked_ptr<T> > ApiResourceMap; |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 ->GetSequencedTaskRunnerWithShutdownBehavior( | 456 ->GetSequencedTaskRunnerWithShutdownBehavior( |
457 content::BrowserThread::GetBlockingPool()->GetNamedSequenceToken( | 457 content::BrowserThread::GetBlockingPool()->GetNamedSequenceToken( |
458 T::kSequenceToken), | 458 T::kSequenceToken), |
459 T::kShutdownBehavior); | 459 T::kShutdownBehavior); |
460 } | 460 } |
461 }; | 461 }; |
462 | 462 |
463 } // namespace extensions | 463 } // namespace extensions |
464 | 464 |
465 #endif // EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ | 465 #endif // EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ |
OLD | NEW |