Chromium Code Reviews| Index: chrome/renderer/extensions/schema_generated_bindings.cc |
| diff --git a/chrome/renderer/extensions/schema_generated_bindings.cc b/chrome/renderer/extensions/schema_generated_bindings.cc |
| index eda15d85c1bbbdc75c36801654dc534e67afcf29..6f6bb33f64103ab4e56449f59a63b9292c707bfb 100644 |
| --- a/chrome/renderer/extensions/schema_generated_bindings.cc |
| +++ b/chrome/renderer/extensions/schema_generated_bindings.cc |
| @@ -118,30 +118,32 @@ class ExtensionImpl : public ChromeV8Extension { |
| ChromeV8Context* v8_context = dispatcher->v8_context_set().GetCurrent(); |
| CHECK(v8_context); |
| - std::string extension_id = v8_context->extension_id(); |
| - ExtensionAPI::SchemaMap schemas; |
| - ExtensionAPI::GetSchemasFilter filter = |
| - dispatcher->is_extension_process() ? |
| - ExtensionAPI::ALL : ExtensionAPI::ONLY_UNPRIVILEGED; |
| + // TODO(kalman): can we just cache this in the ChromeV8Context instance? |
|
not at google - send to devlin
2012/03/20 03:32:13
I deleted this TODO because it *was* no longer rel
koz (OOO until 15th September)
2012/03/20 04:43:05
I can't think of any particularly good reason not
not at google - send to devlin
2012/03/20 07:02:05
Bahhhhhhhhhhhhhhhhhhh turns out this is hard becau
koz (OOO until 15th September)
2012/03/20 23:04:18
Surely!
|
| + scoped_ptr<std::set<std::string> > apis; |
| + const std::string& extension_id = v8_context->extension_id(); |
| if (dispatcher->IsTestExtensionId(extension_id)) { |
| - ExtensionAPI::GetInstance()->GetDefaultSchemas(filter, &schemas); |
| + apis.reset(new std::set<std::string>()); |
| + // The minimal set of APIs that tests need. |
| + apis->insert("extension"); |
| } else { |
| - const ::Extension* extension = |
| - dispatcher->extensions()->GetByID(extension_id); |
| - CHECK(extension) << extension_id << " not found"; |
| - ExtensionAPI::GetInstance()->GetSchemasForExtension( |
| - *extension, filter, &schemas); |
| + apis = ExtensionAPI::GetInstance()->GetAPIsForContext( |
| + v8_context->context_type(), |
| + dispatcher->extensions()->GetByID(extension_id), |
| + UserScriptSlave::GetDataSourceURLForFrame(v8_context->web_frame())); |
| } |
| v8::Persistent<v8::Context> context(v8::Context::New()); |
| v8::Context::Scope context_scope(context); |
| - v8::Handle<v8::Array> api(v8::Array::New(schemas.size())); |
| + v8::Handle<v8::Array> api(v8::Array::New(apis->size())); |
| size_t api_index = 0; |
| - for (ExtensionAPI::SchemaMap::iterator it = schemas.begin(); |
| - it != schemas.end(); ++it) { |
| - std::string api_name = it->first; |
| - api->Set(api_index, GetV8SchemaForAPI(self, context, api_name)); |
| + for (std::set<std::string>::iterator i = apis->begin(); i != apis->end(); |
| + ++i) { |
| + // TODO(kalman): this caching is actually useless now, because |
|
koz (OOO until 15th September)
2012/03/20 04:43:05
"this caching" -> "the caching in GetV8SchemaForAP
not at google - send to devlin
2012/03/20 07:02:05
I've actually fixed this in a follow-up http://cod
|
| + // SchemaGeneratedBindings is per-context not per-process. We should |
| + // (e.g.) hang a SchemaRegistry off ExtensionDispatcher (which maintains |
| + // a *single* v8::Context rather than multiple ones as here). |
| + api->Set(api_index, GetV8SchemaForAPI(self, context, *i)); |
| ++api_index; |
| } |
| @@ -323,6 +325,7 @@ class ExtensionImpl : public ChromeV8Extension { |
| namespace extensions { |
| +// static |
| ChromeV8Extension* SchemaGeneratedBindings::Get( |
| ExtensionDispatcher* extension_dispatcher) { |
| return new ExtensionImpl(extension_dispatcher); |