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

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

Issue 319703002: Add mime type information to the download database (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 | « chrome/browser/history/download_database.h ('k') | chrome/browser/history/download_row.h » ('j') | 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 "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.
sky 2014/06/05 16:02:03 Add new types to the end so it's easier to see wha
Fredrik Öhrn 2014/06/05 16:28:25 Moved in patch #2.
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 22 matching lines...) Expand all
320 void DownloadDatabase::QueryDownloads( 353 void DownloadDatabase::QueryDownloads(
321 std::vector<DownloadRow>* results) { 354 std::vector<DownloadRow>* results) {
322 EnsureInProgressEntriesCleanedUp(); 355 EnsureInProgressEntriesCleanedUp();
323 356
324 results->clear(); 357 results->clear();
325 std::set<uint32> ids; 358 std::set<uint32> ids;
326 359
327 std::map<uint32, DownloadRow*> info_map; 360 std::map<uint32, DownloadRow*> info_map;
328 361
329 sql::Statement statement_main(GetDB().GetCachedStatement(SQL_FROM_HERE, 362 sql::Statement statement_main(GetDB().GetCachedStatement(SQL_FROM_HERE,
330 "SELECT id, current_path, target_path, start_time, received_bytes, " 363 "SELECT id, current_path, target_path, "
364 "mime_type, original_mime_type, "
365 "start_time, received_bytes, "
331 "total_bytes, state, danger_type, interrupt_reason, end_time, opened, " 366 "total_bytes, state, danger_type, interrupt_reason, end_time, opened, "
332 "referrer, by_ext_id, by_ext_name, etag, last_modified " 367 "referrer, by_ext_id, by_ext_name, etag, last_modified "
333 "FROM downloads ORDER BY start_time")); 368 "FROM downloads ORDER BY start_time"));
334 369
335 while (statement_main.Step()) { 370 while (statement_main.Step()) {
336 scoped_ptr<DownloadRow> info(new DownloadRow()); 371 scoped_ptr<DownloadRow> info(new DownloadRow());
337 int column = 0; 372 int column = 0;
338 373
339 // SQLITE does not have unsigned integers, so explicitly handle negative 374 // SQLITE does not have unsigned integers, so explicitly handle negative
340 // |id|s instead of casting them to very large uint32s, which would break 375 // |id|s instead of casting them to very large uint32s, which would break
341 // the max(id) logic in GetNextDownloadId(). 376 // the max(id) logic in GetNextDownloadId().
342 int64 signed_id = statement_main.ColumnInt64(column++); 377 int64 signed_id = statement_main.ColumnInt64(column++);
343 info->id = static_cast<uint32>(signed_id); 378 info->id = static_cast<uint32>(signed_id);
344 info->current_path = ColumnFilePath(statement_main, column++); 379 info->current_path = ColumnFilePath(statement_main, column++);
345 info->target_path = ColumnFilePath(statement_main, column++); 380 info->target_path = ColumnFilePath(statement_main, column++);
381 info->mime_type = statement_main.ColumnString(column++);
382 info->original_mime_type = statement_main.ColumnString(column++);
346 info->start_time = base::Time::FromInternalValue( 383 info->start_time = base::Time::FromInternalValue(
347 statement_main.ColumnInt64(column++)); 384 statement_main.ColumnInt64(column++));
348 info->received_bytes = statement_main.ColumnInt64(column++); 385 info->received_bytes = statement_main.ColumnInt64(column++);
349 info->total_bytes = statement_main.ColumnInt64(column++); 386 info->total_bytes = statement_main.ColumnInt64(column++);
350 int state = statement_main.ColumnInt(column++); 387 int state = statement_main.ColumnInt(column++);
351 info->state = IntToState(state); 388 info->state = IntToState(state);
352 if (info->state == DownloadItem::MAX_DOWNLOAD_STATE) 389 if (info->state == DownloadItem::MAX_DOWNLOAD_STATE)
353 UMA_HISTOGRAM_COUNTS("Download.DatabaseInvalidState", state); 390 UMA_HISTOGRAM_COUNTS("Download.DatabaseInvalidState", state);
354 info->danger_type = IntToDangerType(statement_main.ColumnInt(column++)); 391 info->danger_type = IntToDangerType(statement_main.ColumnInt(column++));
355 info->interrupt_reason = static_cast<content::DownloadInterruptReason>( 392 info->interrupt_reason = static_cast<content::DownloadInterruptReason>(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 return false; 493 return false;
457 } 494 }
458 int danger_type = DangerTypeToInt(data.danger_type); 495 int danger_type = DangerTypeToInt(data.danger_type);
459 if (danger_type == kDangerTypeInvalid) { 496 if (danger_type == kDangerTypeInvalid) {
460 NOTREACHED(); 497 NOTREACHED();
461 return false; 498 return false;
462 } 499 }
463 500
464 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, 501 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
465 "UPDATE downloads " 502 "UPDATE downloads "
466 "SET current_path=?, target_path=?, received_bytes=?, state=?, " 503 "SET current_path=?, target_path=?, "
504 "mime_type=?, original_mime_type=?, "
505 "received_bytes=?, state=?, "
467 "danger_type=?, interrupt_reason=?, end_time=?, total_bytes=?, " 506 "danger_type=?, interrupt_reason=?, end_time=?, total_bytes=?, "
468 "opened=?, by_ext_id=?, by_ext_name=?, etag=?, last_modified=? " 507 "opened=?, by_ext_id=?, by_ext_name=?, etag=?, last_modified=? "
469 "WHERE id=?")); 508 "WHERE id=?"));
470 int column = 0; 509 int column = 0;
471 BindFilePath(statement, data.current_path, column++); 510 BindFilePath(statement, data.current_path, column++);
472 BindFilePath(statement, data.target_path, column++); 511 BindFilePath(statement, data.target_path, column++);
512 statement.BindString(column++, data.mime_type);
513 statement.BindString(column++, data.original_mime_type);
473 statement.BindInt64(column++, data.received_bytes); 514 statement.BindInt64(column++, data.received_bytes);
474 statement.BindInt(column++, state); 515 statement.BindInt(column++, state);
475 statement.BindInt(column++, danger_type); 516 statement.BindInt(column++, danger_type);
476 statement.BindInt(column++, static_cast<int>(data.interrupt_reason)); 517 statement.BindInt(column++, static_cast<int>(data.interrupt_reason));
477 statement.BindInt64(column++, data.end_time.ToInternalValue()); 518 statement.BindInt64(column++, data.end_time.ToInternalValue());
478 statement.BindInt64(column++, data.total_bytes); 519 statement.BindInt64(column++, data.total_bytes);
479 statement.BindInt(column++, (data.opened ? 1 : 0)); 520 statement.BindInt(column++, (data.opened ? 1 : 0));
480 statement.BindString(column++, data.by_ext_id); 521 statement.BindString(column++, data.by_ext_id);
481 statement.BindString(column++, data.by_ext_name); 522 statement.BindString(column++, data.by_ext_name);
482 statement.BindString(column++, data.etag); 523 statement.BindString(column++, data.etag);
(...skipping 29 matching lines...) Expand all
512 return false; 553 return false;
513 554
514 int danger_type = DangerTypeToInt(info.danger_type); 555 int danger_type = DangerTypeToInt(info.danger_type);
515 if (danger_type == kDangerTypeInvalid) 556 if (danger_type == kDangerTypeInvalid)
516 return false; 557 return false;
517 558
518 { 559 {
519 sql::Statement statement_insert(GetDB().GetCachedStatement( 560 sql::Statement statement_insert(GetDB().GetCachedStatement(
520 SQL_FROM_HERE, 561 SQL_FROM_HERE,
521 "INSERT INTO downloads " 562 "INSERT INTO downloads "
522 "(id, current_path, target_path, start_time, " 563 "(id, current_path, target_path, "
564 "mime_type, original_mime_type, "
565 "start_time, "
523 " received_bytes, total_bytes, state, danger_type, interrupt_reason, " 566 " received_bytes, total_bytes, state, danger_type, interrupt_reason, "
524 " end_time, opened, referrer, by_ext_id, by_ext_name, etag, " 567 " end_time, opened, referrer, by_ext_id, by_ext_name, etag, "
525 " last_modified) " 568 " last_modified) "
526 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")); 569 "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"));
527 570
528 int column = 0; 571 int column = 0;
529 statement_insert.BindInt(column++, info.id); 572 statement_insert.BindInt(column++, info.id);
530 BindFilePath(statement_insert, info.current_path, column++); 573 BindFilePath(statement_insert, info.current_path, column++);
531 BindFilePath(statement_insert, info.target_path, column++); 574 BindFilePath(statement_insert, info.target_path, column++);
575 statement_insert.BindString(column++, info.mime_type);
576 statement_insert.BindString(column++, info.original_mime_type);
532 statement_insert.BindInt64(column++, info.start_time.ToInternalValue()); 577 statement_insert.BindInt64(column++, info.start_time.ToInternalValue());
533 statement_insert.BindInt64(column++, info.received_bytes); 578 statement_insert.BindInt64(column++, info.received_bytes);
534 statement_insert.BindInt64(column++, info.total_bytes); 579 statement_insert.BindInt64(column++, info.total_bytes);
535 statement_insert.BindInt(column++, state); 580 statement_insert.BindInt(column++, state);
536 statement_insert.BindInt(column++, danger_type); 581 statement_insert.BindInt(column++, danger_type);
537 statement_insert.BindInt(column++, info.interrupt_reason); 582 statement_insert.BindInt(column++, info.interrupt_reason);
538 statement_insert.BindInt64(column++, info.end_time.ToInternalValue()); 583 statement_insert.BindInt64(column++, info.end_time.ToInternalValue());
539 statement_insert.BindInt(column++, info.opened ? 1 : 0); 584 statement_insert.BindInt(column++, info.opened ? 1 : 0);
540 statement_insert.BindString(column++, info.referrer_url.spec()); 585 statement_insert.BindString(column++, info.referrer_url.spec());
541 statement_insert.BindString(column++, info.by_ext_id); 586 statement_insert.BindString(column++, info.by_ext_id);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 size_t DownloadDatabase::CountDownloads() { 662 size_t DownloadDatabase::CountDownloads() {
618 EnsureInProgressEntriesCleanedUp(); 663 EnsureInProgressEntriesCleanedUp();
619 664
620 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, 665 sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE,
621 "SELECT count(*) from downloads")); 666 "SELECT count(*) from downloads"));
622 statement.Step(); 667 statement.Step();
623 return statement.ColumnInt(0); 668 return statement.ColumnInt(0);
624 } 669 }
625 670
626 } // namespace history 671 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/download_database.h ('k') | chrome/browser/history/download_row.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698