| 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 MOJO_SHELL_UI_SERVICE_LOADER_ANDROID_H_ | 5 #ifndef MOJO_SHELL_UI_SERVICE_LOADER_ANDROID_H_ |
| 6 #define MOJO_SHELL_UI_SERVICE_LOADER_ANDROID_H_ | 6 #define MOJO_SHELL_UI_SERVICE_LOADER_ANDROID_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "mojo/service_manager/service_loader.h" | 9 #include "mojo/service_manager/service_loader.h" |
| 10 | 10 |
| 11 namespace mojo { | 11 namespace mojo { |
| 12 | 12 |
| 13 class ServiceManager; | 13 class ServiceManager; |
| 14 | 14 |
| 15 namespace shell { | 15 namespace shell { |
| 16 class Context; | 16 class Context; |
| 17 } | 17 } |
| 18 | 18 |
| 19 // ServiceLoader implementation that creates a background thread and issues load | 19 // ServiceLoader implementation that creates a background thread and issues load |
| 20 // requests there. | 20 // requests there. |
| 21 class UIServiceLoader : public ServiceLoader { | 21 class UIServiceLoader : public ServiceLoader { |
| 22 public: | 22 public: |
| 23 UIServiceLoader(scoped_ptr<ServiceLoader> real_loader, | 23 UIServiceLoader(scoped_ptr<ServiceLoader> real_loader, |
| 24 shell::Context* context); | 24 shell::Context* context); |
| 25 virtual ~UIServiceLoader(); | 25 virtual ~UIServiceLoader(); |
| 26 | 26 |
| 27 // ServiceLoader overrides: | 27 // ServiceLoader overrides: |
| 28 virtual void Load(ServiceManager* manager, | 28 virtual void LoadService(ServiceManager* manager, |
| 29 const GURL& url, | 29 const GURL& url, |
| 30 scoped_refptr<LoadCallbacks> callbacks) OVERRIDE; | 30 ScopedMessagePipeHandle shell_handle) OVERRIDE; |
| 31 virtual void OnServiceError(ServiceManager* manager, | 31 virtual void OnServiceError(ServiceManager* manager, |
| 32 const GURL& url) OVERRIDE; | 32 const GURL& url) OVERRIDE; |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 class UILoader; | 35 class UILoader; |
| 36 | 36 |
| 37 // These functions are exected on the background thread. They call through | 37 // These functions are exected on the background thread. They call through |
| 38 // to |background_loader_| to do the actual loading. | 38 // to |background_loader_| to do the actual loading. |
| 39 // TODO: having this code take a |manager| is fragile (as ServiceManager isn't | 39 // TODO: having this code take a |manager| is fragile (as ServiceManager isn't |
| 40 // thread safe). | 40 // thread safe). |
| 41 void LoadOnUIThread(ServiceManager* manager, | 41 void LoadServiceOnUIThread(ServiceManager* manager, |
| 42 const GURL& url, | 42 const GURL& url, |
| 43 ScopedMessagePipeHandle* shell_handle); | 43 ScopedMessagePipeHandle* shell_handle); |
| 44 void OnServiceErrorOnUIThread(ServiceManager* manager, const GURL& url); | 44 void OnServiceErrorOnUIThread(ServiceManager* manager, const GURL& url); |
| 45 void ShutdownOnUIThread(); | 45 void ShutdownOnUIThread(); |
| 46 | 46 |
| 47 scoped_ptr<ServiceLoader> loader_; | 47 scoped_ptr<ServiceLoader> loader_; |
| 48 shell::Context* context_; | 48 shell::Context* context_; |
| 49 | 49 |
| 50 // Lives on the UI thread. Trivial interface that calls through to |loader_|. | 50 // Lives on the UI thread. Trivial interface that calls through to |loader_|. |
| 51 UILoader* ui_loader_; | 51 UILoader* ui_loader_; |
| 52 | 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(UIServiceLoader); | 53 DISALLOW_COPY_AND_ASSIGN(UIServiceLoader); |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 } // namespace mojo | 56 } // namespace mojo |
| 57 | 57 |
| 58 #endif // MOJO_SHELL_UI_SERVICE_LOADER_ANDROID_H_ | 58 #endif // MOJO_SHELL_UI_SERVICE_LOADER_ANDROID_H_ |
| OLD | NEW |