Index: third_party/grpc/src/core/surface/validate_metadata.c |
diff --git a/third_party/WebKit/Source/build/win/Precompile.h b/third_party/grpc/src/core/surface/validate_metadata.c |
similarity index 53% |
copy from third_party/WebKit/Source/build/win/Precompile.h |
copy to third_party/grpc/src/core/surface/validate_metadata.c |
index 8a0ff29c353fc1d30c92d27f369d7c422a579bc8..bf4126867fd7e68b4381f6a9d37d89ef075ba9b8 100644 |
--- a/third_party/WebKit/Source/build/win/Precompile.h |
+++ b/third_party/grpc/src/core/surface/validate_metadata.c |
@@ -1,5 +1,7 @@ |
/* |
- * Copyright (C) 2012 Google Inc. All rights reserved. |
+ * |
+ * Copyright 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 |
@@ -26,43 +28,46 @@ |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
- */ |
- |
-/* |
- * Precompiled header for WebKit when built on Windows using |
- * GYP-generated project files. Not used by other build |
- * configurations. |
* |
- * Using precompiled headers speeds the build up significantly. On a |
- * fast machine (HP Z600, 12 GB of RAM), an ~18% decrease in full |
- * build time was measured. |
*/ |
-#if defined(WinPrecompile_h_) |
-#error You shouldn't include the precompiled header file more than once. |
-#endif |
+#include <stdlib.h> |
+#include <string.h> |
-#define WinPrecompile_h_ |
+#include <grpc/support/port_platform.h> |
-#define _USE_MATH_DEFINES // Make math.h behave like other platforms. |
+static int conforms_to(const char *s, size_t len, const uint8_t *legal_bits) { |
+ const char *p = s; |
+ const char *e = s + len; |
+ for (; p != e; p++) { |
+ int idx = *p; |
+ int byte = idx / 8; |
+ int bit = idx % 8; |
+ if ((legal_bits[byte] & (1 << bit)) == 0) return 0; |
+ } |
+ return 1; |
+} |
-#include <Windows.h> |
+int grpc_header_key_is_legal(const char *key, size_t length) { |
+ static const uint8_t legal_header_bits[256 / 8] = { |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xff, 0x03, 0x00, 0x00, 0x00, |
+ 0x80, 0xfe, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
+ if (length == 0) { |
+ return 0; |
+ } |
+ return conforms_to(key, length, legal_header_bits); |
+} |
-#include <errno.h> |
-#include <fcntl.h> |
-#include <limits.h> |
-#include <math.h> |
-#include <stdarg.h> |
-#include <stddef.h> |
-#include <stdio.h> |
-#include <stdlib.h> |
-#include <string.h> |
-#include <time.h> |
+int grpc_header_nonbin_value_is_legal(const char *value, size_t length) { |
+ static const uint8_t legal_header_bits[256 / 8] = { |
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, |
+ 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
+ return conforms_to(value, length, legal_header_bits); |
+} |
-#include <algorithm> |
-#include <ciso646> |
-#include <cmath> |
-#include <cstddef> |
-#include <limits> |
-#include <string> |
-#include <utility> |
+int grpc_is_binary_header(const char *key, size_t length) { |
+ if (length < 5) return 0; |
+ return 0 == memcmp(key + length - 4, "-bin", 4); |
+} |