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

Side by Side Diff: net/test/embedded_test_server/embedded_test_server.cc

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 "net/test/embedded_test_server/embedded_test_server.h" 5 #include "net/test/embedded_test_server/embedded_test_server.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 delete connection; 252 delete connection;
253 } 253 }
254 254
255 GURL EmbeddedTestServer::GetURL(const std::string& relative_url) const { 255 GURL EmbeddedTestServer::GetURL(const std::string& relative_url) const {
256 DCHECK(Started()) << "You must start the server first."; 256 DCHECK(Started()) << "You must start the server first.";
257 DCHECK(StartsWithASCII(relative_url, "/", true /* case_sensitive */)) 257 DCHECK(StartsWithASCII(relative_url, "/", true /* case_sensitive */))
258 << relative_url; 258 << relative_url;
259 return base_url_.Resolve(relative_url); 259 return base_url_.Resolve(relative_url);
260 } 260 }
261 261
262 GURL EmbeddedTestServer::GetURL(
263 const std::string& hostname,
264 const std::string& relative_url) const {
265 GURL local_url = GetURL(relative_url);
266 GURL::Replacements replace_host;
267 replace_host.SetHostStr(hostname);
268 return local_url.ReplaceComponents(replace_host);
269 }
270
262 void EmbeddedTestServer::ServeFilesFromDirectory( 271 void EmbeddedTestServer::ServeFilesFromDirectory(
263 const base::FilePath& directory) { 272 const base::FilePath& directory) {
264 RegisterRequestHandler(base::Bind(&HandleFileRequest, directory)); 273 RegisterRequestHandler(base::Bind(&HandleFileRequest, directory));
265 } 274 }
266 275
267 void EmbeddedTestServer::RegisterRequestHandler( 276 void EmbeddedTestServer::RegisterRequestHandler(
268 const HandleRequestCallback& callback) { 277 const HandleRequestCallback& callback) {
269 request_handlers_.push_back(callback); 278 request_handlers_.push_back(callback);
270 } 279 }
271 280
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 FROM_HERE, closure, run_loop.QuitClosure())) { 347 FROM_HERE, closure, run_loop.QuitClosure())) {
339 return false; 348 return false;
340 } 349 }
341 run_loop.Run(); 350 run_loop.Run();
342 351
343 return true; 352 return true;
344 } 353 }
345 354
346 } // namespace test_server 355 } // namespace test_server
347 } // namespace net 356 } // namespace net
OLDNEW
« no previous file with comments | « net/test/embedded_test_server/embedded_test_server.h ('k') | net/test/embedded_test_server/embedded_test_server_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698