OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/cast_channel/logger.h" | 5 #include "extensions/browser/api/cast_channel/logger.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 Z_DEFLATED, | 70 Z_DEFLATED, |
71 // 16 is added to produce a gzip header + trailer. | 71 // 16 is added to produce a gzip header + trailer. |
72 MAX_WBITS + 16, | 72 MAX_WBITS + 16, |
73 8, // memLevel = 8 is default. | 73 8, // memLevel = 8 is default. |
74 Z_DEFAULT_STRATEGY); | 74 Z_DEFAULT_STRATEGY); |
75 DCHECK_EQ(Z_OK, result); | 75 DCHECK_EQ(Z_OK, result); |
76 | 76 |
77 size_t out_size = deflateBound(&stream, input.size()); | 77 size_t out_size = deflateBound(&stream, input.size()); |
78 scoped_ptr<char[]> out(new char[out_size]); | 78 scoped_ptr<char[]> out(new char[out_size]); |
79 | 79 |
80 static_assert(sizeof(uint8) == sizeof(char), | |
81 "uint8 char should be of different sizes"); | |
82 | |
83 stream.next_in = reinterpret_cast<uint8*>(const_cast<char*>(input.data())); | 80 stream.next_in = reinterpret_cast<uint8*>(const_cast<char*>(input.data())); |
84 stream.avail_in = input.size(); | 81 stream.avail_in = input.size(); |
85 stream.next_out = reinterpret_cast<uint8*>(out.get()); | 82 stream.next_out = reinterpret_cast<uint8*>(out.get()); |
86 stream.avail_out = out_size; | 83 stream.avail_out = out_size; |
87 | 84 |
88 // Do a one-shot compression. This will return Z_STREAM_END only if |output| | 85 // Do a one-shot compression. This will return Z_STREAM_END only if |output| |
89 // is large enough to hold all compressed data. | 86 // is large enough to hold all compressed data. |
90 result = deflate(&stream, Z_FINISH); | 87 result = deflate(&stream, Z_FINISH); |
91 | 88 |
92 bool success = (result == Z_STREAM_END); | 89 bool success = (result == Z_STREAM_END); |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 if (it != aggregated_socket_events_.end()) { | 355 if (it != aggregated_socket_events_.end()) { |
359 return it->second->last_errors; | 356 return it->second->last_errors; |
360 } else { | 357 } else { |
361 return LastErrors(); | 358 return LastErrors(); |
362 } | 359 } |
363 } | 360 } |
364 | 361 |
365 } // namespace cast_channel | 362 } // namespace cast_channel |
366 } // namespace api | 363 } // namespace api |
367 } // namespace extensions | 364 } // namespace extensions |
OLD | NEW |