| OLD | NEW |
| 1 // Copyright (c) 2011 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_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 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 net::IOBuffer* buf, | 73 net::IOBuffer* buf, |
| 74 int buf_size, | 74 int buf_size, |
| 75 int* bytes_written); | 75 int* bytes_written); |
| 76 | 76 |
| 77 void GetResponseInfoConst(net::HttpResponseInfo* info) const; | 77 void GetResponseInfoConst(net::HttpResponseInfo* info) const; |
| 78 | 78 |
| 79 // Mark all pending requests to be finished. We keep track of pending | 79 // Mark all pending requests to be finished. We keep track of pending |
| 80 // requests in |pending_requests_|. | 80 // requests in |pending_requests_|. |
| 81 static void FinishPendingRequests(); | 81 static void FinishPendingRequests(); |
| 82 typedef std::set<URLRequestSlowDownloadJob*> SlowJobsSet; | 82 typedef std::set<URLRequestSlowDownloadJob*> SlowJobsSet; |
| 83 static base::LazyInstance<SlowJobsSet, | 83 static base::LazyInstance<SlowJobsSet>::Leaky pending_requests_; |
| 84 base::LeakyLazyInstanceTraits<SlowJobsSet> > | |
| 85 pending_requests_; | |
| 86 | 84 |
| 87 void StartAsync(); | 85 void StartAsync(); |
| 88 | 86 |
| 89 void set_should_finish_download() { should_finish_download_ = true; } | 87 void set_should_finish_download() { should_finish_download_ = true; } |
| 90 | 88 |
| 91 int bytes_already_sent_; | 89 int bytes_already_sent_; |
| 92 bool should_finish_download_; | 90 bool should_finish_download_; |
| 93 scoped_refptr<net::IOBuffer> buffer_; | 91 scoped_refptr<net::IOBuffer> buffer_; |
| 94 int buffer_size_; | 92 int buffer_size_; |
| 95 | 93 |
| 96 base::WeakPtrFactory<URLRequestSlowDownloadJob> weak_factory_; | 94 base::WeakPtrFactory<URLRequestSlowDownloadJob> weak_factory_; |
| 97 }; | 95 }; |
| 98 | 96 |
| 99 #endif // CONTENT_BROWSER_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ | 97 #endif // CONTENT_BROWSER_NET_URL_REQUEST_SLOW_DOWNLOAD_JOB_H_ |
| OLD | NEW |