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

Side by Side Diff: webkit/browser/appcache/appcache_database.cc

Issue 18286004: Move PathExists to 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
« no previous file with comments | « ui/gfx/icon_util_unittest.cc ('k') | webkit/browser/appcache/appcache_database_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/appcache/appcache_database.h" 5 #include "webkit/browser/appcache/appcache_database.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 return true; 987 return true;
988 988
989 // If we tried and failed once, don't try again in the same session 989 // If we tried and failed once, don't try again in the same session
990 // to avoid creating an incoherent mess on disk. 990 // to avoid creating an incoherent mess on disk.
991 if (is_disabled_) 991 if (is_disabled_)
992 return false; 992 return false;
993 993
994 // Avoid creating a database at all if we can. 994 // Avoid creating a database at all if we can.
995 bool use_in_memory_db = db_file_path_.empty(); 995 bool use_in_memory_db = db_file_path_.empty();
996 if (!create_if_needed && 996 if (!create_if_needed &&
997 (use_in_memory_db || !file_util::PathExists(db_file_path_))) { 997 (use_in_memory_db || !base::PathExists(db_file_path_))) {
998 return false; 998 return false;
999 } 999 }
1000 1000
1001 db_.reset(new sql::Connection); 1001 db_.reset(new sql::Connection);
1002 meta_table_.reset(new sql::MetaTable); 1002 meta_table_.reset(new sql::MetaTable);
1003 1003
1004 db_->set_histogram_tag("AppCache"); 1004 db_->set_histogram_tag("AppCache");
1005 1005
1006 bool opened = false; 1006 bool opened = false;
1007 if (use_in_memory_db) { 1007 if (use_in_memory_db) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 return DeleteExistingAndCreateNewDatabase(); 1172 return DeleteExistingAndCreateNewDatabase();
1173 } 1173 }
1174 1174
1175 void AppCacheDatabase::ResetConnectionAndTables() { 1175 void AppCacheDatabase::ResetConnectionAndTables() {
1176 meta_table_.reset(); 1176 meta_table_.reset();
1177 db_.reset(); 1177 db_.reset();
1178 } 1178 }
1179 1179
1180 bool AppCacheDatabase::DeleteExistingAndCreateNewDatabase() { 1180 bool AppCacheDatabase::DeleteExistingAndCreateNewDatabase() {
1181 DCHECK(!db_file_path_.empty()); 1181 DCHECK(!db_file_path_.empty());
1182 DCHECK(file_util::PathExists(db_file_path_)); 1182 DCHECK(base::PathExists(db_file_path_));
1183 VLOG(1) << "Deleting existing appcache data and starting over."; 1183 VLOG(1) << "Deleting existing appcache data and starting over.";
1184 1184
1185 ResetConnectionAndTables(); 1185 ResetConnectionAndTables();
1186 1186
1187 // This also deletes the disk cache data. 1187 // This also deletes the disk cache data.
1188 base::FilePath directory = db_file_path_.DirName(); 1188 base::FilePath directory = db_file_path_.DirName();
1189 if (!base::Delete(directory, true) || 1189 if (!base::Delete(directory, true) ||
1190 !file_util::CreateDirectory(directory)) { 1190 !file_util::CreateDirectory(directory)) {
1191 return false; 1191 return false;
1192 } 1192 }
1193 1193
1194 // Make sure the steps above actually deleted things. 1194 // Make sure the steps above actually deleted things.
1195 if (file_util::PathExists(db_file_path_)) 1195 if (base::PathExists(db_file_path_))
1196 return false; 1196 return false;
1197 1197
1198 // So we can't go recursive. 1198 // So we can't go recursive.
1199 if (is_recreating_) 1199 if (is_recreating_)
1200 return false; 1200 return false;
1201 1201
1202 base::AutoReset<bool> auto_reset(&is_recreating_, true); 1202 base::AutoReset<bool> auto_reset(&is_recreating_, true);
1203 return LazyOpen(true); 1203 return LazyOpen(true);
1204 } 1204 }
1205 1205
1206 } // namespace appcache 1206 } // namespace appcache
OLDNEW
« no previous file with comments | « ui/gfx/icon_util_unittest.cc ('k') | webkit/browser/appcache/appcache_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698