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

Side by Side Diff: sql/connection.cc

Issue 89523002: Move Posix file utils to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « extensions/common/extension_resource_unittest.cc ('k') | sql/connection_unittest.cc » ('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 "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 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 } 874 }
875 875
876 // TODO(shess): OS_WIN support? 876 // TODO(shess): OS_WIN support?
877 #if defined(OS_POSIX) 877 #if defined(OS_POSIX)
878 if (restrict_to_user_) { 878 if (restrict_to_user_) {
879 DCHECK_NE(file_name, std::string(":memory")); 879 DCHECK_NE(file_name, std::string(":memory"));
880 base::FilePath file_path(file_name); 880 base::FilePath file_path(file_name);
881 int mode = 0; 881 int mode = 0;
882 // TODO(shess): Arguably, failure to retrieve and change 882 // TODO(shess): Arguably, failure to retrieve and change
883 // permissions should be fatal if the file exists. 883 // permissions should be fatal if the file exists.
884 if (file_util::GetPosixFilePermissions(file_path, &mode)) { 884 if (base::GetPosixFilePermissions(file_path, &mode)) {
885 mode &= file_util::FILE_PERMISSION_USER_MASK; 885 mode &= base::FILE_PERMISSION_USER_MASK;
886 file_util::SetPosixFilePermissions(file_path, mode); 886 base::SetPosixFilePermissions(file_path, mode);
887 887
888 // SQLite sets the permissions on these files from the main 888 // SQLite sets the permissions on these files from the main
889 // database on create. Set them here in case they already exist 889 // database on create. Set them here in case they already exist
890 // at this point. Failure to set these permissions should not 890 // at this point. Failure to set these permissions should not
891 // be fatal unless the file doesn't exist. 891 // be fatal unless the file doesn't exist.
892 base::FilePath journal_path(file_name + FILE_PATH_LITERAL("-journal")); 892 base::FilePath journal_path(file_name + FILE_PATH_LITERAL("-journal"));
893 base::FilePath wal_path(file_name + FILE_PATH_LITERAL("-wal")); 893 base::FilePath wal_path(file_name + FILE_PATH_LITERAL("-wal"));
894 file_util::SetPosixFilePermissions(journal_path, mode); 894 base::SetPosixFilePermissions(journal_path, mode);
895 file_util::SetPosixFilePermissions(wal_path, mode); 895 base::SetPosixFilePermissions(wal_path, mode);
896 } 896 }
897 } 897 }
898 #endif // defined(OS_POSIX) 898 #endif // defined(OS_POSIX)
899 899
900 // SQLite uses a lookaside buffer to improve performance of small mallocs. 900 // SQLite uses a lookaside buffer to improve performance of small mallocs.
901 // Chromium already depends on small mallocs being efficient, so we disable 901 // Chromium already depends on small mallocs being efficient, so we disable
902 // this to avoid the extra memory overhead. 902 // this to avoid the extra memory overhead.
903 // This must be called immediatly after opening the database before any SQL 903 // This must be called immediatly after opening the database before any SQL
904 // statements are run. 904 // statements are run.
905 sqlite3_db_config(db_, SQLITE_DBCONFIG_LOOKASIDE, NULL, 0, 0); 905 sqlite3_db_config(db_, SQLITE_DBCONFIG_LOOKASIDE, NULL, 0, 0);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 } 1079 }
1080 1080
1081 // Best effort to put things back as they were before. 1081 // Best effort to put things back as they were before.
1082 const char kNoWritableSchema[] = "PRAGMA writable_schema = OFF"; 1082 const char kNoWritableSchema[] = "PRAGMA writable_schema = OFF";
1083 ignore_result(Execute(kNoWritableSchema)); 1083 ignore_result(Execute(kNoWritableSchema));
1084 1084
1085 return ret; 1085 return ret;
1086 } 1086 }
1087 1087
1088 } // namespace sql 1088 } // namespace sql
OLDNEW
« no previous file with comments | « extensions/common/extension_resource_unittest.cc ('k') | sql/connection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698