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 CONTENT_BROWSER_RENDERER_HOST_RESOURCE_QUEUE_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RESOURCE_QUEUE_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RESOURCE_QUEUE_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RESOURCE_QUEUE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 class URLRequest; | 16 class URLRequest; |
17 } // namespace net | 17 } // namespace net |
18 | 18 |
19 class ResourceDispatcherHostRequestInfo; | 19 class ResourceDispatcherHostRequestInfo; |
20 class ResourceQueue; | 20 class ResourceQueue; |
21 struct GlobalRequestID; | 21 struct GlobalRequestID; |
22 | 22 |
23 // Makes decisions about delaying or not each net::URLRequest in the queue. | 23 // Makes decisions about delaying or not each net::URLRequest in the queue. |
24 // All methods are called on the IO thread. | 24 // All methods are called on the IO thread. |
25 class ResourceQueueDelegate { | 25 class CONTENT_EXPORT ResourceQueueDelegate { |
26 public: | 26 public: |
27 // Gives the delegate a pointer to the queue object. | 27 // Gives the delegate a pointer to the queue object. |
28 virtual void Initialize(ResourceQueue* resource_queue) = 0; | 28 virtual void Initialize(ResourceQueue* resource_queue) = 0; |
29 | 29 |
30 // Should return true if it wants the |request| to not be started at this | 30 // Should return true if it wants the |request| to not be started at this |
31 // point. To start the delayed request, ResourceQueue::StartDelayedRequest | 31 // point. To start the delayed request, ResourceQueue::StartDelayedRequest |
32 // should be used. | 32 // should be used. |
33 virtual bool ShouldDelayRequest( | 33 virtual bool ShouldDelayRequest( |
34 net::URLRequest* request, | 34 net::URLRequest* request, |
35 const ResourceDispatcherHostRequestInfo& request_info, | 35 const ResourceDispatcherHostRequestInfo& request_info, |
36 const GlobalRequestID& request_id) = 0; | 36 const GlobalRequestID& request_id) = 0; |
37 | 37 |
38 // Called just before ResourceQueue shutdown. After that, the delegate | 38 // Called just before ResourceQueue shutdown. After that, the delegate |
39 // should not use the ResourceQueue. | 39 // should not use the ResourceQueue. |
40 virtual void WillShutdownResourceQueue() = 0; | 40 virtual void WillShutdownResourceQueue() = 0; |
41 | 41 |
42 protected: | 42 protected: |
43 CONTENT_EXPORT virtual ~ResourceQueueDelegate(); | 43 virtual ~ResourceQueueDelegate(); |
44 }; | 44 }; |
45 | 45 |
46 // Makes it easy to delay starting URL requests until specified conditions are | 46 // Makes it easy to delay starting URL requests until specified conditions are |
47 // met. | 47 // met. |
48 class CONTENT_EXPORT ResourceQueue { | 48 class CONTENT_EXPORT ResourceQueue { |
49 public: | 49 public: |
50 typedef std::set<ResourceQueueDelegate*> DelegateSet; | 50 typedef std::set<ResourceQueueDelegate*> DelegateSet; |
51 | 51 |
52 // UI THREAD ONLY ------------------------------------------------------------ | 52 // UI THREAD ONLY ------------------------------------------------------------ |
53 | 53 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // associated request from starting yet. | 96 // associated request from starting yet. |
97 InterestedDelegatesMap interested_delegates_; | 97 InterestedDelegatesMap interested_delegates_; |
98 | 98 |
99 // True when we are shutting down. | 99 // True when we are shutting down. |
100 bool shutdown_; | 100 bool shutdown_; |
101 | 101 |
102 DISALLOW_COPY_AND_ASSIGN(ResourceQueue); | 102 DISALLOW_COPY_AND_ASSIGN(ResourceQueue); |
103 }; | 103 }; |
104 | 104 |
105 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_QUEUE_H_ | 105 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_QUEUE_H_ |
OLD | NEW |