Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Unified Diff: cloud_print/gcp20/prototype/dns_sd_server.h

Issue 16389002: GCP2.0 Device: mDNS basics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cloud_print/cloud_print.gyp ('k') | cloud_print/gcp20/prototype/dns_sd_server.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cloud_print/gcp20/prototype/dns_sd_server.h
diff --git a/cloud_print/gcp20/prototype/dns_sd_server.h b/cloud_print/gcp20/prototype/dns_sd_server.h
new file mode 100644
index 0000000000000000000000000000000000000000..9c8ed96b7d33d62790d7797dc061f5b963911f2f
--- /dev/null
+++ b/cloud_print/gcp20/prototype/dns_sd_server.h
@@ -0,0 +1,62 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GCP20_PROTOTYPE_DNS_SD_H_
+#define GCP20_PROTOTYPE_DNS_SD_H_
+
+#include <vector>
+
+#include "net/dns/dns_protocol.h"
+#include "net/udp/udp_socket.h"
+
+// Class for sending multicast announcements, receiving queries and answering on
+// them. Client should call |ProccessMessages| periodically to make server work.
+class DnsSdServer {
+ public:
+ // Constructs unstarted server.
+ DnsSdServer();
+
+ // Stops server.
+ ~DnsSdServer();
+
+ // Starts the server. Returns |true| if server works. Also sends
+ // announcement.
+ bool Start();
+
+ // Sends announcement if server works.
+ void Update();
+
+ // Stops server with announcement.
+ void Shutdown();
+
+ // Process pending queries for the server.
+ void ProcessMessages();
+
+ // Returns |true| if server works.
+ bool is_online() { return is_online_; }
+
+ private:
+ // Binds a socket to multicast address. Returns |true| on success.
+ bool CreateSocket();
+
+ // Sends announcement.
+ void SendAnnouncement(uint32 ttl);
+
+ // Returns |true| if server received some questions.
+ bool CheckPendingQueries();
+
+ // Stores |true| if server was started.
+ bool is_online_;
+
+ // Stores socket to multicast address.
+ scoped_ptr<net::UDPSocket> socket_;
+
+ // Stores multicast address end point.
+ net::IPEndPoint multicast_address_;
+
+ DISALLOW_COPY_AND_ASSIGN(DnsSdServer);
+};
+
+#endif // GCP20_PROTOTYPE_DNS_SD_H_
+
« no previous file with comments | « cloud_print/cloud_print.gyp ('k') | cloud_print/gcp20/prototype/dns_sd_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698