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/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 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 || !file_util::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_error_histogram_name("Sqlite.AppCache.Error"); | 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) { |
1008 opened = db_->OpenInMemory(); | 1008 opened = db_->OpenInMemory(); |
1009 } else if (!file_util::CreateDirectory(db_file_path_.DirName())) { | 1009 } else if (!file_util::CreateDirectory(db_file_path_.DirName())) { |
1010 LOG(ERROR) << "Failed to create appcache directory."; | 1010 LOG(ERROR) << "Failed to create appcache directory."; |
1011 } else { | 1011 } else { |
1012 opened = db_->Open(db_file_path_); | 1012 opened = db_->Open(db_file_path_); |
1013 if (opened) | 1013 if (opened) |
1014 db_->Preload(); | 1014 db_->Preload(); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |