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