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

Side by Side Diff: chrome/browser/chromeos/drive/sync_client.cc

Issue 372713004: Wait for parent directory sync before performing server-side copy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add operation_observer.cc Created 6 years, 5 months 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 (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/sync_client.h" 5 #include "chrome/browser/chromeos/drive/sync_client.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 break; 225 break;
226 } 226 }
227 } 227 }
228 228
229 void SyncClient::AddUpdateTask(const ClientContext& context, 229 void SyncClient::AddUpdateTask(const ClientContext& context,
230 const std::string& local_id) { 230 const std::string& local_id) {
231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
232 AddUpdateTaskInternal(context, local_id, delay_); 232 AddUpdateTaskInternal(context, local_id, delay_);
233 } 233 }
234 234
235 bool SyncClient:: WaitForUpdateTaskToComplete(
236 const std::string& local_id,
237 const FileOperationCallback& callback) {
238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
239
240 SyncTasks::iterator it = tasks_.find(SyncTasks::key_type(UPDATE, local_id));
241 if (it == tasks_.end())
242 return false;
243
244 SyncTask* task = &it->second;
245 task->waiting_callbacks.push_back(callback);
246 return true;
247 }
248
235 base::Closure SyncClient::PerformFetchTask(const std::string& local_id, 249 base::Closure SyncClient::PerformFetchTask(const std::string& local_id,
236 const ClientContext& context) { 250 const ClientContext& context) {
237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 251 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
238 return download_operation_->EnsureFileDownloadedByLocalId( 252 return download_operation_->EnsureFileDownloadedByLocalId(
239 local_id, 253 local_id,
240 context, 254 context,
241 GetFileContentInitializedCallback(), 255 GetFileContentInitializedCallback(),
242 google_apis::GetContentCallback(), 256 google_apis::GetContentCallback(),
243 base::Bind(&SyncClient::OnFetchFileComplete, 257 base::Bind(&SyncClient::OnFetchFileComplete,
244 weak_ptr_factory_.GetWeakPtr(), 258 weak_ptr_factory_.GetWeakPtr(),
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 operation_observer_->OnDriveSyncError( 446 operation_observer_->OnDriveSyncError(
433 file_system::DRIVE_SYNC_ERROR_SERVICE_UNAVAILABLE, local_id); 447 file_system::DRIVE_SYNC_ERROR_SERVICE_UNAVAILABLE, local_id);
434 break; 448 break;
435 default: 449 default:
436 operation_observer_->OnDriveSyncError( 450 operation_observer_->OnDriveSyncError(
437 file_system::DRIVE_SYNC_ERROR_MISC, local_id); 451 file_system::DRIVE_SYNC_ERROR_MISC, local_id);
438 LOG(WARNING) << "Failed: type = " << type << ", id = " << local_id 452 LOG(WARNING) << "Failed: type = " << type << ", id = " << local_id
439 << ": " << FileErrorToString(error); 453 << ": " << FileErrorToString(error);
440 } 454 }
441 455
456 for (size_t i = 0; i < it->second.waiting_callbacks.size(); ++i) {
457 base::MessageLoopProxy::current()->PostTask(
458 FROM_HERE, base::Bind(it->second.waiting_callbacks[i], error));
459 }
460 it->second.waiting_callbacks.clear();
461
442 if (it->second.should_run_again) { 462 if (it->second.should_run_again) {
443 DVLOG(1) << "Running again: type = " << type << ", id = " << local_id; 463 DVLOG(1) << "Running again: type = " << type << ", id = " << local_id;
444 it->second.state = PENDING; 464 it->second.state = PENDING;
445 it->second.should_run_again = false; 465 it->second.should_run_again = false;
446 base::MessageLoopProxy::current()->PostDelayedTask( 466 base::MessageLoopProxy::current()->PostDelayedTask(
447 FROM_HERE, 467 FROM_HERE,
448 base::Bind(&SyncClient::StartTask, weak_ptr_factory_.GetWeakPtr(), key), 468 base::Bind(&SyncClient::StartTask, weak_ptr_factory_.GetWeakPtr(), key),
449 retry_delay); 469 retry_delay);
450 } else { 470 } else {
451 for (size_t i = 0; i < it->second.dependent_tasks.size(); ++i) 471 for (size_t i = 0; i < it->second.dependent_tasks.size(); ++i)
(...skipping 14 matching lines...) Expand all
466 base::PostTaskAndReplyWithResult( 486 base::PostTaskAndReplyWithResult(
467 blocking_task_runner_, 487 blocking_task_runner_,
468 FROM_HERE, 488 FROM_HERE,
469 base::Bind(&FileCache::Unpin, base::Unretained(cache_), local_id), 489 base::Bind(&FileCache::Unpin, base::Unretained(cache_), local_id),
470 base::Bind(&util::EmptyFileOperationCallback)); 490 base::Bind(&util::EmptyFileOperationCallback));
471 } 491 }
472 } 492 }
473 493
474 } // namespace internal 494 } // namespace internal
475 } // namespace drive 495 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/sync_client.h ('k') | chrome/browser/chromeos/drive/sync_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698