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

Side by Side Diff: content/public/test/test_service.cc

Issue 2795883002: Eliminate OnConnect usage (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 | « content/public/test/test_service.h ('k') | mash/package/mash_packaged_service.h » ('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/public/test/test_service.h" 5 #include "content/public/test/test_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "services/service_manager/public/cpp/connection.h" 11 #include "services/service_manager/public/cpp/connection.h"
12 #include "services/service_manager/public/cpp/connector.h" 12 #include "services/service_manager/public/cpp/connector.h"
13 #include "services/service_manager/public/cpp/interface_registry.h"
14 13
15 namespace content { 14 namespace content {
16 15
17 const char kTestServiceUrl[] = "system:content_test_service"; 16 const char kTestServiceUrl[] = "system:content_test_service";
18 17
19 TestService::TestService() : service_binding_(this) { 18 TestService::TestService() : service_binding_(this) {
19 registry_.AddInterface<mojom::TestService>(this);
20 } 20 }
21 21
22 TestService::~TestService() { 22 TestService::~TestService() {
23 } 23 }
24 24
25 bool TestService::OnConnect(const service_manager::ServiceInfo& remote_info, 25 void TestService::OnBindInterface(
26 service_manager::InterfaceRegistry* registry) { 26 const service_manager::ServiceInfo& source_info,
27 requestor_name_ = remote_info.identity.name(); 27 const std::string& interface_name,
28 registry->AddInterface<mojom::TestService>(this); 28 mojo::ScopedMessagePipeHandle interface_pipe) {
29 return true; 29 requestor_name_ = source_info.identity.name();
30 registry_.BindInterface(source_info.identity, interface_name,
31 std::move(interface_pipe));
30 } 32 }
31 33
32 void TestService::Create(const service_manager::Identity& remote_identity, 34 void TestService::Create(const service_manager::Identity& remote_identity,
33 mojom::TestServiceRequest request) { 35 mojom::TestServiceRequest request) {
34 DCHECK(!service_binding_.is_bound()); 36 DCHECK(!service_binding_.is_bound());
35 service_binding_.Bind(std::move(request)); 37 service_binding_.Bind(std::move(request));
36 } 38 }
37 39
38 void TestService::DoSomething(const DoSomethingCallback& callback) { 40 void TestService::DoSomething(const DoSomethingCallback& callback) {
39 callback.Run(); 41 callback.Run();
(...skipping 13 matching lines...) Expand all
53 callback.Run(requestor_name_); 55 callback.Run(requestor_name_);
54 } 56 }
55 57
56 void TestService::CreateSharedBuffer( 58 void TestService::CreateSharedBuffer(
57 const std::string& message, 59 const std::string& message,
58 const CreateSharedBufferCallback& callback) { 60 const CreateSharedBufferCallback& callback) {
59 NOTREACHED(); 61 NOTREACHED();
60 } 62 }
61 63
62 } // namespace content 64 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_service.h ('k') | mash/package/mash_packaged_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698