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_ |
11 | 11 |
12 #include <set> | 12 #include <set> |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "net/url_request/url_request_job.h" | 17 #include "net/url_request/url_request_job.h" |
18 | 18 |
| 19 namespace content { |
| 20 |
19 class URLRequestSlowDownloadJob : public net::URLRequestJob { | 21 class URLRequestSlowDownloadJob : public net::URLRequestJob { |
20 public: | 22 public: |
21 // Test URLs. | 23 // Test URLs. |
22 static const char kUnknownSizeUrl[]; | 24 static const char kUnknownSizeUrl[]; |
23 static const char kKnownSizeUrl[]; | 25 static const char kKnownSizeUrl[]; |
24 static const char kFinishDownloadUrl[]; | 26 static const char kFinishDownloadUrl[]; |
25 | 27 |
26 // Download sizes. | 28 // Download sizes. |
27 static const int kFirstDownloadSize; | 29 static const int kFirstDownloadSize; |
28 static const int kSecondDownloadSize; | 30 static const int kSecondDownloadSize; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 void set_should_finish_download() { should_finish_download_ = true; } | 89 void set_should_finish_download() { should_finish_download_ = true; } |
88 | 90 |
89 int bytes_already_sent_; | 91 int bytes_already_sent_; |
90 bool should_finish_download_; | 92 bool should_finish_download_; |
91 scoped_refptr<net::IOBuffer> buffer_; | 93 scoped_refptr<net::IOBuffer> buffer_; |
92 int buffer_size_; | 94 int buffer_size_; |
93 | 95 |
94 base::WeakPtrFactory<URLRequestSlowDownloadJob> weak_factory_; | 96 base::WeakPtrFactory<URLRequestSlowDownloadJob> weak_factory_; |
95 }; | 97 }; |
96 | 98 |
| 99 } // namespace content |
| 100 |
97 #endif // CONTENT_TEST_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ | 101 #endif // CONTENT_TEST_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ |
OLD | NEW |