Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/local_discovery/service_discovery_host_client.h" | 5 #include "chrome/browser/local_discovery/service_discovery_host_client.h" |
| 6 | 6 |
| 7 #include "chrome/common/local_discovery/local_discovery_messages.h" | 7 #include "chrome/common/local_discovery/local_discovery_messages.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "content/public/browser/utility_process_host.h" | 9 #include "content/public/browser/utility_process_host.h" |
| 10 | 10 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 BrowserThread::IO, | 151 BrowserThread::IO, |
| 152 FROM_HERE, | 152 FROM_HERE, |
| 153 base::Bind(&ServiceDiscoveryHostClient::StartOnIOThread, this)); | 153 base::Bind(&ServiceDiscoveryHostClient::StartOnIOThread, this)); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void ServiceDiscoveryHostClient::Shutdown() { | 156 void ServiceDiscoveryHostClient::Shutdown() { |
| 157 DCHECK(CalledOnValidThread()); | 157 DCHECK(CalledOnValidThread()); |
| 158 BrowserThread::PostTask( | 158 BrowserThread::PostTask( |
| 159 BrowserThread::IO, | 159 BrowserThread::IO, |
| 160 FROM_HERE, | 160 FROM_HERE, |
| 161 base::Bind(&ServiceDiscoveryHostClient::ShutdownOnIOThread, this)); | 161 base::Bind(&ServiceDiscoveryHostClient::ShutdownOnIOThread, this)); |
|
Noam Samuel
2013/07/18 16:29:07
Is there a potential race condition here if shutdo
Vitaly Buka (NO REVIEWS)
2013/07/18 18:16:16
No.
| |
| 162 } | 162 } |
| 163 | 163 |
| 164 void ServiceDiscoveryHostClient::StartOnIOThread() { | 164 void ServiceDiscoveryHostClient::StartOnIOThread() { |
| 165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 166 utility_host_ = UtilityProcessHost::Create( | 166 utility_host_ = UtilityProcessHost::Create( |
| 167 this, base::MessageLoopProxy::current().get())->AsWeakPtr(); | 167 this, base::MessageLoopProxy::current().get())->AsWeakPtr(); |
| 168 if (utility_host_) { | 168 if (utility_host_) { |
| 169 utility_host_->EnableZygote(); | 169 utility_host_->EnableZygote(); |
| 170 // TODO(vitalybuka): enable sandbox. http://crbug.com/245391 | 170 utility_host_->EnableMDns(); |
| 171 utility_host_->DisableSandbox(); | |
| 172 utility_host_->StartBatchMode(); | 171 utility_host_->StartBatchMode(); |
| 173 } | 172 } |
| 174 } | 173 } |
| 175 | 174 |
| 176 void ServiceDiscoveryHostClient::ShutdownOnIOThread() { | 175 void ServiceDiscoveryHostClient::ShutdownOnIOThread() { |
| 177 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 178 if (utility_host_) | 177 if (utility_host_) |
| 179 utility_host_->EndBatchMode(); | 178 utility_host_->EndBatchMode(); |
| 180 } | 179 } |
| 181 | 180 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 uint64 id, | 236 uint64 id, |
| 238 ServiceResolver::RequestStatus status, | 237 ServiceResolver::RequestStatus status, |
| 239 const ServiceDescription& description) { | 238 const ServiceDescription& description) { |
| 240 DCHECK(CalledOnValidThread()); | 239 DCHECK(CalledOnValidThread()); |
| 241 ResolverCallbacks::iterator it = service_resolver_callbacks_.find(id); | 240 ResolverCallbacks::iterator it = service_resolver_callbacks_.find(id); |
| 242 if (it != service_resolver_callbacks_.end() && !it->second.is_null()) | 241 if (it != service_resolver_callbacks_.end() && !it->second.is_null()) |
| 243 it->second.Run(status, description); | 242 it->second.Run(status, description); |
| 244 } | 243 } |
| 245 | 244 |
| 246 } // namespace local_discovery | 245 } // namespace local_discovery |
| OLD | NEW |