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

Unified Diff: third_party/WebKit/Source/platform/v8_inspector/public/StringView.h

Issue 2260233002: [DevTools] Migrate v8_inspector/public from String16 to String{View,Buffer}. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: better Created 4 years, 4 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/v8_inspector/public/StringView.h
diff --git a/third_party/WebKit/Source/platform/v8_inspector/public/StringView.h b/third_party/WebKit/Source/platform/v8_inspector/public/StringView.h
new file mode 100644
index 0000000000000000000000000000000000000000..fc6139e941a71aa551799b70220bd8262f92a750
--- /dev/null
+++ b/third_party/WebKit/Source/platform/v8_inspector/public/StringView.h
@@ -0,0 +1,37 @@
+// 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.
+
+// Note: this guard is specifically made different to not clash with wtf/text/StringView.h.
+// It will be moved to v8 and changed in the future.
+#ifndef v8_inspector_StringView_h
+#define v8_inspector_StringView_h
+
+#include <cctype>
+#include <stdint.h>
+
+namespace v8_inspector {
+
+class StringView {
+public:
+ StringView() : m_is8Bit(true), m_length(0) { m_characters8 = nullptr; }
+ StringView(const uint8_t* characters, unsigned length) : m_is8Bit(true), m_length(length) { m_characters8 = characters; }
+ StringView(const uint16_t* characters, unsigned length) : m_is8Bit(false), m_length(length) { m_characters16 = characters; }
+
+ bool is8Bit() const { return m_is8Bit; }
+ unsigned length() const { return m_length; }
+ const uint8_t* characters8() const { return m_characters8; }
+ const uint16_t* characters16() const { return m_characters16; }
+
+private:
+ bool m_is8Bit;
+ unsigned m_length;
+ union {
+ const uint8_t* m_characters8;
+ const uint16_t* m_characters16;
+ };
+};
+
+} // namespace v8_inspector
+
+#endif // v8_inspector_StringView_h

Powered by Google App Engine
This is Rietveld 408576698