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

Unified Diff: components/leveldb/leveldb_file_thread.h

Issue 1825413003: leveldb_service: Attempt to fix deadlock on shutdown. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: typo Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/leveldb/leveldb_database_impl.cc ('k') | components/leveldb/leveldb_file_thread.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/leveldb/leveldb_file_thread.h
diff --git a/components/leveldb/leveldb_file_thread.h b/components/leveldb/leveldb_file_thread.h
index dc051a4777c3026e89aadb22579ec537bd8d879c..769c324220784aa083ed3e67d65be2d211f532b1 100644
--- a/components/leveldb/leveldb_file_thread.h
+++ b/components/leveldb/leveldb_file_thread.h
@@ -5,7 +5,10 @@
#ifndef COMPONENTS_LEVELDB_LEVELDB_FILE_THREAD_H_
#define COMPONENTS_LEVELDB_LEVELDB_FILE_THREAD_H_
+#include <map>
#include <string>
+#include <utility>
+#include <vector>
#include "base/files/file.h"
#include "base/memory/ref_counted.h"
@@ -96,6 +99,22 @@ class LevelDBFileThread : public base::Thread,
friend class base::RefCountedThreadSafe<LevelDBFileThread>;
~LevelDBFileThread() override;
+ // Called from the beginning of most impls which take an OpaqueDir. Returns
+ // true if the directory was unbound between the time the task was posted and
+ // the task was run on this thread. If it was, no further processing should
+ // be done (and the waitable event will be Signal()ed).
+ bool RegisterDirAndWaitableEvent(OpaqueDir* dir,
+ base::WaitableEvent* done_event);
+
+ // Cleans up internal state related to the waitable event before Signal()ing
+ // it.
+ void CompleteWaitableEvent(base::WaitableEvent* done_event);
+
+ // Called when one of our directory or files has a connection error. This
+ // will find all the outstanding waitable events that depend on it and signal
+ // them.
+ void OnConnectionError();
+
void RegisterDirectoryImpl(
base::WaitableEvent* done_event,
mojo::InterfacePtrInfo<filesystem::Directory> directory_info,
@@ -217,6 +236,14 @@ class LevelDBFileThread : public base::Thread,
int outstanding_opaque_dirs_;
+ // When our public methods are called, we create a WaitableEvent on their
+ // thread so that we can block their thread on the LevelDBFileThread. We then
+ // need to track what DirectoryPtrs and FilePtrs, which if they get closed,
+ // should immediately trigger the waitable event.
+ struct WaitableEventDependencies;
+ std::map<base::WaitableEvent*, WaitableEventDependencies>
+ waitable_event_dependencies_;
+
DISALLOW_COPY_AND_ASSIGN(LevelDBFileThread);
};
« no previous file with comments | « components/leveldb/leveldb_database_impl.cc ('k') | components/leveldb/leveldb_file_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698