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

Side by Side Diff: Source/bindings/v8/DOMWrapperWorld.h

Issue 180743013: Ensure DOMWrapperWorld always exists in all webkit_unit_tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/v8/DOMWrapperWorld.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 class DOMDataStore; 44 class DOMDataStore;
45 class ScriptController; 45 class ScriptController;
46 class ExecutionContext; 46 class ExecutionContext;
47 47
48 enum WorldIdConstants { 48 enum WorldIdConstants {
49 MainWorldId = 0, 49 MainWorldId = 0,
50 // Embedder isolated worlds can use IDs in [1, 1<<29). 50 // Embedder isolated worlds can use IDs in [1, 1<<29).
51 EmbedderWorldIdLimit = (1 << 29), 51 EmbedderWorldIdLimit = (1 << 29),
52 ScriptPreprocessorIsolatedWorldId, 52 ScriptPreprocessorIsolatedWorldId,
53 IsolatedWorldIdLimit,
53 WorkerWorldId, 54 WorkerWorldId,
55 TestingWorldId,
54 }; 56 };
55 57
56 // This class represent a collection of DOM wrappers for a specific world. 58 // This class represent a collection of DOM wrappers for a specific world.
57 class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> { 59 class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {
58 public: 60 public:
59 static PassRefPtr<DOMWrapperWorld> create(int worldId, int extensionGroup); 61 static PassRefPtr<DOMWrapperWorld> create(int worldId = -1, int extensionGro up = -1);
60 62
61 static const int mainWorldExtensionGroup = 0; 63 static const int mainWorldExtensionGroup = 0;
62 static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(int worldId, int exte nsionGroup); 64 static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(int worldId, int exte nsionGroup);
63 ~DOMWrapperWorld(); 65 ~DOMWrapperWorld();
64 66
65 static bool isolatedWorldsExist() { return isolatedWorldCount; } 67 static bool isolatedWorldsExist() { return isolatedWorldCount; }
66 static void allWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld> >& worlds); 68 static void allWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld> >& worlds);
67 69
68 static DOMWrapperWorld* world(v8::Handle<v8::Context> context) 70 static DOMWrapperWorld* world(v8::Handle<v8::Context> context)
69 { 71 {
(...skipping 19 matching lines...) Expand all
89 // 91 //
90 // FIXME: Right now, resource injection simply bypasses the main world's 92 // FIXME: Right now, resource injection simply bypasses the main world's
91 // DOM. More work is necessary to allow the isolated world's policy to be 93 // DOM. More work is necessary to allow the isolated world's policy to be
92 // applied correctly. 94 // applied correctly.
93 static void setIsolatedWorldContentSecurityPolicy(int worldID, const String& policy); 95 static void setIsolatedWorldContentSecurityPolicy(int worldID, const String& policy);
94 static void clearIsolatedWorldContentSecurityPolicy(int worldID); 96 static void clearIsolatedWorldContentSecurityPolicy(int worldID);
95 bool isolatedWorldHasContentSecurityPolicy(); 97 bool isolatedWorldHasContentSecurityPolicy();
96 98
97 bool isMainWorld() const { return m_worldId == MainWorldId; } 99 bool isMainWorld() const { return m_worldId == MainWorldId; }
98 bool isWorkerWorld() const { return m_worldId == WorkerWorldId; } 100 bool isWorkerWorld() const { return m_worldId == WorkerWorldId; }
99 bool isIsolatedWorld() const { return !isMainWorld() && !isWorkerWorld(); } 101 bool isIsolatedWorld() const { return MainWorldId < m_worldId && m_worldId < IsolatedWorldIdLimit; }
100 102
101 int worldId() const { return m_worldId; } 103 int worldId() const { return m_worldId; }
102 int extensionGroup() const { return m_extensionGroup; } 104 int extensionGroup() const { return m_extensionGroup; }
103 DOMDataStore& domDataStore() { return *m_domDataStore; } 105 DOMDataStore& domDataStore() { return *m_domDataStore; }
104 106
105 private: 107 private:
106 static unsigned isolatedWorldCount; 108 static unsigned isolatedWorldCount;
107 109
108 DOMWrapperWorld(int worldId, int extensionGroup); 110 DOMWrapperWorld(int worldId, int extensionGroup);
109 static bool contextHasCorrectPrototype(v8::Handle<v8::Context>); 111 static bool contextHasCorrectPrototype(v8::Handle<v8::Context>);
110 112
111 const int m_worldId; 113 const int m_worldId;
112 const int m_extensionGroup; 114 const int m_extensionGroup;
113 OwnPtr<DOMDataStore> m_domDataStore; 115 OwnPtr<DOMDataStore> m_domDataStore;
114 }; 116 };
115 117
116 } // namespace WebCore 118 } // namespace WebCore
117 119
118 #endif // DOMWrapperWorld_h 120 #endif // DOMWrapperWorld_h
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/v8/DOMWrapperWorld.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698