| 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/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "mojo/public/cpp/application/application_connection.h" | 8 #include "mojo/public/cpp/application/application_connection.h" |
| 9 #include "mojo/public/cpp/application/application_delegate.h" | 9 #include "mojo/public/cpp/application/application_delegate.h" |
| 10 #include "mojo/public/cpp/application/application_impl.h" | 10 #include "mojo/public/cpp/application/application_impl.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 if (context_) | 111 if (context_) |
| 112 ++context_->num_loader_deletes; | 112 ++context_->num_loader_deletes; |
| 113 test_app_.reset(NULL); | 113 test_app_.reset(NULL); |
| 114 } | 114 } |
| 115 | 115 |
| 116 void set_context(TestContext* context) { context_ = context; } | 116 void set_context(TestContext* context) { context_ = context; } |
| 117 int num_loads() const { return num_loads_; } | 117 int num_loads() const { return num_loads_; } |
| 118 | 118 |
| 119 private: | 119 private: |
| 120 // ServiceLoader implementation. | 120 // ServiceLoader implementation. |
| 121 virtual void Load(ServiceManager* manager, | 121 virtual void LoadService( |
| 122 const GURL& url, | 122 ServiceManager* manager, |
| 123 scoped_refptr<LoadCallbacks> callbacks) OVERRIDE { | 123 const GURL& url, |
| 124 ScopedMessagePipeHandle service_provider_handle) OVERRIDE { |
| 124 ++num_loads_; | 125 ++num_loads_; |
| 125 test_app_.reset( | 126 test_app_.reset(new ApplicationImpl(this, service_provider_handle.Pass())); |
| 126 new ApplicationImpl(this, callbacks->RegisterApplication().Pass())); | |
| 127 } | 127 } |
| 128 | 128 |
| 129 virtual void OnServiceError(ServiceManager* manager, | 129 virtual void OnServiceError(ServiceManager* manager, |
| 130 const GURL& url) OVERRIDE { | 130 const GURL& url) OVERRIDE { |
| 131 } | 131 } |
| 132 | 132 |
| 133 // ApplicationDelegate implementation. | 133 // ApplicationDelegate implementation. |
| 134 virtual bool ConfigureIncomingConnection( | 134 virtual bool ConfigureIncomingConnection( |
| 135 ApplicationConnection* connection) OVERRIDE { | 135 ApplicationConnection* connection) OVERRIDE { |
| 136 connection->AddService(this); | 136 connection->AddService(this); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 public InterfaceFactory<TestA>, | 325 public InterfaceFactory<TestA>, |
| 326 public InterfaceFactory<TestB>, | 326 public InterfaceFactory<TestB>, |
| 327 public InterfaceFactory<TestC> { | 327 public InterfaceFactory<TestC> { |
| 328 public: | 328 public: |
| 329 Tester(TesterContext* context, const std::string& requestor_url) | 329 Tester(TesterContext* context, const std::string& requestor_url) |
| 330 : context_(context), | 330 : context_(context), |
| 331 requestor_url_(requestor_url) {} | 331 requestor_url_(requestor_url) {} |
| 332 virtual ~Tester() {} | 332 virtual ~Tester() {} |
| 333 | 333 |
| 334 private: | 334 private: |
| 335 virtual void Load(ServiceManager* manager, | 335 virtual void LoadService( |
| 336 const GURL& url, | 336 ServiceManager* manager, |
| 337 scoped_refptr<LoadCallbacks> callbacks) OVERRIDE { | 337 const GURL& url, |
| 338 app_.reset( | 338 ScopedMessagePipeHandle shell_handle) OVERRIDE { |
| 339 new ApplicationImpl(this, callbacks->RegisterApplication().Pass())); | 339 app_.reset(new ApplicationImpl(this, shell_handle.Pass())); |
| 340 } | 340 } |
| 341 | 341 |
| 342 virtual void OnServiceError(ServiceManager* manager, | 342 virtual void OnServiceError(ServiceManager* manager, |
| 343 const GURL& url) OVERRIDE {} | 343 const GURL& url) OVERRIDE {} |
| 344 | 344 |
| 345 virtual bool ConfigureIncomingConnection( | 345 virtual bool ConfigureIncomingConnection( |
| 346 ApplicationConnection* connection) OVERRIDE { | 346 ApplicationConnection* connection) OVERRIDE { |
| 347 if (!requestor_url_.empty() && | 347 if (!requestor_url_.empty() && |
| 348 requestor_url_ != connection->GetRemoteApplicationURL()) { | 348 requestor_url_ != connection->GetRemoteApplicationURL()) { |
| 349 context_->set_tester_called_quit(); | 349 context_->set_tester_called_quit(); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 std::string url("test:test3"); | 641 std::string url("test:test3"); |
| 642 TestServicePtr test_service; | 642 TestServicePtr test_service; |
| 643 service_manager_->ConnectToService(GURL(url), &test_service); | 643 service_manager_->ConnectToService(GURL(url), &test_service); |
| 644 | 644 |
| 645 EXPECT_EQ(1, interceptor.call_count()); | 645 EXPECT_EQ(1, interceptor.call_count()); |
| 646 EXPECT_EQ(url, interceptor.url_spec()); | 646 EXPECT_EQ(url, interceptor.url_spec()); |
| 647 EXPECT_EQ(1, default_loader->num_loads()); | 647 EXPECT_EQ(1, default_loader->num_loads()); |
| 648 } | 648 } |
| 649 | 649 |
| 650 } // namespace mojo | 650 } // namespace mojo |
| OLD | NEW |