Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 } | 143 } |
| 144 | 144 |
| 145 class V8WrapperInstantiationScope { | 145 class V8WrapperInstantiationScope { |
| 146 public: | 146 public: |
| 147 V8WrapperInstantiationScope(v8::Handle<v8::Object> creationContext, v8:: Isolate* isolate) | 147 V8WrapperInstantiationScope(v8::Handle<v8::Object> creationContext, v8:: Isolate* isolate) |
| 148 : m_didEnterContext(false) | 148 : m_didEnterContext(false) |
| 149 , m_context(isolate->GetCurrentContext()) | 149 , m_context(isolate->GetCurrentContext()) |
| 150 { | 150 { |
| 151 // FIXME: Remove all empty creationContexts from caller sites. | 151 // FIXME: Remove all empty creationContexts from caller sites. |
| 152 // If a creationContext is empty, we will end up creating a new obje ct | 152 // If a creationContext is empty, we will end up creating a new obje ct |
| 153 // in the context currently entered. This is wrong. | 153 // in the context currently entered. This is wrong. |
|
haraken
2014/06/09 06:47:03
Would you update this FIXME to clarify why we have
tasak
2014/06/12 02:08:07
Done.
| |
| 154 if (creationContext.IsEmpty()) | 154 RELEASE_ASSERT(!creationContext.IsEmpty()); |
| 155 return; | |
| 156 v8::Handle<v8::Context> contextForWrapper = creationContext->Creatio nContext(); | 155 v8::Handle<v8::Context> contextForWrapper = creationContext->Creatio nContext(); |
| 157 // For performance, we enter the context only if the currently runni ng context | 156 // For performance, we enter the context only if the currently runni ng context |
| 158 // is different from the context that we are about to enter. | 157 // is different from the context that we are about to enter. |
| 159 if (contextForWrapper == m_context) | 158 if (contextForWrapper == m_context) |
| 160 return; | 159 return; |
| 161 m_context = v8::Local<v8::Context>::New(isolate, contextForWrapper); | 160 m_context = v8::Local<v8::Context>::New(isolate, contextForWrapper); |
| 162 m_didEnterContext = true; | 161 m_didEnterContext = true; |
| 163 m_context->Enter(); | 162 m_context->Enter(); |
| 164 } | 163 } |
| 165 | 164 |
| 166 ~V8WrapperInstantiationScope() | 165 ~V8WrapperInstantiationScope() |
| 167 { | 166 { |
| 168 if (!m_didEnterContext) | 167 if (!m_didEnterContext) |
| 169 return; | 168 return; |
| 170 m_context->Exit(); | 169 m_context->Exit(); |
| 171 } | 170 } |
| 172 | 171 |
| 173 v8::Handle<v8::Context> context() const { return m_context; } | 172 v8::Handle<v8::Context> context() const { return m_context; } |
| 174 | 173 |
| 175 private: | 174 private: |
| 176 bool m_didEnterContext; | 175 bool m_didEnterContext; |
| 177 v8::Handle<v8::Context> m_context; | 176 v8::Handle<v8::Context> m_context; |
| 178 }; | 177 }; |
| 179 | 178 |
| 180 } | 179 } |
| 181 | 180 |
| 182 #endif // V8DOMWrapper_h | 181 #endif // V8DOMWrapper_h |
| OLD | NEW |