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 "content/browser/indexed_db/indexed_db_database_error.h" | 18 #include "content/browser/indexed_db/indexed_db_database_error.h" |
19 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" | 19 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
20 #include "content/common/indexed_db/indexed_db_key.h" | 20 #include "content/common/indexed_db/indexed_db_key.h" |
21 #include "content/common/indexed_db/indexed_db_key_path.h" | 21 #include "content/common/indexed_db/indexed_db_key_path.h" |
22 #include "url/origin.h" | 22 #include "url/origin.h" |
23 | 23 |
24 namespace content { | 24 namespace content { |
25 class IndexedDBBlobInfo; | 25 class IndexedDBBlobInfo; |
26 class IndexedDBConnection; | 26 class IndexedDBConnection; |
27 class IndexedDBCursor; | 27 class IndexedDBCursor; |
28 class IndexedDBDatabase; | 28 class IndexedDBDatabase; |
29 class IndexedDBDatabaseCallbacks; | 29 class IndexedDBDatabaseCallbacks; |
| 30 struct IndexedDBDataLossInfo; |
30 struct IndexedDBDatabaseMetadata; | 31 struct IndexedDBDatabaseMetadata; |
31 struct IndexedDBReturnValue; | 32 struct IndexedDBReturnValue; |
32 struct IndexedDBValue; | 33 struct IndexedDBValue; |
33 | 34 |
34 struct IndexedDBDataLossInfo { | |
35 blink::WebIDBDataLoss status = blink::WebIDBDataLossNone; | |
36 std::string message; | |
37 }; | |
38 | |
39 class CONTENT_EXPORT IndexedDBCallbacks | 35 class CONTENT_EXPORT IndexedDBCallbacks |
40 : public base::RefCounted<IndexedDBCallbacks> { | 36 : public base::RefCounted<IndexedDBCallbacks> { |
41 public: | 37 public: |
42 // Simple payload responses | 38 // Simple payload responses |
43 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, | 39 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, |
44 int32_t ipc_thread_id, | 40 int32_t ipc_thread_id, |
45 int32_t ipc_callbacks_id); | 41 int32_t ipc_callbacks_id); |
46 | 42 |
47 // IndexedDBCursor responses | 43 // IndexedDBCursor responses |
48 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, | 44 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, |
(...skipping 11 matching lines...) Expand all Loading... |
60 | 56 |
61 virtual void OnError(const IndexedDBDatabaseError& error); | 57 virtual void OnError(const IndexedDBDatabaseError& error); |
62 | 58 |
63 // IndexedDBFactory::GetDatabaseNames | 59 // IndexedDBFactory::GetDatabaseNames |
64 virtual void OnSuccess(const std::vector<base::string16>& string); | 60 virtual void OnSuccess(const std::vector<base::string16>& string); |
65 | 61 |
66 // IndexedDBFactory::Open / DeleteDatabase | 62 // IndexedDBFactory::Open / DeleteDatabase |
67 virtual void OnBlocked(int64_t existing_version); | 63 virtual void OnBlocked(int64_t existing_version); |
68 | 64 |
69 // IndexedDBFactory::Open | 65 // IndexedDBFactory::Open |
70 virtual void OnDataLoss(const IndexedDBDataLossInfo& data_loss_info); | |
71 virtual void OnUpgradeNeeded( | 66 virtual void OnUpgradeNeeded( |
72 int64_t old_version, | 67 int64_t old_version, |
73 std::unique_ptr<IndexedDBConnection> connection, | 68 std::unique_ptr<IndexedDBConnection> connection, |
74 const content::IndexedDBDatabaseMetadata& metadata); | 69 const content::IndexedDBDatabaseMetadata& metadata, |
| 70 const IndexedDBDataLossInfo& data_loss_info); |
75 virtual void OnSuccess(std::unique_ptr<IndexedDBConnection> connection, | 71 virtual void OnSuccess(std::unique_ptr<IndexedDBConnection> connection, |
76 const content::IndexedDBDatabaseMetadata& metadata); | 72 const content::IndexedDBDatabaseMetadata& metadata); |
77 | 73 |
78 // IndexedDBDatabase::OpenCursor | 74 // IndexedDBDatabase::OpenCursor |
79 virtual void OnSuccess(scoped_refptr<IndexedDBCursor> cursor, | 75 virtual void OnSuccess(scoped_refptr<IndexedDBCursor> cursor, |
80 const IndexedDBKey& key, | 76 const IndexedDBKey& key, |
81 const IndexedDBKey& primary_key, | 77 const IndexedDBKey& primary_key, |
82 IndexedDBValue* value); | 78 IndexedDBValue* value); |
83 | 79 |
84 // IndexedDBCursor::Continue / Advance | 80 // IndexedDBCursor::Continue / Advance |
(...skipping 19 matching lines...) Expand all Loading... |
104 virtual void OnSuccess(const IndexedDBKey& key); | 100 virtual void OnSuccess(const IndexedDBKey& key); |
105 | 101 |
106 // IndexedDBDatabase::Count | 102 // IndexedDBDatabase::Count |
107 // IndexedDBFactory::DeleteDatabase | 103 // IndexedDBFactory::DeleteDatabase |
108 // IndexedDBDatabase::DeleteRange | 104 // IndexedDBDatabase::DeleteRange |
109 virtual void OnSuccess(int64_t value); | 105 virtual void OnSuccess(int64_t value); |
110 | 106 |
111 // IndexedDBCursor::Continue / Advance (when complete) | 107 // IndexedDBCursor::Continue / Advance (when complete) |
112 virtual void OnSuccess(); | 108 virtual void OnSuccess(); |
113 | 109 |
114 const IndexedDBDataLossInfo& data_loss_info() const { | |
115 return data_loss_info_; | |
116 } | |
117 | |
118 void SetConnectionOpenStartTime(const base::TimeTicks& start_time); | 110 void SetConnectionOpenStartTime(const base::TimeTicks& start_time); |
119 | 111 |
120 protected: | 112 protected: |
121 virtual ~IndexedDBCallbacks(); | 113 virtual ~IndexedDBCallbacks(); |
122 | 114 |
123 private: | 115 private: |
124 void RegisterBlobsAndSend(const std::vector<IndexedDBBlobInfo>& blob_info, | 116 void RegisterBlobsAndSend(const std::vector<IndexedDBBlobInfo>& blob_info, |
125 const base::Closure& callback); | 117 const base::Closure& callback); |
126 | 118 |
127 friend class base::RefCounted<IndexedDBCallbacks>; | 119 friend class base::RefCounted<IndexedDBCallbacks>; |
128 | 120 |
129 // Originally from IndexedDBCallbacks: | 121 // Originally from IndexedDBCallbacks: |
130 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; | 122 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; |
131 int32_t ipc_callbacks_id_; | 123 int32_t ipc_callbacks_id_; |
132 int32_t ipc_thread_id_; | 124 int32_t ipc_thread_id_; |
133 | 125 |
134 // IndexedDBCursor callbacks ------------------------ | 126 // IndexedDBCursor callbacks ------------------------ |
135 int32_t ipc_cursor_id_; | 127 int32_t ipc_cursor_id_; |
136 | 128 |
137 // IndexedDBDatabase callbacks ------------------------ | 129 // IndexedDBDatabase callbacks ------------------------ |
138 int64_t host_transaction_id_; | 130 int64_t host_transaction_id_; |
139 url::Origin origin_; | 131 url::Origin origin_; |
140 int32_t ipc_database_id_; | 132 int32_t ipc_database_id_; |
141 int32_t ipc_database_callbacks_id_; | 133 int32_t ipc_database_callbacks_id_; |
142 | 134 |
143 // Used to assert that OnSuccess is only called if there was no data loss. | 135 // Used to assert that OnSuccess is only called if there was no data loss. |
144 IndexedDBDataLossInfo data_loss_info_; | 136 blink::WebIDBDataLoss data_loss_; |
145 | 137 |
146 // The "blocked" event should be sent at most once per request. | 138 // The "blocked" event should be sent at most once per request. |
147 bool sent_blocked_; | 139 bool sent_blocked_; |
148 base::TimeTicks connection_open_start_time_; | 140 base::TimeTicks connection_open_start_time_; |
149 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacks); | 141 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacks); |
150 }; | 142 }; |
151 | 143 |
152 } // namespace content | 144 } // namespace content |
153 | 145 |
154 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ | 146 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ |
OLD | NEW |