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

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

Issue 2193323002: Tracing: fix error checking from deflate() when compressing trace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: disabled AboutTracingIntegrationTest on Win Created 4 years, 4 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 | tools/perf/core/about_tracing_integration_test.py » ('j') | 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/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 void DrainStreamOnFileThread(bool finished) { 245 void DrainStreamOnFileThread(bool finished) {
246 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 246 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
247 247
248 int err; 248 int err;
249 const int kChunkSize = 0x4000; 249 const int kChunkSize = 0x4000;
250 char buffer[kChunkSize]; 250 char buffer[kChunkSize];
251 do { 251 do {
252 stream_->avail_out = kChunkSize; 252 stream_->avail_out = kChunkSize;
253 stream_->next_out = (unsigned char*)buffer; 253 stream_->next_out = (unsigned char*)buffer;
254 err = deflate(stream_.get(), finished ? Z_FINISH : Z_NO_FLUSH); 254 err = deflate(stream_.get(), finished ? Z_FINISH : Z_NO_FLUSH);
255 if (err != (finished ? Z_STREAM_END : Z_OK)) { 255 if (err != Z_OK && (!finished || err != Z_STREAM_END)) {
256 LOG(ERROR) << "Deflate stream error: " << err;
256 stream_.reset(); 257 stream_.reset();
257 return; 258 return;
258 } 259 }
259 260
260 int bytes = kChunkSize - stream_->avail_out; 261 int bytes = kChunkSize - stream_->avail_out;
261 if (bytes) { 262 if (bytes) {
262 std::string compressed(buffer, bytes); 263 std::string compressed(buffer, bytes);
263 endpoint_->ReceiveTraceChunk(base::MakeUnique<std::string>(compressed)); 264 endpoint_->ReceiveTraceChunk(base::MakeUnique<std::string>(compressed));
264 } 265 }
265 } while (stream_->avail_out == 0); 266 } while (stream_->avail_out == 0);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 return new JSONTraceDataSink(new CompressedTraceDataEndpoint(endpoint)); 331 return new JSONTraceDataSink(new CompressedTraceDataEndpoint(endpoint));
331 } 332 }
332 333
333 scoped_refptr<TraceDataEndpoint> TracingControllerImpl::CreateCallbackEndpoint( 334 scoped_refptr<TraceDataEndpoint> TracingControllerImpl::CreateCallbackEndpoint(
334 const base::Callback<void(std::unique_ptr<const base::DictionaryValue>, 335 const base::Callback<void(std::unique_ptr<const base::DictionaryValue>,
335 base::RefCountedString*)>& callback) { 336 base::RefCountedString*)>& callback) {
336 return new StringTraceDataEndpoint(callback); 337 return new StringTraceDataEndpoint(callback);
337 } 338 }
338 339
339 } // namespace content 340 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | tools/perf/core/about_tracing_integration_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698