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

Side by Side Diff: mojo/shell/context.cc

Issue 696563002: Cache ShellImpl by resolved URL, not initial URL (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebase Created 6 years, 1 month 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
« no previous file with comments | « mojo/shell/context.h ('k') | mojo/shell/dynamic_application_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "mojo/shell/context.h" 5 #include "mojo/shell/context.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 &request); 152 &request);
153 } 153 }
154 154
155 scoped_refptr<gfx::GLShareGroup> share_group_; 155 scoped_refptr<gfx::GLShareGroup> share_group_;
156 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; 156 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_;
157 scoped_ptr<ApplicationImpl> app_; 157 scoped_ptr<ApplicationImpl> app_;
158 DISALLOW_COPY_AND_ASSIGN(NativeViewportApplicationLoader); 158 DISALLOW_COPY_AND_ASSIGN(NativeViewportApplicationLoader);
159 }; 159 };
160 #endif 160 #endif
161 161
162 Context::Context() { 162 Context::Context() : application_manager_(this) {
163 DCHECK(!base::MessageLoop::current()); 163 DCHECK(!base::MessageLoop::current());
164 } 164 }
165 165
166 Context::~Context() { 166 Context::~Context() {
167 DCHECK(!base::MessageLoop::current()); 167 DCHECK(!base::MessageLoop::current());
168 } 168 }
169 169
170 void Context::Init() { 170 void Context::Init() {
171 application_manager_.set_delegate(this);
172 setup.Get(); 171 setup.Get();
173 task_runners_.reset( 172 task_runners_.reset(
174 new TaskRunners(base::MessageLoop::current()->message_loop_proxy())); 173 new TaskRunners(base::MessageLoop::current()->message_loop_proxy()));
175 174
176 for (size_t i = 0; i < arraysize(kLocalMojoURLs); ++i) 175 for (size_t i = 0; i < arraysize(kLocalMojoURLs); ++i)
177 mojo_url_resolver_.AddLocalFileMapping(GURL(kLocalMojoURLs[i])); 176 mojo_url_resolver_.AddLocalFileMapping(GURL(kLocalMojoURLs[i]));
178 177
179 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 178 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
180 179
181 if (command_line->HasSwitch(switches::kEnableExternalApplications)) { 180 if (command_line->HasSwitch(switches::kEnableExternalApplications)) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 base::MessageLoop::TYPE_IO)); 234 base::MessageLoop::TYPE_IO));
236 application_manager_.SetLoaderForURL(loader.Pass(), 235 application_manager_.SetLoaderForURL(loader.Pass(),
237 GURL("mojo:network_service")); 236 GURL("mojo:network_service"));
238 } 237 }
239 #endif 238 #endif
240 239
241 if (listener_) 240 if (listener_)
242 listener_->WaitForListening(); 241 listener_->WaitForListening();
243 } 242 }
244 243
245 void Context::OnApplicationError(const GURL& gurl) { 244 void Context::OnApplicationError(const GURL& url) {
246 if (app_urls_.find(gurl) != app_urls_.end()) { 245 if (app_urls_.find(url) != app_urls_.end()) {
247 app_urls_.erase(gurl); 246 app_urls_.erase(url);
248 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) 247 if (app_urls_.empty() && base::MessageLoop::current()->is_running())
249 base::MessageLoop::current()->Quit(); 248 base::MessageLoop::current()->Quit();
250 } 249 }
251 } 250 }
252 251
252 GURL Context::ResolveURL(const GURL& url) {
253 return mojo_url_resolver_.Resolve(url);
254 }
255
253 void Context::Run(const GURL& url) { 256 void Context::Run(const GURL& url) {
254 EmptyServiceProvider* sp = new EmptyServiceProvider; 257 EmptyServiceProvider* sp = new EmptyServiceProvider;
255 ServiceProviderPtr spp; 258 ServiceProviderPtr spp;
256 BindToProxy(sp, &spp); 259 BindToProxy(sp, &spp);
257 260
258 app_urls_.insert(url); 261 app_urls_.insert(url);
259 application_manager_.ConnectToApplication(url, GURL(), spp.Pass()); 262 application_manager_.ConnectToApplication(url, GURL(), spp.Pass());
260 } 263 }
261 264
262 ScopedMessagePipeHandle Context::ConnectToServiceByName( 265 ScopedMessagePipeHandle Context::ConnectToServiceByName(
263 const GURL& application_url, 266 const GURL& application_url,
264 const std::string& service_name) { 267 const std::string& service_name) {
265 app_urls_.insert(application_url); 268 app_urls_.insert(application_url);
266 return application_manager_.ConnectToServiceByName( 269 return application_manager_.ConnectToServiceByName(
267 application_url, service_name).Pass(); 270 application_url, service_name).Pass();
268 } 271 }
269 272
270 } // namespace shell 273 } // namespace shell
271 } // namespace mojo 274 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/context.h ('k') | mojo/shell/dynamic_application_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698