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.h | |
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.h')
-rw-r--r-- | app/clipboard/clipboard.h | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/app/clipboard/clipboard.h b/app/clipboard/clipboard.h index faaa00c..ee536f6 100644 --- a/app/clipboard/clipboard.h +++ b/app/clipboard/clipboard.h @@ -10,7 +10,9 @@ #include <vector> #include "base/process.h" +#include "base/shared_memory.h" #include "base/string16.h" +#include "testing/gtest/include/gtest/gtest_prod.h" namespace gfx { class Size; @@ -61,7 +63,8 @@ class Clipboard { // CBF_WEBKIT none empty vector // CBF_BITMAP pixels byte array // size gfx::Size struct - // CBF_SMBITMAP shared_mem shared memory handle + // CBF_SMBITMAP shared_mem A pointer to an unmapped base::SharedMemory + // object containing the bitmap data. // size gfx::Size struct // CBF_DATA format char array // data byte array @@ -160,21 +163,26 @@ class Clipboard { static FormatType GetWebKitSmartPasteFormatType(); // Win: MS HTML Format, Other: Generic HTML format static FormatType GetHtmlFormatType(); -#if defined(OS_WIN) static FormatType GetBitmapFormatType(); + + // Embeds a pointer to a SharedMemory object pointed to by |bitmap_handle| + // belonging to |process| into a shared bitmap [CBF_SMBITMAP] slot in + // |objects|. The pointer is deleted by DispatchObjects(). + // + // On non-Windows platforms, |process| is ignored. + static void ReplaceSharedMemHandle(ObjectMap* objects, + base::SharedMemoryHandle bitmap_handle, + base::ProcessHandle process); +#if defined(OS_WIN) // Firefox text/html static FormatType GetTextHtmlFormatType(); static FormatType GetCFHDropFormatType(); static FormatType GetFileDescriptorFormatType(); static FormatType GetFileContentFormatZeroType(); - - // Duplicates any remote shared memory handle embedded inside |objects| that - // was created by |process| so that it can be used by this process. - static void DuplicateRemoteHandles(base::ProcessHandle process, - ObjectMap* objects); #endif private: + FRIEND_TEST(ClipboardTest, SharedBitmapTest); void DispatchObject(ObjectType type, const ObjectMapParams& params); void WriteText(const char* text_data, size_t text_len); @@ -200,10 +208,6 @@ class Clipboard { const char* data_data, size_t data_len); #endif #if defined(OS_WIN) - void WriteBitmapFromSharedMemory(const char* bitmap_data, - const char* size_data, - base::ProcessHandle handle); - void WriteBitmapFromHandle(HBITMAP source_hbitmap, const gfx::Size& size); |