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

Unified Diff: third_party/WebKit/Source/core/dom/Modulator.cpp

Issue 2795593006: Abstract out Modulator from V8PerContextData (Closed)
Patch Set: Fix tests 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/Modulator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5d6d1f326de63a695deb02d5a2c670160942a186..8350bcc85d1a7793228ec9bedffe24be699d122b 100644
--- a/third_party/WebKit/Source/core/dom/Modulator.cpp
+++ b/third_party/WebKit/Source/core/dom/Modulator.cpp
@@ -9,16 +9,41 @@
namespace blink {
-Modulator* Modulator::from(LocalFrame* frame) {
+namespace {
+const char kPerContextDataKey[] = "Modulator";
+
+V8PerContextData* getPerContextData(LocalFrame* frame) {
ScriptState* scriptState = toScriptStateForMainWorld(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) {
+ 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,
« no previous file with comments | « third_party/WebKit/Source/core/dom/Modulator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698