OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "webkit/browser/quota/quota_database.h" | 5 #include "webkit/browser/quota/quota_database.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 if (db_) | 433 if (db_) |
434 return true; | 434 return true; |
435 | 435 |
436 // If we tried and failed once, don't try again in the same session | 436 // If we tried and failed once, don't try again in the same session |
437 // to avoid creating an incoherent mess on disk. | 437 // to avoid creating an incoherent mess on disk. |
438 if (is_disabled_) | 438 if (is_disabled_) |
439 return false; | 439 return false; |
440 | 440 |
441 bool in_memory_only = db_file_path_.empty(); | 441 bool in_memory_only = db_file_path_.empty(); |
442 if (!create_if_needed && | 442 if (!create_if_needed && |
443 (in_memory_only || !file_util::PathExists(db_file_path_))) { | 443 (in_memory_only || !base::PathExists(db_file_path_))) { |
444 return false; | 444 return false; |
445 } | 445 } |
446 | 446 |
447 db_.reset(new sql::Connection); | 447 db_.reset(new sql::Connection); |
448 meta_table_.reset(new sql::MetaTable); | 448 meta_table_.reset(new sql::MetaTable); |
449 | 449 |
450 db_->set_histogram_tag("Quota"); | 450 db_->set_histogram_tag("Quota"); |
451 | 451 |
452 bool opened = false; | 452 bool opened = false; |
453 if (in_memory_only) { | 453 if (in_memory_only) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 VLOG(1) << "Failed to execute " << sql; | 545 VLOG(1) << "Failed to execute " << sql; |
546 return false; | 546 return false; |
547 } | 547 } |
548 } | 548 } |
549 | 549 |
550 return transaction.Commit(); | 550 return transaction.Commit(); |
551 } | 551 } |
552 | 552 |
553 bool QuotaDatabase::ResetSchema() { | 553 bool QuotaDatabase::ResetSchema() { |
554 DCHECK(!db_file_path_.empty()); | 554 DCHECK(!db_file_path_.empty()); |
555 DCHECK(file_util::PathExists(db_file_path_)); | 555 DCHECK(base::PathExists(db_file_path_)); |
556 VLOG(1) << "Deleting existing quota data and starting over."; | 556 VLOG(1) << "Deleting existing quota data and starting over."; |
557 | 557 |
558 db_.reset(); | 558 db_.reset(); |
559 meta_table_.reset(); | 559 meta_table_.reset(); |
560 | 560 |
561 if (!sql::Connection::Delete(db_file_path_)) | 561 if (!sql::Connection::Delete(db_file_path_)) |
562 return false; | 562 return false; |
563 | 563 |
564 // So we can't go recursive. | 564 // So we can't go recursive. |
565 if (is_recreating_) | 565 if (is_recreating_) |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 if (lhs.origin < rhs.origin) return true; | 648 if (lhs.origin < rhs.origin) return true; |
649 if (rhs.origin < lhs.origin) return false; | 649 if (rhs.origin < lhs.origin) return false; |
650 if (lhs.type < rhs.type) return true; | 650 if (lhs.type < rhs.type) return true; |
651 if (rhs.type < lhs.type) return false; | 651 if (rhs.type < lhs.type) return false; |
652 if (lhs.used_count < rhs.used_count) return true; | 652 if (lhs.used_count < rhs.used_count) return true; |
653 if (rhs.used_count < lhs.used_count) return false; | 653 if (rhs.used_count < lhs.used_count) return false; |
654 return lhs.last_access_time < rhs.last_access_time; | 654 return lhs.last_access_time < rhs.last_access_time; |
655 } | 655 } |
656 | 656 |
657 } // quota namespace | 657 } // quota namespace |
OLD | NEW |