libweave: Port base/ changes from Chromium project

Now this makes the state of base/ match libchrome's implementation
on Brillo and Chrome OS.

Change-Id: I1c1eb30d2669aeb58a77f332f8c69f130d00878c
Reviewed-on: https://weave-review.googlesource.com/3065
Reviewed-by: Robert Ginda <rginda@google.com>
diff --git a/third_party/chromium/base/strings/string_util.cc b/third_party/chromium/base/strings/string_util.cc
index eb0c546..50f7a23 100644
--- a/third_party/chromium/base/strings/string_util.cc
+++ b/third_party/chromium/base/strings/string_util.cc
@@ -242,4 +242,17 @@
   return true;
 }
 
+
+template <class string_type>
+inline typename string_type::value_type* WriteIntoT(string_type* str,
+                                                    size_t length_with_null) {
+  DCHECK_GT(length_with_null, 1u);
+  str->reserve(length_with_null);
+  str->resize(length_with_null - 1);
+  return &((*str)[0]);
+}
+
+char* WriteInto(std::string* str, size_t length_with_null) {
+  return WriteIntoT(str, length_with_null);
+}
 }  // namespace base