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

Unified Diff: extensions/renderer/api_type_reference_map.cc

Issue 2716883003: [Extensions Bindings] Store API type methods in the reference map (Closed)
Patch Set: . Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/renderer/api_type_reference_map.h ('k') | extensions/renderer/storage_area.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/api_type_reference_map.cc
diff --git a/extensions/renderer/api_type_reference_map.cc b/extensions/renderer/api_type_reference_map.cc
index d700e34bcbf8ba6b93636bab3e79e61de5f10dd3..328cf28099fe7f5aa985ebd6461cc8b54aaa73c9 100644
--- a/extensions/renderer/api_type_reference_map.cc
+++ b/extensions/renderer/api_type_reference_map.cc
@@ -4,6 +4,7 @@
#include "extensions/renderer/api_type_reference_map.h"
+#include "extensions/renderer/api_signature.h"
#include "extensions/renderer/argument_spec.h"
namespace extensions {
@@ -29,4 +30,27 @@ const ArgumentSpec* APITypeReferenceMap::GetSpec(
return iter == type_refs_.end() ? nullptr : iter->second.get();
}
+void APITypeReferenceMap::AddTypeMethodSignature(
+ const std::string& name,
+ std::unique_ptr<APISignature> signature) {
+ DCHECK(type_methods_.find(name) == type_methods_.end())
+ << "Cannot re-register signature for: " << name;
+ type_methods_[name] = std::move(signature);
+}
+
+const APISignature* APITypeReferenceMap::GetTypeMethodSignature(
+ const std::string& name) const {
+ auto iter = type_methods_.find(name);
+ if (iter == type_methods_.end()) {
+ // Find the type name by stripping away the method suffix.
+ std::string::size_type dot = name.rfind('.');
+ DCHECK_NE(std::string::npos, dot);
+ DCHECK_LT(dot, name.size() - 1);
+ std::string type_name = name.substr(0, dot);
+ initialize_type_.Run(type_name);
+ iter = type_methods_.find(name);
+ }
+ return iter == type_methods_.end() ? nullptr : iter->second.get();
+}
+
} // namespace extensions
« no previous file with comments | « extensions/renderer/api_type_reference_map.h ('k') | extensions/renderer/storage_area.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698