Page Speed Optimization Libraries
1.3.25.1
|
00001 // Copyright 2013 Google Inc. 00016 00017 #ifndef NET_INSTAWEB_APACHE_IN_PLACE_RESOURCE_RECORDER_H_ 00018 #define NET_INSTAWEB_APACHE_IN_PLACE_RESOURCE_RECORDER_H_ 00019 00020 #include "net/instaweb/http/public/http_value.h" 00021 #include "net/instaweb/util/public/basictypes.h" 00022 #include "net/instaweb/util/public/scoped_ptr.h" 00023 #include "net/instaweb/util/public/string.h" 00024 #include "net/instaweb/util/public/string_util.h" 00025 #include "net/instaweb/util/public/writer.h" 00026 00027 namespace net_instaweb { 00028 00029 class HTTPCache; 00030 class MessageHandler; 00031 class RequestHeaders; 00032 class ResponseHeaders; 00033 class Statistics; 00034 class Variable; 00035 00039 class InPlaceResourceRecorder : public Writer { 00040 public: 00044 InPlaceResourceRecorder(StringPiece url, RequestHeaders* request_headers, 00045 bool respect_vary, HTTPCache* cache, 00046 Statistics* statistics, MessageHandler* handler); 00047 virtual ~InPlaceResourceRecorder(); 00048 00049 static void InitStats(Statistics* statistics); 00050 00051 virtual bool Write(const StringPiece& contents, MessageHandler* handler); 00052 virtual bool Flush(MessageHandler* handler); 00053 00055 void Fail() { success_ = false; } 00056 00063 void DoneAndSetHeaders(ResponseHeaders* response_headers); 00064 00065 const GoogleString& url() const { return url_; } 00066 MessageHandler* handler() { return handler_; } 00067 00068 private: 00069 const GoogleString url_; 00070 const scoped_ptr<RequestHeaders> request_headers_; 00071 const bool respect_vary_; 00072 00073 HTTPValue resource_value_; 00074 bool success_; 00075 00076 HTTPCache* cache_; 00077 MessageHandler* handler_; 00078 00079 Variable* num_resources_; 00080 Variable* num_inserted_into_cache_; 00081 Variable* num_not_cacheable_; 00082 Variable* num_failed_; 00083 00084 DISALLOW_COPY_AND_ASSIGN(InPlaceResourceRecorder); 00085 }; 00086 00087 } 00088 00089 #endif ///< NET_INSTAWEB_APACHE_IN_PLACE_RESOURCE_RECORDER_H_