diff options
author | joaoe@opera.com <joaoe@opera.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-12 22:34:08 +0000 |
---|---|---|
committer | joaoe@opera.com <joaoe@opera.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-12 22:34:08 +0000 |
commit | 8df08cf1a988931e952fb85e811418bfe587d050 (patch) | |
tree | e03be7805a62ef18310febf4866408c47d1c8886 /ui | |
parent | 8ed420c98cc6dc1da9d46ca42e47b82843f9de4e (diff) | |
download | chromium_src-8df08cf1a988931e952fb85e811418bfe587d050.zip chromium_src-8df08cf1a988931e952fb85e811418bfe587d050.tar.gz chromium_src-8df08cf1a988931e952fb85e811418bfe587d050.tar.bz2 |
Changed RefCountedStaticMemory() to accept a void pointer.
Using a void pointer saves lots of redundant casting.
Also added RefCountedMemory front_as<type> which saves typing by not having to
wrap each call with a reinterpret_cast<>.
Review URL: https://codereview.chromium.org/126103003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/resource/data_pack.cc | 3 | ||||
-rw-r--r-- | ui/base/resource/resource_bundle.cc | 3 | ||||
-rw-r--r-- | ui/base/resource/resource_bundle_gtk.cc | 2 | ||||
-rw-r--r-- | ui/base/resource/resource_data_dll_win.cc | 3 | ||||
-rw-r--r-- | ui/gfx/icon_util.cc | 4 |
5 files changed, 5 insertions, 10 deletions
diff --git a/ui/base/resource/data_pack.cc b/ui/base/resource/data_pack.cc index 56d74a27..934b14b 100644 --- a/ui/base/resource/data_pack.cc +++ b/ui/base/resource/data_pack.cc @@ -200,8 +200,7 @@ base::RefCountedStaticMemory* DataPack::GetStaticMemory( if (!GetStringPiece(resource_id, &piece)) return NULL; - return new base::RefCountedStaticMemory( - reinterpret_cast<const unsigned char*>(piece.data()), piece.length()); + return new base::RefCountedStaticMemory(piece.data(), piece.length()); } ResourceHandle::TextEncodingType DataPack::GetTextEncodingType() const { diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc index aa0b6f5..42367f7 100644 --- a/ui/base/resource/resource_bundle.cc +++ b/ui/base/resource/resource_bundle.cc @@ -406,8 +406,7 @@ base::RefCountedStaticMemory* ResourceBundle::LoadDataResourceBytesForScale( base::StringPiece data = GetRawDataResourceForScale(resource_id, scale_factor); if (!data.empty()) { - bytes = new base::RefCountedStaticMemory( - reinterpret_cast<const unsigned char*>(data.data()), data.length()); + bytes = new base::RefCountedStaticMemory(data.data(), data.length()); } } diff --git a/ui/base/resource/resource_bundle_gtk.cc b/ui/base/resource/resource_bundle_gtk.cc index 2578dc2..871f9a4 100644 --- a/ui/base/resource/resource_bundle_gtk.cc +++ b/ui/base/resource/resource_bundle_gtk.cc @@ -28,7 +28,7 @@ namespace { GdkPixbuf* LoadPixbuf(base::RefCountedStaticMemory* data, bool rtl_enabled) { ScopedGObject<GdkPixbufLoader>::Type loader(gdk_pixbuf_loader_new()); bool ok = data && gdk_pixbuf_loader_write(loader.get(), - reinterpret_cast<const guint8*>(data->front()), data->size(), NULL); + data->front_as<guint8>(), data->size(), NULL); if (!ok) return NULL; // Calling gdk_pixbuf_loader_close forces the data to be parsed by the diff --git a/ui/base/resource/resource_data_dll_win.cc b/ui/base/resource/resource_data_dll_win.cc index c6c90c71..e6a35aa 100644 --- a/ui/base/resource/resource_data_dll_win.cc +++ b/ui/base/resource/resource_data_dll_win.cc @@ -47,8 +47,7 @@ base::RefCountedStaticMemory* ResourceDataDLL::GetStaticMemory( size_t data_size; if (base::win::GetDataResourceFromModule(module_, resource_id, &data_ptr, &data_size)) { - return new base::RefCountedStaticMemory( - reinterpret_cast<const unsigned char*>(data_ptr), data_size); + return new base::RefCountedStaticMemory(data_ptr, data_size); } return NULL; } diff --git a/ui/gfx/icon_util.cc b/ui/gfx/icon_util.cc index 521c041..5ddf137 100644 --- a/ui/gfx/icon_util.cc +++ b/ui/gfx/icon_util.cc @@ -290,10 +290,8 @@ scoped_ptr<SkBitmap> IconUtil::CreateSkBitmapFromIconResource(HMODULE module, DCHECK(png_data); DCHECK_EQ(png_size, large_icon_entry->dwBytesInRes); - const unsigned char* png_bytes = - reinterpret_cast<const unsigned char*>(png_data); gfx::Image image = gfx::Image::CreateFrom1xPNGBytes( - new base::RefCountedStaticMemory(png_bytes, png_size)); + new base::RefCountedStaticMemory(png_data, png_size)); return scoped_ptr<SkBitmap>(new SkBitmap(image.AsBitmap())); } |