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

Unified Diff: chrome/browser/notifications/notification_conversion_helper.cc

Issue 820673004: json_schema_compiler: Use std::vector<char> for binary values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simplify_json_schema
Patch Set: Fix merge error. Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/image_decoder.cc ('k') | chromeos/dbus/fake_shill_third_party_vpn_driver_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/notifications/notification_conversion_helper.cc
diff --git a/chrome/browser/notifications/notification_conversion_helper.cc b/chrome/browser/notifications/notification_conversion_helper.cc
index dc2c1f5ae09c1fd10b865a56431401df465b5d68..4434af17bedbf677f4c0aa2da6223e3d6ebb0988 100644
--- a/chrome/browser/notifications/notification_conversion_helper.cc
+++ b/chrome/browser/notifications/notification_conversion_helper.cc
@@ -4,8 +4,12 @@
#include "chrome/browser/notifications/notification_conversion_helper.h"
+#include <string>
+#include <vector>
+
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/extensions/api/notification_provider.h"
#include "chrome/common/extensions/api/notifications/notification_style.h"
@@ -123,15 +127,15 @@ void NotificationConversionHelper::GfxImageToNotificationBitmap(
uint32_t* bitmap_pixels = sk_bitmap.getAddr32(0, 0);
const unsigned char* bitmap =
reinterpret_cast<const unsigned char*>(bitmap_pixels);
- scoped_ptr<unsigned char[]> rgba_bitmap_data(
- new unsigned char[pixel_count * BYTES_PER_PIXEL]);
+ scoped_ptr<std::vector<char>> rgba_bitmap_data(
+ new std::vector<char>(pixel_count * BYTES_PER_PIXEL));
- gfx::ConvertSkiaToRGBA(bitmap, pixel_count, rgba_bitmap_data.get());
+ gfx::ConvertSkiaToRGBA(bitmap, pixel_count,
+ reinterpret_cast<unsigned char*>(
+ vector_as_array(rgba_bitmap_data.get())));
sk_bitmap.unlockPixels();
- notification_bitmap->data.reset(new std::string(
- rgba_bitmap_data.get(),
- (rgba_bitmap_data.get() + pixel_count * BYTES_PER_PIXEL)));
+ notification_bitmap->data = rgba_bitmap_data.Pass();
return;
}
@@ -156,11 +160,11 @@ bool NotificationConversionHelper::NotificationBitmapToGfxImage(
return false;
// Ensure we have rgba data.
- std::string* rgba_data = notification_bitmap->data.get();
+ std::vector<char>* rgba_data = notification_bitmap->data.get();
if (!rgba_data)
return false;
- const size_t rgba_data_length = rgba_data->length();
+ const size_t rgba_data_length = rgba_data->size();
const size_t rgba_area = width * height;
if (rgba_data_length != rgba_area * BYTES_PER_PIXEL)
« no previous file with comments | « chrome/browser/image_decoder.cc ('k') | chromeos/dbus/fake_shill_third_party_vpn_driver_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698