remote_change_processor_on_worker.cc revision 5c02ac1a9c1b504631c0a3d2b6e737b5d738bae1
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/remote_change_processor_on_worker.h" 6 7#include "base/bind.h" 8#include "base/location.h" 9#include "base/memory/weak_ptr.h" 10#include "base/single_thread_task_runner.h" 11#include "chrome/browser/sync_file_system/drive_backend/callback_helper.h" 12#include "chrome/browser/sync_file_system/drive_backend/remote_change_processor_wrapper.h" 13#include "chrome/browser/sync_file_system/file_change.h" 14#include "chrome/browser/sync_file_system/sync_file_metadata.h" 15 16namespace sync_file_system { 17namespace drive_backend { 18 19RemoteChangeProcessorOnWorker::RemoteChangeProcessorOnWorker( 20 const base::WeakPtr<RemoteChangeProcessorWrapper>& wrapper, 21 base::SingleThreadTaskRunner* ui_task_runner, 22 base::SequencedTaskRunner* worker_task_runner) 23 : wrapper_(wrapper), 24 ui_task_runner_(ui_task_runner), 25 worker_task_runner_(worker_task_runner) {} 26 27RemoteChangeProcessorOnWorker::~RemoteChangeProcessorOnWorker() {} 28 29void RemoteChangeProcessorOnWorker::PrepareForProcessRemoteChange( 30 const fileapi::FileSystemURL& url, 31 const PrepareChangeCallback& callback) { 32 ui_task_runner_->PostTask( 33 FROM_HERE, 34 base::Bind(&RemoteChangeProcessorWrapper::PrepareForProcessRemoteChange, 35 wrapper_, 36 url, 37 RelayCallbackToTaskRunner( 38 worker_task_runner_, 39 FROM_HERE, 40 callback))); 41} 42 43void RemoteChangeProcessorOnWorker::ApplyRemoteChange( 44 const FileChange& change, 45 const base::FilePath& local_path, 46 const fileapi::FileSystemURL& url, 47 const SyncStatusCallback& callback) { 48 ui_task_runner_->PostTask( 49 FROM_HERE, 50 base::Bind(&RemoteChangeProcessorWrapper::ApplyRemoteChange, 51 wrapper_, 52 change, 53 local_path, 54 url, 55 RelayCallbackToTaskRunner( 56 worker_task_runner_, 57 FROM_HERE, 58 callback))); 59} 60 61void RemoteChangeProcessorOnWorker::FinalizeRemoteSync( 62 const fileapi::FileSystemURL& url, 63 bool clear_local_changes, 64 const base::Closure& completion_callback) { 65 ui_task_runner_->PostTask( 66 FROM_HERE, 67 base::Bind(&RemoteChangeProcessorWrapper::FinalizeRemoteSync, 68 wrapper_, 69 url, 70 clear_local_changes, 71 RelayCallbackToTaskRunner( 72 worker_task_runner_, 73 FROM_HERE, 74 completion_callback))); 75} 76 77void RemoteChangeProcessorOnWorker::RecordFakeLocalChange( 78 const fileapi::FileSystemURL& url, 79 const FileChange& change, 80 const SyncStatusCallback& callback) { 81 ui_task_runner_->PostTask( 82 FROM_HERE, 83 base::Bind(&RemoteChangeProcessorWrapper::RecordFakeLocalChange, 84 wrapper_, 85 url, 86 change, 87 RelayCallbackToTaskRunner( 88 worker_task_runner_, 89 FROM_HERE, 90 callback))); 91} 92 93} // namespace drive_backend 94} // namespace sync_file_system 95