Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Side by Side Diff: shell/application_manager/application_manager_unittest.cc

Issue 1979723002: ApplicationConnection devolution, part 3. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « shell/android/native_viewport_application_loader.cc ('k') | shell/test/pingable_app.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "shell/application_manager/application_manager.h" 5 #include "shell/application_manager/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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 private: 115 private:
116 // ApplicationLoader implementation. 116 // ApplicationLoader implementation.
117 void Load(const GURL& url, 117 void Load(const GURL& url,
118 InterfaceRequest<Application> application_request) override { 118 InterfaceRequest<Application> application_request) override {
119 ++num_loads_; 119 ++num_loads_;
120 test_app_.reset(new ApplicationImpl(this, application_request.Pass())); 120 test_app_.reset(new ApplicationImpl(this, application_request.Pass()));
121 } 121 }
122 122
123 // ApplicationDelegate implementation. 123 // ApplicationDelegate implementation.
124 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { 124 bool ConfigureIncomingConnection(
125 connection->GetServiceProviderImpl().AddService<TestService>( 125 mojo::ServiceProviderImpl* service_provider_impl) override {
126 service_provider_impl->AddService<TestService>(
126 [this](const ConnectionContext& connection_context, 127 [this](const ConnectionContext& connection_context,
127 InterfaceRequest<TestService> request) { 128 InterfaceRequest<TestService> request) {
128 new TestServiceImpl(context_, request.Pass()); 129 new TestServiceImpl(context_, request.Pass());
129 }); 130 });
130 return true; 131 return true;
131 } 132 }
132 133
133 scoped_ptr<ApplicationImpl> test_app_; 134 scoped_ptr<ApplicationImpl> test_app_;
134 TestContext* context_; 135 TestContext* context_;
135 int num_loads_; 136 int num_loads_;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 Tester(TesterContext* context, const std::string& requestor_url) 299 Tester(TesterContext* context, const std::string& requestor_url)
299 : context_(context), requestor_url_(requestor_url) {} 300 : context_(context), requestor_url_(requestor_url) {}
300 ~Tester() override {} 301 ~Tester() override {}
301 302
302 private: 303 private:
303 void Load(const GURL& url, 304 void Load(const GURL& url,
304 InterfaceRequest<Application> application_request) override { 305 InterfaceRequest<Application> application_request) override {
305 app_.reset(new ApplicationImpl(this, application_request.Pass())); 306 app_.reset(new ApplicationImpl(this, application_request.Pass()));
306 } 307 }
307 308
308 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { 309 bool ConfigureIncomingConnection(
310 mojo::ServiceProviderImpl* service_provider_impl) override {
309 const std::string& remote_url = 311 const std::string& remote_url =
310 connection->GetServiceProviderImpl().connection_context().remote_url; 312 service_provider_impl->connection_context().remote_url;
311 if (!requestor_url_.empty() && requestor_url_ != remote_url) { 313 if (!requestor_url_.empty() && requestor_url_ != remote_url) {
312 context_->set_tester_called_quit(); 314 context_->set_tester_called_quit();
313 context_->QuitSoon(); 315 context_->QuitSoon();
314 base::MessageLoop::current()->Quit(); 316 base::MessageLoop::current()->Quit();
315 return false; 317 return false;
316 } 318 }
317 // If we're coming from A, then add B, otherwise A. 319 // If we're coming from A, then add B, otherwise A.
318 if (remote_url == kTestAURLString) { 320 if (remote_url == kTestAURLString) {
319 connection->GetServiceProviderImpl().AddService<TestB>( 321 service_provider_impl->AddService<TestB>(
320 [this](const ConnectionContext& connection_context, 322 [this](const ConnectionContext& connection_context,
321 InterfaceRequest<TestB> test_b_request) { 323 InterfaceRequest<TestB> test_b_request) {
322 new TestBImpl(context_, test_b_request.Pass()); 324 new TestBImpl(context_, test_b_request.Pass());
323 }); 325 });
324 } else { 326 } else {
325 connection->GetServiceProviderImpl().AddService<TestA>( 327 service_provider_impl->AddService<TestA>(
326 [this](const ConnectionContext& connection_context, 328 [this](const ConnectionContext& connection_context,
327 InterfaceRequest<TestA> test_a_request) { 329 InterfaceRequest<TestA> test_a_request) {
328 mojo::InterfaceHandle<mojo::ServiceProvider> incoming_sp_handle; 330 mojo::InterfaceHandle<mojo::ServiceProvider> incoming_sp_handle;
329 app_->shell()->ConnectToApplication( 331 app_->shell()->ConnectToApplication(
330 kTestBURLString, GetProxy(&incoming_sp_handle), nullptr); 332 kTestBURLString, GetProxy(&incoming_sp_handle), nullptr);
331 a_bindings_.push_back(new TestAImpl( 333 a_bindings_.push_back(new TestAImpl(
332 incoming_sp_handle.Pass(), context_, test_a_request.Pass())); 334 incoming_sp_handle.Pass(), context_, test_a_request.Pass()));
333 }); 335 });
334 } 336 }
335 return true; 337 return true;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 371
370 class TestExternal : public ApplicationDelegate { 372 class TestExternal : public ApplicationDelegate {
371 public: 373 public:
372 TestExternal() : configure_incoming_connection_called_(false) {} 374 TestExternal() : configure_incoming_connection_called_(false) {}
373 375
374 void Initialize(ApplicationImpl* app) override { 376 void Initialize(ApplicationImpl* app) override {
375 initialize_args_ = app->args(); 377 initialize_args_ = app->args();
376 base::MessageLoop::current()->Quit(); 378 base::MessageLoop::current()->Quit();
377 } 379 }
378 380
379 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { 381 bool ConfigureIncomingConnection(
382 mojo::ServiceProviderImpl* service_provider_impl) override {
380 configure_incoming_connection_called_ = true; 383 configure_incoming_connection_called_ = true;
381 base::MessageLoop::current()->Quit(); 384 base::MessageLoop::current()->Quit();
382 return true; 385 return true;
383 } 386 }
384 387
385 const std::vector<std::string>& initialize_args() const { 388 const std::vector<std::string>& initialize_args() const {
386 return initialize_args_; 389 return initialize_args_;
387 } 390 }
388 391
389 bool configure_incoming_connection_called() const { 392 bool configure_incoming_connection_called() const {
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 bool called = false; 784 bool called = false;
782 application_manager_->ConnectToApplication( 785 application_manager_->ConnectToApplication(
783 GURL("test:test"), GURL(), nullptr, 786 GURL("test:test"), GURL(), nullptr,
784 base::Bind(&QuitClosure, base::Unretained(&called))); 787 base::Bind(&QuitClosure, base::Unretained(&called)));
785 loop_.Run(); 788 loop_.Run();
786 EXPECT_TRUE(called); 789 EXPECT_TRUE(called);
787 } 790 }
788 791
789 } // namespace 792 } // namespace
790 } // namespace shell 793 } // namespace shell
OLDNEW
« no previous file with comments | « shell/android/native_viewport_application_loader.cc ('k') | shell/test/pingable_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698