19 #ifndef NET_INSTAWEB_HTTP_PUBLIC_RATE_CONTROLLER_H_
20 #define NET_INSTAWEB_HTTP_PUBLIC_RATE_CONTROLLER_H_
26 #include "net/instaweb/util/public/ref_counted_ptr.h"
30 namespace net_instaweb {
39 class UrlAsyncFetcher;
55 static const char kQueuedFetchCount[];
56 static const char kDroppedFetchCount[];
57 static const char kCurrentGlobalFetchQueueSize[];
60 int per_host_outgoing_request_threshold,
61 int per_host_queued_request_threshold,
62 ThreadSystem* thread_system,
63 Statistics* statistics);
69 bool is_shut_down()
const {
return shutdown_.value(); }
73 void Fetch(UrlAsyncFetcher* fetcher,
74 const GoogleString& url,
75 MessageHandler* message_handler,
79 static void InitStats(Statistics* statistics);
84 friend class CustomFetch;
86 typedef RefCountedPtr<HostFetchInfo> HostFetchInfoPtr;
88 typedef std::map<GoogleString, HostFetchInfoPtr*> HostFetchInfoMap;
91 void DeleteFetchInfoIfPossible(
const HostFetchInfoPtr& fetch_info);
94 const int max_global_queue_size_;
96 const int per_host_outgoing_request_threshold_;
98 const int per_host_queued_request_threshold_;
99 ThreadSystem* thread_system_;
102 HostFetchInfoMap fetch_info_map_;
103 scoped_ptr<AbstractMutex> mutex_;
105 TimedVariable* queued_fetch_count_;
106 TimedVariable* dropped_fetch_count_;
109 UpDownCounter* current_global_fetch_queue_size_;
111 AtomicBool shutdown_;
113 DISALLOW_COPY_AND_ASSIGN(RateController);
void ShutDown()
Makes any further fetches quick-fail.
Definition: rate_controller.h:68
Definition: rate_controller.h:53
static void InitStats(Statistics *statistics)
Initializes statistics variables associated with this class.
void Fetch(UrlAsyncFetcher *fetcher, const GoogleString &url, MessageHandler *message_handler, AsyncFetch *fetch)