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

Side by Side Diff: url/gurl.h

Issue 1360533002: Cleanup: Initialize GURL by moving std::string (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass by value and then move it Created 4 years, 6 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
« no previous file with comments | « no previous file | url/gurl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
71 // we pass in a temporary std::string, which lets the compiler skip the 71 // we pass in a temporary std::string, which lets the compiler skip the
72 // copy and just move the std::string into the function argument. In the 72 // copy and just move the std::string into the function argument. In the
73 // implementation, we use swap to move the data into the GURL itself, 73 // implementation, we use std::move to move the data into the GURL itself,
74 // which means we end up with zero copies. 74 // which means we end up with zero copies.
75 GURL(std::string canonical_spec, const url::Parsed& parsed, bool is_valid); 75 GURL(std::string canonical_spec, const url::Parsed& parsed, bool is_valid);
76 76
77 ~GURL(); 77 ~GURL();
78 78
79 GURL& operator=(GURL other); 79 GURL& operator=(GURL other);
80 80
81 // Returns true when this object represents a valid parsed URL. When not 81 // Returns true when this object represents a valid parsed URL. When not
82 // valid, other functions will still succeed, but you will not get canonical 82 // valid, other functions will still succeed, but you will not get canonical
83 // data out in the format you may be expecting. Instead, we keep something 83 // data out in the format you may be expecting. Instead, we keep something
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 url::Parsed parsed_; 437 url::Parsed parsed_;
438 438
439 // Used for nested schemes [currently only filesystem:]. 439 // Used for nested schemes [currently only filesystem:].
440 std::unique_ptr<GURL> inner_url_; 440 std::unique_ptr<GURL> inner_url_;
441 }; 441 };
442 442
443 // Stream operator so GURL can be used in assertion statements. 443 // Stream operator so GURL can be used in assertion statements.
444 URL_EXPORT std::ostream& operator<<(std::ostream& out, const GURL& url); 444 URL_EXPORT std::ostream& operator<<(std::ostream& out, const GURL& url);
445 445
446 #endif // URL_GURL_H_ 446 #endif // URL_GURL_H_
OLDNEW
« no previous file with comments | « no previous file | url/gurl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698