| 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/tools/service_discovery_sniffer/service_discovery_sniffer.h" | 5 #include "chrome/tools/service_discovery_sniffer/service_discovery_sniffer.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 ServiceTypePrinter::ServiceTypePrinter(ServiceDiscoveryClient* client, | 67 ServiceTypePrinter::ServiceTypePrinter(ServiceDiscoveryClient* client, |
| 68 const std::string& service_type) | 68 const std::string& service_type) |
| 69 : client_(client) { | 69 : client_(client) { |
| 70 watcher_ = client_->CreateServiceWatcher( | 70 watcher_ = client_->CreateServiceWatcher( |
| 71 service_type, base::Bind(&ServiceTypePrinter::OnServiceUpdated, | 71 service_type, base::Bind(&ServiceTypePrinter::OnServiceUpdated, |
| 72 base::Unretained(this))); | 72 base::Unretained(this))); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void ServiceTypePrinter::Start() { | 75 void ServiceTypePrinter::Start() { |
| 76 watcher_->Start(); | 76 watcher_->Start(); |
| 77 watcher_->DiscoverNewServices(false); | 77 watcher_->DiscoverNewServices(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 ServiceTypePrinter::~ServiceTypePrinter() { | 80 ServiceTypePrinter::~ServiceTypePrinter() { |
| 81 } | 81 } |
| 82 | 82 |
| 83 void ServiceTypePrinter::OnServiceUpdated(ServiceWatcher::UpdateType update, | 83 void ServiceTypePrinter::OnServiceUpdated(ServiceWatcher::UpdateType update, |
| 84 const std::string& service_name) { | 84 const std::string& service_name) { |
| 85 if (update == ServiceWatcher::UPDATE_ADDED) { | 85 if (update == ServiceWatcher::UPDATE_ADDED) { |
| 86 services_[service_name].reset(new ServicePrinter(client_, service_name)); | 86 services_[service_name].reset(new ServicePrinter(client_, service_name)); |
| 87 services_[service_name]->Added(); | 87 services_[service_name]->Added(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 116 { | 116 { |
| 117 // To guarantee/make explicit the ordering constraint. | 117 // To guarantee/make explicit the ordering constraint. |
| 118 local_discovery::ServiceTypePrinter print_changes( | 118 local_discovery::ServiceTypePrinter print_changes( |
| 119 service_discovery_client.get(), | 119 service_discovery_client.get(), |
| 120 std::string(argv[1]) + "._tcp.local"); | 120 std::string(argv[1]) + "._tcp.local"); |
| 121 | 121 |
| 122 print_changes.Start(); | 122 print_changes.Start(); |
| 123 base::RunLoop().Run(); | 123 base::RunLoop().Run(); |
| 124 } | 124 } |
| 125 } | 125 } |
| OLD | NEW |