Page Speed Optimization Libraries  1.9.32.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 
37 namespace experiment {
38 
39 enum ExperimentState {
48  kForceNoExperiment = -2,
51  kExperimentNotSet = -1,
55  kNoExperiment = 0,
56 };
57 
59 const char kExperimentCookie[] = "PageSpeedExperiment";
60 const char kExperimentCookiePrefix[] = "PageSpeedExperiment=";
61 
64 bool GetExperimentCookieState(const RequestHeaders& headers, int* value);
65 
68 void RemoveExperimentCookie(RequestHeaders *headers);
69 
73 void SetExperimentCookie(ResponseHeaders* headers, int state,
74  const StringPiece& url, int64 expiration_time_ms);
75 
77 int DetermineExperimentState(const RewriteOptions* options);
78 
80 bool AnyActiveExperiments(const RewriteOptions* options);
81 
84 GoogleString ExperimentStateToCookieString(int state);
85 
87 int CookieStringToState(const StringPiece& cookie_str);
88 
89 }
90 
91 }
92 
93 #endif