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/appcache/appcache_database.h" | 5 #include "webkit/appcache/appcache_database.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } | 170 } |
171 | 171 |
172 AppCacheDatabase::NamespaceRecord::NamespaceRecord() | 172 AppCacheDatabase::NamespaceRecord::NamespaceRecord() |
173 : cache_id(0), type(FALLBACK_NAMESPACE) { | 173 : cache_id(0), type(FALLBACK_NAMESPACE) { |
174 } | 174 } |
175 | 175 |
176 AppCacheDatabase::NamespaceRecord::~NamespaceRecord() { | 176 AppCacheDatabase::NamespaceRecord::~NamespaceRecord() { |
177 } | 177 } |
178 | 178 |
179 | 179 |
180 AppCacheDatabase::AppCacheDatabase(const FilePath& path) | 180 AppCacheDatabase::AppCacheDatabase(const base::FilePath& path) |
181 : db_file_path_(path), is_disabled_(false), is_recreating_(false) { | 181 : db_file_path_(path), is_disabled_(false), is_recreating_(false) { |
182 } | 182 } |
183 | 183 |
184 AppCacheDatabase::~AppCacheDatabase() { | 184 AppCacheDatabase::~AppCacheDatabase() { |
185 } | 185 } |
186 | 186 |
187 void AppCacheDatabase::CloseConnection() { | 187 void AppCacheDatabase::CloseConnection() { |
188 // We can't close the connection for an in-memory database w/o | 188 // We can't close the connection for an in-memory database w/o |
189 // losing all of the data, so we don't do that. | 189 // losing all of the data, so we don't do that. |
190 if (!db_file_path_.empty()) | 190 if (!db_file_path_.empty()) |
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 } | 1096 } |
1097 | 1097 |
1098 bool AppCacheDatabase::DeleteExistingAndCreateNewDatabase() { | 1098 bool AppCacheDatabase::DeleteExistingAndCreateNewDatabase() { |
1099 DCHECK(!db_file_path_.empty()); | 1099 DCHECK(!db_file_path_.empty()); |
1100 DCHECK(file_util::PathExists(db_file_path_)); | 1100 DCHECK(file_util::PathExists(db_file_path_)); |
1101 VLOG(1) << "Deleting existing appcache data and starting over."; | 1101 VLOG(1) << "Deleting existing appcache data and starting over."; |
1102 | 1102 |
1103 ResetConnectionAndTables(); | 1103 ResetConnectionAndTables(); |
1104 | 1104 |
1105 // This also deletes the disk cache data. | 1105 // This also deletes the disk cache data. |
1106 FilePath directory = db_file_path_.DirName(); | 1106 base::FilePath directory = db_file_path_.DirName(); |
1107 if (!file_util::Delete(directory, true) || | 1107 if (!file_util::Delete(directory, true) || |
1108 !file_util::CreateDirectory(directory)) { | 1108 !file_util::CreateDirectory(directory)) { |
1109 return false; | 1109 return false; |
1110 } | 1110 } |
1111 | 1111 |
1112 // Make sure the steps above actually deleted things. | 1112 // Make sure the steps above actually deleted things. |
1113 if (file_util::PathExists(db_file_path_)) | 1113 if (file_util::PathExists(db_file_path_)) |
1114 return false; | 1114 return false; |
1115 | 1115 |
1116 // So we can't go recursive. | 1116 // So we can't go recursive. |
1117 if (is_recreating_) | 1117 if (is_recreating_) |
1118 return false; | 1118 return false; |
1119 | 1119 |
1120 base::AutoReset<bool> auto_reset(&is_recreating_, true); | 1120 base::AutoReset<bool> auto_reset(&is_recreating_, true); |
1121 return LazyOpen(true); | 1121 return LazyOpen(true); |
1122 } | 1122 } |
1123 | 1123 |
1124 } // namespace appcache | 1124 } // namespace appcache |
OLD | NEW |