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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 public: | 82 public: |
83 Proxy(MojoShellContext* shell_context) | 83 Proxy(MojoShellContext* shell_context) |
84 : shell_context_(shell_context), | 84 : shell_context_(shell_context), |
85 task_runner_(base::ThreadTaskRunnerHandle::Get()) {} | 85 task_runner_(base::ThreadTaskRunnerHandle::Get()) {} |
86 | 86 |
87 ~Proxy() {} | 87 ~Proxy() {} |
88 | 88 |
89 void ConnectToApplication( | 89 void ConnectToApplication( |
90 const GURL& url, | 90 const GURL& url, |
91 const GURL& requestor_url, | 91 const GURL& requestor_url, |
92 mojo::InterfaceRequest<mojo::ServiceProvider> request) { | 92 mojo::InterfaceRequest<mojo::ServiceProvider> request, |
93 mojo::ServiceProviderPtr exposed_services) { | |
93 if (task_runner_ == base::ThreadTaskRunnerHandle::Get()) { | 94 if (task_runner_ == base::ThreadTaskRunnerHandle::Get()) { |
94 if (shell_context_) | 95 if (shell_context_) |
95 shell_context_->ConnectToApplicationOnOwnThread(url, requestor_url, | 96 shell_context_->ConnectToApplicationOnOwnThread( |
Ken Rockot(use gerrit already)
2015/07/06 18:58:00
nit: this is my fault, but please add braces aroun
xhwang
2015/07/07 19:21:04
Done.
| |
96 request.Pass()); | 97 url, requestor_url, request.Pass(), exposed_services.Pass()); |
97 } else { | 98 } else { |
98 // |shell_context_| outlives the main MessageLoop, so it's safe for it to | 99 // |shell_context_| outlives the main MessageLoop, so it's safe for it to |
99 // be unretained here. | 100 // be unretained here. |
100 task_runner_->PostTask( | 101 task_runner_->PostTask( |
101 FROM_HERE, | 102 FROM_HERE, |
102 base::Bind(&MojoShellContext::ConnectToApplicationOnOwnThread, | 103 base::Bind(&MojoShellContext::ConnectToApplicationOnOwnThread, |
103 base::Unretained(shell_context_), url, requestor_url, | 104 base::Unretained(shell_context_), url, requestor_url, |
104 base::Passed(&request))); | 105 base::Passed(&request), base::Passed(&exposed_services))); |
105 } | 106 } |
106 } | 107 } |
107 | 108 |
108 private: | 109 private: |
109 MojoShellContext* shell_context_; | 110 MojoShellContext* shell_context_; |
110 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 111 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
111 | 112 |
112 DISALLOW_COPY_AND_ASSIGN(Proxy); | 113 DISALLOW_COPY_AND_ASSIGN(Proxy); |
113 }; | 114 }; |
114 | 115 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 #endif | 152 #endif |
152 } | 153 } |
153 | 154 |
154 MojoShellContext::~MojoShellContext() { | 155 MojoShellContext::~MojoShellContext() { |
155 } | 156 } |
156 | 157 |
157 // static | 158 // static |
158 void MojoShellContext::ConnectToApplication( | 159 void MojoShellContext::ConnectToApplication( |
159 const GURL& url, | 160 const GURL& url, |
160 const GURL& requestor_url, | 161 const GURL& requestor_url, |
161 mojo::InterfaceRequest<mojo::ServiceProvider> request) { | 162 mojo::InterfaceRequest<mojo::ServiceProvider> request, |
162 proxy_.Get()->ConnectToApplication(url, requestor_url, request.Pass()); | 163 mojo::ServiceProviderPtr exposed_services) { |
164 proxy_.Get()->ConnectToApplication(url, requestor_url, request.Pass(), | |
165 exposed_services.Pass()); | |
163 } | 166 } |
164 | 167 |
165 void MojoShellContext::ConnectToApplicationOnOwnThread( | 168 void MojoShellContext::ConnectToApplicationOnOwnThread( |
166 const GURL& url, | 169 const GURL& url, |
167 const GURL& requestor_url, | 170 const GURL& requestor_url, |
168 mojo::InterfaceRequest<mojo::ServiceProvider> request) { | 171 mojo::InterfaceRequest<mojo::ServiceProvider> request, |
172 mojo::ServiceProviderPtr exposed_services) { | |
169 mojo::URLRequestPtr url_request = mojo::URLRequest::New(); | 173 mojo::URLRequestPtr url_request = mojo::URLRequest::New(); |
170 url_request->url = mojo::String::From(url); | 174 url_request->url = mojo::String::From(url); |
171 application_manager_->ConnectToApplication( | 175 application_manager_->ConnectToApplication( |
172 url_request.Pass(), requestor_url, request.Pass(), | 176 url_request.Pass(), requestor_url, request.Pass(), |
173 mojo::ServiceProviderPtr(), base::Bind(&base::DoNothing)); | 177 exposed_services.Pass(), base::Bind(&base::DoNothing)); |
174 } | 178 } |
175 | 179 |
176 GURL MojoShellContext::ResolveMappings(const GURL& url) { | 180 GURL MojoShellContext::ResolveMappings(const GURL& url) { |
177 return url; | 181 return url; |
178 } | 182 } |
179 | 183 |
180 GURL MojoShellContext::ResolveMojoURL(const GURL& url) { | 184 GURL MojoShellContext::ResolveMojoURL(const GURL& url) { |
181 return url; | 185 return url; |
182 } | 186 } |
183 | 187 |
184 bool MojoShellContext::CreateFetcher( | 188 bool MojoShellContext::CreateFetcher( |
185 const GURL& url, | 189 const GURL& url, |
186 const mojo::shell::Fetcher::FetchCallback& loader_callback) { | 190 const mojo::shell::Fetcher::FetchCallback& loader_callback) { |
187 return false; | 191 return false; |
188 } | 192 } |
189 | 193 |
190 } // namespace content | 194 } // namespace content |
OLD | NEW |