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

Side by Side Diff: content/renderer/renderer_clipboard_client.cc

Issue 14081010: Cleanup: Remove unnecessary ".get()" from scoped_ptrs<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix some gtk issues Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/renderer_clipboard_client.h" 7 #include "content/renderer/renderer_clipboard_client.h"
8 8
9 #include "base/shared_memory.h" 9 #include "base/shared_memory.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 29 matching lines...) Expand all
40 RendererClipboardWriteContext::~RendererClipboardWriteContext() { 40 RendererClipboardWriteContext::~RendererClipboardWriteContext() {
41 } 41 }
42 42
43 // This definition of WriteBitmapFromPixels uses shared memory to communicate 43 // This definition of WriteBitmapFromPixels uses shared memory to communicate
44 // across processes. 44 // across processes.
45 void RendererClipboardWriteContext::WriteBitmapFromPixels( 45 void RendererClipboardWriteContext::WriteBitmapFromPixels(
46 ui::Clipboard::ObjectMap* objects, 46 ui::Clipboard::ObjectMap* objects,
47 const void* pixels, 47 const void* pixels,
48 const gfx::Size& size) { 48 const gfx::Size& size) {
49 // Do not try to write a bitmap more than once 49 // Do not try to write a bitmap more than once
50 if (shared_buf_.get()) 50 if (shared_buf_)
51 return; 51 return;
52 52
53 uint32 buf_size = 4 * size.width() * size.height(); 53 uint32 buf_size = 4 * size.width() * size.height();
54 54
55 // Allocate a shared memory buffer to hold the bitmap bits. 55 // Allocate a shared memory buffer to hold the bitmap bits.
56 shared_buf_.reset(ChildThread::current()->AllocateSharedMemory(buf_size)); 56 shared_buf_.reset(ChildThread::current()->AllocateSharedMemory(buf_size));
57 if (!shared_buf_.get()) 57 if (!shared_buf_)
58 return; 58 return;
59 59
60 // Copy the bits into shared memory 60 // Copy the bits into shared memory
61 DCHECK(shared_buf_->memory()); 61 DCHECK(shared_buf_->memory());
62 memcpy(shared_buf_->memory(), pixels, buf_size); 62 memcpy(shared_buf_->memory(), pixels, buf_size);
63 shared_buf_->Unmap(); 63 shared_buf_->Unmap();
64 64
65 ui::Clipboard::ObjectMapParam size_param; 65 ui::Clipboard::ObjectMapParam size_param;
66 const char* size_data = reinterpret_cast<const char*>(&size); 66 const char* size_data = reinterpret_cast<const char*>(&size);
67 for (size_t i = 0; i < sizeof(gfx::Size); ++i) 67 for (size_t i = 0; i < sizeof(gfx::Size); ++i)
68 size_param.push_back(size_data[i]); 68 size_param.push_back(size_data[i]);
69 69
70 ui::Clipboard::ObjectMapParams params; 70 ui::Clipboard::ObjectMapParams params;
71 71
72 // The first parameter is replaced on the receiving end with a pointer to 72 // The first parameter is replaced on the receiving end with a pointer to
73 // a shared memory object containing the bitmap. We reserve space for it here. 73 // a shared memory object containing the bitmap. We reserve space for it here.
74 ui::Clipboard::ObjectMapParam place_holder_param; 74 ui::Clipboard::ObjectMapParam place_holder_param;
75 params.push_back(place_holder_param); 75 params.push_back(place_holder_param);
76 params.push_back(size_param); 76 params.push_back(size_param);
77 (*objects)[ui::Clipboard::CBF_SMBITMAP] = params; 77 (*objects)[ui::Clipboard::CBF_SMBITMAP] = params;
78 } 78 }
79 79
80 // Flushes the objects to the clipboard with an IPC. 80 // Flushes the objects to the clipboard with an IPC.
81 void RendererClipboardWriteContext::Flush( 81 void RendererClipboardWriteContext::Flush(
82 const ui::Clipboard::ObjectMap& objects) { 82 const ui::Clipboard::ObjectMap& objects) {
83 if (shared_buf_.get()) { 83 if (shared_buf_) {
84 RenderThreadImpl::current()->Send( 84 RenderThreadImpl::current()->Send(
85 new ClipboardHostMsg_WriteObjectsSync(objects, shared_buf_->handle())); 85 new ClipboardHostMsg_WriteObjectsSync(objects, shared_buf_->handle()));
86 } else { 86 } else {
87 RenderThreadImpl::current()->Send( 87 RenderThreadImpl::current()->Send(
88 new ClipboardHostMsg_WriteObjectsAsync(objects)); 88 new ClipboardHostMsg_WriteObjectsAsync(objects));
89 } 89 }
90 } 90 }
91 91
92 } // anonymous namespace 92 } // anonymous namespace
93 93
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 RenderThreadImpl::current()->Send( 183 RenderThreadImpl::current()->Send(
184 new ClipboardHostMsg_ReadData(format, data)); 184 new ClipboardHostMsg_ReadData(format, data));
185 } 185 }
186 186
187 webkit_glue::ClipboardClient::WriteContext* 187 webkit_glue::ClipboardClient::WriteContext*
188 RendererClipboardClient::CreateWriteContext() { 188 RendererClipboardClient::CreateWriteContext() {
189 return new RendererClipboardWriteContext; 189 return new RendererClipboardWriteContext;
190 } 190 }
191 191
192 } // namespace content 192 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.cc ('k') | content/renderer/renderer_webkitplatformsupport_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698