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

Side by Side Diff: content/shell/renderer/ipc_echo.cc

Issue 1141993002: Inline binding_helpers.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/shell/renderer/ipc_echo.h" 5 #include "content/shell/renderer/ipc_echo.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
8 #include "content/shell/common/shell_messages.h" 9 #include "content/shell/common/shell_messages.h"
9 #include "content/shell/renderer/binding_helpers.h" 10 #include "gin/handle.h"
10 #include "gin/object_template_builder.h" 11 #include "gin/object_template_builder.h"
11 #include "gin/wrappable.h" 12 #include "gin/wrappable.h"
12 #include "ipc/ipc_sender.h" 13 #include "ipc/ipc_sender.h"
13 #include "third_party/WebKit/public/web/WebDOMCustomEvent.h" 14 #include "third_party/WebKit/public/web/WebDOMCustomEvent.h"
14 #include "third_party/WebKit/public/web/WebDOMEvent.h" 15 #include "third_party/WebKit/public/web/WebDOMEvent.h"
16 #include "third_party/WebKit/public/web/WebFrame.h"
17 #include "third_party/WebKit/public/web/WebKit.h"
15 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" 18 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h"
16 19
17 namespace content { 20 namespace content {
18 21
19 class IPCEchoBindings : public gin::Wrappable<IPCEchoBindings> { 22 class IPCEchoBindings : public gin::Wrappable<IPCEchoBindings> {
20 public: 23 public:
21 static gin::WrapperInfo kWrapperInfo; 24 static gin::WrapperInfo kWrapperInfo;
22 static void Install(base::WeakPtr<IPCEcho> echo, blink::WebFrame* frame); 25 static void Install(base::WeakPtr<IPCEcho> echo, blink::WebFrame* frame);
23 26
24 explicit IPCEchoBindings(base::WeakPtr<IPCEcho>); 27 explicit IPCEchoBindings(base::WeakPtr<IPCEcho>);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 &IPCEchoBindings::RequestEcho) 68 &IPCEchoBindings::RequestEcho)
66 .SetProperty("lastEchoId", 69 .SetProperty("lastEchoId",
67 &IPCEchoBindings::GetLastEchoId) 70 &IPCEchoBindings::GetLastEchoId)
68 .SetProperty("lastEchoSize", 71 .SetProperty("lastEchoSize",
69 &IPCEchoBindings::GetLastEchoSize); 72 &IPCEchoBindings::GetLastEchoSize);
70 } 73 }
71 74
72 // static 75 // static
73 void IPCEchoBindings::Install(base::WeakPtr<IPCEcho> echo, 76 void IPCEchoBindings::Install(base::WeakPtr<IPCEcho> echo,
74 blink::WebFrame* frame) { 77 blink::WebFrame* frame) {
75 std::vector<std::string> names; 78 v8::Isolate* isolate = blink::mainThreadIsolate();
76 names.push_back("ipcEcho"); 79 v8::HandleScope handle_scope(isolate);
77 return InstallAsWindowProperties( 80 v8::Local<v8::Context> context = frame->mainWorldScriptContext();
78 new IPCEchoBindings(echo), frame, names); 81 if (context.IsEmpty())
82 return;
83
84 v8::Context::Scope context_scope(context);
85
86 IPCEchoBindings* wrapped = new IPCEchoBindings(echo);
87 gin::Handle<IPCEchoBindings> bindings = gin::CreateHandle(isolate, wrapped);
88 if (bindings.IsEmpty())
89 return;
90 v8::Local<v8::Object> global = context->Global();
91 v8::Local<v8::Value> v8_bindings = bindings.ToV8();
92 global->Set(gin::StringToV8(isolate, "ipcEcho"), v8_bindings);
79 } 93 }
80 94
81 IPCEcho::IPCEcho(blink::WebDocument document, 95 IPCEcho::IPCEcho(blink::WebDocument document,
82 IPC::Sender* sender, 96 IPC::Sender* sender,
83 int routing_id) 97 int routing_id)
84 : document_(document), sender_(sender), routing_id_(routing_id), 98 : document_(document), sender_(sender), routing_id_(routing_id),
85 last_echo_id_(0), 99 last_echo_id_(0),
86 weak_factory_(this) { 100 weak_factory_(this) {
87 } 101 }
88 102
(...skipping 14 matching lines...) Expand all
103 event.to<blink::WebDOMCustomEvent>().initCustomEvent( 117 event.to<blink::WebDOMCustomEvent>().initCustomEvent(
104 eventType, false, false, blink::WebSerializedScriptValue()); 118 eventType, false, false, blink::WebSerializedScriptValue());
105 document_.dispatchEvent(event); 119 document_.dispatchEvent(event);
106 } 120 }
107 121
108 void IPCEcho::Install(blink::WebFrame* frame) { 122 void IPCEcho::Install(blink::WebFrame* frame) {
109 IPCEchoBindings::Install(weak_factory_.GetWeakPtr(), frame); 123 IPCEchoBindings::Install(weak_factory_.GetWeakPtr(), frame);
110 } 124 }
111 125
112 } // namespace content 126 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/binding_helpers.h ('k') | content/shell/renderer/test_runner/test_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698