Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: content/common/mojo/existing_thread_loader.h

Issue 1856313002: mojo: Add ExistingThreadLoader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_COMMON_MOJO_EXISTING_THREAD_LOADER_H_
6 #define CONTENT_COMMON_MOJO_EXISTING_THREAD_LOADER_H_
7
8 #include <vector>
9
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h"
14 #include "mojo/shell/loader.h"
15 #include "mojo/shell/public/cpp/shell_client.h"
16 #include "mojo/shell/public/cpp/shell_connection.h"
17
18 namespace base {
19 class SingleThreadTaskRunner;
20 }
21
22 namespace content {
23
24 // A Loader which loads a single type of app from a mojo::ShellClientFactory on
25 // an existing thread.
26 class ExistingThreadLoader : public mojo::shell::Loader {
27 public:
28 using ApplicationFactory = base::Callback<scoped_ptr<mojo::ShellClient>()>;
29
30 ExistingThreadLoader(const ApplicationFactory& factory,
31 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
32 ~ExistingThreadLoader() override;
33
34 // mojo::shell::Loader:
35 void Load(const std::string& name,
36 mojo::shell::mojom::ShellClientRequest request) override;
37
38 private:
39 void LoadOnTaskRunner(const std::string& name,
40 mojo::shell::mojom::ShellClientRequest request);
41
42 // The factory used to create new instances of the shell client. This is
43 // called exactly once since all connections share a single client.
44 ApplicationFactory factory_;
45
46 // TaskRunner where the |shell_client_| is running on.
47 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
48
49 // Our shared shell client, passed to each connection.
50 scoped_ptr<mojo::ShellClient> shell_client_;
51
52 std::vector<scoped_ptr<mojo::ShellConnection>> connections_;
53
54 base::WeakPtrFactory<ExistingThreadLoader> weak_factory_;
55
56 DISALLOW_COPY_AND_ASSIGN(ExistingThreadLoader);
57 };
58
59 } // namespace content
60
61 #endif // CONTENT_COMMON_MOJO_EXISTING_THREAD_LOADER_H_
OLDNEW
« no previous file with comments | « no previous file | content/common/mojo/existing_thread_loader.cc » ('j') | content/common/mojo/existing_thread_loader.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698