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

Side by Side Diff: chrome/browser/themes/browser_theme_pack.cc

Issue 1803263002: base: Make RefCountedBytes::TakeVector return ref ptr instead of raw ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 "chrome/browser/themes/browser_theme_pack.h" 5 #include "chrome/browser/themes/browser_theme_pack.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // the left and the right of the web contents. 382 // the left and the right of the web contents.
383 bool HasFrameBorder() { 383 bool HasFrameBorder() {
384 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) 384 #if defined(OS_CHROMEOS) || defined(OS_MACOSX)
385 return false; 385 return false;
386 #else 386 #else
387 return true; 387 return true;
388 #endif 388 #endif
389 } 389 }
390 390
391 // Returns a piece of memory with the contents of the file |path|. 391 // Returns a piece of memory with the contents of the file |path|.
392 base::RefCountedMemory* ReadFileData(const base::FilePath& path) { 392 scoped_refptr<base::RefCountedMemory> ReadFileData(const base::FilePath& path) {
393 if (!path.empty()) { 393 if (!path.empty()) {
394 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ); 394 base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_READ);
395 if (file.IsValid()) { 395 if (file.IsValid()) {
396 int64_t length = file.GetLength(); 396 int64_t length = file.GetLength();
397 if (length > 0 && length < INT_MAX) { 397 if (length > 0 && length < INT_MAX) {
398 int size = static_cast<int>(length); 398 int size = static_cast<int>(length);
399 std::vector<unsigned char> raw_data; 399 std::vector<unsigned char> raw_data;
400 raw_data.resize(size); 400 raw_data.resize(size);
401 char* data = reinterpret_cast<char*>(&(raw_data.front())); 401 char* data = reinterpret_cast<char*>(&(raw_data.front()));
402 if (file.ReadAtCurrentPos(data, size) == length) 402 if (file.ReadAtCurrentPos(data, size) == length)
403 return base::RefCountedBytes::TakeVector(&raw_data); 403 return base::RefCountedBytes::TakeVector(&raw_data);
404 } 404 }
405 } 405 }
406 } 406 }
407 407
408 return NULL; 408 return nullptr;
409 } 409 }
410 410
411 // Shifts an image's HSL values. The caller is responsible for deleting 411 // Shifts an image's HSL values. The caller is responsible for deleting
412 // the returned image. 412 // the returned image.
413 gfx::Image CreateHSLShiftedImage(const gfx::Image& image, 413 gfx::Image CreateHSLShiftedImage(const gfx::Image& image,
414 const color_utils::HSL& hsl_shift) { 414 const color_utils::HSL& hsl_shift) {
415 const gfx::ImageSkia* src_image = image.ToImageSkia(); 415 const gfx::ImageSkia* src_image = image.ToImageSkia();
416 return gfx::Image(gfx::ImageSkiaOperations::CreateHSLShiftedImage( 416 return gfx::Image(gfx::ImageSkiaOperations::CreateHSLShiftedImage(
417 *src_image, hsl_shift)); 417 *src_image, hsl_shift));
418 } 418 }
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 false, 1542 false,
1543 &bitmap_data)) { 1543 &bitmap_data)) {
1544 NOTREACHED() << "Unable to encode theme image for prs_id=" 1544 NOTREACHED() << "Unable to encode theme image for prs_id="
1545 << prs_id << " for scale_factor=" << scale_factors_[i]; 1545 << prs_id << " for scale_factor=" << scale_factors_[i];
1546 break; 1546 break;
1547 } 1547 }
1548 image_memory_[scaled_raw_id] = 1548 image_memory_[scaled_raw_id] =
1549 base::RefCountedBytes::TakeVector(&bitmap_data); 1549 base::RefCountedBytes::TakeVector(&bitmap_data);
1550 } 1550 }
1551 } 1551 }
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_preview_message_handler.cc ('k') | chrome/browser/ui/webui/print_preview/print_preview_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698