Chromium Code Reviews| 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..b233d358805b19b4c03648f3d774ecac76704aee |
| --- /dev/null |
| +++ b/cloud_print/gcp20/prototype/dns_txt_builder.cc |
| @@ -0,0 +1,30 @@ |
| +// 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. |
|
gene
2013/06/15 02:13:23
it looks like you can add length directly here:
in
maksymb
2013/06/18 01:14:48
Sure. This strange code appeared because of double
|
| + record += str; |
| + int len = strlen(str); |
| + DCHECK_LT(len, 256); |
| + record[length_ptr] = static_cast<char>(len); // Set length byte. |
| +} |
| + |
| +const std::string& DnsTxtBuilder::Build() const { |
| + return record; |
| +} |
| + |