| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/quic/crypto/cert_compressor.h" | 5 #include "net/quic/crypto/cert_compressor.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "net/quic/quic_utils.h" | 9 #include "net/quic/quic_utils.h" |
| 10 #include "third_party/zlib/zlib.h" | 10 #include "third_party/zlib/zlib.h" |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 } | 415 } |
| 416 | 416 |
| 417 // ScopedZLib deals with the automatic destruction of a zlib context. | 417 // ScopedZLib deals with the automatic destruction of a zlib context. |
| 418 class ScopedZLib { | 418 class ScopedZLib { |
| 419 public: | 419 public: |
| 420 enum Type { | 420 enum Type { |
| 421 INFLATE, | 421 INFLATE, |
| 422 DEFLATE, | 422 DEFLATE, |
| 423 }; | 423 }; |
| 424 | 424 |
| 425 explicit ScopedZLib(Type type) : z_(NULL), type_(type) {} | 425 explicit ScopedZLib(Type type) : z_(nullptr), type_(type) {} |
| 426 | 426 |
| 427 void reset(z_stream* z) { | 427 void reset(z_stream* z) { |
| 428 Clear(); | 428 Clear(); |
| 429 z_ = z; | 429 z_ = z; |
| 430 } | 430 } |
| 431 | 431 |
| 432 ~ScopedZLib() { | 432 ~ScopedZLib() { |
| 433 Clear(); | 433 Clear(); |
| 434 } | 434 } |
| 435 | 435 |
| 436 private: | 436 private: |
| 437 void Clear() { | 437 void Clear() { |
| 438 if (!z_) { | 438 if (!z_) { |
| 439 return; | 439 return; |
| 440 } | 440 } |
| 441 | 441 |
| 442 if (type_ == DEFLATE) { | 442 if (type_ == DEFLATE) { |
| 443 deflateEnd(z_); | 443 deflateEnd(z_); |
| 444 } else { | 444 } else { |
| 445 inflateEnd(z_); | 445 inflateEnd(z_); |
| 446 } | 446 } |
| 447 z_ = NULL; | 447 z_ = nullptr; |
| 448 } | 448 } |
| 449 | 449 |
| 450 z_stream* z_; | 450 z_stream* z_; |
| 451 const Type type_; | 451 const Type type_; |
| 452 }; | 452 }; |
| 453 | 453 |
| 454 } // anonymous namespace | 454 } // anonymous namespace |
| 455 | 455 |
| 456 | 456 |
| 457 // static | 457 // static |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 } | 637 } |
| 638 | 638 |
| 639 if (!uncompressed.empty()) { | 639 if (!uncompressed.empty()) { |
| 640 return false; | 640 return false; |
| 641 } | 641 } |
| 642 | 642 |
| 643 return true; | 643 return true; |
| 644 } | 644 } |
| 645 | 645 |
| 646 } // namespace net | 646 } // namespace net |
| OLD | NEW |