OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // This file declares a raw symbol and should be included only once in a | 5 // This file declares a raw symbol and should be included only once in a |
6 // certain binary target. This needs to be run before we raise the sandbox, | 6 // certain binary target. This needs to be run before we raise the sandbox, |
7 // which means that it can't use mojo. Our runners will dig around in the | 7 // which means that it can't use mojo. Our runners will dig around in the |
8 // symbol table and run this before the mojo system is initialized. | 8 // symbol table and run this before the mojo system is initialized. |
9 | 9 |
| 10 #include <stdint.h> |
| 11 |
10 #include "base/files/file.h" | 12 #include "base/files/file.h" |
11 #include "base/i18n/icu_util.h" | 13 #include "base/i18n/icu_util.h" |
12 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
13 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
14 #include "mojo/public/c/system/types.h" | 16 #include "mojo/public/c/system/types.h" |
15 | 17 |
16 #if !defined(OS_ANDROID) | 18 #if !defined(OS_ANDROID) |
17 #include "third_party/icu/source/i18n/unicode/timezone.h" | 19 #include "third_party/icu/source/i18n/unicode/timezone.h" |
18 #endif | 20 #endif |
19 | 21 |
20 extern "C" { | 22 extern "C" { |
21 #if defined(WIN32) | 23 #if defined(WIN32) |
22 __declspec(dllexport) void __cdecl | 24 __declspec(dllexport) void __cdecl |
23 #else | 25 #else |
24 void __attribute__((visibility("default"))) | 26 void __attribute__((visibility("default"))) |
25 #endif | 27 #endif |
26 InitializeBase(const uint8* icu_data) { | 28 InitializeBase(const uint8_t* icu_data) { |
27 base::RandUint64(); | 29 base::RandUint64(); |
28 base::SysInfo::AmountOfPhysicalMemory(); | 30 base::SysInfo::AmountOfPhysicalMemory(); |
29 base::SysInfo::NumberOfProcessors(); | 31 base::SysInfo::NumberOfProcessors(); |
30 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 32 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
31 base::SysInfo::MaxSharedMemorySize(); | 33 base::SysInfo::MaxSharedMemorySize(); |
32 #endif | 34 #endif |
33 | 35 |
34 // Initialize core ICU. We must perform the full initialization before we | 36 // Initialize core ICU. We must perform the full initialization before we |
35 // initialize icu::TimeZone subsystem because otherwise ICU gets in a state | 37 // initialize icu::TimeZone subsystem because otherwise ICU gets in a state |
36 // where the timezone data is disconnected from the locale data which can | 38 // where the timezone data is disconnected from the locale data which can |
37 // cause crashes. | 39 // cause crashes. |
38 CHECK(base::i18n::InitializeICUFromRawMemory(icu_data)); | 40 CHECK(base::i18n::InitializeICUFromRawMemory(icu_data)); |
39 | 41 |
40 #if !defined(OS_ANDROID) | 42 #if !defined(OS_ANDROID) |
41 // ICU DateFormat class (used in base/time_format.cc) needs to get the | 43 // ICU DateFormat class (used in base/time_format.cc) needs to get the |
42 // Olson timezone ID by accessing the zoneinfo files on disk. After | 44 // Olson timezone ID by accessing the zoneinfo files on disk. After |
43 // TimeZone::createDefault is called once here, the timezone ID is | 45 // TimeZone::createDefault is called once here, the timezone ID is |
44 // cached and there's no more need to access the file system. | 46 // cached and there's no more need to access the file system. |
45 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); | 47 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); |
46 #endif | 48 #endif |
47 } | 49 } |
48 } | 50 } |
OLD | NEW |