| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/test/net/url_request_failed_dns_job.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/compiler_specific.h" | |
| 9 #include "base/message_loop.h" | |
| 10 #include "googleurl/src/gurl.h" | |
| 11 #include "net/base/net_errors.h" | |
| 12 #include "net/url_request/url_request.h" | |
| 13 #include "net/url_request/url_request_filter.h" | |
| 14 | |
| 15 const char URLRequestFailedDnsJob::kTestUrl[] = | |
| 16 "http://url.handled.by.fake.dns/"; | |
| 17 | |
| 18 URLRequestFailedDnsJob::URLRequestFailedDnsJob(net::URLRequest* request) | |
| 19 : net::URLRequestJob(request), | |
| 20 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} | |
| 21 | |
| 22 URLRequestFailedDnsJob::~URLRequestFailedDnsJob() {} | |
| 23 | |
| 24 void URLRequestFailedDnsJob::Start() { | |
| 25 MessageLoop::current()->PostTask( | |
| 26 FROM_HERE, | |
| 27 base::Bind(&URLRequestFailedDnsJob::StartAsync, | |
| 28 weak_factory_.GetWeakPtr())); | |
| 29 } | |
| 30 | |
| 31 // static | |
| 32 void URLRequestFailedDnsJob::AddUrlHandler() { | |
| 33 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); | |
| 34 filter->AddUrlHandler(GURL(kTestUrl), | |
| 35 &URLRequestFailedDnsJob::Factory); | |
| 36 } | |
| 37 | |
| 38 /*static */ | |
| 39 net::URLRequestJob* URLRequestFailedDnsJob::Factory(net::URLRequest* request, | |
| 40 const std::string& scheme) { | |
| 41 return new URLRequestFailedDnsJob(request); | |
| 42 } | |
| 43 | |
| 44 void URLRequestFailedDnsJob::StartAsync() { | |
| 45 NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED, | |
| 46 net::ERR_NAME_NOT_RESOLVED)); | |
| 47 } | |
| OLD | NEW |