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

Side by Side Diff: chrome/browser/history/history_database.cc

Issue 22569006: tmp Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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
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 "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
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/rand_util.h" 14 #include "base/rand_util.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "chrome/browser/history/history_database_delegate.h"
17 #include "sql/transaction.h" 18 #include "sql/transaction.h"
18 19
19 #if defined(OS_MACOSX) 20 #if defined(OS_MACOSX)
20 #include "base/mac/mac_util.h" 21 #include "base/mac/mac_util.h"
21 #endif 22 #endif
22 23
23 namespace history { 24 namespace history {
24 25
25 namespace { 26 namespace {
26 27
27 // Current version number. We write databases at the "current" version number, 28 // Current version number. We write databases at the "current" version number,
28 // 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
29 // or database without *too* many bad effects. 30 // or database without *too* many bad effects.
30 static const int kCurrentVersionNumber = 26; 31 static const int kCurrentVersionNumber = 26;
31 static const int kCompatibleVersionNumber = 16; 32 static const int kCompatibleVersionNumber = 16;
32 static const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold"; 33 static const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold";
33 34
34 // 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
35 // of history. 36 // of history.
36 static const char kNeedsThumbnailMigrationKey[] = "needs_thumbnail_migration"; 37 static const char kNeedsThumbnailMigrationKey[] = "needs_thumbnail_migration";
37 38
38 } // namespace 39 } // namespace
39 40
40 HistoryDatabase::HistoryDatabase() 41 HistoryDatabase::HistoryDatabase()
41 : needs_version_17_migration_(false) { 42 : needs_version_17_migration_(false),
43 delegate_(HistoryDatabaseDelegate::CreateHistoryDatabaseDelegate()) {
42 } 44 }
43 45
44 HistoryDatabase::~HistoryDatabase() { 46 HistoryDatabase::~HistoryDatabase() {
45 } 47 }
46 48
47 sql::InitStatus HistoryDatabase::Init(const base::FilePath& history_name) { 49 sql::InitStatus HistoryDatabase::Init(const base::FilePath& history_name) {
48 db_.set_histogram_tag("History"); 50 db_.set_histogram_tag("History");
49 51
50 // Set the exceptional sqlite error handler. 52 // Set the exceptional sqlite error handler.
51 db_.set_error_callback(error_callback_); 53 db_.set_error_callback(error_callback_);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 87
86 // Create the tables and indices. 88 // Create the tables and indices.
87 // NOTE: If you add something here, also add it to 89 // NOTE: If you add something here, also add it to
88 // RecreateAllButStarAndURLTables. 90 // RecreateAllButStarAndURLTables.
89 if (!meta_table_.Init(&db_, GetCurrentVersion(), kCompatibleVersionNumber)) 91 if (!meta_table_.Init(&db_, GetCurrentVersion(), kCompatibleVersionNumber))
90 return sql::INIT_FAILURE; 92 return sql::INIT_FAILURE;
91 if (!CreateURLTable(false) || !InitVisitTable() || 93 if (!CreateURLTable(false) || !InitVisitTable() ||
92 !InitKeywordSearchTermsTable() || !InitDownloadTable() || 94 !InitKeywordSearchTermsTable() || !InitDownloadTable() ||
93 !InitSegmentTables()) 95 !InitSegmentTables())
94 return sql::INIT_FAILURE; 96 return sql::INIT_FAILURE;
97
98 if (delegate_.get())
99 delegate_->Created(this, history_name);
100
95 CreateMainURLIndex(); 101 CreateMainURLIndex();
96 CreateKeywordSearchTermsIndices(); 102 CreateKeywordSearchTermsIndices();
97 103
98 // TODO(benjhayden) Remove at some point. 104 // TODO(benjhayden) Remove at some point.
99 meta_table_.DeleteKey("next_download_id"); 105 meta_table_.DeleteKey("next_download_id");
100 106
101 // Version check. 107 // Version check.
102 sql::InitStatus version_status = EnsureCurrentVersion(); 108 sql::InitStatus version_status = EnsureCurrentVersion();
103 if (version_status != sql::INIT_OK) 109 if (version_status != sql::INIT_OK)
104 return version_status; 110 return version_status;
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);")); 463 "WHERE id IN (SELECT id FROM segment_usage WHERE time_slot > 0);"));
458 464
459 // Erase all the full text index files. These will take a while to update and 465 // Erase all the full text index files. These will take a while to update and
460 // are less important, so we just blow them away. Same with the archived 466 // are less important, so we just blow them away. Same with the archived
461 // database. 467 // database.
462 needs_version_17_migration_ = true; 468 needs_version_17_migration_ = true;
463 } 469 }
464 #endif 470 #endif
465 471
466 } // namespace history 472 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_database.h ('k') | chrome/browser/history/history_database_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698