Page Speed Optimization Libraries
1.3.25.1
|
00001 /* 00002 * Copyright 2011 Google Inc. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http:///www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00018 00019 #ifndef NET_INSTAWEB_UTIL_PUBLIC_SHARED_MEM_REFERER_STATISTICS_H_ 00020 #define NET_INSTAWEB_UTIL_PUBLIC_SHARED_MEM_REFERER_STATISTICS_H_ 00021 00022 #include <cstddef> 00023 00024 #include "net/instaweb/util/public/scoped_ptr.h" 00025 #include "net/instaweb/util/public/string.h" 00026 #include "net/instaweb/util/public/string_util.h" 00027 00028 namespace net_instaweb { 00029 00030 class AbstractSharedMem; 00031 class GoogleUrl; 00032 class MessageHandler; 00033 class SharedDynamicStringMap; 00034 class Writer; 00035 00041 class SharedMemRefererStatistics { 00042 public: 00044 SharedMemRefererStatistics(size_t number_of_strings, 00045 size_t average_string_length, 00046 AbstractSharedMem* shm_runtime, 00047 const GoogleString& filename_prefix, 00048 const GoogleString& filename_suffix); 00049 virtual ~SharedMemRefererStatistics(); 00050 00052 bool InitSegment(bool parent, MessageHandler* message_handler); 00053 00057 void LogPageRequestWithoutReferer(const GoogleUrl& target); 00058 void LogPageRequestWithReferer(const GoogleUrl& target, 00059 const GoogleUrl& referer); 00060 void LogResourceRequestWithReferer(const GoogleUrl& target, 00061 const GoogleUrl& referer); 00062 00063 int GetNumberOfVisitsForUrl(const GoogleUrl& url); 00064 int GetNumberOfReferencesFromUrlToPage(const GoogleUrl& from_url, 00065 const GoogleUrl& to_url); 00066 int GetNumberOfReferencesFromUrlToDivLocation( 00067 const GoogleUrl& from_url, const GoogleString& div_location); 00068 int GetNumberOfReferencesFromUrlToResource(const GoogleUrl& from_url, 00069 const GoogleUrl& resource_url); 00070 00072 static GoogleString GetDivLocationFromUrl(const GoogleUrl& url); 00073 00075 void GlobalCleanup(MessageHandler* message_handler); 00076 00115 void DumpFast(Writer* writer, MessageHandler* message_handler); 00116 void DumpSimple(Writer* writer, MessageHandler* message_handler); 00117 void DumpOrganized(Writer* writer, MessageHandler* message_handler); 00118 00120 static const char kParamName[]; 00121 00122 protected: 00124 virtual GoogleString GetEntryStringForUrlString( 00125 const StringPiece& url_string) const; 00128 virtual GoogleString GetEntryStringForDivLocation( 00129 const StringPiece& div_location) const; 00130 00131 private: 00133 GoogleString GetUrlEntryStringForUrl(const GoogleUrl& url) const; 00135 GoogleString GetDivLocationEntryStringForUrl(const GoogleUrl& url) const; 00137 static GoogleString GetEntryForReferedPage(const StringPiece& target, 00138 const StringPiece& referer); 00139 static GoogleString GetEntryForReferedDivLocation(const StringPiece& target, 00140 const StringPiece& referer); 00141 static GoogleString GetEntryForVisitedPage(const StringPiece& target); 00142 static GoogleString GetEntryForReferedResource(const StringPiece& target, 00143 const StringPiece& referer); 00147 GoogleString DecodeEntry(const StringPiece& entry, 00148 GoogleString* target, 00149 GoogleString* referer) const; 00150 GoogleString DecodeEntry(const StringPiece& entry) const; 00151 00153 void LogPageRequest(const GoogleUrl& target, GoogleString* target_string); 00154 00155 scoped_ptr<SharedDynamicStringMap> shared_dynamic_string_map_; 00156 }; 00157 00158 } 00159 00160 #endif ///< NET_INSTAWEB_UTIL_PUBLIC_SHARED_MEM_REFERER_STATISTICS_H_