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

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

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 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
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/app_remoting_test_driver_environment.h" 5 #include "remoting/test/app_remoting_test_driver_environment.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 if (!access_token_.empty()) { 52 if (!access_token_.empty()) {
53 return true; 53 return true;
54 } 54 }
55 55
56 if (!base::MessageLoop::current()) { 56 if (!base::MessageLoop::current()) {
57 message_loop_.reset(new base::MessageLoopForIO); 57 message_loop_.reset(new base::MessageLoopForIO);
58 } 58 }
59 59
60 // If a unit test has set |test_refresh_token_store_| then we should use it 60 // If a unit test has set |test_refresh_token_store_| then we should use it
61 // below. Note that we do not want to destroy the test object. 61 // below. Note that we do not want to destroy the test object.
62 scoped_ptr<RefreshTokenStore> temporary_refresh_token_store; 62 std::unique_ptr<RefreshTokenStore> temporary_refresh_token_store;
63 RefreshTokenStore* refresh_token_store = test_refresh_token_store_; 63 RefreshTokenStore* refresh_token_store = test_refresh_token_store_;
64 if (!refresh_token_store) { 64 if (!refresh_token_store) {
65 temporary_refresh_token_store = 65 temporary_refresh_token_store =
66 RefreshTokenStore::OnDisk(user_name_, refresh_token_file_path_); 66 RefreshTokenStore::OnDisk(user_name_, refresh_token_file_path_);
67 refresh_token_store = temporary_refresh_token_store.get(); 67 refresh_token_store = temporary_refresh_token_store.get();
68 } 68 }
69 69
70 // Check to see if we have a refresh token stored for this user. 70 // Check to see if we have a refresh token stored for this user.
71 refresh_token_ = refresh_token_store->FetchRefreshToken(); 71 refresh_token_ = refresh_token_store->FetchRefreshToken();
72 if (refresh_token_.empty()) { 72 if (refresh_token_.empty()) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 base::RunLoop run_loop; 112 base::RunLoop run_loop;
113 113
114 RemoteHostInfoCallback remote_host_info_fetch_callback = base::Bind( 114 RemoteHostInfoCallback remote_host_info_fetch_callback = base::Bind(
115 &AppRemotingTestDriverEnvironment::OnRemoteHostInfoRetrieved, 115 &AppRemotingTestDriverEnvironment::OnRemoteHostInfoRetrieved,
116 base::Unretained(this), run_loop.QuitClosure(), remote_host_info); 116 base::Unretained(this), run_loop.QuitClosure(), remote_host_info);
117 117
118 // If a unit test has set |test_remote_host_info_fetcher_| then we should use 118 // If a unit test has set |test_remote_host_info_fetcher_| then we should use
119 // it below. Note that we do not want to destroy the test object at the end 119 // it below. Note that we do not want to destroy the test object at the end
120 // of the function which is why we have the dance below. 120 // of the function which is why we have the dance below.
121 scoped_ptr<RemoteHostInfoFetcher> temporary_remote_host_info_fetcher; 121 std::unique_ptr<RemoteHostInfoFetcher> temporary_remote_host_info_fetcher;
122 RemoteHostInfoFetcher* remote_host_info_fetcher = 122 RemoteHostInfoFetcher* remote_host_info_fetcher =
123 test_remote_host_info_fetcher_; 123 test_remote_host_info_fetcher_;
124 if (!remote_host_info_fetcher) { 124 if (!remote_host_info_fetcher) {
125 temporary_remote_host_info_fetcher.reset(new RemoteHostInfoFetcher()); 125 temporary_remote_host_info_fetcher.reset(new RemoteHostInfoFetcher());
126 remote_host_info_fetcher = temporary_remote_host_info_fetcher.get(); 126 remote_host_info_fetcher = temporary_remote_host_info_fetcher.get();
127 } 127 }
128 128
129 remote_host_info_fetcher->RetrieveRemoteHostInfo( 129 remote_host_info_fetcher->RetrieveRemoteHostInfo(
130 application_id, access_token_, service_environment_, 130 application_id, access_token_, service_environment_,
131 remote_host_info_fetch_callback); 131 remote_host_info_fetch_callback);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 RemoteHostInfoFetcher* remote_host_info_fetcher) { 221 RemoteHostInfoFetcher* remote_host_info_fetcher) {
222 DCHECK(remote_host_info_fetcher); 222 DCHECK(remote_host_info_fetcher);
223 223
224 test_remote_host_info_fetcher_ = remote_host_info_fetcher; 224 test_remote_host_info_fetcher_ = remote_host_info_fetcher;
225 } 225 }
226 226
227 void AppRemotingTestDriverEnvironment::TearDown() { 227 void AppRemotingTestDriverEnvironment::TearDown() {
228 // If a unit test has set |test_app_remoting_report_issue_request_| then we 228 // If a unit test has set |test_app_remoting_report_issue_request_| then we
229 // should use it below. Note that we do not want to destroy the test object 229 // should use it below. Note that we do not want to destroy the test object
230 // at the end of the function which is why we have the dance below. 230 // at the end of the function which is why we have the dance below.
231 scoped_ptr<AppRemotingReportIssueRequest> temporary_report_issue_request; 231 std::unique_ptr<AppRemotingReportIssueRequest> temporary_report_issue_request;
232 AppRemotingReportIssueRequest* report_issue_request = 232 AppRemotingReportIssueRequest* report_issue_request =
233 test_app_remoting_report_issue_request_; 233 test_app_remoting_report_issue_request_;
234 if (!report_issue_request) { 234 if (!report_issue_request) {
235 temporary_report_issue_request.reset(new AppRemotingReportIssueRequest()); 235 temporary_report_issue_request.reset(new AppRemotingReportIssueRequest());
236 report_issue_request = temporary_report_issue_request.get(); 236 report_issue_request = temporary_report_issue_request.get();
237 } 237 }
238 238
239 for (const auto& kvp : host_ids_to_release_) { 239 for (const auto& kvp : host_ids_to_release_) {
240 std::string application_id = kvp.first; 240 std::string application_id = kvp.first;
241 VLOG(1) << "Releasing hosts for application: " << application_id; 241 VLOG(1) << "Releasing hosts for application: " << application_id;
(...skipping 30 matching lines...) Expand all
272 272
273 access_token_.clear(); 273 access_token_.clear();
274 274
275 AccessTokenCallback access_token_callback = 275 AccessTokenCallback access_token_callback =
276 base::Bind(&AppRemotingTestDriverEnvironment::OnAccessTokenRetrieved, 276 base::Bind(&AppRemotingTestDriverEnvironment::OnAccessTokenRetrieved,
277 base::Unretained(this), run_loop.QuitClosure()); 277 base::Unretained(this), run_loop.QuitClosure());
278 278
279 // If a unit test has set |test_access_token_fetcher_| then we should use it 279 // If a unit test has set |test_access_token_fetcher_| then we should use it
280 // below. Note that we do not want to destroy the test object at the end of 280 // below. Note that we do not want to destroy the test object at the end of
281 // the function which is why we have the dance below. 281 // the function which is why we have the dance below.
282 scoped_ptr<AccessTokenFetcher> temporary_access_token_fetcher; 282 std::unique_ptr<AccessTokenFetcher> temporary_access_token_fetcher;
283 AccessTokenFetcher* access_token_fetcher = test_access_token_fetcher_; 283 AccessTokenFetcher* access_token_fetcher = test_access_token_fetcher_;
284 if (!access_token_fetcher) { 284 if (!access_token_fetcher) {
285 temporary_access_token_fetcher.reset(new AccessTokenFetcher()); 285 temporary_access_token_fetcher.reset(new AccessTokenFetcher());
286 access_token_fetcher = temporary_access_token_fetcher.get(); 286 access_token_fetcher = temporary_access_token_fetcher.get();
287 } 287 }
288 288
289 if (!auth_code.empty()) { 289 if (!auth_code.empty()) {
290 // If the user passed in an authcode, then use it to retrieve an 290 // If the user passed in an authcode, then use it to retrieve an
291 // updated access/refresh token. 291 // updated access/refresh token.
292 access_token_fetcher->GetAccessTokenFromAuthCode(auth_code, 292 access_token_fetcher->GetAccessTokenFromAuthCode(auth_code,
293 access_token_callback); 293 access_token_callback);
294 } else { 294 } else {
295 DCHECK(!refresh_token_.empty()); 295 DCHECK(!refresh_token_.empty());
296 296
297 access_token_fetcher->GetAccessTokenFromRefreshToken(refresh_token_, 297 access_token_fetcher->GetAccessTokenFromRefreshToken(refresh_token_,
298 access_token_callback); 298 access_token_callback);
299 } 299 }
300 300
301 run_loop.Run(); 301 run_loop.Run();
302 302
303 // If we were using an auth_code and received a valid refresh token, 303 // If we were using an auth_code and received a valid refresh token,
304 // then we want to store it locally. If we had an auth code and did not 304 // then we want to store it locally. If we had an auth code and did not
305 // receive a refresh token, then we should let the user know and exit. 305 // receive a refresh token, then we should let the user know and exit.
306 if (!auth_code.empty()) { 306 if (!auth_code.empty()) {
307 if (!refresh_token_.empty()) { 307 if (!refresh_token_.empty()) {
308 // If a unit test has set |test_refresh_token_store_| then we should use 308 // If a unit test has set |test_refresh_token_store_| then we should use
309 // it below. Note that we do not want to destroy the test object. 309 // it below. Note that we do not want to destroy the test object.
310 scoped_ptr<RefreshTokenStore> temporary_refresh_token_store; 310 std::unique_ptr<RefreshTokenStore> temporary_refresh_token_store;
311 RefreshTokenStore* refresh_token_store = test_refresh_token_store_; 311 RefreshTokenStore* refresh_token_store = test_refresh_token_store_;
312 if (!refresh_token_store) { 312 if (!refresh_token_store) {
313 temporary_refresh_token_store = 313 temporary_refresh_token_store =
314 RefreshTokenStore::OnDisk(user_name_, refresh_token_file_path_); 314 RefreshTokenStore::OnDisk(user_name_, refresh_token_file_path_);
315 refresh_token_store = temporary_refresh_token_store.get(); 315 refresh_token_store = temporary_refresh_token_store.get();
316 } 316 }
317 317
318 if (!refresh_token_store->StoreRefreshToken(refresh_token_)) { 318 if (!refresh_token_store->StoreRefreshToken(refresh_token_)) {
319 // If we failed to persist the refresh token, then we should let the 319 // If we failed to persist the refresh token, then we should let the
320 // user sort out the issue before continuing. 320 // user sort out the issue before continuing.
(...skipping 30 matching lines...) Expand all
351 const RemoteHostInfo& retrieved_remote_host_info) { 351 const RemoteHostInfo& retrieved_remote_host_info) {
352 DCHECK(remote_host_info); 352 DCHECK(remote_host_info);
353 353
354 *remote_host_info = retrieved_remote_host_info; 354 *remote_host_info = retrieved_remote_host_info;
355 355
356 done_closure.Run(); 356 done_closure.Run();
357 } 357 }
358 358
359 } // namespace test 359 } // namespace test
360 } // namespace remoting 360 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/test/app_remoting_test_driver_environment.h ('k') | remoting/test/app_remoting_test_driver_environment_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698