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

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

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

Powered by Google App Engine
This is Rietveld 408576698