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

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

Issue 2376403004: Store Origin-Trial tokens to ServiceWorkerDataBase (Closed)
Patch Set: fix comment Created 4 years, 2 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>
9 #include <memory>
8 #include <string> 10 #include <string>
11 #include <vector>
9 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
10 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
11 #include "url/origin.h" 14 #include "url/origin.h"
12 15
13 namespace blink { 16 namespace blink {
14 enum class WebOriginTrialTokenStatus; 17 enum class WebOriginTrialTokenStatus;
15 } 18 }
16 19
17 namespace net { 20 namespace net {
18 class HttpResponseHeaders; 21 class HttpResponseHeaders;
19 class URLRequest; 22 class URLRequest;
20 } 23 }
21 24
22 namespace content { 25 namespace content {
23 26
24 namespace TrialTokenValidator { 27 namespace TrialTokenValidator {
25 28
29 using FeatureToTokensMap = std::map<std::string /* feature_name */,
30 std::vector<std::string /* token */>>;
31
26 // If token validates, |*feature_name| is set to the name of the feature the 32 // If token validates, |*feature_name| is set to the name of the feature the
27 // token enables. 33 // token enables.
28 // This method is thread-safe. 34 // This method is thread-safe.
29 CONTENT_EXPORT blink::WebOriginTrialTokenStatus ValidateToken( 35 CONTENT_EXPORT blink::WebOriginTrialTokenStatus ValidateToken(
30 const std::string& token, 36 const std::string& token,
31 const url::Origin& origin, 37 const url::Origin& origin,
32 std::string* feature_name); 38 std::string* feature_name);
33 39
34 CONTENT_EXPORT bool RequestEnablesFeature(const net::URLRequest* request, 40 CONTENT_EXPORT bool RequestEnablesFeature(const net::URLRequest* request,
35 base::StringPiece feature_name); 41 base::StringPiece feature_name);
36 42
37 CONTENT_EXPORT bool RequestEnablesFeature( 43 CONTENT_EXPORT bool RequestEnablesFeature(
38 const GURL& request_url, 44 const GURL& request_url,
39 const net::HttpResponseHeaders* response_headers, 45 const net::HttpResponseHeaders* response_headers,
40 base::StringPiece feature_name); 46 base::StringPiece feature_name);
41 47
48 CONTENT_EXPORT std::unique_ptr<FeatureToTokensMap> GetValidTokensFromHeaders(
iclelland 2016/10/12 03:31:39 Can you write a comment for these two methods -- a
horo 2016/10/12 04:13:14 Done.
49 const url::Origin& origin,
50 const net::HttpResponseHeaders* headers);
51
52 CONTENT_EXPORT std::unique_ptr<FeatureToTokensMap> GetValidTokens(
53 const url::Origin& origin,
54 const FeatureToTokensMap& tokens);
55
42 } // namespace TrialTokenValidator 56 } // namespace TrialTokenValidator
43 57
44 } // namespace content 58 } // namespace content
45 59
46 #endif // CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_VALIDATOR_H_ 60 #endif // CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_VALIDATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698