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 #include "shell/ui_application_loader_android.h" | 5 #include "shell/android/ui_application_loader_android.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" |
8 #include "mojo/application_manager/application_manager.h" | 9 #include "mojo/application_manager/application_manager.h" |
9 #include "shell/context.h" | |
10 | 10 |
11 namespace mojo { | 11 namespace mojo { |
12 | 12 |
13 UIApplicationLoader::UIApplicationLoader( | 13 UIApplicationLoader::UIApplicationLoader( |
14 scoped_ptr<ApplicationLoader> real_loader, | 14 scoped_ptr<ApplicationLoader> real_loader, |
15 shell::Context* context) | 15 base::MessageLoop* ui_message_loop) |
16 : loader_(real_loader.Pass()), context_(context) { | 16 : loader_(real_loader.Pass()), ui_message_loop_(ui_message_loop) { |
17 } | 17 } |
18 | 18 |
19 UIApplicationLoader::~UIApplicationLoader() { | 19 UIApplicationLoader::~UIApplicationLoader() { |
20 context_->ui_loop()->PostTask( | 20 ui_message_loop_->PostTask( |
21 FROM_HERE, base::Bind(&UIApplicationLoader::ShutdownOnUIThread, | 21 FROM_HERE, base::Bind(&UIApplicationLoader::ShutdownOnUIThread, |
22 base::Unretained(this))); | 22 base::Unretained(this))); |
23 } | 23 } |
24 | 24 |
25 void UIApplicationLoader::Load(ApplicationManager* manager, | 25 void UIApplicationLoader::Load(ApplicationManager* manager, |
26 const GURL& url, | 26 const GURL& url, |
27 ScopedMessagePipeHandle shell_handle, | 27 ScopedMessagePipeHandle shell_handle, |
28 LoadCallback callback) { | 28 LoadCallback callback) { |
29 DCHECK(shell_handle.is_valid()); | 29 DCHECK(shell_handle.is_valid()); |
30 context_->ui_loop()->PostTask( | 30 ui_message_loop_->PostTask( |
31 FROM_HERE, | 31 FROM_HERE, |
32 base::Bind(&UIApplicationLoader::LoadOnUIThread, base::Unretained(this), | 32 base::Bind(&UIApplicationLoader::LoadOnUIThread, base::Unretained(this), |
33 manager, url, base::Passed(&shell_handle))); | 33 manager, url, base::Passed(&shell_handle))); |
34 } | 34 } |
35 | 35 |
36 void UIApplicationLoader::OnApplicationError(ApplicationManager* manager, | 36 void UIApplicationLoader::OnApplicationError(ApplicationManager* manager, |
37 const GURL& url) { | 37 const GURL& url) { |
38 context_->ui_loop()->PostTask( | 38 ui_message_loop_->PostTask( |
39 FROM_HERE, base::Bind(&UIApplicationLoader::OnApplicationErrorOnUIThread, | 39 FROM_HERE, base::Bind(&UIApplicationLoader::OnApplicationErrorOnUIThread, |
40 base::Unretained(this), manager, url)); | 40 base::Unretained(this), manager, url)); |
41 } | 41 } |
42 | 42 |
43 void UIApplicationLoader::LoadOnUIThread(ApplicationManager* manager, | 43 void UIApplicationLoader::LoadOnUIThread(ApplicationManager* manager, |
44 const GURL& url, | 44 const GURL& url, |
45 ScopedMessagePipeHandle shell_handle) { | 45 ScopedMessagePipeHandle shell_handle) { |
46 loader_->Load(manager, url, shell_handle.Pass(), SimpleLoadCallback()); | 46 loader_->Load(manager, url, shell_handle.Pass(), SimpleLoadCallback()); |
47 } | 47 } |
48 | 48 |
49 void UIApplicationLoader::OnApplicationErrorOnUIThread( | 49 void UIApplicationLoader::OnApplicationErrorOnUIThread( |
50 ApplicationManager* manager, | 50 ApplicationManager* manager, |
51 const GURL& url) { | 51 const GURL& url) { |
52 loader_->OnApplicationError(manager, url); | 52 loader_->OnApplicationError(manager, url); |
53 } | 53 } |
54 | 54 |
55 void UIApplicationLoader::ShutdownOnUIThread() { | 55 void UIApplicationLoader::ShutdownOnUIThread() { |
56 // Destroy |loader_| on the thread it's actually used on. | 56 // Destroy |loader_| on the thread it's actually used on. |
57 loader_.reset(); | 57 loader_.reset(); |
58 } | 58 } |
59 | 59 |
60 } // namespace mojo | 60 } // namespace mojo |
OLD | NEW |