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

Unified Diff: third_party/WebKit/Source/platform/exported/URLConversion.cpp

Issue 1568073002: Reduce string copies in GURL creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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: third_party/WebKit/Source/platform/exported/URLConversion.cpp
diff --git a/third_party/WebKit/Source/platform/exported/URLConversion.cpp b/third_party/WebKit/Source/platform/exported/URLConversion.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..35542e35f5661e5e6394105c5a053a1ac526d69f
--- /dev/null
+++ b/third_party/WebKit/Source/platform/exported/URLConversion.cpp
@@ -0,0 +1,27 @@
+// Copyright 2016 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 "public/platform/URLConversion.h"
+
+#include "public/platform/WebString.h"
+#include "url/gurl.h"
+#include "wtf/text/StringUTF8Adaptor.h"
+#include "wtf/text/WTFString.h"
+
+namespace blink {
+
+GURL WebStringToGURL(const WebString& webStr)
esprehn 2016/01/14 01:47:59 webString
+{
+ WTF::String str = webStr;
esprehn 2016/01/14 01:47:59 no need for WTF:: prefix. also wtfString, don't a
+ if (str.is8Bit()) {
+ // Ensure the (possibly Latin-1) 8-bit string is UTF-8 for GURL.
+ WTF::StringUTF8Adaptor utf8(str);
+ return GURL(utf8.asStringPiece());
esprehn 2016/01/14 01:47:59 Note that this isn't safe unless the GURL copies t
+ }
+
+ // GURL can consume UTF-16 directly.
+ return GURL(base::StringPiece16(str.characters16(), str.length()));
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698