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

Unified Diff: extensions/renderer/api_binding.cc

Issue 2438623002: [Extensions Bindings] Add APIBindingsSystem (Closed)
Patch Set: rebase Created 4 years, 2 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
Index: extensions/renderer/api_binding.cc
diff --git a/extensions/renderer/api_binding.cc b/extensions/renderer/api_binding.cc
index 6459365510484864dd4a7974a61f843c5aca51ed..c22bea83f84a580edbc99d1ac8efc54d45e8e8ad 100644
--- a/extensions/renderer/api_binding.cc
+++ b/extensions/renderer/api_binding.cc
@@ -160,12 +160,15 @@ void CallbackHelper(const v8::FunctionCallbackInfo<v8::Value>& info) {
APIBinding::APIPerContextData::APIPerContextData() {}
APIBinding::APIPerContextData::~APIPerContextData() {}
-APIBinding::APIBinding(const std::string& name,
+APIBinding::APIBinding(const std::string& api_name,
const base::ListValue& function_definitions,
const base::ListValue& type_definitions,
const APIMethodCallback& callback,
ArgumentSpec::RefMap* type_refs)
- : method_callback_(callback), type_refs_(type_refs), weak_factory_(this) {
+ : api_name_(api_name),
+ method_callback_(callback),
+ type_refs_(type_refs),
+ weak_factory_(this) {
DCHECK(!method_callback_.is_null());
for (const auto& func : function_definitions) {
const base::DictionaryValue* func_dict = nullptr;
@@ -206,9 +209,11 @@ v8::Local<v8::Object> APIBinding::CreateInstance(v8::Local<v8::Context> context,
api_data.release());
}
for (const auto& sig : signatures_) {
+ std::string full_method_name =
+ base::StringPrintf("%s.%s", api_name_.c_str(), sig.first.c_str());
auto handler_callback = base::MakeUnique<HandlerCallback>(
base::Bind(&APIBinding::HandleCall, weak_factory_.GetWeakPtr(),
- sig.first, sig.second.get()));
+ full_method_name, sig.second.get()));
// TODO(devlin): We should be able to cache these in a function template.
v8::MaybeLocal<v8::Function> maybe_function =
v8::Function::New(context, &CallbackHelper,

Powered by Google App Engine
This is Rietveld 408576698