| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/child/web_database_observer_impl.h" | 5 #include "content/child/web_database_observer_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 estimated_size)); | 88 estimated_size)); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void WebDatabaseObserverImpl::DatabaseModified(const WebSecurityOrigin& origin, | 91 void WebDatabaseObserverImpl::DatabaseModified(const WebSecurityOrigin& origin, |
| 92 const WebString& database_name) { | 92 const WebString& database_name) { |
| 93 sender_->Send(new DatabaseHostMsg_Modified(origin, database_name.Utf16())); | 93 sender_->Send(new DatabaseHostMsg_Modified(origin, database_name.Utf16())); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void WebDatabaseObserverImpl::DatabaseClosed(const WebSecurityOrigin& origin, | 96 void WebDatabaseObserverImpl::DatabaseClosed(const WebSecurityOrigin& origin, |
| 97 const WebString& database_name) { | 97 const WebString& database_name) { |
| 98 DCHECK(!main_thread_task_runner_->RunsTasksOnCurrentThread()); | 98 DCHECK(!main_thread_task_runner_->RunsTasksInCurrentSequence()); |
| 99 base::string16 database_name_utf16 = database_name.Utf16(); | 99 base::string16 database_name_utf16 = database_name.Utf16(); |
| 100 main_thread_task_runner_->PostTask( | 100 main_thread_task_runner_->PostTask( |
| 101 FROM_HERE, | 101 FROM_HERE, |
| 102 base::Bind(base::IgnoreResult(&IPC::SyncMessageFilter::Send), sender_, | 102 base::Bind(base::IgnoreResult(&IPC::SyncMessageFilter::Send), sender_, |
| 103 new DatabaseHostMsg_Closed(origin, database_name_utf16))); | 103 new DatabaseHostMsg_Closed(origin, database_name_utf16))); |
| 104 open_connections_->RemoveOpenConnection(GetIdentifierFromOrigin(origin), | 104 open_connections_->RemoveOpenConnection(GetIdentifierFromOrigin(origin), |
| 105 database_name_utf16); | 105 database_name_utf16); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void WebDatabaseObserverImpl::ReportOpenDatabaseResult( | 108 void WebDatabaseObserverImpl::ReportOpenDatabaseResult( |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 const WebString& database_name, | 174 const WebString& database_name, |
| 175 int sqlite_error) { | 175 int sqlite_error) { |
| 176 int result = DetermineHistogramResult(-1, sqlite_error); | 176 int result = DetermineHistogramResult(-1, sqlite_error); |
| 177 UMA_HISTOGRAM_ENUMERATION("websql.Async.VacuumResult", | 177 UMA_HISTOGRAM_ENUMERATION("websql.Async.VacuumResult", |
| 178 result, kResultHistogramSize); | 178 result, kResultHistogramSize); |
| 179 HandleSqliteError(origin, database_name, sqlite_error); | 179 HandleSqliteError(origin, database_name, sqlite_error); |
| 180 } | 180 } |
| 181 | 181 |
| 182 bool WebDatabaseObserverImpl::WaitForAllDatabasesToClose( | 182 bool WebDatabaseObserverImpl::WaitForAllDatabasesToClose( |
| 183 base::TimeDelta timeout) { | 183 base::TimeDelta timeout) { |
| 184 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); | 184 DCHECK(main_thread_task_runner_->RunsTasksInCurrentSequence()); |
| 185 return open_connections_->WaitForAllDatabasesToClose(timeout); | 185 return open_connections_->WaitForAllDatabasesToClose(timeout); |
| 186 } | 186 } |
| 187 | 187 |
| 188 void WebDatabaseObserverImpl::HandleSqliteError(const WebSecurityOrigin& origin, | 188 void WebDatabaseObserverImpl::HandleSqliteError(const WebSecurityOrigin& origin, |
| 189 const WebString& database_name, | 189 const WebString& database_name, |
| 190 int error) { | 190 int error) { |
| 191 // We filter out errors which the backend doesn't act on to avoid | 191 // We filter out errors which the backend doesn't act on to avoid |
| 192 // a unnecessary ipc traffic, this method can get called at a fairly | 192 // a unnecessary ipc traffic, this method can get called at a fairly |
| 193 // high frequency (per-sqlstatement). | 193 // high frequency (per-sqlstatement). |
| 194 if (error == SQLITE_CORRUPT || error == SQLITE_NOTADB) { | 194 if (error == SQLITE_CORRUPT || error == SQLITE_NOTADB) { |
| 195 sender_->Send(new DatabaseHostMsg_HandleSqliteError( | 195 sender_->Send(new DatabaseHostMsg_HandleSqliteError( |
| 196 origin, database_name.Utf16(), error)); | 196 origin, database_name.Utf16(), error)); |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 | 199 |
| 200 } // namespace content | 200 } // namespace content |
| OLD | NEW |