OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_MANAGER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_MANAGER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
11 #include "base/threading/non_thread_safe.h" | 11 #include "base/threading/non_thread_safe.h" |
12 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
14 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 14 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
18 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
19 | 19 |
20 using content::BrowserThread; | 20 using content::BrowserThread; |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 | 23 |
24 // An ApiResourceManager manages the lifetime of a set of resources that | 24 // An ApiResourceManager manages the lifetime of a set of resources that |
25 // ApiFunctions use. Examples are sockets or USB connections. | 25 // ApiFunctions use. Examples are sockets or USB connections. |
26 template <class T> | 26 template <class T> |
27 class ApiResourceManager : public ProfileKeyedService, | 27 class ApiResourceManager : public BrowserContextKeyedService, |
28 public base::NonThreadSafe, | 28 public base::NonThreadSafe, |
29 public content::NotificationObserver { | 29 public content::NotificationObserver { |
30 public: | 30 public: |
31 explicit ApiResourceManager(const BrowserThread::ID thread_id) | 31 explicit ApiResourceManager(const BrowserThread::ID thread_id) |
32 : thread_id_(thread_id), | 32 : thread_id_(thread_id), |
33 data_(new ApiResourceData(thread_id)) { | 33 data_(new ApiResourceData(thread_id)) { |
34 registrar_.Add(this, | 34 registrar_.Add(this, |
35 chrome::NOTIFICATION_EXTENSION_UNLOADED, | 35 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
36 content::NotificationService::AllSources()); | 36 content::NotificationService::AllSources()); |
37 } | 37 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 }; | 165 }; |
166 | 166 |
167 const BrowserThread::ID thread_id_; | 167 const BrowserThread::ID thread_id_; |
168 content::NotificationRegistrar registrar_; | 168 content::NotificationRegistrar registrar_; |
169 scoped_ptr<ApiResourceData> data_; | 169 scoped_ptr<ApiResourceData> data_; |
170 }; | 170 }; |
171 | 171 |
172 } // namespace extensions | 172 } // namespace extensions |
173 | 173 |
174 #endif // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_MANAGER_H_ | 174 #endif // CHROME_BROWSER_EXTENSIONS_API_API_RESOURCE_MANAGER_H_ |
OLD | NEW |