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

Side by Side Diff: third_party/zlib/google/zip_reader.cc

Issue 2375663002: Replace MessageLoop::current()->task_runner() with ThreadTaskRunnerHandle::Get(). (Closed)
Patch Set: rebase Created 4 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "third_party/zlib/google/zip_reader.h" 5 #include "third_party/zlib/google/zip_reader.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file.h" 10 #include "base/files/file.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/message_loop/message_loop.h"
14 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
16 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
17 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
18 #include "build/build_config.h" 17 #include "build/build_config.h"
19 #include "third_party/zlib/google/zip_internal.h" 18 #include "third_party/zlib/google/zip_internal.h"
20 19
21 #if defined(USE_SYSTEM_MINIZIP) 20 #if defined(USE_SYSTEM_MINIZIP)
22 #include <minizip/unzip.h> 21 #include <minizip/unzip.h>
23 #else 22 #else
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 const int flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE; 384 const int flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE;
386 base::File output_file(output_file_path, flags); 385 base::File output_file(output_file_path, flags);
387 386
388 if (!output_file.IsValid()) { 387 if (!output_file.IsValid()) {
389 DVLOG(1) << "Unzip failed: unable to create platform file at " 388 DVLOG(1) << "Unzip failed: unable to create platform file at "
390 << output_file_path.value(); 389 << output_file_path.value();
391 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, failure_callback); 390 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, failure_callback);
392 return; 391 return;
393 } 392 }
394 393
395 base::MessageLoop::current()->task_runner()->PostTask( 394 base::ThreadTaskRunnerHandle::Get()->PostTask(
396 FROM_HERE, 395 FROM_HERE,
397 base::Bind(&ZipReader::ExtractChunk, weak_ptr_factory_.GetWeakPtr(), 396 base::Bind(&ZipReader::ExtractChunk, weak_ptr_factory_.GetWeakPtr(),
398 Passed(std::move(output_file)), success_callback, 397 Passed(std::move(output_file)), success_callback,
399 failure_callback, progress_callback, 0 /* initial offset */)); 398 failure_callback, progress_callback, 0 /* initial offset */));
400 } 399 }
401 400
402 bool ZipReader::ExtractCurrentEntryIntoDirectory( 401 bool ZipReader::ExtractCurrentEntryIntoDirectory(
403 const base::FilePath& output_directory_path) const { 402 const base::FilePath& output_directory_path) const {
404 DCHECK(current_entry_info_.get()); 403 DCHECK(current_entry_info_.get());
405 404
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 if (num_bytes_read != output_file.Write(offset, buffer, num_bytes_read)) { 491 if (num_bytes_read != output_file.Write(offset, buffer, num_bytes_read)) {
493 DVLOG(1) << "Unzip failed: unable to write all bytes to target."; 492 DVLOG(1) << "Unzip failed: unable to write all bytes to target.";
494 failure_callback.Run(); 493 failure_callback.Run();
495 return; 494 return;
496 } 495 }
497 496
498 int64_t current_progress = offset + num_bytes_read; 497 int64_t current_progress = offset + num_bytes_read;
499 498
500 progress_callback.Run(current_progress); 499 progress_callback.Run(current_progress);
501 500
502 base::MessageLoop::current()->task_runner()->PostTask( 501 base::ThreadTaskRunnerHandle::Get()->PostTask(
503 FROM_HERE, 502 FROM_HERE,
504 base::Bind(&ZipReader::ExtractChunk, weak_ptr_factory_.GetWeakPtr(), 503 base::Bind(&ZipReader::ExtractChunk, weak_ptr_factory_.GetWeakPtr(),
505 Passed(std::move(output_file)), success_callback, 504 Passed(std::move(output_file)), success_callback,
506 failure_callback, progress_callback, current_progress)); 505 failure_callback, progress_callback, current_progress));
507 } 506 }
508 } 507 }
509 508
510 // FileWriterDelegate ---------------------------------------------------------- 509 // FileWriterDelegate ----------------------------------------------------------
511 510
512 FileWriterDelegate::FileWriterDelegate(base::File* file) 511 FileWriterDelegate::FileWriterDelegate(base::File* file)
(...skipping 14 matching lines...) Expand all
527 } 526 }
528 527
529 bool FileWriterDelegate::WriteBytes(const char* data, int num_bytes) { 528 bool FileWriterDelegate::WriteBytes(const char* data, int num_bytes) {
530 int bytes_written = file_->WriteAtCurrentPos(data, num_bytes); 529 int bytes_written = file_->WriteAtCurrentPos(data, num_bytes);
531 if (bytes_written > 0) 530 if (bytes_written > 0)
532 file_length_ += bytes_written; 531 file_length_ += bytes_written;
533 return bytes_written == num_bytes; 532 return bytes_written == num_bytes;
534 } 533 }
535 534
536 } // namespace zip 535 } // namespace zip
OLDNEW
« no previous file with comments | « third_party/libaddressinput/chromium/chrome_address_validator.cc ('k') | ui/aura/test/ui_controls_factory_aurawin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698