Chromium Code Reviews| Index: chrome/browser/chromeos/drive/drive_system_service.cc | 
| diff --git a/chrome/browser/chromeos/drive/drive_system_service.cc b/chrome/browser/chromeos/drive/drive_system_service.cc | 
| index 1ef760612540b24f2377ce57f78e0caf96ccca1d..6bc75e831554e13dda3602624ab31fb73d9b18b5 100644 | 
| --- a/chrome/browser/chromeos/drive/drive_system_service.cc | 
| +++ b/chrome/browser/chromeos/drive/drive_system_service.cc | 
| @@ -24,12 +24,12 @@ | 
| #include "chrome/browser/google_apis/auth_service.h" | 
| #include "chrome/browser/google_apis/drive_api_service.h" | 
| #include "chrome/browser/google_apis/drive_api_util.h" | 
| +#include "chrome/browser/google_apis/drive_notification_manager.h" | 
| +#include "chrome/browser/google_apis/drive_notification_manager_factory.h" | 
| #include "chrome/browser/google_apis/gdata_wapi_service.h" | 
| #include "chrome/browser/google_apis/gdata_wapi_url_generator.h" | 
| #include "chrome/browser/profiles/profile.h" | 
| #include "chrome/browser/profiles/profile_dependency_manager.h" | 
| -#include "chrome/browser/sync/profile_sync_service.h" | 
| -#include "chrome/browser/sync/profile_sync_service_factory.h" | 
| #include "chrome/common/chrome_switches.h" | 
| #include "chrome/common/chrome_version_info.h" | 
| #include "chrome/common/pref_names.h" | 
| @@ -48,9 +48,6 @@ namespace { | 
| static const size_t kEventLogHistorySize = 100; | 
| -// The sync invalidation object ID for Google Drive. | 
| -const char kDriveInvalidationObjectId[] = "CHANGELOG"; | 
| - | 
| // Returns true if Drive is enabled for the given Profile. | 
| bool IsDriveEnabledForProfile(Profile* profile) { | 
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 
| @@ -105,7 +102,6 @@ DriveSystemService::DriveSystemService( | 
| DriveFileSystemInterface* test_file_system) | 
| : profile_(profile), | 
| drive_disabled_(false), | 
| - push_notification_registered_(false), | 
| ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 
| base::SequencedWorkerPool* blocking_pool = BrowserThread::GetBlockingPool(); | 
| @@ -176,19 +172,10 @@ void DriveSystemService::Initialize() { | 
| void DriveSystemService::Shutdown() { | 
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 
| - ProfileSyncService* profile_sync_service = | 
| - profile_ ? ProfileSyncServiceFactory::GetForProfile(profile_) : NULL; | 
| - if (profile_sync_service && push_notification_registered_) { | 
| - // TODO(kochi): Once DriveSystemService gets started / stopped at runtime, | 
| - // this ID needs to be unregistered *before* the handler is unregistered | 
| - // as ID persists across browser restarts. | 
| - if (!IsDriveEnabledForProfile(profile_)) { | 
| - profile_sync_service->UpdateRegisteredInvalidationIds( | 
| - this, syncer::ObjectIdSet()); | 
| - } | 
| - profile_sync_service->UnregisterInvalidationHandler(this); | 
| - push_notification_registered_ = false; | 
| - } | 
| + google_apis::DriveNotificationManager* drive_notification_manager = | 
| + google_apis::DriveNotificationManagerFactory::GetForProfile(profile_); | 
| + DCHECK(drive_notification_manager); | 
| + drive_notification_manager->RemoveObserver(this); | 
| RemoveDriveMountPoint(); | 
| } | 
| @@ -201,6 +188,9 @@ void DriveSystemService::AddObserver(DriveSystemServiceObserver* observer) { | 
| void DriveSystemService::RemoveObserver(DriveSystemServiceObserver* observer) { | 
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 
| observers_.RemoveObserver(observer); | 
| + | 
| +void DriveSystemService::CheckForUpdates() { | 
| + file_system_->CheckForUpdates(); | 
| } | 
| bool DriveSystemService::IsDriveEnabled() { | 
| @@ -216,22 +206,6 @@ bool DriveSystemService::IsDriveEnabled() { | 
| return true; | 
| } | 
| -void DriveSystemService::OnInvalidatorStateChange( | 
| - syncer::InvalidatorState state) { | 
| - DVLOG(1) << "InvalidatorState changed to " << state; | 
| -} | 
| - | 
| -void DriveSystemService::OnIncomingInvalidation( | 
| - const syncer::ObjectIdInvalidationMap& invalidation_map) { | 
| 
 
satorux1
2013/04/19 04:12:13
Wanted to insert EventLogger logging here, but now
 
 | 
| - DCHECK_EQ(1U, invalidation_map.size()); | 
| - const invalidation::ObjectId object_id( | 
| - ipc::invalidation::ObjectSource::COSMO_CHANGELOG, | 
| - kDriveInvalidationObjectId); | 
| - DCHECK_EQ(1U, invalidation_map.count(object_id)); | 
| - | 
| - file_system_->CheckForUpdates(); | 
| -} | 
| - | 
| void DriveSystemService::ClearCacheAndRemountFileSystem( | 
| const base::Callback<void(bool)>& callback) { | 
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 
| @@ -289,19 +263,6 @@ void DriveSystemService::ReloadAndRemountFileSystem() { | 
| AddDriveMountPoint(); | 
| } | 
| -bool DriveSystemService::PushNotificationEnabled() { | 
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 
| - DCHECK(profile_); | 
| - | 
| - ProfileSyncService* profile_sync_service = | 
| - ProfileSyncServiceFactory::GetForProfile(profile_); | 
| - if (!profile_sync_service) | 
| - return false; | 
| - | 
| - return (profile_sync_service->GetInvalidatorState() == | 
| - syncer::INVALIDATIONS_ENABLED); | 
| -} | 
| - | 
| void DriveSystemService::AddDriveMountPoint() { | 
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 
| DCHECK(!file_system_proxy_.get()); | 
| @@ -379,18 +340,10 @@ void DriveSystemService::InitializeAfterResourceMetadataInitialized( | 
| cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_TMP_DOWNLOADS)); | 
| // Register for Google Drive invalidation notifications. | 
| - ProfileSyncService* profile_sync_service = | 
| - profile_ ? ProfileSyncServiceFactory::GetForProfile(profile_) : NULL; | 
| - if (profile_sync_service) { | 
| - DCHECK(!push_notification_registered_); | 
| - profile_sync_service->RegisterInvalidationHandler(this); | 
| - syncer::ObjectIdSet ids; | 
| - ids.insert(invalidation::ObjectId( | 
| - ipc::invalidation::ObjectSource::COSMO_CHANGELOG, | 
| - kDriveInvalidationObjectId)); | 
| - profile_sync_service->UpdateRegisteredInvalidationIds(this, ids); | 
| - push_notification_registered_ = true; | 
| - } | 
| + google_apis::DriveNotificationManager* drive_notification_manager = | 
| + google_apis::DriveNotificationManagerFactory::GetForProfile(profile_); | 
| + DCHECK(drive_notification_manager); | 
| + drive_notification_manager->AddObserver(this); | 
| AddDriveMountPoint(); | 
| } | 
| @@ -459,7 +412,7 @@ void DriveSystemServiceFactory::SetFactoryForTest( | 
| DriveSystemServiceFactory::DriveSystemServiceFactory() | 
| : ProfileKeyedServiceFactory("DriveSystemService", | 
| ProfileDependencyManager::GetInstance()) { | 
| - DependsOn(ProfileSyncServiceFactory::GetInstance()); | 
| + DependsOn(google_apis::DriveNotificationManagerFactory::GetInstance()); | 
| DependsOn(DownloadServiceFactory::GetInstance()); | 
| } |