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

Side by Side Diff: shell/application_manager/application_manager.cc

Issue 873453004: Use ShellPtr type in ApplicationLoader instead of untyped handles (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: fix android Created 5 years, 11 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 "shell/application_manager/application_manager.h" 5 #include "shell/application_manager/application_manager.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 const GURL& requestor_url, 133 const GURL& requestor_url,
134 InterfaceRequest<ServiceProvider> services, 134 InterfaceRequest<ServiceProvider> services,
135 ServiceProviderPtr exposed_services, 135 ServiceProviderPtr exposed_services,
136 ApplicationLoader* loader) { 136 ApplicationLoader* loader) {
137 ShellImpl* shell = nullptr; 137 ShellImpl* shell = nullptr;
138 URLToShellImplMap::const_iterator shell_it = 138 URLToShellImplMap::const_iterator shell_it =
139 url_to_shell_impl_.find(resolved_url); 139 url_to_shell_impl_.find(resolved_url);
140 if (shell_it != url_to_shell_impl_.end()) { 140 if (shell_it != url_to_shell_impl_.end()) {
141 shell = shell_it->second; 141 shell = shell_it->second;
142 } else { 142 } else {
143 MessagePipe pipe; 143 ShellPtr shell_ptr;
144 shell = 144 shell =
145 new ShellImpl(pipe.handle0.Pass(), this, requested_url, resolved_url); 145 new ShellImpl(GetProxy(&shell_ptr), this, requested_url, resolved_url);
146 url_to_shell_impl_[resolved_url] = shell; 146 url_to_shell_impl_[resolved_url] = shell;
147 shell->client()->Initialize(GetArgsForURL(requested_url)); 147 shell->client()->Initialize(GetArgsForURL(requested_url));
148 148
149 loader->Load(this, resolved_url, pipe.handle1.Pass(), 149 loader->Load(this, resolved_url, shell_ptr.Pass(),
150 base::Bind(&ApplicationManager::LoadWithContentHandler, 150 base::Bind(&ApplicationManager::LoadWithContentHandler,
151 weak_ptr_factory_.GetWeakPtr())); 151 weak_ptr_factory_.GetWeakPtr()));
152 } 152 }
153 ConnectToClient(shell, resolved_url, requestor_url, services.Pass(), 153 ConnectToClient(shell, resolved_url, requestor_url, services.Pass(),
154 exposed_services.Pass()); 154 exposed_services.Pass());
155 } 155 }
156 156
157 void ApplicationManager::ConnectToClient( 157 void ApplicationManager::ConnectToClient(
158 ShellImpl* shell_impl, 158 ShellImpl* shell_impl,
159 const GURL& url, 159 const GURL& url,
160 const GURL& requestor_url, 160 const GURL& requestor_url,
161 InterfaceRequest<ServiceProvider> services, 161 InterfaceRequest<ServiceProvider> services,
162 ServiceProviderPtr exposed_services) { 162 ServiceProviderPtr exposed_services) {
163 shell_impl->ConnectToClient(requestor_url, services.Pass(), 163 shell_impl->ConnectToClient(requestor_url, services.Pass(),
164 exposed_services.Pass()); 164 exposed_services.Pass());
165 } 165 }
166 166
167 void ApplicationManager::RegisterExternalApplication( 167 void ApplicationManager::RegisterExternalApplication(
168 const GURL& url, 168 const GURL& url,
169 ScopedMessagePipeHandle shell_handle) { 169 ScopedMessagePipeHandle shell_handle) {
170 ShellImpl* shell_impl = new ShellImpl(shell_handle.Pass(), this, url, url); 170 ShellImpl* shell_impl =
171 new ShellImpl(MakeRequest<Shell>(shell_handle.Pass()), this, url, url);
171 url_to_shell_impl_[url] = shell_impl; 172 url_to_shell_impl_[url] = shell_impl;
172 shell_impl->client()->Initialize(GetArgsForURL(url)); 173 shell_impl->client()->Initialize(GetArgsForURL(url));
173 } 174 }
174 175
175 void ApplicationManager::LoadWithContentHandler( 176 void ApplicationManager::LoadWithContentHandler(
176 const GURL& content_handler_url, 177 const GURL& content_handler_url,
177 ScopedMessagePipeHandle shell_handle, 178 ScopedMessagePipeHandle shell_handle,
178 URLResponsePtr url_response) { 179 URLResponsePtr url_response) {
179 ContentHandlerConnection* connection = NULL; 180 ContentHandlerConnection* connection = NULL;
180 URLToContentHandlerMap::iterator iter = 181 URLToContentHandlerMap::iterator iter =
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 return pipe.handle0.Pass(); 262 return pipe.handle0.Pass();
262 } 263 }
263 264
264 Array<String> ApplicationManager::GetArgsForURL(const GURL& url) { 265 Array<String> ApplicationManager::GetArgsForURL(const GURL& url) {
265 URLToArgsMap::const_iterator args_it = url_to_args_.find(url); 266 URLToArgsMap::const_iterator args_it = url_to_args_.find(url);
266 if (args_it != url_to_args_.end()) 267 if (args_it != url_to_args_.end())
267 return Array<String>::From(args_it->second); 268 return Array<String>::From(args_it->second);
268 return Array<String>(); 269 return Array<String>();
269 } 270 }
270 } // namespace mojo 271 } // namespace mojo
OLDNEW
« no previous file with comments | « shell/application_manager/application_manager.h ('k') | shell/application_manager/application_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698