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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp

Issue 2458183002: Eagerly install Origin Trial features on window (Closed)
Patch Set: Clean up Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "bindings/core/v8/ConditionalFeatures.h" 5 #include "bindings/core/v8/ConditionalFeatures.h"
6 6
7 #include "bindings/core/v8/ScriptState.h" 7 #include "bindings/core/v8/ScriptState.h"
8 #include "bindings/core/v8/V8HTMLLinkElement.h" 8 #include "bindings/core/v8/V8HTMLLinkElement.h"
9 #include "bindings/core/v8/V8Navigator.h" 9 #include "bindings/core/v8/V8Navigator.h"
10 #include "bindings/core/v8/V8Window.h" 10 #include "bindings/core/v8/V8Window.h"
(...skipping 12 matching lines...) Expand all
23 ExecutionContext* executionContext = scriptState->getExecutionContext(); 23 ExecutionContext* executionContext = scriptState->getExecutionContext();
24 if (!executionContext) 24 if (!executionContext)
25 return; 25 return;
26 OriginTrialContext* originTrialContext = OriginTrialContext::from( 26 OriginTrialContext* originTrialContext = OriginTrialContext::from(
27 executionContext, OriginTrialContext::DontCreateIfNotExists); 27 executionContext, OriginTrialContext::DontCreateIfNotExists);
28 if (wrapperTypeInfo == &V8HTMLLinkElement::wrapperTypeInfo) { 28 if (wrapperTypeInfo == &V8HTMLLinkElement::wrapperTypeInfo) {
29 if (RuntimeEnabledFeatures::linkServiceWorkerEnabled() || 29 if (RuntimeEnabledFeatures::linkServiceWorkerEnabled() ||
30 (originTrialContext && 30 (originTrialContext &&
31 originTrialContext->isTrialEnabled("ForeignFetch"))) { 31 originTrialContext->isTrialEnabled("ForeignFetch"))) {
32 V8HTMLLinkElement::installLinkServiceWorker( 32 V8HTMLLinkElement::installLinkServiceWorker(
33 scriptState->isolate(), scriptState->world(), v8::Local<v8::Object>(), 33 scriptState, v8::Local<v8::Object>(), prototypeObject,
34 prototypeObject, interfaceObject); 34 interfaceObject);
35 } 35 }
36 } 36 }
37 } 37 }
38 38
39 namespace { 39 namespace {
40 40
41 InstallConditionalFeaturesFunction s_installConditionalFeaturesFunction = 41 InstallConditionalFeaturesFunction s_installConditionalFeaturesFunction =
42 &installConditionalFeaturesCore; 42 &installConditionalFeaturesCore;
43 } 43 }
44 44
45 InstallConditionalFeaturesFunction setInstallConditionalFeaturesFunction( 45 InstallConditionalFeaturesFunction setInstallConditionalFeaturesFunction(
46 InstallConditionalFeaturesFunction newInstallConditionalFeaturesFunction) { 46 InstallConditionalFeaturesFunction newInstallConditionalFeaturesFunction) {
47 InstallConditionalFeaturesFunction originalFunction = 47 InstallConditionalFeaturesFunction originalFunction =
48 s_installConditionalFeaturesFunction; 48 s_installConditionalFeaturesFunction;
49 s_installConditionalFeaturesFunction = newInstallConditionalFeaturesFunction; 49 s_installConditionalFeaturesFunction = newInstallConditionalFeaturesFunction;
50 return originalFunction; 50 return originalFunction;
51 } 51 }
52 52
53 void installConditionalFeatures(const WrapperTypeInfo* type, 53 void installConditionalFeatures(const WrapperTypeInfo* type,
54 const ScriptState* scriptState, 54 const ScriptState* scriptState,
55 v8::Local<v8::Object> prototypeObject, 55 v8::Local<v8::Object> prototypeObject,
56 v8::Local<v8::Function> interfaceObject) { 56 v8::Local<v8::Function> interfaceObject) {
57 (*s_installConditionalFeaturesFunction)(type, scriptState, prototypeObject, 57 (*s_installConditionalFeaturesFunction)(type, scriptState, prototypeObject,
58 interfaceObject); 58 interfaceObject);
59 } 59 }
60 60
61 void installPendingConditionalFeaturesOnWindow(const ScriptState* scriptState) {
Yuki 2016/11/01 11:37:54 You might want to CHECK: scriptState->context(
iclelland 2016/11/01 17:06:27 In what cases is this not going to be true? I thin
iclelland 2016/11/02 13:49:37 I've added this, now that it's entering a context
62 if (!scriptState)
63 return;
64 if (!scriptState->perContextData())
haraken 2016/11/01 06:42:41 Can this be DCHECK(m_scriptState) and DCHECK(scrip
iclelland 2016/11/01 17:06:27 Yes, done, thanks.
65 return;
66 (*s_installConditionalFeaturesFunction)(&V8Window::wrapperTypeInfo,
67 scriptState, v8::Local<v8::Object>(),
68 v8::Local<v8::Function>());
haraken 2016/11/01 06:42:41 Why is it okay to pass in empty prototype and inte
iclelland 2016/11/01 17:06:27 The only thing that we use Origin Trials for on Wi
69 }
70
61 } // namespace blink 71 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698