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 <stdint.h> |
| 8 |
7 #include <string> | 9 #include <string> |
8 #include <utility> | 10 #include <utility> |
9 | 11 |
10 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
11 #include "base/time/clock.h" | 13 #include "base/time/clock.h" |
12 #include "extensions/browser/api/cast_channel/cast_auth_util.h" | 14 #include "extensions/browser/api/cast_channel/cast_auth_util.h" |
13 #include "extensions/browser/api/cast_channel/cast_socket.h" | 15 #include "extensions/browser/api/cast_channel/cast_socket.h" |
14 #include "extensions/browser/api/cast_channel/logger_util.h" | 16 #include "extensions/browser/api/cast_channel/logger_util.h" |
15 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
16 #include "third_party/zlib/zlib.h" | 18 #include "third_party/zlib/zlib.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 Z_DEFLATED, | 72 Z_DEFLATED, |
71 // 16 is added to produce a gzip header + trailer. | 73 // 16 is added to produce a gzip header + trailer. |
72 MAX_WBITS + 16, | 74 MAX_WBITS + 16, |
73 8, // memLevel = 8 is default. | 75 8, // memLevel = 8 is default. |
74 Z_DEFAULT_STRATEGY); | 76 Z_DEFAULT_STRATEGY); |
75 DCHECK_EQ(Z_OK, result); | 77 DCHECK_EQ(Z_OK, result); |
76 | 78 |
77 size_t out_size = deflateBound(&stream, input.size()); | 79 size_t out_size = deflateBound(&stream, input.size()); |
78 scoped_ptr<char[]> out(new char[out_size]); | 80 scoped_ptr<char[]> out(new char[out_size]); |
79 | 81 |
80 stream.next_in = reinterpret_cast<uint8*>(const_cast<char*>(input.data())); | 82 stream.next_in = reinterpret_cast<uint8_t*>(const_cast<char*>(input.data())); |
81 stream.avail_in = input.size(); | 83 stream.avail_in = input.size(); |
82 stream.next_out = reinterpret_cast<uint8*>(out.get()); | 84 stream.next_out = reinterpret_cast<uint8_t*>(out.get()); |
83 stream.avail_out = out_size; | 85 stream.avail_out = out_size; |
84 | 86 |
85 // Do a one-shot compression. This will return Z_STREAM_END only if |output| | 87 // Do a one-shot compression. This will return Z_STREAM_END only if |output| |
86 // is large enough to hold all compressed data. | 88 // is large enough to hold all compressed data. |
87 result = deflate(&stream, Z_FINISH); | 89 result = deflate(&stream, Z_FINISH); |
88 | 90 |
89 bool success = (result == Z_STREAM_END); | 91 bool success = (result == Z_STREAM_END); |
90 | 92 |
91 if (!success) | 93 if (!success) |
92 VLOG(2) << "deflate() failed. Result: " << result; | 94 VLOG(2) << "deflate() failed. Result: " << result; |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 if (it != aggregated_socket_events_.end()) { | 357 if (it != aggregated_socket_events_.end()) { |
356 return it->second->last_errors; | 358 return it->second->last_errors; |
357 } else { | 359 } else { |
358 return LastErrors(); | 360 return LastErrors(); |
359 } | 361 } |
360 } | 362 } |
361 | 363 |
362 } // namespace cast_channel | 364 } // namespace cast_channel |
363 } // namespace api | 365 } // namespace api |
364 } // namespace extensions | 366 } // namespace extensions |
OLD | NEW |