OLD | NEW |
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 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "core/clipboard/DataTransferItem.h" | 31 #include "core/clipboard/DataTransferItem.h" |
32 | 32 |
33 #include "bindings/core/v8/V8Binding.h" | 33 #include "bindings/core/v8/V8Binding.h" |
34 #include "core/clipboard/DataObjectItem.h" | 34 #include "core/clipboard/DataObjectItem.h" |
35 #include "core/clipboard/DataTransfer.h" | 35 #include "core/clipboard/DataTransfer.h" |
| 36 #include "core/dom/ExecutionContext.h" |
| 37 #include "core/dom/ExecutionContextTask.h" |
36 #include "core/dom/StringCallback.h" | 38 #include "core/dom/StringCallback.h" |
37 #include "core/dom/TaskRunnerHelper.h" | 39 #include "core/dom/TaskRunnerHelper.h" |
| 40 #include "public/platform/WebTraceLocation.h" |
38 #include "wtf/StdLibExtras.h" | 41 #include "wtf/StdLibExtras.h" |
| 42 #include "wtf/text/WTFString.h" |
39 | 43 |
40 namespace blink { | 44 namespace blink { |
41 | 45 |
42 DataTransferItem* DataTransferItem::create(DataTransfer* dataTransfer, | 46 DataTransferItem* DataTransferItem::create(DataTransfer* dataTransfer, |
43 DataObjectItem* item) { | 47 DataObjectItem* item) { |
44 return new DataTransferItem(dataTransfer, item); | 48 return new DataTransferItem(dataTransfer, item); |
45 } | 49 } |
46 | 50 |
47 String DataTransferItem::kind() const { | 51 String DataTransferItem::kind() const { |
48 DEFINE_STATIC_LOCAL(const String, kindString, ("string")); | 52 DEFINE_STATIC_LOCAL(const String, kindString, ("string")); |
(...skipping 16 matching lines...) Expand all Loading... |
65 return m_item->type(); | 69 return m_item->type(); |
66 } | 70 } |
67 | 71 |
68 void DataTransferItem::getAsString(ExecutionContext* context, | 72 void DataTransferItem::getAsString(ExecutionContext* context, |
69 StringCallback* callback) const { | 73 StringCallback* callback) const { |
70 if (!m_dataTransfer->canReadData()) | 74 if (!m_dataTransfer->canReadData()) |
71 return; | 75 return; |
72 if (!callback || m_item->kind() != DataObjectItem::StringKind) | 76 if (!callback || m_item->kind() != DataObjectItem::StringKind) |
73 return; | 77 return; |
74 | 78 |
75 StringCallback::scheduleCallback(TaskType::UserInteraction, callback, context, | 79 context->postTask( |
76 m_item->getAsString(), | 80 TaskType::UserInteraction, BLINK_FROM_HERE, |
77 "DataTransferItem.getAsString"); | 81 createSameThreadTask(&StringCallback::handleEvent, |
| 82 wrapPersistent(callback), m_item->getAsString()), |
| 83 "DataTransferItem.getAsString"); |
78 } | 84 } |
79 | 85 |
80 Blob* DataTransferItem::getAsFile() const { | 86 Blob* DataTransferItem::getAsFile() const { |
81 if (!m_dataTransfer->canReadData()) | 87 if (!m_dataTransfer->canReadData()) |
82 return nullptr; | 88 return nullptr; |
83 | 89 |
84 return m_item->getAsFile(); | 90 return m_item->getAsFile(); |
85 } | 91 } |
86 | 92 |
87 DataTransferItem::DataTransferItem(DataTransfer* dataTransfer, | 93 DataTransferItem::DataTransferItem(DataTransfer* dataTransfer, |
88 DataObjectItem* item) | 94 DataObjectItem* item) |
89 : m_dataTransfer(dataTransfer), m_item(item) {} | 95 : m_dataTransfer(dataTransfer), m_item(item) {} |
90 | 96 |
91 DEFINE_TRACE(DataTransferItem) { | 97 DEFINE_TRACE(DataTransferItem) { |
92 visitor->trace(m_dataTransfer); | 98 visitor->trace(m_dataTransfer); |
93 visitor->trace(m_item); | 99 visitor->trace(m_item); |
94 } | 100 } |
95 | 101 |
96 } // namespace blink | 102 } // namespace blink |
OLD | NEW |