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

Side by Side Diff: services/test/service_impl.cc

Issue 2829003005: Test service as minimum repro for sharing memory handle (Closed)
Patch Set: Created 3 years, 8 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 | « services/test/service_impl.h ('k') | services/test/service_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "services/test/service_impl.h"
6
7 #include "mojo/public/cpp/system/platform_handle.h"
8 #include "services/service_manager/public/cpp/service_info.h"
9
10 namespace test {
11
12 ServiceImpl::ServiceImpl() {
13 registry_.AddInterface<mojom::Service>(this);
14 }
15
16 ServiceImpl::~ServiceImpl() = default;
17
18 void ServiceImpl::OnBindInterface(
19 const service_manager::ServiceInfo& source_info,
20 const std::string& interface_name,
21 mojo::ScopedMessagePipeHandle interface_pipe) {
22 registry_.BindInterface(source_info.identity, interface_name,
23 std::move(interface_pipe));
24 }
25
26 void ServiceImpl::Create(const service_manager::Identity& remote_identity,
27 mojom::ServiceRequest request) {
28 service_bindings_.AddBinding(this, std::move(request));
29 }
30
31 void ServiceImpl::ShareBufferToTestReceiver(mojom::ReceiverPtr receiver) {
32 test_receiver_ = std::move(receiver);
33 const size_t kMemorySize = 1024;
34 bool create_memory_success =
35 shared_memory_.CreateAndMapAnonymous(kMemorySize);
36 CHECK(create_memory_success);
37 mojo::ScopedSharedBufferHandle handle = mojo::WrapSharedMemoryHandle(
38 base::SharedMemory::DuplicateHandle(shared_memory_.handle()), kMemorySize,
39 false /* read_only */);
40 test_receiver_->ReceiveBufferHandle(std::move(handle));
41 }
42
43 } // namespace test
OLDNEW
« no previous file with comments | « services/test/service_impl.h ('k') | services/test/service_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698