├── src ├── base │ ├── test │ │ ├── data │ │ │ ├── file_util │ │ │ │ ├── empty1.txt │ │ │ │ ├── empty2.txt │ │ │ │ ├── shortened.txt │ │ │ │ ├── crlf.txt │ │ │ │ ├── original.txt │ │ │ │ ├── same.txt │ │ │ │ ├── different.txt │ │ │ │ ├── different_last.txt │ │ │ │ ├── same_length.txt │ │ │ │ ├── different_first.txt │ │ │ │ ├── blank_line.txt │ │ │ │ ├── first2.txt │ │ │ │ ├── blank_line_crlf.txt │ │ │ │ ├── first1.txt │ │ │ │ ├── red.png │ │ │ │ ├── binary_file.bin │ │ │ │ ├── binary_file_diff.bin │ │ │ │ └── binary_file_same.bin │ │ │ ├── prefs │ │ │ │ ├── invalid.json │ │ │ │ ├── read.json │ │ │ │ └── write.golden.json │ │ │ ├── serializer_test_nowhitespace.json │ │ │ ├── serializer_test.json │ │ │ ├── json │ │ │ │ └── bom_feff.json │ │ │ └── serializer_nested_test.json │ │ ├── OWNERS │ │ ├── expectations │ │ │ └── OWNERS │ │ ├── DEPS │ │ ├── android │ │ │ ├── OWNERS │ │ │ └── javatests │ │ │ │ └── src │ │ │ │ └── org │ │ │ │ └── chromium │ │ │ │ └── base │ │ │ │ └── test │ │ │ │ └── util │ │ │ │ ├── MinAndroidSdkLevel.java │ │ │ │ ├── TimeoutScale.java │ │ │ │ ├── DisabledTest.java │ │ │ │ ├── Manual.java │ │ │ │ ├── HostDrivenTest.java │ │ │ │ ├── EnormousTest.java │ │ │ │ ├── IntegrationTest.java │ │ │ │ ├── InstrumentationUtils.java │ │ │ │ ├── Feature.java │ │ │ │ └── ScalableTimeout.java │ │ ├── run_all_perftests.cc │ │ ├── mock_devices_changed_observer.cc │ │ ├── test_listener_ios.h │ │ ├── perf_test_suite.h │ │ ├── launcher │ │ │ ├── test_launcher_ios.cc │ │ │ └── unit_test_launcher_ios.cc │ │ ├── simple_test_clock.cc │ │ ├── simple_test_tick_clock.cc │ │ ├── scoped_locale.cc │ │ ├── test_file_util.cc │ │ ├── test_support_ios.h │ │ ├── scoped_locale.h │ │ ├── test_file_util_linux.cc │ │ ├── perf_time_logger.cc │ │ ├── test_support_android.h │ │ ├── null_task_runner.cc │ │ ├── opaque_ref_counted.h │ │ ├── perf_log.h │ │ ├── mock_time_provider.cc │ │ ├── trace_to_file.h │ │ ├── mock_devices_changed_observer.h │ │ ├── gtest_util.h │ │ ├── opaque_ref_counted.cc │ │ ├── test_file_util_android.cc │ │ ├── test_shortcut_win.h │ │ ├── mock_chrome_application_mac.h │ │ ├── perf_time_logger.h │ │ ├── simple_test_clock.h │ │ ├── thread_test_helper.cc │ │ ├── simple_test_tick_clock.h │ │ ├── perf_log.cc │ │ ├── run_all_unittests.cc │ │ └── null_task_runner.h │ ├── numerics │ │ └── OWNERS │ ├── third_party │ │ ├── nspr │ │ │ ├── OWNERS │ │ │ ├── README.chromium │ │ │ └── BUILD.gn │ │ ├── symbolize │ │ │ ├── DEPS │ │ │ ├── glog │ │ │ │ ├── logging.h │ │ │ │ └── raw_logging.h │ │ │ ├── config.h │ │ │ ├── utilities.h │ │ │ ├── README.chromium │ │ │ └── BUILD.gn │ │ ├── superfasthash │ │ │ ├── OWNERS │ │ │ └── README.chromium │ │ ├── xdg_user_dirs │ │ │ ├── README.chromium │ │ │ ├── BUILD.gn │ │ │ └── LICENSE │ │ ├── xdg_mime │ │ │ ├── compile.patch │ │ │ ├── README.chromium │ │ │ ├── README │ │ │ └── BUILD.gn │ │ ├── dmg_fp │ │ │ ├── float_precision_crash.patch │ │ │ ├── gcc_64_bit.patch │ │ │ ├── LICENSE │ │ │ ├── README.chromium │ │ │ └── dmg_fp.h │ │ ├── valgrind │ │ │ └── README.chromium │ │ ├── dynamic_annotations │ │ │ ├── BUILD.gn │ │ │ └── README.chromium │ │ └── icu │ │ │ └── README.chromium │ ├── threading │ │ ├── OWNERS │ │ ├── non_thread_safe_impl.cc │ │ ├── thread_local_android.cc │ │ ├── thread_local_storage_posix.cc │ │ ├── thread_checker_impl.cc │ │ ├── thread_local_win.cc │ │ └── thread_local_posix.cc │ ├── win │ │ ├── OWNERS │ │ ├── iunknown_impl.cc │ │ ├── iunknown_impl.h │ │ ├── i18n.h │ │ ├── scoped_hglobal.h │ │ └── scoped_select_object.h │ ├── metrics │ │ ├── OWNERS │ │ └── user_metrics_action.h │ ├── files │ │ ├── OWNERS │ │ ├── file_util_android.cc │ │ ├── file_enumerator.cc │ │ ├── file_path_constants.cc │ │ ├── file_path_watcher_stub.cc │ │ ├── protect_file_posix.gypi │ │ ├── scoped_file.cc │ │ ├── file_posix_hooks_internal.h │ │ └── dir_reader_fallback.h │ ├── strings │ │ ├── OWNERS │ │ ├── nullable_string16.cc │ │ ├── latin1_string_conversions.cc │ │ ├── sys_string_conversions_mac_unittest.mm │ │ └── stringize_macros.h │ ├── prefs │ │ ├── OWNERS │ │ ├── README │ │ ├── pref_store.cc │ │ ├── pref_observer.h │ │ ├── base_prefs_export.h │ │ ├── mock_pref_change_callback.cc │ │ ├── pref_notifier.h │ │ ├── pref_store_observer_mock.cc │ │ ├── scoped_user_pref_update.cc │ │ └── pref_store_observer_mock.h │ ├── debug │ │ ├── OWNERS │ │ ├── trace_event_unittest.h │ │ ├── alias.cc │ │ ├── debugger_win.cc │ │ ├── alias.h │ │ ├── gdi_debug_util_win.h │ │ ├── dump_without_crashing.cc │ │ ├── stack_trace.cc │ │ ├── dump_without_crashing.h │ │ └── trace_event_impl_constants.cc │ ├── time │ │ ├── clock.cc │ │ ├── tick_clock.cc │ │ ├── default_clock.cc │ │ ├── default_tick_clock.cc │ │ ├── default_clock.h │ │ └── default_tick_clock.h │ ├── bind_helpers.cc │ ├── process │ │ ├── launch_ios.cc │ │ ├── memory_stubs.cc │ │ ├── process_metrics_unittest_ios.cc │ │ ├── process_info_win.cc │ │ ├── memory.cc │ │ ├── process_info.h │ │ ├── kill.cc │ │ ├── process_info_linux.cc │ │ ├── process_handle_linux.cc │ │ ├── process_info_mac.cc │ │ ├── process_handle_mac.cc │ │ ├── memory_unittest_mac.h │ │ ├── process_handle_freebsd.cc │ │ └── process_iterator_win.cc │ ├── allocator │ │ ├── debugallocation_shim.cc │ │ ├── unittest_utils.cc │ │ ├── type_profiler_control.cc │ │ ├── type_profiler_control.h │ │ ├── type_profiler_tcmalloc.h │ │ ├── allocator_shim.h │ │ └── type_profiler_tcmalloc.cc │ ├── power_monitor │ │ ├── power_monitor_device_source_posix.cc │ │ ├── power_monitor_device_source_android.h │ │ ├── power_observer.h │ │ └── power_monitor_device_source_chromeos.cc │ ├── message_loop │ │ ├── message_loop_proxy.cc │ │ ├── message_pump.cc │ │ └── timer_slack.h │ ├── callback_forward.h │ ├── timer │ │ ├── elapsed_timer.cc │ │ ├── hi_res_timer_manager_posix.cc │ │ ├── elapsed_timer.h │ │ ├── hi_res_timer_manager_win.cc │ │ └── mock_timer.h │ ├── os_compat_nacl.h │ ├── critical_closure_internal_ios.mm │ ├── DEPS │ ├── synchronization │ │ ├── cancellation_flag.cc │ │ ├── lock_impl_win.cc │ │ └── lock.cc │ ├── base_paths_mac.h │ ├── hash.cc │ ├── os_compat_nacl.cc │ ├── profiler │ │ ├── scoped_tracker.cc │ │ ├── scoped_profile.cc │ │ └── alternate_timer.cc │ ├── mac │ │ ├── OWNERS │ │ ├── scoped_sending_event.mm │ │ ├── os_crash_dumps.h │ │ ├── scoped_nsautorelease_pool.mm │ │ ├── scoped_mach_vm.cc │ │ ├── mac_logging.cc │ │ └── launchd.h │ ├── check_example.cc │ ├── memory │ │ ├── scoped_policy.h │ │ └── scoped_handle.h │ ├── base_paths_android.h │ ├── guid.cc │ ├── sys_info_internal.h │ ├── tracking_info.cc │ ├── event_recorder_stubs.cc │ ├── debug_message.cc │ ├── base64.h │ ├── float_util.h │ ├── scoped_clear_errno.h │ ├── os_compat_android.h │ ├── base_paths_posix.h │ ├── event_types.h │ ├── build_time.cc │ ├── value_conversions.h │ ├── sha1.h │ ├── build_time.h │ ├── nix │ │ └── mime_util_xdg.h │ ├── sys_info_freebsd.cc │ ├── sequenced_task_runner.cc │ ├── base_export.h │ ├── callback_helpers.cc │ ├── guid_win.cc │ ├── guid.h │ ├── json │ │ └── json_value_converter.cc │ ├── rand_util_nacl.cc │ ├── barrier_closure.h │ ├── bits.h │ ├── base_switches.h │ ├── callback_internal.cc │ └── hash.h ├── third_party │ ├── superfasthash │ │ ├── OWNERS │ │ └── README.chromium │ ├── sqlite3 │ │ └── sqlite3.lib │ └── libevent │ │ ├── autogen.sh │ │ ├── sample │ │ └── Makefile.am │ │ ├── test │ │ ├── regress.rpc │ │ ├── test-init.c │ │ └── Makefile.am │ │ ├── nacl_nonsfi │ │ └── random.c │ │ ├── strlcpy-internal.h │ │ ├── event-config.h │ │ ├── mkinstalldirs │ │ ├── BUILD.gn │ │ └── README.chromium ├── test_qt │ ├── test_qt.qrc │ ├── main.cpp │ ├── global_def.h │ ├── test_qt.ui │ └── test_qt.h └── build │ └── filename_rules.gypi ├── README.md ├── Debug └── sqlite3.dll ├── .gitignore └── .travis.yml /src/base/test/data/file_util/empty1.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/empty2.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/base/test/OWNERS: -------------------------------------------------------------------------------- 1 | phajdan.jr@chromium.org 2 | -------------------------------------------------------------------------------- /src/base/test/data/prefs/invalid.json: -------------------------------------------------------------------------------- 1 | !@#$%^& -------------------------------------------------------------------------------- /src/base/test/data/file_util/shortened.txt: -------------------------------------------------------------------------------- 1 | This file is the -------------------------------------------------------------------------------- /src/base/test/expectations/OWNERS: -------------------------------------------------------------------------------- 1 | rsesek@chromium.org 2 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/crlf.txt: -------------------------------------------------------------------------------- 1 | This file is the same. 2 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/original.txt: -------------------------------------------------------------------------------- 1 | This file is the same. 2 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/same.txt: -------------------------------------------------------------------------------- 1 | This file is the same. 2 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/different.txt: -------------------------------------------------------------------------------- 1 | This file is different. 2 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/different_last.txt: -------------------------------------------------------------------------------- 1 | This file is the same. -------------------------------------------------------------------------------- /src/base/test/data/file_util/same_length.txt: -------------------------------------------------------------------------------- 1 | This file is not same. 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryderfang/chromium_base/HEAD/README.md -------------------------------------------------------------------------------- /src/base/numerics/OWNERS: -------------------------------------------------------------------------------- 1 | jschuh@chromium.org 2 | tsepez@chromium.org 3 | 4 | -------------------------------------------------------------------------------- /src/base/test/DEPS: -------------------------------------------------------------------------------- 1 | include_rules = [ 2 | "+third_party/libxml", 3 | ] 4 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/different_first.txt: -------------------------------------------------------------------------------- 1 | this file is the same. 2 | -------------------------------------------------------------------------------- /src/base/third_party/nspr/OWNERS: -------------------------------------------------------------------------------- 1 | rsleevi@chromium.org 2 | wtc@chromium.org 3 | -------------------------------------------------------------------------------- /src/base/third_party/symbolize/DEPS: -------------------------------------------------------------------------------- 1 | include_rules = [ 2 | "+glog", 3 | ] 4 | -------------------------------------------------------------------------------- /src/base/threading/OWNERS: -------------------------------------------------------------------------------- 1 | # For thread_resrictions.* 2 | jam@chromium.org 3 | -------------------------------------------------------------------------------- /src/base/win/OWNERS: -------------------------------------------------------------------------------- 1 | cpu@chromium.org 2 | grt@chromium.org 3 | rvargas@chromium.org 4 | -------------------------------------------------------------------------------- /src/third_party/superfasthash/OWNERS: -------------------------------------------------------------------------------- 1 | mgiuca@chromium.org 2 | rvargas@chromium.org 3 | -------------------------------------------------------------------------------- /Debug/sqlite3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryderfang/chromium_base/HEAD/Debug/sqlite3.dll -------------------------------------------------------------------------------- /src/base/third_party/superfasthash/OWNERS: -------------------------------------------------------------------------------- 1 | mgiuca@chromium.org 2 | rvargas@chromium.org 3 | -------------------------------------------------------------------------------- /src/base/metrics/OWNERS: -------------------------------------------------------------------------------- 1 | asvitkine@chromium.org 2 | isherman@chromium.org 3 | jar@chromium.org 4 | -------------------------------------------------------------------------------- /src/base/test/android/OWNERS: -------------------------------------------------------------------------------- 1 | feng@chromium.org 2 | nyquist@chromium.org 3 | yfriedman@chromium.org 4 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/blank_line.txt: -------------------------------------------------------------------------------- 1 | The next line is blank. 2 | 3 | But this one isn't. 4 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/first2.txt: -------------------------------------------------------------------------------- 1 | The first line is the same. 2 | The second line is not. 3 | -------------------------------------------------------------------------------- /src/test_qt/test_qt.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/base/files/OWNERS: -------------------------------------------------------------------------------- 1 | rvargas@chromium.org 2 | 3 | per-file file_path_watcher*=mnissler@chromium.org 4 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/blank_line_crlf.txt: -------------------------------------------------------------------------------- 1 | The next line is blank. 2 | 3 | But this one isn't. 4 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/first1.txt: -------------------------------------------------------------------------------- 1 | The first line is the same. 2 | The second line is different. 3 | -------------------------------------------------------------------------------- /src/base/strings/OWNERS: -------------------------------------------------------------------------------- 1 | per-file safe_sprintf*=jln@chromium.org 2 | per-file safe_sprintf*=mdempsky@chromium.org 3 | -------------------------------------------------------------------------------- /src/base/test/data/serializer_test_nowhitespace.json: -------------------------------------------------------------------------------- 1 | {"bool":true,"int":42,"list":[1,2],"null":null,"real":3.14,"string":"hello"} -------------------------------------------------------------------------------- /src/base/test/data/file_util/red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryderfang/chromium_base/HEAD/src/base/test/data/file_util/red.png -------------------------------------------------------------------------------- /src/third_party/sqlite3/sqlite3.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryderfang/chromium_base/HEAD/src/third_party/sqlite3/sqlite3.lib -------------------------------------------------------------------------------- /src/base/prefs/OWNERS: -------------------------------------------------------------------------------- 1 | battre@chromium.org 2 | bauerb@chromium.org 3 | gab@chromium.org 4 | mnissler@chromium.org 5 | pam@chromium.org 6 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/binary_file.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryderfang/chromium_base/HEAD/src/base/test/data/file_util/binary_file.bin -------------------------------------------------------------------------------- /src/base/test/data/file_util/binary_file_diff.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryderfang/chromium_base/HEAD/src/base/test/data/file_util/binary_file_diff.bin -------------------------------------------------------------------------------- /src/base/test/data/file_util/binary_file_same.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryderfang/chromium_base/HEAD/src/base/test/data/file_util/binary_file_same.bin -------------------------------------------------------------------------------- /src/base/third_party/nspr/README.chromium: -------------------------------------------------------------------------------- 1 | Name: Netscape Portable Runtime (NSPR) 2 | URL: http://www.mozilla.org/projects/nspr/ 3 | License: MPL 1.1/GPL 2.0/LGPL 2.1 4 | -------------------------------------------------------------------------------- /src/base/debug/OWNERS: -------------------------------------------------------------------------------- 1 | per-file trace_event*=nduca@chromium.org 2 | per-file trace_event*=dsinclair@chromium.org 3 | per-file trace_event_android.cc=wangxianzhu@chromium.org 4 | -------------------------------------------------------------------------------- /src/base/test/data/serializer_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "bool": true, 3 | "int": 42, 4 | "list": [ 1, 2 ], 5 | "null": null, 6 | "real": 3.14, 7 | "string": "hello" 8 | } 9 | -------------------------------------------------------------------------------- /src/base/test/data/prefs/read.json: -------------------------------------------------------------------------------- 1 | { 2 | "homepage": "http://www.cnn.com", 3 | "some_directory": "/usr/local/", 4 | "tabs": { 5 | "new_windows_in_tabs": true, 6 | "max_tabs": 20 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/base/third_party/symbolize/glog/logging.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010 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 | // Empty. 6 | -------------------------------------------------------------------------------- /src/base/test/data/prefs/write.golden.json: -------------------------------------------------------------------------------- 1 | { 2 | "homepage": "http://www.cnn.com", 3 | "long_int": { 4 | "pref": "214748364842" 5 | }, 6 | "some_directory": "/usr/sbin/", 7 | "tabs": { 8 | "max_tabs": 10, 9 | "new_windows_in_tabs": false 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/third_party/libevent/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | LIBTOOLIZE=libtoolize 3 | SYSNAME=`uname` 4 | if [ "x$SYSNAME" = "xDarwin" ] ; then 5 | LIBTOOLIZE=glibtoolize 6 | fi 7 | aclocal && \ 8 | autoheader && \ 9 | $LIBTOOLIZE && \ 10 | autoconf && \ 11 | automake --add-missing --copy 12 | -------------------------------------------------------------------------------- /src/base/test/data/json/bom_feff.json: -------------------------------------------------------------------------------- 1 | { 2 | "appName": { 3 | "message": "Gmail", 4 | "description": "App name." 5 | }, 6 | "appDesc": { 7 | "message": "بريد إلكتروني يوفر إمكانية البحث مع مقدار أقل من الرسائل غير المرغوب فيها.", 8 | "description":"App description." 9 | } 10 | } -------------------------------------------------------------------------------- /src/base/third_party/symbolize/glog/raw_logging.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010 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 | #define WARNING 1; 6 | #define RAW_LOG(severity, ...); // Do nothing. 7 | -------------------------------------------------------------------------------- /src/base/prefs/README: -------------------------------------------------------------------------------- 1 | Prefs is a general-purpose key-value store for application preferences. 2 | 3 | The Prefs code lives in base/prefs but is not part of the 4 | 'base/base.gyp:base' library because of a desire to keep its use 5 | optional. If you use Prefs, you should add a GYP dependency on 6 | base/base.gyp:base_prefs. 7 | -------------------------------------------------------------------------------- /src/base/time/clock.cc: -------------------------------------------------------------------------------- 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 "base/time/clock.h" 6 | 7 | namespace base { 8 | 9 | Clock::~Clock() {} 10 | 11 | } // namespace base 12 | -------------------------------------------------------------------------------- /src/base/third_party/xdg_user_dirs/README.chromium: -------------------------------------------------------------------------------- 1 | Name: xdg-user-dirs 2 | URL: http://www.freedesktop.org/wiki/Software/xdg-user-dirs 3 | License: MIT 4 | 5 | This directory include xdg-user-dir-lookup.c renamed as xdg_user_dir_lookup.cc 6 | from xdg-user-dirs 0.10. We made xdg_user_dir_lookup() non-static and added a 7 | xdg_user_dir_lookup.h. 8 | -------------------------------------------------------------------------------- /src/base/third_party/symbolize/config.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010 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 | #define GOOGLE_NAMESPACE google 6 | #define _END_GOOGLE_NAMESPACE_ } 7 | #define _START_GOOGLE_NAMESPACE_ namespace google { 8 | -------------------------------------------------------------------------------- /src/base/time/tick_clock.cc: -------------------------------------------------------------------------------- 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 "base/time/tick_clock.h" 6 | 7 | namespace base { 8 | 9 | TickClock::~TickClock() {} 10 | 11 | } // namespace base 12 | -------------------------------------------------------------------------------- /src/base/test/run_all_perftests.cc: -------------------------------------------------------------------------------- 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 "base/test/perf_test_suite.h" 6 | 7 | int main(int argc, char** argv) { 8 | return base::PerfTestSuite(argc, argv).Run(); 9 | } 10 | -------------------------------------------------------------------------------- /src/base/bind_helpers.cc: -------------------------------------------------------------------------------- 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 "base/bind_helpers.h" 6 | 7 | #include "base/callback.h" 8 | 9 | namespace base { 10 | 11 | void DoNothing() { 12 | } 13 | 14 | } // namespace base 15 | -------------------------------------------------------------------------------- /src/base/third_party/xdg_mime/compile.patch: -------------------------------------------------------------------------------- 1 | --- a/xdgmimecache.c 2 | +++ b/xdgmimecache.c 3 | @@ -40,6 +40,8 @@ 4 | 5 | #include /* for ntohl/ntohs */ 6 | 7 | +#define HAVE_MMAP 1 8 | + 9 | #ifdef HAVE_MMAP 10 | #include 11 | #else 12 | @@ -1000,5 +1002,3 @@ 13 | dump_glob_node (cache, offset + 20 * j, 0); 14 | } 15 | } 16 | - 17 | - 18 | -------------------------------------------------------------------------------- /src/base/third_party/xdg_user_dirs/BUILD.gn: -------------------------------------------------------------------------------- 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 | source_set("xdg_user_dirs") { 6 | visibility = [ "//base/*" ] 7 | sources = [ 8 | "xdg_user_dir_lookup.cc", 9 | "xdg_user_dir_lookup.h", 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/base/process/launch_ios.cc: -------------------------------------------------------------------------------- 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 "base/process/launch.h" 6 | 7 | namespace base { 8 | 9 | void RaiseProcessToHighPriority() { 10 | // Impossible on iOS. Do nothing. 11 | } 12 | 13 | } // namespace base 14 | -------------------------------------------------------------------------------- /src/base/test/data/serializer_nested_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "bool": true, 3 | "dict": { 4 | "bool": true, 5 | "dict": { 6 | "bees": "knees", 7 | "cats": "meow" 8 | }, 9 | "foos": "bar", 10 | "list": [ 3.4, "second", null ] 11 | }, 12 | "int": 42, 13 | "list": [ 1, 2 ], 14 | "null": null, 15 | "real": 3.14, 16 | "string": "hello" 17 | } 18 | -------------------------------------------------------------------------------- /src/third_party/libevent/sample/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign no-dependencies 2 | 3 | LDADD = ../libevent.la 4 | AM_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/compat 5 | 6 | noinst_PROGRAMS = event-test time-test signal-test 7 | 8 | event_test_sources = event-test.c 9 | time_test_sources = time-test.c 10 | signal_test_sources = signal-test.c 11 | 12 | verify: 13 | 14 | DISTCLEANFILES = *~ 15 | -------------------------------------------------------------------------------- /src/base/prefs/pref_store.cc: -------------------------------------------------------------------------------- 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 "base/prefs/pref_store.h" 6 | 7 | bool PrefStore::HasObservers() const { 8 | return false; 9 | } 10 | 11 | bool PrefStore::IsInitializationComplete() const { 12 | return true; 13 | } 14 | -------------------------------------------------------------------------------- /src/base/allocator/debugallocation_shim.cc: -------------------------------------------------------------------------------- 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 | #if defined(TCMALLOC_FOR_DEBUGALLOCATION) 6 | #include "third_party/tcmalloc/chromium/src/debugallocation.cc" 7 | #else 8 | #include "third_party/tcmalloc/chromium/src/tcmalloc.cc" 9 | #endif 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | *.sdf 7 | *.user 8 | *.suo 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | 18 | # Fortran module files 19 | *.mod 20 | 21 | # Compiled Static libraries 22 | *.lai 23 | *.la 24 | *.a 25 | *.ilk 26 | *.pdb 27 | *.opensdf 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /src/base/time/default_clock.cc: -------------------------------------------------------------------------------- 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 "base/time/default_clock.h" 6 | 7 | namespace base { 8 | 9 | DefaultClock::~DefaultClock() {} 10 | 11 | Time DefaultClock::Now() { 12 | return Time::Now(); 13 | } 14 | 15 | } // namespace base 16 | -------------------------------------------------------------------------------- /src/base/third_party/symbolize/utilities.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010 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 6 | #include 7 | #include 8 | #include 9 | typedef uint64_t uint64; 10 | #define HAVE_SYMBOLIZE 1 11 | #define ATTRIBUTE_NOINLINE __attribute__ ((noinline)) 12 | -------------------------------------------------------------------------------- /src/test_qt/main.cpp: -------------------------------------------------------------------------------- 1 | #include "test_qt.h" 2 | #include 3 | 4 | #include "qt_windows.h" 5 | 6 | #include "base/at_exit.h" 7 | #include "base/command_line.h" 8 | 9 | int main(int argc, char *argv[]) 10 | { 11 | QApplication a(argc, argv); 12 | 13 | base::CommandLine::Init(0, NULL); 14 | base::AtExitManager exit_manager; 15 | 16 | test_qt w; 17 | w.show(); 18 | return a.exec(); 19 | } 20 | -------------------------------------------------------------------------------- /src/base/third_party/xdg_mime/README.chromium: -------------------------------------------------------------------------------- 1 | Name: xdg-mime 2 | URL: http://freedesktop.org 3 | License: Academic Free License version 2.0 or LGPL v2 4 | 5 | The code in this directory is synced from: 6 | git://anongit.freedesktop.org/xdg/xdgmime 7 | @ 2cdd8d36d7930d5a594587286cb1949ff62f7027 on 2012/08/06. 8 | 9 | In addition, we have the following patch(es): 10 | - compile.patch: small tweaks to make the code compile. 11 | - Added a LICENSE file. 12 | -------------------------------------------------------------------------------- /src/base/time/default_tick_clock.cc: -------------------------------------------------------------------------------- 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 "base/time/default_tick_clock.h" 6 | 7 | namespace base { 8 | 9 | DefaultTickClock::~DefaultTickClock() {} 10 | 11 | TimeTicks DefaultTickClock::NowTicks() { 12 | return TimeTicks::Now(); 13 | } 14 | 15 | } // namespace base 16 | -------------------------------------------------------------------------------- /src/base/power_monitor/power_monitor_device_source_posix.cc: -------------------------------------------------------------------------------- 1 | // Copyright 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 | #include "base/power_monitor/power_monitor_device_source.h" 6 | 7 | namespace base { 8 | 9 | bool PowerMonitorDeviceSource::IsOnBatteryPowerImpl() { 10 | NOTIMPLEMENTED(); 11 | return false; 12 | } 13 | 14 | } // namespace base 15 | -------------------------------------------------------------------------------- /src/third_party/libevent/test/regress.rpc: -------------------------------------------------------------------------------- 1 | /* tests data packing and unpacking */ 2 | 3 | struct msg { 4 | string from_name = 1; 5 | string to_name = 2; 6 | optional struct[kill] attack = 3; 7 | array struct[run] run = 4; 8 | } 9 | 10 | struct kill { 11 | string weapon = 0x10121; 12 | string action = 2; 13 | optional int how_often = 3; 14 | } 15 | 16 | struct run { 17 | string how = 1; 18 | optional bytes some_bytes = 2; 19 | bytes fixed_bytes[24] = 3; 20 | } 21 | -------------------------------------------------------------------------------- /src/base/message_loop/message_loop_proxy.cc: -------------------------------------------------------------------------------- 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 "base/message_loop/message_loop_proxy.h" 6 | 7 | #include "base/bind.h" 8 | 9 | namespace base { 10 | 11 | MessageLoopProxy::MessageLoopProxy() { 12 | } 13 | 14 | MessageLoopProxy::~MessageLoopProxy() { 15 | } 16 | 17 | } // namespace base 18 | -------------------------------------------------------------------------------- /src/base/message_loop/message_pump.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010 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 "base/message_loop/message_pump.h" 6 | 7 | namespace base { 8 | 9 | MessagePump::MessagePump() { 10 | } 11 | 12 | MessagePump::~MessagePump() { 13 | } 14 | 15 | void MessagePump::SetTimerSlack(TimerSlack) { 16 | } 17 | 18 | } // namespace base 19 | -------------------------------------------------------------------------------- /src/base/third_party/dmg_fp/float_precision_crash.patch: -------------------------------------------------------------------------------- 1 | diff --git a/base/third_party/dmg_fp/dtoa.cc b/base/third_party/dmg_fp/dtoa.cc 2 | index 3f7e794..3312fa4 100644 3 | --- dtoa.cc 4 | +++ dtoa.cc 5 | @@ -3891,7 +3891,7 @@ dtoa 6 | goto no_digits; 7 | goto one_digit; 8 | } 9 | - for(i = 1;; i++, dval(&u) *= 10.) { 10 | + for(i = 1; i <= k + 1; i++, dval(&u) *= 10.) { 11 | L = (Long)(dval(&u) / ds); 12 | dval(&u) -= L*ds; 13 | #ifdef Check_FLT_ROUNDS 14 | -------------------------------------------------------------------------------- /src/base/callback_forward.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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_CALLBACK_FORWARD_H_ 6 | #define BASE_CALLBACK_FORWARD_H_ 7 | 8 | namespace base { 9 | 10 | template 11 | class Callback; 12 | 13 | typedef Callback Closure; 14 | 15 | } // namespace base 16 | 17 | #endif // BASE_CALLBACK_FORWARD_H 18 | -------------------------------------------------------------------------------- /src/base/debug/trace_event_unittest.h: -------------------------------------------------------------------------------- 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 "base/time/time.h" 6 | 7 | namespace base { 8 | namespace debug { 9 | 10 | // Sleep until HighResNow has advanced by at least |elapsed|. 11 | void HighResSleepForTraceTest(base::TimeDelta elapsed); 12 | 13 | } // namespace debug 14 | } // namespace base 15 | -------------------------------------------------------------------------------- /src/base/timer/elapsed_timer.cc: -------------------------------------------------------------------------------- 1 | // Copyright 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 | #include "base/timer/elapsed_timer.h" 6 | 7 | namespace base { 8 | 9 | ElapsedTimer::ElapsedTimer() { 10 | begin_ = TimeTicks::Now(); 11 | } 12 | 13 | TimeDelta ElapsedTimer::Elapsed() const { 14 | return TimeTicks::Now() - begin_; 15 | } 16 | 17 | } // namespace base 18 | -------------------------------------------------------------------------------- /src/third_party/libevent/nacl_nonsfi/random.c: -------------------------------------------------------------------------------- 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 3 | * found in the LICENSE file. 4 | */ 5 | 6 | #include 7 | 8 | /* The newlib-based PNaCl toolchain does not provide random(). So, here we 9 | * define it. It just redirects to the rand(), which is provided by the 10 | * toolchain. */ 11 | long int random() { 12 | return rand(); 13 | } 14 | -------------------------------------------------------------------------------- /src/third_party/libevent/strlcpy-internal.h: -------------------------------------------------------------------------------- 1 | #ifndef _STRLCPY_INTERNAL_H_ 2 | #define _STRLCPY_INTERNAL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #ifdef HAVE_CONFIG_H 9 | #include "config.h" 10 | #endif /* HAVE_CONFIG_H */ 11 | 12 | #ifndef HAVE_STRLCPY 13 | #include 14 | size_t _event_strlcpy(char *dst, const char *src, size_t siz); 15 | #define strlcpy _event_strlcpy 16 | #endif 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /src/base/test/mock_devices_changed_observer.cc: -------------------------------------------------------------------------------- 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 "base/test/mock_devices_changed_observer.h" 6 | 7 | namespace base { 8 | 9 | MockDevicesChangedObserver::MockDevicesChangedObserver() { 10 | } 11 | 12 | MockDevicesChangedObserver::~MockDevicesChangedObserver() { 13 | } 14 | 15 | } // namespace base 16 | -------------------------------------------------------------------------------- /src/base/third_party/valgrind/README.chromium: -------------------------------------------------------------------------------- 1 | Name: valgrind 2 | URL: http://valgrind.org 3 | License: BSD 4 | 5 | Header files in this directory define runtime macros that determine whether the 6 | current process is running under Valgrind and tell Memcheck tool about custom 7 | memory allocators. 8 | 9 | These header files were taken from Valgrind source code 10 | (svn://svn.valgrind.org/valgrind/trunk@11504, dated 21 Jan 2011). The files are 11 | covered under BSD license as described within. 12 | -------------------------------------------------------------------------------- /src/base/os_compat_nacl.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_OS_COMPAT_NACL_H_ 6 | #define BASE_OS_COMPAT_NACL_H_ 7 | 8 | #include 9 | 10 | #if !defined (__GLIBC__) 11 | // NaCl has no timegm(). 12 | extern "C" time_t timegm(struct tm* const t); 13 | #endif // !defined (__GLIBC__) 14 | 15 | #endif // BASE_OS_COMPAT_NACL_H_ 16 | 17 | -------------------------------------------------------------------------------- /src/base/process/memory_stubs.cc: -------------------------------------------------------------------------------- 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 | #include "base/process/memory.h" 6 | 7 | namespace base { 8 | 9 | void EnableTerminationOnOutOfMemory() { 10 | } 11 | 12 | void EnableTerminationOnHeapCorruption() { 13 | } 14 | 15 | bool AdjustOOMScore(ProcessId process, int score) { 16 | return false; 17 | } 18 | 19 | } // namespace base 20 | -------------------------------------------------------------------------------- /src/base/critical_closure_internal_ios.mm: -------------------------------------------------------------------------------- 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 3 | // found in the LICENSE file. 4 | 5 | #include "base/critical_closure.h" 6 | 7 | #import 8 | 9 | namespace base { 10 | namespace internal { 11 | 12 | bool IsMultiTaskingSupported() { 13 | return [[UIDevice currentDevice] isMultitaskingSupported]; 14 | } 15 | 16 | } // namespace internal 17 | } // namespace base 18 | -------------------------------------------------------------------------------- /src/base/DEPS: -------------------------------------------------------------------------------- 1 | include_rules = [ 2 | "+jni", 3 | "+third_party/ashmem", 4 | "+third_party/apple_apsl", 5 | "+third_party/libevent", 6 | "+third_party/dmg_fp", 7 | "+third_party/google_toolbox_for_mac/src", 8 | "+third_party/mach_override", 9 | "+third_party/modp_b64", 10 | "+third_party/tcmalloc", 11 | 12 | # These are implicitly brought in from the root, and we don't want them. 13 | "-ipc", 14 | "-url", 15 | 16 | # ICU dependendencies must be separate from the rest of base. 17 | "-i18n", 18 | ] 19 | -------------------------------------------------------------------------------- /src/base/files/file_util_android.cc: -------------------------------------------------------------------------------- 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 "base/files/file_util.h" 6 | 7 | #include "base/files/file_path.h" 8 | #include "base/path_service.h" 9 | 10 | namespace base { 11 | 12 | bool GetShmemTempDir(bool executable, base::FilePath* path) { 13 | return PathService::Get(base::DIR_CACHE, path); 14 | } 15 | 16 | } // namespace base 17 | -------------------------------------------------------------------------------- /src/base/third_party/symbolize/README.chromium: -------------------------------------------------------------------------------- 1 | Name: google-glog's symbolization library 2 | URL: http://code.google.com/p/google-glog/ 3 | License: BSD 4 | 5 | The following files are copied AS-IS from: 6 | http://code.google.com/p/google-glog/source/browse/#svn/trunk/src (r141) 7 | 8 | - demangle.cc 9 | - demangle.h 10 | - symbolize.cc 11 | - symbolize.h 12 | 13 | The following files are minimal stubs created for use in Chromium: 14 | 15 | - config.h 16 | - glog/logging.h 17 | - glog/raw_logging.h 18 | - utilities.h 19 | -------------------------------------------------------------------------------- /src/base/third_party/xdg_mime/README: -------------------------------------------------------------------------------- 1 | This module is a simple module that parses the proposed MIME spec listed 2 | at http://freedesktop.org/. It is currently targetted at version 0.12. 3 | There are no formal releases planned for this module, and it is not 4 | intended to be installed at this time. Rather, it is meant to be used 5 | by other libraries or applications to add support for the MIME system. 6 | 7 | It is dual-licensed under the terms of the GNU Lesser General Public 8 | License, and the Academic Free License, version 2.0. 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | before_install: 4 | # We need this line to have g++4.8 available in apt 5 | - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test 6 | - sudo apt-get update -qq 7 | 8 | install: 9 | - sudo apt-get install -qq gcc-4.8 g++-4.8 10 | # We want to compile with g++ 4.8 when rather than the default g++ 11 | - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90 12 | 13 | compiler: 14 | - gcc 15 | 16 | notifications: 17 | email: false 18 | 19 | script: ./script/cibuild 20 | -------------------------------------------------------------------------------- /src/base/test/test_listener_ios.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_TEST_TEST_LISTENER_IOS_H_ 6 | #define BASE_TEST_TEST_LISTENER_IOS_H_ 7 | 8 | namespace base { 9 | namespace test_listener_ios { 10 | 11 | // Register an IOSRunLoopListener. 12 | void RegisterTestEndListener(); 13 | 14 | } // namespace test_listener_ios 15 | } // namespace base 16 | 17 | #endif // BASE_TEST_TEST_LISTENER_IOS_H_ 18 | -------------------------------------------------------------------------------- /src/base/third_party/dynamic_annotations/BUILD.gn: -------------------------------------------------------------------------------- 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 | source_set("dynamic_annotations") { 6 | sources = [ 7 | "dynamic_annotations.c", 8 | "dynamic_annotations.h", 9 | "../valgrind/valgrind.h", 10 | ] 11 | if (is_android && !is_debug) { 12 | configs -= [ "//build/config/compiler:optimize" ] 13 | configs += [ "//build/config/compiler:optimize_max" ] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/base/debug/alias.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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 "base/debug/alias.h" 6 | #include "build/build_config.h" 7 | 8 | namespace base { 9 | namespace debug { 10 | 11 | #if defined(COMPILER_MSVC) 12 | #pragma optimize("", off) 13 | #endif 14 | 15 | void Alias(const void* var) { 16 | } 17 | 18 | #if defined(COMPILER_MSVC) 19 | #pragma optimize("", on) 20 | #endif 21 | 22 | } // namespace debug 23 | } // namespace base 24 | -------------------------------------------------------------------------------- /src/base/strings/nullable_string16.cc: -------------------------------------------------------------------------------- 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 | #include "base/strings/nullable_string16.h" 6 | 7 | #include 8 | 9 | #include "base/strings/utf_string_conversions.h" 10 | 11 | namespace base { 12 | 13 | std::ostream& operator<<(std::ostream& out, const NullableString16& value) { 14 | return value.is_null() ? out << "(null)" : out << UTF16ToUTF8(value.string()); 15 | } 16 | 17 | } // namespace base 18 | -------------------------------------------------------------------------------- /src/test_qt/global_def.h: -------------------------------------------------------------------------------- 1 | #ifndef GLOBAL_DEF_H_ 2 | #define GLOBAL_DEF_H_ 3 | 4 | #include "base/basictypes.h" 5 | 6 | #include 7 | #include 8 | 9 | struct VideoInfo { 10 | VideoInfo() : offset(0) { 11 | } 12 | 13 | VideoInfo(const std::string& name) : 14 | file_name(name), 15 | offset(0) { 16 | } 17 | 18 | size_t sz() { return piece.size(); } 19 | 20 | std::string file_name; 21 | 22 | std::string file_hash; 23 | 24 | size_t offset; 25 | 26 | std::vector piece; 27 | }; 28 | 29 | #endif // !GLOBAL_DEF_H_ -------------------------------------------------------------------------------- /src/base/debug/debugger_win.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010 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 "base/debug/debugger.h" 6 | 7 | #include 8 | #include 9 | 10 | namespace base { 11 | namespace debug { 12 | 13 | bool BeingDebugged() { 14 | return ::IsDebuggerPresent() != 0; 15 | } 16 | 17 | void BreakDebugger() { 18 | if (IsDebugUISuppressed()) 19 | _exit(1); 20 | 21 | __debugbreak(); 22 | } 23 | 24 | } // namespace debug 25 | } // namespace base 26 | -------------------------------------------------------------------------------- /src/base/allocator/unittest_utils.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009 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 | // The unittests need a this in order to link up without pulling in tons 6 | // of other libraries 7 | 8 | #include 9 | 10 | inline int snprintf(char* buffer, size_t count, const char* format, ...) { 11 | int result; 12 | va_list args; 13 | va_start(args, format); 14 | result = _vsnprintf(buffer, count, format, args); 15 | va_end(args); 16 | return result; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/base/test/perf_test_suite.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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_TEST_PERF_TEST_SUITE_H_ 6 | #define BASE_TEST_PERF_TEST_SUITE_H_ 7 | 8 | #include "base/test/test_suite.h" 9 | 10 | namespace base { 11 | 12 | class PerfTestSuite : public TestSuite { 13 | public: 14 | PerfTestSuite(int argc, char** argv); 15 | 16 | void Initialize() override; 17 | void Shutdown() override; 18 | }; 19 | 20 | } // namespace base 21 | 22 | #endif // BASE_TEST_PERF_TEST_SUITE_H_ 23 | -------------------------------------------------------------------------------- /src/base/third_party/symbolize/BUILD.gn: -------------------------------------------------------------------------------- 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 | source_set("symbolize") { 6 | visibility = [ "//base/*" ] 7 | sources = [ 8 | "config.h", 9 | "demangle.cc", 10 | "demangle.h", 11 | "glog/logging.h", 12 | "glog/raw_logging.h", 13 | "symbolize.cc", 14 | "symbolize.h", 15 | "utilities.h", 16 | ] 17 | 18 | configs -= [ "//build/config/compiler:chromium_code" ] 19 | configs += [ "//build/config/compiler:no_chromium_code" ] 20 | } 21 | -------------------------------------------------------------------------------- /src/base/process/process_metrics_unittest_ios.cc: -------------------------------------------------------------------------------- 1 | // Copyright 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 | #include "base/process/process_metrics.h" 6 | 7 | #include "base/memory/scoped_ptr.h" 8 | #include "testing/gtest/include/gtest/gtest.h" 9 | 10 | TEST(ProcessMetricsTestIos, Memory) { 11 | scoped_ptr process_metrics( 12 | base::ProcessMetrics::CreateProcessMetrics( 13 | base::GetCurrentProcessHandle())); 14 | 15 | ASSERT_NE(0u, process_metrics->GetWorkingSetSize()); 16 | } 17 | -------------------------------------------------------------------------------- /src/base/power_monitor/power_monitor_device_source_android.h: -------------------------------------------------------------------------------- 1 | // Copyright 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_POWER_MONITOR_POWER_MONITOR_DEVICE_SOURCE_ANDROID_H_ 6 | #define BASE_POWER_MONITOR_POWER_MONITOR_DEVICE_SOURCE_ANDROID_H_ 7 | 8 | #include 9 | 10 | namespace base { 11 | 12 | // Registers the JNI bindings for PowerMonitorDeviceSource. 13 | bool RegisterPowerMonitor(JNIEnv* env); 14 | 15 | } // namespace base 16 | 17 | #endif // BASE_POWER_MONITOR_POWER_MONITOR_DEVICE_SOURCE_ANDROID_H_ 18 | -------------------------------------------------------------------------------- /src/base/test/launcher/test_launcher_ios.cc: -------------------------------------------------------------------------------- 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 3 | // found in the LICENSE file. 4 | 5 | #include "base/test/launcher/test_launcher.h" 6 | 7 | #include "base/at_exit.h" 8 | #include "base/bind.h" 9 | #include "base/test/launcher/unit_test_launcher.h" 10 | 11 | namespace { 12 | 13 | int DummyRunTestSuite(void) { 14 | return -1; 15 | } 16 | 17 | } // namespace 18 | 19 | int main(int argc, char** argv) { 20 | base::AtExitManager at_exit; 21 | return base::LaunchUnitTests(argc, argv, base::Bind(&DummyRunTestSuite)); 22 | } 23 | -------------------------------------------------------------------------------- /src/base/synchronization/cancellation_flag.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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 "base/synchronization/cancellation_flag.h" 6 | 7 | #include "base/logging.h" 8 | 9 | namespace base { 10 | 11 | void CancellationFlag::Set() { 12 | #if !defined(NDEBUG) 13 | DCHECK_EQ(set_on_, PlatformThread::CurrentId()); 14 | #endif 15 | base::subtle::Release_Store(&flag_, 1); 16 | } 17 | 18 | bool CancellationFlag::IsSet() const { 19 | return base::subtle::Acquire_Load(&flag_) != 0; 20 | } 21 | 22 | } // namespace base 23 | -------------------------------------------------------------------------------- /src/base/strings/latin1_string_conversions.cc: -------------------------------------------------------------------------------- 1 | // Copyright 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 | #include "base/strings/latin1_string_conversions.h" 6 | 7 | namespace base { 8 | 9 | string16 Latin1OrUTF16ToUTF16(size_t length, 10 | const Latin1Char* latin1, 11 | const char16* utf16) { 12 | if (!length) 13 | return string16(); 14 | if (latin1) 15 | return string16(latin1, latin1 + length); 16 | return string16(utf16, utf16 + length); 17 | } 18 | 19 | } // namespace base 20 | -------------------------------------------------------------------------------- /src/base/threading/non_thread_safe_impl.cc: -------------------------------------------------------------------------------- 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 "base/threading/non_thread_safe_impl.h" 6 | 7 | #include "base/logging.h" 8 | 9 | namespace base { 10 | 11 | bool NonThreadSafeImpl::CalledOnValidThread() const { 12 | return thread_checker_.CalledOnValidThread(); 13 | } 14 | 15 | NonThreadSafeImpl::~NonThreadSafeImpl() { 16 | DCHECK(CalledOnValidThread()); 17 | } 18 | 19 | void NonThreadSafeImpl::DetachFromThread() { 20 | thread_checker_.DetachFromThread(); 21 | } 22 | 23 | } // namespace base 24 | -------------------------------------------------------------------------------- /src/base/third_party/nspr/BUILD.gn: -------------------------------------------------------------------------------- 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 | source_set("nspr") { 6 | visibility = [ "//base" ] 7 | sources = [ 8 | "prtime.cc", 9 | "prtime.h", 10 | ] 11 | 12 | # In GYP this project is part of base, so it uses the base implementation 13 | # define. TODO(brettw) rename this define. 14 | defines = [ "BASE_IMPLEMENTATION" ] 15 | 16 | if (is_android && !is_debug) { 17 | configs -= [ "//build/config/compiler:optimize" ] 18 | configs += [ "//build/config/compiler:optimize_max" ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/base/base_paths_mac.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006-2008 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_BASE_PATHS_MAC_H_ 6 | #define BASE_BASE_PATHS_MAC_H_ 7 | 8 | // This file declares Mac-specific path keys for the base module. 9 | // These can be used with the PathService to access various special 10 | // directories and files. 11 | 12 | namespace base { 13 | 14 | enum { 15 | PATH_MAC_START = 200, 16 | 17 | DIR_APP_DATA, // ~/Library/Application Support 18 | 19 | PATH_MAC_END 20 | }; 21 | 22 | } // namespace base 23 | 24 | #endif // BASE_BASE_PATHS_MAC_H_ 25 | -------------------------------------------------------------------------------- /src/base/debug/alias.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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_DEBUG_ALIAS_H_ 6 | #define BASE_DEBUG_ALIAS_H_ 7 | 8 | #include "base/base_export.h" 9 | 10 | namespace base { 11 | namespace debug { 12 | 13 | // Make the optimizer think that var is aliased. This is to prevent it from 14 | // optimizing out variables that that would not otherwise be live at the point 15 | // of a potential crash. 16 | void BASE_EXPORT Alias(const void* var); 17 | 18 | } // namespace debug 19 | } // namespace base 20 | 21 | #endif // BASE_DEBUG_ALIAS_H_ 22 | -------------------------------------------------------------------------------- /src/base/hash.cc: -------------------------------------------------------------------------------- 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 3 | // found in the LICENSE file. 4 | 5 | #include "base/hash.h" 6 | 7 | // Definition in base/third_party/superfasthash/superfasthash.c. (Third-party 8 | // code did not come with its own header file, so declaring the function here.) 9 | // Note: This algorithm is also in Blink under Source/wtf/StringHasher.h. 10 | extern "C" uint32_t SuperFastHash(const char* data, int len); 11 | 12 | namespace base { 13 | 14 | uint32 SuperFastHash(const char* data, int len) { 15 | return ::SuperFastHash(data, len); 16 | } 17 | 18 | } // namespace base 19 | -------------------------------------------------------------------------------- /src/base/files/file_enumerator.cc: -------------------------------------------------------------------------------- 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 | #include "base/files/file_enumerator.h" 6 | 7 | #include "base/files/file_util.h" 8 | 9 | namespace base { 10 | 11 | FileEnumerator::FileInfo::~FileInfo() { 12 | } 13 | 14 | bool FileEnumerator::ShouldSkip(const FilePath& path) { 15 | FilePath::StringType basename = path.BaseName().value(); 16 | return basename == FILE_PATH_LITERAL(".") || 17 | (basename == FILE_PATH_LITERAL("..") && 18 | !(INCLUDE_DOT_DOT & file_type_)); 19 | } 20 | 21 | } // namespace base 22 | -------------------------------------------------------------------------------- /src/base/third_party/icu/README.chromium: -------------------------------------------------------------------------------- 1 | Name: ICU 2 | URL: http://site.icu-project.org/ 3 | License: MIT 4 | License File: NOT_SHIPPED 5 | 6 | This file has the relevant components from ICU copied to handle basic 7 | UTF8/16/32 conversions. Components are copied from utf.h utf8.h utf16.h and 8 | utf_impl.c 9 | 10 | The same module appears in third_party/icu, so we don't repeat the license 11 | file here. 12 | 13 | The main change is that U_/U8_/U16_ prefixes have been replaced with 14 | CBU_/CBU8_/CBU16_ (for "Chrome Base") to avoid confusion with the "real" ICU 15 | macros should ICU be in use on the system. For the same reason, the functions 16 | and types have been put in the "base_icu" namespace. 17 | -------------------------------------------------------------------------------- /src/test_qt/test_qt.ui: -------------------------------------------------------------------------------- 1 | 2 | test_qtClass 3 | 4 | 5 | test_qtClass 6 | 7 | 8 | 9 | 0 10 | 0 11 | 600 12 | 400 13 | 14 | 15 | 16 | test_qt 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/base/test/android/javatests/src/org/chromium/base/test/util/MinAndroidSdkLevel.java: -------------------------------------------------------------------------------- 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 3 | // found in the LICENSE file. 4 | 5 | package org.chromium.base.test.util; 6 | 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Inherited; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | @Inherited 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Target({ElementType.TYPE}) 16 | public @interface MinAndroidSdkLevel { 17 | int value() default 0; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /src/base/test/simple_test_clock.cc: -------------------------------------------------------------------------------- 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 "base/test/simple_test_clock.h" 6 | 7 | namespace base { 8 | 9 | SimpleTestClock::SimpleTestClock() {} 10 | 11 | SimpleTestClock::~SimpleTestClock() {} 12 | 13 | Time SimpleTestClock::Now() { 14 | AutoLock lock(lock_); 15 | return now_; 16 | } 17 | 18 | void SimpleTestClock::Advance(TimeDelta delta) { 19 | AutoLock lock(lock_); 20 | now_ += delta; 21 | } 22 | 23 | void SimpleTestClock::SetNow(Time now) { 24 | AutoLock lock(lock_); 25 | now_ = now; 26 | } 27 | 28 | } // namespace base 29 | -------------------------------------------------------------------------------- /src/base/third_party/dmg_fp/gcc_64_bit.patch: -------------------------------------------------------------------------------- 1 | Index: dtoa.cc 2 | --- dtoa.cc (old copy) 3 | +++ dtoa.cc (working copy) 4 | @@ -183,8 +183,12 @@ 5 | #define NO_HEX_FP 6 | 7 | #ifndef Long 8 | +#if __LP64__ 9 | +#define Long int 10 | +#else 11 | #define Long long 12 | #endif 13 | +#endif 14 | #ifndef ULong 15 | typedef unsigned Long ULong; 16 | #endif 17 | @@ -221,7 +225,7 @@ extern void *MALLOC(size_t); 18 | #ifndef PRIVATE_MEM 19 | #define PRIVATE_MEM 2304 20 | #endif 21 | -#define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double)) 22 | +#define PRIVATE_mem ((unsigned)((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))) 23 | static double private_mem[PRIVATE_mem], *pmem_next = private_mem; 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /src/base/os_compat_nacl.cc: -------------------------------------------------------------------------------- 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 "base/os_compat_nacl.h" 6 | 7 | #include 8 | #include 9 | 10 | #if !defined (__GLIBC__) 11 | 12 | extern "C" { 13 | // Native Client has no timegm(). 14 | time_t timegm(struct tm* tm) { 15 | time_t ret; 16 | char* tz; 17 | tz = getenv("TZ"); 18 | setenv("TZ", "", 1); 19 | tzset(); 20 | ret = mktime(tm); 21 | if (tz) 22 | setenv("TZ", tz, 1); 23 | else 24 | unsetenv("TZ"); 25 | tzset(); 26 | return ret; 27 | } 28 | } // extern "C" 29 | 30 | #endif // !defined (__GLIBC__) 31 | -------------------------------------------------------------------------------- /src/base/time/default_clock.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_DEFAULT_CLOCK_H_ 6 | #define BASE_DEFAULT_CLOCK_H_ 7 | 8 | #include "base/base_export.h" 9 | #include "base/compiler_specific.h" 10 | #include "base/time/clock.h" 11 | 12 | namespace base { 13 | 14 | // DefaultClock is a Clock implementation that uses Time::Now(). 15 | class BASE_EXPORT DefaultClock : public Clock { 16 | public: 17 | ~DefaultClock() override; 18 | 19 | // Simply returns Time::Now(). 20 | Time Now() override; 21 | }; 22 | 23 | } // namespace base 24 | 25 | #endif // BASE_DEFAULT_CLOCK_H_ 26 | -------------------------------------------------------------------------------- /src/base/message_loop/timer_slack.h: -------------------------------------------------------------------------------- 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 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_MESSAGE_LOOP_TIMER_SLACK_H_ 6 | #define BASE_MESSAGE_LOOP_TIMER_SLACK_H_ 7 | 8 | namespace base { 9 | 10 | // Amount of timer slack to use for delayed timers. Increasing timer slack 11 | // allows the OS to coalesce timers more effectively. 12 | enum TimerSlack { 13 | // Lowest value for timer slack allowed by OS. 14 | TIMER_SLACK_NONE, 15 | 16 | // Maximal value for timer slack allowed by OS. 17 | TIMER_SLACK_MAXIMUM 18 | }; 19 | 20 | } // namespace base 21 | 22 | #endif // BASE_MESSAGE_LOOP_TIMER_SLACK_H_ 23 | -------------------------------------------------------------------------------- /src/base/prefs/pref_observer.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_PREFS_PREF_OBSERVER_H_ 6 | #define BASE_PREFS_PREF_OBSERVER_H_ 7 | 8 | #include 9 | 10 | class PrefService; 11 | 12 | // Used internally to the Prefs subsystem to pass preference change 13 | // notifications between PrefService, PrefNotifierImpl and 14 | // PrefChangeRegistrar. 15 | class PrefObserver { 16 | public: 17 | virtual void OnPreferenceChanged(PrefService* service, 18 | const std::string& pref_name) = 0; 19 | }; 20 | 21 | #endif // BASE_PREFS_PREF_OBSERVER_H_ 22 | -------------------------------------------------------------------------------- /src/base/profiler/scoped_tracker.cc: -------------------------------------------------------------------------------- 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 3 | // found in the LICENSE file. 4 | 5 | #include "base/profiler/scoped_tracker.h" 6 | 7 | #include "base/bind.h" 8 | 9 | namespace tracked_objects { 10 | 11 | namespace { 12 | 13 | ScopedProfile::Mode g_scoped_profile_mode = ScopedProfile::DISABLED; 14 | 15 | } // namespace 16 | 17 | // static 18 | void ScopedTracker::Enable() { 19 | g_scoped_profile_mode = ScopedProfile::ENABLED; 20 | } 21 | 22 | ScopedTracker::ScopedTracker(const Location& location) 23 | : scoped_profile_(location, g_scoped_profile_mode) { 24 | } 25 | 26 | } // namespace tracked_objects 27 | -------------------------------------------------------------------------------- /src/base/process/process_info_win.cc: -------------------------------------------------------------------------------- 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 "base/process/process_info.h" 6 | 7 | #include 8 | 9 | #include "base/basictypes.h" 10 | #include "base/time/time.h" 11 | 12 | namespace base { 13 | 14 | //static 15 | const Time CurrentProcessInfo::CreationTime() { 16 | FILETIME creation_time = {}; 17 | FILETIME ignore = {}; 18 | if (::GetProcessTimes(::GetCurrentProcess(), &creation_time, &ignore, 19 | &ignore, &ignore) == false) 20 | return Time(); 21 | 22 | return Time::FromFileTime(creation_time); 23 | } 24 | 25 | } // namespace base 26 | -------------------------------------------------------------------------------- /src/base/test/simple_test_tick_clock.cc: -------------------------------------------------------------------------------- 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 "base/test/simple_test_tick_clock.h" 6 | 7 | #include "base/logging.h" 8 | 9 | namespace base { 10 | 11 | SimpleTestTickClock::SimpleTestTickClock() {} 12 | 13 | SimpleTestTickClock::~SimpleTestTickClock() {} 14 | 15 | TimeTicks SimpleTestTickClock::NowTicks() { 16 | AutoLock lock(lock_); 17 | return now_ticks_; 18 | } 19 | 20 | void SimpleTestTickClock::Advance(TimeDelta delta) { 21 | AutoLock lock(lock_); 22 | DCHECK(delta >= TimeDelta()); 23 | now_ticks_ += delta; 24 | } 25 | 26 | } // namespace base 27 | -------------------------------------------------------------------------------- /src/base/test/scoped_locale.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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 "base/test/scoped_locale.h" 6 | 7 | #include 8 | 9 | #include "testing/gtest/include/gtest/gtest.h" 10 | 11 | namespace base { 12 | 13 | ScopedLocale::ScopedLocale(const std::string& locale) { 14 | prev_locale_ = setlocale(LC_ALL, NULL); 15 | EXPECT_TRUE(setlocale(LC_ALL, locale.c_str()) != NULL) << 16 | "Failed to set locale: " << locale; 17 | } 18 | 19 | ScopedLocale::~ScopedLocale() { 20 | EXPECT_STREQ(prev_locale_.c_str(), setlocale(LC_ALL, prev_locale_.c_str())); 21 | } 22 | 23 | } // namespace base 24 | -------------------------------------------------------------------------------- /src/base/mac/OWNERS: -------------------------------------------------------------------------------- 1 | mark@chromium.org 2 | thakis@chromium.org 3 | 4 | # sdk_forward_declarations.[h|mm] will likely need to be modified by Cocoa 5 | # developers in general; keep in sync with OWNERS of //chrome/browser/ui/cocoa. 6 | per-file sdk_forward_declarations.*=asvitkine@chromium.org 7 | per-file sdk_forward_declarations.*=avi@chromium.org 8 | per-file sdk_forward_declarations.*=groby@chromium.org 9 | per-file sdk_forward_declarations.*=jeremy@chromium.org 10 | per-file sdk_forward_declarations.*=mark@chromium.org 11 | per-file sdk_forward_declarations.*=rohitrao@chromium.org 12 | per-file sdk_forward_declarations.*=rsesek@chromium.org 13 | per-file sdk_forward_declarations.*=shess@chromium.org 14 | per-file sdk_forward_declarations.*=thakis@chromium.org 15 | -------------------------------------------------------------------------------- /src/base/test/test_file_util.cc: -------------------------------------------------------------------------------- 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 | #include "base/test/test_file_util.h" 6 | 7 | #include "base/test/test_timeouts.h" 8 | #include "base/threading/platform_thread.h" 9 | 10 | namespace base { 11 | 12 | bool EvictFileFromSystemCacheWithRetry(const FilePath& path) { 13 | const int kCycles = 10; 14 | const TimeDelta kDelay = TestTimeouts::action_timeout() / kCycles; 15 | for (int i = 0; i < kCycles; i++) { 16 | if (EvictFileFromSystemCache(path)) 17 | return true; 18 | PlatformThread::Sleep(kDelay); 19 | } 20 | return false; 21 | } 22 | 23 | } // namespace base 24 | -------------------------------------------------------------------------------- /src/base/timer/hi_res_timer_manager_posix.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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 "base/timer/hi_res_timer_manager.h" 6 | 7 | // On POSIX we don't need to do anything special with the system timer. 8 | 9 | namespace base { 10 | 11 | HighResolutionTimerManager::HighResolutionTimerManager() 12 | : hi_res_clock_available_(false) { 13 | } 14 | 15 | HighResolutionTimerManager::~HighResolutionTimerManager() { 16 | } 17 | 18 | void HighResolutionTimerManager::OnPowerStateChange(bool on_battery_power) { 19 | } 20 | 21 | void HighResolutionTimerManager::UseHiResClock(bool use) { 22 | } 23 | 24 | } // namespace base 25 | -------------------------------------------------------------------------------- /src/base/process/memory.cc: -------------------------------------------------------------------------------- 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 3 | // found in the LICENSE file. 4 | 5 | #include "base/process/memory.h" 6 | 7 | namespace base { 8 | 9 | // Defined in memory_mac.mm for Mac. 10 | #if !defined(OS_MACOSX) 11 | 12 | bool UncheckedCalloc(size_t num_items, size_t size, void** result) { 13 | const size_t alloc_size = num_items * size; 14 | 15 | // Overflow check 16 | if (size && ((alloc_size / size) != num_items)) { 17 | *result = NULL; 18 | return false; 19 | } 20 | 21 | if (!UncheckedMalloc(alloc_size, result)) 22 | return false; 23 | 24 | memset(*result, 0, alloc_size); 25 | return true; 26 | } 27 | 28 | #endif 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/base/test/test_support_ios.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_TEST_TEST_SUPPORT_IOS_H_ 6 | #define BASE_TEST_TEST_SUPPORT_IOS_H_ 7 | 8 | #include "base/test/test_suite.h" 9 | 10 | namespace base { 11 | 12 | // Inits the message loop for tests on iOS. 13 | void InitIOSTestMessageLoop(); 14 | 15 | // Inits the run hook for tests on iOS. 16 | void InitIOSRunHook(TestSuite* suite, int argc, char* argv[]); 17 | 18 | // Launches an iOS app that runs the tests in the suite passed to 19 | // InitIOSRunHook. 20 | void RunTestsFromIOSApp(); 21 | 22 | } // namespace base 23 | 24 | #endif // BASE_TEST_TEST_SUPPORT_IOS_H_ 25 | -------------------------------------------------------------------------------- /src/base/mac/scoped_sending_event.mm: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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 | #import "base/mac/scoped_sending_event.h" 6 | 7 | #include "base/logging.h" 8 | 9 | namespace base { 10 | namespace mac { 11 | 12 | ScopedSendingEvent::ScopedSendingEvent() 13 | : app_(static_cast*>(NSApp)) { 14 | DCHECK([app_ conformsToProtocol:@protocol(CrAppControlProtocol)]); 15 | handling_ = [app_ isHandlingSendEvent]; 16 | [app_ setHandlingSendEvent:YES]; 17 | } 18 | 19 | ScopedSendingEvent::~ScopedSendingEvent() { 20 | [app_ setHandlingSendEvent:handling_]; 21 | } 22 | 23 | } // namespace mac 24 | } // namespace base 25 | -------------------------------------------------------------------------------- /src/base/time/default_tick_clock.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_DEFAULT_TICK_CLOCK_H_ 6 | #define BASE_DEFAULT_TICK_CLOCK_H_ 7 | 8 | #include "base/base_export.h" 9 | #include "base/compiler_specific.h" 10 | #include "base/time/tick_clock.h" 11 | 12 | namespace base { 13 | 14 | // DefaultClock is a Clock implementation that uses TimeTicks::Now(). 15 | class BASE_EXPORT DefaultTickClock : public TickClock { 16 | public: 17 | ~DefaultTickClock() override; 18 | 19 | // Simply returns TimeTicks::Now(). 20 | TimeTicks NowTicks() override; 21 | }; 22 | 23 | } // namespace base 24 | 25 | #endif // BASE_DEFAULT_CLOCK_H_ 26 | -------------------------------------------------------------------------------- /src/base/test/android/javatests/src/org/chromium/base/test/util/TimeoutScale.java: -------------------------------------------------------------------------------- 1 | // Copyright 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 | package org.chromium.base.test.util; 6 | 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * This annotation can be used to scale a specific test timeout. 14 | */ 15 | @Target(ElementType.METHOD) 16 | @Retention(RetentionPolicy.RUNTIME) 17 | public @interface TimeoutScale { 18 | /** 19 | * @return A number to scale the test timeout. 20 | */ 21 | public int value(); 22 | } 23 | -------------------------------------------------------------------------------- /src/base/check_example.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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 | // This file is meant for analyzing the code generated by the CHECK 6 | // macros in a small executable file that's easy to disassemble. 7 | 8 | #include "base/logging.h" 9 | 10 | // An official build shouldn't generate code to print out messages for 11 | // the CHECK* macros, nor should it have the strings in the 12 | // executable. 13 | 14 | void DoCheck(bool b) { 15 | CHECK(b) << "DoCheck " << b; 16 | } 17 | 18 | void DoCheckEq(int x, int y) { 19 | CHECK_EQ(x, y); 20 | } 21 | 22 | int main(int argc, const char* argv[]) { 23 | DoCheck(argc > 1); 24 | DoCheckEq(argc, 1); 25 | } 26 | -------------------------------------------------------------------------------- /src/base/test/scoped_locale.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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_TEST_SCOPED_LOCALE_H_ 6 | #define BASE_TEST_SCOPED_LOCALE_H_ 7 | 8 | #include 9 | 10 | #include "base/basictypes.h" 11 | 12 | namespace base { 13 | 14 | // Sets the given |locale| on construction, and restores the previous locale 15 | // on destruction. 16 | class ScopedLocale { 17 | public: 18 | explicit ScopedLocale(const std::string& locale); 19 | ~ScopedLocale(); 20 | 21 | private: 22 | std::string prev_locale_; 23 | 24 | DISALLOW_COPY_AND_ASSIGN(ScopedLocale); 25 | }; 26 | 27 | } // namespace base 28 | 29 | #endif // BASE_TEST_SCOPED_LOCALE_H_ 30 | -------------------------------------------------------------------------------- /src/base/mac/os_crash_dumps.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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_MAC_OS_CRASH_DUMPS_H_ 6 | #define BASE_MAC_OS_CRASH_DUMPS_H_ 7 | 8 | #include "base/base_export.h" 9 | 10 | namespace base { 11 | namespace mac { 12 | 13 | // On Mac OS X, it can take a really long time for the OS crash handler to 14 | // process a Chrome crash when debugging symbols are available. This 15 | // translates into a long wait until the process actually dies. This call 16 | // disables Apple Crash Reporter entirely. 17 | BASE_EXPORT void DisableOSCrashDumps(); 18 | 19 | } // namespace mac 20 | } // namespace base 21 | 22 | #endif // BASE_MAC_OS_CRASH_DUMPS_H_ 23 | -------------------------------------------------------------------------------- /src/base/memory/scoped_policy.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_MEMORY_SCOPED_POLICY_H_ 6 | #define BASE_MEMORY_SCOPED_POLICY_H_ 7 | 8 | namespace base { 9 | namespace scoped_policy { 10 | 11 | // Defines the ownership policy for a scoped object. 12 | enum OwnershipPolicy { 13 | // The scoped object takes ownership of an object by taking over an existing 14 | // ownership claim. 15 | ASSUME, 16 | 17 | // The scoped object will retain the the object and any initial ownership is 18 | // not changed. 19 | RETAIN 20 | }; 21 | 22 | } // namespace scoped_policy 23 | } // namespace base 24 | 25 | #endif // BASE_MEMORY_SCOPED_POLICY_H_ 26 | -------------------------------------------------------------------------------- /src/base/strings/sys_string_conversions_mac_unittest.mm: -------------------------------------------------------------------------------- 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 | #import 6 | 7 | #include "base/strings/string16.h" 8 | #include "base/strings/sys_string_conversions.h" 9 | #include "testing/gtest/include/gtest/gtest.h" 10 | 11 | namespace base { 12 | 13 | TEST(SysStrings, ConversionsFromNSString) { 14 | EXPECT_STREQ("Hello, world!", SysNSStringToUTF8(@"Hello, world!").c_str()); 15 | 16 | // Conversions should be able to handle a NULL value without crashing. 17 | EXPECT_STREQ("", SysNSStringToUTF8(nil).c_str()); 18 | EXPECT_EQ(string16(), SysNSStringToUTF16(nil)); 19 | } 20 | 21 | } // namespace base 22 | -------------------------------------------------------------------------------- /src/base/base_paths_android.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_BASE_PATHS_ANDROID_H_ 6 | #define BASE_BASE_PATHS_ANDROID_H_ 7 | 8 | // This file declares Android-specific path keys for the base module. 9 | // These can be used with the PathService to access various special 10 | // directories and files. 11 | 12 | namespace base { 13 | 14 | enum { 15 | PATH_ANDROID_START = 300, 16 | 17 | DIR_ANDROID_APP_DATA, // Directory where to put Android app's data. 18 | DIR_ANDROID_EXTERNAL_STORAGE, // Android external storage directory. 19 | 20 | PATH_ANDROID_END 21 | }; 22 | 23 | } // namespace base 24 | 25 | #endif // BASE_BASE_PATHS_ANDROID_H_ 26 | -------------------------------------------------------------------------------- /src/base/guid.cc: -------------------------------------------------------------------------------- 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 "base/guid.h" 6 | 7 | #include "base/strings/string_util.h" 8 | 9 | namespace base { 10 | 11 | bool IsValidGUID(const std::string& guid) { 12 | const size_t kGUIDLength = 36U; 13 | if (guid.length() != kGUIDLength) 14 | return false; 15 | 16 | for (size_t i = 0; i < guid.length(); ++i) { 17 | char current = guid[i]; 18 | if (i == 8 || i == 13 || i == 18 || i == 23) { 19 | if (current != '-') 20 | return false; 21 | } else { 22 | if (!IsHexDigit(current)) 23 | return false; 24 | } 25 | } 26 | 27 | return true; 28 | } 29 | 30 | } // namespace base 31 | -------------------------------------------------------------------------------- /src/base/process/process_info.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_PROCESS_PROCESS_PROCESS_INFO_H_ 6 | #define BASE_PROCESS_PROCESS_PROCESS_INFO_H_ 7 | 8 | #include "base/base_export.h" 9 | #include "base/basictypes.h" 10 | 11 | namespace base { 12 | 13 | class Time; 14 | 15 | // Vends information about the current process. 16 | class BASE_EXPORT CurrentProcessInfo { 17 | public: 18 | // Returns the time at which the process was launched. May be empty if an 19 | // error occurred retrieving the information. 20 | static const Time CreationTime(); 21 | }; 22 | 23 | } // namespace base 24 | 25 | #endif // BASE_PROCESS_PROCESS_PROCESS_INFO_H_ 26 | -------------------------------------------------------------------------------- /src/base/sys_info_internal.h: -------------------------------------------------------------------------------- 1 | // Copyright 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_SYS_INFO_INTERNAL_H_ 6 | #define BASE_SYS_INFO_INTERNAL_H_ 7 | 8 | #include "base/basictypes.h" 9 | 10 | namespace base { 11 | 12 | namespace internal { 13 | 14 | template 15 | class LazySysInfoValue { 16 | public: 17 | LazySysInfoValue() 18 | : value_(F()) { } 19 | 20 | ~LazySysInfoValue() { } 21 | 22 | T value() { return value_; } 23 | 24 | private: 25 | const T value_; 26 | 27 | DISALLOW_COPY_AND_ASSIGN(LazySysInfoValue); 28 | }; 29 | 30 | } // namespace internal 31 | 32 | } // namespace base 33 | 34 | #endif // BASE_SYS_INFO_INTERNAL_H_ 35 | -------------------------------------------------------------------------------- /src/base/debug/gdi_debug_util_win.h: -------------------------------------------------------------------------------- 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 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_DEBUG_GDI_DEBUG_UTIL_WIN_H_ 6 | #define BASE_DEBUG_GDI_DEBUG_UTIL_WIN_H_ 7 | 8 | #include 9 | 10 | #include "base/base_export.h" 11 | 12 | namespace base { 13 | namespace debug { 14 | 15 | // Crashes the process leaving valuable information on the dump via 16 | // debug::alias so we can find what is causing the allocation failures. 17 | void BASE_EXPORT GDIBitmapAllocFailure(BITMAPINFOHEADER* header, 18 | HANDLE shared_section); 19 | 20 | } // namespace debug 21 | } // namespace base 22 | 23 | #endif // BASE_DEBUG_GDI_DEBUG_UTIL_WIN_H_ 24 | -------------------------------------------------------------------------------- /src/base/test/android/javatests/src/org/chromium/base/test/util/DisabledTest.java: -------------------------------------------------------------------------------- 1 | // Copyright 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 | package org.chromium.base.test.util; 6 | 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * This annotation is for disabled tests. 14 | *

