| 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.mojom.h" |
| 20 #include "content/common/indexed_db/indexed_db_key.h" | 21 #include "content/common/indexed_db/indexed_db_key.h" |
| 21 #include "content/common/indexed_db/indexed_db_key_path.h" | 22 #include "content/common/indexed_db/indexed_db_key_path.h" |
| 22 #include "url/origin.h" | 23 #include "url/origin.h" |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 class IndexedDBBlobInfo; | 26 class IndexedDBBlobInfo; |
| 26 class IndexedDBConnection; | 27 class IndexedDBConnection; |
| 27 class IndexedDBCursor; | 28 class IndexedDBCursor; |
| 28 class IndexedDBDatabase; | 29 class IndexedDBDatabase; |
| 29 class IndexedDBDatabaseCallbacks; | 30 class IndexedDBDatabaseCallbacks; |
| 30 struct IndexedDBDataLossInfo; | 31 struct IndexedDBDataLossInfo; |
| 31 struct IndexedDBDatabaseMetadata; | 32 struct IndexedDBDatabaseMetadata; |
| 32 struct IndexedDBReturnValue; | 33 struct IndexedDBReturnValue; |
| 33 struct IndexedDBValue; | 34 struct IndexedDBValue; |
| 34 | 35 |
| 35 class CONTENT_EXPORT IndexedDBCallbacks | 36 class CONTENT_EXPORT IndexedDBCallbacks |
| 36 : public base::RefCounted<IndexedDBCallbacks> { | 37 : public base::RefCounted<IndexedDBCallbacks> { |
| 37 public: | 38 public: |
| 38 // Simple payload responses | 39 // Simple payload responses |
| 39 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, | 40 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, |
| 40 int32_t ipc_thread_id, | 41 int32_t ipc_thread_id, |
| 41 int32_t ipc_callbacks_id); | 42 int32_t ipc_callbacks_id); |
| 42 | 43 |
| 43 // IndexedDBCursor responses | 44 // IndexedDBCursor responses |
| 44 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, | 45 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, |
| 45 int32_t ipc_thread_id, | 46 int32_t ipc_thread_id, |
| 46 int32_t ipc_callbacks_id, | 47 int32_t ipc_callbacks_id, |
| 47 int32_t ipc_cursor_id); | 48 int32_t ipc_cursor_id); |
| 48 | 49 |
| 49 // IndexedDBDatabase responses | 50 // Mojo-based responses |
| 50 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, | 51 IndexedDBCallbacks( |
| 51 int32_t ipc_thread_id, | 52 IndexedDBDispatcherHost* dispatcher_host, |
| 52 int32_t ipc_callbacks_id, | 53 const url::Origin& origin, |
| 53 int32_t ipc_database_callbacks_id, | 54 ::indexed_db::mojom::CallbacksAssociatedPtrInfo callbacks_info); |
| 54 int64_t host_transaction_id, | |
| 55 const url::Origin& origin); | |
| 56 | 55 |
| 57 virtual void OnError(const IndexedDBDatabaseError& error); | 56 virtual void OnError(const IndexedDBDatabaseError& error); |
| 58 | 57 |
| 59 // IndexedDBFactory::GetDatabaseNames | 58 // IndexedDBFactory::GetDatabaseNames |
| 60 virtual void OnSuccess(const std::vector<base::string16>& string); | 59 virtual void OnSuccess(const std::vector<base::string16>& string); |
| 61 | 60 |
| 62 // IndexedDBFactory::Open / DeleteDatabase | 61 // IndexedDBFactory::Open / DeleteDatabase |
| 63 virtual void OnBlocked(int64_t existing_version); | 62 virtual void OnBlocked(int64_t existing_version); |
| 64 | 63 |
| 65 // IndexedDBFactory::Open | 64 // IndexedDBFactory::Open |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // IndexedDBDatabase::Count | 101 // IndexedDBDatabase::Count |
| 103 // IndexedDBFactory::DeleteDatabase | 102 // IndexedDBFactory::DeleteDatabase |
| 104 // IndexedDBDatabase::DeleteRange | 103 // IndexedDBDatabase::DeleteRange |
| 105 virtual void OnSuccess(int64_t value); | 104 virtual void OnSuccess(int64_t value); |
| 106 | 105 |
| 107 // IndexedDBCursor::Continue / Advance (when complete) | 106 // IndexedDBCursor::Continue / Advance (when complete) |
| 108 virtual void OnSuccess(); | 107 virtual void OnSuccess(); |
| 109 | 108 |
| 110 void SetConnectionOpenStartTime(const base::TimeTicks& start_time); | 109 void SetConnectionOpenStartTime(const base::TimeTicks& start_time); |
| 111 | 110 |
| 111 void set_host_transaction_id(int64_t host_transaction_id) { |
| 112 host_transaction_id_ = host_transaction_id; |
| 113 } |
| 114 |
| 112 protected: | 115 protected: |
| 113 virtual ~IndexedDBCallbacks(); | 116 virtual ~IndexedDBCallbacks(); |
| 114 | 117 |
| 115 private: | 118 private: |
| 116 void RegisterBlobsAndSend(const std::vector<IndexedDBBlobInfo>& blob_info, | 119 void RegisterBlobsAndSend(const std::vector<IndexedDBBlobInfo>& blob_info, |
| 117 const base::Closure& callback); | 120 const base::Closure& callback); |
| 118 | 121 |
| 119 friend class base::RefCounted<IndexedDBCallbacks>; | 122 friend class base::RefCounted<IndexedDBCallbacks>; |
| 120 | 123 |
| 124 class IOThreadHelper; |
| 125 |
| 121 // Originally from IndexedDBCallbacks: | 126 // Originally from IndexedDBCallbacks: |
| 122 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; | 127 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; |
| 123 int32_t ipc_callbacks_id_; | 128 int32_t ipc_callbacks_id_; |
| 124 int32_t ipc_thread_id_; | 129 int32_t ipc_thread_id_; |
| 125 | 130 |
| 126 // IndexedDBCursor callbacks ------------------------ | 131 // IndexedDBCursor callbacks ------------------------ |
| 127 int32_t ipc_cursor_id_; | 132 int32_t ipc_cursor_id_; |
| 128 | 133 |
| 129 // IndexedDBDatabase callbacks ------------------------ | 134 // IndexedDBDatabase callbacks ------------------------ |
| 130 int64_t host_transaction_id_; | 135 int64_t host_transaction_id_; |
| 131 url::Origin origin_; | 136 url::Origin origin_; |
| 132 int32_t ipc_database_id_; | 137 int32_t ipc_database_id_; |
| 133 int32_t ipc_database_callbacks_id_; | |
| 134 | 138 |
| 135 // Used to assert that OnSuccess is only called if there was no data loss. | 139 // Used to assert that OnSuccess is only called if there was no data loss. |
| 136 blink::WebIDBDataLoss data_loss_; | 140 blink::WebIDBDataLoss data_loss_; |
| 137 | 141 |
| 138 // The "blocked" event should be sent at most once per request. | 142 // The "blocked" event should be sent at most once per request. |
| 139 bool sent_blocked_; | 143 bool sent_blocked_; |
| 140 base::TimeTicks connection_open_start_time_; | 144 base::TimeTicks connection_open_start_time_; |
| 145 |
| 146 IOThreadHelper* helper_; |
| 147 |
| 141 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacks); | 148 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacks); |
| 142 }; | 149 }; |
| 143 | 150 |
| 144 } // namespace content | 151 } // namespace content |
| 145 | 152 |
| 146 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ | 153 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ |
| OLD | NEW |