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

Unified Diff: net/quic/core/frames/quic_frame.cc

Issue 2547583002: Landing Recent QUIC changes until Fri Nov 18 23:21:04 2016 +0000 (Closed)
Patch Set: Remove explicit HTTP/2 enum usage Created 4 years 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/quic/core/frames/quic_frame.h ('k') | net/quic/core/frames/quic_frame_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/core/frames/quic_frame.cc
diff --git a/net/quic/core/frames/quic_frame.cc b/net/quic/core/frames/quic_frame.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c33cb74bd2c84935d2e94f95870cda34c097868a
--- /dev/null
+++ b/net/quic/core/frames/quic_frame.cc
@@ -0,0 +1,163 @@
+// Copyright (c) 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.
+
+#include "net/quic/core/frames/quic_frame.h"
+
+using base::StringPiece;
+using std::ostream;
+using std::string;
+
+namespace net {
+
+QuicFrame::QuicFrame() {}
+
+QuicFrame::QuicFrame(QuicPaddingFrame padding_frame)
+ : type(PADDING_FRAME), padding_frame(padding_frame) {}
+
+QuicFrame::QuicFrame(QuicStreamFrame* stream_frame)
+ : type(STREAM_FRAME), stream_frame(stream_frame) {}
+
+QuicFrame::QuicFrame(QuicAckFrame* frame) : type(ACK_FRAME), ack_frame(frame) {}
+
+QuicFrame::QuicFrame(QuicMtuDiscoveryFrame frame)
+ : type(MTU_DISCOVERY_FRAME), mtu_discovery_frame(frame) {}
+
+QuicFrame::QuicFrame(QuicStopWaitingFrame* frame)
+ : type(STOP_WAITING_FRAME), stop_waiting_frame(frame) {}
+
+QuicFrame::QuicFrame(QuicPingFrame frame)
+ : type(PING_FRAME), ping_frame(frame) {}
+
+QuicFrame::QuicFrame(QuicRstStreamFrame* frame)
+ : type(RST_STREAM_FRAME), rst_stream_frame(frame) {}
+
+QuicFrame::QuicFrame(QuicConnectionCloseFrame* frame)
+ : type(CONNECTION_CLOSE_FRAME), connection_close_frame(frame) {}
+
+QuicFrame::QuicFrame(QuicGoAwayFrame* frame)
+ : type(GOAWAY_FRAME), goaway_frame(frame) {}
+
+QuicFrame::QuicFrame(QuicWindowUpdateFrame* frame)
+ : type(WINDOW_UPDATE_FRAME), window_update_frame(frame) {}
+
+QuicFrame::QuicFrame(QuicBlockedFrame* frame)
+ : type(BLOCKED_FRAME), blocked_frame(frame) {}
+
+QuicFrame::QuicFrame(QuicPathCloseFrame* frame)
+ : type(PATH_CLOSE_FRAME), path_close_frame(frame) {}
+
+void DeleteFrames(QuicFrames* frames) {
+ for (QuicFrame& frame : *frames) {
+ switch (frame.type) {
+ // Frames smaller than a pointer are inlined, so don't need to be deleted.
+ case PADDING_FRAME:
+ case MTU_DISCOVERY_FRAME:
+ case PING_FRAME:
+ break;
+ case STREAM_FRAME:
+ delete frame.stream_frame;
+ break;
+ case ACK_FRAME:
+ delete frame.ack_frame;
+ break;
+ case STOP_WAITING_FRAME:
+ delete frame.stop_waiting_frame;
+ break;
+ case RST_STREAM_FRAME:
+ delete frame.rst_stream_frame;
+ break;
+ case CONNECTION_CLOSE_FRAME:
+ delete frame.connection_close_frame;
+ break;
+ case GOAWAY_FRAME:
+ delete frame.goaway_frame;
+ break;
+ case BLOCKED_FRAME:
+ delete frame.blocked_frame;
+ break;
+ case WINDOW_UPDATE_FRAME:
+ delete frame.window_update_frame;
+ break;
+ case PATH_CLOSE_FRAME:
+ delete frame.path_close_frame;
+ break;
+ case NUM_FRAME_TYPES:
+ DCHECK(false) << "Cannot delete type: " << frame.type;
+ }
+ }
+ frames->clear();
+}
+
+void RemoveFramesForStream(QuicFrames* frames, QuicStreamId stream_id) {
+ QuicFrames::iterator it = frames->begin();
+ while (it != frames->end()) {
+ if (it->type != STREAM_FRAME || it->stream_frame->stream_id != stream_id) {
+ ++it;
+ continue;
+ }
+ delete it->stream_frame;
+ it = frames->erase(it);
+ }
+}
+
+ostream& operator<<(ostream& os, const QuicFrame& frame) {
+ switch (frame.type) {
+ case PADDING_FRAME: {
+ os << "type { PADDING_FRAME } " << frame.padding_frame;
+ break;
+ }
+ case RST_STREAM_FRAME: {
+ os << "type { RST_STREAM_FRAME } " << *(frame.rst_stream_frame);
+ break;
+ }
+ case CONNECTION_CLOSE_FRAME: {
+ os << "type { CONNECTION_CLOSE_FRAME } "
+ << *(frame.connection_close_frame);
+ break;
+ }
+ case GOAWAY_FRAME: {
+ os << "type { GOAWAY_FRAME } " << *(frame.goaway_frame);
+ break;
+ }
+ case WINDOW_UPDATE_FRAME: {
+ os << "type { WINDOW_UPDATE_FRAME } " << *(frame.window_update_frame);
+ break;
+ }
+ case BLOCKED_FRAME: {
+ os << "type { BLOCKED_FRAME } " << *(frame.blocked_frame);
+ break;
+ }
+ case STREAM_FRAME: {
+ os << "type { STREAM_FRAME } " << *(frame.stream_frame);
+ break;
+ }
+ case ACK_FRAME: {
+ os << "type { ACK_FRAME } " << *(frame.ack_frame);
+ break;
+ }
+ case STOP_WAITING_FRAME: {
+ os << "type { STOP_WAITING_FRAME } " << *(frame.stop_waiting_frame);
+ break;
+ }
+ case PING_FRAME: {
+ os << "type { PING_FRAME } ";
+ break;
+ }
+ case MTU_DISCOVERY_FRAME: {
+ os << "type { MTU_DISCOVERY_FRAME } ";
+ break;
+ }
+ case PATH_CLOSE_FRAME: {
+ os << "type { PATH_CLOSE_FRAME } " << *(frame.path_close_frame);
+ break;
+ }
+ default: {
+ LOG(ERROR) << "Unknown frame type: " << frame.type;
+ break;
+ }
+ }
+ return os;
+}
+
+} // namespace net
« no previous file with comments | « net/quic/core/frames/quic_frame.h ('k') | net/quic/core/frames/quic_frame_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698