15 | * Tests with this annotation will not be run on any of the normal bots. 16 | * Please note that they might eventually run on a special bot. 17 | */ 18 | @Target(ElementType.METHOD) 19 | @Retention(RetentionPolicy.RUNTIME) 20 | public @interface DisabledTest { 21 | } 22 | -------------------------------------------------------------------------------- /src/base/test/android/javatests/src/org/chromium/base/test/util/Manual.java: -------------------------------------------------------------------------------- 1 | // Copyright 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 | package org.chromium.base.test.util; 6 | 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * This annotation can be used to mark a test that should only be run manually. 14 | *

15 | * Tests with this annotation will not be run on bots, because they take too long 16 | * or need manual monitoring. 17 | */ 18 | @Target(ElementType.METHOD) 19 | @Retention(RetentionPolicy.RUNTIME) 20 | public @interface Manual { 21 | } 22 | -------------------------------------------------------------------------------- /src/base/tracking_info.cc: -------------------------------------------------------------------------------- 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 "base/tracking_info.h" 6 | 7 | #include 8 | #include "base/tracked_objects.h" 9 | 10 | namespace base { 11 | 12 | TrackingInfo::TrackingInfo() 13 | : birth_tally(NULL) { 14 | } 15 | 16 | TrackingInfo::TrackingInfo( 17 | const tracked_objects::Location& posted_from, 18 | base::TimeTicks delayed_run_time) 19 | : birth_tally( 20 | tracked_objects::ThreadData::TallyABirthIfActive(posted_from)), 21 | time_posted(TimeTicks::Now()), 22 | delayed_run_time(delayed_run_time) { 23 | } 24 | 25 | TrackingInfo::~TrackingInfo() {} 26 | 27 | } // namespace base 28 | 29 | -------------------------------------------------------------------------------- /src/base/event_recorder_stubs.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009 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 "base/event_recorder.h" 6 | 7 | // This file implements a link stub for EventRecorder that can be used on 8 | // platforms that don't have a working EventRecorder implementation. 9 | 10 | namespace base { 11 | 12 | EventRecorder* EventRecorder::current_; // Our singleton. 13 | 14 | bool EventRecorder::StartRecording(const FilePath& filename) { 15 | return true; 16 | } 17 | 18 | void EventRecorder::StopRecording() { 19 | } 20 | 21 | bool EventRecorder::StartPlayback(const FilePath& filename) { 22 | return false; 23 | } 24 | 25 | void EventRecorder::StopPlayback() { 26 | } 27 | 28 | } // namespace 29 | -------------------------------------------------------------------------------- /src/third_party/libevent/event-config.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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 | // This file is Chromium-specific, and brings in the appropriate 6 | // event-config.h depending on your platform. 7 | 8 | #if defined(__native_client_nonsfi__) 9 | #include "nacl_nonsfi/event-config.h" 10 | #elif defined(__APPLE__) 11 | #include "mac/event-config.h" 12 | #elif defined(ANDROID) 13 | #include "android/event-config.h" 14 | #elif defined(__linux__) 15 | #include "linux/event-config.h" 16 | #elif defined(__FreeBSD__) 17 | #include "freebsd/event-config.h" 18 | #elif defined(__sun) 19 | #include "solaris/event-config.h" 20 | #else 21 | #error generate event-config.h for your platform 22 | #endif 23 | -------------------------------------------------------------------------------- /src/third_party/libevent/test/test-init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Compile with: 3 | * cc -I/usr/local/include -o time-test time-test.c -L/usr/local/lib -levent 4 | */ 5 | #ifdef HAVE_CONFIG_H 6 | #include "config.h" 7 | #endif 8 | 9 | #ifdef WIN32 10 | #include 11 | #endif 12 | 13 | #include 14 | #include 15 | #ifdef HAVE_SYS_TIME_H 16 | #include 17 | #endif 18 | #ifdef HAVE_SYS_SOCKET_H 19 | #include 20 | #endif 21 | #include 22 | #include 23 | #include 24 | #include 25 | #ifdef HAVE_UNISTD_H 26 | #include 27 | #endif 28 | #include 29 | 30 | #include 31 | 32 | int 33 | main(int argc, char **argv) 34 | { 35 | /* Initalize the event library */ 36 | event_init(); 37 | 38 | return (0); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /src/base/debug_message.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006-2008 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 6 | 7 | // Display the command line. This program is designed to be called from 8 | // another process to display assertions. Since the other process has 9 | // complete control of our command line, we assume that it did *not* 10 | // add the program name as the first parameter. This allows us to just 11 | // show the command line directly as the message. 12 | int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 13 | LPSTR lpCmdLine, int nCmdShow) { 14 | LPWSTR cmdline = GetCommandLineW(); 15 | MessageBox(NULL, cmdline, L"Kr\x00d8m", MB_TOPMOST); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /src/base/test/test_file_util_linux.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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 "base/test/test_file_util.h" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "base/files/file_path.h" 13 | #include "base/files/scoped_file.h" 14 | 15 | namespace base { 16 | 17 | bool EvictFileFromSystemCache(const FilePath& file) { 18 | ScopedFD fd(open(file.value().c_str(), O_RDONLY)); 19 | if (!fd.is_valid()) 20 | return false; 21 | if (fdatasync(fd.get()) != 0) 22 | return false; 23 | if (posix_fadvise(fd.get(), 0, 0, POSIX_FADV_DONTNEED) != 0) 24 | return false; 25 | return true; 26 | } 27 | 28 | } // namespace base 29 | -------------------------------------------------------------------------------- /src/base/third_party/xdg_mime/BUILD.gn: -------------------------------------------------------------------------------- 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 | source_set("xdg_mime") { 6 | visibility = [ "//base/*" ] 7 | sources = [ 8 | "xdgmime.c", 9 | "xdgmime.h", 10 | "xdgmimealias.c", 11 | "xdgmimealias.h", 12 | "xdgmimecache.c", 13 | "xdgmimecache.h", 14 | "xdgmimeglob.c", 15 | "xdgmimeglob.h", 16 | "xdgmimeicon.c", 17 | "xdgmimeicon.h", 18 | "xdgmimeint.c", 19 | "xdgmimeint.h", 20 | "xdgmimemagic.c", 21 | "xdgmimemagic.h", 22 | "xdgmimeparent.c", 23 | "xdgmimeparent.h", 24 | ] 25 | 26 | configs -= [ "//build/config/compiler:chromium_code" ] 27 | configs += [ "//build/config/compiler:no_chromium_code" ] 28 | } 29 | -------------------------------------------------------------------------------- /src/base/test/android/javatests/src/org/chromium/base/test/util/HostDrivenTest.java: -------------------------------------------------------------------------------- 1 | // Copyright 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 | package org.chromium.base.test.util; 6 | 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * This annotation is for host-driven tests. 14 | *

