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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_
11 #include "base/basictypes.h"
12 #include "base/logging.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/strings/string16.h"
16 #include "content/browser/indexed_db/indexed_db_database_error.h"
17 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h"
18 #include "content/common/indexed_db/indexed_db_key.h"
19 #include "content/common/indexed_db/indexed_db_key_path.h"
20 #include "third_party/WebKit/public/platform/WebIDBCallbacks.h"
24 class IndexedDBConnection;
25 class IndexedDBCursor;
26 class IndexedDBDatabase;
27 class IndexedDBDatabaseCallbacks;
28 struct IndexedDBDatabaseMetadata;
30 class CONTENT_EXPORT IndexedDBCallbacks
31 : public base::RefCounted<IndexedDBCallbacks> {
33 // Simple payload responses
34 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host,
36 int32 ipc_callbacks_id);
38 // IndexedDBCursor responses
39 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host,
41 int32 ipc_callbacks_id,
44 // IndexedDBDatabase responses
45 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host,
47 int32 ipc_callbacks_id,
48 int32 ipc_database_callbacks_id,
49 int64 host_transaction_id,
50 const GURL& origin_url);
52 virtual void OnError(const IndexedDBDatabaseError& error);
54 // IndexedDBFactory::GetDatabaseNames
55 virtual void OnSuccess(const std::vector<string16>& string);
57 // IndexedDBFactory::Open / DeleteDatabase
58 virtual void OnBlocked(int64 existing_version);
60 // IndexedDBFactory::Open
61 virtual void OnUpgradeNeeded(
63 scoped_ptr<IndexedDBConnection> connection,
64 const content::IndexedDBDatabaseMetadata& metadata,
65 WebKit::WebIDBCallbacks::DataLoss data_loss,
66 std::string data_loss_message);
67 virtual void OnSuccess(scoped_ptr<IndexedDBConnection> connection,
68 const content::IndexedDBDatabaseMetadata& metadata);
70 // IndexedDBDatabase::OpenCursor
71 virtual void OnSuccess(scoped_refptr<IndexedDBCursor> cursor,
72 const IndexedDBKey& key,
73 const IndexedDBKey& primary_key,
76 // IndexedDBCursor::Continue / Advance
77 virtual void OnSuccess(const IndexedDBKey& key,
78 const IndexedDBKey& primary_key,
81 // IndexedDBCursor::PrefetchContinue
82 virtual void OnSuccessWithPrefetch(
83 const std::vector<IndexedDBKey>& keys,
84 const std::vector<IndexedDBKey>& primary_keys,
85 const std::vector<std::string>& values);
87 // IndexedDBDatabase::Get (with key injection)
88 virtual void OnSuccess(std::string* data,
89 const IndexedDBKey& key,
90 const IndexedDBKeyPath& key_path);
92 // IndexedDBDatabase::Get
93 virtual void OnSuccess(std::string* value);
95 // IndexedDBDatabase::Put / IndexedDBCursor::Update
96 virtual void OnSuccess(const IndexedDBKey& value);
98 // IndexedDBDatabase::Count
99 virtual void OnSuccess(int64 value);
101 // IndexedDBDatabase::Delete
102 // IndexedDBCursor::Continue / Advance (when complete)
103 virtual void OnSuccess();
106 virtual ~IndexedDBCallbacks();
109 friend class base::RefCounted<IndexedDBCallbacks>;
111 // Originally from IndexedDBCallbacks:
112 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_;
113 int32 ipc_callbacks_id_;
114 int32 ipc_thread_id_;
116 // IndexedDBCursor callbacks ------------------------
117 int32 ipc_cursor_id_;
119 // IndexedDBDatabase callbacks ------------------------
120 int64 host_transaction_id_;
122 int32 ipc_database_id_;
123 int32 ipc_database_callbacks_id_;
126 } // namespace content
128 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_