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_ |
11 #pragma once | 11 #pragma once |
12 | 12 |
13 #include <set> | 13 #include <set> |
14 #include <string> | 14 #include <string> |
15 | 15 |
16 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
17 #include "base/task.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
19 #include "net/url_request/url_request_job.h" | 19 #include "net/url_request/url_request_job.h" |
20 | 20 |
21 class URLRequestSlowDownloadJob : public net::URLRequestJob { | 21 class URLRequestSlowDownloadJob : public net::URLRequestJob { |
22 public: | 22 public: |
23 // Test URLs. | 23 // Test URLs. |
24 CONTENT_EXPORT static const char kUnknownSizeUrl[]; | 24 CONTENT_EXPORT static const char kUnknownSizeUrl[]; |
25 CONTENT_EXPORT static const char kKnownSizeUrl[]; | 25 CONTENT_EXPORT static const char kKnownSizeUrl[]; |
26 CONTENT_EXPORT static const char kFinishDownloadUrl[]; | 26 CONTENT_EXPORT static const char kFinishDownloadUrl[]; |
27 | 27 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 | 65 |
66 void StartAsync(); | 66 void StartAsync(); |
67 | 67 |
68 void set_should_finish_download() { should_finish_download_ = true; } | 68 void set_should_finish_download() { should_finish_download_ = true; } |
69 | 69 |
70 int first_download_size_remaining_; | 70 int first_download_size_remaining_; |
71 bool should_finish_download_; | 71 bool should_finish_download_; |
72 scoped_refptr<net::IOBuffer> buffer_; | 72 scoped_refptr<net::IOBuffer> buffer_; |
73 int buffer_size_; | 73 int buffer_size_; |
74 | 74 |
75 ScopedRunnableMethodFactory<URLRequestSlowDownloadJob> method_factory_; | 75 base::WeakPtrFactory<URLRequestSlowDownloadJob> method_factory_; |
James Hawkins
2011/11/14 17:57:06
weak_factory_
dcheng
2011/11/14 20:47:49
Done.
| |
76 }; | 76 }; |
77 | 77 |
78 #endif // CONTENT_BROWSER_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ | 78 #endif // CONTENT_BROWSER_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ |
OLD | NEW |