| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // separate class from the history service so that it can hold a reference to | 87 // separate class from the history service so that it can hold a reference to |
| 88 // the history service (otherwise we would have to manually AddRef and | 88 // the history service (otherwise we would have to manually AddRef and |
| 89 // Release when the Backend has a reference to us). | 89 // Release when the Backend has a reference to us). |
| 90 class HistoryService::BackendDelegate : public HistoryBackend::Delegate { | 90 class HistoryService::BackendDelegate : public HistoryBackend::Delegate { |
| 91 public: | 91 public: |
| 92 explicit BackendDelegate(HistoryService* history_service) | 92 explicit BackendDelegate(HistoryService* history_service) |
| 93 : history_service_(history_service), | 93 : history_service_(history_service), |
| 94 message_loop_(MessageLoop::current()) { | 94 message_loop_(MessageLoop::current()) { |
| 95 } | 95 } |
| 96 | 96 |
| 97 virtual void NotifyTooNew() { | 97 virtual void NotifyProfileError(int message_id) { |
| 98 // Send the backend to the history service on the main thread. | 98 // Send the backend to the history service on the main thread. |
| 99 message_loop_->PostTask(FROM_HERE, NewRunnableMethod(history_service_.get(), | 99 message_loop_->PostTask(FROM_HERE, NewRunnableMethod(history_service_.get(), |
| 100 &HistoryService::NotifyTooNew)); | 100 &HistoryService::NotifyProfileError, message_id)); |
| 101 } | 101 } |
| 102 | 102 |
| 103 virtual void SetInMemoryBackend( | 103 virtual void SetInMemoryBackend( |
| 104 history::InMemoryHistoryBackend* backend) { | 104 history::InMemoryHistoryBackend* backend) { |
| 105 // Send the backend to the history service on the main thread. | 105 // Send the backend to the history service on the main thread. |
| 106 message_loop_->PostTask(FROM_HERE, NewRunnableMethod(history_service_.get(), | 106 message_loop_->PostTask(FROM_HERE, NewRunnableMethod(history_service_.get(), |
| 107 &HistoryService::SetInMemoryBackend, backend)); | 107 &HistoryService::SetInMemoryBackend, backend)); |
| 108 } | 108 } |
| 109 | 109 |
| 110 virtual void BroadcastNotifications(NotificationType type, | 110 virtual void BroadcastNotifications(NotificationType type, |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 | 659 |
| 660 void HistoryService::SetInMemoryBackend( | 660 void HistoryService::SetInMemoryBackend( |
| 661 history::InMemoryHistoryBackend* mem_backend) { | 661 history::InMemoryHistoryBackend* mem_backend) { |
| 662 DCHECK(!in_memory_backend_.get()) << "Setting mem DB twice"; | 662 DCHECK(!in_memory_backend_.get()) << "Setting mem DB twice"; |
| 663 in_memory_backend_.reset(mem_backend); | 663 in_memory_backend_.reset(mem_backend); |
| 664 | 664 |
| 665 // The database requires additional initialization once we own it. | 665 // The database requires additional initialization once we own it. |
| 666 in_memory_backend_->AttachToHistoryService(profile_); | 666 in_memory_backend_->AttachToHistoryService(profile_); |
| 667 } | 667 } |
| 668 | 668 |
| 669 void HistoryService::NotifyTooNew() { | 669 void HistoryService::NotifyProfileError(int message_id) { |
| 670 Source<HistoryService> source(this); | 670 Source<HistoryService> source(this); |
| 671 NotificationService::current()->Notify(NotificationType::HISTORY_TOO_NEW, | 671 NotificationService::current()->Notify(NotificationType::PROFILE_ERROR, |
| 672 source, NotificationService::NoDetails()); | 672 source, Details<int>(&message_id)); |
| 673 } | 673 } |
| 674 | 674 |
| 675 void HistoryService::DeleteURL(const GURL& url) { | 675 void HistoryService::DeleteURL(const GURL& url) { |
| 676 // We will update the visited links when we observe the delete notifications. | 676 // We will update the visited links when we observe the delete notifications. |
| 677 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::DeleteURL, url); | 677 ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::DeleteURL, url); |
| 678 } | 678 } |
| 679 | 679 |
| 680 void HistoryService::ExpireHistoryBetween( | 680 void HistoryService::ExpireHistoryBetween( |
| 681 Time begin_time, Time end_time, | 681 Time begin_time, Time end_time, |
| 682 CancelableRequestConsumerBase* consumer, | 682 CancelableRequestConsumerBase* consumer, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 ScheduleAndForget(PRIORITY_UI, &HistoryBackend::Init); | 725 ScheduleAndForget(PRIORITY_UI, &HistoryBackend::Init); |
| 726 } | 726 } |
| 727 | 727 |
| 728 void HistoryService::OnDBLoaded() { | 728 void HistoryService::OnDBLoaded() { |
| 729 LOG(INFO) << "History backend finished loading"; | 729 LOG(INFO) << "History backend finished loading"; |
| 730 backend_loaded_ = true; | 730 backend_loaded_ = true; |
| 731 NotificationService::current()->Notify(NotificationType::HISTORY_LOADED, | 731 NotificationService::current()->Notify(NotificationType::HISTORY_LOADED, |
| 732 Source<Profile>(profile_), | 732 Source<Profile>(profile_), |
| 733 Details<HistoryService>(this)); | 733 Details<HistoryService>(this)); |
| 734 } | 734 } |
| OLD | NEW |