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

Side by Side Diff: mojo/shell/static_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, 6 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 MOJO_SHELL_STATIC_APPLICATION_LOADER_H_
6 #define MOJO_SHELL_STATIC_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 "mojo/shell/application_loader.h"
14
15 namespace base {
16 class SimpleThread;
17 }
18
19 namespace mojo {
20 class ApplicationDelegate;
21 }
22
23 namespace mojo {
24 namespace shell {
25
26 // An ApplicationLoader which loads a single type of app from a given
27 // ApplicationDelegate factory. A Load() request is fulfilled by creating an
28 // instance of the app on a new thread. Only one instance of the app will run at
29 // a time. Any Load requests received while the app is running will be dropped.
30 class StaticApplicationLoader : public mojo::shell::ApplicationLoader {
31 public:
32 using ApplicationFactory =
33 base::Callback<scoped_ptr<mojo::ApplicationDelegate>()>;
34
35 // Constructs a static loader for |factory|.
36 explicit StaticApplicationLoader(const ApplicationFactory& factory);
37
38 // Constructs a static loader for |factory| with a closure that will be called
39 // when the loaded application quits.
40 StaticApplicationLoader(const ApplicationFactory& factory,
41 const base::Closure& quit_callback);
42
43 ~StaticApplicationLoader() override;
44
45 // mojo::shell::ApplicationLoader:
46 void Load(const GURL& url,
47 mojo::InterfaceRequest<mojo::Application> request) override;
48
49 private:
50 void StopAppThread();
51
52 // The factory used t create new instances of the application delegate.
53 ApplicationFactory factory_;
54
55 // If not null, this is run when the loaded application quits.
56 base::Closure quit_callback_;
57
58 // Thread for the application if currently running.
59 scoped_ptr<base::SimpleThread> thread_;
60
61 base::WeakPtrFactory<StaticApplicationLoader> weak_factory_;
62
63 DISALLOW_COPY_AND_ASSIGN(StaticApplicationLoader);
64 };
65
66 } // namespace shell
67 } // namespace mojo
68
69 #endif // MOJO_SHELL_STATIC_APPLICATION_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698