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

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

Issue 2107163003: Remove calls to deprecated MessageLoop methods in third_party. (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 | « third_party/libaddressinput/chromium/chrome_metadata_source_unittest.cc ('k') | 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 (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" 13 #include "base/message_loop/message_loop.h"
14 #include "base/single_thread_task_runner.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
17 #include "build/build_config.h" 18 #include "build/build_config.h"
18 #include "third_party/zlib/google/zip_internal.h" 19 #include "third_party/zlib/google/zip_internal.h"
19 20
20 #if defined(USE_SYSTEM_MINIZIP) 21 #if defined(USE_SYSTEM_MINIZIP)
21 #include <minizip/unzip.h> 22 #include <minizip/unzip.h>
22 #else 23 #else
23 #include "third_party/zlib/contrib/minizip/unzip.h" 24 #include "third_party/zlib/contrib/minizip/unzip.h"
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 const int flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE; 388 const int flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE;
388 base::File output_file(output_file_path, flags); 389 base::File output_file(output_file_path, flags);
389 390
390 if (!output_file.IsValid()) { 391 if (!output_file.IsValid()) {
391 DVLOG(1) << "Unzip failed: unable to create platform file at " 392 DVLOG(1) << "Unzip failed: unable to create platform file at "
392 << output_file_path.value(); 393 << output_file_path.value();
393 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, failure_callback); 394 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, failure_callback);
394 return; 395 return;
395 } 396 }
396 397
397 base::MessageLoop::current()->PostTask( 398 base::MessageLoop::current()->task_runner()->PostTask(
398 FROM_HERE, 399 FROM_HERE,
399 base::Bind(&ZipReader::ExtractChunk, weak_ptr_factory_.GetWeakPtr(), 400 base::Bind(&ZipReader::ExtractChunk, weak_ptr_factory_.GetWeakPtr(),
400 Passed(std::move(output_file)), success_callback, 401 Passed(std::move(output_file)), success_callback,
401 failure_callback, progress_callback, 0 /* initial offset */)); 402 failure_callback, progress_callback, 0 /* initial offset */));
402 } 403 }
403 404
404 bool ZipReader::ExtractCurrentEntryIntoDirectory( 405 bool ZipReader::ExtractCurrentEntryIntoDirectory(
405 const base::FilePath& output_directory_path) const { 406 const base::FilePath& output_directory_path) const {
406 DCHECK(current_entry_info_.get()); 407 DCHECK(current_entry_info_.get());
407 408
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 if (num_bytes_read != output_file.Write(offset, buffer, num_bytes_read)) { 495 if (num_bytes_read != output_file.Write(offset, buffer, num_bytes_read)) {
495 DVLOG(1) << "Unzip failed: unable to write all bytes to target."; 496 DVLOG(1) << "Unzip failed: unable to write all bytes to target.";
496 failure_callback.Run(); 497 failure_callback.Run();
497 return; 498 return;
498 } 499 }
499 500
500 int64_t current_progress = offset + num_bytes_read; 501 int64_t current_progress = offset + num_bytes_read;
501 502
502 progress_callback.Run(current_progress); 503 progress_callback.Run(current_progress);
503 504
504 base::MessageLoop::current()->PostTask( 505 base::MessageLoop::current()->task_runner()->PostTask(
505 FROM_HERE, 506 FROM_HERE,
506 base::Bind(&ZipReader::ExtractChunk, weak_ptr_factory_.GetWeakPtr(), 507 base::Bind(&ZipReader::ExtractChunk, weak_ptr_factory_.GetWeakPtr(),
507 Passed(std::move(output_file)), success_callback, 508 Passed(std::move(output_file)), success_callback,
508 failure_callback, progress_callback, current_progress)); 509 failure_callback, progress_callback, current_progress));
509 } 510 }
510 } 511 }
511 512
512 // FileWriterDelegate ---------------------------------------------------------- 513 // FileWriterDelegate ----------------------------------------------------------
513 514
514 FileWriterDelegate::FileWriterDelegate(base::File* file) 515 FileWriterDelegate::FileWriterDelegate(base::File* file)
(...skipping 14 matching lines...) Expand all
529 } 530 }
530 531
531 bool FileWriterDelegate::WriteBytes(const char* data, int num_bytes) { 532 bool FileWriterDelegate::WriteBytes(const char* data, int num_bytes) {
532 int bytes_written = file_->WriteAtCurrentPos(data, num_bytes); 533 int bytes_written = file_->WriteAtCurrentPos(data, num_bytes);
533 if (bytes_written > 0) 534 if (bytes_written > 0)
534 file_length_ += bytes_written; 535 file_length_ += bytes_written;
535 return bytes_written == num_bytes; 536 return bytes_written == num_bytes;
536 } 537 }
537 538
538 } // namespace zip 539 } // namespace zip
OLDNEW
« no previous file with comments | « third_party/libaddressinput/chromium/chrome_metadata_source_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698