| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/sync/entry_update_performer.h" | 5 #include "chrome/browser/chromeos/drive/sync/entry_update_performer.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } | 316 } |
| 317 | 317 |
| 318 // Perform content update. | 318 // Perform content update. |
| 319 if (local_state->should_content_update) { | 319 if (local_state->should_content_update) { |
| 320 if (local_state->entry.resource_id().empty()) { | 320 if (local_state->entry.resource_id().empty()) { |
| 321 // Not locking the loader intentionally here to avoid making the UI | 321 // Not locking the loader intentionally here to avoid making the UI |
| 322 // unresponsive while uploading large files. | 322 // unresponsive while uploading large files. |
| 323 // FinishUpdate() is responsible to resolve conflicts caused by this. | 323 // FinishUpdate() is responsible to resolve conflicts caused by this. |
| 324 scoped_ptr<base::ScopedClosureRunner> null_loader_lock; | 324 scoped_ptr<base::ScopedClosureRunner> null_loader_lock; |
| 325 | 325 |
| 326 DriveUploader::UploadNewFileOptions options; | 326 UploadNewFileOptions options; |
| 327 options.modified_date = last_modified; | 327 options.modified_date = last_modified; |
| 328 options.last_viewed_by_me_date = last_accessed; | 328 options.last_viewed_by_me_date = last_accessed; |
| 329 options.properties = properties; | 329 options.properties = properties; |
| 330 LocalState* const local_state_ptr = local_state.get(); | 330 LocalState* const local_state_ptr = local_state.get(); |
| 331 scheduler_->UploadNewFile( | 331 scheduler_->UploadNewFile( |
| 332 local_state_ptr->parent_entry.resource_id(), | 332 local_state_ptr->parent_entry.resource_id(), |
| 333 local_state_ptr->drive_file_path, local_state_ptr->cache_file_path, | 333 local_state_ptr->drive_file_path, local_state_ptr->cache_file_path, |
| 334 local_state_ptr->entry.title(), | 334 local_state_ptr->entry.title(), |
| 335 local_state_ptr->entry.file_specific_info().content_mime_type(), | 335 local_state_ptr->entry.file_specific_info().content_mime_type(), |
| 336 options, context, | 336 options, context, |
| 337 base::Bind(&EntryUpdatePerformer::UpdateEntryAfterUpdateResource, | 337 base::Bind(&EntryUpdatePerformer::UpdateEntryAfterUpdateResource, |
| 338 weak_ptr_factory_.GetWeakPtr(), context, callback, | 338 weak_ptr_factory_.GetWeakPtr(), context, callback, |
| 339 base::Passed(&local_state), | 339 base::Passed(&local_state), |
| 340 base::Passed(&null_loader_lock))); | 340 base::Passed(&null_loader_lock))); |
| 341 } else { | 341 } else { |
| 342 DriveUploader::UploadExistingFileOptions options; | 342 UploadExistingFileOptions options; |
| 343 options.title = local_state->entry.title(); | 343 options.title = local_state->entry.title(); |
| 344 options.parent_resource_id = local_state->parent_entry.resource_id(); | 344 options.parent_resource_id = local_state->parent_entry.resource_id(); |
| 345 options.modified_date = last_modified; | 345 options.modified_date = last_modified; |
| 346 options.last_viewed_by_me_date = last_accessed; | 346 options.last_viewed_by_me_date = last_accessed; |
| 347 options.properties = properties; | 347 options.properties = properties; |
| 348 LocalState* const local_state_ptr = local_state.get(); | 348 LocalState* const local_state_ptr = local_state.get(); |
| 349 scheduler_->UploadExistingFile( | 349 scheduler_->UploadExistingFile( |
| 350 local_state_ptr->entry.resource_id(), | 350 local_state_ptr->entry.resource_id(), |
| 351 local_state_ptr->drive_file_path, local_state_ptr->cache_file_path, | 351 local_state_ptr->drive_file_path, local_state_ptr->cache_file_path, |
| 352 local_state_ptr->entry.file_specific_info().content_mime_type(), | 352 local_state_ptr->entry.file_specific_info().content_mime_type(), |
| 353 options, context, | 353 options, context, |
| 354 base::Bind(&EntryUpdatePerformer::UpdateEntryAfterUpdateResource, | 354 base::Bind(&EntryUpdatePerformer::UpdateEntryAfterUpdateResource, |
| 355 weak_ptr_factory_.GetWeakPtr(), context, callback, | 355 weak_ptr_factory_.GetWeakPtr(), context, callback, |
| 356 base::Passed(&local_state), | 356 base::Passed(&local_state), |
| 357 base::Passed(scoped_ptr<base::ScopedClosureRunner>()))); | 357 base::Passed(scoped_ptr<base::ScopedClosureRunner>()))); |
| 358 } | 358 } |
| 359 return; | 359 return; |
| 360 } | 360 } |
| 361 | 361 |
| 362 // Create directory. | 362 // Create directory. |
| 363 if (local_state->entry.file_info().is_directory() && | 363 if (local_state->entry.file_info().is_directory() && |
| 364 local_state->entry.resource_id().empty()) { | 364 local_state->entry.resource_id().empty()) { |
| 365 // Lock the loader to avoid race conditions. | 365 // Lock the loader to avoid race conditions. |
| 366 scoped_ptr<base::ScopedClosureRunner> loader_lock = | 366 scoped_ptr<base::ScopedClosureRunner> loader_lock = |
| 367 loader_controller_->GetLock(); | 367 loader_controller_->GetLock(); |
| 368 | 368 |
| 369 DriveServiceInterface::AddNewDirectoryOptions options; | 369 AddNewDirectoryOptions options; |
| 370 options.modified_date = last_modified; | 370 options.modified_date = last_modified; |
| 371 options.last_viewed_by_me_date = last_accessed; | 371 options.last_viewed_by_me_date = last_accessed; |
| 372 options.properties = properties; | 372 options.properties = properties; |
| 373 LocalState* const local_state_ptr = local_state.get(); | 373 LocalState* const local_state_ptr = local_state.get(); |
| 374 scheduler_->AddNewDirectory( | 374 scheduler_->AddNewDirectory( |
| 375 local_state_ptr->parent_entry.resource_id(), | 375 local_state_ptr->parent_entry.resource_id(), |
| 376 local_state_ptr->entry.title(), options, context, | 376 local_state_ptr->entry.title(), options, context, |
| 377 base::Bind(&EntryUpdatePerformer::UpdateEntryAfterUpdateResource, | 377 base::Bind(&EntryUpdatePerformer::UpdateEntryAfterUpdateResource, |
| 378 weak_ptr_factory_.GetWeakPtr(), context, callback, | 378 weak_ptr_factory_.GetWeakPtr(), context, callback, |
| 379 base::Passed(&local_state), base::Passed(&loader_lock))); | 379 base::Passed(&local_state), base::Passed(&loader_lock))); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 FileError error) { | 439 FileError error) { |
| 440 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 440 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 441 DCHECK(!callback.is_null()); | 441 DCHECK(!callback.is_null()); |
| 442 | 442 |
| 443 delegate_->OnFileChangedByOperation(*changed_files); | 443 delegate_->OnFileChangedByOperation(*changed_files); |
| 444 callback.Run(error); | 444 callback.Run(error); |
| 445 } | 445 } |
| 446 | 446 |
| 447 } // namespace internal | 447 } // namespace internal |
| 448 } // namespace drive | 448 } // namespace drive |
| OLD | NEW |