OLD | NEW |
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 19 matching lines...) Expand all Loading... |
30 // thread. Because of this mismatch, we create a proxy object which will | 30 // thread. Because of this mismatch, we create a proxy object which will |
31 // redirect calls to the thread which owns the Mojo pipe, sends and receives | 31 // redirect calls to the thread which owns the Mojo pipe, sends and receives |
32 // messages. | 32 // messages. |
33 // | 33 // |
34 // All public methods can be accessed from any thread. | 34 // All public methods can be accessed from any thread. |
35 class LevelDBMojoProxy : public base::RefCountedThreadSafe<LevelDBMojoProxy> { | 35 class LevelDBMojoProxy : public base::RefCountedThreadSafe<LevelDBMojoProxy> { |
36 public: | 36 public: |
37 explicit LevelDBMojoProxy( | 37 explicit LevelDBMojoProxy( |
38 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 38 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
39 | 39 |
| 40 base::SingleThreadTaskRunner* task_runner() const { |
| 41 return task_runner_.get(); |
| 42 } |
| 43 |
40 // A private struct to hide the underlying file that holds the lock from our | 44 // A private struct to hide the underlying file that holds the lock from our |
41 // callers, forcing them to go through our LockFile()/UnlockFile() interface | 45 // callers, forcing them to go through our LockFile()/UnlockFile() interface |
42 // so that they don't try to use the underlying pointer from an unsafe thread. | 46 // so that they don't try to use the underlying pointer from an unsafe thread. |
43 struct OpaqueLock; | 47 struct OpaqueLock; |
44 | 48 |
45 // A private struct to hide the underlying root directory that we're | 49 // A private struct to hide the underlying root directory that we're |
46 // operating in. LevelDBMojoProxy will want to own all the directory | 50 // operating in. LevelDBMojoProxy will want to own all the directory |
47 // pointers, so while opening a database, we pass the directory to the thread | 51 // pointers, so while opening a database, we pass the directory to the thread |
48 // it will be operated on. | 52 // it will be operated on. |
49 struct OpaqueDir; | 53 struct OpaqueDir; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 161 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
158 | 162 |
159 int outstanding_opaque_dirs_; | 163 int outstanding_opaque_dirs_; |
160 | 164 |
161 DISALLOW_COPY_AND_ASSIGN(LevelDBMojoProxy); | 165 DISALLOW_COPY_AND_ASSIGN(LevelDBMojoProxy); |
162 }; | 166 }; |
163 | 167 |
164 } // namespace leveldb | 168 } // namespace leveldb |
165 | 169 |
166 #endif // COMPONENTS_LEVELDB_LEVELDB_MOJO_PROXY_H_ | 170 #endif // COMPONENTS_LEVELDB_LEVELDB_MOJO_PROXY_H_ |
OLD | NEW |