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 a slow download. This used in a UI test to test the | 4 // This class simulates a slow download. This used in a UI test to test the |
5 // download manager. Requests to |kUnknownSizeUrl| and |kKnownSizeUrl| start | 5 // download manager. Requests to |kUnknownSizeUrl| and |kKnownSizeUrl| start |
6 // downloads that pause after the first N bytes, to be completed by sending a | 6 // downloads that pause after the first N bytes, to be completed by sending a |
7 // request to |kFinishDownloadUrl|. | 7 // request to |kFinishDownloadUrl|. |
8 | 8 |
9 #ifndef CONTENT_BROWSER_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ | 9 #ifndef CONTENT_BROWSER_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ |
10 #define CONTENT_BROWSER_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ | 10 #define CONTENT_BROWSER_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 // Download sizes. | 28 // Download sizes. |
29 CONTENT_EXPORT static const int kFirstDownloadSize; | 29 CONTENT_EXPORT static const int kFirstDownloadSize; |
30 CONTENT_EXPORT static const int kSecondDownloadSize; | 30 CONTENT_EXPORT static const int kSecondDownloadSize; |
31 | 31 |
32 // Timer callback, used to check to see if we should finish our download and | 32 // Timer callback, used to check to see if we should finish our download and |
33 // send the second chunk. | 33 // send the second chunk. |
34 void CheckDoneStatus(); | 34 void CheckDoneStatus(); |
35 | 35 |
36 // net::URLRequestJob methods | 36 // net::URLRequestJob methods |
37 virtual void Start(); | 37 virtual void Start() OVERRIDE; |
38 virtual bool GetMimeType(std::string* mime_type) const; | 38 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; |
39 virtual void GetResponseInfo(net::HttpResponseInfo* info); | 39 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE; |
40 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); | 40 virtual bool ReadRawData(net::IOBuffer* buf, |
| 41 int buf_size, |
| 42 int *bytes_read) OVERRIDE; |
41 | 43 |
42 static net::URLRequestJob* Factory(net::URLRequest* request, | 44 static net::URLRequestJob* Factory(net::URLRequest* request, |
43 const std::string& scheme); | 45 const std::string& scheme); |
44 | 46 |
45 // Returns the current number of URLRequestSlowDownloadJobs that have | 47 // Returns the current number of URLRequestSlowDownloadJobs that have |
46 // not yet completed. | 48 // not yet completed. |
47 CONTENT_EXPORT static size_t NumberOutstandingRequests(); | 49 CONTENT_EXPORT static size_t NumberOutstandingRequests(); |
48 | 50 |
49 // Adds the testing URLs to the net::URLRequestFilter. | 51 // Adds the testing URLs to the net::URLRequestFilter. |
50 CONTENT_EXPORT static void AddUrlHandler(); | 52 CONTENT_EXPORT static void AddUrlHandler(); |
(...skipping 18 matching lines...) Expand all Loading... |
69 | 71 |
70 int first_download_size_remaining_; | 72 int first_download_size_remaining_; |
71 bool should_finish_download_; | 73 bool should_finish_download_; |
72 scoped_refptr<net::IOBuffer> buffer_; | 74 scoped_refptr<net::IOBuffer> buffer_; |
73 int buffer_size_; | 75 int buffer_size_; |
74 | 76 |
75 base::WeakPtrFactory<URLRequestSlowDownloadJob> weak_factory_; | 77 base::WeakPtrFactory<URLRequestSlowDownloadJob> weak_factory_; |
76 }; | 78 }; |
77 | 79 |
78 #endif // CONTENT_BROWSER_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ | 80 #endif // CONTENT_BROWSER_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ |
OLD | NEW |