| 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 "mojo/shell/ui_application_loader_android.h" | 5 #include "mojo/shell/ui_application_loader_android.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "mojo/application_manager/application_manager.h" | 8 #include "mojo/application_manager/application_manager.h" |
| 9 #include "mojo/shell/context.h" | 9 #include "mojo/shell/context.h" |
| 10 | 10 |
| 11 namespace mojo { | 11 namespace mojo { |
| 12 | 12 |
| 13 class UIApplicationLoader::UILoader { | 13 class UIApplicationLoader::UILoader { |
| 14 public: | 14 public: |
| 15 explicit UILoader(ApplicationLoader* loader) : loader_(loader) {} | 15 explicit UILoader(ApplicationLoader* loader) : loader_(loader) {} |
| 16 ~UILoader() {} | 16 ~UILoader() {} |
| 17 | 17 |
| 18 void Load(ApplicationManager* manager, | 18 void Load(ApplicationManager* manager, |
| 19 const GURL& url, | 19 const GURL& url, |
| 20 ScopedMessagePipeHandle shell_handle) { | 20 ScopedMessagePipeHandle shell_handle) { |
| 21 scoped_refptr<LoadCallbacks> callbacks( | 21 scoped_refptr<LoadCallbacks> callbacks( |
| 22 new ApplicationLoader::SimpleLoadCallbacks(shell_handle.Pass())); | 22 new ApplicationLoader::SimpleLoadCallbacks(shell_handle.Pass())); |
| 23 loader_->Load(manager, url, callbacks); | 23 loader_->Load(manager, url, callbacks); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void OnServiceError(ApplicationManager* manager, const GURL& url) { | 26 void OnApplicationError(ApplicationManager* manager, const GURL& url) { |
| 27 loader_->OnServiceError(manager, url); | 27 loader_->OnApplicationError(manager, url); |
| 28 } | 28 } |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 ApplicationLoader* loader_; // Owned by UIApplicationLoader | 31 ApplicationLoader* loader_; // Owned by UIApplicationLoader |
| 32 | 32 |
| 33 DISALLOW_COPY_AND_ASSIGN(UILoader); | 33 DISALLOW_COPY_AND_ASSIGN(UILoader); |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 UIApplicationLoader::UIApplicationLoader( | 36 UIApplicationLoader::UIApplicationLoader( |
| 37 scoped_ptr<ApplicationLoader> real_loader, | 37 scoped_ptr<ApplicationLoader> real_loader, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 55 context_->ui_loop()->PostTask( | 55 context_->ui_loop()->PostTask( |
| 56 FROM_HERE, | 56 FROM_HERE, |
| 57 base::Bind( | 57 base::Bind( |
| 58 &UIApplicationLoader::LoadOnUIThread, | 58 &UIApplicationLoader::LoadOnUIThread, |
| 59 base::Unretained(this), | 59 base::Unretained(this), |
| 60 manager, | 60 manager, |
| 61 url, | 61 url, |
| 62 base::Owned(new ScopedMessagePipeHandle(shell_handle.Pass())))); | 62 base::Owned(new ScopedMessagePipeHandle(shell_handle.Pass())))); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void UIApplicationLoader::OnServiceError(ApplicationManager* manager, | 65 void UIApplicationLoader::OnApplicationError(ApplicationManager* manager, |
| 66 const GURL& url) { | 66 const GURL& url) { |
| 67 context_->ui_loop()->PostTask( | 67 context_->ui_loop()->PostTask( |
| 68 FROM_HERE, | 68 FROM_HERE, |
| 69 base::Bind(&UIApplicationLoader::OnServiceErrorOnUIThread, | 69 base::Bind(&UIApplicationLoader::OnApplicationErrorOnUIThread, |
| 70 base::Unretained(this), | 70 base::Unretained(this), |
| 71 manager, | 71 manager, |
| 72 url)); | 72 url)); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void UIApplicationLoader::LoadOnUIThread( | 75 void UIApplicationLoader::LoadOnUIThread( |
| 76 ApplicationManager* manager, | 76 ApplicationManager* manager, |
| 77 const GURL& url, | 77 const GURL& url, |
| 78 ScopedMessagePipeHandle* shell_handle) { | 78 ScopedMessagePipeHandle* shell_handle) { |
| 79 if (!ui_loader_) | 79 if (!ui_loader_) |
| 80 ui_loader_ = new UILoader(loader_.get()); | 80 ui_loader_ = new UILoader(loader_.get()); |
| 81 ui_loader_->Load(manager, url, shell_handle->Pass()); | 81 ui_loader_->Load(manager, url, shell_handle->Pass()); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void UIApplicationLoader::OnServiceErrorOnUIThread(ApplicationManager* manager, | 84 void UIApplicationLoader::OnApplicationErrorOnUIThread( |
| 85 const GURL& url) { | 85 ApplicationManager* manager, |
| 86 const GURL& url) { |
| 86 if (!ui_loader_) | 87 if (!ui_loader_) |
| 87 ui_loader_ = new UILoader(loader_.get()); | 88 ui_loader_ = new UILoader(loader_.get()); |
| 88 ui_loader_->OnServiceError(manager, url); | 89 ui_loader_->OnApplicationError(manager, url); |
| 89 } | 90 } |
| 90 | 91 |
| 91 void UIApplicationLoader::ShutdownOnUIThread() { | 92 void UIApplicationLoader::ShutdownOnUIThread() { |
| 92 delete ui_loader_; | 93 delete ui_loader_; |
| 93 // Destroy |loader_| on the thread it's actually used on. | 94 // Destroy |loader_| on the thread it's actually used on. |
| 94 loader_.reset(); | 95 loader_.reset(); |
| 95 } | 96 } |
| 96 | 97 |
| 97 } // namespace mojo | 98 } // namespace mojo |
| OLD | NEW |