Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef SQL_CONNECTION_H_ | 5 #ifndef SQL_CONNECTION_H_ |
| 6 #define SQL_CONNECTION_H_ | 6 #define SQL_CONNECTION_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 // error-handling at the end of OnSqliteError(). Expose to allow | 463 // error-handling at the end of OnSqliteError(). Expose to allow |
| 464 // those clients to work appropriately with ScopedErrorIgnorer in | 464 // those clients to work appropriately with ScopedErrorIgnorer in |
| 465 // tests. | 465 // tests. |
| 466 static bool ShouldIgnoreSqliteError(int error); | 466 static bool ShouldIgnoreSqliteError(int error); |
| 467 | 467 |
| 468 // base::trace_event::MemoryDumpProvider implementation. | 468 // base::trace_event::MemoryDumpProvider implementation. |
| 469 bool OnMemoryDump( | 469 bool OnMemoryDump( |
| 470 const base::trace_event::MemoryDumpArgs& args, | 470 const base::trace_event::MemoryDumpArgs& args, |
| 471 base::trace_event::ProcessMemoryDump* process_memory_dump) override; | 471 base::trace_event::ProcessMemoryDump* process_memory_dump) override; |
| 472 | 472 |
| 473 // Helper to determine if it would be appropriate to upload a diagnostic crash | |
| 474 // dump for this database. Returns |false| if a previous dump was uploaded, | |
| 475 // or if the database directory is broken in a way which prevents recording | |
| 476 // the intention to upload (implying that the system is probably broken in a | |
| 477 // way which Chromium cannot address). Should return |true| only once for | |
| 478 // each unique histogram tag. | |
|
pkotwicz
2015/10/15 18:02:30
Nit: In the comment can you mention that calling S
Scott Hess - ex-Googler
2015/10/15 21:12:21
Changed to RegisterIntentToUpload(), with the retu
pkotwicz
2015/10/15 23:31:06
I like this function name better. Thanks for chang
| |
| 479 bool ShouldUploadDiagnosticDump() const; | |
| 480 | |
| 473 private: | 481 private: |
| 474 // For recovery module. | 482 // For recovery module. |
| 475 friend class Recovery; | 483 friend class Recovery; |
| 476 | 484 |
| 477 // Allow test-support code to set/reset error ignorer. | 485 // Allow test-support code to set/reset error ignorer. |
| 478 friend class ScopedErrorIgnorer; | 486 friend class ScopedErrorIgnorer; |
| 479 | 487 |
| 480 // Statement accesses StatementRef which we don't want to expose to everybody | 488 // Statement accesses StatementRef which we don't want to expose to everybody |
| 481 // (they should go through Statement). | 489 // (they should go through Statement). |
| 482 friend class Statement; | 490 friend class Statement; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 497 }; | 505 }; |
| 498 bool OpenInternal(const std::string& file_name, Retry retry_flag); | 506 bool OpenInternal(const std::string& file_name, Retry retry_flag); |
| 499 | 507 |
| 500 // Internal close function used by Close() and RazeAndClose(). | 508 // Internal close function used by Close() and RazeAndClose(). |
| 501 // |forced| indicates that orderly-shutdown checks should not apply. | 509 // |forced| indicates that orderly-shutdown checks should not apply. |
| 502 void CloseInternal(bool forced); | 510 void CloseInternal(bool forced); |
| 503 | 511 |
| 504 // Check whether the current thread is allowed to make IO calls, but only | 512 // Check whether the current thread is allowed to make IO calls, but only |
| 505 // if database wasn't open in memory. Function is inlined to be a no-op in | 513 // if database wasn't open in memory. Function is inlined to be a no-op in |
| 506 // official build. | 514 // official build. |
| 507 void AssertIOAllowed() { | 515 void AssertIOAllowed() const { |
| 508 if (!in_memory_) | 516 if (!in_memory_) |
| 509 base::ThreadRestrictions::AssertIOAllowed(); | 517 base::ThreadRestrictions::AssertIOAllowed(); |
| 510 } | 518 } |
| 511 | 519 |
| 512 // Internal helper for DoesTableExist and DoesIndexExist. | 520 // Internal helper for DoesTableExist and DoesIndexExist. |
| 513 bool DoesTableOrIndexExist(const char* name, const char* type) const; | 521 bool DoesTableOrIndexExist(const char* name, const char* type) const; |
| 514 | 522 |
| 515 // Accessors for global error-ignorer, for injecting behavior during tests. | 523 // Accessors for global error-ignorer, for injecting behavior during tests. |
| 516 // See test/scoped_error_ignorer.h. | 524 // See test/scoped_error_ignorer.h. |
| 517 typedef base::Callback<bool(int)> ErrorIgnorerCallback; | 525 typedef base::Callback<bool(int)> ErrorIgnorerCallback; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 646 base::TimeTicks Now() { | 654 base::TimeTicks Now() { |
| 647 return clock_->Now(); | 655 return clock_->Now(); |
| 648 } | 656 } |
| 649 | 657 |
| 650 // Release page-cache memory if memory-mapped I/O is enabled and the database | 658 // Release page-cache memory if memory-mapped I/O is enabled and the database |
| 651 // was changed. Passing true for |implicit_change_performed| allows | 659 // was changed. Passing true for |implicit_change_performed| allows |
| 652 // overriding the change detection for cases like DDL (CREATE, DROP, etc), | 660 // overriding the change detection for cases like DDL (CREATE, DROP, etc), |
| 653 // which do not participate in the total-rows-changed tracking. | 661 // which do not participate in the total-rows-changed tracking. |
| 654 void ReleaseCacheMemoryIfNeeded(bool implicit_change_performed); | 662 void ReleaseCacheMemoryIfNeeded(bool implicit_change_performed); |
| 655 | 663 |
| 664 // Return the results of sqlite3_db_filename(), which should match the path | |
| 665 // passed to Open(). | |
|
pkotwicz
2015/10/15 18:02:30
Nit: Return -> Returns
Scott Hess - ex-Googler
2015/10/15 21:12:21
Acknowledged. Also moved impl to after ReleaseCac
| |
| 666 base::FilePath DbPath() const; | |
| 667 | |
| 656 // The actual sqlite database. Will be NULL before Init has been called or if | 668 // The actual sqlite database. Will be NULL before Init has been called or if |
| 657 // Init resulted in an error. | 669 // Init resulted in an error. |
| 658 sqlite3* db_; | 670 sqlite3* db_; |
| 659 | 671 |
| 660 // Parameters we'll configure in sqlite before doing anything else. Zero means | 672 // Parameters we'll configure in sqlite before doing anything else. Zero means |
| 661 // use the default value. | 673 // use the default value. |
| 662 int page_size_; | 674 int page_size_; |
| 663 int cache_size_; | 675 int cache_size_; |
| 664 bool exclusive_locking_; | 676 bool exclusive_locking_; |
| 665 bool restrict_to_user_; | 677 bool restrict_to_user_; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 729 // Source for timing information, provided to allow tests to inject time | 741 // Source for timing information, provided to allow tests to inject time |
| 730 // changes. | 742 // changes. |
| 731 scoped_ptr<TimeSource> clock_; | 743 scoped_ptr<TimeSource> clock_; |
| 732 | 744 |
| 733 DISALLOW_COPY_AND_ASSIGN(Connection); | 745 DISALLOW_COPY_AND_ASSIGN(Connection); |
| 734 }; | 746 }; |
| 735 | 747 |
| 736 } // namespace sql | 748 } // namespace sql |
| 737 | 749 |
| 738 #endif // SQL_CONNECTION_H_ | 750 #endif // SQL_CONNECTION_H_ |
| OLD | NEW |