~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/third_party/chromium/src/base/process/memory.h

  • Committer: Vivian
  • Date: 2015-12-04 18:20:11 UTC
  • Revision ID: git-v1:a36f2bc32e884f7473b3a47040e5411306144d7d
* Do not extract psol.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Copyright (c) 2013 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
 
#ifndef BASE_PROCESS_MEMORY_H_
6
 
#define BASE_PROCESS_MEMORY_H_
7
 
 
8
 
#include "base/base_export.h"
9
 
#include "base/basictypes.h"
10
 
#include "base/process/process_handle.h"
11
 
#include "build/build_config.h"
12
 
 
13
 
#if defined(OS_WIN)
14
 
#include <windows.h>
15
 
#endif
16
 
 
17
 
#ifdef PVALLOC_AVAILABLE
18
 
// Build config explicitly tells us whether or not pvalloc is available.
19
 
#elif defined(LIBC_GLIBC) && !defined(USE_TCMALLOC)
20
 
#define PVALLOC_AVAILABLE 1
21
 
#else
22
 
#define PVALLOC_AVAILABLE 0
23
 
#endif
24
 
 
25
 
namespace base {
26
 
 
27
 
// Enables low fragmentation heap (LFH) for every heaps of this process. This
28
 
// won't have any effect on heaps created after this function call. It will not
29
 
// modify data allocated in the heaps before calling this function. So it is
30
 
// better to call this function early in initialization and again before
31
 
// entering the main loop.
32
 
// Note: Returns true on Windows 2000 without doing anything.
33
 
BASE_EXPORT bool EnableLowFragmentationHeap();
34
 
 
35
 
// Enables 'terminate on heap corruption' flag. Helps protect against heap
36
 
// overflow. Has no effect if the OS doesn't provide the necessary facility.
37
 
BASE_EXPORT void EnableTerminationOnHeapCorruption();
38
 
 
39
 
// Turns on process termination if memory runs out.
40
 
BASE_EXPORT void EnableTerminationOnOutOfMemory();
41
 
 
42
 
#if defined(OS_WIN)
43
 
// Returns the module handle to which an address belongs. The reference count
44
 
// of the module is not incremented.
45
 
BASE_EXPORT HMODULE GetModuleFromAddress(void* address);
46
 
#endif
47
 
 
48
 
#if defined(OS_LINUX) || defined(OS_ANDROID)
49
 
BASE_EXPORT extern size_t g_oom_size;
50
 
 
51
 
// The maximum allowed value for the OOM score.
52
 
const int kMaxOomScore = 1000;
53
 
 
54
 
// This adjusts /proc/<pid>/oom_score_adj so the Linux OOM killer will
55
 
// prefer to kill certain process types over others. The range for the
56
 
// adjustment is [-1000, 1000], with [0, 1000] being user accessible.
57
 
// If the Linux system doesn't support the newer oom_score_adj range
58
 
// of [0, 1000], then we revert to using the older oom_adj, and
59
 
// translate the given value into [0, 15].  Some aliasing of values
60
 
// may occur in that case, of course.
61
 
BASE_EXPORT bool AdjustOOMScore(ProcessId process, int score);
62
 
#endif
63
 
 
64
 
#if defined(OS_MACOSX)
65
 
// Very large images or svg canvases can cause huge mallocs.  Skia
66
 
// does tricks on tcmalloc-based systems to allow malloc to fail with
67
 
// a NULL rather than hit the oom crasher.  This replicates that for
68
 
// OSX.
69
 
//
70
 
// IF YOU USE THIS WITHOUT CONSULTING YOUR FRIENDLY OSX DEVELOPER,
71
 
// YOUR CODE IS LIKELY TO BE REVERTED.  THANK YOU.
72
 
BASE_EXPORT void* UncheckedMalloc(size_t size);
73
 
BASE_EXPORT void* UncheckedCalloc(size_t num_items, size_t size);
74
 
#endif  // defined(OS_MACOSX)
75
 
 
76
 
}  // namespace base
77
 
 
78
 
#endif  // BASE_PROCESS_MEMORY_H_