15 | * Tests with these annotations are run explicitly by HostDrivenTestCase-derived 16 | * python tests on the host and are excluded from regular instrumentation test runs. 17 | *

18 | */ 19 | @Target(ElementType.METHOD) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | public @interface HostDrivenTest { 22 | } 23 | -------------------------------------------------------------------------------- /src/base/timer/elapsed_timer.h: -------------------------------------------------------------------------------- 1 | // Copyright 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_TIMER_ELAPSED_TIMER_H_ 6 | #define BASE_TIMER_ELAPSED_TIMER_H_ 7 | 8 | #include "base/base_export.h" 9 | #include "base/basictypes.h" 10 | #include "base/time/time.h" 11 | 12 | namespace base { 13 | 14 | // A simple wrapper around TimeTicks::Now(). 15 | class BASE_EXPORT ElapsedTimer { 16 | public: 17 | ElapsedTimer(); 18 | virtual ~ElapsedTimer() {} 19 | 20 | // Returns the time elapsed since object construction. 21 | virtual TimeDelta Elapsed() const; 22 | 23 | private: 24 | TimeTicks begin_; 25 | 26 | DISALLOW_COPY_AND_ASSIGN(ElapsedTimer); 27 | }; 28 | 29 | } // namespace base 30 | 31 | #endif // BASE_TIMER_ELAPSED_TIMER_H_ 32 | -------------------------------------------------------------------------------- /src/base/process/kill.cc: -------------------------------------------------------------------------------- 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 | #include "base/process/kill.h" 6 | 7 | #include "base/process/process_iterator.h" 8 | 9 | namespace base { 10 | 11 | bool KillProcesses(const FilePath::StringType& executable_name, 12 | int exit_code, 13 | const ProcessFilter* filter) { 14 | bool result = true; 15 | NamedProcessIterator iter(executable_name, filter); 16 | while (const ProcessEntry* entry = iter.NextProcessEntry()) { 17 | #if defined(OS_WIN) 18 | result &= KillProcessById(entry->pid(), exit_code, true); 19 | #else 20 | result &= KillProcess(entry->pid(), exit_code, true); 21 | #endif 22 | } 23 | return result; 24 | } 25 | 26 | } // namespace base 27 | -------------------------------------------------------------------------------- /src/base/test/perf_time_logger.cc: -------------------------------------------------------------------------------- 1 | // Copyright 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 | #include "base/test/perf_time_logger.h" 6 | 7 | #include "base/test/perf_log.h" 8 | 9 | namespace base { 10 | 11 | PerfTimeLogger::PerfTimeLogger(const char* test_name) 12 | : logged_(false), test_name_(test_name) {} 13 | 14 | PerfTimeLogger::~PerfTimeLogger() { 15 | if (!logged_) 16 | Done(); 17 | } 18 | 19 | void PerfTimeLogger::Done() { 20 | // we use a floating-point millisecond value because it is more 21 | // intuitive than microseconds and we want more precision than 22 | // integer milliseconds 23 | LogPerfResult(test_name_.c_str(), timer_.Elapsed().InMillisecondsF(), "ms"); 24 | logged_ = true; 25 | } 26 | 27 | } // namespace base 28 | -------------------------------------------------------------------------------- /src/base/test/test_support_android.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_TEST_TEST_SUPPORT_ANDROID_H_ 6 | #define BASE_TEST_TEST_SUPPORT_ANDROID_H_ 7 | 8 | #include "base/base_export.h" 9 | 10 | namespace base { 11 | 12 | // Init logging for tests on Android. Logs will be output into Android's logcat. 13 | BASE_EXPORT void InitAndroidTestLogging(); 14 | 15 | // Init path providers for tests on Android. 16 | BASE_EXPORT void InitAndroidTestPaths(); 17 | 18 | // Init the message loop for tests on Android. 19 | BASE_EXPORT void InitAndroidTestMessageLoop(); 20 | 21 | // Do all of the initializations above. 22 | BASE_EXPORT void InitAndroidTest(); 23 | 24 | } // namespace base 25 | 26 | #endif // BASE_TEST_TEST_SUPPORT_ANDROID_H_ 27 | -------------------------------------------------------------------------------- /src/base/base64.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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_BASE64_H__ 6 | #define BASE_BASE64_H__ 7 | 8 | #include 9 | 10 | #include "base/base_export.h" 11 | #include "base/strings/string_piece.h" 12 | 13 | namespace base { 14 | 15 | // Encodes the input string in base64. The encoding can be done in-place. 16 | BASE_EXPORT void Base64Encode(const StringPiece& input, std::string* output); 17 | 18 | // Decodes the base64 input string. Returns true if successful and false 19 | // otherwise. The output string is only modified if successful. The decoding can 20 | // be done in-place. 21 | BASE_EXPORT bool Base64Decode(const StringPiece& input, std::string* output); 22 | 23 | } // namespace base 24 | 25 | #endif // BASE_BASE64_H__ 26 | -------------------------------------------------------------------------------- /src/base/test/null_task_runner.cc: -------------------------------------------------------------------------------- 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 "base/test/null_task_runner.h" 6 | 7 | namespace base { 8 | 9 | NullTaskRunner::NullTaskRunner() {} 10 | 11 | NullTaskRunner::~NullTaskRunner() {} 12 | 13 | bool NullTaskRunner::PostDelayedTask( 14 | const tracked_objects::Location& from_here, 15 | const base::Closure& task, 16 | base::TimeDelta delay) { 17 | return false; 18 | } 19 | 20 | bool NullTaskRunner::PostNonNestableDelayedTask( 21 | const tracked_objects::Location& from_here, 22 | const base::Closure& task, 23 | base::TimeDelta delay) { 24 | return false; 25 | } 26 | 27 | bool NullTaskRunner::RunsTasksOnCurrentThread() const { 28 | return true; 29 | } 30 | 31 | } // namespace 32 | -------------------------------------------------------------------------------- /src/base/debug/dump_without_crashing.cc: -------------------------------------------------------------------------------- 1 | // Copyright 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 | #include "base/debug/dump_without_crashing.h" 6 | 7 | #include "base/logging.h" 8 | 9 | namespace { 10 | 11 | // Pointer to the function that's called by DumpWithoutCrashing() to dump the 12 | // process's memory. 13 | void (CDECL *dump_without_crashing_function_)() = NULL; 14 | 15 | } // namespace 16 | 17 | namespace base { 18 | 19 | namespace debug { 20 | 21 | void DumpWithoutCrashing() { 22 | if (dump_without_crashing_function_) 23 | (*dump_without_crashing_function_)(); 24 | } 25 | 26 | void SetDumpWithoutCrashingFunction(void (CDECL *function)()) { 27 | dump_without_crashing_function_ = function; 28 | } 29 | 30 | } // namespace debug 31 | 32 | } // namespace base 33 | -------------------------------------------------------------------------------- /src/base/threading/thread_local_android.cc: -------------------------------------------------------------------------------- 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 3 | // found in the LICENSE file. 4 | 5 | #include "base/threading/thread_local.h" 6 | 7 | #include "base/logging.h" 8 | 9 | namespace base { 10 | namespace internal { 11 | 12 | // static 13 | void ThreadLocalPlatform::AllocateSlot(SlotType* slot) { 14 | bool succeed = slot->Initialize(NULL); 15 | CHECK(succeed); 16 | } 17 | 18 | // static 19 | void ThreadLocalPlatform::FreeSlot(SlotType slot) { 20 | slot.Free(); 21 | } 22 | 23 | // static 24 | void* ThreadLocalPlatform::GetValueFromSlot(SlotType slot) { 25 | return slot.Get(); 26 | } 27 | 28 | // static 29 | void ThreadLocalPlatform::SetValueInSlot(SlotType slot, void* value) { 30 | slot.Set(value); 31 | } 32 | 33 | } // namespace internal 34 | } // namespace base 35 | -------------------------------------------------------------------------------- /src/base/float_util.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_FLOAT_UTIL_H_ 6 | #define BASE_FLOAT_UTIL_H_ 7 | 8 | #include "build/build_config.h" 9 | 10 | #include 11 | 12 | #include 13 | 14 | namespace base { 15 | 16 | template 17 | inline bool IsFinite(const Float& number) { 18 | #if defined(OS_POSIX) 19 | return std::isfinite(number) != 0; 20 | #elif defined(OS_WIN) 21 | return _finite(number) != 0; 22 | #endif 23 | } 24 | 25 | template 26 | inline bool IsNaN(const Float& number) { 27 | #if defined(OS_POSIX) 28 | return std::isnan(number) != 0; 29 | #elif defined(OS_WIN) 30 | return _isnan(number) != 0; 31 | #endif 32 | } 33 | 34 | } // namespace base 35 | 36 | #endif // BASE_FLOAT_UTIL_H_ 37 | -------------------------------------------------------------------------------- /src/base/scoped_clear_errno.h: -------------------------------------------------------------------------------- 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_SCOPED_CLEAR_ERRNO_H_ 6 | #define BASE_SCOPED_CLEAR_ERRNO_H_ 7 | 8 | #include 9 | 10 | #include "base/basictypes.h" 11 | 12 | namespace base { 13 | 14 | // Simple scoper that saves the current value of errno, resets it to 0, and on 15 | // destruction puts the old value back. 16 | class ScopedClearErrno { 17 | public: 18 | ScopedClearErrno() : old_errno_(errno) { 19 | errno = 0; 20 | } 21 | ~ScopedClearErrno() { 22 | if (errno == 0) 23 | errno = old_errno_; 24 | } 25 | 26 | private: 27 | const int old_errno_; 28 | 29 | DISALLOW_COPY_AND_ASSIGN(ScopedClearErrno); 30 | }; 31 | 32 | } // namespace base 33 | 34 | #endif // BASE_SCOPED_CLEAR_ERRNO_H_ 35 | -------------------------------------------------------------------------------- /src/base/test/opaque_ref_counted.h: -------------------------------------------------------------------------------- 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 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_TEST_OPAQUE_REF_COUNTED_H_ 6 | #define BASE_TEST_OPAQUE_REF_COUNTED_H_ 7 | 8 | #include "base/memory/ref_counted.h" 9 | 10 | namespace base { 11 | 12 | // OpaqueRefCounted is a test class for scoped_refptr to ensure it still works 13 | // when the pointed-to type is opaque (i.e., incomplete). 14 | class OpaqueRefCounted; 15 | 16 | // Test functions that return and accept scoped_refptr values. 17 | scoped_refptr MakeOpaqueRefCounted(); 18 | void TestOpaqueRefCounted(scoped_refptr p); 19 | 20 | } // namespace base 21 | 22 | extern template class scoped_refptr; 23 | 24 | #endif // BASE_TEST_OPAQUE_REF_COUNTED_H_ 25 | -------------------------------------------------------------------------------- /src/base/test/android/javatests/src/org/chromium/base/test/util/EnormousTest.java: -------------------------------------------------------------------------------- 1 | // Copyright 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 | package org.chromium.base.test.util; 6 | 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * This annotation is for enormous tests. 14 | *

