blob: 3a08b041859b3e555759a891aa149da109965a01 [file] [log] [blame]
James Robinson646469d2014-10-03 15:33:28 -07001// Copyright 2014 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
Scott Violetbc1184a2014-12-16 08:55:34 -08005#ifndef SHELL_ANDROID_UI_APPLICATION_LOADER_ANDROID_H_
6#define SHELL_ANDROID_UI_APPLICATION_LOADER_ANDROID_H_
James Robinson646469d2014-10-03 15:33:28 -07007
8#include "base/macros.h"
9#include "base/memory/scoped_ptr.h"
Przemysław Pietrzkiewicz6384d092015-01-15 16:03:17 -080010#include "shell/application_manager/application_loader.h"
James Robinson646469d2014-10-03 15:33:28 -070011
Scott Violetbc1184a2014-12-16 08:55:34 -080012namespace base {
13class MessageLoop;
14}
15
Viet-Trung Luu36faa4d2015-03-04 18:08:18 -080016namespace shell {
James Robinson646469d2014-10-03 15:33:28 -070017
18class ApplicationManager;
19
James Robinson646469d2014-10-03 15:33:28 -070020// ApplicationLoader implementation that creates a background thread and issues
21// load
22// requests there.
23class UIApplicationLoader : public ApplicationLoader {
24 public:
25 UIApplicationLoader(scoped_ptr<ApplicationLoader> real_loader,
Scott Violetbc1184a2014-12-16 08:55:34 -080026 base::MessageLoop* ui_message_loop);
James Robinsone1b30cf2014-10-21 12:25:40 -070027 ~UIApplicationLoader() override;
James Robinson646469d2014-10-03 15:33:28 -070028
29 // ApplicationLoader overrides:
Viet-Trung Luubd07e3a2015-04-09 12:43:29 -070030 void Load(
31 const GURL& url,
32 mojo::InterfaceRequest<mojo::Application> application_request) override;
James Robinson646469d2014-10-03 15:33:28 -070033
34 private:
35 class UILoader;
36
37 // These functions are exected on the background thread. They call through
Benjamin Lermanbbc0e082016-05-23 11:28:48 +020038 // to |loader_| to do the actual loading.
Viet-Trung Luubd07e3a2015-04-09 12:43:29 -070039 void LoadOnUIThread(
40 const GURL& url,
41 mojo::InterfaceRequest<mojo::Application> application_request);
James Robinson646469d2014-10-03 15:33:28 -070042 void ShutdownOnUIThread();
43
44 scoped_ptr<ApplicationLoader> loader_;
Scott Violetbc1184a2014-12-16 08:55:34 -080045 base::MessageLoop* ui_message_loop_;
James Robinson646469d2014-10-03 15:33:28 -070046
James Robinson646469d2014-10-03 15:33:28 -070047 DISALLOW_COPY_AND_ASSIGN(UIApplicationLoader);
48};
49
Viet-Trung Luu36faa4d2015-03-04 18:08:18 -080050} // namespace shell
James Robinson646469d2014-10-03 15:33:28 -070051
Scott Violetbc1184a2014-12-16 08:55:34 -080052#endif // SHELL_ANDROID_UI_APPLICATION_LOADER_ANDROID_H_