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

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

Issue 10071032: RefCounted types should not have public destructors, chrome/browser/ part 1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implementation fixes Created 8 years, 8 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 | « chrome/browser/history/shortcuts_backend.h ('k') | chrome/browser/history/shortcuts_database.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) 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 no_db_access_(db_folder_path.empty()) { 88 no_db_access_(db_folder_path.empty()) {
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 ShortcutsBackend::~ShortcutsBackend() {}
99
100 bool ShortcutsBackend::Init() { 98 bool ShortcutsBackend::Init() {
101 if (current_state_ != NOT_INITIALIZED) 99 if (current_state_ != NOT_INITIALIZED)
102 return false; 100 return false;
103 101
104 if (no_db_access_) { 102 if (no_db_access_) {
105 current_state_ = INITIALIZED; 103 current_state_ = INITIALIZED;
106 return true; 104 return true;
107 } 105 }
108 106
109 current_state_ = INITIALIZING; 107 current_state_ = INITIALIZING;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 return false; 181 return false;
184 shortcuts_map_.clear(); 182 shortcuts_map_.clear();
185 guid_map_.clear(); 183 guid_map_.clear();
186 FOR_EACH_OBSERVER(ShortcutsBackendObserver, observer_list_, 184 FOR_EACH_OBSERVER(ShortcutsBackendObserver, observer_list_,
187 OnShortcutsChanged()); 185 OnShortcutsChanged());
188 return no_db_access_ || BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, 186 return no_db_access_ || BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
189 base::Bind(base::IgnoreResult(&ShortcutsDatabase::DeleteAllShortcuts), 187 base::Bind(base::IgnoreResult(&ShortcutsDatabase::DeleteAllShortcuts),
190 db_.get())); 188 db_.get()));
191 } 189 }
192 190
191 ShortcutsBackend::~ShortcutsBackend() {}
192
193 void ShortcutsBackend::InitInternal() { 193 void ShortcutsBackend::InitInternal() {
194 DCHECK(current_state_ == INITIALIZING); 194 DCHECK(current_state_ == INITIALIZING);
195 db_->Init(); 195 db_->Init();
196 ShortcutsDatabase::GuidToShortcutMap shortcuts; 196 ShortcutsDatabase::GuidToShortcutMap shortcuts;
197 db_->LoadShortcuts(&shortcuts); 197 db_->LoadShortcuts(&shortcuts);
198 temp_shortcuts_map_.reset(new ShortcutMap); 198 temp_shortcuts_map_.reset(new ShortcutMap);
199 temp_guid_map_.reset(new GuidToShortcutsIteratorMap); 199 temp_guid_map_.reset(new GuidToShortcutsIteratorMap);
200 for (ShortcutsDatabase::GuidToShortcutMap::iterator it = shortcuts.begin(); 200 for (ShortcutsDatabase::GuidToShortcutMap::iterator it = shortcuts.begin();
201 it != shortcuts.end(); ++it) { 201 it != shortcuts.end(); ++it) {
202 (*temp_guid_map_)[it->first] = temp_shortcuts_map_->insert( 202 (*temp_guid_map_)[it->first] = temp_shortcuts_map_->insert(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(guid::GenerateGUID(), log->text, match.destination_url, 262 AddShortcut(Shortcut(guid::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 } // namespace history 267 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/shortcuts_backend.h ('k') | chrome/browser/history/shortcuts_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698