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

Side by Side Diff: content/browser/indexed_db/indexed_db_callbacks.h

Issue 2727733004: [IndexedDB] Closing mojo connections when renderer quits (Closed)
Patch Set: fix and rebase Created 3 years, 8 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
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_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
18 #include "base/threading/thread_checker.h" 18 #include "base/threading/thread_checker.h"
19 #include "content/browser/indexed_db/indexed_db_database_error.h" 19 #include "content/browser/indexed_db/indexed_db_database_error.h"
20 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" 20 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h"
21 #include "content/common/indexed_db/indexed_db.mojom.h" 21 #include "content/common/indexed_db/indexed_db.mojom.h"
22 #include "content/common/indexed_db/indexed_db_key.h" 22 #include "content/common/indexed_db/indexed_db_key.h"
23 #include "content/common/indexed_db/indexed_db_key_path.h" 23 #include "content/common/indexed_db/indexed_db_key_path.h"
24 #include "url/origin.h" 24 #include "url/origin.h"
25 25
26 namespace base {
27 class SequencedTaskRunner;
28 }
29
26 namespace content { 30 namespace content {
27 class IndexedDBConnection; 31 class IndexedDBConnection;
28 class IndexedDBCursor; 32 class IndexedDBCursor;
29 class IndexedDBDatabase; 33 class IndexedDBDatabase;
30 struct IndexedDBDataLossInfo; 34 struct IndexedDBDataLossInfo;
31 struct IndexedDBDatabaseMetadata; 35 struct IndexedDBDatabaseMetadata;
32 struct IndexedDBReturnValue; 36 struct IndexedDBReturnValue;
33 struct IndexedDBValue; 37 struct IndexedDBValue;
34 38
39 // Expected to be constructed on IO thread and called/deleted from IDB thread.
35 class CONTENT_EXPORT IndexedDBCallbacks 40 class CONTENT_EXPORT IndexedDBCallbacks
36 : public base::RefCounted<IndexedDBCallbacks> { 41 : public base::RefCounted<IndexedDBCallbacks> {
37 public: 42 public:
38 // Destructively converts an IndexedDBValue to a Mojo Value. 43 // Destructively converts an IndexedDBValue to a Mojo Value.
39 static ::indexed_db::mojom::ValuePtr ConvertAndEraseValue( 44 static ::indexed_db::mojom::ValuePtr ConvertAndEraseValue(
40 IndexedDBValue* value); 45 IndexedDBValue* value);
41 46
42 IndexedDBCallbacks( 47 IndexedDBCallbacks(
43 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host, 48 base::WeakPtr<IndexedDBDispatcherHost> dispatcher_host,
44 const url::Origin& origin, 49 const url::Origin& origin,
45 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info); 50 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info,
51 scoped_refptr<base::SequencedTaskRunner> idb_runner);
46 52
47 virtual void OnError(const IndexedDBDatabaseError& error); 53 virtual void OnError(const IndexedDBDatabaseError& error);
48 54
49 // IndexedDBFactory::GetDatabaseNames 55 // IndexedDBFactory::GetDatabaseNames
50 virtual void OnSuccess(const std::vector<base::string16>& string); 56 virtual void OnSuccess(const std::vector<base::string16>& string);
51 57
52 // IndexedDBFactory::Open / DeleteDatabase 58 // IndexedDBFactory::Open / DeleteDatabase
53 virtual void OnBlocked(int64_t existing_version); 59 virtual void OnBlocked(int64_t existing_version);
54 60
55 // IndexedDBFactory::Open 61 // IndexedDBFactory::Open
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 void SetConnectionOpenStartTime(const base::TimeTicks& start_time); 105 void SetConnectionOpenStartTime(const base::TimeTicks& start_time);
100 106
101 protected: 107 protected:
102 virtual ~IndexedDBCallbacks(); 108 virtual ~IndexedDBCallbacks();
103 109
104 private: 110 private:
105 friend class base::RefCounted<IndexedDBCallbacks>; 111 friend class base::RefCounted<IndexedDBCallbacks>;
106 112
107 class IOThreadHelper; 113 class IOThreadHelper;
108 114
109 // Originally from IndexedDBCallbacks: 115 bool closed_ = false;
jsbell 2017/04/11 16:58:04 Add comments about what these mean.
dmurph 2017/04/11 19:32:49 Done.
110 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; 116 bool database_created_ = false;
111
112 // IndexedDBDatabase callbacks ------------------------
113 url::Origin origin_;
114 bool database_sent_ = false;
115 117
116 // Used to assert that OnSuccess is only called if there was no data loss. 118 // Used to assert that OnSuccess is only called if there was no data loss.
117 blink::WebIDBDataLoss data_loss_; 119 blink::WebIDBDataLoss data_loss_;
118 120
119 // The "blocked" event should be sent at most once per request. 121 // The "blocked" event should be sent at most once per request.
120 bool sent_blocked_; 122 bool sent_blocked_ = false;
121 base::TimeTicks connection_open_start_time_; 123 base::TimeTicks connection_open_start_time_;
122 124
123 std::unique_ptr<IOThreadHelper, BrowserThread::DeleteOnIOThread> io_helper_; 125 std::unique_ptr<IOThreadHelper, BrowserThread::DeleteOnIOThread> io_helper_;
124 base::ThreadChecker thread_checker_; 126 base::ThreadChecker thread_checker_;
125 127
126 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacks); 128 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacks);
127 }; 129 };
128 130
129 } // namespace content 131 } // namespace content
130 132
131 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ 133 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698