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

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: Created 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | url/gurl.cc » ('j') | url/gurl.cc » ('J')
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 <iosfwd> 8 #include <iosfwd>
9 #include <string> 9 #include <string>
10 10
(...skipping 28 matching lines...) Expand all
39 explicit GURL(const std::string& url_string /*, output_param_encoding*/); 39 explicit GURL(const std::string& url_string /*, output_param_encoding*/);
40 explicit GURL(const base::string16& url_string /*, output_param_encoding*/); 40 explicit GURL(const base::string16& url_string /*, output_param_encoding*/);
41 41
42 // Constructor for URLs that have already been parsed and canonicalized. This 42 // Constructor for URLs that have already been parsed and canonicalized. This
43 // is used for conversions from KURL, for example. The caller must supply all 43 // is used for conversions from KURL, for example. The caller must supply all
44 // information associated with the URL, which must be correct and consistent. 44 // information associated with the URL, which must be correct and consistent.
45 GURL(const char* canonical_spec, 45 GURL(const char* canonical_spec,
46 size_t canonical_spec_len, 46 size_t canonical_spec_len,
47 const url::Parsed& parsed, 47 const url::Parsed& parsed,
48 bool is_valid); 48 bool is_valid);
49 // Notice that we take the canonical_spec by value so that we can convert 49
50 // from WebURL without copying the string. When we call this constructor 50 // Notice that we can take the canonical_spec by rvalue reference so that we
51 // we pass in a temporary std::string, which lets the compiler skip the 51 // can convert from WebURL without copying the string. When we call this
ki.stfu 2015/09/21 05:55:55 (the original message is here: https://codereview.
52 // copy and just move the std::string into the function argument. In the 52 // constructor we pass in a temporary std::string, which lets the compiler
53 // implementation, we use swap to move the data into the GURL itself, 53 // skip the copy and just move the std::string into the function argument.
54 // which means we end up with zero copies. 54 // The const reference version is used in unittests.
55 GURL(std::string canonical_spec, const url::Parsed& parsed, bool is_valid); 55 GURL(const std::string& canonical_spec,
56 const url::Parsed& parsed,
57 bool is_valid);
58 GURL(std::string&& canonical_spec, const url::Parsed& parsed,
danakj 2016/04/29 02:17:54 According to the google style guide the way to wri
ki.stfu 2016/05/25 16:53:33 I can't find a mention about this way in style gui
danakj 2016/05/25 19:59:37 https://google.github.io/styleguide/cppguide.html#
ki.stfu 2016/05/26 05:15:30 Doesn't it look like a moving "for perfect forward
59 bool is_valid) noexcept;
56 60
57 ~GURL(); 61 ~GURL();
58 62
59 GURL& operator=(GURL other); 63 GURL& operator=(GURL other);
60 64
61 // Returns true when this object represents a valid parsed URL. When not 65 // Returns true when this object represents a valid parsed URL. When not
62 // valid, other functions will still succeed, but you will not get canonical 66 // valid, other functions will still succeed, but you will not get canonical
63 // data out in the format you may be expecting. Instead, we keep something 67 // data out in the format you may be expecting. Instead, we keep something
64 // "reasonable looking" so that the user can see how it's busted if 68 // "reasonable looking" so that the user can see how it's busted if
65 // displayed to them. 69 // displayed to them.
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 // Used for nested schemes [currently only filesystem:]. 383 // Used for nested schemes [currently only filesystem:].
380 scoped_ptr<GURL> inner_url_; 384 scoped_ptr<GURL> inner_url_;
381 385
382 // TODO bug 684583: Add encoding for query params. 386 // TODO bug 684583: Add encoding for query params.
383 }; 387 };
384 388
385 // Stream operator so GURL can be used in assertion statements. 389 // Stream operator so GURL can be used in assertion statements.
386 URL_EXPORT std::ostream& operator<<(std::ostream& out, const GURL& url); 390 URL_EXPORT std::ostream& operator<<(std::ostream& out, const GURL& url);
387 391
388 #endif // URL_GURL_H_ 392 #endif // URL_GURL_H_
OLDNEW
« no previous file with comments | « no previous file | url/gurl.cc » ('j') | url/gurl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698