| Index: remoting/ios/facade/remoting_service.mm
|
| diff --git a/remoting/ios/facade/remoting_service.mm b/remoting/ios/facade/remoting_service.mm
|
| index 10096f18f6a3a2a0083ddfe0731485ed948b6343..7bf1c2540cc460282ad99a75fbdddec5c20bdafe 100644
|
| --- a/remoting/ios/facade/remoting_service.mm
|
| +++ b/remoting/ios/facade/remoting_service.mm
|
| @@ -18,7 +18,6 @@
|
| #import "remoting/ios/facade/host_list_fetcher.h"
|
| #import "remoting/ios/facade/ios_client_runtime_delegate.h"
|
| #import "remoting/ios/facade/remoting_authentication.h"
|
| -#import "remoting/ios/facade/remoting_service.h"
|
| #import "remoting/ios/keychain_wrapper.h"
|
|
|
| #include "base/i18n/time_formatting.h"
|
| @@ -37,9 +36,9 @@ NSString* const kUserDidUpdate = @"kUserDidUpdate";
|
| NSString* const kUserInfo = @"kUserInfo";
|
|
|
| @interface RemotingService ()<RemotingAuthenticationDelegate> {
|
| - std::unique_ptr<remoting::OAuthTokenGetter> _tokenGetter;
|
| remoting::HostListFetcher* _hostListFetcher;
|
| remoting::IosClientRuntimeDelegate* _clientRuntimeDelegate;
|
| + BOOL _isHostListFetching;
|
| }
|
| @end
|
|
|
| @@ -61,10 +60,10 @@ NSString* const kUserInfo = @"kUserInfo";
|
| - (instancetype)init {
|
| self = [super init];
|
| if (self) {
|
| - _authentication = [[RemotingAuthentication alloc] init];
|
| - _authentication.delegate = self;
|
| _hosts = nil;
|
| _hostListFetcher = nil;
|
| + // TODO(yuweih): Maybe better to just cancel the previous request.
|
| + _isHostListFetching = NO;
|
| // TODO(nicholss): This might need a pointer back to the service.
|
| _clientRuntimeDelegate =
|
| new remoting::IosClientRuntimeDelegate();
|
| @@ -76,6 +75,10 @@ NSString* const kUserInfo = @"kUserInfo";
|
| #pragma mark - RemotingService Implementation
|
|
|
| - (void)startHostListFetchWith:(NSString*)accessToken {
|
| + if (_isHostListFetching) {
|
| + return;
|
| + }
|
| + _isHostListFetching = YES;
|
| if (!_hostListFetcher) {
|
| _hostListFetcher = new remoting::HostListFetcher(
|
| remoting::ChromotingClientRuntime::GetInstance()->url_requester());
|
| @@ -116,6 +119,7 @@ NSString* const kUserInfo = @"kUserInfo";
|
| }
|
| _hosts = hosts;
|
| [self hostListUpdated];
|
| + _isHostListFetching = NO;
|
| }));
|
| }
|
|
|
| @@ -133,6 +137,7 @@ NSString* const kUserInfo = @"kUserInfo";
|
| NSDictionary* userInfo = nil;
|
| if (user) {
|
| userInfo = [NSDictionary dictionaryWithObject:user forKey:kUserInfo];
|
| + [self requestHostListFetch];
|
| } else {
|
| _hosts = nil;
|
| [self hostListUpdated];
|
| @@ -159,13 +164,16 @@ NSString* const kUserInfo = @"kUserInfo";
|
|
|
| - (void)requestHostListFetch {
|
| [_authentication
|
| - callbackWithAccessToken:base::BindBlockArc(^(
|
| - remoting::OAuthTokenGetter::Status status,
|
| - const std::string& user_email,
|
| - const std::string& access_token) {
|
| - NSString* accessToken = base::SysUTF8ToNSString(access_token);
|
| + callbackWithAccessToken:^(RemotingAuthenticationStatus status,
|
| + NSString* userEmail, NSString* accessToken) {
|
| [self startHostListFetchWith:accessToken];
|
| - })];
|
| + }];
|
| +}
|
| +
|
| +- (void)setAuthentication:(id<RemotingAuthentication>)authentication {
|
| + DCHECK(_authentication == nil);
|
| + authentication.delegate = self;
|
| + _authentication = authentication;
|
| }
|
|
|
| @end
|
|
|