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 // CancelableRequestProviders and Consumers work together to make requests that | 5 // CancelableRequestProviders and Consumers work together to make requests that |
6 // execute on a background thread in the provider and return data to the | 6 // execute on a background thread in the provider and return data to the |
7 // consumer. These class collaborate to keep a list of open requests and to | 7 // consumer. These class collaborate to keep a list of open requests and to |
8 // make sure that requests to not outlive either of the objects involved in the | 8 // make sure that requests to not outlive either of the objects involved in the |
9 // transaction. | 9 // transaction. |
10 // | 10 // |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // Sent after executing a callback. | 203 // Sent after executing a callback. |
204 virtual void DidExecute(CancelableRequestProvider* provider, | 204 virtual void DidExecute(CancelableRequestProvider* provider, |
205 CancelableRequestProvider::Handle handle) = 0; | 205 CancelableRequestProvider::Handle handle) = 0; |
206 }; | 206 }; |
207 | 207 |
208 // Template for clients to use. It allows them to associate random "client | 208 // Template for clients to use. It allows them to associate random "client |
209 // data" with a specific request. The default value for this type is 0. | 209 // data" with a specific request. The default value for this type is 0. |
210 // The type T should be small and easily copyable (like a pointer | 210 // The type T should be small and easily copyable (like a pointer |
211 // or an integer). | 211 // or an integer). |
212 template<class T> | 212 template<class T> |
213 class CancelableRequestConsumerTSimple : public CancelableRequestConsumerBase { | 213 class CONTENT_EXPORT CancelableRequestConsumerTSimple |
| 214 : public CancelableRequestConsumerBase { |
214 public: | 215 public: |
215 CancelableRequestConsumerTSimple(); | 216 CancelableRequestConsumerTSimple(); |
216 | 217 |
217 // Cancel any outstanding requests so that we do not get called back after we | 218 // Cancel any outstanding requests so that we do not get called back after we |
218 // are destroyed. As these requests are removed, the providers will call us | 219 // are destroyed. As these requests are removed, the providers will call us |
219 // back on OnRequestRemoved, which will then update the list. To iterate | 220 // back on OnRequestRemoved, which will then update the list. To iterate |
220 // successfully while the list is changing out from under us, we make a copy. | 221 // successfully while the list is changing out from under us, we make a copy. |
221 virtual ~CancelableRequestConsumerTSimple(); | 222 virtual ~CancelableRequestConsumerTSimple(); |
222 | 223 |
223 // Associates some random data with a specified request. The request MUST be | 224 // Associates some random data with a specified request. The request MUST be |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 template<class T> | 445 template<class T> |
445 void CancelableRequestConsumerTSimple<T>::DidExecute( | 446 void CancelableRequestConsumerTSimple<T>::DidExecute( |
446 CancelableRequestProvider* provider, | 447 CancelableRequestProvider* provider, |
447 CancelableRequestProvider::Handle handle) { | 448 CancelableRequestProvider::Handle handle) { |
448 current_request_ = PendingRequest(); | 449 current_request_ = PendingRequest(); |
449 } | 450 } |
450 | 451 |
451 // See CancelableRequestConsumerTSimple. The default value for T | 452 // See CancelableRequestConsumerTSimple. The default value for T |
452 // is given in |initial_t|. | 453 // is given in |initial_t|. |
453 template<class T, T initial_t> | 454 template<class T, T initial_t> |
454 class CancelableRequestConsumerT : public CancelableRequestConsumerTSimple<T> { | 455 class CONTENT_EXPORT CancelableRequestConsumerT |
| 456 : public CancelableRequestConsumerTSimple<T> { |
455 public: | 457 public: |
456 CancelableRequestConsumerT(); | 458 CancelableRequestConsumerT(); |
457 virtual ~CancelableRequestConsumerT(); | 459 virtual ~CancelableRequestConsumerT(); |
458 | 460 |
459 protected: | 461 protected: |
460 virtual T get_initial_t() const; | 462 virtual T get_initial_t() const; |
461 }; | 463 }; |
462 | 464 |
463 template<class T, T initial_t> | 465 template<class T, T initial_t> |
464 CancelableRequestConsumerT<T, initial_t>::CancelableRequestConsumerT() { | 466 CancelableRequestConsumerT<T, initial_t>::CancelableRequestConsumerT() { |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 } | 967 } |
966 | 968 |
967 // The value. | 969 // The value. |
968 Type value; | 970 Type value; |
969 | 971 |
970 protected: | 972 protected: |
971 virtual ~CancelableRequest1() {} | 973 virtual ~CancelableRequest1() {} |
972 }; | 974 }; |
973 | 975 |
974 #endif // CONTENT_BROWSER_CANCELABLE_REQUEST_H_ | 976 #endif // CONTENT_BROWSER_CANCELABLE_REQUEST_H_ |
OLD | NEW |