OLD | NEW |
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 "mojo/shell/application_manager.h" | 5 #include "mojo/shell/application_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 private: | 113 private: |
114 // ApplicationLoader implementation. | 114 // ApplicationLoader implementation. |
115 void Load(const GURL& url, | 115 void Load(const GURL& url, |
116 InterfaceRequest<mojom::ShellClient> request) override { | 116 InterfaceRequest<mojom::ShellClient> request) override { |
117 ++num_loads_; | 117 ++num_loads_; |
118 shell_connection_.reset(new ShellConnection(this, std::move(request))); | 118 shell_connection_.reset(new ShellConnection(this, std::move(request))); |
119 } | 119 } |
120 | 120 |
121 // mojo::ShellClient implementation. | 121 // mojo::ShellClient implementation. |
122 bool AcceptConnection(Connection* connection) override { | 122 bool AcceptConnection(Connection* connection) override { |
123 connection->AddService<TestService>(this); | 123 connection->AddInterface<TestService>(this); |
124 last_requestor_url_ = GURL(connection->GetRemoteApplicationURL()); | 124 last_requestor_url_ = GURL(connection->GetRemoteApplicationURL()); |
125 return true; | 125 return true; |
126 } | 126 } |
127 | 127 |
128 // InterfaceFactory<TestService> implementation. | 128 // InterfaceFactory<TestService> implementation. |
129 void Create(Connection* connection, | 129 void Create(Connection* connection, |
130 InterfaceRequest<TestService> request) override { | 130 InterfaceRequest<TestService> request) override { |
131 new TestServiceImpl(context_, std::move(request)); | 131 new TestServiceImpl(context_, std::move(request)); |
132 } | 132 } |
133 | 133 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 | 244 |
245 // Used to test that the requestor url will be correctly passed. | 245 // Used to test that the requestor url will be correctly passed. |
246 class TestAImpl : public TestA { | 246 class TestAImpl : public TestA { |
247 public: | 247 public: |
248 TestAImpl(ShellConnection* app_impl, | 248 TestAImpl(ShellConnection* app_impl, |
249 TesterContext* test_context, | 249 TesterContext* test_context, |
250 InterfaceRequest<TestA> request, | 250 InterfaceRequest<TestA> request, |
251 InterfaceFactory<TestC>* factory) | 251 InterfaceFactory<TestC>* factory) |
252 : test_context_(test_context), binding_(this, std::move(request)) { | 252 : test_context_(test_context), binding_(this, std::move(request)) { |
253 connection_ = app_impl->Connect(kTestBURLString); | 253 connection_ = app_impl->Connect(kTestBURLString); |
254 connection_->AddService<TestC>(factory); | 254 connection_->AddInterface<TestC>(factory); |
255 connection_->ConnectToService(&b_); | 255 connection_->GetInterface(&b_); |
256 } | 256 } |
257 | 257 |
258 ~TestAImpl() override { | 258 ~TestAImpl() override { |
259 test_context_->IncrementNumADeletes(); | 259 test_context_->IncrementNumADeletes(); |
260 if (base::MessageLoop::current()->is_running()) | 260 if (base::MessageLoop::current()->is_running()) |
261 Quit(); | 261 Quit(); |
262 } | 262 } |
263 | 263 |
264 private: | 264 private: |
265 void CallB() override { | 265 void CallB() override { |
(...skipping 15 matching lines...) Expand all Loading... |
281 TestBPtr b_; | 281 TestBPtr b_; |
282 StrongBinding<TestA> binding_; | 282 StrongBinding<TestA> binding_; |
283 }; | 283 }; |
284 | 284 |
285 class TestBImpl : public TestB { | 285 class TestBImpl : public TestB { |
286 public: | 286 public: |
287 TestBImpl(Connection* connection, | 287 TestBImpl(Connection* connection, |
288 TesterContext* test_context, | 288 TesterContext* test_context, |
289 InterfaceRequest<TestB> request) | 289 InterfaceRequest<TestB> request) |
290 : test_context_(test_context), binding_(this, std::move(request)) { | 290 : test_context_(test_context), binding_(this, std::move(request)) { |
291 connection->ConnectToService(&c_); | 291 connection->GetInterface(&c_); |
292 } | 292 } |
293 | 293 |
294 ~TestBImpl() override { | 294 ~TestBImpl() override { |
295 test_context_->IncrementNumBDeletes(); | 295 test_context_->IncrementNumBDeletes(); |
296 if (base::MessageLoop::current()->is_running()) | 296 if (base::MessageLoop::current()->is_running()) |
297 base::MessageLoop::current()->QuitWhenIdle(); | 297 base::MessageLoop::current()->QuitWhenIdle(); |
298 test_context_->QuitSoon(); | 298 test_context_->QuitSoon(); |
299 } | 299 } |
300 | 300 |
301 private: | 301 private: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 bool AcceptConnection(Connection* connection) override { | 352 bool AcceptConnection(Connection* connection) override { |
353 if (!requestor_url_.empty() && | 353 if (!requestor_url_.empty() && |
354 requestor_url_ != connection->GetRemoteApplicationURL()) { | 354 requestor_url_ != connection->GetRemoteApplicationURL()) { |
355 context_->set_tester_called_quit(); | 355 context_->set_tester_called_quit(); |
356 context_->QuitSoon(); | 356 context_->QuitSoon(); |
357 base::MessageLoop::current()->QuitWhenIdle(); | 357 base::MessageLoop::current()->QuitWhenIdle(); |
358 return false; | 358 return false; |
359 } | 359 } |
360 // If we're coming from A, then add B, otherwise A. | 360 // If we're coming from A, then add B, otherwise A. |
361 if (connection->GetRemoteApplicationURL() == kTestAURLString) | 361 if (connection->GetRemoteApplicationURL() == kTestAURLString) |
362 connection->AddService<TestB>(this); | 362 connection->AddInterface<TestB>(this); |
363 else | 363 else |
364 connection->AddService<TestA>(this); | 364 connection->AddInterface<TestA>(this); |
365 return true; | 365 return true; |
366 } | 366 } |
367 | 367 |
368 void Create(Connection* connection, | 368 void Create(Connection* connection, |
369 InterfaceRequest<TestA> request) override { | 369 InterfaceRequest<TestA> request) override { |
370 a_bindings_.push_back( | 370 a_bindings_.push_back( |
371 new TestAImpl(app_.get(), context_, std::move(request), this)); | 371 new TestAImpl(app_.get(), context_, std::move(request), this)); |
372 } | 372 } |
373 | 373 |
374 void Create(Connection* connection, | 374 void Create(Connection* connection, |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 | 621 |
622 // A different identity because the domain is different. | 622 // A different identity because the domain is different. |
623 ConnectToService(application_manager_.get(), | 623 ConnectToService(application_manager_.get(), |
624 GURL("http://www.another_domain.org/abc"), &test_service); | 624 GURL("http://www.another_domain.org/abc"), &test_service); |
625 EXPECT_EQ(4, test_loader_->num_loads()); | 625 EXPECT_EQ(4, test_loader_->num_loads()); |
626 } | 626 } |
627 | 627 |
628 } // namespace test | 628 } // namespace test |
629 } // namespace shell | 629 } // namespace shell |
630 } // namespace mojo | 630 } // namespace mojo |
OLD | NEW |