Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: content/shell/utility/shell_content_utility_client.cc

Issue 2871523002: Use OnceCallback on Mojo interfaces in //content (Closed)
Patch Set: . Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/shell/renderer/shell_content_renderer_client.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 19 matching lines...) Expand all
30 30
31 class TestServiceImpl : public mojom::TestService { 31 class TestServiceImpl : public mojom::TestService {
32 public: 32 public:
33 static void Create(const service_manager::BindSourceInfo&, 33 static void Create(const service_manager::BindSourceInfo&,
34 mojom::TestServiceRequest request) { 34 mojom::TestServiceRequest request) {
35 mojo::MakeStrongBinding(base::WrapUnique(new TestServiceImpl), 35 mojo::MakeStrongBinding(base::WrapUnique(new TestServiceImpl),
36 std::move(request)); 36 std::move(request));
37 } 37 }
38 38
39 // mojom::TestService implementation: 39 // mojom::TestService implementation:
40 void DoSomething(const DoSomethingCallback& callback) override { 40 void DoSomething(DoSomethingCallback callback) override {
41 callback.Run(); 41 std::move(callback).Run();
42 } 42 }
43 43
44 void DoTerminateProcess(const DoTerminateProcessCallback& callback) override { 44 void DoTerminateProcess(DoTerminateProcessCallback callback) override {
45 base::Process::Current().Terminate(0, false); 45 base::Process::Current().Terminate(0, false);
46 } 46 }
47 47
48 void CreateFolder(const CreateFolderCallback& callback) override { 48 void CreateFolder(CreateFolderCallback callback) override {
49 // Note: This is used to check if the sandbox is disabled or not since 49 // Note: This is used to check if the sandbox is disabled or not since
50 // creating a folder is forbidden when it is enabled. 50 // creating a folder is forbidden when it is enabled.
51 callback.Run(base::ScopedTempDir().CreateUniqueTempDir()); 51 std::move(callback).Run(base::ScopedTempDir().CreateUniqueTempDir());
52 } 52 }
53 53
54 void GetRequestorName(const GetRequestorNameCallback& callback) override { 54 void GetRequestorName(GetRequestorNameCallback callback) override {
55 NOTREACHED(); 55 NOTREACHED();
56 } 56 }
57 57
58 void CreateSharedBuffer(const std::string& message, 58 void CreateSharedBuffer(const std::string& message,
59 const CreateSharedBufferCallback& callback) override { 59 CreateSharedBufferCallback callback) override {
60 mojo::ScopedSharedBufferHandle buffer = 60 mojo::ScopedSharedBufferHandle buffer =
61 mojo::SharedBufferHandle::Create(message.size()); 61 mojo::SharedBufferHandle::Create(message.size());
62 CHECK(buffer.is_valid()); 62 CHECK(buffer.is_valid());
63 63
64 mojo::ScopedSharedBufferMapping mapping = buffer->Map(message.size()); 64 mojo::ScopedSharedBufferMapping mapping = buffer->Map(message.size());
65 CHECK(mapping); 65 CHECK(mapping);
66 std::copy(message.begin(), message.end(), 66 std::copy(message.begin(), message.end(),
67 reinterpret_cast<char*>(mapping.get())); 67 reinterpret_cast<char*>(mapping.get()));
68 68
69 callback.Run(std::move(buffer)); 69 std::move(callback).Run(std::move(buffer));
70 } 70 }
71 71
72 private: 72 private:
73 explicit TestServiceImpl() {} 73 explicit TestServiceImpl() {}
74 74
75 DISALLOW_COPY_AND_ASSIGN(TestServiceImpl); 75 DISALLOW_COPY_AND_ASSIGN(TestServiceImpl);
76 }; 76 };
77 77
78 std::unique_ptr<service_manager::Service> CreateTestService() { 78 std::unique_ptr<service_manager::Service> CreateTestService() {
79 return std::unique_ptr<service_manager::Service>(new TestService); 79 return std::unique_ptr<service_manager::Service>(new TestService);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 void ShellContentUtilityClient::BindNetworkServiceTestRequest( 138 void ShellContentUtilityClient::BindNetworkServiceTestRequest(
139 const service_manager::BindSourceInfo& source_info, 139 const service_manager::BindSourceInfo& source_info,
140 mojom::NetworkServiceTestRequest request) { 140 mojom::NetworkServiceTestRequest request) {
141 DCHECK(!network_service_test_); 141 DCHECK(!network_service_test_);
142 network_service_test_ = 142 network_service_test_ =
143 base::MakeUnique<NetworkServiceTestImpl>(std::move(request)); 143 base::MakeUnique<NetworkServiceTestImpl>(std::move(request));
144 } 144 }
145 145
146 } // namespace content 146 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/shell_content_renderer_client.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698