OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/thumbnails/thumbnail_service_impl.h" | 5 #include "chrome/browser/thumbnails/thumbnail_service_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "chrome/browser/history/history_service.h" | 10 #include "chrome/browser/history/history_service.h" |
droger
2015/03/03 18:56:53
Can you remove this include?
| |
11 #include "chrome/browser/history/history_utils.h" | |
11 #include "chrome/browser/history/top_sites_factory.h" | 12 #include "chrome/browser/history/top_sites_factory.h" |
12 #include "chrome/browser/thumbnails/content_based_thumbnailing_algorithm.h" | 13 #include "chrome/browser/thumbnails/content_based_thumbnailing_algorithm.h" |
13 #include "chrome/browser/thumbnails/simple_thumbnail_crop.h" | 14 #include "chrome/browser/thumbnails/simple_thumbnail_crop.h" |
14 #include "chrome/browser/thumbnails/thumbnailing_context.h" | 15 #include "chrome/browser/thumbnails/thumbnailing_context.h" |
15 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
16 #include "components/search/search.h" | 17 #include "components/search/search.h" |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
19 | 20 |
20 using content::BrowserThread; | 21 using content::BrowserThread; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 return new SimpleThumbnailCrop(thumbnail_size); | 93 return new SimpleThumbnailCrop(thumbnail_size); |
93 } | 94 } |
94 | 95 |
95 bool ThumbnailServiceImpl::ShouldAcquirePageThumbnail(const GURL& url) { | 96 bool ThumbnailServiceImpl::ShouldAcquirePageThumbnail(const GURL& url) { |
96 scoped_refptr<history::TopSites> local_ptr(top_sites_); | 97 scoped_refptr<history::TopSites> local_ptr(top_sites_); |
97 | 98 |
98 if (!local_ptr) | 99 if (!local_ptr) |
99 return false; | 100 return false; |
100 | 101 |
101 // Skip if the given URL is not appropriate for history. | 102 // Skip if the given URL is not appropriate for history. |
102 if (!HistoryService::CanAddURL(url)) | 103 if (!CanAddURLToHistory(url)) |
103 return false; | 104 return false; |
104 // Skip if the top sites list is full, and the URL is not known. | 105 // Skip if the top sites list is full, and the URL is not known. |
105 if (local_ptr->IsNonForcedFull() && !local_ptr->IsKnownURL(url)) | 106 if (local_ptr->IsNonForcedFull() && !local_ptr->IsKnownURL(url)) |
106 return false; | 107 return false; |
107 // Skip if we don't have to udpate the existing thumbnail. | 108 // Skip if we don't have to udpate the existing thumbnail. |
108 ThumbnailScore current_score; | 109 ThumbnailScore current_score; |
109 if (local_ptr->GetPageThumbnailScore(url, ¤t_score) && | 110 if (local_ptr->GetPageThumbnailScore(url, ¤t_score) && |
110 !current_score.ShouldConsiderUpdating()) | 111 !current_score.ShouldConsiderUpdating()) |
111 return false; | 112 return false; |
112 // Skip if we don't have to udpate the temporary thumbnail (i.e. the one | 113 // Skip if we don't have to udpate the temporary thumbnail (i.e. the one |
113 // not yet saved). | 114 // not yet saved). |
114 ThumbnailScore temporary_score; | 115 ThumbnailScore temporary_score; |
115 if (local_ptr->GetTemporaryPageThumbnailScore(url, &temporary_score) && | 116 if (local_ptr->GetTemporaryPageThumbnailScore(url, &temporary_score) && |
116 !temporary_score.ShouldConsiderUpdating()) | 117 !temporary_score.ShouldConsiderUpdating()) |
117 return false; | 118 return false; |
118 | 119 |
119 return true; | 120 return true; |
120 } | 121 } |
121 | 122 |
122 void ThumbnailServiceImpl::ShutdownOnUIThread() { | 123 void ThumbnailServiceImpl::ShutdownOnUIThread() { |
123 // Since each call uses its own scoped_refptr, we can just clear the reference | 124 // Since each call uses its own scoped_refptr, we can just clear the reference |
124 // here by assigning null. If another call is completed, it added its own | 125 // here by assigning null. If another call is completed, it added its own |
125 // reference. | 126 // reference. |
126 top_sites_ = NULL; | 127 top_sites_ = NULL; |
127 } | 128 } |
128 | 129 |
129 } // namespace thumbnails | 130 } // namespace thumbnails |
OLD | NEW |