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

Unified Diff: net/spdy/http2_encoding_context.h

Issue 22074002: DO NOT COMMIT: Implement HPACK (draft 03) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update for httpbis-draft-06 / hpack-draft-03 Created 7 years, 2 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 | « net/spdy/http2_decompressor_unittest.cc ('k') | net/spdy/http2_encoding_context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/http2_encoding_context.h
diff --git a/net/spdy/http2_encoding_context.h b/net/spdy/http2_encoding_context.h
new file mode 100644
index 0000000000000000000000000000000000000000..c2fc7f3983c93523c440564245b3ef92bed6d988
--- /dev/null
+++ b/net/spdy/http2_encoding_context.h
@@ -0,0 +1,132 @@
+// Copyright (c) 2013 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 NET_SPDY_HTTP2_ENCODING_CONTEXT_H_
+#define NET_SPDY_HTTP2_ENCODING_CONTEXT_H_
+
+#include <cstddef>
+#include <deque>
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+
+namespace net {
+
+extern const uint8 kIndexOpcode;
+extern const uint8 kIndexN;
+
+extern const uint8 kLiteralNoIndexOpcode;
+extern const uint8 kLiteralNoIndexN;
+
+extern const uint8 kLiteralIncrementalOpcode;
+extern const uint8 kLiteralIncrementalN;
+
+extern const uint8 kLiteralSubstitutionOpcode;
+extern const uint8 kLiteralSubstitutionN;
+
+extern const uint32 kUntouched;
+
+enum Http2Direction {
+ HTTP2_REQUEST,
+ HTTP2_RESPONSE
+};
+
+bool IsValidHeaderName(const std::string& str);
+
+bool IsValidHeaderValue(const std::string& str);
+
+bool StringsEqualConstantTime(const std::string& str1,
+ const std::string& str2);
+
+struct HeaderTableEntry {
+ HeaderTableEntry();
+ HeaderTableEntry(const std::string& name, const std::string& value);
+
+ bool Equals(const HeaderTableEntry& other) const;
+
+ size_t Size() const;
+
+ std::string name;
+ std::string value;
+
+ bool referenced;
+ uint32 touch_count;
+};
+
+class HeaderTable {
+ public:
+ HeaderTable();
+
+ ~HeaderTable();
+
+ size_t GetEntryCount() const;
+
+ void SetMaxSize(size_t max_size);
+
+ const HeaderTableEntry* GetEntry(int32 index) const;
+
+ HeaderTableEntry* GetMutableEntry(int32 index);
+
+ void TryAppendEntry(const HeaderTableEntry& entry,
+ int32* index,
+ std::vector<uint32>* removed_referenced_indices);
+
+ void TryReplaceEntry(uint32 substituted_index,
+ const HeaderTableEntry& entry,
+ int32* index,
+ std::vector<uint32>* removed_referenced_indices);
+
+ private:
+ void RemoveFirstEntry();
+
+ std::deque<HeaderTableEntry> entries_;
+ size_t size_;
+ size_t max_size_;
+
+ DISALLOW_COPY_AND_ASSIGN(HeaderTable);
+};
+
+class EncodingContext {
+ public:
+ EncodingContext(Http2Direction direction);
+
+ ~EncodingContext();
+
+ size_t GetEntryCount() const;
+
+ bool IsReferenced(uint32 index) const;
+
+ bool GetIndexedHeaderName(uint32 index, std::string* name) const;
+
+ bool GetIndexedHeaderValue(uint32 index, std::string* value) const;
+
+ void ProcessIndexedHeader(uint32 index);
+
+ void ProcessLiteralHeaderWithIncrementalIndexing(
+ const std::string& name,
+ const std::string& value,
+ int32* index,
+ std::vector<uint32>* removed_referenced_indices);
+
+ void ProcessLiteralHeaderWithSubstitutionIndexing(
+ const std::string& name,
+ uint32 substituted_index,
+ const std::string& value,
+ int32* index,
+ std::vector<uint32>* removed_referenced_indices);
+
+ void AddTouches(uint32 index, uint32 touch_count);
+
+ HeaderTableEntry* GetMutableEntry(int32 index);
+
+ private:
+ HeaderTable header_table_;
+
+ DISALLOW_COPY_AND_ASSIGN(EncodingContext);
+};
+
+} // namespace net
+
+#endif // NET_SPDY_HTTP2_ENCODING_CONTEXT_H_
« no previous file with comments | « net/spdy/http2_decompressor_unittest.cc ('k') | net/spdy/http2_encoding_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698