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 "base/threading/sequenced_worker_pool.h" | 9 #include "base/threading/sequenced_worker_pool.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 GURL(google_apis::DriveApiUrlGenerator::kBaseUrlForProduction), | 111 GURL(google_apis::DriveApiUrlGenerator::kBaseUrlForProduction), |
112 GetDriveUserAgent())); | 112 GetDriveUserAgent())); |
113 } else { | 113 } else { |
114 drive_service_.reset(new google_apis::GDataWapiService( | 114 drive_service_.reset(new google_apis::GDataWapiService( |
115 g_browser_process->system_request_context(), | 115 g_browser_process->system_request_context(), |
116 GURL(google_apis::GDataWapiUrlGenerator::kBaseUrlForProduction), | 116 GURL(google_apis::GDataWapiUrlGenerator::kBaseUrlForProduction), |
117 GetDriveUserAgent())); | 117 GetDriveUserAgent())); |
118 } | 118 } |
119 scheduler_.reset(new JobScheduler(profile_, drive_service_.get())); | 119 scheduler_.reset(new JobScheduler(profile_, drive_service_.get())); |
120 cache_.reset(new internal::FileCache( | 120 cache_.reset(new internal::FileCache( |
121 !test_cache_root.empty() ? test_cache_root : | 121 !test_cache_root.empty() ? test_cache_root |
122 util::GetCacheRootPath(profile), | 122 : util::GetCacheRootPath(profile), |
123 blocking_task_runner_, | 123 blocking_task_runner_.get(), |
124 NULL /* free_disk_space_getter */)); | 124 NULL /* free_disk_space_getter */)); |
125 drive_app_registry_.reset(new DriveAppRegistry(scheduler_.get())); | 125 drive_app_registry_.reset(new DriveAppRegistry(scheduler_.get())); |
126 | 126 |
127 // We can call FileCache::GetCacheDirectoryPath safely even before the cache | 127 // We can call FileCache::GetCacheDirectoryPath safely even before the cache |
128 // gets initialized. | 128 // gets initialized. |
129 resource_metadata_.reset(new internal::ResourceMetadata( | 129 resource_metadata_.reset(new internal::ResourceMetadata( |
130 cache_->GetCacheDirectoryPath(internal::FileCache::CACHE_TYPE_META), | 130 cache_->GetCacheDirectoryPath(internal::FileCache::CACHE_TYPE_META), |
131 blocking_task_runner_)); | 131 blocking_task_runner_)); |
132 | 132 |
133 file_system_.reset(test_file_system ? test_file_system : | 133 file_system_.reset(test_file_system |
134 new FileSystem(profile_, | 134 ? test_file_system |
135 cache_.get(), | 135 : new FileSystem(profile_, |
136 drive_service_.get(), | 136 cache_.get(), |
137 scheduler_.get(), | 137 drive_service_.get(), |
138 resource_metadata_.get(), | 138 scheduler_.get(), |
139 blocking_task_runner_)); | 139 resource_metadata_.get(), |
| 140 blocking_task_runner_.get())); |
140 file_write_helper_.reset(new FileWriteHelper(file_system())); | 141 file_write_helper_.reset(new FileWriteHelper(file_system())); |
141 download_handler_.reset(new DownloadHandler(file_write_helper(), | 142 download_handler_.reset(new DownloadHandler(file_write_helper(), |
142 file_system())); | 143 file_system())); |
143 debug_info_collector_.reset( | 144 debug_info_collector_.reset( |
144 new DebugInfoCollector(file_system(), cache_.get())); | 145 new DebugInfoCollector(file_system(), cache_.get())); |
145 } | 146 } |
146 | 147 |
147 DriveIntegrationService::~DriveIntegrationService() { | 148 DriveIntegrationService::~DriveIntegrationService() { |
148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
149 } | 150 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 const base::FilePath drive_mount_point = util::GetDriveMountPointPath(); | 253 const base::FilePath drive_mount_point = util::GetDriveMountPointPath(); |
253 fileapi::ExternalMountPoints* mount_points = | 254 fileapi::ExternalMountPoints* mount_points = |
254 BrowserContext::GetMountPoints(profile_); | 255 BrowserContext::GetMountPoints(profile_); |
255 DCHECK(mount_points); | 256 DCHECK(mount_points); |
256 | 257 |
257 file_system_proxy_ = new FileSystemProxy(file_system_.get()); | 258 file_system_proxy_ = new FileSystemProxy(file_system_.get()); |
258 | 259 |
259 bool success = mount_points->RegisterRemoteFileSystem( | 260 bool success = mount_points->RegisterRemoteFileSystem( |
260 drive_mount_point.BaseName().AsUTF8Unsafe(), | 261 drive_mount_point.BaseName().AsUTF8Unsafe(), |
261 fileapi::kFileSystemTypeDrive, | 262 fileapi::kFileSystemTypeDrive, |
262 file_system_proxy_, | 263 file_system_proxy_.get(), |
263 drive_mount_point); | 264 drive_mount_point); |
264 | 265 |
265 if (success) { | 266 if (success) { |
266 util::Log("Drive mount point is added"); | 267 util::Log("Drive mount point is added"); |
267 FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_, | 268 FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_, |
268 OnFileSystemMounted()); | 269 OnFileSystemMounted()); |
269 } | 270 } |
270 } | 271 } |
271 | 272 |
272 void DriveIntegrationService::RemoveDriveMountPoint() { | 273 void DriveIntegrationService::RemoveDriveMountPoint() { |
273 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
274 | 275 |
275 job_list()->CancelAllJobs(); | 276 job_list()->CancelAllJobs(); |
276 | 277 |
277 FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_, | 278 FOR_EACH_OBSERVER(DriveIntegrationServiceObserver, observers_, |
278 OnFileSystemBeingUnmounted()); | 279 OnFileSystemBeingUnmounted()); |
279 | 280 |
280 fileapi::ExternalMountPoints* mount_points = | 281 fileapi::ExternalMountPoints* mount_points = |
281 BrowserContext::GetMountPoints(profile_); | 282 BrowserContext::GetMountPoints(profile_); |
282 DCHECK(mount_points); | 283 DCHECK(mount_points); |
283 | 284 |
284 mount_points->RevokeFileSystem( | 285 mount_points->RevokeFileSystem( |
285 util::GetDriveMountPointPath().BaseName().AsUTF8Unsafe()); | 286 util::GetDriveMountPointPath().BaseName().AsUTF8Unsafe()); |
286 if (file_system_proxy_) { | 287 if (file_system_proxy_.get()) { |
287 file_system_proxy_->DetachFromFileSystem(); | 288 file_system_proxy_->DetachFromFileSystem(); |
288 file_system_proxy_ = NULL; | 289 file_system_proxy_ = NULL; |
289 } | 290 } |
290 util::Log("Drive mount point is removed"); | 291 util::Log("Drive mount point is removed"); |
291 } | 292 } |
292 | 293 |
293 void DriveIntegrationService::InitializeAfterCacheInitialized(bool success) { | 294 void DriveIntegrationService::InitializeAfterCacheInitialized(bool success) { |
294 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 295 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
295 | 296 |
296 if (!success) { | 297 if (!success) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 profile, NULL, base::FilePath(), NULL); | 425 profile, NULL, base::FilePath(), NULL); |
425 } else { | 426 } else { |
426 service = factory_for_test_.Run(profile); | 427 service = factory_for_test_.Run(profile); |
427 } | 428 } |
428 | 429 |
429 service->Initialize(); | 430 service->Initialize(); |
430 return service; | 431 return service; |
431 } | 432 } |
432 | 433 |
433 } // namespace drive | 434 } // namespace drive |
OLD | NEW |