Commit 10e61588 authored by blundell@chromium.org's avatar blundell@chromium.org

Create signin component and componentize TokenWebData.

This CL creates the signin layered component. It additionally componentizes
TokenWebData and moves it into the signin component. The refactorings performed
on TokenWebData are identical to ones performed on AutofillWebDataService:
- threads are injected rather than being obtained from content::BrowserThread
- //chrome code gets the TokenWebData for a Profile via WebDataServiceFactory
  instead of TokenWebData::FromBrowserContext.

BUG=332107
TBR=thakis

Review URL: https://codereview.chromium.org/109783003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243564 0039d316-1c4b-4281-b951-d872f2087c98
parent ebce4931
...@@ -18,6 +18,7 @@ include_rules = [ ...@@ -18,6 +18,7 @@ include_rules = [
"+components/policy", "+components/policy",
"+components/precache", "+components/precache",
"+components/sessions", "+components/sessions",
"+components/signin",
"+components/startup_metric_utils", "+components/startup_metric_utils",
"+components/translate/core/browser", "+components/translate/core/browser",
"+components/translate/core/common", "+components/translate/core/common",
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
#include "chrome/browser/signin/mutable_profile_oauth2_token_service.h" #include "chrome/browser/signin/mutable_profile_oauth2_token_service.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/webdata/token_web_data.h" #include "chrome/browser/webdata/web_data_service_factory.h"
#include "components/signin/core/webdata/token_web_data.h"
#include "components/webdata/common/web_data_service_base.h" #include "components/webdata/common/web_data_service_base.h"
#include "google_apis/gaia/gaia_auth_fetcher.h" #include "google_apis/gaia/gaia_auth_fetcher.h"
#include "google_apis/gaia/gaia_constants.h" #include "google_apis/gaia/gaia_constants.h"
...@@ -82,7 +83,8 @@ MutableProfileOAuth2TokenService::~MutableProfileOAuth2TokenService() { ...@@ -82,7 +83,8 @@ MutableProfileOAuth2TokenService::~MutableProfileOAuth2TokenService() {
void MutableProfileOAuth2TokenService::Shutdown() { void MutableProfileOAuth2TokenService::Shutdown() {
if (web_data_service_request_ != 0) { if (web_data_service_request_ != 0) {
scoped_refptr<TokenWebData> token_web_data = scoped_refptr<TokenWebData> token_web_data =
TokenWebData::FromBrowserContext(profile()); WebDataServiceFactory::GetTokenWebDataForProfile(
profile(), Profile::EXPLICIT_ACCESS);
DCHECK(token_web_data.get()); DCHECK(token_web_data.get());
token_web_data->CancelRequest(web_data_service_request_); token_web_data->CancelRequest(web_data_service_request_);
web_data_service_request_ = 0; web_data_service_request_ = 0;
...@@ -101,7 +103,8 @@ void MutableProfileOAuth2TokenService::LoadCredentials() { ...@@ -101,7 +103,8 @@ void MutableProfileOAuth2TokenService::LoadCredentials() {
CancelAllRequests(); CancelAllRequests();
refresh_tokens().clear(); refresh_tokens().clear();
scoped_refptr<TokenWebData> token_web_data = scoped_refptr<TokenWebData> token_web_data =
TokenWebData::FromBrowserContext(profile()); WebDataServiceFactory::GetTokenWebDataForProfile(
profile(), Profile::EXPLICIT_ACCESS);
if (token_web_data.get()) if (token_web_data.get())
web_data_service_request_ = token_web_data->GetAllTokens(this); web_data_service_request_ = token_web_data->GetAllTokens(this);
} }
...@@ -156,7 +159,8 @@ void MutableProfileOAuth2TokenService::LoadAllCredentialsIntoMemory( ...@@ -156,7 +159,8 @@ void MutableProfileOAuth2TokenService::LoadAllCredentialsIntoMemory(
if (IsLegacyServiceId(prefixed_account_id)) { if (IsLegacyServiceId(prefixed_account_id)) {
scoped_refptr<TokenWebData> token_web_data = scoped_refptr<TokenWebData> token_web_data =
TokenWebData::FromBrowserContext(profile()); WebDataServiceFactory::GetTokenWebDataForProfile(
profile(), Profile::EXPLICIT_ACCESS);
if (token_web_data.get()) if (token_web_data.get())
token_web_data->RemoveTokenForService(prefixed_account_id); token_web_data->RemoveTokenForService(prefixed_account_id);
} else { } else {
...@@ -183,7 +187,8 @@ void MutableProfileOAuth2TokenService::PersistCredentials( ...@@ -183,7 +187,8 @@ void MutableProfileOAuth2TokenService::PersistCredentials(
const std::string& account_id, const std::string& account_id,
const std::string& refresh_token) { const std::string& refresh_token) {
scoped_refptr<TokenWebData> token_web_data = scoped_refptr<TokenWebData> token_web_data =
TokenWebData::FromBrowserContext(profile()); WebDataServiceFactory::GetTokenWebDataForProfile(
profile(), Profile::EXPLICIT_ACCESS);
if (token_web_data.get()) { if (token_web_data.get()) {
token_web_data->SetTokenForService(ApplyAccountIdPrefix(account_id), token_web_data->SetTokenForService(ApplyAccountIdPrefix(account_id),
refresh_token); refresh_token);
...@@ -193,7 +198,8 @@ void MutableProfileOAuth2TokenService::PersistCredentials( ...@@ -193,7 +198,8 @@ void MutableProfileOAuth2TokenService::PersistCredentials(
void MutableProfileOAuth2TokenService::ClearPersistedCredentials( void MutableProfileOAuth2TokenService::ClearPersistedCredentials(
const std::string& account_id) { const std::string& account_id) {
scoped_refptr<TokenWebData> token_web_data = scoped_refptr<TokenWebData> token_web_data =
TokenWebData::FromBrowserContext(profile()); WebDataServiceFactory::GetTokenWebDataForProfile(
profile(), Profile::EXPLICIT_ACCESS);
if (token_web_data.get()) if (token_web_data.get())
token_web_data->RemoveTokenForService(ApplyAccountIdPrefix(account_id)); token_web_data->RemoveTokenForService(ApplyAccountIdPrefix(account_id));
} }
......
...@@ -9,8 +9,9 @@ ...@@ -9,8 +9,9 @@
#include "chrome/browser/signin/signin_account_id_helper.h" #include "chrome/browser/signin/signin_account_id_helper.h"
#include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/webdata/token_web_data.h" #include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "components/signin/core/webdata/token_web_data.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
#include "google_apis/gaia/gaia_constants.h" #include "google_apis/gaia/gaia_constants.h"
#include "google_apis/gaia/gaia_urls.h" #include "google_apis/gaia/gaia_urls.h"
...@@ -76,7 +77,8 @@ class MutableProfileOAuth2TokenServiceTest : ...@@ -76,7 +77,8 @@ class MutableProfileOAuth2TokenServiceTest :
void AddAuthTokenManually(const std::string& service, void AddAuthTokenManually(const std::string& service,
const std::string& value) { const std::string& value) {
scoped_refptr<TokenWebData> token_web_data = scoped_refptr<TokenWebData> token_web_data =
TokenWebData::FromBrowserContext(profile()); WebDataServiceFactory::GetTokenWebDataForProfile(
profile(), Profile::EXPLICIT_ACCESS);
if (token_web_data.get()) if (token_web_data.get())
token_web_data->SetTokenForService(service, value); token_web_data->SetTokenForService(service, value);
} }
......
...@@ -195,7 +195,9 @@ syncer::ModelType GetModelType<AutofillProfile>() { ...@@ -195,7 +195,9 @@ syncer::ModelType GetModelType<AutofillProfile>() {
class TokenWebDataServiceFake : public TokenWebData { class TokenWebDataServiceFake : public TokenWebData {
public: public:
TokenWebDataServiceFake() TokenWebDataServiceFake()
: TokenWebData() { : TokenWebData(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)) {
} }
virtual bool IsDatabaseLoaded() OVERRIDE { virtual bool IsDatabaseLoaded() OVERRIDE {
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
#include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/webdata/keyword_table.h" #include "chrome/browser/webdata/keyword_table.h"
#include "chrome/browser/webdata/logins_table.h" #include "chrome/browser/webdata/logins_table.h"
#include "chrome/browser/webdata/token_service_table.h"
#include "chrome/browser/webdata/web_apps_table.h" #include "chrome/browser/webdata/web_apps_table.h"
#include "chrome/browser/webdata/web_intents_table.h" #include "chrome/browser/webdata/web_intents_table.h"
#include "components/signin/core/webdata/token_service_table.h"
#include "components/webdata/common/web_database_service.h" #include "components/webdata/common/web_database_service.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h" #include "content/public/browser/notification_details.h"
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
#include "chrome/browser/webdata/autofill_profile_syncable_service.h" #include "chrome/browser/webdata/autofill_profile_syncable_service.h"
#include "chrome/browser/webdata/keyword_table.h" #include "chrome/browser/webdata/keyword_table.h"
#include "chrome/browser/webdata/logins_table.h" #include "chrome/browser/webdata/logins_table.h"
#include "chrome/browser/webdata/token_service_table.h"
#include "chrome/browser/webdata/token_web_data.h"
#include "chrome/browser/webdata/web_apps_table.h" #include "chrome/browser/webdata/web_apps_table.h"
#include "chrome/browser/webdata/web_data_service.h" #include "chrome/browser/webdata/web_data_service.h"
#include "chrome/browser/webdata/web_intents_table.h" #include "chrome/browser/webdata/web_intents_table.h"
...@@ -23,6 +21,8 @@ ...@@ -23,6 +21,8 @@
#include "components/autofill/core/browser/webdata/autofill_table.h" #include "components/autofill/core/browser/webdata/autofill_table.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h" #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/browser_context_keyed_service/browser_context_dependency_manager.h" #include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
#include "components/signin/core/webdata/token_service_table.h"
#include "components/signin/core/webdata/token_web_data.h"
#include "components/webdata/common/webdata_constants.h" #include "components/webdata/common/webdata_constants.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "grit/chromium_strings.h" #include "grit/chromium_strings.h"
...@@ -106,8 +106,8 @@ WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) { ...@@ -106,8 +106,8 @@ WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) {
autofill_web_data_->Init(); autofill_web_data_->Init();
token_web_data_ = new TokenWebData( token_web_data_ = new TokenWebData(
web_database_, base::Bind(&ProfileErrorCallback, web_database_, ui_thread, db_thread, base::Bind(
PROFILE_ERROR_DB_TOKEN_WEB_DATA)); &ProfileErrorCallback, PROFILE_ERROR_DB_TOKEN_WEB_DATA));
token_web_data_->Init(); token_web_data_->Init();
web_data_ = new WebDataService( web_data_ = new WebDataService(
...@@ -145,21 +145,6 @@ scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() { ...@@ -145,21 +145,6 @@ scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() {
return token_web_data_.get(); return token_web_data_.get();
} }
// static
scoped_refptr<TokenWebData> TokenWebData::FromBrowserContext(
content::BrowserContext* context) {
// For this service, the implicit/explicit distinction doesn't
// really matter; it's just used for a DCHECK. So we currently
// cheat and always say EXPLICIT_ACCESS.
WebDataServiceWrapper* wrapper =
WebDataServiceFactory::GetForProfile(
static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS);
if (wrapper)
return wrapper->GetTokenWebData();
// |wrapper| can be NULL in Incognito mode.
return scoped_refptr<TokenWebData>(NULL);
}
// static // static
scoped_refptr<WebDataService> WebDataService::FromBrowserContext( scoped_refptr<WebDataService> WebDataService::FromBrowserContext(
content::BrowserContext* context) { content::BrowserContext* context) {
...@@ -221,6 +206,18 @@ WebDataServiceFactory::GetAutofillWebDataForProfile( ...@@ -221,6 +206,18 @@ WebDataServiceFactory::GetAutofillWebDataForProfile(
scoped_refptr<AutofillWebDataService>(NULL); scoped_refptr<AutofillWebDataService>(NULL);
} }
// static
scoped_refptr<TokenWebData>
WebDataServiceFactory::GetTokenWebDataForProfile(
Profile* profile,
Profile::ServiceAccessType access_type) {
WebDataServiceWrapper* wrapper =
WebDataServiceFactory::GetForProfile(profile, access_type);
// |wrapper| can be NULL in Incognito mode.
return wrapper ? wrapper->GetTokenWebData()
: scoped_refptr<TokenWebData>(NULL);
}
// static // static
WebDataServiceFactory* WebDataServiceFactory::GetInstance() { WebDataServiceFactory* WebDataServiceFactory::GetInstance() {
return Singleton<WebDataServiceFactory>::get(); return Singleton<WebDataServiceFactory>::get();
......
...@@ -67,6 +67,10 @@ class WebDataServiceFactory : public BrowserContextKeyedServiceFactory { ...@@ -67,6 +67,10 @@ class WebDataServiceFactory : public BrowserContextKeyedServiceFactory {
GetAutofillWebDataForProfile(Profile* profile, GetAutofillWebDataForProfile(Profile* profile,
Profile::ServiceAccessType access_type); Profile::ServiceAccessType access_type);
// Returns the TokenWebData associated with the |profile|.
static scoped_refptr<TokenWebData> GetTokenWebDataForProfile(Profile* profile,
Profile::ServiceAccessType access_type);
static WebDataServiceFactory* GetInstance(); static WebDataServiceFactory* GetInstance();
private: private:
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
'../components/components.gyp:encryptor', '../components/components.gyp:encryptor',
'../components/components.gyp:navigation_metrics', '../components/components.gyp:navigation_metrics',
'../components/components.gyp:precache_core', '../components/components.gyp:precache_core',
'../components/components.gyp:signin_core',
'../components/components.gyp:startup_metric_utils', '../components/components.gyp:startup_metric_utils',
'../components/components.gyp:translate_core_browser', '../components/components.gyp:translate_core_browser',
'../components/components.gyp:translate_core_common', '../components/components.gyp:translate_core_common',
...@@ -2576,10 +2577,6 @@ ...@@ -2576,10 +2577,6 @@
'browser/webdata/logins_table.cc', 'browser/webdata/logins_table.cc',
'browser/webdata/logins_table.h', 'browser/webdata/logins_table.h',
'browser/webdata/logins_table_win.cc', 'browser/webdata/logins_table_win.cc',
'browser/webdata/token_service_table.cc',
'browser/webdata/token_service_table.h',
'browser/webdata/token_web_data.cc',
'browser/webdata/token_web_data.h',
'browser/webdata/web_apps_table.cc', 'browser/webdata/web_apps_table.cc',
'browser/webdata/web_apps_table.h', 'browser/webdata/web_apps_table.h',
'browser/webdata/web_data_service.cc', 'browser/webdata/web_data_service.cc',
......
...@@ -1761,7 +1761,6 @@ ...@@ -1761,7 +1761,6 @@
'browser/web_resource/resource_request_allowed_notifier_unittest.cc', 'browser/web_resource/resource_request_allowed_notifier_unittest.cc',
'browser/webdata/autofill_profile_syncable_service_unittest.cc', 'browser/webdata/autofill_profile_syncable_service_unittest.cc',
'browser/webdata/keyword_table_unittest.cc', 'browser/webdata/keyword_table_unittest.cc',
'browser/webdata/token_service_table_unittest.cc',
'browser/webdata/web_apps_table_unittest.cc', 'browser/webdata/web_apps_table_unittest.cc',
'common/cancelable_task_tracker_unittest.cc', 'common/cancelable_task_tracker_unittest.cc',
'common/chrome_paths_unittest.cc', 'common/chrome_paths_unittest.cc',
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
'onc.gypi', 'onc.gypi',
'policy.gypi', 'policy.gypi',
'precache.gypi', 'precache.gypi',
'signin.gypi',
'startup_metric_utils.gypi', 'startup_metric_utils.gypi',
'translate.gypi', 'translate.gypi',
'user_prefs.gypi', 'user_prefs.gypi',
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
'precache/core/precache_fetcher_unittest.cc', 'precache/core/precache_fetcher_unittest.cc',
'precache/core/precache_url_table_unittest.cc', 'precache/core/precache_url_table_unittest.cc',
'sessions/serialized_navigation_entry_unittest.cc', 'sessions/serialized_navigation_entry_unittest.cc',
'signin/core/webdata/token_service_table_unittest.cc',
'test/run_all_unittests.cc', 'test/run_all_unittests.cc',
'translate/core/common/translate_metrics_unittest.cc', 'translate/core/common/translate_metrics_unittest.cc',
'translate/core/common/translate_util_unittest.cc', 'translate/core/common/translate_util_unittest.cc',
...@@ -103,6 +104,9 @@ ...@@ -103,6 +104,9 @@
# Dependencies of precache/core # Dependencies of precache/core
'components.gyp:precache_core', 'components.gyp:precache_core',
# Dependencies of signin
'components.gyp:signin_core',
# Dependencies of translate. # Dependencies of translate.
'components.gyp:translate_core_common', 'components.gyp:translate_core_common',
'components.gyp:translate_language_detection', 'components.gyp:translate_language_detection',
...@@ -153,6 +157,7 @@ ...@@ -153,6 +157,7 @@
['include', '^autofill/'], ['include', '^autofill/'],
['include', '^dom_distiller/'], ['include', '^dom_distiller/'],
['include', '^precache/core/'], ['include', '^precache/core/'],
['include', '^signin/'],
['include', '^translate/'], ['include', '^translate/'],
], ],
}], }],
......
# Copyright 2014 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.
{
'targets': [
{
'target_name': 'signin_core',
'type': 'static_library',
'dependencies': [
'encryptor',
'webdata_common',
'../base/base.gyp:base',
'../sql/sql.gyp:sql',
],
'include_dirs': [
'..',
],
'sources': [
'signin/core/webdata/token_service_table.cc',
'signin/core/webdata/token_service_table.h',
'signin/core/webdata/token_web_data.cc',
'signin/core/webdata/token_web_data.h',
],
},
],
}
include_rules = [
"+components/webdata/common",
"+components/webdata/encryptor",
"+google_apis/gaia/gaia_urls.h",
"+grit", # For generated headers
"+net",
"+sql",
"+ui",
# Signin is a layered component; subdirectories must explicitly introduce
# the ability to use the content layer as appropriate.
"-components/signin/content",
"-content/public/common",
"-ipc",
]
atwilson@chromium.org
tim@chromium.org
rogerta@chromium.org
\ No newline at end of file
Signin is in the process of becoming a layered component
(https://sites.google.com/a/chromium.org/dev/developers/design-documents/layered-components-design)
to enable it to be shared cleanly on iOS.
When this process is complete, this component will have the following structure:
- core/: shared code that does not depend on src/content/ or src/ios/
- content/: Driver for the shared code based on the content layer.
- ios/: Driver for the shared code based on src/ios.
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/webdata/token_service_table.h" #include "components/signin/core/webdata/token_service_table.h"
#include <map> #include <map>
#include <string> #include <string>
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_WEBDATA_TOKEN_SERVICE_TABLE_H_ #ifndef COMPONENTS_SIGNIN_CORE_WEBDATA_TOKEN_SERVICE_TABLE_H_
#define CHROME_BROWSER_WEBDATA_TOKEN_SERVICE_TABLE_H_ #define COMPONENTS_SIGNIN_CORE_WEBDATA_TOKEN_SERVICE_TABLE_H_
#include <map> #include <map>
#include <string> #include <string>
...@@ -48,4 +48,4 @@ class TokenServiceTable : public WebDatabaseTable { ...@@ -48,4 +48,4 @@ class TokenServiceTable : public WebDatabaseTable {
DISALLOW_COPY_AND_ASSIGN(TokenServiceTable); DISALLOW_COPY_AND_ASSIGN(TokenServiceTable);
}; };
#endif // CHROME_BROWSER_WEBDATA_TOKEN_SERVICE_TABLE_H_ #endif // COMPONENTS_SIGNIN_CORE_WEBDATA_TOKEN_SERVICE_TABLE_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/webdata/token_service_table.h" #include "components/signin/core/webdata/token_service_table.h"
#include "components/webdata/common/web_database.h" #include "components/webdata/common/web_database.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
......
// Copyright 2013 The Chromium Authors. All rights reserved. // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/webdata/token_web_data.h" #include "components/signin/core/webdata/token_web_data.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/memory/ref_counted_delete_on_message_loop.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "chrome/browser/webdata/token_service_table.h" #include "components/signin/core/webdata/token_service_table.h"
#include "components/webdata/common/web_database_service.h" #include "components/webdata/common/web_database_service.h"
#include "content/public/browser/browser_thread.h"
using base::Bind; using base::Bind;
using base::Time; using base::Time;
using content::BrowserThread;
class TokenWebDataBackend class TokenWebDataBackend
: public base::RefCountedThreadSafe<TokenWebDataBackend, : public base::RefCountedDeleteOnMessageLoop<TokenWebDataBackend> {
BrowserThread::DeleteOnDBThread> {
public: public:
TokenWebDataBackend() { TokenWebDataBackend(scoped_refptr<base::MessageLoopProxy> db_thread)
: base::RefCountedDeleteOnMessageLoop<TokenWebDataBackend>(db_thread) {
} }
WebDatabase::State RemoveAllTokens(WebDatabase* db) { WebDatabase::State RemoveAllTokens(WebDatabase* db) {
...@@ -59,20 +59,16 @@ class TokenWebDataBackend ...@@ -59,20 +59,16 @@ class TokenWebDataBackend
} }
private: private:
friend struct BrowserThread::DeleteOnThread<BrowserThread::DB>; friend class base::RefCountedDeleteOnMessageLoop<TokenWebDataBackend>;
friend class base::DeleteHelper<TokenWebDataBackend>; friend class base::DeleteHelper<TokenWebDataBackend>;
// We have to friend RCTS<> so WIN shared-lib build is happy
// (http://crbug/112250).
friend class base::RefCountedThreadSafe<TokenWebDataBackend,
BrowserThread::DeleteOnDBThread>;
}; };
TokenWebData::TokenWebData(scoped_refptr<WebDatabaseService> wdbs, TokenWebData::TokenWebData(scoped_refptr<WebDatabaseService> wdbs,
const ProfileErrorCallback& callback) scoped_refptr<base::MessageLoopProxy> ui_thread,
: WebDataServiceBase(wdbs, callback, scoped_refptr<base::MessageLoopProxy> db_thread,
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)), const ProfileErrorCallback& callback)
token_backend_(new TokenWebDataBackend()) { : WebDataServiceBase(wdbs, callback, ui_thread),
token_backend_(new TokenWebDataBackend(db_thread)) {
} }
void TokenWebData::SetTokenForService(const std::string& service, void TokenWebData::SetTokenForService(const std::string& service,
...@@ -100,10 +96,10 @@ WebDataServiceBase::Handle TokenWebData::GetAllTokens( ...@@ -100,10 +96,10 @@ WebDataServiceBase::Handle TokenWebData::GetAllTokens(
Bind(&TokenWebDataBackend::GetAllTokens, token_backend_), consumer); Bind(&TokenWebDataBackend::GetAllTokens, token_backend_), consumer);
} }
TokenWebData::TokenWebData() TokenWebData::TokenWebData(scoped_refptr<base::MessageLoopProxy> ui_thread,
: WebDataServiceBase(NULL, ProfileErrorCallback(), scoped_refptr<base::MessageLoopProxy> db_thread)
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)), : WebDataServiceBase(NULL, ProfileErrorCallback(), ui_thread),
token_backend_(new TokenWebDataBackend()) { token_backend_(new TokenWebDataBackend(db_thread)) {
} }
TokenWebData::~TokenWebData() { TokenWebData::~TokenWebData() {
......
// Copyright 2013 The Chromium Authors. All rights reserved. // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
// information and MUST not be extracted, overwritten or modified except // information and MUST not be extracted, overwritten or modified except
// through Chromium defined APIs. // through Chromium defined APIs.
#ifndef CHROME_BROWSER_WEBDATA_TOKEN_WEB_DATA_H__ #ifndef COMPONENTS_SIGNIN_CORE_WEBDATA_TOKEN_WEB_DATA_H__
#define CHROME_BROWSER_WEBDATA_TOKEN_WEB_DATA_H__ #define COMPONENTS_SIGNIN_CORE_WEBDATA_TOKEN_WEB_DATA_H__
#include <map> #include <map>
#include <string> #include <string>
...@@ -22,25 +22,26 @@ ...@@ -22,25 +22,26 @@
#include "components/webdata/common/web_data_service_consumer.h" #include "components/webdata/common/web_data_service_consumer.h"
#include "components/webdata/common/web_database.h" #include "components/webdata/common/web_database.h"
namespace base {
class MessageLoopProxy;
}
class TokenWebDataBackend; class TokenWebDataBackend;
class WebDatabaseService; class WebDatabaseService;
class WebDataServiceConsumer; class WebDataServiceConsumer;
namespace content {
class BrowserContext;
}
// TokenWebData is a data repository for storage of authentication tokens. // TokenWebData is a data repository for storage of authentication tokens.
class TokenWebData : public WebDataServiceBase { class TokenWebData : public WebDataServiceBase {
public: public:
// Retrieve a WebDataService for the given context.
static scoped_refptr<TokenWebData> FromBrowserContext(
content::BrowserContext* context);
TokenWebData(scoped_refptr<WebDatabaseService> wdbs, TokenWebData(scoped_refptr<WebDatabaseService> wdbs,
scoped_refptr<base::MessageLoopProxy> ui_thread,
scoped_refptr<base::MessageLoopProxy> db_thread,
const ProfileErrorCallback& callback); const ProfileErrorCallback& callback);
TokenWebData(scoped_refptr<base::MessageLoopProxy> ui_thread,
scoped_refptr<base::MessageLoopProxy> db_thread);
// Set a token to use for a specified service. // Set a token to use for a specified service.
void SetTokenForService(const std::string& service, void SetTokenForService(const std::string& service,
const std::string& token); const std::string& token);
...@@ -66,4 +67,4 @@ class TokenWebData : public WebDataServiceBase { ...@@ -66,4 +67,4 @@ class TokenWebData : public WebDataServiceBase {
DISALLOW_COPY_AND_ASSIGN(TokenWebData); DISALLOW_COPY_AND_ASSIGN(TokenWebData);
}; };
#endif // CHROME_BROWSER_WEBDATA_TOKEN_WEB_DATA_H__ #endif // COMPONENTS_SIGNIN_CORE_WEBDATA_TOKEN_WEB_DATA_H__
...@@ -18,6 +18,7 @@ specific_include_rules = { ...@@ -18,6 +18,7 @@ specific_include_rules = {
"+chrome/browser/webdata/web_data_service_factory.h", "+chrome/browser/webdata/web_data_service_factory.h",
"+chrome/browser/webdata/web_intents_table.h", "+chrome/browser/webdata/web_intents_table.h",
"+components/autofill/core", "+components/autofill/core",
"+components/signin/core/webdata",
"+content/public/test", "+content/public/test",
], ],
} }
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "chrome/browser/webdata/token_web_data.h"
#include "chrome/browser/webdata/web_data_service.h" #include "chrome/browser/webdata/web_data_service.h"
#include "chrome/browser/webdata/web_data_service_factory.h" #include "chrome/browser/webdata/web_data_service_factory.h"
#include "components/signin/core/webdata/token_web_data.h"
// Base class for mocks of WebDataService, that does nothing in // Base class for mocks of WebDataService, that does nothing in
// Shutdown(). // Shutdown().
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/webdata/keyword_table.h" #include "chrome/browser/webdata/keyword_table.h"
#include "chrome/browser/webdata/logins_table.h" #include "chrome/browser/webdata/logins_table.h"
#include "chrome/browser/webdata/token_service_table.h"
#include "chrome/browser/webdata/web_apps_table.h" #include "chrome/browser/webdata/web_apps_table.h"
#include "chrome/browser/webdata/web_intents_table.h" #include "chrome/browser/webdata/web_intents_table.h"
#include "components/autofill/core/browser/autofill_country.h" #include "components/autofill/core/browser/autofill_country.h"
...@@ -27,6 +26,7 @@ ...@@ -27,6 +26,7 @@
#include "components/autofill/core/browser/webdata/autofill_change.h" #include "components/autofill/core/browser/webdata/autofill_change.h"
#include "components/autofill/core/browser/webdata/autofill_entry.h" #include "components/autofill/core/browser/webdata/autofill_entry.h"
#include "components/autofill/core/browser/webdata/autofill_table.h" #include "components/autofill/core/browser/webdata/autofill_table.h"
#include "components/signin/core/webdata/token_service_table.h"
#include "components/webdata/common/web_database.h" #include "components/webdata/common/web_database.h"
#include "sql/statement.h" #include "sql/statement.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment