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 | 6 // downloads that pause after the first |
7 | 7 |
8 #ifndef CONTENT_BROWSER_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ | 8 #ifndef CONTENT_BROWSER_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ |
9 #define CONTENT_BROWSER_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ | 9 #define CONTENT_BROWSER_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ |
10 #pragma once | 10 #pragma once |
(...skipping 16 matching lines...) Expand all Loading... |
27 // net::URLRequestJob methods | 27 // net::URLRequestJob methods |
28 virtual void Start(); | 28 virtual void Start(); |
29 virtual bool GetMimeType(std::string* mime_type) const; | 29 virtual bool GetMimeType(std::string* mime_type) const; |
30 virtual void GetResponseInfo(net::HttpResponseInfo* info); | 30 virtual void GetResponseInfo(net::HttpResponseInfo* info); |
31 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); | 31 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); |
32 | 32 |
33 static net::URLRequestJob* Factory(net::URLRequest* request, | 33 static net::URLRequestJob* Factory(net::URLRequest* request, |
34 const std::string& scheme); | 34 const std::string& scheme); |
35 | 35 |
36 // Test URLs. | 36 // Test URLs. |
37 static const char kUnknownSizeUrl[]; | 37 CONTENT_EXPORT static const char kUnknownSizeUrl[]; |
38 static const char kKnownSizeUrl[]; | 38 CONTENT_EXPORT static const char kKnownSizeUrl[]; |
39 static const char kFinishDownloadUrl[]; | 39 CONTENT_EXPORT static const char kFinishDownloadUrl[]; |
40 | 40 |
41 // Adds the testing URLs to the net::URLRequestFilter. | 41 // Adds the testing URLs to the net::URLRequestFilter. |
42 CONTENT_EXPORT static void AddUrlHandler(); | 42 CONTENT_EXPORT static void AddUrlHandler(); |
43 | 43 |
44 private: | 44 private: |
45 virtual ~URLRequestSlowDownloadJob(); | 45 virtual ~URLRequestSlowDownloadJob(); |
46 | 46 |
47 void GetResponseInfoConst(net::HttpResponseInfo* info) const; | 47 void GetResponseInfoConst(net::HttpResponseInfo* info) const; |
48 | 48 |
49 // Mark all pending requests to be finished. We keep track of pending | 49 // Mark all pending requests to be finished. We keep track of pending |
50 // requests in |kPendingRequests|. | 50 // requests in |kPendingRequests|. |
51 static void FinishPendingRequests(); | 51 static void FinishPendingRequests(); |
52 static std::vector<URLRequestSlowDownloadJob*> kPendingRequests; | 52 static std::vector<URLRequestSlowDownloadJob*> kPendingRequests; |
53 | 53 |
54 void StartAsync(); | 54 void StartAsync(); |
55 | 55 |
56 void set_should_finish_download() { should_finish_download_ = true; } | 56 void set_should_finish_download() { should_finish_download_ = true; } |
57 | 57 |
58 int first_download_size_remaining_; | 58 int first_download_size_remaining_; |
59 bool should_finish_download_; | 59 bool should_finish_download_; |
60 bool should_send_second_chunk_; | 60 bool should_send_second_chunk_; |
61 | 61 |
62 ScopedRunnableMethodFactory<URLRequestSlowDownloadJob> method_factory_; | 62 ScopedRunnableMethodFactory<URLRequestSlowDownloadJob> method_factory_; |
63 }; | 63 }; |
64 | 64 |
65 #endif // CONTENT_BROWSER_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ | 65 #endif // CONTENT_BROWSER_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ |
OLD | NEW |