| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SHELL_ANDROID_UI_APPLICATION_LOADER_ANDROID_H_ | 5 #ifndef SHELL_ANDROID_UI_APPLICATION_LOADER_ANDROID_H_ |
| 6 #define SHELL_ANDROID_UI_APPLICATION_LOADER_ANDROID_H_ | 6 #define SHELL_ANDROID_UI_APPLICATION_LOADER_ANDROID_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "shell/application_manager/application_loader.h" | 10 #include "shell/application_manager/application_loader.h" |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 class MessageLoop; | 13 class MessageLoop; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace mojo { | 16 namespace mojo { |
| 17 | 17 |
| 18 class ApplicationManager; | 18 class ApplicationManager; |
| 19 | 19 |
| 20 // ApplicationLoader implementation that creates a background thread and issues | 20 // ApplicationLoader implementation that creates a background thread and issues |
| 21 // load | 21 // load |
| 22 // requests there. | 22 // requests there. |
| 23 class UIApplicationLoader : public ApplicationLoader { | 23 class UIApplicationLoader : public ApplicationLoader { |
| 24 public: | 24 public: |
| 25 UIApplicationLoader(scoped_ptr<ApplicationLoader> real_loader, | 25 UIApplicationLoader(scoped_ptr<ApplicationLoader> real_loader, |
| 26 base::MessageLoop* ui_message_loop); | 26 base::MessageLoop* ui_message_loop); |
| 27 ~UIApplicationLoader() override; | 27 ~UIApplicationLoader() override; |
| 28 | 28 |
| 29 // ApplicationLoader overrides: | 29 // ApplicationLoader overrides: |
| 30 void Load(ApplicationManager* manager, | 30 void Load(const GURL& url, |
| 31 const GURL& url, | 31 InterfaceRequest<Application> application_request) override; |
| 32 InterfaceRequest<Application> application_request, | |
| 33 LoadCallback callback) override; | |
| 34 void OnApplicationError(ApplicationManager* manager, | 32 void OnApplicationError(ApplicationManager* manager, |
| 35 const GURL& url) override; | 33 const GURL& url) override; |
| 36 | 34 |
| 37 private: | 35 private: |
| 38 class UILoader; | 36 class UILoader; |
| 39 | 37 |
| 40 // These functions are exected on the background thread. They call through | 38 // These functions are exected on the background thread. They call through |
| 41 // to |background_loader_| to do the actual loading. | 39 // to |background_loader_| to do the actual loading. |
| 42 // TODO: having this code take a |manager| is fragile (as ApplicationManager | 40 // TODO: having this code take a |manager| is fragile (as ApplicationManager |
| 43 // isn't thread safe). | 41 // isn't thread safe). |
| 44 void LoadOnUIThread(ApplicationManager* manager, | 42 void LoadOnUIThread(const GURL& url, |
| 45 const GURL& url, | |
| 46 InterfaceRequest<Application> application_request); | 43 InterfaceRequest<Application> application_request); |
| 47 void OnApplicationErrorOnUIThread(ApplicationManager* manager, | 44 void OnApplicationErrorOnUIThread(ApplicationManager* manager, |
| 48 const GURL& url); | 45 const GURL& url); |
| 49 void ShutdownOnUIThread(); | 46 void ShutdownOnUIThread(); |
| 50 | 47 |
| 51 scoped_ptr<ApplicationLoader> loader_; | 48 scoped_ptr<ApplicationLoader> loader_; |
| 52 base::MessageLoop* ui_message_loop_; | 49 base::MessageLoop* ui_message_loop_; |
| 53 | 50 |
| 54 DISALLOW_COPY_AND_ASSIGN(UIApplicationLoader); | 51 DISALLOW_COPY_AND_ASSIGN(UIApplicationLoader); |
| 55 }; | 52 }; |
| 56 | 53 |
| 57 } // namespace mojo | 54 } // namespace mojo |
| 58 | 55 |
| 59 #endif // SHELL_ANDROID_UI_APPLICATION_LOADER_ANDROID_H_ | 56 #endif // SHELL_ANDROID_UI_APPLICATION_LOADER_ANDROID_H_ |
| OLD | NEW |