| 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 #ifndef EXTENSIONS_RENDERER_V8_SCHEMA_REGISTRY_H_ | 5 #ifndef EXTENSIONS_RENDERER_V8_SCHEMA_REGISTRY_H_ |
| 6 #define EXTENSIONS_RENDERER_V8_SCHEMA_REGISTRY_H_ | 6 #define EXTENSIONS_RENDERER_V8_SCHEMA_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "extensions/renderer/scoped_persistent.h" | 14 #include "gin/public/context_holder.h" |
| 15 #include "v8/include/v8-util.h" | 15 #include "v8/include/v8-util.h" |
| 16 #include "v8/include/v8.h" | 16 #include "v8/include/v8.h" |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 class NativeHandler; | 19 class NativeHandler; |
| 20 | 20 |
| 21 // A registry for the v8::Value representations of extension API schemas. | 21 // A registry for the v8::Value representations of extension API schemas. |
| 22 // In a way, the v8 counterpart to ExtensionAPI. | 22 // In a way, the v8 counterpart to ExtensionAPI. |
| 23 class V8SchemaRegistry { | 23 class V8SchemaRegistry { |
| 24 public: | 24 public: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 38 // Gets the separate context that backs the registry, creating a new one if | 38 // Gets the separate context that backs the registry, creating a new one if |
| 39 // if necessary. Will also initialize schema_cache_. | 39 // if necessary. Will also initialize schema_cache_. |
| 40 v8::Handle<v8::Context> GetOrCreateContext(v8::Isolate* isolate); | 40 v8::Handle<v8::Context> GetOrCreateContext(v8::Isolate* isolate); |
| 41 | 41 |
| 42 // Cache of schemas. Created lazily by GetOrCreateContext. | 42 // Cache of schemas. Created lazily by GetOrCreateContext. |
| 43 typedef v8::StdPersistentValueMap<std::string, v8::Object> SchemaCache; | 43 typedef v8::StdPersistentValueMap<std::string, v8::Object> SchemaCache; |
| 44 scoped_ptr<SchemaCache> schema_cache_; | 44 scoped_ptr<SchemaCache> schema_cache_; |
| 45 | 45 |
| 46 // Single per-instance v8::Context to create v8::Values. | 46 // Single per-instance v8::Context to create v8::Values. |
| 47 // Created lazily via GetOrCreateContext. | 47 // Created lazily via GetOrCreateContext. |
| 48 ScopedPersistent<v8::Context> context_; | 48 scoped_ptr<gin::ContextHolder> context_; |
| 49 | 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(V8SchemaRegistry); | 50 DISALLOW_COPY_AND_ASSIGN(V8SchemaRegistry); |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 } // namespace extensions | 53 } // namespace extensions |
| 54 | 54 |
| 55 #endif // EXTENSIONS_RENDERER_V8_SCHEMA_REGISTRY_H_ | 55 #endif // EXTENSIONS_RENDERER_V8_SCHEMA_REGISTRY_H_ |
| OLD | NEW |