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

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

Issue 2735823006: Bindings: Manage multiple DOMWrapperWorlds for worklets (Closed)
Patch Set: s/lastUsedWorldId/lastGeneratedWorldId Created 3 years, 9 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // Per-thread global identifiers for DOMWrapperWorld. 54 // Per-thread global identifiers for DOMWrapperWorld.
55 enum WorldId { 55 enum WorldId {
56 InvalidWorldId = -1, 56 InvalidWorldId = -1,
57 MainWorldId = 0, 57 MainWorldId = 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 EmbedderWorldIdLimit = (1 << 29), 60 EmbedderWorldIdLimit = (1 << 29),
61 DocumentXMLTreeViewerWorldId, 61 DocumentXMLTreeViewerWorldId,
62 IsolatedWorldIdLimit, 62 IsolatedWorldIdLimit,
63 63
64 // TODO(nhiroki): Dynamically allocate a world id for the following worlds 64 // Other worlds can use IDs after IsolatedWorldIdLimit. Don't manually pick
65 // instead of a fixed value (https://crbug.com/697622). 65 // up an ID from this range. generateWorldIdForType() picks it up on behalf
66 GarbageCollectorWorldId, 66 // of you.
67 RegExpWorldId,
68 TestingWorldId,
69 WorkerWorldId,
70 }; 67 };
71 68
72 enum class WorldType { 69 enum class WorldType {
73 Main, 70 Main,
74 Isolated, 71 Isolated,
75 GarbageCollector, 72 GarbageCollector,
76 RegExp, 73 RegExp,
77 Testing, 74 Testing,
78 Worker, 75 Worker,
79 }; 76 };
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 void registerDOMObjectHolder(v8::Isolate*, T*, v8::Local<v8::Value>); 137 void registerDOMObjectHolder(v8::Isolate*, T*, v8::Local<v8::Value>);
141 138
142 private: 139 private:
143 DOMWrapperWorld(v8::Isolate*, WorldType, int worldId); 140 DOMWrapperWorld(v8::Isolate*, WorldType, int worldId);
144 141
145 static void weakCallbackForDOMObjectHolder( 142 static void weakCallbackForDOMObjectHolder(
146 const v8::WeakCallbackInfo<DOMObjectHolderBase>&); 143 const v8::WeakCallbackInfo<DOMObjectHolderBase>&);
147 void registerDOMObjectHolderInternal(std::unique_ptr<DOMObjectHolderBase>); 144 void registerDOMObjectHolderInternal(std::unique_ptr<DOMObjectHolderBase>);
148 void unregisterDOMObjectHolder(DOMObjectHolderBase*); 145 void unregisterDOMObjectHolder(DOMObjectHolderBase*);
149 146
150 static unsigned s_numberOfNonMainWorldsInMainThread; 147 static unsigned s_numberOfNonMainWorldsInMainThread;
peria 2017/03/14 09:52:46 optional: Can this static variable be replaced wit
nhiroki 2017/03/14 10:58:28 It'd be feasible. I'll work on it in a follow-up C
151 148
152 // Returns an identifier for a given world type. This must not call for 149 // Returns an identifier for a given world type. This must not be called for
153 // WorldType::IsolatedWorld because an identifier for the world is given from 150 // WorldType::IsolatedWorld because an identifier for the world is given from
154 // out of DOMWrapperWorld. 151 // out of DOMWrapperWorld.
155 static int getWorldIdForType(WorldType); 152 static int generateWorldIdForType(WorldType);
156 153
157 const WorldType m_worldType; 154 const WorldType m_worldType;
158 const int m_worldId; 155 const int m_worldId;
159 std::unique_ptr<DOMDataStore> m_domDataStore; 156 std::unique_ptr<DOMDataStore> m_domDataStore;
160 HashSet<std::unique_ptr<DOMObjectHolderBase>> m_domObjectHolders; 157 HashSet<std::unique_ptr<DOMObjectHolderBase>> m_domObjectHolders;
161 }; 158 };
162 159
163 } // namespace blink 160 } // namespace blink
164 161
165 #endif // DOMWrapperWorld_h 162 #endif // DOMWrapperWorld_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698