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

Side by Side Diff: content/renderer/web_ui_mojo_context_state.cc

Issue 214183003: Change mojo JS bindings to expose a handle object, which is Closed when garbage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rm.extra.gc Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | gin/gin.gyp » ('j') | mojo/bindings/js/core.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/web_ui_mojo_context_state.h" 5 #include "content/renderer/web_ui_mojo_context_state.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "content/public/renderer/resource_fetcher.h" 9 #include "content/public/renderer/resource_fetcher.h"
10 #include "content/renderer/web_ui_runner.h" 10 #include "content/renderer/web_ui_runner.h"
11 #include "gin/converter.h" 11 #include "gin/converter.h"
12 #include "gin/modules/module_registry.h" 12 #include "gin/modules/module_registry.h"
13 #include "gin/per_context_data.h" 13 #include "gin/per_context_data.h"
14 #include "gin/public/context_holder.h" 14 #include "gin/public/context_holder.h"
15 #include "gin/try_catch.h" 15 #include "gin/try_catch.h"
16 #include "mojo/bindings/js/core.h" 16 #include "mojo/bindings/js/core.h"
17 #include "mojo/bindings/js/handle.h"
17 #include "mojo/bindings/js/support.h" 18 #include "mojo/bindings/js/support.h"
18 #include "third_party/WebKit/public/platform/WebURLResponse.h" 19 #include "third_party/WebKit/public/platform/WebURLResponse.h"
19 #include "third_party/WebKit/public/web/WebFrame.h" 20 #include "third_party/WebKit/public/web/WebFrame.h"
20 #include "third_party/WebKit/public/web/WebScriptSource.h" 21 #include "third_party/WebKit/public/web/WebScriptSource.h"
21 22
22 using v8::Context; 23 using v8::Context;
23 using v8::HandleScope; 24 using v8::HandleScope;
24 using v8::Isolate; 25 using v8::Isolate;
25 using v8::Object; 26 using v8::Object;
26 using v8::ObjectTemplate; 27 using v8::ObjectTemplate;
27 using v8::Script; 28 using v8::Script;
28 29
29 namespace content { 30 namespace content {
30 31
31 namespace { 32 namespace {
32 33
33 // All modules have this prefixed to them when downloading. 34 // All modules have this prefixed to them when downloading.
34 // TODO(sky): move this into some common place. 35 // TODO(sky): move this into some common place.
35 const char kModulePrefix[] = "chrome://mojo/"; 36 const char kModulePrefix[] = "chrome://mojo/";
36 37
37 void RunMain(base::WeakPtr<gin::Runner> runner, 38 void RunMain(base::WeakPtr<gin::Runner> runner,
38 mojo::ScopedMessagePipeHandle* handle, 39 mojo::ScopedMessagePipeHandle* handle,
39 v8::Handle<v8::Value> module) { 40 v8::Handle<v8::Value> module) {
40 v8::Isolate* isolate = runner->GetContextHolder()->isolate(); 41 v8::Isolate* isolate = runner->GetContextHolder()->isolate();
41 v8::Handle<v8::Function> start; 42 v8::Handle<v8::Function> start;
42 CHECK(gin::ConvertFromV8(isolate, module, &start)); 43 CHECK(gin::ConvertFromV8(isolate, module, &start));
43 v8::Handle<v8::Value> args[] = { 44 v8::Handle<v8::Value> args[] = {
44 gin::ConvertToV8(isolate, handle->release().value()) }; 45 gin::ConvertToV8(isolate, mojo::Handle(handle->release().value())) };
45 runner->Call(start, runner->global(), 1, args); 46 runner->Call(start, runner->global(), 1, args);
46 } 47 }
47 48
48 } // namespace 49 } // namespace
49 50
50 // WebUIMojo ------------------------------------------------------------------- 51 // WebUIMojo -------------------------------------------------------------------
51 52
52 WebUIMojoContextState::WebUIMojoContextState(blink::WebFrame* frame, 53 WebUIMojoContextState::WebUIMojoContextState(blink::WebFrame* frame,
53 v8::Handle<v8::Context> context) 54 v8::Handle<v8::Context> context)
54 : frame_(frame), 55 : frame_(frame),
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 const std::vector<std::string>& dependencies) { 133 const std::vector<std::string>& dependencies) {
133 FetchModules(dependencies); 134 FetchModules(dependencies);
134 135
135 gin::ContextHolder* context_holder = runner_->GetContextHolder(); 136 gin::ContextHolder* context_holder = runner_->GetContextHolder();
136 gin::ModuleRegistry* registry = gin::ModuleRegistry::From( 137 gin::ModuleRegistry* registry = gin::ModuleRegistry::From(
137 context_holder->context()); 138 context_holder->context());
138 registry->AttemptToLoadMoreModules(context_holder->isolate()); 139 registry->AttemptToLoadMoreModules(context_holder->isolate());
139 } 140 }
140 141
141 } // namespace content 142 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | gin/gin.gyp » ('j') | mojo/bindings/js/core.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698