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

Unified Diff: remoting/test/refresh_token_storage.h

Issue 880273006: Adding the AccessTokenFetcher and Environment class to the app remoting test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing some lint/readability errors Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: remoting/test/refresh_token_storage.h
diff --git a/remoting/test/refresh_token_storage.h b/remoting/test/refresh_token_storage.h
new file mode 100644
index 0000000000000000000000000000000000000000..c25fa6f38608c3b091a155c50388e00e5daad624
--- /dev/null
+++ b/remoting/test/refresh_token_storage.h
@@ -0,0 +1,52 @@
+// 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 REMOTING_TEST_REFRESH_TOKEN_STORAGE_H_
+#define REMOTING_TEST_REFRESH_TOKEN_STORAGE_H_
+
+#include <string>
+
+namespace remoting {
+namespace test {
+
+// This interface is used to allow classes which use this functionality to
+// 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.
+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. ;)
+ public:
+ RefreshTokenStorageInterface() {}
+ virtual ~RefreshTokenStorageInterface() {}
+
+ virtual std::string ReadRefreshTokenFromDisk(
+ const std::string& user_name) = 0;
+ virtual bool WriteRefreshTokenToDisk(
+ const std::string& user_name,
+ const std::string& refresh_token) = 0;
+};
+
+// This is the implementation of the interface above, it provides functionality
+// to write a refresh token to a local folder on disk and read it back during
+// subsequent tool runs.
+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.
+ public:
+ RefreshTokenStorage() {}
+ ~RefreshTokenStorage() override {}
+
+ // Reads the refresh token from a file in a user unique directory if it exists
+ // and returns the refresh token value if successful or empty string if not.
+ std::string ReadRefreshTokenFromDisk(
+ const std::string& user_name) override;
+
+ // Stores the given refresh_token in a folder on the user's local disk. It
+ // will create the directory and file if they do not exist and set permissions
+ // on the local file so that it is only readable by the current user. Returns
+ // true if the token was successfully written otherwise false.
+ bool WriteRefreshTokenToDisk(
+ const std::string& user_name,
+ const std::string& refresh_token) override;
+};
+
+} // namespace test
+} // namespace remoting
+
+#endif // REMOTING_TEST_REFRESH_TOKEN_STORAGE_H_

Powered by Google App Engine
This is Rietveld 408576698