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

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

Issue 10701043: Make ShortcutsBackend a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
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/shortcuts_backend.h" 5 #include "chrome/browser/history/shortcuts_backend.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 : last_access_time(base::Time::Now()), 74 : last_access_time(base::Time::Now()),
75 number_of_hits(0) { 75 number_of_hits(0) {
76 } 76 }
77 77
78 ShortcutsBackend::Shortcut::~Shortcut() { 78 ShortcutsBackend::Shortcut::~Shortcut() {
79 } 79 }
80 80
81 81
82 // ShortcutsBackend ----------------------------------------------------------- 82 // ShortcutsBackend -----------------------------------------------------------
83 83
84 ShortcutsBackend::ShortcutsBackend(const FilePath& db_folder_path, 84 ShortcutsBackend::ShortcutsBackend(Profile* profile, bool suppress_db)
85 Profile *profile)
86 : current_state_(NOT_INITIALIZED), 85 : current_state_(NOT_INITIALIZED),
87 db_(new ShortcutsDatabase(db_folder_path)), 86 no_db_access_(suppress_db) {
88 no_db_access_(db_folder_path.empty()) { 87 if (!suppress_db)
88 db_ = new ShortcutsDatabase(profile);
89 // |profile| can be NULL in tests. 89 // |profile| can be NULL in tests.
90 if (profile) { 90 if (profile) {
91 notification_registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, 91 notification_registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL,
92 content::Source<Profile>(profile)); 92 content::Source<Profile>(profile));
93 notification_registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, 93 notification_registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED,
94 content::Source<Profile>(profile)); 94 content::Source<Profile>(profile));
95 } 95 }
96 } 96 }
97 97
98 bool ShortcutsBackend::Init() { 98 bool ShortcutsBackend::Init() {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 match.description_class, base::Time::Now(), 257 match.description_class, base::Time::Now(),
258 it->second.number_of_hits + 1)); 258 it->second.number_of_hits + 1));
259 return; 259 return;
260 } 260 }
261 } 261 }
262 AddShortcut(Shortcut(base::GenerateGUID(), log->text, match.destination_url, 262 AddShortcut(Shortcut(base::GenerateGUID(), log->text, match.destination_url,
263 match.contents, match.contents_class, match.description, 263 match.contents, match.contents_class, match.description,
264 match.description_class, base::Time::Now(), 1)); 264 match.description_class, base::Time::Now(), 1));
265 } 265 }
266 266
267 void ShortcutsBackend::ShutdownOnUIThread() {
268 DCHECK(!BrowserThread::IsWellKnownThread(BrowserThread::UI) ||
269 BrowserThread::CurrentlyOn(BrowserThread::UI));
Miranda Callahan 2012/07/03 15:23:41 hmm, I am again confused -- is this really DCHECKi
mrossetti 2012/07/03 16:42:29 That is correct! ;^) The IsWellKnownThread test t
270 notification_registrar_.RemoveAll();
271 }
272
267 } // namespace history 273 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698