Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(565)

Side by Side Diff: chrome/browser/automation/url_request_slow_download_job.h

Issue 40138: Use FilterContext to allow filters to access URLRequestJob data... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 CHROME_BROWSER_AUTOMATION_URL_REQUEST_SLOW_DOWNLOAD_JOB_H__ 8 #ifndef CHROME_BROWSER_AUTOMATION_URL_REQUEST_SLOW_DOWNLOAD_JOB_H__
9 #define CHROME_BROWSER_AUTOMATION_URL_REQUEST_SLOW_DOWNLOAD_JOB_H__ 9 #define CHROME_BROWSER_AUTOMATION_URL_REQUEST_SLOW_DOWNLOAD_JOB_H__
10 10
11 #include <string>
11 #include <vector> 12 #include <vector>
12 13
13 #include "net/url_request/url_request_job.h" 14 #include "net/url_request/url_request_job.h"
14 15
15 class URLRequestSlowDownloadJob : public URLRequestJob { 16 class URLRequestSlowDownloadJob : public URLRequestJob {
16 public: 17 public:
17 URLRequestSlowDownloadJob(URLRequest* request); 18 explicit URLRequestSlowDownloadJob(URLRequest* request);
18 virtual ~URLRequestSlowDownloadJob() { } 19 virtual ~URLRequestSlowDownloadJob() { }
19 20
20 // Timer callback, used to check to see if we should finish our download and 21 // Timer callback, used to check to see if we should finish our download and
21 // send the second chunk. 22 // send the second chunk.
22 void CheckDoneStatus(); 23 void CheckDoneStatus();
23 24
24 // URLRequestJob methods 25 // URLRequestJob methods
25 virtual void Start(); 26 virtual void Start();
26 virtual bool GetMimeType(std::string* mime_type); 27 virtual bool GetMimeType(std::string* mime_type) const;
27 virtual void GetResponseInfo(net::HttpResponseInfo* info); 28 virtual void GetResponseInfo(net::HttpResponseInfo* info);
28 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); 29 virtual bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read);
29 30
30 static URLRequestJob* Factory(URLRequest* request, 31 static URLRequestJob* Factory(URLRequest* request,
31 const std::string& scheme); 32 const std::string& scheme);
32 33
33 // Test URLs. 34 // Test URLs.
34 static const wchar_t kUnknownSizeUrl[]; 35 static const wchar_t kUnknownSizeUrl[];
35 static const wchar_t kKnownSizeUrl[]; 36 static const wchar_t kKnownSizeUrl[];
36 static const wchar_t kFinishDownloadUrl[]; 37 static const wchar_t kFinishDownloadUrl[];
37 38
38 // For UI tests: adds the testing URLs to the URLRequestFilter. 39 // For UI tests: adds the testing URLs to the URLRequestFilter.
39 static void AddUITestUrls(); 40 static void AddUITestUrls();
40 41
41 private: 42 private:
43 void GetResponseInfoConst(net::HttpResponseInfo* info) const;
44
42 // Mark all pending requests to be finished. We keep track of pending 45 // Mark all pending requests to be finished. We keep track of pending
43 // requests in |kPendingRequests|. 46 // requests in |kPendingRequests|.
44 static void FinishPendingRequests(); 47 static void FinishPendingRequests();
45 static std::vector<URLRequestSlowDownloadJob*> kPendingRequests; 48 static std::vector<URLRequestSlowDownloadJob*> kPendingRequests;
46 49
47 void StartAsync(); 50 void StartAsync();
48 51
49 void set_should_finish_download() { should_finish_download_ = true; } 52 void set_should_finish_download() { should_finish_download_ = true; }
50 53
51 int first_download_size_remaining_; 54 int first_download_size_remaining_;
52 bool should_finish_download_; 55 bool should_finish_download_;
53 bool should_send_second_chunk_; 56 bool should_send_second_chunk_;
54 }; 57 };
55 58
56 #endif // CHROME_BROWSER_AUTOMATION_URL_REQUEST_SLOW_DOWNLOAD_JOB_H__ 59 #endif // CHROME_BROWSER_AUTOMATION_URL_REQUEST_SLOW_DOWNLOAD_JOB_H__
57 60
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698