Page Speed Optimization Libraries  1.3.25.1
net/instaweb/http/public/log_record.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2012 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_HTTP_PUBLIC_LOG_RECORD_H_
00020 #define NET_INSTAWEB_HTTP_PUBLIC_LOG_RECORD_H_
00021 
00022 #include "net/instaweb/http/public/logging_proto.h"
00023 #include "net/instaweb/util/public/basictypes.h"
00024 #include "net/instaweb/util/public/gtest_prod.h"
00025 #include "net/instaweb/util/public/scoped_ptr.h"
00026 #include "net/instaweb/util/public/string.h"
00027 
00031 
00032 
00033 namespace net_instaweb {
00034 
00035 class AbstractMutex;
00036 
00050 
00053 class LogRecord  {
00054  public:
00057   explicit LogRecord(AbstractMutex* mutex);
00058   virtual ~LogRecord();
00059 
00062   void LogAppliedRewriter(const char* rewriter_id);
00063 
00068   GoogleString AppliedRewritersString();
00069 
00074   RewriterInfo* NewRewriterInfo(const char* rewriter_id);
00075 
00078   void SetRewriterLoggingStatus(RewriterInfo* rewriter_info, int status);
00079 
00082   virtual LoggingInfo* logging_info();
00083 
00085   void SetIsHtml(bool is_html);
00086 
00088   int AddPropertyCohortInfo(const GoogleString& cohort);
00089 
00092   void AddFoundPropertyToCohortInfo(int index, const GoogleString& property);
00093 
00096   void SetCacheStatusForCohortInfo(int index, bool found, int key_state);
00097 
00100   void SetDeviceAndCacheTypeForCohortInfo(
00101       int index, int device_type, int cache_type);
00102 
00106   void SetBlinkRequestFlow(int flow);
00107   void SetIsOriginalResourceCacheable(bool cacheable);
00108   void SetTimingRequestStartMs(int64 ms);
00109   void SetTimingHeaderFetchMs(int64 ms);
00110   void SetTimingFetchMs(int64 ms);
00111   int64 GetTimingFetchMs();
00112   void SetTimingProcessingTimeMs(int64 ms);
00119   void UpdateTimingInfoWithFetchStartTime(int64 start_time_ms);
00120 
00122   void SetBlinkInfo(const GoogleString& user_agent);
00123 
00125   void LogImageRewriteActivity(
00126       const char* id,
00127       int status,
00128       bool is_image_inlined,
00129       bool is_critical_image,
00130       bool try_low_res_src_insertion,
00131       bool low_res_src_inserted,
00132       int low_res_data_size);
00133 
00134   void LogJsDisableFilter(const char* id, int status,
00135                           bool has_pagespeed_no_defer);
00136 
00139   bool WriteLog();
00140 
00143   AbstractMutex* mutex() { return mutex_.get(); }
00144 
00147   void SetRewriterInfoMaxSize(int x);
00148 
00149  protected:
00154   LogRecord();
00155 
00156   void set_mutex(AbstractMutex* m);
00157 
00160   virtual void LogAppliedRewriterImpl(const char* rewriter_id);
00161   virtual RewriterInfo* NewRewriterInfoImpl(
00162       const char* rewriter_id, int status);
00164   virtual void SetBlinkInfoImpl(const GoogleString& user_agent) {}
00167   virtual bool WriteLogImpl() { return true; }
00168 
00169  private:
00171   void InitLogging();
00172 
00173   scoped_ptr<LoggingInfo> logging_info_;
00174 
00177   scoped_ptr<AbstractMutex> mutex_;
00178 
00180   int rewriter_info_max_size_;
00181 
00182   DISALLOW_COPY_AND_ASSIGN(LogRecord);
00183 };
00184 
00185 }  
00186 
00187 #endif  ///< NET_INSTAWEB_HTTP_PUBLIC_LOG_RECORD_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines