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

Side by Side Diff: content/browser/transition_request_manager.cc

Issue 598323002: Use of base::StringPairs appropriately in content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 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 #include "content/browser/transition_request_manager.h" 5 #include "content/browser/transition_request_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
11 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
12 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
13 #include "net/http/http_response_headers.h" 14 #include "net/http/http_response_headers.h"
14 #include "net/http/http_util.h" 15 #include "net/http/http_util.h"
15 16
16 namespace { 17 namespace {
17 18
18 // Enumerate all Link: headers with the specified relation in this 19 // Enumerate all Link: headers with the specified relation in this
19 // response, and optionally returns the URL and any additional attributes of 20 // response, and optionally returns the URL and any additional attributes of
20 // each one. See EnumerateHeaders for |iter| usage. 21 // each one. See EnumerateHeaders for |iter| usage.
21 bool EnumerateLinkHeaders( 22 bool EnumerateLinkHeaders(
22 const scoped_refptr<net::HttpResponseHeaders>& headers, 23 const scoped_refptr<net::HttpResponseHeaders>& headers,
23 void** iter, 24 void** iter,
24 const std::string& rel, 25 const std::string& rel,
25 std::string* url, 26 std::string* url,
26 std::vector<std::pair<std::string, std::string> >* attributes) { 27 base::StringPairs* attributes) {
27 std::string header_body; 28 std::string header_body;
28 bool rel_matched = false; 29 bool rel_matched = false;
29 while (!rel_matched && headers->EnumerateHeader(iter, "link", &header_body)) { 30 while (!rel_matched && headers->EnumerateHeader(iter, "link", &header_body)) {
30 const std::string::const_iterator begin = header_body.begin(); 31 const std::string::const_iterator begin = header_body.begin();
31 size_t url_start = header_body.find_first_of('<'); 32 size_t url_start = header_body.find_first_of('<');
32 size_t url_end = header_body.find_first_of('>'); 33 size_t url_end = header_body.find_first_of('>');
33 if (url_start == std::string::npos || url_end == std::string::npos || 34 if (url_start == std::string::npos || url_end == std::string::npos ||
34 url_start > url_end) { 35 url_start > url_end) {
35 break; 36 break;
36 } 37 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 83 }
83 84
84 void TransitionRequestManager::ParseTransitionStylesheetsFromHeaders( 85 void TransitionRequestManager::ParseTransitionStylesheetsFromHeaders(
85 const scoped_refptr<net::HttpResponseHeaders>& headers, 86 const scoped_refptr<net::HttpResponseHeaders>& headers,
86 std::vector<GURL>& entering_stylesheets, 87 std::vector<GURL>& entering_stylesheets,
87 const GURL& resolve_address) { 88 const GURL& resolve_address) {
88 if (headers.get() == NULL) 89 if (headers.get() == NULL)
89 return; 90 return;
90 91
91 std::string transition_stylesheet; 92 std::string transition_stylesheet;
92 std::vector<std::pair<std::string, std::string> > attributes; 93 base::StringPairs attributes;
94 //std::vector<std::pair<std::string, std::string> > attributes;
Avi (use Gerrit) 2014/09/25 04:59:15 Do not commit commented-out lines.
MRV 2014/09/25 05:15:28 Done.
93 void* header_iter = NULL; 95 void* header_iter = NULL;
94 while (EnumerateLinkHeaders(headers, 96 while (EnumerateLinkHeaders(headers,
95 &header_iter, 97 &header_iter,
96 "transition-entering-stylesheet", 98 "transition-entering-stylesheet",
97 &transition_stylesheet, 99 &transition_stylesheet,
98 &attributes)) { 100 &attributes)) {
99 GURL stylesheet_url = resolve_address.Resolve(transition_stylesheet); 101 GURL stylesheet_url = resolve_address.Resolve(transition_stylesheet);
100 if (stylesheet_url.is_valid()) 102 if (stylesheet_url.is_valid())
101 entering_stylesheets.push_back(stylesheet_url); 103 entering_stylesheets.push_back(stylesheet_url);
102 } 104 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 177
176 TransitionRequestManager::~TransitionRequestManager() { 178 TransitionRequestManager::~TransitionRequestManager() {
177 } 179 }
178 180
179 // static 181 // static
180 TransitionRequestManager* TransitionRequestManager::GetInstance() { 182 TransitionRequestManager* TransitionRequestManager::GetInstance() {
181 return Singleton<TransitionRequestManager>::get(); 183 return Singleton<TransitionRequestManager>::get();
182 } 184 }
183 185
184 } // namespace content 186 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698