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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 int result_count); | 153 int result_count); |
154 | 154 |
155 // Computes the most recent URL(s) that the given canonical URL has | 155 // Computes the most recent URL(s) that the given canonical URL has |
156 // redirected to and returns true on success. There may be more than one | 156 // redirected to and returns true on success. There may be more than one |
157 // redirect in a row, so this function will fill the given array with the | 157 // redirect in a row, so this function will fill the given array with the |
158 // entire chain. If there are no redirects for the most recent visit of the | 158 // entire chain. If there are no redirects for the most recent visit of the |
159 // URL, or the URL is not in history, returns false. | 159 // URL, or the URL is not in history, returns false. |
160 // | 160 // |
161 // Backend for QueryRedirectsFrom. | 161 // Backend for QueryRedirectsFrom. |
162 bool GetMostRecentRedirectsFrom(const GURL& url, | 162 bool GetMostRecentRedirectsFrom(const GURL& url, |
163 HistoryService::RedirectList* redirects); | 163 history::RedirectList* redirects); |
164 | 164 |
165 // Similar to above function except computes a chain of redirects to the | 165 // Similar to above function except computes a chain of redirects to the |
166 // given URL. Stores the most recent list of redirects ending at |url| in the | 166 // given URL. Stores the most recent list of redirects ending at |url| in the |
167 // given RedirectList. For example, if we have the redirect list A -> B -> C, | 167 // given RedirectList. For example, if we have the redirect list A -> B -> C, |
168 // then calling this function with url=C would fill redirects with {B, A}. | 168 // then calling this function with url=C would fill redirects with {B, A}. |
169 bool GetMostRecentRedirectsTo(const GURL& url, | 169 bool GetMostRecentRedirectsTo(const GURL& url, |
170 HistoryService::RedirectList* redirects); | 170 history::RedirectList* redirects); |
171 | 171 |
172 // Thumbnails ---------------------------------------------------------------- | 172 // Thumbnails ---------------------------------------------------------------- |
173 | 173 |
174 void SetPageThumbnail(const GURL& url, | 174 void SetPageThumbnail(const GURL& url, |
175 const SkBitmap& thumbnail, | 175 const SkBitmap& thumbnail, |
176 const ThumbnailScore& score); | 176 const ThumbnailScore& score); |
177 | 177 |
178 // Retrieves a thumbnail, passing it across thread boundaries | 178 // Retrieves a thumbnail, passing it across thread boundaries |
179 // via. the included callback. | 179 // via. the included callback. |
180 void GetPageThumbnail(scoped_refptr<GetPageThumbnailRequest> request, | 180 void GetPageThumbnail(scoped_refptr<GetPageThumbnailRequest> request, |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 // subroutine for AddPage only. It also assumes the database is valid. | 303 // subroutine for AddPage only. It also assumes the database is valid. |
304 std::pair<URLID, VisitID> AddPageVisit(const GURL& url, | 304 std::pair<URLID, VisitID> AddPageVisit(const GURL& url, |
305 base::Time time, | 305 base::Time time, |
306 VisitID referring_visit, | 306 VisitID referring_visit, |
307 PageTransition::Type transition); | 307 PageTransition::Type transition); |
308 | 308 |
309 // Returns a redirect chain in |redirects| for the VisitID | 309 // Returns a redirect chain in |redirects| for the VisitID |
310 // |cur_visit|. |cur_visit| is assumed to be valid. Assumes that | 310 // |cur_visit|. |cur_visit| is assumed to be valid. Assumes that |
311 // this HistoryBackend object has been Init()ed successfully. | 311 // this HistoryBackend object has been Init()ed successfully. |
312 void GetRedirectsFromSpecificVisit( | 312 void GetRedirectsFromSpecificVisit( |
313 VisitID cur_visit, HistoryService::RedirectList* redirects); | 313 VisitID cur_visit, history::RedirectList* redirects); |
314 | 314 |
315 // Similar to the above function except returns a redirect list ending | 315 // Similar to the above function except returns a redirect list ending |
316 // at |cur_visit|. | 316 // at |cur_visit|. |
317 void GetRedirectsToSpecificVisit( | 317 void GetRedirectsToSpecificVisit( |
318 VisitID cur_visit, HistoryService::RedirectList* redirects); | 318 VisitID cur_visit, history::RedirectList* redirects); |
319 | 319 |
320 // Thumbnail Helpers --------------------------------------------------------- | 320 // Thumbnail Helpers --------------------------------------------------------- |
321 | 321 |
322 // When a simple GetMostRecentRedirectsFrom() fails, this method is | 322 // When a simple GetMostRecentRedirectsFrom() fails, this method is |
323 // called which searches the last N visit sessions instead of just | 323 // called which searches the last N visit sessions instead of just |
324 // the current one. Returns true and puts thumbnail data in |data| | 324 // the current one. Returns true and puts thumbnail data in |data| |
325 // if a proper thumbnail was found. Returns false otherwise. Assumes | 325 // if a proper thumbnail was found. Returns false otherwise. Assumes |
326 // that this HistoryBackend object has been Init()ed successfully. | 326 // that this HistoryBackend object has been Init()ed successfully. |
327 bool GetThumbnailFromOlderRedirect( | 327 bool GetThumbnailFromOlderRedirect( |
328 const GURL& page_url, std::vector<unsigned char>* data); | 328 const GURL& page_url, std::vector<unsigned char>* data); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 464 |
465 // Maps recent redirect destination pages to the chain of redirects that | 465 // Maps recent redirect destination pages to the chain of redirects that |
466 // brought us to there. Pages that did not have redirects or were not the | 466 // brought us to there. Pages that did not have redirects or were not the |
467 // final redirect in a chain will not be in this list, as well as pages that | 467 // final redirect in a chain will not be in this list, as well as pages that |
468 // redirected "too long" ago (as determined by ExpireOldRedirects above). | 468 // redirected "too long" ago (as determined by ExpireOldRedirects above). |
469 // It is used to set titles & favicons for redirects to that of the | 469 // It is used to set titles & favicons for redirects to that of the |
470 // destination. | 470 // destination. |
471 // | 471 // |
472 // As with AddPage, the last item in the redirect chain will be the | 472 // As with AddPage, the last item in the redirect chain will be the |
473 // destination of the redirect (i.e., the key into recent_redirects_); | 473 // destination of the redirect (i.e., the key into recent_redirects_); |
474 typedef MRUCache<GURL, HistoryService::RedirectList> RedirectCache; | 474 typedef MRUCache<GURL, history::RedirectList> RedirectCache; |
475 RedirectCache recent_redirects_; | 475 RedirectCache recent_redirects_; |
476 | 476 |
477 // Timestamp of the last page addition request. We use this to detect when | 477 // Timestamp of the last page addition request. We use this to detect when |
478 // multiple additions are requested at the same time (within the resolution | 478 // multiple additions are requested at the same time (within the resolution |
479 // of the timer), so we can try to ensure they're unique when they're added | 479 // of the timer), so we can try to ensure they're unique when they're added |
480 // to the database by using the last_recorded_time_ (q.v.). We still can't | 480 // to the database by using the last_recorded_time_ (q.v.). We still can't |
481 // enforce or guarantee uniqueness, since the user might set his clock back. | 481 // enforce or guarantee uniqueness, since the user might set his clock back. |
482 base::Time last_requested_time_; | 482 base::Time last_requested_time_; |
483 | 483 |
484 // Timestamp of the last page addition, as it was recorded in the database. | 484 // Timestamp of the last page addition, as it was recorded in the database. |
(...skipping 30 matching lines...) Expand all Loading... |
515 // Publishes the history to all indexers which are registered to receive | 515 // Publishes the history to all indexers which are registered to receive |
516 // history data from us. Can be NULL if there are no listeners. | 516 // history data from us. Can be NULL if there are no listeners. |
517 scoped_ptr<HistoryPublisher> history_publisher_; | 517 scoped_ptr<HistoryPublisher> history_publisher_; |
518 | 518 |
519 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); | 519 DISALLOW_COPY_AND_ASSIGN(HistoryBackend); |
520 }; | 520 }; |
521 | 521 |
522 } // namespace history | 522 } // namespace history |
523 | 523 |
524 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ | 524 #endif // CHROME_BROWSER_HISTORY_HISTORY_BACKEND_H_ |
OLD | NEW |