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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 void set_context(TestContext* context) { context_ = context; } | 133 void set_context(TestContext* context) { context_ = context; } |
134 int num_loads() const { return num_loads_; } | 134 int num_loads() const { return num_loads_; } |
135 const GURL& last_requestor_url() const { return last_requestor_url_; } | 135 const GURL& last_requestor_url() const { return last_requestor_url_; } |
136 | 136 |
137 private: | 137 private: |
138 // ApplicationLoader implementation. | 138 // ApplicationLoader implementation. |
139 void Load(const GURL& url, | 139 void Load(const GURL& url, |
140 InterfaceRequest<Application> application_request) override { | 140 InterfaceRequest<Application> application_request) override { |
141 ++num_loads_; | 141 ++num_loads_; |
142 test_app_.reset(new ApplicationImpl(this, application_request.Pass())); | 142 test_app_.reset( |
| 143 new ApplicationImpl(this, application_request.Pass(), |
| 144 base::MessageLoop::QuitWhenIdleClosure())); |
143 } | 145 } |
144 | 146 |
145 // ApplicationDelegate implementation. | 147 // ApplicationDelegate implementation. |
146 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { | 148 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { |
147 connection->AddService(this); | 149 connection->AddService(this); |
148 last_requestor_url_ = GURL(connection->GetRemoteApplicationURL()); | 150 last_requestor_url_ = GURL(connection->GetRemoteApplicationURL()); |
149 return true; | 151 return true; |
150 } | 152 } |
151 | 153 |
152 // InterfaceFactory implementation. | 154 // InterfaceFactory implementation. |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 public InterfaceFactory<TestB>, | 362 public InterfaceFactory<TestB>, |
361 public InterfaceFactory<TestC> { | 363 public InterfaceFactory<TestC> { |
362 public: | 364 public: |
363 Tester(TesterContext* context, const std::string& requestor_url) | 365 Tester(TesterContext* context, const std::string& requestor_url) |
364 : context_(context), requestor_url_(requestor_url) {} | 366 : context_(context), requestor_url_(requestor_url) {} |
365 ~Tester() override {} | 367 ~Tester() override {} |
366 | 368 |
367 private: | 369 private: |
368 void Load(const GURL& url, | 370 void Load(const GURL& url, |
369 InterfaceRequest<Application> application_request) override { | 371 InterfaceRequest<Application> application_request) override { |
370 app_.reset(new ApplicationImpl(this, application_request.Pass())); | 372 app_.reset(new ApplicationImpl(this, application_request.Pass(), |
| 373 base::MessageLoop::QuitWhenIdleClosure())); |
371 } | 374 } |
372 | 375 |
373 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { | 376 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { |
374 if (!requestor_url_.empty() && | 377 if (!requestor_url_.empty() && |
375 requestor_url_ != connection->GetRemoteApplicationURL()) { | 378 requestor_url_ != connection->GetRemoteApplicationURL()) { |
376 context_->set_tester_called_quit(); | 379 context_->set_tester_called_quit(); |
377 context_->QuitSoon(); | 380 context_->QuitSoon(); |
378 base::MessageLoop::current()->Quit(); | 381 base::MessageLoop::current()->Quit(); |
379 return false; | 382 return false; |
380 } | 383 } |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 loop.Run(); | 796 loop.Run(); |
794 EXPECT_TRUE(called); | 797 EXPECT_TRUE(called); |
795 | 798 |
796 ASSERT_EQ(1, loader->num_loads()); | 799 ASSERT_EQ(1, loader->num_loads()); |
797 EXPECT_EQ(requestor_url, loader->last_requestor_url()); | 800 EXPECT_EQ(requestor_url, loader->last_requestor_url()); |
798 } | 801 } |
799 | 802 |
800 } // namespace | 803 } // namespace |
801 } // namespace shell | 804 } // namespace shell |
802 } // namespace mojo | 805 } // namespace mojo |
OLD | NEW |