OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef URL_GURL_H_ | 5 #ifndef URL_GURL_H_ |
6 #define URL_GURL_H_ | 6 #define URL_GURL_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <iosfwd> | 10 #include <iosfwd> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 typedef url::StringPieceReplacements<base::string16> ReplacementsW; | 49 typedef url::StringPieceReplacements<base::string16> ReplacementsW; |
50 | 50 |
51 // Creates an empty, invalid URL. | 51 // Creates an empty, invalid URL. |
52 GURL(); | 52 GURL(); |
53 | 53 |
54 // Copy construction is relatively inexpensive, with most of the time going | 54 // Copy construction is relatively inexpensive, with most of the time going |
55 // to reallocating the string. It does not re-parse. | 55 // to reallocating the string. It does not re-parse. |
56 GURL(const GURL& other); | 56 GURL(const GURL& other); |
57 | 57 |
58 // The strings to this contructor should be UTF-8 / UTF-16. | 58 // The strings to this contructor should be UTF-8 / UTF-16. |
59 explicit GURL(const std::string& url_string); | 59 explicit GURL(base::StringPiece url_string); |
60 explicit GURL(const base::string16& url_string); | 60 explicit GURL(base::StringPiece16 url_string); |
61 | 61 |
62 // Constructor for URLs that have already been parsed and canonicalized. This | 62 // Constructor for URLs that have already been parsed and canonicalized. This |
63 // is used for conversions from KURL, for example. The caller must supply all | 63 // is used for conversions from KURL, for example. The caller must supply all |
64 // information associated with the URL, which must be correct and consistent. | 64 // information associated with the URL, which must be correct and consistent. |
65 GURL(const char* canonical_spec, | 65 GURL(const char* canonical_spec, |
66 size_t canonical_spec_len, | 66 size_t canonical_spec_len, |
67 const url::Parsed& parsed, | 67 const url::Parsed& parsed, |
68 bool is_valid); | 68 bool is_valid); |
69 // Notice that we take the canonical_spec by value so that we can convert | 69 // Notice that we take the canonical_spec by value so that we can convert |
70 // from WebURL without copying the string. When we call this constructor | 70 // from WebURL without copying the string. When we call this constructor |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 private: | 398 private: |
399 // Variant of the string parsing constructor that allows the caller to elect | 399 // Variant of the string parsing constructor that allows the caller to elect |
400 // retain trailing whitespace, if any, on the passed URL spec, but only if | 400 // retain trailing whitespace, if any, on the passed URL spec, but only if |
401 // the scheme is one that allows trailing whitespace. The primary use-case is | 401 // the scheme is one that allows trailing whitespace. The primary use-case is |
402 // for data: URLs. In most cases, you want to use the single parameter | 402 // for data: URLs. In most cases, you want to use the single parameter |
403 // constructor above. | 403 // constructor above. |
404 enum RetainWhiteSpaceSelector { RETAIN_TRAILING_PATH_WHITEPACE }; | 404 enum RetainWhiteSpaceSelector { RETAIN_TRAILING_PATH_WHITEPACE }; |
405 GURL(const std::string& url_string, RetainWhiteSpaceSelector); | 405 GURL(const std::string& url_string, RetainWhiteSpaceSelector); |
406 | 406 |
407 template<typename STR> | 407 template<typename STR> |
408 void InitCanonical(const STR& input_spec, bool trim_path_end); | 408 void InitCanonical(base::BasicStringPiece<STR> input_spec, |
| 409 bool trim_path_end); |
409 | 410 |
410 void InitializeFromCanonicalSpec(); | 411 void InitializeFromCanonicalSpec(); |
411 | 412 |
412 // Returns the substring of the input identified by the given component. | 413 // Returns the substring of the input identified by the given component. |
413 std::string ComponentString(const url::Component& comp) const { | 414 std::string ComponentString(const url::Component& comp) const { |
414 if (comp.len <= 0) | 415 if (comp.len <= 0) |
415 return std::string(); | 416 return std::string(); |
416 return std::string(spec_, comp.begin, comp.len); | 417 return std::string(spec_, comp.begin, comp.len); |
417 } | 418 } |
418 base::StringPiece ComponentStringPiece(const url::Component& comp) const { | 419 base::StringPiece ComponentStringPiece(const url::Component& comp) const { |
(...skipping 14 matching lines...) Expand all Loading... |
433 url::Parsed parsed_; | 434 url::Parsed parsed_; |
434 | 435 |
435 // Used for nested schemes [currently only filesystem:]. | 436 // Used for nested schemes [currently only filesystem:]. |
436 scoped_ptr<GURL> inner_url_; | 437 scoped_ptr<GURL> inner_url_; |
437 }; | 438 }; |
438 | 439 |
439 // Stream operator so GURL can be used in assertion statements. | 440 // Stream operator so GURL can be used in assertion statements. |
440 URL_EXPORT std::ostream& operator<<(std::ostream& out, const GURL& url); | 441 URL_EXPORT std::ostream& operator<<(std::ostream& out, const GURL& url); |
441 | 442 |
442 #endif // URL_GURL_H_ | 443 #endif // URL_GURL_H_ |
OLD | NEW |