Page Speed Optimization Libraries  1.9.32.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
blink_util.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012 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_BLINK_UTIL_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_BLINK_UTIL_H_
21 
22 #include <map>
23 #include <utility>
24 #include <vector>
25 
27 #include "net/instaweb/util/public/json.h"
30 
31 namespace net_instaweb {
32 
33 class AsyncFetch;
34 class GoogleUrl;
35 class HtmlElement;
36 class Panel;
37 class PanelSet;
38 class ServerContext;
39 
40 typedef std::map<GoogleString, const Panel*> PanelIdToSpecMap;
41 typedef std::multimap<GoogleString, std::pair<GoogleString, const int>,
42  StringCompareInsensitive> AttributesToNonCacheableValuesMap;
43 
44 namespace BlinkUtil {
45 
46 const char kContiguous[] = "contiguous";
47 const char kCritical[] = "critical";
48 const char kPanelId[] = "panel-id";
49 const char kImages[] = "images";
50 const char kInstanceHtml[] = "instance_html";
51 const char kStartBodyMarker[] = "<!--GooglePanel **** Start body ****-->";
52 const char kEndBodyTag[] = "</body>";
53 const char kLayoutMarker[] = "<!--GooglePanel **** Layout end ****-->";
54 const char kJsonCachePrefix[] = "json:";
56 const char kBlinkResponseCodePropertyName[] = "blink_last_response_code";
57 const char kXpath[] = "xpath";
59 const char kBlinkCohort[] = "blink";
60 const char kBlinkCriticalLineDataPropertyName[] = "blink_critical_line_data";
61 const char kCacheHtmlRewriterInfo[] = "cache_html";
62 const char kComputeVisibleTextFilterOutputEndMarker[] =
63  "<!--GooglePanel **** Output end ****-->";
64 
66 bool IsBlinkRequest(const GoogleUrl& url,
67  AsyncFetch* async_fetch,
68  const RewriteOptions* options,
69  const char* user_agent,
70  const ServerContext* server_context,
71  RewriteOptions::Filter filter);
72 
75 bool IsJsonEmpty(const Json::Value& json);
76 
78 void ClearArrayIfAllEmpty(Json::Value* json);
79 
82 bool ComputePanels(const PanelSet* panel_set_,
83  PanelIdToSpecMap* panel_id_to_spec);
84 
86 void EscapeString(GoogleString* str);
87 
89 bool StripTrailingNewline(GoogleString* s);
90 
92 void PopulateAttributeToNonCacheableValuesMap(
93  const RewriteOptions* rewrite_options,
94  const GoogleUrl& url,
95  AttributesToNonCacheableValuesMap* attribute_non_cacheable_values_map,
96  std::vector<int>* panel_number_num_instances);
97 
99 int GetPanelNumberForNonCacheableElement(
100  const AttributesToNonCacheableValuesMap& attribute_non_cacheable_values_map,
101  const HtmlElement* element);
102 
104 GoogleString GetPanelId(int panel_number, int instance_number);
105 }
106 
107 }
108 
109 #endif
Filter
Definition: rewrite_options.h:104