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

Unified Diff: third_party/WebKit/Source/core/inspector/ProtocolString.h

Issue 2251343003: [DevTools] Generate separate copies of inspector_protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/core/inspector/ProtocolString.h
diff --git a/third_party/WebKit/Source/core/inspector/ProtocolString.h b/third_party/WebKit/Source/core/inspector/ProtocolString.h
new file mode 100644
index 0000000000000000000000000000000000000000..11a6dd6568085255a6b9248117be7b72ea9d1afa
--- /dev/null
+++ b/third_party/WebKit/Source/core/inspector/ProtocolString.h
@@ -0,0 +1,59 @@
+// 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.
+
+#ifndef ProtocolString_h
+#define ProtocolString_h
+
+#include "platform/Decimal.h"
+#include "wtf/Allocator.h"
+#include "wtf/text/StringBuilder.h"
+#include "wtf/text/StringHash.h"
+#include "wtf/text/WTFString.h"
+
+namespace blink {
+namespace protocol {
+
+using String = WTF::String;
+using StringBuilder = WTF::StringBuilder;
+
+class CORE_EXPORT StringUtil {
+ STATIC_ONLY(StringUtil);
+public:
+ static String substring(const String& s, unsigned pos, unsigned len = UINT_MAX) { return s.substring(pos, len); }
+ static String fromInteger(int number) { return String::number(number); }
+ static String fromDouble(double number) { return Decimal::fromDouble(number).toString(); }
+ static const size_t kNotFound = WTF::kNotFound;
+ static void toCharacters(const String& s, const UChar** characters, size_t* length)
+ {
+ if (s.isEmpty()) {
+ *characters = nullptr;
+ *length = 0;
+ return;
+ }
+ if (s.is8Bit()) {
+ String s16 = s;
+ s16.ensure16Bit();
+ *characters = s16.characters16();
+ *length = s16.length();
+ } else {
+ *characters = s.characters16();
+ *length = s.length();
+ }
+ }
+ static void builderReserve(StringBuilder& builder, unsigned capacity) { builder.reserveCapacity(capacity); }
+};
+
+} // namespace protocol
+} // namespace blink
+
+namespace std {
+template<> struct hash<WTF::String> {
+ std::size_t operator()(const WTF::String& string) const
+ {
+ return StringHash::hash(string);
+ }
+};
+} // namespace std
+
+#endif // !defined(ProtocolString_h)

Powered by Google App Engine
This is Rietveld 408576698