Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: content/common/origin_trials/trial_token_validator.h

Issue 2555333006: Deflake origin trial token validator tests (Closed)
Patch Set: Switch WrapUnique to MakeUnique Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_VALIDATOR_H_ 5 #ifndef CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_VALIDATOR_H_
6 #define CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_VALIDATOR_H_ 6 #define CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_VALIDATOR_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
13 #include "base/time/time.h"
13 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
14 #include "url/origin.h" 15 #include "url/origin.h"
15 16
16 namespace blink { 17 namespace blink {
17 enum class WebOriginTrialTokenStatus; 18 enum class WebOriginTrialTokenStatus;
18 } 19 }
19 20
20 namespace net { 21 namespace net {
21 class HttpResponseHeaders; 22 class HttpResponseHeaders;
22 class URLRequest; 23 class URLRequest;
23 } 24 }
24 25
25 namespace content { 26 namespace content {
26 27
27 namespace TrialTokenValidator { 28 namespace TrialTokenValidator {
28 29
29 using FeatureToTokensMap = std::map<std::string /* feature_name */, 30 using FeatureToTokensMap = std::map<std::string /* feature_name */,
30 std::vector<std::string /* token */>>; 31 std::vector<std::string /* token */>>;
31 32
32 // If token validates, |*feature_name| is set to the name of the feature the 33 // If token validates, |*feature_name| is set to the name of the feature the
33 // token enables. 34 // token enables.
34 // This method is thread-safe. 35 // This method is thread-safe.
35 CONTENT_EXPORT blink::WebOriginTrialTokenStatus ValidateToken( 36 CONTENT_EXPORT blink::WebOriginTrialTokenStatus ValidateToken(
36 const std::string& token, 37 const std::string& token,
37 const url::Origin& origin, 38 const url::Origin& origin,
38 std::string* feature_name); 39 std::string* feature_name,
40 base::Time current_time);
39 41
40 CONTENT_EXPORT bool RequestEnablesFeature(const net::URLRequest* request, 42 CONTENT_EXPORT bool RequestEnablesFeature(const net::URLRequest* request,
41 base::StringPiece feature_name); 43 base::StringPiece feature_name,
44 base::Time current_time);
42 45
43 CONTENT_EXPORT bool RequestEnablesFeature( 46 CONTENT_EXPORT bool RequestEnablesFeature(
44 const GURL& request_url, 47 const GURL& request_url,
45 const net::HttpResponseHeaders* response_headers, 48 const net::HttpResponseHeaders* response_headers,
46 base::StringPiece feature_name); 49 base::StringPiece feature_name,
50 base::Time current_time);
47 51
48 // Returns all valid tokens in |headers|. 52 // Returns all valid tokens in |headers|.
49 CONTENT_EXPORT std::unique_ptr<FeatureToTokensMap> GetValidTokensFromHeaders( 53 CONTENT_EXPORT std::unique_ptr<FeatureToTokensMap> GetValidTokensFromHeaders(
50 const url::Origin& origin, 54 const url::Origin& origin,
51 const net::HttpResponseHeaders* headers); 55 const net::HttpResponseHeaders* headers,
56 base::Time current_time);
52 57
53 // Returns all valid tokens in |tokens|. This method is used to re-validate 58 // Returns all valid tokens in |tokens|. This method is used to re-validate
54 // previously stored tokens. 59 // previously stored tokens.
55 CONTENT_EXPORT std::unique_ptr<FeatureToTokensMap> GetValidTokens( 60 CONTENT_EXPORT std::unique_ptr<FeatureToTokensMap> GetValidTokens(
56 const url::Origin& origin, 61 const url::Origin& origin,
57 const FeatureToTokensMap& tokens); 62 const FeatureToTokensMap& tokens,
63 base::Time current_time);
58 64
59 } // namespace TrialTokenValidator 65 } // namespace TrialTokenValidator
60 66
61 } // namespace content 67 } // namespace content
62 68
63 #endif // CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_VALIDATOR_H_ 69 #endif // CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_VALIDATOR_H_
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_version.cc ('k') | content/common/origin_trials/trial_token_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698