OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // TODO(dcarney): Remove this when UnsafePersistent is removed. | 5 // TODO(dcarney): Remove this when UnsafePersistent is removed. |
6 #define V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | 6 #define V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR |
7 | 7 |
8 #include "chrome/renderer/extensions/v8_schema_registry.h" | 8 #include "chrome/renderer/extensions/v8_schema_registry.h" |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 v8::Local<v8::Object> to_return = | 101 v8::Local<v8::Object> to_return = |
102 v8::Local<v8::Object>::New(isolate, v8_schema); | 102 v8::Local<v8::Object>::New(isolate, v8_schema); |
103 schema_cache_[api] = UnsafePersistent<v8::Object>(&v8_schema); | 103 schema_cache_[api] = UnsafePersistent<v8::Object>(&v8_schema); |
104 return handle_scope.Close(to_return); | 104 return handle_scope.Close(to_return); |
105 } | 105 } |
106 | 106 |
107 v8::Handle<v8::Context> V8SchemaRegistry::GetOrCreateContext( | 107 v8::Handle<v8::Context> V8SchemaRegistry::GetOrCreateContext( |
108 v8::Isolate* isolate) { | 108 v8::Isolate* isolate) { |
109 // It's ok to create local handles in this function, since this is only called | 109 // It's ok to create local handles in this function, since this is only called |
110 // when we have a HandleScope. | 110 // when we have a HandleScope. |
111 if (context_.get().IsEmpty()) { | 111 if (context_.IsEmpty()) { |
112 v8::Handle<v8::Context> context = v8::Context::New(isolate); | 112 v8::Handle<v8::Context> context = v8::Context::New(isolate); |
113 context_.reset(context); | 113 context_.reset(context); |
114 return context; | 114 return context; |
115 } | 115 } |
116 return v8::Local<v8::Context>::New(isolate, context_.get()); | 116 return context_.NewHandle(isolate); |
117 } | 117 } |
118 | 118 |
119 } // namespace extensions | 119 } // namespace extensions |
OLD | NEW |