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/indexed_db/indexed_db_database.h" | 5 #include "content/browser/indexed_db/indexed_db_database.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 scoped_refptr<IndexedDBCallbacks> callbacks_; | 125 scoped_refptr<IndexedDBCallbacks> callbacks_; |
126 }; | 126 }; |
127 | 127 |
128 scoped_refptr<IndexedDBDatabase> IndexedDBDatabase::Create( | 128 scoped_refptr<IndexedDBDatabase> IndexedDBDatabase::Create( |
129 const base::string16& name, | 129 const base::string16& name, |
130 IndexedDBBackingStore* backing_store, | 130 IndexedDBBackingStore* backing_store, |
131 IndexedDBFactory* factory, | 131 IndexedDBFactory* factory, |
132 const Identifier& unique_identifier, | 132 const Identifier& unique_identifier, |
133 leveldb::Status* s) { | 133 leveldb::Status* s) { |
134 scoped_refptr<IndexedDBDatabase> database = | 134 scoped_refptr<IndexedDBDatabase> database = |
135 new IndexedDBDatabase(name, backing_store, factory, unique_identifier); | 135 IndexedDBClassFactory::Get()->CreateIndexedDBDatabase( |
| 136 name, backing_store, factory, unique_identifier); |
136 *s = database->OpenInternal(); | 137 *s = database->OpenInternal(); |
137 if (s->ok()) | 138 if (s->ok()) |
138 return database; | 139 return database; |
139 else | 140 else |
140 return NULL; | 141 return NULL; |
141 } | 142 } |
142 | 143 |
143 namespace { | 144 namespace { |
144 const base::string16::value_type kNoStringVersion[] = {0}; | 145 const base::string16::value_type kNoStringVersion[] = {0}; |
145 } | 146 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 return backing_store_->CreateIDBDatabaseMetaData( | 221 return backing_store_->CreateIDBDatabaseMetaData( |
221 metadata_.name, metadata_.version, metadata_.int_version, &metadata_.id); | 222 metadata_.name, metadata_.version, metadata_.int_version, &metadata_.id); |
222 } | 223 } |
223 | 224 |
224 IndexedDBDatabase::~IndexedDBDatabase() { | 225 IndexedDBDatabase::~IndexedDBDatabase() { |
225 DCHECK(transactions_.empty()); | 226 DCHECK(transactions_.empty()); |
226 DCHECK(pending_open_calls_.empty()); | 227 DCHECK(pending_open_calls_.empty()); |
227 DCHECK(pending_delete_calls_.empty()); | 228 DCHECK(pending_delete_calls_.empty()); |
228 } | 229 } |
229 | 230 |
| 231 size_t IndexedDBDatabase::GetMaxMessageSizeInBytes() const { |
| 232 return kMaxIDBMessageSizeInBytes; |
| 233 } |
| 234 |
230 scoped_ptr<IndexedDBConnection> IndexedDBDatabase::CreateConnection( | 235 scoped_ptr<IndexedDBConnection> IndexedDBDatabase::CreateConnection( |
231 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, | 236 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, |
232 int child_process_id) { | 237 int child_process_id) { |
233 scoped_ptr<IndexedDBConnection> connection( | 238 scoped_ptr<IndexedDBConnection> connection( |
234 new IndexedDBConnection(this, database_callbacks)); | 239 new IndexedDBConnection(this, database_callbacks)); |
235 connections_.insert(connection.get()); | 240 connections_.insert(connection.get()); |
236 backing_store_->GrantChildProcessPermissions(child_process_id); | 241 backing_store_->GrantChildProcessPermissions(child_process_id); |
237 return connection.Pass(); | 242 return connection.Pass(); |
238 } | 243 } |
239 | 244 |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 if (!return_value.empty() && generated_key) { | 851 if (!return_value.empty() && generated_key) { |
847 return_value.primary_key = cursor->primary_key(); | 852 return_value.primary_key = cursor->primary_key(); |
848 return_value.key_path = object_store_metadata.key_path; | 853 return_value.key_path = object_store_metadata.key_path; |
849 } | 854 } |
850 } | 855 } |
851 | 856 |
852 if (cursor_type == indexed_db::CURSOR_KEY_ONLY) | 857 if (cursor_type == indexed_db::CURSOR_KEY_ONLY) |
853 response_size += return_key.size_estimate(); | 858 response_size += return_key.size_estimate(); |
854 else | 859 else |
855 response_size += return_value.SizeEstimate(); | 860 response_size += return_value.SizeEstimate(); |
856 if (response_size > IPC::Channel::kMaximumMessageSize) { | 861 if (response_size > GetMaxMessageSizeInBytes()) { |
857 // TODO(cmumford): Reach this limit more gracefully (crbug.com/478949) | 862 callbacks->OnError( |
858 break; | 863 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError, |
| 864 "Maximum IPC message size exceeded.")); |
| 865 return; |
859 } | 866 } |
860 | 867 |
861 if (cursor_type == indexed_db::CURSOR_KEY_ONLY) | 868 if (cursor_type == indexed_db::CURSOR_KEY_ONLY) |
862 found_keys.push_back(return_key); | 869 found_keys.push_back(return_key); |
863 else | 870 else |
864 found_values.push_back(return_value); | 871 found_values.push_back(return_value); |
865 } | 872 } |
866 | 873 |
867 if (cursor_type == indexed_db::CURSOR_KEY_ONLY) { | 874 if (cursor_type == indexed_db::CURSOR_KEY_ONLY) { |
868 // IndexedDBKey already supports an array of values so we can leverage this | 875 // IndexedDBKey already supports an array of values so we can leverage this |
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1960 const base::string16& previous_version, | 1967 const base::string16& previous_version, |
1961 int64 previous_int_version, | 1968 int64 previous_int_version, |
1962 IndexedDBTransaction* transaction) { | 1969 IndexedDBTransaction* transaction) { |
1963 DCHECK(!transaction); | 1970 DCHECK(!transaction); |
1964 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); | 1971 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); |
1965 metadata_.version = previous_version; | 1972 metadata_.version = previous_version; |
1966 metadata_.int_version = previous_int_version; | 1973 metadata_.int_version = previous_int_version; |
1967 } | 1974 } |
1968 | 1975 |
1969 } // namespace content | 1976 } // namespace content |
OLD | NEW |