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

Side by Side Diff: webkit/glue/dalvik_heap_size_android.cc

Issue 10113009: Set Android/V8 memory limits from dalvik.vm.heapsize. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "webkit/glue/dalvik_heap_size_android.h"
6
7 #include "base/memory/singleton.h"
8
9 namespace webkit_glue {
10
11 DalvikHeapSize* DalvikHeapSize::GetInstance() {
12 return Singleton<DalvikHeapSize>::get();
13 }
14
tonyg 2012/04/19 16:04:30 Just one blank line between methods.
ulan 2012/04/19 17:46:24 Done.
15
16 DalvikHeapSize::DalvikHeapSize() : heap_size_mb_(0) {
17 char heap_size_str[PROP_VALUE_MAX];
18 __system_property_get("dalvik.vm.heapsize", heap_size_str);
19 heap_size_mb_ = ParseHeapSize(std::string(heap_size_str));
20 }
21
22
23 DalvikHeapSize::~DalvikHeapSize() {}
24
25
26 int DalvikHeapSize::HeapSizeMB() { return heap_size_mb_; }
27
28
29 int DalvikHeapSize::ParseHeapSize(const std::string& str) {
30 CHECK_GT(str.size(), 0u);
31 DCHECK_EQ('m', str[str.size() - 1]);
32 int result = 0;
33 base::StringToInt(str.substr(0, str.size() - 1), &result);
34 DCHECK_GT(result, 0);
35 // dalvik.vm.heapsize property is writable by user,
36 // truncate it to reasonable value to avoid overflows later.
37 return std::min(std::max(32, result), 1024);
38 }
39
40 } // webkit_glue namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698