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

Side by Side Diff: components/metrics/drive_metrics_provider_linux.cc

Issue 1254983003: Componentize DriveMetricsProvider* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to review Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/metrics/drive_metrics_provider.h" 5 #include "components/metrics/drive_metrics_provider.h"
6 6
7 #include <linux/kdev_t.h> // For MAJOR()/MINOR(). 7 #include <linux/kdev_t.h> // For MAJOR()/MINOR().
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 #include <string> 9 #include <string>
10 10
11 #include "base/files/file.h" 11 #include "base/files/file.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 15
16 #if defined(OS_CHROMEOS) 16 #if defined(OS_CHROMEOS)
17 #include "base/sys_info.h" 17 #include "base/sys_info.h"
18 #endif 18 #endif
19 19
20 namespace metrics {
21
20 namespace { 22 namespace {
21 23
22 // See http://www.kernel.org/doc/Documentation/devices.txt for more info. 24 // See http://www.kernel.org/doc/Documentation/devices.txt for more info.
23 const int kFirstScsiMajorNumber = 8; 25 const int kFirstScsiMajorNumber = 8;
24 const int kPartitionsPerScsiDevice = 16; 26 const int kPartitionsPerScsiDevice = 16;
25 const char kRotationalFormat[] = "/sys/block/sd%c/queue/rotational"; 27 const char kRotationalFormat[] = "/sys/block/sd%c/queue/rotational";
26 28
27 } // namespace 29 } // namespace
28 30
29 // static 31 // static
(...skipping 21 matching lines...) Expand all
51 53
52 char sdX = 'a' + MINOR(path_stat.st_dev) / kPartitionsPerScsiDevice; 54 char sdX = 'a' + MINOR(path_stat.st_dev) / kPartitionsPerScsiDevice;
53 std::string rotational_path = base::StringPrintf(kRotationalFormat, sdX); 55 std::string rotational_path = base::StringPrintf(kRotationalFormat, sdX);
54 std::string rotates; 56 std::string rotates;
55 if (!base::ReadFileToString(base::FilePath(rotational_path), &rotates)) 57 if (!base::ReadFileToString(base::FilePath(rotational_path), &rotates))
56 return false; 58 return false;
57 59
58 *has_seek_penalty = rotates.substr(0, 1) == "1"; 60 *has_seek_penalty = rotates.substr(0, 1) == "1";
59 return true; 61 return true;
60 } 62 }
63
64 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/drive_metrics_provider_ios.mm ('k') | components/metrics/drive_metrics_provider_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698