15 | * Examples of enormous tests are tests that depend on external web sites or 16 | * tests that are long running. 17 | *

18 | * Such tests are likely NOT reliable enough to run on tree closing bots and 19 | * should only be run on FYI bots. 20 | */ 21 | @Target(ElementType.METHOD) 22 | @Retention(RetentionPolicy.RUNTIME) 23 | public @interface EnormousTest { 24 | } 25 | -------------------------------------------------------------------------------- /src/base/test/perf_log.h: -------------------------------------------------------------------------------- 1 | // Copyright 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_TEST_PERF_LOG_H_ 6 | #define BASE_TEST_PERF_LOG_H_ 7 | 8 | namespace base { 9 | 10 | class FilePath; 11 | 12 | // Initializes and finalizes the perf log. These functions should be 13 | // called at the beginning and end (respectively) of running all the 14 | // performance tests. The init function returns true on success. 15 | bool InitPerfLog(const FilePath& log_path); 16 | void FinalizePerfLog(); 17 | 18 | // Writes to the perf result log the given 'value' resulting from the 19 | // named 'test'. The units are to aid in reading the log by people. 20 | void LogPerfResult(const char* test_name, double value, const char* units); 21 | 22 | } // namespace base 23 | 24 | #endif // BASE_TEST_PERF_LOG_H_ 25 | -------------------------------------------------------------------------------- /src/base/prefs/base_prefs_export.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_PREFS_BASE_PREFS_EXPORT_H_ 6 | #define BASE_PREFS_BASE_PREFS_EXPORT_H_ 7 | 8 | #if defined(COMPONENT_BUILD) 9 | #if defined(WIN32) 10 | 11 | #if defined(BASE_PREFS_IMPLEMENTATION) 12 | #define BASE_PREFS_EXPORT __declspec(dllexport) 13 | #else 14 | #define BASE_PREFS_EXPORT __declspec(dllimport) 15 | #endif // defined(BASE_PREFS_IMPLEMENTATION) 16 | 17 | #else // defined(WIN32) 18 | #if defined(BASE_PREFS_IMPLEMENTATION) 19 | #define BASE_PREFS_EXPORT __attribute__((visibility("default"))) 20 | #else 21 | #define BASE_PREFS_EXPORT 22 | #endif 23 | #endif 24 | 25 | #else // defined(COMPONENT_BUILD) 26 | #define BASE_PREFS_EXPORT 27 | #endif 28 | 29 | #endif // BASE_PREFS_BASE_PREFS_EXPORT_H_ 30 | -------------------------------------------------------------------------------- /src/third_party/libevent/mkinstalldirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | # Author: Noah Friedman 4 | # Created: 1993-05-16 5 | # Public domain 6 | 7 | # $Id: mkinstalldirs 11 2002-04-09 17:52:23Z nprovos $ 8 | 9 | errstatus=0 10 | 11 | for file 12 | do 13 | set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 14 | shift 15 | 16 | pathcomp= 17 | for d 18 | do 19 | pathcomp="$pathcomp$d" 20 | case "$pathcomp" in 21 | -* ) pathcomp=./$pathcomp ;; 22 | esac 23 | 24 | if test ! -d "$pathcomp"; then 25 | echo "mkdir $pathcomp" 26 | 27 | mkdir "$pathcomp" || lasterr=$? 28 | 29 | if test ! -d "$pathcomp"; then 30 | errstatus=$lasterr 31 | fi 32 | fi 33 | 34 | pathcomp="$pathcomp/" 35 | done 36 | done 37 | 38 | exit $errstatus 39 | 40 | # mkinstalldirs ends here 41 | -------------------------------------------------------------------------------- /src/base/os_compat_android.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_OS_COMPAT_ANDROID_H_ 6 | #define BASE_OS_COMPAT_ANDROID_H_ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | // Not implemented in Bionic. 13 | extern "C" int futimes(int fd, const struct timeval tv[2]); 14 | 15 | // Not exposed or implemented in Bionic. 16 | extern "C" char* mkdtemp(char* path); 17 | 18 | // Android has no timegm(). 19 | extern "C" time_t timegm(struct tm* const t); 20 | 21 | // The lockf() function is not available on Android; we translate to flock(). 22 | #define F_LOCK LOCK_EX 23 | #define F_ULOCK LOCK_UN 24 | inline int lockf(int fd, int cmd, off_t ignored_len) { 25 | return flock(fd, cmd); 26 | } 27 | 28 | #endif // BASE_OS_COMPAT_ANDROID_H_ 29 | -------------------------------------------------------------------------------- /src/base/test/mock_time_provider.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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 "base/logging.h" 6 | #include "base/test/mock_time_provider.h" 7 | 8 | using ::testing::DefaultValue; 9 | 10 | namespace base { 11 | 12 | MockTimeProvider* MockTimeProvider::instance_ = NULL; 13 | 14 | MockTimeProvider::MockTimeProvider() { 15 | DCHECK(!instance_) << "Only one instance of MockTimeProvider can exist"; 16 | DCHECK(!DefaultValue

