OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "content/browser/indexed_db/indexed_db_pending_connection.h" | 5 #include "content/browser/indexed_db/indexed_db_pending_connection.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
| 9 #include "content/browser/indexed_db/indexed_db_connection.h" |
| 10 #include "content/browser/indexed_db/indexed_db_metadata.h" |
| 11 #include "content/browser/indexed_db/indexed_db_open_request_observer.h" |
| 12 #include "content/public/browser/indexed_db_context.h" |
| 13 |
7 namespace content { | 14 namespace content { |
8 | 15 |
9 IndexedDBPendingConnection::IndexedDBPendingConnection( | 16 IndexedDBPendingConnection::IndexedDBPendingConnection( |
10 scoped_refptr<IndexedDBCallbacks> callbacks_in, | 17 const OpenResultCallback& open_callback, |
11 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks_in, | 18 scoped_refptr<IndexedDBChangeHandler> change_handler, |
12 int child_process_id_in, | 19 scoped_refptr<IndexedDBOpenRequestObserver> open_observer, |
13 int64_t transaction_id_in, | 20 int child_process_id, |
14 int64_t version_in) | 21 int64_t transaction_id, |
15 : callbacks(callbacks_in), | 22 int64_t version, |
16 database_callbacks(database_callbacks_in), | 23 const url::Origin& origin) |
17 child_process_id(child_process_id_in), | 24 : open_callback_(std::move(open_callback)), |
18 transaction_id(transaction_id_in), | 25 change_handler_(change_handler), |
19 version(version_in) {} | 26 open_observer_(open_observer), |
20 | 27 child_process_id_(child_process_id), |
21 IndexedDBPendingConnection::IndexedDBPendingConnection( | 28 transaction_id_(transaction_id), |
22 const IndexedDBPendingConnection& other) = default; | 29 version_(version), |
| 30 origin_(origin) {} |
23 | 31 |
24 IndexedDBPendingConnection::~IndexedDBPendingConnection() {} | 32 IndexedDBPendingConnection::~IndexedDBPendingConnection() {} |
25 | 33 |
| 34 void IndexedDBPendingConnection::SetDataLossInfo( |
| 35 const IndexedDBDataLossInfo& data_loss_info) { |
| 36 data_loss_info_ = data_loss_info; |
| 37 } |
| 38 |
| 39 void IndexedDBPendingConnection::OnError( |
| 40 const IndexedDBDatabaseError& error) const { |
| 41 IndexedDBDatabaseMetadata metadata; |
| 42 open_callback_.Run(nullptr, metadata, error); |
| 43 } |
| 44 |
| 45 void IndexedDBPendingConnection::OnSuccess( |
| 46 std::unique_ptr<IndexedDBConnection> connection, |
| 47 const IndexedDBDatabaseMetadata& metadata) const { |
| 48 DCHECK_EQ(data_loss_info_.status, blink::WebIDBDataLossNone); |
| 49 IndexedDBDatabaseError error; |
| 50 open_callback_.Run(std::move(connection), metadata, error); |
| 51 } |
| 52 |
| 53 void IndexedDBPendingConnection::OnBlocked(int64_t old_version) const { |
| 54 open_observer_->OnBlocked(old_version); |
| 55 } |
| 56 |
| 57 void IndexedDBPendingConnection::OnUpgradeNeeded( |
| 58 int64_t old_version, |
| 59 IndexedDBConnection* connection, |
| 60 const IndexedDBDatabaseMetadata& metadata) const { |
| 61 connection->RegisterTransactionId(transaction_id_, origin_); |
| 62 open_observer_->OnUpgradeNeeded(old_version, connection, data_loss_info_, |
| 63 metadata); |
| 64 } |
| 65 |
26 } // namespace content | 66 } // namespace content |
OLD | NEW |