| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/support/simple_database_system.h" | 5 #include "webkit/support/simple_database_system.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 } | 148 } |
| 149 quota_per_origin_ = quota; | 149 quota_per_origin_ = quota; |
| 150 } | 150 } |
| 151 | 151 |
| 152 void SimpleDatabaseSystem::DatabaseOpened(const string16& origin_identifier, | 152 void SimpleDatabaseSystem::DatabaseOpened(const string16& origin_identifier, |
| 153 const string16& database_name, | 153 const string16& database_name, |
| 154 const string16& description, | 154 const string16& description, |
| 155 int64 estimated_size) { | 155 int64 estimated_size) { |
| 156 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); | 156 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); |
| 157 int64 database_size = 0; | 157 int64 database_size = 0; |
| 158 int64 space_available_not_used = 0; | |
| 159 db_tracker_->DatabaseOpened( | 158 db_tracker_->DatabaseOpened( |
| 160 origin_identifier, database_name, description, | 159 origin_identifier, database_name, description, |
| 161 estimated_size, &database_size, &space_available_not_used); | 160 estimated_size, &database_size); |
| 162 OnDatabaseSizeChanged(origin_identifier, database_name, | 161 OnDatabaseSizeChanged(origin_identifier, database_name, |
| 163 database_size, 0); | 162 database_size); |
| 164 } | 163 } |
| 165 | 164 |
| 166 void SimpleDatabaseSystem::DatabaseModified(const string16& origin_identifier, | 165 void SimpleDatabaseSystem::DatabaseModified(const string16& origin_identifier, |
| 167 const string16& database_name) { | 166 const string16& database_name) { |
| 168 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); | 167 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); |
| 169 db_tracker_->DatabaseModified(origin_identifier, database_name); | 168 db_tracker_->DatabaseModified(origin_identifier, database_name); |
| 170 } | 169 } |
| 171 | 170 |
| 172 void SimpleDatabaseSystem::DatabaseClosed(const string16& origin_identifier, | 171 void SimpleDatabaseSystem::DatabaseClosed(const string16& origin_identifier, |
| 173 const string16& database_name) { | 172 const string16& database_name) { |
| 174 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); | 173 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); |
| 175 db_tracker_->DatabaseClosed(origin_identifier, database_name); | 174 db_tracker_->DatabaseClosed(origin_identifier, database_name); |
| 176 open_connections_->RemoveOpenConnection(origin_identifier, database_name); | 175 open_connections_->RemoveOpenConnection(origin_identifier, database_name); |
| 177 } | 176 } |
| 178 | 177 |
| 179 void SimpleDatabaseSystem::OnDatabaseSizeChanged( | 178 void SimpleDatabaseSystem::OnDatabaseSizeChanged( |
| 180 const string16& origin_identifier, | 179 const string16& origin_identifier, |
| 181 const string16& database_name, | 180 const string16& database_name, |
| 182 int64 database_size, | 181 int64 database_size) { |
| 183 int64 space_available_not_used) { | |
| 184 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); | 182 DCHECK(db_thread_proxy_->BelongsToCurrentThread()); |
| 185 // We intentionally call into webkit on our background db_thread_ | 183 // We intentionally call into webkit on our background db_thread_ |
| 186 // to better emulate what happens in chrome where this method is | 184 // to better emulate what happens in chrome where this method is |
| 187 // invoked on the background ipc thread. | 185 // invoked on the background ipc thread. |
| 188 WebKit::WebDatabase::updateDatabaseSize( | 186 WebKit::WebDatabase::updateDatabaseSize( |
| 189 origin_identifier, database_name, database_size); | 187 origin_identifier, database_name, database_size); |
| 190 } | 188 } |
| 191 | 189 |
| 192 void SimpleDatabaseSystem::OnDatabaseScheduledForDeletion( | 190 void SimpleDatabaseSystem::OnDatabaseScheduledForDeletion( |
| 193 const string16& origin_identifier, | 191 const string16& origin_identifier, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 file_util::Delete(db_tracker_->DatabaseDirectory(), true); | 281 file_util::Delete(db_tracker_->DatabaseDirectory(), true); |
| 284 } | 282 } |
| 285 | 283 |
| 286 void SimpleDatabaseSystem::ThreadCleanup(base::WaitableEvent* done_event) { | 284 void SimpleDatabaseSystem::ThreadCleanup(base::WaitableEvent* done_event) { |
| 287 ResetTracker(); | 285 ResetTracker(); |
| 288 db_tracker_->RemoveObserver(this); | 286 db_tracker_->RemoveObserver(this); |
| 289 db_tracker_ = NULL; | 287 db_tracker_ = NULL; |
| 290 done_event->Signal(); | 288 done_event->Signal(); |
| 291 } | 289 } |
| 292 | 290 |
| OLD | NEW |