| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 bool WebSocketDeflater::initialize() | 65 bool WebSocketDeflater::initialize() |
| 66 { | 66 { |
| 67 return deflateInit2(m_stream.get(), Z_DEFAULT_COMPRESSION, Z_DEFLATED, -m_wi
ndowBits, defaultMemLevel, Z_DEFAULT_STRATEGY) == Z_OK; | 67 return deflateInit2(m_stream.get(), Z_DEFAULT_COMPRESSION, Z_DEFLATED, -m_wi
ndowBits, defaultMemLevel, Z_DEFAULT_STRATEGY) == Z_OK; |
| 68 } | 68 } |
| 69 | 69 |
| 70 WebSocketDeflater::~WebSocketDeflater() | 70 WebSocketDeflater::~WebSocketDeflater() |
| 71 { | 71 { |
| 72 int result = deflateEnd(m_stream.get()); | 72 int result = deflateEnd(m_stream.get()); |
| 73 if (result != Z_OK) | 73 if (result != Z_OK) |
| 74 LOG(Network, "deflateEnd() failed: %d", result); | 74 LOG_INFO(Network, "deflateEnd() failed: %d", result); |
| 75 } | 75 } |
| 76 | 76 |
| 77 static void setStreamParameter(z_stream* stream, const char* inputData, size_t i
nputLength, char* outputData, size_t outputLength) | 77 static void setStreamParameter(z_stream* stream, const char* inputData, size_t i
nputLength, char* outputData, size_t outputLength) |
| 78 { | 78 { |
| 79 stream->next_in = reinterpret_cast<Bytef*>(const_cast<char*>(inputData)); | 79 stream->next_in = reinterpret_cast<Bytef*>(const_cast<char*>(inputData)); |
| 80 stream->avail_in = inputLength; | 80 stream->avail_in = inputLength; |
| 81 stream->next_out = reinterpret_cast<Bytef*>(outputData); | 81 stream->next_out = reinterpret_cast<Bytef*>(outputData); |
| 82 stream->avail_out = outputLength; | 82 stream->avail_out = outputLength; |
| 83 } | 83 } |
| 84 | 84 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 bool WebSocketInflater::initialize() | 142 bool WebSocketInflater::initialize() |
| 143 { | 143 { |
| 144 return inflateInit2(m_stream.get(), -m_windowBits) == Z_OK; | 144 return inflateInit2(m_stream.get(), -m_windowBits) == Z_OK; |
| 145 } | 145 } |
| 146 | 146 |
| 147 WebSocketInflater::~WebSocketInflater() | 147 WebSocketInflater::~WebSocketInflater() |
| 148 { | 148 { |
| 149 int result = inflateEnd(m_stream.get()); | 149 int result = inflateEnd(m_stream.get()); |
| 150 if (result != Z_OK) | 150 if (result != Z_OK) |
| 151 LOG(Network, "inflateEnd() failed: %d", result); | 151 LOG_INFO(Network, "inflateEnd() failed: %d", result); |
| 152 } | 152 } |
| 153 | 153 |
| 154 bool WebSocketInflater::addBytes(const char* data, size_t length) | 154 bool WebSocketInflater::addBytes(const char* data, size_t length) |
| 155 { | 155 { |
| 156 if (!length) | 156 if (!length) |
| 157 return false; | 157 return false; |
| 158 | 158 |
| 159 size_t consumedSoFar = 0; | 159 size_t consumedSoFar = 0; |
| 160 while (consumedSoFar < length) { | 160 while (consumedSoFar < length) { |
| 161 size_t writePosition = m_buffer.size(); | 161 size_t writePosition = m_buffer.size(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 210 } |
| 211 | 211 |
| 212 void WebSocketInflater::reset() | 212 void WebSocketInflater::reset() |
| 213 { | 213 { |
| 214 m_buffer.clear(); | 214 m_buffer.clear(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 } // namespace WebCore | 217 } // namespace WebCore |
| 218 | 218 |
| 219 #endif // ENABLE(WEB_SOCKETS) && USE(ZLIB) | 219 #endif // ENABLE(WEB_SOCKETS) && USE(ZLIB) |
| OLD | NEW |