| 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_
|
|
|