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

Unified Diff: extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc

Issue 974183005: Cache locally function templates returned by gin::CreateFunctionTemplate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | « content/renderer/pepper/message_channel.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc
diff --git a/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc b/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc
index b50d5ad43ec9d98fa11b16fe40b85faf41d6471c..3c3ea931ea782bde0acc213d09b54a2d00d9aa51 100644
--- a/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc
+++ b/extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc
@@ -50,9 +50,15 @@ class ScriptableObject : public gin::Wrappable<ScriptableObject>,
v8::Isolate* isolate,
const std::string& identifier) override {
if (identifier == kPostMessageName) {
- return gin::CreateFunctionTemplate(isolate,
- base::Bind(&MimeHandlerViewContainer::PostMessage,
- container_, isolate))->GetFunction();
+ if (post_message_function_template_.IsEmpty()) {
+ post_message_function_template_.Reset(
+ isolate,
+ gin::CreateFunctionTemplate(
+ isolate, base::Bind(&MimeHandlerViewContainer::PostMessage,
+ container_, isolate)));
+ }
+ return v8::Local<v8::FunctionTemplate>::New(
+ isolate, post_message_function_template_)->GetFunction();
}
return v8::Local<v8::Value>();
}
@@ -71,6 +77,7 @@ class ScriptableObject : public gin::Wrappable<ScriptableObject>,
}
base::WeakPtr<MimeHandlerViewContainer> container_;
+ v8::Persistent<v8::FunctionTemplate> post_message_function_template_;
};
// static
« no previous file with comments | « content/renderer/pepper/message_channel.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698