Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 REMOTING_TEST_REFRESH_TOKEN_STORAGE_H_ | |
| 6 #define REMOTING_TEST_REFRESH_TOKEN_STORAGE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 namespace remoting { | |
| 11 namespace test { | |
| 12 | |
| 13 // This interface is used to allow classes which use this functionality to | |
| 14 // remove the file system dependency for testing. | |
|
Wez
2015/02/13 03:01:55
See elsewhere re comment style. Sounds like this i
joedow
2015/02/14 02:31:29
Done.
| |
| 15 class RefreshTokenStorageInterface { | |
|
Wez
2015/02/13 03:01:55
It's traditional in Chromium to call this e.g. Ref
joedow
2015/02/14 02:31:29
Done.
Wez
2015/02/19 22:00:22
Doesn't look like this actually got done. ;)
| |
| 16 public: | |
| 17 RefreshTokenStorageInterface() {} | |
| 18 virtual ~RefreshTokenStorageInterface() {} | |
| 19 | |
| 20 virtual std::string ReadRefreshTokenFromDisk( | |
| 21 const std::string& user_name) = 0; | |
| 22 virtual bool WriteRefreshTokenToDisk( | |
| 23 const std::string& user_name, | |
| 24 const std::string& refresh_token) = 0; | |
| 25 }; | |
| 26 | |
| 27 // This is the implementation of the interface above, it provides functionality | |
| 28 // to write a refresh token to a local folder on disk and read it back during | |
| 29 // subsequent tool runs. | |
| 30 class RefreshTokenStorage : public RefreshTokenStorageInterface { | |
|
Wez
2015/02/13 03:01:55
I'd suggest moving this concrete implementation in
joedow
2015/02/14 02:31:29
Done.
| |
| 31 public: | |
| 32 RefreshTokenStorage() {} | |
| 33 ~RefreshTokenStorage() override {} | |
| 34 | |
| 35 // Reads the refresh token from a file in a user unique directory if it exists | |
| 36 // and returns the refresh token value if successful or empty string if not. | |
| 37 std::string ReadRefreshTokenFromDisk( | |
| 38 const std::string& user_name) override; | |
| 39 | |
| 40 // Stores the given refresh_token in a folder on the user's local disk. It | |
| 41 // will create the directory and file if they do not exist and set permissions | |
| 42 // on the local file so that it is only readable by the current user. Returns | |
| 43 // true if the token was successfully written otherwise false. | |
| 44 bool WriteRefreshTokenToDisk( | |
| 45 const std::string& user_name, | |
| 46 const std::string& refresh_token) override; | |
| 47 }; | |
| 48 | |
| 49 } // namespace test | |
| 50 } // namespace remoting | |
| 51 | |
| 52 #endif // REMOTING_TEST_REFRESH_TOKEN_STORAGE_H_ | |
| OLD | NEW |