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