Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / browser / indexed_db / indexed_db_database_callbacks.cc
blob3d47ad0c11c4dfe3f3a683c25636ea6f4236ebd7
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 #include "content/browser/indexed_db/indexed_db_database_callbacks.h"
7 #include "content/browser/indexed_db/indexed_db_database_error.h"
8 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h"
9 #include "content/common/indexed_db/indexed_db_messages.h"
11 namespace content {
13 IndexedDBDatabaseCallbacks::IndexedDBDatabaseCallbacks(
14 IndexedDBDispatcherHost* dispatcher_host,
15 int ipc_thread_id,
16 int ipc_database_callbacks_id)
17 : dispatcher_host_(dispatcher_host),
18 ipc_thread_id_(ipc_thread_id),
19 ipc_database_callbacks_id_(ipc_database_callbacks_id) {}
21 IndexedDBDatabaseCallbacks::~IndexedDBDatabaseCallbacks() {}
23 void IndexedDBDatabaseCallbacks::OnForcedClose() {
24 if (!dispatcher_host_.get())
25 return;
27 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksForcedClose(
28 ipc_thread_id_, ipc_database_callbacks_id_));
30 dispatcher_host_ = NULL;
33 void IndexedDBDatabaseCallbacks::OnVersionChange(int64 old_version,
34 int64 new_version) {
35 if (!dispatcher_host_.get())
36 return;
38 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksIntVersionChange(
39 ipc_thread_id_, ipc_database_callbacks_id_, old_version, new_version));
42 void IndexedDBDatabaseCallbacks::OnAbort(
43 int64 host_transaction_id,
44 const IndexedDBDatabaseError& error) {
45 if (!dispatcher_host_.get())
46 return;
48 dispatcher_host_->FinishTransaction(host_transaction_id, false);
49 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksAbort(
50 ipc_thread_id_,
51 ipc_database_callbacks_id_,
52 dispatcher_host_->RendererTransactionId(host_transaction_id),
53 error.code(),
54 error.message()));
57 void IndexedDBDatabaseCallbacks::OnComplete(int64 host_transaction_id) {
58 if (!dispatcher_host_.get())
59 return;
61 dispatcher_host_->FinishTransaction(host_transaction_id, true);
62 dispatcher_host_->Send(new IndexedDBMsg_DatabaseCallbacksComplete(
63 ipc_thread_id_,
64 ipc_database_callbacks_id_,
65 dispatcher_host_->RendererTransactionId(host_transaction_id)));
68 } // namespace content