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

Side by Side Diff: content/common/fileapi/file_system_dispatcher.h

Issue 14796018: Cleanup: Deprecate FileSystemCallbackDispatcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 (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 CONTENT_COMMON_FILEAPI_FILE_SYSTEM_DISPATCHER_H_ 5 #ifndef CONTENT_COMMON_FILEAPI_FILE_SYSTEM_DISPATCHER_H_
6 #define CONTENT_COMMON_FILEAPI_FILE_SYSTEM_DISPATCHER_H_ 6 #define CONTENT_COMMON_FILEAPI_FILE_SYSTEM_DISPATCHER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback_forward.h"
12 #include "base/files/file_util_proxy.h" 13 #include "base/files/file_util_proxy.h"
13 #include "base/id_map.h" 14 #include "base/id_map.h"
14 #include "base/process.h" 15 #include "base/process.h"
15 #include "ipc/ipc_listener.h" 16 #include "ipc/ipc_listener.h"
16 #include "ipc/ipc_platform_file.h" 17 #include "ipc/ipc_platform_file.h"
17 #include "webkit/fileapi/file_system_callback_dispatcher.h"
18 #include "webkit/fileapi/file_system_types.h" 18 #include "webkit/fileapi/file_system_types.h"
19 #include "webkit/quota/quota_types.h" 19 #include "webkit/quota/quota_types.h"
20 20
21 namespace base { 21 namespace base {
22 class FilePath; 22 class FilePath;
23 struct PlatformFileInfo; 23 struct PlatformFileInfo;
24 } 24 }
25 25
26 class GURL; 26 class GURL;
27 27
28 namespace content { 28 namespace content {
29 29
30 // Dispatches and sends file system related messages sent to/from a child 30 // Dispatches and sends file system related messages sent to/from a child
31 // process from/to the main browser process. There is one instance 31 // process from/to the main browser process. There is one instance
32 // per child process. Messages are dispatched on the main child thread. 32 // per child process. Messages are dispatched on the main child thread.
33 class FileSystemDispatcher : public IPC::Listener { 33 class FileSystemDispatcher : public IPC::Listener {
34 public: 34 public:
35 typedef base::Callback<void(base::PlatformFileError error)>
36 StatusCallback;
37 typedef base::Callback<void(
38 base::PlatformFileError error,
39 const base::PlatformFileInfo& file_info,
40 const base::FilePath& platform_path)> MetadataCallback;
41 typedef MetadataCallback CreateSnapshotFileCallback;
42 typedef base::Callback<void(
43 base::PlatformFileError error,
44 const std::vector<base::FileUtilProxy::Entry>& entries,
45 bool has_more)> ReadDirectoryCallback;
46 typedef base::Callback<void(
47 base::PlatformFileError error,
48 const std::string& name,
49 const GURL& root)> OpenFileSystemCallback;
50 typedef base::Callback<void(
51 base::PlatformFileError error,
52 int64 bytes,
53 bool complete)> WriteCallback;
54 typedef base::Callback<void(
55 base::PlatformFileError error,
56 base::PlatformFile file,
57 int file_open_id,
58 quota::QuotaLimitType quota_policy)> OpenFileCallback;
59
35 FileSystemDispatcher(); 60 FileSystemDispatcher();
36 virtual ~FileSystemDispatcher(); 61 virtual ~FileSystemDispatcher();
37 62
38 // IPC::Listener implementation. 63 // IPC::Listener implementation.
39 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; 64 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
40 65
41 bool OpenFileSystem(const GURL& origin_url, 66 bool OpenFileSystem(const GURL& origin_url,
42 fileapi::FileSystemType type, 67 fileapi::FileSystemType type,
43 long long size, 68 long long size,
44 bool create, 69 bool create,
45 fileapi::FileSystemCallbackDispatcher* dispatcher); 70 const OpenFileSystemCallback& callback);
46 bool DeleteFileSystem(const GURL& origin_url, 71 bool DeleteFileSystem(const GURL& origin_url,
47 fileapi::FileSystemType type, 72 fileapi::FileSystemType type,
48 fileapi::FileSystemCallbackDispatcher* dispatcher); 73 const StatusCallback& callback);
49 bool Move(const GURL& src_path, 74 bool Move(const GURL& src_path,
50 const GURL& dest_path, 75 const GURL& dest_path,
51 fileapi::FileSystemCallbackDispatcher* dispatcher); 76 const StatusCallback& callback);
52 bool Copy(const GURL& src_path, 77 bool Copy(const GURL& src_path,
53 const GURL& dest_path, 78 const GURL& dest_path,
54 fileapi::FileSystemCallbackDispatcher* dispatcher); 79 const StatusCallback& callback);
55 bool Remove(const GURL& path, 80 bool Remove(const GURL& path,
56 bool recursive, 81 bool recursive,
57 fileapi::FileSystemCallbackDispatcher* dispatcher); 82 const StatusCallback& callback);
58 bool ReadMetadata(const GURL& path, 83 bool ReadMetadata(const GURL& path,
59 fileapi::FileSystemCallbackDispatcher* dispatcher); 84 const MetadataCallback& callback);
60 bool Create(const GURL& path, 85 bool Create(const GURL& path,
61 bool exclusive, 86 bool exclusive,
62 bool is_directory, 87 bool is_directory,
63 bool recursive, 88 bool recursive,
64 fileapi::FileSystemCallbackDispatcher* dispatcher); 89 const StatusCallback& callback);
65 bool Exists(const GURL& path, 90 bool Exists(const GURL& path,
66 bool for_directory, 91 bool for_directory,
67 fileapi::FileSystemCallbackDispatcher* dispatcher); 92 const StatusCallback& callback);
68 bool ReadDirectory(const GURL& path, 93 bool ReadDirectory(const GURL& path,
69 fileapi::FileSystemCallbackDispatcher* dispatcher); 94 const ReadDirectoryCallback& callback);
70 bool Truncate(const GURL& path, 95 bool Truncate(const GURL& path,
71 int64 offset, 96 int64 offset,
72 int* request_id_out, 97 int* request_id_out,
73 fileapi::FileSystemCallbackDispatcher* dispatcher); 98 const StatusCallback& callback);
74 bool Write(const GURL& path, 99 bool Write(const GURL& path,
75 const GURL& blob_url, 100 const GURL& blob_url,
76 int64 offset, 101 int64 offset,
77 int* request_id_out, 102 int* request_id_out,
78 fileapi::FileSystemCallbackDispatcher* dispatcher); 103 const WriteCallback& callback);
79 bool Cancel(int request_id_to_cancel, 104 bool Cancel(int request_id_to_cancel,
80 fileapi::FileSystemCallbackDispatcher* dispatcher); 105 const StatusCallback& callback);
81 bool TouchFile(const GURL& file_path, 106 bool TouchFile(const GURL& file_path,
82 const base::Time& last_access_time, 107 const base::Time& last_access_time,
83 const base::Time& last_modified_time, 108 const base::Time& last_modified_time,
84 fileapi::FileSystemCallbackDispatcher* dispatcher); 109 const StatusCallback& callback);
85 110
86 // This returns a raw open PlatformFile, unlike the above, which are 111 // This returns a raw open PlatformFile, unlike the above, which are
87 // self-contained operations. 112 // self-contained operations.
88 bool OpenFile(const GURL& file_path, 113 bool OpenFile(const GURL& file_path,
89 int file_flags, // passed to FileUtilProxy::CreateOrOpen 114 int file_flags, // passed to FileUtilProxy::CreateOrOpen
90 fileapi::FileSystemCallbackDispatcher* dispatcher); 115 const OpenFileCallback& callback);
91 // This must be paired with OpenFile, and called after finished using the 116 // This must be paired with OpenFile, and called after finished using the
92 // raw PlatformFile returned from OpenFile. 117 // raw PlatformFile returned from OpenFile.
93 bool NotifyCloseFile(int file_open_id); 118 bool NotifyCloseFile(int file_open_id);
94 119
95 bool CreateSnapshotFile(const GURL& file_path, 120 bool CreateSnapshotFile(const GURL& file_path,
96 fileapi::FileSystemCallbackDispatcher* dispatcher); 121 const CreateSnapshotFileCallback& callback);
97 122
98 private: 123 private:
124 class CallbackDispatcher;
125
99 // Message handlers. 126 // Message handlers.
100 void OnDidOpenFileSystem(int request_id, 127 void OnDidOpenFileSystem(int request_id,
101 const std::string& name, 128 const std::string& name,
102 const GURL& root); 129 const GURL& root);
103 void OnDidSucceed(int request_id); 130 void OnDidSucceed(int request_id);
104 void OnDidReadMetadata(int request_id, 131 void OnDidReadMetadata(int request_id,
105 const base::PlatformFileInfo& file_info, 132 const base::PlatformFileInfo& file_info,
106 const base::FilePath& platform_path); 133 const base::FilePath& platform_path);
107 void OnDidCreateSnapshotFile(int request_id, 134 void OnDidCreateSnapshotFile(int request_id,
108 const base::PlatformFileInfo& file_info, 135 const base::PlatformFileInfo& file_info,
109 const base::FilePath& platform_path); 136 const base::FilePath& platform_path);
110 void OnDidReadDirectory( 137 void OnDidReadDirectory(
111 int request_id, 138 int request_id,
112 const std::vector<base::FileUtilProxy::Entry>& entries, 139 const std::vector<base::FileUtilProxy::Entry>& entries,
113 bool has_more); 140 bool has_more);
114 void OnDidFail(int request_id, base::PlatformFileError error_code); 141 void OnDidFail(int request_id, base::PlatformFileError error_code);
115 void OnDidWrite(int request_id, int64 bytes, bool complete); 142 void OnDidWrite(int request_id, int64 bytes, bool complete);
116 void OnDidOpenFile( 143 void OnDidOpenFile(
117 int request_id, 144 int request_id,
118 IPC::PlatformFileForTransit file, 145 IPC::PlatformFileForTransit file,
119 int file_open_id, 146 int file_open_id,
120 quota::QuotaLimitType quota_policy); 147 quota::QuotaLimitType quota_policy);
121 148
122 IDMap<fileapi::FileSystemCallbackDispatcher, IDMapOwnPointer> dispatchers_; 149 IDMap<CallbackDispatcher, IDMapOwnPointer> dispatchers_;
123 150
124 DISALLOW_COPY_AND_ASSIGN(FileSystemDispatcher); 151 DISALLOW_COPY_AND_ASSIGN(FileSystemDispatcher);
125 }; 152 };
126 153
127 } // namespace content 154 } // namespace content
128 155
129 #endif // CONTENT_COMMON_FILEAPI_FILE_SYSTEM_DISPATCHER_H_ 156 #endif // CONTENT_COMMON_FILEAPI_FILE_SYSTEM_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698