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

Side by Side Diff: Source/core/loader/FrameFetchContext.cpp

Issue 1078633003: Added preloader support for sizes based RW values (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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 | « Source/core/html/parser/HTMLResourcePreloader.cpp ('k') | no next file » | 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) 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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 } 659 }
660 660
661 void FrameFetchContext::addClientHintsIfNecessary(FetchRequest& fetchRequest) 661 void FrameFetchContext::addClientHintsIfNecessary(FetchRequest& fetchRequest)
662 { 662 {
663 if (!frame() || !RuntimeEnabledFeatures::clientHintsEnabled() || !m_document ) 663 if (!frame() || !RuntimeEnabledFeatures::clientHintsEnabled() || !m_document )
664 return; 664 return;
665 665
666 if (frame()->shouldSendDPRHint()) 666 if (frame()->shouldSendDPRHint())
667 fetchRequest.mutableResourceRequest().addHTTPHeaderField("DPR", AtomicSt ring(String::number(m_document->devicePixelRatio()))); 667 fetchRequest.mutableResourceRequest().addHTTPHeaderField("DPR", AtomicSt ring(String::number(m_document->devicePixelRatio())));
668 668
669 // FIXME: Send the RW hint based on the actual resource width, when we have it. 669 if (frame()->shouldSendRWHint() && frame()->view()) {
670 if (frame()->shouldSendRWHint() && frame()->view()) 670 int resourceWidth = fetchRequest.resourceWidth();
671 fetchRequest.mutableResourceRequest().addHTTPHeaderField("RW", AtomicStr ing(String::number(frame()->view()->viewportWidth()))); 671 if (resourceWidth < 0)
Mike West 2015/04/09 11:42:48 Can resourceWidth reasonably be 0? It would be nic
672 resourceWidth = frame()->view()->viewportWidth();
673 fetchRequest.mutableResourceRequest().addHTTPHeaderField("RW", AtomicStr ing(String::number(resourceWidth)));
674 }
672 } 675 }
673 676
674 void FrameFetchContext::addCSPHeaderIfNecessary(Resource::Type type, FetchReques t& fetchRequest) 677 void FrameFetchContext::addCSPHeaderIfNecessary(Resource::Type type, FetchReques t& fetchRequest)
675 { 678 {
676 if (!document() || !frame()) 679 if (!document() || !frame())
677 return; 680 return;
678 681
679 const ContentSecurityPolicy* csp = document()->contentSecurityPolicy(); 682 const ContentSecurityPolicy* csp = document()->contentSecurityPolicy();
680 if (csp->shouldSendCSPHeader(type)) 683 if (csp->shouldSendCSPHeader(type))
681 fetchRequest.mutableResourceRequest().addHTTPHeaderField("CSP", "active" ); 684 fetchRequest.mutableResourceRequest().addHTTPHeaderField("CSP", "active" );
682 } 685 }
683 686
684 DEFINE_TRACE(FrameFetchContext) 687 DEFINE_TRACE(FrameFetchContext)
685 { 688 {
686 visitor->trace(m_document); 689 visitor->trace(m_document);
687 FetchContext::trace(visitor); 690 FetchContext::trace(visitor);
688 } 691 }
689 692
690 } // namespace blink 693 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/parser/HTMLResourcePreloader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698