OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 4 |
5 #ifndef NET_URL_REQUEST_URL_REQUEST_JOB_TRACKER_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_JOB_TRACKER_H_ |
6 #define NET_URL_REQUEST_URL_REQUEST_JOB_TRACKER_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_JOB_TRACKER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 class JobObserver { | 33 class JobObserver { |
34 public: | 34 public: |
35 // Called after the given job has been added to the list | 35 // Called after the given job has been added to the list |
36 virtual void OnJobAdded(URLRequestJob* job) = 0; | 36 virtual void OnJobAdded(URLRequestJob* job) = 0; |
37 | 37 |
38 // Called after the given job has been removed from the list | 38 // Called after the given job has been removed from the list |
39 virtual void OnJobRemoved(URLRequestJob* job) = 0; | 39 virtual void OnJobRemoved(URLRequestJob* job) = 0; |
40 | 40 |
41 // Called when the given job has completed, before notifying the request | 41 // Called when the given job has completed, before notifying the request |
42 virtual void OnJobDone(URLRequestJob* job, | 42 virtual void OnJobDone(URLRequestJob* job, |
43 const URLRequestStatus& status) = 0; | 43 const net::URLRequestStatus& status) = 0; |
44 | 44 |
45 // Called when the given job is about to follow a redirect to the given | 45 // Called when the given job is about to follow a redirect to the given |
46 // new URL. The redirect type is given in status_code | 46 // new URL. The redirect type is given in status_code |
47 virtual void OnJobRedirect(URLRequestJob* job, const GURL& location, | 47 virtual void OnJobRedirect(URLRequestJob* job, const GURL& location, |
48 int status_code) = 0; | 48 int status_code) = 0; |
49 | 49 |
50 // Called when a new chunk of unfiltered bytes has been read for | 50 // Called when a new chunk of unfiltered bytes has been read for |
51 // the given job. |byte_count| is the number of bytes for that | 51 // the given job. |byte_count| is the number of bytes for that |
52 // read event only. |buf| is a pointer to the data buffer that | 52 // read event only. |buf| is a pointer to the data buffer that |
53 // contains those bytes. The data in |buf| is only valid for the | 53 // contains those bytes. The data in |buf| is only valid for the |
(...skipping 16 matching lines...) Expand all Loading... |
70 observers_.RemoveObserver(observer); | 70 observers_.RemoveObserver(observer); |
71 } | 71 } |
72 | 72 |
73 // adds or removes the job from the active list, should be called by the | 73 // adds or removes the job from the active list, should be called by the |
74 // job constructor and destructor. Note: don't use "AddJob" since that | 74 // job constructor and destructor. Note: don't use "AddJob" since that |
75 // is #defined by windows.h :( | 75 // is #defined by windows.h :( |
76 void AddNewJob(URLRequestJob* job); | 76 void AddNewJob(URLRequestJob* job); |
77 void RemoveJob(URLRequestJob* job); | 77 void RemoveJob(URLRequestJob* job); |
78 | 78 |
79 // Job status change notifications | 79 // Job status change notifications |
80 void OnJobDone(URLRequestJob* job, const URLRequestStatus& status); | 80 void OnJobDone(URLRequestJob* job, const net::URLRequestStatus& status); |
81 void OnJobRedirect(URLRequestJob* job, const GURL& location, | 81 void OnJobRedirect(URLRequestJob* job, const GURL& location, |
82 int status_code); | 82 int status_code); |
83 | 83 |
84 // Bytes read notifications. | 84 // Bytes read notifications. |
85 void OnBytesRead(URLRequestJob* job, const char* buf, int byte_count); | 85 void OnBytesRead(URLRequestJob* job, const char* buf, int byte_count); |
86 | 86 |
87 // allows iteration over all active jobs | 87 // allows iteration over all active jobs |
88 JobIterator begin() const { | 88 JobIterator begin() const { |
89 return active_jobs_.begin(); | 89 return active_jobs_.begin(); |
90 } | 90 } |
91 JobIterator end() const { | 91 JobIterator end() const { |
92 return active_jobs_.end(); | 92 return active_jobs_.end(); |
93 } | 93 } |
94 | 94 |
95 private: | 95 private: |
96 ObserverList<JobObserver> observers_; | 96 ObserverList<JobObserver> observers_; |
97 JobList active_jobs_; | 97 JobList active_jobs_; |
98 }; | 98 }; |
99 | 99 |
100 extern URLRequestJobTracker g_url_request_job_tracker; | 100 extern URLRequestJobTracker g_url_request_job_tracker; |
101 | 101 |
102 } // namespace net | 102 } // namespace net |
103 | 103 |
104 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_TRACKER_H_ | 104 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_TRACKER_H_ |
OLD | NEW |