blob: e5e6e35de2c6bb1853d7622a05b0040b9cafc929 (
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
|
// 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 CONTENT_COMMON_MOJO_CURRENT_THREAD_LOADER_H_
#define CONTENT_COMMON_MOJO_CURRENT_THREAD_LOADER_H_
#include <vector>
#include "base/callback.h"
#include "base/macros.h"
#include "mojo/shell/loader.h"
#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/public/cpp/shell_connection.h"
namespace content {
// A Loader which loads a single type of app from a mojo::ShellClientFactory on
// the current thread.
class CurrentThreadLoader : public mojo::shell::Loader {
public:
using ApplicationFactory = base::Callback<scoped_ptr<mojo::ShellClient>()>;
explicit CurrentThreadLoader(const ApplicationFactory& factory);
~CurrentThreadLoader() override;
// mojo::shell::Loader:
void Load(const std::string& name,
mojo::shell::mojom::ShellClientRequest request) override;
private:
// The factory used to create new instances of the application delegate. This
// is called exactly once since all connections share a single client.
ApplicationFactory factory_;
// Our shared shell client, passed to each connection.
scoped_ptr<mojo::ShellClient> shell_client_;
std::vector<scoped_ptr<mojo::ShellConnection>> connections_;
DISALLOW_COPY_AND_ASSIGN(CurrentThreadLoader);
};
} // namespace content
#endif // CONTENT_COMMON_MOJO_CURRENT_THREAD_LOADER_H_
|