| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/database/database_tracker.h" | 5 #include "webkit/database/database_tracker.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 db_dir_.Append(base::FilePath(kTrackerDatabaseFileName)); | 475 db_dir_.Append(base::FilePath(kTrackerDatabaseFileName)); |
| 476 if (file_util::DirectoryExists(db_dir_) && | 476 if (file_util::DirectoryExists(db_dir_) && |
| 477 file_util::PathExists(kTrackerDatabaseFullPath) && | 477 file_util::PathExists(kTrackerDatabaseFullPath) && |
| 478 (!db_->Open(kTrackerDatabaseFullPath) || | 478 (!db_->Open(kTrackerDatabaseFullPath) || |
| 479 !sql::MetaTable::DoesTableExist(db_.get()))) { | 479 !sql::MetaTable::DoesTableExist(db_.get()))) { |
| 480 db_->Close(); | 480 db_->Close(); |
| 481 if (!file_util::Delete(db_dir_, true)) | 481 if (!file_util::Delete(db_dir_, true)) |
| 482 return false; | 482 return false; |
| 483 } | 483 } |
| 484 | 484 |
| 485 db_->set_error_histogram_name("Sqlite.DatabaseTracker.Error"); | 485 db_->set_histogram_tag("DatabaseTracker"); |
| 486 | 486 |
| 487 databases_table_.reset(new DatabasesTable(db_.get())); | 487 databases_table_.reset(new DatabasesTable(db_.get())); |
| 488 meta_table_.reset(new sql::MetaTable()); | 488 meta_table_.reset(new sql::MetaTable()); |
| 489 | 489 |
| 490 is_initialized_ = | 490 is_initialized_ = |
| 491 file_util::CreateDirectory(db_dir_) && | 491 file_util::CreateDirectory(db_dir_) && |
| 492 (db_->is_open() || | 492 (db_->is_open() || |
| 493 (is_incognito_ ? db_->OpenInMemory() : | 493 (is_incognito_ ? db_->OpenInMemory() : |
| 494 db_->Open(kTrackerDatabaseFullPath))) && | 494 db_->Open(kTrackerDatabaseFullPath))) && |
| 495 UpgradeToCurrentVersion(); | 495 UpgradeToCurrentVersion(); |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 if (!db_tracker_thread_->BelongsToCurrentThread()) { | 869 if (!db_tracker_thread_->BelongsToCurrentThread()) { |
| 870 db_tracker_thread_->PostTask( | 870 db_tracker_thread_->PostTask( |
| 871 FROM_HERE, | 871 FROM_HERE, |
| 872 base::Bind(&DatabaseTracker::SetForceKeepSessionState, this)); | 872 base::Bind(&DatabaseTracker::SetForceKeepSessionState, this)); |
| 873 return; | 873 return; |
| 874 } | 874 } |
| 875 force_keep_session_state_ = true; | 875 force_keep_session_state_ = true; |
| 876 } | 876 } |
| 877 | 877 |
| 878 } // namespace webkit_database | 878 } // namespace webkit_database |
| OLD | NEW |