Roll src/third_party/WebKit bf18a82:a9cee16 (svn 185297:185304)
[chromium-blink-merge.git] / chrome / tools / service_discovery_sniffer / service_discovery_sniffer.h
blob43ae3195cc34e1104e541335cd28cf556fe4a5e1
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_
8 #include <map>
9 #include <string>
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 {
19 public:
20 ServicePrinter(ServiceDiscoveryClient* client,
21 const std::string& service_name);
22 ~ServicePrinter();
24 void Added();
25 void Changed();
26 void Removed();
28 private:
29 void OnServiceResolved(ServiceResolver::RequestStatus status,
30 const ServiceDescription& service);
32 bool changed_;
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 {
41 public:
42 ServiceTypePrinter(ServiceDiscoveryClient* client,
43 const std::string& service_type);
44 virtual ~ServiceTypePrinter();
46 void Start();
47 void OnServiceUpdated(ServiceWatcher::UpdateType,
48 const std::string& service_name);
50 private:
51 typedef std::map<std::string, linked_ptr<ServicePrinter> > ServiceMap;
53 ServiceMap services_;
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_