Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: webkit/browser/fileapi/copy_or_move_file_validator.h

Issue 18565002: [FileSystem] Add another copy-or-move validation hook for post-write. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add test Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_BROWSER_FILEAPI_COPY_OR_MOVE_FILE_VALIDATOR_H_ 5 #ifndef WEBKIT_BROWSER_FILEAPI_COPY_OR_MOVE_FILE_VALIDATOR_H_
6 #define WEBKIT_BROWSER_FILEAPI_COPY_OR_MOVE_FILE_VALIDATOR_H_ 6 #define WEBKIT_BROWSER_FILEAPI_COPY_OR_MOVE_FILE_VALIDATOR_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/platform_file.h" 9 #include "base/platform_file.h"
10 #include "webkit/browser/webkit_storage_browser_export.h" 10 #include "webkit/browser/webkit_storage_browser_export.h"
11 11
12 namespace base { 12 namespace base {
13 class FilePath; 13 class FilePath;
14 } 14 }
15 15
16 namespace webkit_blob {
17 class ShareableFileReference;
18 }
19
16 namespace fileapi { 20 namespace fileapi {
17 21
18 class FileSystemURL; 22 class FileSystemURL;
19 23
20 class WEBKIT_STORAGE_BROWSER_EXPORT CopyOrMoveFileValidator { 24 class WEBKIT_STORAGE_BROWSER_EXPORT CopyOrMoveFileValidator {
21 public: 25 public:
22 // Callback that is invoked when validation completes. A result of 26 // Callback that is invoked when validation completes. A result of
23 // base::PLATFORM_FILE_OK means the file validated. 27 // base::PLATFORM_FILE_OK means the file validated.
24 typedef base::Callback<void(base::PlatformFileError result)> ResultCallback; 28 typedef base::Callback<void(base::PlatformFileError result)> ResultCallback;
25 29
26 virtual ~CopyOrMoveFileValidator() {} 30 virtual ~CopyOrMoveFileValidator() {}
27 31
32 // Called on a source file before copying or moving to the final
33 // destination.
28 virtual void StartValidation(const ResultCallback& result_callback) = 0; 34 virtual void StartValidation(const ResultCallback& result_callback) = 0;
35
36 // Called on a destination file after copying or moving to the final
37 // destination. Suitable for running Anti-Virus checks. The |file_ref| is
38 // a refcounted keepalive token for the destination file which may or
39 // may not be present. Implementations should maintain the |file_ref| until
vandebo (ex-Chrome) 2013/07/10 15:52:46 Hmm, can the caller manage the lifetime of the fil
Greg Billock 2013/07/11 22:54:35 There was a good spot you found to manage this. Re
40 // they finish and return in order to make sure the file is not prematurely
41 // deleted from under them.
42 virtual void StartPostWriteValidation(
43 const base::FilePath& dest_platform_path,
44 scoped_refptr<webkit_blob::ShareableFileReference> file_ref,
45 const ResultCallback& result_callback) = 0;
29 }; 46 };
30 47
31 class CopyOrMoveFileValidatorFactory { 48 class CopyOrMoveFileValidatorFactory {
32 public: 49 public:
33 virtual ~CopyOrMoveFileValidatorFactory() {} 50 virtual ~CopyOrMoveFileValidatorFactory() {}
34 51
35 // This method must always return a non-NULL validator. |src_url| is needed 52 // This method must always return a non-NULL validator. |src_url| is needed
36 // in addition to |platform_path| because in the obfuscated file system 53 // in addition to |platform_path| because in the obfuscated file system
37 // case, |platform_path| will be an obfuscated filename and extension. 54 // case, |platform_path| will be an obfuscated filename and extension.
38 virtual CopyOrMoveFileValidator* CreateCopyOrMoveFileValidator( 55 virtual CopyOrMoveFileValidator* CreateCopyOrMoveFileValidator(
39 const FileSystemURL& src_url, 56 const FileSystemURL& src_url,
40 const base::FilePath& platform_path) = 0; 57 const base::FilePath& platform_path) = 0;
41 }; 58 };
42 59
43 } // namespace fileapi 60 } // namespace fileapi
44 61
45 #endif // WEBKIT_BROWSER_FILEAPI_COPY_OR_MOVE_FILE_VALIDATOR_H_ 62 #endif // WEBKIT_BROWSER_FILEAPI_COPY_OR_MOVE_FILE_VALIDATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698