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

Side by Side Diff: Source/bindings/core/v8/ScriptState.cpp

Issue 538933002: ScriptState::contextIsEmpty shouldn't return true for a context whose global object is detached (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/core/v8/ScriptState.h ('k') | Source/bindings/core/v8/ScriptValue.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "bindings/core/v8/ScriptState.h" 6 #include "bindings/core/v8/ScriptState.h"
7 7
8 #include "bindings/core/v8/V8Binding.h" 8 #include "bindings/core/v8/V8Binding.h"
9 #include "core/dom/ExecutionContext.h" 9 #include "core/dom/ExecutionContext.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 14 matching lines...) Expand all
25 data.GetValue()->SetAlignedPointerInEmbedderData(v8ContextPerContextDataInde x, 0); 25 data.GetValue()->SetAlignedPointerInEmbedderData(v8ContextPerContextDataInde x, 0);
26 data.GetParameter()->clearContext(); 26 data.GetParameter()->clearContext();
27 data.GetParameter()->deref(); 27 data.GetParameter()->deref();
28 } 28 }
29 29
30 ScriptState::ScriptState(v8::Handle<v8::Context> context, PassRefPtr<DOMWrapperW orld> world) 30 ScriptState::ScriptState(v8::Handle<v8::Context> context, PassRefPtr<DOMWrapperW orld> world)
31 : m_isolate(context->GetIsolate()) 31 : m_isolate(context->GetIsolate())
32 , m_context(m_isolate, context) 32 , m_context(m_isolate, context)
33 , m_world(world) 33 , m_world(world)
34 , m_perContextData(V8PerContextData::create(context)) 34 , m_perContextData(V8PerContextData::create(context))
35 , m_globalObjectDetached(false)
35 { 36 {
36 ASSERT(m_world); 37 ASSERT(m_world);
37 m_context.setWeak(this, &weakCallback); 38 m_context.setWeak(this, &weakCallback);
38 context->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, this) ; 39 context->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, this) ;
39 } 40 }
40 41
41 ScriptState::~ScriptState() 42 ScriptState::~ScriptState()
42 { 43 {
43 ASSERT(!m_perContextData); 44 ASSERT(!m_perContextData);
44 ASSERT(m_context.isEmpty()); 45 ASSERT(m_context.isEmpty());
45 } 46 }
46 47
48 void ScriptState::detachGlobalObject()
49 {
50 ASSERT(!m_context.isEmpty());
51 context()->DetachGlobal();
52 m_globalObjectDetached = true;
53 }
54
47 bool ScriptState::evalEnabled() const 55 bool ScriptState::evalEnabled() const
48 { 56 {
49 v8::HandleScope handleScope(m_isolate); 57 v8::HandleScope handleScope(m_isolate);
50 return context()->IsCodeGenerationFromStringsAllowed(); 58 return context()->IsCodeGenerationFromStringsAllowed();
51 } 59 }
52 60
53 void ScriptState::setEvalEnabled(bool enabled) 61 void ScriptState::setEvalEnabled(bool enabled)
54 { 62 {
55 v8::HandleScope handleScope(m_isolate); 63 v8::HandleScope handleScope(m_isolate);
56 return context()->AllowCodeGenerationFromStrings(enabled); 64 return context()->AllowCodeGenerationFromStrings(enabled);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 { 113 {
106 return m_executionContext; 114 return m_executionContext;
107 } 115 }
108 116
109 void ScriptStateForTesting::setExecutionContext(ExecutionContext* executionConte xt) 117 void ScriptStateForTesting::setExecutionContext(ExecutionContext* executionConte xt)
110 { 118 {
111 m_executionContext = executionContext; 119 m_executionContext = executionContext;
112 } 120 }
113 121
114 } 122 }
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/ScriptState.h ('k') | Source/bindings/core/v8/ScriptValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698