| 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> |
| 9 |
| 8 #include <string> | 10 #include <string> |
| 9 #include <vector> | 11 #include <vector> |
| 10 | 12 |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 16 #include "content/browser/indexed_db/indexed_db_database_error.h" | 18 #include "content/browser/indexed_db/indexed_db_database_error.h" |
| 17 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" | 19 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
| 18 #include "content/common/indexed_db/indexed_db_key.h" | 20 #include "content/common/indexed_db/indexed_db_key.h" |
| 19 #include "content/common/indexed_db/indexed_db_key_path.h" | 21 #include "content/common/indexed_db/indexed_db_key_path.h" |
| 20 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 21 | 23 |
| 22 namespace content { | 24 namespace content { |
| 23 class IndexedDBBlobInfo; | 25 class IndexedDBBlobInfo; |
| 24 class IndexedDBConnection; | 26 class IndexedDBConnection; |
| 25 class IndexedDBCursor; | 27 class IndexedDBCursor; |
| 26 class IndexedDBDatabase; | 28 class IndexedDBDatabase; |
| 27 class IndexedDBDatabaseCallbacks; | 29 class IndexedDBDatabaseCallbacks; |
| 28 struct IndexedDBDatabaseMetadata; | 30 struct IndexedDBDatabaseMetadata; |
| 29 struct IndexedDBReturnValue; | 31 struct IndexedDBReturnValue; |
| 30 struct IndexedDBValue; | 32 struct IndexedDBValue; |
| 31 | 33 |
| 32 class CONTENT_EXPORT IndexedDBCallbacks | 34 class CONTENT_EXPORT IndexedDBCallbacks |
| 33 : public base::RefCounted<IndexedDBCallbacks> { | 35 : public base::RefCounted<IndexedDBCallbacks> { |
| 34 public: | 36 public: |
| 35 // Simple payload responses | 37 // Simple payload responses |
| 36 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, | 38 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, |
| 37 int32 ipc_thread_id, | 39 int32_t ipc_thread_id, |
| 38 int32 ipc_callbacks_id); | 40 int32_t ipc_callbacks_id); |
| 39 | 41 |
| 40 // IndexedDBCursor responses | 42 // IndexedDBCursor responses |
| 41 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, | 43 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, |
| 42 int32 ipc_thread_id, | 44 int32_t ipc_thread_id, |
| 43 int32 ipc_callbacks_id, | 45 int32_t ipc_callbacks_id, |
| 44 int32 ipc_cursor_id); | 46 int32_t ipc_cursor_id); |
| 45 | 47 |
| 46 // IndexedDBDatabase responses | 48 // IndexedDBDatabase responses |
| 47 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, | 49 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host, |
| 48 int32 ipc_thread_id, | 50 int32_t ipc_thread_id, |
| 49 int32 ipc_callbacks_id, | 51 int32_t ipc_callbacks_id, |
| 50 int32 ipc_database_callbacks_id, | 52 int32_t ipc_database_callbacks_id, |
| 51 int64 host_transaction_id, | 53 int64_t host_transaction_id, |
| 52 const GURL& origin_url); | 54 const GURL& origin_url); |
| 53 | 55 |
| 54 virtual void OnError(const IndexedDBDatabaseError& error); | 56 virtual void OnError(const IndexedDBDatabaseError& error); |
| 55 | 57 |
| 56 // IndexedDBFactory::GetDatabaseNames | 58 // IndexedDBFactory::GetDatabaseNames |
| 57 virtual void OnSuccess(const std::vector<base::string16>& string); | 59 virtual void OnSuccess(const std::vector<base::string16>& string); |
| 58 | 60 |
| 59 // IndexedDBFactory::Open / DeleteDatabase | 61 // IndexedDBFactory::Open / DeleteDatabase |
| 60 virtual void OnBlocked(int64 existing_version); | 62 virtual void OnBlocked(int64_t existing_version); |
| 61 | 63 |
| 62 // IndexedDBFactory::Open | 64 // IndexedDBFactory::Open |
| 63 virtual void OnDataLoss(blink::WebIDBDataLoss data_loss, | 65 virtual void OnDataLoss(blink::WebIDBDataLoss data_loss, |
| 64 std::string data_loss_message); | 66 std::string data_loss_message); |
| 65 virtual void OnUpgradeNeeded( | 67 virtual void OnUpgradeNeeded( |
| 66 int64 old_version, | 68 int64_t old_version, |
| 67 scoped_ptr<IndexedDBConnection> connection, | 69 scoped_ptr<IndexedDBConnection> connection, |
| 68 const content::IndexedDBDatabaseMetadata& metadata); | 70 const content::IndexedDBDatabaseMetadata& metadata); |
| 69 virtual void OnSuccess(scoped_ptr<IndexedDBConnection> connection, | 71 virtual void OnSuccess(scoped_ptr<IndexedDBConnection> connection, |
| 70 const content::IndexedDBDatabaseMetadata& metadata); | 72 const content::IndexedDBDatabaseMetadata& metadata); |
| 71 | 73 |
| 72 // IndexedDBDatabase::OpenCursor | 74 // IndexedDBDatabase::OpenCursor |
| 73 virtual void OnSuccess(scoped_refptr<IndexedDBCursor> cursor, | 75 virtual void OnSuccess(scoped_refptr<IndexedDBCursor> cursor, |
| 74 const IndexedDBKey& key, | 76 const IndexedDBKey& key, |
| 75 const IndexedDBKey& primary_key, | 77 const IndexedDBKey& primary_key, |
| 76 IndexedDBValue* value); | 78 IndexedDBValue* value); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 92 | 94 |
| 93 // IndexedDBDatabase::GetAll | 95 // IndexedDBDatabase::GetAll |
| 94 virtual void OnSuccessArray(std::vector<IndexedDBReturnValue>* values, | 96 virtual void OnSuccessArray(std::vector<IndexedDBReturnValue>* values, |
| 95 const IndexedDBKeyPath& key_path); | 97 const IndexedDBKeyPath& key_path); |
| 96 | 98 |
| 97 // IndexedDBDatabase::Put / IndexedDBCursor::Update | 99 // IndexedDBDatabase::Put / IndexedDBCursor::Update |
| 98 virtual void OnSuccess(const IndexedDBKey& key); | 100 virtual void OnSuccess(const IndexedDBKey& key); |
| 99 | 101 |
| 100 // IndexedDBDatabase::Count | 102 // IndexedDBDatabase::Count |
| 101 // IndexedDBFactory::DeleteDatabase | 103 // IndexedDBFactory::DeleteDatabase |
| 102 virtual void OnSuccess(int64 value); | 104 virtual void OnSuccess(int64_t value); |
| 103 | 105 |
| 104 // IndexedDBDatabase::Delete | 106 // IndexedDBDatabase::Delete |
| 105 // IndexedDBCursor::Continue / Advance (when complete) | 107 // IndexedDBCursor::Continue / Advance (when complete) |
| 106 virtual void OnSuccess(); | 108 virtual void OnSuccess(); |
| 107 | 109 |
| 108 blink::WebIDBDataLoss data_loss() const { return data_loss_; } | 110 blink::WebIDBDataLoss data_loss() const { return data_loss_; } |
| 109 | 111 |
| 110 void SetConnectionOpenStartTime(const base::TimeTicks& start_time); | 112 void SetConnectionOpenStartTime(const base::TimeTicks& start_time); |
| 111 | 113 |
| 112 protected: | 114 protected: |
| 113 virtual ~IndexedDBCallbacks(); | 115 virtual ~IndexedDBCallbacks(); |
| 114 | 116 |
| 115 private: | 117 private: |
| 116 void RegisterBlobsAndSend(const std::vector<IndexedDBBlobInfo>& blob_info, | 118 void RegisterBlobsAndSend(const std::vector<IndexedDBBlobInfo>& blob_info, |
| 117 const base::Closure& callback); | 119 const base::Closure& callback); |
| 118 | 120 |
| 119 friend class base::RefCounted<IndexedDBCallbacks>; | 121 friend class base::RefCounted<IndexedDBCallbacks>; |
| 120 | 122 |
| 121 // Originally from IndexedDBCallbacks: | 123 // Originally from IndexedDBCallbacks: |
| 122 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; | 124 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; |
| 123 int32 ipc_callbacks_id_; | 125 int32_t ipc_callbacks_id_; |
| 124 int32 ipc_thread_id_; | 126 int32_t ipc_thread_id_; |
| 125 | 127 |
| 126 // IndexedDBCursor callbacks ------------------------ | 128 // IndexedDBCursor callbacks ------------------------ |
| 127 int32 ipc_cursor_id_; | 129 int32_t ipc_cursor_id_; |
| 128 | 130 |
| 129 // IndexedDBDatabase callbacks ------------------------ | 131 // IndexedDBDatabase callbacks ------------------------ |
| 130 int64 host_transaction_id_; | 132 int64_t host_transaction_id_; |
| 131 GURL origin_url_; | 133 GURL origin_url_; |
| 132 int32 ipc_database_id_; | 134 int32_t ipc_database_id_; |
| 133 int32 ipc_database_callbacks_id_; | 135 int32_t ipc_database_callbacks_id_; |
| 134 | 136 |
| 135 // Stored in OnDataLoss, merged with OnUpgradeNeeded response. | 137 // Stored in OnDataLoss, merged with OnUpgradeNeeded response. |
| 136 blink::WebIDBDataLoss data_loss_; | 138 blink::WebIDBDataLoss data_loss_; |
| 137 std::string data_loss_message_; | 139 std::string data_loss_message_; |
| 138 | 140 |
| 139 // The "blocked" event should be sent at most once per request. | 141 // The "blocked" event should be sent at most once per request. |
| 140 bool sent_blocked_; | 142 bool sent_blocked_; |
| 141 base::TimeTicks connection_open_start_time_; | 143 base::TimeTicks connection_open_start_time_; |
| 142 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacks); | 144 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacks); |
| 143 }; | 145 }; |
| 144 | 146 |
| 145 } // namespace content | 147 } // namespace content |
| 146 | 148 |
| 147 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ | 149 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_ |
| OLD | NEW |