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

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

Issue 2795593006: Abstract out Modulator from V8PerContextData (Closed)
Patch Set: Add new from method for Modulator Created 3 years, 8 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "gin/public/gin_embedders.h" 42 #include "gin/public/gin_embedders.h"
43 #include "v8/include/v8.h" 43 #include "v8/include/v8.h"
44 #include "wtf/Allocator.h" 44 #include "wtf/Allocator.h"
45 #include "wtf/HashMap.h" 45 #include "wtf/HashMap.h"
46 #include "wtf/Vector.h" 46 #include "wtf/Vector.h"
47 #include "wtf/text/AtomicString.h" 47 #include "wtf/text/AtomicString.h"
48 #include "wtf/text/AtomicStringHash.h" 48 #include "wtf/text/AtomicStringHash.h"
49 49
50 namespace blink { 50 namespace blink {
51 51
52 class Modulator;
53 class V8DOMActivityLogger; 52 class V8DOMActivityLogger;
54 class V8PerContextData; 53 class V8PerContextData;
55 54
56 enum V8ContextEmbedderDataField { 55 enum V8ContextEmbedderDataField {
57 v8ContextPerContextDataIndex = 56 v8ContextPerContextDataIndex =
58 static_cast<int>(gin::kPerContextDataStartIndex + gin::kEmbedderBlink), 57 static_cast<int>(gin::kPerContextDataStartIndex + gin::kEmbedderBlink),
59 }; 58 };
60 59
61 class CORE_EXPORT V8PerContextData final { 60 class CORE_EXPORT V8PerContextData final {
62 USING_FAST_MALLOC(V8PerContextData); 61 USING_FAST_MALLOC(V8PerContextData);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 v8::Local<v8::Object>* prototypeObject, 96 v8::Local<v8::Object>* prototypeObject,
98 v8::Local<v8::Function>* interfaceObject); 97 v8::Local<v8::Function>* interfaceObject);
99 98
100 void addCustomElementBinding(std::unique_ptr<V0CustomElementBinding>); 99 void addCustomElementBinding(std::unique_ptr<V0CustomElementBinding>);
101 100
102 V8DOMActivityLogger* activityLogger() const { return m_activityLogger; } 101 V8DOMActivityLogger* activityLogger() const { return m_activityLogger; }
103 void setActivityLogger(V8DOMActivityLogger* activityLogger) { 102 void setActivityLogger(V8DOMActivityLogger* activityLogger) {
104 m_activityLogger = activityLogger; 103 m_activityLogger = activityLogger;
105 } 104 }
106 105
107 Modulator* modulator() const { return m_modulator.get(); } 106 // Garbage collected classes that use V8PerContextData to hold an instance
108 void setModulator(Modulator*); 107 // should subclass Data, and use addData / clearData / getData to manage the
109 void clearModulator(); 108 // instance.
109 class CORE_EXPORT Data : public GarbageCollectedMixin {};
110
111 void addData(const char* key, Data*);
112 void clearData(const char* key);
113 Data* getData(const char* key);
110 114
111 private: 115 private:
112 V8PerContextData(v8::Local<v8::Context>); 116 V8PerContextData(v8::Local<v8::Context>);
113 117
114 v8::Local<v8::Object> createWrapperFromCacheSlowCase(const WrapperTypeInfo*); 118 v8::Local<v8::Object> createWrapperFromCacheSlowCase(const WrapperTypeInfo*);
115 v8::Local<v8::Function> constructorForTypeSlowCase(const WrapperTypeInfo*); 119 v8::Local<v8::Function> constructorForTypeSlowCase(const WrapperTypeInfo*);
116 120
117 v8::Isolate* m_isolate; 121 v8::Isolate* m_isolate;
118 122
119 // For each possible type of wrapper, we keep a boilerplate object. 123 // For each possible type of wrapper, we keep a boilerplate object.
(...skipping 11 matching lines...) Expand all
131 ScopedPersistent<v8::Context> m_context; 135 ScopedPersistent<v8::Context> m_context;
132 ScopedPersistent<v8::Value> m_errorPrototype; 136 ScopedPersistent<v8::Value> m_errorPrototype;
133 137
134 typedef Vector<std::unique_ptr<V0CustomElementBinding>> 138 typedef Vector<std::unique_ptr<V0CustomElementBinding>>
135 V0CustomElementBindingList; 139 V0CustomElementBindingList;
136 V0CustomElementBindingList m_customElementBindings; 140 V0CustomElementBindingList m_customElementBindings;
137 141
138 // This is owned by a static hash map in V8DOMActivityLogger. 142 // This is owned by a static hash map in V8DOMActivityLogger.
139 V8DOMActivityLogger* m_activityLogger; 143 V8DOMActivityLogger* m_activityLogger;
140 144
141 Persistent<Modulator> m_modulator; 145 using DataMap =
146 PersistentHeapHashMap<const char*, Member<Data>, PtrHash<const char>>;
haraken 2017/04/05 02:08:10 Do we need PtrHash<const char>?
adithyas 2017/04/05 21:45:35 Guess we don't, DefaultHash makes pointer types us
147 DataMap m_dataMap;
142 }; 148 };
143 149
144 } // namespace blink 150 } // namespace blink
145 151
146 #endif // V8PerContextData_h 152 #endif // V8PerContextData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698