Skip to content

Commit

Permalink
Revert of Port iOS to use IOSChromeProfileSyncServiceFactory (patchset
Browse files Browse the repository at this point in the history
…chromium#1 id:1 of https://codereview.chromium.org/1522993002/ )

Reason for revert:
Seems to have broken compilation.

Original issue's description:
> Port iOS to use IOSChromeProfileSyncServiceFactory
>
> This CL switches from using ProfileSyncServiceFactory to
> IOSChromeProfileSyncServiceFactory in ios.
>
> BUG=565305
>
> Committed: https://crrev.com/e9e76ecbe5409e9389a88494ed849041f4fd7384
> Cr-Commit-Position: refs/heads/master@{#365217}

TBR=sdefresne@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=565305

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

Cr-Commit-Position: refs/heads/master@{#365219}
  • Loading branch information
vabr authored and Commit bot committed Dec 15, 2015
1 parent 8a5db5a commit 597e4bb
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "base/prefs/pref_service.h"
#include "base/strings/utf_string_conversions.h"
#include "components/bookmarks/common/bookmark_pref_names.h"
#include "components/browser_sync/browser/profile_sync_service.h"
#include "components/history/core/browser/history_service.h"
#include "components/keyed_service/core/service_access_type.h"
#include "components/omnibox/browser/autocomplete_classifier.h"
Expand All @@ -21,8 +20,8 @@
#include "ios/chrome/browser/history/top_sites_factory.h"
#include "ios/chrome/browser/pref_names.h"
#include "ios/chrome/browser/search_engines/template_url_service_factory.h"
#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/public/provider/chrome/browser/keyed_service_provider.h"

AutocompleteProviderClientImpl::AutocompleteProviderClientImpl(
ios::ChromeBrowserState* browser_state)
Expand Down Expand Up @@ -139,7 +138,8 @@ bool AutocompleteProviderClientImpl::BookmarkBarIsVisible() const {

bool AutocompleteProviderClientImpl::TabSyncEnabledAndUnencrypted() const {
return sync_driver::IsTabSyncEnabledAndUnencrypted(
IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state_),
ios::GetKeyedServiceProvider()->GetSyncServiceForBrowserState(
browser_state_),
browser_state_->GetPrefs());
}

Expand Down
8 changes: 4 additions & 4 deletions ios/chrome/browser/history/web_history_service_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@

#include "base/memory/singleton.h"
#include "base/prefs/pref_service.h"
#include "components/browser_sync/browser/profile_sync_service.h"
#include "components/history/core/browser/web_history_service.h"
#include "components/keyed_service/ios/browser_state_dependency_manager.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/sync_driver/sync_service.h"
#include "ios/chrome/browser/signin/oauth2_token_service_factory.h"
#include "ios/chrome/browser/signin/signin_manager_factory.h"
#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/public/provider/chrome/browser/keyed_service_provider.h"
#include "net/url_request/url_request_context_getter.h"

namespace ios {
Expand All @@ -25,7 +24,7 @@ namespace {
// false otherwise.
bool IsHistorySyncEnabled(ios::ChromeBrowserState* browser_state) {
sync_driver::SyncService* sync_service =
IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state);
GetKeyedServiceProvider()->GetSyncServiceForBrowserState(browser_state);
return sync_service && sync_service->IsSyncActive() &&
sync_service->GetActiveDataTypes().Has(
syncer::HISTORY_DELETE_DIRECTIVES);
Expand Down Expand Up @@ -54,7 +53,8 @@ WebHistoryServiceFactory::WebHistoryServiceFactory()
: BrowserStateKeyedServiceFactory(
"WebHistoryService",
BrowserStateDependencyManager::GetInstance()) {
DependsOn(IOSChromeProfileSyncServiceFactory::GetInstance());
ios::KeyedServiceProvider* provider = ios::GetKeyedServiceProvider();
DependsOn(provider->GetSyncServiceFactory());
DependsOn(OAuth2TokenServiceFactory::GetInstance());
DependsOn(ios::SigninManagerFactory::GetInstance());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "base/command_line.h"
#include "base/memory/singleton.h"
#include "components/browser_sync/browser/profile_sync_service.h"
#include "components/keyed_service/core/service_access_type.h"
#include "components/keyed_service/ios/browser_state_dependency_manager.h"
#include "components/password_manager/core/browser/affiliated_match_helper.h"
Expand All @@ -18,9 +17,9 @@
#include "components/sync_driver/sync_service.h"
#include "ios/chrome/browser/browser_state/browser_state_otr_helper.h"
#include "ios/chrome/browser/sync/glue/sync_start_util.h"
#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#include "ios/chrome/browser/web_data_service_factory.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/public/provider/chrome/browser/keyed_service_provider.h"
#include "ios/web/public/web_thread.h"

// static
Expand Down Expand Up @@ -49,7 +48,7 @@ void IOSChromePasswordStoreFactory::OnPasswordsSyncedStatePotentiallyChanged(
scoped_refptr<password_manager::PasswordStore> password_store =
GetForBrowserState(browser_state, ServiceAccessType::EXPLICIT_ACCESS);
sync_driver::SyncService* sync_service =
IOSChromeProfileSyncServiceFactory::GetForBrowserStateIfExists(
ios::GetKeyedServiceProvider()->GetSyncServiceForBrowserStateIfExists(
browser_state);
net::URLRequestContextGetter* request_context_getter =
browser_state->GetRequestContext();
Expand Down
6 changes: 3 additions & 3 deletions ios/chrome/browser/sync/glue/sync_start_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/location.h"
#include "components/browser_sync/browser/profile_sync_service.h"
#include "components/sync_driver/sync_service.h"
#include "ios/chrome/browser/application_context.h"
#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state_manager.h"
#include "ios/public/provider/chrome/browser/keyed_service_provider.h"
#include "ios/web/public/web_thread.h"

namespace ios {
Expand All @@ -36,7 +35,8 @@ void StartSyncOnUIThread(const base::FilePath& browser_state_path,
}

sync_driver::SyncService* sync_service =
IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state);
ios::GetKeyedServiceProvider()->GetSyncServiceForBrowserState(
browser_state);
if (!sync_service) {
DVLOG(2) << "No SyncService for browser state, can't start sync.";
return;
Expand Down
16 changes: 10 additions & 6 deletions ios/chrome/browser/sync/ios_chrome_sync_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
#include "ios/chrome/browser/pref_names.h"
#include "ios/chrome/browser/signin/oauth2_token_service_factory.h"
#include "ios/chrome/browser/sync/glue/sync_start_util.h"
#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#include "ios/chrome/browser/sync/sessions/ios_chrome_local_session_event_router.h"
#include "ios/chrome/browser/undo/bookmark_undo_service_factory.h"
#include "ios/chrome/browser/web_data_service_factory.h"
#include "ios/chrome/common/channel_info.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#include "ios/public/provider/chrome/browser/keyed_service_provider.h"
#include "ios/web/public/web_thread.h"
#include "sync/internal_api/public/engine/passive_model_worker.h"
#include "sync/util/extensions_activity.h"
Expand Down Expand Up @@ -248,8 +248,9 @@ base::WeakPtr<syncer::SyncableService>
IOSChromeSyncClient::GetSyncableServiceForType(syncer::ModelType type) {
switch (type) {
case syncer::DEVICE_INFO:
return IOSChromeProfileSyncServiceFactory::GetForBrowserState(
browser_state_)
return static_cast<ProfileSyncService*>(
ios::GetKeyedServiceProvider()->GetSyncServiceForBrowserState(
browser_state_))
->GetDeviceInfoSyncableService()
->AsWeakPtr();
case syncer::PREFERENCES:
Expand Down Expand Up @@ -293,7 +294,9 @@ IOSChromeSyncClient::GetSyncableServiceForType(syncer::ModelType type) {
case syncer::FAVICON_IMAGES:
case syncer::FAVICON_TRACKING: {
browser_sync::FaviconCache* favicons =
IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state_)
static_cast<ProfileSyncService*>(
ios::GetKeyedServiceProvider()->GetSyncServiceForBrowserState(
browser_state_))
->GetFaviconCache();
return favicons ? favicons->AsWeakPtr()
: base::WeakPtr<syncer::SyncableService>();
Expand All @@ -307,8 +310,9 @@ IOSChromeSyncClient::GetSyncableServiceForType(syncer::ModelType type) {
return base::WeakPtr<syncer::SyncableService>();
}
case syncer::SESSIONS: {
return IOSChromeProfileSyncServiceFactory::GetForBrowserState(
browser_state_)
return static_cast<ProfileSyncService*>(
ios::GetKeyedServiceProvider()->GetSyncServiceForBrowserState(
browser_state_))
->GetSessionsSyncableService()
->AsWeakPtr();
}
Expand Down
8 changes: 4 additions & 4 deletions ios/chrome/browser/sync/sync_setup_service_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
#include "ios/chrome/browser/sync/sync_setup_service_factory.h"

#include "base/memory/singleton.h"
#include "components/browser_sync/browser/profile_sync_service.h"
#include "components/keyed_service/ios/browser_state_dependency_manager.h"
#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#include "ios/chrome/browser/sync/sync_setup_service.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/public/provider/chrome/browser/keyed_service_provider.h"

// static
SyncSetupService* SyncSetupServiceFactory::GetForBrowserState(
Expand All @@ -34,7 +33,7 @@ SyncSetupServiceFactory::SyncSetupServiceFactory()
: BrowserStateKeyedServiceFactory(
"SyncSetupService",
BrowserStateDependencyManager::GetInstance()) {
DependsOn(IOSChromeProfileSyncServiceFactory::GetInstance());
DependsOn(ios::GetKeyedServiceProvider()->GetSyncServiceFactory());
}

SyncSetupServiceFactory::~SyncSetupServiceFactory() {
Expand All @@ -45,6 +44,7 @@ scoped_ptr<KeyedService> SyncSetupServiceFactory::BuildServiceInstanceFor(
ios::ChromeBrowserState* browser_state =
ios::ChromeBrowserState::FromBrowserState(context);
return make_scoped_ptr(new SyncSetupService(
IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state),
ios::GetKeyedServiceProvider()->GetSyncServiceForBrowserState(
browser_state),
browser_state->GetPrefs()));
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
#include <vector>

#include "base/logging.h"
#include "components/browser_sync/browser/profile_sync_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/sync_driver/about_sync_util.h"
#include "components/sync_driver/sync_service.h"
#include "ios/chrome/browser/signin/signin_manager_factory.h"
#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
#include "ios/chrome/common/channel_info.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/public/provider/chrome/browser/keyed_service_provider.h"
#include "ios/public/provider/web/web_ui_ios.h"
#include "ios/web/public/web_thread.h"
#include "sync/internal_api/public/events/protocol_event.h"
Expand Down Expand Up @@ -232,6 +231,6 @@ void SyncInternalsMessageHandler::SendAboutInfo() {
sync_driver::SyncService* SyncInternalsMessageHandler::GetSyncService() {
ios::ChromeBrowserState* browser_state =
ios::ChromeBrowserState::FromWebUIIOS(web_ui());
return IOSChromeProfileSyncServiceFactory::GetForBrowserState(
return ios::GetKeyedServiceProvider()->GetSyncServiceForBrowserState(
browser_state->GetOriginalChromeBrowserState());
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ KeyedServiceProvider::~KeyedServiceProvider() {
}

void KeyedServiceProvider::AssertKeyedFactoriesBuilt() {
GetSyncServiceFactory();
}

} // namespace ios
16 changes: 16 additions & 0 deletions ios/public/provider/chrome/browser/keyed_service_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
class KeyedServiceBaseFactory;
enum class ServiceAccessType;

namespace sync_driver {
class SyncService;
}

namespace ios {

class ChromeBrowserState;
Expand All @@ -31,6 +35,18 @@ class KeyedServiceProvider {
// correct.
void AssertKeyedFactoriesBuilt();

// Returns the sync_driver::SyncService factory for dependencies.
virtual KeyedServiceBaseFactory* GetSyncServiceFactory() = 0;

// Returns an instance of sync_driver::SyncService tied to |browser_state|.
virtual sync_driver::SyncService* GetSyncServiceForBrowserState(
ChromeBrowserState* browser_state) = 0;

// Returns an instance of sync_driver::SyncService tied to |browser_state| if
// there is one created already.
virtual sync_driver::SyncService* GetSyncServiceForBrowserStateIfExists(
ChromeBrowserState* browser_state) = 0;

private:
DISALLOW_COPY_AND_ASSIGN(KeyedServiceProvider);
};
Expand Down
16 changes: 16 additions & 0 deletions ios/public/test/test_keyed_service_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,20 @@ TestKeyedServiceProvider::TestKeyedServiceProvider() {
TestKeyedServiceProvider::~TestKeyedServiceProvider() {
}

KeyedServiceBaseFactory* TestKeyedServiceProvider::GetSyncServiceFactory() {
return FakeSyncServiceFactory::GetInstance();
}

sync_driver::SyncService*
TestKeyedServiceProvider::GetSyncServiceForBrowserState(
ChromeBrowserState* browser_state) {
return FakeSyncServiceFactory::GetForBrowserState(browser_state);
}

sync_driver::SyncService*
TestKeyedServiceProvider::GetSyncServiceForBrowserStateIfExists(
ChromeBrowserState* browser_state) {
return FakeSyncServiceFactory::GetForBrowserStateIfExists(browser_state);
}

} // namespace ios
7 changes: 7 additions & 0 deletions ios/public/test/test_keyed_service_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ class TestKeyedServiceProvider : public KeyedServiceProvider {
TestKeyedServiceProvider();
~TestKeyedServiceProvider() override;

// KeyedServiceProvider implementation:
KeyedServiceBaseFactory* GetSyncServiceFactory() override;
sync_driver::SyncService* GetSyncServiceForBrowserState(
ChromeBrowserState* browser_state) override;
sync_driver::SyncService* GetSyncServiceForBrowserStateIfExists(
ChromeBrowserState* browser_state) override;

private:
DISALLOW_COPY_AND_ASSIGN(TestKeyedServiceProvider);
};
Expand Down

0 comments on commit 597e4bb

Please sign in to comment.