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

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

Issue 25238003: Will now DCHECK that test writers start the embedded server before using it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing tests which did not init embedded test server Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/lazy_background_page_apitest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 not_found_response.PassAs<HttpResponse>()); 189 not_found_response.PassAs<HttpResponse>());
190 } 190 }
191 191
192 // Drop the connection, since we do not support multiple requests per 192 // Drop the connection, since we do not support multiple requests per
193 // connection. 193 // connection.
194 connections_.erase(connection->socket_.get()); 194 connections_.erase(connection->socket_.get());
195 delete connection; 195 delete connection;
196 } 196 }
197 197
198 GURL EmbeddedTestServer::GetURL(const std::string& relative_url) const { 198 GURL EmbeddedTestServer::GetURL(const std::string& relative_url) const {
199 DCHECK(Started()) << "You must start the server first.";
199 DCHECK(StartsWithASCII(relative_url, "/", true /* case_sensitive */)) 200 DCHECK(StartsWithASCII(relative_url, "/", true /* case_sensitive */))
200 << relative_url; 201 << relative_url;
201 return base_url_.Resolve(relative_url); 202 return base_url_.Resolve(relative_url);
202 } 203 }
203 204
204 void EmbeddedTestServer::ServeFilesFromDirectory( 205 void EmbeddedTestServer::ServeFilesFromDirectory(
205 const base::FilePath& directory) { 206 const base::FilePath& directory) {
206 RegisterRequestHandler(base::Bind(&HandleFileRequest, directory)); 207 RegisterRequestHandler(base::Bind(&HandleFileRequest, directory));
207 } 208 }
208 209
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 base::RunLoop run_loop; 279 base::RunLoop run_loop;
279 if (!io_thread_->PostTaskAndReply(FROM_HERE, closure, run_loop.QuitClosure())) 280 if (!io_thread_->PostTaskAndReply(FROM_HERE, closure, run_loop.QuitClosure()))
280 return false; 281 return false;
281 run_loop.Run(); 282 run_loop.Run();
282 283
283 return true; 284 return true;
284 } 285 }
285 286
286 } // namespace test_server 287 } // namespace test_server
287 } // namespace net 288 } // namespace net
OLDNEW
« no previous file with comments | « chrome/browser/extensions/lazy_background_page_apitest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698