| 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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "mojo/application/public/cpp/application_connection.h" | 10 #include "mojo/application/public/cpp/application_connection.h" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 267 |
| 268 // Used to test that the requestor url will be correctly passed. | 268 // Used to test that the requestor url will be correctly passed. |
| 269 class TestAImpl : public TestA { | 269 class TestAImpl : public TestA { |
| 270 public: | 270 public: |
| 271 TestAImpl(ApplicationImpl* app_impl, | 271 TestAImpl(ApplicationImpl* app_impl, |
| 272 TesterContext* test_context, | 272 TesterContext* test_context, |
| 273 InterfaceRequest<TestA> request) | 273 InterfaceRequest<TestA> request) |
| 274 : test_context_(test_context), binding_(this, request.Pass()) { | 274 : test_context_(test_context), binding_(this, request.Pass()) { |
| 275 mojo::URLRequestPtr request2(mojo::URLRequest::New()); | 275 mojo::URLRequestPtr request2(mojo::URLRequest::New()); |
| 276 request2->url = mojo::String::From(kTestBURLString); | 276 request2->url = mojo::String::From(kTestBURLString); |
| 277 app_impl->ConnectToApplication(request2.Pass())->ConnectToService(&b_); | 277 connection_ = app_impl->ConnectToApplication(request2.Pass()); |
| 278 connection_->ConnectToService(&b_); |
| 278 } | 279 } |
| 279 | 280 |
| 280 ~TestAImpl() override { | 281 ~TestAImpl() override { |
| 281 test_context_->IncrementNumADeletes(); | 282 test_context_->IncrementNumADeletes(); |
| 282 if (base::MessageLoop::current()->is_running()) | 283 if (base::MessageLoop::current()->is_running()) |
| 283 Quit(); | 284 Quit(); |
| 284 } | 285 } |
| 285 | 286 |
| 286 private: | 287 private: |
| 287 void CallB() override { | 288 void CallB() override { |
| 288 b_->B(base::Bind(&TestAImpl::Quit, base::Unretained(this))); | 289 b_->B(base::Bind(&TestAImpl::Quit, base::Unretained(this))); |
| 289 } | 290 } |
| 290 | 291 |
| 291 void CallCFromB() override { | 292 void CallCFromB() override { |
| 292 b_->CallC(base::Bind(&TestAImpl::Quit, base::Unretained(this))); | 293 b_->CallC(base::Bind(&TestAImpl::Quit, base::Unretained(this))); |
| 293 } | 294 } |
| 294 | 295 |
| 295 void Quit() { | 296 void Quit() { |
| 296 base::MessageLoop::current()->Quit(); | 297 base::MessageLoop::current()->Quit(); |
| 297 test_context_->set_a_called_quit(); | 298 test_context_->set_a_called_quit(); |
| 298 test_context_->QuitSoon(); | 299 test_context_->QuitSoon(); |
| 299 } | 300 } |
| 300 | 301 |
| 302 scoped_ptr<ApplicationConnection> connection_; |
| 301 TesterContext* test_context_; | 303 TesterContext* test_context_; |
| 302 TestBPtr b_; | 304 TestBPtr b_; |
| 303 StrongBinding<TestA> binding_; | 305 StrongBinding<TestA> binding_; |
| 304 }; | 306 }; |
| 305 | 307 |
| 306 class TestBImpl : public TestB { | 308 class TestBImpl : public TestB { |
| 307 public: | 309 public: |
| 308 TestBImpl(ApplicationConnection* connection, | 310 TestBImpl(ApplicationConnection* connection, |
| 309 TesterContext* test_context, | 311 TesterContext* test_context, |
| 310 InterfaceRequest<TestB> request) | 312 InterfaceRequest<TestB> request) |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 loop.Run(); | 795 loop.Run(); |
| 794 EXPECT_TRUE(called); | 796 EXPECT_TRUE(called); |
| 795 | 797 |
| 796 ASSERT_EQ(1, loader->num_loads()); | 798 ASSERT_EQ(1, loader->num_loads()); |
| 797 EXPECT_EQ(requestor_url, loader->last_requestor_url()); | 799 EXPECT_EQ(requestor_url, loader->last_requestor_url()); |
| 798 } | 800 } |
| 799 | 801 |
| 800 } // namespace | 802 } // namespace |
| 801 } // namespace shell | 803 } // namespace shell |
| 802 } // namespace mojo | 804 } // namespace mojo |
| OLD | NEW |