| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // The history system runs on a background thread so that potentially slow | 5 // The history system runs on a background thread so that potentially slow |
| 6 // database operations don't delay the browser. This backend processing is | 6 // database operations don't delay the browser. This backend processing is |
| 7 // represented by HistoryBackend. The HistoryService's job is to dispatch to | 7 // represented by HistoryBackend. The HistoryService's job is to dispatch to |
| 8 // that thread. | 8 // that thread. |
| 9 // | 9 // |
| 10 // Main thread History thread | 10 // Main thread History thread |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 MessageLoop* message_loop_; | 92 MessageLoop* message_loop_; |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 // static | 95 // static |
| 96 const history::StarID HistoryService::kBookmarkBarID = 1; | 96 const history::StarID HistoryService::kBookmarkBarID = 1; |
| 97 | 97 |
| 98 HistoryService::HistoryService() | 98 HistoryService::HistoryService() |
| 99 : thread_(new ChromeThread(ChromeThread::HISTORY)), | 99 : thread_(new ChromeThread(ChromeThread::HISTORY)), |
| 100 profile_(NULL), | 100 profile_(NULL), |
| 101 backend_loaded_(false) { | 101 backend_loaded_(false) { |
| 102 if (NotificationService::current()) { // Is NULL when running generate_profil
e. | 102 // Is NULL when running generate_profile. |
| 103 if (NotificationService::current()) { |
| 103 NotificationService::current()->AddObserver( | 104 NotificationService::current()->AddObserver( |
| 104 this, NotificationType::HISTORY_URLS_DELETED, | 105 this, NotificationType::HISTORY_URLS_DELETED, |
| 105 Source<Profile>(profile_)); | 106 Source<Profile>(profile_)); |
| 106 } | 107 } |
| 107 } | 108 } |
| 108 | 109 |
| 109 HistoryService::HistoryService(Profile* profile) | 110 HistoryService::HistoryService(Profile* profile) |
| 110 : thread_(new ChromeThread(ChromeThread::HISTORY)), | 111 : thread_(new ChromeThread(ChromeThread::HISTORY)), |
| 111 profile_(profile), | 112 profile_(profile), |
| 112 backend_loaded_(false) { | 113 backend_loaded_(false) { |
| 113 NotificationService::current()->AddObserver( | 114 NotificationService::current()->AddObserver( |
| 114 this, NotificationType::HISTORY_URLS_DELETED, Source<Profile>(profile_)); | 115 this, NotificationType::HISTORY_URLS_DELETED, Source<Profile>(profile_)); |
| 115 } | 116 } |
| 116 | 117 |
| 117 HistoryService::~HistoryService() { | 118 HistoryService::~HistoryService() { |
| 118 // Shutdown the backend. This does nothing if Cleanup was already invoked. | 119 // Shutdown the backend. This does nothing if Cleanup was already invoked. |
| 119 Cleanup(); | 120 Cleanup(); |
| 120 | 121 |
| 121 // Unregister for notifications. | 122 // Unregister for notifications. |
| 122 if (NotificationService::current()) { // Is NULL when running generate_profil
e. | 123 // Is NULL when running generate_profile. |
| 124 if (NotificationService::current()) { |
| 123 NotificationService::current()->RemoveObserver( | 125 NotificationService::current()->RemoveObserver( |
| 124 this, NotificationType::HISTORY_URLS_DELETED, | 126 this, NotificationType::HISTORY_URLS_DELETED, |
| 125 Source<Profile>(profile_)); | 127 Source<Profile>(profile_)); |
| 126 } | 128 } |
| 127 } | 129 } |
| 128 | 130 |
| 129 bool HistoryService::Init(const FilePath& history_dir, | 131 bool HistoryService::Init(const FilePath& history_dir, |
| 130 BookmarkService* bookmark_service) { | 132 BookmarkService* bookmark_service) { |
| 131 if (!thread_->Start()) | 133 if (!thread_->Start()) |
| 132 return false; | 134 return false; |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 NotificationService::current()->Notify(type, source, det); | 660 NotificationService::current()->Notify(type, source, det); |
| 659 } | 661 } |
| 660 | 662 |
| 661 void HistoryService::OnDBLoaded() { | 663 void HistoryService::OnDBLoaded() { |
| 662 LOG(INFO) << "History backend finished loading"; | 664 LOG(INFO) << "History backend finished loading"; |
| 663 backend_loaded_ = true; | 665 backend_loaded_ = true; |
| 664 NotificationService::current()->Notify(NotificationType::HISTORY_LOADED, | 666 NotificationService::current()->Notify(NotificationType::HISTORY_LOADED, |
| 665 Source<Profile>(profile_), | 667 Source<Profile>(profile_), |
| 666 Details<HistoryService>(this)); | 668 Details<HistoryService>(this)); |
| 667 } | 669 } |
| OLD | NEW |