Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / content / browser / indexed_db / indexed_db_callbacks.h
blob7083bd615a84be2f4f07210bf142d23e382de201
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_
8 #include <string>
9 #include <vector>
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 "url/gurl.h"
22 namespace content {
23 class IndexedDBBlobInfo;
24 class IndexedDBConnection;
25 class IndexedDBCursor;
26 class IndexedDBDatabase;
27 class IndexedDBDatabaseCallbacks;
28 struct IndexedDBDatabaseMetadata;
29 struct IndexedDBReturnValue;
30 struct IndexedDBValue;
32 class CONTENT_EXPORT IndexedDBCallbacks
33 : public base::RefCounted<IndexedDBCallbacks> {
34 public:
35 // Simple payload responses
36 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host,
37 int32 ipc_thread_id,
38 int32 ipc_callbacks_id);
40 // IndexedDBCursor responses
41 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host,
42 int32 ipc_thread_id,
43 int32 ipc_callbacks_id,
44 int32 ipc_cursor_id);
46 // IndexedDBDatabase responses
47 IndexedDBCallbacks(IndexedDBDispatcherHost* dispatcher_host,
48 int32 ipc_thread_id,
49 int32 ipc_callbacks_id,
50 int32 ipc_database_callbacks_id,
51 int64 host_transaction_id,
52 const GURL& origin_url);
54 virtual void OnError(const IndexedDBDatabaseError& error);
56 // IndexedDBFactory::GetDatabaseNames
57 virtual void OnSuccess(const std::vector<base::string16>& string);
59 // IndexedDBFactory::Open / DeleteDatabase
60 virtual void OnBlocked(int64 existing_version);
62 // IndexedDBFactory::Open
63 virtual void OnDataLoss(blink::WebIDBDataLoss data_loss,
64 std::string data_loss_message);
65 virtual void OnUpgradeNeeded(
66 int64 old_version,
67 scoped_ptr<IndexedDBConnection> connection,
68 const content::IndexedDBDatabaseMetadata& metadata);
69 virtual void OnSuccess(scoped_ptr<IndexedDBConnection> connection,
70 const content::IndexedDBDatabaseMetadata& metadata);
72 // IndexedDBDatabase::OpenCursor
73 virtual void OnSuccess(scoped_refptr<IndexedDBCursor> cursor,
74 const IndexedDBKey& key,
75 const IndexedDBKey& primary_key,
76 IndexedDBValue* value);
78 // IndexedDBCursor::Continue / Advance
79 virtual void OnSuccess(const IndexedDBKey& key,
80 const IndexedDBKey& primary_key,
81 IndexedDBValue* value);
83 // IndexedDBCursor::PrefetchContinue
84 virtual void OnSuccessWithPrefetch(
85 const std::vector<IndexedDBKey>& keys,
86 const std::vector<IndexedDBKey>& primary_keys,
87 std::vector<IndexedDBValue>* values);
89 // IndexedDBDatabase::Get
90 // IndexedDBCursor::Advance
91 virtual void OnSuccess(IndexedDBReturnValue* value);
93 // IndexedDBDatabase::Put / IndexedDBCursor::Update
94 virtual void OnSuccess(const IndexedDBKey& key);
96 // IndexedDBDatabase::Count
97 // IndexedDBFactory::DeleteDatabase
98 virtual void OnSuccess(int64 value);
100 // IndexedDBDatabase::Delete
101 // IndexedDBCursor::Continue / Advance (when complete)
102 virtual void OnSuccess();
104 blink::WebIDBDataLoss data_loss() const { return data_loss_; }
106 void SetConnectionOpenStartTime(const base::TimeTicks& start_time);
108 protected:
109 virtual ~IndexedDBCallbacks();
111 private:
112 void RegisterBlobsAndSend(const std::vector<IndexedDBBlobInfo>& blob_info,
113 const base::Closure& callback);
115 friend class base::RefCounted<IndexedDBCallbacks>;
117 // Originally from IndexedDBCallbacks:
118 scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_;
119 int32 ipc_callbacks_id_;
120 int32 ipc_thread_id_;
122 // IndexedDBCursor callbacks ------------------------
123 int32 ipc_cursor_id_;
125 // IndexedDBDatabase callbacks ------------------------
126 int64 host_transaction_id_;
127 GURL origin_url_;
128 int32 ipc_database_id_;
129 int32 ipc_database_callbacks_id_;
131 // Stored in OnDataLoss, merged with OnUpgradeNeeded response.
132 blink::WebIDBDataLoss data_loss_;
133 std::string data_loss_message_;
135 // The "blocked" event should be sent at most once per request.
136 bool sent_blocked_;
137 base::TimeTicks connection_open_start_time_;
138 DISALLOW_COPY_AND_ASSIGN(IndexedDBCallbacks);
141 } // namespace content
143 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CALLBACKS_H_