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

Side by Side Diff: mojo/services/test_service/test_service_application.cc

Issue 380413003: Mojo: Use InterfaceFactory<Interface> for service registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: some InterfaceProvider impls for common cases Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/services/test_service/test_service_application.h" 5 #include "mojo/services/test_service/test_service_application.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 8
9 #include "mojo/public/cpp/application/application_connection.h" 9 #include "mojo/public/cpp/application/application_connection.h"
10 #include "mojo/public/cpp/utility/run_loop.h" 10 #include "mojo/public/cpp/utility/run_loop.h"
11 #include "mojo/services/test_service/test_service_impl.h" 11 #include "mojo/services/test_service/test_service_impl.h"
12 #include "mojo/services/test_service/test_time_service_impl.h" 12 #include "mojo/services/test_service/test_time_service_impl.h"
13 13
14 namespace mojo { 14 namespace mojo {
15 namespace test { 15 namespace test {
16 16
17 TestServiceApplication::TestServiceApplication() : ref_count_(0) { 17 TestServiceApplication::TestServiceApplication() : ref_count_(0) {
18 } 18 }
19 19
20 TestServiceApplication::~TestServiceApplication() { 20 TestServiceApplication::~TestServiceApplication() {
21 } 21 }
22 22
23 bool TestServiceApplication::ConfigureIncomingConnection( 23 bool TestServiceApplication::ConfigureIncomingConnection(
24 ApplicationConnection* connection) { 24 ApplicationConnection* connection) {
25 connection->AddService<TestServiceImpl>(this); 25 connection->AddServiceProvider<TestService>(this);
26 connection->AddService<TestTimeServiceImpl>(); 26 connection->AddServiceProvider<TestTimeService>(this);
27 return true; 27 return true;
28 } 28 }
29 29
30 void TestServiceApplication::BindToRequest(
31 ApplicationConnection* connection,
32 InterfaceRequest<TestService> request) {
33 mojo::BindToRequest(new TestServiceImpl(connection, this), &request);
34 }
35
36 void TestServiceApplication::BindToRequest(
37 ApplicationConnection* connection,
38 InterfaceRequest<TestTimeService> request) {
39 mojo::BindToRequest(new TestTimeServiceImpl(connection), &request);
40 }
41
30 void TestServiceApplication::AddRef() { 42 void TestServiceApplication::AddRef() {
31 assert(ref_count_ >= 0); 43 assert(ref_count_ >= 0);
32 ref_count_++; 44 ref_count_++;
33 } 45 }
34 46
35 void TestServiceApplication::ReleaseRef() { 47 void TestServiceApplication::ReleaseRef() {
36 assert(ref_count_ > 0); 48 assert(ref_count_ > 0);
37 ref_count_--; 49 ref_count_--;
38 if (ref_count_ <= 0) 50 if (ref_count_ <= 0)
39 RunLoop::current()->Quit(); 51 RunLoop::current()->Quit();
40 } 52 }
41 53
42 } // namespace test 54 } // namespace test
43 55
44 // static 56 // static
45 ApplicationDelegate* ApplicationDelegate::Create() { 57 ApplicationDelegate* ApplicationDelegate::Create() {
46 return new mojo::test::TestServiceApplication(); 58 return new mojo::test::TestServiceApplication();
47 } 59 }
48 60
49 } // namespace mojo 61 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698