Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: chrome/renderer/extensions/v8_schema_registry.h

Issue 11571014: Lazy load chrome.* APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android compilation Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef CHROME_RENDERER_EXTENSIONS_V8_SCHEMA_REGISTRY_H_ 5 #ifndef CHROME_RENDERER_EXTENSIONS_V8_SCHEMA_REGISTRY_H_
6 #define CHROME_RENDERER_EXTENSIONS_V8_SCHEMA_REGISTRY_H_ 6 #define CHROME_RENDERER_EXTENSIONS_V8_SCHEMA_REGISTRY_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "chrome/renderer/extensions/scoped_persistent.h"
13 #include "v8/include/v8.h" 14 #include "v8/include/v8.h"
14 15
15 namespace extensions { 16 namespace extensions {
16 17
17 // A registry for the v8::Value representations of extension API schemas. 18 // A registry for the v8::Value representations of extension API schemas.
18 // In a way, the v8 counterpart to ExtensionAPI. 19 // In a way, the v8 counterpart to ExtensionAPI.
19 class V8SchemaRegistry { 20 class V8SchemaRegistry {
20 public: 21 public:
21 V8SchemaRegistry(); 22 V8SchemaRegistry();
22 ~V8SchemaRegistry(); 23 ~V8SchemaRegistry();
23 24
24 // Returns a v8::Array with all the schemas for the APIs in |apis|. 25 // Returns a v8::Array with all the schemas for the APIs in |apis|.
25 v8::Handle<v8::Array> GetSchemas(const std::set<std::string>& apis); 26 v8::Handle<v8::Array> GetSchemas(const std::set<std::string>& apis);
26 27
27 private:
28 // Returns a v8::Object for the schema for |api|, possibly from the cache. 28 // Returns a v8::Object for the schema for |api|, possibly from the cache.
29 v8::Handle<v8::Object> GetSchema(const std::string& api); 29 v8::Handle<v8::Object> GetSchema(const std::string& api);
30 30
31 private:
31 // Cache of schemas. 32 // Cache of schemas.
32 typedef std::map<std::string, v8::Persistent<v8::Object> > SchemaCache; 33 typedef std::map<std::string, v8::Persistent<v8::Object> > SchemaCache;
33 SchemaCache schema_cache_; 34 SchemaCache schema_cache_;
34 35
35 // Single per-instance v8::Context to create v8::Values. 36 // Single per-instance v8::Context to create v8::Values.
36 v8::Persistent<v8::Context> context_; 37 ScopedPersistent<v8::Context> context_;
37 38
38 DISALLOW_COPY_AND_ASSIGN(V8SchemaRegistry); 39 DISALLOW_COPY_AND_ASSIGN(V8SchemaRegistry);
39 }; 40 };
40 41
41 } // namespace extensions 42 } // namespace extensions
42 43
43 #endif // CHROME_RENDERER_EXTENSIONS_V8_SCHEMA_REGISTRY_H_ 44 #endif // CHROME_RENDERER_EXTENSIONS_V8_SCHEMA_REGISTRY_H_
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/tts_custom_bindings.cc ('k') | chrome/renderer/extensions/v8_schema_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698