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 LoadService(ServiceManager* manager, | 28 virtual void LoadService( |
29 const GURL& url, | 29 ServiceManager* manager, |
30 ScopedMessagePipeHandle shell_handle) OVERRIDE; | 30 const GURL& url, |
| 31 scoped_refptr<LoadServiceCallbacks> callbacks) OVERRIDE; |
31 virtual void OnServiceError(ServiceManager* manager, | 32 virtual void OnServiceError(ServiceManager* manager, |
32 const GURL& url) OVERRIDE; | 33 const GURL& url) OVERRIDE; |
33 | 34 |
34 private: | 35 private: |
35 class UILoader; | 36 class UILoader; |
36 | 37 |
37 // These functions are exected on the background thread. They call through | 38 // These functions are exected on the background thread. They call through |
38 // to |background_loader_| to do the actual loading. | 39 // to |background_loader_| to do the actual loading. |
39 // TODO: having this code take a |manager| is fragile (as ServiceManager isn't | 40 // TODO: having this code take a |manager| is fragile (as ServiceManager isn't |
40 // thread safe). | 41 // thread safe). |
41 void LoadServiceOnUIThread(ServiceManager* manager, | 42 void LoadServiceOnUIThread(ServiceManager* manager, |
42 const GURL& url, | 43 const GURL& url, |
43 ScopedMessagePipeHandle* shell_handle); | 44 ScopedMessagePipeHandle shell_handle); |
44 void OnServiceErrorOnUIThread(ServiceManager* manager, const GURL& url); | 45 void OnServiceErrorOnUIThread(ServiceManager* manager, const GURL& url); |
45 void ShutdownOnUIThread(); | 46 void ShutdownOnUIThread(); |
46 | 47 |
47 scoped_ptr<ServiceLoader> loader_; | 48 scoped_ptr<ServiceLoader> loader_; |
48 shell::Context* context_; | 49 shell::Context* context_; |
49 | 50 |
50 // Lives on the UI thread. Trivial interface that calls through to |loader_|. | 51 // Lives on the UI thread. Trivial interface that calls through to |loader_|. |
51 UILoader* ui_loader_; | 52 UILoader* ui_loader_; |
52 | 53 |
53 DISALLOW_COPY_AND_ASSIGN(UIServiceLoader); | 54 DISALLOW_COPY_AND_ASSIGN(UIServiceLoader); |
54 }; | 55 }; |
55 | 56 |
56 } // namespace mojo | 57 } // namespace mojo |
57 | 58 |
58 #endif // MOJO_SHELL_UI_SERVICE_LOADER_ANDROID_H_ | 59 #endif // MOJO_SHELL_UI_SERVICE_LOADER_ANDROID_H_ |
OLD | NEW |