17 #ifndef NET_INSTAWEB_SYSTEM_PUBLIC_IN_PLACE_RESOURCE_RECORDER_H_
18 #define NET_INSTAWEB_SYSTEM_PUBLIC_IN_PLACE_RESOURCE_RECORDER_H_
23 #include "net/instaweb/http/public/request_context.h"
24 #include "pagespeed/kernel/base/atomic_int32.h"
25 #include "pagespeed/kernel/base/basictypes.h"
26 #include "pagespeed/kernel/base/string.h"
27 #include "pagespeed/kernel/base/string_util.h"
28 #include "pagespeed/kernel/base/writer.h"
29 #include "pagespeed/kernel/http/http_options.h"
30 #include "pagespeed/kernel/http/request_headers.h"
32 namespace net_instaweb {
36 class ResponseHeaders;
58 const RequestContextPtr& request_context,
59 StringPiece url, StringPiece fragment,
60 const RequestHeaders::Properties& request_properties,
61 int max_response_bytes,
int max_concurrent_recordings,
62 HTTPCache* cache, Statistics* statistics, MessageHandler* handler);
68 static void InitStats(Statistics* statistics);
72 virtual bool Write(
const StringPiece& contents, MessageHandler* handler);
76 virtual bool Flush(MessageHandler* handler) {
return true; }
102 ResponseHeaders* response_headers);
106 void Fail() { failure_ =
true; }
117 const GoogleString& url()
const {
return url_; }
118 MessageHandler* handler() {
return handler_; }
120 bool failed() {
return failure_; }
121 bool limit_active_recordings() {
return max_concurrent_recordings_ != 0; }
123 const HttpOptions& http_options()
const {
return http_options_; }
126 class HTTPValueFetch :
public AsyncFetchUsingWriter {
128 HTTPValueFetch(
const RequestContextPtr& request_context, HTTPValue* value)
129 : AsyncFetchUsingWriter(request_context, value) {}
130 virtual void HandleDone(
bool ) {}
131 virtual void HandleHeadersComplete() {}
134 bool IsIproContentType(ResponseHeaders* response_headers);
136 void DroppedDueToSize();
138 const GoogleString url_;
139 const GoogleString fragment_;
140 const RequestHeaders::Properties request_properties_;
141 const HttpOptions http_options_;
143 int64 max_response_bytes_;
144 const int max_concurrent_recordings_;
146 HTTPValue resource_value_;
147 HTTPValueFetch write_to_resource_value_;
148 InflatingFetch inflating_fetch_;
151 MessageHandler* handler_;
153 Variable* num_resources_;
154 Variable* num_inserted_into_cache_;
155 Variable* num_not_cacheable_;
156 Variable* num_failed_;
157 Variable* num_dropped_due_to_load_;
158 Variable* num_dropped_due_to_size_;
162 static AtomicInt32 active_recordings_;
170 bool full_response_headers_considered_;
173 bool consider_response_headers_called_;
Definition: in_place_resource_recorder.h:43
Definition: in_place_resource_recorder.h:48
HeadersKind
Definition: in_place_resource_recorder.h:45
void ConsiderResponseHeaders(HeadersKind headers_kind, ResponseHeaders *response_headers)
virtual bool Flush(MessageHandler *handler)
Definition: in_place_resource_recorder.h:76
Headers are complete.
Definition: in_place_resource_recorder.h:51
InPlaceResourceRecorder(const RequestContextPtr &request_context, StringPiece url, StringPiece fragment, const RequestHeaders::Properties &request_properties, int max_response_bytes, int max_concurrent_recordings, HTTPCache *cache, Statistics *statistics, MessageHandler *handler)
void Fail()
Definition: in_place_resource_recorder.h:106
virtual ~InPlaceResourceRecorder()
void DoneAndSetHeaders(ResponseHeaders *response_headers)
virtual bool Write(const StringPiece &contents, MessageHandler *handler)
Definition: http_cache.h:46