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

Side by Side Diff: chrome/chrome_watcher/system_load_estimator.cc

Issue 2018543002: Fix -Wwritable-strings warnings in kasko code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/chrome_watcher/system_load_estimator.h" 5 #include "chrome/chrome_watcher/system_load_estimator.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/threading/platform_thread.h" 11 #include "base/threading/platform_thread.h"
12 12
13 namespace chrome_watcher { 13 namespace chrome_watcher {
14 namespace { 14 namespace {
15 15
16 using CounterHandle = SystemLoadEstimator::CounterHandle; 16 using CounterHandle = SystemLoadEstimator::CounterHandle;
17 17
18 uint64_t FileTimeToUInt64(FILETIME time) { 18 uint64_t FileTimeToUInt64(FILETIME time) {
19 ULARGE_INTEGER output = {}; 19 ULARGE_INTEGER output = {};
20 output.LowPart = time.dwLowDateTime; 20 output.LowPart = time.dwLowDateTime;
21 output.HighPart = time.dwHighDateTime; 21 output.HighPart = time.dwHighDateTime;
22 return static_cast<uint64_t>(output.QuadPart); 22 return static_cast<uint64_t>(output.QuadPart);
23 } 23 }
24 24
25 CounterHandle AddPdhCounter(PDH_HQUERY query, 25 CounterHandle AddPdhCounter(PDH_HQUERY query,
26 wchar_t* object_name, 26 const wchar_t* object_name,
27 wchar_t* counter_name) { 27 const wchar_t* counter_name) {
28 DCHECK(counter_name); 28 DCHECK(counter_name);
29 29
30 // Get the counter's path. 30 // Get the counter's path.
31 PDH_COUNTER_PATH_ELEMENTS path_elements = { 31 PDH_COUNTER_PATH_ELEMENTS path_elements = {
32 nullptr, object_name, nullptr, nullptr, 0, counter_name}; 32 nullptr, const_cast<LPTSTR>(object_name), nullptr, nullptr,
33 0, const_cast<LPTSTR>(counter_name)};
33 std::unique_ptr<wchar_t[]> counter_path(new wchar_t[PDH_MAX_COUNTER_PATH]); 34 std::unique_ptr<wchar_t[]> counter_path(new wchar_t[PDH_MAX_COUNTER_PATH]);
34 DWORD path_len = PDH_MAX_COUNTER_PATH; 35 DWORD path_len = PDH_MAX_COUNTER_PATH;
35 36
36 PDH_STATUS status = 37 PDH_STATUS status =
37 ::PdhMakeCounterPath(&path_elements, counter_path.get(), &path_len, 0); 38 ::PdhMakeCounterPath(&path_elements, counter_path.get(), &path_len, 0);
38 if (status != ERROR_SUCCESS) 39 if (status != ERROR_SUCCESS)
39 return CounterHandle(); 40 return CounterHandle();
40 41
41 // Add the counter. 42 // Add the counter.
42 HCOUNTER counter_raw = nullptr; 43 HCOUNTER counter_raw = nullptr;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 if (!::GetSystemTimes(&time_idle, &time_kernel, &time_user)) 168 if (!::GetSystemTimes(&time_idle, &time_kernel, &time_user))
168 return false; 169 return false;
169 170
170 // Note: kernel time includes idle time. 171 // Note: kernel time includes idle time.
171 *idle = FileTimeToUInt64(time_idle); 172 *idle = FileTimeToUInt64(time_idle);
172 *total = FileTimeToUInt64(time_kernel) + FileTimeToUInt64(time_user); 173 *total = FileTimeToUInt64(time_kernel) + FileTimeToUInt64(time_user);
173 return true; 174 return true;
174 } 175 }
175 176
176 } // namespace chrome_watcher 177 } // namespace chrome_watcher
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698