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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.h

Issue 2550373005: Make WebTaskRunner ThreadSafeRefCounted (Closed)
Patch Set: +DISALLOW_COPY_AND_ASSIGN for win build fix Created 3 years, 11 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/bindings/core/v8/ScriptStreamer.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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ScriptStreamer_h 5 #ifndef ScriptStreamer_h
6 #define ScriptStreamer_h 6 #define ScriptStreamer_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "platform/heap/Handle.h" 9 #include "platform/heap/Handle.h"
10 #include "wtf/Noncopyable.h" 10 #include "wtf/Noncopyable.h"
(...skipping 27 matching lines...) Expand all
38 38
39 ~ScriptStreamer(); 39 ~ScriptStreamer();
40 DECLARE_TRACE(); 40 DECLARE_TRACE();
41 41
42 // Launches a task (on a background thread) which will stream the given 42 // Launches a task (on a background thread) which will stream the given
43 // PendingScript into V8 as it loads. 43 // PendingScript into V8 as it loads.
44 static void startStreaming(PendingScript*, 44 static void startStreaming(PendingScript*,
45 Type, 45 Type,
46 Settings*, 46 Settings*,
47 ScriptState*, 47 ScriptState*,
48 WebTaskRunner*); 48 RefPtr<WebTaskRunner>);
49 49
50 // Returns false if we cannot stream the given encoding. 50 // Returns false if we cannot stream the given encoding.
51 static bool convertEncoding(const char* encodingName, 51 static bool convertEncoding(const char* encodingName,
52 v8::ScriptCompiler::StreamedSource::Encoding*); 52 v8::ScriptCompiler::StreamedSource::Encoding*);
53 53
54 bool isFinished() const; 54 bool isFinished() const;
55 55
56 v8::ScriptCompiler::StreamedSource* source() { return m_source.get(); } 56 v8::ScriptCompiler::StreamedSource* source() { return m_source.get(); }
57 ScriptResource* resource() const { return m_resource; } 57 ScriptResource* resource() const { return m_resource; }
58 58
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 private: 101 private:
102 // Scripts whose first data chunk is smaller than this constant won't be 102 // Scripts whose first data chunk is smaller than this constant won't be
103 // streamed. Non-const for testing. 103 // streamed. Non-const for testing.
104 static size_t s_smallScriptThreshold; 104 static size_t s_smallScriptThreshold;
105 105
106 static ScriptStreamer* create( 106 static ScriptStreamer* create(
107 PendingScript* script, 107 PendingScript* script,
108 Type scriptType, 108 Type scriptType,
109 ScriptState* scriptState, 109 ScriptState* scriptState,
110 v8::ScriptCompiler::CompileOptions compileOptions, 110 v8::ScriptCompiler::CompileOptions compileOptions,
111 WebTaskRunner* loadingTaskRunner) { 111 RefPtr<WebTaskRunner> loadingTaskRunner) {
112 return new ScriptStreamer(script, scriptType, scriptState, compileOptions, 112 return new ScriptStreamer(script, scriptType, scriptState, compileOptions,
113 loadingTaskRunner); 113 std::move(loadingTaskRunner));
114 } 114 }
115 ScriptStreamer(PendingScript*, 115 ScriptStreamer(PendingScript*,
116 Type, 116 Type,
117 ScriptState*, 117 ScriptState*,
118 v8::ScriptCompiler::CompileOptions, 118 v8::ScriptCompiler::CompileOptions,
119 WebTaskRunner*); 119 RefPtr<WebTaskRunner>);
120 120
121 void streamingComplete(); 121 void streamingComplete();
122 void notifyFinishedToClient(); 122 void notifyFinishedToClient();
123 123
124 static bool startStreamingInternal(PendingScript*, 124 static bool startStreamingInternal(PendingScript*,
125 Type, 125 Type,
126 Settings*, 126 Settings*,
127 ScriptState*, 127 ScriptState*,
128 WebTaskRunner*); 128 RefPtr<WebTaskRunner>);
129 129
130 Member<PendingScript> m_pendingScript; 130 Member<PendingScript> m_pendingScript;
131 // This pointer is weak. If PendingScript and its Resource are deleted 131 // This pointer is weak. If PendingScript and its Resource are deleted
132 // before ScriptStreamer, PendingScript will notify ScriptStreamer of its 132 // before ScriptStreamer, PendingScript will notify ScriptStreamer of its
133 // deletion by calling cancel(). 133 // deletion by calling cancel().
134 Member<ScriptResource> m_resource; 134 Member<ScriptResource> m_resource;
135 // Whether ScriptStreamer is detached from the Resource. In those cases, the 135 // Whether ScriptStreamer is detached from the Resource. In those cases, the
136 // script data is not needed any more, and the client won't get notified 136 // script data is not needed any more, and the client won't get notified
137 // when the loading and streaming are done. 137 // when the loading and streaming are done.
138 bool m_detached; 138 bool m_detached;
(...skipping 23 matching lines...) Expand all
162 const String m_scriptURLString; 162 const String m_scriptURLString;
163 163
164 // Keep the script resource dentifier for event tracing. 164 // Keep the script resource dentifier for event tracing.
165 const unsigned long m_scriptResourceIdentifier; 165 const unsigned long m_scriptResourceIdentifier;
166 166
167 mutable Mutex m_mutex; 167 mutable Mutex m_mutex;
168 168
169 // Encoding of the streamed script. Saved for sanity checking purposes. 169 // Encoding of the streamed script. Saved for sanity checking purposes.
170 v8::ScriptCompiler::StreamedSource::Encoding m_encoding; 170 v8::ScriptCompiler::StreamedSource::Encoding m_encoding;
171 171
172 std::unique_ptr<WebTaskRunner> m_loadingTaskRunner; 172 RefPtr<WebTaskRunner> m_loadingTaskRunner;
173 }; 173 };
174 174
175 } // namespace blink 175 } // namespace blink
176 176
177 #endif // ScriptStreamer_h 177 #endif // ScriptStreamer_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698