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
3 // found in the LICENSE file.
5 #ifndef CHROME_TOOLS_SERVICE_DISCOVERY_SNIFFER_SERVICE_DISCOVERY_SNIFFER_H_
6 #define CHROME_TOOLS_SERVICE_DISCOVERY_SNIFFER_SERVICE_DISCOVERY_SNIFFER_H_
11 #include "base/memory/linked_ptr.h"
12 #include "chrome/common/local_discovery/service_discovery_client.h"
14 namespace local_discovery
{
16 // Resolves a service and prints out information regarding it to the
17 // console. |client| must outlive the ServicePrinter.
18 class ServicePrinter
{
20 ServicePrinter(ServiceDiscoveryClient
* client
,
21 const std::string
& service_name
);
29 void OnServiceResolved(ServiceResolver::RequestStatus status
,
30 const ServiceDescription
& service
);
33 scoped_ptr
<ServiceResolver
> service_resolver_
;
35 DISALLOW_COPY_AND_ASSIGN(ServicePrinter
);
38 // Monitors a service type and prints information regarding all services on it
39 // to the console. |client| must outlive the ServiceTypePrinter.
40 class ServiceTypePrinter
{
42 ServiceTypePrinter(ServiceDiscoveryClient
* client
,
43 const std::string
& service_type
);
44 virtual ~ServiceTypePrinter();
47 void OnServiceUpdated(ServiceWatcher::UpdateType
,
48 const std::string
& service_name
);
51 typedef std::map
<std::string
, linked_ptr
<ServicePrinter
> > ServiceMap
;
54 scoped_ptr
<ServiceWatcher
> watcher_
;
55 ServiceDiscoveryClient
* client_
;
57 DISALLOW_COPY_AND_ASSIGN(ServiceTypePrinter
);
60 } // namespace local_discovery
62 #endif // CHROME_TOOLS_SERVICE_DISCOVERY_SNIFFER_SERVICE_DISCOVERY_SNIFFER_H_