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

Side by Side Diff: mojo/fetcher/network_fetcher.cc

Issue 1568073002: Reduce string copies in GURL creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac Created 4 years, 11 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "mojo/fetcher/network_fetcher.h" 5 #include "mojo/fetcher/network_fetcher.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 return url_; 51 return url_;
52 } 52 }
53 53
54 GURL NetworkFetcher::GetRedirectURL() const { 54 GURL NetworkFetcher::GetRedirectURL() const {
55 if (!response_) 55 if (!response_)
56 return GURL::EmptyGURL(); 56 return GURL::EmptyGURL();
57 57
58 if (response_->redirect_url.is_null()) 58 if (response_->redirect_url.is_null())
59 return GURL::EmptyGURL(); 59 return GURL::EmptyGURL();
60 60
61 return GURL(response_->redirect_url); 61 return GURL(response_->redirect_url.get());
62 } 62 }
63 63
64 GURL NetworkFetcher::GetRedirectReferer() const { 64 GURL NetworkFetcher::GetRedirectReferer() const {
65 if (!response_) 65 if (!response_)
66 return GURL::EmptyGURL(); 66 return GURL::EmptyGURL();
67 67
68 if (response_->redirect_referrer.is_null()) 68 if (response_->redirect_referrer.is_null())
69 return GURL::EmptyGURL(); 69 return GURL::EmptyGURL();
70 70
71 return GURL(response_->redirect_referrer); 71 return GURL(response_->redirect_referrer.get());
72 } 72 }
73 URLResponsePtr NetworkFetcher::AsURLResponse(base::TaskRunner* task_runner, 73 URLResponsePtr NetworkFetcher::AsURLResponse(base::TaskRunner* task_runner,
74 uint32_t skip) { 74 uint32_t skip) {
75 if (skip != 0) { 75 if (skip != 0) {
76 MojoResult result = ReadDataRaw( 76 MojoResult result = ReadDataRaw(
77 response_->body.get(), nullptr, &skip, 77 response_->body.get(), nullptr, &skip,
78 MOJO_READ_DATA_FLAG_ALL_OR_NONE | MOJO_READ_DATA_FLAG_DISCARD); 78 MOJO_READ_DATA_FLAG_ALL_OR_NONE | MOJO_READ_DATA_FLAG_DISCARD);
79 DCHECK_EQ(result, MOJO_RESULT_OK); 79 DCHECK_EQ(result, MOJO_RESULT_OK);
80 } 80 }
81 return std::move(response_); 81 return std::move(response_);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 loader_callback_.Run(nullptr); 245 loader_callback_.Run(nullptr);
246 return; 246 return;
247 } 247 }
248 248
249 response_ = std::move(response); 249 response_ = std::move(response);
250 loader_callback_.Run(std::move(owner)); 250 loader_callback_.Run(std::move(owner));
251 } 251 }
252 252
253 } // namespace fetcher 253 } // namespace fetcher
254 } // namespace mojo 254 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698