OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/in_process_webkit/indexed_db_callbacks.h" | 5 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" |
6 #include "content/browser/indexed_db/indexed_db_callbacks_wrapper.h" | 6 #include "content/browser/indexed_db/indexed_db_callbacks_wrapper.h" |
7 #include "content/browser/indexed_db/indexed_db_cursor.h" | 7 #include "content/browser/indexed_db/indexed_db_cursor.h" |
8 #include "content/browser/indexed_db/indexed_db_metadata.h" | 8 #include "content/browser/indexed_db/indexed_db_metadata.h" |
9 #include "content/browser/indexed_db/webidbcursor_impl.h" | 9 #include "content/browser/indexed_db/webidbcursor_impl.h" |
10 #include "content/browser/indexed_db/webidbdatabase_impl.h" | 10 #include "content/browser/indexed_db/webidbdatabase_impl.h" |
11 #include "third_party/WebKit/public/platform/WebIDBDatabaseError.h" | 11 #include "third_party/WebKit/public/platform/WebIDBDatabaseError.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
| 15 using WebKit::WebIDBCallbacks; |
| 16 |
15 IndexedDBCallbacksWrapper::IndexedDBCallbacksWrapper( | 17 IndexedDBCallbacksWrapper::IndexedDBCallbacksWrapper( |
16 IndexedDBCallbacksBase* callbacks) | 18 IndexedDBCallbacksBase* callbacks) |
17 : callbacks_(callbacks), did_complete_(false), did_create_proxy_(false) {} | 19 : callbacks_(callbacks), did_complete_(false), did_create_proxy_(false) {} |
18 | 20 |
19 IndexedDBCallbacksWrapper::~IndexedDBCallbacksWrapper() {} | 21 IndexedDBCallbacksWrapper::~IndexedDBCallbacksWrapper() {} |
20 | 22 |
21 void IndexedDBCallbacksWrapper::OnError(const IndexedDBDatabaseError& error) { | 23 void IndexedDBCallbacksWrapper::OnError(const IndexedDBDatabaseError& error) { |
22 DCHECK(callbacks_); | 24 DCHECK(callbacks_); |
23 callbacks_->onError( | 25 callbacks_->onError( |
24 WebKit::WebIDBDatabaseError(error.code(), error.message())); | 26 WebKit::WebIDBDatabaseError(error.code(), error.message())); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 95 } |
94 | 96 |
95 void IndexedDBCallbacksWrapper::OnBlocked(int64 existing_version) { | 97 void IndexedDBCallbacksWrapper::OnBlocked(int64 existing_version) { |
96 DCHECK(callbacks_); | 98 DCHECK(callbacks_); |
97 callbacks_->onBlocked(existing_version); | 99 callbacks_->onBlocked(existing_version); |
98 } | 100 } |
99 | 101 |
100 void IndexedDBCallbacksWrapper::OnUpgradeNeeded( | 102 void IndexedDBCallbacksWrapper::OnUpgradeNeeded( |
101 int64 old_version, | 103 int64 old_version, |
102 scoped_refptr<IndexedDBDatabase> database, | 104 scoped_refptr<IndexedDBDatabase> database, |
103 const IndexedDBDatabaseMetadata& metadata) { | 105 const IndexedDBDatabaseMetadata& metadata, |
| 106 WebIDBCallbacks::DataLoss data_loss) { |
104 DCHECK(callbacks_); | 107 DCHECK(callbacks_); |
105 did_create_proxy_ = true; | 108 did_create_proxy_ = true; |
106 callbacks_->onUpgradeNeeded( | 109 callbacks_->onUpgradeNeeded( |
107 old_version, | 110 old_version, |
108 new WebIDBDatabaseImpl(database, database_callbacks_), | 111 new WebIDBDatabaseImpl(database, database_callbacks_), |
109 metadata); | 112 metadata, |
| 113 data_loss); |
110 database_callbacks_ = NULL; | 114 database_callbacks_ = NULL; |
111 } | 115 } |
112 | 116 |
113 void IndexedDBCallbacksWrapper::OnSuccess( | 117 void IndexedDBCallbacksWrapper::OnSuccess( |
114 scoped_refptr<IndexedDBDatabase> database, | 118 scoped_refptr<IndexedDBDatabase> database, |
115 const IndexedDBDatabaseMetadata& metadata) { | 119 const IndexedDBDatabaseMetadata& metadata) { |
116 DCHECK(callbacks_); | 120 DCHECK(callbacks_); |
117 scoped_refptr<IndexedDBCallbacksWrapper> self(this); | 121 scoped_refptr<IndexedDBCallbacksWrapper> self(this); |
118 | 122 |
119 WebIDBDatabaseImpl* impl = | 123 WebIDBDatabaseImpl* impl = |
120 did_create_proxy_ ? 0 | 124 did_create_proxy_ ? 0 |
121 : new WebIDBDatabaseImpl(database, database_callbacks_); | 125 : new WebIDBDatabaseImpl(database, database_callbacks_); |
122 database_callbacks_ = NULL; | 126 database_callbacks_ = NULL; |
123 | 127 |
124 callbacks_->onSuccess(impl, metadata); | 128 callbacks_->onSuccess(impl, metadata); |
125 callbacks_.reset(); | 129 callbacks_.reset(); |
126 } | 130 } |
127 | 131 |
128 void IndexedDBCallbacksWrapper::SetDatabaseCallbacks( | 132 void IndexedDBCallbacksWrapper::SetDatabaseCallbacks( |
129 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks) { | 133 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks) { |
130 database_callbacks_ = database_callbacks; | 134 database_callbacks_ = database_callbacks; |
131 } | 135 } |
132 } // namespace content | 136 } // namespace content |
OLD | NEW |