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

Side by Side Diff: webkit/browser/database/database_tracker.cc

Issue 19052005: Move PathIsWritable, DirectoryExists, ContentsEqual, and TextContentsEqual to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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) 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/browser/database/database_tracker.h" 5 #include "webkit/browser/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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 } 444 }
445 445
446 bool DatabaseTracker::LazyInit() { 446 bool DatabaseTracker::LazyInit() {
447 if (!is_initialized_ && !shutting_down_) { 447 if (!is_initialized_ && !shutting_down_) {
448 DCHECK(!db_->is_open()); 448 DCHECK(!db_->is_open());
449 DCHECK(!databases_table_.get()); 449 DCHECK(!databases_table_.get());
450 DCHECK(!meta_table_.get()); 450 DCHECK(!meta_table_.get());
451 451
452 // If there are left-over directories from failed deletion attempts, clean 452 // If there are left-over directories from failed deletion attempts, clean
453 // them up. 453 // them up.
454 if (file_util::DirectoryExists(db_dir_)) { 454 if (base::DirectoryExists(db_dir_)) {
455 base::FileEnumerator directories( 455 base::FileEnumerator directories(
456 db_dir_, 456 db_dir_,
457 false, 457 false,
458 base::FileEnumerator::DIRECTORIES, 458 base::FileEnumerator::DIRECTORIES,
459 kTemporaryDirectoryPattern); 459 kTemporaryDirectoryPattern);
460 for (base::FilePath directory = directories.Next(); !directory.empty(); 460 for (base::FilePath directory = directories.Next(); !directory.empty();
461 directory = directories.Next()) { 461 directory = directories.Next()) {
462 base::Delete(directory, true); 462 base::Delete(directory, true);
463 } 463 }
464 } 464 }
465 465
466 // If the tracker database exists, but it's corrupt or doesn't 466 // If the tracker database exists, but it's corrupt or doesn't
467 // have a meta table, delete the database directory. 467 // have a meta table, delete the database directory.
468 const base::FilePath kTrackerDatabaseFullPath = 468 const base::FilePath kTrackerDatabaseFullPath =
469 db_dir_.Append(base::FilePath(kTrackerDatabaseFileName)); 469 db_dir_.Append(base::FilePath(kTrackerDatabaseFileName));
470 if (file_util::DirectoryExists(db_dir_) && 470 if (base::DirectoryExists(db_dir_) &&
471 base::PathExists(kTrackerDatabaseFullPath) && 471 base::PathExists(kTrackerDatabaseFullPath) &&
472 (!db_->Open(kTrackerDatabaseFullPath) || 472 (!db_->Open(kTrackerDatabaseFullPath) ||
473 !sql::MetaTable::DoesTableExist(db_.get()))) { 473 !sql::MetaTable::DoesTableExist(db_.get()))) {
474 db_->Close(); 474 db_->Close();
475 if (!base::Delete(db_dir_, true)) 475 if (!base::Delete(db_dir_, true))
476 return false; 476 return false;
477 } 477 }
478 478
479 db_->set_histogram_tag("DatabaseTracker"); 479 db_->set_histogram_tag("DatabaseTracker");
480 480
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 void DatabaseTracker::DeleteIncognitoDBDirectory() { 790 void DatabaseTracker::DeleteIncognitoDBDirectory() {
791 shutting_down_ = true; 791 shutting_down_ = true;
792 is_initialized_ = false; 792 is_initialized_ = false;
793 793
794 for (FileHandlesMap::iterator it = incognito_file_handles_.begin(); 794 for (FileHandlesMap::iterator it = incognito_file_handles_.begin();
795 it != incognito_file_handles_.end(); it++) 795 it != incognito_file_handles_.end(); it++)
796 base::ClosePlatformFile(it->second); 796 base::ClosePlatformFile(it->second);
797 797
798 base::FilePath incognito_db_dir = 798 base::FilePath incognito_db_dir =
799 profile_path_.Append(kIncognitoDatabaseDirectoryName); 799 profile_path_.Append(kIncognitoDatabaseDirectoryName);
800 if (file_util::DirectoryExists(incognito_db_dir)) 800 if (base::DirectoryExists(incognito_db_dir))
801 base::Delete(incognito_db_dir, true); 801 base::Delete(incognito_db_dir, true);
802 } 802 }
803 803
804 void DatabaseTracker::ClearSessionOnlyOrigins() { 804 void DatabaseTracker::ClearSessionOnlyOrigins() {
805 shutting_down_ = true; 805 shutting_down_ = true;
806 806
807 bool has_session_only_databases = 807 bool has_session_only_databases =
808 special_storage_policy_.get() && 808 special_storage_policy_.get() &&
809 special_storage_policy_->HasSessionOnlyOrigins(); 809 special_storage_policy_->HasSessionOnlyOrigins();
810 810
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 if (!db_tracker_thread_->BelongsToCurrentThread()) { 865 if (!db_tracker_thread_->BelongsToCurrentThread()) {
866 db_tracker_thread_->PostTask( 866 db_tracker_thread_->PostTask(
867 FROM_HERE, 867 FROM_HERE,
868 base::Bind(&DatabaseTracker::SetForceKeepSessionState, this)); 868 base::Bind(&DatabaseTracker::SetForceKeepSessionState, this));
869 return; 869 return;
870 } 870 }
871 force_keep_session_state_ = true; 871 force_keep_session_state_ = true;
872 } 872 }
873 873
874 } // namespace webkit_database 874 } // namespace webkit_database
OLDNEW
« no previous file with comments | « webkit/browser/appcache/appcache_database_unittest.cc ('k') | webkit/browser/dom_storage/dom_storage_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698