Chromium Code Reviews| Index: crypto/nss_util.cc |
| =================================================================== |
| --- crypto/nss_util.cc (revision 248111) |
| +++ crypto/nss_util.cc (working copy) |
| @@ -13,10 +13,7 @@ |
| #include <prtime.h> |
| #include <secmod.h> |
| -#if defined(OS_LINUX) |
| -#include <linux/nfs_fs.h> |
| -#include <sys/vfs.h> |
| -#elif defined(OS_OPENBSD) |
| +#if defined(OS_OPENBSD) |
|
wtc
2014/02/04 01:26:02
I would just have OS_OPENBSD use file_util::GetFil
Lei Zhang
2014/02/04 01:34:21
GetFileSystemType is Linux-only right now. I don't
|
| #include <sys/mount.h> |
| #include <sys/param.h> |
| #endif |
| @@ -147,21 +144,25 @@ |
| // Because this function sets an environment variable it must be run before we |
| // go multi-threaded. |
| void UseLocalCacheOfNSSDatabaseIfNFS(const base::FilePath& database_dir) { |
| -#if defined(OS_LINUX) || defined(OS_OPENBSD) |
| - struct statfs buf; |
| - if (statfs(database_dir.value().c_str(), &buf) == 0) { |
| + bool db_on_nfs = false; |
| #if defined(OS_LINUX) |
| - if (buf.f_type == NFS_SUPER_MAGIC) { |
| + file_util::FileSystemType fs_type = file_util::FILE_SYSTEM_UNKNOWN; |
| + if (file_util::GetFileSystemType(database_dir, &fs_type)) |
| + db_on_nfs = (fs_type == file_util::FILE_SYSTEM_NFS); |
| #elif defined(OS_OPENBSD) |
| - if (strcmp(buf.f_fstypename, MOUNT_NFS) == 0) { |
| + struct statfs buf; |
| + if (statfs(database_dir.value().c_str(), &buf) == 0) |
| + db_on_nfs = (strcmp(buf.f_fstypename, MOUNT_NFS) == 0); |
| +#else |
| + NOTIMPLEMENTED(); |
| #endif |
| - scoped_ptr<base::Environment> env(base::Environment::Create()); |
| - const char* use_cache_env_var = "NSS_SDB_USE_CACHE"; |
| - if (!env->HasVar(use_cache_env_var)) |
| - env->SetVar(use_cache_env_var, "yes"); |
| - } |
| + |
| + if (db_on_nfs) { |
| + scoped_ptr<base::Environment> env(base::Environment::Create()); |
| + static const char kUseCacheEnvVar[] = "NSS_SDB_USE_CACHE"; |
| + if (!env->HasVar(kUseCacheEnvVar)) |
| + env->SetVar(kUseCacheEnvVar, "yes"); |
| } |
| -#endif // defined(OS_LINUX) || defined(OS_OPENBSD) |
| } |
| #endif // defined(USE_NSS) |
| @@ -912,7 +913,7 @@ |
| #endif |
| #elif defined(ARCH_CPU_MIPSEL) |
| paths.push_back(base::FilePath("/usr/lib/mipsel-linux-gnu/nss")); |
| -#endif |
| +#endif // defined(ARCH_CPU_X86_64) |
|
wtc
2014/02/04 01:26:02
Nit: I usually omit this kind of comment when the
Lei Zhang
2014/02/04 01:34:21
I added it to line 913 as well. Generally I omit i
|
| // A list of library files to load. |
| std::vector<std::string> libs; |
| @@ -938,7 +939,7 @@ |
| } else { |
| LOG(ERROR) << "Failed to load NSS libraries."; |
| } |
| -#endif |
| +#endif // defined(USE_NSS) |
| } |
| bool CheckNSSVersion(const char* version) { |
| @@ -1063,7 +1064,7 @@ |
| prtime + base::Time::UnixEpoch().ToInternalValue()); |
| } |
| -PRTime BaseTimeToPRTime(base::Time time) { |
| +PRTime BaseTimeToPRTime(const base::Time& time) { |
| return time.ToInternalValue() - base::Time::UnixEpoch().ToInternalValue(); |
| } |