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

Unified Diff: content/shell/renderer/binding_helpers.h

Issue 478483005: Add IPC benchmarking API to Blink TestRunner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Landing Created 6 years, 4 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/shell/common/shell_switches.cc ('k') | content/shell/renderer/ipc_echo.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/renderer/binding_helpers.h
diff --git a/content/shell/renderer/binding_helpers.h b/content/shell/renderer/binding_helpers.h
new file mode 100644
index 0000000000000000000000000000000000000000..8f0a62335838682306007c6382b951924dedd45d
--- /dev/null
+++ b/content/shell/renderer/binding_helpers.h
@@ -0,0 +1,42 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_SHELL_BINDING_HELPERS_H_
+#define CONTENT_SHELL_BINDING_HELPERS_H_
+
+#include <string>
+#include <vector>
+
+#include "base/memory/scoped_ptr.h"
+#include "gin/handle.h"
+#include "gin/wrappable.h"
+#include "third_party/WebKit/public/web/WebFrame.h"
+#include "third_party/WebKit/public/web/WebKit.h"
+
+namespace content {
+
+template<class WrappedClass>
+void InstallAsWindowProperties(WrappedClass* wrapped,
+ blink::WebFrame* frame,
+ const std::vector<std::string>& names) {
+ v8::Isolate* isolate = blink::mainThreadIsolate();
+ v8::HandleScope handle_scope(isolate);
+ v8::Handle<v8::Context> context = frame->mainWorldScriptContext();
+ if (context.IsEmpty())
+ return;
+
+ v8::Context::Scope context_scope(context);
+
+ gin::Handle<WrappedClass> bindings = gin::CreateHandle(isolate, wrapped);
+ if (bindings.IsEmpty())
+ return;
+ v8::Handle<v8::Object> global = context->Global();
+ v8::Handle<v8::Value> v8_bindings = bindings.ToV8();
+ for (size_t i = 0; i < names.size(); ++i)
+ global->Set(gin::StringToV8(isolate, names[i].c_str()), v8_bindings);
+}
+
+} // namespace content
+
+#endif // CONTENT_SHELL_BINDING_HELPERS_DISPATCHER_H_
« no previous file with comments | « content/shell/common/shell_switches.cc ('k') | content/shell/renderer/ipc_echo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698