OLD | NEW |
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/ref_counted.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 content { | 26 namespace content { |
27 class IndexedDBBlobInfo; | |
28 class IndexedDBConnection; | 27 class IndexedDBConnection; |
29 class IndexedDBCursor; | 28 class IndexedDBCursor; |
30 class IndexedDBDatabase; | 29 class IndexedDBDatabase; |
31 struct IndexedDBDataLossInfo; | 30 struct IndexedDBDataLossInfo; |
32 struct IndexedDBDatabaseMetadata; | 31 struct IndexedDBDatabaseMetadata; |
33 struct IndexedDBReturnValue; | 32 struct IndexedDBReturnValue; |
34 struct IndexedDBValue; | 33 struct IndexedDBValue; |
35 | 34 |
36 class CONTENT_EXPORT IndexedDBCallbacks | 35 class CONTENT_EXPORT IndexedDBCallbacks |
37 : public base::RefCounted<IndexedDBCallbacks> { | 36 : public base::RefCounted<IndexedDBCallbacks> { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 virtual void OnSuccess(const IndexedDBKey& key); | 85 virtual void OnSuccess(const IndexedDBKey& key); |
87 | 86 |
88 // IndexedDBDatabase::Count | 87 // IndexedDBDatabase::Count |
89 // IndexedDBFactory::DeleteDatabase | 88 // IndexedDBFactory::DeleteDatabase |
90 // IndexedDBDatabase::DeleteRange | 89 // IndexedDBDatabase::DeleteRange |
91 virtual void OnSuccess(int64_t value); | 90 virtual void OnSuccess(int64_t value); |
92 | 91 |
93 // IndexedDBCursor::Continue / Advance (when complete) | 92 // IndexedDBCursor::Continue / Advance (when complete) |
94 virtual void OnSuccess(); | 93 virtual void OnSuccess(); |
95 | 94 |
96 // Checks to see if the associated dispatcher host is still connected. If | |
97 // not this request can be dropped. | |
98 virtual bool IsValid() const; | |
99 | |
100 void SetConnectionOpenStartTime(const base::TimeTicks& start_time); | 95 void SetConnectionOpenStartTime(const base::TimeTicks& start_time); |
101 | 96 |
102 protected: | 97 protected: |
103 virtual ~IndexedDBCallbacks(); | 98 virtual ~IndexedDBCallbacks(); |
104 | 99 |
105 private: | 100 private: |
106 void RegisterBlobsAndSend(const std::vector<IndexedDBBlobInfo>& blob_info, | |
107 const base::Closure& callback); | |
108 | |
109 friend class base::RefCounted<IndexedDBCallbacks>; | 101 friend class base::RefCounted<IndexedDBCallbacks>; |
110 | 102 |
111 class IOThreadHelper; | 103 class IOThreadHelper; |
112 | 104 |
113 // Originally from IndexedDBCallbacks: | 105 // Originally from IndexedDBCallbacks: |
114 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; | 106 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; |
115 | 107 |
116 // IndexedDBDatabase callbacks ------------------------ | 108 // IndexedDBDatabase callbacks ------------------------ |
117 url::Origin origin_; | 109 url::Origin origin_; |
118 bool database_sent_ = false; | 110 bool database_sent_ = false; |
119 | 111 |
120 // Used to assert that OnSuccess is only called if there was no data loss. | 112 // Used to assert that OnSuccess is only called if there was no data loss. |
121 blink::WebIDBDataLoss data_loss_; | 113 blink::WebIDBDataLoss data_loss_; |
122 | 114 |
123 // The "blocked" event should be sent at most once per request. | 115 // The "blocked" event should be sent at most once per request. |
124 bool sent_blocked_; | 116 bool sent_blocked_; |
125 base::TimeTicks connection_open_start_time_; | 117 base::TimeTicks connection_open_start_time_; |
126 | 118 |
127 std::unique_ptr<IOThreadHelper, BrowserThread::DeleteOnIOThread> io_helper_; | 119 std::unique_ptr<IOThreadHelper, BrowserThread::DeleteOnIOThread> io_helper_; |
128 base::ThreadChecker thread_checker_; | 120 base::ThreadChecker thread_checker_; |
129 | 121 |
130 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacks); | 122 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacks); |
131 }; | 123 }; |
132 | 124 |
133 } // namespace content | 125 } // namespace content |
134 | 126 |
135 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ | 127 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ |
OLD | NEW |