summaryrefslogtreecommitdiffstats
path: root/mojo/shell/app_container.h
blob: ae6e27722af99f8db43b7c8a8d3b7d0c9208e1a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MOJO_SHELL_APP_CONTAINER_H_
#define MOJO_SHELL_APP_CONTAINER_H_

#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "mojo/public/system/core.h"
#include "mojo/shell/loader.h"

namespace base {
class FilePath;
class Thread;
}

namespace mojo {
namespace services {
class NativeViewportController;
}
namespace shell {

class Context;

// A container class that runs an app on its own thread.
class AppContainer : public Loader::Delegate {
 public:
  explicit AppContainer(Context* context);
  virtual ~AppContainer();

  void Load(const GURL& app_url);

 private:
  // From Loader::Delegate
  virtual void DidCompleteLoad(const GURL& app_url,
                               const base::FilePath& app_path) OVERRIDE;

  void AppCompleted();

  Context* context_;
  scoped_ptr<Loader::Job> request_;
  scoped_ptr<base::Thread> thread_;
  scoped_ptr<services::NativeViewportController> native_viewport_controller_;

  // Following members are valid only on app thread.
  Handle shell_handle_;

  base::WeakPtrFactory<AppContainer> weak_factory_;

  DISALLOW_COPY_AND_ASSIGN(AppContainer);
};

}  // namespace shell
}  // namespace mojo

#endif  // MOJO_SHELL_APP_CONTAINER_H_