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 | 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 |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "net/base/net_api.h" |
12 #include "net/url_request/url_request_status.h" | 13 #include "net/url_request/url_request_status.h" |
13 | 14 |
14 class GURL; | 15 class GURL; |
15 | 16 |
16 namespace net { | 17 namespace net { |
17 class URLRequestJob; | 18 class URLRequestJob; |
18 | 19 |
19 // This class maintains a list of active URLRequestJobs for debugging purposes. | 20 // This class maintains a list of active URLRequestJobs for debugging purposes. |
20 // This allows us to warn on leaked jobs and also allows an observer to track | 21 // This allows us to warn on leaked jobs and also allows an observer to track |
21 // what is happening, for example, for the network status monitor. | 22 // what is happening, for example, for the network status monitor. |
22 // | 23 // |
23 // NOTE: URLRequest is single-threaded, so this class should only be used | 24 // NOTE: URLRequest is single-threaded, so this class should only be used |
24 // onthe same thread where all of the application's URLRequest calls are | 25 // onthe same thread where all of the application's URLRequest calls are |
25 // made. | 26 // made. |
26 // | 27 // |
27 class URLRequestJobTracker { | 28 class NET_API URLRequestJobTracker { |
28 public: | 29 public: |
29 typedef std::vector<URLRequestJob*> JobList; | 30 typedef std::vector<URLRequestJob*> JobList; |
30 typedef JobList::const_iterator JobIterator; | 31 typedef JobList::const_iterator JobIterator; |
31 | 32 |
32 // The observer's methods are called on the thread that called AddObserver. | 33 // The observer's methods are called on the thread that called AddObserver. |
33 class JobObserver { | 34 class JobObserver { |
34 public: | 35 public: |
35 virtual ~JobObserver() {} | 36 virtual ~JobObserver() {} |
36 | 37 |
37 // Called after the given job has been added to the list | 38 // Called after the given job has been added to the list |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 91 } |
91 JobIterator end() const { | 92 JobIterator end() const { |
92 return active_jobs_.end(); | 93 return active_jobs_.end(); |
93 } | 94 } |
94 | 95 |
95 private: | 96 private: |
96 ObserverList<JobObserver> observers_; | 97 ObserverList<JobObserver> observers_; |
97 JobList active_jobs_; | 98 JobList active_jobs_; |
98 }; | 99 }; |
99 | 100 |
100 extern URLRequestJobTracker g_url_request_job_tracker; | 101 NET_API extern URLRequestJobTracker g_url_request_job_tracker; |
101 | 102 |
102 } // namespace net | 103 } // namespace net |
103 | 104 |
104 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_TRACKER_H_ | 105 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_TRACKER_H_ |
OLD | NEW |