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

Side by Side Diff: net/spdy/spdy_framer.h

Issue 12224019: Add SpdyFramerDebugVisitorInterface for later usage in stats collecting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows compile failure Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/spdy/spdy_framer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_SPDY_SPDY_FRAMER_H_ 5 #ifndef NET_SPDY_SPDY_FRAMER_H_
6 #define NET_SPDY_SPDY_FRAMER_H_ 6 #define NET_SPDY_SPDY_FRAMER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 virtual void OnWindowUpdate(SpdyStreamId stream_id, 207 virtual void OnWindowUpdate(SpdyStreamId stream_id,
208 int delta_window_size) = 0; 208 int delta_window_size) = 0;
209 209
210 // Called after a control frame has been compressed to allow the visitor 210 // Called after a control frame has been compressed to allow the visitor
211 // to record compression statistics. 211 // to record compression statistics.
212 virtual void OnControlFrameCompressed( 212 virtual void OnControlFrameCompressed(
213 const SpdyControlFrame& uncompressed_frame, 213 const SpdyControlFrame& uncompressed_frame,
214 const SpdyControlFrame& compressed_frame) = 0; 214 const SpdyControlFrame& compressed_frame) = 0;
215 }; 215 };
216 216
217 // Optionally, and in addition to SpdyFramerVisitorInterface, a class supporting
218 // SpdyFramerDebugVisitorInterface may be used in conjunction with SpdyFramer in
219 // order to extract debug/internal information about the SpdyFramer as it
220 // operates.
221 //
222 // Most SPDY implementations need not bother with this interface at all.
223 class SpdyFramerDebugVisitorInterface {
224 public:
225 virtual ~SpdyFramerDebugVisitorInterface() {}
226
227 // Called after compressing header blocks.
228 // Provides decompressed and compressed sizes.
229 virtual void OnCompressedHeaderBlock(size_t decompressed_len,
230 size_t compressed_len) {}
231 };
232
217 class NET_EXPORT_PRIVATE SpdyFramer { 233 class NET_EXPORT_PRIVATE SpdyFramer {
218 public: 234 public:
219 // SPDY states. 235 // SPDY states.
220 // TODO(mbelshe): Can we move these into the implementation 236 // TODO(mbelshe): Can we move these into the implementation
221 // and avoid exposing through the header. (Needed for test) 237 // and avoid exposing through the header. (Needed for test)
222 enum SpdyState { 238 enum SpdyState {
223 SPDY_ERROR, 239 SPDY_ERROR,
224 SPDY_DONE, 240 SPDY_DONE,
225 SPDY_RESET, 241 SPDY_RESET,
226 SPDY_AUTO_RESET, 242 SPDY_AUTO_RESET,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 virtual ~SpdyFramer(); 293 virtual ~SpdyFramer();
278 294
279 // Set callbacks to be called from the framer. A visitor must be set, or 295 // Set callbacks to be called from the framer. A visitor must be set, or
280 // else the framer will likely crash. It is acceptable for the visitor 296 // else the framer will likely crash. It is acceptable for the visitor
281 // to do nothing. If this is called multiple times, only the last visitor 297 // to do nothing. If this is called multiple times, only the last visitor
282 // will be used. 298 // will be used.
283 void set_visitor(SpdyFramerVisitorInterface* visitor) { 299 void set_visitor(SpdyFramerVisitorInterface* visitor) {
284 visitor_ = visitor; 300 visitor_ = visitor;
285 } 301 }
286 302
303 // Set debug callbacks to be called from the framer. The debug visitor is
304 // completely optional and need not be set in order for normal operation.
305 // If this is called multiple times, only the last visitor will be used.
306 void set_debug_visitor(SpdyFramerDebugVisitorInterface* debug_visitor) {
307 debug_visitor_ = debug_visitor;
308 }
309
287 // Pass data into the framer for parsing. 310 // Pass data into the framer for parsing.
288 // Returns the number of bytes consumed. It is safe to pass more bytes in 311 // Returns the number of bytes consumed. It is safe to pass more bytes in
289 // than may be consumed. 312 // than may be consumed.
290 size_t ProcessInput(const char* data, size_t len); 313 size_t ProcessInput(const char* data, size_t len);
291 314
292 // Resets the framer state after a frame has been successfully decoded. 315 // Resets the framer state after a frame has been successfully decoded.
293 // TODO(mbelshe): can we make this private? 316 // TODO(mbelshe): can we make this private?
294 void Reset(); 317 void Reset();
295 318
296 // Check the state of the framer. 319 // Check the state of the framer.
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 // TODO(hkhalil): Unify memory for this scratch space with 595 // TODO(hkhalil): Unify memory for this scratch space with
573 // current_frame_buffer_. 596 // current_frame_buffer_.
574 SpdySettingsScratch settings_scratch_; 597 SpdySettingsScratch settings_scratch_;
575 598
576 bool enable_compression_; // Controls all compression 599 bool enable_compression_; // Controls all compression
577 // SPDY header compressors. 600 // SPDY header compressors.
578 scoped_ptr<z_stream> header_compressor_; 601 scoped_ptr<z_stream> header_compressor_;
579 scoped_ptr<z_stream> header_decompressor_; 602 scoped_ptr<z_stream> header_decompressor_;
580 603
581 SpdyFramerVisitorInterface* visitor_; 604 SpdyFramerVisitorInterface* visitor_;
605 SpdyFramerDebugVisitorInterface* debug_visitor_;
582 606
583 std::string display_protocol_; 607 std::string display_protocol_;
584 608
585 // The SPDY version to be spoken/understood by this framer. We support only 609 // The SPDY version to be spoken/understood by this framer. We support only
586 // integer versions here, as major version numbers indicate framer-layer 610 // integer versions here, as major version numbers indicate framer-layer
587 // incompatibility and minor version numbers indicate application-layer 611 // incompatibility and minor version numbers indicate application-layer
588 // incompatibility. 612 // incompatibility.
589 const int spdy_version_; 613 const int spdy_version_;
590 614
591 // Tracks if we've ever gotten far enough in framing to see a control frame of 615 // Tracks if we've ever gotten far enough in framing to see a control frame of
592 // type SYN_STREAM or SYN_REPLY. 616 // type SYN_STREAM or SYN_REPLY.
593 // 617 //
594 // If we ever get something which looks like a data frame before we've had a 618 // If we ever get something which looks like a data frame before we've had a
595 // SYN, we explicitly check to see if it looks like we got an HTTP response to 619 // SYN, we explicitly check to see if it looks like we got an HTTP response to
596 // a SPDY request. This boolean lets us do that. 620 // a SPDY request. This boolean lets us do that.
597 bool syn_frame_processed_; 621 bool syn_frame_processed_;
598 622
599 // If we ever get a data frame before a SYN frame, we check to see if it 623 // If we ever get a data frame before a SYN frame, we check to see if it
600 // starts with HTTP. If it does, we likely have an HTTP response. This 624 // starts with HTTP. If it does, we likely have an HTTP response. This
601 // isn't guaranteed though: we could have gotten a settings frame and then 625 // isn't guaranteed though: we could have gotten a settings frame and then
602 // corrupt data that just looks like HTTP, but deterministic checking requires 626 // corrupt data that just looks like HTTP, but deterministic checking requires
603 // a lot more state. 627 // a lot more state.
604 bool probable_http_response_; 628 bool probable_http_response_;
605 }; 629 };
606 630
607 } // namespace net 631 } // namespace net
608 632
609 #endif // NET_SPDY_SPDY_FRAMER_H_ 633 #endif // NET_SPDY_SPDY_FRAMER_H_
OLDNEW
« no previous file with comments | « no previous file | net/spdy/spdy_framer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698