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

Unified Diff: net/base/net_util.h

Issue 23619016: Switch the offset conversion routines from... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: net/base/net_util.h
===================================================================
--- net/base/net_util.h (revision 221015)
+++ net/base/net_util.h (working copy)
@@ -370,18 +370,28 @@
// UTF-8, decodes %-encoding and UTF-8.
//
// The last three parameters may be NULL.
+//
// |new_parsed| will be set to the parsing parameters of the resultant URL.
+//
// |prefix_end| will be the length before the hostname of the resultant URL.
//
-// (|offset[s]_for_adjustment|) specifies one or more offsets into the original
-// |url|'s spec(); each offset will be modified to reflect changes this function
-// makes to the output string. For example, if |url| is "http://a:b@c.com/",
-// |omit_username_password| is true, and an offset is 12 (the offset of '.'),
-// then on return the output string will be "http://c.com/" and the offset will
-// be 8. If an offset cannot be successfully adjusted (e.g. because it points
-// into the middle of a component that was entirely removed, past the end of the
-// string, or into the middle of an encoding sequence), it will be set to
-// base::string16::npos.
+// |offset[s]_for_adjustment| specifies one or more offsets into the original
+// URL, representing insertion or selection points between characters: if the
+// input is "http://foo.com/", offset 0 is before the entire URL, offset 7 is
+// between the scheme and the host, and offset 15 is after the end of the URL.
+// Valid input offsets range from 0 to the length of the input URL string. On
+// exit, each offset will have been modified to reflect any changes made to the
+// output string. For example, if |url| is "http://a:b@c.com/",
+// |omit_username_password| is true, and an offset is 12 (pointing between 'c'
+// and '.'), then on return the output string will be "http://c.com/" and the
+// offset will be 8. If an offset cannot be successfully adjusted (e.g. because
+// it points into the middle of a component that was entirely removed or into
+// the middle of an encoding sequence), it will be set to base::string16::npos.
+// For consistency, if an input offset points between the scheme and the
+// username/password, and both are removed, on output this offset will be 0
+// rather than npos; this means that offsets at the starts and ends of removed
+// components are always transformed the same way regardless of what other
+// components are adjacent.
NET_EXPORT base::string16 FormatUrl(const GURL& url,
const std::string& languages,
FormatUrlTypes format_types,
« no previous file with comments | « net/base/escape_unittest.cc ('k') | net/base/net_util.cc » ('j') | net/base/net_util_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698