| 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. Requests to |kUnknownSizeUrl| and | 4 // This class simulates a slow download. Requests to |kUnknownSizeUrl| and |
| 5 // |kKnownSizeUrl| start downloads that pause after the first N bytes, to be | 5 // |kKnownSizeUrl| start downloads that pause after the first N bytes, to be |
| 6 // completed by sending a request to |kFinishDownloadUrl|. | 6 // completed by sending a request to |kFinishDownloadUrl|. |
| 7 | 7 |
| 8 #ifndef NET_TEST_URL_REQUEST_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ | 8 #ifndef NET_TEST_URL_REQUEST_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ |
| 9 #define NET_TEST_URL_REQUEST_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ | 9 #define NET_TEST_URL_REQUEST_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 static const int kSecondDownloadSize; | 30 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 // URLRequestJob methods | 36 // URLRequestJob methods |
| 37 void Start() override; | 37 void Start() override; |
| 38 bool GetMimeType(std::string* mime_type) const override; | 38 bool GetMimeType(std::string* mime_type) const override; |
| 39 void GetResponseInfo(HttpResponseInfo* info) override; | 39 void GetResponseInfo(HttpResponseInfo* info) override; |
| 40 bool ReadRawData(IOBuffer* buf, int buf_size, int* bytes_read) override; | 40 int ReadRawData(IOBuffer* buf, int buf_size) override; |
| 41 | 41 |
| 42 // Returns the current number of URLRequestSlowDownloadJobs that have | 42 // Returns the current number of URLRequestSlowDownloadJobs that have |
| 43 // not yet completed. | 43 // not yet completed. |
| 44 static size_t NumberOutstandingRequests(); | 44 static size_t NumberOutstandingRequests(); |
| 45 | 45 |
| 46 // Adds the testing URLs to the URLRequestFilter. | 46 // Adds the testing URLs to the URLRequestFilter. |
| 47 static void AddUrlHandler(); | 47 static void AddUrlHandler(); |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 class Interceptor; | 50 class Interceptor; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 bool should_finish_download_; | 89 bool should_finish_download_; |
| 90 scoped_refptr<IOBuffer> buffer_; | 90 scoped_refptr<IOBuffer> buffer_; |
| 91 int buffer_size_; | 91 int buffer_size_; |
| 92 | 92 |
| 93 base::WeakPtrFactory<URLRequestSlowDownloadJob> weak_factory_; | 93 base::WeakPtrFactory<URLRequestSlowDownloadJob> weak_factory_; |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 } // namespace content | 96 } // namespace content |
| 97 | 97 |
| 98 #endif // NET_TEST_URL_REQUEST_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ | 98 #endif // NET_TEST_URL_REQUEST_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ |
| OLD | NEW |