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

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
« no previous file with comments | « third_party/WebKit/Source/platform/blink_platform.gyp ('k') | third_party/WebKit/public/blink_headers.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7781613fdafe2d0ef63c4beed47d33a8af859ce1
--- /dev/null
+++ b/third_party/WebKit/Source/platform/exported/URLConversion.cpp
@@ -0,0 +1,30 @@
+// 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& webString)
+{
+ if (webString.isEmpty())
+ return GURL();
+
+ String str = webString;
+ if (str.is8Bit()) {
+ // Ensure the (possibly Latin-1) 8-bit string is UTF-8 for GURL.
+ StringUTF8Adaptor utf8(str);
+ return GURL(utf8.asStringPiece());
+ }
+
+ // GURL can consume UTF-16 directly.
+ return GURL(base::StringPiece16(str.characters16(), str.length()));
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/blink_platform.gyp ('k') | third_party/WebKit/public/blink_headers.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698