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

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

Issue 3138006: Next step integrating the HistoryQuickProvider: Implement index initializatio... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/history/in_memory_url_index.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/in_memory_history_backend.h" 5 #include "chrome/browser/history/in_memory_history_backend.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/histogram.h" 8 #include "base/histogram.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/history/history_notifications.h" 12 #include "chrome/browser/history/history_notifications.h"
12 #include "chrome/browser/history/in_memory_database.h" 13 #include "chrome/browser/history/in_memory_database.h"
13 #include "chrome/browser/history/in_memory_url_index.h" 14 #include "chrome/browser/history/in_memory_url_index.h"
14 #include "chrome/browser/history/url_database.h" 15 #include "chrome/browser/history/url_database.h"
16 #include "chrome/browser/pref_service.h"
15 #include "chrome/browser/profile.h" 17 #include "chrome/browser/profile.h"
16 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/notification_service.h" 19 #include "chrome/common/notification_service.h"
20 #include "chrome/common/pref_names.h"
18 21
19 namespace history { 22 namespace history {
20 23
21 // If a page becomes starred we use this id in place of the real starred id. 24 // If a page becomes starred we use this id in place of the real starred id.
22 // See note in OnURLsStarred. 25 // See note in OnURLsStarred.
23 static const StarID kBogusStarredID = 0x0FFFFFFF; 26 static const StarID kBogusStarredID = 0x0FFFFFFF;
24 27
25 InMemoryHistoryBackend::InMemoryHistoryBackend() 28 InMemoryHistoryBackend::InMemoryHistoryBackend()
26 : profile_(NULL) { 29 : profile_(NULL) {
27 } 30 }
28 31
29 InMemoryHistoryBackend::~InMemoryHistoryBackend() { 32 InMemoryHistoryBackend::~InMemoryHistoryBackend() {
30 } 33 }
31 34
32 bool InMemoryHistoryBackend::Init(const FilePath& history_filename, 35 bool InMemoryHistoryBackend::Init(const FilePath& history_filename,
33 URLDatabase* db) { 36 URLDatabase* db) {
34 db_.reset(new InMemoryDatabase); 37 db_.reset(new InMemoryDatabase);
35 bool success = db_->InitFromDisk(history_filename); 38 bool success = db_->InitFromDisk(history_filename);
36 39
37 if (CommandLine::ForCurrentProcess()->HasSwitch( 40 if (CommandLine::ForCurrentProcess()->HasSwitch(
38 switches::kEnableInMemoryURLIndex)) { 41 switches::kEnableInMemoryURLIndex)) {
39 index_.reset(new InMemoryURLIndex); 42 index_.reset(new InMemoryURLIndex());
40 base::TimeTicks beginning_time = base::TimeTicks::Now(); 43 base::TimeTicks beginning_time = base::TimeTicks::Now();
41 index_->Init(db); 44 string16 languages =
45 UTF8ToUTF16(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
46 index_->Init(db, languages);
42 UMA_HISTOGRAM_TIMES("Autocomplete.HistoryDatabaseIndexingTime", 47 UMA_HISTOGRAM_TIMES("Autocomplete.HistoryDatabaseIndexingTime",
43 base::TimeTicks::Now() - beginning_time); 48 base::TimeTicks::Now() - beginning_time);
44 } 49 }
45 50
46 return success; 51 return success;
47 } 52 }
48 53
49 void InMemoryHistoryBackend::AttachToHistoryService(Profile* profile) { 54 void InMemoryHistoryBackend::AttachToHistoryService(Profile* profile) {
50 if (!db_.get()) { 55 if (!db_.get()) {
51 NOTREACHED(); 56 NOTREACHED();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 URLID id = db_->GetRowForURL(*i, NULL); 138 URLID id = db_->GetRowForURL(*i, NULL);
134 if (id) { 139 if (id) {
135 // We typically won't have most of them since we only have a subset of 140 // We typically won't have most of them since we only have a subset of
136 // history, so ignore errors. 141 // history, so ignore errors.
137 db_->DeleteURLRow(id); 142 db_->DeleteURLRow(id);
138 } 143 }
139 } 144 }
140 } 145 }
141 146
142 } // namespace history 147 } // namespace history
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/history/in_memory_url_index.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698