Chromium Code Reviews| Index: components/os_crypt/key_storage_mock.cc |
| diff --git a/components/os_crypt/key_storage_mock.cc b/components/os_crypt/key_storage_mock.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ff10b137a39f3ea7fcc2c04ad299e8f8c66f1f1f |
| --- /dev/null |
| +++ b/components/os_crypt/key_storage_mock.cc |
| @@ -0,0 +1,28 @@ |
| +// Copyright 2016 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. |
| + |
| +#include <components/os_crypt/key_storage_mock.h> |
|
Lei Zhang
2016/05/18 22:38:15
Yse quotes.
cfroussios
2016/05/19 21:18:18
Done.
|
| + |
| +#include "base/base64.h" |
| +#include "base/rand_util.h" |
| + |
| +KeyStorageMock::KeyStorageMock(std::string in_key) : key_(std::move(in_key)) {} |
| + |
| +std::string KeyStorageMock::GetKey() { |
| + if (key_.empty()) |
| + base::Base64Encode(base::RandBytesAsString(128 / 8), &key_); |
|
Lei Zhang
2016/05/18 22:38:15
Ditto, is "128 / 8" necessary?
cfroussios
2016/05/19 21:18:18
Done.
Lei Zhang
2016/05/19 22:45:38
Wait, you kept it in the other place where I asked
cfroussios
2016/05/20 16:44:52
Done.
|
| + return key_; |
| +} |
| + |
| +bool KeyStorageMock::Init() { |
| + return true; |
| +} |
| + |
| +void KeyStorageMock::ResetTo(std::string new_key) { |
|
Lei Zhang
2016/05/18 22:38:15
How about making the parameter a base::StringPiece
cfroussios
2016/05/19 21:18:18
Done.
|
| + key_ = std::move(new_key); |
| +} |
| + |
| +std::string* KeyStorageMock::GetKeyPtr() { |
| + return &key_; |
| +} |