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

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

Issue 2680013008: Reduce use of ExecutionContextTask in core/ (Closed)
Patch Set: fix stacktrace Created 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fileapi/FileReader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 15 matching lines...) Expand all
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"
38 #include "core/dom/StringCallback.h" 36 #include "core/dom/StringCallback.h"
39 #include "core/dom/TaskRunnerHelper.h" 37 #include "core/dom/TaskRunnerHelper.h"
38 #include "core/inspector/InspectorInstrumentation.h"
40 #include "public/platform/WebTraceLocation.h" 39 #include "public/platform/WebTraceLocation.h"
41 #include "wtf/StdLibExtras.h" 40 #include "wtf/StdLibExtras.h"
42 #include "wtf/text/WTFString.h" 41 #include "wtf/text/WTFString.h"
43 42
44 namespace blink { 43 namespace blink {
45 44
46 DataTransferItem* DataTransferItem::create(DataTransfer* dataTransfer, 45 DataTransferItem* DataTransferItem::create(DataTransfer* dataTransfer,
47 DataObjectItem* item) { 46 DataObjectItem* item) {
48 return new DataTransferItem(dataTransfer, item); 47 return new DataTransferItem(dataTransfer, item);
49 } 48 }
(...skipping 12 matching lines...) Expand all
62 ASSERT_NOT_REACHED(); 61 ASSERT_NOT_REACHED();
63 return String(); 62 return String();
64 } 63 }
65 64
66 String DataTransferItem::type() const { 65 String DataTransferItem::type() const {
67 if (!m_dataTransfer->canReadTypes()) 66 if (!m_dataTransfer->canReadTypes())
68 return String(); 67 return String();
69 return m_item->type(); 68 return m_item->type();
70 } 69 }
71 70
71 static void runGetAsStringTask(ExecutionContext* context,
72 StringCallback* callback,
73 const String& data) {
74 InspectorInstrumentation::AsyncTask asyncTask(context, callback);
75 if (context)
76 callback->handleEvent(data);
77 }
78
72 void DataTransferItem::getAsString(ScriptState* scriptState, 79 void DataTransferItem::getAsString(ScriptState* scriptState,
73 StringCallback* callback) const { 80 StringCallback* callback) const {
74 if (!m_dataTransfer->canReadData()) 81 if (!m_dataTransfer->canReadData())
75 return; 82 return;
76 if (!callback || m_item->kind() != DataObjectItem::StringKind) 83 if (!callback || m_item->kind() != DataObjectItem::StringKind)
77 return; 84 return;
78 85
79 scriptState->getExecutionContext()->postTask( 86 ExecutionContext* context = scriptState->getExecutionContext();
80 TaskType::UserInteraction, BLINK_FROM_HERE, 87 InspectorInstrumentation::asyncTaskScheduled(
81 createSameThreadTask(&StringCallback::handleEvent, 88 context, "DataTransferItem.getAsString", callback);
haraken 2017/02/10 05:53:14 Not directly related to this CL, on what tasks do
tzik 2017/02/10 06:13:19 Conceptually, JS-initiated asynchronous tasks that
82 wrapPersistent(callback), m_item->getAsString()), 89 TaskRunnerHelper::get(TaskType::UserInteraction, context)
83 "DataTransferItem.getAsString"); 90 ->postTask(BLINK_FROM_HERE,
91 WTF::bind(&runGetAsStringTask, wrapWeakPersistent(context),
92 wrapPersistent(callback), m_item->getAsString()));
84 } 93 }
85 94
86 File* DataTransferItem::getAsFile() const { 95 File* DataTransferItem::getAsFile() const {
87 if (!m_dataTransfer->canReadData()) 96 if (!m_dataTransfer->canReadData())
88 return nullptr; 97 return nullptr;
89 98
90 return m_item->getAsFile(); 99 return m_item->getAsFile();
91 } 100 }
92 101
93 DataTransferItem::DataTransferItem(DataTransfer* dataTransfer, 102 DataTransferItem::DataTransferItem(DataTransfer* dataTransfer,
94 DataObjectItem* item) 103 DataObjectItem* item)
95 : m_dataTransfer(dataTransfer), m_item(item) {} 104 : m_dataTransfer(dataTransfer), m_item(item) {}
96 105
97 DEFINE_TRACE(DataTransferItem) { 106 DEFINE_TRACE(DataTransferItem) {
98 visitor->trace(m_dataTransfer); 107 visitor->trace(m_dataTransfer);
99 visitor->trace(m_item); 108 visitor->trace(m_item);
100 } 109 }
101 110
102 } // namespace blink 111 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fileapi/FileReader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698