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

Side by Side Diff: chrome/browser/android/thumbnail/thumbnail_cache.cc

Issue 2858073002: Use constexpr TaskTraits constructor in chrome. (Closed)
Patch Set: Created 3 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/android/thumbnail/thumbnail_cache.h" 5 #include "chrome/browser/android/thumbnail/thumbnail_cache.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 post_compression_task = base::Bind(&ThumbnailCache::PostCompressionTask, 380 post_compression_task = base::Bind(&ThumbnailCache::PostCompressionTask,
381 weak_factory_.GetWeakPtr(), 381 weak_factory_.GetWeakPtr(),
382 tab_id, 382 tab_id,
383 time_stamp, 383 time_stamp,
384 scale); 384 scale);
385 385
386 gfx::Size raw_data_size(bitmap.width(), bitmap.height()); 386 gfx::Size raw_data_size(bitmap.width(), bitmap.height());
387 gfx::Size encoded_size = GetEncodedSize( 387 gfx::Size encoded_size = GetEncodedSize(
388 raw_data_size, ui_resource_provider_->SupportsETC1NonPowerOfTwo()); 388 raw_data_size, ui_resource_provider_->SupportsETC1NonPowerOfTwo());
389 389
390 base::PostTaskWithTraits( 390 base::PostTaskWithTraits(FROM_HERE,
391 FROM_HERE, base::TaskTraits() 391 {base::TaskPriority::BACKGROUND,
392 .WithPriority(base::TaskPriority::BACKGROUND) 392 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
393 .WithShutdownBehavior( 393 base::Bind(&ThumbnailCache::CompressionTask, bitmap,
394 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN), 394 encoded_size, post_compression_task));
395 base::Bind(&ThumbnailCache::CompressionTask, bitmap, encoded_size,
396 post_compression_task));
397 } 395 }
398 396
399 void ThumbnailCache::ReadNextThumbnail() { 397 void ThumbnailCache::ReadNextThumbnail() {
400 if (read_queue_.empty() || read_in_progress_) 398 if (read_queue_.empty() || read_in_progress_)
401 return; 399 return;
402 400
403 TabId tab_id = read_queue_.front(); 401 TabId tab_id = read_queue_.front();
404 read_in_progress_ = true; 402 read_in_progress_ = true;
405 403
406 base::Callback<void(sk_sp<SkPixelRef>, float, const gfx::Size&)> 404 base::Callback<void(sk_sp<SkPixelRef>, float, const gfx::Size&)>
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 if (!valid_contents) { 765 if (!valid_contents) {
768 content_size.SetSize(0, 0); 766 content_size.SetSize(0, 0);
769 scale = 0.f; 767 scale = 0.f;
770 compressed_data.reset(); 768 compressed_data.reset();
771 base::DeleteFile(file_path, false); 769 base::DeleteFile(file_path, false);
772 } 770 }
773 } 771 }
774 772
775 if (decompress) { 773 if (decompress) {
776 base::PostTaskWithTraits( 774 base::PostTaskWithTraits(
777 FROM_HERE, 775 FROM_HERE, {base::TaskPriority::BACKGROUND},
778 base::TaskTraits().WithPriority(base::TaskPriority::BACKGROUND),
779 base::Bind(post_read_task, std::move(compressed_data), scale, 776 base::Bind(post_read_task, std::move(compressed_data), scale,
780 content_size)); 777 content_size));
781 } else { 778 } else {
782 content::BrowserThread::PostTask( 779 content::BrowserThread::PostTask(
783 content::BrowserThread::UI, 780 content::BrowserThread::UI,
784 FROM_HERE, 781 FROM_HERE,
785 base::Bind(post_read_task, std::move(compressed_data), scale, 782 base::Bind(post_read_task, std::move(compressed_data), scale,
786 content_size)); 783 content_size));
787 } 784 }
788 } 785 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 return std::make_pair(dst_bitmap, new_scale * scale); 921 return std::make_pair(dst_bitmap, new_scale * scale);
925 } 922 }
926 923
927 void ThumbnailCache::OnMemoryPressure( 924 void ThumbnailCache::OnMemoryPressure(
928 base::MemoryPressureListener::MemoryPressureLevel level) { 925 base::MemoryPressureListener::MemoryPressureLevel level) {
929 if (level == base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { 926 if (level == base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
930 cache_.Clear(); 927 cache_.Clear();
931 approximation_cache_.Clear(); 928 approximation_cache_.Clear();
932 } 929 }
933 } 930 }
OLDNEW
« no previous file with comments | « chrome/browser/android/offline_pages/request_coordinator_factory.cc ('k') | chrome/browser/android/webapk/webapk_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698