diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 22:34:41 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 22:34:41 +0000 |
commit | e587a45fcdc7dec3c5ce894e4fac236cdb8fe2ad (patch) | |
tree | 04883155bf0e43a7dba6717d5f3ce4526c34712e /chrome/browser/history | |
parent | 61206e0c3dfcf17e748dec65139d7e8e3449c8a3 (diff) | |
download | chromium_src-e587a45fcdc7dec3c5ce894e4fac236cdb8fe2ad.zip chromium_src-e587a45fcdc7dec3c5ce894e4fac236cdb8fe2ad.tar.gz chromium_src-e587a45fcdc7dec3c5ce894e4fac236cdb8fe2ad.tar.bz2 |
Show a warning when the history files can't be read correctly.
This re-plumbs the existing "TooNew" codepath to handle arbitrary error messages.
BUG=25822
TEST=Make your history files non-readable, run Chrome (Release), make sure you get a warning dialog.
Review URL: http://codereview.chromium.org/342048
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30642 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history')
-rw-r--r-- | chrome/browser/history/history.cc | 10 | ||||
-rw-r--r-- | chrome/browser/history/history.h | 6 | ||||
-rw-r--r-- | chrome/browser/history/history_backend.cc | 6 | ||||
-rw-r--r-- | chrome/browser/history/history_backend.h | 5 | ||||
-rw-r--r-- | chrome/browser/history/history_backend_unittest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/history/history_unittest.cc | 4 |
6 files changed, 18 insertions, 19 deletions
diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc index a7bf774..ee13114 100644 --- a/chrome/browser/history/history.cc +++ b/chrome/browser/history/history.cc @@ -94,10 +94,10 @@ class HistoryService::BackendDelegate : public HistoryBackend::Delegate { message_loop_(MessageLoop::current()) { } - virtual void NotifyTooNew() { + virtual void NotifyProfileError(int message_id) { // Send the backend to the history service on the main thread. message_loop_->PostTask(FROM_HERE, NewRunnableMethod(history_service_.get(), - &HistoryService::NotifyTooNew)); + &HistoryService::NotifyProfileError, message_id)); } virtual void SetInMemoryBackend( @@ -666,10 +666,10 @@ void HistoryService::SetInMemoryBackend( in_memory_backend_->AttachToHistoryService(profile_); } -void HistoryService::NotifyTooNew() { +void HistoryService::NotifyProfileError(int message_id) { Source<HistoryService> source(this); - NotificationService::current()->Notify(NotificationType::HISTORY_TOO_NEW, - source, NotificationService::NoDetails()); + NotificationService::current()->Notify(NotificationType::PROFILE_ERROR, + source, Details<int>(&message_id)); } void HistoryService::DeleteURL(const GURL& url) { diff --git a/chrome/browser/history/history.h b/chrome/browser/history/history.h index 13bbf4c..d6dab37 100644 --- a/chrome/browser/history/history.h +++ b/chrome/browser/history/history.h @@ -613,9 +613,9 @@ class HistoryService : public CancelableRequestProvider, // database is loaded to make it available. void SetInMemoryBackend(history::InMemoryHistoryBackend* mem_backend); - // Called by our BackendDelegate when the database version is too new to be - // read properly. - void NotifyTooNew(); + // Called by our BackendDelegate when there is a problem reading the database. + // |message_id| is the relevant message in the string table to display. + void NotifyProfileError(int message_id); // Call to schedule a given task for running on the history thread with the // specified priority. The task will have ownership taken. diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc index f9855f4..b7d1a47 100644 --- a/chrome/browser/history/history_backend.cc +++ b/chrome/browser/history/history_backend.cc @@ -25,6 +25,8 @@ #include "chrome/common/sqlite_utils.h" #include "chrome/common/url_constants.h" #include "googleurl/src/gurl.h" +#include "grit/chromium_strings.h" +#include "grit/generated_resources.h" #include "net/base/registry_controlled_domain.h" using base::Time; @@ -501,11 +503,11 @@ void HistoryBackend::InitImpl() { case INIT_FAILURE: // A NULL db_ will cause all calls on this object to notice this error // and to not continue. - LOG(WARNING) << "Unable to initialize history DB."; + delegate_->NotifyProfileError(IDS_COULDNT_OPEN_PROFILE_ERROR); db_.reset(); return; case INIT_TOO_NEW: - delegate_->NotifyTooNew(); + delegate_->NotifyProfileError(IDS_PROFILE_TOO_NEW_ERROR); db_.reset(); return; default: diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h index 4effaca..34481ce 100644 --- a/chrome/browser/history/history_backend.h +++ b/chrome/browser/history/history_backend.h @@ -52,9 +52,8 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, public: virtual ~Delegate() {} - // Called when the database is from a future version of the product and can - // not be used. - virtual void NotifyTooNew() = 0; + // Called when the database cannot be read correctly for some reason. + virtual void NotifyProfileError(int message_id) = 0; // Sets the in-memory history backend. The in-memory backend is created by // the main backend. For non-unit tests, this happens on the background diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc index 7270a3d..833059e 100644 --- a/chrome/browser/history/history_backend_unittest.cc +++ b/chrome/browser/history/history_backend_unittest.cc @@ -32,11 +32,9 @@ class HistoryBackendTest; // This just forwards the messages we're interested in to the test object. class HistoryBackendTestDelegate : public HistoryBackend::Delegate { public: - explicit HistoryBackendTestDelegate(HistoryBackendTest* test) : test_(test) { - } + explicit HistoryBackendTestDelegate(HistoryBackendTest* test) : test_(test) {} - virtual void NotifyTooNew() { - } + virtual void NotifyProfileError(int message_id) {} virtual void SetInMemoryBackend(InMemoryHistoryBackend* backend); virtual void BroadcastNotifications(NotificationType type, HistoryDetails* details); diff --git a/chrome/browser/history/history_unittest.cc b/chrome/browser/history/history_unittest.cc index ce6121a..4316c27 100644 --- a/chrome/browser/history/history_unittest.cc +++ b/chrome/browser/history/history_unittest.cc @@ -96,7 +96,7 @@ class BackendDelegate : public HistoryBackend::Delegate { : history_test_(history_test) { } - virtual void NotifyTooNew(); + virtual void NotifyProfileError(int message_id); virtual void SetInMemoryBackend(InMemoryHistoryBackend* backend); virtual void BroadcastNotifications(NotificationType type, HistoryDetails* details); @@ -294,7 +294,7 @@ class HistoryTest : public testing::Test { HistoryDatabase* db_; // Cached reference to the backend's database. }; -void BackendDelegate::NotifyTooNew() { +void BackendDelegate::NotifyProfileError(int message_id) { } void BackendDelegate::SetInMemoryBackend(InMemoryHistoryBackend* backend) { |