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/shell/utility/shell_content_utility_client.h" | 5 #include "content/shell/utility/shell_content_utility_client.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/process/process.h" | 12 #include "base/process/process.h" |
13 #include "content/public/test/test_mojo_app.h" | 13 #include "content/public/test/test_service.h" |
14 #include "content/public/test/test_mojo_service.mojom.h" | 14 #include "content/public/test/test_service.mojom.h" |
15 #include "mojo/public/cpp/bindings/strong_binding.h" | 15 #include "mojo/public/cpp/bindings/strong_binding.h" |
16 #include "mojo/public/cpp/system/buffer.h" | 16 #include "mojo/public/cpp/system/buffer.h" |
17 #include "services/shell/public/cpp/interface_registry.h" | 17 #include "services/shell/public/cpp/interface_registry.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 class TestMojoServiceImpl : public mojom::TestMojoService { | 23 class TestServiceImpl : public mojom::TestService { |
24 public: | 24 public: |
25 static void Create(mojo::InterfaceRequest<mojom::TestMojoService> request) { | 25 static void Create(mojom::TestServiceRequest request) { |
26 mojo::MakeStrongBinding(base::WrapUnique(new TestMojoServiceImpl), | 26 mojo::MakeStrongBinding(base::WrapUnique(new TestServiceImpl), |
27 std::move(request)); | 27 std::move(request)); |
28 } | 28 } |
29 | 29 |
30 // mojom::TestMojoService implementation: | 30 // mojom::TestService implementation: |
31 void DoSomething(const DoSomethingCallback& callback) override { | 31 void DoSomething(const DoSomethingCallback& callback) override { |
32 callback.Run(); | 32 callback.Run(); |
33 } | 33 } |
34 | 34 |
35 void DoTerminateProcess(const DoTerminateProcessCallback& callback) override { | 35 void DoTerminateProcess(const DoTerminateProcessCallback& callback) override { |
36 base::Process::Current().Terminate(0, false); | 36 base::Process::Current().Terminate(0, false); |
37 } | 37 } |
38 | 38 |
39 void CreateFolder(const CreateFolderCallback& callback) override { | 39 void CreateFolder(const CreateFolderCallback& callback) override { |
40 // Note: This is used to check if the sandbox is disabled or not since | 40 // Note: This is used to check if the sandbox is disabled or not since |
(...skipping 13 matching lines...) Expand all Loading... |
54 | 54 |
55 mojo::ScopedSharedBufferMapping mapping = buffer->Map(message.size()); | 55 mojo::ScopedSharedBufferMapping mapping = buffer->Map(message.size()); |
56 CHECK(mapping); | 56 CHECK(mapping); |
57 std::copy(message.begin(), message.end(), | 57 std::copy(message.begin(), message.end(), |
58 reinterpret_cast<char*>(mapping.get())); | 58 reinterpret_cast<char*>(mapping.get())); |
59 | 59 |
60 callback.Run(std::move(buffer)); | 60 callback.Run(std::move(buffer)); |
61 } | 61 } |
62 | 62 |
63 private: | 63 private: |
64 explicit TestMojoServiceImpl() {} | 64 explicit TestServiceImpl() {} |
65 | 65 |
66 DISALLOW_COPY_AND_ASSIGN(TestMojoServiceImpl); | 66 DISALLOW_COPY_AND_ASSIGN(TestServiceImpl); |
67 }; | 67 }; |
68 | 68 |
69 std::unique_ptr<shell::Service> CreateTestApp( | 69 std::unique_ptr<shell::Service> CreateTestService( |
70 const base::Closure& quit_closure) { | 70 const base::Closure& quit_closure) { |
71 return std::unique_ptr<shell::Service>(new TestMojoApp); | 71 return std::unique_ptr<shell::Service>(new TestService); |
72 } | 72 } |
73 | 73 |
74 } // namespace | 74 } // namespace |
75 | 75 |
76 ShellContentUtilityClient::~ShellContentUtilityClient() { | 76 ShellContentUtilityClient::~ShellContentUtilityClient() { |
77 } | 77 } |
78 | 78 |
79 void ShellContentUtilityClient::RegisterMojoApplications( | 79 void ShellContentUtilityClient::RegisterMojoApplications( |
80 StaticMojoApplicationMap* apps) { | 80 StaticMojoApplicationMap* apps) { |
81 MojoApplicationInfo app_info; | 81 MojoApplicationInfo app_info; |
82 app_info.application_factory = base::Bind(&CreateTestApp); | 82 app_info.application_factory = base::Bind(&CreateTestService); |
83 apps->insert(std::make_pair(kTestMojoAppUrl, app_info)); | 83 apps->insert(std::make_pair(kTestServiceUrl, app_info)); |
84 } | 84 } |
85 | 85 |
86 void ShellContentUtilityClient::ExposeInterfacesToBrowser( | 86 void ShellContentUtilityClient::ExposeInterfacesToBrowser( |
87 shell::InterfaceRegistry* registry) { | 87 shell::InterfaceRegistry* registry) { |
88 registry->AddInterface(base::Bind(&TestMojoServiceImpl::Create)); | 88 registry->AddInterface(base::Bind(&TestServiceImpl::Create)); |
89 } | 89 } |
90 | 90 |
91 } // namespace content | 91 } // namespace content |
OLD | NEW |