Chromium Code Reviews| 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" |
| 11 #include "mojo/public/cpp/application/application_delegate.h" | 11 #include "mojo/public/cpp/application/application_delegate.h" |
| 12 #include "mojo/public/cpp/application/application_impl.h" | 12 #include "mojo/public/cpp/application/application_impl.h" |
| 13 #include "mojo/public/cpp/application/interface_factory.h" | 13 #include "mojo/public/cpp/application/interface_factory.h" |
| 14 #include "mojo/public/cpp/bindings/strong_binding.h" | 14 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 15 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 15 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
| 16 #include "shell/application_manager/application_loader.h" | 16 #include "shell/application_manager/application_loader.h" |
| 17 #include "shell/application_manager/application_manager.h" | 17 #include "shell/application_manager/application_manager.h" |
| 18 #include "shell/application_manager/test.mojom.h" | 18 #include "shell/application_manager/test.mojom.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 21 namespace mojo { | |
| 22 namespace shell { | 21 namespace shell { |
| 23 namespace { | 22 namespace { |
| 24 | 23 |
| 25 const char kTestURLString[] = "test:testService"; | 24 const char kTestURLString[] = "test:testService"; |
| 26 const char kTestAURLString[] = "test:TestA"; | 25 const char kTestAURLString[] = "test:TestA"; |
| 27 const char kTestBURLString[] = "test:TestB"; | 26 const char kTestBURLString[] = "test:TestB"; |
| 28 | 27 |
| 29 struct TestContext { | 28 struct TestContext { |
| 30 TestContext() : num_impls(0), num_loader_deletes(0) {} | 29 TestContext() : num_impls(0), num_loader_deletes(0) {} |
| 31 std::string last_test_string; | 30 std::string last_test_string; |
| 32 int num_impls; | 31 int num_impls; |
| 33 int num_loader_deletes; | 32 int num_loader_deletes; |
| 34 }; | 33 }; |
| 35 | 34 |
| 36 void QuitClosure(bool* value) { | 35 void QuitClosure(bool* value) { |
| 37 *value = true; | 36 *value = true; |
| 38 base::MessageLoop::current()->QuitWhenIdle(); | 37 base::MessageLoop::current()->QuitWhenIdle(); |
| 39 } | 38 } |
| 40 | 39 |
| 41 class QuitMessageLoopErrorHandler : public ErrorHandler { | 40 class QuitMessageLoopErrorHandler : public mojo::ErrorHandler { |
| 42 public: | 41 public: |
| 43 QuitMessageLoopErrorHandler() {} | 42 QuitMessageLoopErrorHandler() {} |
| 44 ~QuitMessageLoopErrorHandler() override {} | 43 ~QuitMessageLoopErrorHandler() override {} |
| 45 | 44 |
| 46 // |ErrorHandler| implementation: | 45 // |mojo::ErrorHandler| implementation: |
| 47 void OnConnectionError() override { | 46 void OnConnectionError() override { |
| 48 base::MessageLoop::current()->QuitWhenIdle(); | 47 base::MessageLoop::current()->QuitWhenIdle(); |
| 49 } | 48 } |
| 50 | 49 |
| 51 private: | 50 private: |
| 52 DISALLOW_COPY_AND_ASSIGN(QuitMessageLoopErrorHandler); | 51 DISALLOW_COPY_AND_ASSIGN(QuitMessageLoopErrorHandler); |
| 53 }; | 52 }; |
| 54 | 53 |
| 55 class TestServiceImpl : public TestService { | 54 class TestServiceImpl : public TestService { |
| 56 public: | 55 public: |
| 57 TestServiceImpl(TestContext* context, InterfaceRequest<TestService> request) | 56 TestServiceImpl(TestContext* context, |
| 57 mojo::InterfaceRequest<TestService> request) | |
| 58 : context_(context), binding_(this, request.Pass()) { | 58 : context_(context), binding_(this, request.Pass()) { |
| 59 ++context_->num_impls; | 59 ++context_->num_impls; |
| 60 } | 60 } |
| 61 | 61 |
| 62 ~TestServiceImpl() override { | 62 ~TestServiceImpl() override { |
| 63 --context_->num_impls; | 63 --context_->num_impls; |
| 64 if (!base::MessageLoop::current()->is_running()) | 64 if (!base::MessageLoop::current()->is_running()) |
| 65 return; | 65 return; |
| 66 base::MessageLoop::current()->Quit(); | 66 base::MessageLoop::current()->Quit(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 // TestService implementation: | 69 // TestService implementation: |
| 70 void Test(const String& test_string, | 70 void Test(const mojo::String& test_string, |
| 71 const Callback<void()>& callback) override { | 71 const mojo::Callback<void()>& callback) override { |
| 72 context_->last_test_string = test_string; | 72 context_->last_test_string = test_string; |
| 73 callback.Run(); | 73 callback.Run(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 TestContext* context_; | 77 TestContext* context_; |
| 78 StrongBinding<TestService> binding_; | 78 mojo::StrongBinding<TestService> binding_; |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 class TestClient { | 81 class TestClient { |
| 82 public: | 82 public: |
| 83 explicit TestClient(TestServicePtr service) | 83 explicit TestClient(TestServicePtr service) |
| 84 : service_(service.Pass()), quit_after_ack_(false) {} | 84 : service_(service.Pass()), quit_after_ack_(false) {} |
| 85 | 85 |
| 86 void AckTest() { | 86 void AckTest() { |
| 87 if (quit_after_ack_) | 87 if (quit_after_ack_) |
| 88 base::MessageLoop::current()->Quit(); | 88 base::MessageLoop::current()->Quit(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void Test(const std::string& test_string) { | 91 void Test(const std::string& test_string) { |
| 92 quit_after_ack_ = true; | 92 quit_after_ack_ = true; |
| 93 service_->Test(test_string, | 93 service_->Test(test_string, |
| 94 base::Bind(&TestClient::AckTest, base::Unretained(this))); | 94 base::Bind(&TestClient::AckTest, base::Unretained(this))); |
| 95 } | 95 } |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 TestServicePtr service_; | 98 TestServicePtr service_; |
| 99 bool quit_after_ack_; | 99 bool quit_after_ack_; |
| 100 DISALLOW_COPY_AND_ASSIGN(TestClient); | 100 DISALLOW_COPY_AND_ASSIGN(TestClient); |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 class TestApplicationLoader : public ApplicationLoader, | 103 class TestApplicationLoader : public ApplicationLoader, |
| 104 public ApplicationDelegate, | 104 public mojo::ApplicationDelegate, |
| 105 public InterfaceFactory<TestService> { | 105 public mojo::InterfaceFactory<TestService> { |
| 106 public: | 106 public: |
| 107 TestApplicationLoader() : context_(nullptr), num_loads_(0) {} | 107 TestApplicationLoader() : context_(nullptr), num_loads_(0) {} |
| 108 | 108 |
| 109 ~TestApplicationLoader() override { | 109 ~TestApplicationLoader() override { |
| 110 if (context_) | 110 if (context_) |
| 111 ++context_->num_loader_deletes; | 111 ++context_->num_loader_deletes; |
| 112 test_app_.reset(); | 112 test_app_.reset(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void set_context(TestContext* context) { context_ = context; } | 115 void set_context(TestContext* context) { context_ = context; } |
| 116 int num_loads() const { return num_loads_; } | 116 int num_loads() const { return num_loads_; } |
| 117 const std::vector<std::string>& GetArgs() const { return test_app_->args(); } | 117 const std::vector<std::string>& GetArgs() const { return test_app_->args(); } |
| 118 | 118 |
| 119 private: | 119 private: |
| 120 // ApplicationLoader implementation. | 120 // ApplicationLoader implementation. |
| 121 void Load(const GURL& url, | 121 void Load( |
| 122 InterfaceRequest<Application> application_request) override { | 122 const GURL& url, |
| 123 mojo::InterfaceRequest<mojo::Application> application_request) override { | |
| 123 ++num_loads_; | 124 ++num_loads_; |
| 124 test_app_.reset(new ApplicationImpl(this, application_request.Pass())); | 125 test_app_.reset( |
| 126 new mojo::ApplicationImpl(this, application_request.Pass())); | |
| 125 } | 127 } |
| 126 | 128 |
| 127 // ApplicationDelegate implementation. | 129 // mojo::ApplicationDelegate implementation. |
| 128 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { | 130 bool ConfigureIncomingConnection( |
| 131 mojo::ApplicationConnection* connection) override { | |
| 129 connection->AddService(this); | 132 connection->AddService(this); |
| 130 return true; | 133 return true; |
| 131 } | 134 } |
| 132 | 135 |
| 133 // InterfaceFactory implementation. | 136 // mojo::InterfaceFactory implementation. |
| 134 void Create(ApplicationConnection* connection, | 137 void Create(mojo::ApplicationConnection* connection, |
| 135 InterfaceRequest<TestService> request) override { | 138 mojo::InterfaceRequest<TestService> request) override { |
| 136 new TestServiceImpl(context_, request.Pass()); | 139 new TestServiceImpl(context_, request.Pass()); |
| 137 } | 140 } |
| 138 | 141 |
| 139 scoped_ptr<ApplicationImpl> test_app_; | 142 scoped_ptr<mojo::ApplicationImpl> test_app_; |
| 140 TestContext* context_; | 143 TestContext* context_; |
| 141 int num_loads_; | 144 int num_loads_; |
| 142 DISALLOW_COPY_AND_ASSIGN(TestApplicationLoader); | 145 DISALLOW_COPY_AND_ASSIGN(TestApplicationLoader); |
| 143 }; | 146 }; |
| 144 | 147 |
| 145 class ClosingApplicationLoader : public ApplicationLoader { | 148 class ClosingApplicationLoader : public ApplicationLoader { |
| 146 private: | 149 private: |
| 147 // ApplicationLoader implementation. | 150 // ApplicationLoader implementation. |
| 148 void Load(const GURL& url, | 151 void Load( |
| 149 InterfaceRequest<Application> application_request) override {} | 152 const GURL& url, |
| 153 mojo::InterfaceRequest<mojo::Application> application_request) override {} | |
| 150 }; | 154 }; |
| 151 | 155 |
| 152 class TesterContext { | 156 class TesterContext { |
| 153 public: | 157 public: |
| 154 explicit TesterContext(base::MessageLoop* loop) | 158 explicit TesterContext(base::MessageLoop* loop) |
| 155 : num_b_calls_(0), | 159 : num_b_calls_(0), |
| 156 num_c_calls_(0), | 160 num_c_calls_(0), |
| 157 num_a_deletes_(0), | 161 num_a_deletes_(0), |
| 158 num_b_deletes_(0), | 162 num_b_deletes_(0), |
| 159 num_c_deletes_(0), | 163 num_c_deletes_(0), |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 int num_c_deletes_; | 244 int num_c_deletes_; |
| 241 bool tester_called_quit_; | 245 bool tester_called_quit_; |
| 242 bool a_called_quit_; | 246 bool a_called_quit_; |
| 243 | 247 |
| 244 base::MessageLoop* loop_; | 248 base::MessageLoop* loop_; |
| 245 }; | 249 }; |
| 246 | 250 |
| 247 // Used to test that the requestor url will be correctly passed. | 251 // Used to test that the requestor url will be correctly passed. |
| 248 class TestAImpl : public TestA { | 252 class TestAImpl : public TestA { |
| 249 public: | 253 public: |
| 250 TestAImpl(ApplicationImpl* app_impl, | 254 TestAImpl(mojo::ApplicationImpl* app_impl, |
| 251 TesterContext* test_context, | 255 TesterContext* test_context, |
| 252 InterfaceRequest<TestA> request) | 256 mojo::InterfaceRequest<TestA> request) |
| 253 : test_context_(test_context), binding_(this, request.Pass()) { | 257 : test_context_(test_context), binding_(this, request.Pass()) { |
| 254 app_impl->ConnectToApplication(kTestBURLString)->ConnectToService(&b_); | 258 app_impl->ConnectToApplication(kTestBURLString)->ConnectToService(&b_); |
| 255 } | 259 } |
| 256 | 260 |
| 257 ~TestAImpl() override { | 261 ~TestAImpl() override { |
| 258 test_context_->IncrementNumADeletes(); | 262 test_context_->IncrementNumADeletes(); |
| 259 if (base::MessageLoop::current()->is_running()) | 263 if (base::MessageLoop::current()->is_running()) |
| 260 Quit(); | 264 Quit(); |
| 261 } | 265 } |
| 262 | 266 |
| 263 private: | 267 private: |
| 264 void CallB() override { | 268 void CallB() override { |
| 265 b_->B(base::Bind(&TestAImpl::Quit, base::Unretained(this))); | 269 b_->B(base::Bind(&TestAImpl::Quit, base::Unretained(this))); |
| 266 } | 270 } |
| 267 | 271 |
| 268 void CallCFromB() override { | 272 void CallCFromB() override { |
| 269 b_->CallC(base::Bind(&TestAImpl::Quit, base::Unretained(this))); | 273 b_->CallC(base::Bind(&TestAImpl::Quit, base::Unretained(this))); |
| 270 } | 274 } |
| 271 | 275 |
| 272 void Quit() { | 276 void Quit() { |
| 273 base::MessageLoop::current()->Quit(); | 277 base::MessageLoop::current()->Quit(); |
| 274 test_context_->set_a_called_quit(); | 278 test_context_->set_a_called_quit(); |
| 275 test_context_->QuitSoon(); | 279 test_context_->QuitSoon(); |
| 276 } | 280 } |
| 277 | 281 |
| 278 TesterContext* test_context_; | 282 TesterContext* test_context_; |
| 279 TestBPtr b_; | 283 TestBPtr b_; |
| 280 StrongBinding<TestA> binding_; | 284 mojo::StrongBinding<TestA> binding_; |
| 281 }; | 285 }; |
| 282 | 286 |
| 283 class TestBImpl : public TestB { | 287 class TestBImpl : public TestB { |
| 284 public: | 288 public: |
| 285 TestBImpl(ApplicationConnection* connection, | 289 TestBImpl(mojo::ApplicationConnection* connection, |
| 286 TesterContext* test_context, | 290 TesterContext* test_context, |
| 287 InterfaceRequest<TestB> request) | 291 mojo::InterfaceRequest<TestB> request) |
| 288 : test_context_(test_context), binding_(this, request.Pass()) { | 292 : test_context_(test_context), binding_(this, request.Pass()) { |
| 289 connection->ConnectToService(&c_); | 293 connection->ConnectToService(&c_); |
| 290 } | 294 } |
| 291 | 295 |
| 292 ~TestBImpl() override { | 296 ~TestBImpl() override { |
| 293 test_context_->IncrementNumBDeletes(); | 297 test_context_->IncrementNumBDeletes(); |
| 294 if (base::MessageLoop::current()->is_running()) | 298 if (base::MessageLoop::current()->is_running()) |
| 295 base::MessageLoop::current()->Quit(); | 299 base::MessageLoop::current()->Quit(); |
| 296 test_context_->QuitSoon(); | 300 test_context_->QuitSoon(); |
| 297 } | 301 } |
| 298 | 302 |
| 299 private: | 303 private: |
| 300 void B(const Callback<void()>& callback) override { | 304 void B(const mojo::Callback<void()>& callback) override { |
|
jamesr
2015/04/09 19:39:25
this file would probably benefit from some using s
| |
| 301 test_context_->IncrementNumBCalls(); | 305 test_context_->IncrementNumBCalls(); |
| 302 callback.Run(); | 306 callback.Run(); |
| 303 } | 307 } |
| 304 | 308 |
| 305 void CallC(const Callback<void()>& callback) override { | 309 void CallC(const mojo::Callback<void()>& callback) override { |
| 306 test_context_->IncrementNumBCalls(); | 310 test_context_->IncrementNumBCalls(); |
| 307 c_->C(callback); | 311 c_->C(callback); |
| 308 } | 312 } |
| 309 | 313 |
| 310 TesterContext* test_context_; | 314 TesterContext* test_context_; |
| 311 TestCPtr c_; | 315 TestCPtr c_; |
| 312 StrongBinding<TestB> binding_; | 316 mojo::StrongBinding<TestB> binding_; |
| 313 }; | 317 }; |
| 314 | 318 |
| 315 class TestCImpl : public TestC { | 319 class TestCImpl : public TestC { |
| 316 public: | 320 public: |
| 317 TestCImpl(ApplicationConnection* connection, | 321 TestCImpl(mojo::ApplicationConnection* connection, |
| 318 TesterContext* test_context, | 322 TesterContext* test_context, |
| 319 InterfaceRequest<TestC> request) | 323 mojo::InterfaceRequest<TestC> request) |
| 320 : test_context_(test_context), binding_(this, request.Pass()) {} | 324 : test_context_(test_context), binding_(this, request.Pass()) {} |
| 321 | 325 |
| 322 ~TestCImpl() override { test_context_->IncrementNumCDeletes(); } | 326 ~TestCImpl() override { test_context_->IncrementNumCDeletes(); } |
| 323 | 327 |
| 324 private: | 328 private: |
| 325 void C(const Callback<void()>& callback) override { | 329 void C(const mojo::Callback<void()>& callback) override { |
| 326 test_context_->IncrementNumCCalls(); | 330 test_context_->IncrementNumCCalls(); |
| 327 callback.Run(); | 331 callback.Run(); |
| 328 } | 332 } |
| 329 | 333 |
| 330 TesterContext* test_context_; | 334 TesterContext* test_context_; |
| 331 StrongBinding<TestC> binding_; | 335 mojo::StrongBinding<TestC> binding_; |
| 332 }; | 336 }; |
| 333 | 337 |
| 334 class Tester : public ApplicationDelegate, | 338 class Tester : public mojo::ApplicationDelegate, |
| 335 public ApplicationLoader, | 339 public ApplicationLoader, |
| 336 public InterfaceFactory<TestA>, | 340 public mojo::InterfaceFactory<TestA>, |
| 337 public InterfaceFactory<TestB>, | 341 public mojo::InterfaceFactory<TestB>, |
| 338 public InterfaceFactory<TestC> { | 342 public mojo::InterfaceFactory<TestC> { |
| 339 public: | 343 public: |
| 340 Tester(TesterContext* context, const std::string& requestor_url) | 344 Tester(TesterContext* context, const std::string& requestor_url) |
| 341 : context_(context), requestor_url_(requestor_url) {} | 345 : context_(context), requestor_url_(requestor_url) {} |
| 342 ~Tester() override {} | 346 ~Tester() override {} |
| 343 | 347 |
| 344 private: | 348 private: |
| 345 void Load(const GURL& url, | 349 void Load( |
| 346 InterfaceRequest<Application> application_request) override { | 350 const GURL& url, |
| 347 app_.reset(new ApplicationImpl(this, application_request.Pass())); | 351 mojo::InterfaceRequest<mojo::Application> application_request) override { |
| 352 app_.reset(new mojo::ApplicationImpl(this, application_request.Pass())); | |
| 348 } | 353 } |
| 349 | 354 |
| 350 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { | 355 bool ConfigureIncomingConnection( |
| 356 mojo::ApplicationConnection* connection) override { | |
| 351 if (!requestor_url_.empty() && | 357 if (!requestor_url_.empty() && |
| 352 requestor_url_ != connection->GetRemoteApplicationURL()) { | 358 requestor_url_ != connection->GetRemoteApplicationURL()) { |
| 353 context_->set_tester_called_quit(); | 359 context_->set_tester_called_quit(); |
| 354 context_->QuitSoon(); | 360 context_->QuitSoon(); |
| 355 base::MessageLoop::current()->Quit(); | 361 base::MessageLoop::current()->Quit(); |
| 356 return false; | 362 return false; |
| 357 } | 363 } |
| 358 // If we're coming from A, then add B, otherwise A. | 364 // If we're coming from A, then add B, otherwise A. |
| 359 if (connection->GetRemoteApplicationURL() == kTestAURLString) | 365 if (connection->GetRemoteApplicationURL() == kTestAURLString) |
| 360 connection->AddService<TestB>(this); | 366 connection->AddService<TestB>(this); |
| 361 else | 367 else |
| 362 connection->AddService<TestA>(this); | 368 connection->AddService<TestA>(this); |
| 363 return true; | 369 return true; |
| 364 } | 370 } |
| 365 | 371 |
| 366 bool ConfigureOutgoingConnection(ApplicationConnection* connection) override { | 372 bool ConfigureOutgoingConnection( |
| 373 mojo::ApplicationConnection* connection) override { | |
| 367 // If we're connecting to B, then add C. | 374 // If we're connecting to B, then add C. |
| 368 if (connection->GetRemoteApplicationURL() == kTestBURLString) | 375 if (connection->GetRemoteApplicationURL() == kTestBURLString) |
| 369 connection->AddService<TestC>(this); | 376 connection->AddService<TestC>(this); |
| 370 return true; | 377 return true; |
| 371 } | 378 } |
| 372 | 379 |
| 373 void Create(ApplicationConnection* connection, | 380 void Create(mojo::ApplicationConnection* connection, |
| 374 InterfaceRequest<TestA> request) override { | 381 mojo::InterfaceRequest<TestA> request) override { |
| 375 a_bindings_.push_back(new TestAImpl(app_.get(), context_, request.Pass())); | 382 a_bindings_.push_back(new TestAImpl(app_.get(), context_, request.Pass())); |
| 376 } | 383 } |
| 377 | 384 |
| 378 void Create(ApplicationConnection* connection, | 385 void Create(mojo::ApplicationConnection* connection, |
| 379 InterfaceRequest<TestB> request) override { | 386 mojo::InterfaceRequest<TestB> request) override { |
| 380 new TestBImpl(connection, context_, request.Pass()); | 387 new TestBImpl(connection, context_, request.Pass()); |
| 381 } | 388 } |
| 382 | 389 |
| 383 void Create(ApplicationConnection* connection, | 390 void Create(mojo::ApplicationConnection* connection, |
| 384 InterfaceRequest<TestC> request) override { | 391 mojo::InterfaceRequest<TestC> request) override { |
| 385 new TestCImpl(connection, context_, request.Pass()); | 392 new TestCImpl(connection, context_, request.Pass()); |
| 386 } | 393 } |
| 387 | 394 |
| 388 TesterContext* context_; | 395 TesterContext* context_; |
| 389 scoped_ptr<ApplicationImpl> app_; | 396 scoped_ptr<mojo::ApplicationImpl> app_; |
| 390 std::string requestor_url_; | 397 std::string requestor_url_; |
| 391 ScopedVector<TestAImpl> a_bindings_; | 398 ScopedVector<TestAImpl> a_bindings_; |
| 392 }; | 399 }; |
| 393 | 400 |
| 394 class TestDelegate : public ApplicationManager::Delegate { | 401 class TestDelegate : public ApplicationManager::Delegate { |
| 395 public: | 402 public: |
| 396 void AddMapping(const GURL& from, const GURL& to) { mappings_[from] = to; } | 403 void AddMapping(const GURL& from, const GURL& to) { mappings_[from] = to; } |
| 397 | 404 |
| 398 // ApplicationManager::Delegate | 405 // ApplicationManager::Delegate |
| 399 GURL ResolveMappings(const GURL& url) override { | 406 GURL ResolveMappings(const GURL& url) override { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 412 replacements.SetScheme("file", url::Component(0, 4)); | 419 replacements.SetScheme("file", url::Component(0, 4)); |
| 413 mapped_url = mapped_url.ReplaceComponents(replacements); | 420 mapped_url = mapped_url.ReplaceComponents(replacements); |
| 414 } | 421 } |
| 415 return mapped_url; | 422 return mapped_url; |
| 416 } | 423 } |
| 417 | 424 |
| 418 private: | 425 private: |
| 419 std::map<GURL, GURL> mappings_; | 426 std::map<GURL, GURL> mappings_; |
| 420 }; | 427 }; |
| 421 | 428 |
| 422 class TestExternal : public ApplicationDelegate { | 429 class TestExternal : public mojo::ApplicationDelegate { |
| 423 public: | 430 public: |
| 424 TestExternal() : configure_incoming_connection_called_(false) {} | 431 TestExternal() : configure_incoming_connection_called_(false) {} |
| 425 | 432 |
| 426 void Initialize(ApplicationImpl* app) override { | 433 void Initialize(mojo::ApplicationImpl* app) override { |
| 427 initialize_args_ = app->args(); | 434 initialize_args_ = app->args(); |
| 428 base::MessageLoop::current()->Quit(); | 435 base::MessageLoop::current()->Quit(); |
| 429 } | 436 } |
| 430 | 437 |
| 431 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { | 438 bool ConfigureIncomingConnection( |
| 439 mojo::ApplicationConnection* connection) override { | |
| 432 configure_incoming_connection_called_ = true; | 440 configure_incoming_connection_called_ = true; |
| 433 base::MessageLoop::current()->Quit(); | 441 base::MessageLoop::current()->Quit(); |
| 434 return true; | 442 return true; |
| 435 } | 443 } |
| 436 | 444 |
| 437 const std::vector<std::string>& initialize_args() const { | 445 const std::vector<std::string>& initialize_args() const { |
| 438 return initialize_args_; | 446 return initialize_args_; |
| 439 } | 447 } |
| 440 | 448 |
| 441 bool configure_incoming_connection_called() const { | 449 bool configure_incoming_connection_called() const { |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 803 bool called = false; | 811 bool called = false; |
| 804 application_manager_->ConnectToApplication( | 812 application_manager_->ConnectToApplication( |
| 805 GURL("test:test"), GURL(), nullptr, nullptr, | 813 GURL("test:test"), GURL(), nullptr, nullptr, |
| 806 base::Bind(&QuitClosure, base::Unretained(&called))); | 814 base::Bind(&QuitClosure, base::Unretained(&called))); |
| 807 loop_.Run(); | 815 loop_.Run(); |
| 808 EXPECT_TRUE(called); | 816 EXPECT_TRUE(called); |
| 809 } | 817 } |
| 810 | 818 |
| 811 } // namespace | 819 } // namespace |
| 812 } // namespace shell | 820 } // namespace shell |
| 813 } // namespace mojo | |
| OLD | NEW |