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/standalone/android/background_application_loader.h" | 5 #include "mojo/shell/standalone/android/background_application_loader.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 thread_name_(thread_name), | 22 thread_name_(thread_name), |
23 message_loop_created_(true, false) {} | 23 message_loop_created_(true, false) {} |
24 | 24 |
25 BackgroundApplicationLoader::~BackgroundApplicationLoader() { | 25 BackgroundApplicationLoader::~BackgroundApplicationLoader() { |
26 if (thread_) | 26 if (thread_) |
27 thread_->Join(); | 27 thread_->Join(); |
28 } | 28 } |
29 | 29 |
30 void BackgroundApplicationLoader::Load( | 30 void BackgroundApplicationLoader::Load( |
31 const GURL& url, | 31 const GURL& url, |
32 InterfaceRequest<Application> application_request) { | 32 InterfaceRequest<mojom::Application> application_request) { |
33 DCHECK(application_request.is_pending()); | 33 DCHECK(application_request.is_pending()); |
34 if (!thread_) { | 34 if (!thread_) { |
35 // TODO(tim): It'd be nice if we could just have each Load call | 35 // TODO(tim): It'd be nice if we could just have each Load call |
36 // result in a new thread like DynamicService{Loader, Runner}. But some | 36 // result in a new thread like DynamicService{Loader, Runner}. But some |
37 // loaders are creating multiple ApplicationImpls (NetworkApplicationLoader) | 37 // loaders are creating multiple ApplicationImpls (NetworkApplicationLoader) |
38 // sharing a delegate (etc). So we have to keep it single threaded, wait | 38 // sharing a delegate (etc). So we have to keep it single threaded, wait |
39 // for the thread to initialize, and post to the TaskRunner for subsequent | 39 // for the thread to initialize, and post to the TaskRunner for subsequent |
40 // Load calls for now. | 40 // Load calls for now. |
41 thread_.reset(new base::DelegateSimpleThread(this, thread_name_)); | 41 thread_.reset(new base::DelegateSimpleThread(this, thread_name_)); |
42 thread_->Start(); | 42 thread_->Start(); |
(...skipping 15 matching lines...) Expand all Loading... |
58 quit_closure_ = loop.QuitClosure(); | 58 quit_closure_ = loop.QuitClosure(); |
59 message_loop_created_.Signal(); | 59 message_loop_created_.Signal(); |
60 loop.Run(); | 60 loop.Run(); |
61 | 61 |
62 // Destroy |loader_| on the thread it's actually used on. | 62 // Destroy |loader_| on the thread it's actually used on. |
63 loader_.reset(); | 63 loader_.reset(); |
64 } | 64 } |
65 | 65 |
66 void BackgroundApplicationLoader::LoadOnBackgroundThread( | 66 void BackgroundApplicationLoader::LoadOnBackgroundThread( |
67 const GURL& url, | 67 const GURL& url, |
68 InterfaceRequest<Application> application_request) { | 68 InterfaceRequest<mojom::Application> application_request) { |
69 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 69 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
70 loader_->Load(url, std::move(application_request)); | 70 loader_->Load(url, std::move(application_request)); |
71 } | 71 } |
72 | 72 |
73 } // namespace shell | 73 } // namespace shell |
74 } // namespace mojo | 74 } // namespace mojo |
OLD | NEW |