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 #ifndef CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H__ | 5 #ifndef CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H__ |
6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H__ | 6 #define CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H__ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/gfx/rect.h" | 10 #include "base/gfx/rect.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 const std::vector<ImportedFavIconUsage>& favicon_usage); | 190 const std::vector<ImportedFavIconUsage>& favicon_usage); |
191 | 191 |
192 // Downloads ----------------------------------------------------------------- | 192 // Downloads ----------------------------------------------------------------- |
193 | 193 |
194 void QueryDownloads(scoped_refptr<DownloadQueryRequest> request); | 194 void QueryDownloads(scoped_refptr<DownloadQueryRequest> request); |
195 void UpdateDownload(int64 received_bytes, int32 state, int64 db_handle); | 195 void UpdateDownload(int64 received_bytes, int32 state, int64 db_handle); |
196 void UpdateDownloadPath(const std::wstring& path, int64 db_handle); | 196 void UpdateDownloadPath(const std::wstring& path, int64 db_handle); |
197 void CreateDownload(scoped_refptr<DownloadCreateRequest> request, | 197 void CreateDownload(scoped_refptr<DownloadCreateRequest> request, |
198 const DownloadCreateInfo& info); | 198 const DownloadCreateInfo& info); |
199 void RemoveDownload(int64 db_handle); | 199 void RemoveDownload(int64 db_handle); |
200 void RemoveDownloadsBetween(const Time remove_begin, | 200 void RemoveDownloadsBetween(const base::Time remove_begin, |
201 const Time remove_end); | 201 const base::Time remove_end); |
202 void RemoveDownloads(const Time remove_end); | 202 void RemoveDownloads(const base::Time remove_end); |
203 void SearchDownloads(scoped_refptr<DownloadSearchRequest>, | 203 void SearchDownloads(scoped_refptr<DownloadSearchRequest>, |
204 const std::wstring& search_text); | 204 const std::wstring& search_text); |
205 | 205 |
206 // Segment usage ------------------------------------------------------------- | 206 // Segment usage ------------------------------------------------------------- |
207 | 207 |
208 void QuerySegmentUsage(scoped_refptr<QuerySegmentUsageRequest> request, | 208 void QuerySegmentUsage(scoped_refptr<QuerySegmentUsageRequest> request, |
209 const Time from_time); | 209 const base::Time from_time); |
210 void DeleteOldSegmentData(); | 210 void DeleteOldSegmentData(); |
211 void SetSegmentPresentationIndex(SegmentID segment_id, int index); | 211 void SetSegmentPresentationIndex(SegmentID segment_id, int index); |
212 | 212 |
213 // Keyword search terms ------------------------------------------------------ | 213 // Keyword search terms ------------------------------------------------------ |
214 | 214 |
215 void SetKeywordSearchTermsForURL(const GURL& url, | 215 void SetKeywordSearchTermsForURL(const GURL& url, |
216 TemplateURL::IDType keyword_id, | 216 TemplateURL::IDType keyword_id, |
217 const std::wstring& term); | 217 const std::wstring& term); |
218 | 218 |
219 void DeleteAllSearchTermsForKeyword(TemplateURL::IDType keyword_id); | 219 void DeleteAllSearchTermsForKeyword(TemplateURL::IDType keyword_id); |
220 | 220 |
221 void GetMostRecentKeywordSearchTerms( | 221 void GetMostRecentKeywordSearchTerms( |
222 scoped_refptr<GetMostRecentKeywordSearchTermsRequest> request, | 222 scoped_refptr<GetMostRecentKeywordSearchTermsRequest> request, |
223 TemplateURL::IDType keyword_id, | 223 TemplateURL::IDType keyword_id, |
224 const std::wstring& prefix, | 224 const std::wstring& prefix, |
225 int max_count); | 225 int max_count); |
226 | 226 |
227 // Generic operations -------------------------------------------------------- | 227 // Generic operations -------------------------------------------------------- |
228 | 228 |
229 void ProcessDBTask(scoped_refptr<HistoryDBTaskRequest> request); | 229 void ProcessDBTask(scoped_refptr<HistoryDBTaskRequest> request); |
230 | 230 |
231 // Deleting ------------------------------------------------------------------ | 231 // Deleting ------------------------------------------------------------------ |
232 | 232 |
233 void DeleteURL(const GURL& url); | 233 void DeleteURL(const GURL& url); |
234 | 234 |
235 // Calls ExpireHistoryBackend::ExpireHistoryBetween and commits the change. | 235 // Calls ExpireHistoryBackend::ExpireHistoryBetween and commits the change. |
236 void ExpireHistoryBetween(scoped_refptr<ExpireHistoryRequest> request, | 236 void ExpireHistoryBetween(scoped_refptr<ExpireHistoryRequest> request, |
237 Time begin_time, | 237 base::Time begin_time, |
238 Time end_time); | 238 base::Time end_time); |
239 | 239 |
240 // Bookmarks ----------------------------------------------------------------- | 240 // Bookmarks ----------------------------------------------------------------- |
241 | 241 |
242 // Notification that a URL is no longer bookmarked. If there are no visits | 242 // Notification that a URL is no longer bookmarked. If there are no visits |
243 // for the specified url, it is deleted. | 243 // for the specified url, it is deleted. |
244 void URLsNoLongerBookmarked(const std::set<GURL>& urls); | 244 void URLsNoLongerBookmarked(const std::set<GURL>& urls); |
245 | 245 |
246 // Testing ------------------------------------------------------------------- | 246 // Testing ------------------------------------------------------------------- |
247 | 247 |
248 // Sets the task to run and the message loop to run it on when this object | 248 // Sets the task to run and the message loop to run it on when this object |
(...skipping 26 matching lines...) Expand all Loading... |
275 void InitImpl(); | 275 void InitImpl(); |
276 | 276 |
277 // Adds a single visit to the database, updating the URL information such | 277 // Adds a single visit to the database, updating the URL information such |
278 // as visit and typed count. The visit ID of the added visit and the URL ID | 278 // as visit and typed count. The visit ID of the added visit and the URL ID |
279 // of the associated URL (whether added or not) is returned. Both values will | 279 // of the associated URL (whether added or not) is returned. Both values will |
280 // be 0 on failure. | 280 // be 0 on failure. |
281 // | 281 // |
282 // This does not schedule database commits, it is intended to be used as a | 282 // This does not schedule database commits, it is intended to be used as a |
283 // subroutine for AddPage only. It also assumes the database is valid. | 283 // subroutine for AddPage only. It also assumes the database is valid. |
284 std::pair<URLID, VisitID> AddPageVisit(const GURL& url, | 284 std::pair<URLID, VisitID> AddPageVisit(const GURL& url, |
285 Time time, | 285 base::Time time, |
286 VisitID referring_visit, | 286 VisitID referring_visit, |
287 PageTransition::Type transition); | 287 PageTransition::Type transition); |
288 | 288 |
289 // Returns a redirect chain in |redirects| for the VisitID | 289 // Returns a redirect chain in |redirects| for the VisitID |
290 // |cur_visit|. |cur_visit| is assumed to be valid. Assumes that | 290 // |cur_visit|. |cur_visit| is assumed to be valid. Assumes that |
291 // this HistoryBackend object has been Init()ed successfully. | 291 // this HistoryBackend object has been Init()ed successfully. |
292 void GetRedirectsFromSpecificVisit( | 292 void GetRedirectsFromSpecificVisit( |
293 VisitID cur_visit, HistoryService::RedirectList* redirects); | 293 VisitID cur_visit, HistoryService::RedirectList* redirects); |
294 | 294 |
295 // Thumbnail Helpers --------------------------------------------------------- | 295 // Thumbnail Helpers --------------------------------------------------------- |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 // Walks back a segment chain to find the last visit with a non null segment | 338 // Walks back a segment chain to find the last visit with a non null segment |
339 // id and returns it. If there is none found, returns 0. | 339 // id and returns it. If there is none found, returns 0. |
340 SegmentID GetLastSegmentID(VisitID from_visit); | 340 SegmentID GetLastSegmentID(VisitID from_visit); |
341 | 341 |
342 // Update the segment information. This is called internally when a page is | 342 // Update the segment information. This is called internally when a page is |
343 // added. Return the segment id of the segment that has been updated. | 343 // added. Return the segment id of the segment that has been updated. |
344 SegmentID UpdateSegments(const GURL& url, | 344 SegmentID UpdateSegments(const GURL& url, |
345 VisitID from_visit, | 345 VisitID from_visit, |
346 VisitID visit_id, | 346 VisitID visit_id, |
347 PageTransition::Type transition_type, | 347 PageTransition::Type transition_type, |
348 const Time ts); | 348 const base::Time ts); |
349 | 349 |
350 // Favicons ------------------------------------------------------------------ | 350 // Favicons ------------------------------------------------------------------ |
351 | 351 |
352 // Used by both UpdateFavIconMappingAndFetch and GetFavIcon. | 352 // Used by both UpdateFavIconMappingAndFetch and GetFavIcon. |
353 // If page_url is non-null and SetFavIcon has previously been invoked for | 353 // If page_url is non-null and SetFavIcon has previously been invoked for |
354 // icon_url the favicon url for page_url (and all redirects) is set to | 354 // icon_url the favicon url for page_url (and all redirects) is set to |
355 // icon_url. | 355 // icon_url. |
356 void UpdateFavIconMappingAndFetchImpl( | 356 void UpdateFavIconMappingAndFetchImpl( |
357 const GURL* page_url, | 357 const GURL* page_url, |
358 const GURL& icon_url, | 358 const GURL& icon_url, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 // As with AddPage, the last item in the redirect chain will be the | 447 // As with AddPage, the last item in the redirect chain will be the |
448 // destination of the redirect (i.e., the key into recent_redirects_); | 448 // destination of the redirect (i.e., the key into recent_redirects_); |
449 typedef MRUCache<GURL, HistoryService::RedirectList> RedirectCache; | 449 typedef MRUCache<GURL, HistoryService::RedirectList> RedirectCache; |
450 RedirectCache recent_redirects_; | 450 RedirectCache recent_redirects_; |
451 | 451 |
452 // Timestamp of the last page addition request. We use this to detect when | 452 // Timestamp of the last page addition request. We use this to detect when |
453 // multiple additions are requested at the same time (within the resolution | 453 // multiple additions are requested at the same time (within the resolution |
454 // of the timer), so we can try to ensure they're unique when they're added | 454 // of the timer), so we can try to ensure they're unique when they're added |
455 // to the database by using the last_recorded_time_ (q.v.). We still can't | 455 // to the database by using the last_recorded_time_ (q.v.). We still can't |
456 // enforce or guarantee uniqueness, since the user might set his clock back. | 456 // enforce or guarantee uniqueness, since the user might set his clock back. |
457 Time last_requested_time_; | 457 base::Time last_requested_time_; |
458 | 458 |
459 // Timestamp of the last page addition, as it was recorded in the database. | 459 // Timestamp of the last page addition, as it was recorded in the database. |
460 // If two or more requests come in at the same time, we increment that time | 460 // If two or more requests come in at the same time, we increment that time |
461 // by 1 us between them so it's more likely to be unique in the database. | 461 // by 1 us between them so it's more likely to be unique in the database. |
462 // This keeps track of that higher-resolution timestamp. | 462 // This keeps track of that higher-resolution timestamp. |
463 Time last_recorded_time_; | 463 base::Time last_recorded_time_; |
464 | 464 |
465 // When non-NULL, this is the task that should be invoked on | 465 // When non-NULL, this is the task that should be invoked on |
466 MessageLoop* backend_destroy_message_loop_; | 466 MessageLoop* backend_destroy_message_loop_; |
467 Task* backend_destroy_task_; | 467 Task* backend_destroy_task_; |
468 | 468 |
469 // Tracks page transition types. | 469 // Tracks page transition types. |
470 VisitTracker tracker_; | 470 VisitTracker tracker_; |
471 | 471 |
472 // A boolean variable to track whether we have already purged obsolete segment | 472 // A boolean variable to track whether we have already purged obsolete segment |
473 // data. | 473 // data. |
474 bool segment_queried_; | 474 bool segment_queried_; |
475 | 475 |
476 // HistoryDBTasks to run. Be sure to AddRef when adding, and Release when | 476 // HistoryDBTasks to run. Be sure to AddRef when adding, and Release when |
477 // done. | 477 // done. |
478 std::list<HistoryDBTaskRequest*> db_task_requests_; | 478 std::list<HistoryDBTaskRequest*> db_task_requests_; |
479 | 479 |
480 // Used to determine if a URL is bookmarked. This is owned by the Profile and | 480 // Used to determine if a URL is bookmarked. This is owned by the Profile and |
481 // may be NULL (during testing). | 481 // may be NULL (during testing). |
482 // | 482 // |
483 // Use GetBookmarkService to access this, which makes sure the service is | 483 // Use GetBookmarkService to access this, which makes sure the service is |
484 // loaded. | 484 // loaded. |
485 BookmarkService* bookmark_service_; | 485 BookmarkService* bookmark_service_; |
486 | 486 |
487 DISALLOW_EVIL_CONSTRUCTORS(HistoryBackend); | 487 DISALLOW_EVIL_CONSTRUCTORS(HistoryBackend); |
488 }; | 488 }; |
489 | 489 |
490 } // namespace history | 490 } // namespace history |
491 | 491 |
492 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H__ | 492 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H__ |
OLD | NEW |