15 | * Examples of integration tests are tests that rely on real instances of the 16 | * application's services and components (e.g. Search) to test the system as 17 | * a whole. These tests may use additional command-line flags to configure the 18 | * existing backends to use. 19 | *

20 | * Such tests are likely NOT reliable enough to run on tree closing bots and 21 | * should only be run on FYI bots. 22 | */ 23 | @Target(ElementType.METHOD) 24 | @Retention(RetentionPolicy.RUNTIME) 25 | public @interface IntegrationTest { 26 | } -------------------------------------------------------------------------------- /src/base/process/process_handle_mac.cc: -------------------------------------------------------------------------------- 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 | #include "base/process/process_handle.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "base/logging.h" 12 | 13 | namespace base { 14 | 15 | ProcessId GetParentProcessId(ProcessHandle process) { 16 | struct kinfo_proc info; 17 | size_t length = sizeof(struct kinfo_proc); 18 | int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process }; 19 | if (sysctl(mib, 4, &info, &length, NULL, 0) < 0) { 20 | DPLOG(ERROR) << "sysctl"; 21 | return -1; 22 | } 23 | if (length == 0) 24 | return -1; 25 | return info.kp_eproc.e_ppid; 26 | } 27 | 28 | FilePath GetProcessExecutablePath(ProcessHandle process) { 29 | char pathbuf[PROC_PIDPATHINFO_MAXSIZE]; 30 | if (!proc_pidpath(process, pathbuf, sizeof(pathbuf))) 31 | return FilePath(); 32 | 33 | return FilePath(pathbuf); 34 | } 35 | 36 | } // namespace base 37 | -------------------------------------------------------------------------------- /src/base/base_export.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_BASE_EXPORT_H_ 6 | #define BASE_BASE_EXPORT_H_ 7 | 8 | #if defined(COMPONENT_BUILD) 9 | #if defined(WIN32) 10 | 11 | #if defined(BASE_IMPLEMENTATION) 12 | #define BASE_EXPORT __declspec(dllexport) 13 | #define BASE_EXPORT_PRIVATE __declspec(dllexport) 14 | #else 15 | #define BASE_EXPORT __declspec(dllimport) 16 | #define BASE_EXPORT_PRIVATE __declspec(dllimport) 17 | #endif // defined(BASE_IMPLEMENTATION) 18 | 19 | #else // defined(WIN32) 20 | #if defined(BASE_IMPLEMENTATION) 21 | #define BASE_EXPORT __attribute__((visibility("default"))) 22 | #define BASE_EXPORT_PRIVATE __attribute__((visibility("default"))) 23 | #else 24 | #define BASE_EXPORT 25 | #define BASE_EXPORT_PRIVATE 26 | #endif // defined(BASE_IMPLEMENTATION) 27 | #endif 28 | 29 | #else // defined(COMPONENT_BUILD) 30 | #define BASE_EXPORT 31 | #define BASE_EXPORT_PRIVATE 32 | #endif 33 | 34 | #endif // BASE_BASE_EXPORT_H_ 35 | -------------------------------------------------------------------------------- /src/base/debug/stack_trace.cc: -------------------------------------------------------------------------------- 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 "base/debug/stack_trace.h" 6 | 7 | #include "base/basictypes.h" 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace base { 15 | namespace debug { 16 | 17 | StackTrace::StackTrace(const void* const* trace, size_t count) { 18 | count = std::min(count, arraysize(trace_)); 19 | if (count) 20 | memcpy(trace_, trace, count * sizeof(trace_[0])); 21 | count_ = count; 22 | } 23 | 24 | StackTrace::~StackTrace() { 25 | } 26 | 27 | const void *const *StackTrace::Addresses(size_t* count) const { 28 | *count = count_; 29 | if (count_) 30 | return trace_; 31 | return NULL; 32 | } 33 | 34 | std::string StackTrace::ToString() const { 35 | std::stringstream stream; 36 | #if !defined(__UCLIBC__) 37 | OutputToStream(&stream); 38 | #endif 39 | return stream.str(); 40 | } 41 | 42 | } // namespace debug 43 | } // namespace base 44 | -------------------------------------------------------------------------------- /src/base/test/test_file_util_android.cc: -------------------------------------------------------------------------------- 1 | // Copyright 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 | #include "base/test/test_file_util.h" 6 | 7 | #include "base/android/jni_android.h" 8 | #include "base/android/jni_string.h" 9 | #include "base/files/file_path.h" 10 | #include "jni/ContentUriTestUtils_jni.h" 11 | 12 | namespace base { 13 | 14 | bool RegisterContentUriTestUtils(JNIEnv* env) { 15 | return RegisterNativesImpl(env); 16 | } 17 | 18 | FilePath InsertImageIntoMediaStore(const FilePath& path) { 19 | JNIEnv* env = base::android::AttachCurrentThread(); 20 | ScopedJavaLocalRef j_path = 21 | base::android::ConvertUTF8ToJavaString(env, path.value()); 22 | ScopedJavaLocalRef j_uri = 23 | Java_ContentUriTestUtils_insertImageIntoMediaStore( 24 | env, base::android::GetApplicationContext(), j_path.obj()); 25 | std::string uri = base::android::ConvertJavaStringToUTF8(j_uri); 26 | return FilePath(uri); 27 | } 28 | 29 | } // namespace base 30 | -------------------------------------------------------------------------------- /src/base/test/test_shortcut_win.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_TEST_TEST_SHORTCUT_WIN_H_ 6 | #define BASE_TEST_TEST_SHORTCUT_WIN_H_ 7 | 8 | #include "base/files/file_path.h" 9 | #include "base/win/shortcut.h" 10 | 11 | // Windows shortcut functions used only by tests. 12 | 13 | namespace base { 14 | namespace win { 15 | 16 | // Validates |actual_path|'s LongPathName case-insensitively matches 17 | // |expected_path|'s LongPathName. 18 | void ValidatePathsAreEqual(const base::FilePath& expected_path, 19 | const base::FilePath& actual_path); 20 | 21 | // Validates that a shortcut exists at |shortcut_path| with the expected 22 | // |properties|. 23 | // Logs gtest failures on failed verifications. 24 | void ValidateShortcut(const FilePath& shortcut_path, 25 | const ShortcutProperties& properties); 26 | 27 | } // namespace win 28 | } // namespace base 29 | 30 | #endif // BASE_TEST_TEST_SHORTCUT_WIN_H_ 31 | -------------------------------------------------------------------------------- /src/base/threading/thread_local_win.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010 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 "base/threading/thread_local.h" 6 | 7 | #include 8 | 9 | #include "base/logging.h" 10 | 11 | namespace base { 12 | namespace internal { 13 | 14 | // static 15 | void ThreadLocalPlatform::AllocateSlot(SlotType* slot) { 16 | *slot = TlsAlloc(); 17 | CHECK_NE(*slot, TLS_OUT_OF_INDEXES); 18 | } 19 | 20 | // static 21 | void ThreadLocalPlatform::FreeSlot(SlotType slot) { 22 | if (!TlsFree(slot)) { 23 | NOTREACHED() << "Failed to deallocate tls slot with TlsFree()."; 24 | } 25 | } 26 | 27 | // static 28 | void* ThreadLocalPlatform::GetValueFromSlot(SlotType slot) { 29 | return TlsGetValue(slot); 30 | } 31 | 32 | // static 33 | void ThreadLocalPlatform::SetValueInSlot(SlotType slot, void* value) { 34 | if (!TlsSetValue(slot, value)) { 35 | LOG(FATAL) << "Failed to TlsSetValue()."; 36 | } 37 | } 38 | 39 | } // namespace internal 40 | } // namespace base 41 | -------------------------------------------------------------------------------- /src/base/callback_helpers.cc: -------------------------------------------------------------------------------- 1 | // Copyright 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 | #include "base/callback_helpers.h" 6 | 7 | #include "base/callback.h" 8 | 9 | namespace base { 10 | 11 | ScopedClosureRunner::ScopedClosureRunner() { 12 | } 13 | 14 | ScopedClosureRunner::ScopedClosureRunner(const Closure& closure) 15 | : closure_(closure) { 16 | } 17 | 18 | ScopedClosureRunner::~ScopedClosureRunner() { 19 | if (!closure_.is_null()) 20 | closure_.Run(); 21 | } 22 | 23 | void ScopedClosureRunner::Reset() { 24 | Closure old_closure = Release(); 25 | if (!old_closure.is_null()) 26 | old_closure.Run(); 27 | } 28 | 29 | void ScopedClosureRunner::Reset(const Closure& closure) { 30 | Closure old_closure = Release(); 31 | closure_ = closure; 32 | if (!old_closure.is_null()) 33 | old_closure.Run(); 34 | } 35 | 36 | Closure ScopedClosureRunner::Release() { 37 | Closure result = closure_; 38 | closure_.Reset(); 39 | return result; 40 | } 41 | 42 | } // namespace base 43 | -------------------------------------------------------------------------------- /src/base/files/protect_file_posix.gypi: -------------------------------------------------------------------------------- 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 3 | # found in the LICENSE file. 4 | 5 | # Provides sanity-checks and early crashes on some improper use of posix file 6 | # descriptors. See protect_file_posix.cc for details. 7 | # 8 | # Usage: 9 | # { 10 | # 'target_name': 'libsomething', 11 | # 'type': 'shared_library', // Do *not* use it for static libraries. 12 | # 'includes': [ 13 | # 'base/files/protect_file_posix.gypi', 14 | # ], 15 | # ... 16 | # } 17 | { 18 | 'conditions': [ 19 | # In the component build the interceptors have to be declared with 20 | # non-hidden visibility, which is not desirable for the release build. 21 | # Disable the extra checks for the component build for simplicity. 22 | ['component != "shared_library"', { 23 | 'ldflags': [ 24 | '-Wl,--wrap=close', 25 | ], 26 | 'dependencies': [ 27 | '<(DEPTH)/base/base.gyp:protect_file_posix', 28 | ], 29 | }], 30 | ], 31 | } 32 | -------------------------------------------------------------------------------- /src/base/third_party/dynamic_annotations/README.chromium: -------------------------------------------------------------------------------- 1 | Name: dynamic annotations 2 | URL: http://code.google.com/p/data-race-test/wiki/DynamicAnnotations 3 | Version: 4384 4 | License: BSD 5 | 6 | ATTENTION: please avoid using these annotations in Chromium code. 7 | They were mainly intended to instruct the Valgrind-based version of 8 | ThreadSanitizer to handle atomic operations. The new version of ThreadSanitizer 9 | based on compiler instrumentation understands atomic operations out of the box, 10 | so normally you don't need the annotations. 11 | If you still think you do, please consider writing a comment at http://crbug.com/349861 12 | 13 | One header and one source file (dynamic_annotations.h and dynamic_annotations.c) 14 | in this directory define runtime macros useful for annotating synchronization 15 | utilities and benign data races so data race detectors can handle Chromium code 16 | with better precision. 17 | 18 | These files were taken from 19 | http://code.google.com/p/data-race-test/source/browse/?#svn/trunk/dynamic_annotations 20 | The files are covered under BSD license as described within the files. 21 | -------------------------------------------------------------------------------- /src/base/guid_win.cc: -------------------------------------------------------------------------------- 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 "base/guid.h" 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #include "base/basictypes.h" 13 | #include "base/logging.h" 14 | #include "base/strings/string_util.h" 15 | #include "base/strings/utf_string_conversions.h" 16 | 17 | namespace base { 18 | 19 | std::string GenerateGUID() { 20 | const int kGUIDSize = 39; 21 | 22 | GUID guid; 23 | HRESULT guid_result = CoCreateGuid(&guid); 24 | DCHECK(SUCCEEDED(guid_result)); 25 | if (!SUCCEEDED(guid_result)) 26 | return std::string(); 27 | 28 | std::wstring guid_string; 29 | int result = StringFromGUID2(guid, 30 | WriteInto(&guid_string, kGUIDSize), kGUIDSize); 31 | DCHECK(result == kGUIDSize); 32 | if (result != kGUIDSize) 33 | return std::string(); 34 | 35 | return WideToUTF8(guid_string.substr(1, guid_string.length() - 2)); 36 | } 37 | 38 | } // namespace guid 39 | -------------------------------------------------------------------------------- /src/base/guid.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_GUID_H_ 6 | #define BASE_GUID_H_ 7 | 8 | #include 9 | 10 | #include "base/base_export.h" 11 | #include "base/basictypes.h" 12 | #include "build/build_config.h" 13 | 14 | namespace base { 15 | 16 | // Generate a 128-bit random GUID of the form: "%08X-%04X-%04X-%04X-%012llX". 17 | // If GUID generation fails an empty string is returned. 18 | // The POSIX implementation uses pseudo random number generation to create 19 | // the GUID. The Windows implementation uses system services. 20 | BASE_EXPORT std::string GenerateGUID(); 21 | 22 | // Returns true if the input string conforms to the GUID format. 23 | BASE_EXPORT bool IsValidGUID(const std::string& guid); 24 | 25 | #if defined(OS_POSIX) 26 | // For unit testing purposes only. Do not use outside of tests. 27 | BASE_EXPORT std::string RandomDataToGUIDString(const uint64 bytes[2]); 28 | #endif 29 | 30 | } // namespace base 31 | 32 | #endif // BASE_GUID_H_ 33 | -------------------------------------------------------------------------------- /src/base/win/iunknown_impl.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_WIN_IUNKNOWN_IMPL_H_ 6 | #define BASE_WIN_IUNKNOWN_IMPL_H_ 7 | 8 | #include 9 | 10 | #include "base/atomic_ref_count.h" 11 | #include "base/base_export.h" 12 | #include "base/compiler_specific.h" 13 | 14 | namespace base { 15 | namespace win { 16 | 17 | // IUnknown implementation for other classes to derive from. 18 | class BASE_EXPORT IUnknownImpl : public IUnknown { 19 | public: 20 | IUnknownImpl(); 21 | 22 | virtual ULONG STDMETHODCALLTYPE AddRef() override; 23 | virtual ULONG STDMETHODCALLTYPE Release() override; 24 | 25 | // Subclasses should extend this to return any interfaces they provide. 26 | virtual STDMETHODIMP QueryInterface(REFIID riid, void** ppv) override; 27 | 28 | protected: 29 | virtual ~IUnknownImpl(); 30 | 31 | private: 32 | AtomicRefCount ref_count_; 33 | }; 34 | 35 | } // namespace win 36 | } // namespace base 37 | 38 | #endif // BASE_WIN_IUNKNOWN_IMPL_H_ 39 | -------------------------------------------------------------------------------- /src/base/debug/dump_without_crashing.h: -------------------------------------------------------------------------------- 1 | // Copyright 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_DEBUG_DUMP_WITHOUT_CRASHING_H_ 6 | #define BASE_DEBUG_DUMP_WITHOUT_CRASHING_H_ 7 | 8 | #include "base/base_export.h" 9 | #include "base/compiler_specific.h" 10 | #include "build/build_config.h" 11 | 12 | namespace base { 13 | 14 | namespace debug { 15 | 16 | // Handler to silently dump the current process without crashing. 17 | // Before calling this function, call SetDumpWithoutCrashingFunction to pass a 18 | // function pointer, typically chrome!DumpProcessWithoutCrash. See example code 19 | // in chrome_main.cc that does this for chrome.dll. 20 | BASE_EXPORT void DumpWithoutCrashing(); 21 | 22 | // Sets a function that'll be invoked to dump the current process when 23 | // DumpWithoutCrashing() is called. 24 | BASE_EXPORT void SetDumpWithoutCrashingFunction(void (CDECL *function)()); 25 | 26 | } // namespace debug 27 | 28 | } // namespace base 29 | 30 | #endif // BASE_DEBUG_DUMP_WITHOUT_CRASHING_H_ 31 | -------------------------------------------------------------------------------- /src/build/filename_rules.gypi: -------------------------------------------------------------------------------- 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 | # This gypi file defines the patterns used for determining whether a 6 | # file is excluded from the build on a given platform. 7 | 8 | { 9 | 'target_conditions': [ 10 | ['OS!="win"', { 11 | 'sources/': [ ['exclude', '_win(_browsertest|_unittest)?\\.(h|cc)$'], 12 | ['exclude', '(^|/)win/'], 13 | ['exclude', '(^|/)win_[^/]*\\.(h|cc)$'] ], 14 | }], 15 | ['OS!="mac"', { 16 | 'sources/': [ ['exclude', '_(cocoa|mac)(_unittest)?\\.(h|cc|mm?)$'], 17 | ['exclude', '(^|/)(cocoa|mac)/'] ], 18 | }], 19 | ['OS!="linux"', { 20 | 'sources/': [ 21 | ['exclude', '_linux(_unittest)?\\.(h|cc)$'], 22 | ['exclude', '(^|/)linux/'], 23 | ], 24 | }], 25 | ['OS=="win"', { 26 | 'sources/': [ 27 | ['exclude', '_posix(_unittest)?\\.(h|cc)$'], 28 | ['exclude', '(^|/)posix/'], 29 | ], 30 | }], 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/base/memory/scoped_handle.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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_MEMORY_SCOPED_HANDLE_H_ 6 | #define BASE_MEMORY_SCOPED_HANDLE_H_ 7 | 8 | #include 9 | 10 | #include "base/basictypes.h" 11 | 12 | class ScopedStdioHandle { 13 | public: 14 | ScopedStdioHandle() 15 | : handle_(NULL) { } 16 | 17 | explicit ScopedStdioHandle(FILE* handle) 18 | : handle_(handle) { } 19 | 20 | ~ScopedStdioHandle() { 21 | Close(); 22 | } 23 | 24 | void Close() { 25 | if (handle_) { 26 | fclose(handle_); 27 | handle_ = NULL; 28 | } 29 | } 30 | 31 | FILE* get() const { return handle_; } 32 | 33 | FILE* Take() { 34 | FILE* temp = handle_; 35 | handle_ = NULL; 36 | return temp; 37 | } 38 | 39 | void Set(FILE* newhandle) { 40 | Close(); 41 | handle_ = newhandle; 42 | } 43 | 44 | private: 45 | FILE* handle_; 46 | 47 | DISALLOW_COPY_AND_ASSIGN(ScopedStdioHandle); 48 | }; 49 | 50 | #endif // BASE_MEMORY_SCOPED_HANDLE_H_ 51 | -------------------------------------------------------------------------------- /src/base/threading/thread_local_posix.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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 "base/threading/thread_local.h" 6 | 7 | #include 8 | 9 | #include "base/logging.h" 10 | 11 | #if !defined(OS_ANDROID) 12 | 13 | namespace base { 14 | namespace internal { 15 | 16 | // static 17 | void ThreadLocalPlatform::AllocateSlot(SlotType* slot) { 18 | int error = pthread_key_create(slot, NULL); 19 | CHECK_EQ(error, 0); 20 | } 21 | 22 | // static 23 | void ThreadLocalPlatform::FreeSlot(SlotType slot) { 24 | int error = pthread_key_delete(slot); 25 | DCHECK_EQ(0, error); 26 | } 27 | 28 | // static 29 | void* ThreadLocalPlatform::GetValueFromSlot(SlotType slot) { 30 | return pthread_getspecific(slot); 31 | } 32 | 33 | // static 34 | void ThreadLocalPlatform::SetValueInSlot(SlotType slot, void* value) { 35 | int error = pthread_setspecific(slot, value); 36 | DCHECK_EQ(error, 0); 37 | } 38 | 39 | } // namespace internal 40 | } // namespace base 41 | 42 | #endif // !defined(OS_ANDROID) 43 | -------------------------------------------------------------------------------- /src/base/test/mock_chrome_application_mac.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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_TEST_MOCK_CHROME_APPLICATION_MAC_H_ 6 | #define BASE_TEST_MOCK_CHROME_APPLICATION_MAC_H_ 7 | 8 | #if defined(__OBJC__) 9 | 10 | #import 11 | 12 | #include "base/mac/scoped_sending_event.h" 13 | #include "base/message_loop/message_pump_mac.h" 14 | 15 | // A basic implementation of CrAppProtocol and 16 | // CrAppControlProtocol. This can be used in tests that need an 17 | // NSApplication and use a runloop, or which need a ScopedSendingEvent 18 | // when handling a nested event loop. 19 | @interface MockCrApp : NSApplication { 21 | @private 22 | BOOL handlingSendEvent_; 23 | } 24 | @end 25 | 26 | #endif 27 | 28 | // To be used to instantiate MockCrApp from C++ code. 29 | namespace mock_cr_app { 30 | void RegisterMockCrApp(); 31 | } // namespace mock_cr_app 32 | 33 | #endif // BASE_TEST_MOCK_CHROME_APPLICATION_MAC_H_ 34 | -------------------------------------------------------------------------------- /src/base/debug/trace_event_impl_constants.cc: -------------------------------------------------------------------------------- 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 | #include "base/debug/trace_event_impl.h" 6 | 7 | namespace base { 8 | namespace debug { 9 | 10 | // Enable everything but debug and test categories by default. 11 | const char CategoryFilter::kDefaultCategoryFilterString[] = "-*Debug,-*Test"; 12 | 13 | // Constant used by TraceLog's internal implementation of trace_option. 14 | const TraceLog::InternalTraceOptions 15 | TraceLog::kInternalNone = 0; 16 | const TraceLog::InternalTraceOptions 17 | TraceLog::kInternalRecordUntilFull = 1 << 0; 18 | const TraceLog::InternalTraceOptions 19 | TraceLog::kInternalRecordContinuously = 1 << 1; 20 | const TraceLog::InternalTraceOptions 21 | TraceLog::kInternalEnableSampling = 1 << 2; 22 | const TraceLog::InternalTraceOptions 23 | TraceLog::kInternalEchoToConsole = 1 << 3; 24 | const TraceLog::InternalTraceOptions 25 | TraceLog::kInternalRecordAsMuchAsPossible = 1 << 4; 26 | 27 | } // namespace debug 28 | } // namespace base 29 | -------------------------------------------------------------------------------- /src/base/files/scoped_file.cc: -------------------------------------------------------------------------------- 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 3 | // found in the LICENSE file. 4 | 5 | #include "base/files/scoped_file.h" 6 | 7 | #include "base/logging.h" 8 | 9 | #if defined(OS_POSIX) 10 | #include 11 | 12 | #include "base/posix/eintr_wrapper.h" 13 | #endif 14 | 15 | namespace base { 16 | namespace internal { 17 | 18 | #if defined(OS_POSIX) 19 | 20 | // static 21 | void ScopedFDCloseTraits::Free(int fd) { 22 | // It's important to crash here. 23 | // There are security implications to not closing a file descriptor 24 | // properly. As file descriptors are "capabilities", keeping them open 25 | // would make the current process keep access to a resource. Much of 26 | // Chrome relies on being able to "drop" such access. 27 | // It's especially problematic on Linux with the setuid sandbox, where 28 | // a single open directory would bypass the entire security model. 29 | PCHECK(0 == IGNORE_EINTR(close(fd))); 30 | } 31 | 32 | #endif // OS_POSIX 33 | 34 | } // namespace internal 35 | } // namespace base 36 | -------------------------------------------------------------------------------- /src/base/json/json_value_converter.cc: -------------------------------------------------------------------------------- 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 3 | // found in the LICENSE file. 4 | 5 | #include "base/json/json_value_converter.h" 6 | 7 | namespace base { 8 | namespace internal { 9 | 10 | bool BasicValueConverter::Convert( 11 | const base::Value& value, int* field) const { 12 | return value.GetAsInteger(field); 13 | } 14 | 15 | bool BasicValueConverter::Convert( 16 | const base::Value& value, std::string* field) const { 17 | return value.GetAsString(field); 18 | } 19 | 20 | bool BasicValueConverter::Convert( 21 | const base::Value& value, string16* field) const { 22 | return value.GetAsString(field); 23 | } 24 | 25 | bool BasicValueConverter::Convert( 26 | const base::Value& value, double* field) const { 27 | return value.GetAsDouble(field); 28 | } 29 | 30 | bool BasicValueConverter::Convert( 31 | const base::Value& value, bool* field) const { 32 | return value.GetAsBoolean(field); 33 | } 34 | 35 | } // namespace internal 36 | } // namespace base 37 | 38 | -------------------------------------------------------------------------------- /src/base/third_party/dmg_fp/dmg_fp.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2008 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 THIRD_PARTY_DMG_FP_H_ 6 | #define THIRD_PARTY_DMG_FP_H_ 7 | 8 | namespace dmg_fp { 9 | 10 | // Return a nearest machine number to the input decimal 11 | // string (or set errno to ERANGE). With IEEE arithmetic, ties are 12 | // broken by the IEEE round-even rule. Otherwise ties are broken by 13 | // biased rounding (add half and chop). 14 | double strtod(const char* s00, char** se); 15 | 16 | // Convert double to ASCII string. For meaning of parameters 17 | // see dtoa.cc file. 18 | char* dtoa(double d, int mode, int ndigits, 19 | int* decpt, int* sign, char** rve); 20 | 21 | // Must be used to free values returned by dtoa. 22 | void freedtoa(char* s); 23 | 24 | // Store the closest decimal approximation to x in b (null terminated). 25 | // Returns a pointer to b. It is sufficient for |b| to be 32 characters. 26 | char* g_fmt(char* b, double x); 27 | 28 | } // namespace dmg_fp 29 | 30 | #endif // THIRD_PARTY_DMG_FP_H_ 31 | -------------------------------------------------------------------------------- /src/base/rand_util_nacl.cc: -------------------------------------------------------------------------------- 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 "base/rand_util.h" 6 | 7 | #include 8 | 9 | #include "base/basictypes.h" 10 | #include "base/logging.h" 11 | 12 | namespace { 13 | 14 | void GetRandomBytes(void* output, size_t num_bytes) { 15 | char* output_ptr = static_cast(output); 16 | while (num_bytes > 0) { 17 | size_t nread; 18 | const int error = nacl_secure_random(output_ptr, num_bytes, &nread); 19 | CHECK_EQ(error, 0); 20 | CHECK_LE(nread, num_bytes); 21 | output_ptr += nread; 22 | num_bytes -= nread; 23 | } 24 | } 25 | 26 | } // namespace 27 | 28 | namespace base { 29 | 30 | // NOTE: This function must be cryptographically secure. http://crbug.com/140076 31 | uint64 RandUint64() { 32 | uint64 result; 33 | GetRandomBytes(&result, sizeof(result)); 34 | return result; 35 | } 36 | 37 | void RandBytes(void* output, size_t output_length) { 38 | GetRandomBytes(output, output_length); 39 | } 40 | 41 | } // namespace base 42 | -------------------------------------------------------------------------------- /src/base/test/perf_time_logger.h: -------------------------------------------------------------------------------- 1 | // Copyright 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_TEST_PERF_TIME_LOGGER_H_ 6 | #define BASE_TEST_PERF_TIME_LOGGER_H_ 7 | 8 | #include 9 | 10 | #include "base/basictypes.h" 11 | #include "base/timer/elapsed_timer.h" 12 | 13 | namespace base { 14 | 15 | // Automates calling LogPerfResult for the common case where you want 16 | // to measure the time that something took. Call Done() when the test 17 | // is complete if you do extra work after the test or there are stack 18 | // objects with potentially expensive constructors. Otherwise, this 19 | // class with automatically log on destruction. 20 | class PerfTimeLogger { 21 | public: 22 | explicit PerfTimeLogger(const char* test_name); 23 | ~PerfTimeLogger(); 24 | 25 | void Done(); 26 | 27 | private: 28 | bool logged_; 29 | std::string test_name_; 30 | ElapsedTimer timer_; 31 | 32 | DISALLOW_COPY_AND_ASSIGN(PerfTimeLogger); 33 | }; 34 | 35 | } // namespace base 36 | 37 | #endif // BASE_TEST_PERF_TIME_LOGGER_H_ 38 | -------------------------------------------------------------------------------- /src/base/test/simple_test_clock.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_SIMPLE_TEST_CLOCK_H_ 6 | #define BASE_SIMPLE_TEST_CLOCK_H_ 7 | 8 | #include "base/compiler_specific.h" 9 | #include "base/synchronization/lock.h" 10 | #include "base/time/clock.h" 11 | #include "base/time/time.h" 12 | 13 | namespace base { 14 | 15 | // SimpleTestClock is a Clock implementation that gives control over 16 | // the returned Time objects. All methods may be called from any 17 | // thread. 18 | class SimpleTestClock : public Clock { 19 | public: 20 | // Starts off with a clock set to Time(). 21 | SimpleTestClock(); 22 | ~SimpleTestClock() override; 23 | 24 | Time Now() override; 25 | 26 | // Advances the clock by |delta|. 27 | void Advance(TimeDelta delta); 28 | 29 | // Sets the clock to the given time. 30 | void SetNow(Time now); 31 | 32 | private: 33 | // Protects |now_|. 34 | Lock lock_; 35 | 36 | Time now_; 37 | }; 38 | 39 | } // namespace base 40 | 41 | #endif // BASE_SIMPLE_TEST_CLOCK_H_ 42 | -------------------------------------------------------------------------------- /src/base/mac/mac_logging.cc: -------------------------------------------------------------------------------- 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 "base/mac/mac_logging.h" 6 | 7 | #include 8 | 9 | #if !defined(OS_IOS) 10 | #include 11 | #endif 12 | 13 | namespace logging { 14 | 15 | OSStatusLogMessage::OSStatusLogMessage(const char* file_path, 16 | int line, 17 | LogSeverity severity, 18 | OSStatus status) 19 | : LogMessage(file_path, line, severity), 20 | status_(status) { 21 | } 22 | 23 | OSStatusLogMessage::~OSStatusLogMessage() { 24 | #if defined(OS_IOS) 25 | // TODO(ios): Consider using NSError with NSOSStatusErrorDomain to try to 26 | // get a description of the failure. 27 | stream() << ": " << status_; 28 | #else 29 | stream() << ": " 30 | << GetMacOSStatusErrorString(status_) 31 | << " (" 32 | << status_ 33 | << ")"; 34 | #endif 35 | } 36 | 37 | } // namespace logging 38 | -------------------------------------------------------------------------------- /src/base/process/memory_unittest_mac.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010 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 | // This file contains helpers for the process_util_unittest to allow it to fully 6 | // test the Mac code. 7 | 8 | #ifndef BASE_PROCESS_MEMORY_UNITTEST_MAC_H_ 9 | #define BASE_PROCESS_MEMORY_UNITTEST_MAC_H_ 10 | 11 | #include "base/basictypes.h" 12 | 13 | namespace base { 14 | 15 | // Allocates memory via system allocators. Alas, they take a _signed_ size for 16 | // allocation. 17 | void* AllocateViaCFAllocatorSystemDefault(ssize_t size); 18 | void* AllocateViaCFAllocatorMalloc(ssize_t size); 19 | void* AllocateViaCFAllocatorMallocZone(ssize_t size); 20 | 21 | #if !defined(ARCH_CPU_64_BITS) 22 | // See process_util_unittest_mac.mm for an explanation of why this function 23 | // isn't implemented for the 64-bit environment. 24 | 25 | // Allocates a huge Objective C object. 26 | void* AllocatePsychoticallyBigObjCObject(); 27 | 28 | #endif // !ARCH_CPU_64_BITS 29 | 30 | } // namespace base 31 | 32 | #endif // BASE_PROCESS_MEMORY_UNITTEST_MAC_H_ 33 | -------------------------------------------------------------------------------- /src/base/strings/stringize_macros.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010 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 | // This file defines preprocessor macros for stringizing preprocessor 6 | // symbols (or their output) and manipulating preprocessor symbols 7 | // that define strings. 8 | 9 | #ifndef BASE_STRINGS_STRINGIZE_MACROS_H_ 10 | #define BASE_STRINGS_STRINGIZE_MACROS_H_ 11 | 12 | #include "build/build_config.h" 13 | 14 | // This is not very useful as it does not expand defined symbols if 15 | // called directly. Use its counterpart without the _NO_EXPANSION 16 | // suffix, below. 17 | #define STRINGIZE_NO_EXPANSION(x) #x 18 | 19 | // Use this to quote the provided parameter, first expanding it if it 20 | // is a preprocessor symbol. 21 | // 22 | // For example, if: 23 | // #define A FOO 24 | // #define B(x) myobj->FunctionCall(x) 25 | // 26 | // Then: 27 | // STRINGIZE(A) produces "FOO" 28 | // STRINGIZE(B(y)) produces "myobj->FunctionCall(y)" 29 | #define STRINGIZE(x) STRINGIZE_NO_EXPANSION(x) 30 | 31 | #endif // BASE_STRINGS_STRINGIZE_MACROS_H_ 32 | -------------------------------------------------------------------------------- /src/base/mac/launchd.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_MAC_LAUNCHD_H_ 6 | #define BASE_MAC_LAUNCHD_H_ 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include "base/base_export.h" 14 | 15 | namespace base { 16 | namespace mac { 17 | 18 | // MessageForJob sends a single message to launchd with a simple dictionary 19 | // mapping |operation| to |job_label|, and returns the result of calling 20 | // launch_msg to send that message. On failure, returns NULL. The caller 21 | // assumes ownership of the returned launch_data_t object. 22 | BASE_EXPORT 23 | launch_data_t MessageForJob(const std::string& job_label, 24 | const char* operation); 25 | 26 | // Returns the process ID for |job_label| if the job is running, 0 if the job 27 | // is loaded but not running, or -1 on error. 28 | BASE_EXPORT 29 | pid_t PIDForJob(const std::string& job_label); 30 | 31 | } // namespace mac 32 | } // namespace base 33 | 34 | #endif // BASE_MAC_LAUNCHD_H_ 35 | -------------------------------------------------------------------------------- /src/base/power_monitor/power_monitor_device_source_chromeos.cc: -------------------------------------------------------------------------------- 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 3 | // found in the LICENSE file. 4 | 5 | #include "base/power_monitor/power_monitor.h" 6 | #include "base/power_monitor/power_monitor_device_source.h" 7 | #include "base/power_monitor/power_monitor_source.h" 8 | 9 | namespace base { 10 | 11 | namespace { 12 | 13 | // The most-recently-seen power source. 14 | bool g_on_battery = false; 15 | 16 | } // namespace 17 | 18 | // static 19 | void PowerMonitorDeviceSource::SetPowerSource(bool on_battery) { 20 | if (on_battery != g_on_battery) { 21 | g_on_battery = on_battery; 22 | ProcessPowerEvent(POWER_STATE_EVENT); 23 | } 24 | } 25 | 26 | // static 27 | void PowerMonitorDeviceSource::HandleSystemSuspending() { 28 | ProcessPowerEvent(SUSPEND_EVENT); 29 | } 30 | 31 | // static 32 | void PowerMonitorDeviceSource::HandleSystemResumed() { 33 | ProcessPowerEvent(RESUME_EVENT); 34 | } 35 | 36 | bool PowerMonitorDeviceSource::IsOnBatteryPowerImpl() { 37 | return g_on_battery; 38 | } 39 | 40 | } // namespace base 41 | -------------------------------------------------------------------------------- /src/base/process/process_handle_freebsd.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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 "base/process/process_handle.h" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace base { 13 | 14 | ProcessId GetParentProcessId(ProcessHandle process) { 15 | struct kinfo_proc info; 16 | size_t length; 17 | int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process }; 18 | 19 | if (sysctl(mib, arraysize(mib), &info, &length, NULL, 0) < 0) 20 | return -1; 21 | 22 | return info.ki_ppid; 23 | } 24 | 25 | FilePath GetProcessExecutablePath(ProcessHandle process) { 26 | char pathname[PATH_MAX]; 27 | size_t length; 28 | int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, process }; 29 | 30 | length = sizeof(pathname); 31 | 32 | if (sysctl(mib, arraysize(mib), pathname, &length, NULL, 0) < 0 || 33 | length == 0) { 34 | return FilePath(); 35 | } 36 | 37 | return FilePath(std::string(pathname)); 38 | } 39 | 40 | } // namespace base 41 | -------------------------------------------------------------------------------- /src/base/profiler/alternate_timer.cc: -------------------------------------------------------------------------------- 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 "base/profiler/alternate_timer.h" 6 | 7 | #include "base/logging.h" 8 | 9 | namespace { 10 | 11 | tracked_objects::NowFunction* g_time_function = NULL; 12 | tracked_objects::TimeSourceType g_time_source_type = 13 | tracked_objects::TIME_SOURCE_TYPE_WALL_TIME; 14 | 15 | } // anonymous namespace 16 | 17 | namespace tracked_objects { 18 | 19 | const char kAlternateProfilerTime[] = "CHROME_PROFILER_TIME"; 20 | 21 | // Set an alternate timer function to replace the OS time function when 22 | // profiling. 23 | void SetAlternateTimeSource(NowFunction* now_function, TimeSourceType type) { 24 | DCHECK_EQ(reinterpret_cast(NULL), g_time_function); 25 | g_time_function = now_function; 26 | g_time_source_type = type; 27 | } 28 | 29 | NowFunction* GetAlternateTimeSource() { 30 | return g_time_function; 31 | } 32 | 33 | TimeSourceType GetTimeSourceType() { 34 | return g_time_source_type; 35 | } 36 | 37 | } // namespace tracked_objects 38 | -------------------------------------------------------------------------------- /src/base/test/thread_test_helper.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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 "base/test/thread_test_helper.h" 6 | 7 | #include "base/bind.h" 8 | #include "base/location.h" 9 | #include "base/threading/thread_restrictions.h" 10 | 11 | namespace base { 12 | 13 | ThreadTestHelper::ThreadTestHelper( 14 | const scoped_refptr& target_thread) 15 | : test_result_(false), 16 | target_thread_(target_thread), 17 | done_event_(false, false) { 18 | } 19 | 20 | bool ThreadTestHelper::Run() { 21 | if (!target_thread_->PostTask( 22 | FROM_HERE, base::Bind(&ThreadTestHelper::RunInThread, this))) { 23 | return false; 24 | } 25 | base::ThreadRestrictions::ScopedAllowWait allow_wait; 26 | done_event_.Wait(); 27 | return test_result_; 28 | } 29 | 30 | void ThreadTestHelper::RunTest() { set_test_result(true); } 31 | 32 | ThreadTestHelper::~ThreadTestHelper() {} 33 | 34 | void ThreadTestHelper::RunInThread() { 35 | RunTest(); 36 | done_event_.Signal(); 37 | } 38 | 39 | } // namespace base 40 | -------------------------------------------------------------------------------- /src/base/test/android/javatests/src/org/chromium/base/test/util/InstrumentationUtils.java: -------------------------------------------------------------------------------- 1 | // Copyright 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 | package org.chromium.base.test.util; 6 | 7 | import android.app.Instrumentation; 8 | 9 | import java.util.concurrent.Callable; 10 | import java.util.concurrent.ExecutionException; 11 | import java.util.concurrent.FutureTask; 12 | 13 | /** 14 | * Utility methods built around the android.app.Instrumentation class. 15 | */ 16 | public final class InstrumentationUtils { 17 | 18 | private InstrumentationUtils() { 19 | } 20 | 21 | public static R runOnMainSyncAndGetResult(Instrumentation instrumentation, 22 | Callable callable) throws Throwable { 23 | FutureTask task = new FutureTask(callable); 24 | instrumentation.runOnMainSync(task); 25 | try { 26 | return task.get(); 27 | } catch (ExecutionException e) { 28 | // Unwrap the cause of the exception and re-throw it. 29 | throw e.getCause(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/base/prefs/scoped_user_pref_update.cc: -------------------------------------------------------------------------------- 1 | // Copyright 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 | #include "base/prefs/scoped_user_pref_update.h" 6 | 7 | #include "base/logging.h" 8 | #include "base/prefs/pref_notifier.h" 9 | #include "base/prefs/pref_service.h" 10 | 11 | namespace subtle { 12 | 13 | ScopedUserPrefUpdateBase::ScopedUserPrefUpdateBase(PrefService* service, 14 | const std::string& path) 15 | : service_(service), path_(path), value_(NULL) { 16 | DCHECK(service_->CalledOnValidThread()); 17 | } 18 | 19 | ScopedUserPrefUpdateBase::~ScopedUserPrefUpdateBase() { 20 | Notify(); 21 | } 22 | 23 | base::Value* ScopedUserPrefUpdateBase::GetValueOfType(base::Value::Type type) { 24 | DCHECK(CalledOnValidThread()); 25 | if (!value_) 26 | value_ = service_->GetMutableUserPref(path_, type); 27 | return value_; 28 | } 29 | 30 | void ScopedUserPrefUpdateBase::Notify() { 31 | if (value_) { 32 | service_->ReportUserPrefChanged(path_); 33 | value_ = NULL; 34 | } 35 | } 36 | 37 | } // namespace subtle 38 | -------------------------------------------------------------------------------- /src/base/test/simple_test_tick_clock.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_SIMPLE_TEST_TICK_CLOCK_H_ 6 | #define BASE_SIMPLE_TEST_TICK_CLOCK_H_ 7 | 8 | #include "base/compiler_specific.h" 9 | #include "base/synchronization/lock.h" 10 | #include "base/time/tick_clock.h" 11 | #include "base/time/time.h" 12 | 13 | namespace base { 14 | 15 | // SimpleTestTickClock is a TickClock implementation that gives 16 | // control over the returned TimeTicks objects. All methods may be 17 | // called from any thread. 18 | class SimpleTestTickClock : public TickClock { 19 | public: 20 | // Starts off with a clock set to TimeTicks(). 21 | SimpleTestTickClock(); 22 | ~SimpleTestTickClock() override; 23 | 24 | TimeTicks NowTicks() override; 25 | 26 | // Advances the clock by |delta|, which must not be negative. 27 | void Advance(TimeDelta delta); 28 | 29 | private: 30 | // Protects |now_ticks_|. 31 | Lock lock_; 32 | 33 | TimeTicks now_ticks_; 34 | }; 35 | 36 | } // namespace base 37 | 38 | #endif // BASE_SIMPLE_TEST_TICK_CLOCK_H_ 39 | -------------------------------------------------------------------------------- /src/base/barrier_closure.h: -------------------------------------------------------------------------------- 1 | // Copyright 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_BARRIER_CLOSURE_H_ 6 | #define BASE_BARRIER_CLOSURE_H_ 7 | 8 | #include "base/base_export.h" 9 | #include "base/callback_forward.h" 10 | 11 | namespace base { 12 | 13 | // BarrierClosure executes |done_closure| after it has been invoked 14 | // |num_closures| times. 15 | // 16 | // If |num_closures| is 0, |done_closure| is executed immediately. 17 | // 18 | // BarrierClosure is thread-safe - the count of remaining closures is 19 | // maintained as a base::AtomicRefCount. |done_closure| will be run on 20 | // the thread that calls the final Run() on the returned closures. 21 | // 22 | // |done_closure| is also Reset() on the final calling thread but due to the 23 | // refcounted nature of callbacks, it is hard to know what thread resources 24 | // will be released on. 25 | BASE_EXPORT base::Closure BarrierClosure(int num_closures, 26 | const base::Closure& done_closure); 27 | 28 | } // namespace base 29 | 30 | #endif // BASE_BARRIER_CLOSURE_H_ 31 | -------------------------------------------------------------------------------- /src/base/third_party/xdg_user_dirs/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007 Red Hat, inc 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation files 5 | (the "Software"), to deal in the Software without restriction, 6 | including without limitation the rights to use, copy, modify, merge, 7 | publish, distribute, sublicense, and/or sell copies of the Software, 8 | and to permit persons to whom the Software is furnished to do so, 9 | subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 18 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 19 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/base/test/perf_log.cc: -------------------------------------------------------------------------------- 1 | // Copyright 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 | #include "base/test/perf_log.h" 6 | 7 | #include "base/files/file_util.h" 8 | #include "base/logging.h" 9 | 10 | namespace base { 11 | 12 | static FILE* perf_log_file = NULL; 13 | 14 | bool InitPerfLog(const FilePath& log_file) { 15 | if (perf_log_file) { 16 | // trying to initialize twice 17 | NOTREACHED(); 18 | return false; 19 | } 20 | 21 | perf_log_file = OpenFile(log_file, "w"); 22 | return perf_log_file != NULL; 23 | } 24 | 25 | void FinalizePerfLog() { 26 | if (!perf_log_file) { 27 | // trying to cleanup without initializing 28 | NOTREACHED(); 29 | return; 30 | } 31 | base::CloseFile(perf_log_file); 32 | } 33 | 34 | void LogPerfResult(const char* test_name, double value, const char* units) { 35 | if (!perf_log_file) { 36 | NOTREACHED(); 37 | return; 38 | } 39 | 40 | fprintf(perf_log_file, "%s\t%g\t%s\n", test_name, value, units); 41 | printf("%s\t%g\t%s\n", test_name, value, units); 42 | fflush(stdout); 43 | } 44 | 45 | } // namespace base 46 | -------------------------------------------------------------------------------- /src/base/bits.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009 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 | // This file defines some bit utilities. 6 | 7 | #ifndef BASE_BITS_H_ 8 | #define BASE_BITS_H_ 9 | 10 | #include "base/basictypes.h" 11 | #include "base/logging.h" 12 | 13 | namespace base { 14 | namespace bits { 15 | 16 | // Returns the integer i such as 2^i <= n < 2^(i+1) 17 | inline int Log2Floor(uint32 n) { 18 | if (n == 0) 19 | return -1; 20 | int log = 0; 21 | uint32 value = n; 22 | for (int i = 4; i >= 0; --i) { 23 | int shift = (1 << i); 24 | uint32 x = value >> shift; 25 | if (x != 0) { 26 | value = x; 27 | log += shift; 28 | } 29 | } 30 | DCHECK_EQ(value, 1u); 31 | return log; 32 | } 33 | 34 | // Returns the integer i such as 2^(i-1) < n <= 2^i 35 | inline int Log2Ceiling(uint32 n) { 36 | if (n == 0) { 37 | return -1; 38 | } else { 39 | // Log2Floor returns -1 for 0, so the following works correctly for n=1. 40 | return 1 + Log2Floor(n - 1); 41 | } 42 | } 43 | 44 | } // namespace bits 45 | } // namespace base 46 | 47 | #endif // BASE_BITS_H_ 48 | -------------------------------------------------------------------------------- /src/base/synchronization/lock.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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 | // This file is used for debugging assertion support. The Lock class 6 | // is functionally a wrapper around the LockImpl class, so the only 7 | // real intelligence in the class is in the debugging logic. 8 | 9 | #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) 10 | 11 | #include "base/synchronization/lock.h" 12 | #include "base/logging.h" 13 | 14 | namespace base { 15 | 16 | Lock::Lock() : lock_() { 17 | } 18 | 19 | Lock::~Lock() { 20 | DCHECK(owning_thread_ref_.is_null()); 21 | } 22 | 23 | void Lock::AssertAcquired() const { 24 | DCHECK(owning_thread_ref_ == PlatformThread::CurrentRef()); 25 | } 26 | 27 | void Lock::CheckHeldAndUnmark() { 28 | DCHECK(owning_thread_ref_ == PlatformThread::CurrentRef()); 29 | owning_thread_ref_ = PlatformThreadRef(); 30 | } 31 | 32 | void Lock::CheckUnheldAndMark() { 33 | DCHECK(owning_thread_ref_.is_null()); 34 | owning_thread_ref_ = PlatformThread::CurrentRef(); 35 | } 36 | 37 | } // namespace base 38 | 39 | #endif // !NDEBUG || DCHECK_ALWAYS_ON 40 | -------------------------------------------------------------------------------- /src/base/allocator/type_profiler_tcmalloc.cc: -------------------------------------------------------------------------------- 1 | // Copyright 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 | #if defined(TYPE_PROFILING) 6 | 7 | #include "base/allocator/type_profiler_tcmalloc.h" 8 | 9 | #include "base/allocator/type_profiler_control.h" 10 | #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" 11 | #include "third_party/tcmalloc/chromium/src/gperftools/type_profiler_map.h" 12 | 13 | namespace base { 14 | namespace type_profiler { 15 | 16 | void* NewInterceptForTCMalloc(void* ptr, 17 | size_t size, 18 | const std::type_info& type) { 19 | if (Controller::IsProfiling()) 20 | InsertType(ptr, size, type); 21 | 22 | return ptr; 23 | } 24 | 25 | void* DeleteInterceptForTCMalloc(void* ptr, 26 | size_t size, 27 | const std::type_info& type) { 28 | if (Controller::IsProfiling()) 29 | EraseType(ptr); 30 | 31 | return ptr; 32 | } 33 | 34 | } // namespace type_profiler 35 | } // namespace base 36 | 37 | #endif // defined(TYPE_PROFILING) 38 | -------------------------------------------------------------------------------- /src/base/base_switches.h: -------------------------------------------------------------------------------- 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 | // Defines all the "base" command-line switches. 6 | 7 | #ifndef BASE_BASE_SWITCHES_H_ 8 | #define BASE_BASE_SWITCHES_H_ 9 | 10 | #include "build/build_config.h" 11 | 12 | namespace switches { 13 | 14 | extern const char kDisableBreakpad[]; 15 | extern const char kEnableCrashReporter[]; 16 | extern const char kFullMemoryCrashReport[]; 17 | extern const char kEnableLowEndDeviceMode[]; 18 | extern const char kDisableLowEndDeviceMode[]; 19 | extern const char kNoErrorDialogs[]; 20 | extern const char kProfilerTiming[]; 21 | extern const char kProfilerTimingDisabledValue[]; 22 | extern const char kTestChildProcess[]; 23 | extern const char kTraceToConsole[]; 24 | extern const char kTraceToFile[]; 25 | extern const char kTraceToFileName[]; 26 | extern const char kV[]; 27 | extern const char kVModule[]; 28 | extern const char kWaitForDebugger[]; 29 | 30 | #if defined(OS_POSIX) 31 | extern const char kEnableCrashReporterForTesting[]; 32 | #endif 33 | 34 | } // namespace switches 35 | 36 | #endif // BASE_BASE_SWITCHES_H_ 37 | -------------------------------------------------------------------------------- /src/base/prefs/pref_store_observer_mock.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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_PREFS_PREF_STORE_OBSERVER_MOCK_H_ 6 | #define BASE_PREFS_PREF_STORE_OBSERVER_MOCK_H_ 7 | 8 | #include 9 | #include 10 | 11 | #include "base/compiler_specific.h" 12 | #include "base/macros.h" 13 | #include "base/prefs/pref_store.h" 14 | 15 | // A mock implementation of PrefStore::Observer. 16 | class PrefStoreObserverMock : public PrefStore::Observer { 17 | public: 18 | PrefStoreObserverMock(); 19 | ~PrefStoreObserverMock() override; 20 | 21 | void VerifyAndResetChangedKey(const std::string& expected); 22 | 23 | // PrefStore::Observer implementation 24 | void OnPrefValueChanged(const std::string& key) override; 25 | void OnInitializationCompleted(bool success) override; 26 | 27 | std::vector changed_keys; 28 | bool initialized; 29 | bool initialization_success; // Only valid if |initialized|. 30 | 31 | private: 32 | DISALLOW_COPY_AND_ASSIGN(PrefStoreObserverMock); 33 | }; 34 | 35 | #endif // BASE_PREFS_PREF_STORE_OBSERVER_MOCK_H_ 36 | -------------------------------------------------------------------------------- /src/base/test/android/javatests/src/org/chromium/base/test/util/Feature.java: -------------------------------------------------------------------------------- 1 | // Copyright 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 | package org.chromium.base.test.util; 6 | 7 | import java.lang.annotation.ElementType; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * The java instrumentation tests are normally fairly large (in terms of 14 | * dependencies), and the test suite ends up containing a large amount of 15 | * tests that are not trivial to filter / group just by their names. 16 | * Instead, we use this annotation: each test should be annotated as: 17 | * @Feature({"Foo", "Bar"}) 18 | * in order for the test runner scripts to be able to filter and group 19 | * them accordingly (for instance, this enable us to run all tests that exercise 20 | * feature Foo). 21 | */ 22 | @Target(ElementType.METHOD) 23 | @Retention(RetentionPolicy.RUNTIME) 24 | public @interface Feature { 25 | /** 26 | * @return A list of feature names. 27 | */ 28 | public String[] value(); 29 | } 30 | -------------------------------------------------------------------------------- /src/base/win/i18n.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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_WIN_I18N_H_ 6 | #define BASE_WIN_I18N_H_ 7 | 8 | #include 9 | #include 10 | 11 | #include "base/base_export.h" 12 | #include "base/basictypes.h" 13 | 14 | namespace base { 15 | namespace win { 16 | namespace i18n { 17 | 18 | // Adds to |languages| the list of user preferred UI languages from MUI, if 19 | // available, falling-back on the user default UI language otherwise. Returns 20 | // true if at least one language is added. 21 | BASE_EXPORT bool GetUserPreferredUILanguageList( 22 | std::vector* languages); 23 | 24 | // Adds to |languages| the list of thread, process, user, and system preferred 25 | // UI languages from MUI, if available, falling-back on the user default UI 26 | // language otherwise. Returns true if at least one language is added. 27 | BASE_EXPORT bool GetThreadPreferredUILanguageList( 28 | std::vector* languages); 29 | 30 | } // namespace i18n 31 | } // namespace win 32 | } // namespace base 33 | 34 | #endif // BASE_WIN_I18N_H_ 35 | -------------------------------------------------------------------------------- /src/base/win/scoped_hglobal.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2010 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_WIN_SCOPED_HGLOBAL_H_ 6 | #define BASE_WIN_SCOPED_HGLOBAL_H_ 7 | 8 | #include 9 | 10 | #include "base/basictypes.h" 11 | 12 | namespace base { 13 | namespace win { 14 | 15 | // Like ScopedHandle except for HGLOBAL. 16 | template 17 | class ScopedHGlobal { 18 | public: 19 | explicit ScopedHGlobal(HGLOBAL glob) : glob_(glob) { 20 | data_ = static_cast(GlobalLock(glob_)); 21 | } 22 | ~ScopedHGlobal() { 23 | GlobalUnlock(glob_); 24 | } 25 | 26 | T get() { return data_; } 27 | 28 | size_t Size() const { return GlobalSize(glob_); } 29 | 30 | T operator->() const { 31 | assert(data_ != 0); 32 | return data_; 33 | } 34 | 35 | T release() { 36 | T data = data_; 37 | data_ = NULL; 38 | return data; 39 | } 40 | 41 | private: 42 | HGLOBAL glob_; 43 | 44 | T data_; 45 | 46 | DISALLOW_COPY_AND_ASSIGN(ScopedHGlobal); 47 | }; 48 | 49 | } // namespace win 50 | } // namespace base 51 | 52 | #endif // BASE_WIN_SCOPED_HGLOBAL_H_ 53 | -------------------------------------------------------------------------------- /src/third_party/libevent/README.chromium: -------------------------------------------------------------------------------- 1 | Name: libevent 2 | URL: http://www.monkey.org/~provos/libevent/ 3 | Version: 1.4.13 4 | License: BSD 5 | Security Critical: yes 6 | 7 | Local Modifications: 8 | Rather than use libevent's own build system, we just build a Chrome 9 | static library using GYP. 10 | 11 | 1) Run configure and "make event-config.h" on Linux, FreeBSD, Solaris, 12 | and Mac and copy config.h and event-config.h to linux/, freebsd/, 13 | solaris/, and mac/ respectively. 14 | 2) Add libevent.gyp. 15 | 3) chromium.patch is applied to allow libevent to be used without 16 | being installed and to fix a race condition. 17 | 4) The directories WIN32-Code and WIN32-Prj are not included. 18 | 5) Apply r87338. 19 | 6) The configs for android were copied from Linux's which were very close to 20 | android one with the exception of HAVE_FD_MASK and HAVE_STRLCPY. 21 | 7) Add files to support building with the PNaCl toolchain. Added 22 | libevent_nacl_nonsfi.gyp for build rule. nacl_nonsfi/config.h and 23 | nacl_nonsfi/event-config.h are derived from linux/ counterparts. 24 | nacl_nonsfi/random.c is also added to provide the random() function, 25 | which is missing in the newlib-based PNaCl toolchain. 26 | -------------------------------------------------------------------------------- /src/base/files/file_posix_hooks_internal.h: -------------------------------------------------------------------------------- 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 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_FILES_FILE_POSIX_HOOKS_INTERNAL_H_ 6 | #define BASE_FILES_FILE_POSIX_HOOKS_INTERNAL_H_ 7 | 8 | #include "base/base_export.h" 9 | 10 | namespace base { 11 | 12 | // Define empty hooks for blacklisting file descriptors used in base::File. 13 | // These functions should be declared 'weak', i.e. the functions declared in 14 | // a default way would have precedence over the weak ones at link time. This 15 | // works for both static and dynamic linking. 16 | // TODO(pasko): Remove these hooks when crbug.com/424562 is fixed. 17 | // 18 | // With compilers other than GCC/Clang define strong no-op symbols for 19 | // simplicity. 20 | #if defined(COMPILER_GCC) 21 | #define ATTRIBUTE_WEAK __attribute__ ((weak)) 22 | #else 23 | #define ATTRIBUTE_WEAK 24 | #endif 25 | BASE_EXPORT void ProtectFileDescriptor(int fd) ATTRIBUTE_WEAK; 26 | BASE_EXPORT void UnprotectFileDescriptor(int fd) ATTRIBUTE_WEAK; 27 | #undef ATTRIBUTE_WEAK 28 | 29 | } // namespace base 30 | 31 | #endif // BASE_FILES_FILE_POSIX_HOOKS_INTERNAL_H_ 32 | -------------------------------------------------------------------------------- /src/base/callback_internal.cc: -------------------------------------------------------------------------------- 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 "base/callback_internal.h" 6 | 7 | #include "base/logging.h" 8 | 9 | namespace base { 10 | namespace internal { 11 | 12 | CallbackBase::CallbackBase(const CallbackBase& c) = default; 13 | CallbackBase& CallbackBase::operator=(const CallbackBase& c) = default; 14 | 15 | void CallbackBase::Reset() { 16 | polymorphic_invoke_ = NULL; 17 | // NULL the bind_state_ last, since it may be holding the last ref to whatever 18 | // object owns us, and we may be deleted after that. 19 | bind_state_ = NULL; 20 | } 21 | 22 | bool CallbackBase::Equals(const CallbackBase& other) const { 23 | return bind_state_.get() == other.bind_state_.get() && 24 | polymorphic_invoke_ == other.polymorphic_invoke_; 25 | } 26 | 27 | CallbackBase::CallbackBase(BindStateBase* bind_state) 28 | : bind_state_(bind_state), 29 | polymorphic_invoke_(NULL) { 30 | DCHECK(!bind_state_.get() || bind_state_->HasOneRef()); 31 | } 32 | 33 | CallbackBase::~CallbackBase() { 34 | } 35 | 36 | } // namespace internal 37 | } // namespace base 38 | -------------------------------------------------------------------------------- /src/base/test/run_all_unittests.cc: -------------------------------------------------------------------------------- 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 "base/at_exit.h" 6 | #include "base/bind.h" 7 | #include "base/test/launcher/unit_test_launcher.h" 8 | #include "base/test/test_suite.h" 9 | 10 | #if defined(OS_ANDROID) 11 | #include "base/android/jni_android.h" 12 | #include "base/test/test_file_util.h" 13 | #endif 14 | 15 | namespace { 16 | 17 | class NoAtExitBaseTestSuite : public base::TestSuite { 18 | public: 19 | NoAtExitBaseTestSuite(int argc, char** argv) 20 | : base::TestSuite(argc, argv, false) { 21 | } 22 | }; 23 | 24 | int RunTestSuite(int argc, char** argv) { 25 | return NoAtExitBaseTestSuite(argc, argv).Run(); 26 | } 27 | 28 | } // namespace 29 | 30 | int main(int argc, char** argv) { 31 | #if defined(OS_ANDROID) 32 | JNIEnv* env = base::android::AttachCurrentThread(); 33 | base::RegisterContentUriTestUtils(env); 34 | #else 35 | base::AtExitManager at_exit; 36 | #endif 37 | return base::LaunchUnitTests(argc, 38 | argv, 39 | base::Bind(&RunTestSuite, argc, argv)); 40 | } 41 | -------------------------------------------------------------------------------- /src/base/timer/hi_res_timer_manager_win.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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 "base/timer/hi_res_timer_manager.h" 6 | 7 | #include "base/power_monitor/power_monitor.h" 8 | #include "base/time/time.h" 9 | 10 | namespace base { 11 | 12 | HighResolutionTimerManager::HighResolutionTimerManager() 13 | : hi_res_clock_available_(false) { 14 | base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); 15 | DCHECK(power_monitor != NULL); 16 | power_monitor->AddObserver(this); 17 | UseHiResClock(!power_monitor->IsOnBatteryPower()); 18 | } 19 | 20 | HighResolutionTimerManager::~HighResolutionTimerManager() { 21 | base::PowerMonitor::Get()->RemoveObserver(this); 22 | UseHiResClock(false); 23 | } 24 | 25 | void HighResolutionTimerManager::OnPowerStateChange(bool on_battery_power) { 26 | UseHiResClock(!on_battery_power); 27 | } 28 | 29 | void HighResolutionTimerManager::UseHiResClock(bool use) { 30 | if (use == hi_res_clock_available_) 31 | return; 32 | hi_res_clock_available_ = use; 33 | base::Time::EnableHighResolutionTimer(use); 34 | } 35 | 36 | } // namespace base 37 | -------------------------------------------------------------------------------- /src/third_party/libevent/test/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign no-dependencies 2 | 3 | AM_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/compat 4 | 5 | EXTRA_DIST = regress.rpc regress.gen.h regress.gen.c 6 | 7 | noinst_PROGRAMS = test-init test-eof test-weof test-time regress bench 8 | 9 | BUILT_SOURCES = regress.gen.c regress.gen.h 10 | test_init_SOURCES = test-init.c 11 | test_init_LDADD = ../libevent_core.la 12 | test_eof_SOURCES = test-eof.c 13 | test_eof_LDADD = ../libevent_core.la 14 | test_weof_SOURCES = test-weof.c 15 | test_weof_LDADD = ../libevent_core.la 16 | test_time_SOURCES = test-time.c 17 | test_time_LDADD = ../libevent_core.la 18 | regress_SOURCES = regress.c regress.h regress_http.c regress_dns.c \ 19 | regress_rpc.c \ 20 | regress.gen.c regress.gen.h 21 | regress_LDADD = ../libevent.la 22 | bench_SOURCES = bench.c 23 | bench_LDADD = ../libevent.la 24 | 25 | regress.gen.c regress.gen.h: regress.rpc $(top_srcdir)/event_rpcgen.py 26 | $(top_srcdir)/event_rpcgen.py $(srcdir)/regress.rpc || echo "No Python installed" 27 | 28 | DISTCLEANFILES = *~ 29 | 30 | test: test-init test-eof test-weof test-time regress 31 | 32 | verify: test 33 | @$(srcdir)/test.sh 34 | 35 | bench test-init test-eof test-weof test-time: ../libevent.la 36 | -------------------------------------------------------------------------------- /src/base/metrics/user_metrics_action.h: -------------------------------------------------------------------------------- 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 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_METRICS_USER_METRICS_ACTION_H_ 6 | #define BASE_METRICS_USER_METRICS_ACTION_H_ 7 | 8 | namespace base { 9 | 10 | // UserMetricsAction exists purely to standardize on the parameters passed to 11 | // UserMetrics. That way, our toolset can scan the source code reliable for 12 | // constructors and extract the associated string constants. 13 | // WARNING: When using UserMetricsAction, UserMetricsAction and a string literal 14 | // parameter must be on the same line, e.g. 15 | // RecordAction(UserMetricsAction("my extremely long action name")); 16 | // or 17 | // RenderThread::Get()->RecordAction( 18 | // UserMetricsAction("my extremely long action name")); 19 | // because otherwise our processing scripts won't pick up on new actions. 20 | // Please see tools/metrics/actions/extract_actions.py for details. 21 | struct UserMetricsAction { 22 | const char* str_; 23 | explicit UserMetricsAction(const char* str) : str_(str) {} 24 | }; 25 | 26 | } // namespace base 27 | 28 | #endif // BASE_METRICS_USER_METRICS_ACTION_H_ 29 | -------------------------------------------------------------------------------- /src/base/test/android/javatests/src/org/chromium/base/test/util/ScalableTimeout.java: -------------------------------------------------------------------------------- 1 | // Copyright 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 | package org.chromium.base.test.util; 6 | 7 | /** 8 | * Utility class for scaling various timeouts by a common factor. 9 | * For example, to run tests under Valgrind, you might want the following: 10 | * adb shell "echo 20.0 > /data/local/tmp/chrome_timeout_scale" 11 | */ 12 | public class ScalableTimeout { 13 | private static Double sTimeoutScale = null; 14 | private static final String PROPERTY_FILE = "/data/local/tmp/chrome_timeout_scale"; 15 | 16 | public static long scaleTimeout(long timeout) { 17 | if (sTimeoutScale == null) { 18 | try { 19 | char[] data = TestFileUtil.readUtf8File(PROPERTY_FILE, 32); 20 | sTimeoutScale = Double.parseDouble(new String(data)); 21 | } catch (Exception e) { 22 | // NumberFormatException, FileNotFoundException, IOException 23 | sTimeoutScale = 1.0; 24 | } 25 | } 26 | return (long) (timeout * sTimeoutScale); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/base/test/launcher/unit_test_launcher_ios.cc: -------------------------------------------------------------------------------- 1 | // Copyright 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 | #include "base/test/launcher/unit_test_launcher.h" 6 | 7 | #include "base/command_line.h" 8 | #include "base/files/file_path.h" 9 | #include "base/logging.h" 10 | #include "base/test/gtest_util.h" 11 | #include "base/test/test_switches.h" 12 | 13 | namespace base { 14 | 15 | int LaunchUnitTests(int argc, 16 | char** argv, 17 | const RunTestSuiteCallback& run_test_suite) { 18 | CHECK(CommandLine::InitializedForCurrentProcess() || 19 | CommandLine::Init(argc, argv)); 20 | const CommandLine* command_line = CommandLine::ForCurrentProcess(); 21 | if (command_line->HasSwitch(switches::kTestLauncherListTests)) { 22 | FilePath list_path(command_line->GetSwitchValuePath( 23 | switches::kTestLauncherListTests)); 24 | if (WriteCompiledInTestsToFile(list_path)) { 25 | return 0; 26 | } else { 27 | LOG(ERROR) << "Failed to write list of tests."; 28 | return 1; 29 | } 30 | } 31 | 32 | return run_test_suite.Run(); 33 | } 34 | 35 | } // namespace base 36 | -------------------------------------------------------------------------------- /src/base/process/process_iterator_win.cc: -------------------------------------------------------------------------------- 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 | #include "base/process/process_iterator.h" 6 | 7 | namespace base { 8 | 9 | ProcessIterator::ProcessIterator(const ProcessFilter* filter) 10 | : started_iteration_(false), 11 | filter_(filter) { 12 | snapshot_ = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); 13 | } 14 | 15 | ProcessIterator::~ProcessIterator() { 16 | CloseHandle(snapshot_); 17 | } 18 | 19 | bool ProcessIterator::CheckForNextProcess() { 20 | InitProcessEntry(&entry_); 21 | 22 | if (!started_iteration_) { 23 | started_iteration_ = true; 24 | return !!Process32First(snapshot_, &entry_); 25 | } 26 | 27 | return !!Process32Next(snapshot_, &entry_); 28 | } 29 | 30 | void ProcessIterator::InitProcessEntry(ProcessEntry* entry) { 31 | memset(entry, 0, sizeof(*entry)); 32 | entry->dwSize = sizeof(*entry); 33 | } 34 | 35 | bool NamedProcessIterator::IncludeEntry() { 36 | // Case insensitive. 37 | return _wcsicmp(executable_name_.c_str(), entry().exe_file()) == 0 && 38 | ProcessIterator::IncludeEntry(); 39 | } 40 | 41 | } // namespace base 42 | -------------------------------------------------------------------------------- /src/base/timer/mock_timer.h: -------------------------------------------------------------------------------- 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 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_TIMER_MOCK_TIMER_H_ 6 | #define BASE_TIMER_MOCK_TIMER_H_ 7 | 8 | #include "base/timer/timer.h" 9 | 10 | namespace base { 11 | 12 | class BASE_EXPORT MockTimer : public Timer { 13 | public: 14 | MockTimer(bool retain_user_task, bool is_repeating); 15 | MockTimer(const tracked_objects::Location& posted_from, 16 | TimeDelta delay, 17 | const base::Closure& user_task, 18 | bool is_repeating); 19 | ~MockTimer() override; 20 | 21 | // base::Timer implementation. 22 | bool IsRunning() const override; 23 | base::TimeDelta GetCurrentDelay() const override; 24 | void Start(const tracked_objects::Location& posted_from, 25 | base::TimeDelta delay, 26 | const base::Closure& user_task) override; 27 | void Stop() override; 28 | void Reset() override; 29 | 30 | // Testing methods. 31 | void Fire(); 32 | 33 | private: 34 | base::Closure user_task_; 35 | TimeDelta delay_; 36 | bool is_running_; 37 | }; 38 | 39 | } // namespace base 40 | 41 | #endif // !BASE_TIMER_MOCK_TIMER_H_ 42 | -------------------------------------------------------------------------------- /src/base/files/dir_reader_fallback.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_FILES_DIR_READER_FALLBACK_H_ 6 | #define BASE_FILES_DIR_READER_FALLBACK_H_ 7 | 8 | namespace base { 9 | 10 | class DirReaderFallback { 11 | public: 12 | // Open a directory. If |IsValid| is true, then |Next| can be called to start 13 | // the iteration at the beginning of the directory. 14 | explicit DirReaderFallback(const char* directory_path) {} 15 | 16 | // After construction, IsValid returns true iff the directory was 17 | // successfully opened. 18 | bool IsValid() const { return false; } 19 | 20 | // Move to the next entry returning false if the iteration is complete. 21 | bool Next() { return false; } 22 | 23 | // Return the name of the current directory entry. 24 | const char* name() { return 0;} 25 | 26 | // Return the file descriptor which is being used. 27 | int fd() const { return -1; } 28 | 29 | // Returns true if this is a no-op fallback class (for testing). 30 | static bool IsFallback() { return true; } 31 | }; 32 | 33 | } // namespace base 34 | 35 | #endif // BASE_FILES_DIR_READER_FALLBACK_H_ 36 | -------------------------------------------------------------------------------- /src/base/test/null_task_runner.h: -------------------------------------------------------------------------------- 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 "base/basictypes.h" 6 | #include "base/compiler_specific.h" 7 | #include "base/single_thread_task_runner.h" 8 | 9 | namespace base { 10 | 11 | // Helper class for tests that need to provide an implementation of a 12 | // *TaskRunner class but don't actually care about tasks being run. 13 | 14 | class NullTaskRunner : public base::SingleThreadTaskRunner { 15 | public: 16 | NullTaskRunner(); 17 | 18 | bool PostDelayedTask(const tracked_objects::Location& from_here, 19 | const base::Closure& task, 20 | base::TimeDelta delay) override; 21 | bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, 22 | const base::Closure& task, 23 | base::TimeDelta delay) override; 24 | // Always returns true to avoid triggering DCHECKs. 25 | bool RunsTasksOnCurrentThread() const override; 26 | 27 | protected: 28 | ~NullTaskRunner() override; 29 | 30 | DISALLOW_COPY_AND_ASSIGN(NullTaskRunner); 31 | }; 32 | 33 | } // namespace 34 | -------------------------------------------------------------------------------- /src/base/win/scoped_select_object.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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_WIN_SCOPED_SELECT_OBJECT_H_ 6 | #define BASE_WIN_SCOPED_SELECT_OBJECT_H_ 7 | 8 | #include 9 | 10 | #include "base/basictypes.h" 11 | #include "base/logging.h" 12 | 13 | namespace base { 14 | namespace win { 15 | 16 | // Helper class for deselecting object from DC. 17 | class ScopedSelectObject { 18 | public: 19 | ScopedSelectObject(HDC hdc, HGDIOBJ object) 20 | : hdc_(hdc), 21 | oldobj_(SelectObject(hdc, object)) { 22 | DCHECK(hdc_); 23 | DCHECK(object); 24 | DCHECK(oldobj_ != NULL && oldobj_ != HGDI_ERROR); 25 | } 26 | 27 | ~ScopedSelectObject() { 28 | HGDIOBJ object = SelectObject(hdc_, oldobj_); 29 | DCHECK((GetObjectType(oldobj_) != OBJ_REGION && object != NULL) || 30 | (GetObjectType(oldobj_) == OBJ_REGION && object != HGDI_ERROR)); 31 | } 32 | 33 | private: 34 | HDC hdc_; 35 | HGDIOBJ oldobj_; 36 | 37 | DISALLOW_COPY_AND_ASSIGN(ScopedSelectObject); 38 | }; 39 | 40 | } // namespace win 41 | } // namespace base 42 | 43 | #endif // BASE_WIN_SCOPED_SELECT_OBJECT_H_ 44 | -------------------------------------------------------------------------------- /src/base/hash.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 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_HASH_H_ 6 | #define BASE_HASH_H_ 7 | 8 | #include 9 | #include 10 | 11 | #include "base/base_export.h" 12 | #include "base/basictypes.h" 13 | #include "base/logging.h" 14 | 15 | namespace base { 16 | 17 | // WARNING: This hash function should not be used for any cryptographic purpose. 18 | BASE_EXPORT uint32 SuperFastHash(const char* data, int len); 19 | 20 | // Computes a hash of a memory buffer |data| of a given |length|. 21 | // WARNING: This hash function should not be used for any cryptographic purpose. 22 | inline uint32 Hash(const char* data, size_t length) { 23 | if (length > static_cast(std::numeric_limits::max())) { 24 | NOTREACHED(); 25 | return 0; 26 | } 27 | return SuperFastHash(data, static_cast(length)); 28 | } 29 | 30 | // Computes a hash of a string |str|. 31 | // WARNING: This hash function should not be used for any cryptographic purpose. 32 | inline uint32 Hash(const std::string& str) { 33 | return Hash(str.data(), str.size()); 34 | } 35 | 36 | } // namespace base 37 | 38 | #endif // BASE_HASH_H_ 39 | --------------------------------------------------------------------------------