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/file_system.h" | 5 #include "chrome/browser/chromeos/drive/file_system.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/platform_file.h" | 11 #include "base/platform_file.h" |
12 #include "base/prefs/pref_change_registrar.h" | 12 #include "base/prefs/pref_change_registrar.h" |
13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
16 #include "chrome/browser/chromeos/drive/change_list_loader.h" | 16 #include "chrome/browser/chromeos/drive/change_list_loader.h" |
17 #include "chrome/browser/chromeos/drive/change_list_processor.h" | 17 #include "chrome/browser/chromeos/drive/change_list_processor.h" |
18 #include "chrome/browser/chromeos/drive/drive.pb.h" | 18 #include "chrome/browser/chromeos/drive/drive.pb.h" |
19 #include "chrome/browser/chromeos/drive/file_cache.h" | 19 #include "chrome/browser/chromeos/drive/file_cache.h" |
| 20 #include "chrome/browser/chromeos/drive/file_system/copy_operation.h" |
| 21 #include "chrome/browser/chromeos/drive/file_system/create_directory_operation.h
" |
| 22 #include "chrome/browser/chromeos/drive/file_system/create_file_operation.h" |
| 23 #include "chrome/browser/chromeos/drive/file_system/download_operation.h" |
| 24 #include "chrome/browser/chromeos/drive/file_system/move_operation.h" |
| 25 #include "chrome/browser/chromeos/drive/file_system/remove_operation.h" |
| 26 #include "chrome/browser/chromeos/drive/file_system/search_operation.h" |
| 27 #include "chrome/browser/chromeos/drive/file_system/touch_operation.h" |
| 28 #include "chrome/browser/chromeos/drive/file_system/update_operation.h" |
20 #include "chrome/browser/chromeos/drive/file_system_observer.h" | 29 #include "chrome/browser/chromeos/drive/file_system_observer.h" |
21 #include "chrome/browser/chromeos/drive/file_system_util.h" | 30 #include "chrome/browser/chromeos/drive/file_system_util.h" |
22 #include "chrome/browser/chromeos/drive/job_scheduler.h" | 31 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
23 #include "chrome/browser/chromeos/drive/remove_stale_cache_files.h" | 32 #include "chrome/browser/chromeos/drive/remove_stale_cache_files.h" |
24 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" | 33 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" |
25 #include "chrome/browser/chromeos/drive/search_metadata.h" | 34 #include "chrome/browser/chromeos/drive/search_metadata.h" |
26 #include "chrome/browser/google_apis/drive_api_parser.h" | 35 #include "chrome/browser/google_apis/drive_api_parser.h" |
27 #include "chrome/browser/google_apis/drive_api_util.h" | 36 #include "chrome/browser/google_apis/drive_api_util.h" |
28 #include "chrome/browser/google_apis/drive_service_interface.h" | 37 #include "chrome/browser/google_apis/drive_service_interface.h" |
29 #include "chrome/browser/profiles/profile.h" | 38 #include "chrome/browser/profiles/profile.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 void FileSystem::Reload() { | 106 void FileSystem::Reload() { |
98 resource_metadata_->ResetOnUIThread(base::Bind( | 107 resource_metadata_->ResetOnUIThread(base::Bind( |
99 &FileSystem::ReloadAfterReset, | 108 &FileSystem::ReloadAfterReset, |
100 weak_ptr_factory_.GetWeakPtr())); | 109 weak_ptr_factory_.GetWeakPtr())); |
101 } | 110 } |
102 | 111 |
103 void FileSystem::Initialize() { | 112 void FileSystem::Initialize() { |
104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
105 | 114 |
106 SetupChangeListLoader(); | 115 SetupChangeListLoader(); |
107 | 116 SetupOperations(); |
108 // Allocate the file system operation handlers. | |
109 operations_.Init(this, // OperationObserver | |
110 scheduler_, | |
111 resource_metadata_, | |
112 cache_, | |
113 this, // FileSystemInterface | |
114 drive_service_, | |
115 blocking_task_runner_); | |
116 | 117 |
117 PrefService* pref_service = profile_->GetPrefs(); | 118 PrefService* pref_service = profile_->GetPrefs(); |
118 hide_hosted_docs_ = pref_service->GetBoolean(prefs::kDisableDriveHostedFiles); | 119 hide_hosted_docs_ = pref_service->GetBoolean(prefs::kDisableDriveHostedFiles); |
119 | 120 |
120 InitializePreferenceObserver(); | 121 InitializePreferenceObserver(); |
121 } | 122 } |
122 | 123 |
123 void FileSystem::ReloadAfterReset(FileError error) { | 124 void FileSystem::ReloadAfterReset(FileError error) { |
124 if (error != FILE_ERROR_OK) { | 125 if (error != FILE_ERROR_OK) { |
125 LOG(ERROR) << "Failed to reset the resource metadata: " | 126 LOG(ERROR) << "Failed to reset the resource metadata: " |
126 << FileErrorToString(error); | 127 << FileErrorToString(error); |
127 return; | 128 return; |
128 } | 129 } |
129 | 130 |
130 SetupChangeListLoader(); | 131 SetupChangeListLoader(); |
131 | 132 |
132 change_list_loader_->LoadIfNeeded( | 133 change_list_loader_->LoadIfNeeded( |
133 DirectoryFetchInfo(), | 134 DirectoryFetchInfo(), |
134 base::Bind(&FileSystem::OnUpdateChecked, | 135 base::Bind(&FileSystem::OnUpdateChecked, |
135 weak_ptr_factory_.GetWeakPtr())); | 136 weak_ptr_factory_.GetWeakPtr())); |
136 } | 137 } |
137 | 138 |
138 void FileSystem::SetupChangeListLoader() { | 139 void FileSystem::SetupChangeListLoader() { |
139 change_list_loader_.reset(new internal::ChangeListLoader( | 140 change_list_loader_.reset(new internal::ChangeListLoader( |
140 blocking_task_runner_, resource_metadata_, scheduler_)); | 141 blocking_task_runner_, resource_metadata_, scheduler_)); |
141 change_list_loader_->AddObserver(this); | 142 change_list_loader_->AddObserver(this); |
142 } | 143 } |
143 | 144 |
| 145 void FileSystem::SetupOperations() { |
| 146 file_system::OperationObserver* observer = this; |
| 147 copy_operation_.reset( |
| 148 new file_system::CopyOperation(blocking_task_runner_, |
| 149 observer, |
| 150 scheduler_, |
| 151 resource_metadata_, |
| 152 cache_, |
| 153 this, |
| 154 drive_service_)); |
| 155 create_directory_operation_.reset(new file_system::CreateDirectoryOperation( |
| 156 blocking_task_runner_, observer, scheduler_, resource_metadata_)); |
| 157 create_file_operation_.reset(new file_system::CreateFileOperation( |
| 158 blocking_task_runner_, observer, scheduler_, resource_metadata_, cache_)); |
| 159 move_operation_.reset(new file_system::MoveOperation( |
| 160 observer, scheduler_, resource_metadata_)); |
| 161 remove_operation_.reset(new file_system::RemoveOperation( |
| 162 observer, scheduler_, resource_metadata_, cache_)); |
| 163 touch_operation_.reset(new file_system::TouchOperation( |
| 164 blocking_task_runner_, observer, scheduler_, resource_metadata_)); |
| 165 download_operation_.reset(new file_system::DownloadOperation( |
| 166 blocking_task_runner_, observer, scheduler_, resource_metadata_, cache_)); |
| 167 update_operation_.reset(new file_system::UpdateOperation( |
| 168 blocking_task_runner_, observer, scheduler_, resource_metadata_, cache_)); |
| 169 search_operation_.reset(new file_system::SearchOperation( |
| 170 blocking_task_runner_, scheduler_, resource_metadata_)); |
| 171 } |
| 172 |
144 void FileSystem::CheckForUpdates() { | 173 void FileSystem::CheckForUpdates() { |
145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
146 DVLOG(1) << "CheckForUpdates"; | 175 DVLOG(1) << "CheckForUpdates"; |
147 | 176 |
148 if (change_list_loader_) { | 177 if (change_list_loader_) { |
149 change_list_loader_->CheckForUpdates( | 178 change_list_loader_->CheckForUpdates( |
150 base::Bind(&FileSystem::OnUpdateChecked, | 179 base::Bind(&FileSystem::OnUpdateChecked, |
151 weak_ptr_factory_.GetWeakPtr())); | 180 weak_ptr_factory_.GetWeakPtr())); |
152 } | 181 } |
153 } | 182 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 entry.Pass(), | 238 entry.Pass(), |
210 base::Bind(&RunGetResourceEntryWithFilePathCallback, | 239 base::Bind(&RunGetResourceEntryWithFilePathCallback, |
211 callback, | 240 callback, |
212 file_path)); | 241 file_path)); |
213 } | 242 } |
214 | 243 |
215 void FileSystem::TransferFileFromRemoteToLocal( | 244 void FileSystem::TransferFileFromRemoteToLocal( |
216 const base::FilePath& remote_src_file_path, | 245 const base::FilePath& remote_src_file_path, |
217 const base::FilePath& local_dest_file_path, | 246 const base::FilePath& local_dest_file_path, |
218 const FileOperationCallback& callback) { | 247 const FileOperationCallback& callback) { |
219 | 248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
220 operations_.TransferFileFromRemoteToLocal(remote_src_file_path, | 249 DCHECK(!callback.is_null()); |
221 local_dest_file_path, | 250 copy_operation_->TransferFileFromRemoteToLocal(remote_src_file_path, |
222 callback); | 251 local_dest_file_path, |
| 252 callback); |
223 } | 253 } |
224 | 254 |
225 void FileSystem::TransferFileFromLocalToRemote( | 255 void FileSystem::TransferFileFromLocalToRemote( |
226 const base::FilePath& local_src_file_path, | 256 const base::FilePath& local_src_file_path, |
227 const base::FilePath& remote_dest_file_path, | 257 const base::FilePath& remote_dest_file_path, |
228 const FileOperationCallback& callback) { | 258 const FileOperationCallback& callback) { |
229 | 259 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
230 operations_.TransferFileFromLocalToRemote(local_src_file_path, | 260 DCHECK(!callback.is_null()); |
231 remote_dest_file_path, | 261 copy_operation_->TransferFileFromLocalToRemote(local_src_file_path, |
232 callback); | 262 remote_dest_file_path, |
| 263 callback); |
233 } | 264 } |
234 | 265 |
235 void FileSystem::Copy(const base::FilePath& src_file_path, | 266 void FileSystem::Copy(const base::FilePath& src_file_path, |
236 const base::FilePath& dest_file_path, | 267 const base::FilePath& dest_file_path, |
237 const FileOperationCallback& callback) { | 268 const FileOperationCallback& callback) { |
238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
239 DCHECK(!callback.is_null()); | 270 DCHECK(!callback.is_null()); |
240 operations_.Copy(src_file_path, dest_file_path, callback); | 271 copy_operation_->Copy(src_file_path, dest_file_path, callback); |
241 } | 272 } |
242 | 273 |
243 void FileSystem::Move(const base::FilePath& src_file_path, | 274 void FileSystem::Move(const base::FilePath& src_file_path, |
244 const base::FilePath& dest_file_path, | 275 const base::FilePath& dest_file_path, |
245 const FileOperationCallback& callback) { | 276 const FileOperationCallback& callback) { |
246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
247 DCHECK(!callback.is_null()); | 278 DCHECK(!callback.is_null()); |
248 operations_.Move(src_file_path, dest_file_path, callback); | 279 move_operation_->Move(src_file_path, dest_file_path, callback); |
249 } | 280 } |
250 | 281 |
251 void FileSystem::Remove(const base::FilePath& file_path, | 282 void FileSystem::Remove(const base::FilePath& file_path, |
252 bool is_recursive, | 283 bool is_recursive, |
253 const FileOperationCallback& callback) { | 284 const FileOperationCallback& callback) { |
254 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 285 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
255 DCHECK(!callback.is_null()); | 286 DCHECK(!callback.is_null()); |
256 operations_.Remove(file_path, is_recursive, callback); | 287 remove_operation_->Remove(file_path, is_recursive, callback); |
257 } | 288 } |
258 | 289 |
259 void FileSystem::CreateDirectory( | 290 void FileSystem::CreateDirectory( |
260 const base::FilePath& directory_path, | 291 const base::FilePath& directory_path, |
261 bool is_exclusive, | 292 bool is_exclusive, |
262 bool is_recursive, | 293 bool is_recursive, |
263 const FileOperationCallback& callback) { | 294 const FileOperationCallback& callback) { |
264 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 295 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
265 DCHECK(!callback.is_null()); | 296 DCHECK(!callback.is_null()); |
266 | 297 |
(...skipping 11 matching lines...) Expand all Loading... |
278 const FileOperationCallback& callback, | 309 const FileOperationCallback& callback, |
279 FileError load_error) { | 310 FileError load_error) { |
280 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 311 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
281 DCHECK(!callback.is_null()); | 312 DCHECK(!callback.is_null()); |
282 | 313 |
283 if (load_error != FILE_ERROR_OK) { | 314 if (load_error != FILE_ERROR_OK) { |
284 callback.Run(load_error); | 315 callback.Run(load_error); |
285 return; | 316 return; |
286 } | 317 } |
287 | 318 |
288 operations_.CreateDirectory( | 319 create_directory_operation_->CreateDirectory( |
289 directory_path, is_exclusive, is_recursive, callback); | 320 directory_path, is_exclusive, is_recursive, callback); |
290 } | 321 } |
291 | 322 |
292 void FileSystem::CreateFile(const base::FilePath& file_path, | 323 void FileSystem::CreateFile(const base::FilePath& file_path, |
293 bool is_exclusive, | 324 bool is_exclusive, |
294 const FileOperationCallback& callback) { | 325 const FileOperationCallback& callback) { |
295 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 326 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
296 DCHECK(!callback.is_null()); | 327 DCHECK(!callback.is_null()); |
297 | 328 create_file_operation_->CreateFile(file_path, is_exclusive, callback); |
298 operations_.CreateFile(file_path, is_exclusive, callback); | |
299 } | 329 } |
300 | 330 |
301 void FileSystem::TouchFile(const base::FilePath& file_path, | 331 void FileSystem::TouchFile(const base::FilePath& file_path, |
302 const base::Time& last_access_time, | 332 const base::Time& last_access_time, |
303 const base::Time& last_modified_time, | 333 const base::Time& last_modified_time, |
304 const FileOperationCallback& callback) { | 334 const FileOperationCallback& callback) { |
305 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 335 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
306 DCHECK(!last_access_time.is_null()); | 336 DCHECK(!last_access_time.is_null()); |
307 DCHECK(!last_modified_time.is_null()); | 337 DCHECK(!last_modified_time.is_null()); |
308 DCHECK(!callback.is_null()); | 338 DCHECK(!callback.is_null()); |
309 | 339 touch_operation_->TouchFile( |
310 operations_.TouchFile( | |
311 file_path, last_access_time, last_modified_time, callback); | 340 file_path, last_access_time, last_modified_time, callback); |
312 } | 341 } |
313 | 342 |
314 void FileSystem::Pin(const base::FilePath& file_path, | 343 void FileSystem::Pin(const base::FilePath& file_path, |
315 const FileOperationCallback& callback) { | 344 const FileOperationCallback& callback) { |
316 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 345 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
317 DCHECK(!callback.is_null()); | 346 DCHECK(!callback.is_null()); |
318 | 347 |
319 GetResourceEntryByPath(file_path, | 348 GetResourceEntryByPath(file_path, |
320 base::Bind(&FileSystem::PinAfterGetResourceEntryByPath, | 349 base::Bind(&FileSystem::PinAfterGetResourceEntryByPath, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 403 |
375 cache_->UnpinOnUIThread(entry->resource_id(), | 404 cache_->UnpinOnUIThread(entry->resource_id(), |
376 entry->file_specific_info().file_md5(), callback); | 405 entry->file_specific_info().file_md5(), callback); |
377 } | 406 } |
378 | 407 |
379 void FileSystem::GetFileByPath(const base::FilePath& file_path, | 408 void FileSystem::GetFileByPath(const base::FilePath& file_path, |
380 const GetFileCallback& callback) { | 409 const GetFileCallback& callback) { |
381 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 410 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
382 DCHECK(!callback.is_null()); | 411 DCHECK(!callback.is_null()); |
383 | 412 |
384 operations_.EnsureFileDownloadedByPath( | 413 download_operation_->EnsureFileDownloadedByPath( |
385 file_path, | 414 file_path, |
386 ClientContext(USER_INITIATED), | 415 ClientContext(USER_INITIATED), |
387 GetFileContentInitializedCallback(), | 416 GetFileContentInitializedCallback(), |
388 google_apis::GetContentCallback(), | 417 google_apis::GetContentCallback(), |
389 callback); | 418 callback); |
390 } | 419 } |
391 | 420 |
392 void FileSystem::GetFileByResourceId( | 421 void FileSystem::GetFileByResourceId( |
393 const std::string& resource_id, | 422 const std::string& resource_id, |
394 const ClientContext& context, | 423 const ClientContext& context, |
395 const GetFileCallback& get_file_callback, | 424 const GetFileCallback& get_file_callback, |
396 const google_apis::GetContentCallback& get_content_callback) { | 425 const google_apis::GetContentCallback& get_content_callback) { |
397 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 426 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
398 DCHECK(!resource_id.empty()); | 427 DCHECK(!resource_id.empty()); |
399 DCHECK(!get_file_callback.is_null()); | 428 DCHECK(!get_file_callback.is_null()); |
400 | 429 |
401 operations_.EnsureFileDownloadedByResourceId( | 430 download_operation_->EnsureFileDownloadedByResourceId( |
402 resource_id, | 431 resource_id, |
403 context, | 432 context, |
404 GetFileContentInitializedCallback(), | 433 GetFileContentInitializedCallback(), |
405 get_content_callback, | 434 get_content_callback, |
406 get_file_callback); | 435 get_file_callback); |
407 } | 436 } |
408 | 437 |
409 void FileSystem::GetFileContentByPath( | 438 void FileSystem::GetFileContentByPath( |
410 const base::FilePath& file_path, | 439 const base::FilePath& file_path, |
411 const GetFileContentInitializedCallback& initialized_callback, | 440 const GetFileContentInitializedCallback& initialized_callback, |
412 const google_apis::GetContentCallback& get_content_callback, | 441 const google_apis::GetContentCallback& get_content_callback, |
413 const FileOperationCallback& completion_callback) { | 442 const FileOperationCallback& completion_callback) { |
414 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 443 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
415 DCHECK(!initialized_callback.is_null()); | 444 DCHECK(!initialized_callback.is_null()); |
416 DCHECK(!get_content_callback.is_null()); | 445 DCHECK(!get_content_callback.is_null()); |
417 DCHECK(!completion_callback.is_null()); | 446 DCHECK(!completion_callback.is_null()); |
418 | 447 |
419 operations_.EnsureFileDownloadedByPath( | 448 download_operation_->EnsureFileDownloadedByPath( |
420 file_path, | 449 file_path, |
421 ClientContext(USER_INITIATED), | 450 ClientContext(USER_INITIATED), |
422 initialized_callback, | 451 initialized_callback, |
423 get_content_callback, | 452 get_content_callback, |
424 base::Bind(&GetFileCallbackToFileOperationCallbackAdapter, | 453 base::Bind(&GetFileCallbackToFileOperationCallbackAdapter, |
425 completion_callback)); | 454 completion_callback)); |
426 } | 455 } |
427 | 456 |
428 void FileSystem::GetResourceEntryByPath( | 457 void FileSystem::GetResourceEntryByPath( |
429 const base::FilePath& file_path, | 458 const base::FilePath& file_path, |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 entry->resource_id(), | 671 entry->resource_id(), |
643 callback); | 672 callback); |
644 } | 673 } |
645 | 674 |
646 void FileSystem::UpdateFileByResourceId( | 675 void FileSystem::UpdateFileByResourceId( |
647 const std::string& resource_id, | 676 const std::string& resource_id, |
648 const ClientContext& context, | 677 const ClientContext& context, |
649 const FileOperationCallback& callback) { | 678 const FileOperationCallback& callback) { |
650 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 679 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
651 DCHECK(!callback.is_null()); | 680 DCHECK(!callback.is_null()); |
652 | 681 update_operation_->UpdateFileByResourceId(resource_id, context, callback); |
653 operations_.UpdateFileByResourceId(resource_id, context, callback); | |
654 } | 682 } |
655 | 683 |
656 void FileSystem::GetAvailableSpace( | 684 void FileSystem::GetAvailableSpace( |
657 const GetAvailableSpaceCallback& callback) { | 685 const GetAvailableSpaceCallback& callback) { |
658 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 686 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
659 DCHECK(!callback.is_null()); | 687 DCHECK(!callback.is_null()); |
660 | 688 |
661 scheduler_->GetAboutResource( | 689 scheduler_->GetAboutResource( |
662 base::Bind(&FileSystem::OnGetAboutResource, | 690 base::Bind(&FileSystem::OnGetAboutResource, |
663 weak_ptr_factory_.GetWeakPtr(), | 691 weak_ptr_factory_.GetWeakPtr(), |
(...skipping 17 matching lines...) Expand all Loading... |
681 callback.Run(FILE_ERROR_OK, | 709 callback.Run(FILE_ERROR_OK, |
682 about_resource->quota_bytes_total(), | 710 about_resource->quota_bytes_total(), |
683 about_resource->quota_bytes_used()); | 711 about_resource->quota_bytes_used()); |
684 } | 712 } |
685 | 713 |
686 void FileSystem::Search(const std::string& search_query, | 714 void FileSystem::Search(const std::string& search_query, |
687 const GURL& next_feed, | 715 const GURL& next_feed, |
688 const SearchCallback& callback) { | 716 const SearchCallback& callback) { |
689 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 717 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
690 DCHECK(!callback.is_null()); | 718 DCHECK(!callback.is_null()); |
691 | 719 search_operation_->Search(search_query, next_feed, callback); |
692 operations_.Search(search_query, next_feed, callback); | |
693 } | 720 } |
694 | 721 |
695 void FileSystem::SearchMetadata(const std::string& query, | 722 void FileSystem::SearchMetadata(const std::string& query, |
696 int options, | 723 int options, |
697 int at_most_num_matches, | 724 int at_most_num_matches, |
698 const SearchMetadataCallback& callback) { | 725 const SearchMetadataCallback& callback) { |
699 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 726 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
700 | 727 |
701 if (hide_hosted_docs_) | 728 if (hide_hosted_docs_) |
702 options |= SEARCH_METADATA_EXCLUDE_HOSTED_DOCUMENTS; | 729 options |= SEARCH_METADATA_EXCLUDE_HOSTED_DOCUMENTS; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 // Open->Open->modify->Close->modify->Close; the second modify may not be | 883 // Open->Open->modify->Close->modify->Close; the second modify may not be |
857 // synchronized to the server since it is already Closed on the cache). | 884 // synchronized to the server since it is already Closed on the cache). |
858 if (open_files_.find(file_path) != open_files_.end()) { | 885 if (open_files_.find(file_path) != open_files_.end()) { |
859 base::MessageLoopProxy::current()->PostTask( | 886 base::MessageLoopProxy::current()->PostTask( |
860 FROM_HERE, | 887 FROM_HERE, |
861 base::Bind(callback, FILE_ERROR_IN_USE, base::FilePath())); | 888 base::Bind(callback, FILE_ERROR_IN_USE, base::FilePath())); |
862 return; | 889 return; |
863 } | 890 } |
864 open_files_.insert(file_path); | 891 open_files_.insert(file_path); |
865 | 892 |
866 operations_.EnsureFileDownloadedByPath( | 893 download_operation_->EnsureFileDownloadedByPath( |
867 file_path, | 894 file_path, |
868 ClientContext(USER_INITIATED), | 895 ClientContext(USER_INITIATED), |
869 GetFileContentInitializedCallback(), | 896 GetFileContentInitializedCallback(), |
870 google_apis::GetContentCallback(), | 897 google_apis::GetContentCallback(), |
871 base::Bind(&FileSystem::OpenFileAfterFileDownloaded, | 898 base::Bind(&FileSystem::OpenFileAfterFileDownloaded, |
872 weak_ptr_factory_.GetWeakPtr(), | 899 weak_ptr_factory_.GetWeakPtr(), |
873 file_path, | 900 file_path, |
874 base::Bind(&FileSystem::OnOpenFileFinished, | 901 base::Bind(&FileSystem::OnOpenFileFinished, |
875 weak_ptr_factory_.GetWeakPtr(), | 902 weak_ptr_factory_.GetWeakPtr(), |
876 file_path, | 903 file_path, |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 return; | 1134 return; |
1108 } | 1135 } |
1109 | 1136 |
1110 PlatformFileInfoProto entry_file_info; | 1137 PlatformFileInfoProto entry_file_info; |
1111 util::ConvertPlatformFileInfoToResourceEntry(*file_info, &entry_file_info); | 1138 util::ConvertPlatformFileInfoToResourceEntry(*file_info, &entry_file_info); |
1112 *entry->mutable_file_info() = entry_file_info; | 1139 *entry->mutable_file_info() = entry_file_info; |
1113 callback.Run(FILE_ERROR_OK, entry.Pass()); | 1140 callback.Run(FILE_ERROR_OK, entry.Pass()); |
1114 } | 1141 } |
1115 | 1142 |
1116 } // namespace drive | 1143 } // namespace drive |
OLD | NEW |