drive_service_wrapper.cc revision 46d4c2bc3267f3f028f39e7e311b0f89aba2e4fd
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/drive_service_wrapper.h" 6 7#include <string> 8 9#include "base/memory/weak_ptr.h" 10#include "chrome/browser/drive/drive_service_interface.h" 11 12namespace sync_file_system { 13namespace drive_backend { 14 15DriveServiceWrapper::DriveServiceWrapper( 16 drive::DriveServiceInterface* drive_service) 17 : drive_service_(drive_service) { 18 DCHECK(drive_service_); 19} 20 21void DriveServiceWrapper::AddNewDirectory( 22 const std::string& parent_resource_id, 23 const std::string& directory_title, 24 const drive::DriveServiceInterface::AddNewDirectoryOptions& options, 25 const google_apis::FileResourceCallback& callback) { 26 DCHECK(sequece_checker_.CalledOnValidSequencedThread()); 27 drive_service_->AddNewDirectory(parent_resource_id, 28 directory_title, 29 options, 30 callback); 31} 32 33void DriveServiceWrapper::DeleteResource( 34 const std::string& resource_id, 35 const std::string& etag, 36 const google_apis::EntryActionCallback& callback) { 37 DCHECK(sequece_checker_.CalledOnValidSequencedThread()); 38 drive_service_->DeleteResource(resource_id, 39 etag, 40 callback); 41} 42 43void DriveServiceWrapper::DownloadFile( 44 const base::FilePath& local_cache_path, 45 const std::string& resource_id, 46 const google_apis::DownloadActionCallback& download_action_callback, 47 const google_apis::GetContentCallback& get_content_callback, 48 const google_apis::ProgressCallback& progress_callback) { 49 DCHECK(sequece_checker_.CalledOnValidSequencedThread()); 50 drive_service_->DownloadFile(local_cache_path, 51 resource_id, 52 download_action_callback, 53 get_content_callback, 54 progress_callback); 55} 56 57void DriveServiceWrapper::GetAboutResource( 58 const google_apis::AboutResourceCallback& callback) { 59 DCHECK(sequece_checker_.CalledOnValidSequencedThread()); 60 drive_service_->GetAboutResource(callback); 61} 62 63void DriveServiceWrapper::GetChangeList( 64 int64 start_changestamp, 65 const google_apis::ChangeListCallback& callback) { 66 DCHECK(sequece_checker_.CalledOnValidSequencedThread()); 67 drive_service_->GetChangeList(start_changestamp, callback); 68} 69 70void DriveServiceWrapper::GetRemainingChangeList( 71 const GURL& next_link, 72 const google_apis::ChangeListCallback& callback) { 73 DCHECK(sequece_checker_.CalledOnValidSequencedThread()); 74 drive_service_->GetRemainingChangeList(next_link, callback); 75} 76 77void DriveServiceWrapper::GetRemainingFileList( 78 const GURL& next_link, 79 const google_apis::FileListCallback& callback) { 80 DCHECK(sequece_checker_.CalledOnValidSequencedThread()); 81 drive_service_->GetRemainingFileList(next_link, callback); 82} 83 84void DriveServiceWrapper::GetFileResource( 85 const std::string& resource_id, 86 const google_apis::FileResourceCallback& callback) { 87 DCHECK(sequece_checker_.CalledOnValidSequencedThread()); 88 drive_service_->GetFileResource(resource_id, callback); 89} 90 91void DriveServiceWrapper::GetFileListInDirectory( 92 const std::string& directory_resource_id, 93 const google_apis::FileListCallback& callback) { 94 DCHECK(sequece_checker_.CalledOnValidSequencedThread()); 95 drive_service_->GetFileListInDirectory(directory_resource_id, callback); 96} 97 98void DriveServiceWrapper::RemoveResourceFromDirectory( 99 const std::string& parent_resource_id, 100 const std::string& resource_id, 101 const google_apis::EntryActionCallback& callback) { 102 DCHECK(sequece_checker_.CalledOnValidSequencedThread()); 103 drive_service_->RemoveResourceFromDirectory( 104 parent_resource_id, resource_id, callback); 105} 106 107void DriveServiceWrapper::SearchByTitle( 108 const std::string& title, 109 const std::string& directory_resource_id, 110 const google_apis::FileListCallback& callback) { 111 DCHECK(sequece_checker_.CalledOnValidSequencedThread()); 112 drive_service_->SearchByTitle( 113 title, directory_resource_id, callback); 114} 115 116} // namespace drive_backend 117} // namespace sync_file_system 118