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

Side by Side Diff: shell/context.cc

Issue 845593003: Pass ServiceProvider and ServiceProvider& params in Connect (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 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 "shell/context.h" 5 #include "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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 GURL url(parts[i + 1]); 82 GURL url(parts[i + 1]);
83 if (!url.is_valid()) { 83 if (!url.is_valid()) {
84 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers 84 LOG(ERROR) << "Invalid value for switch " << switches::kContentHandlers
85 << ": '" << parts[i + 1] << "' is not a valid URL."; 85 << ": '" << parts[i + 1] << "' is not a valid URL.";
86 return; 86 return;
87 } 87 }
88 loader->RegisterContentHandler(parts[i], url); 88 loader->RegisterContentHandler(parts[i], url);
89 } 89 }
90 } 90 }
91 91
92 class EmptyServiceProvider : public InterfaceImpl<ServiceProvider> {
93 private:
94 void ConnectToService(const mojo::String& service_name,
95 ScopedMessagePipeHandle client_handle) override {}
96 };
97
98 bool ConfigureURLMappings(const std::string& mappings, 92 bool ConfigureURLMappings(const std::string& mappings,
99 mojo::shell::MojoURLResolver* resolver) { 93 mojo::shell::MojoURLResolver* resolver) {
100 base::StringPairs pairs; 94 base::StringPairs pairs;
101 if (!base::SplitStringIntoKeyValuePairs(mappings, '=', ',', &pairs)) 95 if (!base::SplitStringIntoKeyValuePairs(mappings, '=', ',', &pairs))
102 return false; 96 return false;
103 using StringPair = std::pair<std::string, std::string>; 97 using StringPair = std::pair<std::string, std::string>;
104 for (const StringPair& pair : pairs) { 98 for (const StringPair& pair : pairs) {
105 const GURL from(pair.first); 99 const GURL from(pair.first);
106 const GURL to(pair.second); 100 const GURL to(pair.second);
107 if (!from.is_valid() || !to.is_valid()) 101 if (!from.is_valid() || !to.is_valid())
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 if (app_urls_.empty() && base::MessageLoop::current()->is_running()) 183 if (app_urls_.empty() && base::MessageLoop::current()->is_running())
190 base::MessageLoop::current()->Quit(); 184 base::MessageLoop::current()->Quit();
191 } 185 }
192 } 186 }
193 187
194 GURL Context::ResolveURL(const GURL& url) { 188 GURL Context::ResolveURL(const GURL& url) {
195 return mojo_url_resolver_.Resolve(url); 189 return mojo_url_resolver_.Resolve(url);
196 } 190 }
197 191
198 void Context::Run(const GURL& url) { 192 void Context::Run(const GURL& url) {
199 EmptyServiceProvider* sp = new EmptyServiceProvider; 193 ServiceProviderPtr services;
200 ServiceProviderPtr spp; 194 ServiceProviderPtr exported_services;
201 BindToProxy(sp, &spp);
202 195
203 app_urls_.insert(url); 196 app_urls_.insert(url);
204 application_manager_.ConnectToApplication(url, GURL(), spp.Pass()); 197 application_manager_.ConnectToApplication(url, GURL(), GetProxy(&services),
198 exported_services.Pass());
205 } 199 }
206 200
207 ScopedMessagePipeHandle Context::ConnectToServiceByName( 201 ScopedMessagePipeHandle Context::ConnectToServiceByName(
208 const GURL& application_url, 202 const GURL& application_url,
209 const std::string& service_name) { 203 const std::string& service_name) {
210 app_urls_.insert(application_url); 204 app_urls_.insert(application_url);
211 return application_manager_.ConnectToServiceByName(application_url, 205 return application_manager_.ConnectToServiceByName(application_url,
212 service_name).Pass(); 206 service_name).Pass();
213 } 207 }
214 208
215 } // namespace shell 209 } // namespace shell
216 } // namespace mojo 210 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698