OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_FILE_OBSERVERS_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_FILE_OBSERVERS_H_ |
6 #define WEBKIT_BROWSER_FILEAPI_FILE_OBSERVERS_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_FILE_OBSERVERS_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "webkit/browser/webkit_storage_browser_export.h" | 9 #include "storage/common/storage_export.h" |
10 | 10 |
11 // TODO(kinuko): Split this file into per-observer multiple files. | 11 // TODO(kinuko): Split this file into per-observer multiple files. |
12 | 12 |
13 namespace fileapi { | 13 namespace storage { |
14 | 14 |
15 class FileSystemURL; | 15 class FileSystemURL; |
16 | 16 |
17 // An abstract interface to observe update operations. | 17 // An abstract interface to observe update operations. |
18 // | 18 // |
19 // OnStartUpdate and OnEndUpdate are called once for each target url | 19 // OnStartUpdate and OnEndUpdate are called once for each target url |
20 // before and after following operations regardless of whether the operation | 20 // before and after following operations regardless of whether the operation |
21 // is made recursively or not (i.e. StartUpdate() will be called only once | 21 // is made recursively or not (i.e. StartUpdate() will be called only once |
22 // for destination url regardless of whether it is recursive copy or not): | 22 // for destination url regardless of whether it is recursive copy or not): |
23 // CreateFile(), CreateDirectory(), | 23 // CreateFile(), CreateDirectory(), |
24 // Copy() (destination only), | 24 // Copy() (destination only), |
25 // Move() (both for source and destination), | 25 // Move() (both for source and destination), |
26 // Remove(), Write(), Truncate(), TouchFile() | 26 // Remove(), Write(), Truncate(), TouchFile() |
27 // | 27 // |
28 // OnUpdate() is called each time the |url| is updated but works only for | 28 // OnUpdate() is called each time the |url| is updated but works only for |
29 // sandboxed files (where usage is tracked). | 29 // sandboxed files (where usage is tracked). |
30 class WEBKIT_STORAGE_BROWSER_EXPORT FileUpdateObserver { | 30 class STORAGE_EXPORT FileUpdateObserver { |
31 public: | 31 public: |
32 FileUpdateObserver() {} | 32 FileUpdateObserver() {} |
33 virtual ~FileUpdateObserver() {} | 33 virtual ~FileUpdateObserver() {} |
34 | 34 |
35 virtual void OnStartUpdate(const FileSystemURL& url) = 0; | 35 virtual void OnStartUpdate(const FileSystemURL& url) = 0; |
36 virtual void OnUpdate(const FileSystemURL& url, int64 delta) = 0; | 36 virtual void OnUpdate(const FileSystemURL& url, int64 delta) = 0; |
37 virtual void OnEndUpdate(const FileSystemURL& url) = 0; | 37 virtual void OnEndUpdate(const FileSystemURL& url) = 0; |
38 | 38 |
39 private: | 39 private: |
40 DISALLOW_COPY_AND_ASSIGN(FileUpdateObserver); | 40 DISALLOW_COPY_AND_ASSIGN(FileUpdateObserver); |
41 }; | 41 }; |
42 | 42 |
43 // An abstract interface to observe file access. | 43 // An abstract interface to observe file access. |
44 // OnAccess is called whenever an operation reads file contents or metadata. | 44 // OnAccess is called whenever an operation reads file contents or metadata. |
45 // (It is called only once per operation regardless of whether the operation | 45 // (It is called only once per operation regardless of whether the operation |
46 // is recursive or not) | 46 // is recursive or not) |
47 class WEBKIT_STORAGE_BROWSER_EXPORT FileAccessObserver { | 47 class STORAGE_EXPORT FileAccessObserver { |
48 public: | 48 public: |
49 FileAccessObserver() {} | 49 FileAccessObserver() {} |
50 virtual ~FileAccessObserver() {} | 50 virtual ~FileAccessObserver() {} |
51 | 51 |
52 virtual void OnAccess(const FileSystemURL& url) = 0; | 52 virtual void OnAccess(const FileSystemURL& url) = 0; |
53 | 53 |
54 private: | 54 private: |
55 DISALLOW_COPY_AND_ASSIGN(FileAccessObserver); | 55 DISALLOW_COPY_AND_ASSIGN(FileAccessObserver); |
56 }; | 56 }; |
57 | 57 |
58 // An abstract interface to observe file changes. | 58 // An abstract interface to observe file changes. |
59 // Each method of this class is called once per file/directory is created, | 59 // Each method of this class is called once per file/directory is created, |
60 // removed or modified. For recursive operations each method is called for | 60 // removed or modified. For recursive operations each method is called for |
61 // each subdirectory/subfile. Currently ChangeObserver is only supported | 61 // each subdirectory/subfile. Currently ChangeObserver is only supported |
62 // by the local sandbox file system. | 62 // by the local sandbox file system. |
63 class WEBKIT_STORAGE_BROWSER_EXPORT FileChangeObserver { | 63 class STORAGE_EXPORT FileChangeObserver { |
64 public: | 64 public: |
65 FileChangeObserver() {} | 65 FileChangeObserver() {} |
66 virtual ~FileChangeObserver() {} | 66 virtual ~FileChangeObserver() {} |
67 | 67 |
68 virtual void OnCreateFile(const FileSystemURL& url) = 0; | 68 virtual void OnCreateFile(const FileSystemURL& url) = 0; |
69 virtual void OnCreateFileFrom(const FileSystemURL& url, | 69 virtual void OnCreateFileFrom(const FileSystemURL& url, |
70 const FileSystemURL& src) = 0; | 70 const FileSystemURL& src) = 0; |
71 virtual void OnRemoveFile(const FileSystemURL& url) = 0; | 71 virtual void OnRemoveFile(const FileSystemURL& url) = 0; |
72 virtual void OnModifyFile(const FileSystemURL& url) = 0; | 72 virtual void OnModifyFile(const FileSystemURL& url) = 0; |
73 | 73 |
74 virtual void OnCreateDirectory(const FileSystemURL& url) = 0; | 74 virtual void OnCreateDirectory(const FileSystemURL& url) = 0; |
75 virtual void OnRemoveDirectory(const FileSystemURL& url) = 0; | 75 virtual void OnRemoveDirectory(const FileSystemURL& url) = 0; |
76 | 76 |
77 private: | 77 private: |
78 DISALLOW_COPY_AND_ASSIGN(FileChangeObserver); | 78 DISALLOW_COPY_AND_ASSIGN(FileChangeObserver); |
79 }; | 79 }; |
80 | 80 |
81 } // namespace fileapi | 81 } // namespace storage |
82 | 82 |
83 #endif // WEBKIT_BROWSER_FILEAPI_FILE_OBSERVERS_H_ | 83 #endif // WEBKIT_BROWSER_FILEAPI_FILE_OBSERVERS_H_ |
OLD | NEW |