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

Unified Diff: cloud_print/gcp20/prototype/dns_txt_builder.cc

Issue 16975004: Finished DNS-SD server. Finished Privet-specified DNS-SD server. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Lint errors. 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
Index: cloud_print/gcp20/prototype/dns_txt_builder.cc
diff --git a/cloud_print/gcp20/prototype/dns_txt_builder.cc b/cloud_print/gcp20/prototype/dns_txt_builder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5c6d92332b4912d808cd6baac2e84db6d040c8d8
--- /dev/null
+++ b/cloud_print/gcp20/prototype/dns_txt_builder.cc
@@ -0,0 +1,34 @@
+// 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.
+
+#include "cloud_print/gcp20/prototype/dns_txt_builder.h"
+
+#include <string.h>
+
+#include "base/logging.h"
+#include "base/strings/string_piece.h"
+
+DnsTxtBuilder::DnsTxtBuilder() {
+}
+
+DnsTxtBuilder::~DnsTxtBuilder() {
+}
+
+void DnsTxtBuilder::AddRecord(const char* str) {
+ size_t length_ptr = record.size(); // Remember position of length byte.
+ record += '\0'; // Allocate space for length byte.
+ record += str;
+ int len = strlen(str);
+ DCHECK_LT(len, 256);
+ record[length_ptr] = static_cast<char>(len); // Set length byte.
+}
+
+void DnsTxtBuilder::Build(std::string* out) const {
+ *out = record;
+}
+
+const std::string& DnsTxtBuilder::Build() const {
+ return record;
+}
+

Powered by Google App Engine
This is Rietveld 408576698