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

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

Issue 208263008: Revert 258763 "Adds plumbing to pass WebUI mojo::Handle from bro..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 9 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
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"
(...skipping 17 matching lines...) Expand all
28 28
29 namespace content { 29 namespace content {
30 30
31 namespace { 31 namespace {
32 32
33 // All modules have this prefixed to them when downloading. 33 // All modules have this prefixed to them when downloading.
34 // TODO(sky): move this into some common place. 34 // TODO(sky): move this into some common place.
35 const char kModulePrefix[] = "chrome://mojo/"; 35 const char kModulePrefix[] = "chrome://mojo/";
36 36
37 void RunMain(base::WeakPtr<gin::Runner> runner, 37 void RunMain(base::WeakPtr<gin::Runner> runner,
38 mojo::ScopedMessagePipeHandle* handle, 38 mojo::ScopedHandle* handle,
39 v8::Handle<v8::Value> module) { 39 v8::Handle<v8::Value> module) {
40 v8::Isolate* isolate = runner->GetContextHolder()->isolate(); 40 v8::Isolate* isolate = runner->GetContextHolder()->isolate();
41 v8::Handle<v8::Function> start; 41 v8::Handle<v8::Function> start;
42 CHECK(gin::ConvertFromV8(isolate, module, &start)); 42 CHECK(gin::ConvertFromV8(isolate, module, &start));
43 v8::Handle<v8::Value> args[] = { 43 v8::Handle<v8::Value> args[] = {
44 gin::ConvertToV8(isolate, handle->release().value()) }; 44 gin::ConvertToV8(isolate, handle->release().value()) };
45 runner->Call(start, runner->global(), 1, args); 45 runner->Call(start, runner->global(), 1, args);
46 } 46 }
47 47
48 } // namespace 48 } // namespace
(...skipping 14 matching lines...) Expand all
63 // Warning |frame| may be destroyed. 63 // Warning |frame| may be destroyed.
64 // TODO(sky): add test for this. 64 // TODO(sky): add test for this.
65 } 65 }
66 66
67 WebUIMojoContextState::~WebUIMojoContextState() { 67 WebUIMojoContextState::~WebUIMojoContextState() {
68 gin::Runner::Scope scoper(runner_.get()); 68 gin::Runner::Scope scoper(runner_.get());
69 gin::ModuleRegistry::From( 69 gin::ModuleRegistry::From(
70 runner_->GetContextHolder()->context())->RemoveObserver(this); 70 runner_->GetContextHolder()->context())->RemoveObserver(this);
71 } 71 }
72 72
73 void WebUIMojoContextState::SetHandle(mojo::ScopedMessagePipeHandle handle) { 73 void WebUIMojoContextState::SetHandle(mojo::ScopedHandle handle) {
74 gin::ContextHolder* context_holder = runner_->GetContextHolder(); 74 gin::ContextHolder* context_holder = runner_->GetContextHolder();
75 mojo::ScopedMessagePipeHandle* passed_handle = 75 mojo::ScopedHandle* passed_handle = new mojo::ScopedHandle(handle.Pass());
76 new mojo::ScopedMessagePipeHandle(handle.Pass());
77 gin::ModuleRegistry::From(context_holder->context())->LoadModule( 76 gin::ModuleRegistry::From(context_holder->context())->LoadModule(
78 context_holder->isolate(), 77 context_holder->isolate(),
79 "main", 78 "main",
80 base::Bind(RunMain, runner_->GetWeakPtr(), base::Owned(passed_handle))); 79 base::Bind(RunMain, runner_->GetWeakPtr(), base::Owned(passed_handle)));
81 } 80 }
82 81
83 void WebUIMojoContextState::FetchModules(const std::vector<std::string>& ids) { 82 void WebUIMojoContextState::FetchModules(const std::vector<std::string>& ids) {
84 gin::Runner::Scope scoper(runner_.get()); 83 gin::Runner::Scope scoper(runner_.get());
85 gin::ContextHolder* context_holder = runner_->GetContextHolder(); 84 gin::ContextHolder* context_holder = runner_->GetContextHolder();
86 gin::ModuleRegistry* registry = gin::ModuleRegistry::From( 85 gin::ModuleRegistry* registry = gin::ModuleRegistry::From(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 const std::vector<std::string>& dependencies) { 131 const std::vector<std::string>& dependencies) {
133 FetchModules(dependencies); 132 FetchModules(dependencies);
134 133
135 gin::ContextHolder* context_holder = runner_->GetContextHolder(); 134 gin::ContextHolder* context_holder = runner_->GetContextHolder();
136 gin::ModuleRegistry* registry = gin::ModuleRegistry::From( 135 gin::ModuleRegistry* registry = gin::ModuleRegistry::From(
137 context_holder->context()); 136 context_holder->context());
138 registry->AttemptToLoadMoreModules(context_holder->isolate()); 137 registry->AttemptToLoadMoreModules(context_holder->isolate());
139 } 138 }
140 139
141 } // namespace content 140 } // namespace content
OLDNEW
« no previous file with comments | « trunk/src/content/renderer/web_ui_mojo_context_state.h ('k') | trunk/src/content/test/data/web_ui_mojo.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698