summaryrefslogtreecommitdiffstats
path: root/mojo/shell/background/background_shell.h
blob: d1e9c412438094b186bfdcc445873b0759086655 (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
// Copyright 2016 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_SHELL_BACKGROUND_BACKGROUND_SHELL_H_
#define MOJO_SHELL_BACKGROUND_BACKGROUND_SHELL_H_

#include <vector>

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/shell/public/interfaces/shell_client.mojom.h"

class GURL;

namespace mojo {
namespace shell {

struct CommandLineSwitch;

// BackgroundShell starts up the mojo shell on a background thread, and
// destroys the thread in the destructor. Once created use CreateApplication()
// to obtain an InterfaceRequest for the Application. The InterfaceRequest can
// then be bound to an ApplicationImpl.
class BackgroundShell {
 public:
  BackgroundShell();
  ~BackgroundShell();

  // Starts the background shell. |command_line_switches| are additional
  // switches applied to any processes spawned by this call.
  void Init(const std::vector<CommandLineSwitch>& command_line_switches);

  // Obtains an InterfaceRequest for the specified url.
  InterfaceRequest<mojom::ShellClient> CreateShellClientRequest(
      const GURL& url);

 private:
  class MojoThread;

  scoped_ptr<MojoThread> thread_;

  DISALLOW_COPY_AND_ASSIGN(BackgroundShell);
};

}  // namespace shell
}  // namespace mojo

#endif  // MOJO_SHELL_BACKGROUND_BACKGROUND_SHELL_H_