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

Side by Side Diff: content/public/test/browser_test_utils.cc

Issue 889463003: GURL::Replacements methods accept a StringPiece instead of std::string&. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase (fixed some merge conflicts). Created 5 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/public/test/browser_test_utils.h" 5 #include "content/public/test/browser_test_utils.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/process/kill.h" 10 #include "base/process/kill.h"
11 #include "base/rand_util.h" 11 #include "base/rand_util.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_piece.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "base/synchronization/waitable_event.h" 15 #include "base/synchronization/waitable_event.h"
15 #include "base/test/test_timeouts.h" 16 #include "base/test/test_timeouts.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "content/browser/renderer_host/render_widget_host_impl.h" 18 #include "content/browser/renderer_host/render_widget_host_impl.h"
18 #include "content/browser/web_contents/web_contents_impl.h" 19 #include "content/browser/web_contents/web_contents_impl.h"
19 #include "content/browser/web_contents/web_contents_view.h" 20 #include "content/browser/web_contents/web_contents_view.h"
20 #include "content/common/input/synthetic_web_input_event_builders.h" 21 #include "content/common/input/synthetic_web_input_event_builders.h"
21 #include "content/public/browser/browser_context.h" 22 #include "content/public/browser/browser_context.h"
22 #include "content/public/browser/dom_operation_notification_details.h" 23 #include "content/public/browser/dom_operation_notification_details.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 234
234 std::string params = request.relative_url.substr(prefix.length()); 235 std::string params = request.relative_url.substr(prefix.length());
235 236
236 // A hostname to redirect to must be included in the URL, therefore at least 237 // A hostname to redirect to must be included in the URL, therefore at least
237 // one '/' character is expected. 238 // one '/' character is expected.
238 size_t slash = params.find('/'); 239 size_t slash = params.find('/');
239 if (slash == std::string::npos) 240 if (slash == std::string::npos)
240 return scoped_ptr<net::test_server::HttpResponse>(); 241 return scoped_ptr<net::test_server::HttpResponse>();
241 242
242 // Replace the host of the URL with the one passed in the URL. 243 // Replace the host of the URL with the one passed in the URL.
243 std::string host = params.substr(0, slash);
244 GURL::Replacements replace_host; 244 GURL::Replacements replace_host;
245 replace_host.SetHostStr(host); 245 replace_host.SetHostStr(base::StringPiece(params).substr(0, slash));
246 GURL redirect_server = server_base_url.ReplaceComponents(replace_host); 246 GURL redirect_server = server_base_url.ReplaceComponents(replace_host);
247 247
248 // Append the real part of the path to the new URL. 248 // Append the real part of the path to the new URL.
249 std::string path = params.substr(slash + 1); 249 std::string path = params.substr(slash + 1);
250 GURL redirect_target(redirect_server.Resolve(path)); 250 GURL redirect_target(redirect_server.Resolve(path));
251 DCHECK(redirect_target.is_valid()); 251 DCHECK(redirect_target.is_valid());
252 252
253 scoped_ptr<net::test_server::BasicHttpResponse> http_response( 253 scoped_ptr<net::test_server::BasicHttpResponse> http_response(
254 new net::test_server::BasicHttpResponse); 254 new net::test_server::BasicHttpResponse);
255 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); 255 http_response->set_code(net::HTTP_MOVED_PERMANENTLY);
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 939
940 bool WebContentsAddedObserver::RenderViewCreatedCalled() { 940 bool WebContentsAddedObserver::RenderViewCreatedCalled() {
941 if (child_observer_) { 941 if (child_observer_) {
942 return child_observer_->render_view_created_called_ && 942 return child_observer_->render_view_created_called_ &&
943 child_observer_->main_frame_created_called_; 943 child_observer_->main_frame_created_called_;
944 } 944 }
945 return false; 945 return false;
946 } 946 }
947 947
948 } // namespace content 948 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl_browsertest.cc ('k') | content/test/browser_test_utils_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698