| OLD | NEW |
| 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/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/history/history_notifications.h" | 9 #include "chrome/browser/history/history_notifications.h" |
| 10 #include "chrome/browser/history/url_database.h" | 10 #include "chrome/browser/history/url_database.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 private_data_(new URLIndexPrivateData), | 95 private_data_(new URLIndexPrivateData), |
| 96 restore_cache_observer_(NULL), | 96 restore_cache_observer_(NULL), |
| 97 save_cache_observer_(NULL), | 97 save_cache_observer_(NULL), |
| 98 shutdown_(false), | 98 shutdown_(false), |
| 99 needs_to_be_cached_(false) { | 99 needs_to_be_cached_(false) { |
| 100 InitializeSchemeWhitelist(&scheme_whitelist_); | 100 InitializeSchemeWhitelist(&scheme_whitelist_); |
| 101 if (profile) { | 101 if (profile) { |
| 102 // TODO(mrossetti): Register for language change notifications. | 102 // TODO(mrossetti): Register for language change notifications. |
| 103 content::Source<Profile> source(profile); | 103 content::Source<Profile> source(profile); |
| 104 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URL_VISITED, source); | 104 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URL_VISITED, source); |
| 105 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_TYPED_URLS_MODIFIED, | 105 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, |
| 106 source); | 106 source); |
| 107 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, source); | 107 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, source); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 // Called only by unit tests. | 111 // Called only by unit tests. |
| 112 InMemoryURLIndex::InMemoryURLIndex() | 112 InMemoryURLIndex::InMemoryURLIndex() |
| 113 : profile_(NULL), | 113 : profile_(NULL), |
| 114 private_data_(new URLIndexPrivateData), | 114 private_data_(new URLIndexPrivateData), |
| 115 restore_cache_observer_(NULL), | 115 restore_cache_observer_(NULL), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 // Updating -------------------------------------------------------------------- | 158 // Updating -------------------------------------------------------------------- |
| 159 | 159 |
| 160 void InMemoryURLIndex::Observe(int notification_type, | 160 void InMemoryURLIndex::Observe(int notification_type, |
| 161 const content::NotificationSource& source, | 161 const content::NotificationSource& source, |
| 162 const content::NotificationDetails& details) { | 162 const content::NotificationDetails& details) { |
| 163 switch (notification_type) { | 163 switch (notification_type) { |
| 164 case chrome::NOTIFICATION_HISTORY_URL_VISITED: | 164 case chrome::NOTIFICATION_HISTORY_URL_VISITED: |
| 165 OnURLVisited(content::Details<URLVisitedDetails>(details).ptr()); | 165 OnURLVisited(content::Details<URLVisitedDetails>(details).ptr()); |
| 166 break; | 166 break; |
| 167 case chrome::NOTIFICATION_HISTORY_TYPED_URLS_MODIFIED: | 167 case chrome::NOTIFICATION_HISTORY_URLS_MODIFIED: |
| 168 OnURLsModified( | 168 OnURLsModified( |
| 169 content::Details<history::URLsModifiedDetails>(details).ptr()); | 169 content::Details<history::URLsModifiedDetails>(details).ptr()); |
| 170 break; | 170 break; |
| 171 case chrome::NOTIFICATION_HISTORY_URLS_DELETED: | 171 case chrome::NOTIFICATION_HISTORY_URLS_DELETED: |
| 172 OnURLsDeleted( | 172 OnURLsDeleted( |
| 173 content::Details<history::URLsDeletedDetails>(details).ptr()); | 173 content::Details<history::URLsDeletedDetails>(details).ptr()); |
| 174 break; | 174 break; |
| 175 case chrome::NOTIFICATION_HISTORY_LOADED: | 175 case chrome::NOTIFICATION_HISTORY_LOADED: |
| 176 registrar_.Remove(this, chrome::NOTIFICATION_HISTORY_LOADED, | 176 registrar_.Remove(this, chrome::NOTIFICATION_HISTORY_LOADED, |
| 177 content::Source<Profile>(profile_)); | 177 content::Source<Profile>(profile_)); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 | 310 |
| 311 void InMemoryURLIndex::OnCacheSaveDone( | 311 void InMemoryURLIndex::OnCacheSaveDone( |
| 312 scoped_refptr<RefCountedBool> succeeded) { | 312 scoped_refptr<RefCountedBool> succeeded) { |
| 313 if (save_cache_observer_) | 313 if (save_cache_observer_) |
| 314 save_cache_observer_->OnCacheSaveFinished(succeeded->value()); | 314 save_cache_observer_->OnCacheSaveFinished(succeeded->value()); |
| 315 } | 315 } |
| 316 | 316 |
| 317 } // namespace history | 317 } // namespace history |
| OLD | NEW |