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

Unified Diff: third_party/WebKit/public/platform/WebStringUTF8Adaptor.h

Issue 1568073002: Reduce string copies in GURL creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Mojo issues 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/public/platform/WebStringUTF8Adaptor.h
diff --git a/third_party/WebKit/public/web/WebCustomElement.h b/third_party/WebKit/public/platform/WebStringUTF8Adaptor.h
similarity index 66%
copy from third_party/WebKit/public/web/WebCustomElement.h
copy to third_party/WebKit/public/platform/WebStringUTF8Adaptor.h
index a57083116524a20c883e98b554b9940c8f7e87d7..a66548123a2b9ba3d5214a2c20f16ac264243be4 100644
--- a/third_party/WebKit/public/web/WebCustomElement.h
+++ b/third_party/WebKit/public/platform/WebStringUTF8Adaptor.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,26 +28,36 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebCustomElement_h
-#define WebCustomElement_h
+#ifndef WebStringUTF8Adaptor_h
+#define WebStringUTF8Adaptor_h
-#include "../platform/WebCommon.h"
+#include "base/strings/string_piece.h"
+#include "WebCommon.h"
+#include "WebPrivatePtr.h"
+
+namespace WTF {
+class CStringBuffer;
+}
namespace blink {
class WebString;
-class WebCustomElement {
+// This class lets you get UTF-8 data out of a String without mallocing a
+// separate buffer to hold the data if the String happens to be 8 bit and
+// contain only ASCII characters.
+class BLINK_COMMON_EXPORT WebStringUTF8Adaptor {
public:
- // Adds a name to the set of names embedders can use
- // WebDocument::registerEmbedderCustomElement to register their
- // own types for. Because Custom Element processing requires the
- // set of valid names to be known ahead of time, this method
- // should be called before an element with this name is created.
- BLINK_EXPORT static void addEmbedderCustomElementName(const WebString& name);
+ WebStringUTF8Adaptor(const WebString& string);
+ ~WebStringUTF8Adaptor();
+
+ base::StringPiece asStringPiece() const { return m_stringPiece; }
private:
- WebCustomElement();
+ base::StringPiece m_stringPiece;
+
+ // Holds the UTF-8 buffer backing the string piece if conversion was necessary.
+ WebPrivatePtr<WTF::CStringBuffer> m_utf8Buffer;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698