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/history/android/favicon_sql_handler.h" | 5 #include "chrome/browser/history/android/favicon_sql_handler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
10 #include "chrome/browser/history/thumbnail_database.h" | 10 #include "chrome/browser/history/thumbnail_database.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 FaviconID favicon_id = 0; | 34 FaviconID favicon_id = 0; |
35 if (!row.favicon().empty()) { | 35 if (!row.favicon().empty()) { |
36 // If the image_data will be updated, it is not reasonable to find if the | 36 // If the image_data will be updated, it is not reasonable to find if the |
37 // icon is already in database, just create a new favicon. | 37 // icon is already in database, just create a new favicon. |
38 favicon_id = thumbnail_db_->AddFavicon(GURL(), history::FAVICON); | 38 favicon_id = thumbnail_db_->AddFavicon(GURL(), history::FAVICON); |
39 if (!favicon_id) | 39 if (!favicon_id) |
40 return false; | 40 return false; |
41 | 41 |
42 scoped_refptr<base::RefCountedMemory> image_data = | 42 scoped_refptr<base::RefCountedMemory> image_data = |
43 new base::RefCountedBytes(row.favicon()); | 43 new base::RefCountedBytes(row.favicon()); |
44 if (!thumbnail_db_->SetFavicon(favicon_id, image_data, Time::Now())) | 44 if (!thumbnail_db_->AddFaviconFrame(favicon_id, image_data, Time::Now())) |
45 return false; | 45 return false; |
46 } | 46 } |
47 | 47 |
48 std::vector<FaviconID> favicon_ids; | 48 std::vector<FaviconID> favicon_ids; |
49 for (TableIDRows::const_iterator i = ids_set.begin(); | 49 for (TableIDRows::const_iterator i = ids_set.begin(); |
50 i != ids_set.end(); ++i) { | 50 i != ids_set.end(); ++i) { |
51 IconMapping icon_mapping; | 51 IconMapping icon_mapping; |
52 if (thumbnail_db_->GetIconMappingForPageURL(i->url, FAVICON, | 52 if (thumbnail_db_->GetIconMappingForPageURL(i->url, FAVICON, |
53 &icon_mapping)) { | 53 &icon_mapping)) { |
54 if (favicon_id) { | 54 if (favicon_id) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 DCHECK(row->is_value_set_explicitly(HistoryAndBookmarkRow::URL)); | 111 DCHECK(row->is_value_set_explicitly(HistoryAndBookmarkRow::URL)); |
112 | 112 |
113 // Is it a problem to give a empty URL? | 113 // Is it a problem to give a empty URL? |
114 FaviconID id = thumbnail_db_->AddFavicon(GURL(), history::FAVICON); | 114 FaviconID id = thumbnail_db_->AddFavicon(GURL(), history::FAVICON); |
115 if (!id) | 115 if (!id) |
116 return false; | 116 return false; |
117 | 117 |
118 scoped_refptr<base::RefCountedMemory> image_data = | 118 scoped_refptr<base::RefCountedMemory> image_data = |
119 new base::RefCountedBytes(row->favicon()); | 119 new base::RefCountedBytes(row->favicon()); |
120 if (!thumbnail_db_->SetFavicon(id, image_data, Time::Now())) | 120 if (!thumbnail_db_->AddFaviconFrame(id, image_data, Time::Now())) |
121 return false; | 121 return false; |
122 return thumbnail_db_->AddIconMapping(row->url(), id); | 122 return thumbnail_db_->AddIconMapping(row->url(), id); |
123 } | 123 } |
124 | 124 |
125 bool FaviconSQLHandler::DeleteUnusedFavicon(const std::vector<FaviconID>& ids) { | 125 bool FaviconSQLHandler::DeleteUnusedFavicon(const std::vector<FaviconID>& ids) { |
126 for (std::vector<FaviconID>::const_iterator i = ids.begin(); i != ids.end(); | 126 for (std::vector<FaviconID>::const_iterator i = ids.begin(); i != ids.end(); |
127 ++i) { | 127 ++i) { |
128 if (!thumbnail_db_->HasMappingFor(*i) && !thumbnail_db_->DeleteFavicon(*i)) | 128 if (!thumbnail_db_->HasMappingFor(*i) && !thumbnail_db_->DeleteFavicon(*i)) |
129 return false; | 129 return false; |
130 } | 130 } |
131 return true; | 131 return true; |
132 } | 132 } |
133 | 133 |
134 } // namespace history. | 134 } // namespace history. |
OLD | NEW |