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/application_manager/background_shell_application_loader.h" | 5 #include "mojo/application_manager/background_shell_application_loader.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "mojo/application_manager/application_manager.h" | 9 #include "mojo/application_manager/application_manager.h" |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 if (!thread_) { | 60 if (!thread_) { |
61 // TODO(tim): It'd be nice if we could just have each Load call | 61 // TODO(tim): It'd be nice if we could just have each Load call |
62 // result in a new thread like DynamicService{Loader, Runner}. But some | 62 // result in a new thread like DynamicService{Loader, Runner}. But some |
63 // loaders are creating multiple ApplicationImpls (NetworkApplicationLoader) | 63 // loaders are creating multiple ApplicationImpls (NetworkApplicationLoader) |
64 // sharing a delegate (etc). So we have to keep it single threaded, wait | 64 // sharing a delegate (etc). So we have to keep it single threaded, wait |
65 // for the thread to initialize, and post to the TaskRunner for subsequent | 65 // for the thread to initialize, and post to the TaskRunner for subsequent |
66 // Load calls for now. | 66 // Load calls for now. |
67 thread_.reset(new base::DelegateSimpleThread(this, thread_name_)); | 67 thread_.reset(new base::DelegateSimpleThread(this, thread_name_)); |
68 thread_->Start(); | 68 thread_->Start(); |
69 message_loop_created_.Wait(); | 69 message_loop_created_.Wait(); |
70 DCHECK(task_runner_); | 70 DCHECK(task_runner_.get()); |
71 } | 71 } |
72 | 72 |
73 task_runner_->PostTask( | 73 task_runner_->PostTask( |
74 FROM_HERE, | 74 FROM_HERE, |
75 base::Bind( | 75 base::Bind( |
76 &BackgroundShellApplicationLoader::LoadOnBackgroundThread, | 76 &BackgroundShellApplicationLoader::LoadOnBackgroundThread, |
77 base::Unretained(this), | 77 base::Unretained(this), |
78 manager, | 78 manager, |
79 url, | 79 url, |
80 base::Owned(new ScopedMessagePipeHandle(shell_handle.Pass())))); | 80 base::Owned(new ScopedMessagePipeHandle(shell_handle.Pass())))); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 void BackgroundShellApplicationLoader::OnServiceErrorOnBackgroundThread( | 119 void BackgroundShellApplicationLoader::OnServiceErrorOnBackgroundThread( |
120 ApplicationManager* manager, | 120 ApplicationManager* manager, |
121 const GURL& url) { | 121 const GURL& url) { |
122 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 122 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
123 if (!background_loader_) | 123 if (!background_loader_) |
124 background_loader_ = new BackgroundLoader(loader_.get()); | 124 background_loader_ = new BackgroundLoader(loader_.get()); |
125 background_loader_->OnServiceError(manager, url); | 125 background_loader_->OnServiceError(manager, url); |
126 } | 126 } |
127 | 127 |
128 } // namespace mojo | 128 } // namespace mojo |
OLD | NEW |