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

Side by Side Diff: chrome/browser/prerender/prerender_manager.cc

Issue 2355453002: [NoStatePrefetch] Support only GET and HEAD (Closed)
Patch Set: review comments Created 4 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/prerender/prerender_manager.h" 5 #include "chrome/browser/prerender/prerender_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <functional> 10 #include <functional>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 using content::WebContents; 68 using content::WebContents;
69 using namespace chrome_browser_net; 69 using namespace chrome_browser_net;
70 70
71 namespace prerender { 71 namespace prerender {
72 72
73 namespace { 73 namespace {
74 74
75 // Time interval at which periodic cleanups are performed. 75 // Time interval at which periodic cleanups are performed.
76 const int kPeriodicCleanupIntervalMs = 1000; 76 const int kPeriodicCleanupIntervalMs = 1000;
77 77
78 // Valid HTTP methods for prerendering.
79 const char* const kValidHttpMethods[] = {
80 "GET",
81 "HEAD",
82 "OPTIONS",
83 "POST",
84 "TRACE",
85 };
86
87 // Length of prerender history, for display in chrome://net-internals 78 // Length of prerender history, for display in chrome://net-internals
88 const int kHistoryLength = 100; 79 const int kHistoryLength = 100;
89 80
90 } // namespace 81 } // namespace
91 82
92 class PrerenderManager::OnCloseWebContentsDeleter 83 class PrerenderManager::OnCloseWebContentsDeleter
93 : public content::WebContentsDelegate, 84 : public content::WebContentsDelegate,
94 public base::SupportsWeakPtr< 85 public base::SupportsWeakPtr<
95 PrerenderManager::OnCloseWebContentsDeleter> { 86 PrerenderManager::OnCloseWebContentsDeleter> {
96 public: 87 public:
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 base::TimeDelta delta = GetCurrentTimeTicks() - it->time; 718 base::TimeDelta delta = GetCurrentTimeTicks() - it->time;
728 histograms_->RecordTimeSinceLastRecentVisit(origin, delta); 719 histograms_->RecordTimeSinceLastRecentVisit(origin, delta);
729 return true; 720 return true;
730 } 721 }
731 } 722 }
732 723
733 return false; 724 return false;
734 } 725 }
735 726
736 // static 727 // static
737 bool PrerenderManager::IsValidHttpMethod(const std::string& method) {
738 // method has been canonicalized to upper case at this point so we can just
739 // compare them.
740 DCHECK_EQ(method, base::ToUpperASCII(method));
741 for (size_t i = 0; i < arraysize(kValidHttpMethods); ++i) {
742 if (method.compare(kValidHttpMethods[i]) == 0)
743 return true;
744 }
745
746 return false;
747 }
748
749 // static
750 bool PrerenderManager::DoesURLHaveValidScheme(const GURL& url) { 728 bool PrerenderManager::DoesURLHaveValidScheme(const GURL& url) {
751 return (url.SchemeIsHTTPOrHTTPS() || 729 return (url.SchemeIsHTTPOrHTTPS() ||
752 url.SchemeIs(extensions::kExtensionScheme) || 730 url.SchemeIs(extensions::kExtensionScheme) ||
753 url.SchemeIs("data")); 731 url.SchemeIs("data"));
754 } 732 }
755 733
756 // static 734 // static
757 bool PrerenderManager::DoesSubresourceURLHaveValidScheme(const GURL& url) { 735 bool PrerenderManager::DoesSubresourceURLHaveValidScheme(const GURL& url) {
758 return DoesURLHaveValidScheme(url) || url == GURL(url::kAboutBlankURL); 736 return DoesURLHaveValidScheme(url) || url == GURL(url::kAboutBlankURL);
759 } 737 }
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 DCHECK_EQ(1u, erased); 1343 DCHECK_EQ(1u, erased);
1366 } 1344 }
1367 1345
1368 void PrerenderManager::SetPrerenderContentsFactoryForTest( 1346 void PrerenderManager::SetPrerenderContentsFactoryForTest(
1369 PrerenderContents::Factory* prerender_contents_factory) { 1347 PrerenderContents::Factory* prerender_contents_factory) {
1370 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1348 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1371 prerender_contents_factory_.reset(prerender_contents_factory); 1349 prerender_contents_factory_.reset(prerender_contents_factory);
1372 } 1350 }
1373 1351
1374 } // namespace prerender 1352 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_manager.h ('k') | chrome/browser/prerender/prerender_resource_throttle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698