Commit ca881b87 authored by rlp@chromium.org's avatar rlp@chromium.org

Fixing some more instances where I put in HistoryServiceFactory::GetForProfile...

Fixing some more instances where I put in HistoryServiceFactory::GetForProfile which will force creation of the history. Replacing those instantces where we should not force creation and should instead just check if the history has already been created.

BUG=97804
TEST=unittests

Review URL: https://chromiumcodereview.appspot.com/10605003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148626 0039d316-1c4b-4281-b951-d872f2087c98
parent c5a6ed4c
...@@ -1069,7 +1069,8 @@ TEST_F(BookmarkModelTestWithProfile2, RemoveNotification) { ...@@ -1069,7 +1069,8 @@ TEST_F(BookmarkModelTestWithProfile2, RemoveNotification) {
// This won't actually delete the URL, rather it'll empty out the visits. // This won't actually delete the URL, rather it'll empty out the visits.
// This triggers blocking on the BookmarkModel. // This triggers blocking on the BookmarkModel.
profile_->GetHistoryService(Profile::EXPLICIT_ACCESS)->DeleteURL(url); HistoryServiceFactory::GetForProfile(
profile_.get(), Profile::EXPLICIT_ACCESS)->DeleteURL(url);
} }
TEST_F(BookmarkModelTest, Sort) { TEST_F(BookmarkModelTest, Sort) {
......
...@@ -25,8 +25,8 @@ DownloadHistory::~DownloadHistory() {} ...@@ -25,8 +25,8 @@ DownloadHistory::~DownloadHistory() {}
void DownloadHistory::GetNextId( void DownloadHistory::GetNextId(
const HistoryService::DownloadNextIdCallback& callback) { const HistoryService::DownloadNextIdCallback& callback) {
HistoryService* hs = HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists(
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); profile_, Profile::EXPLICIT_ACCESS);
if (!hs) if (!hs)
return; return;
...@@ -35,8 +35,8 @@ void DownloadHistory::GetNextId( ...@@ -35,8 +35,8 @@ void DownloadHistory::GetNextId(
void DownloadHistory::Load( void DownloadHistory::Load(
const HistoryService::DownloadQueryCallback& callback) { const HistoryService::DownloadQueryCallback& callback) {
HistoryService* hs = HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists(
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); profile_, Profile::EXPLICIT_ACCESS);
if (!hs) if (!hs)
return; return;
...@@ -51,9 +51,8 @@ void DownloadHistory::CheckVisitedReferrerBefore( ...@@ -51,9 +51,8 @@ void DownloadHistory::CheckVisitedReferrerBefore(
const GURL& referrer_url, const GURL& referrer_url,
const VisitedBeforeDoneCallback& callback) { const VisitedBeforeDoneCallback& callback) {
if (referrer_url.is_valid()) { if (referrer_url.is_valid()) {
HistoryService* hs = HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists(
HistoryServiceFactory::GetForProfile(profile_, profile_, Profile::EXPLICIT_ACCESS);
Profile::EXPLICIT_ACCESS);
if (hs) { if (hs) {
HistoryService::Handle handle = HistoryService::Handle handle =
hs->GetVisibleVisitCountToHost(referrer_url, &history_consumer_, hs->GetVisibleVisitCountToHost(referrer_url, &history_consumer_,
...@@ -79,8 +78,8 @@ void DownloadHistory::AddEntry( ...@@ -79,8 +78,8 @@ void DownloadHistory::AddEntry(
// handles, so we use a negative value. Eventually, they could overlap, but // handles, so we use a negative value. Eventually, they could overlap, but
// you'd have to do enough downloading that your ISP would likely stab you in // you'd have to do enough downloading that your ISP would likely stab you in
// the neck first. YMMV. // the neck first. YMMV.
HistoryService* hs = HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists(
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); profile_, Profile::EXPLICIT_ACCESS);
if (download_item->IsOtr() || if (download_item->IsOtr() ||
download_crx_util::IsExtensionDownload(*download_item) || download_crx_util::IsExtensionDownload(*download_item) ||
download_item->IsTemporary() || !hs) { download_item->IsTemporary() || !hs) {
...@@ -100,8 +99,8 @@ void DownloadHistory::UpdateEntry(DownloadItem* download_item) { ...@@ -100,8 +99,8 @@ void DownloadHistory::UpdateEntry(DownloadItem* download_item) {
if (download_item->GetDbHandle() <= DownloadItem::kUninitializedHandle) if (download_item->GetDbHandle() <= DownloadItem::kUninitializedHandle)
return; return;
HistoryService* hs = HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists(
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); profile_, Profile::EXPLICIT_ACCESS);
if (!hs) if (!hs)
return; return;
hs->UpdateDownload(download_item->GetPersistentStoreInfo()); hs->UpdateDownload(download_item->GetPersistentStoreInfo());
...@@ -113,8 +112,8 @@ void DownloadHistory::UpdateDownloadPath(DownloadItem* download_item, ...@@ -113,8 +112,8 @@ void DownloadHistory::UpdateDownloadPath(DownloadItem* download_item,
if (download_item->GetDbHandle() <= DownloadItem::kUninitializedHandle) if (download_item->GetDbHandle() <= DownloadItem::kUninitializedHandle)
return; return;
HistoryService* hs = HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists(
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); profile_, Profile::EXPLICIT_ACCESS);
if (hs) if (hs)
hs->UpdateDownloadPath(new_path, download_item->GetDbHandle()); hs->UpdateDownloadPath(new_path, download_item->GetDbHandle());
} }
...@@ -124,16 +123,16 @@ void DownloadHistory::RemoveEntry(DownloadItem* download_item) { ...@@ -124,16 +123,16 @@ void DownloadHistory::RemoveEntry(DownloadItem* download_item) {
if (download_item->GetDbHandle() <= DownloadItem::kUninitializedHandle) if (download_item->GetDbHandle() <= DownloadItem::kUninitializedHandle)
return; return;
HistoryService* hs = HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists(
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); profile_, Profile::EXPLICIT_ACCESS);
if (hs) if (hs)
hs->RemoveDownload(download_item->GetDbHandle()); hs->RemoveDownload(download_item->GetDbHandle());
} }
void DownloadHistory::RemoveEntriesBetween(const base::Time remove_begin, void DownloadHistory::RemoveEntriesBetween(const base::Time remove_begin,
const base::Time remove_end) { const base::Time remove_end) {
HistoryService* hs = HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists(
HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); profile_, Profile::EXPLICIT_ACCESS);
if (hs) if (hs)
hs->RemoveDownloadsBetween(remove_begin, remove_end); hs->RemoveDownloadsBetween(remove_begin, remove_end);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment