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

Side by Side Diff: chrome/common/extensions/api/extension_api.cc

Issue 11571014: Lazy load chrome.* APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 #include "chrome/common/extensions/api/extension_api.h" 5 #include "chrome/common/extensions/api/extension_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 std::string feature_type; 686 std::string feature_type;
687 std::string feature_name; 687 std::string feature_name;
688 SplitDependencyName(*iter, &feature_type, &feature_name); 688 SplitDependencyName(*iter, &feature_type, &feature_name);
689 if (feature_type == "api") 689 if (feature_type == "api")
690 result->insert(feature_name); 690 result->insert(feature_name);
691 } 691 }
692 692
693 return result.Pass(); 693 return result.Pass();
694 } 694 }
695 695
696 scoped_ptr<std::set<std::string> > ExtensionAPI::GetAllAPINames() {
697 // Don't do this. Instead reference the unloaded schemas and load as needed.
not at google - send to devlin 2012/12/13 22:26:40 Yup. Loading all the schemas somewhat defeats load
698 LoadAllSchemas();
699 scoped_ptr<std::set<std::string> > result(new std::set<std::string>());
700 for (SchemaMap::iterator i = schemas_.begin(); i != schemas_.end(); ++i)
701 result->insert(i->first);
702 return result.Pass();
703 }
704
696 Feature* ExtensionAPI::GetFeature(const std::string& full_name) { 705 Feature* ExtensionAPI::GetFeature(const std::string& full_name) {
697 // Ensure it's loaded. 706 // Ensure it's loaded.
698 GetSchema(full_name); 707 GetSchema(full_name);
699 708
700 std::string child_name; 709 std::string child_name;
701 std::string api_namespace = GetAPINameFromFullName(full_name, &child_name); 710 std::string api_namespace = GetAPINameFromFullName(full_name, &child_name);
702 711
703 APIFeatureMap::iterator feature_map = features_.find(api_namespace); 712 APIFeatureMap::iterator feature_map = features_.find(api_namespace);
704 if (feature_map == features_.end()) 713 if (feature_map == features_.end())
705 return NULL; 714 return NULL;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 865
857 void ExtensionAPI::LoadAllSchemas() { 866 void ExtensionAPI::LoadAllSchemas() {
858 while (unloaded_schemas_.size()) { 867 while (unloaded_schemas_.size()) {
859 std::map<std::string, base::StringPiece>::iterator it = 868 std::map<std::string, base::StringPiece>::iterator it =
860 unloaded_schemas_.begin(); 869 unloaded_schemas_.begin();
861 LoadSchema(it->first, it->second); 870 LoadSchema(it->first, it->second);
862 } 871 }
863 } 872 }
864 873
865 } // namespace extensions 874 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698