diff options
author | Alex Vakulenko <avakulenko@google.com> | 2015-10-12 15:21:28 -0700 |
---|---|---|
committer | Alex Vakulenko <avakulenko@google.com> | 2015-10-13 16:10:03 -0700 |
commit | 9ed0cab99f18acb3570a35e9408f24355f6b8324 (patch) | |
tree | 60e3b4c2822b812b3218489a9a6d835df1e8ca6e | |
parent | eabfe23a51c91a103042793ac2d5c28170994e1f (diff) | |
download | libchromeos-9ed0cab99f18acb3570a35e9408f24355f6b8324.tar.gz |
Move chromeos symbols into brillo namespace
And move the include files into "brillo" directory instead of "chromeos"
BUG: 24872993
TEST=built aosp and brillo and unit tests pass on dragonoboard
Change-Id: Ieb979d1ebd3152921d36cd15acbd6247f02aae69
-rw-r--r-- | Android.mk | 172 | ||||
-rw-r--r-- | brillo/any.cc (renamed from chromeos/any.cc) | 6 | ||||
-rw-r--r-- | brillo/any.h (renamed from chromeos/any.h) | 26 | ||||
-rw-r--r-- | brillo/any_internal_impl.h (renamed from chromeos/any_internal_impl.h) | 18 | ||||
-rw-r--r-- | brillo/any_internal_impl_unittest.cc (renamed from chromeos/any_internal_impl_unittest.cc) | 4 | ||||
-rw-r--r-- | brillo/any_unittest.cc (renamed from chromeos/any_unittest.cc) | 4 | ||||
-rw-r--r-- | brillo/asynchronous_signal_handler.cc (renamed from chromeos/asynchronous_signal_handler.cc) | 6 | ||||
-rw-r--r-- | brillo/asynchronous_signal_handler.h (renamed from chromeos/asynchronous_signal_handler.h) | 22 | ||||
-rw-r--r-- | brillo/asynchronous_signal_handler_interface.h (renamed from chromeos/asynchronous_signal_handler_interface.h) | 14 | ||||
-rw-r--r-- | brillo/asynchronous_signal_handler_unittest.cc (renamed from chromeos/asynchronous_signal_handler_unittest.cc) | 22 | ||||
-rw-r--r-- | brillo/backoff_entry.cc (renamed from chromeos/backoff_entry.cc) | 6 | ||||
-rw-r--r-- | brillo/backoff_entry.h (renamed from chromeos/backoff_entry.h) | 14 | ||||
-rw-r--r-- | brillo/backoff_entry_unittest.cc (renamed from chromeos/backoff_entry_unittest.cc) | 10 | ||||
-rw-r--r-- | brillo/bind_lambda.h (renamed from chromeos/bind_lambda.h) | 6 | ||||
-rw-r--r-- | brillo/binder_watcher.cc (renamed from chromeos/binder_watcher.cc) | 6 | ||||
-rw-r--r-- | brillo/binder_watcher.h (renamed from chromeos/binder_watcher.h) | 10 | ||||
-rw-r--r-- | brillo/brillo_export.h (renamed from chromeos/chromeos_export.h) | 26 | ||||
-rw-r--r-- | brillo/cryptohome.cc (renamed from chromeos/cryptohome.cc) | 6 | ||||
-rw-r--r-- | brillo/cryptohome.h (renamed from chromeos/cryptohome.h) | 40 | ||||
-rw-r--r-- | brillo/daemons/daemon.cc (renamed from chromeos/daemons/daemon.cc) | 12 | ||||
-rw-r--r-- | brillo/daemons/daemon.h (renamed from chromeos/daemons/daemon.h) | 22 | ||||
-rw-r--r-- | brillo/daemons/dbus_daemon.cc (renamed from chromeos/daemons/dbus_daemon.cc) | 14 | ||||
-rw-r--r-- | brillo/daemons/dbus_daemon.h (renamed from chromeos/daemons/dbus_daemon.h) | 20 | ||||
-rw-r--r-- | brillo/data_encoding.cc (renamed from chromeos/data_encoding.cc) | 18 | ||||
-rw-r--r-- | brillo/data_encoding.h (renamed from chromeos/data_encoding.h) | 40 | ||||
-rw-r--r-- | brillo/data_encoding_unittest.cc (renamed from chromeos/data_encoding_unittest.cc) | 18 | ||||
-rw-r--r-- | brillo/dbus/async_event_sequencer.cc (renamed from chromeos/dbus/async_event_sequencer.cc) | 6 | ||||
-rw-r--r-- | brillo/dbus/async_event_sequencer.h (renamed from chromeos/dbus/async_event_sequencer.h) | 34 | ||||
-rw-r--r-- | brillo/dbus/async_event_sequencer_unittest.cc (renamed from chromeos/dbus/async_event_sequencer_unittest.cc) | 6 | ||||
-rw-r--r-- | brillo/dbus/data_serialization.cc (renamed from chromeos/dbus/data_serialization.cc) | 36 | ||||
-rw-r--r-- | brillo/dbus/data_serialization.h (renamed from chromeos/dbus/data_serialization.h) | 88 | ||||
-rw-r--r-- | brillo/dbus/data_serialization_unittest.cc (renamed from chromeos/dbus/data_serialization_unittest.cc) | 8 | ||||
-rw-r--r-- | brillo/dbus/dbus_method_invoker.cc (renamed from chromeos/dbus/dbus_method_invoker.cc) | 6 | ||||
-rw-r--r-- | brillo/dbus/dbus_method_invoker.h (renamed from chromeos/dbus/dbus_method_invoker.h) | 42 | ||||
-rw-r--r-- | brillo/dbus/dbus_method_invoker_unittest.cc (renamed from chromeos/dbus/dbus_method_invoker_unittest.cc) | 54 | ||||
-rw-r--r-- | brillo/dbus/dbus_method_response.cc (renamed from chromeos/dbus/dbus_method_response.cc) | 10 | ||||
-rw-r--r-- | brillo/dbus/dbus_method_response.h (renamed from chromeos/dbus/dbus_method_response.h) | 22 | ||||
-rw-r--r-- | brillo/dbus/dbus_object.cc (renamed from chromeos/dbus/dbus_object.cc) | 12 | ||||
-rw-r--r-- | brillo/dbus/dbus_object.h (renamed from chromeos/dbus/dbus_object.h) | 44 | ||||
-rw-r--r-- | brillo/dbus/dbus_object_internal_impl.h (renamed from chromeos/dbus/dbus_object_internal_impl.h) | 22 | ||||
-rw-r--r-- | brillo/dbus/dbus_object_test_helpers.h (renamed from chromeos/dbus/dbus_object_test_helpers.h) | 14 | ||||
-rw-r--r-- | brillo/dbus/dbus_object_unittest.cc (renamed from chromeos/dbus/dbus_object_unittest.cc) | 10 | ||||
-rw-r--r-- | brillo/dbus/dbus_param_reader.h (renamed from chromeos/dbus/dbus_param_reader.h) | 18 | ||||
-rw-r--r-- | brillo/dbus/dbus_param_reader_unittest.cc (renamed from chromeos/dbus/dbus_param_reader_unittest.cc) | 8 | ||||
-rw-r--r-- | brillo/dbus/dbus_param_writer.h (renamed from chromeos/dbus/dbus_param_writer.h) | 12 | ||||
-rw-r--r-- | brillo/dbus/dbus_param_writer_unittest.cc (renamed from chromeos/dbus/dbus_param_writer_unittest.cc) | 8 | ||||
-rw-r--r-- | brillo/dbus/dbus_property.h (renamed from chromeos/dbus/dbus_property.h) | 12 | ||||
-rw-r--r-- | brillo/dbus/dbus_service_watcher.cc (renamed from chromeos/dbus/dbus_service_watcher.cc) | 6 | ||||
-rw-r--r-- | brillo/dbus/dbus_service_watcher.h (renamed from chromeos/dbus/dbus_service_watcher.h) | 14 | ||||
-rw-r--r-- | brillo/dbus/dbus_signal.cc (renamed from chromeos/dbus/dbus_signal.cc) | 8 | ||||
-rw-r--r-- | brillo/dbus/dbus_signal.h (renamed from chromeos/dbus/dbus_signal.h) | 16 | ||||
-rw-r--r-- | brillo/dbus/dbus_signal_handler.h (renamed from chromeos/dbus/dbus_signal_handler.h) | 18 | ||||
-rw-r--r-- | brillo/dbus/dbus_signal_handler_unittest.cc (renamed from chromeos/dbus/dbus_signal_handler_unittest.cc) | 14 | ||||
-rw-r--r-- | brillo/dbus/exported_object_manager.cc (renamed from chromeos/dbus/exported_object_manager.cc) | 12 | ||||
-rw-r--r-- | brillo/dbus/exported_object_manager.h (renamed from chromeos/dbus/exported_object_manager.h) | 28 | ||||
-rw-r--r-- | brillo/dbus/exported_object_manager_unittest.cc (renamed from chromeos/dbus/exported_object_manager_unittest.cc) | 14 | ||||
-rw-r--r-- | brillo/dbus/exported_property_set.cc (renamed from chromeos/dbus/exported_property_set.cc) | 54 | ||||
-rw-r--r-- | brillo/dbus/exported_property_set.h (renamed from chromeos/dbus/exported_property_set.h) | 72 | ||||
-rw-r--r-- | brillo/dbus/exported_property_set_unittest.cc (renamed from chromeos/dbus/exported_property_set_unittest.cc) | 47 | ||||
-rw-r--r-- | brillo/dbus/mock_dbus_object.h (renamed from chromeos/dbus/mock_dbus_object.h) | 14 | ||||
-rw-r--r-- | brillo/dbus/mock_exported_object_manager.h (renamed from chromeos/dbus/mock_exported_object_manager.h) | 18 | ||||
-rw-r--r-- | brillo/dbus/test.proto (renamed from chromeos/dbus/test.proto) | 0 | ||||
-rw-r--r-- | brillo/dbus/utils.cc (renamed from chromeos/dbus/utils.cc) | 14 | ||||
-rw-r--r-- | brillo/dbus/utils.h (renamed from chromeos/dbus/utils.h) | 28 | ||||
-rw-r--r-- | brillo/errors/error.cc (renamed from chromeos/errors/error.cc) | 8 | ||||
-rw-r--r-- | brillo/errors/error.h (renamed from chromeos/errors/error.h) | 14 | ||||
-rw-r--r-- | brillo/errors/error_codes.cc (renamed from chromeos/errors/error_codes.cc) | 6 | ||||
-rw-r--r-- | brillo/errors/error_codes.h | 43 | ||||
-rw-r--r-- | brillo/errors/error_codes_unittest.cc (renamed from chromeos/errors/error_codes_unittest.cc) | 14 | ||||
-rw-r--r-- | brillo/errors/error_unittest.cc (renamed from chromeos/errors/error_unittest.cc) | 22 | ||||
-rw-r--r-- | brillo/file_utils.cc (renamed from chromeos/file_utils.cc) | 6 | ||||
-rw-r--r-- | brillo/file_utils.h (renamed from chromeos/file_utils.h) | 22 | ||||
-rw-r--r-- | brillo/file_utils_unittest.cc (renamed from chromeos/file_utils_unittest.cc) | 6 | ||||
-rw-r--r-- | brillo/flag_helper.cc (renamed from chromeos/flag_helper.cc) | 14 | ||||
-rw-r--r-- | brillo/flag_helper.h (renamed from chromeos/flag_helper.h) | 47 | ||||
-rw-r--r-- | brillo/flag_helper_unittest.cc (renamed from chromeos/flag_helper_unittest.cc) | 62 | ||||
-rw-r--r-- | brillo/glib/abstract_dbus_service.cc (renamed from chromeos/glib/abstract_dbus_service.cc) | 8 | ||||
-rw-r--r-- | brillo/glib/abstract_dbus_service.h (renamed from chromeos/glib/abstract_dbus_service.h) | 18 | ||||
-rw-r--r-- | brillo/glib/dbus.cc (renamed from chromeos/glib/dbus.cc) | 8 | ||||
-rw-r--r-- | brillo/glib/dbus.h (renamed from chromeos/glib/dbus.h) | 70 | ||||
-rw-r--r-- | brillo/glib/object.h (renamed from chromeos/glib/object.h) | 10 | ||||
-rw-r--r-- | brillo/glib/object_unittest.cc (renamed from chromeos/glib/object_unittest.cc) | 12 | ||||
-rw-r--r-- | brillo/http/curl_api.cc (renamed from chromeos/http/curl_api.cc) | 6 | ||||
-rw-r--r-- | brillo/http/curl_api.h (renamed from chromeos/http/curl_api.h) | 14 | ||||
-rw-r--r-- | brillo/http/http_connection.h (renamed from chromeos/http/http_connection.h) | 29 | ||||
-rw-r--r-- | brillo/http/http_connection_curl.cc (renamed from chromeos/http/http_connection_curl.cc) | 28 | ||||
-rw-r--r-- | brillo/http/http_connection_curl.h (renamed from chromeos/http/http_connection_curl.h) | 49 | ||||
-rw-r--r-- | brillo/http/http_connection_curl_unittest.cc (renamed from chromeos/http/http_connection_curl_unittest.cc) | 22 | ||||
-rw-r--r-- | brillo/http/http_connection_fake.cc (renamed from chromeos/http/http_connection_fake.cc) | 30 | ||||
-rw-r--r-- | brillo/http/http_connection_fake.h (renamed from chromeos/http/http_connection_fake.h) | 23 | ||||
-rw-r--r-- | brillo/http/http_form_data.cc (renamed from chromeos/http/http_form_data.cc) | 22 | ||||
-rw-r--r-- | brillo/http/http_form_data.h (renamed from chromeos/http/http_form_data.h) | 34 | ||||
-rw-r--r-- | brillo/http/http_form_data_unittest.cc (renamed from chromeos/http/http_form_data_unittest.cc) | 12 | ||||
-rw-r--r-- | brillo/http/http_request.cc (renamed from chromeos/http/http_request.cc) | 38 | ||||
-rw-r--r-- | brillo/http/http_request.h (renamed from chromeos/http/http_request.h) | 192 | ||||
-rw-r--r-- | brillo/http/http_request_unittest.cc (renamed from chromeos/http/http_request_unittest.cc) | 16 | ||||
-rw-r--r-- | brillo/http/http_transport.cc (renamed from chromeos/http/http_transport.cc) | 8 | ||||
-rw-r--r-- | brillo/http/http_transport.h (renamed from chromeos/http/http_transport.h) | 23 | ||||
-rw-r--r-- | brillo/http/http_transport_curl.cc (renamed from chromeos/http/http_transport_curl.cc) | 60 | ||||
-rw-r--r-- | brillo/http/http_transport_curl.h (renamed from chromeos/http/http_transport_curl.h) | 28 | ||||
-rw-r--r-- | brillo/http/http_transport_curl_unittest.cc (renamed from chromeos/http/http_transport_curl_unittest.cc) | 14 | ||||
-rw-r--r-- | brillo/http/http_transport_fake.cc (renamed from chromeos/http/http_transport_fake.cc) | 42 | ||||
-rw-r--r-- | brillo/http/http_transport_fake.h (renamed from chromeos/http/http_transport_fake.h) | 20 | ||||
-rw-r--r-- | brillo/http/http_utils.cc (renamed from chromeos/http/http_utils.cc) | 112 | ||||
-rw-r--r-- | brillo/http/http_utils.h (renamed from chromeos/http/http_utils.h) | 96 | ||||
-rw-r--r-- | brillo/http/http_utils_unittest.cc (renamed from chromeos/http/http_utils_unittest.cc) | 76 | ||||
-rw-r--r-- | brillo/http/mock_connection.h (renamed from chromeos/http/mock_connection.h) | 18 | ||||
-rw-r--r-- | brillo/http/mock_curl_api.h (renamed from chromeos/http/mock_curl_api.h) | 12 | ||||
-rw-r--r-- | brillo/http/mock_transport.h (renamed from chromeos/http/mock_transport.h) | 14 | ||||
-rw-r--r-- | brillo/key_value_store.cc (renamed from chromeos/key_value_store.cc) | 10 | ||||
-rw-r--r-- | brillo/key_value_store.h (renamed from chromeos/key_value_store.h) | 14 | ||||
-rw-r--r-- | brillo/key_value_store_unittest.cc (renamed from chromeos/key_value_store_unittest.cc) | 8 | ||||
-rw-r--r-- | brillo/location_logging.h (renamed from chromeos/location_logging.h) | 6 | ||||
-rw-r--r-- | brillo/make_unique_ptr.h (renamed from chromeos/make_unique_ptr.h) | 10 | ||||
-rw-r--r-- | brillo/map_utils.h (renamed from chromeos/map_utils.h) | 10 | ||||
-rw-r--r-- | brillo/map_utils_unittest.cc (renamed from chromeos/map_utils_unittest.cc) | 6 | ||||
-rw-r--r-- | brillo/message_loops/base_message_loop.cc (renamed from chromeos/message_loops/base_message_loop.cc) | 8 | ||||
-rw-r--r-- | brillo/message_loops/base_message_loop.h (renamed from chromeos/message_loops/base_message_loop.h) | 20 | ||||
-rw-r--r-- | brillo/message_loops/fake_message_loop.cc (renamed from chromeos/message_loops/fake_message_loop.cc) | 8 | ||||
-rw-r--r-- | brillo/message_loops/fake_message_loop.h (renamed from chromeos/message_loops/fake_message_loop.h) | 16 | ||||
-rw-r--r-- | brillo/message_loops/fake_message_loop_unittest.cc (renamed from chromeos/message_loops/fake_message_loop_unittest.cc) | 10 | ||||
-rw-r--r-- | brillo/message_loops/glib_message_loop.cc (renamed from chromeos/message_loops/glib_message_loop.cc) | 8 | ||||
-rw-r--r-- | brillo/message_loops/glib_message_loop.h (renamed from chromeos/message_loops/glib_message_loop.h) | 16 | ||||
-rw-r--r-- | brillo/message_loops/glib_message_loop_unittest.cc (renamed from chromeos/message_loops/glib_message_loop_unittest.cc) | 12 | ||||
-rw-r--r-- | brillo/message_loops/message_loop.cc (renamed from chromeos/message_loops/message_loop.cc) | 6 | ||||
-rw-r--r-- | brillo/message_loops/message_loop.h (renamed from chromeos/message_loops/message_loop.h) | 17 | ||||
-rw-r--r-- | brillo/message_loops/message_loop_unittest.cc (renamed from chromeos/message_loops/message_loop_unittest.cc) | 18 | ||||
-rw-r--r-- | brillo/message_loops/message_loop_utils.cc (renamed from chromeos/message_loops/message_loop_utils.cc) | 8 | ||||
-rw-r--r-- | brillo/message_loops/message_loop_utils.h (renamed from chromeos/message_loops/message_loop_utils.h) | 20 | ||||
-rw-r--r-- | brillo/message_loops/mock_message_loop.h (renamed from chromeos/message_loops/mock_message_loop.h) | 18 | ||||
-rw-r--r-- | brillo/mime_utils.cc (renamed from chromeos/mime_utils.cc) | 30 | ||||
-rw-r--r-- | brillo/mime_utils.h | 126 | ||||
-rw-r--r-- | brillo/mime_utils_unittest.cc (renamed from chromeos/mime_utils_unittest.cc) | 6 | ||||
-rw-r--r-- | brillo/minijail/minijail.cc (renamed from chromeos/minijail/minijail.cc) | 6 | ||||
-rw-r--r-- | brillo/minijail/minijail.h (renamed from chromeos/minijail/minijail.h) | 10 | ||||
-rw-r--r-- | brillo/minijail/mock_minijail.h (renamed from chromeos/minijail/mock_minijail.h) | 14 | ||||
-rw-r--r-- | brillo/osrelease_reader.cc (renamed from chromeos/osrelease_reader.cc) | 10 | ||||
-rw-r--r-- | brillo/osrelease_reader.h (renamed from chromeos/osrelease_reader.h) | 18 | ||||
-rw-r--r-- | brillo/osrelease_reader_unittest.cc (renamed from chromeos/osrelease_reader_unittest.cc) | 6 | ||||
-rw-r--r-- | brillo/pointer_utils.h (renamed from chromeos/pointer_utils.h) | 10 | ||||
-rw-r--r-- | brillo/process.cc (renamed from chromeos/process.cc) | 6 | ||||
-rw-r--r-- | brillo/process.h (renamed from chromeos/process.h) | 16 | ||||
-rw-r--r-- | brillo/process_information.cc (renamed from chromeos/process_information.cc) | 6 | ||||
-rw-r--r-- | brillo/process_information.h (renamed from chromeos/process_information.h) | 14 | ||||
-rw-r--r-- | brillo/process_mock.h (renamed from chromeos/process_mock.h) | 12 | ||||
-rw-r--r-- | brillo/process_reaper.cc (renamed from chromeos/process_reaper.cc) | 14 | ||||
-rw-r--r-- | brillo/process_reaper.h (renamed from chromeos/process_reaper.h) | 20 | ||||
-rw-r--r-- | brillo/process_reaper_unittest.cc (renamed from chromeos/process_reaper_unittest.cc) | 30 | ||||
-rw-r--r-- | brillo/process_unittest.cc (renamed from chromeos/process_unittest.cc) | 14 | ||||
-rw-r--r-- | brillo/secure_blob.cc (renamed from chromeos/secure_blob.cc) | 6 | ||||
-rw-r--r-- | brillo/secure_blob.h (renamed from chromeos/secure_blob.h) | 18 | ||||
-rw-r--r-- | brillo/secure_blob_unittest.cc (renamed from chromeos/secure_blob_unittest.cc) | 16 | ||||
-rw-r--r-- | brillo/streams/fake_stream.cc (renamed from chromeos/streams/fake_stream.cc) | 26 | ||||
-rw-r--r-- | brillo/streams/fake_stream.h (renamed from chromeos/streams/fake_stream.h) | 36 | ||||
-rw-r--r-- | brillo/streams/fake_stream_unittest.cc (renamed from chromeos/streams/fake_stream_unittest.cc) | 10 | ||||
-rw-r--r-- | brillo/streams/file_stream.cc (renamed from chromeos/streams/file_stream.cc) | 29 | ||||
-rw-r--r-- | brillo/streams/file_stream.h (renamed from chromeos/streams/file_stream.h) | 18 | ||||
-rw-r--r-- | brillo/streams/file_stream_unittest.cc (renamed from chromeos/streams/file_stream_unittest.cc) | 51 | ||||
-rw-r--r-- | brillo/streams/input_stream_set.cc (renamed from chromeos/streams/input_stream_set.cc) | 16 | ||||
-rw-r--r-- | brillo/streams/input_stream_set.h (renamed from chromeos/streams/input_stream_set.h) | 19 | ||||
-rw-r--r-- | brillo/streams/input_stream_set_unittest.cc (renamed from chromeos/streams/input_stream_set_unittest.cc) | 12 | ||||
-rw-r--r-- | brillo/streams/memory_containers.cc (renamed from chromeos/streams/memory_containers.cc) | 8 | ||||
-rw-r--r-- | brillo/streams/memory_containers.h (renamed from chromeos/streams/memory_containers.h) | 33 | ||||
-rw-r--r-- | brillo/streams/memory_containers_unittest.cc (renamed from chromeos/streams/memory_containers_unittest.cc) | 10 | ||||
-rw-r--r-- | brillo/streams/memory_stream.cc (renamed from chromeos/streams/memory_stream.cc) | 22 | ||||
-rw-r--r-- | brillo/streams/memory_stream.h (renamed from chromeos/streams/memory_stream.h) | 23 | ||||
-rw-r--r-- | brillo/streams/memory_stream_unittest.cc (renamed from chromeos/streams/memory_stream_unittest.cc) | 14 | ||||
-rw-r--r-- | brillo/streams/mock_stream.h (renamed from chromeos/streams/mock_stream.h) | 12 | ||||
-rw-r--r-- | brillo/streams/openssl_stream_bio.cc (renamed from chromeos/streams/openssl_stream_bio.cc) | 20 | ||||
-rw-r--r-- | brillo/streams/openssl_stream_bio.h (renamed from chromeos/streams/openssl_stream_bio.h) | 16 | ||||
-rw-r--r-- | brillo/streams/openssl_stream_bio_unittests.cc (renamed from chromeos/streams/openssl_stream_bio_unittests.cc) | 8 | ||||
-rw-r--r-- | brillo/streams/stream.cc (renamed from chromeos/streams/stream.cc) | 14 | ||||
-rw-r--r-- | brillo/streams/stream.h (renamed from chromeos/streams/stream.h) | 36 | ||||
-rw-r--r-- | brillo/streams/stream_errors.cc (renamed from chromeos/streams/stream_errors.cc) | 6 | ||||
-rw-r--r-- | brillo/streams/stream_errors.h | 27 | ||||
-rw-r--r-- | brillo/streams/stream_unittest.cc (renamed from chromeos/streams/stream_unittest.cc) | 12 | ||||
-rw-r--r-- | brillo/streams/stream_utils.cc (renamed from chromeos/streams/stream_utils.cc) | 23 | ||||
-rw-r--r-- | brillo/streams/stream_utils.h (renamed from chromeos/streams/stream_utils.h) | 48 | ||||
-rw-r--r-- | brillo/streams/stream_utils_unittest.cc (renamed from chromeos/streams/stream_utils_unittest.cc) | 24 | ||||
-rw-r--r-- | brillo/streams/tls_stream.cc (renamed from chromeos/streams/tls_stream.cc) | 25 | ||||
-rw-r--r-- | brillo/streams/tls_stream.h (renamed from chromeos/streams/tls_stream.h) | 20 | ||||
-rw-r--r-- | brillo/strings/string_utils.cc (renamed from chromeos/strings/string_utils.cc) | 6 | ||||
-rw-r--r-- | brillo/strings/string_utils.h (renamed from chromeos/strings/string_utils.h) | 42 | ||||
-rw-r--r-- | brillo/strings/string_utils_unittest.cc (renamed from chromeos/strings/string_utils_unittest.cc) | 6 | ||||
-rw-r--r-- | brillo/syslog_logging.cc (renamed from chromeos/syslog_logging.cc) | 6 | ||||
-rw-r--r-- | brillo/syslog_logging.h (renamed from chromeos/syslog_logging.h) | 28 | ||||
-rw-r--r-- | brillo/syslog_logging_unittest.cc (renamed from chromeos/syslog_logging_unittest.cc) | 6 | ||||
-rw-r--r-- | brillo/test_helpers.h (renamed from chromeos/test_helpers.h) | 12 | ||||
-rw-r--r-- | brillo/type_name_undecorate.cc (renamed from chromeos/type_name_undecorate.cc) | 6 | ||||
-rw-r--r-- | brillo/type_name_undecorate.h (renamed from chromeos/type_name_undecorate.h) | 16 | ||||
-rw-r--r-- | brillo/url_utils.cc (renamed from chromeos/url_utils.cc) | 6 | ||||
-rw-r--r-- | brillo/url_utils.h (renamed from chromeos/url_utils.h) | 38 | ||||
-rw-r--r-- | brillo/url_utils_unittest.cc (renamed from chromeos/url_utils_unittest.cc) | 6 | ||||
-rw-r--r-- | brillo/userdb_utils.cc (renamed from chromeos/userdb_utils.cc) | 6 | ||||
-rw-r--r-- | brillo/userdb_utils.h (renamed from chromeos/userdb_utils.h) | 16 | ||||
-rw-r--r-- | brillo/variant_dictionary.h (renamed from chromeos/variant_dictionary.h) | 16 | ||||
-rw-r--r-- | brillo/variant_dictionary_unittest.cc (renamed from chromeos/variant_dictionary_unittest.cc) | 8 | ||||
-rw-r--r-- | chromeos/errors/error_codes.h | 43 | ||||
-rw-r--r-- | chromeos/mime_utils.h | 126 | ||||
-rw-r--r-- | chromeos/streams/stream_errors.h | 27 | ||||
-rw-r--r-- | libchromeos.gypi | 210 | ||||
-rw-r--r-- | policy/device_policy.h | 6 | ||||
-rw-r--r-- | policy/device_policy_impl.h | 6 | ||||
-rw-r--r-- | policy/libpolicy.h | 6 | ||||
-rw-r--r-- | policy/mock_device_policy.h | 6 | ||||
-rw-r--r-- | policy/mock_libpolicy.h | 6 | ||||
-rw-r--r-- | testrunner.cc | 2 | ||||
-rw-r--r-- | testrunner_android.cc | 2 |
208 files changed, 2360 insertions, 2418 deletions
@@ -16,109 +16,109 @@ LOCAL_PATH := $(call my-dir) libchromeos_cpp_extension := .cc libchromeos_core_sources := \ - chromeos/backoff_entry.cc \ - chromeos/data_encoding.cc \ - chromeos/errors/error.cc \ - chromeos/errors/error_codes.cc \ - chromeos/flag_helper.cc \ - chromeos/key_value_store.cc \ - chromeos/message_loops/base_message_loop.cc \ - chromeos/message_loops/message_loop.cc \ - chromeos/message_loops/message_loop_utils.cc \ - chromeos/mime_utils.cc \ - chromeos/osrelease_reader.cc \ - chromeos/process.cc \ - chromeos/process_information.cc \ - chromeos/secure_blob.cc \ - chromeos/strings/string_utils.cc \ - chromeos/syslog_logging.cc \ - chromeos/type_name_undecorate.cc \ - chromeos/url_utils.cc \ + brillo/backoff_entry.cc \ + brillo/data_encoding.cc \ + brillo/errors/error.cc \ + brillo/errors/error_codes.cc \ + brillo/flag_helper.cc \ + brillo/key_value_store.cc \ + brillo/message_loops/base_message_loop.cc \ + brillo/message_loops/message_loop.cc \ + brillo/message_loops/message_loop_utils.cc \ + brillo/mime_utils.cc \ + brillo/osrelease_reader.cc \ + brillo/process.cc \ + brillo/process_information.cc \ + brillo/secure_blob.cc \ + brillo/strings/string_utils.cc \ + brillo/syslog_logging.cc \ + brillo/type_name_undecorate.cc \ + brillo/url_utils.cc \ libchromeos_linux_sources := \ - chromeos/asynchronous_signal_handler.cc \ - chromeos/daemons/daemon.cc \ - chromeos/file_utils.cc \ - chromeos/process_reaper.cc \ + brillo/asynchronous_signal_handler.cc \ + brillo/daemons/daemon.cc \ + brillo/file_utils.cc \ + brillo/process_reaper.cc \ libchromeos_binder_sources := \ - chromeos/binder_watcher.cc \ + brillo/binder_watcher.cc \ libchromeos_dbus_sources := \ - chromeos/any.cc \ - chromeos/daemons/dbus_daemon.cc \ - chromeos/dbus/async_event_sequencer.cc \ - chromeos/dbus/data_serialization.cc \ - chromeos/dbus/dbus_method_invoker.cc \ - chromeos/dbus/dbus_method_response.cc \ - chromeos/dbus/dbus_object.cc \ - chromeos/dbus/dbus_service_watcher.cc \ - chromeos/dbus/dbus_signal.cc \ - chromeos/dbus/exported_object_manager.cc \ - chromeos/dbus/exported_property_set.cc \ - chromeos/dbus/utils.cc \ + brillo/any.cc \ + brillo/daemons/dbus_daemon.cc \ + brillo/dbus/async_event_sequencer.cc \ + brillo/dbus/data_serialization.cc \ + brillo/dbus/dbus_method_invoker.cc \ + brillo/dbus/dbus_method_response.cc \ + brillo/dbus/dbus_object.cc \ + brillo/dbus/dbus_service_watcher.cc \ + brillo/dbus/dbus_signal.cc \ + brillo/dbus/exported_object_manager.cc \ + brillo/dbus/exported_property_set.cc \ + brillo/dbus/utils.cc \ libchromeos_http_sources := \ - chromeos/http/curl_api.cc \ - chromeos/http/http_connection_curl.cc \ - chromeos/http/http_form_data.cc \ - chromeos/http/http_request.cc \ - chromeos/http/http_transport.cc \ - chromeos/http/http_transport_curl.cc \ - chromeos/http/http_utils.cc \ + brillo/http/curl_api.cc \ + brillo/http/http_connection_curl.cc \ + brillo/http/http_form_data.cc \ + brillo/http/http_request.cc \ + brillo/http/http_transport.cc \ + brillo/http/http_transport_curl.cc \ + brillo/http/http_utils.cc \ libchromeos_policy_sources := \ policy/device_policy.cc \ policy/libpolicy.cc \ libchromeos_stream_sources := \ - chromeos/streams/file_stream.cc \ - chromeos/streams/input_stream_set.cc \ - chromeos/streams/memory_containers.cc \ - chromeos/streams/memory_stream.cc \ - chromeos/streams/openssl_stream_bio.cc \ - chromeos/streams/stream.cc \ - chromeos/streams/stream_errors.cc \ - chromeos/streams/stream_utils.cc \ - chromeos/streams/tls_stream.cc \ + brillo/streams/file_stream.cc \ + brillo/streams/input_stream_set.cc \ + brillo/streams/memory_containers.cc \ + brillo/streams/memory_stream.cc \ + brillo/streams/openssl_stream_bio.cc \ + brillo/streams/stream.cc \ + brillo/streams/stream_errors.cc \ + brillo/streams/stream_utils.cc \ + brillo/streams/tls_stream.cc \ libchromeos_test_helpers_sources := \ - chromeos/http/http_connection_fake.cc \ - chromeos/http/http_transport_fake.cc \ - chromeos/message_loops/fake_message_loop.cc \ - chromeos/streams/fake_stream.cc \ + brillo/http/http_connection_fake.cc \ + brillo/http/http_transport_fake.cc \ + brillo/message_loops/fake_message_loop.cc \ + brillo/streams/fake_stream.cc \ libchromeos_test_sources := \ - chromeos/asynchronous_signal_handler_unittest.cc \ - chromeos/backoff_entry_unittest.cc \ - chromeos/data_encoding_unittest.cc \ - chromeos/errors/error_codes_unittest.cc \ - chromeos/errors/error_unittest.cc \ - chromeos/file_utils_unittest.cc \ - chromeos/flag_helper_unittest.cc \ - chromeos/http/http_connection_curl_unittest.cc \ - chromeos/http/http_form_data_unittest.cc \ - chromeos/http/http_request_unittest.cc \ - chromeos/http/http_transport_curl_unittest.cc \ - chromeos/http/http_utils_unittest.cc \ - chromeos/key_value_store_unittest.cc \ - chromeos/map_utils_unittest.cc \ - chromeos/message_loops/fake_message_loop_unittest.cc \ - chromeos/mime_utils_unittest.cc \ - chromeos/osrelease_reader_unittest.cc \ - chromeos/process_reaper_unittest.cc \ - chromeos/process_unittest.cc \ - chromeos/secure_blob_unittest.cc \ - chromeos/streams/fake_stream_unittest.cc \ - chromeos/streams/file_stream_unittest.cc \ - chromeos/streams/input_stream_set_unittest.cc \ - chromeos/streams/memory_containers_unittest.cc \ - chromeos/streams/memory_stream_unittest.cc \ - chromeos/streams/openssl_stream_bio_unittests.cc \ - chromeos/streams/stream_unittest.cc \ - chromeos/streams/stream_utils_unittest.cc \ - chromeos/strings/string_utils_unittest.cc \ - chromeos/url_utils_unittest.cc \ + brillo/asynchronous_signal_handler_unittest.cc \ + brillo/backoff_entry_unittest.cc \ + brillo/data_encoding_unittest.cc \ + brillo/errors/error_codes_unittest.cc \ + brillo/errors/error_unittest.cc \ + brillo/file_utils_unittest.cc \ + brillo/flag_helper_unittest.cc \ + brillo/http/http_connection_curl_unittest.cc \ + brillo/http/http_form_data_unittest.cc \ + brillo/http/http_request_unittest.cc \ + brillo/http/http_transport_curl_unittest.cc \ + brillo/http/http_utils_unittest.cc \ + brillo/key_value_store_unittest.cc \ + brillo/map_utils_unittest.cc \ + brillo/message_loops/fake_message_loop_unittest.cc \ + brillo/mime_utils_unittest.cc \ + brillo/osrelease_reader_unittest.cc \ + brillo/process_reaper_unittest.cc \ + brillo/process_unittest.cc \ + brillo/secure_blob_unittest.cc \ + brillo/streams/fake_stream_unittest.cc \ + brillo/streams/file_stream_unittest.cc \ + brillo/streams/input_stream_set_unittest.cc \ + brillo/streams/memory_containers_unittest.cc \ + brillo/streams/memory_stream_unittest.cc \ + brillo/streams/openssl_stream_bio_unittests.cc \ + brillo/streams/stream_unittest.cc \ + brillo/streams/stream_utils_unittest.cc \ + brillo/strings/string_utils_unittest.cc \ + brillo/url_utils_unittest.cc \ libchromeos_CFLAGS := -Wall \ -Wno-char-subscripts -Wno-missing-field-initializers \ @@ -181,7 +181,7 @@ include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_CPP_EXTENSION := $(libchromeos_cpp_extension) LOCAL_MODULE := libchromeos-minijail -LOCAL_SRC_FILES := chromeos/minijail/minijail.cc \ +LOCAL_SRC_FILES := brillo/minijail/minijail.cc \ LOCAL_C_INCLUDES := $(libchromeos_includes) LOCAL_SHARED_LIBRARIES := $(libchromeos_shared_libraries) libchromeos \ diff --git a/chromeos/any.cc b/brillo/any.cc index 4cedff6..30e875b 100644 --- a/chromeos/any.cc +++ b/brillo/any.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/any.h> +#include <brillo/any.h> #include <algorithm> -namespace chromeos { +namespace brillo { Any::Any() { } @@ -77,4 +77,4 @@ void Any::AppendToDBusMessageWriter(dbus::MessageWriter* writer) const { data_buffer_.GetDataPtr()->AppendToDBusMessage(writer); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/any.h b/brillo/any.h index 68ff996..b872962 100644 --- a/chromeos/any.h +++ b/brillo/any.h @@ -3,14 +3,14 @@ // found in the LICENSE file. // This is an implementation of a "true" variant class in C++. -// The chromeos::Any class can hold any C++ type, but both the setter and +// The brillo::Any class can hold any C++ type, but both the setter and // getter sites need to know the actual type of data. // Note that C-style arrays when stored in Any are reduced to simple // data pointers. Any will not copy a contents of the array. // const int data[] = [1,2,3]; // Any v(data); // stores const int*, effectively "Any v(&data[0]);" -// chromeos::Any is a value type. Which means, the data is copied into it +// brillo::Any is a value type. Which means, the data is copied into it // and Any owns it. The owned object (stored by value) will be destroyed // when Any is cleared or reassigned. The contained value type must be // copy-constructible. You can also store pointers and references to objects. @@ -20,23 +20,23 @@ // will be std::reference_wrapper<T>. See 'References' unit tests in // any_unittest.cc for examples. -#ifndef LIBCHROMEOS_CHROMEOS_ANY_H_ -#define LIBCHROMEOS_CHROMEOS_ANY_H_ +#ifndef LIBCHROMEOS_BRILLO_ANY_H_ +#define LIBCHROMEOS_BRILLO_ANY_H_ -#include <chromeos/any_internal_impl.h> +#include <brillo/any_internal_impl.h> #include <algorithm> -#include <chromeos/chromeos_export.h> -#include <chromeos/type_name_undecorate.h> +#include <brillo/brillo_export.h> +#include <brillo/type_name_undecorate.h> namespace dbus { class MessageWriter; } // namespace dbus -namespace chromeos { +namespace brillo { -class CHROMEOS_EXPORT Any final { +class BRILLO_EXPORT Any final { public: Any(); // Do not inline to hide internal_details::Buffer from export table. // Standard copy/move constructors. This is a value-class container @@ -191,15 +191,15 @@ class CHROMEOS_EXPORT Any final { internal_details::Buffer data_buffer_; }; -} // namespace chromeos +} // namespace brillo namespace std { -// Specialize std::swap() algorithm for chromeos::Any class. -inline void swap(chromeos::Any& lhs, chromeos::Any& rhs) { +// Specialize std::swap() algorithm for brillo::Any class. +inline void swap(brillo::Any& lhs, brillo::Any& rhs) { lhs.Swap(rhs); } } // namespace std -#endif // LIBCHROMEOS_CHROMEOS_ANY_H_ +#endif // LIBCHROMEOS_BRILLO_ANY_H_ diff --git a/chromeos/any_internal_impl.h b/brillo/any_internal_impl.h index dc4265a..932f0ee 100644 --- a/chromeos/any_internal_impl.h +++ b/brillo/any_internal_impl.h @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Internal implementation of chromeos::Any class. +// Internal implementation of brillo::Any class. -#ifndef LIBCHROMEOS_CHROMEOS_ANY_INTERNAL_IMPL_H_ -#define LIBCHROMEOS_CHROMEOS_ANY_INTERNAL_IMPL_H_ +#ifndef LIBCHROMEOS_BRILLO_ANY_INTERNAL_IMPL_H_ +#define LIBCHROMEOS_BRILLO_ANY_INTERNAL_IMPL_H_ #include <type_traits> #include <typeinfo> #include <utility> #include <base/logging.h> -#include <chromeos/dbus/data_serialization.h> -#include <chromeos/type_name_undecorate.h> +#include <brillo/dbus/data_serialization.h> +#include <brillo/type_name_undecorate.h> -namespace chromeos { +namespace brillo { namespace internal_details { @@ -182,7 +182,7 @@ struct TypedData : public Data { template<typename U> static typename std::enable_if<dbus_utils::IsTypeSupported<U>::value>::type AppendValueHelper(dbus::MessageWriter* writer, const U& value) { - chromeos::dbus_utils::AppendValueToWriterAsVariant(writer, value); + brillo::dbus_utils::AppendValueToWriterAsVariant(writer, value); } template<typename U> static typename std::enable_if<!dbus_utils::IsTypeSupported<U>::value>::type @@ -368,6 +368,6 @@ void TypedData<T>::MoveTo(Buffer* buffer) { } // namespace internal_details -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_ANY_INTERNAL_IMPL_H_ +#endif // LIBCHROMEOS_BRILLO_ANY_INTERNAL_IMPL_H_ diff --git a/chromeos/any_internal_impl_unittest.cc b/brillo/any_internal_impl_unittest.cc index da27020..e782cd0 100644 --- a/chromeos/any_internal_impl_unittest.cc +++ b/brillo/any_internal_impl_unittest.cc @@ -4,10 +4,10 @@ #include <string> -#include <chromeos/any.h> +#include <brillo/any.h> #include <gtest/gtest.h> -using chromeos::internal_details::Buffer; +using brillo::internal_details::Buffer; TEST(Buffer, Empty) { Buffer buffer; diff --git a/chromeos/any_unittest.cc b/brillo/any_unittest.cc index a1114d9..4fd23d7 100644 --- a/chromeos/any_unittest.cc +++ b/brillo/any_unittest.cc @@ -7,10 +7,10 @@ #include <string> #include <vector> -#include <chromeos/any.h> +#include <brillo/any.h> #include <gtest/gtest.h> -using chromeos::Any; +using brillo::Any; TEST(Any, Empty) { Any val; diff --git a/chromeos/asynchronous_signal_handler.cc b/brillo/asynchronous_signal_handler.cc index 4d188c7..b8ec529 100644 --- a/chromeos/asynchronous_signal_handler.cc +++ b/brillo/asynchronous_signal_handler.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/asynchronous_signal_handler.h" +#include "brillo/asynchronous_signal_handler.h" #include <signal.h> #include <sys/types.h> @@ -18,7 +18,7 @@ namespace { const int kInvalidDescriptor = -1; } // namespace -namespace chromeos { +namespace brillo { AsynchronousSignalHandler::AsynchronousSignalHandler() : descriptor_(kInvalidDescriptor) { @@ -105,4 +105,4 @@ void AsynchronousSignalHandler::UpdateSignals() { } } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/asynchronous_signal_handler.h b/brillo/asynchronous_signal_handler.h index 4127c11..8205cd6 100644 --- a/chromeos/asynchronous_signal_handler.h +++ b/brillo/asynchronous_signal_handler.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_ASYNCHRONOUS_SIGNAL_HANDLER_H_ -#define LIBCHROMEOS_CHROMEOS_ASYNCHRONOUS_SIGNAL_HANDLER_H_ +#ifndef LIBCHROMEOS_BRILLO_ASYNCHRONOUS_SIGNAL_HANDLER_H_ +#define LIBCHROMEOS_BRILLO_ASYNCHRONOUS_SIGNAL_HANDLER_H_ #include <signal.h> #include <sys/signalfd.h> @@ -15,15 +15,15 @@ #include <base/macros.h> #include <base/memory/scoped_ptr.h> #include <base/message_loop/message_loop.h> -#include <chromeos/asynchronous_signal_handler_interface.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/message_loops/message_loop.h> +#include <brillo/asynchronous_signal_handler_interface.h> +#include <brillo/brillo_export.h> +#include <brillo/message_loops/message_loop.h> -namespace chromeos { +namespace brillo { // Sets up signal handlers for registered signals, and converts signal receipt // into a write on a pipe. Watches that pipe for data and, when some appears, // execute the associated callback. -class CHROMEOS_EXPORT AsynchronousSignalHandler final : +class BRILLO_EXPORT AsynchronousSignalHandler final : public AsynchronousSignalHandlerInterface { public: AsynchronousSignalHandler(); @@ -62,14 +62,14 @@ class CHROMEOS_EXPORT AsynchronousSignalHandler final : // Resets the given signal to its default behavior. Doesn't touch // |registered_callbacks_|. - CHROMEOS_PRIVATE void ResetSignal(int signal); + BRILLO_PRIVATE void ResetSignal(int signal); // Updates the set of signals that this handler listens to. - CHROMEOS_PRIVATE void UpdateSignals(); + BRILLO_PRIVATE void UpdateSignals(); DISALLOW_COPY_AND_ASSIGN(AsynchronousSignalHandler); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_ASYNCHRONOUS_SIGNAL_HANDLER_H_ +#endif // LIBCHROMEOS_BRILLO_ASYNCHRONOUS_SIGNAL_HANDLER_H_ diff --git a/chromeos/asynchronous_signal_handler_interface.h b/brillo/asynchronous_signal_handler_interface.h index 51e90c5..300d975 100644 --- a/chromeos/asynchronous_signal_handler_interface.h +++ b/brillo/asynchronous_signal_handler_interface.h @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_ASYNCHRONOUS_SIGNAL_HANDLER_INTERFACE_H_ -#define LIBCHROMEOS_CHROMEOS_ASYNCHRONOUS_SIGNAL_HANDLER_INTERFACE_H_ +#ifndef LIBCHROMEOS_BRILLO_ASYNCHRONOUS_SIGNAL_HANDLER_INTERFACE_H_ +#define LIBCHROMEOS_BRILLO_ASYNCHRONOUS_SIGNAL_HANDLER_INTERFACE_H_ #include <sys/signalfd.h> #include <base/callback.h> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> -namespace chromeos { +namespace brillo { // Sets up signal handlers for registered signals, and converts signal receipt // into a write on a pipe. Watches that pipe for data and, when some appears, // execute the associated callback. -class CHROMEOS_EXPORT AsynchronousSignalHandlerInterface { +class BRILLO_EXPORT AsynchronousSignalHandlerInterface { public: virtual ~AsynchronousSignalHandlerInterface() = default; @@ -37,6 +37,6 @@ class CHROMEOS_EXPORT AsynchronousSignalHandlerInterface { virtual void UnregisterHandler(int signal) = 0; }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_ASYNCHRONOUS_SIGNAL_HANDLER_INTERFACE_H_ +#endif // LIBCHROMEOS_BRILLO_ASYNCHRONOUS_SIGNAL_HANDLER_INTERFACE_H_ diff --git a/chromeos/asynchronous_signal_handler_unittest.cc b/brillo/asynchronous_signal_handler_unittest.cc index 949b02a..ec3b061 100644 --- a/chromeos/asynchronous_signal_handler_unittest.cc +++ b/brillo/asynchronous_signal_handler_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/asynchronous_signal_handler.h" +#include "brillo/asynchronous_signal_handler.h" #include <signal.h> #include <sys/types.h> @@ -14,10 +14,10 @@ #include <base/macros.h> #include <base/message_loop/message_loop.h> #include <base/run_loop.h> -#include <chromeos/message_loops/base_message_loop.h> +#include <brillo/message_loops/base_message_loop.h> #include <gtest/gtest.h> -namespace chromeos { +namespace brillo { class AsynchronousSignalHandlerTest : public ::testing::Test { public: @@ -25,7 +25,7 @@ class AsynchronousSignalHandlerTest : public ::testing::Test { virtual ~AsynchronousSignalHandlerTest() {} virtual void SetUp() { - chromeos_loop_.SetAsCurrent(); + brillo_loop_.SetAsCurrent(); handler_.Init(); } @@ -33,13 +33,13 @@ class AsynchronousSignalHandlerTest : public ::testing::Test { bool RecordInfoAndQuit(bool response, const struct signalfd_siginfo& info) { infos_.push_back(info); - chromeos_loop_.PostTask(FROM_HERE, chromeos_loop_.QuitClosure()); + brillo_loop_.PostTask(FROM_HERE, brillo_loop_.QuitClosure()); return response; } protected: base::MessageLoopForIO base_loop_; - BaseMessageLoop chromeos_loop_{&base_loop_}; + BaseMessageLoop brillo_loop_{&base_loop_}; std::vector<struct signalfd_siginfo> infos_; AsynchronousSignalHandler handler_; @@ -81,10 +81,10 @@ TEST_F(AsynchronousSignalHandlerTest, CheckSignalUnregistration) { EXPECT_EQ(0, kill(getpid(), SIGCHLD)); // Run the loop with a timeout, as no message are expected. - chromeos_loop_.PostDelayedTask(FROM_HERE, - base::Bind(&MessageLoop::BreakLoop, - base::Unretained(&chromeos_loop_)), - base::TimeDelta::FromMilliseconds(10)); + brillo_loop_.PostDelayedTask(FROM_HERE, + base::Bind(&MessageLoop::BreakLoop, + base::Unretained(&brillo_loop_)), + base::TimeDelta::FromMilliseconds(10)); MessageLoop::current()->Run(); // The signal handle should have been unregistered. No new message are @@ -135,4 +135,4 @@ TEST_F(AsynchronousSignalHandlerTest, CheckChld) { EXPECT_EQ(EXIT_SUCCESS, infos_[0].ssi_status); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/backoff_entry.cc b/brillo/backoff_entry.cc index f3cb1a8..acef714 100644 --- a/chromeos/backoff_entry.cc +++ b/brillo/backoff_entry.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/backoff_entry.h> +#include <brillo/backoff_entry.h> #include <algorithm> #include <cmath> @@ -12,7 +12,7 @@ #include <base/numerics/safe_math.h> #include <base/rand_util.h> -namespace chromeos { +namespace brillo { BackoffEntry::BackoffEntry(const BackoffEntry::Policy* const policy) : policy_(policy) { @@ -164,4 +164,4 @@ base::TimeTicks BackoffEntry::CalculateReleaseTime() const { exponential_backoff_release_time_); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/backoff_entry.h b/brillo/backoff_entry.h index aeace00..ff9872b 100644 --- a/chromeos/backoff_entry.h +++ b/brillo/backoff_entry.h @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_BACKOFF_ENTRY_H_ -#define LIBCHROMEOS_CHROMEOS_BACKOFF_ENTRY_H_ +#ifndef LIBCHROMEOS_BRILLO_BACKOFF_ENTRY_H_ +#define LIBCHROMEOS_BRILLO_BACKOFF_ENTRY_H_ #include <base/time/time.h> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> -namespace chromeos { +namespace brillo { // Provides the core logic needed for randomized exponential back-off // on requests to a given resource, given a back-off policy. @@ -16,7 +16,7 @@ namespace chromeos { // This class is largely taken from net/base/backoff_entry.h from Chromium. // TODO(avakulenko): Consider packaging portions of Chrome's //net functionality // into the current libchrome library. -class CHROMEOS_EXPORT BackoffEntry { +class BRILLO_EXPORT BackoffEntry { public: // The set of parameters that define a back-off policy. struct Policy { @@ -110,6 +110,6 @@ class CHROMEOS_EXPORT BackoffEntry { DISALLOW_COPY_AND_ASSIGN(BackoffEntry); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_BACKOFF_ENTRY_H_ +#endif // LIBCHROMEOS_BRILLO_BACKOFF_ENTRY_H_ diff --git a/chromeos/backoff_entry_unittest.cc b/brillo/backoff_entry_unittest.cc index 27f181a..dcfa0b2 100644 --- a/chromeos/backoff_entry_unittest.cc +++ b/brillo/backoff_entry_unittest.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/backoff_entry.h> +#include <brillo/backoff_entry.h> #include <gtest/gtest.h> using base::TimeDelta; using base::TimeTicks; -namespace chromeos { +namespace brillo { BackoffEntry::Policy base_policy = { 0, 1000, 2.0, 0.0, 20000, 2000, false }; @@ -299,9 +299,9 @@ TEST(BackoffEntryTest, OverflowProtection) { // to represent the exponential backoff intermediate values. Given a multiply // factor of 256 (2^8), 129 iterations is enough: 2^(8*(129-1)) = 2^1024. for (int i = 0; i < 129; ++i) { - custom.set_now(custom.ImplGetTimeNow() + custom.GetTimeUntilRelease()); - custom.InformOfRequest(false); - ASSERT_TRUE(custom.ShouldRejectRequest()); + custom.set_now(custom.ImplGetTimeNow() + custom.GetTimeUntilRelease()); + custom.InformOfRequest(false); + ASSERT_TRUE(custom.ShouldRejectRequest()); } // Max delay should still be respected. diff --git a/chromeos/bind_lambda.h b/brillo/bind_lambda.h index 27b4d4e..7ae692d 100644 --- a/chromeos/bind_lambda.h +++ b/brillo/bind_lambda.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_BIND_LAMBDA_H_ -#define LIBCHROMEOS_CHROMEOS_BIND_LAMBDA_H_ +#ifndef LIBCHROMEOS_BRILLO_BIND_LAMBDA_H_ +#define LIBCHROMEOS_BRILLO_BIND_LAMBDA_H_ #include <base/bind.h> @@ -60,4 +60,4 @@ class RunnableAdapter } // namespace internal } // namespace base -#endif // LIBCHROMEOS_CHROMEOS_BIND_LAMBDA_H_ +#endif // LIBCHROMEOS_BRILLO_BIND_LAMBDA_H_ diff --git a/chromeos/binder_watcher.cc b/brillo/binder_watcher.cc index 30e7754..53494bb 100644 --- a/chromeos/binder_watcher.cc +++ b/brillo/binder_watcher.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include <chromeos/binder_watcher.h> +#include <brillo/binder_watcher.h> #include <base/logging.h> #include <binder/IPCThreadState.h> @@ -23,7 +23,7 @@ using android::IPCThreadState; using android::ProcessState; -namespace chromeos { +namespace brillo { BinderWatcher::BinderWatcher() = default; @@ -55,4 +55,4 @@ void BinderWatcher::OnFileCanWriteWithoutBlocking(int fd) { NOTREACHED() << "Unexpected writable notification for FD " << fd; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/binder_watcher.h b/brillo/binder_watcher.h index 198f4f8..af74f31 100644 --- a/chromeos/binder_watcher.h +++ b/brillo/binder_watcher.h @@ -14,13 +14,13 @@ * limitations under the License. */ -#ifndef LIBCHROMEOS_CHROMEOS_BINDER_WATCHER_H_ -#define LIBCHROMEOS_CHROMEOS_BINDER_WATCHER_H_ +#ifndef LIBCHROMEOS_BRILLO_BINDER_WATCHER_H_ +#define LIBCHROMEOS_BRILLO_BINDER_WATCHER_H_ #include <base/macros.h> #include <base/message_loop/message_loop.h> -namespace chromeos { +namespace brillo { // Bridge between libbinder and base::MessageLoop. Construct at startup to make // the message loop watch for binder events and pass them to libbinder. @@ -42,6 +42,6 @@ class BinderWatcher : public base::MessageLoopForIO::Watcher { DISALLOW_COPY_AND_ASSIGN(BinderWatcher); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_BINDER_WATCHER_H_ +#endif // LIBCHROMEOS_BRILLO_BINDER_WATCHER_H_ diff --git a/chromeos/chromeos_export.h b/brillo/brillo_export.h index 8b61394..8d42f58 100644 --- a/chromeos/chromeos_export.h +++ b/brillo/brillo_export.h @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_CHROMEOS_EXPORT_H_ -#define LIBCHROMEOS_CHROMEOS_CHROMEOS_EXPORT_H_ +#ifndef LIBCHROMEOS_BRILLO_CHROMEOS_EXPORT_H_ +#define LIBCHROMEOS_BRILLO_CHROMEOS_EXPORT_H_ -// Use CHROMEOS_EXPORT attribute to decorate your classes, methods and variables +// Use BRILLO_EXPORT attribute to decorate your classes, methods and variables // that need to be exported out of libchromeos. By default, any symbol not -// explicitly marked with CHROMEOS_EXPORT attribute is not exported. +// explicitly marked with BRILLO_EXPORT attribute is not exported. -// Put CHROMEOS_EXPORT in front of methods or variables and in between the +// Put BRILLO_EXPORT in front of methods or variables and in between the // class and the tag name: /* -CHROMEOS_EXPORT void foo(); +BRILLO_EXPORT void foo(); -class CHROMEOS_EXPORT Bar { +class BRILLO_EXPORT Bar { public: void baz(); // Exported since it is a member of an exported class. }; @@ -31,20 +31,20 @@ class CHROMEOS_EXPORT Bar { // inlined by the compiler automatically and the out-of-line version will not // be exported and fail to link. Marking those inline explicitly might help. // Alternatively, exporting specific instantiation of the template could be -// used with "extern template" and combining this with CHROMEOS_EXPORT. -#define CHROMEOS_EXPORT __attribute__((__visibility__("default"))) +// used with "extern template" and combining this with BRILLO_EXPORT. +#define BRILLO_EXPORT __attribute__((__visibility__("default"))) // On occasion you might need to disable exporting a particular symbol if // you don't want the clients to see it. For example, you can explicitly // hide a member of an exported class: /* -class CHROMEOS_EXPORT Foo { +class BRILLO_EXPORT Foo { public: void bar(); // Exported since it is a member of an exported class. private: - CHROMEOS_PRIVATE void baz(); // Explicitly removed from export table. + BRILLO_PRIVATE void baz(); // Explicitly removed from export table. }; */ @@ -55,6 +55,6 @@ class CHROMEOS_EXPORT Foo { // if that private method is not exported. // So be careful with hiding members if you don't want to deal with obscure // linker errors. -#define CHROMEOS_PRIVATE __attribute__((__visibility__("hidden"))) +#define BRILLO_PRIVATE __attribute__((__visibility__("hidden"))) -#endif // LIBCHROMEOS_CHROMEOS_CHROMEOS_EXPORT_H_ +#endif // LIBCHROMEOS_BRILLO_CHROMEOS_EXPORT_H_ diff --git a/chromeos/cryptohome.cc b/brillo/cryptohome.cc index 5aa53d8..49a4a88 100644 --- a/chromeos/cryptohome.cc +++ b/brillo/cryptohome.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/cryptohome.h" +#include "brillo/cryptohome.h" #include <openssl/sha.h> #include <stdint.h> @@ -18,7 +18,7 @@ using base::FilePath; -namespace chromeos { +namespace brillo { namespace cryptohome { namespace home { @@ -139,4 +139,4 @@ void SetSystemSalt(std::string* value) { } // namespace home } // namespace cryptohome -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/cryptohome.h b/brillo/cryptohome.h index 8584507..af2097e 100644 --- a/chromeos/cryptohome.h +++ b/brillo/cryptohome.h @@ -2,60 +2,60 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_CRYPTOHOME_H_ -#define LIBCHROMEOS_CHROMEOS_CRYPTOHOME_H_ +#ifndef LIBCHROMEOS_BRILLO_CRYPTOHOME_H_ +#define LIBCHROMEOS_BRILLO_CRYPTOHOME_H_ #include <string> #include <base/files/file_path.h> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> -namespace chromeos { +namespace brillo { namespace cryptohome { namespace home { -CHROMEOS_EXPORT extern const char kGuestUserName[]; +BRILLO_EXPORT extern const char kGuestUserName[]; // Returns the common prefix under which the mount points for user homes are // created. -CHROMEOS_EXPORT base::FilePath GetUserPathPrefix(); +BRILLO_EXPORT base::FilePath GetUserPathPrefix(); // Returns the common prefix under which the mount points for root homes are // created. -CHROMEOS_EXPORT base::FilePath GetRootPathPrefix(); +BRILLO_EXPORT base::FilePath GetRootPathPrefix(); // Returns the path at which the user home for |username| will be mounted. // Returns "" for failures. -CHROMEOS_EXPORT base::FilePath GetUserPath(const std::string& username); +BRILLO_EXPORT base::FilePath GetUserPath(const std::string& username); // Returns the path at which the user home for |hashed_username| will be // mounted. Useful when you already have the username hashed. // Returns "" for failures. -CHROMEOS_EXPORT base::FilePath GetHashedUserPath( +BRILLO_EXPORT base::FilePath GetHashedUserPath( const std::string& hashed_username); // Returns the path at which the root home for |username| will be mounted. // Returns "" for failures. -CHROMEOS_EXPORT base::FilePath GetRootPath(const std::string& username); +BRILLO_EXPORT base::FilePath GetRootPath(const std::string& username); // Returns the path at which the daemon |daemon| should store per-user data. -CHROMEOS_EXPORT base::FilePath GetDaemonPath(const std::string& username, - const std::string& daemon); +BRILLO_EXPORT base::FilePath GetDaemonPath(const std::string& username, + const std::string& daemon); // Checks whether |sanitized| has the format of a sanitized username. -CHROMEOS_EXPORT bool IsSanitizedUserName(const std::string& sanitized); +BRILLO_EXPORT bool IsSanitizedUserName(const std::string& sanitized); // Returns a sanitized form of |username|. For x != y, SanitizeUserName(x) != // SanitizeUserName(y). -CHROMEOS_EXPORT std::string SanitizeUserName(const std::string& username); +BRILLO_EXPORT std::string SanitizeUserName(const std::string& username); // Overrides the common prefix under which the mount points for user homes are // created. This is used for testing only. -CHROMEOS_EXPORT void SetUserHomePrefix(const std::string& prefix); +BRILLO_EXPORT void SetUserHomePrefix(const std::string& prefix); // Overrides the common prefix under which the mount points for root homes are // created. This is used for testing only. -CHROMEOS_EXPORT void SetRootHomePrefix(const std::string& prefix); +BRILLO_EXPORT void SetRootHomePrefix(const std::string& prefix); // Overrides the contents of the system salt. // salt should be non-NULL and non-empty when attempting to avoid filesystem @@ -63,13 +63,13 @@ CHROMEOS_EXPORT void SetRootHomePrefix(const std::string& prefix); // Note: // (1) Never mix usage with SetSystemSaltPath(). // (2) Ownership of the pointer stays with the caller. -CHROMEOS_EXPORT void SetSystemSalt(std::string* salt); +BRILLO_EXPORT void SetSystemSalt(std::string* salt); // Returns the system salt. -CHROMEOS_EXPORT std::string* GetSystemSalt(); +BRILLO_EXPORT std::string* GetSystemSalt(); } // namespace home } // namespace cryptohome -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_CRYPTOHOME_H_ +#endif // LIBCHROMEOS_BRILLO_CRYPTOHOME_H_ diff --git a/chromeos/daemons/daemon.cc b/brillo/daemons/daemon.cc index a964e95..11700f1 100644 --- a/chromeos/daemons/daemon.cc +++ b/brillo/daemons/daemon.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/daemons/daemon.h> +#include <brillo/daemons/daemon.h> #include <sysexits.h> @@ -12,10 +12,10 @@ #include <base/logging.h> #include <base/run_loop.h> -namespace chromeos { +namespace brillo { Daemon::Daemon() : exit_code_{EX_OK} { - chromeos_message_loop_.SetAsCurrent(); + brillo_message_loop_.SetAsCurrent(); } Daemon::~Daemon() { @@ -26,7 +26,7 @@ int Daemon::Run() { if (exit_code != EX_OK) return exit_code; - chromeos_message_loop_.Run(); + brillo_message_loop_.Run(); OnShutdown(&exit_code_); @@ -35,7 +35,7 @@ int Daemon::Run() { // Run a secondary loop to make sure all those are processed. // This becomes important when working with D-Bus since dbus::Bus does // a bunch of clean-up tasks asynchronously when shutting down. - while (chromeos_message_loop_.RunOnce(false /* may_block */)) {} + while (brillo_message_loop_.RunOnce(false /* may_block */)) {} return exit_code_; } @@ -89,4 +89,4 @@ bool Daemon::Restart(const signalfd_siginfo& info) { return true; // Unregister the signal handler. } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/daemons/daemon.h b/brillo/daemons/daemon.h index c1b7d2b..be9c8ca 100644 --- a/chromeos/daemons/daemon.h +++ b/brillo/daemons/daemon.h @@ -2,30 +2,30 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_DAEMONS_DAEMON_H_ -#define LIBCHROMEOS_CHROMEOS_DAEMONS_DAEMON_H_ +#ifndef LIBCHROMEOS_BRILLO_DAEMONS_DAEMON_H_ +#define LIBCHROMEOS_BRILLO_DAEMONS_DAEMON_H_ #include <string> #include <base/at_exit.h> #include <base/macros.h> #include <base/message_loop/message_loop.h> -#include <chromeos/asynchronous_signal_handler.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/message_loops/base_message_loop.h> +#include <brillo/asynchronous_signal_handler.h> +#include <brillo/brillo_export.h> +#include <brillo/message_loops/base_message_loop.h> struct signalfd_siginfo; -namespace chromeos { +namespace brillo { // Daemon is a simple base class for system daemons. It provides a lot // of useful facilities such as a message loop, handling of SIGTERM, SIGINT, and // SIGHUP system signals. // You can use this class directly to implement your daemon or you can // specialize it by creating your own class and deriving it from -// chromeos::Daemon. Override some of the virtual methods provide to fine-tune +// brillo::Daemon. Override some of the virtual methods provide to fine-tune // its behavior to suit your daemon's needs. -class CHROMEOS_EXPORT Daemon : public AsynchronousSignalHandlerInterface { +class BRILLO_EXPORT Daemon : public AsynchronousSignalHandlerInterface { public: Daemon(); virtual ~Daemon(); @@ -100,7 +100,7 @@ class CHROMEOS_EXPORT Daemon : public AsynchronousSignalHandlerInterface { base::AtExitManager at_exit_manager_; // The main message loop for the daemon. base::MessageLoopForIO message_loop_; - // The chromeos wrapper for the main message loop. + // The brillo wrapper for the main message loop. BaseMessageLoop chromeos_message_loop_{&message_loop_}; // A helper to dispatch signal handlers asynchronously, so that the main // system signal handler returns as soon as possible. @@ -111,6 +111,6 @@ class CHROMEOS_EXPORT Daemon : public AsynchronousSignalHandlerInterface { DISALLOW_COPY_AND_ASSIGN(Daemon); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DAEMONS_DAEMON_H_ +#endif // LIBCHROMEOS_BRILLO_DAEMONS_DAEMON_H_ diff --git a/chromeos/daemons/dbus_daemon.cc b/brillo/daemons/dbus_daemon.cc index c5d1ca9..ebbfd94 100644 --- a/chromeos/daemons/dbus_daemon.cc +++ b/brillo/daemons/dbus_daemon.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/daemons/dbus_daemon.h> +#include <brillo/daemons/dbus_daemon.h> #include <sysexits.h> #include <base/bind.h> -#include <chromeos/dbus/async_event_sequencer.h> -#include <chromeos/dbus/exported_object_manager.h> +#include <brillo/dbus/async_event_sequencer.h> +#include <brillo/dbus/exported_object_manager.h> -using chromeos::dbus_utils::AsyncEventSequencer; -using chromeos::dbus_utils::ExportedObjectManager; +using brillo::dbus_utils::AsyncEventSequencer; +using brillo::dbus_utils::ExportedObjectManager; -namespace chromeos { +namespace brillo { DBusDaemon::DBusDaemon() { } @@ -87,4 +87,4 @@ void DBusServiceDaemon::TakeServiceOwnership(bool success) { << "Unable to take ownership of " << service_name_; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/daemons/dbus_daemon.h b/brillo/daemons/dbus_daemon.h index 2f08dfa..c2352c1 100644 --- a/chromeos/daemons/dbus_daemon.h +++ b/brillo/daemons/dbus_daemon.h @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_DAEMONS_DBUS_DAEMON_H_ -#define LIBCHROMEOS_CHROMEOS_DAEMONS_DBUS_DAEMON_H_ +#ifndef LIBCHROMEOS_BRILLO_DAEMONS_DBUS_DAEMON_H_ +#define LIBCHROMEOS_BRILLO_DAEMONS_DBUS_DAEMON_H_ #include <memory> #include <string> #include <base/strings/string_piece.h> #include <base/memory/ref_counted.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/daemons/daemon.h> -#include <chromeos/dbus/exported_object_manager.h> +#include <brillo/brillo_export.h> +#include <brillo/daemons/daemon.h> +#include <brillo/dbus/exported_object_manager.h> #include <dbus/bus.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { class AsyncEventSequencer; @@ -24,7 +24,7 @@ class AsyncEventSequencer; // DBusDaemon adds D-Bus support to Daemon. // Derive your daemon from this class if you want D-Bus client services in your // daemon (consuming other D-Bus objects). Currently uses a SYSTEM bus. -class CHROMEOS_EXPORT DBusDaemon : public Daemon { +class BRILLO_EXPORT DBusDaemon : public Daemon { public: DBusDaemon(); ~DBusDaemon() override; @@ -44,7 +44,7 @@ class CHROMEOS_EXPORT DBusDaemon : public Daemon { // Derive your daemon from this class if your daemon exposes D-Bus objects. // Provides an ExportedObjectManager to announce your object/interface creation // and destruction. -class CHROMEOS_EXPORT DBusServiceDaemon : public DBusDaemon { +class BRILLO_EXPORT DBusServiceDaemon : public DBusDaemon { public: // Constructs the daemon. // |service_name| is the name of D-Bus service provided by the daemon. @@ -83,6 +83,6 @@ class CHROMEOS_EXPORT DBusServiceDaemon : public DBusDaemon { DISALLOW_COPY_AND_ASSIGN(DBusServiceDaemon); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DAEMONS_DBUS_DAEMON_H_ +#endif // LIBCHROMEOS_BRILLO_DAEMONS_DBUS_DAEMON_H_ diff --git a/chromeos/data_encoding.cc b/brillo/data_encoding.cc index 7d6b6c3..f3e95f8 100644 --- a/chromeos/data_encoding.cc +++ b/brillo/data_encoding.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/data_encoding.h> +#include <brillo/data_encoding.h> #include <modp_b64/modp_b64.h> #include <memory> @@ -10,7 +10,7 @@ #include <base/logging.h> #include <base/strings/string_util.h> #include <base/strings/stringprintf.h> -#include <chromeos/strings/string_utils.h> +#include <brillo/strings/string_utils.h> namespace { @@ -39,7 +39,7 @@ std::string Base64EncodeHelper(const void* data, size_t size) { } // namespace ///////////////////////////////////////////////////////////////////////// -namespace chromeos { +namespace brillo { namespace data_encoding { std::string UrlEncode(const char* data, bool encodeSpaceAsPlus) { @@ -93,17 +93,17 @@ std::string WebParamsEncode(const WebParamList& params, for (const auto& p : params) { std::string key = UrlEncode(p.first.c_str(), encodeSpaceAsPlus); std::string value = UrlEncode(p.second.c_str(), encodeSpaceAsPlus); - pairs.push_back(chromeos::string_utils::Join("=", key, value)); + pairs.push_back(brillo::string_utils::Join("=", key, value)); } - return chromeos::string_utils::Join("&", pairs); + return brillo::string_utils::Join("&", pairs); } WebParamList WebParamsDecode(const std::string& data) { WebParamList result; - std::vector<std::string> params = chromeos::string_utils::Split(data, "&"); + std::vector<std::string> params = brillo::string_utils::Split(data, "&"); for (const auto& p : params) { - auto pair = chromeos::string_utils::SplitAtFirst(p, "="); + auto pair = brillo::string_utils::SplitAtFirst(p, "="); result.emplace_back(UrlDecode(pair.first.c_str()), UrlDecode(pair.second.c_str())); } @@ -125,7 +125,7 @@ std::string Base64EncodeWrapLines(const void* data, size_t size) { return wrapped; } -bool Base64Decode(const std::string& input, chromeos::Blob* output) { +bool Base64Decode(const std::string& input, brillo::Blob* output) { std::string temp_buffer; const std::string* data = &input; if (input.find_first_of("\r\n") != std::string::npos) { @@ -151,4 +151,4 @@ bool Base64Decode(const std::string& input, chromeos::Blob* output) { } } // namespace data_encoding -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/data_encoding.h b/brillo/data_encoding.h index 4332c62..d850f39 100644 --- a/chromeos/data_encoding.h +++ b/brillo/data_encoding.h @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_DATA_ENCODING_H_ -#define LIBCHROMEOS_CHROMEOS_DATA_ENCODING_H_ +#ifndef LIBCHROMEOS_BRILLO_DATA_ENCODING_H_ +#define LIBCHROMEOS_BRILLO_DATA_ENCODING_H_ #include <string> #include <utility> #include <vector> -#include <chromeos/chromeos_export.h> -#include <chromeos/secure_blob.h> +#include <brillo/brillo_export.h> +#include <brillo/secure_blob.h> -namespace chromeos { +namespace brillo { namespace data_encoding { using WebParamList = std::vector<std::pair<std::string, std::string>>; @@ -20,7 +20,7 @@ using WebParamList = std::vector<std::pair<std::string, std::string>>; // Encode/escape string to be used in the query portion of a URL. // If |encodeSpaceAsPlus| is set to true, spaces are encoded as '+' instead // of "%20" -CHROMEOS_EXPORT std::string UrlEncode(const char* data, bool encodeSpaceAsPlus); +BRILLO_EXPORT std::string UrlEncode(const char* data, bool encodeSpaceAsPlus); inline std::string UrlEncode(const char* data) { return UrlEncode(data, true); @@ -28,12 +28,12 @@ inline std::string UrlEncode(const char* data) { // Decodes/unescapes a URL. Replaces all %XX sequences with actual characters. // Also replaces '+' with spaces. -CHROMEOS_EXPORT std::string UrlDecode(const char* data); +BRILLO_EXPORT std::string UrlDecode(const char* data); // Converts a list of key-value pairs into a string compatible with // 'application/x-www-form-urlencoded' content encoding. -CHROMEOS_EXPORT std::string WebParamsEncode(const WebParamList& params, - bool encodeSpaceAsPlus); +BRILLO_EXPORT std::string WebParamsEncode(const WebParamList& params, + bool encodeSpaceAsPlus); inline std::string WebParamsEncode(const WebParamList& params) { return WebParamsEncode(params, true); @@ -42,26 +42,24 @@ inline std::string WebParamsEncode(const WebParamList& params) { // Parses a string of '&'-delimited key-value pairs (separated by '=') and // encoded in a way compatible with 'application/x-www-form-urlencoded' // content encoding. -CHROMEOS_EXPORT WebParamList WebParamsDecode(const std::string& data); +BRILLO_EXPORT WebParamList WebParamsDecode(const std::string& data); // Encodes binary data using base64-encoding. -CHROMEOS_EXPORT std::string Base64Encode(const void* data, size_t size); +BRILLO_EXPORT std::string Base64Encode(const void* data, size_t size); // Encodes binary data using base64-encoding and wraps lines at 64 character // boundary using LF as required by PEM (RFC 1421) specification. -CHROMEOS_EXPORT std::string Base64EncodeWrapLines(const void* data, - size_t size); +BRILLO_EXPORT std::string Base64EncodeWrapLines(const void* data, size_t size); // Decodes the input string from Base64. -CHROMEOS_EXPORT bool Base64Decode(const std::string& input, - chromeos::Blob* output); +BRILLO_EXPORT bool Base64Decode(const std::string& input, brillo::Blob* output); -// Helper wrappers to use std::string and chromeos::Blob as binary data +// Helper wrappers to use std::string and brillo::Blob as binary data // containers. -inline std::string Base64Encode(const chromeos::Blob& input) { +inline std::string Base64Encode(const brillo::Blob& input) { return Base64Encode(input.data(), input.size()); } -inline std::string Base64EncodeWrapLines(const chromeos::Blob& input) { +inline std::string Base64EncodeWrapLines(const brillo::Blob& input) { return Base64EncodeWrapLines(input.data(), input.size()); } inline std::string Base64Encode(const std::string& input) { @@ -71,7 +69,7 @@ inline std::string Base64EncodeWrapLines(const std::string& input) { return Base64EncodeWrapLines(input.data(), input.size()); } inline bool Base64Decode(const std::string& input, std::string* output) { - chromeos::Blob blob; + brillo::Blob blob; if (!Base64Decode(input, &blob)) return false; *output = std::string{blob.begin(), blob.end()}; @@ -79,6 +77,6 @@ inline bool Base64Decode(const std::string& input, std::string* output) { } } // namespace data_encoding -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DATA_ENCODING_H_ +#endif // LIBCHROMEOS_BRILLO_DATA_ENCODING_H_ diff --git a/chromeos/data_encoding_unittest.cc b/brillo/data_encoding_unittest.cc index 70bd748..cb73da6 100644 --- a/chromeos/data_encoding_unittest.cc +++ b/brillo/data_encoding_unittest.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/data_encoding.h> +#include <brillo/data_encoding.h> #include <algorithm> #include <numeric> #include <gtest/gtest.h> -namespace chromeos { +namespace brillo { namespace data_encoding { TEST(data_encoding, UrlEncoding) { @@ -53,7 +53,7 @@ TEST(data_encoding, Base64Encode) { "RlZ2VyIGVyYXQgaXBzdW0sIGludGVnZXIgbW9sZXN0aWUsIGFyY3UgaW4sIHNpdCBtYXVya" "XMgYWMgYSBzZWQgc2l0IGV0aWFtLg=="; - chromeos::Blob data3(256); + brillo::Blob data3(256); std::iota(data3.begin(), data3.end(), 0); // Fills the buffer with 0x00-0xFF. const std::string encoded3 = "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ" @@ -81,7 +81,7 @@ TEST(data_encoding, Base64EncodeWrapLines) { "bmNpZHVudCBpbnRlZ2VyIGVyYXQgaXBzdW0sIGludGVnZXIgbW9sZXN0aWUsIGFy\n" "Y3UgaW4sIHNpdCBtYXVyaXMgYWMgYSBzZWQgc2l0IGV0aWFtLg==\n"; - chromeos::Blob data3(256); + brillo::Blob data3(256); std::iota(data3.begin(), data3.end(), 0); // Fills the buffer with 0x00-0xFF. const std::string encoded3 = "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4v\n" @@ -116,7 +116,7 @@ TEST(data_encoding, Base64Decode) { "prbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en" "6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU" "1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="; - chromeos::Blob decoded3(256); + brillo::Blob decoded3(256); std::iota(decoded3.begin(), decoded3.end(), 0); // Fill with 0x00..0xFF. std::string decoded; @@ -126,7 +126,7 @@ TEST(data_encoding, Base64Decode) { EXPECT_TRUE(Base64Decode(encoded2, &decoded)); EXPECT_EQ(decoded2, decoded); - chromeos::Blob decoded_blob; + brillo::Blob decoded_blob; EXPECT_TRUE(Base64Decode(encoded3, &decoded_blob)); EXPECT_EQ(decoded3, decoded_blob); @@ -134,14 +134,14 @@ TEST(data_encoding, Base64Decode) { EXPECT_TRUE(decoded_blob.empty()); EXPECT_TRUE(Base64Decode("/w==", &decoded_blob)); - EXPECT_EQ((chromeos::Blob{0xFF}), decoded_blob); + EXPECT_EQ((brillo::Blob{0xFF}), decoded_blob); EXPECT_TRUE(Base64Decode("//8=", &decoded_blob)); - EXPECT_EQ((chromeos::Blob{0xFF, 0xFF}), decoded_blob); + EXPECT_EQ((brillo::Blob{0xFF, 0xFF}), decoded_blob); EXPECT_FALSE(Base64Decode("AAECAwQFB,cI", &decoded_blob)); EXPECT_TRUE(decoded_blob.empty()); } } // namespace data_encoding -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/async_event_sequencer.cc b/brillo/dbus/async_event_sequencer.cc index 741bd67..862aa30 100644 --- a/chromeos/dbus/async_event_sequencer.cc +++ b/brillo/dbus/async_event_sequencer.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/async_event_sequencer.h> +#include <brillo/dbus/async_event_sequencer.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { @@ -128,4 +128,4 @@ void AsyncEventSequencer::PossiblyRunCompletionActions() { } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/async_event_sequencer.h b/brillo/dbus/async_event_sequencer.h index f555c82..719c9ad 100644 --- a/chromeos/dbus/async_event_sequencer.h +++ b/brillo/dbus/async_event_sequencer.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_ASYNC_EVENT_SEQUENCER_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_ASYNC_EVENT_SEQUENCER_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_ASYNC_EVENT_SEQUENCER_H_ +#define LIBCHROMEOS_BRILLO_DBUS_ASYNC_EVENT_SEQUENCER_H_ #include <set> #include <string> @@ -12,9 +12,9 @@ #include <base/bind.h> #include <base/macros.h> #include <base/memory/ref_counted.h> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { @@ -35,7 +35,7 @@ namespace dbus_utils { // "another delegate is flaky", false)); // sequencer->OnAllTasksCompletedCall({cb}); // } -class CHROMEOS_EXPORT AsyncEventSequencer +class BRILLO_EXPORT AsyncEventSequencer : public base::RefCounted<AsyncEventSequencer> { public: using Handler = base::Callback<void(bool success)>; @@ -77,23 +77,23 @@ class CHROMEOS_EXPORT AsyncEventSequencer // GetHandler. Note that the returned callbacks have // references to *this, which gives us the neat property that we'll // destroy *this only when all our callbacks have been destroyed. - CHROMEOS_PRIVATE void HandleFinish(int registration_number, - const std::string& error_message, - bool failure_is_fatal, - bool success); + BRILLO_PRIVATE void HandleFinish(int registration_number, + const std::string& error_message, + bool failure_is_fatal, + bool success); // Similar to HandleFinish. - CHROMEOS_PRIVATE void HandleDBusMethodExported( + BRILLO_PRIVATE void HandleDBusMethodExported( const Handler& finish_handler, const std::string& expected_interface_name, const std::string& expected_method_name, const std::string& actual_interface_name, const std::string& actual_method_name, bool success); - CHROMEOS_PRIVATE void RetireRegistration(int registration_number); - CHROMEOS_PRIVATE void CheckForFailure(bool failure_is_fatal, - bool success, - const std::string& error_message); - CHROMEOS_PRIVATE void PossiblyRunCompletionActions(); + BRILLO_PRIVATE void RetireRegistration(int registration_number); + BRILLO_PRIVATE void CheckForFailure(bool failure_is_fatal, + bool success, + const std::string& error_message); + BRILLO_PRIVATE void PossiblyRunCompletionActions(); bool started_{false}; int registration_counter_{0}; @@ -108,6 +108,6 @@ class CHROMEOS_EXPORT AsyncEventSequencer } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_ASYNC_EVENT_SEQUENCER_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_ASYNC_EVENT_SEQUENCER_H_ diff --git a/chromeos/dbus/async_event_sequencer_unittest.cc b/brillo/dbus/async_event_sequencer_unittest.cc index 91e39cc..5f4c0e2 100644 --- a/chromeos/dbus/async_event_sequencer_unittest.cc +++ b/brillo/dbus/async_event_sequencer_unittest.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/async_event_sequencer.h> +#include <brillo/dbus/async_event_sequencer.h> #include <base/bind_helpers.h> #include <gmock/gmock.h> #include <gtest/gtest.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { @@ -93,4 +93,4 @@ TEST_F(AsyncEventSequencerTest, MixedActions) { } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/data_serialization.cc b/brillo/dbus/data_serialization.cc index f57697b..5c1d50e 100644 --- a/chromeos/dbus/data_serialization.cc +++ b/brillo/dbus/data_serialization.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/data_serialization.h> +#include <brillo/dbus/data_serialization.h> #include <base/logging.h> -#include <chromeos/any.h> -#include <chromeos/variant_dictionary.h> +#include <brillo/any.h> +#include <brillo/variant_dictionary.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { void AppendValueToWriter(dbus::MessageWriter* writer, bool value) { @@ -67,7 +67,7 @@ void AppendValueToWriter(dbus::MessageWriter* writer, } void AppendValueToWriter(dbus::MessageWriter* writer, - const chromeos::Any& value) { + const brillo::Any& value) { value.AppendToDBusMessageWriter(writer); } @@ -156,7 +156,7 @@ namespace { // it to |value| of type Any. template<typename T> bool PopTypedValueFromReader(dbus::MessageReader* reader, - chromeos::Any* value) { + brillo::Any* value) { T data{}; if (!PopValueFromReader(reader, &data)) return false; @@ -167,13 +167,13 @@ bool PopTypedValueFromReader(dbus::MessageReader* reader, // std::vector<T> overload. template<typename T> bool PopTypedArrayFromReader(dbus::MessageReader* reader, - chromeos::Any* value) { + brillo::Any* value) { return PopTypedValueFromReader<std::vector<T>>(reader, value); } // std::map<KEY, VALUE> overload. template<typename KEY, typename VALUE> -bool PopTypedMapFromReader(dbus::MessageReader* reader, chromeos::Any* value) { +bool PopTypedMapFromReader(dbus::MessageReader* reader, brillo::Any* value) { return PopTypedValueFromReader<std::map<KEY, VALUE>>(reader, value); } @@ -181,7 +181,7 @@ bool PopTypedMapFromReader(dbus::MessageReader* reader, chromeos::Any* value) { // Note that only common types are supported. If an additional specific // type signature is required, feel free to add support for it. bool PopArrayValueFromReader(dbus::MessageReader* reader, - chromeos::Any* value) { + brillo::Any* value) { std::string signature = reader->GetDataSignature(); if (signature == "ab") return PopTypedArrayFromReader<bool>(reader, value); @@ -206,24 +206,24 @@ bool PopArrayValueFromReader(dbus::MessageReader* reader, else if (signature == "ao") return PopTypedArrayFromReader<dbus::ObjectPath>(reader, value); else if (signature == "av") - return PopTypedArrayFromReader<chromeos::Any>(reader, value); + return PopTypedArrayFromReader<brillo::Any>(reader, value); else if (signature == "a{ss}") return PopTypedMapFromReader<std::string, std::string>(reader, value); else if (signature == "a{sv}") - return PopTypedValueFromReader<chromeos::VariantDictionary>(reader, value); + return PopTypedValueFromReader<brillo::VariantDictionary>(reader, value); else if (signature == "aa{sv}") - return PopTypedArrayFromReader<chromeos::VariantDictionary>(reader, value); + return PopTypedArrayFromReader<brillo::VariantDictionary>(reader, value); else if (signature == "a{sa{ss}}") return PopTypedMapFromReader< std::string, std::map<std::string, std::string>>(reader, value); else if (signature == "a{sa{sv}}") return PopTypedMapFromReader< - std::string, chromeos::VariantDictionary>(reader, value); + std::string, brillo::VariantDictionary>(reader, value); else if (signature == "a{say}") return PopTypedMapFromReader< std::string, std::vector<uint8_t>>(reader, value); else if (signature == "a{uv}") - return PopTypedMapFromReader<uint32_t, chromeos::Any>(reader, value); + return PopTypedMapFromReader<uint32_t, brillo::Any>(reader, value); else if (signature == "a(su)") return PopTypedArrayFromReader< std::tuple<std::string, uint32_t>>(reader, value); @@ -244,7 +244,7 @@ bool PopArrayValueFromReader(dbus::MessageReader* reader, // Note that only common types are supported. If an additional specific // type signature is required, feel free to add support for it. bool PopStructValueFromReader(dbus::MessageReader* reader, - chromeos::Any* value) { + brillo::Any* value) { std::string signature = reader->GetDataSignature(); if (signature == "(ii)") return PopTypedValueFromReader<std::tuple<int, int>>(reader, value); @@ -266,7 +266,7 @@ bool PopStructValueFromReader(dbus::MessageReader* reader, } // anonymous namespace -bool PopValueFromReader(dbus::MessageReader* reader, chromeos::Any* value) { +bool PopValueFromReader(dbus::MessageReader* reader, brillo::Any* value) { dbus::MessageReader variant_reader(nullptr); if (!details::DescendIntoVariantIfPresent(&reader, &variant_reader)) return false; @@ -307,7 +307,7 @@ bool PopValueFromReader(dbus::MessageReader* reader, chromeos::Any* value) { case dbus::Message::UNIX_FD: CHECK(dbus::IsDBusTypeUnixFdSupported()) << "UNIX_FD data not supported"; // dbus::FileDescriptor is not a copyable type. Cannot be returned via - // chromeos::Any. Fail here. + // brillo::Any. Fail here. LOG(ERROR) << "Cannot return FileDescriptor via Any"; return false; default: @@ -318,4 +318,4 @@ bool PopValueFromReader(dbus::MessageReader* reader, chromeos::Any* value) { } } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/data_serialization.h b/brillo/dbus/data_serialization.h index a039ec2..dbd96ac 100644 --- a/chromeos/dbus/data_serialization.h +++ b/brillo/dbus/data_serialization.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_DATA_SERIALIZATION_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_DATA_SERIALIZATION_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_DATA_SERIALIZATION_H_ +#define LIBCHROMEOS_BRILLO_DBUS_DATA_SERIALIZATION_H_ // The main functionality provided by this header file is methods to serialize // native C++ data over D-Bus. This includes three major parts: @@ -35,20 +35,20 @@ // STRUCT | (UV) | std::pair<U,V> // | (UVW...) | std::tuple<U,V,W,...> // DICT | a{KV} | std::map<K,V> -// VARIANT | v | chromeos::Any +// VARIANT | v | brillo::Any // UNIX_FD | h | dbus::FileDescriptor // SIGNATURE | g | (unsupported) // // Additional overloads/specialization can be provided for custom types. // In order to do that, provide overloads of AppendValueToWriter() and -// PopValueFromReader() functions in chromeos::dbus_utils namespace for the +// PopValueFromReader() functions in brillo::dbus_utils namespace for the // CustomType. As well as a template specialization of DBusType<> for the same // CustomType. This specialization must provide three static functions: // - static std::string GetSignature(); // - static void Write(dbus::MessageWriter* writer, const CustomType& value); // - static bool Read(dbus::MessageReader* reader, CustomType* value); // See an example in DBusUtils.CustomStruct unit test in -// chromeos/dbus/data_serialization_unittest.cc. +// brillo/dbus/data_serialization_unittest.cc. #include <map> #include <memory> @@ -58,8 +58,8 @@ #include <vector> #include <base/logging.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/type_name_undecorate.h> +#include <brillo/brillo_export.h> +#include <brillo/type_name_undecorate.h> #include <dbus/message.h> namespace google { @@ -68,7 +68,7 @@ class MessageLite; } // namespace protobuf } // namespace google -namespace chromeos { +namespace brillo { // Forward-declare only. Can't include any.h right now because it needs // AppendValueToWriter() declared below. @@ -183,9 +183,9 @@ inline std::string GetDBusDictEntryType() { // DBusType<T> for various C++ types that can be serialized over D-Bus. // bool ----------------------------------------------------------------------- -CHROMEOS_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, +BRILLO_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, bool value); -CHROMEOS_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, +BRILLO_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, bool* value); template<> @@ -202,9 +202,9 @@ struct DBusType<bool> { }; // uint8_t -------------------------------------------------------------------- -CHROMEOS_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, +BRILLO_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, uint8_t value); -CHROMEOS_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, +BRILLO_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, uint8_t* value); template<> @@ -219,9 +219,9 @@ struct DBusType<uint8_t> { }; // int16_t -------------------------------------------------------------------- -CHROMEOS_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, +BRILLO_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, int16_t value); -CHROMEOS_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, +BRILLO_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, int16_t* value); template<> @@ -236,9 +236,9 @@ struct DBusType<int16_t> { }; // uint16_t ------------------------------------------------------------------- -CHROMEOS_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, +BRILLO_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, uint16_t value); -CHROMEOS_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, +BRILLO_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, uint16_t* value); template<> @@ -255,9 +255,9 @@ struct DBusType<uint16_t> { }; // int32_t -------------------------------------------------------------------- -CHROMEOS_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, +BRILLO_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, int32_t value); -CHROMEOS_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, +BRILLO_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, int32_t* value); template<> @@ -272,9 +272,9 @@ struct DBusType<int32_t> { }; // uint32_t ------------------------------------------------------------------- -CHROMEOS_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, +BRILLO_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, uint32_t value); -CHROMEOS_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, +BRILLO_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, uint32_t* value); template<> @@ -291,9 +291,9 @@ struct DBusType<uint32_t> { }; // int64_t -------------------------------------------------------------------- -CHROMEOS_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, +BRILLO_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, int64_t value); -CHROMEOS_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, +BRILLO_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, int64_t* value); template<> @@ -308,9 +308,9 @@ struct DBusType<int64_t> { }; // uint64_t ------------------------------------------------------------------- -CHROMEOS_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, +BRILLO_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, uint64_t value); -CHROMEOS_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, +BRILLO_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, uint64_t* value); template<> @@ -327,9 +327,9 @@ struct DBusType<uint64_t> { }; // double --------------------------------------------------------------------- -CHROMEOS_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, +BRILLO_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, double value); -CHROMEOS_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, +BRILLO_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, double* value); template<> @@ -346,9 +346,9 @@ struct DBusType<double> { }; // std::string ---------------------------------------------------------------- -CHROMEOS_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, +BRILLO_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, const std::string& value); -CHROMEOS_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, +BRILLO_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, std::string* value); template<> @@ -366,7 +366,7 @@ struct DBusType<std::string> { }; // const char* -CHROMEOS_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, +BRILLO_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, const char* value); template<> @@ -391,9 +391,9 @@ struct DBusType<const char[]> { }; // dbus::ObjectPath ----------------------------------------------------------- -CHROMEOS_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, +BRILLO_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, const dbus::ObjectPath& value); -CHROMEOS_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, +BRILLO_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, dbus::ObjectPath* value); template<> @@ -412,9 +412,9 @@ struct DBusType<dbus::ObjectPath> { }; // dbus::FileDescriptor ------------------------------------------------------- -CHROMEOS_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, +BRILLO_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, const dbus::FileDescriptor& value); -CHROMEOS_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, +BRILLO_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, dbus::FileDescriptor* value); template<> @@ -432,22 +432,22 @@ struct DBusType<dbus::FileDescriptor> { } }; -// chromeos::Any -------------------------------------------------------------- -CHROMEOS_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, - const chromeos::Any& value); -CHROMEOS_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, - chromeos::Any* value); +// brillo::Any -------------------------------------------------------------- +BRILLO_EXPORT void AppendValueToWriter(dbus::MessageWriter* writer, + const brillo::Any& value); +BRILLO_EXPORT bool PopValueFromReader(dbus::MessageReader* reader, + brillo::Any* value); template<> -struct DBusType<chromeos::Any> { +struct DBusType<brillo::Any> { inline static std::string GetSignature() { return DBUS_TYPE_VARIANT_AS_STRING; } inline static void Write(dbus::MessageWriter* writer, - const chromeos::Any& value) { + const brillo::Any& value) { AppendValueToWriter(writer, value); } - inline static bool Read(dbus::MessageReader* reader, chromeos::Any* value) { + inline static bool Read(dbus::MessageReader* reader, brillo::Any* value) { return PopValueFromReader(reader, value); } }; @@ -850,7 +850,7 @@ AppendValueToWriterAsVariant(dbus::MessageWriter* writer, const T& value) { // Special case: do not allow to write a Variant containing a Variant. // Just redirect to normal AppendValueToWriter(). inline void AppendValueToWriterAsVariant(dbus::MessageWriter* writer, - const chromeos::Any& value) { + const brillo::Any& value) { return AppendValueToWriter(writer, value); } @@ -881,6 +881,6 @@ inline bool PopVariantValueFromReader(dbus::MessageReader* reader, Any* value) { } } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_DATA_SERIALIZATION_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_DATA_SERIALIZATION_H_ diff --git a/chromeos/dbus/data_serialization_unittest.cc b/brillo/dbus/data_serialization_unittest.cc index 953a608..879e52e 100644 --- a/chromeos/dbus/data_serialization_unittest.cc +++ b/brillo/dbus/data_serialization_unittest.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/data_serialization.h> +#include <brillo/dbus/data_serialization.h> #include <limits> -#include <chromeos/variant_dictionary.h> +#include <brillo/variant_dictionary.h> #include <gtest/gtest.h> #include "unittests/test.pb.h" @@ -18,7 +18,7 @@ using dbus::MessageWriter; using dbus::ObjectPath; using dbus::Response; -namespace chromeos { +namespace brillo { namespace dbus_utils { TEST(DBusUtils, Supported_BasicTypes) { @@ -783,4 +783,4 @@ TEST(DBusUtils, Protobuf) { } } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/dbus_method_invoker.cc b/brillo/dbus/dbus_method_invoker.cc index 4f1f28f..94002c2 100644 --- a/chromeos/dbus/dbus_method_invoker.cc +++ b/brillo/dbus/dbus_method_invoker.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/dbus_method_invoker.h> +#include <brillo/dbus/dbus_method_invoker.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { void TranslateErrorResponse(const AsyncErrorCallback& callback, @@ -20,4 +20,4 @@ void TranslateErrorResponse(const AsyncErrorCallback& callback, } } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/dbus_method_invoker.h b/brillo/dbus/dbus_method_invoker.h index aea5695..df8c3c5 100644 --- a/chromeos/dbus/dbus_method_invoker.h +++ b/brillo/dbus/dbus_method_invoker.h @@ -8,7 +8,7 @@ // CallMethodAndBlock (along with CallMethodAndBlockWithTimeout) lets you call // a D-Bus method synchronously and pass all the required parameters as C++ // function arguments. CallMethodAndBlock relies on automatic C++ to D-Bus data -// serialization implemented in chromeos/dbus/data_serialization.h. +// serialization implemented in brillo/dbus/data_serialization.h. // CallMethodAndBlock invokes the D-Bus method and returns the Response. // The method call response should be parsed with ExtractMethodCallResults(). @@ -22,10 +22,10 @@ // Here is an example of synchronous calls: // Call "std::string MyInterface::MyMethod(int, double)" over D-Bus: -// using chromeos::dbus_utils::CallMethodAndBlock; -// using chromeos::dbus_utils::ExtractMethodCallResults; +// using brillo::dbus_utils::CallMethodAndBlock; +// using brillo::dbus_utils::ExtractMethodCallResults; // -// chromeos::ErrorPtr error; +// brillo::ErrorPtr error; // auto resp = CallMethodAndBlock(obj, // "org.chromium.MyService.MyInterface", // "MyMethod", @@ -41,43 +41,43 @@ // And here is how to call D-Bus methods asynchronously: // Call "std::string MyInterface::MyMethod(int, double)" over D-Bus: -// using chromeos::dbus_utils::CallMethod; -// using chromeos::dbus_utils::ExtractMethodCallResults; +// using brillo::dbus_utils::CallMethod; +// using brillo::dbus_utils::ExtractMethodCallResults; // // void OnSuccess(const std::string& return_value) { // // Use the |return_value|. // } // -// void OnError(chromeos::Error* error) { +// void OnError(brillo::Error* error) { // // An error occurred. Use |error| to get details. // } // -// chromeos::dbus_utils::CallMethod(obj, +// brillo::dbus_utils::CallMethod(obj, // "org.chromium.MyService.MyInterface", // "MyMethod", // base::Bind(OnSuccess), // base::Bind(OnError), // 2, 8.7); -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_DBUS_METHOD_INVOKER_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_DBUS_METHOD_INVOKER_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_DBUS_METHOD_INVOKER_H_ +#define LIBCHROMEOS_BRILLO_DBUS_DBUS_METHOD_INVOKER_H_ #include <memory> #include <string> #include <tuple> #include <base/bind.h> -#include <chromeos/dbus/dbus_param_reader.h> -#include <chromeos/dbus/dbus_param_writer.h> -#include <chromeos/dbus/utils.h> -#include <chromeos/errors/error.h> -#include <chromeos/errors/error_codes.h> -#include <chromeos/chromeos_export.h> +#include <brillo/dbus/dbus_param_reader.h> +#include <brillo/dbus/dbus_param_writer.h> +#include <brillo/dbus/utils.h> +#include <brillo/errors/error.h> +#include <brillo/errors/error_codes.h> +#include <brillo/brillo_export.h> #include <dbus/file_descriptor.h> #include <dbus/message.h> #include <dbus/object_proxy.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { // A helper method to dispatch a blocking D-Bus method call. Can specify @@ -243,8 +243,8 @@ inline bool ExtractMethodCallResults(dbus::Message* message, using AsyncErrorCallback = base::Callback<void(Error* error)>; // A helper function that translates dbus::ErrorResponse response -// from D-Bus into chromeos::Error* and invokes the |callback|. -void CHROMEOS_EXPORT TranslateErrorResponse(const AsyncErrorCallback& callback, +// from D-Bus into brillo::Error* and invokes the |callback|. +void BRILLO_EXPORT TranslateErrorResponse(const AsyncErrorCallback& callback, dbus::ErrorResponse* resp); // A helper function that translates dbus::Response from D-Bus into @@ -319,6 +319,6 @@ inline void CallMethod(dbus::ObjectProxy* object, } } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_DBUS_METHOD_INVOKER_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_DBUS_METHOD_INVOKER_H_ diff --git a/chromeos/dbus/dbus_method_invoker_unittest.cc b/brillo/dbus/dbus_method_invoker_unittest.cc index 6159bc8..44383aa 100644 --- a/chromeos/dbus/dbus_method_invoker_unittest.cc +++ b/brillo/dbus/dbus_method_invoker_unittest.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/dbus_method_invoker.h> +#include <brillo/dbus/dbus_method_invoker.h> #include <string> -#include <chromeos/bind_lambda.h> +#include <brillo/bind_lambda.h> #include <dbus/mock_bus.h> #include <dbus/mock_object_proxy.h> #include <dbus/scoped_dbus_error.h> @@ -25,7 +25,7 @@ using dbus::MessageReader; using dbus::MessageWriter; using dbus::Response; -namespace chromeos { +namespace brillo { namespace dbus_utils { const char kTestPath[] = "/test/path"; @@ -107,14 +107,12 @@ class DBusMethodInvokerTest : public testing::Test { std::string CallTestMethod(int v1, int v2) { std::unique_ptr<dbus::Response> response = - chromeos::dbus_utils::CallMethodAndBlock(mock_object_proxy_.get(), - kTestInterface, - kTestMethod1, - nullptr, - v1, v2); + brillo::dbus_utils::CallMethodAndBlock(mock_object_proxy_.get(), + kTestInterface, kTestMethod1, + nullptr, v1, v2); EXPECT_NE(nullptr, response.get()); std::string result; - using chromeos::dbus_utils::ExtractMethodCallResults; + using brillo::dbus_utils::ExtractMethodCallResults; EXPECT_TRUE(ExtractMethodCallResults(response.get(), nullptr, &result)); return result; } @@ -122,14 +120,12 @@ class DBusMethodInvokerTest : public testing::Test { dbus_utils_test::TestMessage CallProtobufTestMethod( const dbus_utils_test::TestMessage& message) { std::unique_ptr<dbus::Response> response = - chromeos::dbus_utils::CallMethodAndBlock(mock_object_proxy_.get(), - kTestInterface, - kTestMethod3, - nullptr, - message); + brillo::dbus_utils::CallMethodAndBlock(mock_object_proxy_.get(), + kTestInterface, kTestMethod3, + nullptr, message); EXPECT_NE(nullptr, response.get()); dbus_utils_test::TestMessage result; - using chromeos::dbus_utils::ExtractMethodCallResults; + using brillo::dbus_utils::ExtractMethodCallResults; EXPECT_TRUE(ExtractMethodCallResults(response.get(), nullptr, &result)); return result; } @@ -137,12 +133,12 @@ class DBusMethodInvokerTest : public testing::Test { // Sends a file descriptor received over D-Bus back to the caller. dbus::FileDescriptor EchoFD(const dbus::FileDescriptor& fd_in) { std::unique_ptr<dbus::Response> response = - chromeos::dbus_utils::CallMethodAndBlock(mock_object_proxy_.get(), - kTestInterface, kTestMethod4, - nullptr, fd_in); + brillo::dbus_utils::CallMethodAndBlock(mock_object_proxy_.get(), + kTestInterface, kTestMethod4, + nullptr, fd_in); EXPECT_NE(nullptr, response.get()); dbus::FileDescriptor fd_out; - using chromeos::dbus_utils::ExtractMethodCallResults; + using brillo::dbus_utils::ExtractMethodCallResults; EXPECT_TRUE(ExtractMethodCallResults(response.get(), nullptr, &fd_out)); return fd_out.Pass(); } @@ -158,12 +154,12 @@ TEST_F(DBusMethodInvokerTest, TestSuccess) { } TEST_F(DBusMethodInvokerTest, TestFailure) { - chromeos::ErrorPtr error; + brillo::ErrorPtr error; std::unique_ptr<dbus::Response> response = - chromeos::dbus_utils::CallMethodAndBlock( + brillo::dbus_utils::CallMethodAndBlock( mock_object_proxy_.get(), kTestInterface, kTestMethod2, &error); EXPECT_EQ(nullptr, response.get()); - EXPECT_EQ(chromeos::errors::dbus::kDomain, error->GetDomain()); + EXPECT_EQ(brillo::errors::dbus::kDomain, error->GetDomain()); EXPECT_EQ("org.MyError", error->GetCode()); EXPECT_EQ("My error message", error->GetMessage()); } @@ -275,7 +271,7 @@ class AsyncDBusMethodInvokerTest : public testing::Test { explicit ErrorCallback(int* in_counter) : counter(in_counter) {} - void operator()(chromeos::Error* error) { + void operator()(brillo::Error* error) { (*counter)++; EXPECT_NE(nullptr, error); EXPECT_EQ(domain, error->GetDomain()); @@ -296,21 +292,21 @@ class AsyncDBusMethodInvokerTest : public testing::Test { TEST_F(AsyncDBusMethodInvokerTest, TestSuccess) { int error_count = 0; int success_count = 0; - chromeos::dbus_utils::CallMethod( + brillo::dbus_utils::CallMethod( mock_object_proxy_.get(), kTestInterface, kTestMethod1, base::Bind(SuccessCallback{"4", &success_count}), base::Bind(ErrorCallback{&error_count}), 2, 2); - chromeos::dbus_utils::CallMethod( + brillo::dbus_utils::CallMethod( mock_object_proxy_.get(), kTestInterface, kTestMethod1, base::Bind(SuccessCallback{"10", &success_count}), base::Bind(ErrorCallback{&error_count}), 3, 7); - chromeos::dbus_utils::CallMethod( + brillo::dbus_utils::CallMethod( mock_object_proxy_.get(), kTestInterface, kTestMethod1, @@ -324,12 +320,12 @@ TEST_F(AsyncDBusMethodInvokerTest, TestSuccess) { TEST_F(AsyncDBusMethodInvokerTest, TestFailure) { int error_count = 0; int success_count = 0; - chromeos::dbus_utils::CallMethod( + brillo::dbus_utils::CallMethod( mock_object_proxy_.get(), kTestInterface, kTestMethod2, base::Bind(SuccessCallback{&success_count}), - base::Bind(ErrorCallback{chromeos::errors::dbus::kDomain, + base::Bind(ErrorCallback{brillo::errors::dbus::kDomain, "org.MyError", "My error message", &error_count}), @@ -339,4 +335,4 @@ TEST_F(AsyncDBusMethodInvokerTest, TestFailure) { } } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/dbus_method_response.cc b/brillo/dbus/dbus_method_response.cc index 25d0b27..bc75ee0 100644 --- a/chromeos/dbus/dbus_method_response.cc +++ b/brillo/dbus/dbus_method_response.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/dbus_method_response.h> +#include <brillo/dbus/dbus_method_response.h> -#include <chromeos/dbus/utils.h> +#include <brillo/dbus/utils.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { DBusMethodResponseBase::DBusMethodResponseBase(dbus::MethodCall* method_call, @@ -21,7 +21,7 @@ DBusMethodResponseBase::~DBusMethodResponseBase() { } } -void DBusMethodResponseBase::ReplyWithError(const chromeos::Error* error) { +void DBusMethodResponseBase::ReplyWithError(const brillo::Error* error) { CheckCanSendResponse(); auto response = GetDBusError(method_call_, error); SendRawResponse(std::move(response)); @@ -63,4 +63,4 @@ void DBusMethodResponseBase::CheckCanSendResponse() const { } } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/dbus_method_response.h b/brillo/dbus/dbus_method_response.h index b0c69b6..e30c71c 100644 --- a/chromeos/dbus/dbus_method_response.h +++ b/brillo/dbus/dbus_method_response.h @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_DBUS_METHOD_RESPONSE_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_DBUS_METHOD_RESPONSE_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_DBUS_METHOD_RESPONSE_H_ +#define LIBCHROMEOS_BRILLO_DBUS_DBUS_METHOD_RESPONSE_H_ #include <string> #include <base/macros.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/dbus/dbus_param_writer.h> -#include <chromeos/errors/error.h> +#include <brillo/brillo_export.h> +#include <brillo/dbus/dbus_param_writer.h> +#include <brillo/errors/error.h> #include <dbus/exported_object.h> #include <dbus/message.h> -namespace chromeos { +namespace brillo { class Error; @@ -25,7 +25,7 @@ using ResponseSender = dbus::ExportedObject::ResponseSender; // DBusMethodResponseBase is a helper class used with asynchronous D-Bus method // handlers to encapsulate the information needed to send the method call // response when it is available. -class CHROMEOS_EXPORT DBusMethodResponseBase { +class BRILLO_EXPORT DBusMethodResponseBase { public: DBusMethodResponseBase(dbus::MethodCall* method_call, ResponseSender sender); virtual ~DBusMethodResponseBase(); @@ -36,9 +36,9 @@ class CHROMEOS_EXPORT DBusMethodResponseBase { // For error is from other domains, the full error information (domain, error // code, error message) is encoded into the D-Bus error message and returned // to the caller as "org.freedesktop.DBus.Failed". - void ReplyWithError(const chromeos::Error* error); + void ReplyWithError(const brillo::Error* error); - // Constructs chromeos::Error object from the parameters specified and send + // Constructs brillo::Error object from the parameters specified and send // the error information over D-Bus using the method above. void ReplyWithError(const tracked_objects::Location& location, const std::string& error_domain, @@ -93,6 +93,6 @@ class DBusMethodResponse : public DBusMethodResponseBase { }; } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_DBUS_METHOD_RESPONSE_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_DBUS_METHOD_RESPONSE_H_ diff --git a/chromeos/dbus/dbus_object.cc b/brillo/dbus/dbus_object.cc index 16539e2..7b5834d 100644 --- a/chromeos/dbus/dbus_object.cc +++ b/brillo/dbus/dbus_object.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/dbus_object.h> +#include <brillo/dbus/dbus_object.h> #include <vector> #include <base/bind.h> #include <base/logging.h> -#include <chromeos/dbus/async_event_sequencer.h> -#include <chromeos/dbus/exported_object_manager.h> -#include <chromeos/dbus/exported_property_set.h> +#include <brillo/dbus/async_event_sequencer.h> +#include <brillo/dbus/exported_object_manager.h> +#include <brillo/dbus/exported_property_set.h> #include <dbus/property.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { ////////////////////////////////////////////////////////////////////////////// @@ -276,4 +276,4 @@ bool DBusObject::SendSignal(dbus::Signal* signal) { } } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/dbus_object.h b/brillo/dbus/dbus_object.h index 10894e6..1bd7ca7 100644 --- a/chromeos/dbus/dbus_object.h +++ b/brillo/dbus/dbus_object.h @@ -38,14 +38,14 @@ class MyDbusObject { DBusObject dbus_object_; // Make sure the properties outlive the DBusObject they are registered with. - chromeos::dbus_utils::ExportedProperty<std::string> prop1_; - chromeos::dbus_utils::ExportedProperty<int> prop2_; + brillo::dbus_utils::ExportedProperty<std::string> prop1_; + brillo::dbus_utils::ExportedProperty<int> prop2_; int Method1() { return 5; } - bool Method2(chromeos::ErrorPtr* error, const std::string& message); + bool Method2(brillo::ErrorPtr* error, const std::string& message); void Method3(std::unique_ptr<DBusMethodResponse<int_32>> response, const std::string& message) { if (message.empty()) { - response->ReplyWithError(chromeos::errors::dbus::kDomain, + response->ReplyWithError(brillo::errors::dbus::kDomain, DBUS_ERROR_INVALID_ARGS, "Message string cannot be empty"); return; @@ -58,8 +58,8 @@ class MyDbusObject { }; */ -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_DBUS_OBJECT_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_DBUS_OBJECT_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_DBUS_OBJECT_H_ +#define LIBCHROMEOS_BRILLO_DBUS_DBUS_OBJECT_H_ #include <map> #include <string> @@ -68,18 +68,18 @@ class MyDbusObject { #include <base/callback_helpers.h> #include <base/macros.h> #include <base/memory/weak_ptr.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/dbus/async_event_sequencer.h> -#include <chromeos/dbus/dbus_object_internal_impl.h> -#include <chromeos/dbus/dbus_signal.h> -#include <chromeos/dbus/exported_property_set.h> -#include <chromeos/errors/error.h> +#include <brillo/brillo_export.h> +#include <brillo/dbus/async_event_sequencer.h> +#include <brillo/dbus/dbus_object_internal_impl.h> +#include <brillo/dbus/dbus_signal.h> +#include <brillo/dbus/exported_property_set.h> +#include <brillo/errors/error.h> #include <dbus/bus.h> #include <dbus/exported_object.h> #include <dbus/message.h> #include <dbus/object_path.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { class ExportedObjectManager; @@ -114,7 +114,7 @@ class DBusObject; // response. // The signature of the handler for AddRawMethodHandler must be: // void(dbus::MethodCall* method_call, ResponseSender sender) -class CHROMEOS_EXPORT DBusInterface final { +class BRILLO_EXPORT DBusInterface final { public: DBusInterface(DBusObject* dbus_object, const std::string& interface_name); @@ -443,13 +443,13 @@ class CHROMEOS_EXPORT DBusInterface final { // map and dispatched the call to that handler. void HandleMethodCall(dbus::MethodCall* method_call, ResponseSender sender); // Helper to add a handler for method |method_name| to the |handlers_| map. - // Not marked CHROMEOS_PRIVATE because it needs to be called by the inline + // Not marked BRILLO_PRIVATE because it needs to be called by the inline // template functions AddMethodHandler(...) void AddHandlerImpl( const std::string& method_name, std::unique_ptr<DBusInterfaceMethodHandlerInterface> handler); // Helper to add a signal object to the |signals_| map. - // Not marked CHROMEOS_PRIVATE because it needs to be called by the inline + // Not marked BRILLO_PRIVATE because it needs to be called by the inline // template function RegisterSignalOfType(...) void AddSignalImpl(const std::string& signal_name, const std::shared_ptr<DBusSignalBase>& signal); @@ -462,7 +462,7 @@ class CHROMEOS_EXPORT DBusInterface final { // interface_name - name of interface being registered. // completion_callback - a callback to be called when the asynchronous // registration operation is completed. - CHROMEOS_PRIVATE void ExportAsync( + BRILLO_PRIVATE void ExportAsync( ExportedObjectManager* object_manager, dbus::Bus* bus, dbus::ExportedObject* exported_object, @@ -475,13 +475,13 @@ class CHROMEOS_EXPORT DBusInterface final { // exported_object - instance of D-Bus object the interface is being added to. // object_path - D-Bus object path for the object instance. // interface_name - name of interface being registered. - CHROMEOS_PRIVATE void ExportAndBlock( + BRILLO_PRIVATE void ExportAndBlock( ExportedObjectManager* object_manager, dbus::Bus* bus, dbus::ExportedObject* exported_object, const dbus::ObjectPath& object_path); - CHROMEOS_PRIVATE void ClaimInterface( + BRILLO_PRIVATE void ClaimInterface( base::WeakPtr<ExportedObjectManager> object_manager, const dbus::ObjectPath& object_path, const ExportedPropertySet::PropertyWriter& writer, @@ -505,7 +505,7 @@ class CHROMEOS_EXPORT DBusInterface final { // A D-Bus object implementation class. Manages the interfaces implemented // by this object. -class CHROMEOS_EXPORT DBusObject { +class BRILLO_EXPORT DBusObject { public: // object_manager - ExportedObjectManager instance that notifies D-Bus // listeners of a new interface being claimed and property @@ -574,6 +574,6 @@ class CHROMEOS_EXPORT DBusObject { }; } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_DBUS_OBJECT_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_DBUS_OBJECT_H_ diff --git a/chromeos/dbus/dbus_object_internal_impl.h b/brillo/dbus/dbus_object_internal_impl.h index 544dadb..4ed4bb9 100644 --- a/chromeos/dbus/dbus_object_internal_impl.h +++ b/brillo/dbus/dbus_object_internal_impl.h @@ -26,22 +26,22 @@ // to the appropriate method handler using additional data captured by the // lambda object. -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_DBUS_OBJECT_INTERNAL_IMPL_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_DBUS_OBJECT_INTERNAL_IMPL_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_DBUS_OBJECT_INTERNAL_IMPL_H_ +#define LIBCHROMEOS_BRILLO_DBUS_DBUS_OBJECT_INTERNAL_IMPL_H_ #include <memory> #include <string> #include <type_traits> -#include <chromeos/dbus/data_serialization.h> -#include <chromeos/dbus/dbus_method_response.h> -#include <chromeos/dbus/dbus_param_reader.h> -#include <chromeos/dbus/dbus_param_writer.h> -#include <chromeos/dbus/utils.h> -#include <chromeos/errors/error.h> +#include <brillo/dbus/data_serialization.h> +#include <brillo/dbus/dbus_method_response.h> +#include <brillo/dbus/dbus_param_reader.h> +#include <brillo/dbus/dbus_param_writer.h> +#include <brillo/dbus/utils.h> +#include <brillo/errors/error.h> #include <dbus/message.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { // This is an abstract base class to allow dispatching a native C++ callback @@ -358,6 +358,6 @@ class RawDBusInterfaceMethodHandler }; } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_DBUS_OBJECT_INTERNAL_IMPL_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_DBUS_OBJECT_INTERNAL_IMPL_H_ diff --git a/chromeos/dbus/dbus_object_test_helpers.h b/brillo/dbus/dbus_object_test_helpers.h index db24c9f..6b90c5a 100644 --- a/chromeos/dbus/dbus_object_test_helpers.h +++ b/brillo/dbus/dbus_object_test_helpers.h @@ -9,15 +9,15 @@ // still use DBusMethodResponse to send back the method results). // This file provide testing-only helpers to make calling D-Bus method handlers // easier. -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_DBUS_OBJECT_TEST_HELPERS_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_DBUS_OBJECT_TEST_HELPERS_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_DBUS_OBJECT_TEST_HELPERS_H_ +#define LIBCHROMEOS_BRILLO_DBUS_DBUS_OBJECT_TEST_HELPERS_H_ #include <base/bind.h> #include <base/memory/weak_ptr.h> -#include <chromeos/dbus/dbus_method_invoker.h> -#include <chromeos/dbus/dbus_object.h> +#include <brillo/dbus/dbus_method_invoker.h> +#include <brillo/dbus/dbus_object.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { // Helper friend class to call DBusInterface::HandleMethodCall() since it is @@ -138,6 +138,6 @@ struct MethodHandlerInvoker<void> { } // namespace testing } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_DBUS_OBJECT_TEST_HELPERS_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_DBUS_OBJECT_TEST_HELPERS_H_ diff --git a/chromeos/dbus/dbus_object_unittest.cc b/brillo/dbus/dbus_object_unittest.cc index 87a79e8..f833530 100644 --- a/chromeos/dbus/dbus_object_unittest.cc +++ b/brillo/dbus/dbus_object_unittest.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/dbus_object.h> +#include <brillo/dbus/dbus_object.h> #include <memory> #include <base/bind.h> -#include <chromeos/dbus/dbus_object_test_helpers.h> -#include <chromeos/dbus/mock_exported_object_manager.h> +#include <brillo/dbus/dbus_object_test_helpers.h> +#include <brillo/dbus/mock_exported_object_manager.h> #include <dbus/message.h> #include <dbus/property.h> #include <dbus/object_path.h> @@ -21,7 +21,7 @@ using ::testing::Invoke; using ::testing::Mock; using ::testing::_; -namespace chromeos { +namespace brillo { namespace dbus_utils { namespace { @@ -389,4 +389,4 @@ TEST_F(DBusObjectTest, ShouldReleaseOnlyClaimedInterfaces) { } } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/dbus_param_reader.h b/brillo/dbus/dbus_param_reader.h index 0ac1c2a..f72f93c 100644 --- a/chromeos/dbus/dbus_param_reader.h +++ b/brillo/dbus/dbus_param_reader.h @@ -13,18 +13,18 @@ // until there is only the return type remaining and we fall through to either // the void or the non-void final specialization. -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_DBUS_PARAM_READER_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_DBUS_PARAM_READER_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_DBUS_PARAM_READER_H_ +#define LIBCHROMEOS_BRILLO_DBUS_DBUS_PARAM_READER_H_ #include <type_traits> -#include <chromeos/dbus/data_serialization.h> -#include <chromeos/dbus/utils.h> -#include <chromeos/errors/error.h> -#include <chromeos/errors/error_codes.h> +#include <brillo/dbus/data_serialization.h> +#include <brillo/dbus/utils.h> +#include <brillo/errors/error.h> +#include <brillo/errors/error_codes.h> #include <dbus/message.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { // A generic DBusParamReader stub class which allows us to specialize on @@ -160,6 +160,6 @@ struct DBusParamReader<allow_out_params> { }; // struct DBusParamReader<> } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_DBUS_PARAM_READER_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_DBUS_PARAM_READER_H_ diff --git a/chromeos/dbus/dbus_param_reader_unittest.cc b/brillo/dbus/dbus_param_reader_unittest.cc index d498516..c2669a7 100644 --- a/chromeos/dbus/dbus_param_reader_unittest.cc +++ b/brillo/dbus/dbus_param_reader_unittest.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/dbus_param_reader.h> +#include <brillo/dbus/dbus_param_reader.h> #include <string> -#include <chromeos/variant_dictionary.h> +#include <brillo/variant_dictionary.h> #include <gtest/gtest.h> using dbus::MessageReader; using dbus::MessageWriter; using dbus::Response; -namespace chromeos { +namespace brillo { namespace dbus_utils { TEST(DBusParamReader, NoArgs) { @@ -250,4 +250,4 @@ TEST(DBusParamReader, TooFewArgs_With_OUT) { } } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/dbus_param_writer.h b/brillo/dbus/dbus_param_writer.h index 16a5ce2..3eb736e 100644 --- a/chromeos/dbus/dbus_param_writer.h +++ b/brillo/dbus/dbus_param_writer.h @@ -11,13 +11,13 @@ // method response message. This method skips any non-pointer parameters and // only appends the data for arguments that are pointers. -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_DBUS_PARAM_WRITER_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_DBUS_PARAM_WRITER_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_DBUS_PARAM_WRITER_H_ +#define LIBCHROMEOS_BRILLO_DBUS_DBUS_PARAM_WRITER_H_ -#include <chromeos/dbus/data_serialization.h> +#include <brillo/dbus/data_serialization.h> #include <dbus/message.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { class DBusParamWriter final { @@ -75,6 +75,6 @@ class DBusParamWriter final { }; } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_DBUS_PARAM_WRITER_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_DBUS_PARAM_WRITER_H_ diff --git a/chromeos/dbus/dbus_param_writer_unittest.cc b/brillo/dbus/dbus_param_writer_unittest.cc index 37c3f6f..428c810 100644 --- a/chromeos/dbus/dbus_param_writer_unittest.cc +++ b/brillo/dbus/dbus_param_writer_unittest.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/dbus_param_writer.h> +#include <brillo/dbus/dbus_param_writer.h> #include <string> -#include <chromeos/any.h> +#include <brillo/any.h> #include <gtest/gtest.h> using dbus::MessageReader; @@ -14,7 +14,7 @@ using dbus::MessageWriter; using dbus::ObjectPath; using dbus::Response; -namespace chromeos { +namespace brillo { namespace dbus_utils { TEST(DBusParamWriter, Append_NoArgs) { @@ -186,4 +186,4 @@ TEST(DBusParamWriter, AppendDBusOutParams_Mixed_ManyArgs) { EXPECT_TRUE(bool_value); } } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/dbus_property.h b/brillo/dbus/dbus_property.h index 0f76a13..a7b11df 100644 --- a/chromeos/dbus/dbus_property.h +++ b/brillo/dbus/dbus_property.h @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_DBUS_PROPERTY_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_DBUS_PROPERTY_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_DBUS_PROPERTY_H_ +#define LIBCHROMEOS_BRILLO_DBUS_DBUS_PROPERTY_H_ -#include <chromeos/dbus/data_serialization.h> +#include <brillo/dbus/data_serialization.h> #include <dbus/property.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { // Re-implementation of dbus::Property<T> that can handle any type supported by @@ -89,6 +89,6 @@ class Property : public dbus::PropertyBase { }; } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_DBUS_PROPERTY_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_DBUS_PROPERTY_H_ diff --git a/chromeos/dbus/dbus_service_watcher.cc b/brillo/dbus/dbus_service_watcher.cc index 6b6319e..ede2e6e 100644 --- a/chromeos/dbus/dbus_service_watcher.cc +++ b/brillo/dbus/dbus_service_watcher.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/dbus_service_watcher.h> +#include <brillo/dbus/dbus_service_watcher.h> #include <base/bind.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { DBusServiceWatcher::DBusServiceWatcher( @@ -36,4 +36,4 @@ void DBusServiceWatcher::OnServiceOwnerChange( } } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/dbus_service_watcher.h b/brillo/dbus/dbus_service_watcher.h index 175ac96..730f1f2 100644 --- a/chromeos/dbus/dbus_service_watcher.h +++ b/brillo/dbus/dbus_service_watcher.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_DBUS_SERVICE_WATCHER_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_DBUS_SERVICE_WATCHER_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_DBUS_SERVICE_WATCHER_H_ +#define LIBCHROMEOS_BRILLO_DBUS_DBUS_SERVICE_WATCHER_H_ #include <string> @@ -11,10 +11,10 @@ #include <base/macros.h> #include <base/memory/ref_counted.h> #include <base/memory/weak_ptr.h> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> #include <dbus/bus.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { // DBusServiceWatcher just asks the bus to notify us when the owner of a remote @@ -27,7 +27,7 @@ namespace dbus_utils { // The chief value of this class is that it manages the lifetime of the // registered callback in the Bus, because failure to remove callbacks will // cause the Bus to crash the process on destruction. -class CHROMEOS_EXPORT DBusServiceWatcher { +class BRILLO_EXPORT DBusServiceWatcher { public: DBusServiceWatcher(scoped_refptr<dbus::Bus> bus, const std::string& connection_name, @@ -48,6 +48,6 @@ class CHROMEOS_EXPORT DBusServiceWatcher { }; } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_DBUS_SERVICE_WATCHER_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_DBUS_SERVICE_WATCHER_H_ diff --git a/chromeos/dbus/dbus_signal.cc b/brillo/dbus/dbus_signal.cc index b4e12d3..d227bd7 100644 --- a/chromeos/dbus/dbus_signal.cc +++ b/brillo/dbus/dbus_signal.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/dbus_signal.h> +#include <brillo/dbus/dbus_signal.h> -#include <chromeos/dbus/dbus_object.h> +#include <brillo/dbus/dbus_object.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { DBusSignalBase::DBusSignalBase(DBusObject* dbus_object, @@ -25,4 +25,4 @@ bool DBusSignalBase::SendSignal(dbus::Signal* signal) const { } } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/dbus_signal.h b/brillo/dbus/dbus_signal.h index ed7e129..b19f1c8 100644 --- a/chromeos/dbus/dbus_signal.h +++ b/brillo/dbus/dbus_signal.h @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_DBUS_SIGNAL_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_DBUS_SIGNAL_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_DBUS_SIGNAL_H_ +#define LIBCHROMEOS_BRILLO_DBUS_DBUS_SIGNAL_H_ #include <string> #include <typeinfo> #include <base/bind.h> #include <base/macros.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/dbus/dbus_param_writer.h> +#include <brillo/brillo_export.h> +#include <brillo/dbus/dbus_param_writer.h> #include <dbus/message.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { class DBusObject; @@ -22,7 +22,7 @@ class DBusObject; // Base class for D-Bus signal proxy classes. // Used mostly to store the polymorphic DBusSignal<...> in a single map // container inside DBusInterface object. -class CHROMEOS_EXPORT DBusSignalBase { +class BRILLO_EXPORT DBusSignalBase { public: DBusSignalBase(DBusObject* dbus_object, const std::string& interface_name, @@ -63,6 +63,6 @@ class DBusSignal : public DBusSignalBase { }; } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_DBUS_SIGNAL_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_DBUS_SIGNAL_H_ diff --git a/chromeos/dbus/dbus_signal_handler.h b/brillo/dbus/dbus_signal_handler.h index 13a2b82..dfa1e78 100644 --- a/chromeos/dbus/dbus_signal_handler.h +++ b/brillo/dbus/dbus_signal_handler.h @@ -2,24 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_DBUS_SIGNAL_HANDLER_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_DBUS_SIGNAL_HANDLER_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_DBUS_SIGNAL_HANDLER_H_ +#define LIBCHROMEOS_BRILLO_DBUS_DBUS_SIGNAL_HANDLER_H_ #include <string> -#include <chromeos/bind_lambda.h> -#include <chromeos/dbus/dbus_param_reader.h> +#include <brillo/bind_lambda.h> +#include <brillo/dbus/dbus_param_reader.h> #include <dbus/message.h> #include <dbus/object_proxy.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { -// chromeos::dbus_utils::ConnectToSignal() is a helper function similar to +// brillo::dbus_utils::ConnectToSignal() is a helper function similar to // dbus::ObjectProxy::ConnectToSignal() but the |signal_callback| is an actual // C++ signal handler with expected signal parameters as native method args. // -// chromeos::dbus_utils::ConnectToSignal() actually registers a stub signal +// brillo::dbus_utils::ConnectToSignal() actually registers a stub signal // handler with D-Bus which has a standard signature that matches // dbus::ObjectProxy::SignalCallback. // @@ -63,6 +63,6 @@ void ConnectToSignal( } } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_DBUS_SIGNAL_HANDLER_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_DBUS_SIGNAL_HANDLER_H_ diff --git a/chromeos/dbus/dbus_signal_handler_unittest.cc b/brillo/dbus/dbus_signal_handler_unittest.cc index 88d5559..e0bea10 100644 --- a/chromeos/dbus/dbus_signal_handler_unittest.cc +++ b/brillo/dbus/dbus_signal_handler_unittest.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/dbus_signal_handler.h> +#include <brillo/dbus/dbus_signal_handler.h> #include <string> -#include <chromeos/bind_lambda.h> -#include <chromeos/dbus/dbus_param_writer.h> +#include <brillo/bind_lambda.h> +#include <brillo/dbus/dbus_param_writer.h> #include <dbus/mock_bus.h> #include <dbus/mock_object_proxy.h> #include <gmock/gmock.h> @@ -18,7 +18,7 @@ using testing::Return; using testing::SaveArg; using testing::_; -namespace chromeos { +namespace brillo { namespace dbus_utils { const char kTestPath[] = "/test/path"; @@ -52,7 +52,7 @@ class DBusSignalHandlerTest : public testing::Test { EXPECT_CALL(*mock_object_proxy_, ConnectToSignal(kInterface, kSignal, _, _)) .WillOnce(SaveArg<2>(&signal_callback)); - chromeos::dbus_utils::ConnectToSignal( + brillo::dbus_utils::ConnectToSignal( mock_object_proxy_.get(), kInterface, kSignal, @@ -73,7 +73,7 @@ TEST_F(DBusSignalHandlerTest, ConnectToSignal) { EXPECT_CALL(*mock_object_proxy_, ConnectToSignal(kInterface, kSignal, _, _)) .Times(1); - chromeos::dbus_utils::ConnectToSignal( + brillo::dbus_utils::ConnectToSignal( mock_object_proxy_.get(), kInterface, kSignal, base::Closure{}, {}); } @@ -142,4 +142,4 @@ TEST_F(DBusSignalHandlerTest, CallSignal_Error_TypeMismatchArgs) { } } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/exported_object_manager.cc b/brillo/dbus/exported_object_manager.cc index f952e57..61dae68 100644 --- a/chromeos/dbus/exported_object_manager.cc +++ b/brillo/dbus/exported_object_manager.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/exported_object_manager.h> +#include <brillo/dbus/exported_object_manager.h> #include <vector> -#include <chromeos/dbus/async_event_sequencer.h> +#include <brillo/dbus/async_event_sequencer.h> #include <dbus/object_manager.h> -using chromeos::dbus_utils::AsyncEventSequencer; +using brillo::dbus_utils::AsyncEventSequencer; -namespace chromeos { +namespace brillo { namespace dbus_utils { @@ -100,6 +100,6 @@ ExportedObjectManager::HandleGetManagedObjects() { return objects; } -} // namespace dbus_utils +} // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/exported_object_manager.h b/brillo/dbus/exported_object_manager.h index 183e676..584c0b6 100644 --- a/chromeos/dbus/exported_object_manager.h +++ b/brillo/dbus/exported_object_manager.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_EXPORTED_OBJECT_MANAGER_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_EXPORTED_OBJECT_MANAGER_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_EXPORTED_OBJECT_MANAGER_H_ +#define LIBCHROMEOS_BRILLO_DBUS_EXPORTED_OBJECT_MANAGER_H_ #include <map> #include <string> @@ -11,16 +11,16 @@ #include <base/callback.h> #include <base/memory/weak_ptr.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/dbus/dbus_object.h> -#include <chromeos/dbus/exported_property_set.h> -#include <chromeos/variant_dictionary.h> +#include <brillo/brillo_export.h> +#include <brillo/dbus/dbus_object.h> +#include <brillo/dbus/exported_property_set.h> +#include <brillo/variant_dictionary.h> #include <dbus/bus.h> #include <dbus/exported_object.h> #include <dbus/message.h> #include <dbus/object_path.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { @@ -76,7 +76,7 @@ namespace dbus_utils { // Properties my_properties_; // ExampleObjectManager* object_manager_; // }; -class CHROMEOS_EXPORT ExportedObjectManager +class BRILLO_EXPORT ExportedObjectManager : public base::SupportsWeakPtr<ExportedObjectManager> { public: using ObjectMap = @@ -92,7 +92,7 @@ class CHROMEOS_EXPORT ExportedObjectManager // exported on the path given in the constructor. Must be called on the // origin thread. virtual void RegisterAsync( - const chromeos::dbus_utils::AsyncEventSequencer::CompletionAction& + const brillo::dbus_utils::AsyncEventSequencer::CompletionAction& completion_callback); // Trigger a signal that |path| has added an interface |interface_name| @@ -109,10 +109,10 @@ class CHROMEOS_EXPORT ExportedObjectManager const scoped_refptr<dbus::Bus>& GetBus() const { return bus_; } private: - CHROMEOS_PRIVATE ObjectMap HandleGetManagedObjects(); + BRILLO_PRIVATE ObjectMap HandleGetManagedObjects(); scoped_refptr<dbus::Bus> bus_; - chromeos::dbus_utils::DBusObject dbus_object_; + brillo::dbus_utils::DBusObject dbus_object_; // Tracks all objects currently known to the ExportedObjectManager. std::map<dbus::ObjectPath, InterfaceProperties> registered_objects_; @@ -128,8 +128,8 @@ class CHROMEOS_EXPORT ExportedObjectManager DISALLOW_COPY_AND_ASSIGN(ExportedObjectManager); }; -} // namespace dbus_utils +} // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_EXPORTED_OBJECT_MANAGER_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_EXPORTED_OBJECT_MANAGER_H_ diff --git a/chromeos/dbus/exported_object_manager_unittest.cc b/brillo/dbus/exported_object_manager_unittest.cc index 3df1466..00fe108 100644 --- a/chromeos/dbus/exported_object_manager_unittest.cc +++ b/brillo/dbus/exported_object_manager_unittest.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/exported_object_manager.h> +#include <brillo/dbus/exported_object_manager.h> #include <base/bind.h> -#include <chromeos/dbus/dbus_object_test_helpers.h> -#include <chromeos/dbus/utils.h> +#include <brillo/dbus/dbus_object_test_helpers.h> +#include <brillo/dbus/utils.h> #include <dbus/mock_bus.h> #include <dbus/mock_exported_object.h> #include <dbus/object_manager.h> @@ -19,7 +19,7 @@ using ::testing::Invoke; using ::testing::Return; using ::testing::_; -namespace chromeos { +namespace brillo { namespace dbus_utils { @@ -125,8 +125,8 @@ class ExportedObjectManagerTest : public ::testing::Test { dbus::MethodCall method_call(dbus::kObjectManagerInterface, dbus::kObjectManagerGetManagedObjects); method_call.SetSerial(1234); - return chromeos::dbus_utils::testing::CallMethod(om_->dbus_object_, - &method_call); + return brillo::dbus_utils::testing::CallMethod(om_->dbus_object_, + &method_call); } scoped_refptr<dbus::MockBus> bus_; @@ -191,4 +191,4 @@ TEST_F(ExportedObjectManagerTest, GetManagedObjectsResponseCorrectness) { } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/exported_property_set.cc b/brillo/dbus/exported_property_set.cc index 0f7d7cf..8d6ae65 100644 --- a/chromeos/dbus/exported_property_set.cc +++ b/brillo/dbus/exported_property_set.cc @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/exported_property_set.h> +#include <brillo/dbus/exported_property_set.h> #include <base/bind.h> #include <dbus/bus.h> #include <dbus/property.h> // For kPropertyInterface -#include <chromeos/dbus/async_event_sequencer.h> -#include <chromeos/dbus/dbus_object.h> -#include <chromeos/errors/error_codes.h> +#include <brillo/dbus/async_event_sequencer.h> +#include <brillo/dbus/dbus_object.h> +#include <brillo/errors/error_codes.h> -using chromeos::dbus_utils::AsyncEventSequencer; +using brillo::dbus_utils::AsyncEventSequencer; -namespace chromeos { +namespace brillo { namespace dbus_utils { @@ -77,56 +77,48 @@ void ExportedPropertySet::WritePropertiesToDict( *dict = GetInterfaceProperties(interface_name); } -bool ExportedPropertySet::HandleGet(chromeos::ErrorPtr* error, +bool ExportedPropertySet::HandleGet(brillo::ErrorPtr* error, const std::string& interface_name, const std::string& property_name, - chromeos::Any* result) { + brillo::Any* result) { bus_->AssertOnOriginThread(); auto property_map_itr = properties_.find(interface_name); if (property_map_itr == properties_.end()) { - chromeos::Error::AddTo(error, - FROM_HERE, - errors::dbus::kDomain, - DBUS_ERROR_UNKNOWN_INTERFACE, - "No such interface on object."); + brillo::Error::AddTo(error, FROM_HERE, errors::dbus::kDomain, + DBUS_ERROR_UNKNOWN_INTERFACE, + "No such interface on object."); return false; } LOG(INFO) << "Looking for " << property_name << " on " << interface_name; auto property_itr = property_map_itr->second.find(property_name); if (property_itr == property_map_itr->second.end()) { - chromeos::Error::AddTo(error, - FROM_HERE, - errors::dbus::kDomain, - DBUS_ERROR_UNKNOWN_PROPERTY, - "No such property on interface."); + brillo::Error::AddTo(error, FROM_HERE, errors::dbus::kDomain, + DBUS_ERROR_UNKNOWN_PROPERTY, + "No such property on interface."); return false; } *result = property_itr->second->GetValue(); return true; } -bool ExportedPropertySet::HandleSet(chromeos::ErrorPtr* error, +bool ExportedPropertySet::HandleSet(brillo::ErrorPtr* error, const std::string& interface_name, const std::string& property_name, - const chromeos::Any& value) { + const brillo::Any& value) { bus_->AssertOnOriginThread(); auto property_map_itr = properties_.find(interface_name); if (property_map_itr == properties_.end()) { - chromeos::Error::AddTo(error, - FROM_HERE, - errors::dbus::kDomain, - DBUS_ERROR_UNKNOWN_INTERFACE, - "No such interface on object."); + brillo::Error::AddTo(error, FROM_HERE, errors::dbus::kDomain, + DBUS_ERROR_UNKNOWN_INTERFACE, + "No such interface on object."); return false; } LOG(INFO) << "Looking for " << property_name << " on " << interface_name; auto property_itr = property_map_itr->second.find(property_name); if (property_itr == property_map_itr->second.end()) { - chromeos::Error::AddTo(error, - FROM_HERE, - errors::dbus::kDomain, - DBUS_ERROR_UNKNOWN_PROPERTY, - "No such property on interface."); + brillo::Error::AddTo(error, FROM_HERE, errors::dbus::kDomain, + DBUS_ERROR_UNKNOWN_PROPERTY, + "No such property on interface."); return false; } @@ -179,4 +171,4 @@ ExportedPropertyBase::Access ExportedPropertyBase::GetAccessMode() const { } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/exported_property_set.h b/brillo/dbus/exported_property_set.h index b7069ba..16f5086 100644 --- a/chromeos/dbus/exported_property_set.h +++ b/brillo/dbus/exported_property_set.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_EXPORTED_PROPERTY_SET_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_EXPORTED_PROPERTY_SET_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_EXPORTED_PROPERTY_SET_H_ +#define LIBCHROMEOS_BRILLO_DBUS_EXPORTED_PROPERTY_SET_H_ #include <stdint.h> @@ -12,16 +12,16 @@ #include <vector> #include <base/memory/weak_ptr.h> -#include <chromeos/any.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/dbus/dbus_signal.h> -#include <chromeos/errors/error.h> -#include <chromeos/errors/error_codes.h> -#include <chromeos/variant_dictionary.h> +#include <brillo/any.h> +#include <brillo/brillo_export.h> +#include <brillo/dbus/dbus_signal.h> +#include <brillo/errors/error.h> +#include <brillo/errors/error_codes.h> +#include <brillo/variant_dictionary.h> #include <dbus/exported_object.h> #include <dbus/message.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { @@ -53,7 +53,7 @@ namespace dbus_utils { class DBusInterface; class DBusObject; -class CHROMEOS_EXPORT ExportedPropertyBase { +class BRILLO_EXPORT ExportedPropertyBase { public: enum class Access { kReadOnly, @@ -72,10 +72,10 @@ class CHROMEOS_EXPORT ExportedPropertyBase { virtual void SetUpdateCallback(const OnUpdateCallback& cb); // Returns the contained value as Any. - virtual chromeos::Any GetValue() const = 0; + virtual brillo::Any GetValue() const = 0; - virtual bool SetValue(chromeos::ErrorPtr* error, - const chromeos::Any& value) = 0; + virtual bool SetValue(brillo::ErrorPtr* error, + const brillo::Any& value) = 0; void SetAccessMode(Access access_mode); Access GetAccessMode() const; @@ -90,7 +90,7 @@ class CHROMEOS_EXPORT ExportedPropertyBase { Access access_mode_{Access::kReadOnly}; }; -class CHROMEOS_EXPORT ExportedPropertySet { +class BRILLO_EXPORT ExportedPropertySet { public: using PropertyWriter = base::Callback<void(VariantDictionary* dict)>; @@ -113,18 +113,18 @@ class CHROMEOS_EXPORT ExportedPropertySet { // D-Bus methods for org.freedesktop.DBus.Properties interface. VariantDictionary HandleGetAll(const std::string& interface_name); - bool HandleGet(chromeos::ErrorPtr* error, + bool HandleGet(brillo::ErrorPtr* error, const std::string& interface_name, const std::string& property_name, - chromeos::Any* result); + brillo::Any* result); // While Properties.Set has a handler to complete the interface, we don't // support writable properties. This is almost a feature, since bindings for // many languages don't support errors coming back from invalid writes. // Instead, use setters in exposed interfaces. - bool HandleSet(chromeos::ErrorPtr* error, + bool HandleSet(brillo::ErrorPtr* error, const std::string& interface_name, const std::string& property_name, - const chromeos::Any& value); + const brillo::Any& value); // Returns a string-to-variant map of all the properties for the given // interface and their values. VariantDictionary GetInterfaceProperties( @@ -134,9 +134,9 @@ class CHROMEOS_EXPORT ExportedPropertySet { // Used to write the dictionary of string->variant to a message. // This dictionary represents the property name/value pairs for the // given interface. - CHROMEOS_PRIVATE void WritePropertiesToDict(const std::string& interface_name, - VariantDictionary* dict); - CHROMEOS_PRIVATE void HandlePropertyUpdated( + BRILLO_PRIVATE void WritePropertiesToDict(const std::string& interface_name, + VariantDictionary* dict); + BRILLO_PRIVATE void HandlePropertyUpdated( const std::string& interface_name, const std::string& property_name, const ExportedPropertyBase* exported_property); @@ -180,29 +180,25 @@ class ExportedProperty : public ExportedPropertyBase { // Set the validator for value checking when setting the property by remote // application. void SetValidator( - const base::Callback<bool(chromeos::ErrorPtr*, const T&)>& validator) { + const base::Callback<bool(brillo::ErrorPtr*, const T&)>& validator) { validator_ = validator; } // Implementation provided by specialization. - chromeos::Any GetValue() const override { return value_; } + brillo::Any GetValue() const override { return value_; } - bool SetValue(chromeos::ErrorPtr* error, - const chromeos::Any& value) override { + bool SetValue(brillo::ErrorPtr* error, + const brillo::Any& value) override { if (GetAccessMode() == ExportedPropertyBase::Access::kReadOnly) { - chromeos::Error::AddTo(error, - FROM_HERE, - errors::dbus::kDomain, - DBUS_ERROR_PROPERTY_READ_ONLY, - "Property is read-only."); + brillo::Error::AddTo(error, FROM_HERE, errors::dbus::kDomain, + DBUS_ERROR_PROPERTY_READ_ONLY, + "Property is read-only."); return false; } if (!value.IsTypeCompatible<T>()) { - chromeos::Error::AddTo(error, - FROM_HERE, - errors::dbus::kDomain, - DBUS_ERROR_INVALID_ARGS, - "Argument type mismatched."); + brillo::Error::AddTo(error, FROM_HERE, errors::dbus::kDomain, + DBUS_ERROR_INVALID_ARGS, + "Argument type mismatched."); return false; } if (value_ == value.Get<T>()) { @@ -218,13 +214,13 @@ class ExportedProperty : public ExportedPropertyBase { private: T value_{}; - base::Callback<bool(chromeos::ErrorPtr*, const T&)> validator_; + base::Callback<bool(brillo::ErrorPtr*, const T&)> validator_; DISALLOW_COPY_AND_ASSIGN(ExportedProperty); }; } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_EXPORTED_PROPERTY_SET_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_EXPORTED_PROPERTY_SET_H_ diff --git a/chromeos/dbus/exported_property_set_unittest.cc b/brillo/dbus/exported_property_set_unittest.cc index ff38c37..c0deace 100644 --- a/chromeos/dbus/exported_property_set_unittest.cc +++ b/brillo/dbus/exported_property_set_unittest.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/exported_property_set.h> +#include <brillo/dbus/exported_property_set.h> #include <string> #include <vector> #include <base/bind.h> #include <base/macros.h> -#include <chromeos/dbus/dbus_object.h> -#include <chromeos/dbus/dbus_object_test_helpers.h> -#include <chromeos/errors/error_codes.h> +#include <brillo/dbus/dbus_object.h> +#include <brillo/dbus/dbus_object_test_helpers.h> +#include <brillo/errors/error_codes.h> #include <dbus/message.h> #include <dbus/property.h> #include <dbus/object_path.h> @@ -26,7 +26,7 @@ using ::testing::Invoke; using ::testing::_; using ::testing::Unused; -namespace chromeos { +namespace brillo { namespace dbus_utils { @@ -151,7 +151,7 @@ class ExportedPropertySetTest : public ::testing::Test { std::unique_ptr<dbus::Response> SetPropertyOnInterface( const std::string& interface_name, const std::string& property_name, - const chromeos::Any& value) { + const brillo::Any& value) { dbus::MethodCall method_call(dbus::kPropertiesInterface, dbus::kPropertiesSet); method_call.SetSerial(123); @@ -178,15 +178,15 @@ class PropertyValidatorObserver { virtual ~PropertyValidatorObserver() {} MOCK_METHOD2_T(ValidateProperty, - bool(chromeos::ErrorPtr* error, const T& value)); + bool(brillo::ErrorPtr* error, const T& value)); - const base::Callback<bool(chromeos::ErrorPtr*, const T&)>& + const base::Callback<bool(brillo::ErrorPtr*, const T&)>& validate_property_callback() const { return validate_property_callback_; } private: - base::Callback<bool(chromeos::ErrorPtr*, const T&)> + base::Callback<bool(brillo::ErrorPtr*, const T&)> validate_property_callback_; DISALLOW_COPY_AND_ASSIGN(PropertyValidatorObserver); @@ -461,21 +461,21 @@ TEST_F(ExportedPropertySetTest, GetWorksWithUint8List) { TEST_F(ExportedPropertySetTest, SetInvalidInterface) { auto response = SetPropertyOnInterface( - "BadInterfaceName", kStringPropName, chromeos::Any(kTestString)); + "BadInterfaceName", kStringPropName, brillo::Any(kTestString)); ASSERT_EQ(dbus::Message::MESSAGE_ERROR, response->GetMessageType()); ASSERT_EQ(DBUS_ERROR_UNKNOWN_INTERFACE, response->GetErrorName()); } TEST_F(ExportedPropertySetTest, SetBadPropertyName) { auto response = SetPropertyOnInterface( - kTestInterface3, "IAmNotAProperty", chromeos::Any(kTestString)); + kTestInterface3, "IAmNotAProperty", brillo::Any(kTestString)); ASSERT_EQ(dbus::Message::MESSAGE_ERROR, response->GetMessageType()); ASSERT_EQ(DBUS_ERROR_UNKNOWN_PROPERTY, response->GetErrorName()); } TEST_F(ExportedPropertySetTest, SetFailsWithReadOnlyProperty) { auto response = SetPropertyOnInterface( - kTestInterface3, kStringPropName, chromeos::Any(kTestString)); + kTestInterface3, kStringPropName, brillo::Any(kTestString)); ASSERT_EQ(dbus::Message::MESSAGE_ERROR, response->GetMessageType()); ASSERT_EQ(DBUS_ERROR_PROPERTY_READ_ONLY, response->GetErrorName()); } @@ -483,19 +483,16 @@ TEST_F(ExportedPropertySetTest, SetFailsWithReadOnlyProperty) { TEST_F(ExportedPropertySetTest, SetFailsWithMismatchedValueType) { p_->string_prop_.SetAccessMode(ExportedPropertyBase::Access::kReadWrite); auto response = SetPropertyOnInterface( - kTestInterface3, kStringPropName, chromeos::Any(true)); + kTestInterface3, kStringPropName, brillo::Any(true)); ASSERT_EQ(dbus::Message::MESSAGE_ERROR, response->GetMessageType()); ASSERT_EQ(DBUS_ERROR_INVALID_ARGS, response->GetErrorName()); } namespace { -bool SetInvalidProperty(chromeos::ErrorPtr* error, Unused) { - chromeos::Error::AddTo(error, - FROM_HERE, - errors::dbus::kDomain, - DBUS_ERROR_INVALID_ARGS, - "Invalid value"); +bool SetInvalidProperty(brillo::ErrorPtr* error, Unused) { + brillo::Error::AddTo(error, FROM_HERE, errors::dbus::kDomain, + DBUS_ERROR_INVALID_ARGS, "Invalid value"); return false; } @@ -507,12 +504,12 @@ TEST_F(ExportedPropertySetTest, SetFailsWithValidator) { p_->string_prop_.SetValidator( property_validator.validate_property_callback()); - chromeos::ErrorPtr error = chromeos::Error::Create( + brillo::ErrorPtr error = brillo::Error::Create( FROM_HERE, errors::dbus::kDomain, DBUS_ERROR_INVALID_ARGS, ""); EXPECT_CALL(property_validator, ValidateProperty(_, kTestString)) .WillOnce(Invoke(SetInvalidProperty)); auto response = SetPropertyOnInterface( - kTestInterface3, kStringPropName, chromeos::Any(kTestString)); + kTestInterface3, kStringPropName, brillo::Any(kTestString)); ASSERT_EQ(dbus::Message::MESSAGE_ERROR, response->GetMessageType()); ASSERT_EQ(DBUS_ERROR_INVALID_ARGS, response->GetErrorName()); } @@ -526,7 +523,7 @@ TEST_F(ExportedPropertySetTest, SetWorksWithValidator) { EXPECT_CALL(property_validator, ValidateProperty(_, kTestString)) .WillOnce(Return(true)); auto response = SetPropertyOnInterface( - kTestInterface3, kStringPropName, chromeos::Any(kTestString)); + kTestInterface3, kStringPropName, brillo::Any(kTestString)); ASSERT_NE(dbus::Message::MESSAGE_ERROR, response->GetMessageType()); ASSERT_EQ(kTestString, p_->string_prop_.value()); } @@ -542,7 +539,7 @@ TEST_F(ExportedPropertySetTest, SetWorksWithSameValue) { // No need to validate the value if it is the same as the current one. EXPECT_CALL(property_validator, ValidateProperty(_, _)).Times(0); auto response = SetPropertyOnInterface( - kTestInterface3, kStringPropName, chromeos::Any(kTestString)); + kTestInterface3, kStringPropName, brillo::Any(kTestString)); ASSERT_NE(dbus::Message::MESSAGE_ERROR, response->GetMessageType()); ASSERT_EQ(kTestString, p_->string_prop_.value()); } @@ -550,7 +547,7 @@ TEST_F(ExportedPropertySetTest, SetWorksWithSameValue) { TEST_F(ExportedPropertySetTest, SetWorksWithoutValidator) { p_->string_prop_.SetAccessMode(ExportedPropertyBase::Access::kReadWrite); auto response = SetPropertyOnInterface( - kTestInterface3, kStringPropName, chromeos::Any(kTestString)); + kTestInterface3, kStringPropName, brillo::Any(kTestString)); ASSERT_NE(dbus::Message::MESSAGE_ERROR, response->GetMessageType()); ASSERT_EQ(kTestString, p_->string_prop_.value()); } @@ -592,4 +589,4 @@ TEST_F(ExportedPropertySetTest, SignalsAreParsable) { } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/mock_dbus_object.h b/brillo/dbus/mock_dbus_object.h index 2c30970..75cfb71 100644 --- a/chromeos/dbus/mock_dbus_object.h +++ b/brillo/dbus/mock_dbus_object.h @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_MOCK_DBUS_OBJECT_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_MOCK_DBUS_OBJECT_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_MOCK_DBUS_OBJECT_H_ +#define LIBCHROMEOS_BRILLO_DBUS_MOCK_DBUS_OBJECT_H_ #include <string> -#include <chromeos/dbus/async_event_sequencer.h> -#include <chromeos/dbus/dbus_object.h> +#include <brillo/dbus/async_event_sequencer.h> +#include <brillo/dbus/dbus_object.h> #include <gmock/gmock.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { class MockDBusObject : public DBusObject { @@ -27,6 +27,6 @@ class MockDBusObject : public DBusObject { }; // class MockDBusObject } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_MOCK_DBUS_OBJECT_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_MOCK_DBUS_OBJECT_H_ diff --git a/chromeos/dbus/mock_exported_object_manager.h b/brillo/dbus/mock_exported_object_manager.h index 2b49dbd..5a45ec3 100644 --- a/chromeos/dbus/mock_exported_object_manager.h +++ b/brillo/dbus/mock_exported_object_manager.h @@ -2,24 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_MOCK_EXPORTED_OBJECT_MANAGER_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_MOCK_EXPORTED_OBJECT_MANAGER_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_MOCK_EXPORTED_OBJECT_MANAGER_H_ +#define LIBCHROMEOS_BRILLO_DBUS_MOCK_EXPORTED_OBJECT_MANAGER_H_ #include <string> -#include <chromeos/dbus/async_event_sequencer.h> -#include <chromeos/dbus/exported_object_manager.h> +#include <brillo/dbus/async_event_sequencer.h> +#include <brillo/dbus/exported_object_manager.h> #include <dbus/object_path.h> #include <gmock/gmock.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { class MockExportedObjectManager : public ExportedObjectManager { public: using CompletionAction = - chromeos::dbus_utils::AsyncEventSequencer::CompletionAction; + brillo::dbus_utils::AsyncEventSequencer::CompletionAction; using ExportedObjectManager::ExportedObjectManager; ~MockExportedObjectManager() override = default; @@ -35,8 +35,8 @@ class MockExportedObjectManager : public ExportedObjectManager { const std::string& interface_name)); }; -} // namespace dbus_utils +} // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_MOCK_EXPORTED_OBJECT_MANAGER_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_MOCK_EXPORTED_OBJECT_MANAGER_H_ diff --git a/chromeos/dbus/test.proto b/brillo/dbus/test.proto index 84607a3..84607a3 100644 --- a/chromeos/dbus/test.proto +++ b/brillo/dbus/test.proto diff --git a/chromeos/dbus/utils.cc b/brillo/dbus/utils.cc index 3f58dd8..4fbd0ef 100644 --- a/chromeos/dbus/utils.cc +++ b/brillo/dbus/utils.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/dbus/utils.h> +#include <brillo/dbus/utils.h> #include <tuple> #include <vector> #include <base/bind.h> #include <base/memory/scoped_ptr.h> -#include <chromeos/errors/error_codes.h> -#include <chromeos/strings/string_utils.h> +#include <brillo/errors/error_codes.h> +#include <brillo/strings/string_utils.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { std::unique_ptr<dbus::Response> CreateDBusErrorResponse( @@ -25,7 +25,7 @@ std::unique_ptr<dbus::Response> CreateDBusErrorResponse( } std::unique_ptr<dbus::Response> GetDBusError(dbus::MethodCall* method_call, - const chromeos::Error* error) { + const brillo::Error* error) { CHECK(error) << "Error object must be specified"; std::string error_name = DBUS_ERROR_FAILED; // Default error code. std::string error_message; @@ -51,7 +51,7 @@ std::unique_ptr<dbus::Response> GetDBusError(dbus::MethodCall* method_call, return CreateDBusErrorResponse(method_call, error_name, error_message); } -void AddDBusError(chromeos::ErrorPtr* error, +void AddDBusError(brillo::ErrorPtr* error, const std::string& dbus_error_name, const std::string& dbus_error_message) { std::vector<std::string> parts = string_utils::Split(dbus_error_message, ";"); @@ -92,4 +92,4 @@ void AddDBusError(chromeos::ErrorPtr* error, } } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/dbus/utils.h b/brillo/dbus/utils.h index 52c33f7..af76ed4 100644 --- a/chromeos/dbus/utils.h +++ b/brillo/dbus/utils.h @@ -2,43 +2,43 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_DBUS_UTILS_H_ -#define LIBCHROMEOS_CHROMEOS_DBUS_UTILS_H_ +#ifndef LIBCHROMEOS_BRILLO_DBUS_UTILS_H_ +#define LIBCHROMEOS_BRILLO_DBUS_UTILS_H_ #include <memory> #include <string> -#include <chromeos/chromeos_export.h> -#include <chromeos/errors/error.h> +#include <brillo/brillo_export.h> +#include <brillo/errors/error.h> #include <dbus/exported_object.h> #include <dbus/message.h> #include <dbus/scoped_dbus_error.h> -namespace chromeos { +namespace brillo { namespace dbus_utils { // A helper function to create a D-Bus error response object as unique_ptr<>. -CHROMEOS_EXPORT std::unique_ptr<dbus::Response> CreateDBusErrorResponse( +BRILLO_EXPORT std::unique_ptr<dbus::Response> CreateDBusErrorResponse( dbus::MethodCall* method_call, const std::string& error_name, const std::string& error_message); -// Create a D-Bus error response object from chromeos::Error. If the last +// Create a D-Bus error response object from brillo::Error. If the last // error in the error chain belongs to "dbus" error domain, its error code // and message are directly translated to D-Bus error code and message. // Any inner errors are formatted as "domain/code:message" string and appended // to the D-Bus error message, delimited by semi-colons. -CHROMEOS_EXPORT std::unique_ptr<dbus::Response> GetDBusError( +BRILLO_EXPORT std::unique_ptr<dbus::Response> GetDBusError( dbus::MethodCall* method_call, - const chromeos::Error* error); + const brillo::Error* error); // AddDBusError() is the opposite of GetDBusError(). It de-serializes the Error // object received over D-Bus. -CHROMEOS_EXPORT void AddDBusError(chromeos::ErrorPtr* error, - const std::string& dbus_error_name, - const std::string& dbus_error_message); +BRILLO_EXPORT void AddDBusError(brillo::ErrorPtr* error, + const std::string& dbus_error_name, + const std::string& dbus_error_message); } // namespace dbus_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_DBUS_UTILS_H_ +#endif // LIBCHROMEOS_BRILLO_DBUS_UTILS_H_ diff --git a/chromeos/errors/error.cc b/brillo/errors/error.cc index b3fa711..1236220 100644 --- a/chromeos/errors/error.cc +++ b/brillo/errors/error.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/errors/error.h> +#include <brillo/errors/error.h> #include <base/logging.h> #include <base/strings/stringprintf.h> -using chromeos::Error; -using chromeos::ErrorPtr; +using brillo::Error; +using brillo::ErrorPtr; namespace { inline void LogError(const tracked_objects::Location& location, @@ -18,7 +18,7 @@ inline void LogError(const tracked_objects::Location& location, // Use logging::LogMessage() directly instead of LOG(ERROR) to substitute // the current error location with the location passed in to the Error object. // This way the log will contain the actual location of the error, and not - // as if it always comes from chromeos/errors/error.cc(22). + // as if it always comes from brillo/errors/error.cc(22). logging::LogMessage( location.file_name(), location.line_number(), logging::LOG_ERROR).stream() << location.function_name() << "(...): " diff --git a/chromeos/errors/error.h b/brillo/errors/error.h index eb8406c..2c0f089 100644 --- a/chromeos/errors/error.h +++ b/brillo/errors/error.h @@ -2,23 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_ERRORS_ERROR_H_ -#define LIBCHROMEOS_CHROMEOS_ERRORS_ERROR_H_ +#ifndef LIBCHROMEOS_BRILLO_ERRORS_ERROR_H_ +#define LIBCHROMEOS_BRILLO_ERRORS_ERROR_H_ #include <memory> #include <string> #include <base/macros.h> #include <base/tracked_objects.h> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> -namespace chromeos { +namespace brillo { class Error; // Forward declaration. using ErrorPtr = std::unique_ptr<Error>; -class CHROMEOS_EXPORT Error { +class BRILLO_EXPORT Error { public: virtual ~Error() = default; @@ -124,6 +124,6 @@ class CHROMEOS_EXPORT Error { DISALLOW_COPY_AND_ASSIGN(Error); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_ERRORS_ERROR_H_ +#endif // LIBCHROMEOS_BRILLO_ERRORS_ERROR_H_ diff --git a/chromeos/errors/error_codes.cc b/brillo/errors/error_codes.cc index 14af14b..4e48b4e 100644 --- a/chromeos/errors/error_codes.cc +++ b/brillo/errors/error_codes.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/errors/error_codes.h> +#include <brillo/errors/error_codes.h> #include <base/posix/safe_strerror.h> -namespace chromeos { +namespace brillo { namespace errors { namespace dbus { @@ -222,4 +222,4 @@ void AddSystemError(ErrorPtr* error, } // namespace system } // namespace errors -} // namespace chromeos +} // namespace brillo diff --git a/brillo/errors/error_codes.h b/brillo/errors/error_codes.h new file mode 100644 index 0000000..0189e00 --- /dev/null +++ b/brillo/errors/error_codes.h @@ -0,0 +1,43 @@ +// Copyright 2014 The Chromium OS Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LIBCHROMEOS_BRILLO_ERRORS_ERROR_CODES_H_ +#define LIBCHROMEOS_BRILLO_ERRORS_ERROR_CODES_H_ + +#include <string> + +#include <brillo/brillo_export.h> +#include <brillo/errors/error.h> + +namespace brillo { +namespace errors { + +namespace dbus { +BRILLO_EXPORT extern const char kDomain[]; +} // namespace dbus + +namespace json { +BRILLO_EXPORT extern const char kDomain[]; +BRILLO_EXPORT extern const char kParseError[]; +BRILLO_EXPORT extern const char kObjectExpected[]; +} // namespace json + +namespace http { +BRILLO_EXPORT extern const char kDomain[]; +} // namespace http + +namespace system { +BRILLO_EXPORT extern const char kDomain[]; + +// Adds an Error object to the error chain identified by |error|, using +// the system error code (see "errno"). +BRILLO_EXPORT void AddSystemError(ErrorPtr* error, + const tracked_objects::Location& location, + int errnum); +} // namespace system + +} // namespace errors +} // namespace brillo + +#endif // LIBCHROMEOS_BRILLO_ERRORS_ERROR_CODES_H_ diff --git a/chromeos/errors/error_codes_unittest.cc b/brillo/errors/error_codes_unittest.cc index 49633da..2baa28f 100644 --- a/chromeos/errors/error_codes_unittest.cc +++ b/brillo/errors/error_codes_unittest.cc @@ -2,32 +2,32 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/errors/error_codes.h> +#include <brillo/errors/error_codes.h> #include <gtest/gtest.h> -using chromeos::errors::system::AddSystemError; +using brillo::errors::system::AddSystemError; TEST(SystemErrorCodes, AddTo) { - chromeos::ErrorPtr error; + brillo::ErrorPtr error; AddSystemError(&error, FROM_HERE, ENOENT); - EXPECT_EQ(chromeos::errors::system::kDomain, error->GetDomain()); + EXPECT_EQ(brillo::errors::system::kDomain, error->GetDomain()); EXPECT_EQ("ENOENT", error->GetCode()); EXPECT_EQ("No such file or directory", error->GetMessage()); error.reset(); AddSystemError(&error, FROM_HERE, EPROTO); - EXPECT_EQ(chromeos::errors::system::kDomain, error->GetDomain()); + EXPECT_EQ(brillo::errors::system::kDomain, error->GetDomain()); EXPECT_EQ("EPROTO", error->GetCode()); EXPECT_EQ("Protocol error", error->GetMessage()); error.reset(); } TEST(SystemErrorCodes, AddTo_UnknownError) { - chromeos::ErrorPtr error; + brillo::ErrorPtr error; AddSystemError(&error, FROM_HERE, 10000); - EXPECT_EQ(chromeos::errors::system::kDomain, error->GetDomain()); + EXPECT_EQ(brillo::errors::system::kDomain, error->GetDomain()); EXPECT_EQ("error_10000", error->GetCode()); EXPECT_EQ("Unknown error 10000", error->GetMessage()); } diff --git a/chromeos/errors/error_unittest.cc b/brillo/errors/error_unittest.cc index 9e6a2e9..517dab5 100644 --- a/chromeos/errors/error_unittest.cc +++ b/brillo/errors/error_unittest.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/errors/error.h> +#include <brillo/errors/error.h> #include <gtest/gtest.h> -using chromeos::Error; +using brillo::Error; namespace { -chromeos::ErrorPtr GenerateNetworkError() { +brillo::ErrorPtr GenerateNetworkError() { tracked_objects::Location loc("GenerateNetworkError", "error_unittest.cc", 15, @@ -18,15 +18,15 @@ chromeos::ErrorPtr GenerateNetworkError() { return Error::Create(loc, "network", "not_found", "Resource not found"); } -chromeos::ErrorPtr GenerateHttpError() { - chromeos::ErrorPtr inner = GenerateNetworkError(); +brillo::ErrorPtr GenerateHttpError() { + brillo::ErrorPtr inner = GenerateNetworkError(); return Error::Create(FROM_HERE, "HTTP", "404", "Not found", std::move(inner)); } } // namespace TEST(Error, Single) { - chromeos::ErrorPtr err = GenerateNetworkError(); + brillo::ErrorPtr err = GenerateNetworkError(); EXPECT_EQ("network", err->GetDomain()); EXPECT_EQ("not_found", err->GetCode()); EXPECT_EQ("Resource not found", err->GetMessage()); @@ -45,7 +45,7 @@ TEST(Error, Single) { } TEST(Error, Nested) { - chromeos::ErrorPtr err = GenerateHttpError(); + brillo::ErrorPtr err = GenerateHttpError(); EXPECT_EQ("HTTP", err->GetDomain()); EXPECT_EQ("404", err->GetCode()); EXPECT_EQ("Not found", err->GetMessage()); @@ -62,10 +62,10 @@ TEST(Error, Nested) { } TEST(Error, Clone) { - chromeos::ErrorPtr err = GenerateHttpError(); - chromeos::ErrorPtr clone = err->Clone(); - const chromeos::Error* error1 = err.get(); - const chromeos::Error* error2 = clone.get(); + brillo::ErrorPtr err = GenerateHttpError(); + brillo::ErrorPtr clone = err->Clone(); + const brillo::Error* error1 = err.get(); + const brillo::Error* error2 = clone.get(); while (error1 && error2) { EXPECT_NE(error1, error2); EXPECT_EQ(error1->GetDomain(), error2->GetDomain()); diff --git a/chromeos/file_utils.cc b/brillo/file_utils.cc index ba08acc..24ed347 100644 --- a/chromeos/file_utils.cc +++ b/brillo/file_utils.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/file_utils.h" +#include "brillo/file_utils.h" #include <fcntl.h> #include <unistd.h> @@ -13,7 +13,7 @@ #include <base/logging.h> #include <base/posix/eintr_wrapper.h> -namespace chromeos { +namespace brillo { namespace { @@ -162,4 +162,4 @@ bool TouchFile(const base::FilePath& path) { return TouchFile(path, kPermissions600, geteuid(), getegid()); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/file_utils.h b/brillo/file_utils.h index 4cb1f46..968588b 100644 --- a/chromeos/file_utils.h +++ b/brillo/file_utils.h @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_FILE_UTILS_H_ -#define LIBCHROMEOS_CHROMEOS_FILE_UTILS_H_ +#ifndef LIBCHROMEOS_BRILLO_FILE_UTILS_H_ +#define LIBCHROMEOS_BRILLO_FILE_UTILS_H_ #include <sys/types.h> #include <base/files/file_path.h> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> -namespace chromeos { +namespace brillo { // Ensures a regular file owned by user |uid| and group |gid| exists at |path|. // Any other entity at |path| will be deleted and replaced with an empty @@ -19,17 +19,17 @@ namespace chromeos { // Should be safe to use in all directories, including tmpdirs with the sticky // bit set. // Returns true if the file existed or was able to be created. -CHROMEOS_EXPORT bool TouchFile(const base::FilePath& path, - int new_file_permissions, - uid_t uid, - gid_t gid); +BRILLO_EXPORT bool TouchFile(const base::FilePath& path, + int new_file_permissions, + uid_t uid, + gid_t gid); // Convenience version of TouchFile() defaulting to 600 permissions and the // current euid/egid. // Should be safe to use in all directories, including tmpdirs with the sticky // bit set. -CHROMEOS_EXPORT bool TouchFile(const base::FilePath& path); +BRILLO_EXPORT bool TouchFile(const base::FilePath& path); -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_FILE_UTILS_H_ +#endif // LIBCHROMEOS_BRILLO_FILE_UTILS_H_ diff --git a/chromeos/file_utils_unittest.cc b/brillo/file_utils_unittest.cc index 0c23986..f8898a0 100644 --- a/chromeos/file_utils_unittest.cc +++ b/brillo/file_utils_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/file_utils.h" +#include "brillo/file_utils.h" #include <sys/stat.h> #include <unistd.h> @@ -13,7 +13,7 @@ #include <base/files/scoped_temp_dir.h> #include <gtest/gtest.h> -namespace chromeos { +namespace brillo { class FileUtilsTest : public testing::Test { public: @@ -132,4 +132,4 @@ TEST_F(FileUtilsTest, TouchFileExistingPermissionsUnchanged) { ExpectFilePermissions(kPermissions777); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/flag_helper.cc b/brillo/flag_helper.cc index c1a65d9..337e8da 100644 --- a/chromeos/flag_helper.cc +++ b/brillo/flag_helper.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/flag_helper.h" +#include "brillo/flag_helper.h" #include <memory> #include <stdio.h> @@ -16,7 +16,7 @@ #include <base/strings/stringprintf.h> #include <base/strings/string_number_conversions.h> -namespace chromeos { +namespace brillo { Flag::Flag(const char* name, const char* default_value, @@ -28,7 +28,7 @@ Flag::Flag(const char* name, visible_(visible) { } -class HelpFlag : public chromeos::Flag { +class HelpFlag : public brillo::Flag { public: HelpFlag() : Flag("help", "false", "Show this help message", true) {} @@ -151,7 +151,7 @@ const char* StringFlag::GetType() const { } namespace { -chromeos::FlagHelper* instance_ = nullptr; +brillo::FlagHelper* instance_ = nullptr; } // namespace FlagHelper::FlagHelper() : command_line_(nullptr) { @@ -161,7 +161,7 @@ FlagHelper::FlagHelper() : command_line_(nullptr) { FlagHelper::~FlagHelper() { } -chromeos::FlagHelper* FlagHelper::GetInstance() { +brillo::FlagHelper* FlagHelper::GetInstance() { if (!instance_) instance_ = new FlagHelper(); @@ -176,7 +176,7 @@ void FlagHelper::ResetForTesting() { void FlagHelper::Init(int argc, const char* const* argv, std::string help_usage) { - chromeos::FlagHelper* helper = GetInstance(); + brillo::FlagHelper* helper = GetInstance(); if (!helper->command_line_) { if (!base::CommandLine::InitializedForCurrentProcess()) base::CommandLine::Init(argc, argv); @@ -264,4 +264,4 @@ std::string FlagHelper::GetHelpMessage() const { return help; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/flag_helper.h b/brillo/flag_helper.h index b20ac7e..4e770a2 100644 --- a/chromeos/flag_helper.h +++ b/brillo/flag_helper.h @@ -32,12 +32,12 @@ // // -- // -// #include <chromeos/flag_helper.h> +// #include <brillo/flag_helper.h> // #include <stdio.h> // // int main(int argc, char** argv) { // DEFINE_int32(example, 0, "Example int flag"); -// chromeos::FlagHelper::Init(argc, argv, "Test application."); +// brillo::FlagHelper::Init(argc, argv, "Test application."); // // printf("You passed in %d to --example command line flag\n", // FLAGS_example); @@ -50,8 +50,8 @@ // values passed in to the command line, Init(...) must be called after // all the DEFINE_xxxx macros have instantiated the variables. -#ifndef LIBCHROMEOS_CHROMEOS_FLAG_HELPER_H_ -#define LIBCHROMEOS_CHROMEOS_FLAG_HELPER_H_ +#ifndef LIBCHROMEOS_BRILLO_FLAG_HELPER_H_ +#define LIBCHROMEOS_BRILLO_FLAG_HELPER_H_ #include <map> #include <memory> @@ -59,9 +59,9 @@ #include <base/command_line.h> #include <base/macros.h> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> -namespace chromeos { +namespace brillo { // The corresponding class representation of a command line flag, used // to keep track of pointers to the FLAGS_xxxx variables so that they @@ -86,7 +86,7 @@ class Flag { bool visible_; }; -class CHROMEOS_EXPORT BoolFlag final : public Flag { +class BRILLO_EXPORT BoolFlag final : public Flag { public: BoolFlag(const char* name, bool* value, @@ -103,7 +103,7 @@ class CHROMEOS_EXPORT BoolFlag final : public Flag { bool* no_value_; }; -class CHROMEOS_EXPORT Int32Flag final : public Flag { +class BRILLO_EXPORT Int32Flag final : public Flag { public: Int32Flag(const char* name, int* value, @@ -118,7 +118,7 @@ class CHROMEOS_EXPORT Int32Flag final : public Flag { int* value_; }; -class CHROMEOS_EXPORT Int64Flag final : public Flag { +class BRILLO_EXPORT Int64Flag final : public Flag { public: Int64Flag(const char* name, int64_t* value, @@ -133,7 +133,7 @@ class CHROMEOS_EXPORT Int64Flag final : public Flag { int64_t* value_; }; -class CHROMEOS_EXPORT UInt64Flag final : public Flag { +class BRILLO_EXPORT UInt64Flag final : public Flag { public: UInt64Flag(const char* name, uint64_t* value, @@ -148,7 +148,7 @@ class CHROMEOS_EXPORT UInt64Flag final : public Flag { uint64_t* value_; }; -class CHROMEOS_EXPORT DoubleFlag final : public Flag { +class BRILLO_EXPORT DoubleFlag final : public Flag { public: DoubleFlag(const char* name, double* value, @@ -163,7 +163,7 @@ class CHROMEOS_EXPORT DoubleFlag final : public Flag { double* value_; }; -class CHROMEOS_EXPORT StringFlag final : public Flag { +class BRILLO_EXPORT StringFlag final : public Flag { public: StringFlag(const char* name, std::string* value, @@ -184,11 +184,10 @@ class CHROMEOS_EXPORT StringFlag final : public Flag { // set bool flags to false. Creating the FLAGS_noxxxx variables here // will also ensure a compiler error will be thrown if another flag // is created with a conflicting name. -#define DEFINE_type(type, classtype, name, value, help) \ - type FLAGS_##name = value; \ - chromeos::FlagHelper::GetInstance()->AddFlag( \ - std::unique_ptr<chromeos::Flag>( \ - new chromeos::classtype(#name, &FLAGS_##name, #value, help, true))); +#define DEFINE_type(type, classtype, name, value, help) \ + type FLAGS_##name = value; \ + brillo::FlagHelper::GetInstance()->AddFlag(std::unique_ptr<brillo::Flag>( \ + new brillo::classtype(#name, &FLAGS_##name, #value, help, true))); #define DEFINE_int32(name, value, help) \ DEFINE_type(int, Int32Flag, name, value, help) @@ -206,18 +205,18 @@ class CHROMEOS_EXPORT StringFlag final : public Flag { #define DEFINE_bool(name, value, help) \ bool FLAGS_##name = value; \ bool FLAGS_no##name = !value; \ - chromeos::FlagHelper::GetInstance()->AddFlag( \ - std::unique_ptr<chromeos::Flag>(new chromeos::BoolFlag( \ + brillo::FlagHelper::GetInstance()->AddFlag( \ + std::unique_ptr<brillo::Flag>(new brillo::BoolFlag( \ #name, &FLAGS_##name, &FLAGS_no##name, #value, help, true))); \ - chromeos::FlagHelper::GetInstance()->AddFlag( \ - std::unique_ptr<chromeos::Flag>(new chromeos::BoolFlag( \ + brillo::FlagHelper::GetInstance()->AddFlag( \ + std::unique_ptr<brillo::Flag>(new brillo::BoolFlag( \ "no" #name, &FLAGS_no##name, &FLAGS_##name, #value, help, false))); // The FlagHelper class is a singleton class used for registering command // line flags and pointers to their associated scoped variables, so that // the variables can be updated once the command line arguments have been // parsed by base::CommandLine. -class CHROMEOS_EXPORT FlagHelper final { +class BRILLO_EXPORT FlagHelper final { public: // The singleton accessor function. static FlagHelper* GetInstance(); @@ -270,6 +269,6 @@ class CHROMEOS_EXPORT FlagHelper final { DISALLOW_COPY_AND_ASSIGN(FlagHelper); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_FLAG_HELPER_H_ +#endif // LIBCHROMEOS_BRILLO_FLAG_HELPER_H_ diff --git a/chromeos/flag_helper_unittest.cc b/brillo/flag_helper_unittest.cc index 3178aaa..29c6429 100644 --- a/chromeos/flag_helper_unittest.cc +++ b/brillo/flag_helper_unittest.cc @@ -8,19 +8,17 @@ #include <base/command_line.h> #include <base/macros.h> -#include <chromeos/flag_helper.h> +#include <brillo/flag_helper.h> #include <gtest/gtest.h> -namespace chromeos { +namespace brillo { class FlagHelperTest : public ::testing::Test { public: FlagHelperTest() {} - ~FlagHelperTest() override { chromeos::FlagHelper::ResetForTesting(); } - static void SetUpTestCase() { - base::CommandLine::Init(0, nullptr); - } + ~FlagHelperTest() override { brillo::FlagHelper::ResetForTesting(); } + static void SetUpTestCase() { base::CommandLine::Init(0, nullptr); } }; // Test that the DEFINE_xxxx macros can create the respective variables @@ -45,9 +43,9 @@ TEST_F(FlagHelperTest, Defaults) { const char* argv[] = {"test_program"}; base::CommandLine command_line(arraysize(argv), argv); - chromeos::FlagHelper::GetInstance()->set_command_line_for_testing( + brillo::FlagHelper::GetInstance()->set_command_line_for_testing( &command_line); - chromeos::FlagHelper::Init(arraysize(argv), argv, "TestDefaultTrue"); + brillo::FlagHelper::Init(arraysize(argv), argv, "TestDefaultTrue"); EXPECT_TRUE(FLAGS_bool1); EXPECT_FALSE(FLAGS_bool2); @@ -107,9 +105,9 @@ TEST_F(FlagHelperTest, SetValueDoubleDash) { "--string_2=value"}; base::CommandLine command_line(arraysize(argv), argv); - chromeos::FlagHelper::GetInstance()->set_command_line_for_testing( + brillo::FlagHelper::GetInstance()->set_command_line_for_testing( &command_line); - chromeos::FlagHelper::Init(arraysize(argv), argv, "TestDefaultTrue"); + brillo::FlagHelper::Init(arraysize(argv), argv, "TestDefaultTrue"); EXPECT_TRUE(FLAGS_bool1); EXPECT_FALSE(FLAGS_bool2); @@ -167,9 +165,9 @@ TEST_F(FlagHelperTest, SetValueSingleDash) { "-string_2=value"}; base::CommandLine command_line(arraysize(argv), argv); - chromeos::FlagHelper::GetInstance()->set_command_line_for_testing( + brillo::FlagHelper::GetInstance()->set_command_line_for_testing( &command_line); - chromeos::FlagHelper::Init(arraysize(argv), argv, "TestDefaultTrue"); + brillo::FlagHelper::Init(arraysize(argv), argv, "TestDefaultTrue"); EXPECT_TRUE(FLAGS_bool1); EXPECT_FALSE(FLAGS_bool2); @@ -196,9 +194,9 @@ TEST_F(FlagHelperTest, DuplicateSetValue) { const char* argv[] = {"test_program", "--int32_1=5", "--int32_1=10"}; base::CommandLine command_line(arraysize(argv), argv); - chromeos::FlagHelper::GetInstance()->set_command_line_for_testing( + brillo::FlagHelper::GetInstance()->set_command_line_for_testing( &command_line); - chromeos::FlagHelper::Init(arraysize(argv), argv, "TestDuplicateSetvalue"); + brillo::FlagHelper::Init(arraysize(argv), argv, "TestDuplicateSetvalue"); EXPECT_EQ(FLAGS_int32_1, 10); } @@ -210,9 +208,9 @@ TEST_F(FlagHelperTest, FlagTerminator) { const char* argv[] = {"test_program", "--int32_1=5", "--", "--int32_1=10"}; base::CommandLine command_line(arraysize(argv), argv); - chromeos::FlagHelper::GetInstance()->set_command_line_for_testing( + brillo::FlagHelper::GetInstance()->set_command_line_for_testing( &command_line); - chromeos::FlagHelper::Init(arraysize(argv), argv, "TestFlagTerminator"); + brillo::FlagHelper::Init(arraysize(argv), argv, "TestFlagTerminator"); EXPECT_EQ(FLAGS_int32_1, 5); } @@ -230,14 +228,14 @@ TEST_F(FlagHelperTest, HelpMessage) { const char* argv[] = {"test_program", "--int_1=value", "--help"}; base::CommandLine command_line(arraysize(argv), argv); - chromeos::FlagHelper::GetInstance()->set_command_line_for_testing( + brillo::FlagHelper::GetInstance()->set_command_line_for_testing( &command_line); FILE* orig = stdout; stdout = stderr; ASSERT_EXIT( - chromeos::FlagHelper::Init(arraysize(argv), argv, "TestHelpMessage"), + brillo::FlagHelper::Init(arraysize(argv), argv, "TestHelpMessage"), ::testing::ExitedWithCode(EX_OK), "TestHelpMessage\n\n" " --bool_1 \\(Test bool flag\\) type: bool default: true\n" @@ -257,13 +255,13 @@ TEST_F(FlagHelperTest, UnknownFlag) { const char* argv[] = {"test_program", "--flag=value"}; base::CommandLine command_line(arraysize(argv), argv); - chromeos::FlagHelper::GetInstance()->set_command_line_for_testing( + brillo::FlagHelper::GetInstance()->set_command_line_for_testing( &command_line); FILE* orig = stdout; stdout = stderr; - ASSERT_EXIT(chromeos::FlagHelper::Init(arraysize(argv), argv, "TestIntExit"), + ASSERT_EXIT(brillo::FlagHelper::Init(arraysize(argv), argv, "TestIntExit"), ::testing::ExitedWithCode(EX_USAGE), "ERROR: unknown command line flag 'flag'"); @@ -278,14 +276,14 @@ TEST_F(FlagHelperTest, BoolParseError) { const char* argv[] = {"test_program", "--bool_1=value"}; base::CommandLine command_line(arraysize(argv), argv); - chromeos::FlagHelper::GetInstance()->set_command_line_for_testing( + brillo::FlagHelper::GetInstance()->set_command_line_for_testing( &command_line); FILE* orig = stdout; stdout = stderr; ASSERT_EXIT( - chromeos::FlagHelper::Init(arraysize(argv), argv, "TestBoolParseError"), + brillo::FlagHelper::Init(arraysize(argv), argv, "TestBoolParseError"), ::testing::ExitedWithCode(EX_DATAERR), "ERROR: illegal value 'value' specified for bool flag 'bool_1'"); @@ -300,15 +298,15 @@ TEST_F(FlagHelperTest, Int32ParseError) { const char* argv[] = {"test_program", "--int_1=value"}; base::CommandLine command_line(arraysize(argv), argv); - chromeos::FlagHelper::GetInstance()->set_command_line_for_testing( + brillo::FlagHelper::GetInstance()->set_command_line_for_testing( &command_line); FILE* orig = stdout; stdout = stderr; - ASSERT_EXIT(chromeos::FlagHelper::Init(arraysize(argv), - argv, - "TestInt32ParseError"), + ASSERT_EXIT(brillo::FlagHelper::Init(arraysize(argv), + argv, + "TestInt32ParseError"), ::testing::ExitedWithCode(EX_DATAERR), "ERROR: illegal value 'value' specified for int flag 'int_1'"); @@ -320,17 +318,17 @@ TEST_F(FlagHelperTest, Int32ParseError) { TEST_F(FlagHelperTest, Int64ParseError) { DEFINE_int64(int64_1, 0, "Test int64 flag"); - const char* argv[] = {"test_program", "--int64_1=value" }; + const char* argv[] = {"test_program", "--int64_1=value"}; base::CommandLine command_line(arraysize(argv), argv); - chromeos::FlagHelper::GetInstance()->set_command_line_for_testing( + brillo::FlagHelper::GetInstance()->set_command_line_for_testing( &command_line); FILE* orig = stdout; stdout = stderr; ASSERT_EXIT( - chromeos::FlagHelper::Init(arraysize(argv), argv, "TestInt64ParseError"), + brillo::FlagHelper::Init(arraysize(argv), argv, "TestInt64ParseError"), ::testing::ExitedWithCode(EX_DATAERR), "ERROR: illegal value 'value' specified for int64 flag " "'int64_1'"); @@ -346,14 +344,14 @@ TEST_F(FlagHelperTest, UInt64ParseError) { const char* argv[] = {"test_program", "--uint64_1=value"}; base::CommandLine command_line(arraysize(argv), argv); - chromeos::FlagHelper::GetInstance()->set_command_line_for_testing( + brillo::FlagHelper::GetInstance()->set_command_line_for_testing( &command_line); FILE* orig = stdout; stdout = stderr; ASSERT_EXIT( - chromeos::FlagHelper::Init(arraysize(argv), argv, "TestUInt64ParseError"), + brillo::FlagHelper::Init(arraysize(argv), argv, "TestUInt64ParseError"), ::testing::ExitedWithCode(EX_DATAERR), "ERROR: illegal value 'value' specified for uint64 flag " "'uint64_1'"); @@ -361,4 +359,4 @@ TEST_F(FlagHelperTest, UInt64ParseError) { stdout = orig; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/glib/abstract_dbus_service.cc b/brillo/glib/abstract_dbus_service.cc index d759427..c5ed27d 100644 --- a/chromeos/glib/abstract_dbus_service.cc +++ b/brillo/glib/abstract_dbus_service.cc @@ -4,12 +4,12 @@ #include <base/logging.h> -#include "chromeos/glib/abstract_dbus_service.h" +#include "brillo/glib/abstract_dbus_service.h" -namespace chromeos { +namespace brillo { namespace dbus { -bool AbstractDbusService::Register(const chromeos::dbus::BusConnection& conn) { +bool AbstractDbusService::Register(const brillo::dbus::BusConnection& conn) { return RegisterExclusiveService(conn, service_interface(), service_name(), @@ -33,4 +33,4 @@ bool AbstractDbusService::Shutdown() { } } // namespace dbus -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/glib/abstract_dbus_service.h b/brillo/glib/abstract_dbus_service.h index c351d2c..8b559df 100644 --- a/chromeos/glib/abstract_dbus_service.h +++ b/brillo/glib/abstract_dbus_service.h @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_GLIB_ABSTRACT_DBUS_SERVICE_H_ -#define LIBCHROMEOS_CHROMEOS_GLIB_ABSTRACT_DBUS_SERVICE_H_ +#ifndef LIBCHROMEOS_BRILLO_GLIB_ABSTRACT_DBUS_SERVICE_H_ +#define LIBCHROMEOS_BRILLO_GLIB_ABSTRACT_DBUS_SERVICE_H_ -#include <chromeos/chromeos_export.h> -#include <chromeos/glib/dbus.h> +#include <brillo/brillo_export.h> +#include <brillo/glib/dbus.h> -namespace chromeos { +namespace brillo { // \precondition No functions in the dbus namespace can be called before // ::g_type_init(); namespace dbus { -class CHROMEOS_EXPORT AbstractDbusService { +class BRILLO_EXPORT AbstractDbusService { public: virtual ~AbstractDbusService() {} @@ -25,7 +25,7 @@ class CHROMEOS_EXPORT AbstractDbusService { // Registers the GObject as a service with the system DBus // TODO(wad) make this testable by making BusConn and Proxy // subclassing friendly. - virtual bool Register(const chromeos::dbus::BusConnection& conn); + virtual bool Register(const brillo::dbus::BusConnection& conn); // Starts the run loop virtual bool Run(); @@ -45,6 +45,6 @@ class CHROMEOS_EXPORT AbstractDbusService { }; } // namespace dbus -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_GLIB_ABSTRACT_DBUS_SERVICE_H_ +#endif // LIBCHROMEOS_BRILLO_GLIB_ABSTRACT_DBUS_SERVICE_H_ diff --git a/chromeos/glib/dbus.cc b/brillo/glib/dbus.cc index b825434..c56a88c 100644 --- a/chromeos/glib/dbus.cc +++ b/brillo/glib/dbus.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/glib/dbus.h" +#include "brillo/glib/dbus.h" #include <dbus/dbus.h> #include <dbus/dbus-glib-bindings.h> @@ -11,7 +11,7 @@ #include <base/logging.h> #include <base/strings/stringprintf.h> -namespace chromeos { +namespace brillo { namespace dbus { bool CallPtrArray(const Proxy& proxy, @@ -218,7 +218,7 @@ bool RegisterExclusiveService(const BusConnection& connection, CHECK(service_name); // Create a proxy to DBus itself so that we can request to become a // service name owner and then register an object at the related service path. - Proxy proxy = chromeos::dbus::Proxy(connection, + Proxy proxy = brillo::dbus::Proxy(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); @@ -353,4 +353,4 @@ DBusHandlerResult SignalWatcher::FilterDBusMessage(DBusConnection* dbus_conn, } } // namespace dbus -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/glib/dbus.h b/brillo/glib/dbus.h index 9ef012e..73a54c9 100644 --- a/chromeos/glib/dbus.h +++ b/brillo/glib/dbus.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_GLIB_DBUS_H_ -#define LIBCHROMEOS_CHROMEOS_GLIB_DBUS_H_ +#ifndef LIBCHROMEOS_BRILLO_GLIB_DBUS_H_ +#define LIBCHROMEOS_BRILLO_GLIB_DBUS_H_ #include <dbus/dbus-glib.h> #include <glib-object.h> @@ -12,13 +12,13 @@ #include <string> #include "base/logging.h" -#include <chromeos/chromeos_export.h> -#include <chromeos/glib/object.h> +#include <brillo/brillo_export.h> +#include <brillo/glib/object.h> struct DBusMessage; struct DBusConnection; -namespace chromeos { +namespace brillo { // \precondition No functions in the dbus namespace can be called before // ::g_type_init(); @@ -33,7 +33,7 @@ namespace dbus { // \models Copyable, Assignable // \related GetSystemBusConnection() -class CHROMEOS_EXPORT BusConnection { +class BRILLO_EXPORT BusConnection { public: typedef ::DBusGConnection* value_type; @@ -69,7 +69,7 @@ class CHROMEOS_EXPORT BusConnection { friend BusConnection GetPrivateBusConnection(const char* address); // Constructor takes ownership - CHROMEOS_PRIVATE explicit BusConnection(::DBusGConnection* x) : object_(x) {} + BRILLO_PRIVATE explicit BusConnection(::DBusGConnection* x) : object_(x) {} value_type object_; }; @@ -85,7 +85,7 @@ inline void swap(BusConnection& x, BusConnection& y) { // to an entity on the bus, a path to an object owned by the entity, and an // interface protocol name used to communicate with the object. -class CHROMEOS_EXPORT Proxy { +class BRILLO_EXPORT Proxy { public: typedef ::DBusGProxy* value_type; @@ -135,18 +135,18 @@ class CHROMEOS_EXPORT Proxy { operator bool() const { return object_; } private: - CHROMEOS_PRIVATE static value_type GetGProxy(const BusConnection& connection, - const char* name, - const char* path, - const char* interface, - bool connect_to_name_owner); + BRILLO_PRIVATE static value_type GetGProxy(const BusConnection& connection, + const char* name, + const char* path, + const char* interface, + bool connect_to_name_owner); - CHROMEOS_PRIVATE static value_type GetGPeerProxy( + BRILLO_PRIVATE static value_type GetGPeerProxy( const BusConnection& connection, const char* path, const char* interface); - CHROMEOS_PRIVATE operator int() const; // for safe bool cast + BRILLO_PRIVATE operator int() const; // for safe bool cast friend void swap(Proxy& x, Proxy& y); value_type object_; @@ -167,11 +167,11 @@ inline void swap(Proxy& x, Proxy& y) { // Type information for the \param object must be installed with // dbus_g_object_type_install_info prior to use. -CHROMEOS_EXPORT bool RegisterExclusiveService(const BusConnection& connection, - const char* interface_name, - const char* service_name, - const char* service_path, - GObject* object); +BRILLO_EXPORT bool RegisterExclusiveService(const BusConnection& connection, + const char* interface_name, + const char* service_name, + const char* service_path, + GObject* object); template<typename F> // F is a function signature class MonitorConnection; @@ -365,7 +365,7 @@ void Disconnect(MonitorConnection<F>* connection) { // something like Call(proxy, method, arg1, arg2, ..., ResultType*) in the // future. However, I don't yet have enough cases to generalize from. -CHROMEOS_EXPORT bool CallPtrArray(const Proxy& proxy, +BRILLO_EXPORT bool CallPtrArray(const Proxy& proxy, const char* method, glib::ScopedPtrArray<const char*>* result); @@ -415,32 +415,32 @@ inline bool RetrieveProperty(const Proxy& proxy, // \brief RetrieveProperties returns a HashTable of all properties for the // specified interface. -CHROMEOS_EXPORT bool RetrieveProperties(const Proxy& proxy, - const char* interface, - glib::ScopedHashTable* result); +BRILLO_EXPORT bool RetrieveProperties(const Proxy& proxy, + const char* interface, + glib::ScopedHashTable* result); // \brief Returns a connection to the system bus. -CHROMEOS_EXPORT BusConnection GetSystemBusConnection(); +BRILLO_EXPORT BusConnection GetSystemBusConnection(); // \brief Returns a private connection to a bus at |address|. -CHROMEOS_EXPORT BusConnection GetPrivateBusConnection(const char* address); +BRILLO_EXPORT BusConnection GetPrivateBusConnection(const char* address); // \brief Calls a method |method_name| with no arguments per the given |path| // and |interface_name|. Ignores return value. -CHROMEOS_EXPORT void CallMethodWithNoArguments(const char* service_name, - const char* path, - const char* interface_name, - const char* method_name); +BRILLO_EXPORT void CallMethodWithNoArguments(const char* service_name, + const char* path, + const char* interface_name, + const char* method_name); // \brief Low-level signal monitor base class. // // Used when there is no definite named signal sender (that Proxy // could be used for). -class CHROMEOS_EXPORT SignalWatcher { +class BRILLO_EXPORT SignalWatcher { public: SignalWatcher() {} ~SignalWatcher(); @@ -451,10 +451,10 @@ class CHROMEOS_EXPORT SignalWatcher { virtual void OnSignal(DBusMessage* message) = 0; // Returns a string matching the D-Bus messages that we want to listen for. - CHROMEOS_PRIVATE std::string GetDBusMatchString() const; + BRILLO_PRIVATE std::string GetDBusMatchString() const; // A D-Bus message filter to receive signals. - CHROMEOS_PRIVATE static DBusHandlerResult FilterDBusMessage( + BRILLO_PRIVATE static DBusHandlerResult FilterDBusMessage( DBusConnection* dbus_conn, DBusMessage* message, void* data); @@ -463,6 +463,6 @@ class CHROMEOS_EXPORT SignalWatcher { }; } // namespace dbus -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_GLIB_DBUS_H_ +#endif // LIBCHROMEOS_BRILLO_GLIB_DBUS_H_ diff --git a/chromeos/glib/object.h b/brillo/glib/object.h index 9bbdb33..c4dc58d 100644 --- a/chromeos/glib/object.h +++ b/brillo/glib/object.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_GLIB_OBJECT_H_ -#define LIBCHROMEOS_CHROMEOS_GLIB_OBJECT_H_ +#ifndef LIBCHROMEOS_BRILLO_GLIB_OBJECT_H_ +#define LIBCHROMEOS_BRILLO_GLIB_OBJECT_H_ #include <glib-object.h> #include <stdint.h> @@ -16,7 +16,7 @@ #include <cstddef> #include <string> -namespace chromeos { +namespace brillo { namespace details { // NOLINT @@ -503,6 +503,6 @@ class ScopedHashTable { }; } // namespace glib -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_GLIB_OBJECT_H_ +#endif // LIBCHROMEOS_BRILLO_GLIB_OBJECT_H_ diff --git a/chromeos/glib/object_unittest.cc b/brillo/glib/object_unittest.cc index 1e53296..5bc4b85 100644 --- a/chromeos/glib/object_unittest.cc +++ b/brillo/glib/object_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/glib/object.h" +#include "brillo/glib/object.h" #include <gtest/gtest.h> @@ -11,11 +11,11 @@ #include <iterator> #include <string> -using chromeos::glib::ScopedPtrArray; -using chromeos::glib::ScopedError; -using chromeos::glib::Retrieve; -using chromeos::glib::Value; -using chromeos::Resetter; +using brillo::glib::ScopedPtrArray; +using brillo::glib::ScopedError; +using brillo::glib::Retrieve; +using brillo::glib::Value; +using brillo::Resetter; namespace { // NOLINT diff --git a/chromeos/http/curl_api.cc b/brillo/http/curl_api.cc index 215c943..96a12f1 100644 --- a/chromeos/http/curl_api.cc +++ b/brillo/http/curl_api.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/http/curl_api.h> +#include <brillo/http/curl_api.h> #include <base/logging.h> -namespace chromeos { +namespace brillo { namespace http { namespace { @@ -181,4 +181,4 @@ std::string CurlApi::MultiStrError(CURLMcode code) const { } } // namespace http -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/http/curl_api.h b/brillo/http/curl_api.h index b3c1171..5c18158 100644 --- a/chromeos/http/curl_api.h +++ b/brillo/http/curl_api.h @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_HTTP_CURL_API_H_ -#define LIBCHROMEOS_CHROMEOS_HTTP_CURL_API_H_ +#ifndef LIBCHROMEOS_BRILLO_HTTP_CURL_API_H_ +#define LIBCHROMEOS_BRILLO_HTTP_CURL_API_H_ #include <curl/curl.h> #include <string> #include <base/macros.h> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> -namespace chromeos { +namespace brillo { namespace http { // Abstract wrapper around libcurl C API that allows us to mock it out in tests. @@ -117,7 +117,7 @@ class CurlInterface { DISALLOW_COPY_AND_ASSIGN(CurlInterface); }; -class CHROMEOS_EXPORT CurlApi : public CurlInterface { +class BRILLO_EXPORT CurlApi : public CurlInterface { public: CurlApi(); ~CurlApi() override; @@ -205,6 +205,6 @@ class CHROMEOS_EXPORT CurlApi : public CurlInterface { }; } // namespace http -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_HTTP_CURL_API_H_ +#endif // LIBCHROMEOS_BRILLO_HTTP_CURL_API_H_ diff --git a/chromeos/http/http_connection.h b/brillo/http/http_connection.h index 014fde0..44d3ccb 100644 --- a/chromeos/http/http_connection.h +++ b/brillo/http/http_connection.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_HTTP_HTTP_CONNECTION_H_ -#define LIBCHROMEOS_CHROMEOS_HTTP_HTTP_CONNECTION_H_ +#ifndef LIBCHROMEOS_BRILLO_HTTP_HTTP_CONNECTION_H_ +#define LIBCHROMEOS_BRILLO_HTTP_HTTP_CONNECTION_H_ #include <memory> #include <string> @@ -11,12 +11,12 @@ #include <base/callback_forward.h> #include <base/macros.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/errors/error.h> -#include <chromeos/http/http_transport.h> -#include <chromeos/streams/stream.h> +#include <brillo/brillo_export.h> +#include <brillo/errors/error.h> +#include <brillo/http/http_transport.h> +#include <brillo/streams/stream.h> -namespace chromeos { +namespace brillo { namespace http { class Response; @@ -40,7 +40,7 @@ class Response; // is received. The class does NOT represent a persistent TCP connection though // (e.g. in keep-alive scenarios). /////////////////////////////////////////////////////////////////////////////// -class CHROMEOS_EXPORT Connection +class BRILLO_EXPORT Connection : public std::enable_shared_from_this<Connection> { public: explicit Connection(const std::shared_ptr<Transport>& transport) @@ -54,10 +54,9 @@ class CHROMEOS_EXPORT Connection // Called by http::Request to initiate the connection with the server. // This normally opens the socket and sends the request headers. virtual bool SendHeaders(const HeaderList& headers, - chromeos::ErrorPtr* error) = 0; + brillo::ErrorPtr* error) = 0; // If needed, this function can be called to send the request body data. - virtual bool SetRequestData(StreamPtr stream, - chromeos::ErrorPtr* error) = 0; + virtual bool SetRequestData(StreamPtr stream, brillo::ErrorPtr* error) = 0; // If needed, this function can be called to customize where the response // data is streamed to. virtual void SetResponseData(StreamPtr stream) = 0; @@ -65,7 +64,7 @@ class CHROMEOS_EXPORT Connection // to receive the response data. The method will block until the whole // response message is received, or if an error occur in which case the // function will return false and fill the error details in |error| object. - virtual bool FinishRequest(chromeos::ErrorPtr* error) = 0; + virtual bool FinishRequest(brillo::ErrorPtr* error) = 0; // Send the request asynchronously and invoke the callback with the response // received. Returns the ID of the pending async request. virtual RequestID FinishRequestAsync(const SuccessCallback& success_callback, @@ -91,7 +90,7 @@ class CHROMEOS_EXPORT Connection // calls will fail with "Stream closed" error. // Returns empty stream on failure and fills in the error information in // |error| object. - virtual StreamPtr ExtractDataStream(chromeos::ErrorPtr* error) = 0; + virtual StreamPtr ExtractDataStream(brillo::ErrorPtr* error) = 0; protected: // |transport_| is mainly used to keep the object alive as long as the @@ -104,6 +103,6 @@ class CHROMEOS_EXPORT Connection }; } // namespace http -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_HTTP_HTTP_CONNECTION_H_ +#endif // LIBCHROMEOS_BRILLO_HTTP_HTTP_CONNECTION_H_ diff --git a/chromeos/http/http_connection_curl.cc b/brillo/http/http_connection_curl.cc index c36a606..4b8e96d 100644 --- a/chromeos/http/http_connection_curl.cc +++ b/brillo/http/http_connection_curl.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/http/http_connection_curl.h> +#include <brillo/http/http_connection_curl.h> #include <base/logging.h> -#include <chromeos/http/http_request.h> -#include <chromeos/http/http_transport_curl.h> -#include <chromeos/streams/memory_stream.h> -#include <chromeos/streams/stream_utils.h> -#include <chromeos/strings/string_utils.h> +#include <brillo/http/http_request.h> +#include <brillo/http/http_transport_curl.h> +#include <brillo/streams/memory_stream.h> +#include <brillo/streams/stream_utils.h> +#include <brillo/strings/string_utils.h> -namespace chromeos { +namespace brillo { namespace http { namespace curl { @@ -72,12 +72,12 @@ Connection::~Connection() { } bool Connection::SendHeaders(const HeaderList& headers, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { headers_.insert(headers.begin(), headers.end()); return true; } -bool Connection::SetRequestData(StreamPtr stream, chromeos::ErrorPtr* error) { +bool Connection::SetRequestData(StreamPtr stream, brillo::ErrorPtr* error) { request_data_stream_ = std::move(stream); return true; } @@ -124,7 +124,7 @@ void Connection::PrepareRequest() { CHECK(header_list_ == nullptr); for (auto pair : headers_) { std::string header = - chromeos::string_utils::Join(": ", pair.first, pair.second); + brillo::string_utils::Join(": ", pair.first, pair.second); VLOG(2) << "Request header: " << header; header_list_ = curl_slist_append(header_list_, header.c_str()); } @@ -149,7 +149,7 @@ void Connection::PrepareRequest() { curl_interface_->EasySetOptPtr(curl_handle_, CURLOPT_HEADERDATA, this); } -bool Connection::FinishRequest(chromeos::ErrorPtr* error) { +bool Connection::FinishRequest(brillo::ErrorPtr* error) { PrepareRequest(); CURLcode ret = curl_interface_->EasyPerform(curl_handle_); if (ret != CURLE_OK) { @@ -193,7 +193,7 @@ std::string Connection::GetResponseHeader( return p != headers_.end() ? p->second : std::string(); } -StreamPtr Connection::ExtractDataStream(chromeos::ErrorPtr* error) { +StreamPtr Connection::ExtractDataStream(brillo::ErrorPtr* error) { if (!response_data_stream_) { stream_utils::ErrorStreamClosed(FROM_HERE, error); } @@ -236,7 +236,7 @@ size_t Connection::header_callback(char* ptr, size_t size, size_t num, void* data) { - using chromeos::string_utils::SplitAtFirst; + using brillo::string_utils::SplitAtFirst; Connection* me = reinterpret_cast<Connection*>(data); size_t hdr_len = size * num; std::string header(ptr, hdr_len); @@ -264,4 +264,4 @@ size_t Connection::header_callback(char* ptr, } // namespace curl } // namespace http -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/http/http_connection_curl.h b/brillo/http/http_connection_curl.h index 32fd450..f173025 100644 --- a/chromeos/http/http_connection_curl.h +++ b/brillo/http/http_connection_curl.h @@ -2,25 +2,25 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_HTTP_HTTP_CONNECTION_CURL_H_ -#define LIBCHROMEOS_CHROMEOS_HTTP_HTTP_CONNECTION_CURL_H_ +#ifndef LIBCHROMEOS_BRILLO_HTTP_HTTP_CONNECTION_CURL_H_ +#define LIBCHROMEOS_BRILLO_HTTP_HTTP_CONNECTION_CURL_H_ #include <map> #include <string> #include <vector> #include <base/macros.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/http/http_connection.h> -#include <chromeos/http/http_transport_curl.h> +#include <brillo/brillo_export.h> +#include <brillo/http/http_connection.h> +#include <brillo/http/http_transport_curl.h> #include <curl/curl.h> -namespace chromeos { +namespace brillo { namespace http { namespace curl { // This is a libcurl-based implementation of http::Connection. -class CHROMEOS_EXPORT Connection : public http::Connection { +class BRILLO_EXPORT Connection : public http::Connection { public: Connection(CURL* curl_handle, const std::string& method, @@ -30,11 +30,10 @@ class CHROMEOS_EXPORT Connection : public http::Connection { // Overrides from http::Connection. // See http_connection.h for description of these methods. - bool SendHeaders(const HeaderList& headers, - chromeos::ErrorPtr* error) override; - bool SetRequestData(StreamPtr stream, chromeos::ErrorPtr* error) override; + bool SendHeaders(const HeaderList& headers, brillo::ErrorPtr* error) override; + bool SetRequestData(StreamPtr stream, brillo::ErrorPtr* error) override; void SetResponseData(StreamPtr stream) override; - bool FinishRequest(chromeos::ErrorPtr* error) override; + bool FinishRequest(brillo::ErrorPtr* error) override; RequestID FinishRequestAsync( const SuccessCallback& success_callback, const ErrorCallback& error_callback) override; @@ -43,28 +42,28 @@ class CHROMEOS_EXPORT Connection : public http::Connection { std::string GetResponseStatusText() const override; std::string GetProtocolVersion() const override; std::string GetResponseHeader(const std::string& header_name) const override; - StreamPtr ExtractDataStream(chromeos::ErrorPtr* error) override; + StreamPtr ExtractDataStream(brillo::ErrorPtr* error) override; protected: // Write data callback. Used by CURL when receiving response data. - CHROMEOS_PRIVATE static size_t write_callback(char* ptr, - size_t size, - size_t num, - void* data); + BRILLO_PRIVATE static size_t write_callback(char* ptr, + size_t size, + size_t num, + void* data); // Read data callback. Used by CURL when sending request body data. - CHROMEOS_PRIVATE static size_t read_callback(char* ptr, + BRILLO_PRIVATE static size_t read_callback(char* ptr, + size_t size, + size_t num, + void* data); + // Write header data callback. Used by CURL when receiving response headers. + BRILLO_PRIVATE static size_t header_callback(char* ptr, size_t size, size_t num, void* data); - // Write header data callback. Used by CURL when receiving response headers. - CHROMEOS_PRIVATE static size_t header_callback(char* ptr, - size_t size, - size_t num, - void* data); // Helper method to set up the |curl_handle_| with all the parameters // pertaining to the current connection. - CHROMEOS_PRIVATE void PrepareRequest(); + BRILLO_PRIVATE void PrepareRequest(); // HTTP request verb, such as "GET", "POST", "PUT", ... std::string method_; @@ -99,6 +98,6 @@ class CHROMEOS_EXPORT Connection : public http::Connection { } // namespace curl } // namespace http -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_HTTP_HTTP_CONNECTION_CURL_H_ +#endif // LIBCHROMEOS_BRILLO_HTTP_HTTP_CONNECTION_CURL_H_ diff --git a/chromeos/http/http_connection_curl_unittest.cc b/brillo/http/http_connection_curl_unittest.cc index f099b0f..90a5626 100644 --- a/chromeos/http/http_connection_curl_unittest.cc +++ b/brillo/http/http_connection_curl_unittest.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/http/http_connection_curl.h> +#include <brillo/http/http_connection_curl.h> #include <algorithm> #include <set> #include <base/callback.h> -#include <chromeos/http/http_request.h> -#include <chromeos/http/http_transport.h> -#include <chromeos/http/mock_curl_api.h> -#include <chromeos/http/mock_transport.h> -#include <chromeos/streams/memory_stream.h> -#include <chromeos/streams/mock_stream.h> -#include <chromeos/strings/string_utils.h> -#include <chromeos/mime_utils.h> +#include <brillo/http/http_request.h> +#include <brillo/http/http_transport.h> +#include <brillo/http/mock_curl_api.h> +#include <brillo/http/mock_transport.h> +#include <brillo/streams/memory_stream.h> +#include <brillo/streams/mock_stream.h> +#include <brillo/strings/string_utils.h> +#include <brillo/mime_utils.h> #include <gmock/gmock.h> #include <gtest/gtest.h> @@ -25,7 +25,7 @@ using testing::Return; using testing::SetArgPointee; using testing::_; -namespace chromeos { +namespace brillo { namespace http { namespace curl { @@ -321,4 +321,4 @@ TEST_F(HttpCurlConnectionTest, FinishRequest) { } // namespace curl } // namespace http -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/http/http_connection_fake.cc b/brillo/http/http_connection_fake.cc index e671984..dfb40a3 100644 --- a/chromeos/http/http_connection_fake.cc +++ b/brillo/http/http_connection_fake.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/http/http_connection_fake.h> +#include <brillo/http/http_connection_fake.h> #include <base/logging.h> -#include <chromeos/bind_lambda.h> -#include <chromeos/http/http_request.h> -#include <chromeos/mime_utils.h> -#include <chromeos/streams/memory_stream.h> -#include <chromeos/strings/string_utils.h> +#include <brillo/bind_lambda.h> +#include <brillo/http/http_request.h> +#include <brillo/mime_utils.h> +#include <brillo/streams/memory_stream.h> +#include <brillo/strings/string_utils.h> -namespace chromeos { +namespace brillo { namespace http { namespace fake { @@ -27,18 +27,18 @@ Connection::~Connection() { } bool Connection::SendHeaders(const HeaderList& headers, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { request_.AddHeaders(headers); return true; } -bool Connection::SetRequestData(StreamPtr stream, chromeos::ErrorPtr* error) { +bool Connection::SetRequestData(StreamPtr stream, brillo::ErrorPtr* error) { request_.SetData(std::move(stream)); return true; } -bool Connection::FinishRequest(chromeos::ErrorPtr* error) { - using chromeos::string_utils::ToString; +bool Connection::FinishRequest(brillo::ErrorPtr* error) { + using brillo::string_utils::ToString; request_.AddHeaders( {{request_header::kContentLength, ToString(request_.GetData().size())}}); fake::Transport* transport = static_cast<fake::Transport*>(transport_.get()); @@ -49,7 +49,7 @@ bool Connection::FinishRequest(chromeos::ErrorPtr* error) { << " request at " << request_.GetURL(); response_.ReplyText(status_code::NotFound, "<html><body>Not found</body></html>", - chromeos::mime::text::kHtml); + brillo::mime::text::kHtml); } else { handler.Run(request_, &response_); } @@ -72,7 +72,7 @@ RequestID Connection::FinishRequestAsync( void Connection::FinishRequestAsyncHelper( const SuccessCallback& success_callback, const ErrorCallback& error_callback) { - chromeos::ErrorPtr error; + brillo::ErrorPtr error; if (!FinishRequest(&error)) { error_callback.Run(1, error.get()); } else { @@ -98,7 +98,7 @@ std::string Connection::GetResponseHeader( return response_.GetHeader(header_name); } -StreamPtr Connection::ExtractDataStream(chromeos::ErrorPtr* error) { +StreamPtr Connection::ExtractDataStream(brillo::ErrorPtr* error) { // HEAD requests must not return body. if (request_.GetMethod() != request_type::kHead) { return MemoryStream::OpenRef(response_.GetData(), error); @@ -110,4 +110,4 @@ StreamPtr Connection::ExtractDataStream(chromeos::ErrorPtr* error) { } // namespace fake } // namespace http -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/http/http_connection_fake.h b/brillo/http/http_connection_fake.h index 710f59a..cc05fbd 100644 --- a/chromeos/http/http_connection_fake.h +++ b/brillo/http/http_connection_fake.h @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_HTTP_HTTP_CONNECTION_FAKE_H_ -#define LIBCHROMEOS_CHROMEOS_HTTP_HTTP_CONNECTION_FAKE_H_ +#ifndef LIBCHROMEOS_BRILLO_HTTP_HTTP_CONNECTION_FAKE_H_ +#define LIBCHROMEOS_BRILLO_HTTP_HTTP_CONNECTION_FAKE_H_ #include <map> #include <string> #include <vector> #include <base/macros.h> -#include <chromeos/http/http_connection.h> -#include <chromeos/http/http_transport_fake.h> +#include <brillo/http/http_connection.h> +#include <brillo/http/http_transport_fake.h> -namespace chromeos { +namespace brillo { namespace http { namespace fake { @@ -27,11 +27,10 @@ class Connection : public http::Connection { // Overrides from http::Connection. // See http_connection.h for description of these methods. - bool SendHeaders(const HeaderList& headers, - chromeos::ErrorPtr* error) override; - bool SetRequestData(StreamPtr stream, chromeos::ErrorPtr* error) override; + bool SendHeaders(const HeaderList& headers, brillo::ErrorPtr* error) override; + bool SetRequestData(StreamPtr stream, brillo::ErrorPtr* error) override; void SetResponseData(StreamPtr stream) override {} - bool FinishRequest(chromeos::ErrorPtr* error) override; + bool FinishRequest(brillo::ErrorPtr* error) override; RequestID FinishRequestAsync(const SuccessCallback& success_callback, const ErrorCallback& error_callback) override; @@ -39,7 +38,7 @@ class Connection : public http::Connection { std::string GetResponseStatusText() const override; std::string GetProtocolVersion() const override; std::string GetResponseHeader(const std::string& header_name) const override; - StreamPtr ExtractDataStream(chromeos::ErrorPtr* error) override; + StreamPtr ExtractDataStream(brillo::ErrorPtr* error) override; private: // A helper method for FinishRequestAsync() implementation. @@ -58,6 +57,6 @@ class Connection : public http::Connection { } // namespace fake } // namespace http -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_HTTP_HTTP_CONNECTION_FAKE_H_ +#endif // LIBCHROMEOS_BRILLO_HTTP_HTTP_CONNECTION_FAKE_H_ diff --git a/chromeos/http/http_form_data.cc b/brillo/http/http_form_data.cc index 149f544..4d8f6f0 100644 --- a/chromeos/http/http_form_data.cc +++ b/brillo/http/http_form_data.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/http/http_form_data.h> +#include <brillo/http/http_form_data.h> #include <limits> @@ -10,14 +10,14 @@ #include <base/rand_util.h> #include <base/strings/stringprintf.h> -#include <chromeos/errors/error_codes.h> -#include <chromeos/http/http_transport.h> -#include <chromeos/mime_utils.h> -#include <chromeos/streams/file_stream.h> -#include <chromeos/streams/input_stream_set.h> -#include <chromeos/streams/memory_stream.h> +#include <brillo/errors/error_codes.h> +#include <brillo/http/http_transport.h> +#include <brillo/mime_utils.h> +#include <brillo/streams/file_stream.h> +#include <brillo/streams/input_stream_set.h> +#include <brillo/streams/memory_stream.h> -namespace chromeos { +namespace brillo { namespace http { namespace form_header { @@ -158,7 +158,7 @@ bool MultiPartFormField::AddFileField(const std::string& name, const base::FilePath& file_path, const std::string& content_disposition, const std::string& content_type, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { StreamPtr stream = FileStream::Open(file_path, Stream::AccessMode::READ, FileStream::Disposition::OPEN_EXISTING, error); @@ -201,7 +201,7 @@ void FormData::AddTextField(const std::string& name, const std::string& data) { bool FormData::AddFileField(const std::string& name, const base::FilePath& file_path, const std::string& content_type, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { return form_data_.AddFileField( name, file_path, content_disposition::kFormData, content_type, error); } @@ -218,4 +218,4 @@ StreamPtr FormData::ExtractDataStream() { } } // namespace http -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/http/http_form_data.h b/brillo/http/http_form_data.h index 9d857ba..8bbc946 100644 --- a/chromeos/http/http_form_data.h +++ b/brillo/http/http_form_data.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_HTTP_HTTP_FORM_DATA_H_ -#define LIBCHROMEOS_CHROMEOS_HTTP_HTTP_FORM_DATA_H_ +#ifndef LIBCHROMEOS_BRILLO_HTTP_HTTP_FORM_DATA_H_ +#define LIBCHROMEOS_BRILLO_HTTP_HTTP_FORM_DATA_H_ #include <memory> #include <string> @@ -11,16 +11,16 @@ #include <base/files/file_path.h> #include <base/macros.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/errors/error.h> -#include <chromeos/streams/stream.h> +#include <brillo/brillo_export.h> +#include <brillo/errors/error.h> +#include <brillo/streams/stream.h> -namespace chromeos { +namespace brillo { namespace http { namespace content_disposition { -CHROMEOS_EXPORT extern const char kFormData[]; -CHROMEOS_EXPORT extern const char kFile[]; +BRILLO_EXPORT extern const char kFormData[]; +BRILLO_EXPORT extern const char kFile[]; } // namespace content_disposition // An abstract base class for all types of form fields used by FormData class. @@ -30,7 +30,7 @@ CHROMEOS_EXPORT extern const char kFile[]; // http://www.ietf.org/rfc/rfc2388 // For more details on MIME and content headers, see the following RFC: // http://www.ietf.org/rfc/rfc2045 -class CHROMEOS_EXPORT FormField { +class BRILLO_EXPORT FormField { public: // The constructor that takes the basic data part information common to // all part types. An example of part's headers could include: @@ -92,7 +92,7 @@ class CHROMEOS_EXPORT FormField { }; // Simple text form field. -class CHROMEOS_EXPORT TextFormField : public FormField { +class BRILLO_EXPORT TextFormField : public FormField { public: // Constructor. Parameters: // name: field name @@ -114,7 +114,7 @@ class CHROMEOS_EXPORT TextFormField : public FormField { }; // File upload form field. -class CHROMEOS_EXPORT FileFormField : public FormField { +class BRILLO_EXPORT FileFormField : public FormField { public: // Constructor. Parameters: // name: field name @@ -148,7 +148,7 @@ class CHROMEOS_EXPORT FileFormField : public FormField { // This is used directly by FormData class to build the request body for // form upload. It can also be used with multiple file uploads for a single // file field, when the uploaded files should be sent as "multipart/mixed". -class CHROMEOS_EXPORT MultiPartFormField : public FormField { +class BRILLO_EXPORT MultiPartFormField : public FormField { public: // Constructor. Parameters: // name: field name @@ -177,7 +177,7 @@ class CHROMEOS_EXPORT MultiPartFormField : public FormField { const base::FilePath& file_path, const std::string& content_disposition, const std::string& content_type, - chromeos::ErrorPtr* error); + brillo::ErrorPtr* error); // Returns a boundary string used to separate multipart form fields. const std::string& GetBoundary() const { return boundary_; } @@ -195,7 +195,7 @@ class CHROMEOS_EXPORT MultiPartFormField : public FormField { }; // A class representing a multipart form data for sending as HTTP POST request. -class CHROMEOS_EXPORT FormData final { +class BRILLO_EXPORT FormData final { public: FormData(); // Allows to specify a custom |boundary| separator string. @@ -212,7 +212,7 @@ class CHROMEOS_EXPORT FormData final { bool AddFileField(const std::string& name, const base::FilePath& file_path, const std::string& content_type, - chromeos::ErrorPtr* error); + brillo::ErrorPtr* error); // Returns the complete content type string to be used in HTTP requests. std::string GetContentType() const; @@ -228,6 +228,6 @@ class CHROMEOS_EXPORT FormData final { }; } // namespace http -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_HTTP_HTTP_FORM_DATA_H_ +#endif // LIBCHROMEOS_BRILLO_HTTP_HTTP_FORM_DATA_H_ diff --git a/chromeos/http/http_form_data_unittest.cc b/brillo/http/http_form_data_unittest.cc index fccef00..842225d 100644 --- a/chromeos/http/http_form_data_unittest.cc +++ b/brillo/http/http_form_data_unittest.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/http/http_form_data.h> +#include <brillo/http/http_form_data.h> #include <set> #include <base/files/file_util.h> #include <base/files/scoped_temp_dir.h> -#include <chromeos/mime_utils.h> -#include <chromeos/streams/file_stream.h> -#include <chromeos/streams/input_stream_set.h> +#include <brillo/mime_utils.h> +#include <brillo/streams/file_stream.h> +#include <brillo/streams/input_stream_set.h> #include <gtest/gtest.h> -namespace chromeos { +namespace brillo { namespace http { namespace { std::string GetFormFieldData(FormField* field) { @@ -199,4 +199,4 @@ TEST(HttpFormData, FormData) { EXPECT_EQ(expected_data, (std::string{data.begin(), data.end()})); } } // namespace http -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/http/http_request.cc b/brillo/http/http_request.cc index f99f7d2..2784b8e 100644 --- a/chromeos/http/http_request.cc +++ b/brillo/http/http_request.cc @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/http/http_request.h> +#include <brillo/http/http_request.h> #include <base/bind.h> #include <base/callback.h> #include <base/logging.h> -#include <chromeos/http/http_form_data.h> -#include <chromeos/map_utils.h> -#include <chromeos/mime_utils.h> -#include <chromeos/streams/memory_stream.h> -#include <chromeos/strings/string_utils.h> +#include <brillo/http/http_form_data.h> +#include <brillo/map_utils.h> +#include <brillo/mime_utils.h> +#include <brillo/streams/memory_stream.h> +#include <brillo/strings/string_utils.h> -namespace chromeos { +namespace brillo { namespace http { // request_type @@ -132,7 +132,7 @@ void Request::AddRange(uint64_t from_byte, uint64_t to_byte) { } std::unique_ptr<Response> Request::GetResponseAndBlock( - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { if (!SendRequestIfNeeded(error) || !connection_->FinishRequest(error)) return std::unique_ptr<Response>(); std::unique_ptr<Response> response(new Response(connection_)); @@ -186,27 +186,27 @@ void Request::AddHeaders(const HeaderList& headers) { bool Request::AddRequestBody(const void* data, size_t size, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { if (!SendRequestIfNeeded(error)) return false; StreamPtr stream = MemoryStream::OpenCopyOf(data, size, error); return stream && connection_->SetRequestData(std::move(stream), error); } -bool Request::AddRequestBody(StreamPtr stream, chromeos::ErrorPtr* error) { +bool Request::AddRequestBody(StreamPtr stream, brillo::ErrorPtr* error) { return SendRequestIfNeeded(error) && connection_->SetRequestData(std::move(stream), error); } bool Request::AddRequestBodyAsFormData(std::unique_ptr<FormData> form_data, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { AddHeader(request_header::kContentType, form_data->GetContentType()); if (!SendRequestIfNeeded(error)) return false; return connection_->SetRequestData(form_data->ExtractDataStream(), error); } -bool Request::AddResponseStream(StreamPtr stream, chromeos::ErrorPtr* error) { +bool Request::AddResponseStream(StreamPtr stream, brillo::ErrorPtr* error) { if (!SendRequestIfNeeded(error)) return false; connection_->SetResponseData(std::move(stream)); @@ -239,10 +239,10 @@ const std::string& Request::GetUserAgent() const { return user_agent_; } -bool Request::SendRequestIfNeeded(chromeos::ErrorPtr* error) { +bool Request::SendRequestIfNeeded(brillo::ErrorPtr* error) { if (transport_) { if (!connection_) { - http::HeaderList headers = chromeos::MapToVector(headers_); + http::HeaderList headers = brillo::MapToVector(headers_); std::vector<std::string> ranges; if (method_ != request_type::kHead) { ranges.reserve(ranges_.size()); @@ -251,11 +251,11 @@ bool Request::SendRequestIfNeeded(chromeos::ErrorPtr* error) { p.second != range_value_omitted) { std::string range; if (p.first != range_value_omitted) { - range = chromeos::string_utils::ToString(p.first); + range = brillo::string_utils::ToString(p.first); } range += '-'; if (p.second != range_value_omitted) { - range += chromeos::string_utils::ToString(p.second); + range += brillo::string_utils::ToString(p.second); } ranges.push_back(range); } @@ -264,7 +264,7 @@ bool Request::SendRequestIfNeeded(chromeos::ErrorPtr* error) { if (!ranges.empty()) headers.emplace_back( request_header::kRange, - "bytes=" + chromeos::string_utils::Join(",", ranges)); + "bytes=" + brillo::string_utils::Join(",", ranges)); headers.emplace_back(request_header::kAccept, GetAccept()); if (method_ != request_type::kGet && method_ != request_type::kHead) { @@ -278,7 +278,7 @@ bool Request::SendRequestIfNeeded(chromeos::ErrorPtr* error) { if (connection_) return true; } else { - chromeos::Error::AddTo(error, + brillo::Error::AddTo(error, FROM_HERE, http::kErrorDomain, "response_already_received", @@ -354,4 +354,4 @@ std::string Response::GetHeader(const std::string& header_name) const { } } // namespace http -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/http/http_request.h b/brillo/http/http_request.h index 5c0f086..b47a50c 100644 --- a/chromeos/http/http_request.h +++ b/brillo/http/http_request.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_HTTP_HTTP_REQUEST_H_ -#define LIBCHROMEOS_CHROMEOS_HTTP_HTTP_REQUEST_H_ +#ifndef LIBCHROMEOS_BRILLO_HTTP_HTTP_REQUEST_H_ +#define LIBCHROMEOS_BRILLO_HTTP_HTTP_REQUEST_H_ #include <limits> #include <map> @@ -13,103 +13,103 @@ #include <vector> #include <base/macros.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/errors/error.h> -#include <chromeos/http/http_connection.h> -#include <chromeos/http/http_transport.h> +#include <brillo/brillo_export.h> +#include <brillo/errors/error.h> +#include <brillo/http/http_connection.h> +#include <brillo/http/http_transport.h> -namespace chromeos { +namespace brillo { namespace http { // HTTP request verbs namespace request_type { -CHROMEOS_EXPORT extern const char kOptions[]; -CHROMEOS_EXPORT extern const char kGet[]; -CHROMEOS_EXPORT extern const char kHead[]; -CHROMEOS_EXPORT extern const char kPost[]; -CHROMEOS_EXPORT extern const char kPut[]; -CHROMEOS_EXPORT extern const char kPatch[]; // Non-standard HTTP/1.1 verb -CHROMEOS_EXPORT extern const char kDelete[]; -CHROMEOS_EXPORT extern const char kTrace[]; -CHROMEOS_EXPORT extern const char kConnect[]; -CHROMEOS_EXPORT extern const char kCopy[]; // Non-standard HTTP/1.1 verb -CHROMEOS_EXPORT extern const char kMove[]; // Non-standard HTTP/1.1 verb +BRILLO_EXPORT extern const char kOptions[]; +BRILLO_EXPORT extern const char kGet[]; +BRILLO_EXPORT extern const char kHead[]; +BRILLO_EXPORT extern const char kPost[]; +BRILLO_EXPORT extern const char kPut[]; +BRILLO_EXPORT extern const char kPatch[]; // Non-standard HTTP/1.1 verb +BRILLO_EXPORT extern const char kDelete[]; +BRILLO_EXPORT extern const char kTrace[]; +BRILLO_EXPORT extern const char kConnect[]; +BRILLO_EXPORT extern const char kCopy[]; // Non-standard HTTP/1.1 verb +BRILLO_EXPORT extern const char kMove[]; // Non-standard HTTP/1.1 verb } // namespace request_type // HTTP request header names namespace request_header { -CHROMEOS_EXPORT extern const char kAccept[]; -CHROMEOS_EXPORT extern const char kAcceptCharset[]; -CHROMEOS_EXPORT extern const char kAcceptEncoding[]; -CHROMEOS_EXPORT extern const char kAcceptLanguage[]; -CHROMEOS_EXPORT extern const char kAllow[]; -CHROMEOS_EXPORT extern const char kAuthorization[]; -CHROMEOS_EXPORT extern const char kCacheControl[]; -CHROMEOS_EXPORT extern const char kConnection[]; -CHROMEOS_EXPORT extern const char kContentEncoding[]; -CHROMEOS_EXPORT extern const char kContentLanguage[]; -CHROMEOS_EXPORT extern const char kContentLength[]; -CHROMEOS_EXPORT extern const char kContentLocation[]; -CHROMEOS_EXPORT extern const char kContentMd5[]; -CHROMEOS_EXPORT extern const char kContentRange[]; -CHROMEOS_EXPORT extern const char kContentType[]; -CHROMEOS_EXPORT extern const char kCookie[]; -CHROMEOS_EXPORT extern const char kDate[]; -CHROMEOS_EXPORT extern const char kExpect[]; -CHROMEOS_EXPORT extern const char kExpires[]; -CHROMEOS_EXPORT extern const char kFrom[]; -CHROMEOS_EXPORT extern const char kHost[]; -CHROMEOS_EXPORT extern const char kIfMatch[]; -CHROMEOS_EXPORT extern const char kIfModifiedSince[]; -CHROMEOS_EXPORT extern const char kIfNoneMatch[]; -CHROMEOS_EXPORT extern const char kIfRange[]; -CHROMEOS_EXPORT extern const char kIfUnmodifiedSince[]; -CHROMEOS_EXPORT extern const char kLastModified[]; -CHROMEOS_EXPORT extern const char kMaxForwards[]; -CHROMEOS_EXPORT extern const char kPragma[]; -CHROMEOS_EXPORT extern const char kProxyAuthorization[]; -CHROMEOS_EXPORT extern const char kRange[]; -CHROMEOS_EXPORT extern const char kReferer[]; -CHROMEOS_EXPORT extern const char kTE[]; -CHROMEOS_EXPORT extern const char kTrailer[]; -CHROMEOS_EXPORT extern const char kTransferEncoding[]; -CHROMEOS_EXPORT extern const char kUpgrade[]; -CHROMEOS_EXPORT extern const char kUserAgent[]; -CHROMEOS_EXPORT extern const char kVia[]; -CHROMEOS_EXPORT extern const char kWarning[]; +BRILLO_EXPORT extern const char kAccept[]; +BRILLO_EXPORT extern const char kAcceptCharset[]; +BRILLO_EXPORT extern const char kAcceptEncoding[]; +BRILLO_EXPORT extern const char kAcceptLanguage[]; +BRILLO_EXPORT extern const char kAllow[]; +BRILLO_EXPORT extern const char kAuthorization[]; +BRILLO_EXPORT extern const char kCacheControl[]; +BRILLO_EXPORT extern const char kConnection[]; +BRILLO_EXPORT extern const char kContentEncoding[]; +BRILLO_EXPORT extern const char kContentLanguage[]; +BRILLO_EXPORT extern const char kContentLength[]; +BRILLO_EXPORT extern const char kContentLocation[]; +BRILLO_EXPORT extern const char kContentMd5[]; +BRILLO_EXPORT extern const char kContentRange[]; +BRILLO_EXPORT extern const char kContentType[]; +BRILLO_EXPORT extern const char kCookie[]; +BRILLO_EXPORT extern const char kDate[]; +BRILLO_EXPORT extern const char kExpect[]; +BRILLO_EXPORT extern const char kExpires[]; +BRILLO_EXPORT extern const char kFrom[]; +BRILLO_EXPORT extern const char kHost[]; +BRILLO_EXPORT extern const char kIfMatch[]; +BRILLO_EXPORT extern const char kIfModifiedSince[]; +BRILLO_EXPORT extern const char kIfNoneMatch[]; +BRILLO_EXPORT extern const char kIfRange[]; +BRILLO_EXPORT extern const char kIfUnmodifiedSince[]; +BRILLO_EXPORT extern const char kLastModified[]; +BRILLO_EXPORT extern const char kMaxForwards[]; +BRILLO_EXPORT extern const char kPragma[]; +BRILLO_EXPORT extern const char kProxyAuthorization[]; +BRILLO_EXPORT extern const char kRange[]; +BRILLO_EXPORT extern const char kReferer[]; +BRILLO_EXPORT extern const char kTE[]; +BRILLO_EXPORT extern const char kTrailer[]; +BRILLO_EXPORT extern const char kTransferEncoding[]; +BRILLO_EXPORT extern const char kUpgrade[]; +BRILLO_EXPORT extern const char kUserAgent[]; +BRILLO_EXPORT extern const char kVia[]; +BRILLO_EXPORT extern const char kWarning[]; } // namespace request_header // HTTP response header names namespace response_header { -CHROMEOS_EXPORT extern const char kAcceptRanges[]; -CHROMEOS_EXPORT extern const char kAge[]; -CHROMEOS_EXPORT extern const char kAllow[]; -CHROMEOS_EXPORT extern const char kCacheControl[]; -CHROMEOS_EXPORT extern const char kConnection[]; -CHROMEOS_EXPORT extern const char kContentEncoding[]; -CHROMEOS_EXPORT extern const char kContentLanguage[]; -CHROMEOS_EXPORT extern const char kContentLength[]; -CHROMEOS_EXPORT extern const char kContentLocation[]; -CHROMEOS_EXPORT extern const char kContentMd5[]; -CHROMEOS_EXPORT extern const char kContentRange[]; -CHROMEOS_EXPORT extern const char kContentType[]; -CHROMEOS_EXPORT extern const char kDate[]; -CHROMEOS_EXPORT extern const char kETag[]; -CHROMEOS_EXPORT extern const char kExpires[]; -CHROMEOS_EXPORT extern const char kLastModified[]; -CHROMEOS_EXPORT extern const char kLocation[]; -CHROMEOS_EXPORT extern const char kPragma[]; -CHROMEOS_EXPORT extern const char kProxyAuthenticate[]; -CHROMEOS_EXPORT extern const char kRetryAfter[]; -CHROMEOS_EXPORT extern const char kServer[]; -CHROMEOS_EXPORT extern const char kSetCookie[]; -CHROMEOS_EXPORT extern const char kTrailer[]; -CHROMEOS_EXPORT extern const char kTransferEncoding[]; -CHROMEOS_EXPORT extern const char kUpgrade[]; -CHROMEOS_EXPORT extern const char kVary[]; -CHROMEOS_EXPORT extern const char kVia[]; -CHROMEOS_EXPORT extern const char kWarning[]; -CHROMEOS_EXPORT extern const char kWwwAuthenticate[]; +BRILLO_EXPORT extern const char kAcceptRanges[]; +BRILLO_EXPORT extern const char kAge[]; +BRILLO_EXPORT extern const char kAllow[]; +BRILLO_EXPORT extern const char kCacheControl[]; +BRILLO_EXPORT extern const char kConnection[]; +BRILLO_EXPORT extern const char kContentEncoding[]; +BRILLO_EXPORT extern const char kContentLanguage[]; +BRILLO_EXPORT extern const char kContentLength[]; +BRILLO_EXPORT extern const char kContentLocation[]; +BRILLO_EXPORT extern const char kContentMd5[]; +BRILLO_EXPORT extern const char kContentRange[]; +BRILLO_EXPORT extern const char kContentType[]; +BRILLO_EXPORT extern const char kDate[]; +BRILLO_EXPORT extern const char kETag[]; +BRILLO_EXPORT extern const char kExpires[]; +BRILLO_EXPORT extern const char kLastModified[]; +BRILLO_EXPORT extern const char kLocation[]; +BRILLO_EXPORT extern const char kPragma[]; +BRILLO_EXPORT extern const char kProxyAuthenticate[]; +BRILLO_EXPORT extern const char kRetryAfter[]; +BRILLO_EXPORT extern const char kServer[]; +BRILLO_EXPORT extern const char kSetCookie[]; +BRILLO_EXPORT extern const char kTrailer[]; +BRILLO_EXPORT extern const char kTransferEncoding[]; +BRILLO_EXPORT extern const char kUpgrade[]; +BRILLO_EXPORT extern const char kVary[]; +BRILLO_EXPORT extern const char kVia[]; +BRILLO_EXPORT extern const char kWarning[]; +BRILLO_EXPORT extern const char kWwwAuthenticate[]; } // namespace response_header // HTTP request status (error) codes @@ -211,7 +211,7 @@ class FormData; // and obtain the server response. The returned Response object can be // used to inspect the response code, HTTP headers and/or response body. /////////////////////////////////////////////////////////////////////////////// -class CHROMEOS_EXPORT Request final { +class BRILLO_EXPORT Request final { public: // The main constructor. |url| specifies the remote host address/path // to send the request to. |method| is the HTTP request verb and @@ -237,17 +237,17 @@ class CHROMEOS_EXPORT Request final { void RemoveHeader(const std::string& header); // Adds a request body. This is not to be used with GET method - bool AddRequestBody(const void* data, size_t size, chromeos::ErrorPtr* error); - bool AddRequestBody(StreamPtr stream, chromeos::ErrorPtr* error); + bool AddRequestBody(const void* data, size_t size, brillo::ErrorPtr* error); + bool AddRequestBody(StreamPtr stream, brillo::ErrorPtr* error); // Adds a request body. This is not to be used with GET method. // This method also sets the correct content-type of the request, including // the multipart data boundary. bool AddRequestBodyAsFormData(std::unique_ptr<FormData> form_data, - chromeos::ErrorPtr* error); + brillo::ErrorPtr* error); // Adds a stream for the response. Otherwise a MemoryStream will be used. - bool AddResponseStream(StreamPtr stream, chromeos::ErrorPtr* error); + bool AddResponseStream(StreamPtr stream, brillo::ErrorPtr* error); // Makes a request for a subrange of data. Specifies a partial range with // either from beginning of the data to the specified offset (if |bytes| is @@ -280,7 +280,7 @@ class CHROMEOS_EXPORT Request final { // In case the server couldn't be reached for whatever reason, returns // empty unique_ptr (null). In such a case, the additional error information // can be returned through the optional supplied |error| parameter. - std::unique_ptr<Response> GetResponseAndBlock(chromeos::ErrorPtr* error); + std::unique_ptr<Response> GetResponseAndBlock(brillo::ErrorPtr* error); // Sends out the request and invokes the |success_callback| when the response // is received. In case of an error, the |error_callback| is invoked. @@ -292,7 +292,7 @@ class CHROMEOS_EXPORT Request final { friend class HttpRequestTest; // Helper function to create an http::Connection and send off request headers. - CHROMEOS_PRIVATE bool SendRequestIfNeeded(chromeos::ErrorPtr* error); + BRILLO_PRIVATE bool SendRequestIfNeeded(brillo::ErrorPtr* error); // Implementation that provides particular HTTP transport. std::shared_ptr<Transport> transport_; @@ -337,7 +337,7 @@ class CHROMEOS_EXPORT Request final { // to get to response status, error codes, response HTTP headers and response // data (body) if available. /////////////////////////////////////////////////////////////////////////////// -class CHROMEOS_EXPORT Response final { +class BRILLO_EXPORT Response final { public: explicit Response(const std::shared_ptr<Connection>& connection); ~Response(); @@ -376,6 +376,6 @@ class CHROMEOS_EXPORT Response final { }; } // namespace http -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_HTTP_HTTP_REQUEST_H_ +#endif // LIBCHROMEOS_BRILLO_HTTP_HTTP_REQUEST_H_ diff --git a/chromeos/http/http_request_unittest.cc b/brillo/http/http_request_unittest.cc index 09867ee..ab6c2a5 100644 --- a/chromeos/http/http_request_unittest.cc +++ b/brillo/http/http_request_unittest.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/http/http_request.h> +#include <brillo/http/http_request.h> #include <string> #include <base/callback.h> -#include <chromeos/bind_lambda.h> -#include <chromeos/http/mock_connection.h> -#include <chromeos/http/mock_transport.h> -#include <chromeos/mime_utils.h> -#include <chromeos/streams/mock_stream.h> +#include <brillo/bind_lambda.h> +#include <brillo/http/mock_connection.h> +#include <brillo/http/mock_transport.h> +#include <brillo/mime_utils.h> +#include <brillo/streams/mock_stream.h> #include <gmock/gmock.h> #include <gtest/gtest.h> @@ -23,7 +23,7 @@ using testing::Unused; using testing::WithArg; using testing::_; -namespace chromeos { +namespace brillo { namespace http { MATCHER_P(ContainsStringData, str, "") { @@ -199,4 +199,4 @@ TEST_F(HttpRequestTest, GetResponse) { } } // namespace http -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/http/http_transport.cc b/brillo/http/http_transport.cc index 785e5fd..d77eabe 100644 --- a/chromeos/http/http_transport.cc +++ b/brillo/http/http_transport.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/http/http_transport.h> +#include <brillo/http/http_transport.h> -#include <chromeos/http/http_transport_curl.h> +#include <brillo/http/http_transport_curl.h> -namespace chromeos { +namespace brillo { namespace http { const char kErrorDomain[] = "http_transport"; @@ -16,4 +16,4 @@ std::shared_ptr<Transport> Transport::CreateDefault() { } } // namespace http -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/http/http_transport.h b/brillo/http/http_transport.h index f3f5e47..5b56b5c 100644 --- a/chromeos/http/http_transport.h +++ b/brillo/http/http_transport.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_HTTP_HTTP_TRANSPORT_H_ -#define LIBCHROMEOS_CHROMEOS_HTTP_HTTP_TRANSPORT_H_ +#ifndef LIBCHROMEOS_BRILLO_HTTP_HTTP_TRANSPORT_H_ +#define LIBCHROMEOS_BRILLO_HTTP_HTTP_TRANSPORT_H_ #include <memory> #include <string> @@ -14,13 +14,13 @@ #include <base/location.h> #include <base/macros.h> #include <base/time/time.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/errors/error.h> +#include <brillo/brillo_export.h> +#include <brillo/errors/error.h> -namespace chromeos { +namespace brillo { namespace http { -CHROMEOS_EXPORT extern const char kErrorDomain[]; +BRILLO_EXPORT extern const char kErrorDomain[]; class Request; class Response; @@ -31,15 +31,14 @@ using RequestID = int; using HeaderList = std::vector<std::pair<std::string, std::string>>; using SuccessCallback = base::Callback<void(RequestID, std::unique_ptr<Response>)>; -using ErrorCallback = base::Callback<void(RequestID, const chromeos::Error*)>; +using ErrorCallback = base::Callback<void(RequestID, const brillo::Error*)>; /////////////////////////////////////////////////////////////////////////////// // Transport is a base class for specific implementation of HTTP communication. // This class (and its underlying implementation) is used by http::Request and // http::Response classes to provide HTTP functionality to the clients. /////////////////////////////////////////////////////////////////////////////// -class CHROMEOS_EXPORT Transport - : public std::enable_shared_from_this<Transport> { +class BRILLO_EXPORT Transport : public std::enable_shared_from_this<Transport> { public: Transport() = default; virtual ~Transport() = default; @@ -55,7 +54,7 @@ class CHROMEOS_EXPORT Transport const HeaderList& headers, const std::string& user_agent, const std::string& referer, - chromeos::ErrorPtr* error) = 0; + brillo::ErrorPtr* error) = 0; // Runs |callback| on the task runner (message loop) associated with the // transport. For transports that do not contain references to real message @@ -91,6 +90,6 @@ class CHROMEOS_EXPORT Transport }; } // namespace http -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_HTTP_HTTP_TRANSPORT_H_ +#endif // LIBCHROMEOS_BRILLO_HTTP_HTTP_TRANSPORT_H_ diff --git a/chromeos/http/http_transport_curl.cc b/brillo/http/http_transport_curl.cc index 4bc6208..048429e 100644 --- a/chromeos/http/http_transport_curl.cc +++ b/brillo/http/http_transport_curl.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/http/http_transport_curl.h> +#include <brillo/http/http_transport_curl.h> #include <limits> #include <base/bind.h> #include <base/logging.h> #include <base/message_loop/message_loop.h> -#include <chromeos/http/http_connection_curl.h> -#include <chromeos/http/http_request.h> -#include <chromeos/strings/string_utils.h> +#include <brillo/http/http_connection_curl.h> +#include <brillo/http/http_request.h> +#include <brillo/strings/string_utils.h> namespace { @@ -19,12 +19,12 @@ const char kCACertificatePath[] = #ifdef __ANDROID__ "/system/etc/security/cacerts"; #else - "/usr/share/chromeos-ca-certificates"; + "/usr/share/brillo-ca-certificates"; #endif } // namespace -namespace chromeos { +namespace brillo { namespace http { namespace curl { @@ -119,16 +119,13 @@ std::shared_ptr<http::Connection> Transport::CreateConnection( const HeaderList& headers, const std::string& user_agent, const std::string& referer, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { std::shared_ptr<http::Connection> connection; CURL* curl_handle = curl_interface_->EasyInit(); if (!curl_handle) { LOG(ERROR) << "Failed to initialize CURL"; - chromeos::Error::AddTo(error, - FROM_HERE, - http::kErrorDomain, - "curl_init_failed", - "Failed to initialize CURL"); + brillo::Error::AddTo(error, FROM_HERE, http::kErrorDomain, + "curl_init_failed", "Failed to initialize CURL"); return connection; } @@ -212,7 +209,7 @@ void Transport::RunCallbackAsync(const tracked_objects::Location& from_here, RequestID Transport::StartAsyncTransfer(http::Connection* connection, const SuccessCallback& success_callback, const ErrorCallback& error_callback) { - chromeos::ErrorPtr error; + brillo::ErrorPtr error; if (!SetupAsyncCurl(&error)) { RunCallbackAsync( FROM_HERE, base::Bind(error_callback, 0, base::Owned(error.release()))); @@ -238,7 +235,7 @@ RequestID Transport::StartAsyncTransfer(http::Connection* connection, CURLMcode code = curl_interface_->MultiAddHandle( curl_multi_handle_, curl_connection->curl_handle_); if (code != CURLM_OK) { - chromeos::ErrorPtr error; + brillo::ErrorPtr error; AddMultiCurlError(&error, FROM_HERE, code, curl_interface_.get()); RunCallbackAsync( FROM_HERE, base::Bind(error_callback, 0, base::Owned(error.release()))); @@ -267,40 +264,33 @@ void Transport::SetDefaultTimeout(base::TimeDelta timeout) { connection_timeout_ = timeout; } -void Transport::AddEasyCurlError(chromeos::ErrorPtr* error, +void Transport::AddEasyCurlError(brillo::ErrorPtr* error, const tracked_objects::Location& location, CURLcode code, CurlInterface* curl_interface) { - chromeos::Error::AddTo(error, - location, - "curl_easy_error", - chromeos::string_utils::ToString(code), - curl_interface->EasyStrError(code)); + brillo::Error::AddTo(error, location, "curl_easy_error", + brillo::string_utils::ToString(code), + curl_interface->EasyStrError(code)); } -void Transport::AddMultiCurlError(chromeos::ErrorPtr* error, +void Transport::AddMultiCurlError(brillo::ErrorPtr* error, const tracked_objects::Location& location, CURLMcode code, CurlInterface* curl_interface) { - chromeos::Error::AddTo(error, - location, - "curl_multi_error", - chromeos::string_utils::ToString(code), - curl_interface->MultiStrError(code)); + brillo::Error::AddTo(error, location, "curl_multi_error", + brillo::string_utils::ToString(code), + curl_interface->MultiStrError(code)); } -bool Transport::SetupAsyncCurl(chromeos::ErrorPtr* error) { +bool Transport::SetupAsyncCurl(brillo::ErrorPtr* error) { if (curl_multi_handle_) return true; curl_multi_handle_ = curl_interface_->MultiInit(); if (!curl_multi_handle_) { LOG(ERROR) << "Failed to initialize CURL"; - chromeos::Error::AddTo(error, - FROM_HERE, - http::kErrorDomain, - "curl_init_failed", - "Failed to initialize CURL"); + brillo::Error::AddTo(error, FROM_HERE, http::kErrorDomain, + "curl_init_failed", "Failed to initialize CURL"); return false; } @@ -450,7 +440,7 @@ void Transport::OnTransferComplete(Connection* connection, CURLcode code) { << " has completed " << (code == CURLE_OK ? "successfully" : "with an error"); if (code != CURLE_OK) { - chromeos::ErrorPtr error; + brillo::ErrorPtr error; AddEasyCurlError(&error, FROM_HERE, code, curl_interface_.get()); RunCallbackAsync(FROM_HERE, base::Bind(request_data->error_callback, @@ -459,7 +449,7 @@ void Transport::OnTransferComplete(Connection* connection, CURLcode code) { } else { LOG(INFO) << "Response: " << connection->GetResponseStatusCode() << " (" << connection->GetResponseStatusText() << ")"; - chromeos::ErrorPtr error; + brillo::ErrorPtr error; // Rewind the response data stream to the beginning so the clients can // read the data back. const auto& stream = request_data->connection->response_data_stream_; @@ -520,4 +510,4 @@ void Transport::CleanAsyncConnection(Connection* connection) { } // namespace curl } // namespace http -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/http/http_transport_curl.h b/brillo/http/http_transport_curl.h index 441e0b5..e07f56f 100644 --- a/chromeos/http/http_transport_curl.h +++ b/brillo/http/http_transport_curl.h @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_HTTP_HTTP_TRANSPORT_CURL_H_ -#define LIBCHROMEOS_CHROMEOS_HTTP_HTTP_TRANSPORT_CURL_H_ +#ifndef LIBCHROMEOS_BRILLO_HTTP_HTTP_TRANSPORT_CURL_H_ +#define LIBCHROMEOS_BRILLO_HTTP_HTTP_TRANSPORT_CURL_H_ #include <map> #include <string> #include <utility> #include <base/memory/weak_ptr.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/http/curl_api.h> -#include <chromeos/http/http_transport.h> +#include <brillo/brillo_export.h> +#include <brillo/http/curl_api.h> +#include <brillo/http/http_transport.h> -namespace chromeos { +namespace brillo { namespace http { namespace curl { @@ -27,7 +27,7 @@ class Connection; // functionality to the clients. // See http_transport.h for more details. /////////////////////////////////////////////////////////////////////////////// -class CHROMEOS_EXPORT Transport : public http::Transport { +class BRILLO_EXPORT Transport : public http::Transport { public: // Constructs the transport using the current message loop for async // operations. @@ -46,7 +46,7 @@ class CHROMEOS_EXPORT Transport : public http::Transport { const HeaderList& headers, const std::string& user_agent, const std::string& referer, - chromeos::ErrorPtr* error) override; + brillo::ErrorPtr* error) override; void RunCallbackAsync(const tracked_objects::Location& from_here, const base::Closure& callback) override; @@ -60,13 +60,13 @@ class CHROMEOS_EXPORT Transport : public http::Transport { void SetDefaultTimeout(base::TimeDelta timeout) override; // Helper methods to convert CURL error codes (CURLcode and CURLMcode) - // into chromeos::Error object. - static void AddEasyCurlError(chromeos::ErrorPtr* error, + // into brillo::Error object. + static void AddEasyCurlError(brillo::ErrorPtr* error, const tracked_objects::Location& location, CURLcode code, CurlInterface* curl_interface); - static void AddMultiCurlError(chromeos::ErrorPtr* error, + static void AddMultiCurlError(brillo::ErrorPtr* error, const tracked_objects::Location& location, CURLMcode code, CurlInterface* curl_interface); @@ -77,7 +77,7 @@ class CHROMEOS_EXPORT Transport : public http::Transport { class SocketPollData; // Initializes CURL for async operation. - bool SetupAsyncCurl(chromeos::ErrorPtr* error); + bool SetupAsyncCurl(brillo::ErrorPtr* error); // Stops CURL's async operations. void ShutDownAsyncCurl(); @@ -135,6 +135,6 @@ class CHROMEOS_EXPORT Transport : public http::Transport { } // namespace curl } // namespace http -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_HTTP_HTTP_TRANSPORT_CURL_H_ +#endif // LIBCHROMEOS_BRILLO_HTTP_HTTP_TRANSPORT_CURL_H_ diff --git a/chromeos/http/http_transport_curl_unittest.cc b/brillo/http/http_transport_curl_unittest.cc index 43213c0..131c066 100644 --- a/chromeos/http/http_transport_curl_unittest.cc +++ b/brillo/http/http_transport_curl_unittest.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/http/http_transport_curl.h> +#include <brillo/http/http_transport_curl.h> #include <base/at_exit.h> #include <base/message_loop/message_loop.h> #include <base/run_loop.h> -#include <chromeos/bind_lambda.h> -#include <chromeos/http/http_connection_curl.h> -#include <chromeos/http/http_request.h> -#include <chromeos/http/mock_curl_api.h> +#include <brillo/bind_lambda.h> +#include <brillo/http/http_connection_curl.h> +#include <brillo/http/http_request.h> +#include <brillo/http/mock_curl_api.h> #include <gmock/gmock.h> #include <gtest/gtest.h> @@ -22,7 +22,7 @@ using testing::SetArgPointee; using testing::WithoutArgs; using testing::_; -namespace chromeos { +namespace brillo { namespace http { namespace curl { @@ -302,4 +302,4 @@ TEST_F(HttpCurlTransportTest, RequestGetTimeout) { } // namespace curl } // namespace http -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/http/http_transport_fake.cc b/brillo/http/http_transport_fake.cc index a5346e3..3833449 100644 --- a/chromeos/http/http_transport_fake.cc +++ b/brillo/http/http_transport_fake.cc @@ -2,22 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/http/http_transport_fake.h> +#include <brillo/http/http_transport_fake.h> #include <utility> #include <base/json/json_reader.h> #include <base/json/json_writer.h> #include <base/logging.h> -#include <chromeos/bind_lambda.h> -#include <chromeos/http/http_connection_fake.h> -#include <chromeos/http/http_request.h> -#include <chromeos/mime_utils.h> -#include <chromeos/streams/memory_stream.h> -#include <chromeos/strings/string_utils.h> -#include <chromeos/url_utils.h> +#include <brillo/bind_lambda.h> +#include <brillo/http/http_connection_fake.h> +#include <brillo/http/http_request.h> +#include <brillo/mime_utils.h> +#include <brillo/streams/memory_stream.h> +#include <brillo/strings/string_utils.h> +#include <brillo/url_utils.h> -namespace chromeos { +namespace brillo { using http::fake::Transport; using http::fake::ServerRequestResponseBase; @@ -38,7 +38,7 @@ std::shared_ptr<http::Connection> Transport::CreateConnection( const HeaderList& headers, const std::string& user_agent, const std::string& referer, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { std::shared_ptr<http::Connection> connection; if (create_connection_error_) { if (error) @@ -171,9 +171,9 @@ std::string ServerRequestResponseBase::GetDataAsString() const { std::unique_ptr<base::DictionaryValue> ServerRequestResponseBase::GetDataAsJson() const { - if (chromeos::mime::RemoveParameters( + if (brillo::mime::RemoveParameters( GetHeader(request_header::kContentType)) == - chromeos::mime::application::kJson) { + brillo::mime::application::kJson) { auto value = base::JSONReader::Read(GetDataAsString()); if (value) { base::DictionaryValue* dict = nullptr; @@ -214,18 +214,18 @@ std::string ServerRequestResponseBase::GetHeader( ServerRequest::ServerRequest(const std::string& url, const std::string& method) : method_(method) { - auto params = chromeos::url::GetQueryStringParameters(url); - url_ = chromeos::url::RemoveQueryString(url, true); + auto params = brillo::url::GetQueryStringParameters(url); + url_ = brillo::url::RemoveQueryString(url, true); form_fields_.insert(params.begin(), params.end()); } std::string ServerRequest::GetFormField(const std::string& field_name) const { if (!form_fields_parsed_) { - std::string mime_type = chromeos::mime::RemoveParameters( + std::string mime_type = brillo::mime::RemoveParameters( GetHeader(request_header::kContentType)); - if (mime_type == chromeos::mime::application::kWwwFormUrlEncoded && + if (mime_type == brillo::mime::application::kWwwFormUrlEncoded && !GetData().empty()) { - auto fields = chromeos::data_encoding::WebParamsDecode(GetDataAsString()); + auto fields = brillo::data_encoding::WebParamsDecode(GetDataAsString()); form_fields_.insert(fields.begin(), fields.end()); } form_fields_parsed_ = true; @@ -242,7 +242,7 @@ void ServerResponse::Reply(int status_code, status_code_ = status_code; SetData(MemoryStream::OpenCopyOf(data, data_size, nullptr)); AddHeaders({{response_header::kContentLength, - chromeos::string_utils::ToString(data_size)}, + brillo::string_utils::ToString(data_size)}, {response_header::kContentType, mime_type}}); } @@ -257,8 +257,8 @@ void ServerResponse::ReplyJson(int status_code, const base::Value* json) { base::JSONWriter::WriteWithOptions( *json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &text); std::string mime_type = - chromeos::mime::AppendParameter(chromeos::mime::application::kJson, - chromeos::mime::parameters::kCharset, + brillo::mime::AppendParameter(brillo::mime::application::kJson, + brillo::mime::parameters::kCharset, "utf-8"); ReplyText(status_code, text, mime_type); } @@ -329,4 +329,4 @@ std::string ServerResponse::GetStatusText() const { return std::string(); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/http/http_transport_fake.h b/brillo/http/http_transport_fake.h index 297294e..3d6aecb 100644 --- a/chromeos/http/http_transport_fake.h +++ b/brillo/http/http_transport_fake.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_HTTP_HTTP_TRANSPORT_FAKE_H_ -#define LIBCHROMEOS_CHROMEOS_HTTP_HTTP_TRANSPORT_FAKE_H_ +#ifndef LIBCHROMEOS_BRILLO_HTTP_HTTP_TRANSPORT_FAKE_H_ +#define LIBCHROMEOS_BRILLO_HTTP_HTTP_TRANSPORT_FAKE_H_ #include <map> #include <queue> @@ -13,10 +13,10 @@ #include <base/callback.h> #include <base/values.h> -#include <chromeos/http/http_transport.h> -#include <chromeos/http/http_utils.h> +#include <brillo/http/http_transport.h> +#include <brillo/http/http_utils.h> -namespace chromeos { +namespace brillo { namespace http { namespace fake { @@ -67,7 +67,7 @@ class Transport : public http::Transport { // For tests that wish to simulate critical transport errors, this method // can be used to specify the error to be returned when creating a connection. - void SetCreateConnectionError(chromeos::ErrorPtr create_connection_error) { + void SetCreateConnectionError(brillo::ErrorPtr create_connection_error) { create_connection_error_ = std::move(create_connection_error); } @@ -89,7 +89,7 @@ class Transport : public http::Transport { const HeaderList& headers, const std::string& user_agent, const std::string& referer, - chromeos::ErrorPtr* error) override; + brillo::ErrorPtr* error) override; void RunCallbackAsync(const tracked_objects::Location& from_here, const base::Closure& callback) override; @@ -113,7 +113,7 @@ class Transport : public http::Transport { std::queue<base::Closure> async_callback_queue_; // Fake error to be returned from CreateConnection method. - chromeos::ErrorPtr create_connection_error_; + brillo::ErrorPtr create_connection_error_; DISALLOW_COPY_AND_ASSIGN(Transport); }; @@ -260,6 +260,6 @@ class ServerResponse : public ServerRequestResponseBase { } // namespace fake } // namespace http -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_HTTP_HTTP_TRANSPORT_FAKE_H_ +#endif // LIBCHROMEOS_BRILLO_HTTP_HTTP_TRANSPORT_FAKE_H_ diff --git a/chromeos/http/http_utils.cc b/brillo/http/http_utils.cc index 3413817..c8f5802 100644 --- a/chromeos/http/http_utils.cc +++ b/brillo/http/http_utils.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/http/http_utils.h> +#include <brillo/http/http_utils.h> #include <algorithm> @@ -10,21 +10,21 @@ #include <base/json/json_reader.h> #include <base/json/json_writer.h> #include <base/values.h> -#include <chromeos/data_encoding.h> -#include <chromeos/errors/error_codes.h> -#include <chromeos/mime_utils.h> -#include <chromeos/streams/memory_stream.h> +#include <brillo/data_encoding.h> +#include <brillo/errors/error_codes.h> +#include <brillo/mime_utils.h> +#include <brillo/streams/memory_stream.h> -using chromeos::mime::AppendParameter; -using chromeos::mime::RemoveParameters; +using brillo::mime::AppendParameter; +using brillo::mime::RemoveParameters; -namespace chromeos { +namespace brillo { namespace http { std::unique_ptr<Response> GetAndBlock(const std::string& url, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { return SendRequestWithNoDataAndBlock( request_type::kGet, url, headers, transport, error); } @@ -44,7 +44,7 @@ RequestID Get(const std::string& url, std::unique_ptr<Response> HeadAndBlock(const std::string& url, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { return SendRequestWithNoDataAndBlock( request_type::kHead, url, {}, transport, error); } @@ -66,7 +66,7 @@ std::unique_ptr<Response> PostTextAndBlock(const std::string& url, const std::string& mime_type, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { return PostBinaryAndBlock( url, data.data(), data.size(), mime_type, headers, transport, error); } @@ -96,7 +96,7 @@ std::unique_ptr<Response> SendRequestAndBlock( const std::string& mime_type, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { Request request(url, method, transport); request.AddHeaders(headers); if (data_size > 0) { @@ -114,7 +114,7 @@ std::unique_ptr<Response> SendRequestWithNoDataAndBlock( const std::string& url, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { return SendRequestAndBlock( method, url, nullptr, 0, {}, headers, transport, error); } @@ -133,7 +133,7 @@ RequestID SendRequest(const std::string& method, CHECK(!mime_type.empty()) << "MIME type must be specified if request body " "message is provided"; request.SetContentType(mime_type); - chromeos::ErrorPtr error; + brillo::ErrorPtr error; if (!request.AddRequestBody(std::move(stream), &error)) { transport->RunCallbackAsync( FROM_HERE, base::Bind(error_callback, @@ -186,7 +186,7 @@ std::unique_ptr<Response> PostBinaryAndBlock( const std::string& mime_type, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { return SendRequestAndBlock(request_type::kPost, url, data, @@ -238,12 +238,12 @@ std::unique_ptr<Response> PostFormDataAndBlock( const FormFieldList& data, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error) { - std::string encoded_data = chromeos::data_encoding::WebParamsEncode(data); + brillo::ErrorPtr* error) { + std::string encoded_data = brillo::data_encoding::WebParamsEncode(data); return PostBinaryAndBlock(url, encoded_data.c_str(), encoded_data.size(), - chromeos::mime::application::kWwwFormUrlEncoded, + brillo::mime::application::kWwwFormUrlEncoded, headers, transport, error); @@ -254,7 +254,7 @@ std::unique_ptr<Response> PostFormDataAndBlock( std::unique_ptr<FormData> form_data, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { Request request(url, request_type::kPost, transport); request.AddHeaders(headers); if (!request.AddRequestBodyAsFormData(std::move(form_data), error)) @@ -268,11 +268,11 @@ RequestID PostFormData(const std::string& url, std::shared_ptr<Transport> transport, const SuccessCallback& success_callback, const ErrorCallback& error_callback) { - std::string encoded_data = chromeos::data_encoding::WebParamsEncode(data); + std::string encoded_data = brillo::data_encoding::WebParamsEncode(data); return PostBinary(url, encoded_data.c_str(), encoded_data.size(), - chromeos::mime::application::kWwwFormUrlEncoded, + brillo::mime::application::kWwwFormUrlEncoded, headers, transport, success_callback, @@ -287,7 +287,7 @@ RequestID PostFormData(const std::string& url, const ErrorCallback& error_callback) { Request request(url, request_type::kPost, transport); request.AddHeaders(headers); - chromeos::ErrorPtr error; + brillo::ErrorPtr error; if (!request.AddRequestBodyAsFormData(std::move(form_data), &error)) { transport->RunCallbackAsync( FROM_HERE, base::Bind(error_callback, 0, base::Owned(error.release()))); @@ -300,12 +300,12 @@ std::unique_ptr<Response> PostJsonAndBlock(const std::string& url, const base::Value* json, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { std::string data; if (json) base::JSONWriter::Write(*json, &data); - std::string mime_type = AppendParameter(chromeos::mime::application::kJson, - chromeos::mime::parameters::kCharset, + std::string mime_type = AppendParameter(brillo::mime::application::kJson, + brillo::mime::parameters::kCharset, "utf-8"); return PostBinaryAndBlock( url, data.c_str(), data.size(), mime_type, headers, transport, error); @@ -320,8 +320,8 @@ RequestID PostJson(const std::string& url, std::string data; if (json) base::JSONWriter::Write(*json, &data); - std::string mime_type = AppendParameter(chromeos::mime::application::kJson, - chromeos::mime::parameters::kCharset, + std::string mime_type = AppendParameter(brillo::mime::application::kJson, + brillo::mime::parameters::kCharset, "utf-8"); return PostBinary(url, data.c_str(), @@ -338,12 +338,12 @@ std::unique_ptr<Response> PatchJsonAndBlock( const base::Value* json, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { std::string data; if (json) base::JSONWriter::Write(*json, &data); - std::string mime_type = AppendParameter(chromeos::mime::application::kJson, - chromeos::mime::parameters::kCharset, + std::string mime_type = AppendParameter(brillo::mime::application::kJson, + brillo::mime::parameters::kCharset, "utf-8"); return SendRequestAndBlock(request_type::kPatch, url, @@ -364,24 +364,18 @@ RequestID PatchJson(const std::string& url, std::string data; if (json) base::JSONWriter::Write(*json, &data); - std::string mime_type = AppendParameter(chromeos::mime::application::kJson, - chromeos::mime::parameters::kCharset, - "utf-8"); - return SendRequest(request_type::kPatch, - url, - data.c_str(), - data.size(), - mime_type, - headers, - transport, - success_callback, + std::string mime_type = + AppendParameter(brillo::mime::application::kJson, + brillo::mime::parameters::kCharset, "utf-8"); + return SendRequest(request_type::kPatch, url, data.c_str(), data.size(), + mime_type, headers, transport, success_callback, error_callback); } std::unique_ptr<base::DictionaryValue> ParseJsonResponse( Response* response, int* status_code, - chromeos::ErrorPtr* error) { + brillo::ErrorPtr* error) { if (!response) return std::unique_ptr<base::DictionaryValue>(); @@ -391,13 +385,11 @@ std::unique_ptr<base::DictionaryValue> ParseJsonResponse( // Make sure we have a correct content type. Do not try to parse // binary files, or HTML output. Limit to application/json and text/plain. auto content_type = RemoveParameters(response->GetContentType()); - if (content_type != chromeos::mime::application::kJson && - content_type != chromeos::mime::text::kPlain) { - chromeos::Error::AddTo(error, - FROM_HERE, - chromeos::errors::json::kDomain, - "non_json_content_type", - "Unexpected response content type: " + content_type); + if (content_type != brillo::mime::application::kJson && + content_type != brillo::mime::text::kPlain) { + brillo::Error::AddTo(error, FROM_HERE, brillo::errors::json::kDomain, + "non_json_content_type", + "Unexpected response content type: " + content_type); return std::unique_ptr<base::DictionaryValue>(); } @@ -406,22 +398,18 @@ std::unique_ptr<base::DictionaryValue> ParseJsonResponse( auto value = base::JSONReader::ReadAndReturnError(json, base::JSON_PARSE_RFC, nullptr, &error_message); if (!value) { - chromeos::Error::AddToPrintf(error, - FROM_HERE, - chromeos::errors::json::kDomain, - chromeos::errors::json::kParseError, - "Error '%s' occurred parsing JSON string '%s'", - error_message.c_str(), json.c_str()); + brillo::Error::AddToPrintf(error, FROM_HERE, brillo::errors::json::kDomain, + brillo::errors::json::kParseError, + "Error '%s' occurred parsing JSON string '%s'", + error_message.c_str(), json.c_str()); return std::unique_ptr<base::DictionaryValue>(); } base::DictionaryValue* dict_value = nullptr; if (!value->GetAsDictionary(&dict_value)) { - chromeos::Error::AddToPrintf(error, - FROM_HERE, - chromeos::errors::json::kDomain, - chromeos::errors::json::kObjectExpected, - "Response is not a valid JSON object: '%s'", - json.c_str()); + brillo::Error::AddToPrintf(error, FROM_HERE, brillo::errors::json::kDomain, + brillo::errors::json::kObjectExpected, + "Response is not a valid JSON object: '%s'", + json.c_str()); return std::unique_ptr<base::DictionaryValue>(); } else { // |value| is now owned by |dict_value|, so release the scoped_ptr now. @@ -449,4 +437,4 @@ std::string GetCanonicalHeaderName(const std::string& name) { } } // namespace http -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/http/http_utils.h b/brillo/http/http_utils.h index 679bd6b..7d5f937 100644 --- a/chromeos/http/http_utils.h +++ b/brillo/http/http_utils.h @@ -2,24 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_HTTP_HTTP_UTILS_H_ -#define LIBCHROMEOS_CHROMEOS_HTTP_HTTP_UTILS_H_ +#ifndef LIBCHROMEOS_BRILLO_HTTP_HTTP_UTILS_H_ +#define LIBCHROMEOS_BRILLO_HTTP_HTTP_UTILS_H_ #include <string> #include <utility> #include <vector> -#include <chromeos/chromeos_export.h> -#include <chromeos/errors/error.h> -#include <chromeos/http/http_form_data.h> -#include <chromeos/http/http_request.h> +#include <brillo/brillo_export.h> +#include <brillo/errors/error.h> +#include <brillo/http/http_form_data.h> +#include <brillo/http/http_request.h> namespace base { class Value; class DictionaryValue; } // namespace base -namespace chromeos { +namespace brillo { namespace http { using FormFieldList = std::vector<std::pair<std::string, std::string>>; @@ -38,11 +38,11 @@ using FormFieldList = std::vector<std::pair<std::string, std::string>>; // {{"Authorization", "Bearer TOKEN"}}, // transport, error); // You should do use this instead: -// SendRequestAndBlock(chromeos::http::request_type::kPost, +// SendRequestAndBlock(brillo::http::request_type::kPost, // "http://url", // "data", 4, -// chromeos::mime::text::kPlain, -// {{chromeos::http::request_header::kAuthorization, +// brillo::mime::text::kPlain, +// {{brillo::http::request_header::kAuthorization, // "Bearer TOKEN"}}, // transport, error); // @@ -53,7 +53,7 @@ using FormFieldList = std::vector<std::pair<std::string, std::string>>; // Performs a generic HTTP request with binary data. Success status, // returned data and additional information (such as returned HTTP headers) // can be obtained from the returned Response object. -CHROMEOS_EXPORT std::unique_ptr<Response> SendRequestAndBlock( +BRILLO_EXPORT std::unique_ptr<Response> SendRequestAndBlock( const std::string& method, const std::string& url, const void* data, @@ -61,23 +61,23 @@ CHROMEOS_EXPORT std::unique_ptr<Response> SendRequestAndBlock( const std::string& mime_type, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error); + brillo::ErrorPtr* error); // Same as above, but without sending the request body. // This is especially useful for requests like "GET" and "HEAD". -CHROMEOS_EXPORT std::unique_ptr<Response> SendRequestWithNoDataAndBlock( +BRILLO_EXPORT std::unique_ptr<Response> SendRequestWithNoDataAndBlock( const std::string& method, const std::string& url, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error); + brillo::ErrorPtr* error); // Same as above but asynchronous. On success, |success_callback| is called // with the response object. On failure, |error_callback| is called with the // error details. // Returns the ID of the request which can be used to cancel the pending // request using Transport::CancelRequest(). -CHROMEOS_EXPORT RequestID SendRequest( +BRILLO_EXPORT RequestID SendRequest( const std::string& method, const std::string& url, StreamPtr stream, @@ -92,7 +92,7 @@ CHROMEOS_EXPORT RequestID SendRequest( // available for the duration of the asynchronous operation. // Returns the ID of the request which can be used to cancel the pending // request using Transport::CancelRequest(). -CHROMEOS_EXPORT RequestID SendRequest( +BRILLO_EXPORT RequestID SendRequest( const std::string& method, const std::string& url, const void* data, @@ -106,7 +106,7 @@ CHROMEOS_EXPORT RequestID SendRequest( // Asynchronous version of SendRequestNoData(). // Returns the ID of the request which can be used to cancel the pending // request using Transport::CancelRequest(). -CHROMEOS_EXPORT RequestID SendRequestWithNoData( +BRILLO_EXPORT RequestID SendRequestWithNoData( const std::string& method, const std::string& url, const HeaderList& headers, @@ -117,16 +117,16 @@ CHROMEOS_EXPORT RequestID SendRequestWithNoData( // Performs a GET request. Success status, returned data and additional // information (such as returned HTTP headers) can be obtained from // the returned Response object. -CHROMEOS_EXPORT std::unique_ptr<Response> GetAndBlock( +BRILLO_EXPORT std::unique_ptr<Response> GetAndBlock( const std::string& url, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error); + brillo::ErrorPtr* error); // Asynchronous version of http::Get(). // Returns the ID of the request which can be used to cancel the pending // request using Transport::CancelRequest(). -CHROMEOS_EXPORT RequestID Get( +BRILLO_EXPORT RequestID Get( const std::string& url, const HeaderList& headers, std::shared_ptr<Transport> transport, @@ -136,15 +136,15 @@ CHROMEOS_EXPORT RequestID Get( // Performs a HEAD request. Success status and additional // information (such as returned HTTP headers) can be obtained from // the returned Response object. -CHROMEOS_EXPORT std::unique_ptr<Response> HeadAndBlock( +BRILLO_EXPORT std::unique_ptr<Response> HeadAndBlock( const std::string& url, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error); + brillo::ErrorPtr* error); // Performs an asynchronous HEAD request. // Returns the ID of the request which can be used to cancel the pending // request using Transport::CancelRequest(). -CHROMEOS_EXPORT RequestID Head( +BRILLO_EXPORT RequestID Head( const std::string& url, std::shared_ptr<Transport> transport, const SuccessCallback& success_callback, @@ -153,19 +153,19 @@ CHROMEOS_EXPORT RequestID Head( // Performs a POST request with binary data. Success status, returned data // and additional information (such as returned HTTP headers) can be obtained // from the returned Response object. -CHROMEOS_EXPORT std::unique_ptr<Response> PostBinaryAndBlock( +BRILLO_EXPORT std::unique_ptr<Response> PostBinaryAndBlock( const std::string& url, const void* data, size_t data_size, const std::string& mime_type, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error); + brillo::ErrorPtr* error); // Async version of PostBinary(). // Returns the ID of the request which can be used to cancel the pending // request using Transport::CancelRequest(). -CHROMEOS_EXPORT RequestID PostBinary( +BRILLO_EXPORT RequestID PostBinary( const std::string& url, StreamPtr stream, const std::string& mime_type, @@ -179,7 +179,7 @@ CHROMEOS_EXPORT RequestID PostBinary( // to be available for the duration of the asynchronous operation. // Returns the ID of the request which can be used to cancel the pending // request using Transport::CancelRequest(). -CHROMEOS_EXPORT RequestID PostBinary( +BRILLO_EXPORT RequestID PostBinary( const std::string& url, const void* data, size_t data_size, @@ -192,18 +192,18 @@ CHROMEOS_EXPORT RequestID PostBinary( // Performs a POST request with text data. Success status, returned data // and additional information (such as returned HTTP headers) can be obtained // from the returned Response object. -CHROMEOS_EXPORT std::unique_ptr<Response> PostTextAndBlock( +BRILLO_EXPORT std::unique_ptr<Response> PostTextAndBlock( const std::string& url, const std::string& data, const std::string& mime_type, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error); + brillo::ErrorPtr* error); // Async version of PostText(). // Returns the ID of the request which can be used to cancel the pending // request using Transport::CancelRequest(). -CHROMEOS_EXPORT RequestID PostText( +BRILLO_EXPORT RequestID PostText( const std::string& url, const std::string& data, const std::string& mime_type, @@ -216,17 +216,17 @@ CHROMEOS_EXPORT RequestID PostText( // and additional information (such as returned HTTP headers) can be obtained // from the returned Response object. The form data is a list of key/value // pairs. The data is posed as "application/x-www-form-urlencoded". -CHROMEOS_EXPORT std::unique_ptr<Response> PostFormDataAndBlock( +BRILLO_EXPORT std::unique_ptr<Response> PostFormDataAndBlock( const std::string& url, const FormFieldList& data, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error); + brillo::ErrorPtr* error); // Async version of PostFormData() above. // Returns the ID of the request which can be used to cancel the pending // request using Transport::CancelRequest(). -CHROMEOS_EXPORT RequestID PostFormData( +BRILLO_EXPORT RequestID PostFormData( const std::string& url, const FormFieldList& data, const HeaderList& headers, @@ -238,17 +238,17 @@ CHROMEOS_EXPORT RequestID PostFormData( // Success status, returned data and additional information (such as returned // HTTP headers) can be obtained from the returned Response object. // The data is posed as "multipart/form-data". -CHROMEOS_EXPORT std::unique_ptr<Response> PostFormDataAndBlock( +BRILLO_EXPORT std::unique_ptr<Response> PostFormDataAndBlock( const std::string& url, std::unique_ptr<FormData> form_data, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error); + brillo::ErrorPtr* error); // Async version of PostFormData() above. // Returns the ID of the request which can be used to cancel the pending // request using Transport::CancelRequest(). -CHROMEOS_EXPORT RequestID PostFormData( +BRILLO_EXPORT RequestID PostFormData( const std::string& url, std::unique_ptr<FormData> form_data, const HeaderList& headers, @@ -260,17 +260,17 @@ CHROMEOS_EXPORT RequestID PostFormData( // and additional information (such as returned HTTP headers) can be obtained // from the returned Response object. If a JSON response is expected, // use ParseJsonResponse() method on the returned Response object. -CHROMEOS_EXPORT std::unique_ptr<Response> PostJsonAndBlock( +BRILLO_EXPORT std::unique_ptr<Response> PostJsonAndBlock( const std::string& url, const base::Value* json, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error); + brillo::ErrorPtr* error); // Async version of PostJson(). // Returns the ID of the request which can be used to cancel the pending // request using Transport::CancelRequest(). -CHROMEOS_EXPORT RequestID PostJson( +BRILLO_EXPORT RequestID PostJson( const std::string& url, std::unique_ptr<base::Value> json, const HeaderList& headers, @@ -282,17 +282,17 @@ CHROMEOS_EXPORT RequestID PostJson( // and additional information (such as returned HTTP headers) can be obtained // from the returned Response object. If a JSON response is expected, // use ParseJsonResponse() method on the returned Response object. -CHROMEOS_EXPORT std::unique_ptr<Response> PatchJsonAndBlock( +BRILLO_EXPORT std::unique_ptr<Response> PatchJsonAndBlock( const std::string& url, const base::Value* json, const HeaderList& headers, std::shared_ptr<Transport> transport, - chromeos::ErrorPtr* error); + brillo::ErrorPtr* error); // Async version of PatchJson(). // Returns the ID of the request which can be used to cancel the pending // request using Transport::CancelRequest(). -CHROMEOS_EXPORT RequestID PatchJson( +BRILLO_EXPORT RequestID PatchJson( const std::string& url, std::unique_ptr<base::Value> json, const HeaderList& headers, @@ -303,15 +303,17 @@ CHROMEOS_EXPORT RequestID PatchJson( // Given an http::Response object, parse the body data into Json object. // Returns null if failed. Optional |error| can be passed in to // get the extended error information as to why the parse failed. -CHROMEOS_EXPORT std::unique_ptr<base::DictionaryValue> ParseJsonResponse( - Response* response, int* status_code, chromeos::ErrorPtr* error); +BRILLO_EXPORT std::unique_ptr<base::DictionaryValue> ParseJsonResponse( + Response* response, + int* status_code, + brillo::ErrorPtr* error); // Converts a request header name to canonical form (lowercase with uppercase // first letter and each letter after a hyphen ('-')). // "content-TYPE" will be converted to "Content-Type". -CHROMEOS_EXPORT std::string GetCanonicalHeaderName(const std::string& name); +BRILLO_EXPORT std::string GetCanonicalHeaderName(const std::string& name); } // namespace http -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_HTTP_HTTP_UTILS_H_ +#endif // LIBCHROMEOS_BRILLO_HTTP_HTTP_UTILS_H_ diff --git a/chromeos/http/http_utils_unittest.cc b/brillo/http/http_utils_unittest.cc index 3e9a7c8..ee408b8 100644 --- a/chromeos/http/http_utils_unittest.cc +++ b/brillo/http/http_utils_unittest.cc @@ -7,15 +7,15 @@ #include <vector> #include <base/values.h> -#include <chromeos/bind_lambda.h> -#include <chromeos/http/http_transport_fake.h> -#include <chromeos/http/http_utils.h> -#include <chromeos/mime_utils.h> -#include <chromeos/strings/string_utils.h> -#include <chromeos/url_utils.h> +#include <brillo/bind_lambda.h> +#include <brillo/http/http_transport_fake.h> +#include <brillo/http/http_utils.h> +#include <brillo/mime_utils.h> +#include <brillo/strings/string_utils.h> +#include <brillo/url_utils.h> #include <gtest/gtest.h> -namespace chromeos { +namespace brillo { namespace http { static const char kFakeUrl[] = "http://localhost"; @@ -35,7 +35,7 @@ static void EchoDataHandler(const fake::ServerRequest& request, static void EchoMethodHandler(const fake::ServerRequest& request, fake::ServerResponse* response) { response->ReplyText( - status_code::Ok, request.GetMethod(), chromeos::mime::text::kPlain); + status_code::Ok, request.GetMethod(), brillo::mime::text::kPlain); } /////////////////////////////////////////////////////////////////////////////// @@ -51,12 +51,12 @@ TEST(HttpUtils, SendRequest_BinaryData) { kEchoUrl, custom_data.data(), custom_data.size(), - chromeos::mime::application::kOctet_stream, + brillo::mime::application::kOctet_stream, {}, transport, nullptr); EXPECT_TRUE(response->IsSuccessful()); - EXPECT_EQ(chromeos::mime::application::kOctet_stream, + EXPECT_EQ(brillo::mime::application::kOctet_stream, response->GetContentType()); EXPECT_EQ(custom_data, response->ExtractData()); } @@ -71,7 +71,7 @@ TEST(HttpUtils, SendRequestAsync_BinaryData) { auto success_callback = [&custom_data](RequestID id, std::unique_ptr<http::Response> response) { EXPECT_TRUE(response->IsSuccessful()); - EXPECT_EQ(chromeos::mime::application::kOctet_stream, + EXPECT_EQ(brillo::mime::application::kOctet_stream, response->GetContentType()); EXPECT_EQ(custom_data, response->ExtractData()); }; @@ -82,7 +82,7 @@ TEST(HttpUtils, SendRequestAsync_BinaryData) { kEchoUrl, custom_data.data(), custom_data.size(), - chromeos::mime::application::kOctet_stream, + brillo::mime::application::kOctet_stream, {}, transport, base::Bind(success_callback), @@ -102,12 +102,12 @@ TEST(HttpUtils, SendRequest_Post) { kMethodEchoUrl, custom_data.data(), custom_data.size(), - chromeos::mime::application::kOctet_stream, + brillo::mime::application::kOctet_stream, {}, transport, nullptr); EXPECT_TRUE(response->IsSuccessful()); - EXPECT_EQ(chromeos::mime::text::kPlain, response->GetContentType()); + EXPECT_EQ(brillo::mime::text::kPlain, response->GetContentType()); EXPECT_EQ(request_type::kPost, response->ExtractDataAsString()); } @@ -124,7 +124,7 @@ TEST(HttpUtils, SendRequest_Get) { transport, nullptr); EXPECT_TRUE(response->IsSuccessful()); - EXPECT_EQ(chromeos::mime::text::kPlain, response->GetContentType()); + EXPECT_EQ(brillo::mime::text::kPlain, response->GetContentType()); EXPECT_EQ(request_type::kGet, response->ExtractDataAsString()); } @@ -141,7 +141,7 @@ TEST(HttpUtils, SendRequest_Put) { transport, nullptr); EXPECT_TRUE(response->IsSuccessful()); - EXPECT_EQ(chromeos::mime::text::kPlain, response->GetContentType()); + EXPECT_EQ(brillo::mime::text::kPlain, response->GetContentType()); EXPECT_EQ(request_type::kPut, response->ExtractDataAsString()); } @@ -190,13 +190,13 @@ TEST(HttpUtils, SendRequest_Headers) { transport->AddHandler(json_echo_url, "*", base::Bind(JsonEchoHandler)); auto response = http::SendRequestAndBlock( request_type::kPost, json_echo_url, "abcd", 4, - chromeos::mime::application::kOctet_stream, { + brillo::mime::application::kOctet_stream, { {request_header::kCookie, "flavor=vanilla"}, {request_header::kIfMatch, "*"}, }, transport, nullptr); EXPECT_TRUE(response->IsSuccessful()); - EXPECT_EQ(chromeos::mime::application::kJson, - chromeos::mime::RemoveParameters(response->GetContentType())); + EXPECT_EQ(brillo::mime::application::kJson, + brillo::mime::RemoveParameters(response->GetContentType())); auto json = ParseJsonResponse(response.get(), nullptr, nullptr); std::string value; EXPECT_TRUE(json->GetString("method", &value)); @@ -206,7 +206,7 @@ TEST(HttpUtils, SendRequest_Headers) { EXPECT_TRUE(json->GetString("header.Cookie", &value)); EXPECT_EQ("flavor=vanilla", value); EXPECT_TRUE(json->GetString("header.Content-Type", &value)); - EXPECT_EQ(chromeos::mime::application::kOctet_stream, value); + EXPECT_EQ(brillo::mime::application::kOctet_stream, value); EXPECT_TRUE(json->GetString("header.Content-Length", &value)); EXPECT_EQ("4", value); EXPECT_TRUE(json->GetString("header.If-Match", &value)); @@ -224,7 +224,7 @@ TEST(HttpUtils, Get) { EXPECT_EQ("", request.GetHeader(request_header::kContentType)); response->ReplyText(status_code::Ok, request.GetFormField("test"), - chromeos::mime::text::kPlain); + brillo::mime::text::kPlain); }; std::shared_ptr<fake::Transport> transport(new fake::Transport); @@ -234,11 +234,11 @@ TEST(HttpUtils, Get) { // Make sure Get() actually does the GET request auto response = http::GetAndBlock(kMethodEchoUrl, {}, transport, nullptr); EXPECT_TRUE(response->IsSuccessful()); - EXPECT_EQ(chromeos::mime::text::kPlain, response->GetContentType()); + EXPECT_EQ(brillo::mime::text::kPlain, response->GetContentType()); EXPECT_EQ(request_type::kGet, response->ExtractDataAsString()); for (std::string data : {"blah", "some data", ""}) { - std::string url = chromeos::url::AppendQueryParam(kFakeUrl, "test", data); + std::string url = brillo::url::AppendQueryParam(kFakeUrl, "test", data); response = http::GetAndBlock(url, {}, transport, nullptr); EXPECT_EQ(data, response->ExtractDataAsString()); } @@ -250,7 +250,7 @@ TEST(HttpUtils, Head) { EXPECT_EQ(request_type::kHead, request.GetMethod()); EXPECT_EQ("0", request.GetHeader(request_header::kContentLength)); EXPECT_EQ("", request.GetHeader(request_header::kContentType)); - response->ReplyText(status_code::Ok, "blah", chromeos::mime::text::kPlain); + response->ReplyText(status_code::Ok, "blah", brillo::mime::text::kPlain); }; std::shared_ptr<fake::Transport> transport(new fake::Transport); @@ -258,7 +258,7 @@ TEST(HttpUtils, Head) { auto response = http::HeadAndBlock(kFakeUrl, transport, nullptr); EXPECT_TRUE(response->IsSuccessful()); - EXPECT_EQ(chromeos::mime::text::kPlain, response->GetContentType()); + EXPECT_EQ(brillo::mime::text::kPlain, response->GetContentType()); EXPECT_EQ("", response->ExtractDataAsString()); // Must not have actual body. EXPECT_EQ("4", response->GetHeader(request_header::kContentLength)); } @@ -268,7 +268,7 @@ TEST(HttpUtils, PostBinary) { [](const fake::ServerRequest& request, fake::ServerResponse* response) { EXPECT_EQ(request_type::kPost, request.GetMethod()); EXPECT_EQ("256", request.GetHeader(request_header::kContentLength)); - EXPECT_EQ(chromeos::mime::application::kOctet_stream, + EXPECT_EQ(brillo::mime::application::kOctet_stream, request.GetHeader(request_header::kContentType)); const auto& data = request.GetData(); EXPECT_EQ(256, data.size()); @@ -276,7 +276,7 @@ TEST(HttpUtils, PostBinary) { // Sum up all the bytes. int sum = std::accumulate(data.begin(), data.end(), 0); EXPECT_EQ(32640, sum); // sum(i, i => [0, 255]) = 32640. - response->ReplyText(status_code::Ok, "", chromeos::mime::text::kPlain); + response->ReplyText(status_code::Ok, "", brillo::mime::text::kPlain); }; std::shared_ptr<fake::Transport> transport(new fake::Transport); @@ -303,11 +303,11 @@ TEST(HttpUtils, PostText) { EXPECT_EQ(request_type::kPost, request.GetMethod()); EXPECT_EQ(fake_data.size(), std::stoul(request.GetHeader(request_header::kContentLength))); - EXPECT_EQ(chromeos::mime::text::kPlain, + EXPECT_EQ(brillo::mime::text::kPlain, request.GetHeader(request_header::kContentType)); response->ReplyText(status_code::Ok, request.GetDataAsString(), - chromeos::mime::text::kPlain); + brillo::mime::text::kPlain); }; std::shared_ptr<fake::Transport> transport(new fake::Transport); @@ -315,12 +315,12 @@ TEST(HttpUtils, PostText) { auto response = http::PostTextAndBlock(kFakeUrl, fake_data, - chromeos::mime::text::kPlain, + brillo::mime::text::kPlain, {}, transport, nullptr); EXPECT_TRUE(response->IsSuccessful()); - EXPECT_EQ(chromeos::mime::text::kPlain, response->GetContentType()); + EXPECT_EQ(brillo::mime::text::kPlain, response->GetContentType()); EXPECT_EQ(fake_data, response->ExtractDataAsString()); } @@ -335,7 +335,7 @@ TEST(HttpUtils, PostFormData) { {"field", "field value"}, }, {}, transport, nullptr); EXPECT_TRUE(response->IsSuccessful()); - EXPECT_EQ(chromeos::mime::application::kWwwFormUrlEncoded, + EXPECT_EQ(brillo::mime::application::kWwwFormUrlEncoded, response->GetContentType()); EXPECT_EQ("key=value&field=field+value", response->ExtractDataAsString()); } @@ -369,9 +369,9 @@ TEST(HttpUtils, PostMultipartFormData) { TEST(HttpUtils, PostPatchJson) { auto JsonHandler = [](const fake::ServerRequest& request, fake::ServerResponse* response) { - auto mime_type = chromeos::mime::RemoveParameters( + auto mime_type = brillo::mime::RemoveParameters( request.GetHeader(request_header::kContentType)); - EXPECT_EQ(chromeos::mime::application::kJson, mime_type); + EXPECT_EQ(brillo::mime::application::kJson, mime_type); response->ReplyJson( status_code::Ok, { @@ -417,7 +417,7 @@ TEST(HttpUtils, ParseJsonResponse) { // Test valid JSON responses (with success or error codes). for (auto item : {"200;data", "400;wrong", "500;Internal Server error"}) { - auto pair = chromeos::string_utils::SplitAtFirst(item, ";"); + auto pair = brillo::string_utils::SplitAtFirst(item, ";"); auto response = http::PostFormDataAndBlock( kFakeUrl, { {"code", pair.first}, @@ -428,14 +428,14 @@ TEST(HttpUtils, ParseJsonResponse) { EXPECT_NE(nullptr, json.get()); std::string value; EXPECT_TRUE(json->GetString("data", &value)); - EXPECT_EQ(pair.first, chromeos::string_utils::ToString(code)); + EXPECT_EQ(pair.first, brillo::string_utils::ToString(code)); EXPECT_EQ(pair.second, value); } // Test invalid (non-JSON) response. auto response = http::GetAndBlock("http://bad.url", {}, transport, nullptr); EXPECT_EQ(status_code::NotFound, response->GetStatusCode()); - EXPECT_EQ(chromeos::mime::text::kHtml, response->GetContentType()); + EXPECT_EQ(brillo::mime::text::kHtml, response->GetContentType()); int code = 0; auto json = http::ParseJsonResponse(response.get(), &code, nullptr); EXPECT_EQ(nullptr, json.get()); @@ -494,4 +494,4 @@ TEST(HttpUtils, GetCanonicalHeaderName) { } } // namespace http -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/http/mock_connection.h b/brillo/http/mock_connection.h index ccd62d9..c57aac1 100644 --- a/chromeos/http/mock_connection.h +++ b/brillo/http/mock_connection.h @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_HTTP_MOCK_CONNECTION_H_ -#define LIBCHROMEOS_CHROMEOS_HTTP_MOCK_CONNECTION_H_ +#ifndef LIBCHROMEOS_BRILLO_HTTP_MOCK_CONNECTION_H_ +#define LIBCHROMEOS_BRILLO_HTTP_MOCK_CONNECTION_H_ #include <memory> #include <string> #include <base/macros.h> -#include <chromeos/http/http_connection.h> +#include <brillo/http/http_connection.h> #include <gmock/gmock.h> -namespace chromeos { +namespace brillo { namespace http { class MockConnection : public Connection { @@ -29,16 +29,16 @@ class MockConnection : public Connection { MOCK_CONST_METHOD0(GetResponseStatusText, std::string()); MOCK_CONST_METHOD0(GetProtocolVersion, std::string()); MOCK_CONST_METHOD1(GetResponseHeader, std::string(const std::string&)); - MOCK_CONST_METHOD1(MockExtractDataStream, Stream*(chromeos::ErrorPtr*)); + MOCK_CONST_METHOD1(MockExtractDataStream, Stream*(brillo::ErrorPtr*)); private: - bool SetRequestData(StreamPtr stream, chromeos::ErrorPtr* error) override { + bool SetRequestData(StreamPtr stream, brillo::ErrorPtr* error) override { return MockSetRequestData(stream.get(), error); } void SetResponseData(StreamPtr stream) override { MockSetResponseData(stream.get()); } - StreamPtr ExtractDataStream(chromeos::ErrorPtr* error) override { + StreamPtr ExtractDataStream(brillo::ErrorPtr* error) override { return StreamPtr{MockExtractDataStream(error)}; } @@ -46,6 +46,6 @@ class MockConnection : public Connection { }; } // namespace http -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_HTTP_MOCK_CONNECTION_H_ +#endif // LIBCHROMEOS_BRILLO_HTTP_MOCK_CONNECTION_H_ diff --git a/chromeos/http/mock_curl_api.h b/brillo/http/mock_curl_api.h index c3cb4c9..838ebf2 100644 --- a/chromeos/http/mock_curl_api.h +++ b/brillo/http/mock_curl_api.h @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_HTTP_MOCK_CURL_API_H_ -#define LIBCHROMEOS_CHROMEOS_HTTP_MOCK_CURL_API_H_ +#ifndef LIBCHROMEOS_BRILLO_HTTP_MOCK_CURL_API_H_ +#define LIBCHROMEOS_BRILLO_HTTP_MOCK_CURL_API_H_ #include <string> -#include <chromeos/http/curl_api.h> +#include <brillo/http/curl_api.h> #include <gmock/gmock.h> -namespace chromeos { +namespace brillo { namespace http { // This is a mock for CURL interfaces which allows to mock out the CURL's @@ -51,6 +51,6 @@ class MockCurlInterface : public CurlInterface { }; } // namespace http -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_HTTP_MOCK_CURL_API_H_ +#endif // LIBCHROMEOS_BRILLO_HTTP_MOCK_CURL_API_H_ diff --git a/chromeos/http/mock_transport.h b/brillo/http/mock_transport.h index 0627e54..bba1708 100644 --- a/chromeos/http/mock_transport.h +++ b/brillo/http/mock_transport.h @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_HTTP_MOCK_TRANSPORT_H_ -#define LIBCHROMEOS_CHROMEOS_HTTP_MOCK_TRANSPORT_H_ +#ifndef LIBCHROMEOS_BRILLO_HTTP_MOCK_TRANSPORT_H_ +#define LIBCHROMEOS_BRILLO_HTTP_MOCK_TRANSPORT_H_ #include <memory> #include <string> #include <base/macros.h> -#include <chromeos/http/http_transport.h> +#include <brillo/http/http_transport.h> #include <gmock/gmock.h> -namespace chromeos { +namespace brillo { namespace http { class MockTransport : public Transport { @@ -25,7 +25,7 @@ class MockTransport : public Transport { const HeaderList&, const std::string&, const std::string&, - chromeos::ErrorPtr*)); + brillo::ErrorPtr*)); MOCK_METHOD2(RunCallbackAsync, void(const tracked_objects::Location&, const base::Closure&)); MOCK_METHOD3(StartAsyncTransfer, RequestID(Connection*, @@ -39,6 +39,6 @@ class MockTransport : public Transport { }; } // namespace http -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_HTTP_MOCK_TRANSPORT_H_ +#endif // LIBCHROMEOS_BRILLO_HTTP_MOCK_TRANSPORT_H_ diff --git a/chromeos/key_value_store.cc b/brillo/key_value_store.cc index 8d91dac..2efa50e 100644 --- a/chromeos/key_value_store.cc +++ b/brillo/key_value_store.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/key_value_store.h" +#include "brillo/key_value_store.h" #include <map> #include <string> @@ -12,14 +12,14 @@ #include <base/files/important_file_writer.h> #include <base/strings/string_split.h> #include <base/strings/string_util.h> -#include <chromeos/strings/string_utils.h> -#include <chromeos/map_utils.h> +#include <brillo/strings/string_utils.h> +#include <brillo/map_utils.h> using std::map; using std::string; using std::vector; -namespace chromeos { +namespace brillo { namespace { @@ -124,4 +124,4 @@ std::vector<std::string> KeyValueStore::GetKeys() const { return GetMapKeysAsVector(store_); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/key_value_store.h b/brillo/key_value_store.h index 10f273c..0511326 100644 --- a/chromeos/key_value_store.h +++ b/brillo/key_value_store.h @@ -6,19 +6,19 @@ // key value store. Each key/value pair is stored on its own line and // separated by the first '=' on the line. -#ifndef LIBCHROMEOS_CHROMEOS_KEY_VALUE_STORE_H_ -#define LIBCHROMEOS_CHROMEOS_KEY_VALUE_STORE_H_ +#ifndef LIBCHROMEOS_BRILLO_KEY_VALUE_STORE_H_ +#define LIBCHROMEOS_BRILLO_KEY_VALUE_STORE_H_ #include <map> #include <string> #include <vector> #include <base/files/file_path.h> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> -namespace chromeos { +namespace brillo { -class CHROMEOS_EXPORT KeyValueStore { +class BRILLO_EXPORT KeyValueStore { public: // Creates an empty KeyValueStore. KeyValueStore() = default; @@ -71,6 +71,6 @@ class CHROMEOS_EXPORT KeyValueStore { DISALLOW_COPY_AND_ASSIGN(KeyValueStore); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_KEY_VALUE_STORE_H_ +#endif // LIBCHROMEOS_BRILLO_KEY_VALUE_STORE_H_ diff --git a/chromeos/key_value_store_unittest.cc b/brillo/key_value_store_unittest.cc index 649832b..cd18e89 100644 --- a/chromeos/key_value_store_unittest.cc +++ b/brillo/key_value_store_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/key_value_store.h> +#include <brillo/key_value_store.h> #include <map> #include <string> @@ -12,7 +12,7 @@ #include <base/files/scoped_temp_dir.h> #include <base/logging.h> #include <base/strings/string_util.h> -#include <chromeos/map_utils.h> +#include <brillo/map_utils.h> #include <gtest/gtest.h> using base::FilePath; @@ -21,7 +21,7 @@ using std::map; using std::string; using std::vector; -namespace chromeos { +namespace brillo { class KeyValueStoreTest : public ::testing::Test { protected: @@ -189,4 +189,4 @@ TEST_F(KeyValueStoreTest, GetKeys) { EXPECT_EQ(keys, store_.GetKeys()); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/location_logging.h b/brillo/location_logging.h index a90aab8..011d1e2 100644 --- a/chromeos/location_logging.h +++ b/brillo/location_logging.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_LOCATION_LOGGING_H_ -#define LIBCHROMEOS_CHROMEOS_LOCATION_LOGGING_H_ +#ifndef LIBCHROMEOS_BRILLO_LOCATION_LOGGING_H_ +#define LIBCHROMEOS_BRILLO_LOCATION_LOGGING_H_ // These macros help to log Location objects in verbose mode. @@ -21,4 +21,4 @@ LAZY_STREAM(VLOG_LOC_STREAM(from_here, verbose_level), \ ::logging::DEBUG_MODE && VLOG_IS_ON(verbose_level)) -#endif // LIBCHROMEOS_CHROMEOS_LOCATION_LOGGING_H_ +#endif // LIBCHROMEOS_BRILLO_LOCATION_LOGGING_H_ diff --git a/chromeos/make_unique_ptr.h b/brillo/make_unique_ptr.h index 0d0ec16..35b135e 100644 --- a/chromeos/make_unique_ptr.h +++ b/brillo/make_unique_ptr.h @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_MAKE_UNIQUE_PTR_H_ -#define LIBCHROMEOS_CHROMEOS_MAKE_UNIQUE_PTR_H_ +#ifndef LIBCHROMEOS_BRILLO_MAKE_UNIQUE_PTR_H_ +#define LIBCHROMEOS_BRILLO_MAKE_UNIQUE_PTR_H_ #include <memory> -namespace chromeos { +namespace brillo { // A function to convert T* into unique_ptr<T> // Doing e.g. make_unique_ptr(new FooBarBaz<type>(arg)) is a shorter notation @@ -20,6 +20,6 @@ std::unique_ptr<T> make_unique_ptr(T* ptr) { return std::unique_ptr<T>(ptr); } -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_MAKE_UNIQUE_PTR_H_ +#endif // LIBCHROMEOS_BRILLO_MAKE_UNIQUE_PTR_H_ diff --git a/chromeos/map_utils.h b/brillo/map_utils.h index cf4fcd6..b7f1658 100644 --- a/chromeos/map_utils.h +++ b/brillo/map_utils.h @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_MAP_UTILS_H_ -#define LIBCHROMEOS_CHROMEOS_MAP_UTILS_H_ +#ifndef LIBCHROMEOS_BRILLO_MAP_UTILS_H_ +#define LIBCHROMEOS_BRILLO_MAP_UTILS_H_ #include <map> #include <set> #include <utility> #include <vector> -namespace chromeos { +namespace brillo { // Given an STL map, returns a set containing all keys from the map. template<typename T> @@ -66,6 +66,6 @@ inline typename T::mapped_type GetOrDefault( return it->second; } -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_MAP_UTILS_H_ +#endif // LIBCHROMEOS_BRILLO_MAP_UTILS_H_ diff --git a/chromeos/map_utils_unittest.cc b/brillo/map_utils_unittest.cc index b04620e..19bda1d 100644 --- a/chromeos/map_utils_unittest.cc +++ b/brillo/map_utils_unittest.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/map_utils.h> +#include <brillo/map_utils.h> #include <string> #include <gtest/gtest.h> -namespace chromeos { +namespace brillo { class MapUtilsTest : public ::testing::Test { public: @@ -56,4 +56,4 @@ TEST_F(MapUtilsTest, Empty) { EXPECT_TRUE(MapToVector(empty_map).empty()); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/message_loops/base_message_loop.cc b/brillo/message_loops/base_message_loop.cc index 4923138..a24c64b 100644 --- a/chromeos/message_loops/base_message_loop.cc +++ b/brillo/message_loops/base_message_loop.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/message_loops/base_message_loop.h> +#include <brillo/message_loops/base_message_loop.h> #include <fcntl.h> #include <unistd.h> @@ -10,11 +10,11 @@ #include <base/bind.h> #include <base/run_loop.h> -#include <chromeos/location_logging.h> +#include <brillo/location_logging.h> using base::Closure; -namespace chromeos { +namespace brillo { BaseMessageLoop::BaseMessageLoop(base::MessageLoopForIO* base_loop) : base_loop_(base_loop), @@ -339,4 +339,4 @@ bool BaseMessageLoop::IOTask::CancelTask() { return true; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/message_loops/base_message_loop.h b/brillo/message_loops/base_message_loop.h index 902b828..76bd94a 100644 --- a/chromeos/message_loops/base_message_loop.h +++ b/brillo/message_loops/base_message_loop.h @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_BASE_MESSAGE_LOOP_H_ -#define LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_BASE_MESSAGE_LOOP_H_ +#ifndef LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_BASE_MESSAGE_LOOP_H_ +#define LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_BASE_MESSAGE_LOOP_H_ -// BaseMessageLoop is a chromeos::MessageLoop implementation based on +// BaseMessageLoop is a brillo::MessageLoop implementation based on // base::MessageLoopForIO. This allows to mix new code using -// chromeos::MessageLoop and legacy code using base::MessageLoopForIO in the +// brillo::MessageLoop and legacy code using base::MessageLoopForIO in the // same thread and share a single main loop. This disadvantage of using this // class is a less efficient implementation of CancelTask() for delayed tasks // since base::MessageLoopForIO doesn't provide a way to remove the event. @@ -20,12 +20,12 @@ #include <base/message_loop/message_loop.h> #include <base/time/time.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/message_loops/message_loop.h> +#include <brillo/brillo_export.h> +#include <brillo/message_loops/message_loop.h> -namespace chromeos { +namespace brillo { -class CHROMEOS_EXPORT BaseMessageLoop : public MessageLoop { +class BRILLO_EXPORT BaseMessageLoop : public MessageLoop { public: explicit BaseMessageLoop(base::MessageLoopForIO* base_loop); ~BaseMessageLoop() override; @@ -150,6 +150,6 @@ class CHROMEOS_EXPORT BaseMessageLoop : public MessageLoop { DISALLOW_COPY_AND_ASSIGN(BaseMessageLoop); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_BASE_MESSAGE_LOOP_H_ +#endif // LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_BASE_MESSAGE_LOOP_H_ diff --git a/chromeos/message_loops/fake_message_loop.cc b/brillo/message_loops/fake_message_loop.cc index 786cde2..4d0f157 100644 --- a/chromeos/message_loops/fake_message_loop.cc +++ b/brillo/message_loops/fake_message_loop.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/message_loops/fake_message_loop.h> +#include <brillo/message_loops/fake_message_loop.h> #include <base/logging.h> -#include <chromeos/location_logging.h> +#include <brillo/location_logging.h> -namespace chromeos { +namespace brillo { FakeMessageLoop::FakeMessageLoop(base::SimpleTestClock* clock) : test_clock_(clock) { @@ -138,4 +138,4 @@ bool FakeMessageLoop::PendingTasks() { return !tasks_.empty(); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/message_loops/fake_message_loop.h b/brillo/message_loops/fake_message_loop.h index e9f0c51..043152b 100644 --- a/chromeos/message_loops/fake_message_loop.h +++ b/brillo/message_loops/fake_message_loop.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_FAKE_MESSAGE_LOOP_H_ -#define LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_FAKE_MESSAGE_LOOP_H_ +#ifndef LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_FAKE_MESSAGE_LOOP_H_ +#define LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_FAKE_MESSAGE_LOOP_H_ #include <functional> #include <map> @@ -16,10 +16,10 @@ #include <base/test/simple_test_clock.h> #include <base/time/time.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/message_loops/message_loop.h> +#include <brillo/brillo_export.h> +#include <brillo/message_loops/message_loop.h> -namespace chromeos { +namespace brillo { // The FakeMessageLoop implements a message loop that doesn't block or wait for // time based tasks to be ready. The tasks are executed in the order they should @@ -29,7 +29,7 @@ namespace chromeos { // optionally updates a SimpleTestClock instance when it needs to advance the // clock. // This message loop implementation is useful for unittests. -class CHROMEOS_EXPORT FakeMessageLoop : public MessageLoop { +class BRILLO_EXPORT FakeMessageLoop : public MessageLoop { public: // Create a FakeMessageLoop optionally using a SimpleTestClock to update the // time when Run() or RunOnce(true) are called and should block. @@ -94,6 +94,6 @@ class CHROMEOS_EXPORT FakeMessageLoop : public MessageLoop { DISALLOW_COPY_AND_ASSIGN(FakeMessageLoop); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_FAKE_MESSAGE_LOOP_H_ +#endif // LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_FAKE_MESSAGE_LOOP_H_ diff --git a/chromeos/message_loops/fake_message_loop_unittest.cc b/brillo/message_loops/fake_message_loop_unittest.cc index cec715d..10b551e 100644 --- a/chromeos/message_loops/fake_message_loop_unittest.cc +++ b/brillo/message_loops/fake_message_loop_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/message_loops/fake_message_loop.h> +#include <brillo/message_loops/fake_message_loop.h> #include <memory> #include <vector> @@ -12,15 +12,15 @@ #include <base/test/simple_test_clock.h> #include <gtest/gtest.h> -#include <chromeos/bind_lambda.h> -#include <chromeos/message_loops/message_loop.h> +#include <brillo/bind_lambda.h> +#include <brillo/message_loops/message_loop.h> using base::Bind; using base::Time; using base::TimeDelta; using std::vector; -namespace chromeos { +namespace brillo { using TaskId = MessageLoop::TaskId; @@ -113,4 +113,4 @@ TEST_F(FakeMessageLoopTest, PendingTasksTest) { loop_->Run(); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/message_loops/glib_message_loop.cc b/brillo/message_loops/glib_message_loop.cc index 6db3a01..20c271d 100644 --- a/chromeos/message_loops/glib_message_loop.cc +++ b/brillo/message_loops/glib_message_loop.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/message_loops/glib_message_loop.h> +#include <brillo/message_loops/glib_message_loop.h> #include <fcntl.h> #include <unistd.h> -#include <chromeos/location_logging.h> +#include <brillo/location_logging.h> using base::Closure; -namespace chromeos { +namespace brillo { GlibMessageLoop::GlibMessageLoop() { loop_ = g_main_loop_new(g_main_context_default(), FALSE); @@ -191,4 +191,4 @@ void GlibMessageLoop::DestroyPostedTask(gpointer user_data) { delete reinterpret_cast<ScheduledTask*>(user_data); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/message_loops/glib_message_loop.h b/brillo/message_loops/glib_message_loop.h index 12d5af9..1bebc23 100644 --- a/chromeos/message_loops/glib_message_loop.h +++ b/brillo/message_loops/glib_message_loop.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_GLIB_MESSAGE_LOOP_H_ -#define LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_GLIB_MESSAGE_LOOP_H_ +#ifndef LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_GLIB_MESSAGE_LOOP_H_ +#define LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_GLIB_MESSAGE_LOOP_H_ #include <map> #include <memory> @@ -12,12 +12,12 @@ #include <base/time/time.h> #include <glib.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/message_loops/message_loop.h> +#include <brillo/brillo_export.h> +#include <brillo/message_loops/message_loop.h> -namespace chromeos { +namespace brillo { -class CHROMEOS_EXPORT GlibMessageLoop : public MessageLoop { +class BRILLO_EXPORT GlibMessageLoop : public MessageLoop { public: GlibMessageLoop(); ~GlibMessageLoop() override; @@ -78,6 +78,6 @@ class CHROMEOS_EXPORT GlibMessageLoop : public MessageLoop { DISALLOW_COPY_AND_ASSIGN(GlibMessageLoop); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_GLIB_MESSAGE_LOOP_H_ +#endif // LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_GLIB_MESSAGE_LOOP_H_ diff --git a/chromeos/message_loops/glib_message_loop_unittest.cc b/brillo/message_loops/glib_message_loop_unittest.cc index 0563bd5..4b72a11 100644 --- a/chromeos/message_loops/glib_message_loop_unittest.cc +++ b/brillo/message_loops/glib_message_loop_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/message_loops/glib_message_loop.h> +#include <brillo/message_loops/glib_message_loop.h> #include <fcntl.h> #include <unistd.h> @@ -14,13 +14,13 @@ #include <base/posix/eintr_wrapper.h> #include <gtest/gtest.h> -#include <chromeos/bind_lambda.h> -#include <chromeos/message_loops/message_loop.h> -#include <chromeos/message_loops/message_loop_utils.h> +#include <brillo/bind_lambda.h> +#include <brillo/message_loops/message_loop.h> +#include <brillo/message_loops/message_loop_utils.h> using base::Bind; -namespace chromeos { +namespace brillo { using TaskId = MessageLoop::TaskId; @@ -66,4 +66,4 @@ TEST_F(GlibMessageLoopTest, WatchFileDescriptorTriggersWhenInvalid) { EXPECT_TRUE(loop_->CancelTask(task_id)); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/message_loops/message_loop.cc b/brillo/message_loops/message_loop.cc index e913f13..3d64ccb 100644 --- a/chromeos/message_loops/message_loop.cc +++ b/brillo/message_loops/message_loop.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/message_loops/message_loop.h> +#include <brillo/message_loops/message_loop.h> #include <base/lazy_instance.h> #include <base/logging.h> #include <base/threading/thread_local.h> -namespace chromeos { +namespace brillo { namespace { @@ -60,4 +60,4 @@ void MessageLoop::BreakLoop() { should_exit_ = true; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/message_loops/message_loop.h b/brillo/message_loops/message_loop.h index 73032c8..4ffce02 100644 --- a/chromeos/message_loops/message_loop.h +++ b/brillo/message_loops/message_loop.h @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_MESSAGE_LOOP_H_ -#define LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_MESSAGE_LOOP_H_ +#ifndef LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_MESSAGE_LOOP_H_ +#define LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_MESSAGE_LOOP_H_ #include <string> #include <base/callback.h> #include <base/location.h> #include <base/time/time.h> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> -namespace chromeos { +namespace brillo { -class CHROMEOS_EXPORT MessageLoop { +class BRILLO_EXPORT MessageLoop { public: virtual ~MessageLoop(); @@ -53,8 +53,7 @@ class CHROMEOS_EXPORT MessageLoop { const base::Closure& task, base::TimeDelta delay) = 0; // Variant without the Location for easier usage. - TaskId PostDelayedTask(const base::Closure& task, - base::TimeDelta delay) { + TaskId PostDelayedTask(const base::Closure& task, base::TimeDelta delay) { return PostDelayedTask(tracked_objects::Location(), task, delay); } @@ -131,6 +130,6 @@ class CHROMEOS_EXPORT MessageLoop { DISALLOW_COPY_AND_ASSIGN(MessageLoop); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_MESSAGE_LOOP_H_ +#endif // LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_MESSAGE_LOOP_H_ diff --git a/chromeos/message_loops/message_loop_unittest.cc b/brillo/message_loops/message_loop_unittest.cc index 73b1f96..20fb6be 100644 --- a/chromeos/message_loops/message_loop_unittest.cc +++ b/brillo/message_loops/message_loop_unittest.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/message_loops/message_loop.h> +#include <brillo/message_loops/message_loop.h> -// These are the common tests for all the chromeos::MessageLoop implementations +// These are the common tests for all the brillo::MessageLoop implementations // that should conform to this interface's contracts. For extra // implementation-specific tests see the particular implementation unittests in // the *_unittest.cc files. @@ -22,10 +22,10 @@ #include <base/posix/eintr_wrapper.h> #include <gtest/gtest.h> -#include <chromeos/bind_lambda.h> -#include <chromeos/message_loops/base_message_loop.h> -#include <chromeos/message_loops/glib_message_loop.h> -#include <chromeos/message_loops/message_loop_utils.h> +#include <brillo/bind_lambda.h> +#include <brillo/message_loops/base_message_loop.h> +#include <brillo/message_loops/glib_message_loop.h> +#include <brillo/message_loops/message_loop_utils.h> using base::Bind; using base::TimeDelta; @@ -86,7 +86,7 @@ class ScopedSocketPair { }; } // namespace -namespace chromeos { +namespace brillo { using TaskId = MessageLoop::TaskId; @@ -414,9 +414,9 @@ TYPED_TEST(MessageLoopTest, AllTasksAreEqual) { EXPECT_TRUE(this->loop_->CancelTask(timeout_task)); for (int i = 0; i < kNumTasks; ++i) { EXPECT_GE(reads[i], 10) << "Reading from pipes[" << i << "], fd " - << pipes[i].reader; + << pipes[i].reader; EXPECT_TRUE(this->loop_->CancelTask(tasks[i])); } } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/message_loops/message_loop_utils.cc b/brillo/message_loops/message_loop_utils.cc index cb2eb22..7931447 100644 --- a/chromeos/message_loops/message_loop_utils.cc +++ b/brillo/message_loops/message_loop_utils.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/message_loops/message_loop_utils.h> +#include <brillo/message_loops/message_loop_utils.h> #include <base/location.h> -#include <chromeos/bind_lambda.h> +#include <brillo/bind_lambda.h> -namespace chromeos { +namespace brillo { void MessageLoopRunUntil( MessageLoop* loop, @@ -31,4 +31,4 @@ int MessageLoopRunMaxIterations(MessageLoop* loop, int iterations) { return result; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/message_loops/message_loop_utils.h b/brillo/message_loops/message_loop_utils.h index 0af0e36..b7338fd 100644 --- a/chromeos/message_loops/message_loop_utils.h +++ b/brillo/message_loops/message_loop_utils.h @@ -2,29 +2,29 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_MESSAGE_LOOP_UTILS_H_ -#define LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_MESSAGE_LOOP_UTILS_H_ +#ifndef LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_MESSAGE_LOOP_UTILS_H_ +#define LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_MESSAGE_LOOP_UTILS_H_ #include <base/callback.h> #include <base/time/time.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/message_loops/message_loop.h> +#include <brillo/brillo_export.h> +#include <brillo/message_loops/message_loop.h> -namespace chromeos { +namespace brillo { // Run the MessageLoop until the condition passed in |terminate| returns true // or the timeout expires. -CHROMEOS_EXPORT void MessageLoopRunUntil( +BRILLO_EXPORT void MessageLoopRunUntil( MessageLoop* loop, base::TimeDelta timeout, base::Callback<bool()> terminate); // Run the MessageLoop |loop| for up to |iterations| times without blocking. // Return the number of tasks run. -CHROMEOS_EXPORT int MessageLoopRunMaxIterations(MessageLoop* loop, - int iterations); +BRILLO_EXPORT int MessageLoopRunMaxIterations(MessageLoop* loop, + int iterations); -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_MESSAGE_LOOP_UTILS_H_ +#endif // LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_MESSAGE_LOOP_UTILS_H_ diff --git a/chromeos/message_loops/mock_message_loop.h b/brillo/message_loops/mock_message_loop.h index a4fcd77..73fbe8d 100644 --- a/chromeos/message_loops/mock_message_loop.h +++ b/brillo/message_loops/mock_message_loop.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_MOCK_MESSAGE_LOOP_H_ -#define LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_MOCK_MESSAGE_LOOP_H_ +#ifndef LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_MOCK_MESSAGE_LOOP_H_ +#define LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_MOCK_MESSAGE_LOOP_H_ #include <gmock/gmock.h> @@ -11,11 +11,11 @@ #include <base/test/simple_test_clock.h> #include <base/time/time.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/message_loops/fake_message_loop.h> -#include <chromeos/message_loops/message_loop.h> +#include <brillo/brillo_export.h> +#include <brillo/message_loops/fake_message_loop.h> +#include <brillo/message_loops/message_loop.h> -namespace chromeos { +namespace brillo { // The MockMessageLoop is a mockable MessageLoop that will by default act as a // FakeMessageLoop. It is possible to set expectations with EXPECT_CALL without @@ -23,7 +23,7 @@ namespace chromeos { // FakeMessageLoop implementation. // This message loop implementation is useful to check interaction with the // message loop when running unittests. -class CHROMEOS_EXPORT MockMessageLoop : public MessageLoop { +class BRILLO_EXPORT MockMessageLoop : public MessageLoop { public: // Create a FakeMessageLoop optionally using a SimpleTestClock to update the // time when Run() or RunOnce(true) are called and should block. @@ -84,6 +84,6 @@ class CHROMEOS_EXPORT MockMessageLoop : public MessageLoop { DISALLOW_COPY_AND_ASSIGN(MockMessageLoop); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_MOCK_MESSAGE_LOOP_H_ +#endif // LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_MOCK_MESSAGE_LOOP_H_ diff --git a/chromeos/mime_utils.cc b/brillo/mime_utils.cc index ce67b2a..f194cd2 100644 --- a/chromeos/mime_utils.cc +++ b/brillo/mime_utils.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/mime_utils.h> +#include <brillo/mime_utils.h> #include <algorithm> #include <base/strings/string_util.h> -#include <chromeos/strings/string_utils.h> +#include <brillo/strings/string_utils.h> -namespace chromeos { +namespace brillo { // *************************************************************************** // ******************************* MIME types ******************************** @@ -70,7 +70,7 @@ bool mime::Split(const std::string& mime_string, std::string* subtype, mime::Parameters* parameters) { std::vector<std::string> parts = - chromeos::string_utils::Split(mime_string, ";"); + brillo::string_utils::Split(mime_string, ";"); if (parts.empty()) return false; @@ -81,7 +81,7 @@ bool mime::Split(const std::string& mime_string, parameters->clear(); parameters->reserve(parts.size() - 1); for (size_t i = 1; i < parts.size(); i++) { - auto pair = chromeos::string_utils::SplitAtFirst(parts[i], "="); + auto pair = brillo::string_utils::SplitAtFirst(parts[i], "="); pair.second = DecodeParam(pair.second); parameters->push_back(pair); } @@ -93,7 +93,7 @@ bool mime::Split(const std::string& mime_string, std::string* type, std::string* subtype) { std::string mime = mime::RemoveParameters(mime_string); - auto types = chromeos::string_utils::SplitAtFirst(mime, "/"); + auto types = brillo::string_utils::SplitAtFirst(mime, "/"); if (type) *type = types.first; @@ -108,22 +108,22 @@ std::string mime::Combine(const std::string& type, const std::string& subtype, const mime::Parameters& parameters) { std::vector<std::string> parts; - parts.push_back(chromeos::string_utils::Join("/", type, subtype)); + parts.push_back(brillo::string_utils::Join("/", type, subtype)); for (const auto& pair : parameters) { - parts.push_back(chromeos::string_utils::Join("=", pair.first, - EncodeParam(pair.second))); + parts.push_back( + brillo::string_utils::Join("=", pair.first, EncodeParam(pair.second))); } - return chromeos::string_utils::Join("; ", parts); + return brillo::string_utils::Join("; ", parts); } std::string mime::GetType(const std::string& mime_string) { std::string mime = mime::RemoveParameters(mime_string); - return chromeos::string_utils::SplitAtFirst(mime, "/").first; + return brillo::string_utils::SplitAtFirst(mime, "/").first; } std::string mime::GetSubtype(const std::string& mime_string) { std::string mime = mime::RemoveParameters(mime_string); - return chromeos::string_utils::SplitAtFirst(mime, "/").second; + return brillo::string_utils::SplitAtFirst(mime, "/").second; } mime::Parameters mime::GetParameters(const std::string& mime_string) { @@ -138,7 +138,7 @@ mime::Parameters mime::GetParameters(const std::string& mime_string) { } std::string mime::RemoveParameters(const std::string& mime_string) { - return chromeos::string_utils::SplitAtFirst(mime_string, ";").first; + return brillo::string_utils::SplitAtFirst(mime_string, ";").first; } std::string mime::AppendParameter(const std::string& mime_string, @@ -146,7 +146,7 @@ std::string mime::AppendParameter(const std::string& mime_string, const std::string& paramValue) { std::string mime(mime_string); mime += "; "; - mime += chromeos::string_utils::Join("=", paramName, EncodeParam(paramValue)); + mime += brillo::string_utils::Join("=", paramName, EncodeParam(paramValue)); return mime; } @@ -160,4 +160,4 @@ std::string mime::GetParameterValue(const std::string& mime_string, return std::string(); } -} // namespace chromeos +} // namespace brillo diff --git a/brillo/mime_utils.h b/brillo/mime_utils.h new file mode 100644 index 0000000..9e05460 --- /dev/null +++ b/brillo/mime_utils.h @@ -0,0 +1,126 @@ +// Copyright 2014 The Chromium OS Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LIBCHROMEOS_BRILLO_MIME_UTILS_H_ +#define LIBCHROMEOS_BRILLO_MIME_UTILS_H_ + +#include <string> +#include <utility> +#include <vector> + +#include <base/compiler_specific.h> +#include <base/macros.h> +#include <brillo/brillo_export.h> + +namespace brillo { +namespace mime { + +namespace types { +// Main MIME type categories +BRILLO_EXPORT extern const char kApplication[]; // application +BRILLO_EXPORT extern const char kAudio[]; // audio +BRILLO_EXPORT extern const char kImage[]; // image +BRILLO_EXPORT extern const char kMessage[]; // message +BRILLO_EXPORT extern const char kMultipart[]; // multipart +BRILLO_EXPORT extern const char kText[]; // test +BRILLO_EXPORT extern const char kVideo[]; // video +} // namespace types + +namespace parameters { +// Common MIME parameters +BRILLO_EXPORT extern const char kCharset[]; // charset=... +} // namespace parameters + +namespace image { +// Common image MIME types +BRILLO_EXPORT extern const char kJpeg[]; // image/jpeg +BRILLO_EXPORT extern const char kPng[]; // image/png +BRILLO_EXPORT extern const char kBmp[]; // image/bmp +BRILLO_EXPORT extern const char kTiff[]; // image/tiff +BRILLO_EXPORT extern const char kGif[]; // image/gif +} // namespace image + +namespace text { +// Common text MIME types +BRILLO_EXPORT extern const char kPlain[]; // text/plain +BRILLO_EXPORT extern const char kHtml[]; // text/html +BRILLO_EXPORT extern const char kXml[]; // text/xml +} // namespace text + +namespace application { +// Common application MIME types +// application/octet-stream +BRILLO_EXPORT extern const char kOctet_stream[]; +// application/json +BRILLO_EXPORT extern const char kJson[]; +// application/x-www-form-urlencoded +BRILLO_EXPORT extern const char kWwwFormUrlEncoded[]; +// application/x-protobuf +BRILLO_EXPORT extern const char kProtobuf[]; +} // namespace application + +namespace multipart { +// Common multipart MIME types +// multipart/form-data +BRILLO_EXPORT extern const char kFormData[]; +// multipart/mixed +BRILLO_EXPORT extern const char kMixed[]; +} // namespace multipart + +using Parameters = std::vector<std::pair<std::string, std::string>>; + +// Combine a MIME type, subtype and parameters into a MIME string. +// e.g. Combine("text", "plain", {{"charset", "utf-8"}}) will give: +// "text/plain; charset=utf-8" +BRILLO_EXPORT std::string Combine( + const std::string& type, + const std::string& subtype, + const Parameters& parameters = {}) WARN_UNUSED_RESULT; + +// Splits a MIME string into type and subtype. +// "text/plain;charset=utf-8" => ("text", "plain") +BRILLO_EXPORT bool Split(const std::string& mime_string, + std::string* type, + std::string* subtype); + +// Splits a MIME string into type, subtype, and parameters. +// "text/plain;charset=utf-8" => ("text", "plain", {{"charset","utf-8"}}) +BRILLO_EXPORT bool Split(const std::string& mime_string, + std::string* type, + std::string* subtype, + Parameters* parameters); + +// Returns the MIME type from MIME string. +// "text/plain;charset=utf-8" => "text" +BRILLO_EXPORT std::string GetType(const std::string& mime_string); + +// Returns the MIME sub-type from MIME string. +// "text/plain;charset=utf-8" => "plain" +BRILLO_EXPORT std::string GetSubtype(const std::string& mime_string); + +// Returns the MIME parameters from MIME string. +// "text/plain;charset=utf-8" => {{"charset","utf-8"}} +BRILLO_EXPORT Parameters GetParameters(const std::string& mime_string); + +// Removes parameters from a MIME string +// "text/plain;charset=utf-8" => "text/plain" +BRILLO_EXPORT std::string RemoveParameters( + const std::string& mime_string) WARN_UNUSED_RESULT; + +// Appends a parameter to a MIME string. +// "text/plain" => "text/plain; charset=utf-8" +BRILLO_EXPORT std::string AppendParameter( + const std::string& mime_string, + const std::string& paramName, + const std::string& paramValue) WARN_UNUSED_RESULT; + +// Returns the value of a parameter on a MIME string (empty string if missing). +// ("text/plain;charset=utf-8","charset") => "utf-8" +BRILLO_EXPORT std::string GetParameterValue(const std::string& mime_string, + const std::string& paramName); + +} // namespace mime +} // namespace brillo + +#endif // LIBCHROMEOS_BRILLO_MIME_UTILS_H_ diff --git a/chromeos/mime_utils_unittest.cc b/brillo/mime_utils_unittest.cc index 751d7fd..a7595dc 100644 --- a/chromeos/mime_utils_unittest.cc +++ b/brillo/mime_utils_unittest.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/mime_utils.h> +#include <brillo/mime_utils.h> #include <gtest/gtest.h> -namespace chromeos { +namespace brillo { TEST(MimeUtils, Combine) { std::string mime_string = mime::Combine(mime::types::kText, "xml"); @@ -63,4 +63,4 @@ TEST(MimeUtils, AppendRemoveParams) { EXPECT_EQ(mime::text::kXml, mime_string); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/minijail/minijail.cc b/brillo/minijail/minijail.cc index a3e0f57..b72f41b 100644 --- a/chromeos/minijail/minijail.cc +++ b/brillo/minijail/minijail.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/minijail/minijail.h" +#include "brillo/minijail/minijail.h" #include <sys/types.h> #include <sys/wait.h> using std::vector; -namespace chromeos { +namespace brillo { static base::LazyInstance<Minijail> g_minijail = LAZY_INSTANCE_INITIALIZER; @@ -132,4 +132,4 @@ bool Minijail::RunPipesAndDestroy(struct minijail* jail, return res; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/minijail/minijail.h b/brillo/minijail/minijail.h index 08edeca..a04268d 100644 --- a/chromeos/minijail/minijail.h +++ b/brillo/minijail/minijail.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_MINIJAIL_MINIJAIL_H_ -#define LIBCHROMEOS_CHROMEOS_MINIJAIL_MINIJAIL_H_ +#ifndef LIBCHROMEOS_BRILLO_MINIJAIL_MINIJAIL_H_ +#define LIBCHROMEOS_BRILLO_MINIJAIL_MINIJAIL_H_ #include <vector> @@ -16,7 +16,7 @@ extern "C" { #include <libminijail.h> -namespace chromeos { +namespace brillo { // A Minijail abstraction allowing Minijail mocking in tests. class Minijail { @@ -110,6 +110,6 @@ class Minijail { DISALLOW_COPY_AND_ASSIGN(Minijail); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_MINIJAIL_MINIJAIL_H_ +#endif // LIBCHROMEOS_BRILLO_MINIJAIL_MINIJAIL_H_ diff --git a/chromeos/minijail/mock_minijail.h b/brillo/minijail/mock_minijail.h index 4a21914..8eb209f 100644 --- a/chromeos/minijail/mock_minijail.h +++ b/brillo/minijail/mock_minijail.h @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_MINIJAIL_MOCK_MINIJAIL_H_ -#define LIBCHROMEOS_CHROMEOS_MINIJAIL_MOCK_MINIJAIL_H_ +#ifndef LIBCHROMEOS_BRILLO_MINIJAIL_MOCK_MINIJAIL_H_ +#define LIBCHROMEOS_BRILLO_MINIJAIL_MOCK_MINIJAIL_H_ #include <vector> #include <base/macros.h> #include <gmock/gmock.h> -#include "chromeos/minijail/minijail.h" +#include "brillo/minijail/minijail.h" -namespace chromeos { +namespace brillo { -class MockMinijail : public chromeos::Minijail { +class MockMinijail : public brillo::Minijail { public: MockMinijail() {} virtual ~MockMinijail() {} @@ -62,6 +62,6 @@ class MockMinijail : public chromeos::Minijail { DISALLOW_COPY_AND_ASSIGN(MockMinijail); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_MINIJAIL_MOCK_MINIJAIL_H_ +#endif // LIBCHROMEOS_BRILLO_MINIJAIL_MOCK_MINIJAIL_H_ diff --git a/chromeos/osrelease_reader.cc b/brillo/osrelease_reader.cc index b75405d..6e4bf90 100644 --- a/chromeos/osrelease_reader.cc +++ b/brillo/osrelease_reader.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/osrelease_reader.h> +#include <brillo/osrelease_reader.h> #include <base/files/file_enumerator.h> #include <base/files/file_util.h> #include <base/logging.h> -#include <chromeos/strings/string_utils.h> +#include <brillo/strings/string_utils.h> -namespace chromeos { +namespace brillo { void OsReleaseReader::Load() { Load(base::FilePath("/")); @@ -47,10 +47,10 @@ void OsReleaseReader::Load(const base::FilePath& root_dir) { } // There might be a trailing new line. Strip it to keep only the first line // of the file. - content = chromeos::string_utils::SplitAtFirst(content, "\n", true).first; + content = brillo::string_utils::SplitAtFirst(content, "\n", true).first; store_.SetString(path.BaseName().value(), content); } initialized_ = true; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/osrelease_reader.h b/brillo/osrelease_reader.h index 55d9390..b72f733 100644 --- a/chromeos/osrelease_reader.h +++ b/brillo/osrelease_reader.h @@ -6,18 +6,18 @@ // Standard fields can come from both places depending on how we set them. They // should always be accessed through this interface. -#ifndef LIBCHROMEOS_CHROMEOS_OSRELEASE_READER_H_ -#define LIBCHROMEOS_CHROMEOS_OSRELEASE_READER_H_ +#ifndef LIBCHROMEOS_BRILLO_OSRELEASE_READER_H_ +#define LIBCHROMEOS_BRILLO_OSRELEASE_READER_H_ #include <string> -#include <chromeos/chromeos_export.h> -#include <chromeos/key_value_store.h> +#include <brillo/brillo_export.h> +#include <brillo/key_value_store.h> #include <gtest/gtest_prod.h> -namespace chromeos { +namespace brillo { -class CHROMEOS_EXPORT OsReleaseReader final { +class BRILLO_EXPORT OsReleaseReader final { public: // Create an empty reader OsReleaseReader() = default; @@ -44,11 +44,11 @@ class CHROMEOS_EXPORT OsReleaseReader final { bool initialized_; // Load the data from a given root_dir. - CHROMEOS_PRIVATE void Load(const base::FilePath& root_dir); + BRILLO_PRIVATE void Load(const base::FilePath& root_dir); DISALLOW_COPY_AND_ASSIGN(OsReleaseReader); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_OSRELEASE_READER_H_ +#endif // LIBCHROMEOS_BRILLO_OSRELEASE_READER_H_ diff --git a/chromeos/osrelease_reader_unittest.cc b/brillo/osrelease_reader_unittest.cc index ea5ec75..88185a0 100644 --- a/chromeos/osrelease_reader_unittest.cc +++ b/brillo/osrelease_reader_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/osrelease_reader.h> +#include <brillo/osrelease_reader.h> #include <base/files/file_util.h> #include <base/files/scoped_temp_dir.h> @@ -10,7 +10,7 @@ using std::string; -namespace chromeos { +namespace brillo { class OsReleaseReaderTest : public ::testing::Test { public: @@ -92,4 +92,4 @@ TEST_F(OsReleaseReaderTest, NoNewLine) { ASSERT_EQ("bonjour", bonjour_value); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/pointer_utils.h b/brillo/pointer_utils.h index d431a5d..1cee1f8 100644 --- a/chromeos/pointer_utils.h +++ b/brillo/pointer_utils.h @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_POINTER_UTILS_H_ -#define LIBCHROMEOS_CHROMEOS_POINTER_UTILS_H_ +#ifndef LIBCHROMEOS_BRILLO_POINTER_UTILS_H_ +#define LIBCHROMEOS_BRILLO_POINTER_UTILS_H_ #include <cstdint> #include <sys/types.h> -namespace chromeos { +namespace brillo { // AdvancePointer() is a helper function to advance void pointer by // |byte_offset| bytes. Both const and non-const overloads are provided. @@ -19,6 +19,6 @@ inline const void* AdvancePointer(const void* pointer, ssize_t byte_offset) { return reinterpret_cast<const uint8_t*>(pointer) + byte_offset; } -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_POINTER_UTILS_H_ +#endif // LIBCHROMEOS_BRILLO_POINTER_UTILS_H_ diff --git a/chromeos/process.cc b/brillo/process.cc index ffe1525..6199bc1 100644 --- a/chromeos/process.cc +++ b/brillo/process.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/process.h" +#include "brillo/process.h" #include <fcntl.h> #include <signal.h> @@ -26,7 +26,7 @@ #define setresgid(_g1, _g2, _g3) setregid(_g1, _g2) #endif // !__linux__ -namespace chromeos { +namespace brillo { bool ReturnTrue() { return true; @@ -355,4 +355,4 @@ pid_t ProcessImpl::Release() { return old_pid; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/process.h b/brillo/process.h index b216941..568e8e0 100644 --- a/chromeos/process.h +++ b/brillo/process.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_PROCESS_H_ -#define LIBCHROMEOS_CHROMEOS_PROCESS_H_ +#ifndef LIBCHROMEOS_BRILLO_PROCESS_H_ +#define LIBCHROMEOS_BRILLO_PROCESS_H_ #include <sys/types.h> @@ -15,16 +15,16 @@ #include <base/callback.h> #include <base/strings/string_util.h> #include <base/strings/stringprintf.h> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> #include <gtest/gtest_prod.h> -namespace chromeos { +namespace brillo { // Manages a process. Can create the process, attach to an existing // process by pid or pid file, and kill the process. Upon destruction // any managed process is killed with SIGKILL. Use Release() to // release the process from management. A given system process may // only be managed by one Process at a time. -class CHROMEOS_EXPORT Process { +class BRILLO_EXPORT Process { public: Process(); virtual ~Process(); @@ -132,7 +132,7 @@ class CHROMEOS_EXPORT Process { enum { kErrorExitStatus = 127 }; }; -class CHROMEOS_EXPORT ProcessImpl : public Process { +class BRILLO_EXPORT ProcessImpl : public Process { public: ProcessImpl(); virtual ~ProcessImpl(); @@ -195,6 +195,6 @@ class CHROMEOS_EXPORT ProcessImpl : public Process { bool inherit_parent_signal_mask_; }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_PROCESS_H_ +#endif // LIBCHROMEOS_BRILLO_PROCESS_H_ diff --git a/chromeos/process_information.cc b/brillo/process_information.cc index 9f1d773..6b03c40 100644 --- a/chromeos/process_information.cc +++ b/brillo/process_information.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/process_information.h" +#include "brillo/process_information.h" -namespace chromeos { +namespace brillo { ProcessInformation::ProcessInformation() : cmd_line_(), process_id_(-1) { } @@ -24,4 +24,4 @@ std::string ProcessInformation::GetCommandLine() { return result; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/process_information.h b/brillo/process_information.h index bc2818e..8bdcf43 100644 --- a/chromeos/process_information.h +++ b/brillo/process_information.h @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_PROCESS_INFORMATION_H_ -#define LIBCHROMEOS_CHROMEOS_PROCESS_INFORMATION_H_ +#ifndef LIBCHROMEOS_BRILLO_PROCESS_INFORMATION_H_ +#define LIBCHROMEOS_BRILLO_PROCESS_INFORMATION_H_ #include <set> #include <string> #include <vector> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> -namespace chromeos { +namespace brillo { // Information for a single running process. Stores its command line, set of // open files, process id and working directory. -class CHROMEOS_EXPORT ProcessInformation { +class BRILLO_EXPORT ProcessInformation { public: ProcessInformation(); virtual ~ProcessInformation(); @@ -60,6 +60,6 @@ class CHROMEOS_EXPORT ProcessInformation { int process_id_; }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_PROCESS_INFORMATION_H_ +#endif // LIBCHROMEOS_BRILLO_PROCESS_INFORMATION_H_ diff --git a/chromeos/process_mock.h b/brillo/process_mock.h index c494c2d..88b60c6 100644 --- a/chromeos/process_mock.h +++ b/brillo/process_mock.h @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_PROCESS_MOCK_H_ -#define LIBCHROMEOS_CHROMEOS_PROCESS_MOCK_H_ +#ifndef LIBCHROMEOS_BRILLO_PROCESS_MOCK_H_ +#define LIBCHROMEOS_BRILLO_PROCESS_MOCK_H_ #include <string> #include <gmock/gmock.h> -#include "chromeos/process.h" +#include "brillo/process.h" -namespace chromeos { +namespace brillo { class ProcessMock : public Process { public: @@ -38,6 +38,6 @@ class ProcessMock : public Process { MOCK_METHOD0(Release, pid_t()); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_PROCESS_MOCK_H_ +#endif // LIBCHROMEOS_BRILLO_PROCESS_MOCK_H_ diff --git a/chromeos/process_reaper.cc b/brillo/process_reaper.cc index 858e588..5ee1195 100644 --- a/chromeos/process_reaper.cc +++ b/brillo/process_reaper.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/process_reaper.h" +#include "brillo/process_reaper.h" #include <sys/signalfd.h> #include <sys/types.h> @@ -10,18 +10,18 @@ #include <base/bind.h> #include <base/posix/eintr_wrapper.h> -#include <chromeos/asynchronous_signal_handler.h> -#include <chromeos/daemons/daemon.h> -#include <chromeos/location_logging.h> +#include <brillo/asynchronous_signal_handler.h> +#include <brillo/daemons/daemon.h> +#include <brillo/location_logging.h> -namespace chromeos { +namespace brillo { ProcessReaper::~ProcessReaper() { Unregister(); } void ProcessReaper::Register( - AsynchronousSignalHandlerInterface* async_signal_handler) { + AsynchronousSignalHandlerInterface* async_signal_handler) { CHECK(!async_signal_handler_); async_signal_handler_ = async_signal_handler; async_signal_handler->RegisterHandler( @@ -83,4 +83,4 @@ bool ProcessReaper::HandleSIGCHLD(const struct signalfd_siginfo& sigfd_info) { return false; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/process_reaper.h b/brillo/process_reaper.h index 8a8189d..4d28f4e 100644 --- a/chromeos/process_reaper.h +++ b/brillo/process_reaper.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_PROCESS_REAPER_H_ -#define LIBCHROMEOS_CHROMEOS_PROCESS_REAPER_H_ +#ifndef LIBCHROMEOS_BRILLO_PROCESS_REAPER_H_ +#define LIBCHROMEOS_BRILLO_PROCESS_REAPER_H_ #include <sys/wait.h> @@ -12,12 +12,12 @@ #include <base/callback.h> #include <base/location.h> #include <base/macros.h> -#include <chromeos/asynchronous_signal_handler.h> -#include <chromeos/daemons/daemon.h> +#include <brillo/asynchronous_signal_handler.h> +#include <brillo/daemons/daemon.h> -namespace chromeos { +namespace brillo { -class CHROMEOS_EXPORT ProcessReaper final { +class BRILLO_EXPORT ProcessReaper final { public: // The callback called when a child exits. using ChildCallback = base::Callback<void(const siginfo_t&)>; @@ -26,13 +26,13 @@ class CHROMEOS_EXPORT ProcessReaper final { ~ProcessReaper(); // Register the ProcessReaper using either the provided - // chromeos::AsynchronousSignalHandlerInterface. You can call Unregister() to + // brillo::AsynchronousSignalHandlerInterface. You can call Unregister() to // remove this ProcessReapper or it will be called during shutdown. // You can only register this ProcessReaper with one signal handler at a time. void Register(AsynchronousSignalHandlerInterface* async_signal_handler); // Unregisters the ProcessReaper from the - // chromeos::AsynchronousSignalHandlerInterface passed in Register(). It + // brillo::AsynchronousSignalHandlerInterface passed in Register(). It // doesn't do anything if not registered. void Unregister(); @@ -62,6 +62,6 @@ class CHROMEOS_EXPORT ProcessReaper final { DISALLOW_COPY_AND_ASSIGN(ProcessReaper); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_PROCESS_REAPER_H_ +#endif // LIBCHROMEOS_BRILLO_PROCESS_REAPER_H_ diff --git a/chromeos/process_reaper_unittest.cc b/brillo/process_reaper_unittest.cc index d49ce37..499b908 100644 --- a/chromeos/process_reaper_unittest.cc +++ b/brillo/process_reaper_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/process_reaper.h> +#include <brillo/process_reaper.h> #include <signal.h> #include <sys/wait.h> @@ -11,9 +11,9 @@ #include <base/bind.h> #include <base/location.h> #include <base/message_loop/message_loop.h> -#include <chromeos/asynchronous_signal_handler.h> -#include <chromeos/bind_lambda.h> -#include <chromeos/message_loops/base_message_loop.h> +#include <brillo/asynchronous_signal_handler.h> +#include <brillo/bind_lambda.h> +#include <brillo/message_loops/base_message_loop.h> #include <gtest/gtest.h> namespace { @@ -41,20 +41,20 @@ pid_t ForkChildAndKill(int sig) { } // namespace -namespace chromeos { +namespace brillo { class ProcessReaperTest : public ::testing::Test { public: void SetUp() override { - chromeos_loop_.SetAsCurrent(); + brillo_loop_.SetAsCurrent(); async_signal_handler_.Init(); process_reaper_.Register(&async_signal_handler_); } protected: base::MessageLoopForIO base_loop_; - chromeos::BaseMessageLoop chromeos_loop_{&base_loop_}; - chromeos::AsynchronousSignalHandler async_signal_handler_; + brillo::BaseMessageLoop brillo_loop_{&base_loop_}; + brillo::AsynchronousSignalHandler async_signal_handler_; // ProcessReaper under test. ProcessReaper process_reaper_; @@ -78,9 +78,9 @@ TEST_F(ProcessReaperTest, ReapExitedChild) { [this](const siginfo_t& info) { EXPECT_EQ(CLD_EXITED, info.si_code); EXPECT_EQ(123, info.si_status); - this->chromeos_loop_.BreakLoop(); + this->brillo_loop_.BreakLoop(); }))); - chromeos_loop_.Run(); + brillo_loop_.Run(); } // Test that simultaneous child processes fire their respective callbacks when @@ -97,13 +97,13 @@ TEST_F(ProcessReaperTest, ReapedChildsMatchCallbacks) { EXPECT_EQ(exit_value, info.si_status); running_childs--; if (running_childs == 0) - this->chromeos_loop_.BreakLoop(); + this->brillo_loop_.BreakLoop(); }))); } // This sleep is optional. It helps to have more processes exit before we // start watching for them in the message loop. usleep(10 * 1000); - chromeos_loop_.Run(); + brillo_loop_.Run(); EXPECT_EQ(0, running_childs); } @@ -113,9 +113,9 @@ TEST_F(ProcessReaperTest, ReapKilledChild) { [this](const siginfo_t& info) { EXPECT_EQ(CLD_KILLED, info.si_code); EXPECT_EQ(SIGKILL, info.si_status); - this->chromeos_loop_.BreakLoop(); + this->brillo_loop_.BreakLoop(); }))); - chromeos_loop_.Run(); + brillo_loop_.Run(); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/process_unittest.cc b/brillo/process_unittest.cc index 1d83cb7..ebf1d4e 100644 --- a/chromeos/process_unittest.cc +++ b/brillo/process_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/process.h" +#include "brillo/process.h" #include <unistd.h> @@ -11,8 +11,8 @@ #include <base/files/scoped_temp_dir.h> #include <gtest/gtest.h> -#include "chromeos/process_mock.h" -#include "chromeos/test_helpers.h" +#include "brillo/process_mock.h" +#include "brillo/test_helpers.h" using base::FilePath; @@ -31,7 +31,7 @@ static const char kBinFalse[] = SYSTEM_PREFIX "/bin/false"; static const char kBinSleep[] = SYSTEM_PREFIX "/bin/sleep"; static const char kBinTrue[] = SYSTEM_PREFIX "/bin/true"; -namespace chromeos { +namespace brillo { // Test that the mock has all the functions of the interface by // instantiating it. This variable is not used elsewhere. @@ -87,8 +87,8 @@ class ProcessTest : public ::testing::Test { static void SetUpTestCase() { base::CommandLine::Init(0, nullptr); - ::chromeos::InitLog(chromeos::kLogToStderr); - ::chromeos::LogToString(true); + ::brillo::InitLog(brillo::kLogToStderr); + ::brillo::LogToString(true); } protected: @@ -334,4 +334,4 @@ TEST_F(ProcessTest, PreExecCallback) { ASSERT_NE(0, process_.Run()); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/secure_blob.cc b/brillo/secure_blob.cc index b7e215f..9e6d570 100644 --- a/chromeos/secure_blob.cc +++ b/brillo/secure_blob.cc @@ -6,9 +6,9 @@ #include <base/stl_util.h> -#include "chromeos/secure_blob.h" +#include "brillo/secure_blob.h" -namespace chromeos { +namespace brillo { SecureBlob::SecureBlob(const std::string& data) : SecureBlob(data.begin(), data.end()) {} @@ -72,4 +72,4 @@ int SecureMemcmp(const void* s1, const void* s2, size_t n) { return result != 0; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/secure_blob.h b/brillo/secure_blob.h index e92658e..dec9444 100644 --- a/chromeos/secure_blob.h +++ b/brillo/secure_blob.h @@ -2,21 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_SECURE_BLOB_H_ -#define LIBCHROMEOS_CHROMEOS_SECURE_BLOB_H_ +#ifndef LIBCHROMEOS_BRILLO_SECURE_BLOB_H_ +#define LIBCHROMEOS_BRILLO_SECURE_BLOB_H_ #include <string> #include <vector> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> -namespace chromeos { +namespace brillo { using Blob = std::vector<uint8_t>; // SecureBlob erases the contents on destruction. It does not guarantee erasure // on resize, assign, etc. -class CHROMEOS_EXPORT SecureBlob : public Blob { +class BRILLO_EXPORT SecureBlob : public Blob { public: SecureBlob() = default; using Blob::vector; // Inherit standard constructors from vector. @@ -46,13 +46,13 @@ class CHROMEOS_EXPORT SecureBlob : public Blob { // While memset() can be optimized out in certain situations (since most // compilers implement this function as intrinsic and know of its side effects), // this function will not be optimized out. -CHROMEOS_EXPORT void* SecureMemset(void* v, int c, size_t n); +BRILLO_EXPORT void* SecureMemset(void* v, int c, size_t n); // Compare [n] bytes starting at [s1] with [s2] and return 0 if they match, // 1 if they don't. Time taken to perform the comparison is only dependent on // [n] and not on the relationship of the match between [s1] and [s2]. -CHROMEOS_EXPORT int SecureMemcmp(const void* s1, const void* s2, size_t n); +BRILLO_EXPORT int SecureMemcmp(const void* s1, const void* s2, size_t n); -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_SECURE_BLOB_H_ +#endif // LIBCHROMEOS_BRILLO_SECURE_BLOB_H_ diff --git a/chromeos/secure_blob_unittest.cc b/brillo/secure_blob_unittest.cc index e85e2af..d4fd555 100644 --- a/chromeos/secure_blob_unittest.cc +++ b/brillo/secure_blob_unittest.cc @@ -4,7 +4,7 @@ // Unit tests for SecureBlob. -#include "chromeos/secure_blob.h" +#include "brillo/secure_blob.h" #include <algorithm> #include <iterator> @@ -13,7 +13,7 @@ #include <base/logging.h> #include <gtest/gtest.h> -namespace chromeos { +namespace brillo { using std::string; class SecureBlobTest : public ::testing::Test { @@ -21,15 +21,15 @@ class SecureBlobTest : public ::testing::Test { SecureBlobTest() {} virtual ~SecureBlobTest() {} - static bool FindBlobInBlob(const chromeos::Blob& haystack, - const chromeos::Blob& needle) { + static bool FindBlobInBlob(const brillo::Blob& haystack, + const brillo::Blob& needle) { auto pos = std::search( haystack.begin(), haystack.end(), needle.begin(), needle.end()); return (pos != haystack.end()); } - static int FindBlobIndexInBlob(const chromeos::Blob& haystack, - const chromeos::Blob& needle) { + static int FindBlobIndexInBlob(const brillo::Blob& haystack, + const brillo::Blob& needle) { auto pos = std::search( haystack.begin(), haystack.end(), needle.begin(), needle.end()); if (pos == haystack.end()) { @@ -65,7 +65,7 @@ TEST_F(SecureBlobTest, AllocationCopyTest) { TEST_F(SecureBlobTest, IteratorConstructorTest) { // Check that allocating a SecureBlob with an iterator works - chromeos::Blob from_blob(32); + brillo::Blob from_blob(32); for (unsigned int i = 0; i < from_blob.size(); i++) { from_blob[i] = i; } @@ -117,4 +117,4 @@ TEST_F(SecureBlobTest, BlobToStringTest) { EXPECT_EQ(test_string.compare(result_string), 0); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/fake_stream.cc b/brillo/streams/fake_stream.cc index c1ccacd..db24e95 100644 --- a/chromeos/streams/fake_stream.cc +++ b/brillo/streams/fake_stream.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/fake_stream.h> +#include <brillo/streams/fake_stream.h> #include <algorithm> #include <base/bind.h> -#include <chromeos/message_loops/message_loop.h> -#include <chromeos/streams/stream_utils.h> +#include <brillo/message_loops/message_loop.h> +#include <brillo/streams/stream_utils.h> -namespace chromeos { +namespace brillo { namespace { @@ -62,10 +62,10 @@ void FakeStream::AddReadPacketData(base::TimeDelta delay, const void* data, size_t size) { auto* byte_ptr = static_cast<const uint8_t*>(data); - AddReadPacketData(delay, chromeos::Blob{byte_ptr, byte_ptr + size}); + AddReadPacketData(delay, brillo::Blob{byte_ptr, byte_ptr + size}); } -void FakeStream::AddReadPacketData(base::TimeDelta delay, chromeos::Blob data) { +void FakeStream::AddReadPacketData(base::TimeDelta delay, brillo::Blob data) { InputDataPacket packet; packet.data = std::move(data); packet.delay_before = delay; @@ -74,7 +74,7 @@ void FakeStream::AddReadPacketData(base::TimeDelta delay, chromeos::Blob data) { void FakeStream::AddReadPacketString(base::TimeDelta delay, const std::string& data) { - AddReadPacketData(delay, chromeos::Blob{data.begin(), data.end()}); + AddReadPacketData(delay, brillo::Blob{data.begin(), data.end()}); } void FakeStream::QueueReadError(base::TimeDelta delay) { @@ -110,11 +110,11 @@ void FakeStream::ExpectWritePacketData(base::TimeDelta delay, const void* data, size_t size) { auto* byte_ptr = static_cast<const uint8_t*>(data); - ExpectWritePacketData(delay, chromeos::Blob{byte_ptr, byte_ptr + size}); + ExpectWritePacketData(delay, brillo::Blob{byte_ptr, byte_ptr + size}); } void FakeStream::ExpectWritePacketData(base::TimeDelta delay, - chromeos::Blob data) { + brillo::Blob data) { OutputDataPacket packet; packet.expected_size = data.size(); packet.data = std::move(data); @@ -124,7 +124,7 @@ void FakeStream::ExpectWritePacketData(base::TimeDelta delay, void FakeStream::ExpectWritePacketString(base::TimeDelta delay, const std::string& data) { - ExpectWritePacketData(delay, chromeos::Blob{data.begin(), data.end()}); + ExpectWritePacketData(delay, brillo::Blob{data.begin(), data.end()}); } void FakeStream::QueueWriteError(base::TimeDelta delay) { @@ -151,7 +151,7 @@ void FakeStream::ClearWriteQueue() { report_write_error_ = 0; } -const chromeos::Blob& FakeStream::GetFlushedOutputData() const { +const brillo::Blob& FakeStream::GetFlushedOutputData() const { return all_output_data_; } @@ -337,7 +337,7 @@ bool FakeStream::FlushBlocking(ErrorPtr* error) { expected_output_data_ != output_buffer_) { // We expected different data to be written, report an error. Error::AddTo(error, FROM_HERE, "fake_stream", "data_mismatch", - "Unexpected data written"); + "Unexpected data written"); success = false; } all_output_data_.insert(all_output_data_.end(), @@ -401,4 +401,4 @@ bool FakeStream::WaitForDataBlocking(AccessMode in_mode, return true; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/fake_stream.h b/brillo/streams/fake_stream.h index 2f8567d..2943a44 100644 --- a/chromeos/streams/fake_stream.h +++ b/brillo/streams/fake_stream.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_STREAMS_FAKE_STREAM_H_ -#define LIBCHROMEOS_CHROMEOS_STREAMS_FAKE_STREAM_H_ +#ifndef LIBCHROMEOS_BRILLO_STREAMS_FAKE_STREAM_H_ +#define LIBCHROMEOS_BRILLO_STREAMS_FAKE_STREAM_H_ #include <queue> #include <string> @@ -12,10 +12,10 @@ #include <base/macros.h> #include <base/time/clock.h> #include <base/time/time.h> -#include <chromeos/secure_blob.h> -#include <chromeos/streams/stream.h> +#include <brillo/secure_blob.h> +#include <brillo/streams/stream.h> -namespace chromeos { +namespace brillo { // Fake stream implementation for testing. // This class allows to provide data for the stream in tests that can be later @@ -43,7 +43,7 @@ class FakeStream : public Stream { // Add data packets to the read queue of the stream. // Optional |delay| indicates that the data packet should be delayed. void AddReadPacketData(base::TimeDelta delay, const void* data, size_t size); - void AddReadPacketData(base::TimeDelta delay, chromeos::Blob data); + void AddReadPacketData(base::TimeDelta delay, brillo::Blob data); void AddReadPacketString(base::TimeDelta delay, const std::string& data); // Schedule a read error by adding a special error packet to the queue. @@ -63,7 +63,7 @@ class FakeStream : public Stream { void ExpectWritePacketData(base::TimeDelta delay, const void* data, size_t size); - void ExpectWritePacketData(base::TimeDelta delay, chromeos::Blob data); + void ExpectWritePacketData(base::TimeDelta delay, brillo::Blob data); void ExpectWritePacketString(base::TimeDelta delay, const std::string& data); // Schedule a write error by adding a special error packet to the queue. @@ -76,14 +76,14 @@ class FakeStream : public Stream { // Returns the output data accumulated so far by all complete write packets, // or explicitly flushed. - const chromeos::Blob& GetFlushedOutputData() const; + const brillo::Blob& GetFlushedOutputData() const; std::string GetFlushedOutputDataAsString() const; - // Overrides from chromeos::Stream. + // Overrides from brillo::Stream. bool IsOpen() const override { return is_open_; } bool CanRead() const override; bool CanWrite() const override; - bool CanSeek() const override { return false; } + bool CanSeek() const override { return false; } bool CanGetSize() const override { return false; } uint64_t GetSize() const override { return 0; } bool SetSizeBlocking(uint64_t size, ErrorPtr* error) override; @@ -116,7 +116,7 @@ class FakeStream : public Stream { private: // Input data packet to be placed on the read queue. struct InputDataPacket { - chromeos::Blob data; // Data to be read. + brillo::Blob data; // Data to be read. base::TimeDelta delay_before; // Possible delay for the first read. bool read_error{false}; // Set to true if this packet generates an error. }; @@ -124,7 +124,7 @@ class FakeStream : public Stream { // Output data packet to be placed on the write queue. struct OutputDataPacket { size_t expected_size{0}; // Output packet size - chromeos::Blob data; // Possible data to verify the output with. + brillo::Blob data; // Possible data to verify the output with. base::TimeDelta delay_before; // Possible delay for the first write. bool write_error{false}; // Set to true if this packet generates an error. }; @@ -150,22 +150,22 @@ class FakeStream : public Stream { // Internal data for read operations. std::queue<InputDataPacket> incoming_queue_; base::Time delay_input_until_; - chromeos::Blob input_buffer_; + brillo::Blob input_buffer_; size_t input_ptr_{0}; bool report_read_error_{false}; // Internal data for write operations. std::queue<OutputDataPacket> outgoing_queue_; base::Time delay_output_until_; - chromeos::Blob output_buffer_; - chromeos::Blob expected_output_data_; + brillo::Blob output_buffer_; + brillo::Blob expected_output_data_; size_t max_output_buffer_size_{0}; bool report_write_error_{false}; - chromeos::Blob all_output_data_; + brillo::Blob all_output_data_; DISALLOW_COPY_AND_ASSIGN(FakeStream); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_STREAMS_FAKE_STREAM_H_ +#endif // LIBCHROMEOS_BRILLO_STREAMS_FAKE_STREAM_H_ diff --git a/chromeos/streams/fake_stream_unittest.cc b/brillo/streams/fake_stream_unittest.cc index 89bada0..2aa18fd 100644 --- a/chromeos/streams/fake_stream_unittest.cc +++ b/brillo/streams/fake_stream_unittest.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/fake_stream.h> +#include <brillo/streams/fake_stream.h> #include <vector> #include <base/callback.h> #include <base/test/simple_test_clock.h> -#include <chromeos/bind_lambda.h> -#include <chromeos/message_loops/mock_message_loop.h> +#include <brillo/bind_lambda.h> +#include <brillo/message_loops/mock_message_loop.h> #include <gmock/gmock.h> #include <gtest/gtest.h> @@ -17,7 +17,7 @@ using testing::AnyNumber; using testing::InSequence; using testing::_; -namespace chromeos { +namespace brillo { class FakeStreamTest : public testing::Test { public: @@ -507,4 +507,4 @@ TEST_F(FakeStreamTest, WaitForDataReadWrite) { EXPECT_EQ(4, call_count); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/file_stream.cc b/brillo/streams/file_stream.cc index 35fae6d..7b28a5a 100644 --- a/chromeos/streams/file_stream.cc +++ b/brillo/streams/file_stream.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/file_stream.h> +#include <brillo/streams/file_stream.h> #include <algorithm> #include <fcntl.h> @@ -12,12 +12,12 @@ #include <base/bind.h> #include <base/files/file_util.h> #include <base/posix/eintr_wrapper.h> -#include <chromeos/errors/error_codes.h> -#include <chromeos/message_loops/message_loop.h> -#include <chromeos/streams/stream_errors.h> -#include <chromeos/streams/stream_utils.h> +#include <brillo/errors/error_codes.h> +#include <brillo/message_loops/message_loop.h> +#include <brillo/streams/stream_errors.h> +#include <brillo/streams/stream_utils.h> -namespace chromeos { +namespace brillo { // FileDescriptor is a helper class that serves two purposes: // 1. It wraps low-level system APIs (as FileDescriptorInterface) to allow @@ -167,7 +167,7 @@ class FileDescriptor : public FileStream::FileDescriptorInterface { } } - // Called from the chromeos::MessageLoop when the file descriptor is available + // Called from the brillo::MessageLoop when the file descriptor is available // for reading. void OnFileCanReadWithoutBlocking() { CHECK(!read_data_callback_.is_null()); @@ -205,7 +205,6 @@ class FileDescriptor : public FileStream::FileDescriptorInterface { DISALLOW_COPY_AND_ASSIGN(FileDescriptor); }; - StreamPtr FileStream::Open(const base::FilePath& path, AccessMode mode, Disposition disposition, @@ -242,11 +241,11 @@ StreamPtr FileStream::Open(const base::FilePath& path, mode_t creation_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; int fd = HANDLE_EINTR(open(path.value().c_str(), open_flags, creation_mode)); if (fd < 0) { - chromeos::errors::system::AddSystemError(error, FROM_HERE, errno); + brillo::errors::system::AddSystemError(error, FROM_HERE, errno); return stream; } if (HANDLE_EINTR(fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK)) < 0) { - chromeos::errors::system::AddSystemError(error, FROM_HERE, errno); + brillo::errors::system::AddSystemError(error, FROM_HERE, errno); IGNORE_EINTR(close(fd)); return stream; } @@ -267,14 +266,14 @@ StreamPtr FileStream::CreateTemporary(ErrorPtr* error) { // 3.11 and not all our configurations have that. So, for now just create // a temp file first and then open it. if (!base::CreateTemporaryFile(&path)) { - chromeos::errors::system::AddSystemError(error, FROM_HERE, errno); + brillo::errors::system::AddSystemError(error, FROM_HERE, errno); return stream; } int open_flags = O_CLOEXEC | O_RDWR | O_CREAT | O_TRUNC; mode_t creation_mode = S_IRUSR | S_IWUSR; int fd = HANDLE_EINTR(open(path.value().c_str(), open_flags, creation_mode)); if (fd < 0) { - chromeos::errors::system::AddSystemError(error, FROM_HERE, errno); + brillo::errors::system::AddSystemError(error, FROM_HERE, errno); return stream; } unlink(path.value().c_str()); @@ -298,7 +297,7 @@ StreamPtr FileStream::FromFileDescriptor(int file_descriptor, int fd_flags = HANDLE_EINTR(fcntl(file_descriptor, F_GETFL)); if (fd_flags < 0) { - chromeos::errors::system::AddSystemError(error, FROM_HERE, errno); + brillo::errors::system::AddSystemError(error, FROM_HERE, errno); return stream; } int file_access_mode = (fd_flags & O_ACCMODE); @@ -313,7 +312,7 @@ StreamPtr FileStream::FromFileDescriptor(int file_descriptor, if ((fd_flags & O_NONBLOCK) == 0) { fd_flags |= O_NONBLOCK; if (HANDLE_EINTR(fcntl(file_descriptor, F_SETFL, fd_flags)) < 0) { - chromeos::errors::system::AddSystemError(error, FROM_HERE, errno); + brillo::errors::system::AddSystemError(error, FROM_HERE, errno); return stream; } } @@ -546,4 +545,4 @@ void FileStream::CancelPendingAsyncOperations() { Stream::CancelPendingAsyncOperations(); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/file_stream.h b/brillo/streams/file_stream.h index a59405c..002a850 100644 --- a/chromeos/streams/file_stream.h +++ b/brillo/streams/file_stream.h @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_STREAMS_FILE_STREAM_H_ -#define LIBCHROMEOS_CHROMEOS_STREAMS_FILE_STREAM_H_ +#ifndef LIBCHROMEOS_BRILLO_STREAMS_FILE_STREAM_H_ +#define LIBCHROMEOS_BRILLO_STREAMS_FILE_STREAM_H_ #include <base/files/file_path.h> #include <base/macros.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/streams/stream.h> +#include <brillo/brillo_export.h> +#include <brillo/streams/stream.h> -namespace chromeos { +namespace brillo { -// FileStream class provides the implementation of chromeos::Stream for files +// FileStream class provides the implementation of brillo::Stream for files // and file-descriptor-based streams, such as pipes and sockets. // The FileStream class cannot be instantiated by clients directly. However // they should use the static factory methods such as: @@ -20,7 +20,7 @@ namespace chromeos { // - FileStream::CreateTemporary(): to create a temporary file stream. // - FileStream::FromFileDescriptor(): to create a stream using an existing // file descriptor. -class CHROMEOS_EXPORT FileStream : public Stream { +class BRILLO_EXPORT FileStream : public Stream { public: // See comments for FileStream::Open() for detailed description of this enum. enum class Disposition { @@ -170,6 +170,6 @@ class CHROMEOS_EXPORT FileStream : public Stream { DISALLOW_COPY_AND_ASSIGN(FileStream); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_STREAMS_FILE_STREAM_H_ +#endif // LIBCHROMEOS_BRILLO_STREAMS_FILE_STREAM_H_ diff --git a/chromeos/streams/file_stream_unittest.cc b/brillo/streams/file_stream_unittest.cc index 7f01067..5941621 100644 --- a/chromeos/streams/file_stream_unittest.cc +++ b/brillo/streams/file_stream_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/file_stream.h> +#include <brillo/streams/file_stream.h> #include <limits> #include <numeric> @@ -15,11 +15,11 @@ #include <base/message_loop/message_loop.h> #include <base/rand_util.h> #include <base/run_loop.h> -#include <chromeos/bind_lambda.h> -#include <chromeos/errors/error_codes.h> -#include <chromeos/message_loops/base_message_loop.h> -#include <chromeos/message_loops/message_loop_utils.h> -#include <chromeos/streams/stream_errors.h> +#include <brillo/bind_lambda.h> +#include <brillo/errors/error_codes.h> +#include <brillo/message_loops/base_message_loop.h> +#include <brillo/message_loops/message_loop_utils.h> +#include <brillo/streams/stream_errors.h> #include <gmock/gmock.h> #include <gtest/gtest.h> @@ -30,7 +30,7 @@ using testing::SaveArg; using testing::SetErrnoAndReturn; using testing::_; -namespace chromeos { +namespace brillo { namespace { @@ -280,7 +280,7 @@ TEST_F(FileStreamTest, SetSizeBlocking) { } TEST_F(FileStreamTest, SetSizeBlocking_Fail) { - chromeos::ErrorPtr error; + brillo::ErrorPtr error; EXPECT_CALL(fd_mock(), Truncate(1235)).WillOnce(SetErrnoAndReturn(EIO, -1)); EXPECT_FALSE(stream_->SetSizeBlocking(1235, &error)); @@ -360,7 +360,7 @@ TEST_F(FileStreamTest, Seek_End) { } TEST_F(FileStreamTest, Seek_Fail) { - chromeos::ErrorPtr error; + brillo::ErrorPtr error; EXPECT_CALL(fd_mock(), Seek(0, SEEK_SET)) .WillOnce(SetErrnoAndReturn(EPIPE, -1)); EXPECT_FALSE(stream_->Seek(0, Stream::Whence::FROM_BEGIN, nullptr, &error)); @@ -423,7 +423,7 @@ TEST_F(FileStreamTest, ReadNonBlocking) { TEST_F(FileStreamTest, ReadNonBlocking_Fail) { size_t size = 0; - chromeos::ErrorPtr error; + brillo::ErrorPtr error; EXPECT_CALL(fd_mock(), Read(test_read_buffer_, _)) .WillOnce(SetErrnoAndReturn(EACCES, -1)); EXPECT_FALSE(stream_->ReadNonBlocking(test_read_buffer_, 100, &size, nullptr, @@ -462,7 +462,7 @@ TEST_F(FileStreamTest, ReadBlocking_Fail) { EXPECT_CALL(fd_mock(), WaitForDataBlocking(Stream::AccessMode::READ, _, _)) .WillOnce(SetErrnoAndReturn(EBADF, -1)); } - chromeos::ErrorPtr error; + brillo::ErrorPtr error; size_t size = 0; EXPECT_FALSE(stream_->ReadBlocking(test_read_buffer_, 80, &size, &error)); EXPECT_EQ(errors::system::kDomain, error->GetDomain()); @@ -500,7 +500,7 @@ TEST_F(FileStreamTest, ReadAllBlocking_Fail) { EXPECT_CALL(fd_mock(), Read(test_read_buffer_ + 20, 80)) .WillOnce(Return(0)); } - chromeos::ErrorPtr error; + brillo::ErrorPtr error; EXPECT_FALSE(stream_->ReadAllBlocking(test_read_buffer_, 100, &error)); EXPECT_EQ(errors::stream::kDomain, error->GetDomain()); EXPECT_EQ(errors::stream::kPartialData, error->GetCode()); @@ -556,7 +556,7 @@ TEST_F(FileStreamTest, WriteNonBlocking) { TEST_F(FileStreamTest, WriteNonBlocking_Fail) { size_t size = 0; - chromeos::ErrorPtr error; + brillo::ErrorPtr error; EXPECT_CALL(fd_mock(), Write(test_write_buffer_, _)) .WillOnce(SetErrnoAndReturn(EACCES, -1)); EXPECT_FALSE(stream_->WriteNonBlocking(test_write_buffer_, 100, &size, @@ -601,7 +601,7 @@ TEST_F(FileStreamTest, WriteBlocking_Fail) { EXPECT_CALL(fd_mock(), WaitForDataBlocking(Stream::AccessMode::WRITE, _, _)) .WillOnce(SetErrnoAndReturn(EBADF, -1)); } - chromeos::ErrorPtr error; + brillo::ErrorPtr error; size_t size = 0; EXPECT_FALSE(stream_->WriteBlocking(test_write_buffer_, 80, &size, &error)); EXPECT_EQ(errors::system::kDomain, error->GetDomain()); @@ -640,7 +640,7 @@ TEST_F(FileStreamTest, WriteAllBlocking_Fail) { EXPECT_CALL(fd_mock(), WaitForDataBlocking(Stream::AccessMode::WRITE, _, _)) .WillOnce(SetErrnoAndReturn(EBADF, -1)); } - chromeos::ErrorPtr error; + brillo::ErrorPtr error; EXPECT_FALSE(stream_->WriteAllBlocking(test_write_buffer_, 80, &error)); EXPECT_EQ(errors::system::kDomain, error->GetDomain()); EXPECT_EQ("EBADF", error->GetCode()); @@ -649,7 +649,7 @@ TEST_F(FileStreamTest, WriteAllBlocking_Fail) { TEST_F(FileStreamTest, WaitForDataBlocking_Timeout) { EXPECT_CALL(fd_mock(), WaitForDataBlocking(Stream::AccessMode::WRITE, _, _)) .WillOnce(Return(0)); - chromeos::ErrorPtr error; + brillo::ErrorPtr error; EXPECT_FALSE(stream_->WaitForDataBlocking(Stream::AccessMode::WRITE, {}, nullptr, &error)); EXPECT_EQ(errors::stream::kDomain, error->GetDomain()); @@ -669,7 +669,7 @@ TEST_F(FileStreamTest, CloseBlocking) { } TEST_F(FileStreamTest, CloseBlocking_Fail) { - chromeos::ErrorPtr error; + brillo::ErrorPtr error; EXPECT_CALL(fd_mock(), Close()).WillOnce(SetErrnoAndReturn(EFBIG, -1)); EXPECT_FALSE(stream_->CloseBlocking(&error)); EXPECT_EQ(errors::system::kDomain, error->GetDomain()); @@ -722,7 +722,6 @@ TEST_F(FileStreamTest, OpenRead) { EXPECT_EQ(0u, stream->GetPosition()); EXPECT_EQ(buffer.size(), stream->GetSize()); - std::vector<char> buffer2(buffer.size()); EXPECT_TRUE(stream->ReadAllBlocking(buffer2.data(), buffer2.size(), nullptr)); EXPECT_EQ(buffer2, buffer); @@ -1031,8 +1030,8 @@ TEST_F(FileStreamTest, FromFileDescriptor_ReadAsync) { bool failed = false; char buffer[100]; base::MessageLoopForIO base_loop; - BaseMessageLoop chromeos_loop{&base_loop}; - chromeos_loop.SetAsCurrent(); + BaseMessageLoop brillo_loop{&base_loop}; + brillo_loop.SetAsCurrent(); auto success_callback = [&succeeded, &buffer](size_t size) { std::string data{buffer, buffer + size}; @@ -1054,7 +1053,7 @@ TEST_F(FileStreamTest, FromFileDescriptor_ReadAsync) { StreamPtr stream = FileStream::FromFileDescriptor(fds[0], true, nullptr); // Write to the pipe with a bit of delay. - chromeos_loop.PostDelayedTask( + brillo_loop.PostDelayedTask( FROM_HERE, base::Bind(write_data_callback, fds[1]), base::TimeDelta::FromMilliseconds(10)); @@ -1063,7 +1062,7 @@ TEST_F(FileStreamTest, FromFileDescriptor_ReadAsync) { base::Bind(error_callback), nullptr)); auto end_condition = [&failed, &succeeded] { return failed || succeeded; }; - MessageLoopRunUntil(&chromeos_loop, + MessageLoopRunUntil(&brillo_loop, base::TimeDelta::FromSeconds(1), base::Bind(end_condition)); @@ -1080,8 +1079,8 @@ TEST_F(FileStreamTest, FromFileDescriptor_WriteAsync) { bool failed = false; const std::string data{"abracadabra"}; base::MessageLoopForIO base_loop; - BaseMessageLoop chromeos_loop{&base_loop}; - chromeos_loop.SetAsCurrent(); + BaseMessageLoop brillo_loop{&base_loop}; + brillo_loop.SetAsCurrent(); ASSERT_EQ(0, pipe(fds)); @@ -1103,7 +1102,7 @@ TEST_F(FileStreamTest, FromFileDescriptor_WriteAsync) { base::Bind(error_callback), nullptr)); auto end_condition = [&failed, &succeeded] { return failed || succeeded; }; - MessageLoopRunUntil(&chromeos_loop, + MessageLoopRunUntil(&brillo_loop, base::TimeDelta::FromSeconds(1), base::Bind(end_condition)); @@ -1114,4 +1113,4 @@ TEST_F(FileStreamTest, FromFileDescriptor_WriteAsync) { EXPECT_TRUE(stream->CloseBlocking(nullptr)); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/input_stream_set.cc b/brillo/streams/input_stream_set.cc index 745b964..913aaa0 100644 --- a/chromeos/streams/input_stream_set.cc +++ b/brillo/streams/input_stream_set.cc @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/input_stream_set.h> +#include <brillo/streams/input_stream_set.h> #include <base/bind.h> -#include <chromeos/message_loops/message_loop.h> -#include <chromeos/streams/stream_errors.h> -#include <chromeos/streams/stream_utils.h> +#include <brillo/message_loops/message_loop.h> +#include <brillo/streams/stream_errors.h> +#include <brillo/streams/stream_utils.h> -namespace chromeos { +namespace brillo { InputStreamSet::InputStreamSet( std::vector<Stream*> source_streams, @@ -26,8 +26,8 @@ StreamPtr InputStreamSet::Create(std::vector<Stream*> source_streams, if (source_streams.empty()) { Error::AddTo(error, FROM_HERE, errors::stream::kDomain, - errors::stream::kInvalidParameter, - "Source stream list is empty"); + errors::stream::kInvalidParameter, + "Source stream list is empty"); return stream; } @@ -202,4 +202,4 @@ void InputStreamSet::CancelPendingAsyncOperations() { Stream::CancelPendingAsyncOperations(); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/input_stream_set.h b/brillo/streams/input_stream_set.h index a37ab08..fda255f 100644 --- a/chromeos/streams/input_stream_set.h +++ b/brillo/streams/input_stream_set.h @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_STREAMS_INPUT_STREAM_SET_H_ -#define LIBCHROMEOS_CHROMEOS_STREAMS_INPUT_STREAM_SET_H_ +#ifndef LIBCHROMEOS_BRILLO_STREAMS_INPUT_STREAM_SET_H_ +#define LIBCHROMEOS_BRILLO_STREAMS_INPUT_STREAM_SET_H_ #include <vector> #include <base/macros.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/streams/stream.h> +#include <brillo/brillo_export.h> +#include <brillo/streams/stream.h> -namespace chromeos { +namespace brillo { // Multiplexer stream allows to bundle a bunch of secondary streams in one // logical stream and simulate a read operation across data concatenated from @@ -28,7 +28,7 @@ namespace chromeos { // Referenced source streams' life time is maintained elsewhere and they must // be valid for the duration of InputStreamSet's life. Closing the // muliplexer stream does not close the referenced streams. -class CHROMEOS_EXPORT InputStreamSet : public Stream { +class BRILLO_EXPORT InputStreamSet : public Stream { public: // == Construction ========================================================== @@ -47,8 +47,7 @@ class CHROMEOS_EXPORT InputStreamSet : public Stream { // Simple helper method to create a multiplexer stream with a list of // referenced streams. None of the streams will be owned. // Effectively calls Create(source_streams, {}, error); - static StreamPtr Create(std::vector<Stream*> source_streams, - ErrorPtr* error); + static StreamPtr Create(std::vector<Stream*> source_streams, ErrorPtr* error); // Simple helper method to create a multiplexer stream with a list of // referenced streams. None of the streams will be owned. @@ -128,6 +127,6 @@ class CHROMEOS_EXPORT InputStreamSet : public Stream { DISALLOW_COPY_AND_ASSIGN(InputStreamSet); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_STREAMS_INPUT_STREAM_SET_H_ +#endif // LIBCHROMEOS_BRILLO_STREAMS_INPUT_STREAM_SET_H_ diff --git a/chromeos/streams/input_stream_set_unittest.cc b/brillo/streams/input_stream_set_unittest.cc index 82ac60c..3268d96 100644 --- a/chromeos/streams/input_stream_set_unittest.cc +++ b/brillo/streams/input_stream_set_unittest.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/input_stream_set.h> +#include <brillo/streams/input_stream_set.h> -#include <chromeos/errors/error_codes.h> -#include <chromeos/streams/mock_stream.h> -#include <chromeos/streams/stream_errors.h> +#include <brillo/errors/error_codes.h> +#include <brillo/streams/mock_stream.h> +#include <brillo/streams/stream_errors.h> #include <gmock/gmock.h> #include <gtest/gtest.h> @@ -18,7 +18,7 @@ using testing::SetArgPointee; using testing::StrictMock; using testing::_; -namespace chromeos { +namespace brillo { class InputStreamSetTest : public testing::Test { public: @@ -167,4 +167,4 @@ TEST_F(InputStreamSetTest, ReadBlocking) { EXPECT_EQ(0, read); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/memory_containers.cc b/brillo/streams/memory_containers.cc index 5a0b653..6e277b8 100644 --- a/chromeos/streams/memory_containers.cc +++ b/brillo/streams/memory_containers.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/memory_containers.h> +#include <brillo/streams/memory_containers.h> #include <base/callback.h> -#include <chromeos/streams/stream_errors.h> +#include <brillo/streams/stream_errors.h> -namespace chromeos { +namespace brillo { namespace data_container { namespace { @@ -126,4 +126,4 @@ ReadOnlyStringCopy::ReadOnlyStringCopy(std::string string) : ReadOnlyStringRef(string_copy_), string_copy_(std::move(string)) {} } // namespace data_container -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/memory_containers.h b/brillo/streams/memory_containers.h index 3b8d216..498401e 100644 --- a/chromeos/streams/memory_containers.h +++ b/brillo/streams/memory_containers.h @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_STREAMS_MEMORY_CONTAINERS_H_ -#define LIBCHROMEOS_CHROMEOS_STREAMS_MEMORY_CONTAINERS_H_ +#ifndef LIBCHROMEOS_BRILLO_STREAMS_MEMORY_CONTAINERS_H_ +#define LIBCHROMEOS_BRILLO_STREAMS_MEMORY_CONTAINERS_H_ #include <string> #include <vector> -#include <chromeos/chromeos_export.h> -#include <chromeos/errors/error.h> -#include <chromeos/streams/stream.h> +#include <brillo/brillo_export.h> +#include <brillo/errors/error.h> +#include <brillo/streams/stream.h> -namespace chromeos { +namespace brillo { namespace data_container { // MemoryStream class relies on helper classes defined below to support data @@ -24,7 +24,7 @@ namespace data_container { // container, getting and changing the buffer size, and so on, must be provided. // Not all methods must be provided. For example, for read-only containers, only // read operations can be provided. -class CHROMEOS_EXPORT DataContainerInterface { +class BRILLO_EXPORT DataContainerInterface { public: DataContainerInterface() = default; virtual ~DataContainerInterface() = default; @@ -65,7 +65,7 @@ class CHROMEOS_EXPORT DataContainerInterface { // employ contiguous memory for all of their data. This class provides the // default implementation for Read() and Write() functions and requires the // implementations to provide GetBuffer() and/or ReadOnlyBuffer() functions. -class CHROMEOS_EXPORT ContiguousBufferBase : public DataContainerInterface { +class BRILLO_EXPORT ContiguousBufferBase : public DataContainerInterface { public: ContiguousBufferBase() = default; // Implementation of DataContainerInterface::Read(). @@ -101,8 +101,7 @@ class CHROMEOS_EXPORT ContiguousBufferBase : public DataContainerInterface { // ContiguousReadOnlyBufferBase is a specialization of ContiguousBufferBase for // read-only containers. -class CHROMEOS_EXPORT ContiguousReadOnlyBufferBase - : public ContiguousBufferBase { +class BRILLO_EXPORT ContiguousReadOnlyBufferBase : public ContiguousBufferBase { public: ContiguousReadOnlyBufferBase() = default; // Fails with an error "operation_not_supported" (Stream is read-only) error. @@ -123,7 +122,7 @@ class CHROMEOS_EXPORT ContiguousReadOnlyBufferBase }; // ReadOnlyBuffer implements a read-only container based on raw memory block. -class CHROMEOS_EXPORT ReadOnlyBuffer : public ContiguousReadOnlyBufferBase { +class BRILLO_EXPORT ReadOnlyBuffer : public ContiguousReadOnlyBufferBase { public: // Constructs the container based at the pointer to memory |buffer| and its // |size|. The pointer to the memory must be valid throughout life-time of @@ -225,7 +224,7 @@ class ReadOnlyVectorCopy : public ContiguousReadOnlyBufferBase { // ByteBuffer is a read/write container that manages the data and underlying // storage. -class CHROMEOS_EXPORT ByteBuffer : public VectorPtr<uint8_t> { +class BRILLO_EXPORT ByteBuffer : public VectorPtr<uint8_t> { public: explicit ByteBuffer(size_t reserve_size); ~ByteBuffer() override; @@ -235,7 +234,7 @@ class CHROMEOS_EXPORT ByteBuffer : public VectorPtr<uint8_t> { }; // StringPtr is a read/write container based on external std::string storage. -class CHROMEOS_EXPORT StringPtr : public ContiguousBufferBase { +class BRILLO_EXPORT StringPtr : public ContiguousBufferBase { public: explicit StringPtr(std::string* string); @@ -253,7 +252,7 @@ class CHROMEOS_EXPORT StringPtr : public ContiguousBufferBase { }; // ReadOnlyStringRef is a read-only container based on external std::string. -class CHROMEOS_EXPORT ReadOnlyStringRef : public ContiguousReadOnlyBufferBase { +class BRILLO_EXPORT ReadOnlyStringRef : public ContiguousReadOnlyBufferBase { public: explicit ReadOnlyStringRef(const std::string& string); const void* GetReadOnlyBuffer(size_t offset, ErrorPtr* error) const override; @@ -268,7 +267,7 @@ class CHROMEOS_EXPORT ReadOnlyStringRef : public ContiguousReadOnlyBufferBase { // ReadOnlyStringCopy is a read-only container based on a copy of a std::string. // This container actually owns the data stored in the string. -class CHROMEOS_EXPORT ReadOnlyStringCopy : public ReadOnlyStringRef { +class BRILLO_EXPORT ReadOnlyStringCopy : public ReadOnlyStringRef { public: explicit ReadOnlyStringCopy(std::string string); @@ -280,6 +279,6 @@ class CHROMEOS_EXPORT ReadOnlyStringCopy : public ReadOnlyStringRef { }; } // namespace data_container -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_STREAMS_MEMORY_CONTAINERS_H_ +#endif // LIBCHROMEOS_BRILLO_STREAMS_MEMORY_CONTAINERS_H_ diff --git a/chromeos/streams/memory_containers_unittest.cc b/brillo/streams/memory_containers_unittest.cc index 1882ac6..2f0bf38 100644 --- a/chromeos/streams/memory_containers_unittest.cc +++ b/brillo/streams/memory_containers_unittest.cc @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/memory_containers.h> +#include <brillo/streams/memory_containers.h> #include <limits> #include <memory> -#include <chromeos/streams/mock_stream.h> -#include <chromeos/streams/stream_errors.h> +#include <brillo/streams/mock_stream.h> +#include <brillo/streams/stream_errors.h> #include <gmock/gmock.h> #include <gtest/gtest.h> @@ -19,7 +19,7 @@ using testing::Return; using testing::WithArgs; using testing::_; -namespace chromeos { +namespace brillo { namespace { class MockContiguousBuffer : public data_container::ContiguousBufferBase { @@ -210,5 +210,5 @@ TEST_F(MemoryContainerTest, Write_Error) { EXPECT_EQ("write error", error->GetMessage()); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/memory_stream.cc b/brillo/streams/memory_stream.cc index 6bc5756..c9712b0 100644 --- a/chromeos/streams/memory_stream.cc +++ b/brillo/streams/memory_stream.cc @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/memory_stream.h> +#include <brillo/streams/memory_stream.h> #include <limits> #include <base/bind.h> -#include <chromeos/message_loops/message_loop.h> -#include <chromeos/streams/stream_errors.h> -#include <chromeos/streams/stream_utils.h> +#include <brillo/message_loops/message_loop.h> +#include <brillo/streams/stream_errors.h> +#include <brillo/streams/stream_utils.h> -namespace chromeos { +namespace brillo { MemoryStream::MemoryStream( std::unique_ptr<data_container::DataContainerInterface> container, @@ -105,7 +105,7 @@ bool MemoryStream::SetSizeBlocking(uint64_t size, ErrorPtr* error) { uint64_t MemoryStream::GetRemainingSize() const { uint64_t pos = GetPosition(); uint64_t size = GetSize(); - return (pos < size) ? size - pos : 0; + return (pos < size) ? size - pos : 0; } uint64_t MemoryStream::GetPosition() const { @@ -125,11 +125,9 @@ bool MemoryStream::Seek(int64_t offset, } if (pos > static_cast<uint64_t>(std::numeric_limits<size_t>::max())) { // This can only be the case on 32 bit systems. - chromeos::Error::AddTo(error, - FROM_HERE, - errors::stream::kDomain, - errors::stream::kInvalidParameter, - "Stream pointer position is outside allowed limits"); + brillo::Error::AddTo(error, FROM_HERE, errors::stream::kDomain, + errors::stream::kInvalidParameter, + "Stream pointer position is outside allowed limits"); return false; } @@ -200,4 +198,4 @@ bool MemoryStream::WaitForDataBlocking(AccessMode in_mode, return true; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/memory_stream.h b/brillo/streams/memory_stream.h index ac03440..b9f5e4b 100644 --- a/chromeos/streams/memory_stream.h +++ b/brillo/streams/memory_stream.h @@ -2,21 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_STREAMS_MEMORY_STREAM_H_ -#define LIBCHROMEOS_CHROMEOS_STREAMS_MEMORY_STREAM_H_ +#ifndef LIBCHROMEOS_BRILLO_STREAMS_MEMORY_STREAM_H_ +#define LIBCHROMEOS_BRILLO_STREAMS_MEMORY_STREAM_H_ #include <string> #include <vector> #include <base/macros.h> #include <base/memory/weak_ptr.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/streams/memory_containers.h> -#include <chromeos/streams/stream.h> +#include <brillo/brillo_export.h> +#include <brillo/streams/memory_containers.h> +#include <brillo/streams/stream.h> -namespace chromeos { +namespace brillo { -// MemoryStream is a chromeos::Stream implementation for memory buffer. A number +// MemoryStream is a brillo::Stream implementation for memory buffer. A number // of memory containers are supported, such as raw memory pointers, data stored // in std::vector and std::string. // MemoryStream offers support for constant read-only memory buffers as well as @@ -48,7 +48,7 @@ namespace chromeos { // positions the stream seek pointer at the end of the data, // which makes it possible to append more data to the existing // container. -class CHROMEOS_EXPORT MemoryStream : public Stream { +class BRILLO_EXPORT MemoryStream : public Stream { public: // == Construction ========================================================== @@ -59,8 +59,7 @@ class CHROMEOS_EXPORT MemoryStream : public Stream { static StreamPtr OpenCopyOf(const char* buffer, ErrorPtr* error); // Only vectors of char and uint8_t are supported. template<typename T> - inline static StreamPtr OpenCopyOf(std::vector<T> buffer, - ErrorPtr* error) { + inline static StreamPtr OpenCopyOf(std::vector<T> buffer, ErrorPtr* error) { std::unique_ptr<data_container::ReadOnlyVectorCopy<T>> container{ new data_container::ReadOnlyVectorCopy<T>{std::move(buffer)}}; return CreateEx(std::move(container), 0, error); @@ -208,6 +207,6 @@ class CHROMEOS_EXPORT MemoryStream : public Stream { DISALLOW_COPY_AND_ASSIGN(MemoryStream); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_STREAMS_MEMORY_STREAM_H_ +#endif // LIBCHROMEOS_BRILLO_STREAMS_MEMORY_STREAM_H_ diff --git a/chromeos/streams/memory_stream_unittest.cc b/brillo/streams/memory_stream_unittest.cc index 423681a..75278f7 100644 --- a/chromeos/streams/memory_stream_unittest.cc +++ b/brillo/streams/memory_stream_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/memory_stream.h> +#include <brillo/streams/memory_stream.h> #include <algorithm> #include <limits> @@ -10,7 +10,7 @@ #include <string> #include <vector> -#include <chromeos/streams/stream_errors.h> +#include <brillo/streams/stream_errors.h> #include <gmock/gmock.h> #include <gtest/gtest.h> @@ -19,11 +19,11 @@ using testing::Return; using testing::SetArgPointee; using testing::_; -namespace chromeos { +namespace brillo { namespace { -int ReadByte(Stream* stream, chromeos::ErrorPtr* error) { +int ReadByte(Stream* stream, brillo::ErrorPtr* error) { uint8_t byte = 0; return stream->ReadAllBlocking(&byte, sizeof(byte), error) ? byte : -1; } @@ -209,7 +209,7 @@ TEST(MemoryStream, OpenBinary) { EXPECT_EQ(5, ReadByte(stream.get(), nullptr)); EXPECT_EQ(2, ReadByte(stream.get(), nullptr)); EXPECT_EQ(3, ReadByte(stream.get(), nullptr)); - chromeos::ErrorPtr error; + brillo::ErrorPtr error; EXPECT_EQ(-1, ReadByte(stream.get(), &error)); EXPECT_EQ(errors::stream::kPartialData, error->GetCode()); EXPECT_EQ("Reading past the end of stream", error->GetMessage()); @@ -223,7 +223,7 @@ TEST(MemoryStream, OpenBinaryCopy) { EXPECT_EQ(1, ReadByte(stream.get(), nullptr)); EXPECT_EQ(2, ReadByte(stream.get(), nullptr)); EXPECT_EQ(3, ReadByte(stream.get(), nullptr)); - chromeos::ErrorPtr error; + brillo::ErrorPtr error; EXPECT_EQ(-1, ReadByte(stream.get(), &error)); EXPECT_EQ(errors::stream::kPartialData, error->GetCode()); EXPECT_EQ("Reading past the end of stream", error->GetMessage()); @@ -379,4 +379,4 @@ TEST(MemoryStream, CreateString) { EXPECT_EQ("abcd_1234", buffer); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/mock_stream.h b/brillo/streams/mock_stream.h index a1303c2..4289cc0 100644 --- a/chromeos/streams/mock_stream.h +++ b/brillo/streams/mock_stream.h @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_STREAMS_MOCK_STREAM_H_ -#define LIBCHROMEOS_CHROMEOS_STREAMS_MOCK_STREAM_H_ +#ifndef LIBCHROMEOS_BRILLO_STREAMS_MOCK_STREAM_H_ +#define LIBCHROMEOS_BRILLO_STREAMS_MOCK_STREAM_H_ #include <gmock/gmock.h> -#include <chromeos/streams/stream.h> +#include <brillo/streams/stream.h> -namespace chromeos { +namespace brillo { // Mock Stream implementation for testing. class MockStream : public Stream { @@ -70,6 +70,6 @@ class MockStream : public Stream { DISALLOW_COPY_AND_ASSIGN(MockStream); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_STREAMS_MOCK_STREAM_H_ +#endif // LIBCHROMEOS_BRILLO_STREAMS_MOCK_STREAM_H_ diff --git a/chromeos/streams/openssl_stream_bio.cc b/brillo/streams/openssl_stream_bio.cc index 7c40b18..54a5536 100644 --- a/chromeos/streams/openssl_stream_bio.cc +++ b/brillo/streams/openssl_stream_bio.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/openssl_stream_bio.h> +#include <brillo/streams/openssl_stream_bio.h> #include <openssl/bio.h> #include <base/numerics/safe_conversions.h> -#include <chromeos/streams/stream.h> +#include <brillo/streams/stream.h> -namespace chromeos { +namespace brillo { namespace { -// Internal functions for implementing OpenSSL BIO on chromeos::Stream. +// Internal functions for implementing OpenSSL BIO on brillo::Stream. int stream_write(BIO* bio, const char* buf, int size) { - chromeos::Stream* stream = static_cast<chromeos::Stream*>(bio->ptr); + brillo::Stream* stream = static_cast<brillo::Stream*>(bio->ptr); size_t written = 0; BIO_clear_retry_flags(bio); if (!stream->WriteNonBlocking(buf, size, &written, nullptr)) @@ -30,7 +30,7 @@ int stream_write(BIO* bio, const char* buf, int size) { } int stream_read(BIO* bio, char* buf, int size) { - chromeos::Stream* stream = static_cast<chromeos::Stream*>(bio->ptr); + brillo::Stream* stream = static_cast<brillo::Stream*>(bio->ptr); size_t read = 0; BIO_clear_retry_flags(bio); bool eos = false; @@ -49,7 +49,7 @@ int stream_read(BIO* bio, char* buf, int size) { // NOLINTNEXTLINE(runtime/int) long stream_ctrl(BIO* bio, int cmd, long num, void* ptr) { if (cmd == BIO_CTRL_FLUSH) { - chromeos::Stream* stream = static_cast<chromeos::Stream*>(bio->ptr); + brillo::Stream* stream = static_cast<brillo::Stream*>(bio->ptr); return stream->FlushBlocking(nullptr) ? 1 : 0; } return 0; @@ -73,7 +73,7 @@ int stream_free(BIO* bio) { return 1; } -// BIO_METHOD structure describing the BIO built on top of chromeos::Stream. +// BIO_METHOD structure describing the BIO built on top of brillo::Stream. BIO_METHOD stream_method = { 0x7F | BIO_TYPE_SOURCE_SINK, // type: 0x7F is an arbitrary unused type ID. "stream", // name @@ -89,7 +89,7 @@ BIO_METHOD stream_method = { } // anonymous namespace -BIO* BIO_new_stream(chromeos::Stream* stream) { +BIO* BIO_new_stream(brillo::Stream* stream) { BIO* bio = BIO_new(&stream_method); if (bio) { bio->ptr = stream; @@ -98,4 +98,4 @@ BIO* BIO_new_stream(chromeos::Stream* stream) { return bio; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/openssl_stream_bio.h b/brillo/streams/openssl_stream_bio.h index dba2b1c..3cb0989 100644 --- a/chromeos/streams/openssl_stream_bio.h +++ b/brillo/streams/openssl_stream_bio.h @@ -2,26 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_STREAMS_OPENSSL_STREAM_BIO_H_ -#define LIBCHROMEOS_CHROMEOS_STREAMS_OPENSSL_STREAM_BIO_H_ +#ifndef LIBCHROMEOS_BRILLO_STREAMS_OPENSSL_STREAM_BIO_H_ +#define LIBCHROMEOS_BRILLO_STREAMS_OPENSSL_STREAM_BIO_H_ -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> // Forward-declare BIO as an alias to OpenSSL's internal bio_st structure. using BIO = struct bio_st; -namespace chromeos { +namespace brillo { class Stream; -// Creates a new BIO that uses the chromeos::Stream as the back-end storage. +// Creates a new BIO that uses the brillo::Stream as the back-end storage. // The created BIO does *NOT* own the |stream| and the stream must out-live // the BIO. // At the moment, only BIO_read and BIO_write operations are supported as well // as BIO_flush. More functionality could be added to this when/if needed. // The returned BIO performs *NON-BLOCKING* IO on the underlying stream. -CHROMEOS_EXPORT BIO* BIO_new_stream(chromeos::Stream* stream); +BRILLO_EXPORT BIO* BIO_new_stream(brillo::Stream* stream); -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_STREAMS_OPENSSL_STREAM_BIO_H_ +#endif // LIBCHROMEOS_BRILLO_STREAMS_OPENSSL_STREAM_BIO_H_ diff --git a/chromeos/streams/openssl_stream_bio_unittests.cc b/brillo/streams/openssl_stream_bio_unittests.cc index 5deb521..a80710d 100644 --- a/chromeos/streams/openssl_stream_bio_unittests.cc +++ b/brillo/streams/openssl_stream_bio_unittests.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/openssl_stream_bio.h> +#include <brillo/streams/openssl_stream_bio.h> #include <memory> #include <openssl/bio.h> -#include <chromeos/streams/mock_stream.h> +#include <brillo/streams/mock_stream.h> #include <gmock/gmock.h> #include <gtest/gtest.h> @@ -17,7 +17,7 @@ using testing::SetArgPointee; using testing::StrictMock; using testing::_; -namespace chromeos { +namespace brillo { class StreamBIOTest : public testing::Test { public: @@ -122,4 +122,4 @@ TEST_F(StreamBIOTest, FlushError) { EXPECT_EQ(0, BIO_flush(bio_)); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/stream.cc b/brillo/streams/stream.cc index 64f9428..cd9b0a8 100644 --- a/chromeos/streams/stream.cc +++ b/brillo/streams/stream.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/stream.h> +#include <brillo/streams/stream.h> #include <algorithm> #include <base/bind.h> -#include <chromeos/message_loops/message_loop.h> -#include <chromeos/pointer_utils.h> -#include <chromeos/streams/stream_errors.h> -#include <chromeos/streams/stream_utils.h> +#include <brillo/message_loops/message_loop.h> +#include <brillo/pointer_utils.h> +#include <brillo/streams/stream_errors.h> +#include <brillo/streams/stream_utils.h> -namespace chromeos { +namespace brillo { bool Stream::TruncateBlocking(ErrorPtr* error) { return SetSizeBlocking(GetPosition(), error); @@ -389,4 +389,4 @@ void Stream::CancelPendingAsyncOperations() { is_async_write_pending_ = false; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/stream.h b/brillo/streams/stream.h index f1ad75a..6614cb3 100644 --- a/chromeos/streams/stream.h +++ b/brillo/streams/stream.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_STREAMS_STREAM_H_ -#define LIBCHROMEOS_CHROMEOS_STREAMS_STREAM_H_ +#ifndef LIBCHROMEOS_BRILLO_STREAMS_STREAM_H_ +#define LIBCHROMEOS_BRILLO_STREAMS_STREAM_H_ #include <cstdint> #include <memory> @@ -12,10 +12,10 @@ #include <base/macros.h> #include <base/memory/weak_ptr.h> #include <base/time/time.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/errors/error.h> +#include <brillo/brillo_export.h> +#include <brillo/errors/error.h> -namespace chromeos { +namespace brillo { // Stream is a base class that specific stream storage implementations must // derive from to provide I/O facilities. @@ -81,7 +81,7 @@ namespace chromeos { // return my_stream; // } // -class CHROMEOS_EXPORT Stream { +class BRILLO_EXPORT Stream { public: // When seeking in streams, whence specifies the origin of the seek operation. enum class Whence { FROM_BEGIN, FROM_CURRENT, FROM_END }; @@ -396,7 +396,7 @@ class CHROMEOS_EXPORT Stream { private: // Simple wrapper to call the externally exposed |success_callback| that only // receives a size_t. - CHROMEOS_PRIVATE static void IgnoreEOSCallback( + BRILLO_PRIVATE static void IgnoreEOSCallback( const base::Callback<void(size_t)>& success_callback, size_t read, bool eos); @@ -409,7 +409,7 @@ class CHROMEOS_EXPORT Stream { // situation in which it would block (bytes_read = 0 and eos = false), // preventing us from calling WaitForData() on streams that don't support such // feature. - CHROMEOS_PRIVATE bool ReadAsyncImpl( + BRILLO_PRIVATE bool ReadAsyncImpl( void* buffer, size_t size_to_read, const base::Callback<void(size_t, bool)>& success_callback, @@ -421,14 +421,14 @@ class CHROMEOS_EXPORT Stream { // without waiting for data. We use this callback to call the // |sucess_callback| but invalidate the callback if the Stream is destroyed // while this call is waiting in the main loop. - CHROMEOS_PRIVATE void OnReadAsyncDone( + BRILLO_PRIVATE void OnReadAsyncDone( const base::Callback<void(size_t, bool)>& success_callback, size_t bytes_read, bool eos); // Called from WaitForData() when read operations can be performed // without blocking (the type of operation is provided in |mode|). - CHROMEOS_PRIVATE void OnReadAvailable( + BRILLO_PRIVATE void OnReadAvailable( void* buffer, size_t size_to_read, const base::Callback<void(size_t, bool)>& success_callback, @@ -443,7 +443,7 @@ class CHROMEOS_EXPORT Stream { // WriteNonBlocking() returns a situation in which it would block // (size_written = 0 and eos = false), preventing us from calling // WaitForData() on streams that don't support such feature. - CHROMEOS_PRIVATE bool WriteAsyncImpl( + BRILLO_PRIVATE bool WriteAsyncImpl( const void* buffer, size_t size_to_write, const base::Callback<void(size_t)>& success_callback, @@ -455,13 +455,13 @@ class CHROMEOS_EXPORT Stream { // without waiting for data. We use this callback to call the // |sucess_callback| but invalidate the callback if the Stream is destroyed // while this call is waiting in the main loop. - CHROMEOS_PRIVATE void OnWriteAsyncDone( + BRILLO_PRIVATE void OnWriteAsyncDone( const base::Callback<void(size_t)>& success_callback, size_t size_written); // Called from WaitForData() when write operations can be performed // without blocking (the type of operation is provided in |mode|). - CHROMEOS_PRIVATE void OnWriteAvailable( + BRILLO_PRIVATE void OnWriteAvailable( const void* buffer, size_t size, const base::Callback<void(size_t)>& success_callback, @@ -469,14 +469,14 @@ class CHROMEOS_EXPORT Stream { AccessMode mode); // Helper callbacks to implement ReadAllAsync/WriteAllAsync. - CHROMEOS_PRIVATE void ReadAllAsyncCallback( + BRILLO_PRIVATE void ReadAllAsyncCallback( void* buffer, size_t size_to_read, const base::Closure& success_callback, const ErrorCallback& error_callback, size_t size_read, bool eos); - CHROMEOS_PRIVATE void WriteAllAsyncCallback( + BRILLO_PRIVATE void WriteAllAsyncCallback( const void* buffer, size_t size_to_write, const base::Closure& success_callback, @@ -484,7 +484,7 @@ class CHROMEOS_EXPORT Stream { size_t size_written); // Helper callbacks to implement FlushAsync(). - CHROMEOS_PRIVATE void FlushAsyncCallback( + BRILLO_PRIVATE void FlushAsyncCallback( const base::Closure& success_callback, const ErrorCallback& error_callback); @@ -501,6 +501,6 @@ class CHROMEOS_EXPORT Stream { // A smart pointer to the stream used to pass the stream object around. using StreamPtr = std::unique_ptr<Stream>; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_STREAMS_STREAM_H_ +#endif // LIBCHROMEOS_BRILLO_STREAMS_STREAM_H_ diff --git a/chromeos/streams/stream_errors.cc b/brillo/streams/stream_errors.cc index 35911c5..e7c3dcd 100644 --- a/chromeos/streams/stream_errors.cc +++ b/brillo/streams/stream_errors.cc @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/stream_errors.h> +#include <brillo/streams/stream_errors.h> -namespace chromeos { +namespace brillo { namespace errors { namespace stream { @@ -18,4 +18,4 @@ const char kTimeout[] = "time_out"; } // namespace stream } // namespace errors -} // namespace chromeos +} // namespace brillo diff --git a/brillo/streams/stream_errors.h b/brillo/streams/stream_errors.h new file mode 100644 index 0000000..564d097 --- /dev/null +++ b/brillo/streams/stream_errors.h @@ -0,0 +1,27 @@ +// Copyright 2015 The Chromium OS Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef LIBCHROMEOS_BRILLO_STREAMS_STREAM_ERRORS_H_ +#define LIBCHROMEOS_BRILLO_STREAMS_STREAM_ERRORS_H_ + +#include <brillo/brillo_export.h> + +namespace brillo { +namespace errors { +namespace stream { + +// Error domain for generic stream-based errors. +BRILLO_EXPORT extern const char kDomain[]; + +BRILLO_EXPORT extern const char kStreamClosed[]; +BRILLO_EXPORT extern const char kOperationNotSupported[]; +BRILLO_EXPORT extern const char kPartialData[]; +BRILLO_EXPORT extern const char kInvalidParameter[]; +BRILLO_EXPORT extern const char kTimeout[]; + +} // namespace stream +} // namespace errors +} // namespace brillo + +#endif // LIBCHROMEOS_BRILLO_STREAMS_STREAM_ERRORS_H_ diff --git a/chromeos/streams/stream_unittest.cc b/brillo/streams/stream_unittest.cc index 6485a17..d19b9ac 100644 --- a/chromeos/streams/stream_unittest.cc +++ b/brillo/streams/stream_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/stream.h> +#include <brillo/streams/stream.h> #include <limits> @@ -10,9 +10,9 @@ #include <gmock/gmock.h> #include <gtest/gtest.h> -#include <chromeos/bind_lambda.h> -#include <chromeos/message_loops/fake_message_loop.h> -#include <chromeos/streams/stream_errors.h> +#include <brillo/bind_lambda.h> +#include <brillo/message_loops/fake_message_loop.h> +#include <brillo/streams/stream_errors.h> using testing::DoAll; using testing::InSequence; @@ -21,7 +21,7 @@ using testing::SaveArg; using testing::SetArgPointee; using testing::_; -namespace chromeos { +namespace brillo { using AccessMode = Stream::AccessMode; using Whence = Stream::Whence; @@ -478,4 +478,4 @@ TEST(Stream, WriteAllBlocking) { EXPECT_TRUE(stream_mock.WriteAllBlocking(buf, sizeof(buf), nullptr)); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/stream_utils.cc b/brillo/streams/stream_utils.cc index b9e9847..5f3be24 100644 --- a/chromeos/streams/stream_utils.cc +++ b/brillo/streams/stream_utils.cc @@ -2,23 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/stream_utils.h> +#include <brillo/streams/stream_utils.h> #include <limits> #include <base/bind.h> -#include <chromeos/message_loops/message_loop.h> -#include <chromeos/streams/stream_errors.h> +#include <brillo/message_loops/message_loop.h> +#include <brillo/streams/stream_errors.h> -namespace chromeos { +namespace brillo { namespace stream_utils { namespace { // Status of asynchronous CopyData operation. struct CopyDataState { - chromeos::StreamPtr in_stream; - chromeos::StreamPtr out_stream; + brillo::StreamPtr in_stream; + brillo::StreamPtr out_stream; std::vector<uint8_t> buffer; uint64_t remaining_to_copy; uint64_t size_copied; @@ -28,7 +28,7 @@ struct CopyDataState { // Async CopyData I/O error callback. void OnCopyDataError(const std::shared_ptr<CopyDataState>& state, - const chromeos::Error* error) { + const brillo::Error* error) { state->error_callback.Run(std::move(state->in_stream), std::move(state->out_stream), error); } @@ -49,7 +49,7 @@ void PerformWrite(const std::shared_ptr<CopyDataState>& state, size_t size) { CHECK_GE(state->remaining_to_copy, size); state->remaining_to_copy -= size; - chromeos::ErrorPtr error; + brillo::ErrorPtr error; bool success = state->out_stream->WriteAllAsync( state->buffer.data(), size, base::Bind(&PerformRead, state), base::Bind(&OnCopyDataError, state), &error); @@ -62,7 +62,7 @@ void PerformWrite(const std::shared_ptr<CopyDataState>& state, size_t size) { // from input stream and invokes PerformWrite when done to write the data to // the output stream. void PerformRead(const std::shared_ptr<CopyDataState>& state) { - chromeos::ErrorPtr error; + brillo::ErrorPtr error; const uint64_t buffer_size = state->buffer.size(); // |buffer_size| is guaranteed to fit in size_t, so |size_to_read| value will // also not overflow size_t, so the static_cast below is safe. @@ -120,7 +120,6 @@ bool ErrorOperationTimeout(const tracked_objects::Location& location, return false; } - bool CheckInt64Overflow(const tracked_objects::Location& location, uint64_t position, int64_t offset, @@ -209,9 +208,9 @@ void CopyData(StreamPtr in_stream, state->size_copied = 0; state->success_callback = success_callback; state->error_callback = error_callback; - chromeos::MessageLoop::current()->PostTask(FROM_HERE, + brillo::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&PerformRead, state)); } } // namespace stream_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/stream_utils.h b/brillo/streams/stream_utils.h index 0e85887..84792ce 100644 --- a/chromeos/streams/stream_utils.h +++ b/brillo/streams/stream_utils.h @@ -2,30 +2,30 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_STREAMS_STREAM_UTILS_H_ -#define LIBCHROMEOS_CHROMEOS_STREAMS_STREAM_UTILS_H_ +#ifndef LIBCHROMEOS_BRILLO_STREAMS_STREAM_UTILS_H_ +#define LIBCHROMEOS_BRILLO_STREAMS_STREAM_UTILS_H_ #include <base/location.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/streams/stream.h> +#include <brillo/brillo_export.h> +#include <brillo/streams/stream.h> -namespace chromeos { +namespace brillo { namespace stream_utils { // Generates "Stream closed" error and returns false. -CHROMEOS_EXPORT bool ErrorStreamClosed( +BRILLO_EXPORT bool ErrorStreamClosed( const tracked_objects::Location& location, ErrorPtr* error); // Generates "Not supported" error and returns false. -CHROMEOS_EXPORT bool ErrorOperationNotSupported( +BRILLO_EXPORT bool ErrorOperationNotSupported( const tracked_objects::Location& location, ErrorPtr* error); // Generates "Read past end of stream" error and returns false. -CHROMEOS_EXPORT bool ErrorReadPastEndOfStream( +BRILLO_EXPORT bool ErrorReadPastEndOfStream( const tracked_objects::Location& location, ErrorPtr* error); // Generates "Operation time out" error and returns false. -CHROMEOS_EXPORT bool ErrorOperationTimeout( +BRILLO_EXPORT bool ErrorOperationTimeout( const tracked_objects::Location& location, ErrorPtr* error); // Checks if |position| + |offset| fit within the constraint of positive @@ -36,7 +36,7 @@ CHROMEOS_EXPORT bool ErrorOperationTimeout( // "only" up to 9 exabytes, instead of the possible 18). // The |location| parameter will be used to report the origin of the error // if one is generated/triggered. -CHROMEOS_EXPORT bool CheckInt64Overflow( +BRILLO_EXPORT bool CheckInt64Overflow( const tracked_objects::Location& location, uint64_t position, int64_t offset, @@ -49,7 +49,7 @@ CHROMEOS_EXPORT bool CheckInt64Overflow( // false and "invalid_parameter" |error|. // The |location| parameter will be used to report the origin of the error // if one is generated/triggered. -CHROMEOS_EXPORT bool CalculateStreamPosition( +BRILLO_EXPORT bool CalculateStreamPosition( const tracked_objects::Location& location, int64_t offset, Stream::Whence whence, @@ -81,7 +81,7 @@ inline Stream::AccessMode MakeAccessMode(bool read, bool write) { using CopyDataSuccessCallback = base::Callback<void(StreamPtr, StreamPtr, uint64_t)>; using CopyDataErrorCallback = - base::Callback<void(StreamPtr, StreamPtr, const chromeos::Error*)>; + base::Callback<void(StreamPtr, StreamPtr, const brillo::Error*)>; // Asynchronously copies data from input stream to output stream until all the // data from the input stream is read. The function takes ownership of both @@ -89,10 +89,10 @@ using CopyDataErrorCallback = // either the |success_callback| or |error_callback| is called. // |success_callback| also provides the number of bytes actually copied. // This variant of CopyData uses internal buffer of 4 KiB for the operation. -CHROMEOS_EXPORT void CopyData(StreamPtr in_stream, - StreamPtr out_stream, - const CopyDataSuccessCallback& success_callback, - const CopyDataErrorCallback& error_callback); +BRILLO_EXPORT void CopyData(StreamPtr in_stream, + StreamPtr out_stream, + const CopyDataSuccessCallback& success_callback, + const CopyDataErrorCallback& error_callback); // Asynchronously copies data from input stream to output stream until the // maximum amount of data specified in |max_size_to_copy| is copied or the end @@ -101,14 +101,14 @@ CHROMEOS_EXPORT void CopyData(StreamPtr in_stream, // either the |success_callback| or |error_callback| is called. // |success_callback| also provides the number of bytes actually copied. // |buffer_size| specifies the size of the read buffer to use for the operation. -CHROMEOS_EXPORT void CopyData(StreamPtr in_stream, - StreamPtr out_stream, - uint64_t max_size_to_copy, - size_t buffer_size, - const CopyDataSuccessCallback& success_callback, - const CopyDataErrorCallback& error_callback); +BRILLO_EXPORT void CopyData(StreamPtr in_stream, + StreamPtr out_stream, + uint64_t max_size_to_copy, + size_t buffer_size, + const CopyDataSuccessCallback& success_callback, + const CopyDataErrorCallback& error_callback); } // namespace stream_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_STREAMS_STREAM_UTILS_H_ +#endif // LIBCHROMEOS_BRILLO_STREAMS_STREAM_UTILS_H_ diff --git a/chromeos/streams/stream_utils_unittest.cc b/brillo/streams/stream_utils_unittest.cc index 1de4fc3..8145027 100644 --- a/chromeos/streams/stream_utils_unittest.cc +++ b/brillo/streams/stream_utils_unittest.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/stream_utils.h> +#include <brillo/streams/stream_utils.h> #include <limits> #include <base/bind.h> -#include <chromeos/message_loops/fake_message_loop.h> -#include <chromeos/message_loops/message_loop.h> -#include <chromeos/streams/mock_stream.h> -#include <chromeos/streams/stream_errors.h> +#include <brillo/message_loops/fake_message_loop.h> +#include <brillo/message_loops/message_loop.h> +#include <brillo/streams/mock_stream.h> +#include <brillo/streams/stream_errors.h> #include <gmock/gmock.h> #include <gtest/gtest.h> @@ -23,7 +23,7 @@ using testing::_; ACTION_TEMPLATE(InvokeAsyncCallback, HAS_1_TEMPLATE_PARAMS(int, k), AND_1_VALUE_PARAMS(size)) { - chromeos::MessageLoop::current()->PostTask( + brillo::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(std::get<k>(args), size)); return true; } @@ -31,21 +31,21 @@ ACTION_TEMPLATE(InvokeAsyncCallback, ACTION_TEMPLATE(InvokeAsyncCallback, HAS_1_TEMPLATE_PARAMS(int, k), AND_0_VALUE_PARAMS()) { - chromeos::MessageLoop::current()->PostTask(FROM_HERE, std::get<k>(args)); + brillo::MessageLoop::current()->PostTask(FROM_HERE, std::get<k>(args)); return true; } ACTION_TEMPLATE(InvokeAsyncErrorCallback, HAS_1_TEMPLATE_PARAMS(int, k), AND_1_VALUE_PARAMS(code)) { - chromeos::ErrorPtr error; - chromeos::Error::AddTo(&error, FROM_HERE, "test", code, "message"); - chromeos::MessageLoop::current()->PostTask( + brillo::ErrorPtr error; + brillo::Error::AddTo(&error, FROM_HERE, "test", code, "message"); + brillo::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(std::get<k>(args), base::Owned(error.release()))); return true; } -namespace chromeos { +namespace brillo { TEST(StreamUtils, ErrorStreamClosed) { ErrorPtr error; @@ -297,4 +297,4 @@ TEST_F(CopyStreamDataTest, ErrorWrite) { ExpectFailure(); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/tls_stream.cc b/brillo/streams/tls_stream.cc index 6dc5ef5..70d1e13 100644 --- a/chromeos/streams/tls_stream.cc +++ b/brillo/streams/tls_stream.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/streams/tls_stream.h> +#include <brillo/streams/tls_stream.h> #include <algorithm> #include <limits> @@ -14,17 +14,17 @@ #include <base/bind.h> #include <base/memory/weak_ptr.h> -#include <chromeos/message_loops/message_loop.h> -#include <chromeos/secure_blob.h> -#include <chromeos/streams/openssl_stream_bio.h> -#include <chromeos/streams/stream_utils.h> -#include <chromeos/strings/string_utils.h> +#include <brillo/message_loops/message_loop.h> +#include <brillo/secure_blob.h> +#include <brillo/streams/openssl_stream_bio.h> +#include <brillo/streams/stream_utils.h> +#include <brillo/strings/string_utils.h> namespace { // SSL info callback which is called by OpenSSL when we enable logging level of // at least 3. This logs the information about the internal TLS handshake. -void TlsInfoCallback(const SSL *ssl, int where, int ret) { +void TlsInfoCallback(const SSL* ssl, int where, int ret) { std::string reason; std::vector<std::string> info; if (where & SSL_CB_LOOP) @@ -47,7 +47,7 @@ void TlsInfoCallback(const SSL *ssl, int where, int ret) { if (where & SSL_CB_HANDSHAKE_DONE) info.push_back("handshake_done"); - VLOG(3) << "TLS progress info: " << chromeos::string_utils::Join(",", info) + VLOG(3) << "TLS progress info: " << brillo::string_utils::Join(",", info) << ", with status: " << ret << reason; } @@ -65,10 +65,10 @@ const char kCACertificatePath[] = } // anonymous namespace -namespace chromeos { +namespace brillo { // Helper implementation of TLS stream used to hide most of OpenSSL inner -// workings from the users of chromeos::TlsStream. +// workings from the users of brillo::TlsStream. class TlsStream::TlsStreamImpl { public: TlsStreamImpl(); @@ -355,8 +355,7 @@ bool TlsStream::TlsStreamImpl::Init(StreamPtr socket, if (res != 1) return ReportError(error, FROM_HERE, "Cannot set the cipher list"); - res = SSL_CTX_load_verify_locations(ctx_.get(), nullptr, - kCACertificatePath); + res = SSL_CTX_load_verify_locations(ctx_.get(), nullptr, kCACertificatePath); if (res != 1) { return ReportError(error, FROM_HERE, "Failed to specify trusted certificate location"); @@ -543,4 +542,4 @@ void TlsStream::CancelPendingAsyncOperations() { Stream::CancelPendingAsyncOperations(); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/streams/tls_stream.h b/brillo/streams/tls_stream.h index fb5b323..5513eb5 100644 --- a/chromeos/streams/tls_stream.h +++ b/brillo/streams/tls_stream.h @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_STREAMS_TLS_STREAM_H_ -#define LIBCHROMEOS_CHROMEOS_STREAMS_TLS_STREAM_H_ +#ifndef LIBCHROMEOS_BRILLO_STREAMS_TLS_STREAM_H_ +#define LIBCHROMEOS_BRILLO_STREAMS_TLS_STREAM_H_ #include <memory> #include <string> #include <base/macros.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/errors/error.h> -#include <chromeos/streams/stream.h> +#include <brillo/brillo_export.h> +#include <brillo/errors/error.h> +#include <brillo/streams/stream.h> -namespace chromeos { +namespace brillo { // This class provides client-side TLS stream that performs handshake with the // server and established a secure communication channel which can be used @@ -21,7 +21,7 @@ namespace chromeos { // asynchronous I/O is supported. // The underlying socket stream must already be created and connected to the // destination server and passed in TlsStream::Connect() method as |socket|. -class CHROMEOS_EXPORT TlsStream : public Stream { +class BRILLO_EXPORT TlsStream : public Stream { public: ~TlsStream() override; @@ -39,7 +39,7 @@ class CHROMEOS_EXPORT TlsStream : public Stream { bool IsOpen() const override; bool CanRead() const override { return true; } bool CanWrite() const override { return true; } - bool CanSeek() const override { return false; } + bool CanSeek() const override { return false; } bool CanGetSize() const override { return false; } uint64_t GetSize() const override { return 0; } bool SetSizeBlocking(uint64_t size, ErrorPtr* error) override; @@ -79,6 +79,6 @@ class CHROMEOS_EXPORT TlsStream : public Stream { DISALLOW_COPY_AND_ASSIGN(TlsStream); }; -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_STREAMS_TLS_STREAM_H_ +#endif // LIBCHROMEOS_BRILLO_STREAMS_TLS_STREAM_H_ diff --git a/chromeos/strings/string_utils.cc b/brillo/strings/string_utils.cc index 503d8f8..8279a0e 100644 --- a/chromeos/strings/string_utils.cc +++ b/brillo/strings/string_utils.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/strings/string_utils.h> +#include <brillo/strings/string_utils.h> #include <algorithm> #include <string.h> @@ -11,7 +11,7 @@ #include <base/strings/string_util.h> #include <base/strings/stringprintf.h> -namespace chromeos { +namespace brillo { namespace string_utils { std::vector<std::string> Split(const std::string& str, @@ -86,4 +86,4 @@ std::vector<uint8_t> GetStringAsBytes(const std::string& str) { } } // namespace string_utils -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/strings/string_utils.h b/brillo/strings/string_utils.h index 1f56395..f467bf9 100644 --- a/chromeos/strings/string_utils.h +++ b/brillo/strings/string_utils.h @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_STRINGS_STRING_UTILS_H_ -#define LIBCHROMEOS_CHROMEOS_STRINGS_STRING_UTILS_H_ +#ifndef LIBCHROMEOS_BRILLO_STRINGS_STRING_UTILS_H_ +#define LIBCHROMEOS_BRILLO_STRINGS_STRING_UTILS_H_ #include <string> #include <utility> #include <vector> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> -namespace chromeos { +namespace brillo { namespace string_utils { // Treats the string as a delimited list of substrings and returns the array @@ -19,10 +19,10 @@ namespace string_utils { // |trim_whitespaces| causes each element to have all whitespaces trimmed off. // |purge_empty_strings| specifies whether empty elements from the original // string should be omitted. -CHROMEOS_EXPORT std::vector<std::string> Split(const std::string& str, - const std::string& delimiter, - bool trim_whitespaces, - bool purge_empty_strings); +BRILLO_EXPORT std::vector<std::string> Split(const std::string& str, + const std::string& delimiter, + bool trim_whitespaces, + bool purge_empty_strings); // Splits the string, trims all whitespaces, omits empty string parts. inline std::vector<std::string> Split(const std::string& str, const std::string& delimiter) { @@ -37,7 +37,7 @@ inline std::vector<std::string> Split(const std::string& str, // Splits the string into two pieces at the first position of the specified // delimiter. -CHROMEOS_EXPORT std::pair<std::string, std::string> SplitAtFirst( +BRILLO_EXPORT std::pair<std::string, std::string> SplitAtFirst( const std::string& str, const std::string& delimiter, bool trim_whitespaces); @@ -52,11 +52,11 @@ inline std::pair<std::string, std::string> SplitAtFirst( // The following overload returns false if the delimiter was not found in the // source string. In this case, |left_part| will be set to |str| and // |right_part| will be empty. -CHROMEOS_EXPORT bool SplitAtFirst(const std::string& str, - const std::string& delimiter, - std::string* left_part, - std::string* right_part, - bool trim_whitespaces); +BRILLO_EXPORT bool SplitAtFirst(const std::string& str, + const std::string& delimiter, + std::string* left_part, + std::string* right_part, + bool trim_whitespaces); // Always trims the white spaces in the split parts. inline bool SplitAtFirst(const std::string& str, const std::string& delimiter, @@ -102,7 +102,7 @@ inline std::string Join(const std::string& delimiter, // string_utils::ToString() is a helper function to convert any scalar type // to a string. In most cases, it redirects the call to std::to_string with // two exceptions: for std::string itself and for double and bool. -template<typename T> +template <typename T> inline std::string ToString(T value) { return std::to_string(value); } @@ -113,19 +113,19 @@ inline std::string ToString(std::string value) { } // We overload this for double because std::to_string(double) uses %f to // format the value and I would like to use a shorter %g format instead. -CHROMEOS_EXPORT std::string ToString(double value); +BRILLO_EXPORT std::string ToString(double value); // And the bool to be converted as true/false instead of 1/0. -CHROMEOS_EXPORT std::string ToString(bool value); +BRILLO_EXPORT std::string ToString(bool value); // Converts a byte-array into a string. This method doesn't perform any // data re-encoding. It just takes every byte from the buffer and appends it // to the string as a character. -CHROMEOS_EXPORT std::string GetBytesAsString(const std::vector<uint8_t>& buf); +BRILLO_EXPORT std::string GetBytesAsString(const std::vector<uint8_t>& buf); // Converts a string into a byte-array. Opposite of GetBytesAsString(). -CHROMEOS_EXPORT std::vector<uint8_t> GetStringAsBytes(const std::string& str); +BRILLO_EXPORT std::vector<uint8_t> GetStringAsBytes(const std::string& str); } // namespace string_utils -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_STRINGS_STRING_UTILS_H_ +#endif // LIBCHROMEOS_BRILLO_STRINGS_STRING_UTILS_H_ diff --git a/chromeos/strings/string_utils_unittest.cc b/brillo/strings/string_utils_unittest.cc index 7b5909c..c554e74 100644 --- a/chromeos/strings/string_utils_unittest.cc +++ b/brillo/strings/string_utils_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/strings/string_utils.h> +#include <brillo/strings/string_utils.h> #include <list> #include <set> @@ -11,7 +11,7 @@ #include <gtest/gtest.h> -namespace chromeos { +namespace brillo { TEST(StringUtils, Split) { std::vector<std::string> parts; @@ -160,4 +160,4 @@ TEST(StringUtils, GetStringAsBytes) { EXPECT_EQ(255, buf[3]); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/syslog_logging.cc b/brillo/syslog_logging.cc index 79d0840..045c6e3 100644 --- a/chromeos/syslog_logging.cc +++ b/brillo/syslog_logging.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/syslog_logging.h" +#include "brillo/syslog_logging.h" #include <syslog.h> @@ -74,7 +74,7 @@ static bool HandleMessage(int severity, return !s_log_to_stderr && severity != kSyslogCritical; } -namespace chromeos { +namespace brillo { void SetLogFlags(int log_flags) { s_log_to_syslog = (log_flags & kLogToSyslog) != 0; s_log_to_stderr = (log_flags & kLogToStderr) != 0; @@ -117,4 +117,4 @@ void ClearLog() { bool FindLog(const char* string) { return s_accumulated.find(string) != std::string::npos; } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/syslog_logging.h b/brillo/syslog_logging.h index 134d3cc..d940b42 100644 --- a/chromeos/syslog_logging.h +++ b/brillo/syslog_logging.h @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_SYSLOG_LOGGING_H_ -#define LIBCHROMEOS_CHROMEOS_SYSLOG_LOGGING_H_ +#ifndef LIBCHROMEOS_BRILLO_SYSLOG_LOGGING_H_ +#define LIBCHROMEOS_BRILLO_SYSLOG_LOGGING_H_ #include <string> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> -namespace chromeos { +namespace brillo { enum InitFlags { kLogToSyslog = 1, @@ -19,30 +19,30 @@ enum InitFlags { // Initialize logging subsystem. |init_flags| is a bitfield, with bits defined // in InitFlags above. -CHROMEOS_EXPORT void InitLog(int init_flags); +BRILLO_EXPORT void InitLog(int init_flags); // Gets the current logging flags. -CHROMEOS_EXPORT int GetLogFlags(); +BRILLO_EXPORT int GetLogFlags(); // Sets the current logging flags. -CHROMEOS_EXPORT void SetLogFlags(int log_flags); +BRILLO_EXPORT void SetLogFlags(int log_flags); // Convenience function for configuring syslog via openlog. Users // could call openlog directly except for naming collisions between // base/logging.h and syslog.h. Similarly users cannot pass the // normal parameters so we pick a representative set. |log_pid| // causes pid to be logged with |ident|. -CHROMEOS_EXPORT void OpenLog(const char* ident, bool log_pid); +BRILLO_EXPORT void OpenLog(const char* ident, bool log_pid); // Start accumulating the logs to a string. This is inefficient, so // do not set to true if large numbers of log messages are coming. // Accumulated logs are only ever cleared when the clear function ings // called. -CHROMEOS_EXPORT void LogToString(bool enabled); +BRILLO_EXPORT void LogToString(bool enabled); // Get the accumulated logs as a string. -CHROMEOS_EXPORT std::string GetLog(); +BRILLO_EXPORT std::string GetLog(); // Clear the accumulated logs. -CHROMEOS_EXPORT void ClearLog(); +BRILLO_EXPORT void ClearLog(); // Returns true if the accumulated log contains the given string. Useful // for testing. -CHROMEOS_EXPORT bool FindLog(const char* string); +BRILLO_EXPORT bool FindLog(const char* string); -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_SYSLOG_LOGGING_H_ +#endif // LIBCHROMEOS_BRILLO_SYSLOG_LOGGING_H_ diff --git a/chromeos/syslog_logging_unittest.cc b/brillo/syslog_logging_unittest.cc index 982b83a..e852e50 100644 --- a/chromeos/syslog_logging_unittest.cc +++ b/brillo/syslog_logging_unittest.cc @@ -3,10 +3,10 @@ // found in the LICENSE file. #include <base/logging.h> -#include <chromeos/syslog_logging.h> +#include <brillo/syslog_logging.h> #include <gtest/gtest.h> -namespace chromeos { +namespace brillo { class SyslogLoggingDeathTest : public ::testing::Test { public: @@ -28,4 +28,4 @@ TEST_F(SyslogLoggingDeathTest, FatalLoggingIsFatal) { SetLogFlags(old_flags); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/test_helpers.h b/brillo/test_helpers.h index d43a9c8..f035b66 100644 --- a/chromeos/test_helpers.h +++ b/brillo/test_helpers.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_TEST_HELPERS_H_ -#define LIBCHROMEOS_CHROMEOS_TEST_HELPERS_H_ +#ifndef LIBCHROMEOS_BRILLO_TEST_HELPERS_H_ +#define LIBCHROMEOS_BRILLO_TEST_HELPERS_H_ #include "gtest/gtest.h" @@ -14,7 +14,7 @@ #include <base/files/file_util.h> #include <base/logging.h> -#include "chromeos/syslog_logging.h" +#include "brillo/syslog_logging.h" inline void ExpectFileEquals(const char* golden, const char* file_path) { std::string contents; @@ -24,9 +24,9 @@ inline void ExpectFileEquals(const char* golden, const char* file_path) { inline void SetUpTests(int* argc, char** argv, bool log_to_stderr) { base::CommandLine::Init(*argc, argv); - ::chromeos::InitLog(log_to_stderr ? chromeos::kLogToStderr : 0); - ::chromeos::LogToString(true); + ::brillo::InitLog(log_to_stderr ? brillo::kLogToStderr : 0); + ::brillo::LogToString(true); ::testing::InitGoogleTest(argc, argv); } -#endif // LIBCHROMEOS_CHROMEOS_TEST_HELPERS_H_ +#endif // LIBCHROMEOS_BRILLO_TEST_HELPERS_H_ diff --git a/chromeos/type_name_undecorate.cc b/brillo/type_name_undecorate.cc index 636c575..9a1d6a1 100644 --- a/chromeos/type_name_undecorate.cc +++ b/brillo/type_name_undecorate.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/type_name_undecorate.h> +#include <brillo/type_name_undecorate.h> #ifdef __GNUG__ #include <cstdlib> @@ -10,7 +10,7 @@ #include <memory> #endif // __GNUG__ -namespace chromeos { +namespace brillo { std::string UndecorateTypeName(const char* type_name) { #ifdef __GNUG__ @@ -30,4 +30,4 @@ std::string UndecorateTypeName(const char* type_name) { #endif } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/type_name_undecorate.h b/brillo/type_name_undecorate.h index ea3c14b..2da657c 100644 --- a/chromeos/type_name_undecorate.h +++ b/brillo/type_name_undecorate.h @@ -2,19 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_TYPE_NAME_UNDECORATE_H_ -#define LIBCHROMEOS_CHROMEOS_TYPE_NAME_UNDECORATE_H_ +#ifndef LIBCHROMEOS_BRILLO_TYPE_NAME_UNDECORATE_H_ +#define LIBCHROMEOS_BRILLO_TYPE_NAME_UNDECORATE_H_ #include <string> #include <typeinfo> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> -namespace chromeos { +namespace brillo { -// Use chromeos::UndecorateTypeName() to obtain human-readable type from +// Use brillo::UndecorateTypeName() to obtain human-readable type from // the decorated/mangled type name returned by std::type_info::name(). -CHROMEOS_EXPORT std::string UndecorateTypeName(const char* type_name); +BRILLO_EXPORT std::string UndecorateTypeName(const char* type_name); // A template helper function that returns the undecorated type name for type T. template<typename T> @@ -22,6 +22,6 @@ inline std::string GetUndecoratedTypeName() { return UndecorateTypeName(typeid(T).name()); } -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_TYPE_NAME_UNDECORATE_H_ +#endif // LIBCHROMEOS_BRILLO_TYPE_NAME_UNDECORATE_H_ diff --git a/chromeos/url_utils.cc b/brillo/url_utils.cc index 3a2e166..eba7db8 100644 --- a/chromeos/url_utils.cc +++ b/brillo/url_utils.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/url_utils.h> +#include <brillo/url_utils.h> #include <algorithm> @@ -52,7 +52,7 @@ bool GetQueryStringPos(const std::string& url, } } // anonymous namespace -namespace chromeos { +namespace brillo { std::string url::TrimOffQueryString(std::string* url) { size_t query_pos; @@ -163,4 +163,4 @@ bool url::HasQueryString(const std::string& url) { return (query_len > 0); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/url_utils.h b/brillo/url_utils.h index caa890b..80dea5a 100644 --- a/chromeos/url_utils.h +++ b/brillo/url_utils.h @@ -2,27 +2,27 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_URL_UTILS_H_ -#define LIBCHROMEOS_CHROMEOS_URL_UTILS_H_ +#ifndef LIBCHROMEOS_BRILLO_URL_UTILS_H_ +#define LIBCHROMEOS_BRILLO_URL_UTILS_H_ #include <string> #include <vector> #include <base/compiler_specific.h> #include <base/macros.h> -#include <chromeos/chromeos_export.h> -#include <chromeos/data_encoding.h> +#include <brillo/brillo_export.h> +#include <brillo/data_encoding.h> -namespace chromeos { +namespace brillo { namespace url { // Appends a subpath to url and delimiting then with '/' if the path doesn't // end with it already. Also handles URLs with query parameters/fragment. -CHROMEOS_EXPORT std::string Combine( +BRILLO_EXPORT std::string Combine( const std::string& url, const std::string& subpath) WARN_UNUSED_RESULT; -CHROMEOS_EXPORT std::string CombineMultiple( +BRILLO_EXPORT std::string CombineMultiple( const std::string& url, const std::vector<std::string>& parts) WARN_UNUSED_RESULT; @@ -30,7 +30,7 @@ CHROMEOS_EXPORT std::string CombineMultiple( // This method actually modifies |url|. So, if you call it on this: // http://www.test.org/?foo=bar // it will modify |url| to "http://www.test.org/" and return "?foo=bar" -CHROMEOS_EXPORT std::string TrimOffQueryString(std::string* url); +BRILLO_EXPORT std::string TrimOffQueryString(std::string* url); // Returns the query string, if available. // For example, for the following URL: @@ -41,18 +41,18 @@ CHROMEOS_EXPORT std::string TrimOffQueryString(std::string* url); // #fragment - URL fragment string // If |remove_fragment| is true, the function returns the query string without // the fragment. Otherwise the fragment is included as part of the result. -CHROMEOS_EXPORT std::string GetQueryString(const std::string& url, - bool remove_fragment); +BRILLO_EXPORT std::string GetQueryString(const std::string& url, + bool remove_fragment); // Parses the query string into a set of key-value pairs. -CHROMEOS_EXPORT data_encoding::WebParamList GetQueryStringParameters( +BRILLO_EXPORT data_encoding::WebParamList GetQueryStringParameters( const std::string& url); // Returns a value of the specified query parameter, or empty string if missing. -CHROMEOS_EXPORT std::string GetQueryStringValue( +BRILLO_EXPORT std::string GetQueryStringValue( const std::string& url, const std::string& name); -CHROMEOS_EXPORT std::string GetQueryStringValue( +BRILLO_EXPORT std::string GetQueryStringValue( const data_encoding::WebParamList& params, const std::string& name); @@ -62,24 +62,24 @@ CHROMEOS_EXPORT std::string GetQueryStringValue( // http://server.com/path/to/object?k=v&foo=bar#fragment // true -> http://server.com/path/to/object // false -> http://server.com/path/to/object#fragment -CHROMEOS_EXPORT std::string RemoveQueryString( +BRILLO_EXPORT std::string RemoveQueryString( const std::string& url, bool remove_fragment) WARN_UNUSED_RESULT; // Appends a single query parameter to the URL. -CHROMEOS_EXPORT std::string AppendQueryParam( +BRILLO_EXPORT std::string AppendQueryParam( const std::string& url, const std::string& name, const std::string& value) WARN_UNUSED_RESULT; // Appends a list of query parameters to the URL. -CHROMEOS_EXPORT std::string AppendQueryParams( +BRILLO_EXPORT std::string AppendQueryParams( const std::string& url, const data_encoding::WebParamList& params) WARN_UNUSED_RESULT; // Checks if the URL has query parameters. -CHROMEOS_EXPORT bool HasQueryString(const std::string& url); +BRILLO_EXPORT bool HasQueryString(const std::string& url); } // namespace url -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_URL_UTILS_H_ +#endif // LIBCHROMEOS_BRILLO_URL_UTILS_H_ diff --git a/chromeos/url_utils_unittest.cc b/brillo/url_utils_unittest.cc index d52d720..a2603cb 100644 --- a/chromeos/url_utils_unittest.cc +++ b/brillo/url_utils_unittest.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <chromeos/url_utils.h> +#include <brillo/url_utils.h> #include <gtest/gtest.h> -namespace chromeos { +namespace brillo { TEST(UrlUtils, Combine) { EXPECT_EQ("http://sample.org/path", @@ -143,4 +143,4 @@ TEST(UrlUtils, HasQueryString) { EXPECT_TRUE(url::HasQueryString("?ss")); } -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/userdb_utils.cc b/brillo/userdb_utils.cc index 096557a..55c964c 100644 --- a/chromeos/userdb_utils.cc +++ b/brillo/userdb_utils.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chromeos/userdb_utils.h" +#include "brillo/userdb_utils.h" #include <grp.h> #include <pwd.h> @@ -13,7 +13,7 @@ #include <base/logging.h> -namespace chromeos { +namespace brillo { namespace userdb { bool GetUserInfo(const std::string& user, uid_t* uid, gid_t* gid) { @@ -53,4 +53,4 @@ bool GetGroupInfo(const std::string& group, gid_t* gid) { } } // namespace userdb -} // namespace chromeos +} // namespace brillo diff --git a/chromeos/userdb_utils.h b/brillo/userdb_utils.h index 019336a..4377119 100644 --- a/chromeos/userdb_utils.h +++ b/brillo/userdb_utils.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_USERDB_UTILS_H_ -#define LIBCHROMEOS_CHROMEOS_USERDB_UTILS_H_ +#ifndef LIBCHROMEOS_BRILLO_USERDB_UTILS_H_ +#define LIBCHROMEOS_BRILLO_USERDB_UTILS_H_ #include <sys/types.h> @@ -11,22 +11,22 @@ #include <base/compiler_specific.h> #include <base/macros.h> -#include <chromeos/chromeos_export.h> +#include <brillo/brillo_export.h> -namespace chromeos { +namespace brillo { namespace userdb { // Looks up the UID and GID corresponding to |user|. Returns true on success. // Passing nullptr for |uid| or |gid| causes them to be ignored. -CHROMEOS_EXPORT bool GetUserInfo( +BRILLO_EXPORT bool GetUserInfo( const std::string& user, uid_t* uid, gid_t* gid) WARN_UNUSED_RESULT; // Looks up the GID corresponding to |group|. Returns true on success. // Passing nullptr for |gid| causes it to be ignored. -CHROMEOS_EXPORT bool GetGroupInfo( +BRILLO_EXPORT bool GetGroupInfo( const std::string& group, gid_t* gid) WARN_UNUSED_RESULT; } // namespace userdb -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_USERDB_UTILS_H_ +#endif // LIBCHROMEOS_BRILLO_USERDB_UTILS_H_ diff --git a/chromeos/variant_dictionary.h b/brillo/variant_dictionary.h index dbc8385..c934455 100644 --- a/chromeos/variant_dictionary.h +++ b/brillo/variant_dictionary.h @@ -2,18 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_VARIANT_DICTIONARY_H_ -#define LIBCHROMEOS_CHROMEOS_VARIANT_DICTIONARY_H_ +#ifndef LIBCHROMEOS_BRILLO_VARIANT_DICTIONARY_H_ +#define LIBCHROMEOS_BRILLO_VARIANT_DICTIONARY_H_ #include <map> #include <string> -#include <chromeos/any.h> -#include <chromeos/chromeos_export.h> +#include <brillo/any.h> +#include <brillo/brillo_export.h> -namespace chromeos { +namespace brillo { -using VariantDictionary = std::map<std::string, chromeos::Any>; +using VariantDictionary = std::map<std::string, brillo::Any>; // GetVariantValueOrDefault tries to retrieve the named key from the dictionary // and convert it to the type T. If the value does not exist, or the type @@ -28,6 +28,6 @@ const T GetVariantValueOrDefault(const VariantDictionary& dictionary, return it->second.TryGet<T>(); } -} // namespace chromeos +} // namespace brillo -#endif // LIBCHROMEOS_CHROMEOS_VARIANT_DICTIONARY_H_ +#endif // LIBCHROMEOS_BRILLO_VARIANT_DICTIONARY_H_ diff --git a/chromeos/variant_dictionary_unittest.cc b/brillo/variant_dictionary_unittest.cc index d960dda..73ead2c 100644 --- a/chromeos/variant_dictionary_unittest.cc +++ b/brillo/variant_dictionary_unittest.cc @@ -4,12 +4,12 @@ #include <string> -#include <chromeos/any.h> -#include <chromeos/variant_dictionary.h> +#include <brillo/any.h> +#include <brillo/variant_dictionary.h> #include <gtest/gtest.h> -using chromeos::VariantDictionary; -using chromeos::GetVariantValueOrDefault; +using brillo::VariantDictionary; +using brillo::GetVariantValueOrDefault; TEST(VariantDictionary, GetVariantValueOrDefault) { VariantDictionary dictionary; diff --git a/chromeos/errors/error_codes.h b/chromeos/errors/error_codes.h deleted file mode 100644 index d612640..0000000 --- a/chromeos/errors/error_codes.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2014 The Chromium OS Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef LIBCHROMEOS_CHROMEOS_ERRORS_ERROR_CODES_H_ -#define LIBCHROMEOS_CHROMEOS_ERRORS_ERROR_CODES_H_ - -#include <string> - -#include <chromeos/chromeos_export.h> -#include <chromeos/errors/error.h> - -namespace chromeos { -namespace errors { - -namespace dbus { -CHROMEOS_EXPORT extern const char kDomain[]; -} // namespace dbus - -namespace json { -CHROMEOS_EXPORT extern const char kDomain[]; -CHROMEOS_EXPORT extern const char kParseError[]; -CHROMEOS_EXPORT extern const char kObjectExpected[]; -} // namespace json - -namespace http { -CHROMEOS_EXPORT extern const char kDomain[]; -} // namespace http - -namespace system { -CHROMEOS_EXPORT extern const char kDomain[]; - -// Adds an Error object to the error chain identified by |error|, using -// the system error code (see "errno"). -CHROMEOS_EXPORT void AddSystemError(ErrorPtr* error, - const tracked_objects::Location& location, - int errnum); -} // namespace system - -} // namespace errors -} // namespace chromeos - -#endif // LIBCHROMEOS_CHROMEOS_ERRORS_ERROR_CODES_H_ diff --git a/chromeos/mime_utils.h b/chromeos/mime_utils.h deleted file mode 100644 index 46d4b88..0000000 --- a/chromeos/mime_utils.h +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2014 The Chromium OS Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef LIBCHROMEOS_CHROMEOS_MIME_UTILS_H_ -#define LIBCHROMEOS_CHROMEOS_MIME_UTILS_H_ - -#include <string> -#include <utility> -#include <vector> - -#include <base/compiler_specific.h> -#include <base/macros.h> -#include <chromeos/chromeos_export.h> - -namespace chromeos { -namespace mime { - -namespace types { -// Main MIME type categories -CHROMEOS_EXPORT extern const char kApplication[]; // application -CHROMEOS_EXPORT extern const char kAudio[]; // audio -CHROMEOS_EXPORT extern const char kImage[]; // image -CHROMEOS_EXPORT extern const char kMessage[]; // message -CHROMEOS_EXPORT extern const char kMultipart[]; // multipart -CHROMEOS_EXPORT extern const char kText[]; // test -CHROMEOS_EXPORT extern const char kVideo[]; // video -} // namespace types - -namespace parameters { -// Common MIME parameters -CHROMEOS_EXPORT extern const char kCharset[]; // charset=... -} // namespace parameters - -namespace image { -// Common image MIME types -CHROMEOS_EXPORT extern const char kJpeg[]; // image/jpeg -CHROMEOS_EXPORT extern const char kPng[]; // image/png -CHROMEOS_EXPORT extern const char kBmp[]; // image/bmp -CHROMEOS_EXPORT extern const char kTiff[]; // image/tiff -CHROMEOS_EXPORT extern const char kGif[]; // image/gif -} // namespace image - -namespace text { -// Common text MIME types -CHROMEOS_EXPORT extern const char kPlain[]; // text/plain -CHROMEOS_EXPORT extern const char kHtml[]; // text/html -CHROMEOS_EXPORT extern const char kXml[]; // text/xml -} // namespace text - -namespace application { -// Common application MIME types -// application/octet-stream -CHROMEOS_EXPORT extern const char kOctet_stream[]; -// application/json -CHROMEOS_EXPORT extern const char kJson[]; -// application/x-www-form-urlencoded -CHROMEOS_EXPORT extern const char kWwwFormUrlEncoded[]; -// application/x-protobuf -CHROMEOS_EXPORT extern const char kProtobuf[]; -} // namespace application - -namespace multipart { -// Common multipart MIME types -// multipart/form-data -CHROMEOS_EXPORT extern const char kFormData[]; -// multipart/mixed -CHROMEOS_EXPORT extern const char kMixed[]; -} // namespace multipart - -using Parameters = std::vector<std::pair<std::string, std::string>>; - -// Combine a MIME type, subtype and parameters into a MIME string. -// e.g. Combine("text", "plain", {{"charset", "utf-8"}}) will give: -// "text/plain; charset=utf-8" -CHROMEOS_EXPORT std::string Combine( - const std::string& type, - const std::string& subtype, - const Parameters& parameters = {}) WARN_UNUSED_RESULT; - -// Splits a MIME string into type and subtype. -// "text/plain;charset=utf-8" => ("text", "plain") -CHROMEOS_EXPORT bool Split(const std::string& mime_string, - std::string* type, - std::string* subtype); - -// Splits a MIME string into type, subtype, and parameters. -// "text/plain;charset=utf-8" => ("text", "plain", {{"charset","utf-8"}}) -CHROMEOS_EXPORT bool Split(const std::string& mime_string, - std::string* type, - std::string* subtype, - Parameters* parameters); - -// Returns the MIME type from MIME string. -// "text/plain;charset=utf-8" => "text" -CHROMEOS_EXPORT std::string GetType(const std::string& mime_string); - -// Returns the MIME sub-type from MIME string. -// "text/plain;charset=utf-8" => "plain" -CHROMEOS_EXPORT std::string GetSubtype(const std::string& mime_string); - -// Returns the MIME parameters from MIME string. -// "text/plain;charset=utf-8" => {{"charset","utf-8"}} -CHROMEOS_EXPORT Parameters GetParameters(const std::string& mime_string); - -// Removes parameters from a MIME string -// "text/plain;charset=utf-8" => "text/plain" -CHROMEOS_EXPORT std::string RemoveParameters( - const std::string& mime_string) WARN_UNUSED_RESULT; - -// Appends a parameter to a MIME string. -// "text/plain" => "text/plain; charset=utf-8" -CHROMEOS_EXPORT std::string AppendParameter( - const std::string& mime_string, - const std::string& paramName, - const std::string& paramValue) WARN_UNUSED_RESULT; - -// Returns the value of a parameter on a MIME string (empty string if missing). -// ("text/plain;charset=utf-8","charset") => "utf-8" -CHROMEOS_EXPORT std::string GetParameterValue(const std::string& mime_string, - const std::string& paramName); - -} // namespace mime -} // namespace chromeos - -#endif // LIBCHROMEOS_CHROMEOS_MIME_UTILS_H_ diff --git a/chromeos/streams/stream_errors.h b/chromeos/streams/stream_errors.h deleted file mode 100644 index 61f8a6f..0000000 --- a/chromeos/streams/stream_errors.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 The Chromium OS Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef LIBCHROMEOS_CHROMEOS_STREAMS_STREAM_ERRORS_H_ -#define LIBCHROMEOS_CHROMEOS_STREAMS_STREAM_ERRORS_H_ - -#include <chromeos/chromeos_export.h> - -namespace chromeos { -namespace errors { -namespace stream { - -// Error domain for generic stream-based errors. -CHROMEOS_EXPORT extern const char kDomain[]; - -CHROMEOS_EXPORT extern const char kStreamClosed[]; -CHROMEOS_EXPORT extern const char kOperationNotSupported[]; -CHROMEOS_EXPORT extern const char kPartialData[]; -CHROMEOS_EXPORT extern const char kInvalidParameter[]; -CHROMEOS_EXPORT extern const char kTimeout[]; - -} // namespace stream -} // namespace errors -} // namespace chromeos - -#endif // LIBCHROMEOS_CHROMEOS_STREAMS_STREAM_ERRORS_H_ diff --git a/libchromeos.gypi b/libchromeos.gypi index 5dd5255..7e58063 100644 --- a/libchromeos.gypi +++ b/libchromeos.gypi @@ -46,41 +46,41 @@ }, 'libraries': ['-lmodp_b64'], 'sources': [ - 'chromeos/any.cc', - 'chromeos/asynchronous_signal_handler.cc', - 'chromeos/backoff_entry.cc', - 'chromeos/daemons/dbus_daemon.cc', - 'chromeos/daemons/daemon.cc', - 'chromeos/data_encoding.cc', - 'chromeos/dbus/async_event_sequencer.cc', - 'chromeos/dbus/data_serialization.cc', - 'chromeos/dbus/dbus_method_invoker.cc', - 'chromeos/dbus/dbus_method_response.cc', - 'chromeos/dbus/dbus_object.cc', - 'chromeos/dbus/dbus_service_watcher.cc', - 'chromeos/dbus/dbus_signal.cc', - 'chromeos/dbus/exported_object_manager.cc', - 'chromeos/dbus/exported_property_set.cc', - 'chromeos/dbus/utils.cc', - 'chromeos/errors/error.cc', - 'chromeos/errors/error_codes.cc', - 'chromeos/file_utils.cc', - 'chromeos/flag_helper.cc', - 'chromeos/key_value_store.cc', - 'chromeos/message_loops/base_message_loop.cc', - 'chromeos/message_loops/message_loop.cc', - 'chromeos/message_loops/message_loop_utils.cc', - 'chromeos/mime_utils.cc', - 'chromeos/osrelease_reader.cc', - 'chromeos/process.cc', - 'chromeos/process_reaper.cc', - 'chromeos/process_information.cc', - 'chromeos/secure_blob.cc', - 'chromeos/strings/string_utils.cc', - 'chromeos/syslog_logging.cc', - 'chromeos/type_name_undecorate.cc', - 'chromeos/url_utils.cc', - 'chromeos/userdb_utils.cc', + 'brillo/any.cc', + 'brillo/asynchronous_signal_handler.cc', + 'brillo/backoff_entry.cc', + 'brillo/daemons/dbus_daemon.cc', + 'brillo/daemons/daemon.cc', + 'brillo/data_encoding.cc', + 'brillo/dbus/async_event_sequencer.cc', + 'brillo/dbus/data_serialization.cc', + 'brillo/dbus/dbus_method_invoker.cc', + 'brillo/dbus/dbus_method_response.cc', + 'brillo/dbus/dbus_object.cc', + 'brillo/dbus/dbus_service_watcher.cc', + 'brillo/dbus/dbus_signal.cc', + 'brillo/dbus/exported_object_manager.cc', + 'brillo/dbus/exported_property_set.cc', + 'brillo/dbus/utils.cc', + 'brillo/errors/error.cc', + 'brillo/errors/error_codes.cc', + 'brillo/file_utils.cc', + 'brillo/flag_helper.cc', + 'brillo/key_value_store.cc', + 'brillo/message_loops/base_message_loop.cc', + 'brillo/message_loops/message_loop.cc', + 'brillo/message_loops/message_loop_utils.cc', + 'brillo/mime_utils.cc', + 'brillo/osrelease_reader.cc', + 'brillo/process.cc', + 'brillo/process_reaper.cc', + 'brillo/process_information.cc', + 'brillo/secure_blob.cc', + 'brillo/strings/string_utils.cc', + 'brillo/syslog_logging.cc', + 'brillo/type_name_undecorate.cc', + 'brillo/url_utils.cc', + 'brillo/userdb_utils.cc', ], }, { @@ -104,13 +104,13 @@ }, }, 'sources': [ - 'chromeos/http/curl_api.cc', - 'chromeos/http/http_connection_curl.cc', - 'chromeos/http/http_form_data.cc', - 'chromeos/http/http_request.cc', - 'chromeos/http/http_transport.cc', - 'chromeos/http/http_transport_curl.cc', - 'chromeos/http/http_utils.cc', + 'brillo/http/curl_api.cc', + 'brillo/http/http_connection_curl.cc', + 'brillo/http/http_form_data.cc', + 'brillo/http/http_request.cc', + 'brillo/http/http_transport.cc', + 'brillo/http/http_transport_curl.cc', + 'brillo/http/http_utils.cc', ], }, { @@ -133,15 +133,15 @@ }, }, 'sources': [ - 'chromeos/streams/file_stream.cc', - 'chromeos/streams/input_stream_set.cc', - 'chromeos/streams/memory_containers.cc', - 'chromeos/streams/memory_stream.cc', - 'chromeos/streams/openssl_stream_bio.cc', - 'chromeos/streams/stream.cc', - 'chromeos/streams/stream_errors.cc', - 'chromeos/streams/stream_utils.cc', - 'chromeos/streams/tls_stream.cc', + 'brillo/streams/file_stream.cc', + 'brillo/streams/input_stream_set.cc', + 'brillo/streams/memory_containers.cc', + 'brillo/streams/memory_stream.cc', + 'brillo/streams/openssl_stream_bio.cc', + 'brillo/streams/stream.cc', + 'brillo/streams/stream_errors.cc', + 'brillo/streams/stream_utils.cc', + 'brillo/streams/tls_stream.cc', ], }, { @@ -152,10 +152,10 @@ 'libchromeos-http-<(libbase_ver)', ], 'sources': [ - 'chromeos/http/http_connection_fake.cc', - 'chromeos/http/http_transport_fake.cc', - 'chromeos/message_loops/fake_message_loop.cc', - 'chromeos/streams/fake_stream.cc', + 'brillo/http/http_connection_fake.cc', + 'brillo/http/http_transport_fake.cc', + 'brillo/message_loops/fake_message_loop.cc', + 'brillo/streams/fake_stream.cc', ], 'includes': ['../common-mk/deps.gypi'], }, @@ -176,7 +176,7 @@ }, }, 'sources': [ - 'chromeos/cryptohome.cc', + 'brillo/cryptohome.cc', ], }, { @@ -199,7 +199,7 @@ '-fvisibility=default', ], 'sources': [ - 'chromeos/minijail/minijail.cc', + 'brillo/minijail/minijail.cc', ], }, { @@ -259,9 +259,9 @@ }, }, 'sources': [ - 'chromeos/glib/abstract_dbus_service.cc', - 'chromeos/glib/dbus.cc', - 'chromeos/message_loops/glib_message_loop.cc', + 'brillo/glib/abstract_dbus_service.cc', + 'brillo/glib/dbus.cc', + 'brillo/message_loops/glib_message_loop.cc', ], 'includes': ['../common-mk/deps.gypi'], }, @@ -304,51 +304,51 @@ }], ], 'sources': [ - 'chromeos/any_unittest.cc', - 'chromeos/any_internal_impl_unittest.cc', - 'chromeos/asynchronous_signal_handler_unittest.cc', - 'chromeos/backoff_entry_unittest.cc', - 'chromeos/data_encoding_unittest.cc', - 'chromeos/dbus/async_event_sequencer_unittest.cc', - 'chromeos/dbus/data_serialization_unittest.cc', - 'chromeos/dbus/dbus_method_invoker_unittest.cc', - 'chromeos/dbus/dbus_object_unittest.cc', - 'chromeos/dbus/dbus_param_reader_unittest.cc', - 'chromeos/dbus/dbus_param_writer_unittest.cc', - 'chromeos/dbus/dbus_signal_handler_unittest.cc', - 'chromeos/dbus/exported_object_manager_unittest.cc', - 'chromeos/dbus/exported_property_set_unittest.cc', - 'chromeos/errors/error_codes_unittest.cc', - 'chromeos/errors/error_unittest.cc', - 'chromeos/file_utils_unittest.cc', - 'chromeos/flag_helper_unittest.cc', - 'chromeos/glib/object_unittest.cc', - 'chromeos/http/http_connection_curl_unittest.cc', - 'chromeos/http/http_form_data_unittest.cc', - 'chromeos/http/http_request_unittest.cc', - 'chromeos/http/http_transport_curl_unittest.cc', - 'chromeos/http/http_utils_unittest.cc', - 'chromeos/key_value_store_unittest.cc', - 'chromeos/map_utils_unittest.cc', - 'chromeos/message_loops/fake_message_loop_unittest.cc', - 'chromeos/message_loops/glib_message_loop_unittest.cc', - 'chromeos/message_loops/message_loop_unittest.cc', - 'chromeos/mime_utils_unittest.cc', - 'chromeos/osrelease_reader_unittest.cc', - 'chromeos/process_reaper_unittest.cc', - 'chromeos/process_unittest.cc', - 'chromeos/secure_blob_unittest.cc', - 'chromeos/streams/fake_stream_unittest.cc', - 'chromeos/streams/file_stream_unittest.cc', - 'chromeos/streams/input_stream_set_unittest.cc', - 'chromeos/streams/memory_containers_unittest.cc', - 'chromeos/streams/memory_stream_unittest.cc', - 'chromeos/streams/openssl_stream_bio_unittests.cc', - 'chromeos/streams/stream_unittest.cc', - 'chromeos/streams/stream_utils_unittest.cc', - 'chromeos/strings/string_utils_unittest.cc', - 'chromeos/url_utils_unittest.cc', - 'chromeos/variant_dictionary_unittest.cc', + 'brillo/any_unittest.cc', + 'brillo/any_internal_impl_unittest.cc', + 'brillo/asynchronous_signal_handler_unittest.cc', + 'brillo/backoff_entry_unittest.cc', + 'brillo/data_encoding_unittest.cc', + 'brillo/dbus/async_event_sequencer_unittest.cc', + 'brillo/dbus/data_serialization_unittest.cc', + 'brillo/dbus/dbus_method_invoker_unittest.cc', + 'brillo/dbus/dbus_object_unittest.cc', + 'brillo/dbus/dbus_param_reader_unittest.cc', + 'brillo/dbus/dbus_param_writer_unittest.cc', + 'brillo/dbus/dbus_signal_handler_unittest.cc', + 'brillo/dbus/exported_object_manager_unittest.cc', + 'brillo/dbus/exported_property_set_unittest.cc', + 'brillo/errors/error_codes_unittest.cc', + 'brillo/errors/error_unittest.cc', + 'brillo/file_utils_unittest.cc', + 'brillo/flag_helper_unittest.cc', + 'brillo/glib/object_unittest.cc', + 'brillo/http/http_connection_curl_unittest.cc', + 'brillo/http/http_form_data_unittest.cc', + 'brillo/http/http_request_unittest.cc', + 'brillo/http/http_transport_curl_unittest.cc', + 'brillo/http/http_utils_unittest.cc', + 'brillo/key_value_store_unittest.cc', + 'brillo/map_utils_unittest.cc', + 'brillo/message_loops/fake_message_loop_unittest.cc', + 'brillo/message_loops/glib_message_loop_unittest.cc', + 'brillo/message_loops/message_loop_unittest.cc', + 'brillo/mime_utils_unittest.cc', + 'brillo/osrelease_reader_unittest.cc', + 'brillo/process_reaper_unittest.cc', + 'brillo/process_unittest.cc', + 'brillo/secure_blob_unittest.cc', + 'brillo/streams/fake_stream_unittest.cc', + 'brillo/streams/file_stream_unittest.cc', + 'brillo/streams/input_stream_set_unittest.cc', + 'brillo/streams/memory_containers_unittest.cc', + 'brillo/streams/memory_stream_unittest.cc', + 'brillo/streams/openssl_stream_bio_unittests.cc', + 'brillo/streams/stream_unittest.cc', + 'brillo/streams/stream_utils_unittest.cc', + 'brillo/strings/string_utils_unittest.cc', + 'brillo/url_utils_unittest.cc', + 'brillo/variant_dictionary_unittest.cc', 'testrunner.cc', '<(proto_in_dir)/test.proto', ] diff --git a/policy/device_policy.h b/policy/device_policy.h index 38bdbc3..12a21fd 100644 --- a/policy/device_policy.h +++ b/policy/device_policy.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_POLICY_DEVICE_POLICY_H_ -#define LIBCHROMEOS_CHROMEOS_POLICY_DEVICE_POLICY_H_ +#ifndef LIBCHROMEOS_POLICY_DEVICE_POLICY_H_ +#define LIBCHROMEOS_POLICY_DEVICE_POLICY_H_ #include <stdint.h> @@ -160,4 +160,4 @@ class DevicePolicy { #pragma GCC visibility pop -#endif // LIBCHROMEOS_CHROMEOS_POLICY_DEVICE_POLICY_H_ +#endif // LIBCHROMEOS_POLICY_DEVICE_POLICY_H_ diff --git a/policy/device_policy_impl.h b/policy/device_policy_impl.h index 484e78d..458cd35 100644 --- a/policy/device_policy_impl.h +++ b/policy/device_policy_impl.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_POLICY_DEVICE_POLICY_IMPL_H_ -#define LIBCHROMEOS_CHROMEOS_POLICY_DEVICE_POLICY_IMPL_H_ +#ifndef LIBCHROMEOS_POLICY_DEVICE_POLICY_IMPL_H_ +#define LIBCHROMEOS_POLICY_DEVICE_POLICY_IMPL_H_ #include <set> #include <string> @@ -84,4 +84,4 @@ class DevicePolicyImpl : public DevicePolicy { #pragma GCC visibility pop -#endif // LIBCHROMEOS_CHROMEOS_POLICY_DEVICE_POLICY_IMPL_H_ +#endif // LIBCHROMEOS_POLICY_DEVICE_POLICY_IMPL_H_ diff --git a/policy/libpolicy.h b/policy/libpolicy.h index f05a37e..e2df0c3 100644 --- a/policy/libpolicy.h +++ b/policy/libpolicy.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_POLICY_LIBPOLICY_H_ -#define LIBCHROMEOS_CHROMEOS_POLICY_LIBPOLICY_H_ +#ifndef LIBCHROMEOS_POLICY_LIBPOLICY_H_ +#define LIBCHROMEOS_POLICY_LIBPOLICY_H_ #include <string> @@ -47,4 +47,4 @@ class PolicyProvider { #pragma GCC visibility pop -#endif // LIBCHROMEOS_CHROMEOS_POLICY_LIBPOLICY_H_ +#endif // LIBCHROMEOS_POLICY_LIBPOLICY_H_ diff --git a/policy/mock_device_policy.h b/policy/mock_device_policy.h index 0960664..aeb8dd8 100644 --- a/policy/mock_device_policy.h +++ b/policy/mock_device_policy.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_POLICY_MOCK_DEVICE_POLICY_H_ -#define LIBCHROMEOS_CHROMEOS_POLICY_MOCK_DEVICE_POLICY_H_ +#ifndef LIBCHROMEOS_POLICY_MOCK_DEVICE_POLICY_H_ +#define LIBCHROMEOS_POLICY_MOCK_DEVICE_POLICY_H_ #include <set> #include <string> @@ -104,4 +104,4 @@ class MockDevicePolicy : public DevicePolicy { #pragma GCC visibility pop -#endif // LIBCHROMEOS_CHROMEOS_POLICY_MOCK_DEVICE_POLICY_H_ +#endif // LIBCHROMEOS_POLICY_MOCK_DEVICE_POLICY_H_ diff --git a/policy/mock_libpolicy.h b/policy/mock_libpolicy.h index c4315ea..04fe92d 100644 --- a/policy/mock_libpolicy.h +++ b/policy/mock_libpolicy.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef LIBCHROMEOS_CHROMEOS_POLICY_MOCK_LIBPOLICY_H_ -#define LIBCHROMEOS_CHROMEOS_POLICY_MOCK_LIBPOLICY_H_ +#ifndef LIBCHROMEOS_POLICY_MOCK_LIBPOLICY_H_ +#define LIBCHROMEOS_POLICY_MOCK_LIBPOLICY_H_ #include <gmock/gmock.h> #include <set> @@ -32,4 +32,4 @@ class MockPolicyProvider : public PolicyProvider { #pragma GCC visibility pop -#endif // LIBCHROMEOS_CHROMEOS_POLICY_MOCK_LIBPOLICY_H_ +#endif // LIBCHROMEOS_POLICY_MOCK_LIBPOLICY_H_ diff --git a/testrunner.cc b/testrunner.cc index 5e51343..7122b9c 100644 --- a/testrunner.cc +++ b/testrunner.cc @@ -8,7 +8,7 @@ #include <gtest/gtest.h> #include <base/at_exit.h> -#include <chromeos/test_helpers.h> +#include <brillo/test_helpers.h> int main(int argc, char** argv) { base::AtExitManager at_exit_manager; diff --git a/testrunner_android.cc b/testrunner_android.cc index e776bc1..93377bf 100644 --- a/testrunner_android.cc +++ b/testrunner_android.cc @@ -17,7 +17,7 @@ #include <gtest/gtest.h> #include <base/at_exit.h> -#include <chromeos/test_helpers.h> +#include <brillo/test_helpers.h> int main(int argc, char** argv) { base::AtExitManager at_exit_manager; |