Bluetooth: Don't attempt a pairing for devices not supporting it.
[chromium-blink-merge.git] / content / common / fileapi / file_system_dispatcher.h
blobed5aa2b912a1a8a1d35dc32140c12cdedf5e4ad1
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_COMMON_FILEAPI_FILE_SYSTEM_DISPATCHER_H_
6 #define CONTENT_COMMON_FILEAPI_FILE_SYSTEM_DISPATCHER_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/files/file_util_proxy.h"
13 #include "base/id_map.h"
14 #include "base/process.h"
15 #include "ipc/ipc_listener.h"
16 #include "ipc/ipc_platform_file.h"
17 #include "webkit/fileapi/file_system_callback_dispatcher.h"
18 #include "webkit/fileapi/file_system_types.h"
19 #include "webkit/quota/quota_types.h"
21 namespace base {
22 class FilePath;
23 struct PlatformFileInfo;
26 class GURL;
28 namespace content {
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
32 // per child process. Messages are dispatched on the main child thread.
33 class FileSystemDispatcher : public IPC::Listener {
34 public:
35 FileSystemDispatcher();
36 virtual ~FileSystemDispatcher();
38 // IPC::Listener implementation.
39 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
41 bool OpenFileSystem(const GURL& origin_url,
42 fileapi::FileSystemType type,
43 long long size,
44 bool create,
45 fileapi::FileSystemCallbackDispatcher* dispatcher);
46 bool DeleteFileSystem(const GURL& origin_url,
47 fileapi::FileSystemType type,
48 fileapi::FileSystemCallbackDispatcher* dispatcher);
49 bool Move(const GURL& src_path,
50 const GURL& dest_path,
51 fileapi::FileSystemCallbackDispatcher* dispatcher);
52 bool Copy(const GURL& src_path,
53 const GURL& dest_path,
54 fileapi::FileSystemCallbackDispatcher* dispatcher);
55 bool Remove(const GURL& path,
56 bool recursive,
57 fileapi::FileSystemCallbackDispatcher* dispatcher);
58 bool ReadMetadata(const GURL& path,
59 fileapi::FileSystemCallbackDispatcher* dispatcher);
60 bool Create(const GURL& path,
61 bool exclusive,
62 bool is_directory,
63 bool recursive,
64 fileapi::FileSystemCallbackDispatcher* dispatcher);
65 bool Exists(const GURL& path,
66 bool for_directory,
67 fileapi::FileSystemCallbackDispatcher* dispatcher);
68 bool ReadDirectory(const GURL& path,
69 fileapi::FileSystemCallbackDispatcher* dispatcher);
70 bool Truncate(const GURL& path,
71 int64 offset,
72 int* request_id_out,
73 fileapi::FileSystemCallbackDispatcher* dispatcher);
74 bool Write(const GURL& path,
75 const GURL& blob_url,
76 int64 offset,
77 int* request_id_out,
78 fileapi::FileSystemCallbackDispatcher* dispatcher);
79 bool Cancel(int request_id_to_cancel,
80 fileapi::FileSystemCallbackDispatcher* dispatcher);
81 bool TouchFile(const GURL& file_path,
82 const base::Time& last_access_time,
83 const base::Time& last_modified_time,
84 fileapi::FileSystemCallbackDispatcher* dispatcher);
86 // This returns a raw open PlatformFile, unlike the above, which are
87 // self-contained operations.
88 bool OpenFile(const GURL& file_path,
89 int file_flags, // passed to FileUtilProxy::CreateOrOpen
90 fileapi::FileSystemCallbackDispatcher* dispatcher);
91 // This must be paired with OpenFile, and called after finished using the
92 // raw PlatformFile returned from OpenFile.
93 bool NotifyCloseFile(const GURL& file_path);
95 bool CreateSnapshotFile(const GURL& file_path,
96 fileapi::FileSystemCallbackDispatcher* dispatcher);
98 private:
99 // Message handlers.
100 void OnDidOpenFileSystem(int request_id,
101 const std::string& name,
102 const GURL& root);
103 void OnDidSucceed(int request_id);
104 void OnDidReadMetadata(int request_id,
105 const base::PlatformFileInfo& file_info,
106 const base::FilePath& platform_path);
107 void OnDidCreateSnapshotFile(int request_id,
108 const base::PlatformFileInfo& file_info,
109 const base::FilePath& platform_path);
110 void OnDidReadDirectory(
111 int request_id,
112 const std::vector<base::FileUtilProxy::Entry>& entries,
113 bool has_more);
114 void OnDidFail(int request_id, base::PlatformFileError error_code);
115 void OnDidWrite(int request_id, int64 bytes, bool complete);
116 void OnDidOpenFile(
117 int request_id,
118 IPC::PlatformFileForTransit file,
119 quota::QuotaLimitType quota_policy);
121 IDMap<fileapi::FileSystemCallbackDispatcher, IDMapOwnPointer> dispatchers_;
123 DISALLOW_COPY_AND_ASSIGN(FileSystemDispatcher);
126 } // namespace content
128 #endif // CONTENT_COMMON_FILEAPI_FILE_SYSTEM_DISPATCHER_H_