OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/browser/mojo/mojo_shell_context.h" | 5 #include "content/browser/mojo/mojo_shell_context.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 : shell_context_(shell_context), | 92 : shell_context_(shell_context), |
93 task_runner_(base::ThreadTaskRunnerHandle::Get()) {} | 93 task_runner_(base::ThreadTaskRunnerHandle::Get()) {} |
94 | 94 |
95 ~Proxy() {} | 95 ~Proxy() {} |
96 | 96 |
97 void ConnectToApplication( | 97 void ConnectToApplication( |
98 const GURL& url, | 98 const GURL& url, |
99 const GURL& requestor_url, | 99 const GURL& requestor_url, |
100 mojo::InterfaceRequest<mojo::ServiceProvider> request, | 100 mojo::InterfaceRequest<mojo::ServiceProvider> request, |
101 mojo::ServiceProviderPtr exposed_services, | 101 mojo::ServiceProviderPtr exposed_services, |
102 const mojo::shell::CapabilityFilter& filter) { | 102 const mojo::shell::CapabilityFilter& filter, |
| 103 const mojo::Shell::ConnectToApplicationCallback& callback) { |
103 if (task_runner_ == base::ThreadTaskRunnerHandle::Get()) { | 104 if (task_runner_ == base::ThreadTaskRunnerHandle::Get()) { |
104 if (shell_context_) { | 105 if (shell_context_) { |
105 shell_context_->ConnectToApplicationOnOwnThread( | 106 shell_context_->ConnectToApplicationOnOwnThread( |
106 url, requestor_url, request.Pass(), exposed_services.Pass(), | 107 url, requestor_url, request.Pass(), exposed_services.Pass(), filter, |
107 filter); | 108 callback); |
108 } | 109 } |
109 } else { | 110 } else { |
110 // |shell_context_| outlives the main MessageLoop, so it's safe for it to | 111 // |shell_context_| outlives the main MessageLoop, so it's safe for it to |
111 // be unretained here. | 112 // be unretained here. |
112 task_runner_->PostTask( | 113 task_runner_->PostTask( |
113 FROM_HERE, | 114 FROM_HERE, |
114 base::Bind(&MojoShellContext::ConnectToApplicationOnOwnThread, | 115 base::Bind(&MojoShellContext::ConnectToApplicationOnOwnThread, |
115 base::Unretained(shell_context_), url, requestor_url, | 116 base::Unretained(shell_context_), url, requestor_url, |
116 base::Passed(&request), base::Passed(&exposed_services), | 117 base::Passed(&request), base::Passed(&exposed_services), |
117 filter)); | 118 filter, callback)); |
118 } | 119 } |
119 } | 120 } |
120 | 121 |
121 private: | 122 private: |
122 MojoShellContext* shell_context_; | 123 MojoShellContext* shell_context_; |
123 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 124 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
124 | 125 |
125 DISALLOW_COPY_AND_ASSIGN(Proxy); | 126 DISALLOW_COPY_AND_ASSIGN(Proxy); |
126 }; | 127 }; |
127 | 128 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 180 |
180 MojoShellContext::~MojoShellContext() { | 181 MojoShellContext::~MojoShellContext() { |
181 } | 182 } |
182 | 183 |
183 // static | 184 // static |
184 void MojoShellContext::ConnectToApplication( | 185 void MojoShellContext::ConnectToApplication( |
185 const GURL& url, | 186 const GURL& url, |
186 const GURL& requestor_url, | 187 const GURL& requestor_url, |
187 mojo::InterfaceRequest<mojo::ServiceProvider> request, | 188 mojo::InterfaceRequest<mojo::ServiceProvider> request, |
188 mojo::ServiceProviderPtr exposed_services, | 189 mojo::ServiceProviderPtr exposed_services, |
189 const mojo::shell::CapabilityFilter& filter) { | 190 const mojo::shell::CapabilityFilter& filter, |
| 191 const mojo::Shell::ConnectToApplicationCallback& callback) { |
190 proxy_.Get()->ConnectToApplication(url, requestor_url, request.Pass(), | 192 proxy_.Get()->ConnectToApplication(url, requestor_url, request.Pass(), |
191 exposed_services.Pass(), filter); | 193 exposed_services.Pass(), filter, callback); |
192 } | 194 } |
193 | 195 |
194 void MojoShellContext::ConnectToApplicationOnOwnThread( | 196 void MojoShellContext::ConnectToApplicationOnOwnThread( |
195 const GURL& url, | 197 const GURL& url, |
196 const GURL& requestor_url, | 198 const GURL& requestor_url, |
197 mojo::InterfaceRequest<mojo::ServiceProvider> request, | 199 mojo::InterfaceRequest<mojo::ServiceProvider> request, |
198 mojo::ServiceProviderPtr exposed_services, | 200 mojo::ServiceProviderPtr exposed_services, |
199 const mojo::shell::CapabilityFilter& filter) { | 201 const mojo::shell::CapabilityFilter& filter, |
| 202 const mojo::Shell::ConnectToApplicationCallback& callback) { |
200 mojo::URLRequestPtr url_request = mojo::URLRequest::New(); | 203 mojo::URLRequestPtr url_request = mojo::URLRequest::New(); |
201 url_request->url = mojo::String::From(url); | 204 url_request->url = mojo::String::From(url); |
202 application_manager_->ConnectToApplication( | 205 application_manager_->ConnectToApplication( |
203 nullptr, url_request.Pass(), std::string(), requestor_url, request.Pass(), | 206 nullptr, url_request.Pass(), std::string(), requestor_url, request.Pass(), |
204 exposed_services.Pass(), filter, base::Bind(&base::DoNothing)); | 207 exposed_services.Pass(), filter, base::Bind(&base::DoNothing), callback); |
205 } | 208 } |
206 | 209 |
207 GURL MojoShellContext::ResolveMappings(const GURL& url) { | 210 GURL MojoShellContext::ResolveMappings(const GURL& url) { |
208 return url; | 211 return url; |
209 } | 212 } |
210 | 213 |
211 GURL MojoShellContext::ResolveMojoURL(const GURL& url) { | 214 GURL MojoShellContext::ResolveMojoURL(const GURL& url) { |
212 return url; | 215 return url; |
213 } | 216 } |
214 | 217 |
215 bool MojoShellContext::CreateFetcher( | 218 bool MojoShellContext::CreateFetcher( |
216 const GURL& url, | 219 const GURL& url, |
217 const mojo::shell::Fetcher::FetchCallback& loader_callback) { | 220 const mojo::shell::Fetcher::FetchCallback& loader_callback) { |
218 return false; | 221 return false; |
219 } | 222 } |
220 | 223 |
221 } // namespace content | 224 } // namespace content |
OLD | NEW |