| OLD | NEW |
| 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_request_tracker_application.h" | 5 #include "mojo/services/test_service/test_request_tracker_application.h" |
| 6 | 6 |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "mojo/public/c/system/main.h" | 10 #include "mojo/public/c/system/main.h" |
| 11 #include "mojo/services/test_service/test_time_service_impl.h" | 11 #include "mojo/services/test_service/test_time_service_impl.h" |
| 12 #include "mojo/shell/public/cpp/application_connection.h" | 12 #include "mojo/shell/public/cpp/application_connection.h" |
| 13 #include "mojo/shell/public/cpp/application_runner.h" | 13 #include "mojo/shell/public/cpp/application_runner.h" |
| 14 | 14 |
| 15 namespace mojo { | 15 namespace mojo { |
| 16 namespace test { | 16 namespace test { |
| 17 | 17 |
| 18 TestRequestTrackerApplication::TestRequestTrackerApplication() | 18 TestRequestTrackerApplication::TestRequestTrackerApplication() |
| 19 : app_impl_(nullptr) { | 19 : shell_(nullptr) {} |
| 20 } | 20 TestRequestTrackerApplication::~TestRequestTrackerApplication() {} |
| 21 | 21 |
| 22 TestRequestTrackerApplication::~TestRequestTrackerApplication() { | 22 void TestRequestTrackerApplication::Initialize(Shell* shell, |
| 23 } | 23 const std::string& url, |
| 24 | 24 uint32_t id) { |
| 25 void TestRequestTrackerApplication::Initialize(ApplicationImpl* app) { | 25 shell_ = shell; |
| 26 app_impl_ = app; | |
| 27 } | 26 } |
| 28 | 27 |
| 29 bool TestRequestTrackerApplication::AcceptConnection( | 28 bool TestRequestTrackerApplication::AcceptConnection( |
| 30 ApplicationConnection* connection) { | 29 ApplicationConnection* connection) { |
| 31 // Every instance of the service and recorder shares the context. | 30 // Every instance of the service and recorder shares the context. |
| 32 // Note, this app is single-threaded, so this is thread safe. | 31 // Note, this app is single-threaded, so this is thread safe. |
| 33 connection->AddService<TestTimeService>(this); | 32 connection->AddService<TestTimeService>(this); |
| 34 connection->AddService<TestRequestTracker>(this); | 33 connection->AddService<TestRequestTracker>(this); |
| 35 connection->AddService<TestTrackedRequestService>(this); | 34 connection->AddService<TestTrackedRequestService>(this); |
| 36 return true; | 35 return true; |
| 37 } | 36 } |
| 38 | 37 |
| 39 void TestRequestTrackerApplication::Create( | 38 void TestRequestTrackerApplication::Create( |
| 40 ApplicationConnection* connection, | 39 ApplicationConnection* connection, |
| 41 InterfaceRequest<TestTimeService> request) { | 40 InterfaceRequest<TestTimeService> request) { |
| 42 new TestTimeServiceImpl(app_impl_, std::move(request)); | 41 new TestTimeServiceImpl(shell_, std::move(request)); |
| 43 } | 42 } |
| 44 | 43 |
| 45 void TestRequestTrackerApplication::Create( | 44 void TestRequestTrackerApplication::Create( |
| 46 ApplicationConnection* connection, | 45 ApplicationConnection* connection, |
| 47 InterfaceRequest<TestRequestTracker> request) { | 46 InterfaceRequest<TestRequestTracker> request) { |
| 48 new TestRequestTrackerImpl(std::move(request), &context_); | 47 new TestRequestTrackerImpl(std::move(request), &context_); |
| 49 } | 48 } |
| 50 | 49 |
| 51 void TestRequestTrackerApplication::Create( | 50 void TestRequestTrackerApplication::Create( |
| 52 ApplicationConnection* connection, | 51 ApplicationConnection* connection, |
| 53 InterfaceRequest<TestTrackedRequestService> request) { | 52 InterfaceRequest<TestTrackedRequestService> request) { |
| 54 new TestTrackedRequestServiceImpl(std::move(request), &context_); | 53 new TestTrackedRequestServiceImpl(std::move(request), &context_); |
| 55 } | 54 } |
| 56 | 55 |
| 57 } // namespace test | 56 } // namespace test |
| 58 } // namespace mojo | 57 } // namespace mojo |
| 59 | 58 |
| 60 MojoResult MojoMain(MojoHandle shell_handle) { | 59 MojoResult MojoMain(MojoHandle shell_handle) { |
| 61 mojo::ApplicationRunner runner( | 60 mojo::ApplicationRunner runner( |
| 62 new mojo::test::TestRequestTrackerApplication); | 61 new mojo::test::TestRequestTrackerApplication); |
| 63 return runner.Run(shell_handle); | 62 return runner.Run(shell_handle); |
| 64 } | 63 } |
| OLD | NEW |