summaryrefslogtreecommitdiffstats
path: root/mojo/shell/context.h
blob: c9acdc4fb15030a1e461c3e89171f86e930daf5f (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
59
60
61
62
// 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_CONTEXT_H_
#define MOJO_SHELL_CONTEXT_H_

#include "mojo/service_manager/service_manager.h"
#include "mojo/shell/keep_alive.h"
#include "mojo/shell/loader.h"
#include "mojo/shell/storage.h"
#include "mojo/shell/task_runners.h"

#if defined(OS_ANDROID)
#include "base/android/scoped_java_ref.h"
#endif  // defined(OS_ANDROID)

namespace mojo {

class Spy;

namespace shell {

class DynamicServiceLoader;

// The "global" context for the shell's main process.
class Context {
 public:
  Context();
  ~Context();

  TaskRunners* task_runners() { return &task_runners_; }
  Storage* storage() { return &storage_; }
  Loader* loader() { return &loader_; }
  ServiceManager* service_manager() { return &service_manager_; }
  KeepAliveCounter* keep_alive_counter() { return &keep_alive_counter_; }

#if defined(OS_ANDROID)
  jobject activity() const { return activity_.obj(); }
  void set_activity(jobject activity) { activity_.Reset(NULL, activity); }
#endif  // defined(OS_ANDROID)

 private:
  class NativeViewportServiceLoader;
  TaskRunners task_runners_;
  Storage storage_;
  Loader loader_;
  ServiceManager service_manager_;
  scoped_ptr<Spy> spy_;
#if defined(OS_ANDROID)
  base::android::ScopedJavaGlobalRef<jobject> activity_;
#endif  // defined(OS_ANDROID)

  KeepAliveCounter keep_alive_counter_;

  DISALLOW_COPY_AND_ASSIGN(Context);
};

}  // namespace shell
}  // namespace mojo

#endif  // MOJO_SHELL_CONTEXT_H_