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

Side by Side Diff: third_party/WebKit/Source/core/clipboard/DataObjectItem.cpp

Issue 1876653003: Register clipboard image blob in the browser process to copy data less. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use blocking pool. Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return m_file.get(); 109 return m_file.get();
110 ASSERT(m_sharedBuffer); 110 ASSERT(m_sharedBuffer);
111 // FIXME: This code is currently impossible--we never populate m_sharedB uffer when dragging 111 // FIXME: This code is currently impossible--we never populate m_sharedB uffer when dragging
112 // in. At some point though, we may need to support correctly converting a shared buffer 112 // in. At some point though, we may need to support correctly converting a shared buffer
113 // into a file. 113 // into a file.
114 return nullptr; 114 return nullptr;
115 } 115 }
116 116
117 ASSERT(m_source == PasteboardSource); 117 ASSERT(m_source == PasteboardSource);
118 if (type() == mimeTypeImagePng) { 118 if (type() == mimeTypeImagePng) {
119 // FIXME: This is pretty inefficient. We copy the data from the browser 119 WebBlobInfo blobInfo = Platform::current()->clipboard()->readImage(WebCl ipboard::BufferStandard);
120 // to the renderer. We then place it in a blob in WebKit, which 120 if (blobInfo.size() < 0)
121 // registers it and copies it *back* to the browser. When a consumer 121 return nullptr;
122 // wants to read the data, we then copy the data back into the renderer. 122 return Blob::create(BlobDataHandle::create(blobInfo.uuid(), blobInfo.typ e(), blobInfo.size()));
dmurph 2016/04/12 00:10:23 Hmmm.. Well if you went the register-blob-in-dispa
123 // https://bugs.webkit.org/show_bug.cgi?id=58107 has been filed to track
124 // improvements to this code (in particular, add a registerClipboardBlob
125 // method to the blob registry; that way the data is only copied over
126 // into the renderer when it's actually read, not when the blob is
127 // initially constructed).
128 RefPtr<SharedBuffer> data = static_cast<PassRefPtr<SharedBuffer>>(Platfo rm::current()->clipboard()->readImage(WebClipboard::BufferStandard));
129 OwnPtr<BlobData> blobData = BlobData::create();
130 blobData->appendBytes(data->data(), data->size());
131 blobData->setContentType(mimeTypeImagePng);
132 return Blob::create(BlobDataHandle::create(blobData.release(), data->siz e()));
133 } 123 }
134 124
135 return nullptr; 125 return nullptr;
136 } 126 }
137 127
138 String DataObjectItem::getAsString() const 128 String DataObjectItem::getAsString() const
139 { 129 {
140 ASSERT(m_kind == StringKind); 130 ASSERT(m_kind == StringKind);
141 131
142 if (m_source == InternalSource) 132 if (m_source == InternalSource)
(...skipping 23 matching lines...) Expand all
166 // we'll need to make sure this works as expected for DragDataChromium. 156 // we'll need to make sure this works as expected for DragDataChromium.
167 return m_kind == FileKind && m_file; 157 return m_kind == FileKind && m_file;
168 } 158 }
169 159
170 DEFINE_TRACE(DataObjectItem) 160 DEFINE_TRACE(DataObjectItem)
171 { 161 {
172 visitor->trace(m_file); 162 visitor->trace(m_file);
173 } 163 }
174 164
175 } // namespace blink 165 } // namespace blink
OLDNEW
« no previous file with comments | « content/test/mock_webclipboard_impl.cc ('k') | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698