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

Side by Side Diff: net/url_request/url_request_unittest.h

Issue 368001: Second patch in making destructors of refcounted objects private. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ 5 #ifndef NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_
6 #define NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ 6 #define NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_
7 7
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include <sstream> 10 #include <sstream>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 host_resolver_ = net::CreateSystemHostResolver(); 56 host_resolver_ = net::CreateSystemHostResolver();
57 net::ProxyConfig proxy_config; 57 net::ProxyConfig proxy_config;
58 proxy_config.proxy_rules.ParseFromString(proxy); 58 proxy_config.proxy_rules.ParseFromString(proxy);
59 proxy_service_ = net::ProxyService::CreateFixed(proxy_config); 59 proxy_service_ = net::ProxyService::CreateFixed(proxy_config);
60 ssl_config_service_ = new net::SSLConfigServiceDefaults; 60 ssl_config_service_ = new net::SSLConfigServiceDefaults;
61 http_transaction_factory_ = 61 http_transaction_factory_ =
62 net::HttpNetworkLayer::CreateFactory(host_resolver_, 62 net::HttpNetworkLayer::CreateFactory(host_resolver_,
63 proxy_service_, ssl_config_service_); 63 proxy_service_, ssl_config_service_);
64 } 64 }
65 65
66 virtual ~TestURLRequestContext() { 66 protected:
67 ~TestURLRequestContext() {
67 delete http_transaction_factory_; 68 delete http_transaction_factory_;
68 } 69 }
69 }; 70 };
70 71
71 class TestDelegate : public URLRequest::Delegate { 72 class TestDelegate : public URLRequest::Delegate {
72 public: 73 public:
73 TestDelegate() 74 TestDelegate()
74 : cancel_in_rr_(false), 75 : cancel_in_rr_(false),
75 cancel_in_rs_(false), 76 cancel_in_rs_(false),
76 cancel_in_rd_(false), 77 cancel_in_rd_(false),
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 238
238 // This object bounds the lifetime of an external python-based HTTP/FTP server 239 // This object bounds the lifetime of an external python-based HTTP/FTP server
239 // that can provide various responses useful for testing. 240 // that can provide various responses useful for testing.
240 class BaseTestServer : public base::RefCounted<BaseTestServer> { 241 class BaseTestServer : public base::RefCounted<BaseTestServer> {
241 protected: 242 protected:
242 BaseTestServer() { } 243 BaseTestServer() { }
243 BaseTestServer(int connection_attempts, int connection_timeout) 244 BaseTestServer(int connection_attempts, int connection_timeout)
244 : launcher_(connection_attempts, connection_timeout) { } 245 : launcher_(connection_attempts, connection_timeout) { }
245 246
246 public: 247 public:
247 virtual ~BaseTestServer() { }
248
249 void set_forking(bool forking) { 248 void set_forking(bool forking) {
250 launcher_.set_forking(forking); 249 launcher_.set_forking(forking);
251 } 250 }
252 251
253 // Used with e.g. HTTPTestServer::SendQuit() 252 // Used with e.g. HTTPTestServer::SendQuit()
254 bool WaitToFinish(int milliseconds) { 253 bool WaitToFinish(int milliseconds) {
255 return launcher_.WaitToFinish(milliseconds); 254 return launcher_.WaitToFinish(milliseconds);
256 } 255 }
257 256
258 bool Stop() { 257 bool Stop() {
(...skipping 29 matching lines...) Expand all
288 return TestServerPage(WideToUTF8(path)); 287 return TestServerPage(WideToUTF8(path));
289 } 288 }
290 289
291 virtual bool MakeGETRequest(const std::string& page_name) = 0; 290 virtual bool MakeGETRequest(const std::string& page_name) = 0;
292 291
293 FilePath GetDataDirectory() { 292 FilePath GetDataDirectory() {
294 return launcher_.GetDocumentRootPath(); 293 return launcher_.GetDocumentRootPath();
295 } 294 }
296 295
297 protected: 296 protected:
297 friend class base::RefCounted<BaseTestServer>;
298 virtual ~BaseTestServer() { }
299
298 bool Start(net::TestServerLauncher::Protocol protocol, 300 bool Start(net::TestServerLauncher::Protocol protocol,
299 const std::string& host_name, int port, 301 const std::string& host_name, int port,
300 const FilePath& document_root, 302 const FilePath& document_root,
301 const FilePath& cert_path, 303 const FilePath& cert_path,
302 const std::wstring& file_root_url) { 304 const std::wstring& file_root_url) {
303 if (!launcher_.Start(protocol, 305 if (!launcher_.Start(protocol,
304 host_name, port, document_root, cert_path, file_root_url)) 306 host_name, port, document_root, cert_path, file_root_url))
305 return false; 307 return false;
306 308
307 if (protocol == net::TestServerLauncher::ProtoFTP) 309 if (protocol == net::TestServerLauncher::ProtoFTP)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // HTTP 351 // HTTP
350 class HTTPTestServer : public BaseTestServer { 352 class HTTPTestServer : public BaseTestServer {
351 protected: 353 protected:
352 explicit HTTPTestServer() : loop_(NULL) { 354 explicit HTTPTestServer() : loop_(NULL) {
353 } 355 }
354 356
355 explicit HTTPTestServer(int connection_attempts, int connection_timeout) 357 explicit HTTPTestServer(int connection_attempts, int connection_timeout)
356 : BaseTestServer(connection_attempts, connection_timeout), loop_(NULL) { 358 : BaseTestServer(connection_attempts, connection_timeout), loop_(NULL) {
357 } 359 }
358 360
361 virtual ~HTTPTestServer() {}
362
359 public: 363 public:
360 // Creates and returns a new HTTPTestServer. If |loop| is non-null, requests 364 // Creates and returns a new HTTPTestServer. If |loop| is non-null, requests
361 // are serviced on it, otherwise a new thread and message loop are created. 365 // are serviced on it, otherwise a new thread and message loop are created.
362 static scoped_refptr<HTTPTestServer> CreateServer( 366 static scoped_refptr<HTTPTestServer> CreateServer(
363 const std::wstring& document_root, 367 const std::wstring& document_root,
364 MessageLoop* loop) { 368 MessageLoop* loop) {
365 return CreateServerWithFileRootURL(document_root, std::wstring(), loop); 369 return CreateServerWithFileRootURL(document_root, std::wstring(), loop);
366 } 370 }
367 371
368 static scoped_refptr<HTTPTestServer> CreateServer( 372 static scoped_refptr<HTTPTestServer> CreateServer(
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 scoped_refptr<HTTPSTestServer> test_server = new HTTPSTestServer(); 557 scoped_refptr<HTTPSTestServer> test_server = new HTTPSTestServer();
554 FilePath docroot = FilePath::FromWStringHack(document_root); 558 FilePath docroot = FilePath::FromWStringHack(document_root);
555 FilePath certpath = FilePath::FromWStringHack(cert_path); 559 FilePath certpath = FilePath::FromWStringHack(cert_path);
556 if (!test_server->Start(net::TestServerLauncher::ProtoHTTP, 560 if (!test_server->Start(net::TestServerLauncher::ProtoHTTP,
557 host_name, port, docroot, certpath, std::wstring())) { 561 host_name, port, docroot, certpath, std::wstring())) {
558 return NULL; 562 return NULL;
559 } 563 }
560 return test_server; 564 return test_server;
561 } 565 }
562 566
563 virtual ~HTTPSTestServer() {
564 }
565
566 protected: 567 protected:
567 std::wstring cert_path_; 568 std::wstring cert_path_;
569
570 private:
571 virtual ~HTTPSTestServer() {}
568 }; 572 };
569 573
570 574
571 class FTPTestServer : public BaseTestServer { 575 class FTPTestServer : public BaseTestServer {
572 public: 576 public:
573 FTPTestServer() { 577 FTPTestServer() {
574 } 578 }
575 579
576 static scoped_refptr<FTPTestServer> CreateServer( 580 static scoped_refptr<FTPTestServer> CreateServer(
577 const std::wstring& document_root) { 581 const std::wstring& document_root) {
(...skipping 15 matching lines...) Expand all
593 request.set_method("GET"); 597 request.set_method("GET");
594 request.Start(); 598 request.Start();
595 EXPECT_TRUE(request.is_pending()); 599 EXPECT_TRUE(request.is_pending());
596 600
597 MessageLoop::current()->Run(); 601 MessageLoop::current()->Run();
598 if (request.is_pending()) 602 if (request.is_pending())
599 return false; 603 return false;
600 604
601 return true; 605 return true;
602 } 606 }
607
608 private:
609 ~FTPTestServer() {}
603 }; 610 };
604 611
605 #endif // NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ 612 #endif // NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698