Page Speed Optimization Libraries  1.9.32.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
add_instrumentation_filter.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_ADD_INSTRUMENTATION_FILTER_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_ADD_INSTRUMENTATION_FILTER_H_
21 
23 #include "pagespeed/kernel/base/basictypes.h"
24 #include "pagespeed/kernel/base/string.h"
25 #include "pagespeed/kernel/base/string_util.h"
26 
27 namespace net_instaweb {
28 
29 class HtmlElement;
30 class RewriteDriver;
31 class Statistics;
32 class Variable;
33 
36  public:
37  static const char kLoadTag[];
38  static const char kUnloadTag[];
39  static GoogleString* kUnloadScriptFormatXhtml;
40  static GoogleString* kTailScriptFormatXhtml;
41 
43  static const char kInstrumentationScriptAddedCount[];
44 
45  explicit AddInstrumentationFilter(RewriteDriver* driver);
46  virtual ~AddInstrumentationFilter();
47 
48  static void InitStats(Statistics* statistics);
49 
50  virtual void StartDocumentImpl();
51  virtual void EndDocument();
52  virtual void StartElementImpl(HtmlElement* element);
53  virtual void EndElementImpl(HtmlElement* element);
54  virtual const char* Name() const { return "AddInstrumentation"; }
55 
56  protected:
57  virtual void DetermineEnabled(GoogleString* disabled_reason);
58 
61 
62  private:
64  GoogleString GetScriptJs(StringPiece event);
65 
68  void AddHeadScript(HtmlElement* element);
69 
70  bool found_head_;
71  bool added_head_script_;
72  bool added_unload_script_;
73 
74  DISALLOW_COPY_AND_ASSIGN(AddInstrumentationFilter);
75 };
76 
77 }
78 
79 #endif
Definition: common_filter.h:48
Variable * instrumentation_script_added_count_
The total number of times instrumentation script is added.
Definition: add_instrumentation_filter.h:60
static const char kInstrumentationScriptAddedCount[]
Counters.
Definition: add_instrumentation_filter.h:43
Definition: rewrite_driver.h:98
Injects javascript instrumentation for monitoring page-rendering time.
Definition: add_instrumentation_filter.h:35