Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: content/browser/tracing/tracing_controller_impl_data_sinks.cc

Issue 2150783002: Tracing: fix error checking of deflate() to be performed always... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include <utility> 4 #include <utility>
5 5
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/pattern.h" 10 #include "base/strings/pattern.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 const int kChunkSize = 0x4000; 255 const int kChunkSize = 0x4000;
256 256
257 char buffer[kChunkSize]; 257 char buffer[kChunkSize];
258 int err; 258 int err;
259 stream_->avail_in = chunk.size(); 259 stream_->avail_in = chunk.size();
260 stream_->next_in = (unsigned char*)chunk.data(); 260 stream_->next_in = (unsigned char*)chunk.data();
261 do { 261 do {
262 stream_->avail_out = kChunkSize; 262 stream_->avail_out = kChunkSize;
263 stream_->next_out = (unsigned char*)buffer; 263 stream_->next_out = (unsigned char*)buffer;
264 err = deflate(stream_.get(), finished ? Z_FINISH : Z_NO_FLUSH); 264 err = deflate(stream_.get(), finished ? Z_FINISH : Z_NO_FLUSH);
265 if (err != Z_OK && (err != Z_STREAM_END && finished)) { 265 if (err != (finished ? Z_STREAM_END : Z_OK)) {
266 stream_.reset(); 266 stream_.reset();
267 return; 267 return;
268 } 268 }
269 269
270 int bytes = kChunkSize - stream_->avail_out; 270 int bytes = kChunkSize - stream_->avail_out;
271 if (bytes) { 271 if (bytes) {
272 std::string compressed_chunk = std::string(buffer, bytes); 272 std::string compressed_chunk = std::string(buffer, bytes);
273 endpoint_->ReceiveTraceChunk(compressed_chunk); 273 endpoint_->ReceiveTraceChunk(compressed_chunk);
274 } 274 }
275 } while (stream_->avail_out == 0); 275 } while (stream_->avail_out == 0);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 return new CompressedStringTraceDataSink(endpoint); 360 return new CompressedStringTraceDataSink(endpoint);
361 } 361 }
362 362
363 scoped_refptr<TraceDataEndpoint> TracingControllerImpl::CreateCallbackEndpoint( 363 scoped_refptr<TraceDataEndpoint> TracingControllerImpl::CreateCallbackEndpoint(
364 const base::Callback<void(std::unique_ptr<const base::DictionaryValue>, 364 const base::Callback<void(std::unique_ptr<const base::DictionaryValue>,
365 base::RefCountedString*)>& callback) { 365 base::RefCountedString*)>& callback) {
366 return new StringTraceDataEndpoint(callback); 366 return new StringTraceDataEndpoint(callback);
367 } 367 }
368 368
369 } // namespace content 369 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698