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

Side by Side Diff: chrome/browser/sync/token_migrator.cc

Issue 3305003: New authorization framework for sync. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/token_migrator.h"
6
7 #include "chrome/browser/sync/profile_sync_service.h"
8 #include "chrome/browser/sync/util/user_settings.h"
9 #include "chrome/common/net/gaia/gaia_constants.h"
10
11 const FilePath::CharType kSyncDataFolderName[] =
12 FILE_PATH_LITERAL("Sync Data");
13
14 const FilePath::CharType kBookmarkSyncUserSettingsDatabase[] =
15 FILE_PATH_LITERAL("BookmarkSyncSettings.sqlite3");
16
17 using browser_sync::UserSettings;
18
19 TokenMigrator::TokenMigrator(ProfileSyncService* service,
20 const FilePath& profile_path)
21 : service_(service),
22 database_location_(profile_path.Append(kSyncDataFolderName)) {
23 }
24
25 TokenMigrator::~TokenMigrator() {
26 }
27
28 void TokenMigrator::TryMigration() {
29 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
30 ChromeThread::PostTask(ChromeThread::DB, FROM_HERE,
31 NewRunnableMethod(this, &TokenMigrator::LoadTokens));
32 }
33
34 void TokenMigrator::LoadTokens() {
35 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::DB));
36 scoped_ptr<UserSettings> user_settings(new UserSettings());
37 FilePath settings_db_file =
38 database_location_.Append(FilePath(kBookmarkSyncUserSettingsDatabase));
39 if (!user_settings->Init(settings_db_file))
40 return;
41
42 if (!user_settings->GetLastUserAndServiceToken(GaiaConstants::kSyncService,
43 &username_, &token_))
44 return;
45
46 ChromeThread::PostTask(ChromeThread::UI, FROM_HERE,
47 NewRunnableMethod(this, &TokenMigrator::PostTokensBack));
48 }
49
50 void TokenMigrator::PostTokensBack() {
51 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
52 service_->LoadMigratedCredentials(username_, token_);
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698