Chromium Code Reviews| Index: content/browser/experiments/api_key.h |
| diff --git a/content/browser/experiments/api_key.h b/content/browser/experiments/api_key.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c8b61f7fe507a8967695a35e90f1cba116fbb7e8 |
| --- /dev/null |
| +++ b/content/browser/experiments/api_key.h |
| @@ -0,0 +1,60 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_EXPERIMENTS_API_KEY_H_ |
| +#define CONTENT_BROWSER_EXPERIMENTS_API_KEY_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/time/time.h" |
| +#include "content/common/content_export.h" |
| +#include "url/gurl.h" |
| + |
| +namespace content { |
| + |
| +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.
|
| + |
| +// The Experimental Framework (EF) provides limited access to experimental APIs, |
| +// on a per-origin basis. This class defines the API key data structure, used |
| +// to securely provide access to an experimental API. |
| +// |
| +// Experimental APIs are defined by string names, provided by the implementers. |
| +// The EF code does not maintain an enum or constant list for experiment names. |
| +// Instead, the EF validates the name provided by the API implementation against |
| +// any provided API keys. |
| +// TODO(chasej): Link to documentation, or provide more detail on keys, .etc |
| +class CONTENT_EXPORT ApiKey { |
| + public: |
| + ~ApiKey(); |
| + |
| + // Returns a key object if the string represents a well-formed key, or |
| + // nullptr otherwise. |
| + static scoped_ptr<ApiKey> Parse(const std::string&); |
| + |
| + // Returns true if this API key has a valid signature, and has not expired. |
| + bool IsValidNow(const base::Time& now) const; |
| + |
| + std::string signature() { return signature_; } |
| + std::string data() { return data_; } |
| + GURL origin() { return origin_; } |
| + std::string api_name() { return api_name_; } |
| + 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
|
| + |
| + private: |
| + ApiKey(); |
| + ApiKey(const std::string& signature, |
| + const std::string& data, |
| + const GURL& origin, |
| + const std::string& api_name, |
| + uint64_t expiry); |
| + |
| + std::string signature_; |
| + std::string data_; |
| + GURL origin_; |
| + std::string api_name_; |
| + uint64_t expiry_; |
| +}; |
| + |
| +} // namespace |
| +#endif // CONTENT_BROWSER_EXPERIMENTS_API_KEY_H_ |