Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/extensions/api/dial/mdns_service.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 | |
| 9 using local_discovery::ServiceWatcher; | |
| 10 using local_discovery::ServiceDiscoveryHostClientFactory; | |
| 11 | |
| 12 namespace extensions { | |
| 13 | |
| 14 | |
| 15 MDNSService::MDNSService(std::string service_type) | |
| 16 : service_type_(service_type), | |
| 17 service_discovery_client_(ServiceDiscoveryHostClientFactory::GetClient()), | |
| 18 started_(false) { | |
| 19 } | |
| 20 | |
| 21 MDNSService::~MDNSService() {} | |
| 22 | |
| 23 bool MDNSService::Start() { | |
| 24 if (!started_) { | |
| 25 service_watcher_ = service_discovery_client_->CreateServiceWatcher( | |
| 26 service_type_, | |
| 27 base::Bind(&MDNSService::OnServiceUpdated, | |
| 28 base::Unretained(this))); | |
| 29 service_watcher_->Start(); | |
| 30 started_ = true; | |
| 31 } | |
| 32 return true; | |
| 33 } | |
| 34 | |
| 35 void MDNSService::Stop() { | |
| 36 } | |
| 37 | |
| 38 void MDNSService::Discover(bool force_update) { | |
| 39 service_watcher_->DiscoverNewServices(force_update); | |
| 40 } | |
| 41 | |
| 42 void MDNSService::OnServiceUpdated( | |
| 43 ServiceWatcher::UpdateType update, | |
| 44 const std::string& service_name) { | |
| 45 if (update != ServiceWatcher::UPDATE_REMOVED) { | |
| 46 // bool added = (update == ServiceWatcher::UPDATE_ADDED); | |
| 47 // std::pair<ServiceResolverMap::iterator, bool> insert_result = | |
| 48 // resolvers_.insert(make_pair(service_name, | |
| 49 // linked_ptr<ServiceResolver>(NULL))); | |
| 50 | |
| 51 // // If there is already a resolver working on this service, don't add one. | |
|
mark a. foltz
2013/08/19 18:25:26
Yeah, if we want to use the device we have to fire
| |
| 52 // if (insert_result.second) { | |
| 53 // scoped_ptr<ServiceResolver> resolver = | |
| 54 // service_discovery_client_->CreateServiceResolver( | |
| 55 // service_name, base::Bind( | |
| 56 // &PrivetDeviceListerImpl::OnResolveComplete, | |
| 57 // base::Unretained(this), | |
| 58 // added)); | |
| 59 | |
| 60 // insert_result.first->second.reset(resolver.release()); | |
| 61 // insert_result.first->second->StartResolving(); | |
| 62 // } | |
| 63 } else { | |
| 64 // delegate_->DeviceRemoved(service_name); | |
| 65 } | |
| 66 } | |
| 67 | |
| 68 } // namespace extensions | |
| OLD | NEW |