| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 5 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/chromeos/drive/debug_info_collector.h" | 10 #include "chrome/browser/chromeos/drive/debug_info_collector.h" |
| 11 #include "chrome/browser/chromeos/drive/download_handler.h" | 11 #include "chrome/browser/chromeos/drive/download_handler.h" |
| 12 #include "chrome/browser/chromeos/drive/drive_webapps_registry.h" | 12 #include "chrome/browser/chromeos/drive/drive_app_registry.h" |
| 13 #include "chrome/browser/chromeos/drive/file_cache.h" | 13 #include "chrome/browser/chromeos/drive/file_cache.h" |
| 14 #include "chrome/browser/chromeos/drive/file_system.h" | 14 #include "chrome/browser/chromeos/drive/file_system.h" |
| 15 #include "chrome/browser/chromeos/drive/file_system_proxy.h" | 15 #include "chrome/browser/chromeos/drive/file_system_proxy.h" |
| 16 #include "chrome/browser/chromeos/drive/file_system_util.h" | 16 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 17 #include "chrome/browser/chromeos/drive/file_write_helper.h" | 17 #include "chrome/browser/chromeos/drive/file_write_helper.h" |
| 18 #include "chrome/browser/chromeos/drive/logging.h" | 18 #include "chrome/browser/chromeos/drive/logging.h" |
| 19 #include "chrome/browser/chromeos/drive/sync_client.h" | 19 #include "chrome/browser/chromeos/drive/sync_client.h" |
| 20 #include "chrome/browser/download/download_service.h" | 20 #include "chrome/browser/download/download_service.h" |
| 21 #include "chrome/browser/download/download_service_factory.h" | 21 #include "chrome/browser/download/download_service_factory.h" |
| 22 #include "chrome/browser/download/download_util.h" | 22 #include "chrome/browser/download/download_util.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 g_browser_process->system_request_context(), | 114 g_browser_process->system_request_context(), |
| 115 GURL(google_apis::GDataWapiUrlGenerator::kBaseUrlForProduction), | 115 GURL(google_apis::GDataWapiUrlGenerator::kBaseUrlForProduction), |
| 116 GetDriveUserAgent())); | 116 GetDriveUserAgent())); |
| 117 } | 117 } |
| 118 scheduler_.reset(new JobScheduler(profile_, drive_service_.get())); | 118 scheduler_.reset(new JobScheduler(profile_, drive_service_.get())); |
| 119 cache_.reset(new internal::FileCache( | 119 cache_.reset(new internal::FileCache( |
| 120 !test_cache_root.empty() ? test_cache_root : | 120 !test_cache_root.empty() ? test_cache_root : |
| 121 util::GetCacheRootPath(profile), | 121 util::GetCacheRootPath(profile), |
| 122 blocking_task_runner_, | 122 blocking_task_runner_, |
| 123 NULL /* free_disk_space_getter */)); | 123 NULL /* free_disk_space_getter */)); |
| 124 webapps_registry_.reset(new DriveWebAppsRegistry(scheduler_.get())); | 124 drive_app_registry_.reset(new DriveAppRegistry(scheduler_.get())); |
| 125 | 125 |
| 126 // We can call FileCache::GetCacheDirectoryPath safely even before the cache | 126 // We can call FileCache::GetCacheDirectoryPath safely even before the cache |
| 127 // gets initialized. | 127 // gets initialized. |
| 128 resource_metadata_.reset(new internal::ResourceMetadata( | 128 resource_metadata_.reset(new internal::ResourceMetadata( |
| 129 cache_->GetCacheDirectoryPath(internal::FileCache::CACHE_TYPE_META), | 129 cache_->GetCacheDirectoryPath(internal::FileCache::CACHE_TYPE_META), |
| 130 blocking_task_runner_)); | 130 blocking_task_runner_)); |
| 131 | 131 |
| 132 file_system_.reset(test_file_system ? test_file_system : | 132 file_system_.reset(test_file_system ? test_file_system : |
| 133 new FileSystem(profile_, | 133 new FileSystem(profile_, |
| 134 cache_.get(), | 134 cache_.get(), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 175 } |
| 176 | 176 |
| 177 void DriveIntegrationService::RemoveObserver( | 177 void DriveIntegrationService::RemoveObserver( |
| 178 DriveIntegrationServiceObserver* observer) { | 178 DriveIntegrationServiceObserver* observer) { |
| 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 180 observers_.RemoveObserver(observer); | 180 observers_.RemoveObserver(observer); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void DriveIntegrationService::OnNotificationReceived() { | 183 void DriveIntegrationService::OnNotificationReceived() { |
| 184 file_system_->CheckForUpdates(); | 184 file_system_->CheckForUpdates(); |
| 185 webapps_registry_->Update(); | 185 drive_app_registry_->Update(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void DriveIntegrationService::OnPushNotificationEnabled(bool enabled) { | 188 void DriveIntegrationService::OnPushNotificationEnabled(bool enabled) { |
| 189 const char* status = (enabled ? "enabled" : "disabled"); | 189 const char* status = (enabled ? "enabled" : "disabled"); |
| 190 util::Log("Push notification is %s", status); | 190 util::Log("Push notification is %s", status); |
| 191 } | 191 } |
| 192 | 192 |
| 193 bool DriveIntegrationService::IsDriveEnabled() { | 193 bool DriveIntegrationService::IsDriveEnabled() { |
| 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 195 | 195 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 220 bool success) { | 220 bool success) { |
| 221 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 221 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 222 DCHECK(!callback.is_null()); | 222 DCHECK(!callback.is_null()); |
| 223 | 223 |
| 224 if (!success) { | 224 if (!success) { |
| 225 callback.Run(false); | 225 callback.Run(false); |
| 226 return; | 226 return; |
| 227 } | 227 } |
| 228 | 228 |
| 229 file_system_->Initialize(); | 229 file_system_->Initialize(); |
| 230 webapps_registry_->Update(); | 230 drive_app_registry_->Update(); |
| 231 AddDriveMountPoint(); | 231 AddDriveMountPoint(); |
| 232 | 232 |
| 233 callback.Run(true); | 233 callback.Run(true); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void DriveIntegrationService::ReloadAndRemountFileSystem() { | 236 void DriveIntegrationService::ReloadAndRemountFileSystem() { |
| 237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 238 | 238 |
| 239 RemoveDriveMountPoint(); | 239 RemoveDriveMountPoint(); |
| 240 file_system_->Reload(); | 240 file_system_->Reload(); |
| 241 webapps_registry_->Update(); | 241 drive_app_registry_->Update(); |
| 242 | 242 |
| 243 // Reload() is asynchronous. But we can add back the mount point right away | 243 // Reload() is asynchronous. But we can add back the mount point right away |
| 244 // because every operation waits until loading is complete. | 244 // because every operation waits until loading is complete. |
| 245 AddDriveMountPoint(); | 245 AddDriveMountPoint(); |
| 246 } | 246 } |
| 247 | 247 |
| 248 void DriveIntegrationService::AddDriveMountPoint() { | 248 void DriveIntegrationService::AddDriveMountPoint() { |
| 249 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 249 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 250 DCHECK(!file_system_proxy_.get()); | 250 DCHECK(!file_system_proxy_.get()); |
| 251 | 251 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 google_apis::DriveNotificationManager* drive_notification_manager = | 328 google_apis::DriveNotificationManager* drive_notification_manager = |
| 329 google_apis::DriveNotificationManagerFactory::GetForProfile(profile_); | 329 google_apis::DriveNotificationManagerFactory::GetForProfile(profile_); |
| 330 if (drive_notification_manager) { | 330 if (drive_notification_manager) { |
| 331 drive_notification_manager->AddObserver(this); | 331 drive_notification_manager->AddObserver(this); |
| 332 const bool registered = | 332 const bool registered = |
| 333 drive_notification_manager->push_notification_registered(); | 333 drive_notification_manager->push_notification_registered(); |
| 334 const char* status = (registered ? "registered" : "not registered"); | 334 const char* status = (registered ? "registered" : "not registered"); |
| 335 util::Log("Push notification is %s", status); | 335 util::Log("Push notification is %s", status); |
| 336 } | 336 } |
| 337 | 337 |
| 338 webapps_registry_->Update(); | 338 drive_app_registry_->Update(); |
| 339 AddDriveMountPoint(); | 339 AddDriveMountPoint(); |
| 340 } | 340 } |
| 341 | 341 |
| 342 void DriveIntegrationService::DisableDrive() { | 342 void DriveIntegrationService::DisableDrive() { |
| 343 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 343 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 344 | 344 |
| 345 drive_disabled_ = true; | 345 drive_disabled_ = true; |
| 346 // Change the download directory to the default value if the download | 346 // Change the download directory to the default value if the download |
| 347 // destination is set to under Drive mount point. | 347 // destination is set to under Drive mount point. |
| 348 PrefService* pref_service = profile_->GetPrefs(); | 348 PrefService* pref_service = profile_->GetPrefs(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 profile, NULL, base::FilePath(), NULL); | 424 profile, NULL, base::FilePath(), NULL); |
| 425 } else { | 425 } else { |
| 426 service = factory_for_test_.Run(profile); | 426 service = factory_for_test_.Run(profile); |
| 427 } | 427 } |
| 428 | 428 |
| 429 service->Initialize(); | 429 service->Initialize(); |
| 430 return service; | 430 return service; |
| 431 } | 431 } |
| 432 | 432 |
| 433 } // namespace drive | 433 } // namespace drive |
| OLD | NEW |