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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/token_migrator.cc
===================================================================
--- chrome/browser/sync/token_migrator.cc (revision 0)
+++ chrome/browser/sync/token_migrator.cc (revision 0)
@@ -0,0 +1,53 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sync/token_migrator.h"
+
+#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/util/user_settings.h"
+#include "chrome/common/net/gaia/gaia_constants.h"
+
+const FilePath::CharType kSyncDataFolderName[] =
+ FILE_PATH_LITERAL("Sync Data");
+
+const FilePath::CharType kBookmarkSyncUserSettingsDatabase[] =
+ FILE_PATH_LITERAL("BookmarkSyncSettings.sqlite3");
+
+using browser_sync::UserSettings;
+
+TokenMigrator::TokenMigrator(ProfileSyncService* service,
+ const FilePath& profile_path)
+ : service_(service),
+ database_location_(profile_path.Append(kSyncDataFolderName)) {
+}
+
+TokenMigrator::~TokenMigrator() {
+}
+
+void TokenMigrator::TryMigration() {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+ ChromeThread::PostTask(ChromeThread::DB, FROM_HERE,
+ NewRunnableMethod(this, &TokenMigrator::LoadTokens));
+}
+
+void TokenMigrator::LoadTokens() {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::DB));
+ scoped_ptr<UserSettings> user_settings(new UserSettings());
+ FilePath settings_db_file =
+ database_location_.Append(FilePath(kBookmarkSyncUserSettingsDatabase));
+ if (!user_settings->Init(settings_db_file))
+ return;
+
+ if (!user_settings->GetLastUserAndServiceToken(GaiaConstants::kSyncService,
+ &username_, &token_))
+ return;
+
+ ChromeThread::PostTask(ChromeThread::UI, FROM_HERE,
+ NewRunnableMethod(this, &TokenMigrator::PostTokensBack));
+}
+
+void TokenMigrator::PostTokensBack() {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+ service_->LoadMigratedCredentials(username_, token_);
+}

Powered by Google App Engine
This is Rietveld 408576698