OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 class PLATFORM_EXPORT DOMWrapperWorld : public RefCounted<DOMWrapperWorld> { | 52 class PLATFORM_EXPORT DOMWrapperWorld : public RefCounted<DOMWrapperWorld> { |
53 public: | 53 public: |
54 // Per-thread global identifiers for DOMWrapperWorld. | 54 // Per-thread global identifiers for DOMWrapperWorld. |
55 enum WorldId { | 55 enum WorldId { |
56 kInvalidWorldId = -1, | 56 kInvalidWorldId = -1, |
57 kMainWorldId = 0, | 57 kMainWorldId = 0, |
58 | 58 |
59 // Embedder isolated worlds can use IDs in [1, 1<<29). | 59 // Embedder isolated worlds can use IDs in [1, 1<<29). |
60 kEmbedderWorldIdLimit = (1 << 29), | 60 kEmbedderWorldIdLimit = (1 << 29), |
61 kDocumentXMLTreeViewerWorldId, | 61 kDocumentXMLTreeViewerWorldId, |
| 62 kDevToolsFirstIsolatedWorldId, |
| 63 kDevToolsLastIsolatedWorldId = kDevToolsFirstIsolatedWorldId + 10, |
62 kIsolatedWorldIdLimit, | 64 kIsolatedWorldIdLimit, |
63 | 65 |
64 // Other worlds can use IDs after this. Don't manually pick up an ID from | 66 // Other worlds can use IDs after this. Don't manually pick up an ID from |
65 // this range. generateWorldIdForType() picks it up on behalf of you. | 67 // this range. generateWorldIdForType() picks it up on behalf of you. |
66 kUnspecifiedWorldIdStart, | 68 kUnspecifiedWorldIdStart, |
67 }; | 69 }; |
68 | 70 |
69 enum class WorldType { | 71 enum class WorldType { |
70 kMain, | 72 kMain, |
71 kIsolated, | 73 kIsolated, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 DOMDataStore& DomDataStore() const { return *dom_data_store_; } | 136 DOMDataStore& DomDataStore() const { return *dom_data_store_; } |
135 | 137 |
136 template <typename T> | 138 template <typename T> |
137 void RegisterDOMObjectHolder(v8::Isolate* isolate, | 139 void RegisterDOMObjectHolder(v8::Isolate* isolate, |
138 T* object, | 140 T* object, |
139 v8::Local<v8::Value> wrapper) { | 141 v8::Local<v8::Value> wrapper) { |
140 RegisterDOMObjectHolderInternal( | 142 RegisterDOMObjectHolderInternal( |
141 DOMObjectHolder<T>::Create(isolate, object, wrapper)); | 143 DOMObjectHolder<T>::Create(isolate, object, wrapper)); |
142 } | 144 } |
143 | 145 |
| 146 // Returns an id in the range |
| 147 // [kDevToolsFirstIsolatedWorldId, kDevToolsLastIsolatedWorldId] or |
| 148 // kInvalidWorldId if that range has been exhausted. |
| 149 static int GetNextDevToolsIsolatedWorldId(); |
| 150 |
144 private: | 151 private: |
145 class DOMObjectHolderBase { | 152 class DOMObjectHolderBase { |
146 USING_FAST_MALLOC(DOMObjectHolderBase); | 153 USING_FAST_MALLOC(DOMObjectHolderBase); |
147 | 154 |
148 public: | 155 public: |
149 DOMObjectHolderBase(v8::Isolate* isolate, v8::Local<v8::Value> wrapper) | 156 DOMObjectHolderBase(v8::Isolate* isolate, v8::Local<v8::Value> wrapper) |
150 : wrapper_(isolate, wrapper), world_(nullptr) {} | 157 : wrapper_(isolate, wrapper), world_(nullptr) {} |
151 virtual ~DOMObjectHolderBase() {} | 158 virtual ~DOMObjectHolderBase() {} |
152 | 159 |
153 DOMWrapperWorld* World() const { return world_; } | 160 DOMWrapperWorld* World() const { return world_; } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 225 |
219 const WorldType world_type_; | 226 const WorldType world_type_; |
220 const int world_id_; | 227 const int world_id_; |
221 std::unique_ptr<DOMDataStore> dom_data_store_; | 228 std::unique_ptr<DOMDataStore> dom_data_store_; |
222 HashSet<std::unique_ptr<DOMObjectHolderBase>> dom_object_holders_; | 229 HashSet<std::unique_ptr<DOMObjectHolderBase>> dom_object_holders_; |
223 }; | 230 }; |
224 | 231 |
225 } // namespace blink | 232 } // namespace blink |
226 | 233 |
227 #endif // DOMWrapperWorld_h | 234 #endif // DOMWrapperWorld_h |
OLD | NEW |