- add sources.
[platform/framework/web/crosswalk.git] / src / mojo / shell / app_container.h
1 // Copyright 2013 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_APP_CONTAINER_H_
6 #define MOJO_SHELL_APP_CONTAINER_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "mojo/public/system/core.h"
12 #include "mojo/shell/loader.h"
13
14 namespace base {
15 class FilePath;
16 class Thread;
17 }
18
19 namespace mojo {
20 namespace services {
21 class NativeViewportController;
22 }
23 namespace shell {
24
25 class Context;
26
27 // A container class that runs an app on its own thread.
28 class AppContainer : public Loader::Delegate {
29  public:
30   explicit AppContainer(Context* context);
31   virtual ~AppContainer();
32
33   void Load(const GURL& app_url);
34
35  private:
36   // From Loader::Delegate
37   virtual void DidCompleteLoad(const GURL& app_url,
38                                const base::FilePath& app_path) OVERRIDE;
39
40   void AppCompleted();
41
42   Context* context_;
43   scoped_ptr<Loader::Job> request_;
44   scoped_ptr<base::Thread> thread_;
45   scoped_ptr<services::NativeViewportController> native_viewport_controller_;
46
47   // Following members are valid only on app thread.
48   Handle shell_handle_;
49
50   base::WeakPtrFactory<AppContainer> weak_factory_;
51
52   DISALLOW_COPY_AND_ASSIGN(AppContainer);
53 };
54
55 }  // namespace shell
56 }  // namespace mojo
57
58 #endif  // MOJO_SHELL_APP_CONTAINER_H_