OLD | NEW |
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 "extensions/renderer/v8_schema_registry.h" | 5 #include "extensions/renderer/v8_schema_registry.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "content/public/renderer/v8_value_converter.h" | 9 #include "content/public/renderer/v8_value_converter.h" |
10 #include "extensions/common/extension_api.h" | 10 #include "extensions/common/extension_api.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 v8::Local<v8::Object> v8_schema(v8::Handle<v8::Object>::Cast(value)); | 98 v8::Local<v8::Object> v8_schema(v8::Handle<v8::Object>::Cast(value)); |
99 schema_cache_->Set(api, v8_schema); | 99 schema_cache_->Set(api, v8_schema); |
100 | 100 |
101 return handle_scope.Escape(v8_schema); | 101 return handle_scope.Escape(v8_schema); |
102 } | 102 } |
103 | 103 |
104 v8::Handle<v8::Context> V8SchemaRegistry::GetOrCreateContext( | 104 v8::Handle<v8::Context> V8SchemaRegistry::GetOrCreateContext( |
105 v8::Isolate* isolate) { | 105 v8::Isolate* isolate) { |
106 // It's ok to create local handles in this function, since this is only called | 106 // It's ok to create local handles in this function, since this is only called |
107 // when we have a HandleScope. | 107 // when we have a HandleScope. |
108 if (context_.IsEmpty()) { | 108 if (!context_holder_) { |
109 v8::Handle<v8::Context> context = v8::Context::New(isolate); | 109 context_holder_.reset(new gin::ContextHolder(isolate)); |
110 context_.reset(context); | 110 context_holder_->SetContext(v8::Context::New(isolate)); |
111 schema_cache_.reset(new SchemaCache(isolate)); | 111 schema_cache_.reset(new SchemaCache(isolate)); |
112 return context; | 112 return context_holder_->context(); |
113 } | 113 } |
114 return context_.NewHandle(isolate); | 114 return context_holder_->context(); |
115 } | 115 } |
116 | 116 |
117 } // namespace extensions | 117 } // namespace extensions |
OLD | NEW |