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

Side by Side Diff: content/child/blink_platform_impl.cc

Issue 1433603004: Add ProcessMetrics::CreateCurrentProcessMetrics() method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a_counter_with_ts
Patch Set: Lei Zhang comments #3 (use CreateCurrentProcessMetrics where relevant, nits, comments) Created 5 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/child/blink_platform_impl.h" 5 #include "content/child/blink_platform_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 return false; 1208 return false;
1209 } 1209 }
1210 1210
1211 blink::WebString BlinkPlatformImpl::signedPublicKeyAndChallengeString( 1211 blink::WebString BlinkPlatformImpl::signedPublicKeyAndChallengeString(
1212 unsigned key_size_index, 1212 unsigned key_size_index,
1213 const blink::WebString& challenge, 1213 const blink::WebString& challenge,
1214 const blink::WebURL& url) { 1214 const blink::WebURL& url) {
1215 return blink::WebString(""); 1215 return blink::WebString("");
1216 } 1216 }
1217 1217
1218 static scoped_ptr<base::ProcessMetrics> CurrentProcessMetrics() {
1219 using base::ProcessMetrics;
1220 #if defined(OS_MACOSX)
1221 return scoped_ptr<ProcessMetrics>(
1222 // The default port provider is sufficient to get data for the current
1223 // process.
1224 ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle(),
1225 NULL));
1226 #else
1227 return scoped_ptr<ProcessMetrics>(
1228 ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle()));
1229 #endif
1230 }
1231
1232 static size_t getMemoryUsageMB(bool bypass_cache) { 1218 static size_t getMemoryUsageMB(bool bypass_cache) {
1233 size_t current_mem_usage = 0; 1219 size_t current_mem_usage = 0;
1234 MemoryUsageCache* mem_usage_cache_singleton = MemoryUsageCache::GetInstance(); 1220 MemoryUsageCache* mem_usage_cache_singleton = MemoryUsageCache::GetInstance();
1235 if (!bypass_cache && 1221 if (!bypass_cache &&
1236 mem_usage_cache_singleton->IsCachedValueValid(&current_mem_usage)) 1222 mem_usage_cache_singleton->IsCachedValueValid(&current_mem_usage))
1237 return current_mem_usage; 1223 return current_mem_usage;
1238 1224
1239 current_mem_usage = GetMemoryUsageKB() >> 10; 1225 current_mem_usage = GetMemoryUsageKB() >> 10;
1240 mem_usage_cache_singleton->SetMemoryValue(current_mem_usage); 1226 mem_usage_cache_singleton->SetMemoryValue(current_mem_usage);
1241 return current_mem_usage; 1227 return current_mem_usage;
(...skipping 19 matching lines...) Expand all
1261 return base::SysInfo::IsLowEndDevice(); 1247 return base::SysInfo::IsLowEndDevice();
1262 } 1248 }
1263 1249
1264 size_t BlinkPlatformImpl::numberOfProcessors() { 1250 size_t BlinkPlatformImpl::numberOfProcessors() {
1265 return static_cast<size_t>(base::SysInfo::NumberOfProcessors()); 1251 return static_cast<size_t>(base::SysInfo::NumberOfProcessors());
1266 } 1252 }
1267 1253
1268 bool BlinkPlatformImpl::processMemorySizesInBytes( 1254 bool BlinkPlatformImpl::processMemorySizesInBytes(
1269 size_t* private_bytes, 1255 size_t* private_bytes,
1270 size_t* shared_bytes) { 1256 size_t* shared_bytes) {
1271 return CurrentProcessMetrics()->GetMemoryBytes(private_bytes, shared_bytes); 1257 using base::ProcessMetrics;
Lei Zhang 2015/11/10 22:02:29 meh, you can omit this line and add base:: below.
fdoray 2015/11/11 22:04:38 Done.
1258 scoped_ptr<CurrentProcessMetrics> current_process_metrics(
1259 ProcessMetrics::CreateCurrentProcessMetrics());
1260 return current_process_metrics->GetMemoryBytes(private_bytes, shared_bytes);
1272 } 1261 }
1273 1262
1274 bool BlinkPlatformImpl::memoryAllocatorWasteInBytes(size_t* size) { 1263 bool BlinkPlatformImpl::memoryAllocatorWasteInBytes(size_t* size) {
1275 return base::allocator::GetAllocatorWasteSize(size); 1264 return base::allocator::GetAllocatorWasteSize(size);
1276 } 1265 }
1277 1266
1278 blink::WebDiscardableMemory* 1267 blink::WebDiscardableMemory*
1279 BlinkPlatformImpl::allocateAndLockDiscardableMemory(size_t bytes) { 1268 BlinkPlatformImpl::allocateAndLockDiscardableMemory(size_t bytes) {
1280 return content::WebDiscardableMemoryImpl::CreateLockedMemory(bytes).release(); 1269 return content::WebDiscardableMemoryImpl::CreateLockedMemory(bytes).release();
1281 } 1270 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString( 1314 return WebString::fromUTF8(ui::KeycodeConverter::DomKeyToKeyString(
1326 static_cast<ui::DomKey>(dom_key))); 1315 static_cast<ui::DomKey>(dom_key)));
1327 } 1316 }
1328 1317
1329 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) { 1318 int BlinkPlatformImpl::domKeyEnumFromString(const WebString& key_string) {
1330 return static_cast<int>( 1319 return static_cast<int>(
1331 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8())); 1320 ui::KeycodeConverter::KeyStringToDomKey(key_string.utf8()));
1332 } 1321 }
1333 1322
1334 } // namespace content 1323 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698