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

Side by Side Diff: remoting/test/refresh_token_store.cc

Issue 1037723003: Updated the formatting for the app remoting test driver files using clag-format for consistency. N… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « remoting/test/mock_access_token_fetcher.cc ('k') | remoting/test/remote_host_info.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/test/refresh_token_store.h" 5 #include "remoting/test/refresh_token_store.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 namespace { 10 namespace {
11 const base::FilePath::CharType kTokenFileName[] = 11 const base::FilePath::CharType kTokenFileName[] =
12 FILE_PATH_LITERAL("refresh_token.txt"); 12 FILE_PATH_LITERAL("refresh_token.txt");
13 const base::FilePath::CharType kRemotingFolder[] = 13 const base::FilePath::CharType kRemotingFolder[] =
14 FILE_PATH_LITERAL("remoting"); 14 FILE_PATH_LITERAL("remoting");
15 const base::FilePath::CharType kRefreshTokenStoreFolder[] = 15 const base::FilePath::CharType kRefreshTokenStoreFolder[] =
16 FILE_PATH_LITERAL("refresh_token_store"); 16 FILE_PATH_LITERAL("refresh_token_store");
17 17
18 // Returns the FilePath of the token store file for |user_name|. 18 // Returns the FilePath of the token store file for |user_name|.
19 base::FilePath GetRefreshTokenDirPath(const std::string& user_name) { 19 base::FilePath GetRefreshTokenDirPath(const std::string& user_name) {
20 base::FilePath refresh_token_dir_path; 20 base::FilePath refresh_token_dir_path;
21 if (!GetTempDir(&refresh_token_dir_path)) { 21 if (!GetTempDir(&refresh_token_dir_path)) {
22 LOG(WARNING) << "Failed to retrieve temporary directory path."; 22 LOG(WARNING) << "Failed to retrieve temporary directory path.";
23 return base::FilePath(); 23 return base::FilePath();
24 } 24 }
25 25
26 refresh_token_dir_path = refresh_token_dir_path.Append(kRemotingFolder); 26 refresh_token_dir_path = refresh_token_dir_path.Append(kRemotingFolder);
27 refresh_token_dir_path = refresh_token_dir_path.Append( 27 refresh_token_dir_path =
28 kRefreshTokenStoreFolder); 28 refresh_token_dir_path.Append(kRefreshTokenStoreFolder);
29 29
30 // We call AppendASCII here our user_name is a std::string but wide strings 30 // We call AppendASCII here our user_name is a std::string but wide strings
31 // are used on WIN platforms. ApendASCII will convert our std::string into 31 // are used on WIN platforms. ApendASCII will convert our std::string into
32 // the correct type for windows platforms. 32 // the correct type for windows platforms.
33 refresh_token_dir_path = refresh_token_dir_path.AppendASCII(user_name); 33 refresh_token_dir_path = refresh_token_dir_path.AppendASCII(user_name);
34 34
35 return refresh_token_dir_path; 35 return refresh_token_dir_path;
36 } 36 }
37 37
38 } // namespace 38 } // namespace
(...skipping 12 matching lines...) Expand all
51 std::string FetchRefreshToken() override; 51 std::string FetchRefreshToken() override;
52 bool StoreRefreshToken(const std::string& refresh_token) override; 52 bool StoreRefreshToken(const std::string& refresh_token) override;
53 53
54 private: 54 private:
55 // Used to access the user specific token file. 55 // Used to access the user specific token file.
56 std::string user_name_; 56 std::string user_name_;
57 57
58 DISALLOW_COPY_AND_ASSIGN(RefreshTokenStoreOnDisk); 58 DISALLOW_COPY_AND_ASSIGN(RefreshTokenStoreOnDisk);
59 }; 59 };
60 60
61 RefreshTokenStoreOnDisk::RefreshTokenStoreOnDisk(const std::string user_name) : 61 RefreshTokenStoreOnDisk::RefreshTokenStoreOnDisk(const std::string user_name)
62 user_name_(user_name) {} 62 : user_name_(user_name) {
63 }
63 64
64 RefreshTokenStoreOnDisk::~RefreshTokenStoreOnDisk() {} 65 RefreshTokenStoreOnDisk::~RefreshTokenStoreOnDisk() {
66 }
65 67
66 std::string RefreshTokenStoreOnDisk::FetchRefreshToken() { 68 std::string RefreshTokenStoreOnDisk::FetchRefreshToken() {
67 base::FilePath token_dir_path(GetRefreshTokenDirPath(user_name_)); 69 base::FilePath token_dir_path(GetRefreshTokenDirPath(user_name_));
68 DCHECK(!token_dir_path.empty()); 70 DCHECK(!token_dir_path.empty());
69 71
70 DVLOG(2) << "Reading token from path: " << token_dir_path.value(); 72 DVLOG(2) << "Reading token from path: " << token_dir_path.value();
71 base::FilePath token_file_path(token_dir_path.Append(kTokenFileName)); 73 base::FilePath token_file_path(token_dir_path.Append(kTokenFileName));
72 74
73 std::string refresh_token; 75 std::string refresh_token;
74 if (!base::ReadFileToString(token_file_path, &refresh_token)) { 76 if (!base::ReadFileToString(token_file_path, &refresh_token)) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 126
125 return true; 127 return true;
126 #else 128 #else
127 NOTIMPLEMENTED(); 129 NOTIMPLEMENTED();
128 return false; 130 return false;
129 #endif // OS_POSIX 131 #endif // OS_POSIX
130 } 132 }
131 133
132 scoped_ptr<RefreshTokenStore> RefreshTokenStore::OnDisk( 134 scoped_ptr<RefreshTokenStore> RefreshTokenStore::OnDisk(
133 const std::string& user_name) { 135 const std::string& user_name) {
134 return make_scoped_ptr<RefreshTokenStore>(new RefreshTokenStoreOnDisk( 136 return make_scoped_ptr<RefreshTokenStore>(
135 user_name)); 137 new RefreshTokenStoreOnDisk(user_name));
136 } 138 }
137 139
138 } // namespace test 140 } // namespace test
139 } // namespace remoting 141 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/test/mock_access_token_fetcher.cc ('k') | remoting/test/remote_host_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698