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