summaryrefslogtreecommitdiffstats
path: root/mojo/shell/standalone/android/ui_application_loader_android.h
blob: c990ace952c5adacf49317b075b7e4b1f39e99b7 (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
// Copyright 2014 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_STANDALONE_ANDROID_UI_APPLICATION_LOADER_ANDROID_H_
#define MOJO_SHELL_STANDALONE_ANDROID_UI_APPLICATION_LOADER_ANDROID_H_

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "mojo/shell/application_loader.h"

namespace base {
class MessageLoop;
}

namespace mojo {
namespace shell {

class ApplicationManager;

// ApplicationLoader implementation that creates a background thread and issues
// load
// requests there.
class UIApplicationLoader : public ApplicationLoader {
 public:
  UIApplicationLoader(scoped_ptr<ApplicationLoader> real_loader,
                      base::MessageLoop* ui_message_loop);
  ~UIApplicationLoader() override;

  // ApplicationLoader overrides:
  void Load(const GURL& url,
            InterfaceRequest<Application> application_request) override;

 private:
  class UILoader;

  // These functions are exected on the background thread. They call through
  // to |background_loader_| to do the actual loading.
  // TODO: having this code take a |manager| is fragile (as ApplicationManager
  // isn't thread safe).
  void LoadOnUIThread(const GURL& url,
                      InterfaceRequest<Application> application_request);
  void ShutdownOnUIThread();

  scoped_ptr<ApplicationLoader> loader_;
  base::MessageLoop* ui_message_loop_;

  DISALLOW_COPY_AND_ASSIGN(UIApplicationLoader);
};

}  // namespace shell
}  // namespace mojo

#endif  // MOJO_SHELL_STANDALONE_ANDROID_UI_APPLICATION_LOADER_ANDROID_H_