| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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/core/spdy_framer_decoder_adapter.h" | 5 #include "net/spdy/core/spdy_framer_decoder_adapter.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h" | 12 #include "net/spdy/platform/api/spdy_estimate_memory_usage.h" |
| 13 #include "net/spdy/platform/api/spdy_ptr_util.h" |
| 13 #include "net/spdy/platform/api/spdy_string_utils.h" | 14 #include "net/spdy/platform/api/spdy_string_utils.h" |
| 14 | 15 |
| 15 #if defined(COMPILER_GCC) | 16 #if defined(COMPILER_GCC) |
| 16 #define PRETTY_THIS SpdyStringPrintf("%s@%p ", __PRETTY_FUNCTION__, this) | 17 #define PRETTY_THIS SpdyStringPrintf("%s@%p ", __PRETTY_FUNCTION__, this) |
| 17 #elif defined(COMPILER_MSVC) | 18 #elif defined(COMPILER_MSVC) |
| 18 #define PRETTY_THIS SpdyStringPrintf("%s@%p ", __FUNCSIG__, this) | 19 #define PRETTY_THIS SpdyStringPrintf("%s@%p ", __FUNCSIG__, this) |
| 19 #else | 20 #else |
| 20 #define PRETTY_THIS SpdyStringPrintf("%s@%p ", __func__, this) | 21 #define PRETTY_THIS SpdyStringPrintf("%s@%p ", __func__, this) |
| 21 #endif | 22 #endif |
| 22 | 23 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 : SpdyFramer::DISABLE_COMPRESSION), | 180 : SpdyFramer::DISABLE_COMPRESSION), |
| 180 outer_(outer) { | 181 outer_(outer) { |
| 181 DVLOG(1) << PRETTY_THIS; | 182 DVLOG(1) << PRETTY_THIS; |
| 182 } | 183 } |
| 183 ~NestedSpdyFramerDecoder() override { DVLOG(1) << PRETTY_THIS; } | 184 ~NestedSpdyFramerDecoder() override { DVLOG(1) << PRETTY_THIS; } |
| 184 | 185 |
| 185 // Wrap the visitor in a SpdyFramerVisitorAdapter so that the correct | 186 // Wrap the visitor in a SpdyFramerVisitorAdapter so that the correct |
| 186 // SpdyFramer instance is passed to OnError. Passes the call on to the | 187 // SpdyFramer instance is passed to OnError. Passes the call on to the |
| 187 // base adapter class and wrapped SpdyFramer. | 188 // base adapter class and wrapped SpdyFramer. |
| 188 void set_visitor(SpdyFramerVisitorInterface* visitor) override { | 189 void set_visitor(SpdyFramerVisitorInterface* visitor) override { |
| 189 visitor_adapter_.reset(new SpdyFramerVisitorAdapter(visitor, outer_)); | 190 visitor_adapter_ = |
| 191 SpdyMakeUnique<SpdyFramerVisitorAdapter>(visitor, outer_); |
| 190 SpdyFramerDecoderAdapter::set_visitor(visitor_adapter_.get()); | 192 SpdyFramerDecoderAdapter::set_visitor(visitor_adapter_.get()); |
| 191 framer_.set_visitor(visitor_adapter_.get()); | 193 framer_.set_visitor(visitor_adapter_.get()); |
| 192 } | 194 } |
| 193 | 195 |
| 194 void set_extension_visitor(ExtensionVisitorInterface* visitor) override { | 196 void set_extension_visitor(ExtensionVisitorInterface* visitor) override { |
| 195 framer_.set_extension_visitor(visitor); | 197 framer_.set_extension_visitor(visitor); |
| 196 } | 198 } |
| 197 | 199 |
| 198 // Passes the call on to the base adapter class and wrapped SpdyFramer. | 200 // Passes the call on to the base adapter class and wrapped SpdyFramer. |
| 199 void set_debug_visitor( | 201 void set_debug_visitor( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 } | 239 } |
| 238 | 240 |
| 239 private: | 241 private: |
| 240 SpdyFramer framer_; | 242 SpdyFramer framer_; |
| 241 SpdyFramer* const outer_; | 243 SpdyFramer* const outer_; |
| 242 std::unique_ptr<SpdyFramerVisitorAdapter> visitor_adapter_; | 244 std::unique_ptr<SpdyFramerVisitorAdapter> visitor_adapter_; |
| 243 }; | 245 }; |
| 244 | 246 |
| 245 std::unique_ptr<SpdyFramerDecoderAdapter> CreateNestedSpdyFramerDecoder( | 247 std::unique_ptr<SpdyFramerDecoderAdapter> CreateNestedSpdyFramerDecoder( |
| 246 SpdyFramer* outer) { | 248 SpdyFramer* outer) { |
| 247 return std::unique_ptr<SpdyFramerDecoderAdapter>( | 249 return SpdyMakeUnique<NestedSpdyFramerDecoder>(outer); |
| 248 new NestedSpdyFramerDecoder(outer)); | |
| 249 } | 250 } |
| 250 | 251 |
| 251 } // namespace net | 252 } // namespace net |
| OLD | NEW |