diff options
author | dbeam <dbeam@chromium.org> | 2015-04-02 10:24:47 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-02 17:25:21 +0000 |
commit | 005649e4ef576270314678ca7c2aab55e557ee35 (patch) | |
tree | d88c1ecc111fe971b7ab2e482062539cfbf029cc /base/sys_info_win.cc | |
parent | 58e913aa2a031aab0d082d3380c49e1b5881eba4 (diff) | |
download | chromium_src-005649e4ef576270314678ca7c2aab55e557ee35.zip chromium_src-005649e4ef576270314678ca7c2aab55e557ee35.tar.gz chromium_src-005649e4ef576270314678ca7c2aab55e557ee35.tar.bz2 |
Move HasSeekPenalty() out of base::SysInfo and base/.
It's only called from one place, so move it there:
- chrome/browser/metrics/drive_metrics_provider.cc
R=rvargas@chromium.org,asvitkine@chromium.org
BUG=463209
Review URL: https://codereview.chromium.org/1051663002
Cr-Commit-Position: refs/heads/master@{#323526}
Diffstat (limited to 'base/sys_info_win.cc')
-rw-r--r-- | base/sys_info_win.cc | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/base/sys_info_win.cc b/base/sys_info_win.cc index eccb6ac..c8314c7 100644 --- a/base/sys_info_win.cc +++ b/base/sys_info_win.cc @@ -4,14 +4,10 @@ #include "base/sys_info.h" -#include <ntddscsi.h> #include <windows.h> -#include <winioctl.h> -#include "base/files/file.h" #include "base/files/file_path.h" #include "base/logging.h" -#include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/strings/stringprintf.h" #include "base/threading/thread_restrictions.h" @@ -19,19 +15,6 @@ namespace { -// Semi-copy of similarly named struct from ata.h in WinDDK. -struct IDENTIFY_DEVICE_DATA { - USHORT UnusedWords[217]; - USHORT NominalMediaRotationRate; - USHORT MoreUnusedWords[38]; -}; -COMPILE_ASSERT(sizeof(IDENTIFY_DEVICE_DATA) == 512, IdentifyDeviceDataSize); - -struct AtaRequest { - ATA_PASS_THROUGH_EX query; - IDENTIFY_DEVICE_DATA result; -}; - int64 AmountOfMemory(DWORDLONG MEMORYSTATUSEX::* memory_field) { MEMORYSTATUSEX memory_info; memory_info.dwLength = sizeof(memory_info); @@ -80,67 +63,6 @@ int64 SysInfo::AmountOfFreeDiskSpace(const FilePath& path) { return rv < 0 ? kint64max : rv; } -bool SysInfo::HasSeekPenalty(const FilePath& path, bool* has_seek_penalty) { - ThreadRestrictions::AssertIOAllowed(); - - DCHECK(path.IsAbsolute()); - DCHECK(has_seek_penalty); - - std::vector<FilePath::StringType> components; - path.GetComponents(&components); - - int flags = File::FLAG_OPEN; - const bool win7_or_higher = win::GetVersion() >= win::VERSION_WIN7; - if (!win7_or_higher) - flags |= File::FLAG_READ | File::FLAG_WRITE; - - File volume(FilePath(L"\\\\.\\" + components[0]), flags); - if (!volume.IsValid()) - return false; - - if (win7_or_higher) { - STORAGE_PROPERTY_QUERY query = {}; - query.QueryType = PropertyStandardQuery; - query.PropertyId = StorageDeviceSeekPenaltyProperty; - - DEVICE_SEEK_PENALTY_DESCRIPTOR result; - DWORD bytes_returned; - BOOL success = DeviceIoControl(volume.GetPlatformFile(), - IOCTL_STORAGE_QUERY_PROPERTY, - &query, sizeof(query), - &result, sizeof(result), - &bytes_returned, NULL); - if (success == FALSE || bytes_returned < sizeof(result)) - return false; - - *has_seek_penalty = result.IncursSeekPenalty != FALSE; - } else { - AtaRequest request = {}; - request.query.AtaFlags = ATA_FLAGS_DATA_IN; - request.query.CurrentTaskFile[6] = ID_CMD; - request.query.DataBufferOffset = sizeof(request.query); - request.query.DataTransferLength = sizeof(request.result); - request.query.Length = sizeof(request.query); - request.query.TimeOutValue = 10; - - DWORD bytes_returned; - BOOL success = DeviceIoControl(volume.GetPlatformFile(), - IOCTL_ATA_PASS_THROUGH, - &request, sizeof(request), - &request, sizeof(request), - &bytes_returned, NULL); - if (success == FALSE || bytes_returned < sizeof(request) || - request.query.CurrentTaskFile[0]) { - return false; - } - - *has_seek_penalty = request.result.NominalMediaRotationRate != 1; - } - - return true; -} - -// static std::string SysInfo::OperatingSystemName() { return "Windows NT"; } |