| OLD | NEW |
| 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 #include "net/spdy/spdy_framer.h" | 5 #include "net/spdy/spdy_framer.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/metrics/stats_counters.h" | 9 #include "base/metrics/stats_counters.h" |
| 10 #include "base/third_party/valgrind/memcheck.h" | 10 #include "base/third_party/valgrind/memcheck.h" |
| (...skipping 2821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2832 builder.WriteUInt8(priority.weight()); | 2832 builder.WriteUInt8(priority.weight()); |
| 2833 DCHECK_EQ(GetPrioritySize(), builder.length()); | 2833 DCHECK_EQ(GetPrioritySize(), builder.length()); |
| 2834 return builder.take(); | 2834 return builder.take(); |
| 2835 } | 2835 } |
| 2836 | 2836 |
| 2837 namespace { | 2837 namespace { |
| 2838 | 2838 |
| 2839 class FrameSerializationVisitor : public SpdyFrameVisitor { | 2839 class FrameSerializationVisitor : public SpdyFrameVisitor { |
| 2840 public: | 2840 public: |
| 2841 explicit FrameSerializationVisitor(SpdyFramer* framer) : framer_(framer) {} | 2841 explicit FrameSerializationVisitor(SpdyFramer* framer) : framer_(framer) {} |
| 2842 virtual ~FrameSerializationVisitor() {} | 2842 ~FrameSerializationVisitor() override {} |
| 2843 | 2843 |
| 2844 SpdySerializedFrame* ReleaseSerializedFrame() { return frame_.release(); } | 2844 SpdySerializedFrame* ReleaseSerializedFrame() { return frame_.release(); } |
| 2845 | 2845 |
| 2846 virtual void VisitData(const SpdyDataIR& data) override { | 2846 void VisitData(const SpdyDataIR& data) override { |
| 2847 frame_.reset(framer_->SerializeData(data)); | 2847 frame_.reset(framer_->SerializeData(data)); |
| 2848 } | 2848 } |
| 2849 virtual void VisitSynStream(const SpdySynStreamIR& syn_stream) override { | 2849 void VisitSynStream(const SpdySynStreamIR& syn_stream) override { |
| 2850 frame_.reset(framer_->SerializeSynStream(syn_stream)); | 2850 frame_.reset(framer_->SerializeSynStream(syn_stream)); |
| 2851 } | 2851 } |
| 2852 virtual void VisitSynReply(const SpdySynReplyIR& syn_reply) override { | 2852 void VisitSynReply(const SpdySynReplyIR& syn_reply) override { |
| 2853 frame_.reset(framer_->SerializeSynReply(syn_reply)); | 2853 frame_.reset(framer_->SerializeSynReply(syn_reply)); |
| 2854 } | 2854 } |
| 2855 virtual void VisitRstStream(const SpdyRstStreamIR& rst_stream) override { | 2855 void VisitRstStream(const SpdyRstStreamIR& rst_stream) override { |
| 2856 frame_.reset(framer_->SerializeRstStream(rst_stream)); | 2856 frame_.reset(framer_->SerializeRstStream(rst_stream)); |
| 2857 } | 2857 } |
| 2858 virtual void VisitSettings(const SpdySettingsIR& settings) override { | 2858 void VisitSettings(const SpdySettingsIR& settings) override { |
| 2859 frame_.reset(framer_->SerializeSettings(settings)); | 2859 frame_.reset(framer_->SerializeSettings(settings)); |
| 2860 } | 2860 } |
| 2861 virtual void VisitPing(const SpdyPingIR& ping) override { | 2861 void VisitPing(const SpdyPingIR& ping) override { |
| 2862 frame_.reset(framer_->SerializePing(ping)); | 2862 frame_.reset(framer_->SerializePing(ping)); |
| 2863 } | 2863 } |
| 2864 virtual void VisitGoAway(const SpdyGoAwayIR& goaway) override { | 2864 void VisitGoAway(const SpdyGoAwayIR& goaway) override { |
| 2865 frame_.reset(framer_->SerializeGoAway(goaway)); | 2865 frame_.reset(framer_->SerializeGoAway(goaway)); |
| 2866 } | 2866 } |
| 2867 virtual void VisitHeaders(const SpdyHeadersIR& headers) override { | 2867 void VisitHeaders(const SpdyHeadersIR& headers) override { |
| 2868 frame_.reset(framer_->SerializeHeaders(headers)); | 2868 frame_.reset(framer_->SerializeHeaders(headers)); |
| 2869 } | 2869 } |
| 2870 virtual void VisitWindowUpdate( | 2870 void VisitWindowUpdate(const SpdyWindowUpdateIR& window_update) override { |
| 2871 const SpdyWindowUpdateIR& window_update) override { | |
| 2872 frame_.reset(framer_->SerializeWindowUpdate(window_update)); | 2871 frame_.reset(framer_->SerializeWindowUpdate(window_update)); |
| 2873 } | 2872 } |
| 2874 virtual void VisitBlocked(const SpdyBlockedIR& blocked) override { | 2873 void VisitBlocked(const SpdyBlockedIR& blocked) override { |
| 2875 frame_.reset(framer_->SerializeBlocked(blocked)); | 2874 frame_.reset(framer_->SerializeBlocked(blocked)); |
| 2876 } | 2875 } |
| 2877 virtual void VisitPushPromise( | 2876 void VisitPushPromise(const SpdyPushPromiseIR& push_promise) override { |
| 2878 const SpdyPushPromiseIR& push_promise) override { | |
| 2879 frame_.reset(framer_->SerializePushPromise(push_promise)); | 2877 frame_.reset(framer_->SerializePushPromise(push_promise)); |
| 2880 } | 2878 } |
| 2881 virtual void VisitContinuation( | 2879 void VisitContinuation(const SpdyContinuationIR& continuation) override { |
| 2882 const SpdyContinuationIR& continuation) override { | |
| 2883 frame_.reset(framer_->SerializeContinuation(continuation)); | 2880 frame_.reset(framer_->SerializeContinuation(continuation)); |
| 2884 } | 2881 } |
| 2885 virtual void VisitAltSvc(const SpdyAltSvcIR& altsvc) override { | 2882 void VisitAltSvc(const SpdyAltSvcIR& altsvc) override { |
| 2886 frame_.reset(framer_->SerializeAltSvc(altsvc)); | 2883 frame_.reset(framer_->SerializeAltSvc(altsvc)); |
| 2887 } | 2884 } |
| 2888 virtual void VisitPriority(const SpdyPriorityIR& priority) override { | 2885 void VisitPriority(const SpdyPriorityIR& priority) override { |
| 2889 frame_.reset(framer_->SerializePriority(priority)); | 2886 frame_.reset(framer_->SerializePriority(priority)); |
| 2890 } | 2887 } |
| 2891 | 2888 |
| 2892 private: | 2889 private: |
| 2893 SpdyFramer* framer_; | 2890 SpdyFramer* framer_; |
| 2894 scoped_ptr<SpdySerializedFrame> frame_; | 2891 scoped_ptr<SpdySerializedFrame> frame_; |
| 2895 }; | 2892 }; |
| 2896 | 2893 |
| 2897 } // namespace | 2894 } // namespace |
| 2898 | 2895 |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3243 builder->Seek(compressed_size); | 3240 builder->Seek(compressed_size); |
| 3244 builder->RewriteLength(*this); | 3241 builder->RewriteLength(*this); |
| 3245 | 3242 |
| 3246 pre_compress_bytes.Add(uncompressed_len); | 3243 pre_compress_bytes.Add(uncompressed_len); |
| 3247 post_compress_bytes.Add(compressed_size); | 3244 post_compress_bytes.Add(compressed_size); |
| 3248 | 3245 |
| 3249 compressed_frames.Increment(); | 3246 compressed_frames.Increment(); |
| 3250 } | 3247 } |
| 3251 | 3248 |
| 3252 } // namespace net | 3249 } // namespace net |
| OLD | NEW |