Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
experiment_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 
23 
24 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_EXPERIMENT_UTIL_H_
25 #define NET_INSTAWEB_REWRITER_PUBLIC_EXPERIMENT_UTIL_H_
26 
30 
31 namespace net_instaweb {
32 
33 class RequestHeaders;
34 class ResponseHeaders;
35 class RewriteOptions;
36 class UserAgentMatcher;
37 
38 namespace experiment {
39 
40 enum ExperimentState {
49  kForceNoExperiment = -2,
52  kExperimentNotSet = -1,
56  kNoExperiment = 0,
57 };
58 
60 const char kExperimentCookie[] = "PageSpeedExperiment";
61 const char kExperimentCookiePrefix[] = "PageSpeedExperiment=";
62 
65 bool GetExperimentCookieState(const RequestHeaders& headers, int* value);
66 
69 void RemoveExperimentCookie(RequestHeaders *headers);
70 
74 void SetExperimentCookie(ResponseHeaders* headers, int state,
75  const StringPiece& url, int64 expiration_time_ms);
76 
78 int DetermineExperimentState(const RewriteOptions* options,
79  const RequestHeaders& headers,
80  const UserAgentMatcher& matcher);
81 
83 bool AnyActiveExperiments(const RewriteOptions* options);
84 
87 GoogleString ExperimentStateToCookieString(int state);
88 
90 int CookieStringToState(const StringPiece& cookie_str);
91 
92 }
93 
94 }
95 
96 #endif
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24