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_APPLICATION_MANAGER_BACKGROUND_SHELL_APPLICATION_LOADER_H_ | 5 #ifndef MOJO_APPLICATION_MANAGER_BACKGROUND_SHELL_APPLICATION_LOADER_H_ |
6 #define MOJO_APPLICATION_MANAGER_BACKGROUND_SHELL_APPLICATION_LOADER_H_ | 6 #define MOJO_APPLICATION_MANAGER_BACKGROUND_SHELL_APPLICATION_LOADER_H_ |
7 | 7 |
| 8 #include "base/macros.h" |
8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
10 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
11 #include "base/threading/simple_thread.h" | 12 #include "base/threading/simple_thread.h" |
12 #include "mojo/application_manager/application_loader.h" | 13 #include "mojo/application_manager/application_loader.h" |
13 | 14 |
14 namespace mojo { | 15 namespace mojo { |
15 | 16 |
16 // TODO(tim): Eventually this should be Android-only to support services | 17 // TODO(tim): Eventually this should be Android-only to support services |
17 // that we need to bundle with the shell (such as NetworkService). Perhaps | 18 // that we need to bundle with the shell (such as NetworkService). Perhaps |
18 // we should move it to shell/ as well. | 19 // we should move it to shell/ as well. |
19 class MOJO_APPLICATION_MANAGER_EXPORT BackgroundShellApplicationLoader | 20 class MOJO_APPLICATION_MANAGER_EXPORT BackgroundShellApplicationLoader |
20 : public ApplicationLoader, | 21 : public ApplicationLoader, |
21 public base::DelegateSimpleThread::Delegate { | 22 public base::DelegateSimpleThread::Delegate { |
22 public: | 23 public: |
23 BackgroundShellApplicationLoader(scoped_ptr<ApplicationLoader> real_loader, | 24 BackgroundShellApplicationLoader(scoped_ptr<ApplicationLoader> real_loader, |
24 const std::string& thread_name, | 25 const std::string& thread_name, |
25 base::MessageLoop::Type message_loop_type); | 26 base::MessageLoop::Type message_loop_type); |
26 virtual ~BackgroundShellApplicationLoader(); | 27 virtual ~BackgroundShellApplicationLoader(); |
27 | 28 |
28 // ApplicationLoader overrides: | 29 // ApplicationLoader overrides: |
29 virtual void Load(ApplicationManager* manager, | 30 virtual void Load(ApplicationManager* manager, |
30 const GURL& url, | 31 const GURL& url, |
31 scoped_refptr<LoadCallbacks> callbacks) OVERRIDE; | 32 scoped_refptr<LoadCallbacks> callbacks) override; |
32 virtual void OnApplicationError(ApplicationManager* manager, | 33 virtual void OnApplicationError(ApplicationManager* manager, |
33 const GURL& url) OVERRIDE; | 34 const GURL& url) override; |
34 | 35 |
35 private: | 36 private: |
36 class BackgroundLoader; | 37 class BackgroundLoader; |
37 | 38 |
38 // |base::DelegateSimpleThread::Delegate| method: | 39 // |base::DelegateSimpleThread::Delegate| method: |
39 virtual void Run() OVERRIDE; | 40 virtual void Run() override; |
40 | 41 |
41 // These functions are exected on the background thread. They call through | 42 // These functions are exected on the background thread. They call through |
42 // to |background_loader_| to do the actual loading. | 43 // to |background_loader_| to do the actual loading. |
43 // TODO: having this code take a |manager| is fragile (as ApplicationManager | 44 // TODO: having this code take a |manager| is fragile (as ApplicationManager |
44 // isn't thread safe). | 45 // isn't thread safe). |
45 void LoadOnBackgroundThread(ApplicationManager* manager, | 46 void LoadOnBackgroundThread(ApplicationManager* manager, |
46 const GURL& url, | 47 const GURL& url, |
47 ScopedMessagePipeHandle* shell_handle); | 48 ScopedMessagePipeHandle* shell_handle); |
48 void OnApplicationErrorOnBackgroundThread(ApplicationManager* manager, | 49 void OnApplicationErrorOnBackgroundThread(ApplicationManager* manager, |
49 const GURL& url); | 50 const GURL& url); |
(...skipping 17 matching lines...) Expand all Loading... |
67 | 68 |
68 // Lives on |thread_|. Trivial interface that calls through to |loader_|. | 69 // Lives on |thread_|. Trivial interface that calls through to |loader_|. |
69 BackgroundLoader* background_loader_; | 70 BackgroundLoader* background_loader_; |
70 | 71 |
71 DISALLOW_COPY_AND_ASSIGN(BackgroundShellApplicationLoader); | 72 DISALLOW_COPY_AND_ASSIGN(BackgroundShellApplicationLoader); |
72 }; | 73 }; |
73 | 74 |
74 } // namespace mojo | 75 } // namespace mojo |
75 | 76 |
76 #endif // MOJO_APPLICATION_MANAGER_BACKGROUND_SHELL_APPLICATION_LOADER_H_ | 77 #endif // MOJO_APPLICATION_MANAGER_BACKGROUND_SHELL_APPLICATION_LOADER_H_ |
OLD | NEW |