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

Side by Side Diff: third_party/WebKit/Source/core/dom/ClassicPendingScript.cpp

Issue 2724673002: [WIP] Introduce ScriptResourceData
Patch Set: Compile fix Created 3 years, 4 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #include "core/dom/ClassicPendingScript.h" 5 #include "core/dom/ClassicPendingScript.h"
6 6
7 #include "bindings/core/v8/ScriptSourceCode.h" 7 #include "bindings/core/v8/ScriptSourceCode.h"
8 #include "bindings/core/v8/ScriptStreamer.h" 8 #include "bindings/core/v8/ScriptStreamer.h"
9 #include "bindings/core/v8/V8BindingForCore.h" 9 #include "bindings/core/v8/V8BindingForCore.h"
10 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // It is possible to get back a script resource with integrity metadata 135 // It is possible to get back a script resource with integrity metadata
136 // for a request with an empty integrity attribute. In that case, the 136 // for a request with an empty integrity attribute. In that case, the
137 // integrity check should be skipped, so this check ensures that the 137 // integrity check should be skipped, so this check ensures that the
138 // integrity attribute isn't empty in addition to checking if the 138 // integrity attribute isn't empty in addition to checking if the
139 // resource has empty integrity metadata. 139 // resource has empty integrity metadata.
140 if (!element->IntegrityAttributeValue().IsEmpty()) { 140 if (!element->IntegrityAttributeValue().IsEmpty()) {
141 integrity_failure_ = GetResource()->IntegrityDisposition() != 141 integrity_failure_ = GetResource()->IntegrityDisposition() !=
142 ResourceIntegrityDisposition::kPassed; 142 ResourceIntegrityDisposition::kPassed;
143 } 143 }
144 } 144 }
145 DCHECK(!resource_data_);
146 resource_data_ = GetResource()->ResourceData();
147 DCHECK(resource_data_);
145 148
146 // We are now waiting for script streaming to finish. 149 // We are now waiting for script streaming to finish.
147 // If there is no script streamer, this step completes immediately. 150 // If there is no script streamer, this step completes immediately.
148 AdvanceReadyState(kWaitingForStreaming); 151 AdvanceReadyState(kWaitingForStreaming);
149 if (streamer_) 152 if (streamer_)
150 streamer_->NotifyFinished(resource); 153 streamer_->NotifyFinished(resource);
151 else 154 else
152 FinishWaitingForStreaming(); 155 FinishWaitingForStreaming();
153 } 156 }
154 157
155 void ClassicPendingScript::NotifyAppendData(ScriptResource* resource) { 158 void ClassicPendingScript::NotifyAppendData(ScriptResource* resource) {
156 if (streamer_) 159 if (streamer_)
157 streamer_->NotifyAppendData(resource); 160 streamer_->NotifyAppendData(resource);
158 } 161 }
159 162
160 DEFINE_TRACE(ClassicPendingScript) { 163 DEFINE_TRACE(ClassicPendingScript) {
161 visitor->Trace(streamer_); 164 visitor->Trace(streamer_);
165 visitor->Trace(resource_data_);
162 ResourceOwner<ScriptResource>::Trace(visitor); 166 ResourceOwner<ScriptResource>::Trace(visitor);
163 MemoryCoordinatorClient::Trace(visitor); 167 MemoryCoordinatorClient::Trace(visitor);
164 PendingScript::Trace(visitor); 168 PendingScript::Trace(visitor);
165 } 169 }
166 170
167 ClassicScript* ClassicPendingScript::GetSource(const KURL& document_url, 171 ClassicScript* ClassicPendingScript::GetSource(const KURL& document_url,
168 bool& error_occurred) const { 172 bool& error_occurred) const {
169 CheckState(); 173 CheckState();
170 DCHECK(IsReady()); 174 DCHECK(IsReady());
171 175
172 error_occurred = ErrorOccurred(); 176 error_occurred = ErrorOccurred();
173 if (!is_external_) { 177 if (!is_external_) {
174 return ClassicScript::Create(ScriptSourceCode( 178 return ClassicScript::Create(ScriptSourceCode(
175 GetElement()->TextFromChildren(), document_url, StartingPosition())); 179 GetElement()->TextFromChildren(), document_url, StartingPosition()));
176 } 180 }
177 181
178 DCHECK(GetResource()->IsLoaded()); 182 CHECK(ResourceData());
179 bool streamer_ready = (ready_state_ == kReady) && streamer_ && 183 bool streamer_ready = (ready_state_ == kReady) && streamer_ &&
180 !streamer_->StreamingSuppressed(); 184 !streamer_->StreamingSuppressed();
181 return ClassicScript::Create( 185 return ClassicScript::Create(
182 ScriptSourceCode(streamer_ready ? streamer_ : nullptr, GetResource())); 186 ScriptSourceCode(streamer_ready ? streamer_ : nullptr, ResourceData()));
183 } 187 }
184 188
185 void ClassicPendingScript::SetStreamer(ScriptStreamer* streamer) { 189 void ClassicPendingScript::SetStreamer(ScriptStreamer* streamer) {
186 DCHECK(streamer); 190 DCHECK(streamer);
187 DCHECK(!streamer_); 191 DCHECK(!streamer_);
188 DCHECK(!IsWatchingForLoad() || ready_state_ != kWaitingForResource); 192 DCHECK(!IsWatchingForLoad() || ready_state_ != kWaitingForResource);
189 DCHECK(!streamer->IsFinished()); 193 DCHECK(!streamer->IsFinished());
190 DCHECK(ready_state_ == kWaitingForResource || ready_state_ == kReady); 194 DCHECK(ready_state_ == kWaitingForResource || ready_state_ == kReady);
191 195
192 streamer_ = streamer; 196 streamer_ = streamer;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 return ready_state_ == kReadyStreaming || (streamer_ && !IsReady()); 321 return ready_state_ == kReadyStreaming || (streamer_ && !IsReady());
318 } 322 }
319 323
320 bool ClassicPendingScript::WasCanceled() const { 324 bool ClassicPendingScript::WasCanceled() const {
321 if (!is_external_) 325 if (!is_external_)
322 return false; 326 return false;
323 return GetResource()->WasCanceled(); 327 return GetResource()->WasCanceled();
324 } 328 }
325 329
326 KURL ClassicPendingScript::UrlForClassicScript() const { 330 KURL ClassicPendingScript::UrlForClassicScript() const {
331 if (ResourceData())
332 return ResourceData()->Url();
333 CHECK(GetResource());
327 return GetResource()->Url(); 334 return GetResource()->Url();
328 } 335 }
329 336
330 void ClassicPendingScript::RemoveFromMemoryCache() { 337 void ClassicPendingScript::RemoveFromMemoryCache() {
331 GetMemoryCache()->Remove(GetResource()); 338 GetMemoryCache()->Remove(GetResource());
332 } 339 }
333 340
334 } // namespace blink 341 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698