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_EXTENSION_INFO_MAP_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "chrome/browser/extensions/extensions_quota_service.h" | 15 #include "chrome/browser/extensions/extensions_quota_service.h" |
16 #include "chrome/browser/extensions/process_map.h" | 16 #include "chrome/browser/extensions/process_map.h" |
17 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
18 #include "chrome/common/extensions/extension_set.h" | 18 #include "chrome/common/extensions/extension_set.h" |
19 | 19 |
20 using extensions::APIPermission; | |
miket_OOO
2012/06/25 22:01:11
In a case like this file where there's only a sing
Peng
2012/06/25 22:49:01
Done.
| |
21 | |
20 namespace extensions { | 22 namespace extensions { |
21 class Extension; | 23 class Extension; |
22 } | 24 } |
23 | 25 |
24 // Contains extension data that needs to be accessed on the IO thread. It can | 26 // Contains extension data that needs to be accessed on the IO thread. It can |
25 // be created/destroyed on any thread, but all other methods must be called on | 27 // be created/destroyed on any thread, but all other methods must be called on |
26 // the IO thread. | 28 // the IO thread. |
27 class ExtensionInfoMap : public base::RefCountedThreadSafe<ExtensionInfoMap> { | 29 class ExtensionInfoMap : public base::RefCountedThreadSafe<ExtensionInfoMap> { |
28 public: | 30 public: |
29 ExtensionInfoMap(); | 31 ExtensionInfoMap(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 // Removes an entry from process_map_. | 65 // Removes an entry from process_map_. |
64 void UnregisterExtensionProcess(const std::string& extension_id, | 66 void UnregisterExtensionProcess(const std::string& extension_id, |
65 int process_id, | 67 int process_id, |
66 int site_instance_id); | 68 int site_instance_id); |
67 void UnregisterAllExtensionsInProcess(int process_id); | 69 void UnregisterAllExtensionsInProcess(int process_id); |
68 | 70 |
69 // Returns true if there is exists an extension with the same origin as | 71 // Returns true if there is exists an extension with the same origin as |
70 // |origin| in |process_id| with |permission|. | 72 // |origin| in |process_id| with |permission|. |
71 bool SecurityOriginHasAPIPermission( | 73 bool SecurityOriginHasAPIPermission( |
72 const GURL& origin, int process_id, | 74 const GURL& origin, int process_id, |
73 ExtensionAPIPermission::ID permission) const; | 75 APIPermission::ID permission) const; |
74 | 76 |
75 ExtensionsQuotaService* GetQuotaService(); | 77 ExtensionsQuotaService* GetQuotaService(); |
76 | 78 |
77 private: | 79 private: |
78 friend class base::RefCountedThreadSafe<ExtensionInfoMap>; | 80 friend class base::RefCountedThreadSafe<ExtensionInfoMap>; |
79 | 81 |
80 // Extra dynamic data related to an extension. | 82 // Extra dynamic data related to an extension. |
81 struct ExtraData; | 83 struct ExtraData; |
82 // Map of extension_id to ExtraData. | 84 // Map of extension_id to ExtraData. |
83 typedef std::map<std::string, ExtraData> ExtraDataMap; | 85 typedef std::map<std::string, ExtraData> ExtraDataMap; |
84 | 86 |
85 ~ExtensionInfoMap(); | 87 ~ExtensionInfoMap(); |
86 | 88 |
87 ExtensionSet extensions_; | 89 ExtensionSet extensions_; |
88 ExtensionSet disabled_extensions_; | 90 ExtensionSet disabled_extensions_; |
89 | 91 |
90 // Extra data associated with enabled extensions. | 92 // Extra data associated with enabled extensions. |
91 ExtraDataMap extra_data_; | 93 ExtraDataMap extra_data_; |
92 | 94 |
93 // Used by dispatchers to limit API quota for individual extensions. | 95 // Used by dispatchers to limit API quota for individual extensions. |
94 // The ExtensionQutoaService is not thread safe. We need to create and destroy | 96 // The ExtensionQutoaService is not thread safe. We need to create and destroy |
95 // it on the IO thread. | 97 // it on the IO thread. |
96 scoped_ptr<ExtensionsQuotaService> quota_service_; | 98 scoped_ptr<ExtensionsQuotaService> quota_service_; |
97 | 99 |
98 // Assignment of extensions to processes. | 100 // Assignment of extensions to processes. |
99 extensions::ProcessMap process_map_; | 101 extensions::ProcessMap process_map_; |
100 }; | 102 }; |
101 | 103 |
102 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_ | 104 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_ |
OLD | NEW |