| 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> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "mojo/shell/public/cpp/application_connection.h" | 10 #include "mojo/shell/public/cpp/connection.h" |
| 11 #include "mojo/shell/public/cpp/shell.h" | 11 #include "mojo/shell/public/cpp/shell.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 const char kTestMojoAppUrl[] = "system:content_mojo_test"; | 15 const char kTestMojoAppUrl[] = "system:content_mojo_test"; |
| 16 | 16 |
| 17 TestMojoApp::TestMojoApp() : service_binding_(this), shell_(nullptr) { | 17 TestMojoApp::TestMojoApp() : service_binding_(this), shell_(nullptr) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 TestMojoApp::~TestMojoApp() { | 20 TestMojoApp::~TestMojoApp() { |
| 21 } | 21 } |
| 22 | 22 |
| 23 void TestMojoApp::Initialize(mojo::Shell* shell, const std::string& url, | 23 void TestMojoApp::Initialize(mojo::Shell* shell, const std::string& url, |
| 24 uint32_t id) { | 24 uint32_t id) { |
| 25 shell_ = shell; | 25 shell_ = shell; |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool TestMojoApp::AcceptConnection( | 28 bool TestMojoApp::AcceptConnection(mojo::Connection* connection) { |
| 29 mojo::ApplicationConnection* connection) { | |
| 30 requestor_url_ = GURL(connection->GetRemoteApplicationURL()); | 29 requestor_url_ = GURL(connection->GetRemoteApplicationURL()); |
| 31 connection->AddService<TestMojoService>(this); | 30 connection->AddService<TestMojoService>(this); |
| 32 return true; | 31 return true; |
| 33 } | 32 } |
| 34 | 33 |
| 35 void TestMojoApp::Create(mojo::ApplicationConnection* connection, | 34 void TestMojoApp::Create(mojo::Connection* connection, |
| 36 mojo::InterfaceRequest<TestMojoService> request) { | 35 mojo::InterfaceRequest<TestMojoService> request) { |
| 37 DCHECK(!service_binding_.is_bound()); | 36 DCHECK(!service_binding_.is_bound()); |
| 38 service_binding_.Bind(std::move(request)); | 37 service_binding_.Bind(std::move(request)); |
| 39 } | 38 } |
| 40 | 39 |
| 41 void TestMojoApp::DoSomething(const DoSomethingCallback& callback) { | 40 void TestMojoApp::DoSomething(const DoSomethingCallback& callback) { |
| 42 callback.Run(); | 41 callback.Run(); |
| 43 DCHECK(shell_); | 42 DCHECK(shell_); |
| 44 shell_->Quit(); | 43 shell_->Quit(); |
| 45 } | 44 } |
| 46 | 45 |
| 47 void TestMojoApp::GetRequestorURL(const GetRequestorURLCallback& callback) { | 46 void TestMojoApp::GetRequestorURL(const GetRequestorURLCallback& callback) { |
| 48 callback.Run(requestor_url_.spec()); | 47 callback.Run(requestor_url_.spec()); |
| 49 } | 48 } |
| 50 | 49 |
| 51 } // namespace content | 50 } // namespace content |
| OLD | NEW |