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

Side by Side Diff: content/public/common/static_mojo_application_loader.h

Issue 1128453004: Embed a simple Mojo shell in content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 2015 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_PUBLIC_COMMON_STATIC_MOJO_APPLICATION_LOADER_H_
6 #define CONTENT_PUBLIC_COMMON_STATIC_MOJO_APPLICATION_LOADER_H_
7
8 #include <list>
9 #include <string>
10
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "mojo/shell/application_loader.h"
16
17 namespace base {
18 class Thread;
19 }
20
21 namespace mojo {
22 class ApplicationDelegate;
23 }
24
25 namespace content {
26
27 // This ApplicationLoader may be used to load applications which are linked into
28 // the content embedder's binary.
29 class StaticMojoApplicationLoader : public mojo::shell::ApplicationLoader {
30 public:
31 using ApplicationFactory =
32 base::Callback<scoped_ptr<mojo::ApplicationDelegate>()>;
33
34 // Create a new loader for a static applications. |name| is used to identify
35 // application-main threads. |factory| MUST be safe to run on any thread.
36 StaticMojoApplicationLoader(const std::string& name,
37 const ApplicationFactory& factory);
38 ~StaticMojoApplicationLoader() override;
39
40 // mojo::shell::ApplicationLoader:
41 void Load(const GURL& url,
42 mojo::InterfaceRequest<mojo::Application> request) override;
43
44 private:
45 using ThreadList = std::list<scoped_ptr<base::Thread>>;
46
47 void ClearThread(typename ThreadList::iterator iter);
48
49 // The name to use this app's threads.
50 std::string name_;
51
52 // The factory used to create new instances of the application's delegate.
53 ApplicationFactory factory_;
54
55 // List of all threads started by this loader. Each running instance of an
56 // application will have a corresponding thread in this list.
57 ThreadList threads_;
58
59 base::WeakPtrFactory<StaticMojoApplicationLoader> weak_factory_;
60
61 DISALLOW_COPY_AND_ASSIGN(StaticMojoApplicationLoader);
62 };
63
64 } // namespace content
65
66 #endif // CONTENT_PUBLIC_COMMON_STATIC_MOJO_APPLICATION_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698