summaryrefslogtreecommitdiffstats
path: root/mojo/services/test_service/test_request_tracker_application.cc
blob: 4e657cb4bc990b7df64afd68e0cebfd5050690be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "mojo/services/test_service/test_request_tracker_application.h"

#include <assert.h>
#include <utility>

#include "mojo/public/c/system/main.h"
#include "mojo/services/test_service/test_time_service_impl.h"
#include "mojo/shell/public/cpp/application_runner.h"
#include "mojo/shell/public/cpp/connection.h"

namespace mojo {
namespace test {

TestRequestTrackerApplication::TestRequestTrackerApplication()
    : shell_(nullptr) {}
TestRequestTrackerApplication::~TestRequestTrackerApplication() {}

void TestRequestTrackerApplication::Initialize(Shell* shell,
                                               const std::string& url,
                                               uint32_t id) {
  shell_ = shell;
}

bool TestRequestTrackerApplication::AcceptConnection(Connection* connection) {
  // Every instance of the service and recorder shares the context.
  // Note, this app is single-threaded, so this is thread safe.
  connection->AddService<TestTimeService>(this);
  connection->AddService<TestRequestTracker>(this);
  connection->AddService<TestTrackedRequestService>(this);
  return true;
}

void TestRequestTrackerApplication::Create(
    Connection* connection,
    InterfaceRequest<TestTimeService> request) {
  new TestTimeServiceImpl(shell_, std::move(request));
}

void TestRequestTrackerApplication::Create(
    Connection* connection,
    InterfaceRequest<TestRequestTracker> request) {
  new TestRequestTrackerImpl(std::move(request), &context_);
}

void TestRequestTrackerApplication::Create(
    Connection* connection,
    InterfaceRequest<TestTrackedRequestService> request) {
  new TestTrackedRequestServiceImpl(std::move(request), &context_);
}

}  // namespace test
}  // namespace mojo

MojoResult MojoMain(MojoHandle shell_handle) {
  mojo::ApplicationRunner runner(
      new mojo::test::TestRequestTrackerApplication);
  return runner.Run(shell_handle);
}