| 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 |
| 32 private: | 34 private: |
| 33 void GetSchema(const v8::FunctionCallbackInfo<v8::Value>& args) { | 35 void GetSchema(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 34 args.GetReturnValue().Set( | 36 args.GetReturnValue().Set( |
| 35 registry_->GetSchema(*v8::String::Utf8Value(args[0]))); | 37 registry_->GetSchema(*v8::String::Utf8Value(args[0]))); |
| 36 } | 38 } |
| 37 | 39 |
| 38 scoped_ptr<ScriptContext> context_; | 40 scoped_ptr<ScriptContext> context_; |
| 39 V8SchemaRegistry* registry_; | 41 V8SchemaRegistry* registry_; |
| 40 }; | 42 }; |
| 41 | 43 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 if (!context_holder_) { | 112 if (!context_holder_) { |
| 111 context_holder_.reset(new gin::ContextHolder(isolate)); | 113 context_holder_.reset(new gin::ContextHolder(isolate)); |
| 112 context_holder_->SetContext(v8::Context::New(isolate)); | 114 context_holder_->SetContext(v8::Context::New(isolate)); |
| 113 schema_cache_.reset(new SchemaCache(isolate)); | 115 schema_cache_.reset(new SchemaCache(isolate)); |
| 114 return context_holder_->context(); | 116 return context_holder_->context(); |
| 115 } | 117 } |
| 116 return context_holder_->context(); | 118 return context_holder_->context(); |
| 117 } | 119 } |
| 118 | 120 |
| 119 } // namespace extensions | 121 } // namespace extensions |
| OLD | NEW |