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

Unified Diff: Source/web/WebDragData.cpp

Issue 169323002: Oilpan: Move core/clipboard/ to oilpan's heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: Source/web/WebDragData.cpp
diff --git a/Source/web/WebDragData.cpp b/Source/web/WebDragData.cpp
index adff6b448e1cd6aa3050a75f0f83a037629bab71..32106354a6d34b2c9252e28b76e9d0869c5597ed 100644
--- a/Source/web/WebDragData.cpp
+++ b/Source/web/WebDragData.cpp
@@ -32,6 +32,7 @@
#include "core/clipboard/DataObject.h"
#include "core/clipboard/DataTransferItem.h"
+#include "heap/Handle.h"
#include "modules/filesystem/DraggedIsolatedFileSystem.h"
#include "platform/clipboard/ClipboardMimeTypes.h"
#include "public/platform/WebData.h"
@@ -46,9 +47,101 @@ using namespace WebCore;
namespace blink {
+#if ENABLE(OILPAN)
+class WebDragDataPrivate {
+ explicit WebDragDataPrivate(DataObject* dragData) : m_dragData(dragData) { }
+ Persistent<DataObject> m_dragData;
+ friend class WebDragData;
+};
+
+WebDragData::~WebDragData()
+{
+ delete m_private;
+}
+
+WebDragData::WebDragData()
+ : m_private(new WebDragDataPrivate(0))
+{
+}
+
+WebDragData::WebDragData(const WebDragData& other)
+ : m_private(new WebDragDataPrivate(other.getValue()))
+{
+}
+
+WebDragData& WebDragData::operator=(const WebDragData& dragData)
+{
+ assign(dragData);
+ return *this;
+}
+
+void WebDragData::initialize()
+{
+ m_private->m_dragData = DataObject::create();
+}
+
+void WebDragData::reset()
+{
+ m_private->m_dragData.clear();
+}
+
+void WebDragData::assign(const WebDragData& other)
+{
+ m_private->m_dragData = other.m_private->m_dragData;
+}
+
+WebDragData::WebDragData(const WTF::RawPtr<WebCore::DataObject>& data)
+{
+ assign(data);
+}
+
+WebDragData& WebDragData::operator=(const WTF::RawPtr<WebCore::DataObject>& other)
+{
+ assign(other);
+ return *this;
+}
+
+DataObject* WebDragData::getValue() const
+{
+ return m_private->m_dragData;
+}
+
+// FIXME: oilpan: Remove this once we remove the oilpan flag.
+void WebDragData::assign(WebDragDataPrivate*)
+{
+ ASSERT_NOT_REACHED();
+}
+
+void WebDragData::ensureMutable()
+{
+ ASSERT(!isNull());
+ ASSERT(m_private);
+}
+
+#else
class WebDragDataPrivate : public DataObject {
};
+~WebDragData()
+{
+ reset();
+}
+
+WebDragData() : m_private(0)
+{
+}
+
+WebDragData(const WebDragData& dragData) : m_private(0)
+{
+ assign(dragData);
+}
+
+WebDragData& operator=(const WebDragData& dragData)
+{
+ assign(dragData);
+ return *this;
+}
+
void WebDragData::initialize()
{
assign(static_cast<WebDragDataPrivate*>(DataObject::create().leakRef()));
@@ -67,11 +160,42 @@ void WebDragData::assign(const WebDragData& other)
assign(p);
}
+WebDragData::WebDragData(const WTF::PassRefPtr<WebCore::DataObject>& data)
+ : m_private(static_cast<WebDragDataPrivate*>(data.leakRef()))
+{
+}
+
+WebDragData& WebDragData::operator=(const WTF::PassRefPtr<WebCore::DataObject>& data)
+{
+ assign(static_cast<WebDragDataPrivate*>(data.leakRef()));
+ return *this;
+}
+
+DataObject* WebDragData::getValue() const
+{
+ return m_private;
+}
+
+void WebDragData::assign(WebDragDataPrivate* p)
+{
+ // p is already ref'd for us by the caller
+ if (m_private)
+ m_private->deref();
+ m_private = p;
+}
+
+void WebDragData::ensureMutable()
+{
+ ASSERT(!isNull());
+ ASSERT(m_private->hasOneRef());
+}
+#endif // ENABLE(OILPAN)
+
WebVector<WebDragData::Item> WebDragData::items() const
{
Vector<Item> itemList;
- for (size_t i = 0; i < m_private->length(); ++i) {
- DataObjectItem* originalItem = m_private->item(i).get();
+ for (size_t i = 0; i < getValue()->length(); ++i) {
+ DataObjectItem* originalItem = getValue()->item(i).get();
WebDragData::Item item;
if (originalItem->kind() == DataObjectItem::StringKind) {
item.storageType = Item::StorageTypeString;
@@ -103,7 +227,7 @@ WebVector<WebDragData::Item> WebDragData::items() const
void WebDragData::setItems(const WebVector<Item>& itemList)
{
- m_private->clearAll();
+ getValue()->clearAll();
for (size_t i = 0; i < itemList.size(); ++i)
addItem(itemList[i]);
}
@@ -114,14 +238,14 @@ void WebDragData::addItem(const Item& item)
switch (item.storageType) {
case Item::StorageTypeString:
if (String(item.stringType) == mimeTypeTextURIList)
- m_private->setURLAndTitle(item.stringData, item.title);
+ getValue()->setURLAndTitle(item.stringData, item.title);
else if (String(item.stringType) == mimeTypeTextHTML)
- m_private->setHTMLAndBaseURL(item.stringData, item.baseURL);
+ getValue()->setHTMLAndBaseURL(item.stringData, item.baseURL);
else
- m_private->setData(item.stringType, item.stringData);
+ getValue()->setData(item.stringType, item.stringData);
return;
case Item::StorageTypeFilename:
- m_private->addFilename(item.filenameData, item.displayNameData);
+ getValue()->addFilename(item.filenameData, item.displayNameData);
return;
case Item::StorageTypeBinaryData:
// This should never happen when dragging in.
@@ -132,7 +256,7 @@ void WebDragData::addItem(const Item& item)
WebString WebDragData::filesystemId() const
{
ASSERT(!isNull());
- DraggedIsolatedFileSystem* filesystem = DraggedIsolatedFileSystem::from(m_private);
+ DraggedIsolatedFileSystem* filesystem = DraggedIsolatedFileSystem::from(getValue());
if (filesystem)
return filesystem->filesystemId();
return WebString();
@@ -142,37 +266,7 @@ void WebDragData::setFilesystemId(const WebString& filesystemId)
{
// The ID is an opaque string, given by and validated by chromium port.
ensureMutable();
- DraggedIsolatedFileSystem::provideTo(m_private, DraggedIsolatedFileSystem::supplementName(), DraggedIsolatedFileSystem::create(filesystemId));
-}
-
-WebDragData::WebDragData(const WTF::PassRefPtr<WebCore::DataObject>& data)
- : m_private(static_cast<WebDragDataPrivate*>(data.leakRef()))
-{
-}
-
-WebDragData& WebDragData::operator=(const WTF::PassRefPtr<WebCore::DataObject>& data)
-{
- assign(static_cast<WebDragDataPrivate*>(data.leakRef()));
- return *this;
-}
-
-WebDragData::operator WTF::PassRefPtr<WebCore::DataObject>() const
-{
- return PassRefPtr<DataObject>(const_cast<WebDragDataPrivate*>(m_private));
-}
-
-void WebDragData::assign(WebDragDataPrivate* p)
-{
- // p is already ref'd for us by the caller
- if (m_private)
- m_private->deref();
- m_private = p;
-}
-
-void WebDragData::ensureMutable()
-{
- ASSERT(!isNull());
- ASSERT(m_private->hasOneRef());
+ DraggedIsolatedFileSystem::provideTo(getValue(), DraggedIsolatedFileSystem::supplementName(), DraggedIsolatedFileSystem::create(filesystemId));
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698