| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 LoadService( | 121 virtual void LoadService( |
| 122 ServiceManager* manager, | 122 ServiceManager* manager, |
| 123 const GURL& url, | 123 const GURL& url, |
| 124 ScopedMessagePipeHandle service_provider_handle) OVERRIDE { | 124 scoped_refptr<LoadServiceCallbacks> callbacks) OVERRIDE { |
| 125 ++num_loads_; | 125 ++num_loads_; |
| 126 test_app_.reset(new ApplicationImpl(this, service_provider_handle.Pass())); | 126 test_app_.reset( |
| 127 new ApplicationImpl(this, callbacks->RegisterApplication().Pass())); |
| 127 } | 128 } |
| 128 | 129 |
| 129 virtual void OnServiceError(ServiceManager* manager, | 130 virtual void OnServiceError(ServiceManager* manager, |
| 130 const GURL& url) OVERRIDE { | 131 const GURL& url) OVERRIDE { |
| 131 } | 132 } |
| 132 | 133 |
| 133 // ApplicationDelegate implementation. | 134 // ApplicationDelegate implementation. |
| 134 virtual bool ConfigureIncomingConnection( | 135 virtual bool ConfigureIncomingConnection( |
| 135 ApplicationConnection* connection) OVERRIDE { | 136 ApplicationConnection* connection) OVERRIDE { |
| 136 connection->AddService(this); | 137 connection->AddService(this); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 public: | 329 public: |
| 329 Tester(TesterContext* context, const std::string& requestor_url) | 330 Tester(TesterContext* context, const std::string& requestor_url) |
| 330 : context_(context), | 331 : context_(context), |
| 331 requestor_url_(requestor_url) {} | 332 requestor_url_(requestor_url) {} |
| 332 virtual ~Tester() {} | 333 virtual ~Tester() {} |
| 333 | 334 |
| 334 private: | 335 private: |
| 335 virtual void LoadService( | 336 virtual void LoadService( |
| 336 ServiceManager* manager, | 337 ServiceManager* manager, |
| 337 const GURL& url, | 338 const GURL& url, |
| 338 ScopedMessagePipeHandle shell_handle) OVERRIDE { | 339 scoped_refptr<LoadServiceCallbacks> callbacks) OVERRIDE { |
| 339 app_.reset(new ApplicationImpl(this, shell_handle.Pass())); | 340 app_.reset( |
| 341 new ApplicationImpl(this, callbacks->RegisterApplication().Pass())); |
| 340 } | 342 } |
| 341 | 343 |
| 342 virtual void OnServiceError(ServiceManager* manager, | 344 virtual void OnServiceError(ServiceManager* manager, |
| 343 const GURL& url) OVERRIDE {} | 345 const GURL& url) OVERRIDE {} |
| 344 | 346 |
| 345 virtual bool ConfigureIncomingConnection( | 347 virtual bool ConfigureIncomingConnection( |
| 346 ApplicationConnection* connection) OVERRIDE { | 348 ApplicationConnection* connection) OVERRIDE { |
| 347 if (!requestor_url_.empty() && | 349 if (!requestor_url_.empty() && |
| 348 requestor_url_ != connection->GetRemoteApplicationURL()) { | 350 requestor_url_ != connection->GetRemoteApplicationURL()) { |
| 349 context_->set_tester_called_quit(); | 351 context_->set_tester_called_quit(); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 std::string url("test:test3"); | 650 std::string url("test:test3"); |
| 649 TestServicePtr test_service; | 651 TestServicePtr test_service; |
| 650 service_manager_->ConnectToService(GURL(url), &test_service); | 652 service_manager_->ConnectToService(GURL(url), &test_service); |
| 651 | 653 |
| 652 EXPECT_EQ(1, interceptor.call_count()); | 654 EXPECT_EQ(1, interceptor.call_count()); |
| 653 EXPECT_EQ(url, interceptor.url_spec()); | 655 EXPECT_EQ(url, interceptor.url_spec()); |
| 654 EXPECT_EQ(1, default_loader->num_loads()); | 656 EXPECT_EQ(1, default_loader->num_loads()); |
| 655 } | 657 } |
| 656 | 658 |
| 657 } // namespace mojo | 659 } // namespace mojo |
| OLD | NEW |