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