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_system_service.h" | 5 #include "chrome/browser/chromeos/drive/drive_system_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 profile_sync_service->UpdateRegisteredInvalidationIds( | 184 profile_sync_service->UpdateRegisteredInvalidationIds( |
185 this, syncer::ObjectIdSet()); | 185 this, syncer::ObjectIdSet()); |
186 } | 186 } |
187 profile_sync_service->UnregisterInvalidationHandler(this); | 187 profile_sync_service->UnregisterInvalidationHandler(this); |
188 push_notification_registered_ = false; | 188 push_notification_registered_ = false; |
189 } | 189 } |
190 | 190 |
191 RemoveDriveMountPoint(); | 191 RemoveDriveMountPoint(); |
192 } | 192 } |
193 | 193 |
| 194 void DriveSystemService::AddObserver(DriveSystemServiceObserver* observer) { |
| 195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 196 observers_.AddObserver(observer); |
| 197 } |
| 198 |
| 199 void DriveSystemService::RemoveObserver(DriveSystemServiceObserver* observer) { |
| 200 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 201 observers_.RemoveObserver(observer); |
| 202 } |
| 203 |
194 bool DriveSystemService::IsDriveEnabled() { | 204 bool DriveSystemService::IsDriveEnabled() { |
195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
196 | 206 |
197 if (!IsDriveEnabledForProfile(profile_)) | 207 if (!IsDriveEnabledForProfile(profile_)) |
198 return false; | 208 return false; |
199 | 209 |
200 // Drive may be disabled for cache initialization failure, etc. | 210 // Drive may be disabled for cache initialization failure, etc. |
201 if (drive_disabled_) | 211 if (drive_disabled_) |
202 return false; | 212 return false; |
203 | 213 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 file_system_proxy_ = new DriveFileSystemProxy(file_system_.get()); | 312 file_system_proxy_ = new DriveFileSystemProxy(file_system_.get()); |
303 | 313 |
304 bool success = mount_points->RegisterRemoteFileSystem( | 314 bool success = mount_points->RegisterRemoteFileSystem( |
305 drive_mount_point.BaseName().AsUTF8Unsafe(), | 315 drive_mount_point.BaseName().AsUTF8Unsafe(), |
306 fileapi::kFileSystemTypeDrive, | 316 fileapi::kFileSystemTypeDrive, |
307 file_system_proxy_, | 317 file_system_proxy_, |
308 drive_mount_point); | 318 drive_mount_point); |
309 | 319 |
310 if (success) { | 320 if (success) { |
311 event_logger_->Log("AddDriveMountPoint"); | 321 event_logger_->Log("AddDriveMountPoint"); |
312 file_system_->NotifyFileSystemMounted(); | 322 FOR_EACH_OBSERVER(DriveSystemServiceObserver, observers_, |
| 323 OnFileSystemMounted()); |
313 } | 324 } |
314 } | 325 } |
315 | 326 |
316 void DriveSystemService::RemoveDriveMountPoint() { | 327 void DriveSystemService::RemoveDriveMountPoint() { |
317 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 328 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
318 | 329 |
319 file_system_->NotifyFileSystemToBeUnmounted(); | 330 FOR_EACH_OBSERVER(DriveSystemServiceObserver, observers_, |
| 331 OnFileSystemBeingUnmounted()); |
320 | 332 |
321 fileapi::ExternalMountPoints* mount_points = | 333 fileapi::ExternalMountPoints* mount_points = |
322 BrowserContext::GetMountPoints(profile_); | 334 BrowserContext::GetMountPoints(profile_); |
323 DCHECK(mount_points); | 335 DCHECK(mount_points); |
324 | 336 |
325 mount_points->RevokeFileSystem( | 337 mount_points->RevokeFileSystem( |
326 util::GetDriveMountPointPath().BaseName().AsUTF8Unsafe()); | 338 util::GetDriveMountPointPath().BaseName().AsUTF8Unsafe()); |
327 if (file_system_proxy_) { | 339 if (file_system_proxy_) { |
328 file_system_proxy_->DetachFromFileSystem(); | 340 file_system_proxy_->DetachFromFileSystem(); |
329 file_system_proxy_ = NULL; | 341 file_system_proxy_ = NULL; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 if (factory_for_test_.is_null()) | 470 if (factory_for_test_.is_null()) |
459 service = new DriveSystemService(profile, NULL, base::FilePath(), NULL); | 471 service = new DriveSystemService(profile, NULL, base::FilePath(), NULL); |
460 else | 472 else |
461 service = factory_for_test_.Run(profile); | 473 service = factory_for_test_.Run(profile); |
462 | 474 |
463 service->Initialize(); | 475 service->Initialize(); |
464 return service; | 476 return service; |
465 } | 477 } |
466 | 478 |
467 } // namespace drive | 479 } // namespace drive |
OLD | NEW |