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

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

Issue 6532073: Move core pieces of browser\renderer_host to src\content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 CHROME_BROWSER_RENDERER_HOST_RESOURCE_QUEUE_H_ 5 #ifndef CHROME_BROWSER_RENDERER_HOST_RESOURCE_QUEUE_H_
6 #define CHROME_BROWSER_RENDERER_HOST_RESOURCE_QUEUE_H_ 6 #define CHROME_BROWSER_RENDERER_HOST_RESOURCE_QUEUE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 // TODO(jam): remove this file when all files have been converted.
10 #include <set> 10 #include "content/browser/renderer_host/resource_queue.h"
11
12 #include "base/basictypes.h"
13
14 namespace net {
15 class URLRequest;
16 } // namespace net
17
18 class ResourceDispatcherHostRequestInfo;
19 struct GlobalRequestID;
20
21 // Makes decisions about delaying or not each net::URLRequest in the queue.
22 // All methods are called on the IO thread.
23 class ResourceQueueDelegate {
24 public:
25 // Should return true if it wants the |request| to not be started at this
26 // point. To start the delayed request, ResourceQueue::StartDelayedRequest
27 // should be used.
28 virtual bool ShouldDelayRequest(
29 net::URLRequest* request,
30 const ResourceDispatcherHostRequestInfo& request_info,
31 const GlobalRequestID& request_id) = 0;
32
33 // Called just before ResourceQueue shutdown. After that, the delegate
34 // should not use the ResourceQueue.
35 virtual void WillShutdownResourceQueue() = 0;
36
37 protected:
38 virtual ~ResourceQueueDelegate();
39 };
40
41 // Makes it easy to delay starting URL requests until specified conditions are
42 // met.
43 class ResourceQueue {
44 public:
45 typedef std::set<ResourceQueueDelegate*> DelegateSet;
46
47 // UI THREAD ONLY ------------------------------------------------------------
48
49 // Construct the queue. You must initialize it using Initialize.
50 ResourceQueue();
51 ~ResourceQueue();
52
53 // Initialize the queue with set of delegates it should ask for each incoming
54 // request.
55 void Initialize(const DelegateSet& delegates);
56
57 // IO THREAD ONLY ------------------------------------------------------------
58
59 // Must be called before destroying the queue. No other methods can be called
60 // after that.
61 void Shutdown();
62
63 // Takes care to start the |request| after all delegates allow that. If no
64 // delegate demands delaying the request it will be started immediately.
65 void AddRequest(net::URLRequest* request,
66 const ResourceDispatcherHostRequestInfo& request_info);
67
68 // Tells the queue that the net::URLRequest object associated with
69 // |request_id| is no longer valid.
70 void RemoveRequest(const GlobalRequestID& request_id);
71
72 // A delegate should call StartDelayedRequest when it wants to allow the
73 // request to start. If it was the last delegate that demanded the request
74 // to be delayed, the request will be started.
75 void StartDelayedRequest(ResourceQueueDelegate* delegate,
76 const GlobalRequestID& request_id);
77
78 private:
79 typedef std::map<GlobalRequestID, net::URLRequest*> RequestMap;
80 typedef std::map<GlobalRequestID, DelegateSet> InterestedDelegatesMap;
81
82 // The registered delegates. Will not change after the queue has been
83 // initialized.
84 DelegateSet delegates_;
85
86 // Stores net::URLRequest objects associated with each GlobalRequestID. This
87 // helps decoupling the queue from ResourceDispatcherHost.
88 RequestMap requests_;
89
90 // Maps a GlobalRequestID to the set of delegates that want to prevent the
91 // associated request from starting yet.
92 InterestedDelegatesMap interested_delegates_;
93
94 // True when we are shutting down.
95 bool shutdown_;
96
97 DISALLOW_COPY_AND_ASSIGN(ResourceQueue);
98 };
99 11
100 #endif // CHROME_BROWSER_RENDERER_HOST_RESOURCE_QUEUE_H_ 12 #endif // CHROME_BROWSER_RENDERER_HOST_RESOURCE_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698