summaryrefslogtreecommitdiffstats
path: root/mojo/runner/child/runner_connection.h
blob: 83423ddf3c07ec4338f8a4f4fbd0f072a6f84602 (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
// Copyright 2015 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.

#ifndef MOJO_RUNNER_CHILD_RUNNER_CONNECTION_H_
#define MOJO_RUNNER_CHILD_RUNNER_CONNECTION_H_

#include "base/macros.h"
#include "mojo/shell/public/interfaces/application.mojom.h"

namespace mojo {
namespace runner {

// Encapsulates a connection to a runner process. The connection object starts a
// background controller thread that is used to receive control messages from
// the runner. When this object is destroyed the thread is joined.
class RunnerConnection {
 public:
  virtual ~RunnerConnection();

  // Establish a connection to the runner, blocking the calling thread until
  // it is established. The Application request from the runner is returned via
  // |request|.
  // If a connection to the runner cannot be established, |request| will not be
  // modified and this function will return null.
  static RunnerConnection* ConnectToRunner(
      InterfaceRequest<Application>* request,
      ScopedMessagePipeHandle handle);

 protected:
  RunnerConnection();

 private:
  DISALLOW_COPY_AND_ASSIGN(RunnerConnection);
};

}  // namespace runner
}  // namespace mojo

#endif  // MOJO_RUNNER_CHILD_RUNNER_CONNECTION_H_