OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file provides the embedder's side of random webkit glue functions. | 5 // This file provides the embedder's side of random webkit glue functions. |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // processes. | 88 // processes. |
89 void ScopedClipboardWriterGlue::WriteBitmap(const SkBitmap& bitmap) { | 89 void ScopedClipboardWriterGlue::WriteBitmap(const SkBitmap& bitmap) { |
90 // do not try to write a bitmap more than once | 90 // do not try to write a bitmap more than once |
91 if (shared_buf_) | 91 if (shared_buf_) |
92 return; | 92 return; |
93 | 93 |
94 size_t buf_size = bitmap.getSize(); | 94 size_t buf_size = bitmap.getSize(); |
95 gfx::Size size(bitmap.width(), bitmap.height()); | 95 gfx::Size size(bitmap.width(), bitmap.height()); |
96 | 96 |
97 // Allocate a shared memory buffer to hold the bitmap bits | 97 // Allocate a shared memory buffer to hold the bitmap bits |
98 shared_buf_ = RenderProcess::AllocSharedMemory(buf_size); | 98 shared_buf_ = new base::SharedMemory; |
| 99 shared_buf_->Create(L"", false /* read write */, true /* open existing */, |
| 100 buf_size); |
99 if (!shared_buf_ || !shared_buf_->Map(buf_size)) { | 101 if (!shared_buf_ || !shared_buf_->Map(buf_size)) { |
100 NOTREACHED(); | 102 NOTREACHED(); |
101 return; | 103 return; |
102 } | 104 } |
103 | 105 |
104 // Copy the bits into shared memory | 106 // Copy the bits into shared memory |
105 SkAutoLockPixels bitmap_lock(bitmap); | 107 SkAutoLockPixels bitmap_lock(bitmap); |
106 memcpy(shared_buf_->memory(), bitmap.getPixels(), buf_size); | 108 memcpy(shared_buf_->memory(), bitmap.getPixels(), buf_size); |
107 shared_buf_->Unmap(); | 109 shared_buf_->Unmap(); |
108 | 110 |
(...skipping 18 matching lines...) Expand all Loading... |
127 // Define a destructor that makes IPCs to flush the contents to the | 129 // Define a destructor that makes IPCs to flush the contents to the |
128 // system clipboard. | 130 // system clipboard. |
129 ScopedClipboardWriterGlue::~ScopedClipboardWriterGlue() { | 131 ScopedClipboardWriterGlue::~ScopedClipboardWriterGlue() { |
130 if (objects_.empty()) | 132 if (objects_.empty()) |
131 return; | 133 return; |
132 | 134 |
133 #if defined(OS_WIN) | 135 #if defined(OS_WIN) |
134 if (shared_buf_) { | 136 if (shared_buf_) { |
135 g_render_thread->Send( | 137 g_render_thread->Send( |
136 new ViewHostMsg_ClipboardWriteObjectsSync(objects_)); | 138 new ViewHostMsg_ClipboardWriteObjectsSync(objects_)); |
137 RenderProcess::FreeSharedMemory(shared_buf_); | 139 delete shared_buf_; |
138 return; | 140 return; |
139 } | 141 } |
140 #endif | 142 #endif |
141 | 143 |
142 g_render_thread->Send( | 144 g_render_thread->Send( |
143 new ViewHostMsg_ClipboardWriteObjectsAsync(objects_)); | 145 new ViewHostMsg_ClipboardWriteObjectsAsync(objects_)); |
144 } | 146 } |
145 | 147 |
146 namespace webkit_glue { | 148 namespace webkit_glue { |
147 | 149 |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 // Update the browser about our cache | 367 // Update the browser about our cache |
366 // NOTE: Since this can be called from the plugin process, we might not have | 368 // NOTE: Since this can be called from the plugin process, we might not have |
367 // a RenderThread. Do nothing in that case. | 369 // a RenderThread. Do nothing in that case. |
368 if (g_render_thread) | 370 if (g_render_thread) |
369 g_render_thread->InformHostOfCacheStatsLater(); | 371 g_render_thread->InformHostOfCacheStatsLater(); |
370 } | 372 } |
371 | 373 |
372 #endif // !USING_SIMPLE_RESOURCE_LOADER_BRIDGE | 374 #endif // !USING_SIMPLE_RESOURCE_LOADER_BRIDGE |
373 | 375 |
374 } // namespace webkit_glue | 376 } // namespace webkit_glue |
OLD | NEW |