| 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 #ifndef NET_DNS_MDNS_CLIENT_H_ | 5 #ifndef NET_DNS_MDNS_CLIENT_H_ |
| 6 #define NET_DNS_MDNS_CLIENT_H_ | 6 #define NET_DNS_MDNS_CLIENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // reached, whereas multi-result transactions will not. | 54 // reached, whereas multi-result transactions will not. |
| 55 SINGLE_RESULT = 1 << 0, | 55 SINGLE_RESULT = 1 << 0, |
| 56 // Query the cache or the network. May both be used. One must be present. | 56 // Query the cache or the network. May both be used. One must be present. |
| 57 QUERY_CACHE = 1 << 1, | 57 QUERY_CACHE = 1 << 1, |
| 58 QUERY_NETWORK = 1 << 2, | 58 QUERY_NETWORK = 1 << 2, |
| 59 // TODO(noamsml): Add flag for flushing cache when feature is implemented | 59 // TODO(noamsml): Add flag for flushing cache when feature is implemented |
| 60 // Mask of all possible flags on MDnsTransaction. | 60 // Mask of all possible flags on MDnsTransaction. |
| 61 FLAG_MASK = (1 << 3) - 1, | 61 FLAG_MASK = (1 << 3) - 1, |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 typedef base::Callback<void(Result, const RecordParsed*)> | 64 typedef base::Callback<void(Result, const RecordParsed*)> ResultCallback; |
| 65 ResultCallback; | |
| 66 | 65 |
| 67 // Destroying the transaction cancels it. | 66 // Destroying the transaction cancels it. |
| 68 virtual ~MDnsTransaction() {} | 67 virtual ~MDnsTransaction() {} |
| 69 | 68 |
| 70 // Start the transaction. Return true on success. Cache-based transactions | 69 // Start the transaction. Return true on success. Cache-based transactions |
| 71 // will execute the callback synchronously. | 70 // will execute the callback synchronously. |
| 72 virtual bool Start() = 0; | 71 virtual bool Start() = 0; |
| 73 | 72 |
| 74 // Get the host or service name for the transaction. | 73 // Get the host or service name for the transaction. |
| 75 virtual const std::string& GetName() const = 0; | 74 virtual const std::string& GetName() const = 0; |
| 76 | 75 |
| 77 // Get the type for this transaction (SRV, TXT, A, AAA, etc) | 76 // Get the type for this transaction (SRV, TXT, A, AAA, etc) |
| 78 virtual uint16 GetType() const = 0; | 77 virtual uint16 GetType() const = 0; |
| 79 }; | 78 }; |
| 80 | 79 |
| 81 // A listener listens for updates regarding a specific record or set of records. | 80 // A listener listens for updates regarding a specific record or set of records. |
| 82 // Created by the MDnsClient (see |MDnsClient::CreateListener|) and used to keep | 81 // Created by the MDnsClient (see |MDnsClient::CreateListener|) and used to keep |
| 83 // track of listeners. | 82 // track of listeners. |
| 84 class NET_EXPORT MDnsListener { | 83 class NET_EXPORT MDnsListener { |
| 85 public: | 84 public: |
| 86 // Used in the MDnsListener delegate to signify what type of change has been | 85 // Used in the MDnsListener delegate to signify what type of change has been |
| 87 // made to a record. | 86 // made to a record. |
| 88 enum UpdateType { | 87 enum UpdateType { RECORD_ADDED, RECORD_CHANGED, RECORD_REMOVED }; |
| 89 RECORD_ADDED, | |
| 90 RECORD_CHANGED, | |
| 91 RECORD_REMOVED | |
| 92 }; | |
| 93 | 88 |
| 94 class Delegate { | 89 class Delegate { |
| 95 public: | 90 public: |
| 96 virtual ~Delegate() {} | 91 virtual ~Delegate() {} |
| 97 | 92 |
| 98 // Called when a record is added, removed or updated. | 93 // Called when a record is added, removed or updated. |
| 99 virtual void OnRecordUpdate(UpdateType update, | 94 virtual void OnRecordUpdate(UpdateType update, |
| 100 const RecordParsed* record) = 0; | 95 const RecordParsed* record) = 0; |
| 101 | 96 |
| 102 // Called when a record is marked nonexistent by an NSEC record. | 97 // Called when a record is marked nonexistent by an NSEC record. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // Create sockets, binds socket to MDns endpoint, and sets multicast interface | 173 // Create sockets, binds socket to MDns endpoint, and sets multicast interface |
| 179 // and joins multicast group on for |interface_index|. | 174 // and joins multicast group on for |interface_index|. |
| 180 // Returns NULL if failed. | 175 // Returns NULL if failed. |
| 181 NET_EXPORT scoped_ptr<DatagramServerSocket> CreateAndBindMDnsSocket( | 176 NET_EXPORT scoped_ptr<DatagramServerSocket> CreateAndBindMDnsSocket( |
| 182 AddressFamily address_family, | 177 AddressFamily address_family, |
| 183 uint32 interface_index); | 178 uint32 interface_index); |
| 184 | 179 |
| 185 } // namespace net | 180 } // namespace net |
| 186 | 181 |
| 187 #endif // NET_DNS_MDNS_CLIENT_H_ | 182 #endif // NET_DNS_MDNS_CLIENT_H_ |
| OLD | NEW |