| 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/strings/string_split.h" | 7 #include "base/strings/string_split.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "chrome/browser/history/history_types.h" | 9 #include "chrome/browser/history/history_types.h" |
| 10 #include "chrome/browser/history/top_sites.h" | 10 #include "chrome/browser/history/top_sites.h" |
| 11 #include "chrome/browser/history/top_sites_database.h" | 11 #include "chrome/browser/history/top_sites_database.h" |
| 12 #include "sql/connection.h" | 12 #include "sql/connection.h" |
| 13 #include "sql/transaction.h" | 13 #include "sql/transaction.h" |
| 14 | 14 |
| 15 namespace history { | 15 namespace history { |
| 16 | 16 |
| 17 // From the version 1 to 2, one column was added. Old versions of Chrome | 17 // From the version 1 to 2, one column was added. Old versions of Chrome |
| 18 // should be able to read version 2 files just fine. | 18 // should be able to read version 2 files just fine. |
| 19 static const int kVersionNumber = 2; | 19 static const int kVersionNumber = 2; |
| 20 | 20 |
| 21 TopSitesDatabase::TopSitesDatabase() : may_need_history_migration_(false) { | 21 TopSitesDatabase::TopSitesDatabase() : may_need_history_migration_(false) { |
| 22 } | 22 } |
| 23 | 23 |
| 24 TopSitesDatabase::~TopSitesDatabase() { | 24 TopSitesDatabase::~TopSitesDatabase() { |
| 25 } | 25 } |
| 26 | 26 |
| 27 bool TopSitesDatabase::Init(const base::FilePath& db_name) { | 27 bool TopSitesDatabase::Init(const base::FilePath& db_name) { |
| 28 bool file_existed = file_util::PathExists(db_name); | 28 bool file_existed = base::PathExists(db_name); |
| 29 | 29 |
| 30 if (!file_existed) | 30 if (!file_existed) |
| 31 may_need_history_migration_ = true; | 31 may_need_history_migration_ = true; |
| 32 | 32 |
| 33 db_.reset(CreateDB(db_name)); | 33 db_.reset(CreateDB(db_name)); |
| 34 if (!db_) | 34 if (!db_) |
| 35 return false; | 35 return false; |
| 36 | 36 |
| 37 bool does_meta_exist = sql::MetaTable::DoesTableExist(db_.get()); | 37 bool does_meta_exist = sql::MetaTable::DoesTableExist(db_.get()); |
| 38 if (!does_meta_exist && file_existed) { | 38 if (!does_meta_exist && file_existed) { |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 377 |
| 378 if (!db->Open(db_name)) { | 378 if (!db->Open(db_name)) { |
| 379 LOG(ERROR) << db->GetErrorMessage(); | 379 LOG(ERROR) << db->GetErrorMessage(); |
| 380 return NULL; | 380 return NULL; |
| 381 } | 381 } |
| 382 | 382 |
| 383 return db.release(); | 383 return db.release(); |
| 384 } | 384 } |
| 385 | 385 |
| 386 } // namespace history | 386 } // namespace history |
| OLD | NEW |