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/public/cpp/application/application_connection.h" | 10 #include "mojo/public/cpp/application/application_connection.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 std::vector<std::string>& GetArgs() const { return test_app_->args(); } | 112 const std::vector<std::string>& GetArgs() const { return test_app_->args(); } |
113 | 113 |
114 private: | 114 private: |
115 // ApplicationLoader implementation. | 115 // ApplicationLoader implementation. |
116 void Load(ApplicationManager* manager, | 116 void Load(ApplicationManager* manager, |
117 const GURL& url, | 117 const GURL& url, |
118 ScopedMessagePipeHandle shell_handle, | 118 ShellPtr shell, |
119 LoadCallback callback) override { | 119 LoadCallback callback) override { |
120 ++num_loads_; | 120 ++num_loads_; |
121 test_app_.reset(new ApplicationImpl(this, shell_handle.Pass())); | 121 test_app_.reset(new ApplicationImpl(this, shell.Pass())); |
122 } | 122 } |
123 | 123 |
124 void OnApplicationError(ApplicationManager* manager, | 124 void OnApplicationError(ApplicationManager* manager, |
125 const GURL& url) override {} | 125 const GURL& url) override {} |
126 | 126 |
127 // ApplicationDelegate implementation. | 127 // ApplicationDelegate implementation. |
128 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { | 128 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { |
129 connection->AddService(this); | 129 connection->AddService(this); |
130 return true; | 130 return true; |
131 } | 131 } |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 public InterfaceFactory<TestB>, | 323 public InterfaceFactory<TestB>, |
324 public InterfaceFactory<TestC> { | 324 public InterfaceFactory<TestC> { |
325 public: | 325 public: |
326 Tester(TesterContext* context, const std::string& requestor_url) | 326 Tester(TesterContext* context, const std::string& requestor_url) |
327 : context_(context), requestor_url_(requestor_url) {} | 327 : context_(context), requestor_url_(requestor_url) {} |
328 ~Tester() override {} | 328 ~Tester() override {} |
329 | 329 |
330 private: | 330 private: |
331 void Load(ApplicationManager* manager, | 331 void Load(ApplicationManager* manager, |
332 const GURL& url, | 332 const GURL& url, |
333 ScopedMessagePipeHandle shell_handle, | 333 ShellPtr shell, |
334 LoadCallback callback) override { | 334 LoadCallback callback) override { |
335 app_.reset(new ApplicationImpl(this, shell_handle.Pass())); | 335 app_.reset(new ApplicationImpl(this, shell.Pass())); |
336 } | 336 } |
337 | 337 |
338 void OnApplicationError(ApplicationManager* manager, | 338 void OnApplicationError(ApplicationManager* manager, |
339 const GURL& url) override {} | 339 const GURL& url) override {} |
340 | 340 |
341 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { | 341 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { |
342 if (!requestor_url_.empty() && | 342 if (!requestor_url_.empty() && |
343 requestor_url_ != connection->GetRemoteApplicationURL()) { | 343 requestor_url_ != connection->GetRemoteApplicationURL()) { |
344 context_->set_tester_called_quit(); | 344 context_->set_tester_called_quit(); |
345 context_->QuitSoon(); | 345 context_->QuitSoon(); |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 GURL("mojo:foo")); | 690 GURL("mojo:foo")); |
691 test_delegate_.AddMapping(GURL("mojo:foo2"), GURL("mojo:foo")); | 691 test_delegate_.AddMapping(GURL("mojo:foo2"), GURL("mojo:foo")); |
692 | 692 |
693 TestServicePtr test_service; | 693 TestServicePtr test_service; |
694 application_manager_->ConnectToService(GURL("mojo:foo2"), &test_service); | 694 application_manager_->ConnectToService(GURL("mojo:foo2"), &test_service); |
695 EXPECT_EQ(1, custom_loader->num_loads()); | 695 EXPECT_EQ(1, custom_loader->num_loads()); |
696 custom_loader->set_context(nullptr); | 696 custom_loader->set_context(nullptr); |
697 } | 697 } |
698 | 698 |
699 } // namespace mojo | 699 } // namespace mojo |
OLD | NEW |