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

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

Issue 289033006: Don't try to access an Isolate when don't have one yet. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« 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 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/content_child_helpers.h" 5 #include "content/child/content_child_helpers.h"
6 6
7 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <malloc.h> 8 #include <malloc.h>
9 #endif 9 #endif
10 10
(...skipping 11 matching lines...) Expand all
22 #if defined(USE_TCMALLOC) 22 #if defined(USE_TCMALLOC)
23 minfo.uordblks 23 minfo.uordblks
24 #else 24 #else
25 (minfo.hblkhd + minfo.arena) 25 (minfo.hblkhd + minfo.arena)
26 #endif 26 #endif
27 >> 10; 27 >> 10;
28 28
29 v8::HeapStatistics stat; 29 v8::HeapStatistics stat;
30 // TODO(svenpanne) The call below doesn't take web workers into account, this 30 // TODO(svenpanne) The call below doesn't take web workers into account, this
31 // has to be done manually by iterating over all Isolates involved. 31 // has to be done manually by iterating over all Isolates involved.
32 v8::Isolate::GetCurrent()->GetHeapStatistics(&stat); 32 v8::Isolate* isolate = v8::Isolate::GetCurrent();
33 if (isolate)
34 isolate->GetHeapStatistics(&stat);
33 return mem_usage + (static_cast<uint64_t>(stat.total_heap_size()) >> 10); 35 return mem_usage + (static_cast<uint64_t>(stat.total_heap_size()) >> 10);
34 } 36 }
35 #elif defined(OS_MACOSX) 37 #elif defined(OS_MACOSX)
36 size_t GetMemoryUsageKB() { 38 size_t GetMemoryUsageKB() {
37 scoped_ptr<base::ProcessMetrics> process_metrics( 39 scoped_ptr<base::ProcessMetrics> process_metrics(
38 // The default port provider is sufficient to get data for the current 40 // The default port provider is sufficient to get data for the current
39 // process. 41 // process.
40 base::ProcessMetrics::CreateProcessMetrics( 42 base::ProcessMetrics::CreateProcessMetrics(
41 base::GetCurrentProcessHandle(), NULL)); 43 base::GetCurrentProcessHandle(), NULL));
42 return process_metrics->GetWorkingSetSize() >> 10; 44 return process_metrics->GetWorkingSetSize() >> 10;
43 } 45 }
44 #else 46 #else
45 size_t GetMemoryUsageKB() { 47 size_t GetMemoryUsageKB() {
46 scoped_ptr<base::ProcessMetrics> process_metrics( 48 scoped_ptr<base::ProcessMetrics> process_metrics(
47 base::ProcessMetrics::CreateProcessMetrics( 49 base::ProcessMetrics::CreateProcessMetrics(
48 base::GetCurrentProcessHandle())); 50 base::GetCurrentProcessHandle()));
49 return process_metrics->GetPagefileUsage() >> 10; 51 return process_metrics->GetPagefileUsage() >> 10;
50 } 52 }
51 #endif 53 #endif
52 54
53 } // namespace content 55 } // namespace content
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