Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.cc

Issue 98803002: Dispatch FileStatus change events for LocalToRemote sync too (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/sync_file_system/drive_backend/local_to_remote_syncer.h " 5 #include "chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h "
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } // namespace 77 } // namespace
78 78
79 LocalToRemoteSyncer::LocalToRemoteSyncer(SyncEngineContext* sync_context, 79 LocalToRemoteSyncer::LocalToRemoteSyncer(SyncEngineContext* sync_context,
80 const FileChange& local_change, 80 const FileChange& local_change,
81 const base::FilePath& local_path, 81 const base::FilePath& local_path,
82 const fileapi::FileSystemURL& url) 82 const fileapi::FileSystemURL& url)
83 : sync_context_(sync_context), 83 : sync_context_(sync_context),
84 local_change_(local_change), 84 local_change_(local_change),
85 local_path_(local_path), 85 local_path_(local_path),
86 url_(url), 86 url_(url),
87 sync_action_(SYNC_ACTION_NONE),
87 weak_ptr_factory_(this) { 88 weak_ptr_factory_(this) {
88 } 89 }
89 90
90 LocalToRemoteSyncer::~LocalToRemoteSyncer() { 91 LocalToRemoteSyncer::~LocalToRemoteSyncer() {
91 } 92 }
92 93
93 void LocalToRemoteSyncer::Run(const SyncStatusCallback& callback) { 94 void LocalToRemoteSyncer::Run(const SyncStatusCallback& callback) {
94 if (!IsContextReady()) { 95 if (!IsContextReady()) {
95 NOTREACHED(); 96 NOTREACHED();
96 callback.Run(SYNC_STATUS_FAILED); 97 callback.Run(SYNC_STATUS_FAILED);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // Non-conflicting local folder creation to existing remote folder. 314 // Non-conflicting local folder creation to existing remote folder.
314 DCHECK_EQ(FILE_KIND_FOLDER, synced_details.file_kind()); 315 DCHECK_EQ(FILE_KIND_FOLDER, synced_details.file_kind());
315 callback.Run(SYNC_STATUS_OK); 316 callback.Run(SYNC_STATUS_OK);
316 } 317 }
317 318
318 void LocalToRemoteSyncer::DeleteRemoteFile( 319 void LocalToRemoteSyncer::DeleteRemoteFile(
319 const SyncStatusCallback& callback) { 320 const SyncStatusCallback& callback) {
320 DCHECK(remote_file_tracker_); 321 DCHECK(remote_file_tracker_);
321 DCHECK(remote_file_tracker_->has_synced_details()); 322 DCHECK(remote_file_tracker_->has_synced_details());
322 323
324 sync_action_ = SYNC_ACTION_DELETED;
323 drive_service()->DeleteResource( 325 drive_service()->DeleteResource(
324 remote_file_tracker_->file_id(), 326 remote_file_tracker_->file_id(),
325 remote_file_tracker_->synced_details().etag(), 327 remote_file_tracker_->synced_details().etag(),
326 base::Bind(&LocalToRemoteSyncer::DidDeleteRemoteFile, 328 base::Bind(&LocalToRemoteSyncer::DidDeleteRemoteFile,
327 weak_ptr_factory_.GetWeakPtr(), 329 weak_ptr_factory_.GetWeakPtr(),
328 callback)); 330 callback));
329 } 331 }
330 332
331 void LocalToRemoteSyncer::DidDeleteRemoteFile( 333 void LocalToRemoteSyncer::DidDeleteRemoteFile(
332 const SyncStatusCallback& callback, 334 const SyncStatusCallback& callback,
(...skipping 27 matching lines...) Expand all
360 362
361 void LocalToRemoteSyncer::DidGetMD5ForUpload( 363 void LocalToRemoteSyncer::DidGetMD5ForUpload(
362 const SyncStatusCallback& callback, 364 const SyncStatusCallback& callback,
363 const std::string& local_file_md5) { 365 const std::string& local_file_md5) {
364 if (local_file_md5 == remote_file_tracker_->synced_details().md5()) { 366 if (local_file_md5 == remote_file_tracker_->synced_details().md5()) {
365 // Local file is not changed. 367 // Local file is not changed.
366 callback.Run(SYNC_STATUS_OK); 368 callback.Run(SYNC_STATUS_OK);
367 return; 369 return;
368 } 370 }
369 371
372 sync_action_ = SYNC_ACTION_UPDATED;
370 drive_uploader()->UploadExistingFile( 373 drive_uploader()->UploadExistingFile(
371 remote_file_tracker_->file_id(), 374 remote_file_tracker_->file_id(),
372 local_path_, 375 local_path_,
373 "application/octet_stream", 376 "application/octet_stream",
374 remote_file_tracker_->synced_details().etag(), 377 remote_file_tracker_->synced_details().etag(),
375 base::Bind(&LocalToRemoteSyncer::DidUploadExistingFile, 378 base::Bind(&LocalToRemoteSyncer::DidUploadExistingFile,
376 weak_ptr_factory_.GetWeakPtr(), 379 weak_ptr_factory_.GetWeakPtr(),
377 callback), 380 callback),
378 google_apis::ProgressCallback()); 381 google_apis::ProgressCallback());
379 } 382 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 callback.Run(status); 445 callback.Run(status);
443 return; 446 return;
444 } 447 }
445 448
446 CreateRemoteFolder(callback); 449 CreateRemoteFolder(callback);
447 } 450 }
448 451
449 void LocalToRemoteSyncer::UploadNewFile(const SyncStatusCallback& callback) { 452 void LocalToRemoteSyncer::UploadNewFile(const SyncStatusCallback& callback) {
450 DCHECK(remote_parent_folder_tracker_); 453 DCHECK(remote_parent_folder_tracker_);
451 454
455 sync_action_ = SYNC_ACTION_ADDED;
452 base::FilePath title = fileapi::VirtualPath::BaseName(target_path_); 456 base::FilePath title = fileapi::VirtualPath::BaseName(target_path_);
453 drive_uploader()->UploadNewFile( 457 drive_uploader()->UploadNewFile(
454 remote_parent_folder_tracker_->file_id(), 458 remote_parent_folder_tracker_->file_id(),
455 local_path_, 459 local_path_,
456 title.AsUTF8Unsafe(), 460 title.AsUTF8Unsafe(),
457 GetMimeTypeFromTitle(title), 461 GetMimeTypeFromTitle(title),
458 base::Bind(&LocalToRemoteSyncer::DidUploadNewFile, 462 base::Bind(&LocalToRemoteSyncer::DidUploadNewFile,
459 weak_ptr_factory_.GetWeakPtr(), 463 weak_ptr_factory_.GetWeakPtr(),
460 callback), 464 callback),
461 google_apis::ProgressCallback()); 465 google_apis::ProgressCallback());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 metadata_database()->UpdateTracker( 512 metadata_database()->UpdateTracker(
509 tracker.tracker_id(), 513 tracker.tracker_id(),
510 metadata.details(), 514 metadata.details(),
511 callback); 515 callback);
512 } 516 }
513 517
514 void LocalToRemoteSyncer::CreateRemoteFolder( 518 void LocalToRemoteSyncer::CreateRemoteFolder(
515 const SyncStatusCallback& callback) { 519 const SyncStatusCallback& callback) {
516 base::FilePath title = fileapi::VirtualPath::BaseName(target_path_); 520 base::FilePath title = fileapi::VirtualPath::BaseName(target_path_);
517 DCHECK(remote_parent_folder_tracker_); 521 DCHECK(remote_parent_folder_tracker_);
522 sync_action_ = SYNC_ACTION_ADDED;
518 drive_service()->AddNewDirectory( 523 drive_service()->AddNewDirectory(
519 remote_parent_folder_tracker_->file_id(), 524 remote_parent_folder_tracker_->file_id(),
520 title.AsUTF8Unsafe(), 525 title.AsUTF8Unsafe(),
521 base::Bind(&LocalToRemoteSyncer::DidCreateRemoteFolder, 526 base::Bind(&LocalToRemoteSyncer::DidCreateRemoteFolder,
522 weak_ptr_factory_.GetWeakPtr(), callback)); 527 weak_ptr_factory_.GetWeakPtr(), callback));
523 } 528 }
524 529
525 void LocalToRemoteSyncer::DidCreateRemoteFolder( 530 void LocalToRemoteSyncer::DidCreateRemoteFolder(
526 const SyncStatusCallback& callback, 531 const SyncStatusCallback& callback,
527 google_apis::GDataErrorCode error, 532 google_apis::GDataErrorCode error,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 set_used_network(true); 605 set_used_network(true);
601 return sync_context_->GetDriveUploader(); 606 return sync_context_->GetDriveUploader();
602 } 607 }
603 608
604 MetadataDatabase* LocalToRemoteSyncer::metadata_database() { 609 MetadataDatabase* LocalToRemoteSyncer::metadata_database() {
605 return sync_context_->GetMetadataDatabase(); 610 return sync_context_->GetMetadataDatabase();
606 } 611 }
607 612
608 } // namespace drive_backend 613 } // namespace drive_backend
609 } // namespace sync_file_system 614 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698