Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: chrome/browser/download/download_history.cc

Issue 7294013: Modified cancel and interrupt processing to avoid race with history. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed various problems surfaced by trybots. Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/download/download_history.h" 5 #include "chrome/browser/download/download_history.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/history/download_history_info.h" 8 #include "chrome/browser/history/download_history_info.h"
9 #include "chrome/browser/history/history_marshaling.h" 9 #include "chrome/browser/history/history_marshaling.h"
10 #include "chrome/browser/download/download_item.h" 10 #include "chrome/browser/download/download_item.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 const FilePath& new_path) { 113 const FilePath& new_path) {
114 // No update necessary if the download was initiated while in incognito mode. 114 // No update necessary if the download was initiated while in incognito mode.
115 if (download_item->db_handle() <= kUninitializedHandle) 115 if (download_item->db_handle() <= kUninitializedHandle)
116 return; 116 return;
117 117
118 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); 118 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
119 if (hs) 119 if (hs)
120 hs->UpdateDownloadPath(new_path, download_item->db_handle()); 120 hs->UpdateDownloadPath(new_path, download_item->db_handle());
121 } 121 }
122 122
123 void DownloadHistory::RemoveEntry(DownloadItem* download_item) { 123 void DownloadHistory::RemoveEntry(int64 db_handle) {
124 // No update necessary if the download was initiated while in incognito mode. 124 // No update necessary if the download was initiated while in incognito mode.
125 if (download_item->db_handle() <= kUninitializedHandle) 125 if (db_handle <= kUninitializedHandle)
benjhayden 2011/07/06 18:12:06 Do you want to start using IsFakeHandle(db_handle)
Randy Smith (Not in Mondays) 2011/07/07 22:02:23 I think of IsFakeHandle as an interface to Downloa
126 return; 126 return;
127 127
128 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); 128 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
129 if (hs) 129 if (hs)
130 hs->RemoveDownload(download_item->db_handle()); 130 hs->RemoveDownload(db_handle);
131 } 131 }
132 132
133 void DownloadHistory::RemoveEntriesBetween(const base::Time remove_begin, 133 void DownloadHistory::RemoveEntriesBetween(const base::Time remove_begin,
134 const base::Time remove_end) { 134 const base::Time remove_end) {
135 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); 135 HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
136 if (hs) 136 if (hs)
137 hs->RemoveDownloadsBetween(remove_begin, remove_end); 137 hs->RemoveDownloadsBetween(remove_begin, remove_end);
138 } 138 }
139 139
140 int64 DownloadHistory::GetNextFakeDbHandle() { 140 int64 DownloadHistory::GetNextFakeDbHandle() {
141 return next_fake_db_handle_--; 141 return next_fake_db_handle_--;
142 } 142 }
143 143
144 // static
145 bool DownloadHistory::IsFakeHandle(int64 db_handle) {
146 return db_handle <= 0;
benjhayden 2011/07/06 18:12:06 db_handle <= kUninitializedHandle;
Randy Smith (Not in Mondays) 2011/07/07 22:02:23 Done.
147 }
148
144 void DownloadHistory::OnGotVisitCountToHost(HistoryService::Handle handle, 149 void DownloadHistory::OnGotVisitCountToHost(HistoryService::Handle handle,
145 bool found_visits, 150 bool found_visits,
146 int count, 151 int count,
147 base::Time first_visit) { 152 base::Time first_visit) {
148 VisitedBeforeRequestsMap::iterator request = 153 VisitedBeforeRequestsMap::iterator request =
149 visited_before_requests_.find(handle); 154 visited_before_requests_.find(handle);
150 DCHECK(request != visited_before_requests_.end()); 155 DCHECK(request != visited_before_requests_.end());
151 int32 download_id = request->second.first; 156 int32 download_id = request->second.first;
152 VisitedBeforeDoneCallback* callback = request->second.second; 157 VisitedBeforeDoneCallback* callback = request->second.second;
153 visited_before_requests_.erase(request); 158 visited_before_requests_.erase(request);
154 callback->Run(download_id, found_visits && count && 159 callback->Run(download_id, found_visits && count &&
155 (first_visit.LocalMidnight() < base::Time::Now().LocalMidnight())); 160 (first_visit.LocalMidnight() < base::Time::Now().LocalMidnight()));
156 delete callback; 161 delete callback;
157 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698