Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 return DetermineWebCachePolicy(RequestMethod::kIsNotPost, | 165 return DetermineWebCachePolicy(RequestMethod::kIsNotPost, |
| 166 RequestType::kIsNotConditional, | 166 RequestType::kIsNotConditional, |
| 167 ResourceType::kIsNotMainResource, load_type); | 167 ResourceType::kIsNotMainResource, load_type); |
| 168 } | 168 } |
| 169 | 169 |
| 170 } // namespace | 170 } // namespace |
| 171 | 171 |
| 172 FrameFetchContext::FrameFetchContext(DocumentLoader* loader, Document* document) | 172 FrameFetchContext::FrameFetchContext(DocumentLoader* loader, Document* document) |
| 173 : document_loader_(loader), document_(document) { | 173 : document_loader_(loader), document_(document) { |
| 174 DCHECK(GetFrame()); | 174 DCHECK(GetFrame()); |
| 175 if (document) | |
| 176 network_quiet_detector_ = new NetworkQuietDetector(document); | |
|
zhenw
2017/06/07 17:32:56
I think there is a question about whether NetworkQ
lpy
2017/06/07 18:32:45
Done.
| |
| 175 } | 177 } |
| 176 | 178 |
| 177 void FrameFetchContext::ProvideDocumentToContext(FetchContext& context, | 179 void FrameFetchContext::ProvideDocumentToContext(FetchContext& context, |
| 178 Document* document) { | 180 Document* document) { |
| 179 DCHECK(document); | 181 DCHECK(document); |
| 180 CHECK(context.IsFrameFetchContext()); | 182 CHECK(context.IsFrameFetchContext()); |
| 181 static_cast<FrameFetchContext&>(context).document_ = document; | 183 static_cast<FrameFetchContext&>(context).SetDocument(document); |
| 182 } | 184 } |
| 183 | 185 |
| 184 FrameFetchContext::~FrameFetchContext() { | 186 FrameFetchContext::~FrameFetchContext() { |
| 185 document_loader_ = nullptr; | 187 document_loader_ = nullptr; |
| 186 } | 188 } |
| 187 | 189 |
| 188 LocalFrame* FrameFetchContext::FrameOfImportsController() const { | 190 LocalFrame* FrameFetchContext::FrameOfImportsController() const { |
| 189 DCHECK(GetDocument()); | 191 DCHECK(GetDocument()); |
| 190 HTMLImportsController* imports_controller = | 192 HTMLImportsController* imports_controller = |
| 191 GetDocument()->ImportsController(); | 193 GetDocument()->ImportsController(); |
| 192 DCHECK(imports_controller); | 194 DCHECK(imports_controller); |
| 193 LocalFrame* frame = imports_controller->Master()->GetFrame(); | 195 LocalFrame* frame = imports_controller->Master()->GetFrame(); |
| 194 DCHECK(frame); | 196 DCHECK(frame); |
| 195 return frame; | 197 return frame; |
| 196 } | 198 } |
| 197 | 199 |
| 198 RefPtr<WebTaskRunner> FrameFetchContext::GetTaskRunner() const { | 200 RefPtr<WebTaskRunner> FrameFetchContext::GetTaskRunner() const { |
| 199 return GetFrame()->FrameScheduler()->LoadingTaskRunner(); | 201 return GetFrame()->FrameScheduler()->LoadingTaskRunner(); |
| 200 } | 202 } |
| 201 | 203 |
| 202 Document* FrameFetchContext::GetDocument() const { | 204 Document* FrameFetchContext::GetDocument() const { |
| 203 return document_; | 205 return document_; |
| 204 } | 206 } |
| 205 | 207 |
| 208 void FrameFetchContext::SetDocument(Document* document) { | |
| 209 document_ = document; | |
| 210 if (document) | |
| 211 network_quiet_detector_ = new NetworkQuietDetector(document); | |
| 212 } | |
| 213 | |
| 206 LocalFrame* FrameFetchContext::GetFrame() const { | 214 LocalFrame* FrameFetchContext::GetFrame() const { |
| 207 if (!document_loader_) | 215 if (!document_loader_) |
| 208 return FrameOfImportsController(); | 216 return FrameOfImportsController(); |
| 209 | 217 |
| 210 LocalFrame* frame = document_loader_->GetFrame(); | 218 LocalFrame* frame = document_loader_->GetFrame(); |
| 211 DCHECK(frame); | 219 DCHECK(frame); |
| 212 return frame; | 220 return frame; |
| 213 } | 221 } |
| 214 | 222 |
| 215 LocalFrameClient* FrameFetchContext::GetLocalFrameClient() const { | 223 LocalFrameClient* FrameFetchContext::GetLocalFrameClient() const { |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 argv.push_back(Resource::ResourceTypeToString(type, fetch_initiator_name)); | 502 argv.push_back(Resource::ResourceTypeToString(type, fetch_initiator_name)); |
| 495 argv.push_back(request.Url()); | 503 argv.push_back(request.Url()); |
| 496 activity_logger->LogEvent("blinkRequestResource", argv.size(), argv.data()); | 504 activity_logger->LogEvent("blinkRequestResource", argv.size(), argv.data()); |
| 497 } | 505 } |
| 498 } | 506 } |
| 499 | 507 |
| 500 void FrameFetchContext::DidLoadResource(Resource* resource) { | 508 void FrameFetchContext::DidLoadResource(Resource* resource) { |
| 501 if (!GetDocument()) | 509 if (!GetDocument()) |
| 502 return; | 510 return; |
| 503 FirstMeaningfulPaintDetector::From(*GetDocument()).CheckNetworkStable(); | 511 FirstMeaningfulPaintDetector::From(*GetDocument()).CheckNetworkStable(); |
| 512 network_quiet_detector_->CheckNetworkStable(); | |
|
zhenw
2017/06/07 17:32:56
I think the plan is to let FMPDetector also use th
lpy
2017/06/07 18:32:45
Discussed offline, updated the description to refl
| |
| 504 if (resource->IsLoadEventBlockingResourceType()) | 513 if (resource->IsLoadEventBlockingResourceType()) |
| 505 GetDocument()->CheckCompleted(); | 514 GetDocument()->CheckCompleted(); |
| 506 } | 515 } |
| 507 | 516 |
| 508 void FrameFetchContext::AddResourceTiming(const ResourceTimingInfo& info) { | 517 void FrameFetchContext::AddResourceTiming(const ResourceTimingInfo& info) { |
| 509 Document* initiator_document = GetDocument() && info.IsMainResource() | 518 Document* initiator_document = GetDocument() && info.IsMainResource() |
| 510 ? GetDocument()->ParentDocument() | 519 ? GetDocument()->ParentDocument() |
| 511 : GetDocument(); | 520 : GetDocument(); |
| 512 if (!initiator_document || !initiator_document->domWindow()) | 521 if (!initiator_document || !initiator_document->domWindow()) |
| 513 return; | 522 return; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 848 | 857 |
| 849 void FrameFetchContext::Detach() { | 858 void FrameFetchContext::Detach() { |
| 850 // This is needed to break a reference cycle in which off-heap | 859 // This is needed to break a reference cycle in which off-heap |
| 851 // ComputedStyle is involved. See https://crbug.com/383860 for details. | 860 // ComputedStyle is involved. See https://crbug.com/383860 for details. |
| 852 document_ = nullptr; | 861 document_ = nullptr; |
| 853 } | 862 } |
| 854 | 863 |
| 855 DEFINE_TRACE(FrameFetchContext) { | 864 DEFINE_TRACE(FrameFetchContext) { |
| 856 visitor->Trace(document_loader_); | 865 visitor->Trace(document_loader_); |
| 857 visitor->Trace(document_); | 866 visitor->Trace(document_); |
| 867 visitor->Trace(network_quiet_detector_); | |
| 858 BaseFetchContext::Trace(visitor); | 868 BaseFetchContext::Trace(visitor); |
| 859 } | 869 } |
| 860 | 870 |
| 861 } // namespace blink | 871 } // namespace blink |
| OLD | NEW |