diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-27 10:24:59 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-27 10:24:59 +0000 |
commit | e344c910c5f4a1c88e3da37e074873a6360f3624 (patch) | |
tree | 4c3717fd77e4fcd62fbcb5da37cfe10ca25146fe /app/clipboard/clipboard_mac.mm | |
parent | 98e053c3baec827f9177a429e46abe36cd4fb9f2 (diff) | |
download | chromium_src-e344c910c5f4a1c88e3da37e074873a6360f3624.zip chromium_src-e344c910c5f4a1c88e3da37e074873a6360f3624.tar.gz chromium_src-e344c910c5f4a1c88e3da37e074873a6360f3624.tar.bz2 |
POSIX: Use Shared Mem transport to copy images.
Prior to this change images where copied inline in IPC messages on non-Windows platforms. Copying an oversized image would cause the IPC system to bork and crash the renderer.
Changes in this CL:
* All platforms use a unified mechanism to copy images using shared memory.
* Introduced a new IPC message so the renderer can allocated a shared memory segment on OS X.
* On OS X tried to keep as few copies of the image data in memory as possible.
BUG=26822
TEST=1)On all platforms: navigate to a webpage, right click on an image and copy. Then try pasting into an image editor. 2)Repro steps in bug should no longer crash the Renderer on Mac/Linux
Review URL: http://codereview.chromium.org/552129
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37247 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/clipboard/clipboard_mac.mm')
-rw-r--r-- | app/clipboard/clipboard_mac.mm | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/app/clipboard/clipboard_mac.mm b/app/clipboard/clipboard_mac.mm index ae3f1fe..1596eba 100644 --- a/app/clipboard/clipboard_mac.mm +++ b/app/clipboard/clipboard_mac.mm @@ -123,9 +123,14 @@ void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) { NULL, false, kCGRenderingIntentDefault)); + // Aggressively free storage since image buffers can potentially be very + // large. + data_provider.reset(); + data.reset(); scoped_nsobject<NSBitmapImageRep> bitmap( [[NSBitmapImageRep alloc] initWithCGImage:cgimage]); + cgimage.reset(); scoped_nsobject<NSImage> image([[NSImage alloc] init]); [image addRepresentation:bitmap]; @@ -134,7 +139,11 @@ void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) { // For now, spit out the image as a TIFF. NSPasteboard* pb = GetPasteboard(); [pb addTypes:[NSArray arrayWithObject:NSTIFFPboardType] owner:nil]; - [pb setData:[image TIFFRepresentation] forType:NSTIFFPboardType]; + NSData *tiff_data = [image TIFFRepresentation]; + LOG_IF(ERROR, tiff_data == NULL) << "Failed to allocate image for clipboard"; + if (tiff_data) { + [pb setData:tiff_data forType:NSTIFFPboardType]; + } } // Write an extra flavor that signifies WebKit was the last to modify the @@ -295,6 +304,12 @@ Clipboard::FormatType Clipboard::GetHtmlFormatType() { } // static +Clipboard::FormatType Clipboard::GetBitmapFormatType() { + static const std::string type = base::SysNSStringToUTF8(NSTIFFPboardType); + return type; +} + +// static Clipboard::FormatType Clipboard::GetWebKitSmartPasteFormatType() { static const std::string type = base::SysNSStringToUTF8(kWebSmartPastePboardType); |