Chromium Code Reviews

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.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « Source/core/page/EventHandler.cpp ('k') | Source/web/WebViewImpl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebDragData.cpp
diff --git a/Source/web/WebDragData.cpp b/Source/web/WebDragData.cpp
index adff6b448e1cd6aa3050a75f0f83a037629bab71..50635239f0aa5be603f1e6bafde117182ecf0e6f 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,32 +47,68 @@ using namespace WebCore;
namespace blink {
-class WebDragDataPrivate : public DataObject {
-};
+WebDragData::WebDragData(const WebDragData& object)
+{
+ assign(object);
+}
+
+WebDragData::~WebDragData()
+{
+ reset();
+}
+
+WebDragData& WebDragData::operator=(const WebDragData& object)
+{
+ assign(object);
+ return *this;
+}
+
+bool WebDragData::isNull() const
+{
+ return m_private.isNull();
+}
void WebDragData::initialize()
{
- assign(static_cast<WebDragDataPrivate*>(DataObject::create().leakRef()));
+ m_private = DataObject::create();
}
void WebDragData::reset()
{
- assign(0);
+ m_private.reset();
}
void WebDragData::assign(const WebDragData& other)
{
- WebDragDataPrivate* p = const_cast<WebDragDataPrivate*>(other.m_private);
- if (p)
- p->ref();
- assign(p);
+ m_private = other.m_private;
+}
+
+WebDragData::WebDragData(const PassRefPtrWillBeRawPtr<WebCore::DataObject>& object)
+{
+ assign(object);
+}
+
+WebDragData& WebDragData::operator=(const PassRefPtrWillBeRawPtr<WebCore::DataObject>& object)
+{
+ assign(object);
+ return *this;
+}
+
+DataObject* WebDragData::getValue() const
sof 2014/02/19 08:30:24 I'm not sure getValue() is worth having in this se
haraken 2014/02/19 08:37:12 Yeah, this might be unnecessary. In the experimen
+{
+ return m_private.get();
+}
+
+void WebDragData::ensureMutable()
+{
+ ASSERT(!isNull());
}
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 +140,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 +151,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 +169,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 +179,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
« no previous file with comments | « Source/core/page/EventHandler.cpp ('k') | Source/web/WebViewImpl.h » ('j') | no next file with comments »

Powered by Google App Engine