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_service_loader.h" | 5 #include "mojo/service_manager/background_service_loader.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "mojo/service_manager/service_manager.h" | 8 #include "mojo/service_manager/service_manager.h" |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
11 | 11 |
12 class BackgroundServiceLoader::BackgroundLoader { | 12 class BackgroundServiceLoader::BackgroundLoader { |
13 public: | 13 public: |
14 explicit BackgroundLoader(ServiceLoader* loader) : loader_(loader) {} | 14 explicit BackgroundLoader(ServiceLoader* loader) : loader_(loader) {} |
15 ~BackgroundLoader() {} | 15 ~BackgroundLoader() {} |
16 | 16 |
17 void LoadService(ServiceManager* manager, | 17 void LoadService(ServiceManager* manager, |
18 const GURL& url, | 18 const GURL& url, |
19 ScopedMessagePipeHandle shell_handle) { | 19 ScopedMessagePipeHandle service_provider_handle) { |
20 loader_->LoadService(manager, url, shell_handle.Pass()); | 20 loader_->LoadService(manager, url, service_provider_handle.Pass()); |
21 } | 21 } |
22 | 22 |
23 void OnServiceError(ServiceManager* manager, const GURL& url) { | 23 void OnServiceError(ServiceManager* manager, const GURL& url) { |
24 loader_->OnServiceError(manager, url); | 24 loader_->OnServiceError(manager, url); |
25 } | 25 } |
26 | 26 |
27 private: | 27 private: |
28 base::MessageLoop::Type message_loop_type_; | 28 base::MessageLoop::Type message_loop_type_; |
29 ServiceLoader* loader_; // Owned by BackgroundServiceLoader | 29 ServiceLoader* loader_; // Owned by BackgroundServiceLoader |
30 | 30 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 thread_.Start(); | 73 thread_.Start(); |
74 thread_.message_loop()->PostTask( | 74 thread_.message_loop()->PostTask( |
75 FROM_HERE, | 75 FROM_HERE, |
76 base::Bind(&BackgroundServiceLoader::OnServiceErrorOnBackgroundThread, | 76 base::Bind(&BackgroundServiceLoader::OnServiceErrorOnBackgroundThread, |
77 base::Unretained(this), manager, url)); | 77 base::Unretained(this), manager, url)); |
78 } | 78 } |
79 | 79 |
80 void BackgroundServiceLoader::LoadServiceOnBackgroundThread( | 80 void BackgroundServiceLoader::LoadServiceOnBackgroundThread( |
81 ServiceManager* manager, | 81 ServiceManager* manager, |
82 const GURL& url, | 82 const GURL& url, |
83 ScopedMessagePipeHandle* shell_handle) { | 83 ScopedMessagePipeHandle* service_provider_handle) { |
84 if (!background_loader_) | 84 if (!background_loader_) |
85 background_loader_ = new BackgroundLoader(loader_.get()); | 85 background_loader_ = new BackgroundLoader(loader_.get()); |
86 background_loader_->LoadService(manager, url, shell_handle->Pass()); | 86 background_loader_->LoadService( |
| 87 manager, url, service_provider_handle->Pass()); |
87 } | 88 } |
88 | 89 |
89 void BackgroundServiceLoader::OnServiceErrorOnBackgroundThread( | 90 void BackgroundServiceLoader::OnServiceErrorOnBackgroundThread( |
90 ServiceManager* manager, | 91 ServiceManager* manager, |
91 const GURL& url) { | 92 const GURL& url) { |
92 if (!background_loader_) | 93 if (!background_loader_) |
93 background_loader_ = new BackgroundLoader(loader_.get()); | 94 background_loader_ = new BackgroundLoader(loader_.get()); |
94 background_loader_->OnServiceError(manager, url); | 95 background_loader_->OnServiceError(manager, url); |
95 } | 96 } |
96 | 97 |
97 void BackgroundServiceLoader::ShutdownOnBackgroundThread() { | 98 void BackgroundServiceLoader::ShutdownOnBackgroundThread() { |
98 delete background_loader_; | 99 delete background_loader_; |
99 // Destroy |loader_| on the thread it's actually used on. | 100 // Destroy |loader_| on the thread it's actually used on. |
100 loader_.reset(); | 101 loader_.reset(); |
101 } | 102 } |
102 | 103 |
103 } // namespace mojo | 104 } // namespace mojo |
OLD | NEW |