Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 sream error: " << err; | |
|
shatch
2016/07/29 18:46:45
nit: sream
| |
| 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 Loading... | |
| 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 |
| OLD | NEW |