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

Side by Side Diff: chrome/browser/importer/safari_importer.mm

Issue 9365030: More SQL statement usage regularization. Back-touch some (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix log messages Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <Cocoa/Cocoa.h> 5 #include <Cocoa/Cocoa.h>
6 6
7 #include "chrome/browser/importer/safari_importer.h" 7 #include "chrome/browser/importer/safari_importer.h"
8 8
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 stringByAppendingPathComponent:@"WebpageIcons.db"]; 135 stringByAppendingPathComponent:@"WebpageIcons.db"];
136 136
137 const char* db_path = [favicons_db_path fileSystemRepresentation]; 137 const char* db_path = [favicons_db_path fileSystemRepresentation];
138 return db->Open(FilePath(db_path)); 138 return db->Open(FilePath(db_path));
139 } 139 }
140 140
141 void SafariImporter::ImportFaviconURLs(sql::Connection* db, 141 void SafariImporter::ImportFaviconURLs(sql::Connection* db,
142 FaviconMap* favicon_map) { 142 FaviconMap* favicon_map) {
143 const char* query = "SELECT iconID, url FROM PageURL;"; 143 const char* query = "SELECT iconID, url FROM PageURL;";
144 sql::Statement s(db->GetUniqueStatement(query)); 144 sql::Statement s(db->GetUniqueStatement(query));
145 if (!s)
146 return;
147 145
148 while (s.Step() && !cancelled()) { 146 while (s.Step() && !cancelled()) {
149 int64 icon_id = s.ColumnInt64(0); 147 int64 icon_id = s.ColumnInt64(0);
150 GURL url = GURL(s.ColumnString(1)); 148 GURL url = GURL(s.ColumnString(1));
151 (*favicon_map)[icon_id].insert(url); 149 (*favicon_map)[icon_id].insert(url);
152 } 150 }
153 } 151 }
154 152
155 void SafariImporter::LoadFaviconData( 153 void SafariImporter::LoadFaviconData(
156 sql::Connection* db, 154 sql::Connection* db,
157 const FaviconMap& favicon_map, 155 const FaviconMap& favicon_map,
158 std::vector<history::ImportedFaviconUsage>* favicons) { 156 std::vector<history::ImportedFaviconUsage>* favicons) {
159 const char* query = "SELECT i.url, d.data " 157 const char* query = "SELECT i.url, d.data "
160 "FROM IconInfo i JOIN IconData d " 158 "FROM IconInfo i JOIN IconData d "
161 "ON i.iconID = d.iconID " 159 "ON i.iconID = d.iconID "
162 "WHERE i.iconID = ?;"; 160 "WHERE i.iconID = ?;";
163 sql::Statement s(db->GetUniqueStatement(query)); 161 sql::Statement s(db->GetUniqueStatement(query));
164 if (!s)
165 return;
166 162
167 for (FaviconMap::const_iterator i = favicon_map.begin(); 163 for (FaviconMap::const_iterator i = favicon_map.begin();
168 i != favicon_map.end(); ++i) { 164 i != favicon_map.end(); ++i) {
169 s.Reset(); 165 s.Reset();
170 s.BindInt64(0, i->first); 166 s.BindInt64(0, i->first);
171 if (s.Step()) { 167 if (s.Step()) {
172 history::ImportedFaviconUsage usage; 168 history::ImportedFaviconUsage usage;
173 169
174 usage.favicon_url = GURL(s.ColumnString(0)); 170 usage.favicon_url = GURL(s.ColumnString(0));
175 if (!usage.favicon_url.is_valid()) 171 if (!usage.favicon_url.is_valid())
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 if (!last_visit_str) 390 if (!last_visit_str)
395 continue; 391 continue;
396 392
397 // Convert Safari's last visit time to Unix Epoch time. 393 // Convert Safari's last visit time to Unix Epoch time.
398 double seconds_since_unix_epoch = HistoryTimeToEpochTime(last_visit_str); 394 double seconds_since_unix_epoch = HistoryTimeToEpochTime(last_visit_str);
399 row.set_last_visit(base::Time::FromDoubleT(seconds_since_unix_epoch)); 395 row.set_last_visit(base::Time::FromDoubleT(seconds_since_unix_epoch));
400 396
401 history_items->push_back(row); 397 history_items->push_back(row);
402 } 398 }
403 } 399 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698