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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 test_app_.reset(); | 107 test_app_.reset(); |
108 } | 108 } |
109 | 109 |
110 void set_context(TestContext* context) { context_ = context; } | 110 void set_context(TestContext* context) { context_ = context; } |
111 int num_loads() const { return num_loads_; } | 111 int num_loads() const { return num_loads_; } |
112 const GURL& last_requestor_url() const { return last_requestor_url_; } | 112 const GURL& last_requestor_url() const { return last_requestor_url_; } |
113 | 113 |
114 private: | 114 private: |
115 // ApplicationLoader implementation. | 115 // ApplicationLoader implementation. |
116 void Load(const GURL& url, | 116 void Load(const GURL& url, |
117 InterfaceRequest<Application> application_request) override { | 117 InterfaceRequest<mojom::Application> application_request) override { |
118 ++num_loads_; | 118 ++num_loads_; |
119 test_app_.reset(new ApplicationImpl(this, std::move(application_request))); | 119 test_app_.reset(new ApplicationImpl(this, std::move(application_request))); |
120 } | 120 } |
121 | 121 |
122 // ApplicationDelegate implementation. | 122 // ApplicationDelegate implementation. |
123 bool AcceptConnection(ApplicationConnection* connection) override { | 123 bool AcceptConnection(ApplicationConnection* connection) override { |
124 connection->AddService<TestService>(this); | 124 connection->AddService<TestService>(this); |
125 last_requestor_url_ = GURL(connection->GetRemoteApplicationURL()); | 125 last_requestor_url_ = GURL(connection->GetRemoteApplicationURL()); |
126 return true; | 126 return true; |
127 } | 127 } |
128 | 128 |
129 // InterfaceFactory<TestService> implementation. | 129 // InterfaceFactory<TestService> implementation. |
130 void Create(ApplicationConnection* connection, | 130 void Create(ApplicationConnection* connection, |
131 InterfaceRequest<TestService> request) override { | 131 InterfaceRequest<TestService> request) override { |
132 new TestServiceImpl(context_, std::move(request)); | 132 new TestServiceImpl(context_, std::move(request)); |
133 } | 133 } |
134 | 134 |
135 scoped_ptr<ApplicationImpl> test_app_; | 135 scoped_ptr<ApplicationImpl> test_app_; |
136 TestContext* context_; | 136 TestContext* context_; |
137 int num_loads_; | 137 int num_loads_; |
138 GURL last_requestor_url_; | 138 GURL last_requestor_url_; |
139 | 139 |
140 DISALLOW_COPY_AND_ASSIGN(TestApplicationLoader); | 140 DISALLOW_COPY_AND_ASSIGN(TestApplicationLoader); |
141 }; | 141 }; |
142 | 142 |
143 class ClosingApplicationLoader : public ApplicationLoader { | 143 class ClosingApplicationLoader : public ApplicationLoader { |
144 private: | 144 private: |
145 // ApplicationLoader implementation. | 145 // ApplicationLoader implementation. |
146 void Load(const GURL& url, | 146 void Load(const GURL& url, |
147 InterfaceRequest<Application> application_request) override {} | 147 InterfaceRequest<mojom::Application> application_request) override { |
| 148 } |
148 }; | 149 }; |
149 | 150 |
150 class TesterContext { | 151 class TesterContext { |
151 public: | 152 public: |
152 explicit TesterContext(base::MessageLoop* loop) | 153 explicit TesterContext(base::MessageLoop* loop) |
153 : num_b_calls_(0), | 154 : num_b_calls_(0), |
154 num_c_calls_(0), | 155 num_c_calls_(0), |
155 num_a_deletes_(0), | 156 num_a_deletes_(0), |
156 num_b_deletes_(0), | 157 num_b_deletes_(0), |
157 num_c_deletes_(0), | 158 num_c_deletes_(0), |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 public InterfaceFactory<TestA>, | 339 public InterfaceFactory<TestA>, |
339 public InterfaceFactory<TestB>, | 340 public InterfaceFactory<TestB>, |
340 public InterfaceFactory<TestC> { | 341 public InterfaceFactory<TestC> { |
341 public: | 342 public: |
342 Tester(TesterContext* context, const std::string& requestor_url) | 343 Tester(TesterContext* context, const std::string& requestor_url) |
343 : context_(context), requestor_url_(requestor_url) {} | 344 : context_(context), requestor_url_(requestor_url) {} |
344 ~Tester() override {} | 345 ~Tester() override {} |
345 | 346 |
346 private: | 347 private: |
347 void Load(const GURL& url, | 348 void Load(const GURL& url, |
348 InterfaceRequest<Application> application_request) override { | 349 InterfaceRequest<mojom::Application> application_request) override { |
349 app_.reset(new ApplicationImpl(this, std::move(application_request))); | 350 app_.reset(new ApplicationImpl(this, std::move(application_request))); |
350 } | 351 } |
351 | 352 |
352 bool AcceptConnection(ApplicationConnection* connection) override { | 353 bool AcceptConnection(ApplicationConnection* connection) override { |
353 if (!requestor_url_.empty() && | 354 if (!requestor_url_.empty() && |
354 requestor_url_ != connection->GetRemoteApplicationURL()) { | 355 requestor_url_ != connection->GetRemoteApplicationURL()) { |
355 context_->set_tester_called_quit(); | 356 context_->set_tester_called_quit(); |
356 context_->QuitSoon(); | 357 context_->QuitSoon(); |
357 base::MessageLoop::current()->QuitWhenIdle(); | 358 base::MessageLoop::current()->QuitWhenIdle(); |
358 return false; | 359 return false; |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 | 622 |
622 // A different identity because the domain is different. | 623 // A different identity because the domain is different. |
623 ConnectToService(application_manager_.get(), | 624 ConnectToService(application_manager_.get(), |
624 GURL("http://www.another_domain.org/abc"), &test_service); | 625 GURL("http://www.another_domain.org/abc"), &test_service); |
625 EXPECT_EQ(4, test_loader_->num_loads()); | 626 EXPECT_EQ(4, test_loader_->num_loads()); |
626 } | 627 } |
627 | 628 |
628 } // namespace test | 629 } // namespace test |
629 } // namespace shell | 630 } // namespace shell |
630 } // namespace mojo | 631 } // namespace mojo |
OLD | NEW |