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 #include "sql/connection.h" | 5 #include "sql/connection.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 // junk to prevent other processes from opening it successfully (like | 387 // junk to prevent other processes from opening it successfully (like |
388 // Gears "SQLite poison 3" trick). | 388 // Gears "SQLite poison 3" trick). |
389 // | 389 // |
390 // static | 390 // static |
391 bool Connection::Delete(const base::FilePath& path) { | 391 bool Connection::Delete(const base::FilePath& path) { |
392 base::ThreadRestrictions::AssertIOAllowed(); | 392 base::ThreadRestrictions::AssertIOAllowed(); |
393 | 393 |
394 base::FilePath journal_path(path.value() + FILE_PATH_LITERAL("-journal")); | 394 base::FilePath journal_path(path.value() + FILE_PATH_LITERAL("-journal")); |
395 base::FilePath wal_path(path.value() + FILE_PATH_LITERAL("-wal")); | 395 base::FilePath wal_path(path.value() + FILE_PATH_LITERAL("-wal")); |
396 | 396 |
397 file_util::Delete(journal_path, false); | 397 base::Delete(journal_path, false); |
398 file_util::Delete(wal_path, false); | 398 base::Delete(wal_path, false); |
399 file_util::Delete(path, false); | 399 base::Delete(path, false); |
400 | 400 |
401 return !file_util::PathExists(journal_path) && | 401 return !file_util::PathExists(journal_path) && |
402 !file_util::PathExists(wal_path) && | 402 !file_util::PathExists(wal_path) && |
403 !file_util::PathExists(path); | 403 !file_util::PathExists(path); |
404 } | 404 } |
405 | 405 |
406 bool Connection::BeginTransaction() { | 406 bool Connection::BeginTransaction() { |
407 if (needs_rollback_) { | 407 if (needs_rollback_) { |
408 DCHECK_GT(transaction_nesting_, 0); | 408 DCHECK_GT(transaction_nesting_, 0); |
409 | 409 |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 } | 840 } |
841 | 841 |
842 // Best effort to put things back as they were before. | 842 // Best effort to put things back as they were before. |
843 const char kNoWritableSchema[] = "PRAGMA writable_schema = OFF"; | 843 const char kNoWritableSchema[] = "PRAGMA writable_schema = OFF"; |
844 ignore_result(Execute(kNoWritableSchema)); | 844 ignore_result(Execute(kNoWritableSchema)); |
845 | 845 |
846 return ret; | 846 return ret; |
847 } | 847 } |
848 | 848 |
849 } // namespace sql | 849 } // namespace sql |
OLD | NEW |