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

Side by Side Diff: services/blamer/blamer_service.cc

Issue 2885363004: [Hacky prototype] Create a shared-memory high-performance reporting service.
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
OLDNEW
(Empty)
1 // Copyright 2017 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/blamer/blamer_service.h"
6
7 #include "base/bind.h"
8 #include "services/blamer/shared_memory_heap_registry.h"
9 #include "services/service_manager/public/cpp/interface_registry.h"
10 #include "services/service_manager/public/cpp/service_context.h"
11
12 namespace blamer {
13
14 namespace {
15
16 void OnConnectionLost(std::unique_ptr<service_manager::ServiceContextRef> ref) {
17 // No-op. Merely takes ownership of |ref| so it can be destroyed when this
18 // function is invoked.
19 }
20
21 } // namespace
22
23 BlamerService::BlamerService() : weak_factory_(this) {}
24
25 BlamerService::~BlamerService() = default;
26
27 // static
28 std::unique_ptr<service_manager::Service> BlamerService::Create() {
29 return base::MakeUnique<BlamerService>();
30 }
31
32 void BlamerService::OnStart() {
33 ref_factory_.reset(new service_manager::ServiceContextRefFactory(
34 base::Bind(&service_manager::ServiceContext::RequestQuit,
35 base::Unretained(context()))));
36 }
37
38 bool BlamerService::OnConnect(const service_manager::ServiceInfo& remote_info,
39 service_manager::InterfaceRegistry* registry) {
40 // Add a reference to the service and tie it to the lifetime of the
41 // InterfaceRegistry's connection.
42 std::unique_ptr<service_manager::ServiceContextRef> connection_ref =
43 ref_factory_->CreateRef();
44 registry->AddConnectionLostClosure(
45 base::Bind(&OnConnectionLost, base::Passed(&connection_ref)));
46 registry->AddInterface(base::Bind(&SharedMemoryHeapRegistry::Create,
47 base::Unretained(ref_factory_.get())));
48 return true;
49 }
50
51 } // namespace blamer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698