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 // This class simulates what wininet does when a dns lookup fails. |
| 5 |
| 6 #ifndef CONTENT_BROWSER_NET_URL_REQUEST_ABORT_ON_END_JOB_H_ |
| 7 #define CONTENT_BROWSER_NET_URL_REQUEST_ABORT_ON_END_JOB_H_ |
| 8 #pragma once |
| 9 |
| 10 #include <string> |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/weak_ptr.h" |
| 15 #include "content/common/content_export.h" |
| 16 #include "net/url_request/url_request_job.h" |
| 17 |
| 18 // This url request simulates a network error which occurs immediately after |
| 19 // receiving the very first data. |
| 20 |
| 21 class URLRequestAbortOnEndJob : public net::URLRequestJob { |
| 22 public: |
| 23 static const char k400AbortOnEndUrl[]; |
| 24 |
| 25 // net::URLRequestJob |
| 26 virtual void Start() OVERRIDE; |
| 27 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
| 28 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE; |
| 29 virtual bool ReadRawData(net::IOBuffer* buf, |
| 30 int buf_size, |
| 31 int* bytes_read) OVERRIDE; |
| 32 |
| 33 static net::URLRequestJob* Factory(net::URLRequest* request, |
| 34 const std::string& scheme); |
| 35 |
| 36 CONTENT_EXPORT static void AddUrlHandler(); |
| 37 |
| 38 private: |
| 39 explicit URLRequestAbortOnEndJob(net::URLRequest* request); |
| 40 virtual ~URLRequestAbortOnEndJob(); |
| 41 |
| 42 void GetResponseInfoConst(net::HttpResponseInfo* info) const; |
| 43 void StartAsync(); |
| 44 |
| 45 bool sent_data_; |
| 46 |
| 47 base::WeakPtrFactory<URLRequestAbortOnEndJob> weak_factory_; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(URLRequestAbortOnEndJob); |
| 50 }; |
| 51 #endif |
| 52 |
OLD | NEW |