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

Side by Side Diff: components/leveldb/leveldb_mojo_proxy.h

Issue 1962503002: Add mojom module suffix in .mojom files for components/filesystem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « components/leveldb/env_mojo.cc ('k') | components/leveldb/leveldb_mojo_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 COMPONENTS_LEVELDB_LEVELDB_MOJO_PROXY_H_ 5 #ifndef COMPONENTS_LEVELDB_LEVELDB_MOJO_PROXY_H_
6 #define COMPONENTS_LEVELDB_LEVELDB_MOJO_PROXY_H_ 6 #define COMPONENTS_LEVELDB_LEVELDB_MOJO_PROXY_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 29 matching lines...) Expand all
40 struct OpaqueLock; 40 struct OpaqueLock;
41 41
42 // A private struct to hide the underlying root directory that we're 42 // A private struct to hide the underlying root directory that we're
43 // operating in. LevelDBMojoProxy will want to own all the directory 43 // operating in. LevelDBMojoProxy will want to own all the directory
44 // pointers, so while opening a database, we pass the directory to the thread 44 // pointers, so while opening a database, we pass the directory to the thread
45 // it will be operated on. 45 // it will be operated on.
46 struct OpaqueDir; 46 struct OpaqueDir;
47 47
48 // Passes ownership of a |directory| to the other thread, giving a reference 48 // Passes ownership of a |directory| to the other thread, giving a reference
49 // handle back to the caller. 49 // handle back to the caller.
50 OpaqueDir* RegisterDirectory(filesystem::DirectoryPtr directory); 50 OpaqueDir* RegisterDirectory(filesystem::mojom::DirectoryPtr directory);
51 void UnregisterDirectory(OpaqueDir* dir); 51 void UnregisterDirectory(OpaqueDir* dir);
52 52
53 // Synchronously calls Directory.OpenFileHandle(). 53 // Synchronously calls Directory.OpenFileHandle().
54 base::File OpenFileHandle(OpaqueDir* dir, 54 base::File OpenFileHandle(OpaqueDir* dir,
55 const std::string& name, 55 const std::string& name,
56 uint32_t open_flags); 56 uint32_t open_flags);
57 57
58 // Synchronously syncs |directory_|. 58 // Synchronously syncs |directory_|.
59 filesystem::FileError SyncDirectory(OpaqueDir* dir, const std::string& name); 59 filesystem::mojom::FileError SyncDirectory(OpaqueDir* dir,
60 const std::string& name);
60 61
61 // Synchronously checks whether |name| exists. 62 // Synchronously checks whether |name| exists.
62 bool FileExists(OpaqueDir* dir, const std::string& name); 63 bool FileExists(OpaqueDir* dir, const std::string& name);
63 64
64 // Synchronously returns the filenames of all files in |path|. 65 // Synchronously returns the filenames of all files in |path|.
65 filesystem::FileError GetChildren(OpaqueDir* dir, 66 filesystem::mojom::FileError GetChildren(OpaqueDir* dir,
66 const std::string& path, 67 const std::string& path,
67 std::vector<std::string>* result); 68 std::vector<std::string>* result);
68 69
69 // Synchronously deletes |path|. 70 // Synchronously deletes |path|.
70 filesystem::FileError Delete(OpaqueDir* dir, 71 filesystem::mojom::FileError Delete(OpaqueDir* dir,
71 const std::string& path, 72 const std::string& path,
72 uint32_t delete_flags); 73 uint32_t delete_flags);
73 74
74 // Synchronously creates |path|. 75 // Synchronously creates |path|.
75 filesystem::FileError CreateDir(OpaqueDir* dir, const std::string& path); 76 filesystem::mojom::FileError CreateDir(OpaqueDir* dir,
77 const std::string& path);
76 78
77 // Synchronously gets the size of a file. 79 // Synchronously gets the size of a file.
78 filesystem::FileError GetFileSize(OpaqueDir* dir, 80 filesystem::mojom::FileError GetFileSize(OpaqueDir* dir,
79 const std::string& path, 81 const std::string& path,
80 uint64_t* file_size); 82 uint64_t* file_size);
81 83
82 // Synchronously renames a file. 84 // Synchronously renames a file.
83 filesystem::FileError RenameFile(OpaqueDir* dir, 85 filesystem::mojom::FileError RenameFile(OpaqueDir* dir,
84 const std::string& old_path, 86 const std::string& old_path,
85 const std::string& new_path); 87 const std::string& new_path);
86 88
87 // Synchronously locks a file. Returns both the file return code, and if OK, 89 // Synchronously locks a file. Returns both the file return code, and if OK,
88 // an opaque object to the lock to enforce going through this interface to 90 // an opaque object to the lock to enforce going through this interface to
89 // unlock the file so that unlocking happens on the correct thread. 91 // unlock the file so that unlocking happens on the correct thread.
90 std::pair<filesystem::FileError, OpaqueLock*> LockFile( 92 std::pair<filesystem::mojom::FileError, OpaqueLock*> LockFile(
91 OpaqueDir* dir, 93 OpaqueDir* dir,
92 const std::string& path); 94 const std::string& path);
93 95
94 // Unlocks a file. LevelDBMojoProxy takes ownership of lock. (We don't make 96 // Unlocks a file. LevelDBMojoProxy takes ownership of lock. (We don't make
95 // this a scoped_ptr because exporting the ctor/dtor for this struct publicly 97 // this a scoped_ptr because exporting the ctor/dtor for this struct publicly
96 // defeats the purpose of the struct.) 98 // defeats the purpose of the struct.)
97 filesystem::FileError UnlockFile(OpaqueLock* lock); 99 filesystem::mojom::FileError UnlockFile(OpaqueLock* lock);
98 100
99 private: 101 private:
100 friend class base::RefCountedThreadSafe<LevelDBMojoProxy>; 102 friend class base::RefCountedThreadSafe<LevelDBMojoProxy>;
101 ~LevelDBMojoProxy(); 103 ~LevelDBMojoProxy();
102 104
103 void RunInternal(const base::Closure& task); 105 void RunInternal(const base::Closure& task);
104 106
105 void DoOnOtherThread(const base::Closure& c, base::WaitableEvent* event); 107 void DoOnOtherThread(const base::Closure& c, base::WaitableEvent* event);
106 108
107 // Implementation methods of the public interface. Depending on whether they 109 // Implementation methods of the public interface. Depending on whether they
108 // were called from the thread that |task_runner_| is, these might be run 110 // were called from the thread that |task_runner_| is, these might be run
109 // on the current thread or through PostTask(). 111 // on the current thread or through PostTask().
110 void RegisterDirectoryImpl( 112 void RegisterDirectoryImpl(
111 mojo::InterfacePtrInfo<filesystem::Directory> directory_info, 113 mojo::InterfacePtrInfo<filesystem::mojom::Directory> directory_info,
112 OpaqueDir** out_dir); 114 OpaqueDir** out_dir);
113 void UnregisterDirectoryImpl(OpaqueDir* dir); 115 void UnregisterDirectoryImpl(OpaqueDir* dir);
114 void OpenFileHandleImpl(OpaqueDir* dir, 116 void OpenFileHandleImpl(OpaqueDir* dir,
115 std::string name, 117 std::string name,
116 uint32_t open_flags, 118 uint32_t open_flags,
117 base::File* out_file); 119 base::File* out_file);
118 void SyncDirectoryImpl(OpaqueDir* dir, 120 void SyncDirectoryImpl(OpaqueDir* dir,
119 std::string name, 121 std::string name,
120 filesystem::FileError* out_error); 122 filesystem::mojom::FileError* out_error);
121 void FileExistsImpl(OpaqueDir* dir, 123 void FileExistsImpl(OpaqueDir* dir,
122 std::string name, 124 std::string name,
123 bool* exists); 125 bool* exists);
124 void GetChildrenImpl(OpaqueDir* dir, 126 void GetChildrenImpl(OpaqueDir* dir,
125 std::string name, 127 std::string name,
126 std::vector<std::string>* contents, 128 std::vector<std::string>* contents,
127 filesystem::FileError* out_error); 129 filesystem::mojom::FileError* out_error);
128 void DeleteImpl(OpaqueDir* dir, 130 void DeleteImpl(OpaqueDir* dir,
129 std::string name, 131 std::string name,
130 uint32_t delete_flags, 132 uint32_t delete_flags,
131 filesystem::FileError* out_error); 133 filesystem::mojom::FileError* out_error);
132 void CreateDirImpl(OpaqueDir* dir, 134 void CreateDirImpl(OpaqueDir* dir,
133 std::string name, 135 std::string name,
134 filesystem::FileError* out_error); 136 filesystem::mojom::FileError* out_error);
135 void GetFileSizeImpl(OpaqueDir* dir, 137 void GetFileSizeImpl(OpaqueDir* dir,
136 const std::string& path, 138 const std::string& path,
137 uint64_t* file_size, 139 uint64_t* file_size,
138 filesystem::FileError* out_error); 140 filesystem::mojom::FileError* out_error);
139 void RenameFileImpl(OpaqueDir* dir, 141 void RenameFileImpl(OpaqueDir* dir,
140 const std::string& old_path, 142 const std::string& old_path,
141 const std::string& new_path, 143 const std::string& new_path,
142 filesystem::FileError* out_error); 144 filesystem::mojom::FileError* out_error);
143 void LockFileImpl(OpaqueDir* dir, 145 void LockFileImpl(OpaqueDir* dir,
144 const std::string& path, 146 const std::string& path,
145 filesystem::FileError* out_error, 147 filesystem::mojom::FileError* out_error,
146 OpaqueLock** out_lock); 148 OpaqueLock** out_lock);
147 void UnlockFileImpl(std::unique_ptr<OpaqueLock> lock, 149 void UnlockFileImpl(std::unique_ptr<OpaqueLock> lock,
148 filesystem::FileError* out_error); 150 filesystem::mojom::FileError* out_error);
149 151
150 // The task runner which represents the thread that all mojo objects are 152 // The task runner which represents the thread that all mojo objects are
151 // bound to. 153 // bound to.
152 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 154 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
153 155
154 int outstanding_opaque_dirs_; 156 int outstanding_opaque_dirs_;
155 157
156 DISALLOW_COPY_AND_ASSIGN(LevelDBMojoProxy); 158 DISALLOW_COPY_AND_ASSIGN(LevelDBMojoProxy);
157 }; 159 };
158 160
159 } // namespace leveldb 161 } // namespace leveldb
160 162
161 #endif // COMPONENTS_LEVELDB_LEVELDB_MOJO_PROXY_H_ 163 #endif // COMPONENTS_LEVELDB_LEVELDB_MOJO_PROXY_H_
OLDNEW
« no previous file with comments | « components/leveldb/env_mojo.cc ('k') | components/leveldb/leveldb_mojo_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698