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