Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1003)

Side by Side Diff: third_party/WebKit/Source/platform/bindings/DOMWrapperWorld.h

Issue 2848653003: Add a DevTools command to create an isolated world for a given frame (Closed)
Patch Set: Changes for Sami Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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,
pfeldman 2017/05/05 15:40:24 10 worlds should be enough for everyone? :) Can we
caseq 2017/05/05 16:36:02 +1, I can imagine an easy scenario for leaking the
alex clarke (OOO till 29th) 2017/05/05 19:29:44 Done.
alex clarke (OOO till 29th) 2017/05/05 19:29:44 Done.
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.
caseq 2017/05/05 16:36:02 I just noticed this. Should we just use generateWo
alex clarke (OOO till 29th) 2017/05/05 19:29:44 I suppose we could. We'll need to either make it
66 kUnspecifiedWorldIdStart, 68 kUnspecifiedWorldIdStart,
67 }; 69 };
68 70
69 enum class WorldType { 71 enum class WorldType {
70 kMain, 72 kMain,
71 kIsolated, 73 kIsolated,
72 kGarbageCollector, 74 kGarbageCollector,
73 kRegExp, 75 kRegExp,
74 kTesting, 76 kTesting,
75 kWorker, 77 kWorker,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698