sync_task.cc revision 0529e5d033099cbfc42635f6f6183833b09dff6e
1// Copyright 2014 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "chrome/browser/sync_file_system/drive_backend/sync_task.h" 6 7#include "base/bind.h" 8#include "chrome/browser/sync_file_system/drive_backend/sync_task_manager.h" 9#include "chrome/browser/sync_file_system/drive_backend/sync_task_token.h" 10#include "chrome/browser/sync_file_system/drive_backend/task_dependency_manager.h" 11 12namespace sync_file_system { 13namespace drive_backend { 14 15namespace { 16 17void CallRunExclusive(const base::WeakPtr<ExclusiveTask>& task, 18 scoped_ptr<SyncTaskToken> token) { 19 if (task) 20 task->RunExclusive(SyncTaskToken::WrapToCallback(token.Pass())); 21} 22 23} // namespace 24 25ExclusiveTask::ExclusiveTask() : weak_ptr_factory_(this) {} 26ExclusiveTask::~ExclusiveTask() {} 27 28void ExclusiveTask::RunPreflight(scoped_ptr<SyncTaskToken> token) { 29 scoped_ptr<BlockingFactor> blocking_factor(new BlockingFactor); 30 blocking_factor->exclusive = true; 31 32 SyncTaskManager::UpdateBlockingFactor( 33 token.Pass(), blocking_factor.Pass(), 34 base::Bind(&CallRunExclusive, weak_ptr_factory_.GetWeakPtr())); 35} 36 37} // namespace drive_backend 38} // namespace sync_file_system 39