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/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.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/common/extension.h" | 23 #include "extensions/common/extension.h" |
24 | 24 |
25 namespace extensions { | 25 namespace extensions { |
26 | 26 |
27 namespace api { | 27 namespace api { |
28 class BluetoothSocketApiFunction; | 28 class BluetoothSocketApiFunction; |
29 class BluetoothSocketEventDispatcher; | 29 class BluetoothSocketEventDispatcher; |
30 class SerialEventDispatcher; | |
31 } | 30 } |
32 | 31 |
33 namespace core_api { | 32 namespace core_api { |
| 33 class SerialEventDispatcher; |
34 class TCPServerSocketEventDispatcher; | 34 class TCPServerSocketEventDispatcher; |
35 class TCPSocketEventDispatcher; | 35 class TCPSocketEventDispatcher; |
36 class UDPSocketEventDispatcher; | 36 class UDPSocketEventDispatcher; |
37 } | 37 } |
38 | 38 |
39 // An ApiResourceManager manages the lifetime of a set of resources that | 39 // An ApiResourceManager manages the lifetime of a set of resources that |
40 // ApiFunctions use. Examples are sockets or USB connections. | 40 // ApiFunctions use. Examples are sockets or USB connections. |
41 // | 41 // |
42 // Users of this class should define kThreadId to be the thread that | 42 // Users of this class should define kThreadId to be the thread that |
43 // ApiResourceManager to works on. The default is defined in ApiResource. | 43 // ApiResourceManager to works on. The default is defined in ApiResource. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } | 150 } |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 private: | 154 private: |
155 // TODO(rockot): ApiResourceData could be moved out of ApiResourceManager and | 155 // TODO(rockot): ApiResourceData could be moved out of ApiResourceManager and |
156 // we could avoid maintaining a friends list here. | 156 // we could avoid maintaining a friends list here. |
157 friend class BluetoothAPI; | 157 friend class BluetoothAPI; |
158 friend class api::BluetoothSocketApiFunction; | 158 friend class api::BluetoothSocketApiFunction; |
159 friend class api::BluetoothSocketEventDispatcher; | 159 friend class api::BluetoothSocketEventDispatcher; |
160 friend class api::SerialEventDispatcher; | 160 friend class core_api::SerialEventDispatcher; |
161 friend class core_api::TCPServerSocketEventDispatcher; | 161 friend class core_api::TCPServerSocketEventDispatcher; |
162 friend class core_api::TCPSocketEventDispatcher; | 162 friend class core_api::TCPSocketEventDispatcher; |
163 friend class core_api::UDPSocketEventDispatcher; | 163 friend class core_api::UDPSocketEventDispatcher; |
164 friend class BrowserContextKeyedAPIFactory<ApiResourceManager<T> >; | 164 friend class BrowserContextKeyedAPIFactory<ApiResourceManager<T> >; |
165 | 165 |
166 // BrowserContextKeyedAPI implementation. | 166 // BrowserContextKeyedAPI implementation. |
167 static const char* service_name() { return T::service_name(); } | 167 static const char* service_name() { return T::service_name(); } |
168 | 168 |
169 static const bool kServiceHasOwnInstanceInIncognito = true; | 169 static const bool kServiceHasOwnInstanceInIncognito = true; |
170 static const bool kServiceIsNULLWhileTesting = true; | 170 static const bool kServiceIsNULLWhileTesting = true; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 }; | 339 }; |
340 | 340 |
341 content::BrowserThread::ID thread_id_; | 341 content::BrowserThread::ID thread_id_; |
342 content::NotificationRegistrar registrar_; | 342 content::NotificationRegistrar registrar_; |
343 scoped_refptr<ApiResourceData> data_; | 343 scoped_refptr<ApiResourceData> data_; |
344 }; | 344 }; |
345 | 345 |
346 } // namespace extensions | 346 } // namespace extensions |
347 | 347 |
348 #endif // EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ | 348 #endif // EXTENSIONS_BROWSER_API_API_RESOURCE_MANAGER_H_ |
OLD | NEW |