| 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 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_TEST_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ | 9 #ifndef CONTENT_TEST_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ |
| 10 #define CONTENT_TEST_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ | 10 #define CONTENT_TEST_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 // Download sizes. | 29 // Download sizes. |
| 30 static const int kFirstDownloadSize; | 30 static const int kFirstDownloadSize; |
| 31 static const int kSecondDownloadSize; | 31 static const int kSecondDownloadSize; |
| 32 | 32 |
| 33 // Timer callback, used to check to see if we should finish our download and | 33 // Timer callback, used to check to see if we should finish our download and |
| 34 // send the second chunk. | 34 // send the second chunk. |
| 35 void CheckDoneStatus(); | 35 void CheckDoneStatus(); |
| 36 | 36 |
| 37 // net::URLRequestJob methods | 37 // net::URLRequestJob methods |
| 38 virtual void Start() OVERRIDE; | 38 virtual void Start() override; |
| 39 virtual bool GetMimeType(std::string* mime_type) const OVERRIDE; | 39 virtual bool GetMimeType(std::string* mime_type) const override; |
| 40 virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE; | 40 virtual void GetResponseInfo(net::HttpResponseInfo* info) override; |
| 41 virtual bool ReadRawData(net::IOBuffer* buf, | 41 virtual bool ReadRawData(net::IOBuffer* buf, |
| 42 int buf_size, | 42 int buf_size, |
| 43 int *bytes_read) OVERRIDE; | 43 int *bytes_read) override; |
| 44 | 44 |
| 45 static net::URLRequestJob* Factory(net::URLRequest* request, | 45 static net::URLRequestJob* Factory(net::URLRequest* request, |
| 46 net::NetworkDelegate* network_delegate, | 46 net::NetworkDelegate* network_delegate, |
| 47 const std::string& scheme); | 47 const std::string& scheme); |
| 48 | 48 |
| 49 // Returns the current number of URLRequestSlowDownloadJobs that have | 49 // Returns the current number of URLRequestSlowDownloadJobs that have |
| 50 // not yet completed. | 50 // not yet completed. |
| 51 static size_t NumberOutstandingRequests(); | 51 static size_t NumberOutstandingRequests(); |
| 52 | 52 |
| 53 // Adds the testing URLs to the net::URLRequestFilter. | 53 // Adds the testing URLs to the net::URLRequestFilter. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 bool should_finish_download_; | 96 bool should_finish_download_; |
| 97 scoped_refptr<net::IOBuffer> buffer_; | 97 scoped_refptr<net::IOBuffer> buffer_; |
| 98 int buffer_size_; | 98 int buffer_size_; |
| 99 | 99 |
| 100 base::WeakPtrFactory<URLRequestSlowDownloadJob> weak_factory_; | 100 base::WeakPtrFactory<URLRequestSlowDownloadJob> weak_factory_; |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 } // namespace content | 103 } // namespace content |
| 104 | 104 |
| 105 #endif // CONTENT_TEST_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ | 105 #endif // CONTENT_TEST_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ |
| OLD | NEW |