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

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

Issue 18147009: IndexedDB: Remove unnecessary scoped_refptr<T>::get() calls (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang-format 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 void IndexedDBFactory::GetDatabaseNames( 53 void IndexedDBFactory::GetDatabaseNames(
54 scoped_refptr<IndexedDBCallbacks> 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) {
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
(...skipping 12 matching lines...) Expand all
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 // TODO(dgrogan): Plumb data_loss back to script eventually? 91 // TODO(dgrogan): Plumb data_loss back to script eventually?
92 WebKit::WebIDBCallbacks::DataLoss data_loss; 92 WebKit::WebIDBCallbacks::DataLoss data_loss;
93 scoped_refptr<IndexedDBBackingStore> backing_store = 93 scoped_refptr<IndexedDBBackingStore> backing_store =
94 OpenBackingStore(database_identifier, data_directory, &data_loss); 94 OpenBackingStore(database_identifier, data_directory, &data_loss);
95 if (!backing_store.get()) { 95 if (!backing_store) {
96 callbacks->OnError(IndexedDBDatabaseError( 96 callbacks->OnError(IndexedDBDatabaseError(
97 WebKit::WebIDBDatabaseExceptionUnknownError, 97 WebKit::WebIDBDatabaseExceptionUnknownError,
98 ASCIIToUTF16("Internal error opening backing store " 98 ASCIIToUTF16("Internal error opening backing store "
99 "for indexedDB.deleteDatabase."))); 99 "for indexedDB.deleteDatabase.")));
100 return; 100 return;
101 } 101 }
102 102
103 scoped_refptr<IndexedDBDatabase> database_backend = IndexedDBDatabase::Create( 103 scoped_refptr<IndexedDBDatabase> database_backend =
104 name, backing_store.get(), this, unique_identifier); 104 IndexedDBDatabase::Create(name, backing_store, this, unique_identifier);
105 if (!database_backend.get()) { 105 if (!database_backend) {
106 callbacks->OnError(IndexedDBDatabaseError( 106 callbacks->OnError(IndexedDBDatabaseError(
107 WebKit::WebIDBDatabaseExceptionUnknownError, 107 WebKit::WebIDBDatabaseExceptionUnknownError,
108 ASCIIToUTF16("Internal error creating database backend for " 108 ASCIIToUTF16("Internal error creating database backend for "
109 "indexedDB.deleteDatabase."))); 109 "indexedDB.deleteDatabase.")));
110 return; 110 return;
111 } 111 }
112 112
113 database_backend_map_[unique_identifier] = database_backend.get(); 113 database_backend_map_[unique_identifier] = database_backend;
114 database_backend->DeleteDatabase(callbacks); 114 database_backend->DeleteDatabase(callbacks);
115 database_backend_map_.erase(unique_identifier); 115 database_backend_map_.erase(unique_identifier);
116 } 116 }
117 117
118 scoped_refptr<IndexedDBBackingStore> IndexedDBFactory::OpenBackingStore( 118 scoped_refptr<IndexedDBBackingStore> IndexedDBFactory::OpenBackingStore(
119 const string16& database_identifier, 119 const string16& database_identifier,
120 const base::FilePath& data_directory, 120 const base::FilePath& data_directory,
121 WebKit::WebIDBCallbacks::DataLoss* data_loss) { 121 WebKit::WebIDBCallbacks::DataLoss* data_loss) {
122 const string16 file_identifier = ComputeFileIdentifier(database_identifier); 122 const string16 file_identifier = ComputeFileIdentifier(database_identifier);
123 const bool open_in_memory = data_directory.empty(); 123 const bool open_in_memory = data_directory.empty();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 ComputeUniqueIdentifier(name, database_identifier); 165 ComputeUniqueIdentifier(name, database_identifier);
166 166
167 scoped_refptr<IndexedDBDatabase> database_backend; 167 scoped_refptr<IndexedDBDatabase> database_backend;
168 IndexedDBDatabaseMap::iterator it = 168 IndexedDBDatabaseMap::iterator it =
169 database_backend_map_.find(unique_identifier); 169 database_backend_map_.find(unique_identifier);
170 WebKit::WebIDBCallbacks::DataLoss data_loss = 170 WebKit::WebIDBCallbacks::DataLoss data_loss =
171 WebKit::WebIDBCallbacks::DataLossNone; 171 WebKit::WebIDBCallbacks::DataLossNone;
172 if (it == database_backend_map_.end()) { 172 if (it == database_backend_map_.end()) {
173 scoped_refptr<IndexedDBBackingStore> backing_store = 173 scoped_refptr<IndexedDBBackingStore> backing_store =
174 OpenBackingStore(database_identifier, data_directory, &data_loss); 174 OpenBackingStore(database_identifier, data_directory, &data_loss);
175 if (!backing_store.get()) { 175 if (!backing_store) {
176 callbacks->OnError(IndexedDBDatabaseError( 176 callbacks->OnError(IndexedDBDatabaseError(
177 WebKit::WebIDBDatabaseExceptionUnknownError, 177 WebKit::WebIDBDatabaseExceptionUnknownError,
178 ASCIIToUTF16( 178 ASCIIToUTF16(
179 "Internal error opening backing store for indexedDB.open."))); 179 "Internal error opening backing store for indexedDB.open.")));
180 return; 180 return;
181 } 181 }
182 182
183 database_backend = IndexedDBDatabase::Create( 183 database_backend =
184 name, backing_store.get(), this, unique_identifier); 184 IndexedDBDatabase::Create(name, backing_store, this, unique_identifier);
185 if (!database_backend.get()) { 185 if (!database_backend) {
186 callbacks->OnError(IndexedDBDatabaseError( 186 callbacks->OnError(IndexedDBDatabaseError(
187 WebKit::WebIDBDatabaseExceptionUnknownError, 187 WebKit::WebIDBDatabaseExceptionUnknownError,
188 ASCIIToUTF16( 188 ASCIIToUTF16(
189 "Internal error creating database backend for indexedDB.open."))); 189 "Internal error creating database backend for indexedDB.open.")));
190 return; 190 return;
191 } 191 }
192 192
193 database_backend_map_[unique_identifier] = database_backend.get(); 193 database_backend_map_[unique_identifier] = database_backend;
194 } else { 194 } else {
195 database_backend = it->second; 195 database_backend = it->second;
196 } 196 }
197 197
198 database_backend->OpenConnection( 198 database_backend->OpenConnection(
199 callbacks, database_callbacks, transaction_id, version, data_loss); 199 callbacks, database_callbacks, transaction_id, version, data_loss);
200 } 200 }
201 201
202 } // namespace content 202 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_dispatcher_host.cc ('k') | content/browser/indexed_db/indexed_db_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698