Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(533)

Side by Side Diff: content/browser/indexed_db/indexed_db_callbacks_wrapper.cc

Issue 17033004: Tell IDB frontend about data loss (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ToT Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
16 using WebKit::WebIDBCallbacks;
17
15 IndexedDBCallbacksWrapper::IndexedDBCallbacksWrapper( 18 IndexedDBCallbacksWrapper::IndexedDBCallbacksWrapper(
16 IndexedDBCallbacksBase* callbacks) 19 IndexedDBCallbacksBase* callbacks)
17 : callbacks_(callbacks), did_complete_(false), did_create_proxy_(false) {} 20 : callbacks_(callbacks), did_complete_(false), did_create_proxy_(false) {}
18 21
19 IndexedDBCallbacksWrapper::~IndexedDBCallbacksWrapper() {} 22 IndexedDBCallbacksWrapper::~IndexedDBCallbacksWrapper() {}
20 23
21 void IndexedDBCallbacksWrapper::OnError(const IndexedDBDatabaseError& error) { 24 void IndexedDBCallbacksWrapper::OnError(const IndexedDBDatabaseError& error) {
22 DCHECK(callbacks_); 25 DCHECK(callbacks_);
23 callbacks_->onError( 26 callbacks_->onError(
24 WebKit::WebIDBDatabaseError(error.code(), error.message())); 27 WebKit::WebIDBDatabaseError(error.code(), error.message()));
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 96 }
94 97
95 void IndexedDBCallbacksWrapper::OnBlocked(int64 existing_version) { 98 void IndexedDBCallbacksWrapper::OnBlocked(int64 existing_version) {
96 DCHECK(callbacks_); 99 DCHECK(callbacks_);
97 callbacks_->onBlocked(existing_version); 100 callbacks_->onBlocked(existing_version);
98 } 101 }
99 102
100 void IndexedDBCallbacksWrapper::OnUpgradeNeeded( 103 void IndexedDBCallbacksWrapper::OnUpgradeNeeded(
101 int64 old_version, 104 int64 old_version,
102 scoped_refptr<IndexedDBDatabase> database, 105 scoped_refptr<IndexedDBDatabase> database,
103 const IndexedDBDatabaseMetadata& metadata) { 106 const IndexedDBDatabaseMetadata& metadata,
107 WebIDBCallbacks::DataLoss data_loss) {
104 DCHECK(callbacks_); 108 DCHECK(callbacks_);
105 did_create_proxy_ = true; 109 did_create_proxy_ = true;
106 callbacks_->onUpgradeNeeded( 110 callbacks_->onUpgradeNeeded(
107 old_version, 111 old_version,
108 new WebIDBDatabaseImpl(database, database_callbacks_), 112 new WebIDBDatabaseImpl(database, database_callbacks_),
109 metadata); 113 metadata,
114 data_loss);
110 database_callbacks_ = NULL; 115 database_callbacks_ = NULL;
111 } 116 }
112 117
113 void IndexedDBCallbacksWrapper::OnSuccess( 118 void IndexedDBCallbacksWrapper::OnSuccess(
114 scoped_refptr<IndexedDBDatabase> database, 119 scoped_refptr<IndexedDBDatabase> database,
115 const IndexedDBDatabaseMetadata& metadata) { 120 const IndexedDBDatabaseMetadata& metadata) {
116 DCHECK(callbacks_); 121 DCHECK(callbacks_);
117 scoped_refptr<IndexedDBCallbacksWrapper> self(this); 122 scoped_refptr<IndexedDBCallbacksWrapper> self(this);
118 123
119 WebIDBDatabaseImpl* impl = 124 WebIDBDatabaseImpl* impl =
120 did_create_proxy_ ? 0 125 did_create_proxy_ ? 0
121 : new WebIDBDatabaseImpl(database, database_callbacks_); 126 : new WebIDBDatabaseImpl(database, database_callbacks_);
122 database_callbacks_ = NULL; 127 database_callbacks_ = NULL;
123 128
124 callbacks_->onSuccess(impl, metadata); 129 callbacks_->onSuccess(impl, metadata);
125 callbacks_.reset(); 130 callbacks_.reset();
126 } 131 }
127 132
128 void IndexedDBCallbacksWrapper::SetDatabaseCallbacks( 133 void IndexedDBCallbacksWrapper::SetDatabaseCallbacks(
129 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks) { 134 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks) {
130 database_callbacks_ = database_callbacks; 135 database_callbacks_ = database_callbacks;
131 } 136 }
132 } // namespace content 137 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698