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

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

Issue 1149833007: Embed a mojo ApplicationManager in content/browser (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
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
13 #include "content/common/content_export.h"
14 #include "mojo/shell/application_loader.h"
15
16 namespace base {
17 class Thread;
18 }
19
20 namespace mojo {
21 class ApplicationDelegate;
22 }
23
24 namespace content {
25
26 class CONTENT_EXPORT StaticMojoApplicationLoader
27 : public mojo::shell::ApplicationLoader {
28 public:
29 using ApplicationFactory =
30 base::Callback<scoped_ptr<mojo::ApplicationDelegate>()>;
31
32 // Constructs a static loader for |factory|.
33 explicit StaticMojoApplicationLoader(const ApplicationFactory& factory);
34
35 // Constructs a static loader for |factory| with a closure that will be called
36 // when the loaded application quits.
37 StaticMojoApplicationLoader(const ApplicationFactory& factory,
38 const base::Closure& quit_callback);
39
40 ~StaticMojoApplicationLoader() override;
41
42 // mojo::shell::ApplicationLoader:
43 void Load(const GURL& url,
44 mojo::InterfaceRequest<mojo::Application> request) override;
45
46 private:
47 using ThreadList = std::list<scoped_ptr<base::Thread>>;
48
49 void CleanUpAppThread(typename ThreadList::iterator iter);
50
51 // The factory used t create new instances of the application delegate.
52 ApplicationFactory factory_;
53
54 // If not null, this is called when an instance of the loaded application
55 // quits.
56 base::Closure quit_callback_;
57
58 // List of all threads started by this loader. Each running instance of an
59 // application will have a corresponding thread in this list.
60 ThreadList threads_;
61
62 base::WeakPtrFactory<StaticMojoApplicationLoader> weak_factory_;
63
64 DISALLOW_COPY_AND_ASSIGN(StaticMojoApplicationLoader);
65 };
66
67 } // namespace content
68
69 #endif // CONTENT_PUBLIC_COMMON_STATIC_MOJO_APPLICATION_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698