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

Unified Diff: chrome/browser/metrics/drive_metrics_provider_win.cc

Issue 1254983003: Componentize DriveMetricsProvider* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to review Created 5 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/metrics/drive_metrics_provider_unittest.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/drive_metrics_provider_win.cc
diff --git a/chrome/browser/metrics/drive_metrics_provider_win.cc b/chrome/browser/metrics/drive_metrics_provider_win.cc
deleted file mode 100644
index 70cf3228efaf74432e6eed604b2b858557b6f44c..0000000000000000000000000000000000000000
--- a/chrome/browser/metrics/drive_metrics_provider_win.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/metrics/drive_metrics_provider.h"
-
-#include <windows.h>
-#include <ntddscsi.h>
-#include <winioctl.h>
-#include <vector>
-
-#include "base/files/file.h"
-#include "base/files/file_path.h"
-#include "base/macros.h"
-#include "base/strings/stringprintf.h"
-#include "base/win/windows_version.h"
-
-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;
-};
-
-} // namespace
-
-// static
-bool DriveMetricsProvider::HasSeekPenalty(const base::FilePath& path,
- bool* has_seek_penalty) {
- std::vector<base::FilePath::StringType> components;
- path.GetComponents(&components);
-
- int flags = base::File::FLAG_OPEN;
- bool win7_or_higher = base::win::GetVersion() >= base::win::VERSION_WIN7;
- if (!win7_or_higher)
- flags |= base::File::FLAG_READ | base::File::FLAG_WRITE;
-
- base::File volume(base::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;
-}
« no previous file with comments | « chrome/browser/metrics/drive_metrics_provider_unittest.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698