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

Side by Side Diff: chrome/browser/history/download_database.cc

Issue 102683004: Add mime type information to the download database (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review fixes Created 7 years 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
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 "chrome/browser/history/download_database.h" 5 #include "chrome/browser/history/download_database.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 20 matching lines...) Expand all
31 31
32 // Reason for dropping a particular record. 32 // Reason for dropping a particular record.
33 enum DroppedReason { 33 enum DroppedReason {
34 DROPPED_REASON_BAD_STATE = 0, 34 DROPPED_REASON_BAD_STATE = 0,
35 DROPPED_REASON_BAD_DANGER_TYPE = 1, 35 DROPPED_REASON_BAD_DANGER_TYPE = 1,
36 DROPPED_REASON_BAD_ID = 2, 36 DROPPED_REASON_BAD_ID = 2,
37 DROPPED_REASON_DUPLICATE_ID = 3, 37 DROPPED_REASON_DUPLICATE_ID = 3,
38 DROPPED_REASON_MAX 38 DROPPED_REASON_MAX
39 }; 39 };
40 40
41 static const char kSchema[] =
42 "CREATE TABLE downloads ("
43 "id INTEGER PRIMARY KEY," // Primary key.
44 "current_path LONGVARCHAR NOT NULL," // Current disk location
45 "target_path LONGVARCHAR NOT NULL," // Final disk location
46 "start_time INTEGER NOT NULL," // When the download was started.
47 "received_bytes INTEGER NOT NULL," // Total size downloaded.
48 "total_bytes INTEGER NOT NULL," // Total size of the download.
49 "state INTEGER NOT NULL," // 1=complete, 4=interrupted
50 "danger_type INTEGER NOT NULL, " // Danger type, validated.
51 "interrupt_reason INTEGER NOT NULL," // content::DownloadInterruptReason
52 "end_time INTEGER NOT NULL," // When the download completed.
53 "opened INTEGER NOT NULL," // 1 if it has ever been opened else 0
54 "referrer VARCHAR NOT NULL," // HTTP Referrer
55 "by_ext_id VARCHAR NOT NULL," // ID of extension that started the
56 // download
57 "by_ext_name VARCHAR NOT NULL," // name of extension
58 "etag VARCHAR NOT NULL," // ETag
59 "last_modified VARCHAR NOT NULL)"; // Last-Modified header
60
61 static const char kUrlChainSchema[] =
62 "CREATE TABLE downloads_url_chains ("
63 "id INTEGER NOT NULL," // downloads.id.
64 "chain_index INTEGER NOT NULL," // Index of url in chain
65 // 0 is initial target,
66 // MAX is target after redirects.
67 "url LONGVARCHAR NOT NULL, " // URL.
68 "PRIMARY KEY (id, chain_index) )";
69
70 #if defined(OS_POSIX) 41 #if defined(OS_POSIX)
71 42
72 // Binds/reads the given file path to the given column of the given statement. 43 // Binds/reads the given file path to the given column of the given statement.
73 void BindFilePath(sql::Statement& statement, const base::FilePath& path, 44 void BindFilePath(sql::Statement& statement, const base::FilePath& path,
74 int col) { 45 int col) {
75 statement.BindString(col, path.value()); 46 statement.BindString(col, path.value());
76 } 47 }
77 base::FilePath ColumnFilePath(sql::Statement& statement, int col) { 48 base::FilePath ColumnFilePath(sql::Statement& statement, int col) {
78 return base::FilePath(statement.ColumnString(col)); 49 return base::FilePath(statement.ColumnString(col));
79 } 50 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 DownloadDatabase::~DownloadDatabase() { 177 DownloadDatabase::~DownloadDatabase() {
207 } 178 }
208 179
209 bool DownloadDatabase::EnsureColumnExists( 180 bool DownloadDatabase::EnsureColumnExists(
210 const std::string& name, const std::string& type) { 181 const std::string& name, const std::string& type) {
211 std::string add_col = "ALTER TABLE downloads ADD COLUMN " + name + " " + type; 182 std::string add_col = "ALTER TABLE downloads ADD COLUMN " + name + " " + type;
212 return GetDB().DoesColumnExist("downloads", name.c_str()) || 183 return GetDB().DoesColumnExist("downloads", name.c_str()) ||
213 GetDB().Execute(add_col.c_str()); 184 GetDB().Execute(add_col.c_str());
214 } 185 }
215 186
187 bool DownloadDatabase::MigrateMimeType() {
188 return EnsureColumnExists("mime_type", "VARCHAR(255) NOT NULL"
189 " DEFAULT \"\"") &&
190 EnsureColumnExists("original_mime_type", "VARCHAR(255) NOT NULL"
191 " DEFAULT \"\"");
192 }
193
216 bool DownloadDatabase::MigrateDownloadsState() { 194 bool DownloadDatabase::MigrateDownloadsState() {
217 sql::Statement statement(GetDB().GetUniqueStatement( 195 sql::Statement statement(GetDB().GetUniqueStatement(
218 "UPDATE downloads SET state=? WHERE state=?")); 196 "UPDATE downloads SET state=? WHERE state=?"));
219 statement.BindInt(0, kStateInterrupted); 197 statement.BindInt(0, kStateInterrupted);
220 statement.BindInt(1, kStateBug140687); 198 statement.BindInt(1, kStateBug140687);
221 return statement.Run(); 199 return statement.Run();
222 } 200 }
223 201
224 bool DownloadDatabase::MigrateDownloadsReasonPathsAndDangerType() { 202 bool DownloadDatabase::MigrateDownloadsReasonPathsAndDangerType() {
225 // We need to rename the table and copy back from it because SQLite 203 // We need to rename the table and copy back from it because SQLite
226 // provides no way to rename or delete a column. 204 // provides no way to rename or delete a column.
227 if (!GetDB().Execute("ALTER TABLE downloads RENAME TO downloads_tmp")) 205 if (!GetDB().Execute("ALTER TABLE downloads RENAME TO downloads_tmp"))
228 return false; 206 return false;
229 207
208 const char kReasonPathDangerSchema[] =
209 "CREATE TABLE downloads ("
210 "id INTEGER PRIMARY KEY,"
211 "current_path LONGVARCHAR NOT NULL,"
212 "target_path LONGVARCHAR NOT NULL,"
213 "start_time INTEGER NOT NULL,"
214 "received_bytes INTEGER NOT NULL,"
215 "total_bytes INTEGER NOT NULL,"
216 "state INTEGER NOT NULL,"
217 "danger_type INTEGER NOT NULL,"
218 "interrupt_reason INTEGER NOT NULL,"
219 "end_time INTEGER NOT NULL,"
220 "opened INTEGER NOT NULL)";
221
222 static const char kReasonPathDangerUrlChainSchema[] =
223 "CREATE TABLE downloads_url_chains ("
224 "id INTEGER NOT NULL," // downloads.id.
225 "chain_index INTEGER NOT NULL," // Index of url in chain
226 // 0 is initial target,
227 // MAX is target after redirects.
228 "url LONGVARCHAR NOT NULL, " // URL.
229 "PRIMARY KEY (id, chain_index) )";
230
231
230 // Recreate main table. 232 // Recreate main table.
231 if (!GetDB().Execute(kSchema)) 233 if (!GetDB().Execute(kReasonPathDangerSchema))
232 return false; 234 return false;
233 235
234 // Populate it. As we do so, we transform the time values from time_t 236 // Populate it. As we do so, we transform the time values from time_t
235 // (seconds since 1/1/1970 UTC), to our internal measure (microseconds 237 // (seconds since 1/1/1970 UTC), to our internal measure (microseconds
236 // since the Windows Epoch). Note that this is dependent on the 238 // since the Windows Epoch). Note that this is dependent on the
237 // internal representation of base::Time and needs to change if that changes. 239 // internal representation of base::Time and needs to change if that changes.
238 sql::Statement statement_populate(GetDB().GetUniqueStatement( 240 sql::Statement statement_populate(GetDB().GetUniqueStatement(
239 "INSERT INTO downloads " 241 "INSERT INTO downloads "
240 "( id, current_path, target_path, start_time, received_bytes, " 242 "( id, current_path, target_path, start_time, received_bytes, "
241 " total_bytes, state, danger_type, interrupt_reason, end_time, opened, " 243 " total_bytes, state, danger_type, interrupt_reason, end_time, opened ) "
242 " referrer, by_ext_id, by_ext_name, etag, last_modified ) "
243 "SELECT id, full_path, full_path, " 244 "SELECT id, full_path, full_path, "
244 " CASE start_time WHEN 0 THEN 0 ELSE " 245 " CASE start_time WHEN 0 THEN 0 ELSE "
245 " (start_time + 11644473600) * 1000000 END, " 246 " (start_time + 11644473600) * 1000000 END, "
246 " received_bytes, total_bytes, " 247 " received_bytes, total_bytes, "
247 " state, ?, ?, " 248 " state, ?, ?, "
248 " CASE end_time WHEN 0 THEN 0 ELSE " 249 " CASE end_time WHEN 0 THEN 0 ELSE "
249 " (end_time + 11644473600) * 1000000 END, " 250 " (end_time + 11644473600) * 1000000 END, "
250 " opened, \"\", \"\", \"\", \"\", \"\" " 251 " opened "
251 "FROM downloads_tmp")); 252 "FROM downloads_tmp"));
252 statement_populate.BindInt(0, content::DOWNLOAD_INTERRUPT_REASON_NONE); 253 statement_populate.BindInt(0, content::DOWNLOAD_INTERRUPT_REASON_NONE);
253 statement_populate.BindInt(1, kDangerTypeNotDangerous); 254 statement_populate.BindInt(1, kDangerTypeNotDangerous);
254 if (!statement_populate.Run()) 255 if (!statement_populate.Run())
255 return false; 256 return false;
256 257
257 // Create new chain table and populate it. 258 // Create new chain table and populate it.
258 if (!GetDB().Execute(kUrlChainSchema)) 259 if (!GetDB().Execute(kReasonPathDangerUrlChainSchema))
259 return false; 260 return false;
260 261
261 if (!GetDB().Execute("INSERT INTO downloads_url_chains " 262 if (!GetDB().Execute("INSERT INTO downloads_url_chains "
262 " ( id, chain_index, url) " 263 " ( id, chain_index, url) "
263 " SELECT id, 0, url from downloads_tmp")) 264 " SELECT id, 0, url from downloads_tmp"))
264 return false; 265 return false;
265 266
266 // Get rid of temporary table. 267 // Get rid of temporary table.
267 if (!GetDB().Execute("DROP TABLE downloads_tmp")) 268 if (!GetDB().Execute("DROP TABLE downloads_tmp"))
268 return false; 269 return false;
269 270
270 return true; 271 return true;
271 } 272 }
272 273
273 bool DownloadDatabase::MigrateReferrer() { 274 bool DownloadDatabase::MigrateReferrer() {
274 return EnsureColumnExists("referrer", "VARCHAR NOT NULL DEFAULT \"\""); 275 return EnsureColumnExists("referrer", "VARCHAR NOT NULL DEFAULT \"\"");
275 } 276 }
276 277
277 bool DownloadDatabase::MigrateDownloadedByExtension() { 278 bool DownloadDatabase::MigrateDownloadedByExtension() {
278 return EnsureColumnExists("by_ext_id", "VARCHAR NOT NULL DEFAULT \"\"") && 279 return EnsureColumnExists("by_ext_id", "VARCHAR NOT NULL DEFAULT \"\"") &&
279 EnsureColumnExists("by_ext_name", "VARCHAR NOT NULL DEFAULT \"\""); 280 EnsureColumnExists("by_ext_name", "VARCHAR NOT NULL DEFAULT \"\"");
280 } 281 }
281 282
282 bool DownloadDatabase::MigrateDownloadValidators() { 283 bool DownloadDatabase::MigrateDownloadValidators() {
283 return EnsureColumnExists("etag", "VARCHAR NOT NULL DEFAULT \"\"") && 284 return EnsureColumnExists("etag", "VARCHAR NOT NULL DEFAULT \"\"") &&
284 EnsureColumnExists("last_modified", "VARCHAR NOT NULL DEFAULT \"\""); 285 EnsureColumnExists("last_modified", "VARCHAR NOT NULL DEFAULT \"\"");
285 } 286 }
286 287
287 bool DownloadDatabase::InitDownloadTable() { 288 bool DownloadDatabase::InitDownloadTable() {
289 const char kSchema[] =
290 "CREATE TABLE downloads ("
291 "id INTEGER PRIMARY KEY," // Primary key.
292 "current_path LONGVARCHAR NOT NULL," // Current disk location
293 "target_path LONGVARCHAR NOT NULL," // Final disk location
294 "mime_type VARCHAR(255) NOT NULL," // Mime type.
295 "original_mime_type VARCHAR(255) NOT NULL," // Original mime type.
296 "start_time INTEGER NOT NULL," // When the download was started.
297 "received_bytes INTEGER NOT NULL," // Total size downloaded.
298 "total_bytes INTEGER NOT NULL," // Total size of the download.
299 "state INTEGER NOT NULL," // 1=complete, 4=interrupted
300 "danger_type INTEGER NOT NULL," // Danger type, validated.
301 "interrupt_reason INTEGER NOT NULL," // content::DownloadInterruptReason
302 "end_time INTEGER NOT NULL," // When the download completed.
303 "opened INTEGER NOT NULL," // 1 if it has ever been opened
304 // else 0
305 "referrer VARCHAR NOT NULL," // HTTP Referrer
306 "by_ext_id VARCHAR NOT NULL," // ID of extension that started the
307 // download
308 "by_ext_name VARCHAR NOT NULL," // name of extension
309 "etag VARCHAR NOT NULL," // ETag
310 "last_modified VARCHAR NOT NULL)"; // Last-Modified header
311
312 const char kUrlChainSchema[] =
313 "CREATE TABLE downloads_url_chains ("
314 "id INTEGER NOT NULL," // downloads.id.
315 "chain_index INTEGER NOT NULL," // Index of url in chain
316 // 0 is initial target,
317 // MAX is target after redirects.
318 "url LONGVARCHAR NOT NULL, " // URL.
319 "PRIMARY KEY (id, chain_index) )";
320
288 if (GetDB().DoesTableExist("downloads")) { 321 if (GetDB().DoesTableExist("downloads")) {
289 return EnsureColumnExists("end_time", "INTEGER NOT NULL DEFAULT 0") && 322 return EnsureColumnExists("end_time", "INTEGER NOT NULL DEFAULT 0") &&
290 EnsureColumnExists("opened", "INTEGER NOT NULL DEFAULT 0"); 323 EnsureColumnExists("opened", "INTEGER NOT NULL DEFAULT 0");
291 } else { 324 } else {
292 // If the "downloads" table doesn't exist, the downloads_url_chain 325 // If the "downloads" table doesn't exist, the downloads_url_chain
293 // table better not. 326 // table better not.
294 return (!GetDB().DoesTableExist("downloads_url_chain") && 327 return (!GetDB().DoesTableExist("downloads_url_chain") &&
295 GetDB().Execute(kSchema) && GetDB().Execute(kUrlChainSchema)); 328 GetDB().Execute(kSchema) && GetDB().Execute(kUrlChainSchema));
296 } 329 }
297 } 330 }
(...skipping 25 matching lines...) Expand all
323 void DownloadDatabase::QueryDownloads( 356 void DownloadDatabase::QueryDownloads(
324 std::vector<DownloadRow>* results) { 357 std::vector<DownloadRow>* results) {
325 EnsureInProgressEntriesCleanedUp(); 358 EnsureInProgressEntriesCleanedUp();
326 359
327 results->clear(); 360 results->clear();
328 std::set<uint32> ids; 361 std::set<uint32> ids;
329 362
330 std::map<uint32, DownloadRow*> info_map; 363 std::map<uint32, DownloadRow*> info_map;
331 364
332 sql::Statement statement_main(GetDB().GetCachedStatement(SQL_FROM_HERE, 365 sql::Statement statement_main(GetDB().GetCachedStatement(SQL_FROM_HERE,
333 "SELECT id, current_path, target_path, start_time, received_bytes, " 366 "SELECT id, current_path, target_path, "
367 "mime_type, original_mime_type, "
368 "start_time, received_bytes, "
334 "total_bytes, state, danger_type, interrupt_reason, end_time, opened, " 369 "total_bytes, state, danger_type, interrupt_reason, end_time, opened, "
335 "referrer, by_ext_id, by_ext_name, etag, last_modified " 370 "referrer, by_ext_id, by_ext_name, etag, last_modified "
336 "FROM downloads ORDER BY start_time")); 371 "FROM downloads ORDER BY start_time"));
337 372
338 while (statement_main.Step()) { 373 while (statement_main.Step()) {
339 scoped_ptr<DownloadRow> info(new DownloadRow()); 374 scoped_ptr<DownloadRow> info(new DownloadRow());
340 int column = 0; 375 int column = 0;
341 376
342 // SQLITE does not have unsigned integers, so explicitly handle negative 377 // SQLITE does not have unsigned integers, so explicitly handle negative
343 // |id|s instead of casting them to very large uint32s, which would break 378 // |id|s instead of casting them to very large uint32s, which would break
344 // the max(id) logic in GetNextDownloadId(). 379 // the max(id) logic in GetNextDownloadId().
345 int64 signed_id = statement_main.ColumnInt64(column++); 380 int64 signed_id = statement_main.ColumnInt64(column++);
346 info->id = static_cast<uint32>(signed_id); 381 info->id = static_cast<uint32>(signed_id);
347 info->current_path = ColumnFilePath(statement_main, column++); 382 info->current_path = ColumnFilePath(statement_main, column++);
348 info->target_path = ColumnFilePath(statement_main, column++); 383 info->target_path = ColumnFilePath(statement_main, column++);
384 info->mime_type = statement_main.ColumnString(column++);
385 info->original_mime_type = statement_main.ColumnString(column++);
349 info->start_time = base::Time::FromInternalValue( 386 info->start_time = base::Time::FromInternalValue(
350 statement_main.ColumnInt64(column++)); 387 statement_main.ColumnInt64(column++));
351 info->received_bytes = statement_main.ColumnInt64(column++); 388 info->received_bytes = statement_main.ColumnInt64(column++);
352 info->total_bytes = statement_main.ColumnInt64(column++); 389 info->total_bytes = statement_main.ColumnInt64(column++);
353 int state = statement_main.ColumnInt(column++); 390 int state = statement_main.ColumnInt(column++);
354 info->state = IntToState(state); 391 info->state = IntToState(state);
355 if (info->state == DownloadItem::MAX_DOWNLOAD_STATE) 392 if (info->state == DownloadItem::MAX_DOWNLOAD_STATE)
356 UMA_HISTOGRAM_COUNTS("Download.DatabaseInvalidState", state); 393 UMA_HISTOGRAM_COUNTS("Download.DatabaseInvalidState", state);
357 info->danger_type = IntToDangerType(statement_main.ColumnInt(column++)); 394 info->danger_type = IntToDangerType(statement_main.ColumnInt(column++));
358 info->interrupt_reason = static_cast<content::DownloadInterruptReason>( 395 info->interrupt_reason = static_cast<content::DownloadInterruptReason>(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 return false; 496 return false;
460 } 497 }
461 int danger_type = DangerTypeToInt(data.danger_type); 498 int danger_type = DangerTypeToInt(data.danger_type);
462 if (danger_type == kDangerTypeInvalid) { 499 if (danger_type == kDangerTypeInvalid) {
463 NOTREACHED(); 500 NOTREACHED();
464 return false; 501 return false;
465 } 502 }
466 503
467 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, 504 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
468 "UPDATE downloads " 505 "UPDATE downloads "
469 "SET current_path=?, target_path=?, received_bytes=?, state=?, " 506 "SET current_path=?, target_path=?, "
507 "mime_type=?, original_mime_type=?, "
508 "received_bytes=?, state=?, "
470 "danger_type=?, interrupt_reason=?, end_time=?, total_bytes=?, " 509 "danger_type=?, interrupt_reason=?, end_time=?, total_bytes=?, "
471 "opened=?, by_ext_id=?, by_ext_name=?, etag=?, last_modified=? " 510 "opened=?, by_ext_id=?, by_ext_name=?, etag=?, last_modified=? "
472 "WHERE id=?")); 511 "WHERE id=?"));
473 int column = 0; 512 int column = 0;
474 BindFilePath(statement, data.current_path, column++); 513 BindFilePath(statement, data.current_path, column++);
475 BindFilePath(statement, data.target_path, column++); 514 BindFilePath(statement, data.target_path, column++);
515 statement.BindString(column++, data.mime_type);
516 statement.BindString(column++, data.original_mime_type);
476 statement.BindInt64(column++, data.received_bytes); 517 statement.BindInt64(column++, data.received_bytes);
477 statement.BindInt(column++, state); 518 statement.BindInt(column++, state);
478 statement.BindInt(column++, danger_type); 519 statement.BindInt(column++, danger_type);
479 statement.BindInt(column++, static_cast<int>(data.interrupt_reason)); 520 statement.BindInt(column++, static_cast<int>(data.interrupt_reason));
480 statement.BindInt64(column++, data.end_time.ToInternalValue()); 521 statement.BindInt64(column++, data.end_time.ToInternalValue());
481 statement.BindInt64(column++, data.total_bytes); 522 statement.BindInt64(column++, data.total_bytes);
482 statement.BindInt(column++, (data.opened ? 1 : 0)); 523 statement.BindInt(column++, (data.opened ? 1 : 0));
483 statement.BindString(column++, data.by_ext_id); 524 statement.BindString(column++, data.by_ext_id);
484 statement.BindString(column++, data.by_ext_name); 525 statement.BindString(column++, data.by_ext_name);
485 statement.BindString(column++, data.etag); 526 statement.BindString(column++, data.etag);
(...skipping 29 matching lines...) Expand all
515 return false; 556 return false;
516 557
517 int danger_type = DangerTypeToInt(info.danger_type); 558 int danger_type = DangerTypeToInt(info.danger_type);
518 if (danger_type == kDangerTypeInvalid) 559 if (danger_type == kDangerTypeInvalid)
519 return false; 560 return false;
520 561
521 { 562 {
522 sql::Statement statement_insert(GetDB().GetCachedStatement( 563 sql::Statement statement_insert(GetDB().GetCachedStatement(
523 SQL_FROM_HERE, 564 SQL_FROM_HERE,
524 "INSERT INTO downloads " 565 "INSERT INTO downloads "
525 "(id, current_path, target_path, start_time, " 566 "(id, current_path, target_path, "
567 "mime_type, original_mime_type, "
568 "start_time, "
526 " received_bytes, total_bytes, state, danger_type, interrupt_reason, " 569 " received_bytes, total_bytes, state, danger_type, interrupt_reason, "
527 " end_time, opened, referrer, by_ext_id, by_ext_name, etag, " 570 " end_time, opened, referrer, by_ext_id, by_ext_name, etag, "
528 " last_modified) " 571 " last_modified) "
529 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")); 572 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"));
530 573
531 int column = 0; 574 int column = 0;
532 statement_insert.BindInt(column++, info.id); 575 statement_insert.BindInt(column++, info.id);
533 BindFilePath(statement_insert, info.current_path, column++); 576 BindFilePath(statement_insert, info.current_path, column++);
534 BindFilePath(statement_insert, info.target_path, column++); 577 BindFilePath(statement_insert, info.target_path, column++);
578 statement_insert.BindString(column++, info.mime_type);
579 statement_insert.BindString(column++, info.original_mime_type);
535 statement_insert.BindInt64(column++, info.start_time.ToInternalValue()); 580 statement_insert.BindInt64(column++, info.start_time.ToInternalValue());
536 statement_insert.BindInt64(column++, info.received_bytes); 581 statement_insert.BindInt64(column++, info.received_bytes);
537 statement_insert.BindInt64(column++, info.total_bytes); 582 statement_insert.BindInt64(column++, info.total_bytes);
538 statement_insert.BindInt(column++, state); 583 statement_insert.BindInt(column++, state);
539 statement_insert.BindInt(column++, danger_type); 584 statement_insert.BindInt(column++, danger_type);
540 statement_insert.BindInt(column++, info.interrupt_reason); 585 statement_insert.BindInt(column++, info.interrupt_reason);
541 statement_insert.BindInt64(column++, info.end_time.ToInternalValue()); 586 statement_insert.BindInt64(column++, info.end_time.ToInternalValue());
542 statement_insert.BindInt(column++, info.opened ? 1 : 0); 587 statement_insert.BindInt(column++, info.opened ? 1 : 0);
543 statement_insert.BindString(column++, info.referrer_url.spec()); 588 statement_insert.BindString(column++, info.referrer_url.spec());
544 statement_insert.BindString(column++, info.by_ext_id); 589 statement_insert.BindString(column++, info.by_ext_id);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 size_t DownloadDatabase::CountDownloads() { 665 size_t DownloadDatabase::CountDownloads() {
621 EnsureInProgressEntriesCleanedUp(); 666 EnsureInProgressEntriesCleanedUp();
622 667
623 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, 668 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
624 "SELECT count(*) from downloads")); 669 "SELECT count(*) from downloads"));
625 statement.Step(); 670 statement.Step();
626 return statement.ColumnInt(0); 671 return statement.ColumnInt(0);
627 } 672 }
628 673
629 } // namespace history 674 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698