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 3 // found in the LICENSE file. 4 5 #include "mojo/services/test_service/test_request_tracker_application.h" 6 7 #include <assert.h> 8 9 #include "mojo/public/c/system/main.h" 10 #include "mojo/public/cpp/application/application_connection.h" 11 #include "mojo/public/cpp/application/application_runner.h" 12 #include "mojo/services/test_service/test_time_service_impl.h" 13 14 namespace mojo { 15 namespace test { 16 17 TestRequestTrackerApplication::TestRequestTrackerApplication() 18 : test_tracked_request_factory_(&context_), 19 test_request_tracker_factory_(&context_) { 20 } 21 22 TestRequestTrackerApplication::~TestRequestTrackerApplication() { 23 } 24 25 bool TestRequestTrackerApplication::ConfigureIncomingConnection( 26 ApplicationConnection* connection) { 27 // Every instance of the service and recorder shares the context. 28 // Note, this app is single-threaded, so this is thread safe. 29 connection->AddService(&test_tracked_request_factory_); 30 connection->AddService(&test_request_tracker_factory_); 31 connection->AddService(this); 32 return true; 33 } 34 35 void TestRequestTrackerApplication::Create( 36 ApplicationConnection* connection, 37 InterfaceRequest<TestTimeService> request) { 38 BindToRequest(new TestTimeServiceImpl(connection), &request); 39 } 40 41 } // namespace test 42 } // namespace mojo 43 44 MojoResult MojoMain(MojoHandle shell_handle) { 45 mojo::ApplicationRunner runner( 46 new mojo::test::TestRequestTrackerApplication); 47 return runner.Run(shell_handle); 48 } 49