| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/public/test/test_mojo_app.h" | 5 #include "content/public/test/test_mojo_app.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "mojo/application/public/cpp/application_connection.h" | 10 #include "mojo/application/public/cpp/application_connection.h" |
| 9 #include "mojo/application/public/cpp/application_impl.h" | 11 #include "mojo/application/public/cpp/application_impl.h" |
| 10 | 12 |
| 11 namespace content { | 13 namespace content { |
| 12 | 14 |
| 13 const char kTestMojoAppUrl[] = "system:content_mojo_test"; | 15 const char kTestMojoAppUrl[] = "system:content_mojo_test"; |
| 14 | 16 |
| 15 TestMojoApp::TestMojoApp() : service_binding_(this), app_(nullptr) { | 17 TestMojoApp::TestMojoApp() : service_binding_(this), app_(nullptr) { |
| 16 } | 18 } |
| 17 | 19 |
| 18 TestMojoApp::~TestMojoApp() { | 20 TestMojoApp::~TestMojoApp() { |
| 19 } | 21 } |
| 20 | 22 |
| 21 void TestMojoApp::Initialize(mojo::ApplicationImpl* app) { | 23 void TestMojoApp::Initialize(mojo::ApplicationImpl* app) { |
| 22 app_ = app; | 24 app_ = app; |
| 23 } | 25 } |
| 24 | 26 |
| 25 bool TestMojoApp::ConfigureIncomingConnection( | 27 bool TestMojoApp::ConfigureIncomingConnection( |
| 26 mojo::ApplicationConnection* connection) { | 28 mojo::ApplicationConnection* connection) { |
| 27 requestor_url_ = GURL(connection->GetRemoteApplicationURL()); | 29 requestor_url_ = GURL(connection->GetRemoteApplicationURL()); |
| 28 connection->AddService<TestMojoService>(this); | 30 connection->AddService<TestMojoService>(this); |
| 29 return true; | 31 return true; |
| 30 } | 32 } |
| 31 | 33 |
| 32 void TestMojoApp::Create(mojo::ApplicationConnection* connection, | 34 void TestMojoApp::Create(mojo::ApplicationConnection* connection, |
| 33 mojo::InterfaceRequest<TestMojoService> request) { | 35 mojo::InterfaceRequest<TestMojoService> request) { |
| 34 DCHECK(!service_binding_.is_bound()); | 36 DCHECK(!service_binding_.is_bound()); |
| 35 service_binding_.Bind(request.Pass()); | 37 service_binding_.Bind(std::move(request)); |
| 36 } | 38 } |
| 37 | 39 |
| 38 void TestMojoApp::DoSomething(const DoSomethingCallback& callback) { | 40 void TestMojoApp::DoSomething(const DoSomethingCallback& callback) { |
| 39 callback.Run(); | 41 callback.Run(); |
| 40 DCHECK(app_); | 42 DCHECK(app_); |
| 41 app_->Quit(); | 43 app_->Quit(); |
| 42 } | 44 } |
| 43 | 45 |
| 44 void TestMojoApp::GetRequestorURL(const GetRequestorURLCallback& callback) { | 46 void TestMojoApp::GetRequestorURL(const GetRequestorURLCallback& callback) { |
| 45 callback.Run(requestor_url_.spec()); | 47 callback.Run(requestor_url_.spec()); |
| 46 } | 48 } |
| 47 | 49 |
| 48 } // namespace content | 50 } // namespace content |
| OLD | NEW |