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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_UTIL_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_UTIL_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h"
12 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h"
13 #include "chrome/browser/sync_file_system/sync_status_code.h"
14 #include "google_apis/drive/gdata_errorcode.h"
15 #include "webkit/common/blob/scoped_file.h"
17 namespace google_apis
{
27 namespace sync_file_system
{
28 namespace drive_backend
{
30 void PutServiceMetadataToBatch(const ServiceMetadata
& service_metadata
,
31 leveldb::WriteBatch
* batch
);
32 void PutFileToBatch(const FileMetadata
& file
, leveldb::WriteBatch
* batch
);
33 void PutTrackerToBatch(const FileTracker
& tracker
, leveldb::WriteBatch
* batch
);
35 void PopulateFileDetailsByFileResource(
36 const google_apis::FileResource
& file_resource
,
37 FileDetails
* details
);
38 scoped_ptr
<FileMetadata
> CreateFileMetadataFromFileResource(
40 const google_apis::FileResource
& resource
);
41 scoped_ptr
<FileMetadata
> CreateFileMetadataFromChangeResource(
42 const google_apis::ChangeResource
& change
);
43 scoped_ptr
<FileMetadata
> CreateDeletedFileMetadata(
45 const std::string
& file_id
);
47 // Creates a temporary file in |dir_path|. This must be called on an
48 // IO-allowed task runner, and the runner must be given as |file_task_runner|.
49 webkit_blob::ScopedFile
CreateTemporaryFile(
50 base::TaskRunner
* file_task_runner
);
52 std::string
FileKindToString(FileKind file_kind
);
54 bool HasFileAsParent(const FileDetails
& details
, const std::string
& file_id
);
56 std::string
GetMimeTypeFromTitle(const base::FilePath
& title
);
58 scoped_ptr
<google_apis::ResourceEntry
> GetOldestCreatedFolderResource(
59 ScopedVector
<google_apis::ResourceEntry
> list
);
61 SyncStatusCode
GDataErrorCodeToSyncStatusCode(
62 google_apis::GDataErrorCode error
);
64 } // namespace drive_backend
65 } // namespace sync_file_system
67 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_DRIVE_BACKEND_UTIL_H_