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

Side by Side Diff: ui/gfx/image/image.cc

Issue 2259753003: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « ui/events/x/events_x_unittest.cc ('k') | ui/gl/gl_context.cc » ('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 (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 "ui/gfx/image/image.h" 5 #include "ui/gfx/image/image.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 std::vector<ImagePNGRep> filtered; 401 std::vector<ImagePNGRep> filtered;
402 for (size_t i = 0; i < image_reps.size(); ++i) { 402 for (size_t i = 0; i < image_reps.size(); ++i) {
403 if (image_reps[i].raw_data.get() && image_reps[i].raw_data->size()) 403 if (image_reps[i].raw_data.get() && image_reps[i].raw_data->size())
404 filtered.push_back(image_reps[i]); 404 filtered.push_back(image_reps[i]);
405 } 405 }
406 406
407 if (filtered.empty()) 407 if (filtered.empty())
408 return; 408 return;
409 409
410 storage_ = new internal::ImageStorage(Image::kImageRepPNG); 410 storage_ = new internal::ImageStorage(Image::kImageRepPNG);
411 AddRepresentation(base::WrapUnique(new internal::ImageRepPNG(filtered))); 411 AddRepresentation(base::MakeUnique<internal::ImageRepPNG>(filtered));
412 } 412 }
413 413
414 Image::Image(const ImageSkia& image) { 414 Image::Image(const ImageSkia& image) {
415 if (!image.isNull()) { 415 if (!image.isNull()) {
416 storage_ = new internal::ImageStorage(Image::kImageRepSkia); 416 storage_ = new internal::ImageStorage(Image::kImageRepSkia);
417 AddRepresentation( 417 AddRepresentation(
418 base::WrapUnique(new internal::ImageRepSkia(new ImageSkia(image)))); 418 base::MakeUnique<internal::ImageRepSkia>(new ImageSkia(image)));
419 } 419 }
420 } 420 }
421 421
422 #if defined(OS_IOS) 422 #if defined(OS_IOS)
423 Image::Image(UIImage* image) 423 Image::Image(UIImage* image)
424 : storage_(new internal::ImageStorage(Image::kImageRepCocoaTouch)) { 424 : storage_(new internal::ImageStorage(Image::kImageRepCocoaTouch)) {
425 if (image) 425 if (image)
426 AddRepresentation( 426 AddRepresentation(base::MakeUnique<internal::ImageRepCocoaTouch>(image));
427 base::WrapUnique(new internal::ImageRepCocoaTouch(image)));
428 } 427 }
429 #elif defined(OS_MACOSX) 428 #elif defined(OS_MACOSX)
430 Image::Image(NSImage* image) { 429 Image::Image(NSImage* image) {
431 if (image) { 430 if (image) {
432 storage_ = new internal::ImageStorage(Image::kImageRepCocoa); 431 storage_ = new internal::ImageStorage(Image::kImageRepCocoa);
433 AddRepresentation(base::WrapUnique(new internal::ImageRepCocoa(image))); 432 AddRepresentation(base::MakeUnique<internal::ImageRepCocoa>(image));
434 } 433 }
435 } 434 }
436 #endif 435 #endif
437 436
438 Image::Image(const Image& other) : storage_(other.storage_) { 437 Image::Image(const Image& other) : storage_(other.storage_) {
439 } 438 }
440 439
441 Image& Image::operator=(const Image& other) { 440 Image& Image::operator=(const Image& other) {
442 storage_ = other.storage_; 441 storage_ = other.storage_;
443 return *this; 442 return *this;
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 storage_->representations().insert(std::make_pair(type, std::move(rep))); 756 storage_->representations().insert(std::make_pair(type, std::move(rep)));
758 757
759 // insert should not fail (implies that there was already a representation of 758 // insert should not fail (implies that there was already a representation of
760 // that type in the map). 759 // that type in the map).
761 CHECK(result.second) << "type was already in map."; 760 CHECK(result.second) << "type was already in map.";
762 761
763 return result.first->second.get(); 762 return result.first->second.get();
764 } 763 }
765 764
766 } // namespace gfx 765 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/events/x/events_x_unittest.cc ('k') | ui/gl/gl_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698