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/connection.h" | 10 #include "mojo/shell/public/cpp/connection.h" |
11 #include "mojo/shell/public/cpp/shell.h" | 11 #include "mojo/shell/public/cpp/connector.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) { |
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, | |
24 uint32_t id, uint32_t user_id) { | |
25 shell_ = shell; | |
26 } | |
27 | |
28 bool TestMojoApp::AcceptConnection(mojo::Connection* connection) { | 23 bool TestMojoApp::AcceptConnection(mojo::Connection* connection) { |
29 requestor_url_ = GURL(connection->GetRemoteApplicationURL()); | 24 requestor_url_ = GURL(connection->GetRemoteApplicationURL()); |
30 connection->AddInterface<TestMojoService>(this); | 25 connection->AddInterface<TestMojoService>(this); |
31 return true; | 26 return true; |
32 } | 27 } |
33 | 28 |
34 void TestMojoApp::Create(mojo::Connection* connection, | 29 void TestMojoApp::Create(mojo::Connection* connection, |
35 mojo::InterfaceRequest<TestMojoService> request) { | 30 mojo::InterfaceRequest<TestMojoService> request) { |
36 DCHECK(!service_binding_.is_bound()); | 31 DCHECK(!service_binding_.is_bound()); |
37 service_binding_.Bind(std::move(request)); | 32 service_binding_.Bind(std::move(request)); |
38 } | 33 } |
39 | 34 |
40 void TestMojoApp::DoSomething(const DoSomethingCallback& callback) { | 35 void TestMojoApp::DoSomething(const DoSomethingCallback& callback) { |
41 callback.Run(); | 36 callback.Run(); |
42 DCHECK(shell_); | |
43 shell_->Quit(); | |
44 } | 37 } |
45 | 38 |
46 void TestMojoApp::GetRequestorURL(const GetRequestorURLCallback& callback) { | 39 void TestMojoApp::GetRequestorURL(const GetRequestorURLCallback& callback) { |
47 callback.Run(requestor_url_.spec()); | 40 callback.Run(requestor_url_.spec()); |
48 } | 41 } |
49 | 42 |
50 } // namespace content | 43 } // namespace content |
OLD | NEW |