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/child/v8_value_converter.h" | 9 #include "content/public/child/v8_value_converter.h" |
10 #include "extensions/common/extension_api.h" | 10 #include "extensions/common/extension_api.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 SchemaRegistryNativeHandler(V8SchemaRegistry* registry, | 22 SchemaRegistryNativeHandler(V8SchemaRegistry* registry, |
23 scoped_ptr<ScriptContext> context) | 23 scoped_ptr<ScriptContext> context) |
24 : ObjectBackedNativeHandler(context.get()), | 24 : ObjectBackedNativeHandler(context.get()), |
25 context_(context.Pass()), | 25 context_(context.Pass()), |
26 registry_(registry) { | 26 registry_(registry) { |
27 RouteFunction("GetSchema", | 27 RouteFunction("GetSchema", |
28 base::Bind(&SchemaRegistryNativeHandler::GetSchema, | 28 base::Bind(&SchemaRegistryNativeHandler::GetSchema, |
29 base::Unretained(this))); | 29 base::Unretained(this))); |
30 } | 30 } |
31 | 31 |
32 ~SchemaRegistryNativeHandler() override { context_->Invalidate(); } | |
33 | |
34 private: | 32 private: |
35 void GetSchema(const v8::FunctionCallbackInfo<v8::Value>& args) { | 33 void GetSchema(const v8::FunctionCallbackInfo<v8::Value>& args) { |
36 args.GetReturnValue().Set( | 34 args.GetReturnValue().Set( |
37 registry_->GetSchema(*v8::String::Utf8Value(args[0]))); | 35 registry_->GetSchema(*v8::String::Utf8Value(args[0]))); |
38 } | 36 } |
39 | 37 |
40 scoped_ptr<ScriptContext> context_; | 38 scoped_ptr<ScriptContext> context_; |
41 V8SchemaRegistry* registry_; | 39 V8SchemaRegistry* registry_; |
42 }; | 40 }; |
43 | 41 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 if (!context_holder_) { | 110 if (!context_holder_) { |
113 context_holder_.reset(new gin::ContextHolder(isolate)); | 111 context_holder_.reset(new gin::ContextHolder(isolate)); |
114 context_holder_->SetContext(v8::Context::New(isolate)); | 112 context_holder_->SetContext(v8::Context::New(isolate)); |
115 schema_cache_.reset(new SchemaCache(isolate)); | 113 schema_cache_.reset(new SchemaCache(isolate)); |
116 return context_holder_->context(); | 114 return context_holder_->context(); |
117 } | 115 } |
118 return context_holder_->context(); | 116 return context_holder_->context(); |
119 } | 117 } |
120 | 118 |
121 } // namespace extensions | 119 } // namespace extensions |
OLD | NEW |