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

Side by Side Diff: components/history/core/browser/thumbnail_database.cc

Issue 1055173003: Remove unused ThumbnailDatabase::UpdateIconMapping() and ThumbnailDatabase::CloneIconMappings() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « components/history/core/browser/thumbnail_database.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/history/core/browser/thumbnail_database.h" 5 #include "components/history/core/browser/thumbnail_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, kSql)); 1028 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, kSql));
1029 statement.BindString(0, URLDatabase::GURLToDatabaseURL(page_url)); 1029 statement.BindString(0, URLDatabase::GURLToDatabaseURL(page_url));
1030 statement.BindInt64(1, icon_id); 1030 statement.BindInt64(1, icon_id);
1031 1031
1032 if (!statement.Run()) 1032 if (!statement.Run())
1033 return 0; 1033 return 0;
1034 1034
1035 return db_.GetLastInsertRowId(); 1035 return db_.GetLastInsertRowId();
1036 } 1036 }
1037 1037
1038 bool ThumbnailDatabase::UpdateIconMapping(IconMappingID mapping_id,
1039 favicon_base::FaviconID icon_id) {
1040 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
1041 "UPDATE icon_mapping SET icon_id=? WHERE id=?"));
1042 statement.BindInt64(0, icon_id);
1043 statement.BindInt64(1, mapping_id);
1044
1045 return statement.Run();
1046 }
1047
1048 bool ThumbnailDatabase::DeleteIconMappings(const GURL& page_url) { 1038 bool ThumbnailDatabase::DeleteIconMappings(const GURL& page_url) {
1049 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, 1039 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
1050 "DELETE FROM icon_mapping WHERE page_url = ?")); 1040 "DELETE FROM icon_mapping WHERE page_url = ?"));
1051 statement.BindString(0, URLDatabase::GURLToDatabaseURL(page_url)); 1041 statement.BindString(0, URLDatabase::GURLToDatabaseURL(page_url));
1052 1042
1053 return statement.Run(); 1043 return statement.Run();
1054 } 1044 }
1055 1045
1056 bool ThumbnailDatabase::DeleteIconMapping(IconMappingID mapping_id) { 1046 bool ThumbnailDatabase::DeleteIconMapping(IconMappingID mapping_id) {
1057 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, 1047 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
1058 "DELETE FROM icon_mapping WHERE id=?")); 1048 "DELETE FROM icon_mapping WHERE id=?"));
1059 statement.BindInt64(0, mapping_id); 1049 statement.BindInt64(0, mapping_id);
1060 1050
1061 return statement.Run(); 1051 return statement.Run();
1062 } 1052 }
1063 1053
1064 bool ThumbnailDatabase::HasMappingFor(favicon_base::FaviconID id) { 1054 bool ThumbnailDatabase::HasMappingFor(favicon_base::FaviconID id) {
1065 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE, 1055 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
1066 "SELECT id FROM icon_mapping " 1056 "SELECT id FROM icon_mapping "
1067 "WHERE icon_id=?")); 1057 "WHERE icon_id=?"));
1068 statement.BindInt64(0, id); 1058 statement.BindInt64(0, id);
1069 1059
1070 return statement.Step(); 1060 return statement.Step();
1071 } 1061 }
1072 1062
1073 bool ThumbnailDatabase::CloneIconMappings(const GURL& old_page_url,
1074 const GURL& new_page_url) {
1075 sql::Statement statement(db_.GetCachedStatement(SQL_FROM_HERE,
1076 "SELECT icon_id FROM icon_mapping "
1077 "WHERE page_url=?"));
1078 if (!statement.is_valid())
1079 return false;
1080
1081 // Do nothing if there are existing bindings
1082 statement.BindString(0, URLDatabase::GURLToDatabaseURL(new_page_url));
1083 if (statement.Step())
1084 return true;
1085
1086 statement.Assign(db_.GetCachedStatement(SQL_FROM_HERE,
1087 "INSERT INTO icon_mapping (page_url, icon_id) "
1088 "SELECT ?, icon_id FROM icon_mapping "
1089 "WHERE page_url = ?"));
1090
1091 statement.BindString(0, URLDatabase::GURLToDatabaseURL(new_page_url));
1092 statement.BindString(1, URLDatabase::GURLToDatabaseURL(old_page_url));
1093 return statement.Run();
1094 }
1095
1096 bool ThumbnailDatabase::InitIconMappingEnumerator( 1063 bool ThumbnailDatabase::InitIconMappingEnumerator(
1097 favicon_base::IconType type, 1064 favicon_base::IconType type,
1098 IconMappingEnumerator* enumerator) { 1065 IconMappingEnumerator* enumerator) {
1099 DCHECK(!enumerator->statement_.is_valid()); 1066 DCHECK(!enumerator->statement_.is_valid());
1100 enumerator->statement_.Assign(db_.GetCachedStatement( 1067 enumerator->statement_.Assign(db_.GetCachedStatement(
1101 SQL_FROM_HERE, 1068 SQL_FROM_HERE,
1102 "SELECT icon_mapping.id, icon_mapping.icon_id, favicons.icon_type, " 1069 "SELECT icon_mapping.id, icon_mapping.icon_id, favicons.icon_type, "
1103 "favicons.url, icon_mapping.page_url " 1070 "favicons.url, icon_mapping.page_url "
1104 "FROM icon_mapping JOIN favicons ON (" 1071 "FROM icon_mapping JOIN favicons ON ("
1105 "icon_mapping.icon_id = favicons.id) " 1072 "icon_mapping.icon_id = favicons.id) "
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 meta_table_.SetVersionNumber(8); 1372 meta_table_.SetVersionNumber(8);
1406 meta_table_.SetCompatibleVersionNumber(std::min(8, kCompatibleVersionNumber)); 1373 meta_table_.SetCompatibleVersionNumber(std::min(8, kCompatibleVersionNumber));
1407 return true; 1374 return true;
1408 } 1375 }
1409 1376
1410 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() { 1377 bool ThumbnailDatabase::IsFaviconDBStructureIncorrect() {
1411 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons"); 1378 return !db_.IsSQLValid("SELECT id, url, icon_type FROM favicons");
1412 } 1379 }
1413 1380
1414 } // namespace history 1381 } // namespace history
OLDNEW
« no previous file with comments | « components/history/core/browser/thumbnail_database.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698