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

Side by Side Diff: content/browser/renderer_host/resource_queue.h

Issue 8296017: Revert 105659 - Delay network requests on startup if any webRequest or webNavigation extensions a... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 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) 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>
(...skipping 10 matching lines...) Expand all
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 CONTENT_EXPORT 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. Use ResourceQueue::StartDelayedRequests to restart requests. 31 // point. To start the delayed request, ResourceQueue::StartDelayedRequest
32 // should be used.
32 virtual bool ShouldDelayRequest( 33 virtual bool ShouldDelayRequest(
33 net::URLRequest* request, 34 net::URLRequest* request,
34 const ResourceDispatcherHostRequestInfo& request_info, 35 const ResourceDispatcherHostRequestInfo& request_info,
35 const GlobalRequestID& request_id) = 0; 36 const GlobalRequestID& request_id) = 0;
36 37
37 // Called just before ResourceQueue shutdown. After that, the delegate 38 // Called just before ResourceQueue shutdown. After that, the delegate
38 // should not use the ResourceQueue. 39 // should not use the ResourceQueue.
39 virtual void WillShutdownResourceQueue() = 0; 40 virtual void WillShutdownResourceQueue() = 0;
40 41
41 protected: 42 protected:
(...skipping 24 matching lines...) Expand all
66 67
67 // Takes care to start the |request| after all delegates allow that. If no 68 // Takes care to start the |request| after all delegates allow that. If no
68 // delegate demands delaying the request it will be started immediately. 69 // delegate demands delaying the request it will be started immediately.
69 void AddRequest(net::URLRequest* request, 70 void AddRequest(net::URLRequest* request,
70 const ResourceDispatcherHostRequestInfo& request_info); 71 const ResourceDispatcherHostRequestInfo& request_info);
71 72
72 // Tells the queue that the net::URLRequest object associated with 73 // Tells the queue that the net::URLRequest object associated with
73 // |request_id| is no longer valid. 74 // |request_id| is no longer valid.
74 void RemoveRequest(const GlobalRequestID& request_id); 75 void RemoveRequest(const GlobalRequestID& request_id);
75 76
76 // A delegate should call StartDelayedRequests when it wants to allow all 77 // A delegate should call StartDelayedRequest when it wants to allow the
77 // its delayed requests to start. If it was the last delegate that required 78 // request to start. If it was the last delegate that demanded the request
78 // a request to be delayed, that request will be started. 79 // to be delayed, the request will be started.
79 void StartDelayedRequests(ResourceQueueDelegate* delegate); 80 void StartDelayedRequest(ResourceQueueDelegate* delegate,
81 const GlobalRequestID& request_id);
80 82
81 private: 83 private:
82 typedef std::map<GlobalRequestID, net::URLRequest*> RequestMap; 84 typedef std::map<GlobalRequestID, net::URLRequest*> RequestMap;
83 typedef std::map<GlobalRequestID, DelegateSet> InterestedDelegatesMap; 85 typedef std::map<GlobalRequestID, DelegateSet> InterestedDelegatesMap;
84 86
85 // The registered delegates. Will not change after the queue has been 87 // The registered delegates. Will not change after the queue has been
86 // initialized. 88 // initialized.
87 DelegateSet delegates_; 89 DelegateSet delegates_;
88 90
89 // Stores net::URLRequest objects associated with each GlobalRequestID. This 91 // Stores net::URLRequest objects associated with each GlobalRequestID. This
90 // helps decoupling the queue from ResourceDispatcherHost. 92 // helps decoupling the queue from ResourceDispatcherHost.
91 RequestMap requests_; 93 RequestMap requests_;
92 94
93 // Maps a GlobalRequestID to the set of delegates that want to prevent the 95 // Maps a GlobalRequestID to the set of delegates that want to prevent the
94 // associated request from starting yet. 96 // associated request from starting yet.
95 InterestedDelegatesMap interested_delegates_; 97 InterestedDelegatesMap interested_delegates_;
96 98
97 // True when we are shutting down. 99 // True when we are shutting down.
98 bool shutdown_; 100 bool shutdown_;
99 101
100 DISALLOW_COPY_AND_ASSIGN(ResourceQueue); 102 DISALLOW_COPY_AND_ASSIGN(ResourceQueue);
101 }; 103 };
102 104
103 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_QUEUE_H_ 105 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698