| 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" |
| 6 |
| 7 #include <memory> |
| 5 #include <vector> | 8 #include <vector> |
| 6 | 9 |
| 7 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| 8 #include "base/bind.h" | 11 #include "base/bind.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 11 #include "chrome/browser/local_discovery/service_discovery_client_impl.h" | 13 #include "chrome/browser/local_discovery/service_discovery_client_impl.h" |
| 12 #include "chrome/tools/service_discovery_sniffer/service_discovery_sniffer.h" | |
| 13 #include "net/dns/mdns_client.h" | 14 #include "net/dns/mdns_client.h" |
| 14 | 15 |
| 15 namespace local_discovery { | 16 namespace local_discovery { |
| 16 | 17 |
| 17 ServicePrinter::ServicePrinter(ServiceDiscoveryClient* client, | 18 ServicePrinter::ServicePrinter(ServiceDiscoveryClient* client, |
| 18 const std::string& service_name) | 19 const std::string& service_name) |
| 19 : changed_(false) { | 20 : changed_(false) { |
| 20 service_resolver_ = | 21 service_resolver_ = |
| 21 client->CreateServiceResolver( | 22 client->CreateServiceResolver( |
| 22 service_name, | 23 service_name, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 96 |
| 96 int main(int argc, char** argv) { | 97 int main(int argc, char** argv) { |
| 97 base::AtExitManager at_exit_manager; | 98 base::AtExitManager at_exit_manager; |
| 98 base::MessageLoopForIO message_loop; | 99 base::MessageLoopForIO message_loop; |
| 99 | 100 |
| 100 if (argc != 2) { | 101 if (argc != 2) { |
| 101 printf("Please provide exactly 1 argument.\n"); | 102 printf("Please provide exactly 1 argument.\n"); |
| 102 return 1; | 103 return 1; |
| 103 } | 104 } |
| 104 | 105 |
| 105 scoped_ptr<net::MDnsClient> mdns_client = net::MDnsClient::CreateDefault(); | 106 std::unique_ptr<net::MDnsClient> mdns_client = |
| 106 scoped_ptr<net::MDnsSocketFactory> socket_factory = | 107 net::MDnsClient::CreateDefault(); |
| 108 std::unique_ptr<net::MDnsSocketFactory> socket_factory = |
| 107 net::MDnsSocketFactory::CreateDefault(); | 109 net::MDnsSocketFactory::CreateDefault(); |
| 108 mdns_client->StartListening(socket_factory.get()); | 110 mdns_client->StartListening(socket_factory.get()); |
| 109 scoped_ptr<local_discovery::ServiceDiscoveryClient> service_discovery_client; | 111 std::unique_ptr<local_discovery::ServiceDiscoveryClient> |
| 112 service_discovery_client; |
| 110 service_discovery_client.reset( | 113 service_discovery_client.reset( |
| 111 new local_discovery::ServiceDiscoveryClientImpl(mdns_client.get())); | 114 new local_discovery::ServiceDiscoveryClientImpl(mdns_client.get())); |
| 112 { | 115 { |
| 113 // To guarantee/make explicit the ordering constraint. | 116 // To guarantee/make explicit the ordering constraint. |
| 114 local_discovery::ServiceTypePrinter print_changes( | 117 local_discovery::ServiceTypePrinter print_changes( |
| 115 service_discovery_client.get(), | 118 service_discovery_client.get(), |
| 116 std::string(argv[1]) + "._tcp.local"); | 119 std::string(argv[1]) + "._tcp.local"); |
| 117 | 120 |
| 118 print_changes.Start(); | 121 print_changes.Start(); |
| 119 message_loop.Run(); | 122 message_loop.Run(); |
| 120 } | 123 } |
| 121 } | 124 } |
| OLD | NEW |