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/service_manager/background_shell_service_loader.h" | 5 #include "mojo/service_manager/background_shell_service_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/service_manager/service_manager.h" | 9 #include "mojo/service_manager/service_manager.h" |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 private: | 28 private: |
29 ServiceLoader* loader_; // Owned by BackgroundShellServiceLoader | 29 ServiceLoader* loader_; // Owned by BackgroundShellServiceLoader |
30 | 30 |
31 DISALLOW_COPY_AND_ASSIGN(BackgroundLoader); | 31 DISALLOW_COPY_AND_ASSIGN(BackgroundLoader); |
32 }; | 32 }; |
33 | 33 |
34 BackgroundShellServiceLoader::BackgroundShellServiceLoader( | 34 BackgroundShellServiceLoader::BackgroundShellServiceLoader( |
35 scoped_ptr<ServiceLoader> real_loader, | 35 scoped_ptr<ServiceLoader> real_loader, |
36 const std::string& thread_name, | 36 const std::string& thread_name, |
37 base::MessageLoop::Type message_loop_type) | 37 base::MessageLoop::Type message_loop_type) |
38 : quit_on_shutdown_(false), | 38 : loader_(real_loader.Pass()), |
39 loader_(real_loader.Pass()), | |
40 message_loop_type_(message_loop_type), | 39 message_loop_type_(message_loop_type), |
41 thread_name_(thread_name), | 40 thread_name_(thread_name), |
42 message_loop_created_(true, false), | 41 message_loop_created_(true, false), |
43 background_loader_(NULL) { | 42 background_loader_(NULL) { |
44 } | 43 } |
45 | 44 |
46 BackgroundShellServiceLoader::~BackgroundShellServiceLoader() { | 45 BackgroundShellServiceLoader::~BackgroundShellServiceLoader() { |
47 if (thread_) { | 46 if (thread_) |
48 if (quit_on_shutdown_) | |
49 task_runner_->PostTask(FROM_HERE, quit_closure_); | |
50 thread_->Join(); | 47 thread_->Join(); |
51 } | |
52 } | 48 } |
53 | 49 |
54 void BackgroundShellServiceLoader::LoadService( | 50 void BackgroundShellServiceLoader::LoadService( |
55 ServiceManager* manager, | 51 ServiceManager* manager, |
56 const GURL& url, | 52 const GURL& url, |
57 ScopedMessagePipeHandle shell_handle) { | 53 ScopedMessagePipeHandle shell_handle) { |
58 if (!thread_) { | 54 if (!thread_) { |
59 // TODO(tim): It'd be nice if we could just have each LoadService call | 55 // TODO(tim): It'd be nice if we could just have each LoadService call |
60 // result in a new thread like DynamicService{Loader, Runner}. But some | 56 // result in a new thread like DynamicService{Loader, Runner}. But some |
61 // loaders are creating multiple ApplicationImpls (NetworkServiceLoader) | 57 // loaders are creating multiple ApplicationImpls (NetworkServiceLoader) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 105 |
110 void BackgroundShellServiceLoader::OnServiceErrorOnBackgroundThread( | 106 void BackgroundShellServiceLoader::OnServiceErrorOnBackgroundThread( |
111 ServiceManager* manager, const GURL& url) { | 107 ServiceManager* manager, const GURL& url) { |
112 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 108 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
113 if (!background_loader_) | 109 if (!background_loader_) |
114 background_loader_ = new BackgroundLoader(loader_.get()); | 110 background_loader_ = new BackgroundLoader(loader_.get()); |
115 background_loader_->OnServiceError(manager, url); | 111 background_loader_->OnServiceError(manager, url); |
116 } | 112 } |
117 | 113 |
118 } // namespace mojo | 114 } // namespace mojo |
OLD | NEW |