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

Side by Side Diff: third_party/WebKit/Source/core/dom/Modulator.cpp

Issue 2826803004: [ES6 modules] Introduce ModulatorImpl (Closed)
Patch Set: no double private 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 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/Modulator.h" 5 #include "core/dom/Modulator.h"
6 6
7 #include "bindings/core/v8/ScriptState.h" 7 #include "bindings/core/v8/ScriptState.h"
8 #include "bindings/core/v8/V8Binding.h" 8 #include "bindings/core/v8/V8Binding.h"
9 #include "bindings/core/v8/V8PerContextData.h"
10 #include "core/dom/Document.h"
11 #include "core/dom/ModulatorImpl.h"
12 #include "core/frame/LocalFrame.h"
9 13
10 namespace blink { 14 namespace blink {
11 15
12 namespace { 16 namespace {
13 const char kPerContextDataKey[] = "Modulator"; 17 const char kPerContextDataKey[] = "Modulator";
14 } // namespace 18 } // namespace
15 19
16 Modulator* Modulator::From(ScriptState* script_state) { 20 Modulator* Modulator::From(ScriptState* script_state) {
17 if (!script_state) 21 if (!script_state)
18 return nullptr; 22 return nullptr;
23
19 V8PerContextData* per_context_data = script_state->PerContextData(); 24 V8PerContextData* per_context_data = script_state->PerContextData();
20 if (!per_context_data) 25 if (!per_context_data)
21 return nullptr; 26 return nullptr;
22 return static_cast<Modulator*>(per_context_data->GetData(kPerContextDataKey)); 27
28 Modulator* modulator =
29 static_cast<Modulator*>(per_context_data->GetData(kPerContextDataKey));
30 if (!modulator) {
31 if (Document* document = ToDocument(ExecutionContext::From(script_state))) {
32 modulator = ModulatorImpl::Create(script_state, *document);
33 Modulator::SetModulator(script_state, modulator);
34 }
35 }
36 return modulator;
23 } 37 }
24 38
25 Modulator::~Modulator() {} 39 Modulator::~Modulator() {}
26 40
27 void Modulator::SetModulator(ScriptState* script_state, Modulator* modulator) { 41 void Modulator::SetModulator(ScriptState* script_state, Modulator* modulator) {
28 DCHECK(script_state); 42 DCHECK(script_state);
29 V8PerContextData* per_context_data = script_state->PerContextData(); 43 V8PerContextData* per_context_data = script_state->PerContextData();
30 DCHECK(per_context_data); 44 DCHECK(per_context_data);
31 per_context_data->AddData(kPerContextDataKey, modulator); 45 per_context_data->AddData(kPerContextDataKey, modulator);
32 } 46 }
(...skipping 25 matching lines...) Expand all
58 // script's base URL as the base URL. 72 // script's base URL as the base URL.
59 DCHECK(base_url.IsValid()); 73 DCHECK(base_url.IsValid());
60 KURL absolute_url(base_url, module_request); 74 KURL absolute_url(base_url, module_request);
61 if (absolute_url.IsValid()) 75 if (absolute_url.IsValid())
62 return absolute_url; 76 return absolute_url;
63 77
64 return KURL(); 78 return KURL();
65 } 79 }
66 80
67 } // namespace blink 81 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/BUILD.gn ('k') | third_party/WebKit/Source/core/dom/ModulatorImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698