├── .gitignore ├── .travis.yml ├── Debug └── sqlite3.dll ├── LICENSE ├── README.md ├── base.gyp ├── base.sln ├── base.vcxproj ├── base.vcxproj.filters ├── main.cc ├── src ├── base │ ├── DEPS │ ├── OWNERS │ ├── PRESUBMIT.py │ ├── allocator │ │ ├── BUILD.gn │ │ ├── README │ │ ├── allocator.gyp │ │ ├── allocator_extension.cc │ │ ├── allocator_extension.h │ │ ├── allocator_extension_thunks.cc │ │ ├── allocator_extension_thunks.h │ │ ├── allocator_shim.cc │ │ ├── allocator_shim.h │ │ ├── debugallocation_shim.cc │ │ ├── generic_allocators.cc │ │ ├── prep_libc.py │ │ ├── type_profiler.cc │ │ ├── type_profiler.h │ │ ├── type_profiler_control.cc │ │ ├── type_profiler_control.h │ │ ├── type_profiler_tcmalloc.cc │ │ ├── type_profiler_tcmalloc.h │ │ ├── unittest_utils.cc │ │ └── win_allocator.cc │ ├── async_socket_io_handler.h │ ├── async_socket_io_handler_posix.cc │ ├── async_socket_io_handler_win.cc │ ├── at_exit.cc │ ├── at_exit.h │ ├── atomic_ref_count.h │ ├── atomic_sequence_num.h │ ├── atomicops.h │ ├── atomicops_internals_arm64_gcc.h │ ├── atomicops_internals_arm_gcc.h │ ├── atomicops_internals_atomicword_compat.h │ ├── atomicops_internals_gcc.h │ ├── atomicops_internals_mac.h │ ├── atomicops_internals_mips_gcc.h │ ├── atomicops_internals_portable.h │ ├── atomicops_internals_tsan.h │ ├── atomicops_internals_x86_gcc.cc │ ├── atomicops_internals_x86_gcc.h │ ├── atomicops_internals_x86_msvc.h │ ├── auto_reset.h │ ├── barrier_closure.cc │ ├── barrier_closure.h │ ├── base.gyp │ ├── base.gypi │ ├── base.isolate │ ├── base64.cc │ ├── base64.h │ ├── base_export.h │ ├── base_nacl.gyp │ ├── base_paths.cc │ ├── base_paths.h │ ├── base_paths_android.cc │ ├── base_paths_android.h │ ├── base_paths_mac.h │ ├── base_paths_mac.mm │ ├── base_paths_posix.cc │ ├── base_paths_posix.h │ ├── base_paths_win.cc │ ├── base_paths_win.h │ ├── base_switches.cc │ ├── base_switches.h │ ├── base_unittests.isolate │ ├── basictypes.h │ ├── big_endian.cc │ ├── big_endian.h │ ├── bind.h │ ├── bind_helpers.cc │ ├── bind_helpers.h │ ├── bind_internal.h │ ├── bind_internal.h.pump │ ├── bind_internal_win.h │ ├── bind_unittest.nc │ ├── bits.h │ ├── build_time.cc │ ├── build_time.h │ ├── callback.h │ ├── callback_forward.h │ ├── callback_helpers.cc │ ├── callback_helpers.h │ ├── callback_internal.cc │ ├── callback_internal.h │ ├── callback_list.h │ ├── callback_list_unittest.nc │ ├── callback_registry.h │ ├── callback_unittest.nc │ ├── cancelable_callback.h │ ├── check_example.cc │ ├── command_line.cc │ ├── command_line.h │ ├── compiler_specific.h │ ├── containers │ │ ├── adapters.h │ │ ├── hash_tables.h │ │ ├── linked_list.h │ │ ├── mru_cache.h │ │ ├── scoped_ptr_hash_map.h │ │ ├── small_map.h │ │ └── stack_container.h │ ├── cpu.cc │ ├── cpu.h │ ├── critical_closure.h │ ├── critical_closure_internal_ios.mm │ ├── debug │ │ ├── OWNERS │ │ ├── alias.cc │ │ ├── alias.h │ │ ├── asan_invalid_access.cc │ │ ├── asan_invalid_access.h │ │ ├── crash_logging.cc │ │ ├── crash_logging.h │ │ ├── debugger.cc │ │ ├── debugger.h │ │ ├── debugger_posix.cc │ │ ├── debugger_win.cc │ │ ├── dump_without_crashing.cc │ │ ├── dump_without_crashing.h │ │ ├── gdi_debug_util_win.cc │ │ ├── gdi_debug_util_win.h │ │ ├── leak_annotations.h │ │ ├── leak_tracker.h │ │ ├── proc_maps_linux.cc │ │ ├── proc_maps_linux.h │ │ ├── profiler.cc │ │ ├── profiler.h │ │ ├── stack_trace.cc │ │ ├── stack_trace.h │ │ ├── stack_trace_android.cc │ │ ├── stack_trace_posix.cc │ │ ├── stack_trace_win.cc │ │ ├── task_annotator.cc │ │ ├── task_annotator.h │ │ ├── trace_event.h │ │ ├── trace_event_android.cc │ │ ├── trace_event_argument.cc │ │ ├── trace_event_argument.h │ │ ├── trace_event_impl.cc │ │ ├── trace_event_impl.h │ │ ├── trace_event_impl_constants.cc │ │ ├── trace_event_memory.cc │ │ ├── trace_event_memory.h │ │ ├── trace_event_synthetic_delay.cc │ │ ├── trace_event_synthetic_delay.h │ │ ├── trace_event_system_stats_monitor.cc │ │ ├── trace_event_system_stats_monitor.h │ │ ├── trace_event_unittest.h │ │ ├── trace_event_win.cc │ │ └── trace_event_win.h │ ├── debug_message.cc │ ├── deferred_sequenced_task_runner.cc │ ├── deferred_sequenced_task_runner.h │ ├── environment.cc │ ├── environment.h │ ├── event_recorder.h │ ├── event_recorder_stubs.cc │ ├── event_recorder_win.cc │ ├── event_types.h │ ├── file_descriptor_posix.h │ ├── file_version_info.h │ ├── file_version_info_mac.h │ ├── file_version_info_mac.mm │ ├── file_version_info_win.cc │ ├── file_version_info_win.h │ ├── files │ │ ├── OWNERS │ │ ├── dir_reader_fallback.h │ │ ├── dir_reader_linux.h │ │ ├── dir_reader_posix.h │ │ ├── file.cc │ │ ├── file.h │ │ ├── file_enumerator.cc │ │ ├── file_enumerator.h │ │ ├── file_enumerator_posix.cc │ │ ├── file_enumerator_win.cc │ │ ├── file_path.cc │ │ ├── file_path.h │ │ ├── file_path_constants.cc │ │ ├── file_path_watcher.cc │ │ ├── file_path_watcher.h │ │ ├── file_path_watcher_browsertest.cc │ │ ├── file_path_watcher_fsevents.cc │ │ ├── file_path_watcher_fsevents.h │ │ ├── file_path_watcher_kqueue.cc │ │ ├── file_path_watcher_kqueue.h │ │ ├── file_path_watcher_linux.cc │ │ ├── file_path_watcher_mac.cc │ │ ├── file_path_watcher_stub.cc │ │ ├── file_path_watcher_win.cc │ │ ├── file_posix.cc │ │ ├── file_posix_hooks_internal.h │ │ ├── file_proxy.cc │ │ ├── file_proxy.h │ │ ├── file_util.cc │ │ ├── file_util.h │ │ ├── file_util_android.cc │ │ ├── file_util_linux.cc │ │ ├── file_util_mac.mm │ │ ├── file_util_posix.cc │ │ ├── file_util_proxy.cc │ │ ├── file_util_proxy.h │ │ ├── file_util_win.cc │ │ ├── file_win.cc │ │ ├── important_file_writer.cc │ │ ├── important_file_writer.h │ │ ├── memory_mapped_file.cc │ │ ├── memory_mapped_file.h │ │ ├── memory_mapped_file_posix.cc │ │ ├── memory_mapped_file_win.cc │ │ ├── protect_file_posix.cc │ │ ├── protect_file_posix.gypi │ │ ├── scoped_file.cc │ │ ├── scoped_file.h │ │ ├── scoped_temp_dir.cc │ │ └── scoped_temp_dir.h │ ├── float_util.h │ ├── format_macros.h │ ├── glibc-x86-32.base_untrusted.source_list.gypcmd │ ├── glibc-x86-64.base_untrusted.source_list.gypcmd │ ├── gtest_prod_util.h │ ├── guid.cc │ ├── guid.h │ ├── guid_posix.cc │ ├── guid_win.cc │ ├── hash.cc │ ├── hash.h │ ├── id_map.h │ ├── json │ │ ├── json_file_value_serializer.cc │ │ ├── json_file_value_serializer.h │ │ ├── json_parser.cc │ │ ├── json_parser.h │ │ ├── json_parser_unittest.cc │ │ ├── json_reader.cc │ │ ├── json_reader.h │ │ ├── json_reader_unittest.cc │ │ ├── json_string_value_serializer.cc │ │ ├── json_string_value_serializer.h │ │ ├── json_value_converter.cc │ │ ├── json_value_converter.h │ │ ├── json_value_converter_unittest.cc │ │ ├── json_value_serializer_unittest.cc │ │ ├── json_writer.cc │ │ ├── json_writer.h │ │ ├── json_writer_unittest.cc │ │ ├── string_escape.cc │ │ ├── string_escape.h │ │ └── string_escape_unittest.cc │ ├── lazy_instance.cc │ ├── lazy_instance.h │ ├── linux_util.cc │ ├── linux_util.h │ ├── location.cc │ ├── location.h │ ├── logging.cc │ ├── logging.h │ ├── logging_win.cc │ ├── logging_win.h │ ├── mac │ │ ├── OWNERS │ │ ├── authorization_util.h │ │ ├── authorization_util.mm │ │ ├── bind_objc_block.h │ │ ├── bind_objc_block_unittest.mm │ │ ├── bundle_locations.h │ │ ├── bundle_locations.mm │ │ ├── close_nocancel.cc │ │ ├── cocoa_protocols.h │ │ ├── foundation_util.h │ │ ├── foundation_util.mm │ │ ├── foundation_util_unittest.mm │ │ ├── launch_services_util.cc │ │ ├── launch_services_util.h │ │ ├── launchd.cc │ │ ├── launchd.h │ │ ├── libdispatch_task_runner.cc │ │ ├── libdispatch_task_runner.h │ │ ├── mac_logging.cc │ │ ├── mac_logging.h │ │ ├── mac_util.h │ │ ├── mac_util.mm │ │ ├── mac_util_unittest.mm │ │ ├── mach_logging.cc │ │ ├── mach_logging.h │ │ ├── objc_property_releaser.h │ │ ├── objc_property_releaser.mm │ │ ├── objc_property_releaser_unittest.mm │ │ ├── os_crash_dumps.cc │ │ ├── os_crash_dumps.h │ │ ├── scoped_aedesc.h │ │ ├── scoped_authorizationref.h │ │ ├── scoped_block.h │ │ ├── scoped_cffiledescriptorref.h │ │ ├── scoped_cftyperef.h │ │ ├── scoped_ioobject.h │ │ ├── scoped_ioplugininterface.h │ │ ├── scoped_launch_data.h │ │ ├── scoped_mach_port.cc │ │ ├── scoped_mach_port.h │ │ ├── scoped_mach_vm.cc │ │ ├── scoped_mach_vm.h │ │ ├── scoped_nsautorelease_pool.h │ │ ├── scoped_nsautorelease_pool.mm │ │ ├── scoped_nsexception_enabler.h │ │ ├── scoped_nsexception_enabler.mm │ │ ├── scoped_nsobject.h │ │ ├── scoped_nsobject_unittest.mm │ │ ├── scoped_objc_class_swizzler.h │ │ ├── scoped_objc_class_swizzler.mm │ │ ├── scoped_objc_class_swizzler_unittest.mm │ │ ├── scoped_sending_event.h │ │ ├── scoped_sending_event.mm │ │ ├── scoped_sending_event_unittest.mm │ │ ├── scoped_typeref.h │ │ ├── sdk_forward_declarations.h │ │ └── sdk_forward_declarations.mm │ ├── macros.h │ ├── md5.cc │ ├── md5.h │ ├── memory │ │ ├── aligned_memory.cc │ │ ├── aligned_memory.h │ │ ├── discardable_memory.cc │ │ ├── discardable_memory.h │ │ ├── discardable_memory_android.cc │ │ ├── discardable_memory_ashmem.cc │ │ ├── discardable_memory_ashmem.h │ │ ├── discardable_memory_ashmem_allocator.cc │ │ ├── discardable_memory_ashmem_allocator.h │ │ ├── discardable_memory_emulated.cc │ │ ├── discardable_memory_emulated.h │ │ ├── discardable_memory_linux.cc │ │ ├── discardable_memory_mac.cc │ │ ├── discardable_memory_mach.cc │ │ ├── discardable_memory_mach.h │ │ ├── discardable_memory_manager.cc │ │ ├── discardable_memory_manager.h │ │ ├── discardable_memory_shmem.cc │ │ ├── discardable_memory_shmem.h │ │ ├── discardable_memory_shmem_allocator.cc │ │ ├── discardable_memory_shmem_allocator.h │ │ ├── discardable_memory_win.cc │ │ ├── discardable_shared_memory.cc │ │ ├── discardable_shared_memory.h │ │ ├── linked_ptr.h │ │ ├── manual_constructor.h │ │ ├── memory_pressure_listener.cc │ │ ├── memory_pressure_listener.h │ │ ├── raw_scoped_refptr_mismatch_checker.h │ │ ├── ref_counted.cc │ │ ├── ref_counted.h │ │ ├── ref_counted_delete_on_message_loop.h │ │ ├── ref_counted_memory.cc │ │ ├── ref_counted_memory.h │ │ ├── scoped_handle.h │ │ ├── scoped_open_process.h │ │ ├── scoped_policy.h │ │ ├── scoped_ptr.h │ │ ├── scoped_ptr_unittest.nc │ │ ├── scoped_vector.h │ │ ├── shared_memory.h │ │ ├── shared_memory_android.cc │ │ ├── shared_memory_nacl.cc │ │ ├── shared_memory_posix.cc │ │ ├── shared_memory_win.cc │ │ ├── singleton.cc │ │ ├── singleton.h │ │ ├── singleton_objc.h │ │ ├── weak_ptr.cc │ │ ├── weak_ptr.h │ │ └── weak_ptr_unittest.nc │ ├── message_loop │ │ ├── incoming_task_queue.cc │ │ ├── incoming_task_queue.h │ │ ├── message_loop.cc │ │ ├── message_loop.h │ │ ├── message_loop_proxy.cc │ │ ├── message_loop_proxy.h │ │ ├── message_loop_proxy_impl.cc │ │ ├── message_loop_proxy_impl.h │ │ ├── message_loop_test.cc │ │ ├── message_loop_test.h │ │ ├── message_pump.cc │ │ ├── message_pump.h │ │ ├── message_pump_android.cc │ │ ├── message_pump_android.h │ │ ├── message_pump_default.cc │ │ ├── message_pump_default.h │ │ ├── message_pump_dispatcher.h │ │ ├── message_pump_glib.cc │ │ ├── message_pump_glib.h │ │ ├── message_pump_io_ios.cc │ │ ├── message_pump_io_ios.h │ │ ├── message_pump_libevent.cc │ │ ├── message_pump_libevent.h │ │ ├── message_pump_mac.h │ │ ├── message_pump_mac.mm │ │ ├── message_pump_perftest.cc │ │ ├── message_pump_win.cc │ │ ├── message_pump_win.h │ │ └── timer_slack.h │ ├── metrics │ │ ├── OWNERS │ │ ├── bucket_ranges.cc │ │ ├── bucket_ranges.h │ │ ├── field_trial.cc │ │ ├── field_trial.h │ │ ├── histogram.cc │ │ ├── histogram.h │ │ ├── histogram_base.cc │ │ ├── histogram_base.h │ │ ├── histogram_delta_serialization.cc │ │ ├── histogram_delta_serialization.h │ │ ├── histogram_flattener.h │ │ ├── histogram_macros.h │ │ ├── histogram_samples.cc │ │ ├── histogram_samples.h │ │ ├── histogram_snapshot_manager.cc │ │ ├── histogram_snapshot_manager.h │ │ ├── sample_map.cc │ │ ├── sample_map.h │ │ ├── sample_vector.cc │ │ ├── sample_vector.h │ │ ├── sparse_histogram.cc │ │ ├── sparse_histogram.h │ │ ├── statistics_recorder.cc │ │ ├── statistics_recorder.h │ │ ├── stats_counters.cc │ │ ├── stats_counters.h │ │ ├── stats_table.cc │ │ ├── stats_table.h │ │ ├── user_metrics.cc │ │ ├── user_metrics.h │ │ └── user_metrics_action.h │ ├── move.h │ ├── native_library.h │ ├── native_library_mac.mm │ ├── native_library_posix.cc │ ├── native_library_win.cc │ ├── newlib-x86-32.base_untrusted.source_list.gypcmd │ ├── newlib-x86-64.base_untrusted.source_list.gypcmd │ ├── nix │ │ ├── mime_util_xdg.cc │ │ ├── mime_util_xdg.h │ │ ├── xdg_util.cc │ │ └── xdg_util.h │ ├── numerics │ │ ├── OWNERS │ │ ├── safe_conversions.h │ │ ├── safe_conversions_impl.h │ │ ├── safe_math.h │ │ └── safe_math_impl.h │ ├── observer_list.h │ ├── observer_list_threadsafe.h │ ├── os_compat_android.cc │ ├── os_compat_android.h │ ├── os_compat_nacl.cc │ ├── os_compat_nacl.h │ ├── path_service.cc │ ├── path_service.h │ ├── pending_task.cc │ ├── pending_task.h │ ├── pickle.cc │ ├── pickle.h │ ├── port.h │ ├── posix │ │ ├── eintr_wrapper.h │ │ ├── file_descriptor_shuffle.cc │ │ ├── file_descriptor_shuffle.h │ │ ├── global_descriptors.cc │ │ ├── global_descriptors.h │ │ ├── unix_domain_socket_linux.cc │ │ └── unix_domain_socket_linux.h │ ├── power_monitor │ │ ├── power_monitor.cc │ │ ├── power_monitor.h │ │ ├── power_monitor_device_source.cc │ │ ├── power_monitor_device_source.h │ │ ├── power_monitor_device_source_android.cc │ │ ├── power_monitor_device_source_android.h │ │ ├── power_monitor_device_source_chromeos.cc │ │ ├── power_monitor_device_source_ios.mm │ │ ├── power_monitor_device_source_mac.mm │ │ ├── power_monitor_device_source_posix.cc │ │ ├── power_monitor_device_source_win.cc │ │ ├── power_monitor_source.cc │ │ ├── power_monitor_source.h │ │ └── power_observer.h │ ├── prefs │ │ ├── OWNERS │ │ ├── README │ │ ├── base_prefs_export.h │ │ ├── default_pref_store.cc │ │ ├── default_pref_store.h │ │ ├── json_pref_store.cc │ │ ├── json_pref_store.h │ │ ├── mock_pref_change_callback.cc │ │ ├── mock_pref_change_callback.h │ │ ├── overlay_user_pref_store.cc │ │ ├── overlay_user_pref_store.h │ │ ├── persistent_pref_store.h │ │ ├── pref_change_registrar.cc │ │ ├── pref_change_registrar.h │ │ ├── pref_filter.h │ │ ├── pref_member.cc │ │ ├── pref_member.h │ │ ├── pref_notifier.h │ │ ├── pref_notifier_impl.cc │ │ ├── pref_notifier_impl.h │ │ ├── pref_observer.h │ │ ├── pref_registry.cc │ │ ├── pref_registry.h │ │ ├── pref_registry_simple.cc │ │ ├── pref_registry_simple.h │ │ ├── pref_service.cc │ │ ├── pref_service.h │ │ ├── pref_service_factory.cc │ │ ├── pref_service_factory.h │ │ ├── pref_store.cc │ │ ├── pref_store.h │ │ ├── pref_store_observer_mock.cc │ │ ├── pref_store_observer_mock.h │ │ ├── pref_value_map.cc │ │ ├── pref_value_map.h │ │ ├── pref_value_store.cc │ │ ├── pref_value_store.h │ │ ├── scoped_user_pref_update.cc │ │ ├── scoped_user_pref_update.h │ │ ├── testing_pref_service.cc │ │ ├── testing_pref_service.h │ │ ├── testing_pref_store.cc │ │ ├── testing_pref_store.h │ │ ├── value_map_pref_store.cc │ │ ├── value_map_pref_store.h │ │ └── writeable_pref_store.h │ ├── process │ │ ├── internal_linux.cc │ │ ├── internal_linux.h │ │ ├── kill.cc │ │ ├── kill.h │ │ ├── kill_mac.cc │ │ ├── kill_posix.cc │ │ ├── kill_win.cc │ │ ├── launch.cc │ │ ├── launch.h │ │ ├── launch_ios.cc │ │ ├── launch_mac.cc │ │ ├── launch_posix.cc │ │ ├── launch_win.cc │ │ ├── memory.cc │ │ ├── memory.h │ │ ├── memory_linux.cc │ │ ├── memory_mac.mm │ │ ├── memory_stubs.cc │ │ ├── memory_unittest_mac.h │ │ ├── memory_unittest_mac.mm │ │ ├── memory_win.cc │ │ ├── process.h │ │ ├── process_handle.h │ │ ├── process_handle_freebsd.cc │ │ ├── process_handle_linux.cc │ │ ├── process_handle_mac.cc │ │ ├── process_handle_openbsd.cc │ │ ├── process_handle_posix.cc │ │ ├── process_handle_win.cc │ │ ├── process_info.h │ │ ├── process_info_linux.cc │ │ ├── process_info_mac.cc │ │ ├── process_info_win.cc │ │ ├── process_iterator.cc │ │ ├── process_iterator.h │ │ ├── process_iterator_freebsd.cc │ │ ├── process_iterator_linux.cc │ │ ├── process_iterator_mac.cc │ │ ├── process_iterator_openbsd.cc │ │ ├── process_iterator_win.cc │ │ ├── process_linux.cc │ │ ├── process_metrics.cc │ │ ├── process_metrics.h │ │ ├── process_metrics_freebsd.cc │ │ ├── process_metrics_ios.cc │ │ ├── process_metrics_linux.cc │ │ ├── process_metrics_mac.cc │ │ ├── process_metrics_openbsd.cc │ │ ├── process_metrics_posix.cc │ │ ├── process_metrics_unittest_ios.cc │ │ ├── process_metrics_win.cc │ │ ├── process_posix.cc │ │ └── process_win.cc │ ├── profiler │ │ ├── alternate_timer.cc │ │ ├── alternate_timer.h │ │ ├── scoped_profile.cc │ │ ├── scoped_profile.h │ │ ├── scoped_tracker.cc │ │ ├── scoped_tracker.h │ │ ├── tracked_time.cc │ │ └── tracked_time.h │ ├── rand_util.cc │ ├── rand_util.h │ ├── rand_util_nacl.cc │ ├── rand_util_posix.cc │ ├── rand_util_win.cc │ ├── run_loop.cc │ ├── run_loop.h │ ├── safe_strerror_posix.cc │ ├── safe_strerror_posix.h │ ├── scoped_clear_errno.h │ ├── scoped_generic.h │ ├── scoped_native_library.cc │ ├── scoped_native_library.h │ ├── scoped_observer.h │ ├── sequence_checker.h │ ├── sequence_checker_impl.cc │ ├── sequence_checker_impl.h │ ├── sequenced_task_runner.cc │ ├── sequenced_task_runner.h │ ├── sequenced_task_runner_helpers.h │ ├── sha1.h │ ├── sha1_portable.cc │ ├── sha1_win.cc │ ├── single_thread_task_runner.h │ ├── stl_util.h │ ├── strings │ │ ├── OWNERS │ │ ├── latin1_string_conversions.cc │ │ ├── latin1_string_conversions.h │ │ ├── nullable_string16.cc │ │ ├── nullable_string16.h │ │ ├── safe_sprintf.cc │ │ ├── safe_sprintf.h │ │ ├── string16.cc │ │ ├── string16.h │ │ ├── string_number_conversions.cc │ │ ├── string_number_conversions.h │ │ ├── string_piece.cc │ │ ├── string_piece.h │ │ ├── string_split.cc │ │ ├── string_split.h │ │ ├── string_tokenizer.h │ │ ├── string_util.cc │ │ ├── string_util.h │ │ ├── string_util_constants.cc │ │ ├── string_util_posix.h │ │ ├── string_util_win.h │ │ ├── stringize_macros.h │ │ ├── stringprintf.cc │ │ ├── stringprintf.h │ │ ├── sys_string_conversions.h │ │ ├── sys_string_conversions_mac.mm │ │ ├── sys_string_conversions_mac_unittest.mm │ │ ├── sys_string_conversions_posix.cc │ │ ├── sys_string_conversions_win.cc │ │ ├── utf_offset_string_conversions.cc │ │ ├── utf_offset_string_conversions.h │ │ ├── utf_string_conversion_utils.cc │ │ ├── utf_string_conversion_utils.h │ │ ├── utf_string_conversions.cc │ │ └── utf_string_conversions.h │ ├── supports_user_data.cc │ ├── supports_user_data.h │ ├── sync_socket.h │ ├── sync_socket_nacl.cc │ ├── sync_socket_posix.cc │ ├── sync_socket_win.cc │ ├── synchronization │ │ ├── cancellation_flag.cc │ │ ├── cancellation_flag.h │ │ ├── condition_variable.h │ │ ├── condition_variable_posix.cc │ │ ├── condition_variable_win.cc │ │ ├── lock.cc │ │ ├── lock.h │ │ ├── lock_impl.h │ │ ├── lock_impl_posix.cc │ │ ├── lock_impl_win.cc │ │ ├── spin_wait.h │ │ ├── waitable_event.h │ │ ├── waitable_event_posix.cc │ │ ├── waitable_event_watcher.h │ │ ├── waitable_event_watcher_posix.cc │ │ ├── waitable_event_watcher_win.cc │ │ └── waitable_event_win.cc │ ├── sys_byteorder.h │ ├── sys_info.cc │ ├── sys_info.h │ ├── sys_info_android.cc │ ├── sys_info_chromeos.cc │ ├── sys_info_freebsd.cc │ ├── sys_info_internal.h │ ├── sys_info_ios.mm │ ├── sys_info_linux.cc │ ├── sys_info_mac.cc │ ├── sys_info_openbsd.cc │ ├── sys_info_posix.cc │ ├── sys_info_win.cc │ ├── system_monitor │ │ ├── system_monitor.cc │ │ └── system_monitor.h │ ├── task │ │ ├── cancelable_task_tracker.cc │ │ └── cancelable_task_tracker.h │ ├── task_runner.cc │ ├── task_runner.h │ ├── task_runner_util.h │ ├── template_util.h │ ├── test │ │ ├── BUILD.gn │ │ ├── DEPS │ │ ├── OWNERS │ │ ├── android │ │ │ ├── OWNERS │ │ │ ├── java │ │ │ │ └── src │ │ │ │ │ └── org │ │ │ │ │ └── chromium │ │ │ │ │ └── base │ │ │ │ │ └── ContentUriTestUtils.java │ │ │ └── javatests │ │ │ │ └── src │ │ │ │ └── org │ │ │ │ └── chromium │ │ │ │ └── base │ │ │ │ └── test │ │ │ │ └── util │ │ │ │ ├── AdvancedMockContext.java │ │ │ │ ├── DisabledTest.java │ │ │ │ ├── EnormousTest.java │ │ │ │ ├── Feature.java │ │ │ │ ├── HostDrivenTest.java │ │ │ │ ├── InMemorySharedPreferences.java │ │ │ │ ├── InstrumentationUtils.java │ │ │ │ ├── IntegrationTest.java │ │ │ │ ├── Manual.java │ │ │ │ ├── MinAndroidSdkLevel.java │ │ │ │ ├── PerfTest.java │ │ │ │ ├── Restriction.java │ │ │ │ ├── ScalableTimeout.java │ │ │ │ ├── TestFileUtil.java │ │ │ │ ├── TestThread.java │ │ │ │ ├── TimeoutScale.java │ │ │ │ └── UrlUtils.java │ │ ├── data │ │ │ ├── file_util │ │ │ │ ├── binary_file.bin │ │ │ │ ├── binary_file_diff.bin │ │ │ │ ├── binary_file_same.bin │ │ │ │ ├── blank_line.txt │ │ │ │ ├── blank_line_crlf.txt │ │ │ │ ├── crlf.txt │ │ │ │ ├── different.txt │ │ │ │ ├── different_first.txt │ │ │ │ ├── different_last.txt │ │ │ │ ├── empty1.txt │ │ │ │ ├── empty2.txt │ │ │ │ ├── first1.txt │ │ │ │ ├── first2.txt │ │ │ │ ├── original.txt │ │ │ │ ├── red.png │ │ │ │ ├── same.txt │ │ │ │ ├── same_length.txt │ │ │ │ └── shortened.txt │ │ │ ├── json │ │ │ │ └── bom_feff.json │ │ │ ├── prefs │ │ │ │ ├── invalid.json │ │ │ │ ├── read.json │ │ │ │ └── write.golden.json │ │ │ ├── serializer_nested_test.json │ │ │ ├── serializer_test.json │ │ │ └── serializer_test_nowhitespace.json │ │ ├── expectations │ │ │ ├── OWNERS │ │ │ ├── expectation.cc │ │ │ ├── expectation.h │ │ │ ├── parser.cc │ │ │ └── parser.h │ │ ├── gtest_util.cc │ │ ├── gtest_util.h │ │ ├── gtest_xml_util.cc │ │ ├── gtest_xml_util.h │ │ ├── histogram_tester.cc │ │ ├── histogram_tester.h │ │ ├── launcher │ │ │ ├── test_launcher.cc │ │ │ ├── test_launcher.h │ │ │ ├── test_launcher_ios.cc │ │ │ ├── test_result.cc │ │ │ ├── test_result.h │ │ │ ├── test_results_tracker.cc │ │ │ ├── test_results_tracker.h │ │ │ ├── unit_test_launcher.cc │ │ │ ├── unit_test_launcher.h │ │ │ └── unit_test_launcher_ios.cc │ │ ├── mock_chrome_application_mac.h │ │ ├── mock_chrome_application_mac.mm │ │ ├── mock_devices_changed_observer.cc │ │ ├── mock_devices_changed_observer.h │ │ ├── mock_time_provider.cc │ │ ├── mock_time_provider.h │ │ ├── multiprocess_test.cc │ │ ├── multiprocess_test.h │ │ ├── multiprocess_test_android.cc │ │ ├── null_task_runner.cc │ │ ├── null_task_runner.h │ │ ├── opaque_ref_counted.cc │ │ ├── opaque_ref_counted.h │ │ ├── perf_log.cc │ │ ├── perf_log.h │ │ ├── perf_test_suite.cc │ │ ├── perf_test_suite.h │ │ ├── perf_time_logger.cc │ │ ├── perf_time_logger.h │ │ ├── power_monitor_test_base.cc │ │ ├── power_monitor_test_base.h │ │ ├── run_all_perftests.cc │ │ ├── run_all_unittests.cc │ │ ├── scoped_locale.cc │ │ ├── scoped_locale.h │ │ ├── scoped_path_override.cc │ │ ├── scoped_path_override.h │ │ ├── sequenced_task_runner_test_template.cc │ │ ├── sequenced_task_runner_test_template.h │ │ ├── sequenced_worker_pool_owner.cc │ │ ├── sequenced_worker_pool_owner.h │ │ ├── simple_test_clock.cc │ │ ├── simple_test_clock.h │ │ ├── simple_test_tick_clock.cc │ │ ├── simple_test_tick_clock.h │ │ ├── task_runner_test_template.cc │ │ ├── task_runner_test_template.h │ │ ├── test_file_util.cc │ │ ├── test_file_util.h │ │ ├── test_file_util_android.cc │ │ ├── test_file_util_linux.cc │ │ ├── test_file_util_mac.cc │ │ ├── test_file_util_posix.cc │ │ ├── test_file_util_win.cc │ │ ├── test_io_thread.cc │ │ ├── test_io_thread.h │ │ ├── test_listener_ios.h │ │ ├── test_listener_ios.mm │ │ ├── test_pending_task.cc │ │ ├── test_pending_task.h │ │ ├── test_reg_util_win.cc │ │ ├── test_reg_util_win.h │ │ ├── test_shortcut_win.cc │ │ ├── test_shortcut_win.h │ │ ├── test_simple_task_runner.cc │ │ ├── test_simple_task_runner.h │ │ ├── test_suite.cc │ │ ├── test_suite.h │ │ ├── test_support_android.cc │ │ ├── test_support_android.h │ │ ├── test_support_ios.h │ │ ├── test_support_ios.mm │ │ ├── test_switches.cc │ │ ├── test_switches.h │ │ ├── test_timeouts.cc │ │ ├── test_timeouts.h │ │ ├── thread_test_helper.cc │ │ ├── thread_test_helper.h │ │ ├── trace_event_analyzer.cc │ │ ├── trace_event_analyzer.h │ │ ├── trace_to_file.cc │ │ ├── trace_to_file.h │ │ ├── values_test_util.cc │ │ └── values_test_util.h │ ├── third_party │ │ ├── dmg_fp │ │ │ ├── LICENSE │ │ │ ├── README.chromium │ │ │ ├── dmg_fp.h │ │ │ ├── dtoa.cc │ │ │ ├── dtoa_wrapper.cc │ │ │ ├── float_precision_crash.patch │ │ │ ├── g_fmt.cc │ │ │ ├── gcc_64_bit.patch │ │ │ ├── gcc_warnings.patch │ │ │ ├── mac_wextra.patch │ │ │ └── msvc_warnings.patch │ │ ├── dynamic_annotations │ │ │ ├── BUILD.gn │ │ │ ├── LICENSE │ │ │ ├── README.chromium │ │ │ ├── dynamic_annotations.c │ │ │ ├── dynamic_annotations.gyp │ │ │ └── dynamic_annotations.h │ │ ├── icu │ │ │ ├── LICENSE │ │ │ ├── README.chromium │ │ │ ├── icu_utf.cc │ │ │ └── icu_utf.h │ │ ├── nspr │ │ │ ├── BUILD.gn │ │ │ ├── LICENSE │ │ │ ├── OWNERS │ │ │ ├── README.chromium │ │ │ ├── prtime.cc │ │ │ └── prtime.h │ │ ├── superfasthash │ │ │ ├── LICENSE │ │ │ ├── OWNERS │ │ │ ├── README.chromium │ │ │ └── superfasthash.c │ │ ├── symbolize │ │ │ ├── BUILD.gn │ │ │ ├── DEPS │ │ │ ├── LICENSE │ │ │ ├── README.chromium │ │ │ ├── config.h │ │ │ ├── demangle.cc │ │ │ ├── demangle.h │ │ │ ├── glog │ │ │ │ ├── logging.h │ │ │ │ └── raw_logging.h │ │ │ ├── symbolize.cc │ │ │ ├── symbolize.h │ │ │ └── utilities.h │ │ ├── valgrind │ │ │ ├── LICENSE │ │ │ ├── README.chromium │ │ │ ├── memcheck.h │ │ │ └── valgrind.h │ │ ├── xdg_mime │ │ │ ├── BUILD.gn │ │ │ ├── LICENSE │ │ │ ├── README │ │ │ ├── README.chromium │ │ │ ├── compile.patch │ │ │ ├── xdgmime.c │ │ │ ├── xdgmime.h │ │ │ ├── xdgmimealias.c │ │ │ ├── xdgmimealias.h │ │ │ ├── xdgmimecache.c │ │ │ ├── xdgmimecache.h │ │ │ ├── xdgmimeglob.c │ │ │ ├── xdgmimeglob.h │ │ │ ├── xdgmimeicon.c │ │ │ ├── xdgmimeicon.h │ │ │ ├── xdgmimeint.c │ │ │ ├── xdgmimeint.h │ │ │ ├── xdgmimemagic.c │ │ │ ├── xdgmimemagic.h │ │ │ ├── xdgmimeparent.c │ │ │ └── xdgmimeparent.h │ │ └── xdg_user_dirs │ │ │ ├── BUILD.gn │ │ │ ├── LICENSE │ │ │ ├── README.chromium │ │ │ ├── xdg_user_dir_lookup.cc │ │ │ └── xdg_user_dir_lookup.h │ ├── thread_task_runner_handle.cc │ ├── thread_task_runner_handle.h │ ├── threading │ │ ├── OWNERS │ │ ├── non_thread_safe.h │ │ ├── non_thread_safe_impl.cc │ │ ├── non_thread_safe_impl.h │ │ ├── platform_thread.h │ │ ├── platform_thread_android.cc │ │ ├── platform_thread_freebsd.cc │ │ ├── platform_thread_linux.cc │ │ ├── platform_thread_mac.mm │ │ ├── platform_thread_posix.cc │ │ ├── platform_thread_win.cc │ │ ├── post_task_and_reply_impl.cc │ │ ├── post_task_and_reply_impl.h │ │ ├── sequenced_worker_pool.cc │ │ ├── sequenced_worker_pool.h │ │ ├── simple_thread.cc │ │ ├── simple_thread.h │ │ ├── thread.cc │ │ ├── thread.h │ │ ├── thread_checker.h │ │ ├── thread_checker_impl.cc │ │ ├── thread_checker_impl.h │ │ ├── thread_collision_warner.cc │ │ ├── thread_collision_warner.h │ │ ├── thread_id_name_manager.cc │ │ ├── thread_id_name_manager.h │ │ ├── thread_local.h │ │ ├── thread_local_android.cc │ │ ├── thread_local_posix.cc │ │ ├── thread_local_storage.cc │ │ ├── thread_local_storage.h │ │ ├── thread_local_storage_posix.cc │ │ ├── thread_local_storage_win.cc │ │ ├── thread_local_win.cc │ │ ├── thread_perftest.cc │ │ ├── thread_restrictions.cc │ │ ├── thread_restrictions.h │ │ ├── watchdog.cc │ │ ├── watchdog.h │ │ ├── worker_pool.cc │ │ ├── worker_pool.h │ │ ├── worker_pool_posix.cc │ │ ├── worker_pool_posix.h │ │ └── worker_pool_win.cc │ ├── time │ │ ├── clock.cc │ │ ├── clock.h │ │ ├── default_clock.cc │ │ ├── default_clock.h │ │ ├── default_tick_clock.cc │ │ ├── default_tick_clock.h │ │ ├── tick_clock.cc │ │ ├── tick_clock.h │ │ ├── time.cc │ │ ├── time.h │ │ ├── time_mac.cc │ │ ├── time_posix.cc │ │ └── time_win.cc │ ├── timer │ │ ├── elapsed_timer.cc │ │ ├── elapsed_timer.h │ │ ├── hi_res_timer_manager.h │ │ ├── hi_res_timer_manager_posix.cc │ │ ├── hi_res_timer_manager_win.cc │ │ ├── mock_timer.cc │ │ ├── mock_timer.h │ │ ├── timer.cc │ │ └── timer.h │ ├── tracked_objects.cc │ ├── tracked_objects.h │ ├── tracking_info.cc │ ├── tracking_info.h │ ├── tuple.h │ ├── value_conversions.cc │ ├── value_conversions.h │ ├── values.cc │ ├── values.h │ ├── version.cc │ ├── version.h │ ├── vlog.cc │ ├── vlog.h │ └── win │ │ ├── OWNERS │ │ ├── dllmain.cc │ │ ├── enum_variant.cc │ │ ├── enum_variant.h │ │ ├── event_trace_consumer.h │ │ ├── event_trace_controller.cc │ │ ├── event_trace_controller.h │ │ ├── event_trace_provider.cc │ │ ├── event_trace_provider.h │ │ ├── i18n.cc │ │ ├── i18n.h │ │ ├── iat_patch_function.cc │ │ ├── iat_patch_function.h │ │ ├── iunknown_impl.cc │ │ ├── iunknown_impl.h │ │ ├── message_window.cc │ │ ├── message_window.h │ │ ├── metro.cc │ │ ├── metro.h │ │ ├── object_watcher.cc │ │ ├── object_watcher.h │ │ ├── pe_image.cc │ │ ├── pe_image.h │ │ ├── registry.cc │ │ ├── registry.h │ │ ├── resource_util.cc │ │ ├── resource_util.h │ │ ├── scoped_bstr.cc │ │ ├── scoped_bstr.h │ │ ├── scoped_co_mem.h │ │ ├── scoped_com_initializer.h │ │ ├── scoped_comptr.h │ │ ├── scoped_gdi_object.h │ │ ├── scoped_handle.cc │ │ ├── scoped_handle.h │ │ ├── scoped_hdc.h │ │ ├── scoped_hglobal.h │ │ ├── scoped_process_information.cc │ │ ├── scoped_process_information.h │ │ ├── scoped_propvariant.h │ │ ├── scoped_select_object.h │ │ ├── scoped_variant.cc │ │ ├── scoped_variant.h │ │ ├── shortcut.cc │ │ ├── shortcut.h │ │ ├── startup_information.cc │ │ ├── startup_information.h │ │ ├── win_util.cc │ │ ├── win_util.h │ │ ├── windows_version.cc │ │ ├── windows_version.h │ │ ├── wrapped_window_proc.cc │ │ └── wrapped_window_proc.h ├── build │ ├── build_config.h │ ├── common.gypi │ └── filename_rules.gypi ├── test_qt │ ├── GeneratedFiles │ │ ├── Debug │ │ │ ├── moc_test_qt.cpp │ │ │ └── moc_work_loop.cpp │ │ ├── qrc_test_qt.cpp │ │ └── ui_test_qt.h │ ├── global_def.h │ ├── main.cpp │ ├── task_pool.hpp │ ├── test_qt.cpp │ ├── test_qt.h │ ├── test_qt.qrc │ ├── test_qt.ui │ ├── test_qt.vcxproj │ ├── test_qt.vcxproj.filters │ └── work_loop.hpp ├── testing │ └── gtest │ │ └── include │ │ └── gtest │ │ └── gtest_prod.h └── third_party │ ├── libevent │ ├── BUILD.gn │ ├── ChangeLog │ ├── LICENSE │ ├── Makefile.am │ ├── Makefile.in │ ├── README │ ├── README.chromium │ ├── aclocal.m4 │ ├── android │ │ ├── config.h │ │ └── event-config.h │ ├── autogen.sh │ ├── buffer.c │ ├── chromium.patch │ ├── compat │ │ └── sys │ │ │ ├── _libevent_time.h │ │ │ ├── _time.h │ │ │ └── queue.h │ ├── config.guess │ ├── config.h.in │ ├── config.sub │ ├── configure │ ├── configure.in │ ├── devpoll.c │ ├── epoll.c │ ├── epoll_sub.c │ ├── evbuffer.c │ ├── evdns.3 │ ├── evdns.c │ ├── evdns.h │ ├── event-config.h │ ├── event-internal.h │ ├── event.3 │ ├── event.c │ ├── event.h │ ├── event_rpcgen.py │ ├── event_tagging.c │ ├── evhttp.h │ ├── evport.c │ ├── evrpc-internal.h │ ├── evrpc.c │ ├── evrpc.h │ ├── evsignal.h │ ├── evutil.c │ ├── evutil.h │ ├── freebsd │ │ ├── config.h │ │ └── event-config.h │ ├── http-internal.h │ ├── http.c │ ├── install-sh │ ├── kqueue.c │ ├── libevent.gyp │ ├── libevent_nacl_nonsfi.gyp │ ├── linux │ │ ├── config.h │ │ └── event-config.h │ ├── log.c │ ├── log.h │ ├── ltmain.sh │ ├── mac │ │ ├── config.h │ │ └── event-config.h │ ├── min_heap.h │ ├── missing │ ├── mkinstalldirs │ ├── nacl_nonsfi │ │ ├── config.h │ │ ├── event-config.h │ │ └── random.c │ ├── poll.c │ ├── sample │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── event-test.c │ │ ├── signal-test.c │ │ └── time-test.c │ ├── select.c │ ├── signal.c │ ├── solaris │ │ ├── config.h │ │ └── event-config.h │ ├── strlcpy-internal.h │ ├── strlcpy.c │ └── test │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── bench.c │ │ ├── regress.c │ │ ├── regress.gen.c │ │ ├── regress.gen.h │ │ ├── regress.h │ │ ├── regress.rpc │ │ ├── regress_dns.c │ │ ├── regress_http.c │ │ ├── regress_rpc.c │ │ ├── test-eof.c │ │ ├── test-init.c │ │ ├── test-time.c │ │ ├── test-weof.c │ │ └── test.sh │ ├── sqlite3 │ ├── sqlite3.h │ └── sqlite3.lib │ └── superfasthash │ ├── LICENSE │ ├── OWNERS │ ├── README.chromium │ └── superfasthash.c └── test_base.vcxproj /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /Debug/sqlite3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryderfang/chromium_base/1e25b45efe2469043682c797159d9b5e0b57c231/Debug/sqlite3.dll -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryderfang/chromium_base/1e25b45efe2469043682c797159d9b5e0b57c231/README.md -------------------------------------------------------------------------------- /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/allocator/allocator_shim.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_ALLOCATOR_ALLOCATOR_SHIM_H_ 6 | #define BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ 7 | 8 | #include 9 | 10 | namespace base { 11 | namespace allocator { 12 | 13 | // Resets the environment variable CHROME_ALLOCATOR to specify the choice to 14 | // be used by subprocesses. Priority is given to the current value of 15 | // CHROME_ALLOCATOR_2 (if specified), then CHROME_ALLOCATOR (if specified), and 16 | // then a default value (typically set to TCMALLOC). 17 | void SetupSubprocessAllocator(); 18 | 19 | // Expose some of tcmalloc functions for test. 20 | void* TCMallocDoMallocForTest(size_t size); 21 | void TCMallocDoFreeForTest(void* ptr); 22 | size_t ExcludeSpaceForMarkForTest(size_t size); 23 | 24 | } // namespace allocator. 25 | } // namespace base. 26 | 27 | #endif // BASE_ALLOCATOR_ALLOCATOR_SHIM_H_ 28 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/base/allocator/type_profiler_control.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 | #include "base/allocator/type_profiler_control.h" 6 | 7 | namespace base { 8 | namespace type_profiler { 9 | 10 | namespace { 11 | 12 | #if defined(TYPE_PROFILING) 13 | const bool kTypeProfilingEnabled = true; 14 | #else 15 | const bool kTypeProfilingEnabled = false; 16 | #endif 17 | 18 | bool g_enable_intercept = kTypeProfilingEnabled; 19 | 20 | } // namespace 21 | 22 | // static 23 | void Controller::Stop() { 24 | g_enable_intercept = false; 25 | } 26 | 27 | // static 28 | bool Controller::IsProfiling() { 29 | return kTypeProfilingEnabled && g_enable_intercept; 30 | } 31 | 32 | // static 33 | void Controller::Restart() { 34 | g_enable_intercept = kTypeProfilingEnabled; 35 | } 36 | 37 | } // namespace type_profiler 38 | } // namespace base 39 | -------------------------------------------------------------------------------- /src/base/allocator/type_profiler_control.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_ALLOCATOR_TYPE_PROFILER_CONTROL_H_ 6 | #define BASE_ALLOCATOR_TYPE_PROFILER_CONTROL_H_ 7 | 8 | #include "base/gtest_prod_util.h" 9 | 10 | namespace base { 11 | namespace type_profiler { 12 | 13 | class Controller { 14 | public: 15 | static void Stop(); 16 | static bool IsProfiling(); 17 | 18 | private: 19 | FRIEND_TEST_ALL_PREFIXES(TypeProfilerTest, 20 | TestProfileNewWithoutProfiledDelete); 21 | 22 | // It must be used only from allowed unit tests. The following is only 23 | // allowed for use in unit tests. Profiling should never be restarted in 24 | // regular use. 25 | static void Restart(); 26 | }; 27 | 28 | } // namespace type_profiler 29 | } // namespace base 30 | 31 | #endif // BASE_ALLOCATOR_TYPE_PROFILER_CONTROL_H_ 32 | -------------------------------------------------------------------------------- /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/allocator/type_profiler_tcmalloc.h: -------------------------------------------------------------------------------- 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 | #ifndef BASE_ALLOCATOR_TYPE_PROFILER_TCMALLOC_H_ 6 | #define BASE_ALLOCATOR_TYPE_PROFILER_TCMALLOC_H_ 7 | 8 | #if defined(TYPE_PROFILING) 9 | 10 | #include // for size_t 11 | #include // for std::type_info 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 | 20 | void* DeleteInterceptForTCMalloc(void* ptr, 21 | size_t size, 22 | const std::type_info& type); 23 | 24 | } // namespace type_profiler 25 | } // namespace base 26 | 27 | #endif // defined(TYPE_PROFILING) 28 | 29 | #endif // BASE_ALLOCATOR_TYPE_PROFILER_TCMALLOC_H_ 30 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/base_paths_posix.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_POSIX_H_ 6 | #define BASE_BASE_PATHS_POSIX_H_ 7 | 8 | // This file declares windows-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_POSIX_START = 400, 16 | 17 | DIR_CACHE, // Directory where to put cache data. Note this is 18 | // *not* where the browser cache lives, but the 19 | // browser cache can be a subdirectory. 20 | // This is $XDG_CACHE_HOME on Linux and 21 | // ~/Library/Caches on Mac. 22 | PATH_POSIX_END 23 | }; 24 | 25 | } // namespace base 26 | 27 | #endif // BASE_BASE_PATHS_POSIX_H_ 28 | -------------------------------------------------------------------------------- /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/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/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/build_time.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/build_time.h" 6 | 7 | #include "base/logging.h" 8 | #include "base/time/time.h" 9 | 10 | namespace base { 11 | 12 | Time GetBuildTime() { 13 | Time integral_build_time; 14 | // The format of __DATE__ and __TIME__ is specified by the ANSI C Standard, 15 | // section 6.8.8. 16 | // 17 | // __DATE__ is exactly "Mmm DD YYYY". 18 | // __TIME__ is exactly "hh:mm:ss". 19 | #if defined(DONT_EMBED_BUILD_METADATA) && !defined(OFFICIAL_BUILD) 20 | const char kDateTime[] = "Sep 02 2008 08:00:00 PST"; 21 | #else 22 | const char kDateTime[] = __DATE__ " " __TIME__ " PST"; 23 | #endif 24 | bool result = Time::FromString(kDateTime, &integral_build_time); 25 | DCHECK(result); 26 | return integral_build_time; 27 | } 28 | 29 | } // namespace base 30 | -------------------------------------------------------------------------------- /src/base/build_time.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_BUILD_TIME_ 6 | #define BASE_BUILD_TIME_ 7 | 8 | #include "base/base_export.h" 9 | #include "base/time/time.h" 10 | 11 | namespace base { 12 | 13 | // GetBuildTime returns the time at which the current binary was built. 14 | // 15 | // This uses the __DATE__ and __TIME__ macros, which don't trigger a rebuild 16 | // when they change. However, official builds will always be rebuilt from 17 | // scratch. 18 | // 19 | // Also, since __TIME__ doesn't include a timezone, this value should only be 20 | // considered accurate to a day. 21 | // 22 | // NOTE: This function is disabled except for the official builds, by default 23 | // the date returned is "Sep 02 2008 08:00:00 PST". 24 | Time BASE_EXPORT GetBuildTime(); 25 | 26 | } // namespace base 27 | 28 | #endif // BASE_BUILD_TIME_ 29 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/base/event_types.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_EVENT_TYPES_H 6 | #define BASE_EVENT_TYPES_H 7 | 8 | #include "build/build_config.h" 9 | 10 | #if defined(OS_WIN) 11 | #include 12 | #elif defined(USE_X11) 13 | typedef union _XEvent XEvent; 14 | #elif defined(OS_MACOSX) 15 | #if defined(__OBJC__) 16 | @class NSEvent; 17 | #else // __OBJC__ 18 | class NSEvent; 19 | #endif // __OBJC__ 20 | #endif 21 | 22 | namespace base { 23 | 24 | // Cross platform typedefs for native event types. 25 | #if defined(OS_WIN) 26 | typedef MSG NativeEvent; 27 | #elif defined(USE_X11) 28 | typedef XEvent* NativeEvent; 29 | #elif defined(OS_MACOSX) 30 | typedef NSEvent* NativeEvent; 31 | #else 32 | typedef void* NativeEvent; 33 | #endif 34 | 35 | } // namespace base 36 | 37 | #endif // BASE_EVENT_TYPES_H 38 | -------------------------------------------------------------------------------- /src/base/files/OWNERS: -------------------------------------------------------------------------------- 1 | rvargas@chromium.org 2 | 3 | per-file file_path_watcher*=mnissler@chromium.org 4 | -------------------------------------------------------------------------------- /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/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/files/file_path_constants.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/files/file_path.h" 6 | 7 | namespace base { 8 | 9 | #if defined(FILE_PATH_USES_WIN_SEPARATORS) 10 | const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("\\/"); 11 | #else // FILE_PATH_USES_WIN_SEPARATORS 12 | const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("/"); 13 | #endif // FILE_PATH_USES_WIN_SEPARATORS 14 | 15 | const size_t FilePath::kSeparatorsLength = arraysize(kSeparators); 16 | 17 | const FilePath::CharType FilePath::kCurrentDirectory[] = FILE_PATH_LITERAL("."); 18 | const FilePath::CharType FilePath::kParentDirectory[] = FILE_PATH_LITERAL(".."); 19 | 20 | const FilePath::CharType FilePath::kExtensionSeparator = FILE_PATH_LITERAL('.'); 21 | 22 | } // namespace base 23 | -------------------------------------------------------------------------------- /src/base/files/file_path_watcher_stub.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 | // This file exists for Unix systems which don't have the inotify headers, and 6 | // thus cannot build file_watcher_inotify.cc 7 | 8 | #include "base/files/file_path_watcher.h" 9 | 10 | namespace base { 11 | 12 | namespace { 13 | 14 | class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate { 15 | public: 16 | virtual bool Watch(const FilePath& path, 17 | bool recursive, 18 | const FilePathWatcher::Callback& callback) override { 19 | return false; 20 | } 21 | 22 | virtual void Cancel() override {} 23 | 24 | virtual void CancelOnMessageLoopThread() override {} 25 | 26 | protected: 27 | virtual ~FilePathWatcherImpl() {} 28 | }; 29 | 30 | } // namespace 31 | 32 | FilePathWatcher::FilePathWatcher() { 33 | impl_ = new FilePathWatcherImpl(); 34 | } 35 | 36 | } // namespace base 37 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/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/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 | -------------------------------------------------------------------------------- /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/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/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/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/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/mac/scoped_mach_vm.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/mac/scoped_mach_vm.h" 6 | 7 | namespace base { 8 | namespace mac { 9 | 10 | void ScopedMachVM::reset(vm_address_t address, vm_size_t size) { 11 | DCHECK(address % PAGE_SIZE == 0); 12 | DCHECK(size % PAGE_SIZE == 0); 13 | 14 | if (size_) { 15 | if (address_ < address) { 16 | vm_deallocate(mach_task_self(), 17 | address_, 18 | std::min(size_, address - address_)); 19 | } 20 | if (address_ + size_ > address + size) { 21 | vm_address_t deallocate_start = std::max(address_, address + size); 22 | vm_deallocate(mach_task_self(), 23 | deallocate_start, 24 | address_ + size_ - deallocate_start); 25 | } 26 | } 27 | 28 | address_ = address; 29 | size_ = size; 30 | } 31 | 32 | } // namespace mac 33 | } // namespace base 34 | -------------------------------------------------------------------------------- /src/base/mac/scoped_nsautorelease_pool.mm: -------------------------------------------------------------------------------- 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/mac/scoped_nsautorelease_pool.h" 6 | 7 | #import 8 | 9 | #include "base/logging.h" 10 | 11 | namespace base { 12 | namespace mac { 13 | 14 | ScopedNSAutoreleasePool::ScopedNSAutoreleasePool() 15 | : autorelease_pool_([[NSAutoreleasePool alloc] init]) { 16 | DCHECK(autorelease_pool_); 17 | } 18 | 19 | ScopedNSAutoreleasePool::~ScopedNSAutoreleasePool() { 20 | [autorelease_pool_ drain]; 21 | } 22 | 23 | // Cycle the internal pool, allowing everything there to get cleaned up and 24 | // start anew. 25 | void ScopedNSAutoreleasePool::Recycle() { 26 | [autorelease_pool_ drain]; 27 | autorelease_pool_ = [[NSAutoreleasePool alloc] init]; 28 | DCHECK(autorelease_pool_); 29 | } 30 | 31 | } // namespace mac 32 | } // namespace base 33 | -------------------------------------------------------------------------------- /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/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/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/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/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/metrics/OWNERS: -------------------------------------------------------------------------------- 1 | asvitkine@chromium.org 2 | isherman@chromium.org 3 | jar@chromium.org 4 | -------------------------------------------------------------------------------- /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/nix/mime_util_xdg.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_NIX_MIME_UTIL_XDG_H_ 6 | #define BASE_NIX_MIME_UTIL_XDG_H_ 7 | 8 | #include 9 | 10 | #include "base/base_export.h" 11 | #include "build/build_config.h" 12 | 13 | namespace base { 14 | 15 | class FilePath; 16 | 17 | namespace nix { 18 | 19 | // Gets the mime type for a file based on its filename. The file path does not 20 | // have to exist. Please note because it doesn't touch the disk, this does not 21 | // work for directories. 22 | // If the mime type is unknown, this will return application/octet-stream. 23 | BASE_EXPORT std::string GetFileMimeType(const FilePath& filepath); 24 | 25 | // Get the mime type for a byte vector. 26 | BASE_EXPORT std::string GetDataMimeType(const std::string& data); 27 | 28 | } // namespace nix 29 | } // namespace base 30 | 31 | #endif // BASE_NIX_MIME_UTIL_XDG_H_ 32 | -------------------------------------------------------------------------------- /src/base/numerics/OWNERS: -------------------------------------------------------------------------------- 1 | jschuh@chromium.org 2 | tsepez@chromium.org 3 | 4 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/base/power_monitor/power_observer.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_OBSERVER_H_ 6 | #define BASE_POWER_MONITOR_POWER_OBSERVER_H_ 7 | 8 | #include "base/base_export.h" 9 | #include "base/compiler_specific.h" 10 | 11 | namespace base { 12 | 13 | class BASE_EXPORT PowerObserver { 14 | public: 15 | // Notification of a change in power status of the computer, such 16 | // as from switching between battery and A/C power. 17 | virtual void OnPowerStateChange(bool on_battery_power) {}; 18 | 19 | // Notification that the system is suspending. 20 | virtual void OnSuspend() {} 21 | 22 | // Notification that the system is resuming. 23 | virtual void OnResume() {} 24 | 25 | protected: 26 | virtual ~PowerObserver() {} 27 | }; 28 | 29 | } // namespace base 30 | 31 | #endif // BASE_POWER_MONITOR_POWER_OBSERVER_H_ 32 | -------------------------------------------------------------------------------- /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/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/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/base/prefs/mock_pref_change_callback.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/prefs/mock_pref_change_callback.h" 6 | 7 | #include "base/bind.h" 8 | 9 | MockPrefChangeCallback::MockPrefChangeCallback(PrefService* prefs) 10 | : prefs_(prefs) { 11 | } 12 | 13 | MockPrefChangeCallback::~MockPrefChangeCallback() {} 14 | 15 | PrefChangeRegistrar::NamedChangeCallback MockPrefChangeCallback::GetCallback() { 16 | return base::Bind(&MockPrefChangeCallback::OnPreferenceChanged, 17 | base::Unretained(this)); 18 | } 19 | 20 | void MockPrefChangeCallback::Expect(const std::string& pref_name, 21 | const base::Value* value) { 22 | EXPECT_CALL(*this, OnPreferenceChanged(pref_name)) 23 | .With(PrefValueMatches(prefs_, pref_name, value)); 24 | } 25 | -------------------------------------------------------------------------------- /src/base/prefs/pref_notifier.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_NOTIFIER_H_ 6 | #define BASE_PREFS_PREF_NOTIFIER_H_ 7 | 8 | #include 9 | 10 | // Delegate interface used by PrefValueStore to notify its owner about changes 11 | // to the preference values. 12 | // TODO(mnissler, danno): Move this declaration to pref_value_store.h once we've 13 | // cleaned up all public uses of this interface. 14 | class PrefNotifier { 15 | public: 16 | virtual ~PrefNotifier() {} 17 | 18 | // Sends out a change notification for the preference identified by 19 | // |pref_name|. 20 | virtual void OnPreferenceChanged(const std::string& pref_name) = 0; 21 | 22 | // Broadcasts the intialization completed notification. 23 | virtual void OnInitializationCompleted(bool succeeded) = 0; 24 | }; 25 | 26 | #endif // BASE_PREFS_PREF_NOTIFIER_H_ 27 | -------------------------------------------------------------------------------- /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/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/prefs/pref_store_observer_mock.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/prefs/pref_store_observer_mock.h" 6 | 7 | #include "testing/gtest/include/gtest/gtest.h" 8 | 9 | PrefStoreObserverMock::PrefStoreObserverMock() 10 | : initialized(false), initialization_success(false) {} 11 | 12 | PrefStoreObserverMock::~PrefStoreObserverMock() {} 13 | 14 | void PrefStoreObserverMock::VerifyAndResetChangedKey( 15 | const std::string& expected) { 16 | EXPECT_EQ(1u, changed_keys.size()); 17 | if (changed_keys.size() >= 1) 18 | EXPECT_EQ(expected, changed_keys.front()); 19 | changed_keys.clear(); 20 | } 21 | 22 | void PrefStoreObserverMock::OnPrefValueChanged(const std::string& key) { 23 | changed_keys.push_back(key); 24 | } 25 | 26 | void PrefStoreObserverMock::OnInitializationCompleted(bool success) { 27 | initialized = true; 28 | initialization_success = success; 29 | } 30 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/process/process_handle_linux.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 "base/files/file_util.h" 8 | #include "base/process/internal_linux.h" 9 | 10 | namespace base { 11 | 12 | ProcessId GetParentProcessId(ProcessHandle process) { 13 | ProcessId pid = 14 | internal::ReadProcStatsAndGetFieldAsInt64(process, internal::VM_PPID); 15 | if (pid) 16 | return pid; 17 | return -1; 18 | } 19 | 20 | FilePath GetProcessExecutablePath(ProcessHandle process) { 21 | FilePath stat_file = internal::GetProcPidDir(process).Append("exe"); 22 | FilePath exe_name; 23 | if (!ReadSymbolicLink(stat_file, &exe_name)) { 24 | // No such process. Happens frequently in e.g. TerminateAllChromeProcesses 25 | return FilePath(); 26 | } 27 | return exe_name; 28 | } 29 | 30 | } // namespace base 31 | -------------------------------------------------------------------------------- /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/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/process/process_info_linux.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_info.h" 6 | 7 | #include "base/basictypes.h" 8 | #include "base/logging.h" 9 | #include "base/process/internal_linux.h" 10 | #include "base/process/process_handle.h" 11 | #include "base/time/time.h" 12 | 13 | namespace base { 14 | 15 | //static 16 | const Time CurrentProcessInfo::CreationTime() { 17 | ProcessHandle pid = GetCurrentProcessHandle(); 18 | int64 start_ticks = 19 | internal::ReadProcStatsAndGetFieldAsInt64(pid, internal::VM_STARTTIME); 20 | DCHECK(start_ticks); 21 | TimeDelta start_offset = internal::ClockTicksToTimeDelta(start_ticks); 22 | Time boot_time = internal::GetBootTime(); 23 | DCHECK(!boot_time.is_null()); 24 | return Time(boot_time + start_offset); 25 | } 26 | 27 | } // namespace base 28 | -------------------------------------------------------------------------------- /src/base/process/process_info_mac.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 | #include 9 | #include 10 | 11 | #include "base/basictypes.h" 12 | #include "base/memory/scoped_ptr.h" 13 | #include "base/time/time.h" 14 | 15 | namespace base { 16 | 17 | //static 18 | const Time CurrentProcessInfo::CreationTime() { 19 | int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() }; 20 | size_t len = 0; 21 | if (sysctl(mib, arraysize(mib), NULL, &len, NULL, 0) < 0) 22 | return Time(); 23 | 24 | scoped_ptr 25 | proc(static_cast(malloc(len))); 26 | if (sysctl(mib, arraysize(mib), proc.get(), &len, NULL, 0) < 0) 27 | return Time(); 28 | return Time::FromTimeVal(proc->kp_proc.p_un.__p_starttime); 29 | } 30 | 31 | } // namespace base 32 | -------------------------------------------------------------------------------- /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/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/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/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/profiler/scoped_profile.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/profiler/scoped_profile.h" 6 | 7 | #include "base/location.h" 8 | #include "base/tracked_objects.h" 9 | 10 | 11 | namespace tracked_objects { 12 | 13 | 14 | ScopedProfile::ScopedProfile(const Location& location, Mode mode) 15 | : birth_(NULL) { 16 | if (mode == DISABLED) 17 | return; 18 | 19 | birth_ = ThreadData::TallyABirthIfActive(location); 20 | if (!birth_) 21 | return; 22 | 23 | ThreadData::PrepareForStartOfRun(birth_); 24 | stopwatch_.Start(); 25 | } 26 | 27 | ScopedProfile::~ScopedProfile() { 28 | if (!birth_) 29 | return; 30 | 31 | stopwatch_.Stop(); 32 | ThreadData::TallyRunInAScopedRegionIfTracking(birth_, stopwatch_); 33 | } 34 | 35 | } // namespace tracked_objects 36 | -------------------------------------------------------------------------------- /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/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/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/sequenced_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/sequenced_task_runner.h" 6 | 7 | #include "base/bind.h" 8 | 9 | namespace base { 10 | 11 | bool SequencedTaskRunner::PostNonNestableTask( 12 | const tracked_objects::Location& from_here, 13 | const Closure& task) { 14 | return PostNonNestableDelayedTask(from_here, task, base::TimeDelta()); 15 | } 16 | 17 | bool SequencedTaskRunner::DeleteSoonInternal( 18 | const tracked_objects::Location& from_here, 19 | void(*deleter)(const void*), 20 | const void* object) { 21 | return PostNonNestableTask(from_here, Bind(deleter, object)); 22 | } 23 | 24 | bool SequencedTaskRunner::ReleaseSoonInternal( 25 | const tracked_objects::Location& from_here, 26 | void(*releaser)(const void*), 27 | const void* object) { 28 | return PostNonNestableTask(from_here, Bind(releaser, object)); 29 | } 30 | 31 | } // namespace base 32 | -------------------------------------------------------------------------------- /src/base/sha1.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_SHA1_H_ 6 | #define BASE_SHA1_H_ 7 | 8 | #include 9 | 10 | #include "base/base_export.h" 11 | 12 | namespace base { 13 | 14 | // These functions perform SHA-1 operations. 15 | 16 | static const size_t kSHA1Length = 20; // Length in bytes of a SHA-1 hash. 17 | 18 | // Computes the SHA-1 hash of the input string |str| and returns the full 19 | // hash. 20 | BASE_EXPORT std::string SHA1HashString(const std::string& str); 21 | 22 | // Computes the SHA-1 hash of the |len| bytes in |data| and puts the hash 23 | // in |hash|. |hash| must be kSHA1Length bytes long. 24 | BASE_EXPORT void SHA1HashBytes(const unsigned char* data, size_t len, 25 | unsigned char* hash); 26 | 27 | } // namespace base 28 | 29 | #endif // BASE_SHA1_H_ 30 | -------------------------------------------------------------------------------- /src/base/strings/OWNERS: -------------------------------------------------------------------------------- 1 | per-file safe_sprintf*=jln@chromium.org 2 | per-file safe_sprintf*=mdempsky@chromium.org 3 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/synchronization/lock_impl_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/synchronization/lock_impl.h" 6 | 7 | namespace base { 8 | namespace internal { 9 | 10 | LockImpl::LockImpl() { 11 | // The second parameter is the spin count, for short-held locks it avoid the 12 | // contending thread from going to sleep which helps performance greatly. 13 | ::InitializeCriticalSectionAndSpinCount(&native_handle_, 2000); 14 | } 15 | 16 | LockImpl::~LockImpl() { 17 | ::DeleteCriticalSection(&native_handle_); 18 | } 19 | 20 | bool LockImpl::Try() { 21 | if (::TryEnterCriticalSection(&native_handle_) != FALSE) { 22 | return true; 23 | } 24 | return false; 25 | } 26 | 27 | void LockImpl::Lock() { 28 | ::EnterCriticalSection(&native_handle_); 29 | } 30 | 31 | void LockImpl::Unlock() { 32 | ::LeaveCriticalSection(&native_handle_); 33 | } 34 | 35 | } // namespace internal 36 | } // namespace base 37 | -------------------------------------------------------------------------------- /src/base/sys_info_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/sys_info.h" 6 | 7 | #include 8 | 9 | #include "base/logging.h" 10 | 11 | namespace base { 12 | 13 | int64 SysInfo::AmountOfPhysicalMemory() { 14 | int pages, page_size; 15 | size_t size = sizeof(pages); 16 | sysctlbyname("vm.stats.vm.v_page_count", &pages, &size, NULL, 0); 17 | sysctlbyname("vm.stats.vm.v_page_size", &page_size, &size, NULL, 0); 18 | if (pages == -1 || page_size == -1) { 19 | NOTREACHED(); 20 | return 0; 21 | } 22 | return static_cast(pages) * page_size; 23 | } 24 | 25 | // static 26 | size_t SysInfo::MaxSharedMemorySize() { 27 | size_t limit; 28 | size_t size = sizeof(limit); 29 | if (sysctlbyname("kern.ipc.shmmax", &limit, &size, NULL, 0) < 0) { 30 | NOTREACHED(); 31 | return 0; 32 | } 33 | return limit; 34 | } 35 | 36 | } // namespace base 37 | -------------------------------------------------------------------------------- /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/test/DEPS: -------------------------------------------------------------------------------- 1 | include_rules = [ 2 | "+third_party/libxml", 3 | ] 4 | -------------------------------------------------------------------------------- /src/base/test/OWNERS: -------------------------------------------------------------------------------- 1 | phajdan.jr@chromium.org 2 | -------------------------------------------------------------------------------- /src/base/test/android/OWNERS: -------------------------------------------------------------------------------- 1 | feng@chromium.org 2 | nyquist@chromium.org 3 | yfriedman@chromium.org 4 | -------------------------------------------------------------------------------- /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/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/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/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/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/test/android/javatests/src/org/chromium/base/test/util/IntegrationTest.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.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * This annotation is for integration tests. 14 | *

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/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/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/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/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/test/data/file_util/binary_file.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryderfang/chromium_base/1e25b45efe2469043682c797159d9b5e0b57c231/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/1e25b45efe2469043682c797159d9b5e0b57c231/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/1e25b45efe2469043682c797159d9b5e0b57c231/src/base/test/data/file_util/binary_file_same.bin -------------------------------------------------------------------------------- /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/blank_line_crlf.txt: -------------------------------------------------------------------------------- 1 | The next line is blank. 2 | 3 | But this one isn't. 4 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/crlf.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_first.txt: -------------------------------------------------------------------------------- 1 | this file is the same. 2 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/different_last.txt: -------------------------------------------------------------------------------- 1 | This file is the same. -------------------------------------------------------------------------------- /src/base/test/data/file_util/empty1.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryderfang/chromium_base/1e25b45efe2469043682c797159d9b5e0b57c231/src/base/test/data/file_util/empty1.txt -------------------------------------------------------------------------------- /src/base/test/data/file_util/empty2.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryderfang/chromium_base/1e25b45efe2469043682c797159d9b5e0b57c231/src/base/test/data/file_util/empty2.txt -------------------------------------------------------------------------------- /src/base/test/data/file_util/first1.txt: -------------------------------------------------------------------------------- 1 | The first line is the same. 2 | The second line is different. 3 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/first2.txt: -------------------------------------------------------------------------------- 1 | The first line is the same. 2 | The second line is not. 3 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/original.txt: -------------------------------------------------------------------------------- 1 | This file is the same. 2 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryderfang/chromium_base/1e25b45efe2469043682c797159d9b5e0b57c231/src/base/test/data/file_util/red.png -------------------------------------------------------------------------------- /src/base/test/data/file_util/same.txt: -------------------------------------------------------------------------------- 1 | This file is the same. 2 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/same_length.txt: -------------------------------------------------------------------------------- 1 | This file is not same. 2 | -------------------------------------------------------------------------------- /src/base/test/data/file_util/shortened.txt: -------------------------------------------------------------------------------- 1 | This file is the -------------------------------------------------------------------------------- /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/test/data/prefs/invalid.json: -------------------------------------------------------------------------------- 1 | !@#$%^& -------------------------------------------------------------------------------- /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/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/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/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/serializer_test_nowhitespace.json: -------------------------------------------------------------------------------- 1 | {"bool":true,"int":42,"list":[1,2],"null":null,"real":3.14,"string":"hello"} -------------------------------------------------------------------------------- /src/base/test/expectations/OWNERS: -------------------------------------------------------------------------------- 1 | rsesek@chromium.org 2 | -------------------------------------------------------------------------------- /src/base/test/gtest_util.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_GTEST_UTIL_H_ 6 | #define BASE_TEST_GTEST_UTIL_H_ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "base/compiler_specific.h" 13 | 14 | namespace base { 15 | 16 | class FilePath; 17 | 18 | // First value is test case name, second one is test name. 19 | typedef std::pair SplitTestName; 20 | 21 | // Returns a vector of gtest-based tests compiled into 22 | // current executable. 23 | std::vector GetCompiledInTests(); 24 | 25 | // Writes the list of gtest-based tests compiled into 26 | // current executable as a JSON file. Returns true on success. 27 | bool WriteCompiledInTestsToFile(const FilePath& path) WARN_UNUSED_RESULT; 28 | 29 | } // namespace base 30 | 31 | #endif // BASE_TEST_GTEST_UTIL_H_ 32 | -------------------------------------------------------------------------------- /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/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/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/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/test/mock_devices_changed_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_TEST_MOCK_DEVICES_CHANGED_OBSERVER_H_ 6 | #define BASE_TEST_MOCK_DEVICES_CHANGED_OBSERVER_H_ 7 | 8 | #include 9 | 10 | #include "base/system_monitor/system_monitor.h" 11 | #include "testing/gmock/include/gmock/gmock.h" 12 | 13 | namespace base { 14 | 15 | class MockDevicesChangedObserver 16 | : public base::SystemMonitor::DevicesChangedObserver { 17 | public: 18 | MockDevicesChangedObserver(); 19 | ~MockDevicesChangedObserver(); 20 | 21 | MOCK_METHOD1(OnDevicesChanged, 22 | void(base::SystemMonitor::DeviceType device_type)); 23 | 24 | DISALLOW_COPY_AND_ASSIGN(MockDevicesChangedObserver); 25 | }; 26 | 27 | } // namespace base 28 | 29 | #endif // BASE_TEST_MOCK_DEVICES_CHANGED_OBSERVER_H_ 30 | -------------------------------------------------------------------------------- /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