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

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

Issue 18241003: IndexedDB: Remove IndexedDBCallbacksWrapper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Include/Forward Declare tidying Created 7 years, 5 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/indexed_db/indexed_db_factory.h" 5 #include "content/browser/indexed_db/indexed_db_factory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "content/browser/indexed_db/indexed_db_backing_store.h" 9 #include "content/browser/indexed_db/indexed_db_backing_store.h"
10 #include "content/browser/indexed_db/indexed_db_database.h" 10 #include "content/browser/indexed_db/indexed_db_database.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 IndexedDBFactory::~IndexedDBFactory() {} 44 IndexedDBFactory::~IndexedDBFactory() {}
45 45
46 void IndexedDBFactory::RemoveIDBDatabaseBackend( 46 void IndexedDBFactory::RemoveIDBDatabaseBackend(
47 const string16& unique_identifier) { 47 const string16& unique_identifier) {
48 DCHECK(database_backend_map_.find(unique_identifier) != 48 DCHECK(database_backend_map_.find(unique_identifier) !=
49 database_backend_map_.end()); 49 database_backend_map_.end());
50 database_backend_map_.erase(unique_identifier); 50 database_backend_map_.erase(unique_identifier);
51 } 51 }
52 52
53 void IndexedDBFactory::GetDatabaseNames( 53 void IndexedDBFactory::GetDatabaseNames(
54 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, 54 scoped_refptr<IndexedDBCallbacks> callbacks,
55 const string16& database_identifier, 55 const string16& database_identifier,
56 const base::FilePath& data_directory) { 56 const base::FilePath& data_directory) {
57 IDB_TRACE("IndexedDBFactory::GetDatabaseNames"); 57 IDB_TRACE("IndexedDBFactory::GetDatabaseNames");
58 // TODO(dgrogan): Plumb data_loss back to script eventually? 58 // TODO(dgrogan): Plumb data_loss back to script eventually?
59 WebKit::WebIDBCallbacks::DataLoss data_loss; 59 WebKit::WebIDBCallbacks::DataLoss data_loss;
60 scoped_refptr<IndexedDBBackingStore> backing_store = 60 scoped_refptr<IndexedDBBackingStore> backing_store =
61 OpenBackingStore(database_identifier, data_directory, &data_loss); 61 OpenBackingStore(database_identifier, data_directory, &data_loss);
62 if (!backing_store.get()) { 62 if (!backing_store.get()) {
63 callbacks->OnError( 63 callbacks->OnError(
64 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, 64 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError,
65 "Internal error opening backing store for " 65 "Internal error opening backing store for "
66 "indexedDB.webkitGetDatabaseNames.")); 66 "indexedDB.webkitGetDatabaseNames."));
67 return; 67 return;
68 } 68 }
69 69
70 callbacks->OnSuccess(backing_store->GetDatabaseNames()); 70 callbacks->OnSuccess(backing_store->GetDatabaseNames());
71 } 71 }
72 72
73 void IndexedDBFactory::DeleteDatabase( 73 void IndexedDBFactory::DeleteDatabase(
74 const string16& name, 74 const string16& name,
75 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, 75 scoped_refptr<IndexedDBCallbacks> callbacks,
76 const string16& database_identifier, 76 const string16& database_identifier,
77 const base::FilePath& data_directory) { 77 const base::FilePath& data_directory) {
78 IDB_TRACE("IndexedDBFactory::DeleteDatabase"); 78 IDB_TRACE("IndexedDBFactory::DeleteDatabase");
79 const string16 unique_identifier = 79 const string16 unique_identifier =
80 ComputeUniqueIdentifier(name, database_identifier); 80 ComputeUniqueIdentifier(name, database_identifier);
81 81
82 IndexedDBDatabaseMap::iterator it = 82 IndexedDBDatabaseMap::iterator it =
83 database_backend_map_.find(unique_identifier); 83 database_backend_map_.find(unique_identifier);
84 if (it != database_backend_map_.end()) { 84 if (it != database_backend_map_.end()) {
85 // If there are any connections to the database, directly delete the 85 // If there are any connections to the database, directly delete the
86 // database. 86 // database.
87 it->second->DeleteDatabase(callbacks); 87 it->second->DeleteDatabase(callbacks);
88 return; 88 return;
89 } 89 }
90 90
91
92 // TODO(dgrogan): Plumb data_loss back to script eventually? 91 // TODO(dgrogan): Plumb data_loss back to script eventually?
93 WebKit::WebIDBCallbacks::DataLoss data_loss; 92 WebKit::WebIDBCallbacks::DataLoss data_loss;
94 scoped_refptr<IndexedDBBackingStore> backing_store = 93 scoped_refptr<IndexedDBBackingStore> backing_store =
95 OpenBackingStore(database_identifier, data_directory, &data_loss); 94 OpenBackingStore(database_identifier, data_directory, &data_loss);
96 if (!backing_store.get()) { 95 if (!backing_store.get()) {
97 callbacks->OnError(IndexedDBDatabaseError( 96 callbacks->OnError(IndexedDBDatabaseError(
98 WebKit::WebIDBDatabaseExceptionUnknownError, 97 WebKit::WebIDBDatabaseExceptionUnknownError,
99 ASCIIToUTF16("Internal error opening backing store " 98 ASCIIToUTF16("Internal error opening backing store "
100 "for indexedDB.deleteDatabase."))); 99 "for indexedDB.deleteDatabase.")));
101 return; 100 return;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 return backing_store; 149 return backing_store;
151 } 150 }
152 151
153 return 0; 152 return 0;
154 } 153 }
155 154
156 void IndexedDBFactory::Open( 155 void IndexedDBFactory::Open(
157 const string16& name, 156 const string16& name,
158 int64 version, 157 int64 version,
159 int64 transaction_id, 158 int64 transaction_id,
160 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, 159 scoped_refptr<IndexedDBCallbacks> callbacks,
161 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, 160 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
162 const string16& database_identifier, 161 const string16& database_identifier,
163 const base::FilePath& data_directory) { 162 const base::FilePath& data_directory) {
164 IDB_TRACE("IndexedDBFactory::Open"); 163 IDB_TRACE("IndexedDBFactory::Open");
165 const string16 unique_identifier = 164 const string16 unique_identifier =
166 ComputeUniqueIdentifier(name, database_identifier); 165 ComputeUniqueIdentifier(name, database_identifier);
167 166
168 scoped_refptr<IndexedDBDatabase> database_backend; 167 scoped_refptr<IndexedDBDatabase> database_backend;
169 IndexedDBDatabaseMap::iterator it = 168 IndexedDBDatabaseMap::iterator it =
170 database_backend_map_.find(unique_identifier); 169 database_backend_map_.find(unique_identifier);
(...skipping 23 matching lines...) Expand all
194 database_backend_map_[unique_identifier] = database_backend.get(); 193 database_backend_map_[unique_identifier] = database_backend.get();
195 } else { 194 } else {
196 database_backend = it->second; 195 database_backend = it->second;
197 } 196 }
198 197
199 database_backend->OpenConnection( 198 database_backend->OpenConnection(
200 callbacks, database_callbacks, transaction_id, version, data_loss); 199 callbacks, database_callbacks, transaction_id, version, data_loss);
201 } 200 }
202 201
203 } // namespace content 202 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_factory.h ('k') | content/browser/indexed_db/indexed_db_index_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698