Skip to content

Commit

Permalink
Remove stuff in TokenService that is not needed anymore (due to OAuth…
Browse files Browse the repository at this point in the history
… based approach):

- Remove the CWS service and token generation for that.
- Remove StartFetchingMissingTokens method
- Remove unit test for removed code.
Review URL: http://codereview.chromium.org/8769053

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113058 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
munjal@chromium.org committed Dec 5, 2011
1 parent bdce7a0 commit 75c3e3a
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 77 deletions.
16 changes: 0 additions & 16 deletions chrome/browser/net/gaia/token_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const char* TokenService::kServices[] = {
GaiaConstants::kSyncService,
GaiaConstants::kTalkService,
GaiaConstants::kDeviceManagementService,
GaiaConstants::kCWSService,
GaiaConstants::kLSOService,
};

Expand Down Expand Up @@ -204,21 +203,6 @@ void TokenService::StartFetchingTokens() {
}
}

void TokenService::StartFetchingMissingTokens() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(AreCredentialsValid());
for (int i = 0; i < kNumServices; i++) {
// if token exists for a service, skip for that service.
if (HasTokenForService(kServices[i]))
continue;

fetchers_[i].reset(new GaiaAuthFetcher(this, source_, getter_));
fetchers_[i]->StartIssueAuthToken(credentials_.sid,
credentials_.lsid,
kServices[i]);
}
}

void TokenService::StartFetchingOAuthTokens() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(HasOAuthCredentials());
Expand Down
6 changes: 1 addition & 5 deletions chrome/browser/net/gaia/token_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ class TokenService : public GaiaAuthConsumer,
// Results come back via event channel. Services can also poll before events
// are issued.
void StartFetchingTokens();
// Fetch tokens for only those services for which we are missing tokens.
// This can happen when new services are added in new Chrome versions and the
// user is already logged in.
void StartFetchingMissingTokens();
void StartFetchingOAuthTokens();
virtual bool HasTokenForService(const char* service) const;
const std::string& GetTokenForService(const char* const service) const;
Expand Down Expand Up @@ -249,7 +245,7 @@ class TokenService : public GaiaAuthConsumer,
// TokenService can continue to do some degree of ClientLogin token
// management, mostly related to persistence while Sync and possibly other
// services are using OAuth-based authentication.
static const int kNumServices = 7;
static const int kNumServices = 6;
// List of services that are capable of ClientLogin-based authentication.
static const char* kServices[kNumServices];
// A bunch of fetchers suitable for ClientLogin token issuing. We don't care
Expand Down
54 changes: 0 additions & 54 deletions chrome/browser/net/gaia/token_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,60 +378,6 @@ TEST_F(TokenServiceTest, FullIntegration) {
EXPECT_FALSE(service_.HasTokenForService(GaiaConstants::kTalkService));
}

TEST_F(TokenServiceTest, FullIntegrationNewServicesAdded) {
std::string token1 = "token1";

for (int i = 0; i < TokenService::kNumServices; ++i) {
const char* service = TokenService::kServices[i];
EXPECT_FALSE(service_.HasTokenForService(service));
}
{
MockFactory<MockFetcher> factory;
factory.set_results(token1);
service_.StartFetchingTokens();
}

for (int i = 0; i < TokenService::kNumServices; ++i) {
const char* service = TokenService::kServices[i];
EXPECT_TRUE(service_.HasTokenForService(service));
EXPECT_EQ(token1, service_.GetTokenForService(service));
}

// Clear tokens for some services to simulate that those services got
// added in a new Chrome release.
service_.token_map_.erase(GaiaConstants::kLSOService);
service_.token_map_.erase(GaiaConstants::kCWSService);

for (int i = 0; i < TokenService::kNumServices; ++i) {
const char* service = TokenService::kServices[i];
if (service == GaiaConstants::kLSOService ||
service == GaiaConstants::kCWSService) {
EXPECT_FALSE(service_.HasTokenForService(service));
} else {
EXPECT_TRUE(service_.HasTokenForService(service));
EXPECT_EQ(token1, service_.GetTokenForService(service));
}
}

std::string token2 = "token2";
{
MockFactory<MockFetcher> factory;
factory.set_results(token2);
service_.StartFetchingMissingTokens();
}

for (int i = 0; i < TokenService::kNumServices; ++i) {
const char* service = TokenService::kServices[i];
EXPECT_TRUE(service_.HasTokenForService(service));
if (service == GaiaConstants::kLSOService ||
service == GaiaConstants::kCWSService) {
EXPECT_EQ(token2, service_.GetTokenForService(service));
} else {
EXPECT_EQ(token1, service_.GetTokenForService(service));
}
}
}

TEST_F(TokenServiceTest, LoadTokensIntoMemoryBasic) {
// Validate that the method sets proper data in notifications and map.
std::map<std::string, std::string> db_tokens;
Expand Down
3 changes: 1 addition & 2 deletions chrome/common/net/gaia/gaia_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ const char kDeviceManagementService[] = "mobilesync";
const char kDeviceManagementServiceOAuth[] =
"https://www.googleapis.com/auth/chromeosdevicemanagement";

// Service/scope names for chrome web store.
const char kCWSService[] = "chromewebstore";
// OAuth scopes for chrome web store.
const char kCWSNotificationScope[] =
"https://www.googleapis.com/auth/chromewebstore.notification";

Expand Down

0 comments on commit 75c3e3a

Please sign in to comment.