| 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 "chrome/browser/history/history_database.h" |    5 #include "chrome/browser/history/history_database.h" | 
|    6  |    6  | 
|    7 #include <algorithm> |    7 #include <algorithm> | 
|    8 #include <set> |    8 #include <set> | 
|    9 #include <string> |    9 #include <string> | 
|   10  |   10  | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|   21 #include "base/mac/mac_util.h" |   21 #include "base/mac/mac_util.h" | 
|   22 #endif |   22 #endif | 
|   23  |   23  | 
|   24 namespace history { |   24 namespace history { | 
|   25  |   25  | 
|   26 namespace { |   26 namespace { | 
|   27  |   27  | 
|   28 // Current version number. We write databases at the "current" version number, |   28 // Current version number. We write databases at the "current" version number, | 
|   29 // but any previous version that can read the "compatible" one can make do with |   29 // but any previous version that can read the "compatible" one can make do with | 
|   30 // or database without *too* many bad effects. |   30 // or database without *too* many bad effects. | 
|   31 static const int kCurrentVersionNumber = 20; |   31 static const int kCurrentVersionNumber = 21; | 
|   32 static const int kCompatibleVersionNumber = 16; |   32 static const int kCompatibleVersionNumber = 16; | 
|   33 static const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold"; |   33 static const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold"; | 
|   34  |   34  | 
|   35 // Key in the meta table used to determine if we need to migrate thumbnails out |   35 // Key in the meta table used to determine if we need to migrate thumbnails out | 
|   36 // of history. |   36 // of history. | 
|   37 static const char kNeedsThumbnailMigrationKey[] = "needs_thumbnail_migration"; |   37 static const char kNeedsThumbnailMigrationKey[] = "needs_thumbnail_migration"; | 
|   38  |   38  | 
|   39 void ComputeDatabaseMetrics(const FilePath& history_name, |   39 void ComputeDatabaseMetrics(const FilePath& history_name, | 
|   40                             sql::Connection& db) { |   40                             sql::Connection& db) { | 
|   41   if (base::RandInt(1, 100) != 50) |   41   if (base::RandInt(1, 100) != 50) | 
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  300   } |  300   } | 
|  301  |  301  | 
|  302   if (cur_version == 19) { |  302   if (cur_version == 19) { | 
|  303     cur_version++; |  303     cur_version++; | 
|  304     meta_table_.SetVersionNumber(cur_version); |  304     meta_table_.SetVersionNumber(cur_version); | 
|  305     // Set a key indicating we need to migrate thumbnails. When successfull the |  305     // Set a key indicating we need to migrate thumbnails. When successfull the | 
|  306     // key is removed (ThumbnailMigrationDone). |  306     // key is removed (ThumbnailMigrationDone). | 
|  307     meta_table_.SetValue(kNeedsThumbnailMigrationKey, 1); |  307     meta_table_.SetValue(kNeedsThumbnailMigrationKey, 1); | 
|  308   } |  308   } | 
|  309  |  309  | 
 |  310   if (cur_version == 20) { | 
 |  311     // This is the version prior to adding the visit_duration field in visits | 
 |  312     // database. We need to migrate the database. | 
 |  313     if (!MigrateVisitsWithoutDuration()) { | 
 |  314       LOG(WARNING) << "Unable to update history database to version 21."; | 
 |  315       return sql::INIT_FAILURE; | 
 |  316     } | 
 |  317     ++cur_version; | 
 |  318     meta_table_.SetVersionNumber(cur_version); | 
 |  319   } | 
 |  320  | 
|  310   // When the version is too old, we just try to continue anyway, there should |  321   // When the version is too old, we just try to continue anyway, there should | 
|  311   // not be a released product that makes a database too old for us to handle. |  322   // not be a released product that makes a database too old for us to handle. | 
|  312   LOG_IF(WARNING, cur_version < GetCurrentVersion()) << |  323   LOG_IF(WARNING, cur_version < GetCurrentVersion()) << | 
|  313          "History database version " << cur_version << " is too old to handle."; |  324          "History database version " << cur_version << " is too old to handle."; | 
|  314  |  325  | 
|  315   return sql::INIT_OK; |  326   return sql::INIT_OK; | 
|  316 } |  327 } | 
|  317  |  328  | 
|  318 #if !defined(OS_WIN) |  329 #if !defined(OS_WIN) | 
|  319 void HistoryDatabase::MigrateTimeEpoch() { |  330 void HistoryDatabase::MigrateTimeEpoch() { | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
|  334       "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); |  345       "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); | 
|  335  |  346  | 
|  336   // Erase all the full text index files. These will take a while to update and |  347   // Erase all the full text index files. These will take a while to update and | 
|  337   // are less important, so we just blow them away. Same with the archived |  348   // are less important, so we just blow them away. Same with the archived | 
|  338   // database. |  349   // database. | 
|  339   needs_version_17_migration_ = true; |  350   needs_version_17_migration_ = true; | 
|  340 } |  351 } | 
|  341 #endif |  352 #endif | 
|  342  |  353  | 
|  343 }  // namespace history |  354 }  // namespace history | 
| OLD | NEW |