- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / drive / write_on_cache_file.h
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.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_WRITE_ON_CACHE_FILE_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_WRITE_ON_CACHE_FILE_H_
7
8 #include "base/callback_forward.h"
9 #include "chrome/browser/chromeos/drive/file_errors.h"
10
11 namespace base {
12 class FilePath;
13 }
14
15 namespace drive {
16
17 class FileSystemInterface;
18
19 // Callback type for WriteOnCacheFile.
20 typedef base::Callback<void (FileError, const base::FilePath& path)>
21     WriteOnCacheFileCallback;
22
23 // Creates (if needed) a file at |path|, brings it to the local cache,
24 // and invokes |callback| on blocking thread pool with the cache file path.
25 // The |callback| can write to the file at the path by normal local file I/O
26 // operations. After it returns, the written content is synced to the server.
27 //
28 // If non-empty |mime_type| is set and the file is created by this function
29 // call, the mime type for the entry is set to |mime_type|. Otherwise the type
30 // is automatically determined from |path|.
31 //
32 // Must be called from UI thread.
33 void WriteOnCacheFile(FileSystemInterface* file_system,
34                       const base::FilePath& path,
35                       const std::string& mime_type,
36                       const WriteOnCacheFileCallback& callback);
37
38 }  // namespace drive
39
40 #endif  // CHROME_BROWSER_CHROMEOS_DRIVE_WRITE_ON_CACHE_FILE_H_