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

Side by Side Diff: content/browser/experiments/api_key.h

Issue 1521063003: Add API Key parsing for experimental APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_EXPERIMENTS_API_KEY_H_
6 #define CONTENT_BROWSER_EXPERIMENTS_API_KEY_H_
7
8 #include <string>
9
10 #include "base/time/time.h"
11 #include "content/common/content_export.h"
12 #include "url/gurl.h"
13
14 namespace content {
15
16 class ApiKeyTest;
chasej 2015/12/15 19:43:41 It doesn't look like this is needed. I'm guessing
iclelland 2015/12/15 21:22:24 Yep. Done.
17
18 // The Experimental Framework (EF) provides limited access to experimental APIs,
19 // on a per-origin basis. This class defines the API key data structure, used
20 // to securely provide access to an experimental API.
21 //
22 // Experimental APIs are defined by string names, provided by the implementers.
23 // The EF code does not maintain an enum or constant list for experiment names.
24 // Instead, the EF validates the name provided by the API implementation against
25 // any provided API keys.
26 // TODO(chasej): Link to documentation, or provide more detail on keys, .etc
27 class CONTENT_EXPORT ApiKey {
28 public:
29 ~ApiKey();
30
31 // Returns a key object if the string represents a well-formed key, or
32 // nullptr otherwise.
33 static scoped_ptr<ApiKey> Parse(const std::string&);
34
35 // Returns true if this API key has a valid signature, and has not expired.
36 bool IsValidNow(const base::Time& now) const;
37
38 std::string signature() { return signature_; }
39 std::string data() { return data_; }
40 GURL origin() { return origin_; }
41 std::string api_name() { return api_name_; }
42 uint64_t expiry() { return expiry_; }
chasej 2015/12/15 19:43:41 Should this have a comment to indicate the date fo
iclelland 2015/12/15 21:22:24 Done. Added explanatory comments to all member var
43
44 private:
45 ApiKey();
46 ApiKey(const std::string& signature,
47 const std::string& data,
48 const GURL& origin,
49 const std::string& api_name,
50 uint64_t expiry);
51
52 std::string signature_;
53 std::string data_;
54 GURL origin_;
55 std::string api_name_;
56 uint64_t expiry_;
57 };
58
59 } // namespace
60 #endif // CONTENT_BROWSER_EXPERIMENTS_API_KEY_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/experiments/api_key.cc » ('j') | content/browser/experiments/api_key.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698