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

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

Issue 642623004: Rename VisitDatabaseObserver to HistoryServiceObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@373326
Patch Set: Created 6 years, 2 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/in_memory_url_index.h" 5 #include "chrome/browser/history/in_memory_url_index.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 needs_to_be_cached_(false) { 106 needs_to_be_cached_(false) {
107 InitializeSchemeWhitelist(&scheme_whitelist_); 107 InitializeSchemeWhitelist(&scheme_whitelist_);
108 if (profile) { 108 if (profile) {
109 // TODO(mrossetti): Register for language change notifications. 109 // TODO(mrossetti): Register for language change notifications.
110 content::Source<Profile> source(profile); 110 content::Source<Profile> source(profile);
111 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, 111 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_MODIFIED,
112 source); 112 source);
113 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, source); 113 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, source);
114 } 114 }
115 if (history_service_) 115 if (history_service_)
116 history_service_->AddHistoryServiceObserver(this); 116 history_service_->AddObserver(this);
117 } 117 }
118 118
119 // Called only by unit tests. 119 // Called only by unit tests.
120 InMemoryURLIndex::InMemoryURLIndex() 120 InMemoryURLIndex::InMemoryURLIndex()
121 : profile_(NULL), 121 : profile_(NULL),
122 history_service_(nullptr), 122 history_service_(nullptr),
123 history_client_(NULL), 123 history_client_(NULL),
124 private_data_(new URLIndexPrivateData), 124 private_data_(new URLIndexPrivateData),
125 restore_cache_observer_(NULL), 125 restore_cache_observer_(NULL),
126 save_cache_observer_(NULL), 126 save_cache_observer_(NULL),
127 shutdown_(false), 127 shutdown_(false),
128 restored_(false), 128 restored_(false),
129 needs_to_be_cached_(false) { 129 needs_to_be_cached_(false) {
130 InitializeSchemeWhitelist(&scheme_whitelist_); 130 InitializeSchemeWhitelist(&scheme_whitelist_);
131 } 131 }
132 132
133 InMemoryURLIndex::~InMemoryURLIndex() { 133 InMemoryURLIndex::~InMemoryURLIndex() {
134 // If there was a history directory (which there won't be for some unit tests) 134 // If there was a history directory (which there won't be for some unit tests)
135 // then insure that the cache has already been saved. 135 // then insure that the cache has already been saved.
136 DCHECK(history_dir_.empty() || !needs_to_be_cached_); 136 DCHECK(history_dir_.empty() || !needs_to_be_cached_);
137 } 137 }
138 138
139 void InMemoryURLIndex::Init() { 139 void InMemoryURLIndex::Init() {
140 PostRestoreFromCacheFileTask(); 140 PostRestoreFromCacheFileTask();
141 } 141 }
142 142
143 void InMemoryURLIndex::ShutDown() { 143 void InMemoryURLIndex::ShutDown() {
144 if (history_service_) 144 if (history_service_)
145 history_service_->RemoveHistoryServiceObserver(this); 145 history_service_->RemoveObserver(this);
146 registrar_.RemoveAll(); 146 registrar_.RemoveAll();
147 cache_reader_tracker_.TryCancelAll(); 147 cache_reader_tracker_.TryCancelAll();
148 shutdown_ = true; 148 shutdown_ = true;
149 base::FilePath path; 149 base::FilePath path;
150 if (!GetCacheFilePath(&path)) 150 if (!GetCacheFilePath(&path))
151 return; 151 return;
152 private_data_tracker_.TryCancelAll(); 152 private_data_tracker_.TryCancelAll();
153 URLIndexPrivateData::WritePrivateDataToCacheFileTask(private_data_, path); 153 URLIndexPrivateData::WritePrivateDataToCacheFileTask(private_data_, path);
154 needs_to_be_cached_ = false; 154 needs_to_be_cached_ = false;
155 } 155 }
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 base::Bind(DeleteCacheFile, path)); 374 base::Bind(DeleteCacheFile, path));
375 } 375 }
376 } 376 }
377 377
378 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) { 378 void InMemoryURLIndex::OnCacheSaveDone(bool succeeded) {
379 if (save_cache_observer_) 379 if (save_cache_observer_)
380 save_cache_observer_->OnCacheSaveFinished(succeeded); 380 save_cache_observer_->OnCacheSaveFinished(succeeded);
381 } 381 }
382 382
383 } // namespace history 383 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698