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

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

Issue 16950028: Move file_util::Delete 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 &new_origin_dir); 409 &new_origin_dir);
410 base::FileEnumerator databases( 410 base::FileEnumerator databases(
411 origin_dir, 411 origin_dir,
412 false, 412 false,
413 base::FileEnumerator::FILES); 413 base::FileEnumerator::FILES);
414 for (base::FilePath database = databases.Next(); !database.empty(); 414 for (base::FilePath database = databases.Next(); !database.empty();
415 database = databases.Next()) { 415 database = databases.Next()) {
416 base::FilePath new_file = new_origin_dir.Append(database.BaseName()); 416 base::FilePath new_file = new_origin_dir.Append(database.BaseName());
417 file_util::Move(database, new_file); 417 file_util::Move(database, new_file);
418 } 418 }
419 file_util::Delete(origin_dir, true); 419 base::Delete(origin_dir, true);
420 file_util::Delete(new_origin_dir, true); // might fail on windows. 420 base::Delete(new_origin_dir, true); // might fail on windows.
421 421
422 databases_table_->DeleteOriginIdentifier(origin_identifier); 422 databases_table_->DeleteOriginIdentifier(origin_identifier);
423 423
424 if (quota_manager_proxy_.get() && deleted_size) { 424 if (quota_manager_proxy_.get() && deleted_size) {
425 quota_manager_proxy_->NotifyStorageModified( 425 quota_manager_proxy_->NotifyStorageModified(
426 quota::QuotaClient::kDatabase, 426 quota::QuotaClient::kDatabase,
427 webkit_database::GetOriginFromIdentifier(origin_identifier), 427 webkit_database::GetOriginFromIdentifier(origin_identifier),
428 quota::kStorageTypeTemporary, 428 quota::kStorageTypeTemporary,
429 -deleted_size); 429 -deleted_size);
430 } 430 }
(...skipping 21 matching lines...) Expand all
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 (file_util::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 file_util::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 (file_util::DirectoryExists(db_dir_) &&
471 file_util::PathExists(kTrackerDatabaseFullPath) && 471 file_util::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 (!file_util::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
481 databases_table_.reset(new DatabasesTable(db_.get())); 481 databases_table_.reset(new DatabasesTable(db_.get()));
482 meta_table_.reset(new sql::MetaTable()); 482 meta_table_.reset(new sql::MetaTable());
483 483
484 is_initialized_ = 484 is_initialized_ =
485 file_util::CreateDirectory(db_dir_) && 485 file_util::CreateDirectory(db_dir_) &&
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 (file_util::DirectoryExists(incognito_db_dir))
801 file_util::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
811 // Clearing only session-only databases, and there are none. 811 // Clearing only session-only databases, and there are none.
(...skipping 53 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_storage_impl.cc ('k') | webkit/browser/database/vfs_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698