Chromium Code Reviews| Index: third_party/WebKit/Source/core/dom/Modulator.cpp |
| diff --git a/third_party/WebKit/Source/core/dom/Modulator.cpp b/third_party/WebKit/Source/core/dom/Modulator.cpp |
| index c5a8aed9e1f46cc004a82536dfcb740228c8ef02..be9a44da5034e08abfa8d8e4d84565483b7a88d7 100644 |
| --- a/third_party/WebKit/Source/core/dom/Modulator.cpp |
| +++ b/third_party/WebKit/Source/core/dom/Modulator.cpp |
| @@ -8,16 +8,41 @@ |
| namespace blink { |
| -Modulator* Modulator::from(LocalFrame* frame) { |
| +namespace { |
| +const char* kPerContextDataKey = "Modulator"; |
|
dcheng
2017/04/05 21:13:29
Drive-by:
const char kPerContextDataKey[] = "Modul
adithyas
2017/04/05 21:45:36
Fixed, nice catch :)
|
| + |
| +V8PerContextData* getPerContextData(LocalFrame* frame) { |
|
haraken
2017/04/05 02:08:10
I'm not sure if it makes sense to let Modulator ta
kouhei (in TOK)
2017/04/05 02:09:05
Ah. This completely makes sense to me.
adithyas
2017/04/05 21:45:36
Yeah, ScriptState sounds appropriate, and it remov
|
| ScriptState* scriptState = ScriptState::forMainWorld(frame); |
| if (!scriptState) |
| return nullptr; |
| - // TODO(kouhei): setModulator in V8PerContextData when we land ModulatorImpl. |
| - return scriptState->perContextData()->modulator(); |
| + return scriptState->perContextData(); |
| +} |
| +} // namespace |
| + |
| +Modulator* Modulator::from(LocalFrame* frame) { |
| + return from(getPerContextData(frame)); |
| +} |
| + |
| +Modulator* Modulator::from(V8PerContextData* perContextData) { |
|
haraken
2017/04/05 02:08:10
Ditto. It would be nicer to pass in a ScriptState*
jbroman
2017/04/05 21:07:00
+1; ScriptState seems nicer here (and it's cheap t
|
| + if (!perContextData) |
| + return nullptr; |
| + return static_cast<Modulator*>(perContextData->getData(kPerContextDataKey)); |
| } |
| Modulator::~Modulator() {} |
| +void Modulator::setModulator(LocalFrame* frame, Modulator* modulator) { |
| + V8PerContextData* perContextData = getPerContextData(frame); |
| + DCHECK(perContextData); |
| + perContextData->addData(kPerContextDataKey, modulator); |
| +} |
| + |
| +void Modulator::clearModulator(LocalFrame* frame) { |
| + V8PerContextData* perContextData = getPerContextData(frame); |
| + DCHECK(perContextData); |
| + perContextData->clearData(kPerContextDataKey); |
| +} |
| + |
| KURL Modulator::resolveModuleSpecifier(const String& moduleRequest, |
| const KURL& baseURL) { |
| // Step 1. Apply the URL parser to specifier. If the result is not failure, |