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

Unified Diff: url/gurl.cc

Issue 20127002: Allow efficient WebURL -> GURL conversions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Elaborate comment Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « url/gurl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: url/gurl.cc
diff --git a/url/gurl.cc b/url/gurl.cc
index 3dd8463c658b243ccef5d5ddabeb51215f1e1197..09b8abbcc23933c884e1fe62a2fea9fac54c2386 100644
--- a/url/gurl.cc
+++ b/url/gurl.cc
@@ -116,6 +116,19 @@ GURL::GURL(const char* canonical_spec, size_t canonical_spec_len,
is_valid_(is_valid),
parsed_(parsed),
inner_url_(NULL) {
+ InitializeFromCanonicalSpec();
+}
+
+GURL::GURL(std::string canonical_spec,
+ const url_parse::Parsed& parsed, bool is_valid)
+ : is_valid_(is_valid),
+ parsed_(parsed),
+ inner_url_(NULL) {
+ spec_.swap(canonical_spec);
+ InitializeFromCanonicalSpec();
+}
+
+void GURL::InitializeFromCanonicalSpec() {
if (is_valid_ && SchemeIsFileSystem()) {
inner_url_ =
new GURL(spec_.data(), parsed_.Length(), *parsed_.inner_parsed(), true);
@@ -127,9 +140,9 @@ GURL::GURL(const char* canonical_spec, size_t canonical_spec_len,
// and we can't always canonicalize then reproducabely.
if (is_valid_) {
url_parse::Component scheme;
- if (!url_util::FindAndCompareScheme(canonical_spec, canonical_spec_len,
+ if (!url_util::FindAndCompareScheme(spec_.data(), spec_.length(),
"filesystem", &scheme) ||
- scheme.begin == parsed.scheme.begin) {
+ scheme.begin == parsed_.scheme.begin) {
// We can't do this check on the inner_url of a filesystem URL, as
// canonical_spec actually points to the start of the outer URL, so we'd
// end up with infinite recursion in this constructor.
« no previous file with comments | « url/gurl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698