Commit 36b8b8de authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Avoid base::RefCountedBytes's data copying ctor.

Use base::RefCountedBytes::TakeVector() or base::RefCountedStaticMemory
instead.

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I6bf4cdc2b0dff5f8c75e3a8dacda0da92213a9fb
Reviewed-on: https://chromium-review.googlesource.com/979398Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546015}
parent 4b21f5cb
...@@ -675,8 +675,8 @@ TEST_F(ExtensionPrinterHandlerTest, Print_Pdf) { ...@@ -675,8 +675,8 @@ TEST_F(ExtensionPrinterHandlerTest, Print_Pdf) {
bool success = false; bool success = false;
std::string status; std::string status;
auto print_data = auto print_data = base::MakeRefCounted<base::RefCountedStaticMemory>(
base::MakeRefCounted<base::RefCountedBytes>(kPrintData, kPrintDataLength); kPrintData, kPrintDataLength);
base::string16 title = base::ASCIIToUTF16("Title"); base::string16 title = base::ASCIIToUTF16("Title");
extension_printer_handler_->StartPrint( extension_printer_handler_->StartPrint(
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted_memory.h"
#include "base/task_scheduler/post_task.h" #include "base/task_scheduler/post_task.h"
#include "content/browser/frame_host/navigation_controller_impl.h" #include "content/browser/frame_host/navigation_controller_impl.h"
#include "content/browser/frame_host/navigation_entry_impl.h" #include "content/browser/frame_host/navigation_entry_impl.h"
...@@ -72,7 +73,7 @@ class ScreenshotData : public base::RefCountedThreadSafe<ScreenshotData> { ...@@ -72,7 +73,7 @@ class ScreenshotData : public base::RefCountedThreadSafe<ScreenshotData> {
// Encode the A8 bitmap to grayscale PNG treating alpha as color intensity. // Encode the A8 bitmap to grayscale PNG treating alpha as color intensity.
std::vector<unsigned char> data; std::vector<unsigned char> data;
if (gfx::PNGCodec::EncodeA8SkBitmap(grayscale_bitmap, &data)) if (gfx::PNGCodec::EncodeA8SkBitmap(grayscale_bitmap, &data))
data_ = new base::RefCountedBytes(data); data_ = base::RefCountedBytes::TakeVector(&data);
} }
scoped_refptr<base::RefCountedBytes> data_; scoped_refptr<base::RefCountedBytes> data_;
......
...@@ -239,7 +239,7 @@ std::unique_ptr<gfx::GpuMemoryBuffer> GLManager::CreateGpuMemoryBuffer( ...@@ -239,7 +239,7 @@ std::unique_ptr<gfx::GpuMemoryBuffer> GLManager::CreateGpuMemoryBuffer(
} }
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
std::vector<uint8_t> data(gfx::BufferSizeForBufferFormat(size, format), 0); std::vector<uint8_t> data(gfx::BufferSizeForBufferFormat(size, format), 0);
scoped_refptr<base::RefCountedBytes> bytes(new base::RefCountedBytes(data)); auto bytes = base::RefCountedBytes::TakeVector(&data);
return base::WrapUnique<gfx::GpuMemoryBuffer>( return base::WrapUnique<gfx::GpuMemoryBuffer>(
new GpuMemoryBufferImpl(bytes.get(), size, format)); new GpuMemoryBufferImpl(bytes.get(), size, format));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment