summaryrefslogtreecommitdiff
path: root/chromium/content/common
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-11-20 15:06:40 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-11-22 11:48:58 +0000
commitdaa093eea7c773db06799a13bd7e4e2e2a9f8f14 (patch)
tree96cc5e7b9194c1b29eab927730bfa419e7111c25 /chromium/content/common
parentbe59a35641616a4cf23c4a13fa0632624b021c1b (diff)
downloadqtwebengine-chromium-daa093eea7c773db06799a13bd7e4e2e2a9f8f14.tar.gz
BASELINE: Update Chromium to 63.0.3239.58
Change-Id: Ia93b322a00ba4dd4004f3bcf1254063ba90e1605 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/content/common')
-rw-r--r--chromium/content/common/BUILD.gn89
-rw-r--r--chromium/content/common/DEPS14
-rw-r--r--chromium/content/common/accessibility_messages.h6
-rw-r--r--chromium/content/common/all_messages.h4
-rw-r--r--chromium/content/common/android/browser_side_navigation_policy_android.cc20
-rw-r--r--chromium/content/common/android/sync_compositor_messages.h21
-rw-r--r--chromium/content/common/appcache_interfaces.h8
-rw-r--r--chromium/content/common/appcache_messages.h12
-rw-r--r--chromium/content/common/background_fetch/background_fetch_struct_traits.cc10
-rw-r--r--chromium/content/common/background_fetch/background_fetch_struct_traits.h32
-rw-r--r--chromium/content/common/background_fetch/background_fetch_struct_traits_unittest.cc15
-rw-r--r--chromium/content/common/background_fetch/background_fetch_types.h21
-rw-r--r--chromium/content/common/browser_plugin/browser_plugin_messages.h16
-rw-r--r--chromium/content/common/cache_storage/cache_storage_messages.h5
-rw-r--r--chromium/content/common/child_process_host_impl.cc3
-rw-r--r--chromium/content/common/child_process_messages.h86
-rw-r--r--chromium/content/common/clipboard_messages.h11
-rw-r--r--chromium/content/common/common.sb56
-rw-r--r--chromium/content/common/common_param_traits_unittest.cc11
-rw-r--r--chromium/content/common/content_message_generator.cc6
-rw-r--r--chromium/content/common/content_message_generator.h149
-rw-r--r--chromium/content/common/content_param_traits.cc52
-rw-r--r--chromium/content/common/content_param_traits.h12
-rw-r--r--chromium/content/common/content_param_traits_macros.h5
-rw-r--r--chromium/content/common/content_switches_internal.cc15
-rw-r--r--chromium/content/common/content_switches_internal.h2
-rw-r--r--chromium/content/common/cursors/webcursor.cc31
-rw-r--r--chromium/content/common/cursors/webcursor.h6
-rw-r--r--chromium/content/common/cursors/webcursor_android.cc8
-rw-r--r--chromium/content/common/cursors/webcursor_aurawin.cc8
-rw-r--r--chromium/content/common/cursors/webcursor_aurax11.cc8
-rw-r--r--chromium/content/common/cursors/webcursor_mac.mm8
-rw-r--r--chromium/content/common/cursors/webcursor_ozone.cc8
-rw-r--r--chromium/content/common/database_messages.h85
-rw-r--r--chromium/content/common/devtools/devtools_network_conditions.cc31
-rw-r--r--chromium/content/common/devtools/devtools_network_conditions.h47
-rw-r--r--chromium/content/common/devtools/devtools_network_controller.cc76
-rw-r--r--chromium/content/common/devtools/devtools_network_controller.h54
-rw-r--r--chromium/content/common/devtools/devtools_network_controller_unittest.cc322
-rw-r--r--chromium/content/common/devtools/devtools_network_interceptor.cc287
-rw-r--r--chromium/content/common/devtools/devtools_network_interceptor.h110
-rw-r--r--chromium/content/common/devtools/devtools_network_transaction.cc319
-rw-r--r--chromium/content/common/devtools/devtools_network_transaction.h135
-rw-r--r--chromium/content/common/devtools/devtools_network_transaction_factory.cc45
-rw-r--r--chromium/content/common/devtools/devtools_network_transaction_factory.h42
-rw-r--r--chromium/content/common/devtools/devtools_network_upload_data_stream.cc97
-rw-r--r--chromium/content/common/devtools/devtools_network_upload_data_stream.h55
-rw-r--r--chromium/content/common/devtools_messages.h6
-rw-r--r--chromium/content/common/dom_storage/dom_storage_map.cc71
-rw-r--r--chromium/content/common/dom_storage/dom_storage_map.h19
-rw-r--r--chromium/content/common/dom_storage/dom_storage_map_unittest.cc61
-rw-r--r--chromium/content/common/dom_storage/dom_storage_messages.h5
-rw-r--r--chromium/content/common/drag_messages.h6
-rw-r--r--chromium/content/common/dwrite_font_proxy_messages.h11
-rw-r--r--chromium/content/common/feature_policy/feature_policy.cc2
-rw-r--r--chromium/content/common/file_utilities.mojom15
-rw-r--r--chromium/content/common/file_utilities_messages.h19
-rw-r--r--chromium/content/common/fileapi/file_system_messages.h9
-rw-r--r--chromium/content/common/fileapi/webblob_messages.h6
-rw-r--r--chromium/content/common/font_cache_dispatcher_win.cc5
-rw-r--r--chromium/content/common/frame.mojom14
-rw-r--r--chromium/content/common/frame_messages.h47
-rw-r--r--chromium/content/common/frame_messages.typemap8
-rw-r--r--chromium/content/common/frame_messages_forward.h25
-rw-r--r--chromium/content/common/gin_java_bridge_messages.h7
-rw-r--r--chromium/content/common/gpu_stream_constants.h4
-rw-r--r--chromium/content/common/histogram_fetcher.mojom17
-rw-r--r--chromium/content/common/indexed_db/indexed_db.mojom2
-rw-r--r--chromium/content/common/indexed_db/indexed_db_key_path.cc3
-rw-r--r--chromium/content/common/indexed_db/indexed_db_key_path.h2
-rw-r--r--chromium/content/common/indexed_db/indexed_db_metadata.cc12
-rw-r--r--chromium/content/common/indexed_db/indexed_db_metadata.h8
-rw-r--r--chromium/content/common/input/ime_text_span_conversions.cc41
-rw-r--r--chromium/content/common/input/ime_text_span_conversions.h20
-rw-r--r--chromium/content/common/input/input_event_struct_traits.cc7
-rw-r--r--chromium/content/common/input/input_handler.mojom48
-rw-r--r--chromium/content/common/input/input_param_traits.cc8
-rw-r--r--chromium/content/common/input/input_param_traits.h1
-rw-r--r--chromium/content/common/input_messages.h14
-rw-r--r--chromium/content/common/leveldb_wrapper.mojom36
-rw-r--r--chromium/content/common/mac/app_nap_activity.h49
-rw-r--r--chromium/content/common/mac/app_nap_activity.mm72
-rw-r--r--chromium/content/common/mac/app_nap_activity_unittest.mm56
-rw-r--r--chromium/content/common/media/aec_dump_messages.h6
-rw-r--r--chromium/content/common/media/audio_messages.h21
-rw-r--r--chromium/content/common/media/cdm_host_file.cc51
-rw-r--r--chromium/content/common/media/cdm_host_file.h53
-rw-r--r--chromium/content/common/media/cdm_host_files.cc295
-rw-r--r--chromium/content/common/media/cdm_host_files.h114
-rw-r--r--chromium/content/common/media/cdm_info.cc27
-rw-r--r--chromium/content/common/media/media_devices.mojom14
-rw-r--r--chromium/content/common/media/media_devices_param_traits.cc6
-rw-r--r--chromium/content/common/media/media_player_delegate_messages.h6
-rw-r--r--chromium/content/common/media/media_player_messages_android.h6
-rw-r--r--chromium/content/common/media/media_stream.mojom20
-rw-r--r--chromium/content/common/media/media_stream.typemap4
-rw-r--r--chromium/content/common/media/media_stream_controls.cc29
-rw-r--r--chromium/content/common/media/media_stream_controls.h (renamed from chromium/content/common/media/media_stream_options.h)45
-rw-r--r--chromium/content/common/media/media_stream_options.cc72
-rw-r--r--chromium/content/common/media/media_stream_param_traits.cc6
-rw-r--r--chromium/content/common/media/media_stream_param_traits.h20
-rw-r--r--chromium/content/common/media/media_stream_track_metrics_host_messages.h5
-rw-r--r--chromium/content/common/media/media_stream_typemap_traits.h2
-rw-r--r--chromium/content/common/media/midi_messages.h6
-rw-r--r--chromium/content/common/media/peer_connection_tracker_messages.h5
-rw-r--r--chromium/content/common/media/surface_view_manager_messages_android.h6
-rw-r--r--chromium/content/common/message_port.cc209
-rw-r--r--chromium/content/common/message_port.h121
-rw-r--r--chromium/content/common/message_port.mojom15
-rw-r--r--chromium/content/common/message_port_message.cc12
-rw-r--r--chromium/content/common/message_port_message.h35
-rw-r--r--chromium/content/common/message_port_message_struct_traits.cc23
-rw-r--r--chromium/content/common/message_port_message_struct_traits.h33
-rw-r--r--chromium/content/common/native_types.typemap2
-rw-r--r--chromium/content/common/navigation_params.cc9
-rw-r--r--chromium/content/common/navigation_params.h8
-rw-r--r--chromium/content/common/origin_trials/OWNERS1
-rw-r--r--chromium/content/common/origin_trials/trial_policy_impl.cc37
-rw-r--r--chromium/content/common/origin_trials/trial_policy_impl.h36
-rw-r--r--chromium/content/common/origin_trials/trial_token.cc234
-rw-r--r--chromium/content/common/origin_trials/trial_token.h120
-rw-r--r--chromium/content/common/origin_trials/trial_token_unittest.cc505
-rw-r--r--chromium/content/common/origin_trials/trial_token_validator.cc144
-rw-r--r--chromium/content/common/origin_trials/trial_token_validator.h69
-rw-r--r--chromium/content/common/origin_trials/trial_token_validator_unittest.cc344
-rw-r--r--chromium/content/common/p2p_messages.h6
-rw-r--r--chromium/content/common/page_messages.h6
-rw-r--r--chromium/content/common/page_state_serialization.cc101
-rw-r--r--chromium/content/common/page_state_serialization.h17
-rw-r--r--chromium/content/common/page_state_serialization_unittest.cc61
-rw-r--r--chromium/content/common/platform_notification_messages.h12
-rw-r--r--chromium/content/common/presentation/presentation_struct_traits.cc7
-rw-r--r--chromium/content/common/quota_messages.h5
-rw-r--r--chromium/content/common/render_process_messages.h6
-rw-r--r--chromium/content/common/render_widget_surface_properties.cc2
-rw-r--r--chromium/content/common/render_widget_surface_properties.h6
-rw-r--r--chromium/content/common/render_widget_window_tree_client_factory.mojom18
-rw-r--r--chromium/content/common/renderer.mojom24
-rw-r--r--chromium/content/common/resize_params.h5
-rw-r--r--chromium/content/common/resource_messages.cc160
-rw-r--r--chromium/content/common/resource_messages.h27
-rw-r--r--chromium/content/common/sandbox_init_mac.cc63
-rw-r--r--chromium/content/common/sandbox_init_win.cc17
-rw-r--r--chromium/content/common/sandbox_linux/bpf_cdm_policy_linux.cc55
-rw-r--r--chromium/content/common/sandbox_linux/bpf_cdm_policy_linux.h28
-rw-r--r--chromium/content/common/sandbox_linux/bpf_cros_amd_gpu_policy_linux.cc171
-rw-r--r--chromium/content/common/sandbox_linux/bpf_cros_amd_gpu_policy_linux.h29
-rw-r--r--chromium/content/common/sandbox_linux/bpf_pdf_compositor_policy_linux.cc55
-rw-r--r--chromium/content/common/sandbox_linux/bpf_pdf_compositor_policy_linux.h28
-rw-r--r--chromium/content/common/sandbox_linux/bpf_renderer_policy_linux.cc4
-rw-r--r--chromium/content/common/sandbox_linux/sandbox_linux.cc69
-rw-r--r--chromium/content/common/sandbox_linux/sandbox_linux.h11
-rw-r--r--chromium/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.cc190
-rw-r--r--chromium/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h20
-rw-r--r--chromium/content/common/sandbox_mac.h76
-rw-r--r--chromium/content/common/sandbox_mac.mm322
-rw-r--r--chromium/content/common/sandbox_mac_diraccess_unittest.mm4
-rw-r--r--chromium/content/common/sandbox_mac_fontloading_unittest.mm6
-rw-r--r--chromium/content/common/sandbox_mac_system_access_unittest.mm2
-rw-r--r--chromium/content/common/sandbox_mac_unittest_helper.h5
-rw-r--r--chromium/content/common/sandbox_mac_unittest_helper.mm27
-rw-r--r--chromium/content/common/sandbox_policy_fuchsia.cc32
-rw-r--r--chromium/content/common/sandbox_policy_fuchsia.h25
-rw-r--r--chromium/content/common/sandbox_win.cc7
-rw-r--r--chromium/content/common/service_worker/OWNERS7
-rw-r--r--chromium/content/common/service_worker/controller_service_worker.mojom43
-rw-r--r--chromium/content/common/service_worker/embedded_worker_messages.h5
-rw-r--r--chromium/content/common/service_worker/service_worker_container.mojom62
-rw-r--r--chromium/content/common/service_worker/service_worker_event_dispatcher.mojom49
-rw-r--r--chromium/content/common/service_worker/service_worker_event_dispatcher.typemap5
-rw-r--r--chromium/content/common/service_worker/service_worker_fetch_response_callback.mojom35
-rw-r--r--chromium/content/common/service_worker/service_worker_loader_helpers.cc87
-rw-r--r--chromium/content/common/service_worker/service_worker_loader_helpers.h35
-rw-r--r--chromium/content/common/service_worker/service_worker_messages.h119
-rw-r--r--chromium/content/common/service_worker/service_worker_provider.mojom3
-rw-r--r--chromium/content/common/service_worker/service_worker_status_code_traits.cc51
-rw-r--r--chromium/content/common/service_worker/service_worker_status_code_traits.h25
-rw-r--r--chromium/content/common/service_worker/service_worker_types.cc11
-rw-r--r--chromium/content/common/service_worker/service_worker_types.h23
-rw-r--r--chromium/content/common/service_worker/service_worker_types.mojom7
-rw-r--r--chromium/content/common/service_worker/service_worker_types.typemap1
-rw-r--r--chromium/content/common/service_worker/service_worker_utils.cc9
-rw-r--r--chromium/content/common/service_worker/service_worker_utils.h4
-rw-r--r--chromium/content/common/shared_worker/OWNERS2
-rw-r--r--chromium/content/common/shared_worker/shared_worker.mojom17
-rw-r--r--chromium/content/common/shared_worker/shared_worker_client.mojom27
-rw-r--r--chromium/content/common/shared_worker/shared_worker_connector.mojom20
-rw-r--r--chromium/content/common/shared_worker/shared_worker_factory.mojom27
-rw-r--r--chromium/content/common/shared_worker/shared_worker_host.mojom33
-rw-r--r--chromium/content/common/shared_worker/shared_worker_info.mojom22
-rw-r--r--chromium/content/common/site_isolation_policy.cc3
-rw-r--r--chromium/content/common/speech_recognition_messages.h5
-rw-r--r--chromium/content/common/swapped_out_messages.cc4
-rw-r--r--chromium/content/common/text_input_client_messages.h4
-rw-r--r--chromium/content/common/throttling_url_loader.cc230
-rw-r--r--chromium/content/common/throttling_url_loader.h60
-rw-r--r--chromium/content/common/throttling_url_loader_unittest.cc301
-rw-r--r--chromium/content/common/typemaps.gni1
-rw-r--r--chromium/content/common/unique_name_helper_unittest.cc6
-rw-r--r--chromium/content/common/view_message_enums.h4
-rw-r--r--chromium/content/common/view_messages.h118
-rw-r--r--chromium/content/common/web_database.mojom66
-rw-r--r--chromium/content/common/widget.mojom4
-rw-r--r--chromium/content/common/worker_messages.h104
204 files changed, 4586 insertions, 4737 deletions
diff --git a/chromium/content/common/BUILD.gn b/chromium/content/common/BUILD.gn
index d79158deed5..d607aae096c 100644
--- a/chromium/content/common/BUILD.gn
+++ b/chromium/content/common/BUILD.gn
@@ -36,6 +36,7 @@ source_set("common") {
sources = [
"accessibility_messages.h",
"all_messages.h",
+ "android/browser_side_navigation_policy_android.cc",
"android/gin_java_bridge_errors.cc",
"android/gin_java_bridge_errors.h",
"android/gin_java_bridge_value.cc",
@@ -112,8 +113,19 @@ source_set("common") {
"cursors/webcursor_aurax11.cc",
"cursors/webcursor_mac.mm",
"cursors/webcursor_ozone.cc",
- "database_messages.h",
"date_time_suggestion.h",
+ "devtools/devtools_network_conditions.cc",
+ "devtools/devtools_network_conditions.h",
+ "devtools/devtools_network_controller.cc",
+ "devtools/devtools_network_controller.h",
+ "devtools/devtools_network_interceptor.cc",
+ "devtools/devtools_network_interceptor.h",
+ "devtools/devtools_network_transaction.cc",
+ "devtools/devtools_network_transaction.h",
+ "devtools/devtools_network_transaction_factory.cc",
+ "devtools/devtools_network_transaction_factory.h",
+ "devtools/devtools_network_upload_data_stream.cc",
+ "devtools/devtools_network_upload_data_stream.h",
"devtools_messages.h",
"dom_storage/dom_storage_map.cc",
"dom_storage/dom_storage_map.h",
@@ -128,7 +140,6 @@ source_set("common") {
"edit_command.h",
"feature_policy/feature_policy.cc",
"feature_policy/feature_policy.h",
- "file_utilities_messages.h",
"fileapi/file_system_messages.h",
"fileapi/webblob_messages.h",
"font_cache_dispatcher_win.cc",
@@ -143,6 +154,7 @@ source_set("common") {
"font_list_win.cc",
"frame_message_enums.h",
"frame_messages.h",
+ "frame_messages_forward.h",
"frame_owner_properties.cc",
"frame_owner_properties.h",
"frame_replication_state.cc",
@@ -164,6 +176,8 @@ source_set("common") {
"input/event_with_latency_info.h",
"input/gesture_event_stream_validator.cc",
"input/gesture_event_stream_validator.h",
+ "input/ime_text_span_conversions.cc",
+ "input/ime_text_span_conversions.h",
"input/input_event.cc",
"input/input_event.h",
"input/input_event_ack.cc",
@@ -206,8 +220,6 @@ source_set("common") {
"layer_tree_settings_factory.h",
"loader_util.cc",
"loader_util.h",
- "mac/app_nap_activity.h",
- "mac/app_nap_activity.mm",
"mac/attributed_string_coder.h",
"mac/attributed_string_coder.mm",
"mac/font_descriptor.h",
@@ -223,8 +235,8 @@ source_set("common") {
"media/media_devices_param_traits.h",
"media/media_player_delegate_messages.h",
"media/media_player_messages_android.h",
- "media/media_stream_options.cc",
- "media/media_stream_options.h",
+ "media/media_stream_controls.cc",
+ "media/media_stream_controls.h",
"media/media_stream_param_traits.cc",
"media/media_stream_param_traits.h",
"media/media_stream_track_metrics_host_messages.h",
@@ -232,12 +244,6 @@ source_set("common") {
"media/peer_connection_tracker_messages.h",
"media/surface_view_manager_messages_android.h",
"media/video_capture.h",
- "message_port.cc",
- "message_port.h",
- "message_port_message.cc",
- "message_port_message.h",
- "message_port_message_struct_traits.cc",
- "message_port_message_struct_traits.h",
"navigation_gesture.h",
"navigation_params.cc",
"navigation_params.h",
@@ -246,10 +252,8 @@ source_set("common") {
"net/url_request_service_worker_data.h",
"net/url_request_user_data.cc",
"net/url_request_user_data.h",
- "origin_trials/trial_token.cc",
- "origin_trials/trial_token.h",
- "origin_trials/trial_token_validator.cc",
- "origin_trials/trial_token_validator.h",
+ "origin_trials/trial_policy_impl.cc",
+ "origin_trials/trial_policy_impl.h",
"origin_util.cc",
"p2p_socket_type.h",
"page_message_enums.h",
@@ -287,10 +291,16 @@ source_set("common") {
"sandbox_init_mac.cc",
"sandbox_init_mac.h",
"sandbox_init_win.cc",
+ "sandbox_linux/bpf_cdm_policy_linux.cc",
+ "sandbox_linux/bpf_cdm_policy_linux.h",
+ "sandbox_linux/bpf_cros_amd_gpu_policy_linux.cc",
+ "sandbox_linux/bpf_cros_amd_gpu_policy_linux.h",
"sandbox_linux/bpf_cros_arm_gpu_policy_linux.cc",
"sandbox_linux/bpf_cros_arm_gpu_policy_linux.h",
"sandbox_linux/bpf_gpu_policy_linux.cc",
"sandbox_linux/bpf_gpu_policy_linux.h",
+ "sandbox_linux/bpf_pdf_compositor_policy_linux.cc",
+ "sandbox_linux/bpf_pdf_compositor_policy_linux.h",
"sandbox_linux/bpf_ppapi_policy_linux.cc",
"sandbox_linux/bpf_ppapi_policy_linux.h",
"sandbox_linux/bpf_renderer_policy_linux.cc",
@@ -306,8 +316,6 @@ source_set("common") {
"sandbox_linux/sandbox_linux.h",
"sandbox_linux/sandbox_seccomp_bpf_linux.cc",
"sandbox_linux/sandbox_seccomp_bpf_linux.h",
- "sandbox_mac.h",
- "sandbox_mac.mm",
"sandbox_win.cc",
"sandbox_win.h",
"savable_subframe.h",
@@ -320,6 +328,8 @@ source_set("common") {
"service_worker/embedded_worker_start_params.h",
"service_worker/service_worker_client_info.cc",
"service_worker/service_worker_client_info.h",
+ "service_worker/service_worker_loader_helpers.cc",
+ "service_worker/service_worker_loader_helpers.h",
"service_worker/service_worker_messages.h",
"service_worker/service_worker_provider_host_info.cc",
"service_worker/service_worker_provider_host_info.h",
@@ -350,7 +360,6 @@ source_set("common") {
"user_agent.cc",
"view_message_enums.h",
"view_messages.h",
- "worker_messages.h",
"zygote_commands_linux.h",
]
@@ -365,6 +374,8 @@ source_set("common") {
"//cc",
"//gpu/command_buffer/common",
"//ipc",
+ "//services/service_manager/sandbox",
+ "//third_party/WebKit/common:blink_common",
"//third_party/WebKit/public:blink_headers",
]
deps = [
@@ -422,6 +433,7 @@ source_set("common") {
"//services/viz/public/interfaces",
"//skia",
"//storage/common",
+ "//third_party/angle:angle_gpu_info_util",
"//third_party/boringssl",
"//third_party/icu",
"//ui/accessibility",
@@ -495,7 +507,7 @@ source_set("common") {
sources -= [ "cursors/webcursor_ozone.cc" ]
}
- if (!use_aura || is_android) {
+ if (!use_aura) {
sources -= [ "cursors/webcursor_aura.cc" ]
}
@@ -536,6 +548,8 @@ source_set("common") {
if (!use_seccomp_bpf) {
if (is_linux) {
sources -= [
+ "sandbox_linux/bpf_cros_amd_gpu_policy_linux.cc",
+ "sandbox_linux/bpf_cros_amd_gpu_policy_linux.h",
"sandbox_linux/bpf_cros_arm_gpu_policy_linux.cc",
"sandbox_linux/bpf_cros_arm_gpu_policy_linux.h",
"sandbox_linux/bpf_gpu_policy_linux.cc",
@@ -564,26 +578,13 @@ source_set("common") {
]
}
- if (enable_cdm_host_verification) {
+ if (is_fuchsia) {
sources += [
- "media/cdm_host_file.cc",
- "media/cdm_host_file.h",
- "media/cdm_host_files.cc",
- "media/cdm_host_files.h",
- ]
- deps += [
- "//media/cdm:cdm_paths",
-
- # Needed for finding CDM path from CDM adapter path.
- # TODO(xhwang): Remove this dependency when CDM adapter is deprecated.
- # See http://crbug.com/403462
- "//third_party/widevine/cdm:headers",
+ "font_list_fuchsia.cc",
+ "sandbox_policy_fuchsia.cc",
+ "sandbox_policy_fuchsia.h",
]
}
-
- if (is_fuchsia) {
- sources += [ "font_list_fuchsia.cc" ]
- }
}
# See comment at the top of //content/BUILD.gn for how this works.
@@ -608,8 +609,10 @@ mojom("mojo_bindings") {
"child.mojom",
"child_memory_coordinator.mojom",
"field_trial_recorder.mojom",
+ "file_utilities.mojom",
"frame.mojom",
"frame_sink_provider.mojom",
+ "histogram_fetcher.mojom",
"host_zoom.mojom",
"image_downloader/image_downloader.mojom",
"indexed_db/indexed_db.mojom",
@@ -621,7 +624,6 @@ mojom("mojo_bindings") {
"media/media_stream.mojom",
"media/renderer_audio_output_stream_factory.mojom",
"memory_coordinator.mojom",
- "message_port.mojom",
"native_types.mojom",
"push_messaging.mojom",
"render_frame_message_filter.mojom",
@@ -629,15 +631,24 @@ mojom("mojo_bindings") {
"render_widget_window_tree_client_factory.mojom",
"renderer.mojom",
"renderer_host.mojom",
+ "service_worker/controller_service_worker.mojom",
"service_worker/embedded_worker.mojom",
"service_worker/service_worker.mojom",
"service_worker/service_worker_container.mojom",
"service_worker/service_worker_event_dispatcher.mojom",
+ "service_worker/service_worker_fetch_response_callback.mojom",
"service_worker/service_worker_installed_scripts_manager.mojom",
"service_worker/service_worker_provider.mojom",
"service_worker/service_worker_types.mojom",
+ "shared_worker/shared_worker.mojom",
+ "shared_worker/shared_worker_client.mojom",
+ "shared_worker/shared_worker_connector.mojom",
+ "shared_worker/shared_worker_factory.mojom",
+ "shared_worker/shared_worker_host.mojom",
+ "shared_worker/shared_worker_info.mojom",
"storage_partition_service.mojom",
"video_capture.mojom",
+ "web_database.mojom",
"widget.mojom",
]
@@ -646,7 +657,7 @@ mojom("mojo_bindings") {
public_deps = [
"//components/leveldb/public/interfaces",
"//content/public/common:interfaces",
- "//ipc:mojom",
+ "//ipc:mojom_constants",
"//media/capture/mojo:capture_types",
"//media/mojo/interfaces",
"//mojo/common:common_custom_types",
diff --git a/chromium/content/common/DEPS b/chromium/content/common/DEPS
index 48d50f5a6ce..628a26dca0b 100644
--- a/chromium/content/common/DEPS
+++ b/chromium/content/common/DEPS
@@ -8,6 +8,7 @@ include_rules = [
"+services/network/public/interfaces",
"+services/resource_coordinator/public/interfaces",
"+services/service_manager/public/cpp",
+ "+services/service_manager/sandbox",
"+services/video_capture/public/interfaces",
"+services/viz/public/interfaces",
@@ -60,10 +61,12 @@ include_rules = [
"+third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerCacheError.h",
"+third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerClientType.h",
"+third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerError.h",
- "+third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerEventResult.h",
"+third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponseError.h",
- "+third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerState.h",
+ "+third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom.h",
"+third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h",
+ "+third_party/WebKit/public/platform/modules/serviceworker/service_worker_state.mojom.h",
+ "+third_party/WebKit/public/platform/modules/serviceworker/service_worker_stream_handle.mojom.h",
+ "+third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h",
"+third_party/WebKit/public/web/WebAXEnums.h",
"+third_party/WebKit/public/web/WebDeviceEmulationParams.h",
"+third_party/WebKit/public/web/WebDragStatus.h",
@@ -80,5 +83,10 @@ include_rules = [
"+third_party/WebKit/public/web/WebTextDirection.h",
"+third_party/WebKit/public/web/WebTreeScopeType.h",
"+third_party/WebKit/public/web/WebTriggeringEventInfo.h",
- "+third_party/WebKit/public/web/win/WebFontRendering.h"
+ "+third_party/WebKit/public/web/win/WebFontRendering.h",
+
+ # Unlike other WebKit directories WebKit/common is for the files that
+ # are commonly referenced by renderer-side and browser-side code, and
+ # does not use Blink types like WTF.
+ "+third_party/WebKit/common"
]
diff --git a/chromium/content/common/accessibility_messages.h b/chromium/content/common/accessibility_messages.h
index f2cbf5a0bb0..dfa018a21f2 100644
--- a/chromium/content/common/accessibility_messages.h
+++ b/chromium/content/common/accessibility_messages.h
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_ACCESSIBILITY_MESSAGES_H_
+#define CONTENT_COMMON_ACCESSIBILITY_MESSAGES_H_
+
// IPC messages for accessibility.
-// Multiply-included message file, hence no include guard.
#include "content/common/ax_content_node_data.h"
#include "content/common/content_export.h"
@@ -212,3 +214,5 @@ IPC_MESSAGE_ROUTED3(AccessibilityHostMsg_ChildFrameHitTestResult,
IPC_MESSAGE_ROUTED2(AccessibilityHostMsg_SnapshotResponse,
int /* callback_id */,
content::AXContentTreeUpdate)
+
+#endif // CONTENT_COMMON_ACCESSIBILITY_MESSAGES_H_
diff --git a/chromium/content/common/all_messages.h b/chromium/content/common/all_messages.h
index 8f33d436d12..31cc3abb117 100644
--- a/chromium/content/common/all_messages.h
+++ b/chromium/content/common/all_messages.h
@@ -12,5 +12,9 @@
#include "content/common/content_message_generator.h"
#if BUILDFLAG(ENABLE_PLUGINS)
+#undef PPAPI_PROXY_PPAPI_MESSAGES_H_
#include "ppapi/proxy/ppapi_messages.h" // nogncheck
+#ifndef PPAPI_PROXY_PPAPI_MESSAGES_H_
+#error "Failed to include ppapi/proxy/ppapi_messages.h"
+#endif
#endif
diff --git a/chromium/content/common/android/browser_side_navigation_policy_android.cc b/chromium/content/common/android/browser_side_navigation_policy_android.cc
new file mode 100644
index 00000000000..d2fe4a86fb0
--- /dev/null
+++ b/chromium/content/common/android/browser_side_navigation_policy_android.cc
@@ -0,0 +1,20 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <jni.h>
+
+#include "base/android/scoped_java_ref.h"
+#include "content/public/common/browser_side_navigation_policy.h"
+#include "jni/BrowserSideNavigationPolicy_jni.h"
+
+using base::android::JavaParamRef;
+
+namespace content {
+
+jboolean IsBrowserSideNavigationEnabled(JNIEnv* env,
+ const JavaParamRef<jclass>& clazz) {
+ return IsBrowserSideNavigationEnabled();
+}
+
+} // namespace content
diff --git a/chromium/content/common/android/sync_compositor_messages.h b/chromium/content/common/android/sync_compositor_messages.h
index b94022ad60e..2367f72b9f7 100644
--- a/chromium/content/common/android/sync_compositor_messages.h
+++ b/chromium/content/common/android/sync_compositor_messages.h
@@ -2,12 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_ANDROID_SYNC_COMPOSITOR_MESSAGES_H_
+#define CONTENT_COMMON_ANDROID_SYNC_COMPOSITOR_MESSAGES_H_
+
#include <stddef.h>
#include "base/memory/shared_memory_handle.h"
#include "base/optional.h"
-#include "cc/output/compositor_frame.h"
#include "components/viz/common/frame_sinks/begin_frame_args.h"
+#include "components/viz/common/quads/compositor_frame.h"
#include "content/common/content_export.h"
#include "content/common/content_param_traits.h"
#include "content/common/input/input_event_ack_state.h"
@@ -16,8 +19,8 @@
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/scroll_offset.h"
-#ifndef CONTENT_COMMON_ANDROID_SYNC_COMPOSITOR_MESSAGES_H_
-#define CONTENT_COMMON_ANDROID_SYNC_COMPOSITOR_MESSAGES_H_
+#ifndef INTERNAL_CONTENT_COMMON_ANDROID_SYNC_COMPOSITOR_MESSAGES_H_
+#define INTERNAL_CONTENT_COMMON_ANDROID_SYNC_COMPOSITOR_MESSAGES_H_
namespace content {
@@ -75,9 +78,7 @@ struct SyncCompositorCommonRendererParams {
} // namespace content
-#endif // CONTENT_COMMON_ANDROID_SYNC_COMPOSITOR_MESSAGES_H_
-
-// Multiply-included message file, hence no include guard.
+#endif // INTERNAL_CONTENT_COMMON_ANDROID_SYNC_COMPOSITOR_MESSAGES_H_
#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
@@ -132,7 +133,7 @@ IPC_SYNC_MESSAGE_ROUTED1_3(SyncCompositorMsg_DemandDrawHw,
content::SyncCompositorDemandDrawHwParams,
content::SyncCompositorCommonRendererParams,
uint32_t /* layer_tree_frame_sink_id */,
- base::Optional<cc::CompositorFrame>);
+ base::Optional<viz::CompositorFrame>);
IPC_SYNC_MESSAGE_ROUTED1_2(SyncCompositorMsg_SetSharedMemory,
content::SyncCompositorSetSharedMemoryParams,
@@ -144,7 +145,7 @@ IPC_MESSAGE_ROUTED0(SyncCompositorMsg_ZeroSharedMemory);
IPC_SYNC_MESSAGE_ROUTED1_2(SyncCompositorMsg_DemandDrawSw,
content::SyncCompositorDemandDrawSwParams,
content::SyncCompositorCommonRendererParams,
- base::Optional<cc::CompositorFrameMetadata>)
+ base::Optional<viz::CompositorFrameMetadata>)
IPC_SYNC_MESSAGE_ROUTED2_1(SyncCompositorMsg_ZoomBy,
float /* delta */,
@@ -170,4 +171,6 @@ IPC_MESSAGE_ROUTED1(SyncCompositorHostMsg_UpdateState,
IPC_MESSAGE_ROUTED2(SyncCompositorHostMsg_ReturnFrame,
uint32_t /* layer_tree_frame_sink_id */,
- base::Optional<cc::CompositorFrame>);
+ base::Optional<viz::CompositorFrame>);
+
+#endif // CONTENT_COMMON_ANDROID_SYNC_COMPOSITOR_MESSAGES_H_
diff --git a/chromium/content/common/appcache_interfaces.h b/chromium/content/common/appcache_interfaces.h
index da5373c8be4..74defd08c69 100644
--- a/chromium/content/common/appcache_interfaces.h
+++ b/chromium/content/common/appcache_interfaces.h
@@ -11,6 +11,7 @@
#include "base/files/file_path.h"
#include "content/public/common/appcache_info.h"
+#include "mojo/public/cpp/system/message_pipe.h"
namespace net {
class URLRequest;
@@ -132,6 +133,13 @@ class CONTENT_EXPORT AppCacheFrontend {
const GURL& manifest_url) = 0;
virtual void OnLogMessage(int host_id, AppCacheLogLevel log_level,
const std::string& message) = 0;
+ // In the network service world, we pass the URLLoaderFactory instance to be
+ // used to issue subresource requeste in the |loader_factory_pipe_handle|
+ // parameter.
+ virtual void OnSetSubresourceFactory(
+ int host_id,
+ mojo::MessagePipeHandle loader_factory_pipe_handle) = 0;
+
virtual ~AppCacheFrontend() {}
};
diff --git a/chromium/content/common/appcache_messages.h b/chromium/content/common/appcache_messages.h
index 95964f71c9d..38f6b48fcfb 100644
--- a/chromium/content/common/appcache_messages.h
+++ b/chromium/content/common/appcache_messages.h
@@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Multiply-included message file, hence no include guard.
+#ifndef CONTENT_COMMON_APPCACHE_MESSAGES_H_
+#define CONTENT_COMMON_APPCACHE_MESSAGES_H_
#include "ipc/ipc_message_macros.h"
#include <stdint.h>
#include "content/common/appcache_interfaces.h"
+#include "mojo/public/cpp/system/message_pipe.h"
#include "url/ipc/url_param_traits.h"
#define IPC_MESSAGE_START AppCacheMsgStart
@@ -160,3 +162,11 @@ IPC_MESSAGE_CONTROL3(AppCacheMsg_LogMessage,
IPC_MESSAGE_CONTROL2(AppCacheMsg_ContentBlocked,
int /* host_id */,
GURL /* manifest_url */)
+
+// In the network service world this message sets the URLLoaderFactory to be
+// used for subresources.
+IPC_MESSAGE_CONTROL2(AppCacheMsg_SetSubresourceFactory,
+ int /* host_id */,
+ mojo::MessagePipeHandle /* url_loader_factory */)
+
+#endif // CONTENT_COMMON_APPCACHE_MESSAGES_H_
diff --git a/chromium/content/common/background_fetch/background_fetch_struct_traits.cc b/chromium/content/common/background_fetch/background_fetch_struct_traits.cc
index 1fe3b792cda..f3f95d427ae 100644
--- a/chromium/content/common/background_fetch/background_fetch_struct_traits.cc
+++ b/chromium/content/common/background_fetch/background_fetch_struct_traits.cc
@@ -19,7 +19,7 @@ bool StructTraits<blink::mojom::BackgroundFetchOptionsDataView,
if (!data.ReadIcons(&options->icons) || !data.ReadTitle(&options->title))
return false;
- options->total_download_size = data.total_download_size();
+ options->download_total = data.download_total();
return true;
}
@@ -28,13 +28,17 @@ bool StructTraits<blink::mojom::BackgroundFetchRegistrationDataView,
content::BackgroundFetchRegistration>::
Read(blink::mojom::BackgroundFetchRegistrationDataView data,
content::BackgroundFetchRegistration* registration) {
- if (!data.ReadId(&registration->id) ||
+ if (!data.ReadDeveloperId(&registration->developer_id) ||
+ !data.ReadUniqueId(&registration->unique_id) ||
!data.ReadIcons(&registration->icons) ||
!data.ReadTitle(&registration->title)) {
return false;
}
- registration->total_download_size = data.total_download_size();
+ registration->upload_total = data.upload_total();
+ registration->uploaded = data.uploaded();
+ registration->download_total = data.download_total();
+ registration->downloaded = data.downloaded();
return true;
}
diff --git a/chromium/content/common/background_fetch/background_fetch_struct_traits.h b/chromium/content/common/background_fetch/background_fetch_struct_traits.h
index 2f2c67a945a..86f4bede1dd 100644
--- a/chromium/content/common/background_fetch/background_fetch_struct_traits.h
+++ b/chromium/content/common/background_fetch/background_fetch_struct_traits.h
@@ -32,9 +32,9 @@ struct CONTENT_EXPORT StructTraits<blink::mojom::BackgroundFetchOptionsDataView,
const content::BackgroundFetchOptions& options) {
return options.title;
}
- static int64_t total_download_size(
+ static uint64_t download_total(
const content::BackgroundFetchOptions& options) {
- return options.total_download_size;
+ return options.download_total;
}
static bool Read(blink::mojom::BackgroundFetchOptionsDataView data,
@@ -45,9 +45,29 @@ template <>
struct CONTENT_EXPORT
StructTraits<blink::mojom::BackgroundFetchRegistrationDataView,
content::BackgroundFetchRegistration> {
- static const std::string& id(
+ static const std::string& developer_id(
const content::BackgroundFetchRegistration& registration) {
- return registration.id;
+ return registration.developer_id;
+ }
+ static const std::string& unique_id(
+ const content::BackgroundFetchRegistration& registration) {
+ return registration.unique_id;
+ }
+ static uint64_t upload_total(
+ const content::BackgroundFetchRegistration& registration) {
+ return registration.upload_total;
+ }
+ static uint64_t uploaded(
+ const content::BackgroundFetchRegistration& registration) {
+ return registration.uploaded;
+ }
+ static uint64_t download_total(
+ const content::BackgroundFetchRegistration& registration) {
+ return registration.download_total;
+ }
+ static uint64_t downloaded(
+ const content::BackgroundFetchRegistration& registration) {
+ return registration.downloaded;
}
static const std::vector<content::IconDefinition>& icons(
const content::BackgroundFetchRegistration& registration) {
@@ -57,10 +77,6 @@ struct CONTENT_EXPORT
const content::BackgroundFetchRegistration& registration) {
return registration.title;
}
- static int64_t total_download_size(
- const content::BackgroundFetchRegistration& registration) {
- return registration.total_download_size;
- }
static bool Read(blink::mojom::BackgroundFetchRegistrationDataView data,
content::BackgroundFetchRegistration* registration);
diff --git a/chromium/content/common/background_fetch/background_fetch_struct_traits_unittest.cc b/chromium/content/common/background_fetch/background_fetch_struct_traits_unittest.cc
index c44f4aea87c..3d46714493a 100644
--- a/chromium/content/common/background_fetch/background_fetch_struct_traits_unittest.cc
+++ b/chromium/content/common/background_fetch/background_fetch_struct_traits_unittest.cc
@@ -40,7 +40,7 @@ TEST(BackgroundFetchStructTraitsTest, BackgroundFetchOptionsRoundtrip) {
CreateIconDefinition("my_icon.png", "256x256", "image/png"),
CreateIconDefinition("my_small_icon.jpg", "128x128", "image/jpg")};
options.title = "My Background Fetch";
- options.total_download_size = 9001;
+ options.download_total = 9001;
BackgroundFetchOptions roundtrip_options;
ASSERT_TRUE(blink::mojom::BackgroundFetchOptions::Deserialize(
@@ -54,24 +54,26 @@ TEST(BackgroundFetchStructTraitsTest, BackgroundFetchOptionsRoundtrip) {
}
EXPECT_EQ(roundtrip_options.title, options.title);
- EXPECT_EQ(roundtrip_options.total_download_size, options.total_download_size);
+ EXPECT_EQ(roundtrip_options.download_total, options.download_total);
}
TEST(BackgroundFetchStructTraitsTest, BackgroundFetchRegistrationRoundTrip) {
BackgroundFetchRegistration registration;
- registration.id = "my_id";
+ registration.developer_id = "my_id";
+ registration.unique_id = "7e57ab1e-c0de-a150-ca75-1e75f005ba11";
registration.icons = {
CreateIconDefinition("my_icon.png", "256x256", "image/png"),
CreateIconDefinition("my_small_icon.jpg", "128x128", "image/jpg")};
registration.title = "My Background Fetch";
- registration.total_download_size = 9001;
+ registration.download_total = 9001;
BackgroundFetchRegistration roundtrip_registration;
ASSERT_TRUE(blink::mojom::BackgroundFetchRegistration::Deserialize(
blink::mojom::BackgroundFetchRegistration::Serialize(&registration),
&roundtrip_registration));
- EXPECT_EQ(roundtrip_registration.id, registration.id);
+ EXPECT_EQ(roundtrip_registration.developer_id, registration.developer_id);
+ EXPECT_EQ(roundtrip_registration.unique_id, registration.unique_id);
ASSERT_EQ(roundtrip_registration.icons.size(), registration.icons.size());
for (size_t i = 0; i < registration.icons.size(); ++i) {
@@ -80,8 +82,7 @@ TEST(BackgroundFetchStructTraitsTest, BackgroundFetchRegistrationRoundTrip) {
}
EXPECT_EQ(roundtrip_registration.title, registration.title);
- EXPECT_EQ(roundtrip_registration.total_download_size,
- registration.total_download_size);
+ EXPECT_EQ(roundtrip_registration.download_total, registration.download_total);
}
TEST(BackgroundFetchStructTraitsTest, IconDefinitionRoundtrip) {
diff --git a/chromium/content/common/background_fetch/background_fetch_types.h b/chromium/content/common/background_fetch/background_fetch_types.h
index 9286000226f..8e57e36644d 100644
--- a/chromium/content/common/background_fetch/background_fetch_types.h
+++ b/chromium/content/common/background_fetch/background_fetch_types.h
@@ -41,7 +41,7 @@ struct CONTENT_EXPORT BackgroundFetchOptions {
std::vector<IconDefinition> icons;
std::string title;
- int64_t total_download_size = 0;
+ uint64_t download_total = 0;
};
// Represents the information associated with a Background Fetch registration.
@@ -52,12 +52,23 @@ struct CONTENT_EXPORT BackgroundFetchRegistration {
BackgroundFetchRegistration(const BackgroundFetchRegistration& other);
~BackgroundFetchRegistration();
- std::string id;
+ // Corresponds to IDL 'id' attribute. Not unique - an active registration can
+ // have the same |developer_id| as one or more inactive registrations.
+ std::string developer_id;
+ // Globally unique ID for the registration, generated in content/. Used to
+ // distinguish registrations in case a developer re-uses |developer_id|s. Not
+ // exposed to JavaScript.
+ std::string unique_id;
+
+ uint64_t upload_total = 0;
+ uint64_t uploaded = 0;
+ uint64_t download_total = 0;
+ uint64_t downloaded = 0;
+ // TODO(crbug.com/699957): Support the `activeFetches` member.
+
+ // TODO(crbug.com/769770): Remove the following deprecated members.
std::vector<IconDefinition> icons;
std::string title;
- int64_t total_download_size = 0;
-
- // TODO(peter): Support the `activeFetches` member of the specification.
};
// Represents a request/response pair for a settled Background Fetch fetch.
diff --git a/chromium/content/common/browser_plugin/browser_plugin_messages.h b/chromium/content/common/browser_plugin/browser_plugin_messages.h
index 12584230f4e..c147db29a90 100644
--- a/chromium/content/common/browser_plugin/browser_plugin_messages.h
+++ b/chromium/content/common/browser_plugin/browser_plugin_messages.h
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Multiply-included message header, no traditional include guard.
+#ifndef CONTENT_COMMON_BROWSER_PLUGIN_BROWSER_PLUGIN_MESSAGES_H_
+#define CONTENT_COMMON_BROWSER_PLUGIN_BROWSER_PLUGIN_MESSAGES_H_
#include <string>
#include "base/process/process.h"
+#include "cc/ipc/cc_param_traits.h"
#include "components/viz/common/surfaces/surface_info.h"
#include "content/common/content_export.h"
#include "content/common/content_param_traits.h"
@@ -151,9 +153,10 @@ IPC_MESSAGE_CONTROL1(BrowserPluginHostMsg_UnlockMouse_ACK,
int /* browser_plugin_instance_id */)
// Sent when plugin's position has changed.
-IPC_MESSAGE_CONTROL2(BrowserPluginHostMsg_UpdateGeometry,
+IPC_MESSAGE_CONTROL3(BrowserPluginHostMsg_UpdateGeometry,
int /* browser_plugin_instance_id */,
- gfx::Rect /* view_rect */)
+ gfx::Rect /* view_rect */,
+ viz::LocalSurfaceId /* local_surface_id */)
IPC_MESSAGE_ROUTED2(BrowserPluginHostMsg_SatisfySequence,
int /* browser_plugin_instance_id */,
@@ -172,8 +175,9 @@ IPC_MESSAGE_ROUTED3(BrowserPluginHostMsg_RequireSequence,
IPC_MESSAGE_CONTROL1(BrowserPluginMsg_GuestGone,
int /* browser_plugin_instance_id */)
-IPC_MESSAGE_CONTROL1(BrowserPluginMsg_GuestReady,
- int /* browser_plugin_instance_id */)
+IPC_MESSAGE_CONTROL2(BrowserPluginMsg_GuestReady,
+ int /* browser_plugin_instance_id */,
+ viz::FrameSinkId /* frame_sink_id */)
// When the user tabs to the end of the tab stops of a guest, the browser
// process informs the embedder to tab out of the browser plugin.
@@ -206,3 +210,5 @@ IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetMouseLock,
IPC_MESSAGE_CONTROL2(BrowserPluginMsg_SetTooltipText,
int /* browser_plugin_instance_id */,
base::string16 /* tooltip_text */)
+
+#endif // CONTENT_COMMON_BROWSER_PLUGIN_BROWSER_PLUGIN_MESSAGES_H_
diff --git a/chromium/content/common/cache_storage/cache_storage_messages.h b/chromium/content/common/cache_storage/cache_storage_messages.h
index 5f2584f3502..5bf579ec5f9 100644
--- a/chromium/content/common/cache_storage/cache_storage_messages.h
+++ b/chromium/content/common/cache_storage/cache_storage_messages.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Message definition file, included multiple times, hence no include guard.
+#ifndef CONTENT_COMMON_CACHE_STORAGE_CACHE_STORAGE_MESSAGES_H_
+#define CONTENT_COMMON_CACHE_STORAGE_CACHE_STORAGE_MESSAGES_H_
#include <string>
#include <vector>
@@ -191,3 +192,5 @@ IPC_MESSAGE_CONTROL3(CacheStorageMsg_CacheBatchError,
int /* thread_id */,
int /* request_id */,
blink::WebServiceWorkerCacheError)
+
+#endif // CONTENT_COMMON_CACHE_STORAGE_CACHE_STORAGE_MESSAGES_H_
diff --git a/chromium/content/common/child_process_host_impl.cc b/chromium/content/common/child_process_host_impl.cc
index be4bae9eecb..55ba42c8c38 100644
--- a/chromium/content/common/child_process_host_impl.cc
+++ b/chromium/content/common/child_process_host_impl.cc
@@ -187,8 +187,7 @@ uint64_t ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId(
// The hash value is incremented so that the tracing id is never equal to
// MemoryDumpManager::kInvalidTracingProcessId.
return static_cast<uint64_t>(
- base::Hash(reinterpret_cast<const char*>(&child_process_id),
- sizeof(child_process_id))) +
+ base::Hash(&child_process_id, sizeof(child_process_id))) +
1;
}
diff --git a/chromium/content/common/child_process_messages.h b/chromium/content/common/child_process_messages.h
index 90227084c30..0d955a33036 100644
--- a/chromium/content/common/child_process_messages.h
+++ b/chromium/content/common/child_process_messages.h
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_CHILD_PROCESS_MESSAGES_H_
+#define CONTENT_COMMON_CHILD_PROCESS_MESSAGES_H_
+
// Common IPC messages used for child processes.
-// Multiply-included message file, hence no include guard.
#include <stdint.h>
@@ -11,7 +13,6 @@
#include <vector>
#include "base/memory/shared_memory.h"
-#include "base/tracked_objects.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/viz/common/resources/shared_bitmap_manager.h"
@@ -31,51 +32,12 @@
#include "base/threading/platform_thread.h"
#endif
-IPC_ENUM_TRAITS_MAX_VALUE(tracked_objects::ThreadData::Status,
- tracked_objects::ThreadData::STATUS_LAST)
-
-IPC_STRUCT_TRAITS_BEGIN(tracked_objects::LocationSnapshot)
+IPC_STRUCT_TRAITS_BEGIN(base::LocationSnapshot)
IPC_STRUCT_TRAITS_MEMBER(file_name)
IPC_STRUCT_TRAITS_MEMBER(function_name)
IPC_STRUCT_TRAITS_MEMBER(line_number)
IPC_STRUCT_TRAITS_END()
-IPC_STRUCT_TRAITS_BEGIN(tracked_objects::BirthOnThreadSnapshot)
- IPC_STRUCT_TRAITS_MEMBER(location)
- IPC_STRUCT_TRAITS_MEMBER(sanitized_thread_name)
-IPC_STRUCT_TRAITS_END()
-
-IPC_STRUCT_TRAITS_BEGIN(tracked_objects::DeathDataSnapshot)
- IPC_STRUCT_TRAITS_MEMBER(count)
- IPC_STRUCT_TRAITS_MEMBER(run_duration_sum)
- IPC_STRUCT_TRAITS_MEMBER(run_duration_max)
- IPC_STRUCT_TRAITS_MEMBER(run_duration_sample)
- IPC_STRUCT_TRAITS_MEMBER(queue_duration_sum)
- IPC_STRUCT_TRAITS_MEMBER(queue_duration_max)
- IPC_STRUCT_TRAITS_MEMBER(queue_duration_sample)
- IPC_STRUCT_TRAITS_MEMBER(alloc_ops)
- IPC_STRUCT_TRAITS_MEMBER(free_ops)
- IPC_STRUCT_TRAITS_MEMBER(allocated_bytes)
- IPC_STRUCT_TRAITS_MEMBER(freed_bytes)
- IPC_STRUCT_TRAITS_MEMBER(alloc_overhead_bytes)
- IPC_STRUCT_TRAITS_MEMBER(max_allocated_bytes)
-IPC_STRUCT_TRAITS_END()
-
-IPC_STRUCT_TRAITS_BEGIN(tracked_objects::TaskSnapshot)
- IPC_STRUCT_TRAITS_MEMBER(birth)
- IPC_STRUCT_TRAITS_MEMBER(death_data)
- IPC_STRUCT_TRAITS_MEMBER(death_sanitized_thread_name)
-IPC_STRUCT_TRAITS_END()
-
-IPC_STRUCT_TRAITS_BEGIN(tracked_objects::ProcessDataPhaseSnapshot)
- IPC_STRUCT_TRAITS_MEMBER(tasks)
-IPC_STRUCT_TRAITS_END()
-
-IPC_STRUCT_TRAITS_BEGIN(tracked_objects::ProcessDataSnapshot)
- IPC_STRUCT_TRAITS_MEMBER(phased_snapshots)
- IPC_STRUCT_TRAITS_MEMBER(process_id)
-IPC_STRUCT_TRAITS_END()
-
#if defined(OS_LINUX)
IPC_ENUM_TRAITS_MAX_VALUE(base::ThreadPriority,
base::ThreadPriority::REALTIME_AUDIO)
@@ -98,33 +60,6 @@ IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetIPCLoggingEnabled,
bool /* on or off */)
#endif
-// Tell the child process to enable or disable the profiler status.
-IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetProfilerStatus,
- tracked_objects::ThreadData::Status /* profiler status */)
-
-// Send to all the child processes to send back profiler data (ThreadData in
-// tracked_objects).
-IPC_MESSAGE_CONTROL2(ChildProcessMsg_GetChildProfilerData,
- int /* sequence_number */,
- int /* current_profiling_phase */)
-
-// Send to all the child processes to mark the current profiling phase as
-// finished and start a new phase.
-IPC_MESSAGE_CONTROL1(ChildProcessMsg_ProfilingPhaseCompleted,
- int /* profiling_phase */)
-
-// Sent to set the shared memory buffer to be used for storing histograms that
-// are to be reported by the browser process to UMA. The following message
-// (GetChildNonPersistentHistogramData) will return any histograms created
-// before this message is received but not any histograms created afterward.
-IPC_MESSAGE_CONTROL2(ChildProcessMsg_SetHistogramMemory,
- base::SharedMemoryHandle /* shm_handle */,
- int /* shm_size */)
-
-// Send to all the child processes to send back histogram data.
-IPC_MESSAGE_CONTROL1(ChildProcessMsg_GetChildNonPersistentHistogramData,
- int /* sequence_number */)
-
// Sent to child processes to tell them to enter or leave background mode.
IPC_MESSAGE_CONTROL1(ChildProcessMsg_SetProcessBackgrounded,
bool /* background */)
@@ -144,17 +79,6 @@ IPC_SYNC_MESSAGE_CONTROL0_1(ChildProcessHostMsg_HasGpuProcess,
IPC_MESSAGE_CONTROL0(ChildProcessHostMsg_ShutdownRequest)
-// Send back profiler data (ThreadData in tracked_objects).
-IPC_MESSAGE_CONTROL2(
- ChildProcessHostMsg_ChildProfilerData,
- int, /* sequence_number */
- tracked_objects::ProcessDataSnapshot /* process_data_snapshot */)
-
-// Send back histograms as vector of pickled-histogram strings.
-IPC_MESSAGE_CONTROL2(ChildProcessHostMsg_ChildHistogramData,
- int, /* sequence_number */
- std::vector<std::string> /* histogram_data */)
-
// Request a histogram from the browser. The browser will send the histogram
// data only if it has been passed the command line flag
// switches::kDomAutomationController.
@@ -178,3 +102,5 @@ IPC_MESSAGE_CONTROL2(ChildProcessHostMsg_SetThreadPriority,
base::PlatformThreadId,
base::ThreadPriority)
#endif
+
+#endif // CONTENT_COMMON_CHILD_PROCESS_MESSAGES_H_
diff --git a/chromium/content/common/clipboard_messages.h b/chromium/content/common/clipboard_messages.h
index f026d7c27aa..3b3d1be12cf 100644
--- a/chromium/content/common/clipboard_messages.h
+++ b/chromium/content/common/clipboard_messages.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Multiply-included message file, so no include guard.
+#ifndef CONTENT_COMMON_CLIPBOARD_MESSAGES_H_
+#define CONTENT_COMMON_CLIPBOARD_MESSAGES_H_
#include <stdint.h>
@@ -23,15 +24,15 @@
#include "url/ipc/url_param_traits.h"
// Singly-included section for types and/or struct declarations.
-#ifndef CONTENT_COMMON_CLIPBOARD_MESSAGES_H_
-#define CONTENT_COMMON_CLIPBOARD_MESSAGES_H_
+#ifndef INTERNAL_CONTENT_COMMON_CLIPBOARD_MESSAGES_H_
+#define INTERNAL_CONTENT_COMMON_CLIPBOARD_MESSAGES_H_
// Custom data consists of arbitrary MIME types an untrusted sender wants to
// write to the clipboard. Note that exposing a general interface to do this is
// dangerous--an untrusted sender could cause a DoS or code execution.
typedef std::map<base::string16, base::string16> CustomDataMap;
-#endif // CONTENT_COMMON_CLIPBOARD_MESSAGES_H_
+#endif // INTERNAL_CONTENT_COMMON_CLIPBOARD_MESSAGES_H_
#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
@@ -112,3 +113,5 @@ IPC_MESSAGE_CONTROL1(ClipboardHostMsg_CommitWrite, ui::ClipboardType /* type */)
IPC_MESSAGE_CONTROL1(ClipboardHostMsg_FindPboardWriteStringAsync,
base::string16 /* text */)
#endif
+
+#endif // CONTENT_COMMON_CLIPBOARD_MESSAGES_H_
diff --git a/chromium/content/common/common.sb b/chromium/content/common/common.sb
deleted file mode 100644
index f8fe48b2c5b..00000000000
--- a/chromium/content/common/common.sb
+++ /dev/null
@@ -1,56 +0,0 @@
-;;
-;; Copyright (c) 2012 The Chromium Authors. All rights reserved.
-;; Use of this source code is governed by a BSD-style license that can be
-;; found in the LICENSE file.
-;;
-; This configuration file isn't used on it's own, but instead implicitly
-; included at the start of all other sandbox configuration files in Chrome.
-(version 1)
-
-; Helper function to check if a param is set to true.
-(define (param-true? str) (string=? (param str) "TRUE"))
-
-; Helper function to determine if a parameter is defined or not.
-(define (param-defined? str) (string? (param str)))
-
-; Define constants for all of the parameter strings passed in.
-(define disable-sandbox-denial-logging "DISABLE_SANDBOX_DENIAL_LOGGING")
-(define enable-logging "ENABLE_LOGGING")
-(define permitted-dir "PERMITTED_DIR")
-(define homedir-as-literal "USER_HOMEDIR_AS_LITERAL")
-(define elcap-or-later "ELCAP_OR_LATER")
-(define macos-1013 "MACOS_1013")
-
-; Consumes a subpath and appends it to the user's homedir path.
-(define (user-homedir-path subpath)
- (string-append (param homedir-as-literal) subpath))
-
-; (path) is not supported until 10.10.
-; TODO(kerrnel): remove this when 10.9 is no longer supported.
-(define (path x) (literal x))
-
-; DISABLE_SANDBOX_DENIAL_LOGGING turns off log messages in the system log.
-(if (param-true? disable-sandbox-denial-logging)
- (deny default (with no-log))
- (deny default))
-
-; Support for programmatically enabling verbose debugging.
-(if (param-true? enable-logging) (debug deny))
-
-; Allow sending signals to self - https://crbug.com/20370
-(allow signal (target self))
-
-; Needed for full-page-zoomed controls - https://crbug.com/11325
-(allow sysctl-read)
-
-; Loading System Libraries.
-(allow file-read*
- (subpath "/System/Library/Frameworks")
- (subpath "/System/Library/PrivateFrameworks")
- (subpath "/System/Library/CoreServices"))
-
-(allow ipc-posix-shm)
-
-; Allow direct access to /dev/urandom, similar to Linux/POSIX, to allow
-; third party code (eg: bits of Adobe Flash and NSS) to function properly.
-(allow file-read-data file-read-metadata (literal "/dev/urandom"))
diff --git a/chromium/content/common/common_param_traits_unittest.cc b/chromium/content/common/common_param_traits_unittest.cc
index 05d0cb80af4..ea3ac26a2c4 100644
--- a/chromium/content/common/common_param_traits_unittest.cc
+++ b/chromium/content/common/common_param_traits_unittest.cc
@@ -50,7 +50,7 @@ TEST(IPCMessageTest, Bitmap) {
SkBitmap bitmap;
bitmap.allocN32Pixels(10, 5);
- memset(bitmap.getPixels(), 'A', bitmap.getSize());
+ memset(bitmap.getPixels(), 'A', bitmap.computeByteSize());
IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
IPC::ParamTraits<SkBitmap>::Write(&msg, bitmap);
@@ -63,9 +63,10 @@ TEST(IPCMessageTest, Bitmap) {
EXPECT_EQ(bitmap.width(), output.width());
EXPECT_EQ(bitmap.height(), output.height());
EXPECT_EQ(bitmap.rowBytes(), output.rowBytes());
- EXPECT_EQ(bitmap.getSize(), output.getSize());
- EXPECT_EQ(memcmp(bitmap.getPixels(), output.getPixels(), bitmap.getSize()),
- 0);
+ EXPECT_EQ(bitmap.computeByteSize(), output.computeByteSize());
+ EXPECT_EQ(
+ memcmp(bitmap.getPixels(), output.getPixels(), bitmap.computeByteSize()),
+ 0);
// Also test the corrupt case.
IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL);
@@ -76,7 +77,7 @@ TEST(IPCMessageTest, Bitmap) {
EXPECT_TRUE(iter.ReadData(&fixed_data, &fixed_data_size));
bad_msg.WriteData(fixed_data, fixed_data_size);
// Add some bogus pixel data.
- const size_t bogus_pixels_size = bitmap.getSize() * 2;
+ const size_t bogus_pixels_size = bitmap.computeByteSize() * 2;
std::unique_ptr<char[]> bogus_pixels(new char[bogus_pixels_size]);
memset(bogus_pixels.get(), 'B', bogus_pixels_size);
bad_msg.WriteData(bogus_pixels.get(), bogus_pixels_size);
diff --git a/chromium/content/common/content_message_generator.cc b/chromium/content/common/content_message_generator.cc
index 621b832345c..2e2b5a63634 100644
--- a/chromium/content/common/content_message_generator.cc
+++ b/chromium/content/common/content_message_generator.cc
@@ -14,12 +14,6 @@
#include "ipc/struct_destructor_macros.h"
#include "content/common/content_message_generator.h"
-// Generate param traits size methods.
-#include "ipc/param_traits_size_macros.h"
-namespace IPC {
-#include "content/common/content_message_generator.h"
-}
-
// Generate param traits write methods.
#include "ipc/param_traits_write_macros.h"
namespace IPC {
diff --git a/chromium/content/common/content_message_generator.h b/chromium/content/common/content_message_generator.h
index 9386b8f19b8..ef635e6024f 100644
--- a/chromium/content/common/content_message_generator.h
+++ b/chromium/content/common/content_message_generator.h
@@ -4,54 +4,197 @@
// Multiply-included file, hence no include guard.
+#undef CONTENT_COMMON_CHILD_PROCESS_MESSAGES_H_
#include "content/common/child_process_messages.h"
+#ifndef CONTENT_COMMON_CHILD_PROCESS_MESSAGES_H_
+#error "Failed to include content/common/child_process_messages.h"
+#endif
#include "build/build_config.h"
+#undef CONTENT_COMMON_ACCESSIBILITY_MESSAGES_H_
#include "content/common/accessibility_messages.h"
+#ifndef CONTENT_COMMON_ACCESSIBILITY_MESSAGES_H_
+#error "Failed to include content/common/accessibility_messages.h"
+#endif
+#undef CONTENT_COMMON_APPCACHE_MESSAGES_H_
#include "content/common/appcache_messages.h"
+#ifndef CONTENT_COMMON_APPCACHE_MESSAGES_H_
+#error "Failed to include content/common/appcache_messages.h"
+#endif
+#undef CONTENT_COMMON_BROWSER_PLUGIN_BROWSER_PLUGIN_MESSAGES_H_
#include "content/common/browser_plugin/browser_plugin_messages.h"
+#ifndef CONTENT_COMMON_BROWSER_PLUGIN_BROWSER_PLUGIN_MESSAGES_H_
+#error \
+ "Failed to include content/common/browser_plugin/browser_plugin_messages.h"
+#endif
+#undef CONTENT_COMMON_CACHE_STORAGE_CACHE_STORAGE_MESSAGES_H_
#include "content/common/cache_storage/cache_storage_messages.h"
+#ifndef CONTENT_COMMON_CACHE_STORAGE_CACHE_STORAGE_MESSAGES_H_
+#error "Failed to include content/common/cache_storage/cache_storage_messages.h"
+#endif
+#undef CONTENT_COMMON_CLIPBOARD_MESSAGES_H_
#include "content/common/clipboard_messages.h"
-#include "content/common/database_messages.h"
+#ifndef CONTENT_COMMON_CLIPBOARD_MESSAGES_H_
+#error "Failed to include content/common/clipboard_messages.h"
+#endif
+#undef CONTENT_COMMON_DEVTOOLS_MESSAGES_H_
#include "content/common/devtools_messages.h"
+#ifndef CONTENT_COMMON_DEVTOOLS_MESSAGES_H_
+#error "Failed to include content/common/devtools_messages.h"
+#endif
+#undef CONTENT_COMMON_DOM_STORAGE_DOM_STORAGE_MESSAGES_H_
#include "content/common/dom_storage/dom_storage_messages.h"
+#ifndef CONTENT_COMMON_DOM_STORAGE_DOM_STORAGE_MESSAGES_H_
+#error "Failed to include content/common/dom_storage/dom_storage_messages.h"
+#endif
+#undef CONTENT_COMMON_DRAG_MESSAGES_H_
#include "content/common/drag_messages.h"
+#ifndef CONTENT_COMMON_DRAG_MESSAGES_H_
+#error "Failed to include content/common/drag_messages.h"
+#endif
#include "content/common/drag_traits.h"
-#include "content/common/file_utilities_messages.h"
+#undef CONTENT_COMMON_FILEAPI_FILE_SYSTEM_MESSAGES_H_
#include "content/common/fileapi/file_system_messages.h"
+#ifndef CONTENT_COMMON_FILEAPI_FILE_SYSTEM_MESSAGES_H_
+#error "Failed to include content/common/fileapi/file_system_messages.h"
+#endif
+#undef CONTENT_COMMON_FILEAPI_WEBBLOB_MESSAGES_H_
#include "content/common/fileapi/webblob_messages.h"
+#ifndef CONTENT_COMMON_FILEAPI_WEBBLOB_MESSAGES_H_
+#error "Failed to include content/common/fileapi/webblob_messages.h"
+#endif
+#undef CONTENT_COMMON_FRAME_MESSAGES_H_
#include "content/common/frame_messages.h"
+#ifndef CONTENT_COMMON_FRAME_MESSAGES_H_
+#error "Failed to include content/common/frame_messages.h"
+#endif
+#undef CONTENT_COMMON_INPUT_MESSAGES_H_
#include "content/common/input_messages.h"
+#ifndef CONTENT_COMMON_INPUT_MESSAGES_H_
+#error "Failed to include content/common/input_messages.h"
+#endif
+#undef CONTENT_COMMON_MEDIA_AEC_DUMP_MESSAGES_H_
#include "content/common/media/aec_dump_messages.h"
+#ifndef CONTENT_COMMON_MEDIA_AEC_DUMP_MESSAGES_H_
+#error "Failed to include content/common/media/aec_dump_messages.h"
+#endif
+#undef CONTENT_COMMON_MEDIA_AUDIO_MESSAGES_H_
#include "content/common/media/audio_messages.h"
+#ifndef CONTENT_COMMON_MEDIA_AUDIO_MESSAGES_H_
+#error "Failed to include content/common/media/audio_messages.h"
+#endif
+#undef CONTENT_COMMON_MEDIA_MEDIA_PLAYER_DELEGATE_MESSAGES_H_
#include "content/common/media/media_player_delegate_messages.h"
+#ifndef CONTENT_COMMON_MEDIA_MEDIA_PLAYER_DELEGATE_MESSAGES_H_
+#error "Failed to include content/common/media/media_player_delegate_messages.h"
+#endif
+#undef CONTENT_COMMON_MEDIA_MEDIA_STREAM_TRACK_METRICS_HOST_MESSAGES_H_
#include "content/common/media/media_stream_track_metrics_host_messages.h"
+#ifndef CONTENT_COMMON_MEDIA_MEDIA_STREAM_TRACK_METRICS_HOST_MESSAGES_H_
+#error \
+ "Failed to include content/common/media/media_stream_track_metrics_host_messages.h"
+#endif
+#undef CONTENT_COMMON_MEDIA_MIDI_MESSAGES_H_
#include "content/common/media/midi_messages.h"
+#ifndef CONTENT_COMMON_MEDIA_MIDI_MESSAGES_H_
+#error "Failed to include content/common/media/midi_messages.h"
+#endif
+#undef CONTENT_COMMON_MEDIA_PEER_CONNECTION_TRACKER_MESSAGES_H_
#include "content/common/media/peer_connection_tracker_messages.h"
+#ifndef CONTENT_COMMON_MEDIA_PEER_CONNECTION_TRACKER_MESSAGES_H_
+#error \
+ "Failed to include content/common/media/peer_connection_tracker_messages.h"
+#endif
+#undef CONTENT_COMMON_PAGE_MESSAGES_H_
#include "content/common/page_messages.h"
+#ifndef CONTENT_COMMON_PAGE_MESSAGES_H_
+#error "Failed to include content/common/page_messages.h"
+#endif
+#undef CONTENT_COMMON_PLATFORM_NOTIFICATION_MESSAGES_H_
#include "content/common/platform_notification_messages.h"
+#ifndef CONTENT_COMMON_PLATFORM_NOTIFICATION_MESSAGES_H_
+#error "Failed to include content/common/platform_notification_messages.h"
+#endif
+#undef CONTENT_COMMON_QUOTA_MESSAGES_H_
#include "content/common/quota_messages.h"
+#ifndef CONTENT_COMMON_QUOTA_MESSAGES_H_
+#error "Failed to include content/common/quota_messages.h"
+#endif
+#undef CONTENT_COMMON_RENDER_PROCESS_MESSAGES_H_
#include "content/common/render_process_messages.h"
+#ifndef CONTENT_COMMON_RENDER_PROCESS_MESSAGES_H_
+#error "Failed to include content/common/render_process_messages.h"
+#endif
+#undef CONTENT_COMMON_RESOURCE_MESSAGES_H_
#include "content/common/resource_messages.h"
+#ifndef CONTENT_COMMON_RESOURCE_MESSAGES_H_
+#error "Failed to include content/common/resource_messages.h"
+#endif
+#undef CONTENT_COMMON_SERVICE_WORKER_EMBEDDED_WORKER_MESSAGES_H_
#include "content/common/service_worker/embedded_worker_messages.h"
+#ifndef CONTENT_COMMON_SERVICE_WORKER_EMBEDDED_WORKER_MESSAGES_H_
+#error \
+ "Failed to include content/common/service_worker/embedded_worker_messages.h"
+#endif
+#undef CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_MESSAGES_H_
#include "content/common/service_worker/service_worker_messages.h"
+#ifndef CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_MESSAGES_H_
+#error \
+ "Failed to include content/common/service_worker/service_worker_messages.h"
+#endif
+#undef CONTENT_COMMON_SPEECH_RECOGNITION_MESSAGES_H_
#include "content/common/speech_recognition_messages.h"
+#ifndef CONTENT_COMMON_SPEECH_RECOGNITION_MESSAGES_H_
+#error "Failed to include content/common/speech_recognition_messages.h"
+#endif
+#undef CONTENT_COMMON_TEXT_INPUT_CLIENT_MESSAGES_H_
#include "content/common/text_input_client_messages.h"
+#ifndef CONTENT_COMMON_TEXT_INPUT_CLIENT_MESSAGES_H_
+#error "Failed to include content/common/text_input_client_messages.h"
+#endif
+#undef CONTENT_COMMON_VIEW_MESSAGES_H_
#include "content/common/view_messages.h"
-#include "content/common/worker_messages.h"
+#ifndef CONTENT_COMMON_VIEW_MESSAGES_H_
+#error "Failed to include content/common/view_messages.h"
+#endif
#include "media/media_features.h"
#if BUILDFLAG(ENABLE_WEBRTC)
+#undef CONTENT_COMMON_P2P_MESSAGES_H_
#include "content/common/p2p_messages.h"
+#ifndef CONTENT_COMMON_P2P_MESSAGES_H_
+#error "Failed to include content/common/p2p_messages.h"
+#endif
#endif
#if defined(OS_ANDROID)
+#undef CONTENT_COMMON_ANDROID_SYNC_COMPOSITOR_MESSAGES_H_
#include "content/common/android/sync_compositor_messages.h"
+#ifndef CONTENT_COMMON_ANDROID_SYNC_COMPOSITOR_MESSAGES_H_
+#error "Failed to include content/common/android/sync_compositor_messages.h"
+#endif
+#undef CONTENT_COMMON_GIN_JAVA_BRIDGE_MESSAGES_H_
#include "content/common/gin_java_bridge_messages.h"
+#ifndef CONTENT_COMMON_GIN_JAVA_BRIDGE_MESSAGES_H_
+#error "Failed to include content/common/gin_java_bridge_messages.h"
+#endif
+#undef CONTENT_COMMON_MEDIA_MEDIA_PLAYER_MESSAGES_ANDROID_H_
#include "content/common/media/media_player_messages_android.h"
+#ifndef CONTENT_COMMON_MEDIA_MEDIA_PLAYER_MESSAGES_ANDROID_H_
+#error "Failed to include content/common/media/media_player_messages_android.h"
+#endif
+#undef CONTENT_COMMON_MEDIA_SURFACE_VIEW_MANAGER_MESSAGES_ANDROID_H_
#include "content/common/media/surface_view_manager_messages_android.h"
+#ifndef CONTENT_COMMON_MEDIA_SURFACE_VIEW_MANAGER_MESSAGES_ANDROID_H_
+#error \
+ "Failed to include content/common/media/surface_view_manager_messages_android.h"
+#endif
#endif // defined(OS_ANDROID)
#if defined(OS_WIN)
+#undef CONTENT_COMMON_DWRITE_FONT_PROXY_MESSAGES_H_
#include "content/common/dwrite_font_proxy_messages.h"
+#ifndef CONTENT_COMMON_DWRITE_FONT_PROXY_MESSAGES_H_
+#error "Failed to include content/common/dwrite_font_proxy_messages.h"
+#endif
#endif // defined(OS_WIN)
diff --git a/chromium/content/common/content_param_traits.cc b/chromium/content/common/content_param_traits.cc
index 89fdec94b79..81ed82b7cc0 100644
--- a/chromium/content/common/content_param_traits.cc
+++ b/chromium/content/common/content_param_traits.cc
@@ -7,20 +7,15 @@
#include <stddef.h>
#include "base/strings/string_number_conversions.h"
-#include "content/common/message_port.h"
#include "ipc/ipc_mojo_message_helper.h"
#include "ipc/ipc_mojo_param_traits.h"
#include "net/base/ip_endpoint.h"
+#include "third_party/WebKit/common/message_port/message_port_channel.h"
#include "ui/accessibility/ax_modes.h"
#include "ui/events/blink/web_input_event_traits.h"
namespace IPC {
-void ParamTraits<WebInputEventPointer>::GetSize(base::PickleSizer* s,
- const param_type& p) {
- s->AddData(p->size());
-}
-
void ParamTraits<WebInputEventPointer>::Write(base::Pickle* m,
const param_type& p) {
m->WriteData(reinterpret_cast<const char*>(p), p->size());
@@ -66,35 +61,23 @@ void ParamTraits<WebInputEventPointer>::Log(const param_type& p,
l->append(")");
}
-void ParamTraits<content::MessagePort>::GetSize(base::PickleSizer* s,
- const param_type& p) {
- ParamTraits<mojo::MessagePipeHandle>::GetSize(s, p.GetHandle().get());
-}
-
-void ParamTraits<content::MessagePort>::Write(base::Pickle* m,
- const param_type& p) {
+void ParamTraits<blink::MessagePortChannel>::Write(base::Pickle* m,
+ const param_type& p) {
ParamTraits<mojo::MessagePipeHandle>::Write(m, p.ReleaseHandle().release());
}
-bool ParamTraits<content::MessagePort>::Read(
- const base::Pickle* m,
- base::PickleIterator* iter,
- param_type* r) {
+bool ParamTraits<blink::MessagePortChannel>::Read(const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* r) {
mojo::MessagePipeHandle handle;
if (!ParamTraits<mojo::MessagePipeHandle>::Read(m, iter, &handle))
return false;
- *r = content::MessagePort(mojo::ScopedMessagePipeHandle(handle));
+ *r = blink::MessagePortChannel(mojo::ScopedMessagePipeHandle(handle));
return true;
}
-void ParamTraits<content::MessagePort>::Log(const param_type& p,
- std::string* l) {
-}
-
-void ParamTraits<ui::AXMode>::GetSize(base::PickleSizer* s,
- const param_type& p) {
- IPC::GetParamSize(s, p.mode());
-}
+void ParamTraits<blink::MessagePortChannel>::Log(const param_type& p,
+ std::string* l) {}
void ParamTraits<ui::AXMode>::Write(base::Pickle* m, const param_type& p) {
IPC::WriteParam(m, p.mode());
@@ -112,16 +95,6 @@ bool ParamTraits<ui::AXMode>::Read(const base::Pickle* m,
void ParamTraits<ui::AXMode>::Log(const param_type& p, std::string* l) {}
-void ParamTraits<scoped_refptr<storage::BlobHandle>>::GetSize(
- base::PickleSizer* s,
- const param_type& p) {
- s->AddBool();
- if (p) {
- s->AddUInt32();
- s->AddAttachment();
- }
-}
-
void ParamTraits<scoped_refptr<storage::BlobHandle>>::Write(
base::Pickle* m,
const param_type& p) {
@@ -163,13 +136,6 @@ void ParamTraits<scoped_refptr<storage::BlobHandle>>::Log(const param_type& p,
} // namespace IPC
-// Generate param traits size methods.
-#include "ipc/param_traits_size_macros.h"
-namespace IPC {
-#undef CONTENT_COMMON_CONTENT_PARAM_TRAITS_MACROS_H_
-#include "content/common/content_param_traits_macros.h"
-}
-
// Generate param traits write methods.
#include "ipc/param_traits_write_macros.h"
namespace IPC {
diff --git a/chromium/content/common/content_param_traits.h b/chromium/content/common/content_param_traits.h
index c16267ea227..22a478242ec 100644
--- a/chromium/content/common/content_param_traits.h
+++ b/chromium/content/common/content_param_traits.h
@@ -21,8 +21,8 @@
#include "third_party/WebKit/public/platform/WebInputEvent.h"
#include "ui/accessibility/ax_modes.h"
-namespace content {
-class MessagePort;
+namespace blink {
+class MessagePortChannel;
}
namespace IPC {
@@ -45,7 +45,6 @@ typedef const blink::WebInputEvent* WebInputEventPointer;
template <>
struct ParamTraits<WebInputEventPointer> {
typedef WebInputEventPointer param_type;
- static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
// Note: upon read, the event has the lifetime of the message.
static bool Read(const base::Pickle* m,
@@ -55,9 +54,8 @@ struct ParamTraits<WebInputEventPointer> {
};
template <>
-struct CONTENT_EXPORT ParamTraits<content::MessagePort> {
- typedef content::MessagePort param_type;
- static void GetSize(base::PickleSizer* sizer, const param_type& p);
+struct CONTENT_EXPORT ParamTraits<blink::MessagePortChannel> {
+ typedef blink::MessagePortChannel param_type;
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m, base::PickleIterator* iter,
param_type* r);
@@ -67,7 +65,6 @@ struct CONTENT_EXPORT ParamTraits<content::MessagePort> {
template <>
struct CONTENT_EXPORT ParamTraits<ui::AXMode> {
typedef ui::AXMode param_type;
- static void GetSize(base::PickleSizer* sizer, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -78,7 +75,6 @@ struct CONTENT_EXPORT ParamTraits<ui::AXMode> {
template <>
struct CONTENT_EXPORT ParamTraits<scoped_refptr<storage::BlobHandle>> {
typedef scoped_refptr<storage::BlobHandle> param_type;
- static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
diff --git a/chromium/content/common/content_param_traits_macros.h b/chromium/content/common/content_param_traits_macros.h
index eb00b5259f3..afb9838ea3a 100644
--- a/chromium/content/common/content_param_traits_macros.h
+++ b/chromium/content/common/content_param_traits_macros.h
@@ -22,7 +22,6 @@
#include "third_party/WebKit/public/platform/WebInputEvent.h"
#include "third_party/WebKit/public/platform/WebPageVisibilityState.h"
#include "third_party/WebKit/public/web/WebImeTextSpan.h"
-#include "third_party/WebKit/public/web/WebSharedWorkerCreationContextType.h"
#include "ui/gfx/gpu_memory_buffer.h"
#include "ui/gfx/ipc/geometry/gfx_param_traits.h"
@@ -44,15 +43,13 @@ IPC_ENUM_TRAITS_MAX_VALUE(blink::WebContentSecurityPolicySource,
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebContentSecurityPolicyType,
blink::kWebContentSecurityPolicyTypeLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebAddressSpace, blink::kWebAddressSpaceLast)
-IPC_ENUM_TRAITS_MAX_VALUE(blink::WebSharedWorkerCreationContextType,
- blink::kWebSharedWorkerCreationContextTypeLast)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(blink::WebInputEvent::Type,
blink::WebInputEvent::kTypeFirst,
blink::WebInputEvent::kTypeLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebPageVisibilityState,
blink::kWebPageVisibilityStateLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebImeTextSpan::Type,
- blink::WebImeTextSpan::Type::kSuggestion)
+ blink::WebImeTextSpan::Type::kMisspellingSuggestion)
IPC_STRUCT_TRAITS_BEGIN(blink::WebImeTextSpan)
IPC_STRUCT_TRAITS_MEMBER(type)
diff --git a/chromium/content/common/content_switches_internal.cc b/chromium/content/common/content_switches_internal.cc
index 52792f401da..89e8a737443 100644
--- a/chromium/content/common/content_switches_internal.cc
+++ b/chromium/content/common/content_switches_internal.cc
@@ -158,6 +158,21 @@ ProgressBarCompletion GetProgressBarCompletionPolicy() {
return ProgressBarCompletion::LOAD_EVENT;
}
+SavePreviousDocumentResources GetSavePreviousDocumentResources() {
+ const base::CommandLine& command_line =
+ *base::CommandLine::ForCurrentProcess();
+ std::string save_previous_document_resources =
+ command_line.GetSwitchValueASCII(
+ switches::kSavePreviousDocumentResources);
+ if (save_previous_document_resources == "never")
+ return SavePreviousDocumentResources::NEVER;
+ if (save_previous_document_resources == "onDOMContentLoaded")
+ return SavePreviousDocumentResources::UNTIL_ON_DOM_CONTENT_LOADED;
+ if (save_previous_document_resources == "onload")
+ return SavePreviousDocumentResources::UNTIL_ON_LOAD;
+ return SavePreviousDocumentResources::NEVER;
+}
+
void WaitForDebugger(const std::string& label) {
#if defined(OS_WIN)
#if defined(GOOGLE_CHROME_BUILD)
diff --git a/chromium/content/common/content_switches_internal.h b/chromium/content/common/content_switches_internal.h
index 8bb2c96934d..c694388478e 100644
--- a/chromium/content/common/content_switches_internal.h
+++ b/chromium/content/common/content_switches_internal.h
@@ -24,6 +24,8 @@ V8CacheOptions GetV8CacheOptions();
ProgressBarCompletion GetProgressBarCompletionPolicy();
+SavePreviousDocumentResources GetSavePreviousDocumentResources();
+
CONTENT_EXPORT bool IsUseZoomForDSFEnabled();
void WaitForDebugger(const std::string& label);
diff --git a/chromium/content/common/cursors/webcursor.cc b/chromium/content/common/cursors/webcursor.cc
index a85d6a8775f..e34ab185550 100644
--- a/chromium/content/common/cursors/webcursor.cc
+++ b/chromium/content/common/cursors/webcursor.cc
@@ -4,6 +4,8 @@
#include "content/common/cursors/webcursor.h"
+#include <algorithm>
+
#include "base/logging.h"
#include "base/pickle.h"
#include "build/build_config.h"
@@ -89,9 +91,8 @@ bool WebCursor::Deserialize(base::PickleIterator* iter) {
// The * 4 is because the expected format is an array of RGBA pixel
// values.
if (size_x * size_y * 4 != data_len) {
- LOG(WARNING) << "WebCursor's data length and image size mismatch: "
- << size_x << "x" << size_y << "x4 != "
- << data_len;
+ DLOG(WARNING) << "WebCursor's data length and image size mismatch: "
+ << size_x << "x" << size_y << "x4 != " << data_len;
return false;
}
@@ -109,25 +110,21 @@ bool WebCursor::Deserialize(base::PickleIterator* iter) {
}
}
}
- return DeserializePlatformData(iter);
+ return true;
}
-bool WebCursor::Serialize(base::Pickle* pickle) const {
- if (!pickle->WriteInt(type_) ||
- !pickle->WriteInt(hotspot_.x()) ||
- !pickle->WriteInt(hotspot_.y()) ||
- !pickle->WriteInt(custom_size_.width()) ||
- !pickle->WriteInt(custom_size_.height()) ||
- !pickle->WriteFloat(custom_scale_))
- return false;
+void WebCursor::Serialize(base::Pickle* pickle) const {
+ pickle->WriteInt(type_);
+ pickle->WriteInt(hotspot_.x());
+ pickle->WriteInt(hotspot_.y());
+ pickle->WriteInt(custom_size_.width());
+ pickle->WriteInt(custom_size_.height());
+ pickle->WriteFloat(custom_scale_);
const char* data = NULL;
if (!custom_data_.empty())
data = &custom_data_[0];
- if (!pickle->WriteData(data, custom_data_.size()))
- return false;
-
- return SerializePlatformData(pickle);
+ pickle->WriteData(data, custom_data_.size());
}
bool WebCursor::IsCustom() const {
@@ -178,7 +175,7 @@ void WebCursor::CreateCustomData(const SkBitmap& bitmap,
return;
// Fill custom_data directly with the NativeImage pixels.
- custom_data->resize(bitmap.getSize());
+ custom_data->resize(bitmap.computeByteSize());
if (!custom_data->empty()) {
//This will divide color values by alpha (un-premultiply) if necessary
SkImageInfo dstInfo = bitmap.info().makeAlphaType(kUnpremul_SkAlphaType);
diff --git a/chromium/content/common/cursors/webcursor.h b/chromium/content/common/cursors/webcursor.h
index 4f7bd59f41f..485eef50591 100644
--- a/chromium/content/common/cursors/webcursor.h
+++ b/chromium/content/common/cursors/webcursor.h
@@ -57,7 +57,7 @@ class CONTENT_EXPORT WebCursor {
// Serialization / De-serialization
bool Deserialize(base::PickleIterator* iter);
- bool Serialize(base::Pickle* pickle) const;
+ void Serialize(base::Pickle* pickle) const;
// Returns true if GetCustomCursor should be used to allocate a platform
// specific cursor object. Otherwise GetCursor should be used.
@@ -103,10 +103,6 @@ class CONTENT_EXPORT WebCursor {
// Platform specific initialization goes here.
void InitPlatformData();
- // Platform specific Serialization / De-serialization
- bool SerializePlatformData(base::Pickle* pickle) const;
- bool DeserializePlatformData(base::PickleIterator* iter);
-
// Returns true if the platform data in the current cursor object
// matches that of the cursor passed in.
bool IsPlatformDataEqual(const WebCursor& other) const ;
diff --git a/chromium/content/common/cursors/webcursor_android.cc b/chromium/content/common/cursors/webcursor_android.cc
index d1d720e9b7b..fc1f67f070e 100644
--- a/chromium/content/common/cursors/webcursor_android.cc
+++ b/chromium/content/common/cursors/webcursor_android.cc
@@ -24,14 +24,6 @@ void WebCursor::SetDisplayInfo(const display::Display& display) {
void WebCursor::InitPlatformData() {
}
-bool WebCursor::SerializePlatformData(base::Pickle* pickle) const {
- return true;
-}
-
-bool WebCursor::DeserializePlatformData(base::PickleIterator* iter) {
- return true;
-}
-
bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
return true;
}
diff --git a/chromium/content/common/cursors/webcursor_aurawin.cc b/chromium/content/common/cursors/webcursor_aurawin.cc
index e379cfa44c9..5b320648039 100644
--- a/chromium/content/common/cursors/webcursor_aurawin.cc
+++ b/chromium/content/common/cursors/webcursor_aurawin.cc
@@ -40,14 +40,6 @@ void WebCursor::InitPlatformData() {
device_scale_factor_ = 1.f;
}
-bool WebCursor::SerializePlatformData(base::Pickle* pickle) const {
- return true;
-}
-
-bool WebCursor::DeserializePlatformData(base::PickleIterator* iter) {
- return true;
-}
-
bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
return true;
}
diff --git a/chromium/content/common/cursors/webcursor_aurax11.cc b/chromium/content/common/cursors/webcursor_aurax11.cc
index d4c9d1d0cfb..feeba909193 100644
--- a/chromium/content/common/cursors/webcursor_aurax11.cc
+++ b/chromium/content/common/cursors/webcursor_aurax11.cc
@@ -34,14 +34,6 @@ void WebCursor::InitPlatformData() {
device_scale_factor_ = 1.f;
}
-bool WebCursor::SerializePlatformData(base::Pickle* pickle) const {
- return true;
-}
-
-bool WebCursor::DeserializePlatformData(base::PickleIterator* iter) {
- return true;
-}
-
bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
return true;
}
diff --git a/chromium/content/common/cursors/webcursor_mac.mm b/chromium/content/common/cursors/webcursor_mac.mm
index 00d1748599c..a55335de75a 100644
--- a/chromium/content/common/cursors/webcursor_mac.mm
+++ b/chromium/content/common/cursors/webcursor_mac.mm
@@ -360,14 +360,6 @@ void WebCursor::InitPlatformData() {
return;
}
-bool WebCursor::SerializePlatformData(base::Pickle* pickle) const {
- return true;
-}
-
-bool WebCursor::DeserializePlatformData(base::PickleIterator* iter) {
- return true;
-}
-
bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
return true;
}
diff --git a/chromium/content/common/cursors/webcursor_ozone.cc b/chromium/content/common/cursors/webcursor_ozone.cc
index b28ab005c63..101af76cda1 100644
--- a/chromium/content/common/cursors/webcursor_ozone.cc
+++ b/chromium/content/common/cursors/webcursor_ozone.cc
@@ -69,14 +69,6 @@ void WebCursor::InitPlatformData() {
gfx::Size(kDefaultMaxCursorWidth, kDefaultMaxCursorHeight);
}
-bool WebCursor::SerializePlatformData(base::Pickle* pickle) const {
- return true;
-}
-
-bool WebCursor::DeserializePlatformData(base::PickleIterator* iter) {
- return true;
-}
-
bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
return true;
}
diff --git a/chromium/content/common/database_messages.h b/chromium/content/common/database_messages.h
deleted file mode 100644
index 5f39cc5ed8c..00000000000
--- a/chromium/content/common/database_messages.h
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Multiply-included message file, no include guard.
-
-#include <stdint.h>
-
-#include "ipc/ipc_message_macros.h"
-#include "ipc/ipc_param_traits.h"
-#include "ipc/ipc_platform_file.h"
-#include "url/origin.h"
-
-#define IPC_MESSAGE_START DatabaseMsgStart
-
-// Database messages sent from the browser to the renderer.
-
-// Notifies the child process of the new database size
-IPC_MESSAGE_CONTROL3(DatabaseMsg_UpdateSize,
- url::Origin /* the origin */,
- base::string16 /* the database name */,
- int64_t /* the new database size */)
-
-// Asks the child process to close a database immediately
-IPC_MESSAGE_CONTROL2(DatabaseMsg_CloseImmediately,
- url::Origin /* the origin */,
- base::string16 /* the database name */)
-
-// Database messages sent from the renderer to the browser.
-
-// Asks the browser process to open a DB file with the given name.
-IPC_SYNC_MESSAGE_CONTROL2_1(DatabaseHostMsg_OpenFile,
- base::string16 /* vfs file name */,
- int /* desired flags */,
- IPC::PlatformFileForTransit /* file_handle */)
-
-// Asks the browser process to delete a DB file
-IPC_SYNC_MESSAGE_CONTROL2_1(DatabaseHostMsg_DeleteFile,
- base::string16 /* vfs file name */,
- bool /* whether or not to sync the directory */,
- int /* SQLite error code */)
-
-// Asks the browser process to return the attributes of a DB file
-IPC_SYNC_MESSAGE_CONTROL1_1(DatabaseHostMsg_GetFileAttributes,
- base::string16 /* vfs file name */,
- int32_t /* the attributes for the given DB file */)
-
-// Asks the browser process to return the size of a DB file
-IPC_SYNC_MESSAGE_CONTROL1_1(DatabaseHostMsg_GetFileSize,
- base::string16 /* vfs file name */,
- int64_t /* the size of the given DB file */)
-
-// Asks the browser process for the amount of space available to an origin
-IPC_SYNC_MESSAGE_CONTROL1_1(DatabaseHostMsg_GetSpaceAvailable,
- url::Origin /* origin */,
- int64_t /* remaining space available */)
-
-// Asks the browser set the size of a DB file
-IPC_SYNC_MESSAGE_CONTROL2_1(DatabaseHostMsg_SetFileSize,
- base::string16 /* vfs file name */,
- int64_t /* expected size of the given DB file */,
- bool /* indicates success */)
-
-// Notifies the browser process that a new database has been opened
-IPC_MESSAGE_CONTROL4(DatabaseHostMsg_Opened,
- url::Origin /* origin */,
- base::string16 /* database name */,
- base::string16 /* database description */,
- int64_t /* estimated size */)
-
-// Notifies the browser process that a database might have been modified
-IPC_MESSAGE_CONTROL2(DatabaseHostMsg_Modified,
- url::Origin /* origin */,
- base::string16 /* database name */)
-
-// Notifies the browser process that a database is about to close
-IPC_MESSAGE_CONTROL2(DatabaseHostMsg_Closed,
- url::Origin /* origin */,
- base::string16 /* database name */)
-
-// Sent when a sqlite error indicates the database is corrupt.
-IPC_MESSAGE_CONTROL3(DatabaseHostMsg_HandleSqliteError,
- url::Origin /* origin */,
- base::string16 /* database name */,
- int /* error */)
diff --git a/chromium/content/common/devtools/devtools_network_conditions.cc b/chromium/content/common/devtools/devtools_network_conditions.cc
new file mode 100644
index 00000000000..d2e1437abc4
--- /dev/null
+++ b/chromium/content/common/devtools/devtools_network_conditions.cc
@@ -0,0 +1,31 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/devtools/devtools_network_conditions.h"
+
+namespace content {
+
+DevToolsNetworkConditions::DevToolsNetworkConditions()
+ : DevToolsNetworkConditions(false) {}
+
+DevToolsNetworkConditions::DevToolsNetworkConditions(bool offline)
+ : DevToolsNetworkConditions(offline, 0, 0, 0) {}
+
+DevToolsNetworkConditions::DevToolsNetworkConditions(bool offline,
+ double latency,
+ double download_throughput,
+ double upload_throughput)
+ : offline_(offline),
+ latency_(latency),
+ download_throughput_(download_throughput),
+ upload_throughput_(upload_throughput) {}
+
+DevToolsNetworkConditions::~DevToolsNetworkConditions() {}
+
+bool DevToolsNetworkConditions::IsThrottling() const {
+ return !offline_ && ((latency_ != 0) || (download_throughput_ != 0.0) ||
+ (upload_throughput_ != 0));
+}
+
+} // namespace content
diff --git a/chromium/content/common/devtools/devtools_network_conditions.h b/chromium/content/common/devtools/devtools_network_conditions.h
new file mode 100644
index 00000000000..c076e76f320
--- /dev/null
+++ b/chromium/content/common/devtools/devtools_network_conditions.h
@@ -0,0 +1,47 @@
+// Copyright 2014 The Chromium 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 CONTET_COMMON_DEVTOOLS_DEVTOOLS_NETWORK_CONDITIONS_H_
+#define CONTET_COMMON_DEVTOOLS_DEVTOOLS_NETWORK_CONDITIONS_H_
+
+#include <string>
+#include <vector>
+
+#include "base/macros.h"
+
+#include "content/common/content_export.h"
+
+namespace content {
+
+// DevToolsNetworkConditions holds information about desired network conditions.
+class CONTENT_EXPORT DevToolsNetworkConditions {
+ public:
+ DevToolsNetworkConditions();
+ ~DevToolsNetworkConditions();
+
+ explicit DevToolsNetworkConditions(bool offline);
+ DevToolsNetworkConditions(bool offline,
+ double latency,
+ double download_throughput,
+ double upload_throughput);
+
+ bool IsThrottling() const;
+
+ bool offline() const { return offline_; }
+ double latency() const { return latency_; }
+ double download_throughput() const { return download_throughput_; }
+ double upload_throughput() const { return upload_throughput_; }
+
+ private:
+ const bool offline_;
+ const double latency_;
+ const double download_throughput_;
+ const double upload_throughput_;
+
+ DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkConditions);
+};
+
+} // namespace content
+
+#endif // CONTET_COMMON_DEVTOOLS_DEVTOOLS_NETWORK_CONDITIONS_H_
diff --git a/chromium/content/common/devtools/devtools_network_controller.cc b/chromium/content/common/devtools/devtools_network_controller.cc
new file mode 100644
index 00000000000..3e485a5b237
--- /dev/null
+++ b/chromium/content/common/devtools/devtools_network_controller.cc
@@ -0,0 +1,76 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/devtools/devtools_network_controller.h"
+
+#include <utility>
+
+#include "content/common/devtools/devtools_network_conditions.h"
+#include "content/common/devtools/devtools_network_interceptor.h"
+#include "net/http/http_request_info.h"
+
+namespace content {
+
+DevToolsNetworkController* DevToolsNetworkController::instance_ = nullptr;
+
+DevToolsNetworkController::DevToolsNetworkController() = default;
+DevToolsNetworkController::~DevToolsNetworkController() = default;
+
+// static
+DevToolsNetworkInterceptor* DevToolsNetworkController::GetInterceptor(
+ const std::string& client_id) {
+ if (!instance_ || client_id.empty())
+ return nullptr;
+ return instance_->FindInterceptor(client_id);
+}
+
+// static
+void DevToolsNetworkController::SetNetworkState(
+ const std::string& client_id,
+ std::unique_ptr<DevToolsNetworkConditions> conditions) {
+ if (!instance_) {
+ if (!conditions)
+ return;
+ instance_ = new DevToolsNetworkController();
+ }
+ instance_->SetConditions(client_id, std::move(conditions));
+}
+
+DevToolsNetworkInterceptor* DevToolsNetworkController::FindInterceptor(
+ const std::string& client_id) {
+ DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
+ auto it = interceptors_.find(client_id);
+ return it != interceptors_.end() ? it->second.get() : nullptr;
+}
+
+void DevToolsNetworkController::SetConditions(
+ const std::string& client_id,
+ std::unique_ptr<DevToolsNetworkConditions> conditions) {
+ DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
+
+ auto it = interceptors_.find(client_id);
+ if (it == interceptors_.end()) {
+ if (!conditions)
+ return;
+ std::unique_ptr<DevToolsNetworkInterceptor> new_interceptor(
+ new DevToolsNetworkInterceptor());
+ new_interceptor->UpdateConditions(std::move(conditions));
+ interceptors_[client_id] = std::move(new_interceptor);
+ } else {
+ if (!conditions) {
+ std::unique_ptr<DevToolsNetworkConditions> online_conditions(
+ new DevToolsNetworkConditions());
+ it->second->UpdateConditions(std::move(online_conditions));
+ interceptors_.erase(client_id);
+ if (interceptors_.empty()) {
+ delete this;
+ instance_ = nullptr;
+ }
+ } else {
+ it->second->UpdateConditions(std::move(conditions));
+ }
+ }
+}
+
+} // namespace content
diff --git a/chromium/content/common/devtools/devtools_network_controller.h b/chromium/content/common/devtools/devtools_network_controller.h
new file mode 100644
index 00000000000..471ac1eb342
--- /dev/null
+++ b/chromium/content/common/devtools/devtools_network_controller.h
@@ -0,0 +1,54 @@
+// Copyright 2014 The Chromium 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 CONTENT_COMMON_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_H_
+#define CONTENT_COMMON_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_H_
+
+#include <map>
+#include <memory>
+#include <string>
+
+#include "base/macros.h"
+#include "base/threading/thread_checker.h"
+#include "content/common/content_export.h"
+
+namespace content {
+
+class DevToolsNetworkConditions;
+class DevToolsNetworkInterceptor;
+
+// DevToolsNetworkController manages interceptors identified by client id
+// and their throttling conditions.
+class CONTENT_EXPORT DevToolsNetworkController {
+ public:
+ // Applies network emulation configuration.
+ static void SetNetworkState(
+ const std::string& client_id,
+ std::unique_ptr<DevToolsNetworkConditions> conditions);
+
+ static DevToolsNetworkInterceptor* GetInterceptor(
+ const std::string& client_id);
+
+ private:
+ DevToolsNetworkController();
+ ~DevToolsNetworkController();
+
+ DevToolsNetworkInterceptor* FindInterceptor(const std::string& client_id);
+ void SetConditions(const std::string& client_id,
+ std::unique_ptr<DevToolsNetworkConditions> conditions);
+
+ static DevToolsNetworkController* instance_;
+
+ using InterceptorMap =
+ std::map<std::string, std::unique_ptr<DevToolsNetworkInterceptor>>;
+
+ InterceptorMap interceptors_;
+ THREAD_CHECKER(thread_checker_);
+
+ DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkController);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_DEVTOOLS_DEVTOOLS_NETWORK_CONTROLLER_H_
diff --git a/chromium/content/common/devtools/devtools_network_controller_unittest.cc b/chromium/content/common/devtools/devtools_network_controller_unittest.cc
new file mode 100644
index 00000000000..b30bb4a19f6
--- /dev/null
+++ b/chromium/content/common/devtools/devtools_network_controller_unittest.cc
@@ -0,0 +1,322 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/devtools/devtools_network_controller.h"
+
+#include <stdint.h>
+
+#include <memory>
+#include <string>
+#include <utility>
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
+#include "content/common/devtools/devtools_network_conditions.h"
+#include "content/common/devtools/devtools_network_interceptor.h"
+#include "content/common/devtools/devtools_network_transaction.h"
+#include "content/common/devtools/devtools_network_upload_data_stream.h"
+#include "net/base/chunked_upload_data_stream.h"
+#include "net/http/http_transaction_test_util.h"
+#include "net/log/net_log_with_source.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "url/gurl.h"
+
+namespace content {
+
+using net::kSimpleGET_Transaction;
+using net::MockHttpRequest;
+using net::MockNetworkLayer;
+using net::MockTransaction;
+using net::TEST_MODE_SYNC_NET_START;
+
+const char kClientId[] = "42";
+const char kAnotherClientId[] = "24";
+const char kUploadData[] = "upload_data";
+int64_t kUploadIdentifier = 17;
+
+class TestCallback {
+ public:
+ TestCallback() : run_count_(0), value_(0) {}
+ void Run(int value) {
+ run_count_++;
+ value_ = value;
+ }
+ int run_count() { return run_count_; }
+ int value() { return value_; }
+
+ private:
+ int run_count_;
+ int value_;
+};
+
+class DevToolsNetworkControllerHelper {
+ public:
+ DevToolsNetworkControllerHelper()
+ : completion_callback_(
+ base::Bind(&TestCallback::Run, base::Unretained(&callback_))),
+ mock_transaction_(kSimpleGET_Transaction),
+ buffer_(new net::IOBuffer(64)) {
+ mock_transaction_.test_mode = TEST_MODE_SYNC_NET_START;
+ mock_transaction_.url = "http://dot.com";
+ mock_transaction_.request_headers =
+ "X-DevTools-Emulate-Network-Conditions-Client-Id: 42\r\n";
+ AddMockTransaction(&mock_transaction_);
+
+ std::unique_ptr<net::HttpTransaction> network_transaction;
+ network_layer_.CreateTransaction(net::DEFAULT_PRIORITY,
+ &network_transaction);
+ transaction_.reset(
+ new DevToolsNetworkTransaction(std::move(network_transaction)));
+ }
+
+ void SetNetworkState(bool offline, double download, double upload) {
+ std::unique_ptr<DevToolsNetworkConditions> conditions(
+ new DevToolsNetworkConditions(offline, 0, download, upload));
+ DevToolsNetworkController::SetNetworkState(kClientId,
+ std::move(conditions));
+ }
+
+ void SetNetworkState(const std::string& id, bool offline) {
+ std::unique_ptr<DevToolsNetworkConditions> conditions(
+ new DevToolsNetworkConditions(offline));
+ DevToolsNetworkController::SetNetworkState(id, std::move(conditions));
+ }
+
+ int Start(bool with_upload) {
+ request_.reset(new MockHttpRequest(mock_transaction_));
+
+ if (with_upload) {
+ upload_data_stream_.reset(
+ new net::ChunkedUploadDataStream(kUploadIdentifier));
+ upload_data_stream_->AppendData(kUploadData, arraysize(kUploadData),
+ true);
+ request_->upload_data_stream = upload_data_stream_.get();
+ }
+
+ int rv = transaction_->Start(request_.get(), completion_callback_,
+ net::NetLogWithSource());
+ EXPECT_EQ(with_upload, !!transaction_->custom_upload_data_stream_);
+ return rv;
+ }
+
+ int Read() {
+ return transaction_->Read(buffer_.get(), 64, completion_callback_);
+ }
+
+ bool ShouldFail() {
+ if (transaction_->interceptor_)
+ return transaction_->interceptor_->IsOffline();
+ DevToolsNetworkInterceptor* interceptor =
+ DevToolsNetworkController::GetInterceptor(kClientId);
+ EXPECT_TRUE(!!interceptor);
+ return interceptor->IsOffline();
+ }
+
+ bool HasStarted() { return !!transaction_->request_; }
+
+ bool HasFailed() { return transaction_->failed_; }
+
+ void CancelTransaction() { transaction_.reset(); }
+
+ int ReadUploadData() {
+ EXPECT_EQ(net::OK, transaction_->custom_upload_data_stream_->Init(
+ completion_callback_, net::NetLogWithSource()));
+ return transaction_->custom_upload_data_stream_->Read(buffer_.get(), 64,
+ completion_callback_);
+ }
+
+ ~DevToolsNetworkControllerHelper() {
+ RemoveMockTransaction(&mock_transaction_);
+ }
+
+ TestCallback* callback() { return &callback_; }
+ DevToolsNetworkTransaction* transaction() { return transaction_.get(); }
+
+ private:
+ base::MessageLoop message_loop_;
+ MockNetworkLayer network_layer_;
+ TestCallback callback_;
+ net::CompletionCallback completion_callback_;
+ MockTransaction mock_transaction_;
+ std::unique_ptr<DevToolsNetworkTransaction> transaction_;
+ scoped_refptr<net::IOBuffer> buffer_;
+ std::unique_ptr<net::ChunkedUploadDataStream> upload_data_stream_;
+ std::unique_ptr<MockHttpRequest> request_;
+};
+
+TEST(DevToolsNetworkControllerTest, SingleDisableEnable) {
+ DevToolsNetworkControllerHelper helper;
+ helper.SetNetworkState(false, 0, 0);
+ helper.Start(false);
+
+ EXPECT_FALSE(helper.ShouldFail());
+ helper.SetNetworkState(true, 0, 0);
+ EXPECT_TRUE(helper.ShouldFail());
+ helper.SetNetworkState(false, 0, 0);
+ EXPECT_FALSE(helper.ShouldFail());
+
+ base::RunLoop().RunUntilIdle();
+}
+
+TEST(DevToolsNetworkControllerTest, InterceptorIsolation) {
+ DevToolsNetworkControllerHelper helper;
+ helper.SetNetworkState(false, 0, 0);
+ helper.Start(false);
+
+ EXPECT_FALSE(helper.ShouldFail());
+ helper.SetNetworkState(kAnotherClientId, true);
+ EXPECT_FALSE(helper.ShouldFail());
+ helper.SetNetworkState(true, 0, 0);
+ EXPECT_TRUE(helper.ShouldFail());
+
+ helper.SetNetworkState(kAnotherClientId, false);
+ helper.SetNetworkState(false, 0, 0);
+ base::RunLoop().RunUntilIdle();
+}
+
+TEST(DevToolsNetworkControllerTest, FailOnStart) {
+ DevToolsNetworkControllerHelper helper;
+ helper.SetNetworkState(true, 0, 0);
+
+ int rv = helper.Start(false);
+ EXPECT_EQ(rv, net::ERR_INTERNET_DISCONNECTED);
+
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(helper.callback()->run_count(), 0);
+}
+
+TEST(DevToolsNetworkControllerTest, FailRunningTransaction) {
+ DevToolsNetworkControllerHelper helper;
+ helper.SetNetworkState(false, 0, 0);
+ TestCallback* callback = helper.callback();
+
+ int rv = helper.Start(false);
+ EXPECT_EQ(rv, net::OK);
+
+ rv = helper.Read();
+ EXPECT_EQ(rv, net::ERR_IO_PENDING);
+ EXPECT_EQ(callback->run_count(), 0);
+
+ helper.SetNetworkState(true, 0, 0);
+ EXPECT_EQ(callback->run_count(), 0);
+
+ // Wait until HttpTrancation completes reading and invokes callback.
+ // DevToolsNetworkTransaction should report error instead.
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(callback->run_count(), 1);
+ EXPECT_EQ(callback->value(), net::ERR_INTERNET_DISCONNECTED);
+
+ // Check that transaction is not failed second time.
+ helper.SetNetworkState(false, 0, 0);
+ helper.SetNetworkState(true, 0, 0);
+ EXPECT_EQ(callback->run_count(), 1);
+}
+
+TEST(DevToolsNetworkControllerTest, ReadAfterFail) {
+ DevToolsNetworkControllerHelper helper;
+ helper.SetNetworkState(false, 0, 0);
+
+ int rv = helper.Start(false);
+ EXPECT_EQ(rv, net::OK);
+ EXPECT_TRUE(helper.HasStarted());
+
+ helper.SetNetworkState(true, 0, 0);
+ // Not failed yet, as no IO was initiated.
+ EXPECT_FALSE(helper.HasFailed());
+
+ rv = helper.Read();
+ // Fails on first IO.
+ EXPECT_EQ(rv, net::ERR_INTERNET_DISCONNECTED);
+
+ // Check that callback is never invoked.
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(helper.callback()->run_count(), 0);
+}
+
+TEST(DevToolsNetworkControllerTest, CancelTransaction) {
+ DevToolsNetworkControllerHelper helper;
+ helper.SetNetworkState(false, 0, 0);
+
+ int rv = helper.Start(false);
+ EXPECT_EQ(rv, net::OK);
+ EXPECT_TRUE(helper.HasStarted());
+ helper.CancelTransaction();
+
+ // Should not crash.
+ helper.SetNetworkState(true, 0, 0);
+ helper.SetNetworkState(false, 0, 0);
+ base::RunLoop().RunUntilIdle();
+}
+
+TEST(DevToolsNetworkControllerTest, CancelFailedTransaction) {
+ DevToolsNetworkControllerHelper helper;
+ helper.SetNetworkState(true, 0, 0);
+
+ int rv = helper.Start(false);
+ EXPECT_EQ(rv, net::ERR_INTERNET_DISCONNECTED);
+ EXPECT_TRUE(helper.HasStarted());
+ helper.CancelTransaction();
+
+ // Should not crash.
+ helper.SetNetworkState(true, 0, 0);
+ helper.SetNetworkState(false, 0, 0);
+ base::RunLoop().RunUntilIdle();
+}
+
+TEST(DevToolsNetworkControllerTest, UploadDoesNotFail) {
+ DevToolsNetworkControllerHelper helper;
+ helper.SetNetworkState(true, 0, 0);
+ int rv = helper.Start(true);
+ EXPECT_EQ(rv, net::ERR_INTERNET_DISCONNECTED);
+ rv = helper.ReadUploadData();
+ EXPECT_EQ(rv, static_cast<int>(arraysize(kUploadData)));
+}
+
+TEST(DevToolsNetworkControllerTest, DownloadOnly) {
+ DevToolsNetworkControllerHelper helper;
+ TestCallback* callback = helper.callback();
+
+ helper.SetNetworkState(false, 10000000, 0);
+ int rv = helper.Start(false);
+ EXPECT_EQ(rv, net::ERR_IO_PENDING);
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(callback->run_count(), 1);
+ EXPECT_GE(callback->value(), net::OK);
+
+ rv = helper.Read();
+ EXPECT_EQ(rv, net::ERR_IO_PENDING);
+ EXPECT_EQ(callback->run_count(), 1);
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(callback->run_count(), 2);
+ EXPECT_GE(callback->value(), net::OK);
+}
+
+TEST(DevToolsNetworkControllerTest, UploadOnly) {
+ DevToolsNetworkControllerHelper helper;
+ TestCallback* callback = helper.callback();
+
+ helper.SetNetworkState(false, 0, 1000000);
+ int rv = helper.Start(true);
+ EXPECT_EQ(rv, net::OK);
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(callback->run_count(), 0);
+
+ rv = helper.Read();
+ EXPECT_EQ(rv, net::ERR_IO_PENDING);
+ EXPECT_EQ(callback->run_count(), 0);
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(callback->run_count(), 1);
+ EXPECT_GE(callback->value(), net::OK);
+
+ rv = helper.ReadUploadData();
+ EXPECT_EQ(rv, net::ERR_IO_PENDING);
+ EXPECT_EQ(callback->run_count(), 1);
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(callback->run_count(), 2);
+ EXPECT_EQ(callback->value(), static_cast<int>(arraysize(kUploadData)));
+}
+
+} // namespace content
diff --git a/chromium/content/common/devtools/devtools_network_interceptor.cc b/chromium/content/common/devtools/devtools_network_interceptor.cc
new file mode 100644
index 00000000000..0379597e305
--- /dev/null
+++ b/chromium/content/common/devtools/devtools_network_interceptor.cc
@@ -0,0 +1,287 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/devtools/devtools_network_interceptor.h"
+
+#include <stddef.h>
+#include <algorithm>
+#include <limits>
+#include <utility>
+
+#include "base/time/time.h"
+#include "content/common/devtools/devtools_network_conditions.h"
+#include "net/base/net_errors.h"
+
+namespace content {
+
+namespace {
+
+int64_t kPacketSize = 1500;
+
+base::TimeDelta CalculateTickLength(double throughput) {
+ if (!throughput)
+ return base::TimeDelta();
+ int64_t us_tick_length = (1000000L * kPacketSize) / throughput;
+ DCHECK(us_tick_length != 0);
+ if (us_tick_length == 0)
+ us_tick_length = 1;
+ return base::TimeDelta::FromMicroseconds(us_tick_length);
+}
+
+} // namespace
+
+DevToolsNetworkInterceptor::ThrottleRecord::ThrottleRecord() {}
+
+DevToolsNetworkInterceptor::ThrottleRecord::ThrottleRecord(
+ const ThrottleRecord& other) = default;
+
+DevToolsNetworkInterceptor::ThrottleRecord::~ThrottleRecord() {}
+
+DevToolsNetworkInterceptor::DevToolsNetworkInterceptor()
+ : conditions_(new DevToolsNetworkConditions()),
+ download_last_tick_(0),
+ upload_last_tick_(0),
+ weak_ptr_factory_(this) {}
+
+DevToolsNetworkInterceptor::~DevToolsNetworkInterceptor() {}
+
+base::WeakPtr<DevToolsNetworkInterceptor>
+DevToolsNetworkInterceptor::GetWeakPtr() {
+ return weak_ptr_factory_.GetWeakPtr();
+}
+
+void DevToolsNetworkInterceptor::FinishRecords(ThrottleRecords* records,
+ bool offline) {
+ ThrottleRecords temp;
+ temp.swap(*records);
+ for (const ThrottleRecord& record : temp) {
+ bool failed = offline && !record.is_upload;
+ record.callback.Run(failed ? net::ERR_INTERNET_DISCONNECTED : record.result,
+ record.bytes);
+ }
+}
+
+void DevToolsNetworkInterceptor::UpdateConditions(
+ std::unique_ptr<DevToolsNetworkConditions> conditions) {
+ DCHECK(conditions);
+ base::TimeTicks now = base::TimeTicks::Now();
+ if (conditions_->IsThrottling())
+ UpdateThrottled(now);
+
+ conditions_ = std::move(conditions);
+
+ bool offline = conditions_->offline();
+ if (offline || !conditions_->IsThrottling()) {
+ timer_.Stop();
+ FinishRecords(&download_, offline);
+ FinishRecords(&upload_, offline);
+ FinishRecords(&suspended_, offline);
+ return;
+ }
+
+ // Throttling.
+ DCHECK(conditions_->download_throughput() != 0 ||
+ conditions_->upload_throughput() != 0);
+ offset_ = now;
+
+ download_last_tick_ = 0;
+ download_tick_length_ =
+ CalculateTickLength(conditions_->download_throughput());
+
+ upload_last_tick_ = 0;
+ upload_tick_length_ = CalculateTickLength(conditions_->upload_throughput());
+
+ latency_length_ = base::TimeDelta();
+ double latency = conditions_->latency();
+ if (latency > 0)
+ latency_length_ = base::TimeDelta::FromMillisecondsD(latency);
+ ArmTimer(now);
+}
+
+uint64_t DevToolsNetworkInterceptor::UpdateThrottledRecords(
+ base::TimeTicks now,
+ ThrottleRecords* records,
+ uint64_t last_tick,
+ base::TimeDelta tick_length) {
+ if (tick_length.is_zero()) {
+ DCHECK(records->empty());
+ return last_tick;
+ }
+
+ int64_t new_tick = (now - offset_) / tick_length;
+ int64_t ticks = new_tick - last_tick;
+
+ int64_t length = records->size();
+ if (!length)
+ return new_tick;
+
+ int64_t shift = ticks % length;
+ for (int64_t i = 0; i < length; ++i) {
+ (*records)[i].bytes -=
+ (ticks / length) * kPacketSize + (i < shift ? kPacketSize : 0);
+ }
+ std::rotate(records->begin(), records->begin() + shift, records->end());
+ return new_tick;
+}
+
+void DevToolsNetworkInterceptor::UpdateThrottled(base::TimeTicks now) {
+ download_last_tick_ = UpdateThrottledRecords(
+ now, &download_, download_last_tick_, download_tick_length_);
+ upload_last_tick_ = UpdateThrottledRecords(now, &upload_, upload_last_tick_,
+ upload_tick_length_);
+ UpdateSuspended(now);
+}
+
+void DevToolsNetworkInterceptor::UpdateSuspended(base::TimeTicks now) {
+ int64_t activation_baseline =
+ (now - latency_length_ - base::TimeTicks()).InMicroseconds();
+ ThrottleRecords suspended;
+ for (const ThrottleRecord& record : suspended_) {
+ if (record.send_end <= activation_baseline) {
+ if (record.is_upload)
+ upload_.push_back(record);
+ else
+ download_.push_back(record);
+ } else {
+ suspended.push_back(record);
+ }
+ }
+ suspended_.swap(suspended);
+}
+
+void DevToolsNetworkInterceptor::CollectFinished(ThrottleRecords* records,
+ ThrottleRecords* finished) {
+ ThrottleRecords active;
+ for (const ThrottleRecord& record : *records) {
+ if (record.bytes < 0)
+ finished->push_back(record);
+ else
+ active.push_back(record);
+ }
+ records->swap(active);
+}
+
+void DevToolsNetworkInterceptor::OnTimer() {
+ base::TimeTicks now = base::TimeTicks::Now();
+ UpdateThrottled(now);
+
+ ThrottleRecords finished;
+ CollectFinished(&download_, &finished);
+ CollectFinished(&upload_, &finished);
+ for (const ThrottleRecord& record : finished)
+ record.callback.Run(record.result, record.bytes);
+
+ ArmTimer(now);
+}
+
+base::TimeTicks DevToolsNetworkInterceptor::CalculateDesiredTime(
+ const ThrottleRecords& records,
+ uint64_t last_tick,
+ base::TimeDelta tick_length) {
+ int64_t min_ticks_left = 0x10000L;
+ size_t count = records.size();
+ for (size_t i = 0; i < count; ++i) {
+ int64_t packets_left = (records[i].bytes + kPacketSize - 1) / kPacketSize;
+ int64_t ticks_left = (i + 1) + count * (packets_left - 1);
+ if (i == 0 || ticks_left < min_ticks_left)
+ min_ticks_left = ticks_left;
+ }
+ return offset_ + tick_length * (last_tick + min_ticks_left);
+}
+
+void DevToolsNetworkInterceptor::ArmTimer(base::TimeTicks now) {
+ size_t suspend_count = suspended_.size();
+ if (download_.empty() && upload_.empty() && !suspend_count)
+ return;
+
+ base::TimeTicks desired_time = CalculateDesiredTime(
+ download_, download_last_tick_, download_tick_length_);
+
+ base::TimeTicks upload_time =
+ CalculateDesiredTime(upload_, upload_last_tick_, upload_tick_length_);
+ if (upload_time < desired_time)
+ desired_time = upload_time;
+
+ int64_t min_baseline = std::numeric_limits<int64_t>::max();
+ for (size_t i = 0; i < suspend_count; ++i) {
+ if (suspended_[i].send_end < min_baseline)
+ min_baseline = suspended_[i].send_end;
+ }
+ if (suspend_count) {
+ base::TimeTicks activation_time =
+ base::TimeTicks() + base::TimeDelta::FromMicroseconds(min_baseline) +
+ latency_length_;
+ if (activation_time < desired_time)
+ desired_time = activation_time;
+ }
+
+ timer_.Start(
+ FROM_HERE, desired_time - now,
+ base::Bind(&DevToolsNetworkInterceptor::OnTimer, base::Unretained(this)));
+}
+
+int DevToolsNetworkInterceptor::StartThrottle(
+ int result,
+ int64_t bytes,
+ base::TimeTicks send_end,
+ bool start,
+ bool is_upload,
+ const ThrottleCallback& callback) {
+ if (result < 0)
+ return result;
+
+ if (conditions_->offline())
+ return is_upload ? result : net::ERR_INTERNET_DISCONNECTED;
+
+ if ((is_upload && !conditions_->upload_throughput()) ||
+ (!is_upload && !conditions_->download_throughput())) {
+ return result;
+ }
+
+ ThrottleRecord record;
+ record.result = result;
+ record.bytes = bytes;
+ record.callback = callback;
+ // TODO(dgozman): use upload throughput.
+ record.is_upload = is_upload;
+
+ base::TimeTicks now = base::TimeTicks::Now();
+ UpdateThrottled(now);
+ if (start && !latency_length_.is_zero()) {
+ record.send_end = (send_end - base::TimeTicks()).InMicroseconds();
+ suspended_.push_back(record);
+ UpdateSuspended(now);
+ } else {
+ if (is_upload)
+ upload_.push_back(record);
+ else
+ download_.push_back(record);
+ }
+ ArmTimer(now);
+
+ return net::ERR_IO_PENDING;
+}
+
+void DevToolsNetworkInterceptor::StopThrottle(
+ const ThrottleCallback& callback) {
+ RemoveRecord(&download_, callback);
+ RemoveRecord(&upload_, callback);
+ RemoveRecord(&suspended_, callback);
+}
+
+void DevToolsNetworkInterceptor::RemoveRecord(
+ ThrottleRecords* records,
+ const ThrottleCallback& callback) {
+ records->erase(std::remove_if(records->begin(), records->end(),
+ [&callback](const ThrottleRecord& record) {
+ return record.callback.Equals(callback);
+ }),
+ records->end());
+}
+
+bool DevToolsNetworkInterceptor::IsOffline() {
+ return conditions_->offline();
+}
+
+} // namespace content \ No newline at end of file
diff --git a/chromium/content/common/devtools/devtools_network_interceptor.h b/chromium/content/common/devtools/devtools_network_interceptor.h
new file mode 100644
index 00000000000..0bf40825be8
--- /dev/null
+++ b/chromium/content/common/devtools/devtools_network_interceptor.h
@@ -0,0 +1,110 @@
+// Copyright 2014 The Chromium 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 CONTENT_COMMON_DEVTOOLS_DEVTOOLS_NETWORK_INTERCEPTOR_H_
+#define CONTENT_COMMON_DEVTOOLS_DEVTOOLS_NETWORK_INTERCEPTOR_H_
+
+#include <stdint.h>
+
+#include <memory>
+#include <set>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "base/macros.h"
+#include "base/timer/timer.h"
+#include "content/common/content_export.h"
+
+namespace base {
+class TimeDelta;
+class TimeTicks;
+} // namespace base
+
+namespace content {
+class DevToolsNetworkConditions;
+
+// DevToolsNetworkInterceptor emulates network conditions for transactions with
+// specific client id.
+class CONTENT_EXPORT DevToolsNetworkInterceptor {
+ public:
+ using ThrottleCallback = base::Callback<void(int, int64_t)>;
+
+ DevToolsNetworkInterceptor();
+ virtual ~DevToolsNetworkInterceptor();
+
+ base::WeakPtr<DevToolsNetworkInterceptor> GetWeakPtr();
+
+ // Applies network emulation configuration.
+ void UpdateConditions(std::unique_ptr<DevToolsNetworkConditions> conditions);
+
+ // Throttles with |is_upload == true| always succeed, even in offline mode.
+ int StartThrottle(int result,
+ int64_t bytes,
+ base::TimeTicks send_end,
+ bool start,
+ bool is_upload,
+ const ThrottleCallback& callback);
+ void StopThrottle(const ThrottleCallback& callback);
+
+ bool IsOffline();
+
+ private:
+ struct ThrottleRecord {
+ public:
+ ThrottleRecord();
+ ThrottleRecord(const ThrottleRecord& other);
+ ~ThrottleRecord();
+ int result;
+ int64_t bytes;
+ int64_t send_end;
+ bool is_upload;
+ ThrottleCallback callback;
+ };
+ using ThrottleRecords = std::vector<ThrottleRecord>;
+
+ void FinishRecords(ThrottleRecords* records, bool offline);
+
+ uint64_t UpdateThrottledRecords(base::TimeTicks now,
+ ThrottleRecords* records,
+ uint64_t last_tick,
+ base::TimeDelta tick_length);
+ void UpdateThrottled(base::TimeTicks now);
+ void UpdateSuspended(base::TimeTicks now);
+
+ void CollectFinished(ThrottleRecords* records, ThrottleRecords* finished);
+ void OnTimer();
+
+ base::TimeTicks CalculateDesiredTime(const ThrottleRecords& records,
+ uint64_t last_tick,
+ base::TimeDelta tick_length);
+ void ArmTimer(base::TimeTicks now);
+
+ void RemoveRecord(ThrottleRecords* records, const ThrottleCallback& callback);
+
+ std::unique_ptr<DevToolsNetworkConditions> conditions_;
+
+ // Throttables suspended for a "latency" period.
+ ThrottleRecords suspended_;
+
+ // Throttables waiting certain amount of transfer to be "accounted".
+ ThrottleRecords download_;
+ ThrottleRecords upload_;
+
+ base::OneShotTimer timer_;
+ base::TimeTicks offset_;
+ base::TimeDelta download_tick_length_;
+ base::TimeDelta upload_tick_length_;
+ base::TimeDelta latency_length_;
+ uint64_t download_last_tick_;
+ uint64_t upload_last_tick_;
+
+ base::WeakPtrFactory<DevToolsNetworkInterceptor> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkInterceptor);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_DEVTOOLS_DEVTOOLS_NETWORK_INTERCEPTOR_H_
diff --git a/chromium/content/common/devtools/devtools_network_transaction.cc b/chromium/content/common/devtools/devtools_network_transaction.cc
new file mode 100644
index 00000000000..848278571f1
--- /dev/null
+++ b/chromium/content/common/devtools/devtools_network_transaction.cc
@@ -0,0 +1,319 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/devtools/devtools_network_transaction.h"
+
+#include <utility>
+
+#include "base/callback_helpers.h"
+#include "content/common/devtools/devtools_network_controller.h"
+#include "content/common/devtools/devtools_network_interceptor.h"
+#include "content/common/devtools/devtools_network_upload_data_stream.h"
+#include "net/base/load_timing_info.h"
+#include "net/base/net_errors.h"
+#include "net/http/http_network_transaction.h"
+#include "net/http/http_request_info.h"
+#include "net/socket/connection_attempts.h"
+
+namespace content {
+
+// Keep in sync with X_DevTools_Emulate_Network_Conditions_Client_Id defined in
+// HTTPNames.json5.
+const char
+ DevToolsNetworkTransaction::kDevToolsEmulateNetworkConditionsClientId[] =
+ "X-DevTools-Emulate-Network-Conditions-Client-Id";
+
+DevToolsNetworkTransaction::DevToolsNetworkTransaction(
+ std::unique_ptr<net::HttpTransaction> network_transaction)
+ : throttled_byte_count_(0),
+ network_transaction_(std::move(network_transaction)),
+ request_(nullptr),
+ failed_(false) {}
+
+DevToolsNetworkTransaction::~DevToolsNetworkTransaction() {
+ if (interceptor_ && !throttle_callback_.is_null())
+ interceptor_->StopThrottle(throttle_callback_);
+}
+
+void DevToolsNetworkTransaction::IOCallback(
+ const net::CompletionCallback& callback,
+ bool start,
+ int result) {
+ result = Throttle(callback, start, result);
+ if (result != net::ERR_IO_PENDING)
+ callback.Run(result);
+}
+
+int DevToolsNetworkTransaction::Throttle(
+ const net::CompletionCallback& callback,
+ bool start,
+ int result) {
+ if (failed_)
+ return net::ERR_INTERNET_DISCONNECTED;
+ if (!interceptor_ || result < 0)
+ return result;
+
+ base::TimeTicks send_end;
+ if (start) {
+ throttled_byte_count_ += network_transaction_->GetTotalReceivedBytes();
+ net::LoadTimingInfo load_timing_info;
+ if (GetLoadTimingInfo(&load_timing_info)) {
+ send_end = load_timing_info.send_end;
+ if (!load_timing_info.push_start.is_null())
+ start = false;
+ }
+ if (send_end.is_null())
+ send_end = base::TimeTicks::Now();
+ }
+ if (result > 0)
+ throttled_byte_count_ += result;
+
+ throttle_callback_ = base::Bind(&DevToolsNetworkTransaction::ThrottleCallback,
+ base::Unretained(this), callback);
+ int rv = interceptor_->StartThrottle(result, throttled_byte_count_, send_end,
+ start, false, throttle_callback_);
+ if (rv != net::ERR_IO_PENDING)
+ throttle_callback_.Reset();
+ if (rv == net::ERR_INTERNET_DISCONNECTED)
+ Fail();
+ return rv;
+}
+
+void DevToolsNetworkTransaction::ThrottleCallback(
+ const net::CompletionCallback& callback,
+ int result,
+ int64_t bytes) {
+ DCHECK(!throttle_callback_.is_null());
+ throttle_callback_.Reset();
+ if (result == net::ERR_INTERNET_DISCONNECTED)
+ Fail();
+ throttled_byte_count_ = bytes;
+ callback.Run(result);
+}
+
+void DevToolsNetworkTransaction::Fail() {
+ DCHECK(request_);
+ DCHECK(!failed_);
+ failed_ = true;
+ network_transaction_->SetBeforeNetworkStartCallback(
+ BeforeNetworkStartCallback());
+ if (interceptor_)
+ interceptor_.reset();
+}
+
+bool DevToolsNetworkTransaction::CheckFailed() {
+ if (failed_)
+ return true;
+ if (interceptor_ && interceptor_->IsOffline()) {
+ Fail();
+ return true;
+ }
+ return false;
+}
+
+int DevToolsNetworkTransaction::Start(const net::HttpRequestInfo* request,
+ const net::CompletionCallback& callback,
+ const net::NetLogWithSource& net_log) {
+ DCHECK(request);
+ request_ = request;
+
+ std::string client_id;
+ bool has_devtools_client_id = request_->extra_headers.HasHeader(
+ kDevToolsEmulateNetworkConditionsClientId);
+ if (has_devtools_client_id) {
+ custom_request_.reset(new net::HttpRequestInfo(*request_));
+ custom_request_->extra_headers.GetHeader(
+ kDevToolsEmulateNetworkConditionsClientId, &client_id);
+ custom_request_->extra_headers.RemoveHeader(
+ kDevToolsEmulateNetworkConditionsClientId);
+
+ if (request_->upload_data_stream) {
+ custom_upload_data_stream_.reset(
+ new DevToolsNetworkUploadDataStream(request_->upload_data_stream));
+ custom_request_->upload_data_stream = custom_upload_data_stream_.get();
+ }
+
+ request_ = custom_request_.get();
+ }
+
+ DevToolsNetworkInterceptor* interceptor =
+ DevToolsNetworkController::GetInterceptor(client_id);
+ if (interceptor) {
+ interceptor_ = interceptor->GetWeakPtr();
+ if (custom_upload_data_stream_)
+ custom_upload_data_stream_->SetInterceptor(interceptor);
+ }
+
+ if (CheckFailed())
+ return net::ERR_INTERNET_DISCONNECTED;
+
+ if (!interceptor_)
+ return network_transaction_->Start(request_, callback, net_log);
+
+ int result = network_transaction_->Start(
+ request_,
+ base::Bind(&DevToolsNetworkTransaction::IOCallback,
+ base::Unretained(this), callback, true),
+ net_log);
+ return Throttle(callback, true, result);
+}
+
+int DevToolsNetworkTransaction::RestartIgnoringLastError(
+ const net::CompletionCallback& callback) {
+ if (CheckFailed())
+ return net::ERR_INTERNET_DISCONNECTED;
+ if (!interceptor_)
+ return network_transaction_->RestartIgnoringLastError(callback);
+
+ int result = network_transaction_->RestartIgnoringLastError(
+ base::Bind(&DevToolsNetworkTransaction::IOCallback,
+ base::Unretained(this), callback, true));
+ return Throttle(callback, true, result);
+}
+
+int DevToolsNetworkTransaction::RestartWithCertificate(
+ scoped_refptr<net::X509Certificate> client_cert,
+ scoped_refptr<net::SSLPrivateKey> client_private_key,
+ const net::CompletionCallback& callback) {
+ if (CheckFailed())
+ return net::ERR_INTERNET_DISCONNECTED;
+ if (!interceptor_) {
+ return network_transaction_->RestartWithCertificate(
+ std::move(client_cert), std::move(client_private_key), callback);
+ }
+
+ int result = network_transaction_->RestartWithCertificate(
+ std::move(client_cert), std::move(client_private_key),
+ base::Bind(&DevToolsNetworkTransaction::IOCallback,
+ base::Unretained(this), callback, true));
+ return Throttle(callback, true, result);
+}
+
+int DevToolsNetworkTransaction::RestartWithAuth(
+ const net::AuthCredentials& credentials,
+ const net::CompletionCallback& callback) {
+ if (CheckFailed())
+ return net::ERR_INTERNET_DISCONNECTED;
+ if (!interceptor_)
+ return network_transaction_->RestartWithAuth(credentials, callback);
+
+ int result = network_transaction_->RestartWithAuth(
+ credentials, base::Bind(&DevToolsNetworkTransaction::IOCallback,
+ base::Unretained(this), callback, true));
+ return Throttle(callback, true, result);
+}
+
+bool DevToolsNetworkTransaction::IsReadyToRestartForAuth() {
+ return network_transaction_->IsReadyToRestartForAuth();
+}
+
+int DevToolsNetworkTransaction::Read(net::IOBuffer* buf,
+ int buf_len,
+ const net::CompletionCallback& callback) {
+ if (CheckFailed())
+ return net::ERR_INTERNET_DISCONNECTED;
+ if (!interceptor_)
+ return network_transaction_->Read(buf, buf_len, callback);
+
+ int result = network_transaction_->Read(
+ buf, buf_len,
+ base::Bind(&DevToolsNetworkTransaction::IOCallback,
+ base::Unretained(this), callback, false));
+ // URLRequestJob relies on synchronous end-of-stream notification.
+ if (result == 0)
+ return result;
+ return Throttle(callback, false, result);
+}
+
+void DevToolsNetworkTransaction::StopCaching() {
+ network_transaction_->StopCaching();
+}
+
+bool DevToolsNetworkTransaction::GetFullRequestHeaders(
+ net::HttpRequestHeaders* headers) const {
+ return network_transaction_->GetFullRequestHeaders(headers);
+}
+
+int64_t DevToolsNetworkTransaction::GetTotalReceivedBytes() const {
+ return network_transaction_->GetTotalReceivedBytes();
+}
+
+int64_t DevToolsNetworkTransaction::GetTotalSentBytes() const {
+ return network_transaction_->GetTotalSentBytes();
+}
+
+void DevToolsNetworkTransaction::DoneReading() {
+ network_transaction_->DoneReading();
+}
+
+const net::HttpResponseInfo* DevToolsNetworkTransaction::GetResponseInfo()
+ const {
+ return network_transaction_->GetResponseInfo();
+}
+
+net::LoadState DevToolsNetworkTransaction::GetLoadState() const {
+ return network_transaction_->GetLoadState();
+}
+
+void DevToolsNetworkTransaction::SetQuicServerInfo(
+ net::QuicServerInfo* quic_server_info) {
+ network_transaction_->SetQuicServerInfo(quic_server_info);
+}
+
+bool DevToolsNetworkTransaction::GetLoadTimingInfo(
+ net::LoadTimingInfo* load_timing_info) const {
+ return network_transaction_->GetLoadTimingInfo(load_timing_info);
+}
+
+bool DevToolsNetworkTransaction::GetRemoteEndpoint(
+ net::IPEndPoint* endpoint) const {
+ return network_transaction_->GetRemoteEndpoint(endpoint);
+}
+
+void DevToolsNetworkTransaction::PopulateNetErrorDetails(
+ net::NetErrorDetails* details) const {
+ return network_transaction_->PopulateNetErrorDetails(details);
+}
+
+void DevToolsNetworkTransaction::SetPriority(net::RequestPriority priority) {
+ network_transaction_->SetPriority(priority);
+}
+
+void DevToolsNetworkTransaction::SetWebSocketHandshakeStreamCreateHelper(
+ net::WebSocketHandshakeStreamBase::CreateHelper* create_helper) {
+ network_transaction_->SetWebSocketHandshakeStreamCreateHelper(create_helper);
+}
+
+void DevToolsNetworkTransaction::SetBeforeNetworkStartCallback(
+ const BeforeNetworkStartCallback& callback) {
+ network_transaction_->SetBeforeNetworkStartCallback(callback);
+}
+
+void DevToolsNetworkTransaction::SetRequestHeadersCallback(
+ net::RequestHeadersCallback callback) {
+ network_transaction_->SetRequestHeadersCallback(std::move(callback));
+}
+
+void DevToolsNetworkTransaction::SetResponseHeadersCallback(
+ net::ResponseHeadersCallback callback) {
+ network_transaction_->SetResponseHeadersCallback(std::move(callback));
+}
+
+void DevToolsNetworkTransaction::SetBeforeHeadersSentCallback(
+ const BeforeHeadersSentCallback& callback) {
+ network_transaction_->SetBeforeHeadersSentCallback(callback);
+}
+
+int DevToolsNetworkTransaction::ResumeNetworkStart() {
+ if (CheckFailed())
+ return net::ERR_INTERNET_DISCONNECTED;
+ return network_transaction_->ResumeNetworkStart();
+}
+
+void DevToolsNetworkTransaction::GetConnectionAttempts(
+ net::ConnectionAttempts* out) const {
+ network_transaction_->GetConnectionAttempts(out);
+}
+
+} // namespace content
diff --git a/chromium/content/common/devtools/devtools_network_transaction.h b/chromium/content/common/devtools/devtools_network_transaction.h
new file mode 100644
index 00000000000..eee12595878
--- /dev/null
+++ b/chromium/content/common/devtools/devtools_network_transaction.h
@@ -0,0 +1,135 @@
+// Copyright 2014 The Chromium 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 CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_
+#define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_
+
+#include <stdint.h>
+
+#include <memory>
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "content/common/content_export.h"
+#include "content/common/devtools/devtools_network_interceptor.h"
+#include "net/base/completion_callback.h"
+#include "net/base/load_states.h"
+#include "net/base/net_error_details.h"
+#include "net/base/request_priority.h"
+#include "net/http/http_transaction.h"
+#include "net/websockets/websocket_handshake_stream_base.h"
+
+namespace net {
+class AuthCredentials;
+class HttpRequestHeaders;
+struct HttpRequestInfo;
+class HttpResponseInfo;
+class IOBuffer;
+struct LoadTimingInfo;
+class NetLogWithSource;
+class X509Certificate;
+} // namespace net
+
+namespace content {
+
+class DevToolsNetworkController;
+class DevToolsNetworkControllerHelper;
+class DevToolsNetworkUploadDataStream;
+
+// DevToolsNetworkTransaction is a wrapper for network transaction. All
+// HttpTransaction methods are proxied to real transaction, but |callback|
+// parameter is saved and replaced with proxy callback. Fail method should be
+// used to simulate network outage. It runs saved callback (if any) with
+// net::ERR_INTERNET_DISCONNECTED result value.
+class CONTENT_EXPORT DevToolsNetworkTransaction : public net::HttpTransaction {
+ public:
+ static const char kDevToolsEmulateNetworkConditionsClientId[];
+
+ explicit DevToolsNetworkTransaction(
+ std::unique_ptr<net::HttpTransaction> network_transaction);
+
+ ~DevToolsNetworkTransaction() override;
+
+ // HttpTransaction methods:
+ int Start(const net::HttpRequestInfo* request,
+ const net::CompletionCallback& callback,
+ const net::NetLogWithSource& net_log) override;
+ int RestartIgnoringLastError(
+ const net::CompletionCallback& callback) override;
+ int RestartWithCertificate(
+ scoped_refptr<net::X509Certificate> client_cert,
+ scoped_refptr<net::SSLPrivateKey> client_private_key,
+ const net::CompletionCallback& callback) override;
+ int RestartWithAuth(const net::AuthCredentials& credentials,
+ const net::CompletionCallback& callback) override;
+ bool IsReadyToRestartForAuth() override;
+
+ int Read(net::IOBuffer* buf,
+ int buf_len,
+ const net::CompletionCallback& callback) override;
+ void StopCaching() override;
+ bool GetFullRequestHeaders(net::HttpRequestHeaders* headers) const override;
+ int64_t GetTotalReceivedBytes() const override;
+ int64_t GetTotalSentBytes() const override;
+ void DoneReading() override;
+ const net::HttpResponseInfo* GetResponseInfo() const override;
+ net::LoadState GetLoadState() const override;
+ void SetQuicServerInfo(net::QuicServerInfo* quic_server_info) override;
+ bool GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override;
+ bool GetRemoteEndpoint(net::IPEndPoint* endpoint) const override;
+ void PopulateNetErrorDetails(net::NetErrorDetails* details) const override;
+ void SetPriority(net::RequestPriority priority) override;
+ void SetWebSocketHandshakeStreamCreateHelper(
+ net::WebSocketHandshakeStreamBase::CreateHelper* create_helper) override;
+ void SetBeforeNetworkStartCallback(
+ const BeforeNetworkStartCallback& callback) override;
+ void SetBeforeHeadersSentCallback(
+ const BeforeHeadersSentCallback& callback) override;
+ void SetRequestHeadersCallback(net::RequestHeadersCallback callback) override;
+ void SetResponseHeadersCallback(
+ net::ResponseHeadersCallback callback) override;
+ int ResumeNetworkStart() override;
+ void GetConnectionAttempts(net::ConnectionAttempts* out) const override;
+
+ protected:
+ friend class content::DevToolsNetworkControllerHelper;
+
+ private:
+ void Fail();
+ bool CheckFailed();
+
+ void IOCallback(const net::CompletionCallback& callback,
+ bool start,
+ int result);
+ int Throttle(const net::CompletionCallback& callback, bool start, int result);
+ void ThrottleCallback(const net::CompletionCallback& callback,
+ int result,
+ int64_t bytes);
+
+ DevToolsNetworkInterceptor::ThrottleCallback throttle_callback_;
+ int64_t throttled_byte_count_;
+
+ DevToolsNetworkController* controller_;
+ base::WeakPtr<DevToolsNetworkInterceptor> interceptor_;
+
+ // Modified upload data stream. Should be destructed after |custom_request_|.
+ std::unique_ptr<DevToolsNetworkUploadDataStream> custom_upload_data_stream_;
+
+ // Modified request. Should be destructed after |network_transaction_|.
+ std::unique_ptr<net::HttpRequestInfo> custom_request_;
+
+ // Real network transaction.
+ std::unique_ptr<net::HttpTransaction> network_transaction_;
+
+ const net::HttpRequestInfo* request_;
+
+ // True if Fail was already invoked.
+ bool failed_;
+
+ DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkTransaction);
+};
+
+} // namespace content
+
+#endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_H_
diff --git a/chromium/content/common/devtools/devtools_network_transaction_factory.cc b/chromium/content/common/devtools/devtools_network_transaction_factory.cc
new file mode 100644
index 00000000000..7441c8be59e
--- /dev/null
+++ b/chromium/content/common/devtools/devtools_network_transaction_factory.cc
@@ -0,0 +1,45 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/devtools/devtools_network_transaction_factory.h"
+
+#include <set>
+#include <string>
+#include <utility>
+
+#include "content/common/devtools/devtools_network_controller.h"
+#include "content/common/devtools/devtools_network_transaction.h"
+#include "net/base/net_errors.h"
+#include "net/http/http_network_layer.h"
+#include "net/http/http_network_transaction.h"
+
+namespace content {
+
+DevToolsNetworkTransactionFactory::DevToolsNetworkTransactionFactory(
+ net::HttpNetworkSession* session)
+ : network_layer_(new net::HttpNetworkLayer(session)) {}
+
+DevToolsNetworkTransactionFactory::~DevToolsNetworkTransactionFactory() {}
+
+int DevToolsNetworkTransactionFactory::CreateTransaction(
+ net::RequestPriority priority,
+ std::unique_ptr<net::HttpTransaction>* trans) {
+ std::unique_ptr<net::HttpTransaction> network_transaction;
+ int rv = network_layer_->CreateTransaction(priority, &network_transaction);
+ if (rv != net::OK) {
+ return rv;
+ }
+ trans->reset(new DevToolsNetworkTransaction(std::move(network_transaction)));
+ return net::OK;
+}
+
+net::HttpCache* DevToolsNetworkTransactionFactory::GetCache() {
+ return network_layer_->GetCache();
+}
+
+net::HttpNetworkSession* DevToolsNetworkTransactionFactory::GetSession() {
+ return network_layer_->GetSession();
+}
+
+} // namespace content
diff --git a/chromium/content/common/devtools/devtools_network_transaction_factory.h b/chromium/content/common/devtools/devtools_network_transaction_factory.h
new file mode 100644
index 00000000000..5929ed3dcab
--- /dev/null
+++ b/chromium/content/common/devtools/devtools_network_transaction_factory.h
@@ -0,0 +1,42 @@
+// Copyright 2014 The Chromium 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 CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_FACTORY_H_
+#define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_FACTORY_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "net/base/request_priority.h"
+#include "net/http/http_transaction_factory.h"
+
+namespace net {
+class HttpCache;
+class HttpNetworkSession;
+class HttpTransaction;
+} // namespace net
+
+namespace content {
+
+// NetworkTransactionFactory wraps HttpNetworkTransactions.
+class DevToolsNetworkTransactionFactory : public net::HttpTransactionFactory {
+ public:
+ explicit DevToolsNetworkTransactionFactory(net::HttpNetworkSession* session);
+ ~DevToolsNetworkTransactionFactory() override;
+
+ // net::HttpTransactionFactory methods:
+ int CreateTransaction(net::RequestPriority priority,
+ std::unique_ptr<net::HttpTransaction>* trans) override;
+ net::HttpCache* GetCache() override;
+ net::HttpNetworkSession* GetSession() override;
+
+ private:
+ std::unique_ptr<net::HttpTransactionFactory> network_layer_;
+
+ DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkTransactionFactory);
+};
+
+} // namespace content
+
+#endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_NETWORK_TRANSACTION_FACTORY_H_
diff --git a/chromium/content/common/devtools/devtools_network_upload_data_stream.cc b/chromium/content/common/devtools/devtools_network_upload_data_stream.cc
new file mode 100644
index 00000000000..73a745dcca2
--- /dev/null
+++ b/chromium/content/common/devtools/devtools_network_upload_data_stream.cc
@@ -0,0 +1,97 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/devtools/devtools_network_upload_data_stream.h"
+
+#include "net/base/net_errors.h"
+
+namespace content {
+
+DevToolsNetworkUploadDataStream::DevToolsNetworkUploadDataStream(
+ net::UploadDataStream* upload_data_stream)
+ : net::UploadDataStream(upload_data_stream->is_chunked(),
+ upload_data_stream->identifier()),
+ throttle_callback_(
+ base::Bind(&DevToolsNetworkUploadDataStream::ThrottleCallback,
+ base::Unretained(this))),
+ throttled_byte_count_(0),
+ upload_data_stream_(upload_data_stream) {}
+
+DevToolsNetworkUploadDataStream::~DevToolsNetworkUploadDataStream() {
+ if (interceptor_)
+ interceptor_->StopThrottle(throttle_callback_);
+}
+
+void DevToolsNetworkUploadDataStream::SetInterceptor(
+ DevToolsNetworkInterceptor* interceptor) {
+ DCHECK(!interceptor_);
+ if (interceptor)
+ interceptor_ = interceptor->GetWeakPtr();
+}
+
+bool DevToolsNetworkUploadDataStream::IsInMemory() const {
+ return false;
+}
+
+int DevToolsNetworkUploadDataStream::InitInternal(
+ const net::NetLogWithSource& net_log) {
+ throttled_byte_count_ = 0;
+ int result = upload_data_stream_->Init(
+ base::Bind(&DevToolsNetworkUploadDataStream::StreamInitCallback,
+ base::Unretained(this)),
+ net_log);
+ if (result == net::OK && !is_chunked())
+ SetSize(upload_data_stream_->size());
+ return result;
+}
+
+void DevToolsNetworkUploadDataStream::StreamInitCallback(int result) {
+ if (!is_chunked())
+ SetSize(upload_data_stream_->size());
+ OnInitCompleted(result);
+}
+
+int DevToolsNetworkUploadDataStream::ReadInternal(net::IOBuffer* buf,
+ int buf_len) {
+ int result = upload_data_stream_->Read(
+ buf, buf_len,
+ base::Bind(&DevToolsNetworkUploadDataStream::StreamReadCallback,
+ base::Unretained(this)));
+ return ThrottleRead(result);
+}
+
+void DevToolsNetworkUploadDataStream::StreamReadCallback(int result) {
+ result = ThrottleRead(result);
+ if (result != net::ERR_IO_PENDING)
+ OnReadCompleted(result);
+}
+
+int DevToolsNetworkUploadDataStream::ThrottleRead(int result) {
+ if (is_chunked() && upload_data_stream_->IsEOF())
+ SetIsFinalChunk();
+
+ if (!interceptor_ || result < 0)
+ return result;
+
+ if (result > 0)
+ throttled_byte_count_ += result;
+ return interceptor_->StartThrottle(result, throttled_byte_count_,
+ base::TimeTicks(), false, true,
+ throttle_callback_);
+}
+
+void DevToolsNetworkUploadDataStream::ThrottleCallback(int result,
+ int64_t bytes) {
+ throttled_byte_count_ = bytes;
+ OnReadCompleted(result);
+}
+
+void DevToolsNetworkUploadDataStream::ResetInternal() {
+ upload_data_stream_->Reset();
+ throttled_byte_count_ = 0;
+ if (interceptor_)
+ interceptor_->StopThrottle(throttle_callback_);
+}
+
+} // namespace content
diff --git a/chromium/content/common/devtools/devtools_network_upload_data_stream.h b/chromium/content/common/devtools/devtools_network_upload_data_stream.h
new file mode 100644
index 00000000000..3c638e4ba4c
--- /dev/null
+++ b/chromium/content/common/devtools/devtools_network_upload_data_stream.h
@@ -0,0 +1,55 @@
+// Copyright 2015 The Chromium 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 CONTENT_COMMON_DEVTOOLS_DEVTOOLS_NETWORK_UPLOAD_DATA_STREAM_H_
+#define CONTENT_COMMON_DEVTOOLS_DEVTOOLS_NETWORK_UPLOAD_DATA_STREAM_H_
+
+#include <stdint.h>
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "content/common/devtools/devtools_network_interceptor.h"
+#include "net/base/completion_callback.h"
+#include "net/base/upload_data_stream.h"
+
+namespace content {
+
+class DevToolsNetworkInterceptor;
+
+// DevToolsNetworkUploadData is a wrapper for upload data stream, which proxies
+// methods and throttles after the original method succeeds.
+class DevToolsNetworkUploadDataStream : public net::UploadDataStream {
+ public:
+ // Supplied |upload_data_stream| must outlive this object.
+ explicit DevToolsNetworkUploadDataStream(
+ net::UploadDataStream* upload_data_stream);
+ ~DevToolsNetworkUploadDataStream() override;
+
+ void SetInterceptor(DevToolsNetworkInterceptor* interceptor);
+
+ private:
+ // net::UploadDataStream implementation.
+ bool IsInMemory() const override;
+ int InitInternal(const net::NetLogWithSource& net_log) override;
+ int ReadInternal(net::IOBuffer* buf, int buf_len) override;
+ void ResetInternal() override;
+
+ void StreamInitCallback(int result);
+ void StreamReadCallback(int result);
+
+ int ThrottleRead(int result);
+ void ThrottleCallback(int result, int64_t bytes);
+
+ DevToolsNetworkInterceptor::ThrottleCallback throttle_callback_;
+ int64_t throttled_byte_count_;
+
+ net::UploadDataStream* upload_data_stream_;
+ base::WeakPtr<DevToolsNetworkInterceptor> interceptor_;
+
+ DISALLOW_COPY_AND_ASSIGN(DevToolsNetworkUploadDataStream);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_DEVTOOLS_DEVTOOLS_NETWORK_UPLOAD_DATA_STREAM_H_
diff --git a/chromium/content/common/devtools_messages.h b/chromium/content/common/devtools_messages.h
index d8fef04fd9c..49360f76cf5 100644
--- a/chromium/content/common/devtools_messages.h
+++ b/chromium/content/common/devtools_messages.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_DEVTOOLS_MESSAGES_H_
+#define CONTENT_COMMON_DEVTOOLS_MESSAGES_H_
+
// Developer tools consist of the following parts:
//
// DevToolsAgent lives in the renderer of an inspected page and provides access
@@ -38,7 +41,6 @@
//
// This file describes developer tools message types.
-// Multiply-included message file, no standard include guard.
#include <map>
#include <string>
@@ -135,3 +137,5 @@ IPC_MESSAGE_ROUTED1(DevToolsMsg_SetupDevToolsClient,
// Transport from Inspector frontend to frontend host.
IPC_MESSAGE_ROUTED1(DevToolsHostMsg_DispatchOnEmbedder,
std::string /* message */)
+
+#endif // CONTENT_COMMON_DEVTOOLS_MESSAGES_H_
diff --git a/chromium/content/common/dom_storage/dom_storage_map.cc b/chromium/content/common/dom_storage/dom_storage_map.cc
index 5ac8bd57dc7..0a6b0176a98 100644
--- a/chromium/content/common/dom_storage/dom_storage_map.cc
+++ b/chromium/content/common/dom_storage/dom_storage_map.cc
@@ -19,12 +19,12 @@ size_t size_in_memory(const base::string16& key,
return (key.length() + value.string().length()) * sizeof(base::char16);
}
-size_t size_of_item(const base::string16& key, const size_t value) {
+size_t size_in_storage(const base::string16& key, const size_t value) {
return key.length() * sizeof(base::char16) + value;
}
-size_t size_of_item(const base::string16& key,
- const base::NullableString16& value) {
+size_t size_in_storage(const base::string16& key,
+ const base::NullableString16& value) {
// Null value indicates deletion. So, key size is not counted.
return value.is_null() ? 0 : size_in_memory(key, value);
}
@@ -34,8 +34,8 @@ size_t size_of_item(const base::string16& key,
DOMStorageMap::DOMStorageMap(size_t quota) : DOMStorageMap(quota, false) {}
DOMStorageMap::DOMStorageMap(size_t quota, bool has_only_keys)
- : bytes_used_(0),
- memory_usage_(0),
+ : storage_used_(0),
+ memory_used_(0),
quota_(quota),
has_only_keys_(has_only_keys) {
ResetKeyIterator();
@@ -74,12 +74,12 @@ bool DOMStorageMap::SetItem(
const base::string16& key, const base::string16& value,
base::NullableString16* old_value) {
if (has_only_keys_) {
- size_t unused;
size_t value_size = value.length() * sizeof(base::char16);
- return SetItemInternal<KeysMap>(&keys_only_, key, value_size, &unused);
+ return SetItemInternal<KeysMap>(&keys_only_, key, value_size, nullptr);
} else {
base::NullableString16 new_value(value, false);
- *old_value = base::NullableString16();
+ if (old_value)
+ *old_value = base::NullableString16();
return SetItemInternal<DOMStorageValuesMap>(&keys_values_, key, new_value,
old_value);
}
@@ -89,13 +89,12 @@ bool DOMStorageMap::RemoveItem(
const base::string16& key,
base::string16* old_value) {
if (has_only_keys_) {
- size_t unused;
- return RemoveItemInternal<KeysMap>(&keys_only_, key, &unused);
+ return RemoveItemInternal<KeysMap>(&keys_only_, key, nullptr);
} else {
base::NullableString16 nullable_old;
- bool success = RemoveItemInternal<DOMStorageValuesMap>(&keys_values_, key,
- &nullable_old);
- if (success)
+ bool success = RemoveItemInternal<DOMStorageValuesMap>(
+ &keys_values_, key, old_value ? &nullable_old : nullptr);
+ if (success && old_value)
*old_value = nullable_old.string();
return success;
}
@@ -118,22 +117,24 @@ void DOMStorageMap::SwapValues(DOMStorageValuesMap* values) {
// Note: A pre-existing file may be over the quota budget.
DCHECK(!has_only_keys_);
keys_values_.swap(*values);
- bytes_used_ = CountBytes(keys_values_);
+ storage_used_ = CountBytes(keys_values_);
+ memory_used_ = storage_used_;
ResetKeyIterator();
}
-void DOMStorageMap::TakeKeysFrom(const DOMStorageValuesMap* values) {
+void DOMStorageMap::TakeKeysFrom(const DOMStorageValuesMap& values) {
// Note: A pre-existing file may be over the quota budget.
DCHECK(has_only_keys_);
keys_only_.clear();
- memory_usage_ = 0;
- for (const auto& item : *values) {
+ memory_used_ = 0;
+ storage_used_ = 0;
+ for (const auto& item : values) {
keys_only_[item.first] =
item.second.string().length() * sizeof(base::char16);
// Do not count size of values for memory usage.
- memory_usage_ += size_in_memory(item.first, 0 /* unused */);
+ memory_used_ += size_in_memory(item.first, 0 /* unused */);
+ storage_used_ += size_in_storage(item.first, item.second);
}
- bytes_used_ = CountBytes(*values);
ResetKeyIterator();
}
@@ -141,8 +142,8 @@ DOMStorageMap* DOMStorageMap::DeepCopy() const {
DOMStorageMap* copy = new DOMStorageMap(quota_, has_only_keys_);
copy->keys_values_ = keys_values_;
copy->keys_only_ = keys_only_;
- copy->bytes_used_ = bytes_used_;
- copy->memory_usage_ = memory_usage_;
+ copy->storage_used_ = storage_used_;
+ copy->memory_used_ = memory_used_;
copy->ResetKeyIterator();
return copy;
}
@@ -160,35 +161,36 @@ size_t DOMStorageMap::CountBytes(const DOMStorageValuesMap& values) {
size_t count = 0;
for (const auto& pair : values)
- count += size_of_item(pair.first, pair.second);
+ count += size_in_storage(pair.first, pair.second);
return count;
}
template <typename MapType>
bool DOMStorageMap::SetItemInternal(MapType* map_type,
const base::string16& key,
- typename MapType::mapped_type value,
+ const typename MapType::mapped_type& value,
typename MapType::mapped_type* old_value) {
const auto found = map_type->find(key);
size_t old_item_size = 0;
size_t old_item_memory = 0;
if (found != map_type->end()) {
- *old_value = found->second;
- old_item_size = size_of_item(key, *old_value);
- old_item_memory = size_in_memory(key, *old_value);
+ old_item_size = size_in_storage(key, found->second);
+ old_item_memory = size_in_memory(key, found->second);
+ if (old_value)
+ *old_value = found->second;
}
- size_t new_item_size = size_of_item(key, value);
- size_t new_bytes_used = bytes_used_ - old_item_size + new_item_size;
+ size_t new_item_size = size_in_storage(key, value);
+ size_t new_storage_used = storage_used_ - old_item_size + new_item_size;
// Only check quota if the size is increasing, this allows
// shrinking changes to pre-existing files that are over budget.
- if (new_item_size > old_item_size && new_bytes_used > quota_)
+ if (new_item_size > old_item_size && new_storage_used > quota_)
return false;
(*map_type)[key] = value;
ResetKeyIterator();
- bytes_used_ = new_bytes_used;
- memory_usage_ = memory_usage_ + size_in_memory(key, value) - old_item_memory;
+ storage_used_ = new_storage_used;
+ memory_used_ = memory_used_ + size_in_memory(key, value) - old_item_memory;
return true;
}
@@ -200,11 +202,12 @@ bool DOMStorageMap::RemoveItemInternal(
const auto found = map_type->find(key);
if (found == map_type->end())
return false;
- *old_value = found->second;
+ storage_used_ -= size_in_storage(key, found->second);
+ memory_used_ -= size_in_memory(key, found->second);
+ if (old_value)
+ *old_value = found->second;
map_type->erase(found);
ResetKeyIterator();
- bytes_used_ -= size_of_item(key, *old_value);
- memory_usage_ -= size_in_memory(key, *old_value);
return true;
}
diff --git a/chromium/content/common/dom_storage/dom_storage_map.h b/chromium/content/common/dom_storage/dom_storage_map.h
index 4ac21900094..7c154bc1551 100644
--- a/chromium/content/common/dom_storage/dom_storage_map.h
+++ b/chromium/content/common/dom_storage/dom_storage_map.h
@@ -30,9 +30,9 @@ class CONTENT_EXPORT DOMStorageMap
unsigned Length() const;
base::NullableString16 Key(unsigned index);
- // Sets and removes items from the storage. |old_value| is only valid if
- // |has_only_keys| is false. |old_value| is not accessed or modified when
- // |has_only_keys|.
+ // Sets and removes items from the storage. Old value is wriiten into
+ // |old_value| if it's not null and |has_only_keys| is false. |old_value| is
+ // not accessed or modified when |has_only_keys|.
bool SetItem(const base::string16& key, const base::string16& value,
base::NullableString16* old_value);
bool RemoveItem(const base::string16& key, base::string16* old_value);
@@ -52,14 +52,15 @@ class CONTENT_EXPORT DOMStorageMap
// Stores the keys and sizes of values from |map| to |keys_only_|. Use only
// when |has_only_keys| is true. This method does not do quota checking.
- void TakeKeysFrom(const DOMStorageValuesMap* map);
+ void TakeKeysFrom(const DOMStorageValuesMap& map);
// Creates a new instance of DOMStorageMap containing
// a deep copy of the map.
DOMStorageMap* DeepCopy() const;
- size_t bytes_used() const { return bytes_used_; }
- size_t memory_usage() const { return memory_usage_; }
+ const DOMStorageValuesMap& keys_values() const { return keys_values_; }
+ size_t storage_used() const { return storage_used_; }
+ size_t memory_used() const { return memory_used_; }
size_t quota() const { return quota_; }
void set_quota(size_t quota) { quota_ = quota; }
bool has_only_keys() const { return has_only_keys_; }
@@ -77,7 +78,7 @@ class CONTENT_EXPORT DOMStorageMap
template <typename MapType>
bool SetItemInternal(MapType* map_type,
const base::string16& key,
- typename MapType::mapped_type value,
+ const typename MapType::mapped_type& value,
typename MapType::mapped_type* old_value);
template <typename MapType>
bool RemoveItemInternal(MapType* map_type,
@@ -94,8 +95,8 @@ class CONTENT_EXPORT DOMStorageMap
DOMStorageValuesMap::const_iterator keys_values_iterator_;
KeysMap::const_iterator keys_only_iterator_;
unsigned last_key_index_;
- size_t bytes_used_;
- size_t memory_usage_;
+ size_t storage_used_;
+ size_t memory_used_;
size_t quota_;
const bool has_only_keys_;
};
diff --git a/chromium/content/common/dom_storage/dom_storage_map_unittest.cc b/chromium/content/common/dom_storage/dom_storage_map_unittest.cc
index 90a51f5a04d..bad1d7d44f5 100644
--- a/chromium/content/common/dom_storage/dom_storage_map_unittest.cc
+++ b/chromium/content/common/dom_storage/dom_storage_map_unittest.cc
@@ -47,13 +47,13 @@ TEST_P(DOMStorageMapParamTest, DOMStorageMapBasics) {
EXPECT_TRUE(map->Key(100).is_null());
if (!has_only_keys)
EXPECT_TRUE(map->GetItem(kKey).is_null());
- EXPECT_FALSE(map->RemoveItem(kKey, &old_value));
- EXPECT_EQ(0u, map->bytes_used());
+ EXPECT_FALSE(map->RemoveItem(kKey, nullptr));
+ EXPECT_EQ(0u, map->storage_used());
copy = map->DeepCopy();
EXPECT_EQ(0u, copy->Length());
- EXPECT_EQ(0u, copy->bytes_used());
+ EXPECT_EQ(0u, copy->storage_used());
if (has_only_keys)
- map->TakeKeysFrom(&swap);
+ map->TakeKeysFrom(swap);
else
map->SwapValues(&swap);
EXPECT_TRUE(swap.empty());
@@ -69,25 +69,25 @@ TEST_P(DOMStorageMapParamTest, DOMStorageMapBasics) {
EXPECT_EQ(kValue, map->GetItem(kKey).string());
EXPECT_TRUE(map->GetItem(kKey2).is_null());
}
- EXPECT_EQ(kItemBytes, map->bytes_used());
+ EXPECT_EQ(kItemBytes, map->storage_used());
EXPECT_TRUE(map->RemoveItem(kKey, &old_value));
if (!has_only_keys)
EXPECT_EQ(kValue, old_value);
old_value.clear();
- EXPECT_EQ(0u, map->bytes_used());
+ EXPECT_EQ(0u, map->storage_used());
- EXPECT_TRUE(map->SetItem(kKey, kValue, &old_nullable_value));
- EXPECT_TRUE(map->SetItem(kKey2, kValue, &old_nullable_value));
- EXPECT_EQ(kItemBytes + kKey2Bytes + kValueBytes, map->bytes_used());
+ EXPECT_TRUE(map->SetItem(kKey, kValue, nullptr));
+ EXPECT_TRUE(map->SetItem(kKey2, kValue, nullptr));
+ EXPECT_EQ(kItemBytes + kKey2Bytes + kValueBytes, map->storage_used());
EXPECT_TRUE(map->SetItem(kKey2, kValue2, &old_nullable_value));
if (!has_only_keys)
EXPECT_EQ(kValue, old_nullable_value.string());
- EXPECT_EQ(kItemBytes + kItem2Bytes, map->bytes_used());
+ EXPECT_EQ(kItemBytes + kItem2Bytes, map->storage_used());
EXPECT_EQ(2u, map->Length());
EXPECT_EQ(kKey, map->Key(0).string());
EXPECT_EQ(kKey2, map->Key(1).string());
EXPECT_EQ(kKey, map->Key(0).string());
- EXPECT_EQ(kItemBytes + kItem2Bytes, map->bytes_used());
+ EXPECT_EQ(kItemBytes + kItem2Bytes, map->storage_used());
copy = map->DeepCopy();
EXPECT_EQ(2u, copy->Length());
@@ -98,14 +98,14 @@ TEST_P(DOMStorageMapParamTest, DOMStorageMapBasics) {
EXPECT_EQ(kKey, copy->Key(0).string());
EXPECT_EQ(kKey2, copy->Key(1).string());
EXPECT_TRUE(copy->Key(2).is_null());
- EXPECT_EQ(kItemBytes + kItem2Bytes, copy->bytes_used());
+ EXPECT_EQ(kItemBytes + kItem2Bytes, copy->storage_used());
if (has_only_keys)
- map->TakeKeysFrom(&swap);
+ map->TakeKeysFrom(swap);
else
map->SwapValues(&swap);
EXPECT_EQ(0u, map->Length());
- EXPECT_EQ(0u, map->bytes_used());
+ EXPECT_EQ(0u, map->storage_used());
}
TEST_P(DOMStorageMapParamTest, EnforcesQuota) {
@@ -122,17 +122,17 @@ TEST_P(DOMStorageMapParamTest, EnforcesQuota) {
const size_t kQuota = 50;
scoped_refptr<DOMStorageMap> map(new DOMStorageMap(kQuota, has_only_keys));
- EXPECT_TRUE(map->SetItem(kKey, kValue, &old_nullable_value));
- EXPECT_FALSE(map->SetItem(kKey2, kValue, &old_nullable_value));
+ EXPECT_TRUE(map->SetItem(kKey, kValue, nullptr));
+ EXPECT_FALSE(map->SetItem(kKey2, kValue, nullptr));
if (has_only_keys)
EXPECT_EQ(kValueSize, map->keys_only_[kKey]);
else
EXPECT_EQ(kValue, map->keys_values_[kKey].string());
EXPECT_EQ(1u, map->Length());
- EXPECT_TRUE(map->RemoveItem(kKey, &old_value));
+ EXPECT_TRUE(map->RemoveItem(kKey, nullptr));
EXPECT_EQ(0u, map->Length());
- EXPECT_TRUE(map->SetItem(kKey2, kValue, &old_nullable_value));
+ EXPECT_TRUE(map->SetItem(kKey2, kValue, nullptr));
EXPECT_EQ(1u, map->Length());
// Verify that the TakeKeysFrom method does not do quota checking.
@@ -140,17 +140,16 @@ TEST_P(DOMStorageMapParamTest, EnforcesQuota) {
swap[kKey] = base::NullableString16(kValue, false);
swap[kKey2] = base::NullableString16(kValue, false);
if (has_only_keys)
- map->TakeKeysFrom(&swap);
+ map->TakeKeysFrom(swap);
else
map->SwapValues(&swap);
- EXPECT_GT(map->bytes_used(), kQuota);
+ EXPECT_GT(map->storage_used(), kQuota);
// When overbudget, a new value of greater size than the existing value can
// not be set, but a new value of lesser or equal size can be set.
- EXPECT_TRUE(map->SetItem(kKey, kValue, &old_nullable_value));
- EXPECT_FALSE(
- map->SetItem(kKey, base::string16(kValue + kValue), &old_nullable_value));
- EXPECT_TRUE(map->SetItem(kKey, base::string16(), &old_nullable_value));
+ EXPECT_TRUE(map->SetItem(kKey, kValue, nullptr));
+ EXPECT_FALSE(map->SetItem(kKey, base::string16(kValue + kValue), nullptr));
+ EXPECT_TRUE(map->SetItem(kKey, base::string16(), nullptr));
if (has_only_keys)
EXPECT_EQ(0u, map->keys_only_[kKey]);
else
@@ -171,19 +170,19 @@ TEST_P(DOMStorageMapParamTest, MemoryUsage) {
scoped_refptr<DOMStorageMap> map(
new DOMStorageMap(1024 /* quota */, has_only_keys));
- EXPECT_TRUE(map->SetItem(kKey, kValue, &old_nullable_value));
- EXPECT_TRUE(map->SetItem(kKey2, kValue, &old_nullable_value));
+ EXPECT_TRUE(map->SetItem(kKey, kValue, nullptr));
+ EXPECT_TRUE(map->SetItem(kKey2, kValue, nullptr));
if (has_only_keys) {
- EXPECT_EQ(kKeySize + kKey2Size + 2 * kValueSize, map->memory_usage());
+ EXPECT_EQ(kKeySize + kKey2Size + 2 * kValueSize, map->memory_used());
} else {
- EXPECT_EQ(map->bytes_used(), map->memory_usage());
+ EXPECT_EQ(map->storage_used(), map->memory_used());
}
- EXPECT_TRUE(map->RemoveItem(kKey, &old_value));
+ EXPECT_TRUE(map->RemoveItem(kKey, nullptr));
if (has_only_keys) {
- EXPECT_EQ(kKey2Size + kValueSize, map->memory_usage());
+ EXPECT_EQ(kKey2Size + kValueSize, map->memory_used());
} else {
- EXPECT_EQ(map->bytes_used(), map->memory_usage());
+ EXPECT_EQ(map->storage_used(), map->memory_used());
}
}
diff --git a/chromium/content/common/dom_storage/dom_storage_messages.h b/chromium/content/common/dom_storage/dom_storage_messages.h
index dc552833a92..af1916591bc 100644
--- a/chromium/content/common/dom_storage/dom_storage_messages.h
+++ b/chromium/content/common/dom_storage/dom_storage_messages.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Multiply-included message file, no traditional include guard.
+#ifndef CONTENT_COMMON_DOM_STORAGE_DOM_STORAGE_MESSAGES_H_
+#define CONTENT_COMMON_DOM_STORAGE_DOM_STORAGE_MESSAGES_H_
#include <stdint.h>
@@ -99,3 +100,5 @@ IPC_MESSAGE_CONTROL2(DOMStorageHostMsg_Clear,
// Used to flush the ipc message queue.
IPC_SYNC_MESSAGE_CONTROL0_0(DOMStorageHostMsg_FlushMessages)
+
+#endif // CONTENT_COMMON_DOM_STORAGE_DOM_STORAGE_MESSAGES_H_
diff --git a/chromium/content/common/drag_messages.h b/chromium/content/common/drag_messages.h
index d1b50db45c4..9d790d0e5da 100644
--- a/chromium/content/common/drag_messages.h
+++ b/chromium/content/common/drag_messages.h
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_DRAG_MESSAGES_H_
+#define CONTENT_COMMON_DRAG_MESSAGES_H_
+
// IPC messages for drag and drop.
-// Multiply-included message file, hence no include guard.
#include <vector>
@@ -68,3 +70,5 @@ IPC_MESSAGE_ROUTED5(DragHostMsg_StartDragging,
// |is_drop_target| is true if the mouse is over a valid drop target.
IPC_MESSAGE_ROUTED1(DragHostMsg_UpdateDragCursor,
blink::WebDragOperation /* drag_operation */)
+
+#endif // CONTENT_COMMON_DRAG_MESSAGES_H_
diff --git a/chromium/content/common/dwrite_font_proxy_messages.h b/chromium/content/common/dwrite_font_proxy_messages.h
index 027ce3387a1..e8534eba169 100644
--- a/chromium/content/common/dwrite_font_proxy_messages.h
+++ b/chromium/content/common/dwrite_font_proxy_messages.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_DWRITE_FONT_PROXY_MESSAGES_H_
+#define CONTENT_COMMON_DWRITE_FONT_PROXY_MESSAGES_H_
+
#include <stdint.h>
#include <utility>
@@ -16,13 +19,13 @@
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
#define IPC_MESSAGE_START DWriteFontProxyMsgStart
-#ifndef CONTENT_COMMON_DWRITE_FONT_PROXY_MESSAGES_H_
-#define CONTENT_COMMON_DWRITE_FONT_PROXY_MESSAGES_H_
+#ifndef INTERNAL_CONTENT_COMMON_DWRITE_FONT_PROXY_MESSAGES_H_
+#define INTERNAL_CONTENT_COMMON_DWRITE_FONT_PROXY_MESSAGES_H_
// The macros can't handle a complex template declaration, so we typedef it.
typedef std::pair<base::string16, base::string16> DWriteStringPair;
-#endif // CONTENT_COMMON_DWRITE_FONT_PROXY_MESSAGES_H_
+#endif // INTERNAL_CONTENT_COMMON_DWRITE_FONT_PROXY_MESSAGES_H_
IPC_STRUCT_BEGIN(DWriteFontStyle)
IPC_STRUCT_MEMBER(uint16_t, font_weight)
@@ -76,3 +79,5 @@ IPC_SYNC_MESSAGE_CONTROL5_1(DWriteFontProxyMsg_MapCharacters,
uint32_t /* reading_direction */,
base::string16 /* base_family_name - optional */,
MapCharactersResult /* out */)
+
+#endif // CONTENT_COMMON_DWRITE_FONT_PROXY_MESSAGES_H_
diff --git a/chromium/content/common/feature_policy/feature_policy.cc b/chromium/content/common/feature_policy/feature_policy.cc
index 82551756e7f..3c2f3ed1c4d 100644
--- a/chromium/content/common/feature_policy/feature_policy.cc
+++ b/chromium/content/common/feature_policy/feature_policy.cc
@@ -208,7 +208,7 @@ const FeaturePolicy::FeatureList& FeaturePolicy::GetDefaultFeatureList() {
CR_DEFINE_STATIC_LOCAL(FeatureList, default_feature_list,
({{blink::WebFeaturePolicyFeature::kCamera,
FeaturePolicy::FeatureDefault::EnableForSelf},
- {blink::WebFeaturePolicyFeature::kEme,
+ {blink::WebFeaturePolicyFeature::kEncryptedMedia,
FeaturePolicy::FeatureDefault::EnableForSelf},
{blink::WebFeaturePolicyFeature::kFullscreen,
FeaturePolicy::FeatureDefault::EnableForSelf},
diff --git a/chromium/content/common/file_utilities.mojom b/chromium/content/common/file_utilities.mojom
new file mode 100644
index 00000000000..6380261f935
--- /dev/null
+++ b/chromium/content/common/file_utilities.mojom
@@ -0,0 +1,15 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module content.mojom;
+
+import "mojo/common/file_info.mojom";
+import "mojo/common/file_path.mojom";
+
+// File utilities messages sent from the renderer to the browser.
+interface FileUtilitiesHost {
+ [Sync]
+ GetFileInfo(mojo.common.mojom.FilePath path) => (
+ mojo.common.mojom.FileInfo? result);
+};
diff --git a/chromium/content/common/file_utilities_messages.h b/chromium/content/common/file_utilities_messages.h
deleted file mode 100644
index 09e37b0a1cc..00000000000
--- a/chromium/content/common/file_utilities_messages.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Multiply-included message file, so no include guard.
-
-#include "content/public/common/common_param_traits.h"
-#include "ipc/ipc_message_macros.h"
-#include "ipc/ipc_param_traits.h"
-#include "ipc/ipc_platform_file.h"
-
-#define IPC_MESSAGE_START FileUtilitiesMsgStart
-
-// File utilities messages sent from the renderer to the browser.
-
-IPC_SYNC_MESSAGE_CONTROL1_2(FileUtilitiesMsg_GetFileInfo,
- base::FilePath /* path */,
- base::File::Info /* result */,
- base::File::Error /* status */)
diff --git a/chromium/content/common/fileapi/file_system_messages.h b/chromium/content/common/fileapi/file_system_messages.h
index 894823eb947..db4d87b3092 100644
--- a/chromium/content/common/fileapi/file_system_messages.h
+++ b/chromium/content/common/fileapi/file_system_messages.h
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_FILEAPI_FILE_SYSTEM_MESSAGES_H_
+#define CONTENT_COMMON_FILEAPI_FILE_SYSTEM_MESSAGES_H_
+
// IPC messages for the file system.
-// Multiply-included message file, hence no include guard.
#include <stdint.h>
@@ -30,7 +32,8 @@ IPC_STRUCT_TRAITS_BEGIN(storage::FileSystemInfo)
IPC_STRUCT_TRAITS_MEMBER(mount_type)
IPC_STRUCT_TRAITS_END()
-IPC_ENUM_TRAITS(storage::FileSystemType)
+IPC_ENUM_TRAITS_MAX_VALUE(storage::FileSystemType,
+ storage::FileSystemType::kFileSystemTypeLast)
IPC_ENUM_TRAITS_MAX_VALUE(storage::QuotaLimitType, storage::kQuotaLimitTypeLast)
// File system messages sent from the browser to the child process.
@@ -163,3 +166,5 @@ IPC_MESSAGE_CONTROL1(FileSystemHostMsg_DidReceiveSnapshotFile,
IPC_SYNC_MESSAGE_CONTROL1_1(FileSystemHostMsg_SyncGetPlatformPath,
GURL /* file path */,
base::FilePath /* platform_path */)
+
+#endif // CONTENT_COMMON_FILEAPI_FILE_SYSTEM_MESSAGES_H_
diff --git a/chromium/content/common/fileapi/webblob_messages.h b/chromium/content/common/fileapi/webblob_messages.h
index 48229204fbe..40808bb39ba 100644
--- a/chromium/content/common/fileapi/webblob_messages.h
+++ b/chromium/content/common/fileapi/webblob_messages.h
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_FILEAPI_WEBBLOB_MESSAGES_H_
+#define CONTENT_COMMON_FILEAPI_WEBBLOB_MESSAGES_H_
+
// IPC messages for HTML5 Blob and Stream.
-// Multiply-included message file, hence no include guard.
#include <stddef.h>
@@ -96,3 +98,5 @@ IPC_SYNC_MESSAGE_CONTROL2_0(BlobHostMsg_RegisterPublicURL,
std::string /* uuid */)
IPC_MESSAGE_CONTROL1(BlobHostMsg_RevokePublicURL,
GURL)
+
+#endif // CONTENT_COMMON_FILEAPI_WEBBLOB_MESSAGES_H_ \ No newline at end of file
diff --git a/chromium/content/common/font_cache_dispatcher_win.cc b/chromium/content/common/font_cache_dispatcher_win.cc
index 09da8f76cdb..a4c897c2589 100644
--- a/chromium/content/common/font_cache_dispatcher_win.cc
+++ b/chromium/content/common/font_cache_dispatcher_win.cc
@@ -9,7 +9,6 @@
#include "base/logging.h"
#include "base/macros.h"
-#include "base/profiler/scoped_tracker.h"
#include "base/strings/string16.h"
#include "content/common/child_process_messages.h"
@@ -23,10 +22,6 @@ class FontCache {
static FontCache* GetInstance() { return base::Singleton<FontCache>::get(); }
void PreCacheFont(const LOGFONT& font, FontCacheDispatcher* dispatcher) {
- // TODO(ananta): Remove ScopedTracker below once crbug.com/90127 is fixed.
- tracked_objects::ScopedTracker tracking_profile(
- FROM_HERE_WITH_EXPLICIT_FUNCTION("90127 FontCache::PreCacheFont"));
-
base::AutoLock lock(mutex_);
// Fetch the font into memory.
diff --git a/chromium/content/common/frame.mojom b/chromium/content/common/frame.mojom
index 613037782fd..2960e7c7a01 100644
--- a/chromium/content/common/frame.mojom
+++ b/chromium/content/common/frame.mojom
@@ -92,6 +92,13 @@ struct CreateNewWindowReply {
int64 cloned_session_storage_namespace_id;
};
+// An opaque handle that keeps alive the associated render process even after
+// the frame is detached. Used by resource requests with "keepalive" specified.
+interface KeepAliveHandle {};
+
+[Native]
+struct DidCommitProvisionalLoadParams;
+
// Implemented by the frame server (i.e. the browser process). For messages that
// must be associated with the IPC channel.
interface FrameHost {
@@ -100,4 +107,11 @@ interface FrameHost {
// be created.
[Sync] CreateNewWindow(CreateNewWindowParams params)
=> (CreateNewWindowReply reply);
+
+ // Creates and returns a KeepAliveHandle.
+ IssueKeepAliveHandle(KeepAliveHandle& keep_alive_handle);
+
+ // Sent by the renderer when a navigation commits in the frame.
+ DidCommitProvisionalLoad(
+ DidCommitProvisionalLoadParams params);
};
diff --git a/chromium/content/common/frame_messages.h b/chromium/content/common/frame_messages.h
index cd68128c616..18c4b420d78 100644
--- a/chromium/content/common/frame_messages.h
+++ b/chromium/content/common/frame_messages.h
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_FRAME_MESSAGES_H_
+#define CONTENT_COMMON_FRAME_MESSAGES_H_
+
// IPC messages for interacting with frames.
-// Multiply-included message file, hence no include guard.
#include <stddef.h>
#include <stdint.h>
@@ -26,7 +28,6 @@
#include "content/common/frame_message_enums.h"
#include "content/common/frame_owner_properties.h"
#include "content/common/frame_replication_state.h"
-#include "content/common/message_port.h"
#include "content/common/navigation_gesture.h"
#include "content/common/navigation_params.h"
#include "content/common/savable_subframe.h"
@@ -51,6 +52,7 @@
#include "ipc/ipc_platform_file.h"
#include "mojo/public/cpp/system/message_pipe.h"
#include "ppapi/features/features.h"
+#include "third_party/WebKit/common/message_port/message_port_channel.h"
#include "third_party/WebKit/public/platform/WebFeaturePolicy.h"
#include "third_party/WebKit/public/platform/WebFocusType.h"
#include "third_party/WebKit/public/platform/WebInsecureRequestPolicy.h"
@@ -73,8 +75,8 @@
#endif
// Singly-included section for type definitions.
-#ifndef CONTENT_COMMON_FRAME_MESSAGES_H_
-#define CONTENT_COMMON_FRAME_MESSAGES_H_
+#ifndef INTERNAL_CONTENT_COMMON_FRAME_MESSAGES_H_
+#define INTERNAL_CONTENT_COMMON_FRAME_MESSAGES_H_
using FrameMsg_GetSerializedHtmlWithLocalLinks_UrlMap =
std::map<GURL, base::FilePath>;
@@ -84,7 +86,7 @@ using FrameMsg_GetSerializedHtmlWithLocalLinks_FrameRoutingIdMap =
using FrameMsg_SerializeAsMHTML_FrameRoutingIdToContentIdMap =
std::map<int, std::string>;
-#endif // CONTENT_COMMON_FRAME_MESSAGES_H_
+#endif // INTERNAL_CONTENT_COMMON_FRAME_MESSAGES_H_
#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
@@ -214,7 +216,6 @@ IPC_STRUCT_END()
IPC_STRUCT_TRAITS_BEGIN(content::FrameNavigateParams)
IPC_STRUCT_TRAITS_MEMBER(nav_entry_id)
- IPC_STRUCT_TRAITS_MEMBER(frame_unique_name)
IPC_STRUCT_TRAITS_MEMBER(item_sequence_number)
IPC_STRUCT_TRAITS_MEMBER(document_sequence_number)
IPC_STRUCT_TRAITS_MEMBER(url)
@@ -227,8 +228,8 @@ IPC_STRUCT_TRAITS_BEGIN(content::FrameNavigateParams)
IPC_STRUCT_TRAITS_MEMBER(socket_address)
IPC_STRUCT_TRAITS_END()
-// Parameters structure for FrameHostMsg_DidCommitProvisionalLoad, which has
-// too many data parameters to be reasonably put in a predefined IPC message.
+// Parameters structure for mojom::FrameHost::DidCommitProvisionalLoad.
+// TODO(https://crbug.com/729021): Convert this to a Mojo struct.
IPC_STRUCT_BEGIN_WITH_PARENT(FrameHostMsg_DidCommitProvisionalLoad_Params,
content::FrameNavigateParams)
IPC_STRUCT_TRAITS_PARENT(content::FrameNavigateParams)
@@ -340,7 +341,7 @@ IPC_STRUCT_BEGIN(FrameMsg_PostMessage_Params)
IPC_STRUCT_MEMBER(base::string16, target_origin)
// Information about the MessagePorts this message contains.
- IPC_STRUCT_MEMBER(std::vector<content::MessagePort>, message_ports)
+ IPC_STRUCT_MEMBER(std::vector<blink::MessagePortChannel>, message_ports)
IPC_STRUCT_END()
IPC_STRUCT_TRAITS_BEGIN(content::SourceLocation)
@@ -1091,9 +1092,12 @@ IPC_MESSAGE_ROUTED4(FrameHostMsg_DidAddMessageToConsole,
//
// Each of these messages will have a corresponding FrameHostMsg_Detach message
// sent when the frame is detached from the DOM.
-IPC_SYNC_MESSAGE_CONTROL1_1(FrameHostMsg_CreateChildFrame,
+// Note that |new_render_frame_id| and |devtools_frame_token| are out
+// parameters. Browser process defines them for the renderer process.
+IPC_SYNC_MESSAGE_CONTROL1_2(FrameHostMsg_CreateChildFrame,
FrameHostMsg_CreateChildFrame_Params,
- int32_t /* new_routing_id */)
+ int32_t /* new_routing_id */,
+ base::UnguessableToken /* devtools_frame_token */)
// Sent by the renderer to the parent RenderFrameHost when a child frame is
// detached from the DOM.
@@ -1118,12 +1122,6 @@ IPC_MESSAGE_ROUTED3(FrameHostMsg_DidStartProvisionalLoad,
IPC_MESSAGE_ROUTED1(FrameHostMsg_DidFailProvisionalLoadWithError,
FrameHostMsg_DidFailProvisionalLoadWithError_Params)
-// Notifies the browser that a frame in the view has changed. This message
-// has a lot of parameters and is packed/unpacked by functions defined in
-// render_messages.h.
-IPC_MESSAGE_ROUTED1(FrameHostMsg_DidCommitProvisionalLoad,
- FrameHostMsg_DidCommitProvisionalLoad_Params)
-
// Notifies the browser that a document has been loaded.
IPC_MESSAGE_ROUTED0(FrameHostMsg_DidFinishDocumentLoad)
@@ -1468,10 +1466,6 @@ IPC_MESSAGE_ROUTED1(FrameHostMsg_SetIsInert, bool /* inert */)
// propagated to any remote frames.
IPC_MESSAGE_ROUTED0(FrameHostMsg_SetHasReceivedUserGesture)
-// Used to tell the browser what the DevTools FrameId is. Needed by Headless
-// Chrome.
-IPC_MESSAGE_ROUTED1(FrameHostMsg_SetDevToolsFrameId, std::string)
-
// Used to tell the parent that the user right clicked on an area of the
// content area, and a context menu should be shown for it. The params
// object contains information about the node(s) that were selected when the
@@ -1692,6 +1686,13 @@ IPC_MESSAGE_ROUTED1(FrameHostMsg_RunFileChooser, content::FileChooserParams)
IPC_MESSAGE_ROUTED1(FrameHostMsg_UpdateFaviconURL,
std::vector<content::FaviconURL> /* candidates */)
+// A message from HTML-based UI. When (trusted) Javascript calls
+// send(message, args), this message is sent to the browser.
+IPC_MESSAGE_ROUTED3(FrameHostMsg_WebUISend,
+ GURL /* source_url */,
+ std::string /* message */,
+ base::ListValue /* args */)
+
#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
// Message to show/hide a popup menu using native controls.
@@ -1727,11 +1728,11 @@ IPC_MESSAGE_ROUTED3(FrameHostMsg_FindMatchRects_Reply,
IPC_MESSAGE_ROUTED2(FrameHostMsg_GetNearestFindResult_Reply,
int /* nfr_request_id */,
float /* distance */)
-
-IPC_MESSAGE_ROUTED0(FrameHostMsg_NavigationHandledByEmbedder)
#endif
// Adding a new message? Stick to the sort order above: first platform
// independent FrameMsg, then ifdefs for platform specific FrameMsg, then
// platform independent FrameHostMsg, then ifdefs for platform specific
// FrameHostMsg.
+
+#endif // CONTENT_COMMON_FRAME_MESSAGES_H_
diff --git a/chromium/content/common/frame_messages.typemap b/chromium/content/common/frame_messages.typemap
new file mode 100644
index 00000000000..49385119f81
--- /dev/null
+++ b/chromium/content/common/frame_messages.typemap
@@ -0,0 +1,8 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+mojom = "//content/common/frame.mojom"
+public_headers = [ "//content/common/frame_messages_forward.h" ]
+traits_headers = [ "//content/common/frame_messages.h" ]
+type_mappings = [ "content.mojom.DidCommitProvisionalLoadParams=std::unique_ptr<::FrameHostMsg_DidCommitProvisionalLoad_Params>[move_only,nullable_is_same_type]" ]
diff --git a/chromium/content/common/frame_messages_forward.h b/chromium/content/common/frame_messages_forward.h
new file mode 100644
index 00000000000..3e83e199d73
--- /dev/null
+++ b/chromium/content/common/frame_messages_forward.h
@@ -0,0 +1,25 @@
+// Copyright 2017 The Chromium 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 CONTENT_COMMON_FRAME_MESSAGES_FORWARD_H_
+#define CONTENT_COMMON_FRAME_MESSAGES_FORWARD_H_
+
+// Forward-declaration for FrameHostMsg_DidCommitProvisionalLoad_Params, which
+// is typemapped to a Mojo [Native] type used by content::mojom::FrameHost. This
+// means that the generated header for mojom::FrameHost requires (at least) a
+// forward declaration of the legacy IPC struct type.
+//
+// Including content/common/frame_messages.h in the generated header for
+// mojom::FrameHost is, however, not possible because legacy IPC struct type
+// definition headers must be included exactly once in each translation unit
+// using them, so any .cc files directly/indirectly including frame_messages.h
+// could no longer include the generated header for mojom::FrameHost. Hence the
+// generated header for mojom::FrameHost does not include frame_messages.h, but
+// instead includes the forward-declaration below.
+//
+// TODO(https://crbug.com/729021): Eventually convert this legacy IPC struct to
+// a proper Mojo type.
+struct FrameHostMsg_DidCommitProvisionalLoad_Params;
+
+#endif // CONTENT_COMMON_FRAME_MESSAGES_FORWARD_H_
diff --git a/chromium/content/common/gin_java_bridge_messages.h b/chromium/content/common/gin_java_bridge_messages.h
index 64a68747ec7..69efa4f3c55 100644
--- a/chromium/content/common/gin_java_bridge_messages.h
+++ b/chromium/content/common/gin_java_bridge_messages.h
@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// IPC messages for injected Java objects (Gin-based implementation).
+#ifndef CONTENT_COMMON_GIN_JAVA_BRIDGE_MESSAGES_H_
+#define CONTENT_COMMON_GIN_JAVA_BRIDGE_MESSAGES_H_
-// Multiply-included message file, hence no include guard.
+// IPC messages for injected Java objects (Gin-based implementation).
#include <stdint.h>
@@ -73,3 +74,5 @@ IPC_SYNC_MESSAGE_ROUTED3_2(GinJavaBridgeHostMsg_InvokeMethod,
// this expectation has failed.
IPC_MESSAGE_ROUTED1(GinJavaBridgeHostMsg_ObjectWrapperDeleted,
int32_t /* object_id */)
+
+#endif // CONTENT_COMMON_GIN_JAVA_BRIDGE_MESSAGES_H_
diff --git a/chromium/content/common/gpu_stream_constants.h b/chromium/content/common/gpu_stream_constants.h
index f3b0254aa7a..c2621165cb5 100644
--- a/chromium/content/common/gpu_stream_constants.h
+++ b/chromium/content/common/gpu_stream_constants.h
@@ -17,9 +17,9 @@ enum {
const gpu::SchedulingPriority kGpuStreamPriorityDefault =
gpu::SchedulingPriority::kNormal;
const gpu::SchedulingPriority kGpuStreamPriorityUI =
- gpu::SchedulingPriority::kHighest;
+ gpu::SchedulingPriority::kHigh;
const gpu::SchedulingPriority kGpuStreamPriorityWorker =
- gpu::SchedulingPriority::kLowest;
+ gpu::SchedulingPriority::kLow;
} // namespace content
diff --git a/chromium/content/common/histogram_fetcher.mojom b/chromium/content/common/histogram_fetcher.mojom
new file mode 100644
index 00000000000..aa78cc94733
--- /dev/null
+++ b/chromium/content/common/histogram_fetcher.mojom
@@ -0,0 +1,17 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module content.mojom;
+
+interface ChildHistogramFetcherFactory {
+ // Creates a ChildHistogram interface that uses shared memory buffer to
+ // store histograms that are to be reported by the browser process to UMA.
+ CreateFetcher(handle<shared_buffer>? shm_handle,
+ ChildHistogramFetcher& child_histogram_fetcher);
+};
+
+interface ChildHistogramFetcher{
+ // Send to all the child processes to send back histogram data.
+ GetChildNonPersistentHistogramData() => (array<string> deltas);
+};
diff --git a/chromium/content/common/indexed_db/indexed_db.mojom b/chromium/content/common/indexed_db/indexed_db.mojom
index 8835113a833..e6cf26fdbb8 100644
--- a/chromium/content/common/indexed_db/indexed_db.mojom
+++ b/chromium/content/common/indexed_db/indexed_db.mojom
@@ -11,6 +11,7 @@ module indexed_db.mojom;
import "mojo/common/file_path.mojom";
import "mojo/common/string16.mojom";
import "mojo/common/time.mojom";
+import "storage/public/interfaces/blobs.mojom";
import "url/mojo/origin.mojom";
enum CursorDirection {
@@ -136,6 +137,7 @@ struct FileInfo {
};
struct BlobInfo {
+ storage.mojom.Blob? blob;
string uuid;
mojo.common.mojom.String16 mime_type;
int64 size;
diff --git a/chromium/content/common/indexed_db/indexed_db_key_path.cc b/chromium/content/common/indexed_db/indexed_db_key_path.cc
index 8644b872ad7..731b12854d0 100644
--- a/chromium/content/common/indexed_db/indexed_db_key_path.cc
+++ b/chromium/content/common/indexed_db/indexed_db_key_path.cc
@@ -21,9 +21,12 @@ IndexedDBKeyPath::IndexedDBKeyPath(const std::vector<base::string16>& array)
: type_(kWebIDBKeyPathTypeArray), array_(array) {}
IndexedDBKeyPath::IndexedDBKeyPath(const IndexedDBKeyPath& other) = default;
+IndexedDBKeyPath::IndexedDBKeyPath(IndexedDBKeyPath&& other) = default;
IndexedDBKeyPath::~IndexedDBKeyPath() = default;
IndexedDBKeyPath& IndexedDBKeyPath::operator=(const IndexedDBKeyPath& other) =
default;
+IndexedDBKeyPath& IndexedDBKeyPath::operator=(IndexedDBKeyPath&& other) =
+ default;
const std::vector<base::string16>& IndexedDBKeyPath::array() const {
DCHECK(type_ == blink::kWebIDBKeyPathTypeArray);
diff --git a/chromium/content/common/indexed_db/indexed_db_key_path.h b/chromium/content/common/indexed_db/indexed_db_key_path.h
index 0d0ab6a82c4..a8431e98dfb 100644
--- a/chromium/content/common/indexed_db/indexed_db_key_path.h
+++ b/chromium/content/common/indexed_db/indexed_db_key_path.h
@@ -21,8 +21,10 @@ class CONTENT_EXPORT IndexedDBKeyPath {
explicit IndexedDBKeyPath(const base::string16&);
explicit IndexedDBKeyPath(const std::vector<base::string16>&);
IndexedDBKeyPath(const IndexedDBKeyPath& other);
+ IndexedDBKeyPath(IndexedDBKeyPath&& other);
~IndexedDBKeyPath();
IndexedDBKeyPath& operator=(const IndexedDBKeyPath& other);
+ IndexedDBKeyPath& operator=(IndexedDBKeyPath&& other);
bool IsNull() const { return type_ == blink::kWebIDBKeyPathTypeNull; }
bool operator==(const IndexedDBKeyPath& other) const;
diff --git a/chromium/content/common/indexed_db/indexed_db_metadata.cc b/chromium/content/common/indexed_db/indexed_db_metadata.cc
index 5fbceaa10b1..82cf74380be 100644
--- a/chromium/content/common/indexed_db/indexed_db_metadata.cc
+++ b/chromium/content/common/indexed_db/indexed_db_metadata.cc
@@ -21,11 +21,15 @@ IndexedDBIndexMetadata::IndexedDBIndexMetadata(const base::string16& name,
IndexedDBIndexMetadata::IndexedDBIndexMetadata(
const IndexedDBIndexMetadata& other) = default;
+IndexedDBIndexMetadata::IndexedDBIndexMetadata(IndexedDBIndexMetadata&& other) =
+ default;
IndexedDBIndexMetadata::~IndexedDBIndexMetadata() = default;
IndexedDBIndexMetadata& IndexedDBIndexMetadata::operator=(
const IndexedDBIndexMetadata& other) = default;
+IndexedDBIndexMetadata& IndexedDBIndexMetadata::operator=(
+ IndexedDBIndexMetadata&& other) = default;
bool IndexedDBIndexMetadata::operator==(
const IndexedDBIndexMetadata& other) const {
@@ -49,11 +53,15 @@ IndexedDBObjectStoreMetadata::IndexedDBObjectStoreMetadata() = default;
IndexedDBObjectStoreMetadata::IndexedDBObjectStoreMetadata(
const IndexedDBObjectStoreMetadata& other) = default;
+IndexedDBObjectStoreMetadata::IndexedDBObjectStoreMetadata(
+ IndexedDBObjectStoreMetadata&& other) = default;
IndexedDBObjectStoreMetadata::~IndexedDBObjectStoreMetadata() = default;
IndexedDBObjectStoreMetadata& IndexedDBObjectStoreMetadata::operator=(
const IndexedDBObjectStoreMetadata& other) = default;
+IndexedDBObjectStoreMetadata& IndexedDBObjectStoreMetadata::operator=(
+ IndexedDBObjectStoreMetadata&& other) = default;
bool IndexedDBObjectStoreMetadata::operator==(
const IndexedDBObjectStoreMetadata& other) const {
@@ -76,11 +84,15 @@ IndexedDBDatabaseMetadata::IndexedDBDatabaseMetadata(
IndexedDBDatabaseMetadata::IndexedDBDatabaseMetadata(
const IndexedDBDatabaseMetadata& other) = default;
+IndexedDBDatabaseMetadata::IndexedDBDatabaseMetadata(
+ IndexedDBDatabaseMetadata&& other) = default;
IndexedDBDatabaseMetadata::~IndexedDBDatabaseMetadata() = default;
IndexedDBDatabaseMetadata& IndexedDBDatabaseMetadata::operator=(
const IndexedDBDatabaseMetadata& other) = default;
+IndexedDBDatabaseMetadata& IndexedDBDatabaseMetadata::operator=(
+ IndexedDBDatabaseMetadata&& other) = default;
bool IndexedDBDatabaseMetadata::operator==(
const IndexedDBDatabaseMetadata& other) const {
diff --git a/chromium/content/common/indexed_db/indexed_db_metadata.h b/chromium/content/common/indexed_db/indexed_db_metadata.h
index e4fa452cdb6..30b4de66b01 100644
--- a/chromium/content/common/indexed_db/indexed_db_metadata.h
+++ b/chromium/content/common/indexed_db/indexed_db_metadata.h
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <map>
+#include <string>
#include "base/strings/string16.h"
#include "content/common/indexed_db/indexed_db_key_path.h"
@@ -24,8 +25,10 @@ struct CONTENT_EXPORT IndexedDBIndexMetadata {
bool unique,
bool multi_entry);
IndexedDBIndexMetadata(const IndexedDBIndexMetadata& other);
+ IndexedDBIndexMetadata(IndexedDBIndexMetadata&& other);
~IndexedDBIndexMetadata();
IndexedDBIndexMetadata& operator=(const IndexedDBIndexMetadata& other);
+ IndexedDBIndexMetadata& operator=(IndexedDBIndexMetadata&& other);
bool operator==(const IndexedDBIndexMetadata& other) const;
base::string16 name;
@@ -37,6 +40,7 @@ struct CONTENT_EXPORT IndexedDBIndexMetadata {
struct CONTENT_EXPORT IndexedDBObjectStoreMetadata {
static const int64_t kInvalidId = -1;
+ static const int64_t kMinimumIndexId = 30;
IndexedDBObjectStoreMetadata();
IndexedDBObjectStoreMetadata(const base::string16& name,
@@ -45,9 +49,11 @@ struct CONTENT_EXPORT IndexedDBObjectStoreMetadata {
bool auto_increment,
int64_t max_index_id);
IndexedDBObjectStoreMetadata(const IndexedDBObjectStoreMetadata& other);
+ IndexedDBObjectStoreMetadata(IndexedDBObjectStoreMetadata&& other);
~IndexedDBObjectStoreMetadata();
IndexedDBObjectStoreMetadata& operator=(
const IndexedDBObjectStoreMetadata& other);
+ IndexedDBObjectStoreMetadata& operator=(IndexedDBObjectStoreMetadata&& other);
bool operator==(const IndexedDBObjectStoreMetadata& other) const;
base::string16 name;
@@ -69,8 +75,10 @@ struct CONTENT_EXPORT IndexedDBDatabaseMetadata {
int64_t version,
int64_t max_object_store_id);
IndexedDBDatabaseMetadata(const IndexedDBDatabaseMetadata& other);
+ IndexedDBDatabaseMetadata(IndexedDBDatabaseMetadata&& other);
~IndexedDBDatabaseMetadata();
IndexedDBDatabaseMetadata& operator=(const IndexedDBDatabaseMetadata& other);
+ IndexedDBDatabaseMetadata& operator=(IndexedDBDatabaseMetadata&& other);
bool operator==(const IndexedDBDatabaseMetadata& other) const;
base::string16 name;
diff --git a/chromium/content/common/input/ime_text_span_conversions.cc b/chromium/content/common/input/ime_text_span_conversions.cc
new file mode 100644
index 00000000000..59ef7f35643
--- /dev/null
+++ b/chromium/content/common/input/ime_text_span_conversions.cc
@@ -0,0 +1,41 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/input/ime_text_span_conversions.h"
+
+#include "base/logging.h"
+
+namespace content {
+
+blink::WebImeTextSpan::Type ConvertUiImeTextSpanTypeToWebType(
+ ui::ImeTextSpan::Type type) {
+ switch (type) {
+ case ui::ImeTextSpan::Type::kComposition:
+ return blink::WebImeTextSpan::Type::kComposition;
+ case ui::ImeTextSpan::Type::kSuggestion:
+ return blink::WebImeTextSpan::Type::kSuggestion;
+ case ui::ImeTextSpan::Type::kMisspellingSuggestion:
+ return blink::WebImeTextSpan::Type::kMisspellingSuggestion;
+ }
+
+ NOTREACHED();
+ return blink::WebImeTextSpan::Type::kComposition;
+}
+
+ui::ImeTextSpan::Type ConvertWebImeTextSpanTypeToUiType(
+ blink::WebImeTextSpan::Type type) {
+ switch (type) {
+ case blink::WebImeTextSpan::Type::kComposition:
+ return ui::ImeTextSpan::Type::kComposition;
+ case blink::WebImeTextSpan::Type::kSuggestion:
+ return ui::ImeTextSpan::Type::kSuggestion;
+ case blink::WebImeTextSpan::Type::kMisspellingSuggestion:
+ return ui::ImeTextSpan::Type::kMisspellingSuggestion;
+ }
+
+ NOTREACHED();
+ return ui::ImeTextSpan::Type::kComposition;
+}
+
+} // namespace content
diff --git a/chromium/content/common/input/ime_text_span_conversions.h b/chromium/content/common/input/ime_text_span_conversions.h
new file mode 100644
index 00000000000..50d78de2899
--- /dev/null
+++ b/chromium/content/common/input/ime_text_span_conversions.h
@@ -0,0 +1,20 @@
+// Copyright 2017 The Chromium 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 CONTENT_COMMON_INPUT_IME_TEXT_SPAN_CONVERSIONS_H_
+#define CONTENT_COMMON_INPUT_IME_TEXT_SPAN_CONVERSIONS_H_
+
+#include "third_party/WebKit/public/web/WebImeTextSpan.h"
+#include "ui/base/ime/ime_text_span.h"
+
+namespace content {
+
+blink::WebImeTextSpan::Type ConvertUiImeTextSpanTypeToWebType(
+ ui::ImeTextSpan::Type type);
+ui::ImeTextSpan::Type ConvertWebImeTextSpanTypeToUiType(
+ blink::WebImeTextSpan::Type type);
+
+} // namespace content
+
+#endif // CONTENT_COMMON_INPUT_IME_TEXT_SPAN_CONVERSIONS_H_
diff --git a/chromium/content/common/input/input_event_struct_traits.cc b/chromium/content/common/input/input_event_struct_traits.cc
index 1c575275021..f5af72738e4 100644
--- a/chromium/content/common/input/input_event_struct_traits.cc
+++ b/chromium/content/common/input/input_event_struct_traits.cc
@@ -200,8 +200,6 @@ bool StructTraits<content::mojom::EventDataView, InputEventUniquePtr>::Read(
.previous_update_in_sequence_prevented =
gesture_data->scroll_data->update_details
->previous_update_in_sequence_prevented;
- gesture_event->data.scroll_update.prevent_propagation =
- gesture_data->scroll_data->update_details->prevent_propagation;
}
break;
}
@@ -253,8 +251,6 @@ bool StructTraits<content::mojom::EventDataView, InputEventUniquePtr>::Read(
.previous_update_in_sequence_prevented =
gesture_data->scroll_data->update_details
->previous_update_in_sequence_prevented;
- gesture_event->data.scroll_update.prevent_propagation =
- gesture_data->scroll_data->update_details->prevent_propagation;
}
break;
}
@@ -488,8 +484,7 @@ StructTraits<content::mojom::EventDataView, InputEventUniquePtr>::gesture_data(
gesture_event->data.scroll_update.velocity_x,
gesture_event->data.scroll_update.velocity_y,
gesture_event->data.scroll_update
- .previous_update_in_sequence_prevented,
- gesture_event->data.scroll_update.prevent_propagation));
+ .previous_update_in_sequence_prevented));
break;
case blink::WebInputEvent::Type::kGestureFlingStart:
gesture_data->fling_data = content::mojom::FlingData::New(
diff --git a/chromium/content/common/input/input_handler.mojom b/chromium/content/common/input/input_handler.mojom
index 86aabccdb41..b7a8296c456 100644
--- a/chromium/content/common/input/input_handler.mojom
+++ b/chromium/content/common/input/input_handler.mojom
@@ -7,11 +7,12 @@ module content.mojom;
import "content/common/native_types.mojom";
import "mojo/common/string16.mojom";
import "services/ui/public/interfaces/ime/ime.mojom";
+import "third_party/WebKit/public/web/selection_menu_behavior.mojom";
import "ui/events/mojo/event.mojom";
import "ui/events/mojo/event_constants.mojom";
-import "ui/latency/mojo/latency_info.mojom";
import "ui/gfx/geometry/mojo/geometry.mojom";
import "ui/gfx/range/mojo/range.mojom";
+import "ui/latency/mojo/latency_info.mojom";
// These structs are purposely duplicated from ui/events/mojom/event.mojom.
@@ -73,7 +74,6 @@ struct ScrollUpdate {
float velocity_x;
float velocity_y;
bool previous_update_in_sequence_prevented;
- bool prevent_propagation;
};
struct ScrollData {
@@ -147,6 +147,44 @@ struct TouchActionOptional {
TouchAction touch_action;
};
+// Interface exposed by the browser to the renderer. The messages
+// contained in here are state changes that the renderer has taken
+// that the browser must be aware of.
+interface WidgetInputHandlerHost {
+ // Cancel the active touch timeout. Occurs when the renderer
+ // has processed a touch-action: none but not yet dispatched
+ // the event to javascript.
+ CancelTouchTimeout();
+
+ // The whitelisted touch action and the associated unique touch event id
+ // for a new touch point sent by the compositor. The unique touch event id is
+ // only needed to verify that the whitelisted touch action is being associated
+ // with the correct touch event. The input event ack state is needed when
+ // the touchstart message was not sent to the renderer and the touch
+ // actions need to be reset and the touch ack timeout needs to be started.
+ SetWhiteListedTouchAction(TouchAction touch_action,
+ uint32 unique_touch_event_id,
+ InputEventAckState state);
+
+ // Sent by the compositor when input scroll events are dropped due to bounds
+ // restrictions on the root scroll offset.
+ DidOverscroll(DidOverscrollParams params);
+
+ // Sent by the compositor when a fling animation is stopped.
+ DidStopFlinging();
+
+ // Required for cancelling an ongoing input method composition.
+ ImeCancelComposition();
+
+ // Sends the character bounds after every composition change
+ // to always have correct bound info.
+ ImeCompositionRangeChanged(gfx.mojom.Range range,
+ array<gfx.mojom.Rect> bounds);
+};
+
+// Interface exposed by the renderer to the browser. This class represents
+// an input interface for an associated Widget object. See FrameInputHandler
+// for an interface at the frame level.
interface WidgetInputHandler {
// Tells widget focus has been changed.
SetFocus(bool focused);
@@ -272,8 +310,10 @@ interface FrameInputHandler {
// Sent by the browser to ask the renderer to adjust the selection start and
// end points by the given amounts. A negative amount moves the selection
// towards the beginning of the document, a positive amount moves the
- // selection towards the end of the document.
- AdjustSelectionByCharacterOffset(int32 start, int32 end);
+ // selection towards the end of the document. Will send show selection menu
+ // event when needed.
+ AdjustSelectionByCharacterOffset(
+ int32 start, int32 end, blink.mojom.SelectionMenuBehavior behavior);
// Requests the renderer to move the selection extent point to a new position.
// Expects a MoveRangeSelectionExtent_ACK message when finished.
diff --git a/chromium/content/common/input/input_param_traits.cc b/chromium/content/common/input/input_param_traits.cc
index 0fe6100a86d..66418e3fc17 100644
--- a/chromium/content/common/input/input_param_traits.cc
+++ b/chromium/content/common/input/input_param_traits.cc
@@ -16,14 +16,6 @@
namespace IPC {
-void ParamTraits<ui::WebScopedInputEvent>::GetSize(base::PickleSizer* s,
- const param_type& p) {
- bool valid_web_event = !!p;
- GetParamSize(s, valid_web_event);
- if (valid_web_event)
- GetParamSize(s, static_cast<WebInputEventPointer>(p.get()));
-}
-
void ParamTraits<ui::WebScopedInputEvent>::Write(base::Pickle* m,
const param_type& p) {
bool valid_web_event = !!p;
diff --git a/chromium/content/common/input/input_param_traits.h b/chromium/content/common/input/input_param_traits.h
index 5c366524572..ec027c5a7e8 100644
--- a/chromium/content/common/input/input_param_traits.h
+++ b/chromium/content/common/input/input_param_traits.h
@@ -17,7 +17,6 @@ namespace IPC {
template <>
struct CONTENT_EXPORT ParamTraits<ui::WebScopedInputEvent> {
typedef ui::WebScopedInputEvent param_type;
- static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
diff --git a/chromium/content/common/input_messages.h b/chromium/content/common/input_messages.h
index 8d24eb334ce..1cfd6f5f437 100644
--- a/chromium/content/common/input_messages.h
+++ b/chromium/content/common/input_messages.h
@@ -2,9 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_INPUT_MESSAGES_H_
+#define CONTENT_COMMON_INPUT_MESSAGES_H_
+
// IPC messages for input events and other messages that require processing in
// order relative to input events.
-// Multiply-included message file, hence no include guard.
#include "base/strings/string16.h"
#include "build/build_config.h"
@@ -290,10 +292,12 @@ IPC_MESSAGE_ROUTED2(InputMsg_SelectRange,
// Sent by the browser to ask the renderer to adjust the selection start and
// end points by the given amounts. A negative amount moves the selection
// towards the beginning of the document, a positive amount moves the selection
-// towards the end of the document.
-IPC_MESSAGE_ROUTED2(InputMsg_AdjustSelectionByCharacterOffset,
+// towards the end of the document. Will send show selection menu event when
+// needed.
+IPC_MESSAGE_ROUTED3(InputMsg_AdjustSelectionByCharacterOffset,
int /* start_adjust*/,
- int /* end_adjust */)
+ int /* end_adjust */,
+ bool /* show_selection_menu */)
// Requests the renderer to move the selection extent point to a new position.
// Expects a MoveRangeSelectionExtent_ACK message when finished.
@@ -372,3 +376,5 @@ IPC_MESSAGE_ROUTED2(InputHostMsg_ImeCompositionRangeChanged,
// independent InputMsg, then ifdefs for platform specific InputMsg, then
// platform independent InputHostMsg, then ifdefs for platform specific
// InputHostMsg.
+
+#endif // CONTENT_COMMON_INPUT_MESSAGES_H_
diff --git a/chromium/content/common/leveldb_wrapper.mojom b/chromium/content/common/leveldb_wrapper.mojom
index e099618c372..d900a880e77 100644
--- a/chromium/content/common/leveldb_wrapper.mojom
+++ b/chromium/content/common/leveldb_wrapper.mojom
@@ -15,6 +15,12 @@ interface LevelDBObserver {
string source);
KeyDeleted(array<uint8> key, array<uint8> old_value, string source);
AllDeleted(string source);
+
+ // Tells the client if it should send the old values for the key on Put() and
+ // Delete() calls for sending notifications. By default the clients are
+ // expected to send old values. It is set to true when the leveldb wrapper
+ // does not cache values in memory.
+ ShouldSendOldValueOnMutations(bool value);
};
struct KeyValue {
@@ -37,13 +43,31 @@ interface LevelDBWrapperGetAllCallback {
interface LevelDBWrapper {
AddObserver(associated LevelDBObserver observer);
- // Sets the database entry for |key| to |value|. Returns OK on success.
- Put(array<uint8> key, array<uint8> value, string source) => (bool success);
+ // Set the database entry for |key| to |value|.
+ // Takes an optional |client_old_value| (see ShouldSendOldValueOnMutations()):
+ // 1. If the client is notified to not send old value on mutations
+ // |client_old_value| is unused and can be nullopt.
+ // 2. If the client is notified to send old values or not notified at all,
+ // |client_old_value| must be filled in with old value of the |key|, or
+ // nullopt if |key| was not present in database. This value is used to send
+ // notifications to LevelDBObserver(s).
+ // Returns OK on success.
+ Put(array<uint8> key, array<uint8> value, array<uint8>? client_old_value,
+ string source) =>
+ (bool success);
- // Remove the database entry (if any) for |key|. Returns OK on success, and a
- // non-OK status on error. It is not an error if |key| did not exist in the
- // database.
- Delete(array<uint8> key, string source) => (bool success);
+ // Remove the database entry (if any) for |key|.
+ // Takes an optional |client_old_value| (see ShouldSendOldValueOnMutations()):
+ // 1. If the client is notified to not send old value on mutations,
+ // |client_old_value| is unused and can be nullopt.
+ // 2. If the client is notified to send old values or not notified at all,
+ // |client_old_value| must be filled in with old value of the |key|, or
+ // nullopt if |key| was not present in database. This value is used to send
+ // notifications to LevelDBObserver(s).
+ // Returns OK on success, and a non-OK status on error. It is not an error if
+ // |key| did not exist in the database.
+ Delete(array<uint8> key, array<uint8>? client_old_value, string source) =>
+ (bool success);
// Removes all the entries.
DeleteAll(string source) => (bool success);
diff --git a/chromium/content/common/mac/app_nap_activity.h b/chromium/content/common/mac/app_nap_activity.h
deleted file mode 100644
index c2896e8390c..00000000000
--- a/chromium/content/common/mac/app_nap_activity.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2017 The Chromium 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 CONTENT_COMMON_MAC_APP_NAP_ACTIVITY_H
-#define CONTENT_COMMON_MAC_APP_NAP_ACTIVITY_H
-
-#include <memory>
-
-#include "base/macros.h"
-#include "content/common/content_export.h"
-
-namespace content {
-
-// Can't import scoped_nsobject here, so wrap it.
-struct AssertionWrapper;
-
-// A wrapper around the macOS "activity" system, which is required to
-// make renderers eligible for AppNap.
-//
-// When doing work, processes are expected to begin an activity, receiving
-// an opaque token called an "assertion". On finishing, they end the activity.
-// When a process has no outstanding assertions, it becomes eligible for
-// AppNap.
-class CONTENT_EXPORT AppNapActivity {
- public:
- AppNapActivity();
- ~AppNapActivity();
-
- // Because there's no NSApplication in renderers, do some housekeeping
- // to become eligible for App Nap.
- static void InitializeAppNapSupport();
-
- // Begin an activity and store the provided token.
- void Begin();
-
- // End the activity represented by |assertion_|.
- void End();
-
- private:
- // An opaque token provided by the OS on beginning an activity.
- std::unique_ptr<AssertionWrapper> assertion_;
-
- DISALLOW_COPY_AND_ASSIGN(AppNapActivity);
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_MAC_APP_NAP_ACTIVITY_H
diff --git a/chromium/content/common/mac/app_nap_activity.mm b/chromium/content/common/mac/app_nap_activity.mm
deleted file mode 100644
index 5187444777b..00000000000
--- a/chromium/content/common/mac/app_nap_activity.mm
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/mac/app_nap_activity.h"
-
-#import <Foundation/Foundation.h>
-
-#include "base/mac/scoped_nsobject.h"
-
-extern "C" {
-void __CFRunLoopSetOptionsReason(uint64_t options,
- NSString* reason,
- int unused);
-}
-
-namespace content {
-
-namespace {
-
-NSString* const kActivityReason = @"Process foregrounded";
-const NSActivityOptions kActivityOptions =
- (NSActivityUserInitiatedAllowingIdleSystemSleep |
- NSActivityLatencyCritical) &
- ~(NSActivitySuddenTerminationDisabled |
- NSActivityAutomaticTerminationDisabled);
-
-} // namespace
-
-struct AssertionWrapper {
- base::scoped_nsobject<id> obj;
-};
-
-AppNapActivity::AppNapActivity() {
- assertion_.reset(new AssertionWrapper());
-};
-
-AppNapActivity::~AppNapActivity() {
- if (assertion_->obj.get())
- End();
-};
-
-void AppNapActivity::InitializeAppNapSupport() {
- // Reason strings are the same as
- // what macOS sends in the corresponding call.
- // |options| (argument 1) are magic numbers as found in the
- // callsites mentioned above.
- //
- // Normally happens during launch services check-in. (HIToolbox)
- __CFRunLoopSetOptionsReason(
- 1, @"Finished checking in as application - waiting for events", 0);
- // Normally happens in a dispatch_once in the NSApplication event loop.
- // (CoreFoundation).
- __CFRunLoopSetOptionsReason(
- 0x3b000000, @"Finished delay after app launch and bundle check", 0);
-}
-
-void AppNapActivity::Begin() {
- DCHECK(!assertion_->obj.get());
- id assertion =
- [[NSProcessInfo processInfo] beginActivityWithOptions:kActivityOptions
- reason:kActivityReason];
- assertion_->obj.reset([assertion retain]);
-}
-
-void AppNapActivity::End() {
- id assertion = assertion_->obj.autorelease();
- DCHECK(assertion);
- [[NSProcessInfo processInfo] endActivity:assertion];
-}
-
-} // namespace content
diff --git a/chromium/content/common/mac/app_nap_activity_unittest.mm b/chromium/content/common/mac/app_nap_activity_unittest.mm
deleted file mode 100644
index 44d2ee3f2fd..00000000000
--- a/chromium/content/common/mac/app_nap_activity_unittest.mm
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/mac/app_nap_activity.h"
-
-#include "testing/gtest_mac.h"
-#include "testing/platform_test.h"
-#import "third_party/ocmock/OCMock/OCMock.h"
-#include "third_party/ocmock/gtest_support.h"
-
-class AppNapActivityTest : public PlatformTest {};
-
-TEST_F(AppNapActivityTest, StoresAssertion) {
- const NSActivityOptions expectedOptions =
- (NSActivityUserInitiatedAllowingIdleSystemSleep |
- NSActivityLatencyCritical) &
- ~(NSActivitySuddenTerminationDisabled |
- NSActivityAutomaticTerminationDisabled);
- id processInfoMock =
- [OCMockObject partialMockForObject:[NSProcessInfo processInfo]];
- id assertion = @"An activity assertion";
- [[[processInfoMock expect] andReturn:assertion]
- beginActivityWithOptions:expectedOptions
- reason:OCMOCK_ANY];
-
- content::AppNapActivity activity;
- activity.Begin();
-
- EXPECT_OCMOCK_VERIFY(processInfoMock);
-
- [[processInfoMock expect] endActivity:assertion];
-
- activity.End();
-
- EXPECT_OCMOCK_VERIFY(processInfoMock);
- [processInfoMock stopMocking];
-}
-
-TEST_F(AppNapActivityTest, EndsActivityOnDestruct) {
- id processInfoMock =
- [OCMockObject partialMockForObject:[NSProcessInfo processInfo]];
- id assertion = @"An activity assertion";
- [[[[processInfoMock stub] ignoringNonObjectArgs] andReturn:assertion]
- beginActivityWithOptions:0
- reason:OCMOCK_ANY];
-
- [[processInfoMock expect] endActivity:assertion];
- {
- content::AppNapActivity activity;
- activity.Begin();
- }
-
- EXPECT_OCMOCK_VERIFY(processInfoMock);
- [processInfoMock stopMocking];
-}
diff --git a/chromium/content/common/media/aec_dump_messages.h b/chromium/content/common/media/aec_dump_messages.h
index 33e727d2dab..427c82bb781 100644
--- a/chromium/content/common/media/aec_dump_messages.h
+++ b/chromium/content/common/media/aec_dump_messages.h
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_MEDIA_AEC_DUMP_MESSAGES_H_
+#define CONTENT_COMMON_MEDIA_AEC_DUMP_MESSAGES_H_
+
// IPC messages for the AEC dump.
-// Multiply-included message file, hence no include guard.
#include "content/common/content_export.h"
#include "ipc/ipc_message_macros.h"
@@ -39,3 +41,5 @@ IPC_MESSAGE_CONTROL1(AecDumpMsg_UnregisterAecDumpConsumer,
IPC_MESSAGE_CONTROL2(AudioProcessingMsg_EnableAec3,
int /* id */,
bool /* enable */)
+
+#endif // CONTENT_COMMON_MEDIA_AEC_DUMP_MESSAGES_H_
diff --git a/chromium/content/common/media/audio_messages.h b/chromium/content/common/media/audio_messages.h
index f9186608d51..c4c2f3535af 100644
--- a/chromium/content/common/media/audio_messages.h
+++ b/chromium/content/common/media/audio_messages.h
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_MEDIA_AUDIO_MESSAGES_H_
+#define CONTENT_COMMON_MEDIA_AUDIO_MESSAGES_H_
+
// IPC messages for the audio.
-// Multiply-included message file, hence no include guard.
#include <stdint.h>
@@ -46,23 +48,18 @@ IPC_MESSAGE_CONTROL4(AudioMsg_NotifyDeviceAuthorized,
// buffer it shares with the browser process. It is also given a SyncSocket that
// it uses to communicate with the browser process about the state of the
// buffered audio data.
-IPC_MESSAGE_CONTROL4(
- AudioMsg_NotifyStreamCreated,
- int /* stream id */,
- base::SharedMemoryHandle /* handle */,
- base::SyncSocket::TransitDescriptor /* socket descriptor */,
- uint32_t /* length */)
+IPC_MESSAGE_CONTROL(AudioMsg_NotifyStreamCreated,
+ int /* stream id */,
+ base::SharedMemoryHandle /* handle */,
+ base::SyncSocket::TransitDescriptor /* socket descriptor */)
// Tell the renderer process that an audio input stream has been created.
// The renderer process would be given a SyncSocket that it should read from
-// from then on. It is also given number of segments in shared memory and
-// whether the stream initially is muted.
+// from then on. It is also given whether the stream initially is muted.
IPC_MESSAGE_CONTROL(AudioInputMsg_NotifyStreamCreated,
int /* stream id */,
base::SharedMemoryHandle /* handle */,
base::SyncSocket::TransitDescriptor /* socket descriptor */,
- uint32_t /* length */,
- uint32_t /* segment count */,
bool /* initially muted */)
// Notification message sent from AudioRendererHost to renderer for state
@@ -135,3 +132,5 @@ IPC_MESSAGE_CONTROL2(AudioHostMsg_SetVolume,
IPC_MESSAGE_CONTROL2(AudioInputHostMsg_SetVolume,
int /* stream_id */,
double /* volume */)
+
+#endif // CONTENT_COMMON_MEDIA_AUDIO_MESSAGES_H_
diff --git a/chromium/content/common/media/cdm_host_file.cc b/chromium/content/common/media/cdm_host_file.cc
deleted file mode 100644
index ff023839cea..00000000000
--- a/chromium/content/common/media/cdm_host_file.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/media/cdm_host_file.h"
-
-#include <memory>
-
-#include "base/command_line.h"
-#include "base/feature_list.h"
-#include "base/logging.h"
-#include "base/memory/ptr_util.h"
-#include "media/cdm/api/content_decryption_module_ext.h"
-
-namespace content {
-
-// static
-std::unique_ptr<CdmHostFile> CdmHostFile::Create(
- const base::FilePath& file_path,
- const base::FilePath& sig_file_path) {
- DVLOG(1) << __func__;
-
- // Open file at |file_path|.
- base::File file(file_path, base::File::FLAG_OPEN | base::File::FLAG_READ);
- DVLOG(1) << " " << file.IsValid() << ": " << file_path.MaybeAsASCII();
-
- // Also open the sig file at |sig_file_path|.
- base::File sig_file(sig_file_path,
- base::File::FLAG_OPEN | base::File::FLAG_READ);
- DVLOG(1) << " " << sig_file.IsValid() << ": "
- << sig_file_path.MaybeAsASCII();
-
- return std::unique_ptr<CdmHostFile>(
- new CdmHostFile(file_path, std::move(file), std::move(sig_file)));
-}
-
-cdm::HostFile CdmHostFile::TakePlatformFile() {
- return cdm::HostFile(file_path_.value().c_str(), file_.TakePlatformFile(),
- sig_file_.TakePlatformFile());
-}
-
-CdmHostFile::CdmHostFile(const base::FilePath& file_path,
- base::File file,
- base::File sig_file)
- : file_path_(file_path),
- file_(std::move(file)),
- sig_file_(std::move(sig_file)) {
- DCHECK(!file_path_.empty());
-}
-
-} // namespace content
diff --git a/chromium/content/common/media/cdm_host_file.h b/chromium/content/common/media/cdm_host_file.h
deleted file mode 100644
index ade3a27bf00..00000000000
--- a/chromium/content/common/media/cdm_host_file.h
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2016 The Chromium 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 CONTENT_COMMON_MEDIA_CDM_HOST_FILE_H_
-#define CONTENT_COMMON_MEDIA_CDM_HOST_FILE_H_
-
-#include <memory>
-
-#include "base/files/file.h"
-#include "base/files/file_path.h"
-#include "base/macros.h"
-
-namespace cdm {
-struct HostFile;
-}
-
-namespace content {
-
-// Represents a file that participated in hosting the CDM.
-class CdmHostFile {
- public:
- // Opens the file at |file_path| and the corresponding signature file at
- // |sig_file_path|. Upon success, constructs and returns a CdmHostFile object.
- // Otherwise returns nullptr. The opened files are closed when |this| is
- // destructed unless TakePlatformFile() was called, in which case the caller
- // must make sure the files are closed properly.
- static std::unique_ptr<CdmHostFile> Create(
- const base::FilePath& file_path,
- const base::FilePath& sig_file_path);
-
- // Takes the PlatformFile of the |file_| and |sig_file_| and put them in the
- // returned cdm::HostFile. The caller must make sure the PlatformFiles are
- // properly closed after use.
- cdm::HostFile TakePlatformFile();
-
- private:
- CdmHostFile(const base::FilePath& file_path,
- base::File file,
- base::File sig_file);
-
- base::FilePath file_path_;
- base::File file_;
-
- // The signature file associated with |file_|.
- base::File sig_file_;
-
- DISALLOW_COPY_AND_ASSIGN(CdmHostFile);
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_MEDIA_CDM_HOST_FILE_H_
diff --git a/chromium/content/common/media/cdm_host_files.cc b/chromium/content/common/media/cdm_host_files.cc
deleted file mode 100644
index 49c55622861..00000000000
--- a/chromium/content/common/media/cdm_host_files.cc
+++ /dev/null
@@ -1,295 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/media/cdm_host_files.h"
-
-#include <map>
-#include <memory>
-#include <vector>
-
-#include "base/command_line.h"
-#include "base/files/file.h"
-#include "base/files/file_path.h"
-#include "base/lazy_instance.h"
-#include "base/logging.h"
-#include "base/memory/ptr_util.h"
-#include "base/native_library.h"
-#include "base/path_service.h"
-#include "base/scoped_native_library.h"
-#include "build/build_config.h"
-#include "content/common/media/cdm_host_file.h"
-#include "content/public/common/cdm_info.h"
-#include "content/public/common/content_client.h"
-#include "media/cdm/api/content_decryption_module_ext.h"
-#include "media/cdm/cdm_paths.h"
-
-#if defined(POSIX_WITH_ZYGOTE)
-#include "content/common/pepper_plugin_list.h"
-#include "content/public/common/pepper_plugin_info.h"
-#endif
-
-#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
-
-namespace content {
-
-namespace {
-
-// TODO(xhwang): Move this to a common place if needed.
-const base::FilePath::CharType kSignatureFileExtension[] =
- FILE_PATH_LITERAL(".sig");
-
-// Returns the signature file path given the |file_path|. This function should
-// only be used when the signature file and the file are located in the same
-// directory, which is the case for the CDM and CDM adapter.
-base::FilePath GetSigFilePath(const base::FilePath& file_path) {
- return file_path.AddExtension(kSignatureFileExtension);
-}
-
-// Returns the CDM library file name given the |cdm_adapter_file_name|. Returns
-// nullptr if |cdm_adapter_file_name| does not correspond to a known CDM.
-const char* GetCdmFileName(const base::FilePath& cdm_adapter_file_name) {
-#if defined(WIDEVINE_CDM_AVAILABLE)
- if (cdm_adapter_file_name ==
- base::FilePath::FromUTF8Unsafe(kWidevineCdmAdapterFileName))
- return kWidevineCdmLibraryName;
-#endif
-
- // Clear Key CDM. For test only.
- if (cdm_adapter_file_name ==
- base::FilePath::FromUTF8Unsafe(media::kClearKeyCdmAdapterFileName))
- return media::kClearKeyCdmLibraryName;
-
- return nullptr;
-}
-
-// Returns the path to the CDM binary given the |cdm_adapter_path|. Returns an
-// empty path if |cdm_adapter_path| does not correspond to a known CDM.
-base::FilePath GetCdmPath(const base::FilePath& cdm_adapter_path) {
- const char* cdm_file_name = GetCdmFileName(cdm_adapter_path.BaseName());
- if (!cdm_file_name)
- return base::FilePath();
-
- return cdm_adapter_path.DirName().AppendASCII(
- base::GetNativeLibraryName(cdm_file_name));
-}
-
-#if defined(POSIX_WITH_ZYGOTE)
-// From the list of registered plugins, finds all registered CDMs and fills
-// |cdm_adapter_paths| with found CDM adapters paths.
-void GetRegisteredCdms(std::vector<base::FilePath>* cdm_adapter_paths) {
- std::vector<PepperPluginInfo> plugins;
- ComputePepperPluginList(&plugins);
- for (const auto& plugin : plugins) {
- // CDM is not an internal plugin.
- if (plugin.is_internal)
- continue;
-
- if (IsCdm(plugin.path))
- cdm_adapter_paths->push_back(plugin.path);
- }
-}
-
-// A global instance used on platforms where we have to open the files in the
-// Zygote process.
-base::LazyInstance<std::unique_ptr<CdmHostFiles>>::DestructorAtExit
- g_cdm_host_files = LAZY_INSTANCE_INITIALIZER;
-#endif
-
-} // namespace
-
-CdmHostFiles::CdmHostFiles() {
- DVLOG(1) << __func__;
-}
-
-CdmHostFiles::~CdmHostFiles() {
- DVLOG(1) << __func__;
-}
-
-#if defined(POSIX_WITH_ZYGOTE)
-// static
-void CdmHostFiles::CreateGlobalInstance() {
- DVLOG(1) << __func__;
- DCHECK(!g_cdm_host_files.Get().get());
-
- std::unique_ptr<CdmHostFiles> cdm_host_files =
- base::MakeUnique<CdmHostFiles>();
- cdm_host_files->OpenFilesForAllRegisteredCdms();
- g_cdm_host_files.Get().reset(cdm_host_files.release());
-}
-
-// static
-std::unique_ptr<CdmHostFiles> CdmHostFiles::TakeGlobalInstance() {
- return std::move(g_cdm_host_files.Get());
-}
-#endif
-
-// static
-std::unique_ptr<CdmHostFiles> CdmHostFiles::Create(
- const base::FilePath& cdm_adapter_path) {
- DVLOG(1) << __func__;
- std::unique_ptr<CdmHostFiles> cdm_host_files =
- base::MakeUnique<CdmHostFiles>();
- cdm_host_files->OpenFiles(cdm_adapter_path);
- return cdm_host_files;
-}
-
-CdmHostFiles::Status CdmHostFiles::InitVerification(
- base::NativeLibrary cdm_adapter_library,
- const base::FilePath& cdm_adapter_path) {
- DVLOG(1) << __func__;
- DCHECK(cdm_adapter_library);
-
- // Get function pointer exported by the CDM.
- // See media/cdm/api/content_decryption_module_ext.h.
- using InitVerificationFunc =
- bool (*)(const cdm::HostFile* cdm_host_files, uint32_t num_files);
- static const char kInitVerificationFuncName[] = "VerifyCdmHost_0";
-
- base::NativeLibrary cdm_library;
-#if defined(OS_LINUX) || defined(OS_MACOSX)
- // On POSIX, "the dlsym() function shall search for the named symbol in all
- // objects loaded automatically as a result of loading the object referenced
- // by handle". Since the CDM is loaded automatically as a result of loading
- // the CDM adapter, we can just use the adapter to look for CDM symbols.
- cdm_library = cdm_adapter_library;
-#elif defined(OS_WIN)
- // On Windows, we have manually load the CDM.
- base::ScopedNativeLibrary scoped_cdm_library;
- base::NativeLibraryLoadError error;
- scoped_cdm_library.Reset(
- base::LoadNativeLibrary(GetCdmPath(cdm_adapter_path), &error));
- if (!scoped_cdm_library.is_valid()) {
- LOG(ERROR) << "Failed to load CDM (error: " << error.ToString() << ")";
- CloseAllFiles();
- return Status::kCdmLoadFailed;
- }
- cdm_library = scoped_cdm_library.get();
-#endif
-
- InitVerificationFunc init_verification_func =
- reinterpret_cast<InitVerificationFunc>(
- base::GetFunctionPointerFromNativeLibrary(cdm_library,
- kInitVerificationFuncName));
- if (!init_verification_func) {
- LOG(ERROR) << "Function " << kInitVerificationFuncName << " not found.";
- CloseAllFiles();
- return Status::kGetFunctionFailed;
- }
-
- // Fills |cdm_host_files| with common and CDM specific files for
- // |cdm_adapter_path|.
- std::vector<cdm::HostFile> cdm_host_files;
- TakePlatformFiles(cdm_adapter_path, &cdm_host_files);
-
- // std::vector::data() is not guaranteed to be nullptr when empty().
- const cdm::HostFile* cdm_host_files_ptr =
- cdm_host_files.empty() ? nullptr : cdm_host_files.data();
-
- // Call |init_verification_func| on the CDM with |cdm_host_files|. Note that
- // the ownership of these files are transferred to the CDM, which will close
- // the files immediately after use.
- DVLOG(1) << __func__ << ": Calling " << kInitVerificationFuncName
- << "() with " << cdm_host_files.size() << " files.";
- for (const auto& host_file : cdm_host_files) {
- DVLOG(1) << " - File Path: " << host_file.file_path;
- DVLOG(1) << " - File: " << host_file.file;
- DVLOG(1) << " - Sig File: " << host_file.sig_file;
- }
-
- if (!init_verification_func(cdm_host_files_ptr, cdm_host_files.size())) {
- DVLOG(1) << "Failed to verify CDM host.";
- CloseAllFiles();
- return Status::kInitVerificationFailed;
- }
-
- // Close all files not passed to the CDM.
- CloseAllFiles();
- return Status::kSuccess;
-}
-
-#if defined(POSIX_WITH_ZYGOTE)
-void CdmHostFiles::OpenFilesForAllRegisteredCdms() {
- std::vector<base::FilePath> cdm_adapter_paths;
- GetRegisteredCdms(&cdm_adapter_paths);
- if (cdm_adapter_paths.empty()) {
- DVLOG(1) << "No CDM registered.";
- return;
- }
-
- for (auto& cdm_adapter_path : cdm_adapter_paths)
- OpenCdmFiles(cdm_adapter_path);
-
- OpenCommonFiles();
-}
-#endif
-
-void CdmHostFiles::OpenFiles(const base::FilePath& cdm_adapter_path) {
- OpenCdmFiles(cdm_adapter_path);
- OpenCommonFiles();
-}
-
-void CdmHostFiles::OpenCommonFiles() {
- DCHECK(common_files_.empty());
-
- std::vector<CdmHostFilePath> cdm_host_file_paths;
- GetContentClient()->AddContentDecryptionModules(nullptr,
- &cdm_host_file_paths);
-
- for (const CdmHostFilePath& value : cdm_host_file_paths) {
- common_files_.push_back(
- CdmHostFile::Create(value.file_path, value.sig_file_path));
- }
-}
-
-void CdmHostFiles::OpenCdmFiles(const base::FilePath& cdm_adapter_path) {
- DCHECK(!cdm_adapter_path.empty());
- DCHECK(!cdm_specific_files_map_.count(cdm_adapter_path));
-
- std::unique_ptr<CdmHostFile> cdm_adapter_file =
- CdmHostFile::Create(cdm_adapter_path, GetSigFilePath(cdm_adapter_path));
-
- base::FilePath cdm_path = GetCdmPath(cdm_adapter_path);
- std::unique_ptr<CdmHostFile> cdm_file =
- CdmHostFile::Create(cdm_path, GetSigFilePath(cdm_path));
-
- ScopedFileVector cdm_specific_files;
- cdm_specific_files.reserve(2);
- cdm_specific_files.push_back(std::move(cdm_adapter_file));
- cdm_specific_files.push_back(std::move(cdm_file));
-
- cdm_specific_files_map_[cdm_adapter_path] = std::move(cdm_specific_files);
-}
-
-void CdmHostFiles::TakePlatformFiles(
- const base::FilePath& cdm_adapter_path,
- std::vector<cdm::HostFile>* cdm_host_files) {
- DCHECK(cdm_host_files->empty());
-
- // Populate an array of cdm::HostFile.
- for (const auto& file : common_files_)
- cdm_host_files->push_back(file->TakePlatformFile());
-
- // Check whether CDM specific files exist.
- const auto& iter = cdm_specific_files_map_.find(cdm_adapter_path);
- if (iter == cdm_specific_files_map_.end()) {
- NOTREACHED() << "No CDM specific files for " << cdm_adapter_path.value();
- } else {
- const ScopedFileVector& cdm_specific_files = iter->second;
- for (const auto& file : cdm_specific_files)
- cdm_host_files->push_back(file->TakePlatformFile());
- }
-}
-
-void CdmHostFiles::CloseAllFiles() {
- common_files_.clear();
- cdm_specific_files_map_.clear();
-}
-
-// Question(xhwang): Any better way to check whether a plugin is a CDM? Maybe
-// when we register the plugin we can set some flag explicitly?
-bool IsCdm(const base::FilePath& cdm_adapter_path) {
- return !GetCdmPath(cdm_adapter_path).empty();
-}
-
-} // namespace content
diff --git a/chromium/content/common/media/cdm_host_files.h b/chromium/content/common/media/cdm_host_files.h
deleted file mode 100644
index a1f584996fb..00000000000
--- a/chromium/content/common/media/cdm_host_files.h
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright 2016 The Chromium 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 CONTENT_COMMON_MEDIA_CDM_HOST_FILES_H_
-#define CONTENT_COMMON_MEDIA_CDM_HOST_FILES_H_
-
-#include <map>
-#include <memory>
-#include <vector>
-
-#include "base/files/file.h"
-#include "base/files/file_path.h"
-#include "base/lazy_instance.h"
-#include "base/logging.h"
-#include "base/memory/ptr_util.h"
-#include "base/native_library.h"
-#include "base/path_service.h"
-#include "build/build_config.h"
-#include "content/common/media/cdm_host_file.h"
-#include "content/common/pepper_plugin_list.h"
-#include "content/public/common/pepper_plugin_info.h"
-#include "media/cdm/api/content_decryption_module_ext.h"
-#include "media/cdm/cdm_paths.h"
-
-// On systems that use the zygote process to spawn child processes, we must
-// open files in the zygote process.
-#if defined(OS_POSIX) && !defined(OS_NACL) && !defined(OS_MACOSX) && \
- !defined(OS_ANDROID)
-#define POSIX_WITH_ZYGOTE 1
-#endif
-
-namespace base {
-class FilePath;
-}
-
-namespace content {
-
-// Manages all CDM host files.
-class CdmHostFiles {
- public:
- CdmHostFiles();
- ~CdmHostFiles();
-
-#if defined(POSIX_WITH_ZYGOTE)
- // Opens CDM host files for all registered CDMs and set the global
- // CdmHostFiles instance. On any failure, the global instance will not be
- // set and no file will be left open.
- static void CreateGlobalInstance();
-
- // Takes and returns the global CdmHostFiles instance. The return value could
- // be nullptr if CreateGlobalInstance() failed.
- static std::unique_ptr<CdmHostFiles> TakeGlobalInstance();
-#endif
-
- // Opens CDM host files for the CDM adapter at |cdm_adapter_path| and returns
- // the created CdmHostFiles instance. Returns nullptr if any of the files
- // cannot be opened, in which case no file will be left open.
- static std::unique_ptr<CdmHostFiles> Create(
- const base::FilePath& cdm_adapter_path);
-
- // Status of CDM host verification.
- // Note: Reported to UMA. Do not change the values.
- enum class Status {
- kNotCalled = 0,
- kSuccess = 1,
- kCdmLoadFailed = 2,
- kGetFunctionFailed = 3,
- kInitVerificationFailed = 4,
- kStatusCount
- };
-
- // Initializes the verification of CDM files by calling the function exported
- // by the CDM. If unexpected error happens, all files will be closed.
- // Otherwise, the PlatformFiles are passed to the CDM which will close the
- // files later.
- Status InitVerification(base::NativeLibrary cdm_adapter_library,
- const base::FilePath& cdm_adapter_path);
-
- private:
-#if defined(POSIX_WITH_ZYGOTE)
- // Opens all common files and CDM specific files for all registered CDMs.
- void OpenFilesForAllRegisteredCdms();
-#endif
-
- // Opens all common files and CDM specific files for the CDM adapter
- // registered at |cdm_adapter_path|.
- void OpenFiles(const base::FilePath& cdm_adapter_path);
-
- // Opens common CDM host files shared by all CDMs.
- void OpenCommonFiles();
-
- // Opens CDM specific files for the CDM adapter registered at
- // |cdm_adapter_path|.
- void OpenCdmFiles(const base::FilePath& cdm_adapter_path);
-
- // Fills |cdm_host_files| with common and CDM specific files for
- // |cdm_adapter_path|. The ownership of those files are also transferred.
- void TakePlatformFiles(const base::FilePath& cdm_adapter_path,
- std::vector<cdm::HostFile>* cdm_host_files);
-
- void CloseAllFiles();
-
- using ScopedFileVector = std::vector<std::unique_ptr<CdmHostFile>>;
- ScopedFileVector common_files_;
- std::map<base::FilePath, ScopedFileVector> cdm_specific_files_map_;
-};
-
-// Returns whether the |cdm_adapter_path| corresponds to a known CDM.
-bool IsCdm(const base::FilePath& cdm_adapter_path);
-
-} // namespace content
-
-#endif // CONTENT_COMMON_MEDIA_CDM_HOST_FILES_H_
diff --git a/chromium/content/common/media/cdm_info.cc b/chromium/content/common/media/cdm_info.cc
index 3dbdcdab98c..3947bc7ef5d 100644
--- a/chromium/content/common/media/cdm_info.cc
+++ b/chromium/content/common/media/cdm_info.cc
@@ -4,25 +4,32 @@
#include "content/public/common/cdm_info.h"
+#include "base/guid.h"
+#include "base/logging.h"
+
namespace content {
-CdmInfo::CdmInfo(const std::string& type,
+CdmInfo::CdmInfo(const std::string& name,
+ const std::string& guid,
const base::Version& version,
const base::FilePath& path,
- const std::vector<std::string>& supported_codecs)
- : type(type),
+ const std::string& file_system_id,
+ const std::vector<std::string>& supported_codecs,
+ const std::string& supported_key_system,
+ bool supports_sub_key_systems)
+ : name(name),
+ guid(guid),
version(version),
path(path),
- supported_codecs(supported_codecs) {}
+ file_system_id(file_system_id),
+ supported_codecs(supported_codecs),
+ supported_key_system(supported_key_system),
+ supports_sub_key_systems(supports_sub_key_systems) {
+ DCHECK(base::IsValidGUID(guid));
+}
CdmInfo::CdmInfo(const CdmInfo& other) = default;
CdmInfo::~CdmInfo() {}
-CdmHostFilePath::CdmHostFilePath(const base::FilePath& file_path,
- const base::FilePath& sig_file_path)
- : file_path(file_path), sig_file_path(sig_file_path) {}
-
-CdmHostFilePath::~CdmHostFilePath() {}
-
} // namespace content
diff --git a/chromium/content/common/media/media_devices.mojom b/chromium/content/common/media/media_devices.mojom
index 6940ccbabbe..c466598c967 100644
--- a/chromium/content/common/media/media_devices.mojom
+++ b/chromium/content/common/media/media_devices.mojom
@@ -57,6 +57,20 @@ interface MediaDevicesDispatcherHost {
GetVideoInputCapabilities()
=> (array<VideoInputDeviceCapabilities> video_input_device_capabilities);
+ // Returns a list of all video formats supported by a given device, regardless
+ // of whether the device is being used or not. If the given |device_id| is
+ // invalid, the result is empty.
+ GetAllVideoInputDeviceFormats(string device_id)
+ => (array<media.mojom.VideoCaptureFormat> formats);
+
+ // Returns a list of video formats currently available for a given device.
+ // When the device is in use, it is expected that the result will contain only
+ // one entry. When the device is not in use, the result should be the same as
+ // for GetAllVideoInputDeviceFormats. If the given |device_id| is not valid,
+ // the result is empty.
+ GetAvailableVideoInputDeviceFormats(string device_id)
+ => (array<media.mojom.VideoCaptureFormat> formats);
+
// Returns a list of audio input devices and their capabilities.
// If there is a user-preferred device, it is the first in the result.
// Otherwise, the system-default device is the first in the result.
diff --git a/chromium/content/common/media/media_devices_param_traits.cc b/chromium/content/common/media/media_devices_param_traits.cc
index d130d42b02c..74874406c7b 100644
--- a/chromium/content/common/media/media_devices_param_traits.cc
+++ b/chromium/content/common/media/media_devices_param_traits.cc
@@ -4,12 +4,6 @@
#include "content/common/media/media_devices_param_traits.h"
-// Generate param traits size methods.
-#include "ipc/param_traits_size_macros.h"
-namespace IPC {
-#include "content/common/media/media_devices_param_traits.h"
-} // namespace IPC
-
// Generate param traits write methods.
#include "ipc/param_traits_write_macros.h"
namespace IPC {
diff --git a/chromium/content/common/media/media_player_delegate_messages.h b/chromium/content/common/media/media_player_delegate_messages.h
index 45b495b137f..69f372344cc 100644
--- a/chromium/content/common/media/media_player_delegate_messages.h
+++ b/chromium/content/common/media/media_player_delegate_messages.h
@@ -2,9 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_MEDIA_MEDIA_PLAYER_DELEGATE_MESSAGES_H_
+#define CONTENT_COMMON_MEDIA_MEDIA_PLAYER_DELEGATE_MESSAGES_H_
+
// IPC messages for interactions between the WebMediaPlayerDelegate in the
// renderer process and MediaWebContentsObserver in the browser process.
-// Multiply-included message file, hence no include guard.
#include <stdint.h>
@@ -69,3 +71,5 @@ IPC_MESSAGE_ROUTED2(
IPC_MESSAGE_ROUTED2(MediaPlayerDelegateHostMsg_OnMediaSizeChanged,
int /* delegate_id, distinguishes instances */,
gfx::Size /* new size of video */)
+
+#endif // CONTENT_COMMON_MEDIA_MEDIA_PLAYER_DELEGATE_MESSAGES_H_
diff --git a/chromium/content/common/media/media_player_messages_android.h b/chromium/content/common/media/media_player_messages_android.h
index 712e3d0c636..b9729bda437 100644
--- a/chromium/content/common/media/media_player_messages_android.h
+++ b/chromium/content/common/media/media_player_messages_android.h
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_MEDIA_MEDIA_PLAYER_MESSAGES_ANDROID_H_
+#define CONTENT_COMMON_MEDIA_MEDIA_PLAYER_MESSAGES_ANDROID_H_
+
// IPC messages for android media player.
-// Multiply-included message file, hence no include guard.
#include "base/time/time.h"
#include "content/common/content_export.h"
@@ -188,3 +190,5 @@ IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_RequestRemotePlaybackControl,
// Stop playing media on a remote device.
IPC_MESSAGE_ROUTED1(MediaPlayerHostMsg_RequestRemotePlaybackStop,
int /* player_id */)
+
+#endif // #ifndef CONTENT_COMMON_MEDIA_MEDIA_PLAYER_MESSAGES_ANDROID_H_
diff --git a/chromium/content/common/media/media_stream.mojom b/chromium/content/common/media/media_stream.mojom
index 84238f770f2..9bdc1ff543e 100644
--- a/chromium/content/common/media/media_stream.mojom
+++ b/chromium/content/common/media/media_stream.mojom
@@ -6,12 +6,12 @@ module content.mojom;
import "url/mojo/origin.mojom";
-// TODO(c.padhi): Add typemapping for StreamDeviceInfo,
+// TODO(c.padhi): Add typemapping for MediaStreamDevice,
// see https://crbug.com/742682.
-// Native struct content::StreamDeviceInfo.
-// (see content/common/media/media_stream_options.h)
+// Native struct content::MediaStreamDevice.
+// (see content/public/common/media_stream_request.h)
[Native]
-struct StreamDeviceInfo;
+struct MediaStreamDevice;
// Types of media streams (see content/public/common/media_stream_request.h).
enum MediaStreamType {
@@ -43,14 +43,14 @@ enum MediaStreamRequestResult {
KILL_SWITCH_ON
};
-// See content/common/media/media_stream_options.h.
+// See content/common/media/media_stream_controls.h.
struct TrackControls {
bool requested;
string stream_source;
string device_id;
};
-// See content/common/media/media_stream_options.h.
+// See content/common/media/media_stream_controls.h.
struct StreamControls {
TrackControls audio;
TrackControls video;
@@ -63,8 +63,8 @@ struct StreamControls {
interface MediaStreamDispatcher {
// Informs the renderer that browser has generated a stream successfully.
OnStreamGenerated(int32 request_id, string label,
- array<StreamDeviceInfo> audio_array,
- array<StreamDeviceInfo> video_array);
+ array<MediaStreamDevice> audio_devices,
+ array<MediaStreamDevice> video_devices);
// Informs the renderer that browser has failed to generate a stream.
OnStreamGenerationFailed(int32 request_id, MediaStreamRequestResult result);
@@ -72,14 +72,14 @@ interface MediaStreamDispatcher {
// TODO(wjia): should DeviceOpen* methods be merged with
// StreamGenerat* ones?
// Informs the renderer that browser has opened a device successfully.
- OnDeviceOpened(int32 request_id, string label, StreamDeviceInfo device_info);
+ OnDeviceOpened(int32 request_id, string label, MediaStreamDevice device);
// Informs the renderer that browser has failed to open a device.
OnDeviceOpenFailed(int32 request_id);
// The browser reports that a media device has been stopped. Stopping was
// triggered from the browser process.
- OnDeviceStopped(string label, StreamDeviceInfo device_info);
+ OnDeviceStopped(string label, MediaStreamDevice device);
};
// Per-process browser-side interface that is used by the renderer process to
diff --git a/chromium/content/common/media/media_stream.typemap b/chromium/content/common/media/media_stream.typemap
index 6b7dc4e4a74..dca615202b3 100644
--- a/chromium/content/common/media/media_stream.typemap
+++ b/chromium/content/common/media/media_stream.typemap
@@ -5,7 +5,7 @@
mojom = "//content/common/media/media_stream.mojom"
public_headers = [
- "//content/common/media/media_stream_options.h",
+ "//content/common/media/media_stream_controls.h",
"//content/public/common/media_stream_request.h",
]
@@ -23,9 +23,9 @@ deps = [
]
type_mappings = [
+ "content.mojom.MediaStreamDevice=content::MediaStreamDevice",
"content.mojom.MediaStreamRequestResult=content::MediaStreamRequestResult",
"content.mojom.MediaStreamType=content::MediaStreamType",
"content.mojom.StreamControls=content::StreamControls",
- "content.mojom.StreamDeviceInfo=content::StreamDeviceInfo",
"content.mojom.TrackControls=content::TrackControls",
]
diff --git a/chromium/content/common/media/media_stream_controls.cc b/chromium/content/common/media/media_stream_controls.cc
new file mode 100644
index 00000000000..bcd9cdfb147
--- /dev/null
+++ b/chromium/content/common/media/media_stream_controls.cc
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/media/media_stream_controls.h"
+
+namespace content {
+
+const char kMediaStreamSourceTab[] = "tab";
+const char kMediaStreamSourceScreen[] = "screen";
+const char kMediaStreamSourceDesktop[] = "desktop";
+const char kMediaStreamSourceSystem[] = "system";
+
+TrackControls::TrackControls() {}
+
+TrackControls::TrackControls(bool request) : requested(request) {}
+
+TrackControls::TrackControls(const TrackControls& other) = default;
+
+TrackControls::~TrackControls() {}
+
+StreamControls::StreamControls() {}
+
+StreamControls::StreamControls(bool request_audio, bool request_video)
+ : audio(request_audio), video(request_video) {}
+
+StreamControls::~StreamControls() {}
+
+} // namespace content
diff --git a/chromium/content/common/media/media_stream_options.h b/chromium/content/common/media/media_stream_controls.h
index 55f568736b9..39d351345db 100644
--- a/chromium/content/common/media/media_stream_options.h
+++ b/chromium/content/common/media/media_stream_controls.h
@@ -2,14 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_COMMON_MEDIA_MEDIA_STREAM_OPTIONS_H_
-#define CONTENT_COMMON_MEDIA_MEDIA_STREAM_OPTIONS_H_
+#ifndef CONTENT_COMMON_MEDIA_MEDIA_STREAM_CONTROLS_H_
+#define CONTENT_COMMON_MEDIA_MEDIA_STREAM_CONTROLS_H_
#include <string>
-#include <vector>
#include "content/common/content_export.h"
-#include "content/public/common/media_stream_request.h"
namespace content {
@@ -22,12 +20,12 @@ CONTENT_EXPORT extern const char kMediaStreamSourceDesktop[];
CONTENT_EXPORT extern const char kMediaStreamSourceSystem[];
struct CONTENT_EXPORT TrackControls {
- public:
TrackControls();
explicit TrackControls(bool request);
explicit TrackControls(const TrackControls& other);
~TrackControls();
- bool requested;
+
+ bool requested = false;
// Source. This is "tab", "screen", "desktop", "system", or blank.
// Consider replacing with MediaStreamType enum variables.
@@ -42,45 +40,20 @@ struct CONTENT_EXPORT TrackControls {
// from the renderer process in order to control the opening of a device
// pair. This may result in opening one audio and/or one video device.
// This has to be a struct with public members in order to allow it to
-// be sent in the IPC of media_stream_messages.h
+// be sent in the mojo IPC.
struct CONTENT_EXPORT StreamControls {
- public:
StreamControls();
StreamControls(bool request_audio, bool request_video);
~StreamControls();
+
TrackControls audio;
TrackControls video;
// Hotword functionality (chromeos only)
// See crbug.com/564574 for discussion on possibly #ifdef'ing this out.
- bool hotword_enabled; // kMediaStreamAudioHotword = "googHotword";
- bool disable_local_echo;
-};
-
-// StreamDeviceInfo describes information about a device.
-struct CONTENT_EXPORT StreamDeviceInfo {
- static const int kNoId;
-
- StreamDeviceInfo();
- StreamDeviceInfo(MediaStreamType service_param,
- const std::string& name_param,
- const std::string& device_param);
- StreamDeviceInfo(MediaStreamType service_param,
- const std::string& name_param,
- const std::string& device_param,
- int sample_rate,
- int channel_layout,
- int frames_per_buffer);
- static bool IsEqual(const StreamDeviceInfo& first,
- const StreamDeviceInfo& second);
-
- MediaStreamDevice device;
-
- // Id for this capture session. Unique for all sessions of the same type.
- int session_id;
+ bool hotword_enabled = false;
+ bool disable_local_echo = false;
};
-typedef std::vector<StreamDeviceInfo> StreamDeviceInfoArray;
-
} // namespace content
-#endif // CONTENT_COMMON_MEDIA_MEDIA_STREAM_OPTIONS_H_
+#endif // CONTENT_COMMON_MEDIA_MEDIA_STREAM_CONTROLS_H_
diff --git a/chromium/content/common/media/media_stream_options.cc b/chromium/content/common/media/media_stream_options.cc
deleted file mode 100644
index ba390927fba..00000000000
--- a/chromium/content/common/media/media_stream_options.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/media/media_stream_options.h"
-
-#include "base/logging.h"
-
-namespace content {
-
-const char kMediaStreamSourceTab[] = "tab";
-const char kMediaStreamSourceScreen[] = "screen";
-const char kMediaStreamSourceDesktop[] = "desktop";
-const char kMediaStreamSourceSystem[] = "system";
-
-TrackControls::TrackControls()
- : requested(false) {}
-
-TrackControls::TrackControls(bool request)
- : requested(request) {}
-
-TrackControls::TrackControls(const TrackControls& other) = default;
-
-TrackControls::~TrackControls() {}
-
-StreamControls::StreamControls()
- : audio(false),
- video(false),
- hotword_enabled(false),
- disable_local_echo(false) {}
-
-StreamControls::StreamControls(bool request_audio, bool request_video)
- : audio(request_audio),
- video(request_video),
- hotword_enabled(false),
- disable_local_echo(false) {}
-
-StreamControls::~StreamControls() {}
-
-// static
-const int StreamDeviceInfo::kNoId = -1;
-
-StreamDeviceInfo::StreamDeviceInfo()
- : session_id(kNoId) {}
-
-StreamDeviceInfo::StreamDeviceInfo(MediaStreamType service_param,
- const std::string& name_param,
- const std::string& device_param)
- : device(service_param, device_param, name_param), session_id(kNoId) {}
-
-StreamDeviceInfo::StreamDeviceInfo(MediaStreamType service_param,
- const std::string& name_param,
- const std::string& device_param,
- int sample_rate,
- int channel_layout,
- int frames_per_buffer)
- : device(service_param,
- device_param,
- name_param,
- sample_rate,
- channel_layout,
- frames_per_buffer),
- session_id(kNoId) {}
-
-// static
-bool StreamDeviceInfo::IsEqual(const StreamDeviceInfo& first,
- const StreamDeviceInfo& second) {
- return first.device.IsEqual(second.device) &&
- first.session_id == second.session_id;
-}
-
-} // namespace content
diff --git a/chromium/content/common/media/media_stream_param_traits.cc b/chromium/content/common/media/media_stream_param_traits.cc
index e752355449d..f515d969175 100644
--- a/chromium/content/common/media/media_stream_param_traits.cc
+++ b/chromium/content/common/media/media_stream_param_traits.cc
@@ -14,12 +14,6 @@
#include "ipc/struct_destructor_macros.h"
#include "content/common/media/media_stream_param_traits.h"
-// Generate param traits size methods.
-#include "ipc/param_traits_size_macros.h"
-namespace IPC {
-#include "content/common/media/media_stream_param_traits.h"
-}
-
// Generate param traits write methods.
#include "ipc/param_traits_write_macros.h"
namespace IPC {
diff --git a/chromium/content/common/media/media_stream_param_traits.h b/chromium/content/common/media/media_stream_param_traits.h
index 190bc2df5c0..dcc50242b71 100644
--- a/chromium/content/common/media/media_stream_param_traits.h
+++ b/chromium/content/common/media/media_stream_param_traits.h
@@ -6,7 +6,7 @@
// Multiply-included message file, hence no include guard.
#include "content/common/content_export.h"
-#include "content/common/media/media_stream_options.h"
+#include "content/public/common/media_stream_request.h"
#include "ipc/ipc_message_macros.h"
#include "media/base/ipc/media_param_traits.h"
#include "media/capture/ipc/capture_param_traits.h"
@@ -20,14 +20,14 @@ IPC_ENUM_TRAITS_MAX_VALUE(content::MediaStreamType,
IPC_ENUM_TRAITS_MAX_VALUE(media::VideoFacingMode,
media::NUM_MEDIA_VIDEO_FACING_MODES - 1)
-IPC_STRUCT_TRAITS_BEGIN(content::StreamDeviceInfo)
- IPC_STRUCT_TRAITS_MEMBER(device.type)
- IPC_STRUCT_TRAITS_MEMBER(device.id)
- IPC_STRUCT_TRAITS_MEMBER(device.video_facing)
- IPC_STRUCT_TRAITS_MEMBER(device.matched_output_device_id)
- IPC_STRUCT_TRAITS_MEMBER(device.name)
- IPC_STRUCT_TRAITS_MEMBER(device.input)
- IPC_STRUCT_TRAITS_MEMBER(device.matched_output)
- IPC_STRUCT_TRAITS_MEMBER(device.camera_calibration)
+IPC_STRUCT_TRAITS_BEGIN(content::MediaStreamDevice)
+ IPC_STRUCT_TRAITS_MEMBER(type)
+ IPC_STRUCT_TRAITS_MEMBER(id)
+ IPC_STRUCT_TRAITS_MEMBER(video_facing)
+ IPC_STRUCT_TRAITS_MEMBER(matched_output_device_id)
+ IPC_STRUCT_TRAITS_MEMBER(name)
+ IPC_STRUCT_TRAITS_MEMBER(input)
+ IPC_STRUCT_TRAITS_MEMBER(matched_output)
IPC_STRUCT_TRAITS_MEMBER(session_id)
+ IPC_STRUCT_TRAITS_MEMBER(camera_calibration)
IPC_STRUCT_TRAITS_END()
diff --git a/chromium/content/common/media/media_stream_track_metrics_host_messages.h b/chromium/content/common/media/media_stream_track_metrics_host_messages.h
index cfee04194e5..6f357094512 100644
--- a/chromium/content/common/media/media_stream_track_metrics_host_messages.h
+++ b/chromium/content/common/media/media_stream_track_metrics_host_messages.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_MEDIA_MEDIA_STREAM_TRACK_METRICS_HOST_MESSAGES_H_
+#define CONTENT_COMMON_MEDIA_MEDIA_STREAM_TRACK_METRICS_HOST_MESSAGES_H_
+
#include <stdint.h>
#include "base/values.h"
@@ -18,3 +21,5 @@ IPC_MESSAGE_CONTROL3(MediaStreamTrackMetricsHost_AddTrack,
bool /* is_audio */,
bool /* is_remote */)
IPC_MESSAGE_CONTROL1(MediaStreamTrackMetricsHost_RemoveTrack, uint64_t /* id */)
+
+#endif // CONTENT_COMMON_MEDIA_MEDIA_STREAM_TRACK_METRICS_HOST_MESSAGES_H_
diff --git a/chromium/content/common/media/media_stream_typemap_traits.h b/chromium/content/common/media/media_stream_typemap_traits.h
index ed967141530..de811eacdf9 100644
--- a/chromium/content/common/media/media_stream_typemap_traits.h
+++ b/chromium/content/common/media/media_stream_typemap_traits.h
@@ -6,7 +6,7 @@
#define CONTENT_COMMON_MEDIA_MEDIA_STREAM_TYPEMAP_TRAITS_H_
#include "content/common/media/media_stream.mojom.h"
-#include "content/common/media/media_stream_options.h"
+#include "content/common/media/media_stream_controls.h"
#include "content/public/common/media_stream_request.h"
namespace mojo {
diff --git a/chromium/content/common/media/midi_messages.h b/chromium/content/common/media/midi_messages.h
index 4882b379daa..35e90284f3b 100644
--- a/chromium/content/common/media/midi_messages.h
+++ b/chromium/content/common/media/midi_messages.h
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_MEDIA_MIDI_MESSAGES_H_
+#define CONTENT_COMMON_MEDIA_MIDI_MESSAGES_H_
+
// IPC messages for access to MIDI hardware.
-// Multiply-included message file, hence no include guard.
// TODO(toyoshim): Mojofication is working in progress. Until the work is
// finished, this file temporarily depends on midi_service.mojom.h.
@@ -71,3 +73,5 @@ IPC_MESSAGE_CONTROL3(MidiMsg_DataReceived,
double /* timestamp */)
IPC_MESSAGE_CONTROL1(MidiMsg_AcknowledgeSentData, uint32_t /* bytes sent */)
+
+#endif // CONTENT_COMMON_MEDIA_MIDI_MESSAGES_H_
diff --git a/chromium/content/common/media/peer_connection_tracker_messages.h b/chromium/content/common/media/peer_connection_tracker_messages.h
index 130f3b6ac4a..290bf3ffb31 100644
--- a/chromium/content/common/media/peer_connection_tracker_messages.h
+++ b/chromium/content/common/media/peer_connection_tracker_messages.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_MEDIA_PEER_CONNECTION_TRACKER_MESSAGES_H_
+#define CONTENT_COMMON_MEDIA_PEER_CONNECTION_TRACKER_MESSAGES_H_
+
#include "base/values.h"
#include "content/common/content_export.h"
#include "ipc/ipc_message_macros.h"
@@ -47,3 +50,5 @@ IPC_MESSAGE_CONTROL2(PeerConnectionTracker_StartEventLog,
IPC::PlatformFileForTransit /* file */)
IPC_MESSAGE_CONTROL1(PeerConnectionTracker_StopEventLog,
int /* peer_connection_local_id */)
+
+#endif // CONTENT_COMMON_MEDIA_PEER_CONNECTION_TRACKER_MESSAGES_H_
diff --git a/chromium/content/common/media/surface_view_manager_messages_android.h b/chromium/content/common/media/surface_view_manager_messages_android.h
index 72426c2539d..50876424549 100644
--- a/chromium/content/common/media/surface_view_manager_messages_android.h
+++ b/chromium/content/common/media/surface_view_manager_messages_android.h
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_MEDIA_SURFACE_VIEW_MANAGER_MESSAGES_ANDROID_H_
+#define CONTENT_COMMON_MEDIA_SURFACE_VIEW_MANAGER_MESSAGES_ANDROID_H_
+
// IPC messages for surface view manager.
-// Multiply-included message file, hence no include guard.
#include "content/common/content_export.h"
#include "ipc/ipc_message_macros.h"
@@ -24,3 +26,5 @@ IPC_MESSAGE_ROUTED1(SurfaceViewManagerHostMsg_NaturalSizeChanged,
IPC_MESSAGE_ROUTED1(SurfaceViewManagerMsg_FullscreenSurfaceCreated,
int /* surface_id */)
+
+#endif // CONTENT_COMMON_MEDIA_SURFACE_VIEW_MANAGER_MESSAGES_ANDROID_H_
diff --git a/chromium/content/common/message_port.cc b/chromium/content/common/message_port.cc
deleted file mode 100644
index 0cb337bd63d..00000000000
--- a/chromium/content/common/message_port.cc
+++ /dev/null
@@ -1,209 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/message_port.h"
-
-#include "base/bind.h"
-#include "base/containers/span.h"
-#include "base/logging.h"
-#include "base/threading/thread_task_runner_handle.h"
-#include "content/common/message_port.mojom.h"
-#include "content/common/message_port_message_struct_traits.h"
-#include "mojo/public/cpp/system/message_pipe.h"
-
-namespace content {
-
-MessagePort::~MessagePort() {}
-
-MessagePort::MessagePort() : state_(new State()) {}
-
-MessagePort::MessagePort(const MessagePort& other) : state_(other.state_) {}
-
-MessagePort& MessagePort::operator=(const MessagePort& other) {
- state_ = other.state_;
- return *this;
-}
-
-MessagePort::MessagePort(mojo::ScopedMessagePipeHandle handle)
- : state_(new State(std::move(handle))) {}
-
-const mojo::ScopedMessagePipeHandle& MessagePort::GetHandle() const {
- return state_->handle();
-}
-
-mojo::ScopedMessagePipeHandle MessagePort::ReleaseHandle() const {
- state_->StopWatching();
- return state_->TakeHandle();
-}
-
-// static
-std::vector<mojo::ScopedMessagePipeHandle> MessagePort::ReleaseHandles(
- const std::vector<MessagePort>& ports) {
- std::vector<mojo::ScopedMessagePipeHandle> handles(ports.size());
- for (size_t i = 0; i < ports.size(); ++i)
- handles[i] = ports[i].ReleaseHandle();
- return handles;
-}
-
-void MessagePort::PostMessage(const uint8_t* encoded_message,
- size_t encoded_message_size,
- std::vector<MessagePort> ports) {
- DCHECK(state_->handle().is_valid());
-
- // NOTE: It is OK to ignore the return value of mojo::WriteMessageNew here.
- // HTML MessagePorts have no way of reporting when the peer is gone.
-
- MessagePortMessage msg;
- msg.encoded_message = base::make_span(encoded_message, encoded_message_size);
- msg.ports.resize(ports.size());
- for (size_t i = 0; i < ports.size(); ++i)
- msg.ports[i] = ports[i].ReleaseHandle();
- mojo::Message mojo_message =
- mojom::MessagePortMessage::SerializeAsMessage(&msg);
- mojo::WriteMessageNew(state_->handle().get(), mojo_message.TakeMojoMessage(),
- MOJO_WRITE_MESSAGE_FLAG_NONE);
-}
-
-bool MessagePort::GetMessage(std::vector<uint8_t>* encoded_message,
- std::vector<MessagePort>* ports) {
- DCHECK(state_->handle().is_valid());
- mojo::ScopedMessageHandle message_handle;
- MojoResult rv = mojo::ReadMessageNew(state_->handle().get(), &message_handle,
- MOJO_READ_MESSAGE_FLAG_NONE);
- if (rv != MOJO_RESULT_OK)
- return false;
-
- mojo::Message message(std::move(message_handle));
- MessagePortMessage msg;
- bool success = mojom::MessagePortMessage::DeserializeFromMessage(
- std::move(message), &msg);
- if (!success)
- return false;
-
- *encoded_message = std::move(msg.owned_encoded_message);
- ports->resize(msg.ports.size());
- for (size_t i = 0; i < ports->size(); ++i)
- ports->at(i) = MessagePort(std::move(msg.ports[i]));
-
- return true;
-}
-
-void MessagePort::SetCallback(const base::Closure& callback) {
- state_->StopWatching();
- state_->StartWatching(callback);
-}
-
-void MessagePort::ClearCallback() {
- state_->StopWatching();
-}
-
-MessagePort::State::State() {}
-
-MessagePort::State::State(mojo::ScopedMessagePipeHandle handle)
- : handle_(std::move(handle)) {}
-
-void MessagePort::State::StartWatching(const base::Closure& callback) {
- base::AutoLock lock(lock_);
- DCHECK(!callback_);
- DCHECK(handle_.is_valid());
- callback_ = callback;
-
- DCHECK(!watcher_handle_.is_valid());
- MojoResult rv = CreateWatcher(&State::CallOnHandleReady, &watcher_handle_);
- DCHECK_EQ(MOJO_RESULT_OK, rv);
-
- // Balanced in CallOnHandleReady when MOJO_RESULT_CANCELLED is received.
- AddRef();
-
- // NOTE: An HTML MessagePort does not receive an event to tell it when the
- // peer has gone away, so we only watch for readability here.
- rv = MojoWatch(watcher_handle_.get().value(), handle_.get().value(),
- MOJO_HANDLE_SIGNAL_READABLE, MOJO_WATCH_CONDITION_SATISFIED,
- reinterpret_cast<uintptr_t>(this));
- DCHECK_EQ(MOJO_RESULT_OK, rv);
-
- ArmWatcher();
-}
-
-void MessagePort::State::StopWatching() {
- mojo::ScopedWatcherHandle watcher_handle;
-
- {
- // NOTE: Resetting the watcher handle may synchronously invoke
- // OnHandleReady(), so we don't hold |lock_| while doing that.
- base::AutoLock lock(lock_);
- watcher_handle = std::move(watcher_handle_);
- callback_.Reset();
- }
-}
-
-mojo::ScopedMessagePipeHandle MessagePort::State::TakeHandle() {
- base::AutoLock lock(lock_);
- DCHECK(!watcher_handle_.is_valid());
- return std::move(handle_);
-}
-
-MessagePort::State::~State() = default;
-
-void MessagePort::State::ArmWatcher() {
- lock_.AssertAcquired();
-
- if (!watcher_handle_.is_valid())
- return;
-
- uint32_t num_ready_contexts = 1;
- uintptr_t ready_context;
- MojoResult ready_result;
- MojoHandleSignalsState ready_state;
- MojoResult rv =
- MojoArmWatcher(watcher_handle_.get().value(), &num_ready_contexts,
- &ready_context, &ready_result, &ready_state);
- if (rv == MOJO_RESULT_OK)
- return;
-
- // The watcher could not be armed because it would notify immediately.
- DCHECK_EQ(MOJO_RESULT_FAILED_PRECONDITION, rv);
- DCHECK_EQ(1u, num_ready_contexts);
- DCHECK_EQ(reinterpret_cast<uintptr_t>(this), ready_context);
-
- if (ready_result == MOJO_RESULT_OK) {
- // The handle is already signaled, so we trigger a callback now.
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::BindOnce(&State::OnHandleReady, this, MOJO_RESULT_OK));
- return;
- }
-
- if (ready_result == MOJO_RESULT_FAILED_PRECONDITION) {
- DVLOG(1) << this << " MojoArmWatcher failed because of a broken pipe.";
- return;
- }
-
- NOTREACHED();
-}
-
-void MessagePort::State::OnHandleReady(MojoResult result) {
- base::AutoLock lock(lock_);
- if (result == MOJO_RESULT_OK && callback_) {
- callback_.Run();
- ArmWatcher();
- } else {
- // And now his watch is ended.
- }
-}
-
-// static
-void MessagePort::State::CallOnHandleReady(uintptr_t context,
- MojoResult result,
- MojoHandleSignalsState signals_state,
- MojoWatcherNotificationFlags flags) {
- auto* state = reinterpret_cast<State*>(context);
- if (result == MOJO_RESULT_CANCELLED) {
- // Balanced in MessagePort::State::StartWatching().
- state->Release();
- } else {
- state->OnHandleReady(result);
- }
-}
-
-} // namespace content
diff --git a/chromium/content/common/message_port.h b/chromium/content/common/message_port.h
deleted file mode 100644
index 2ed695faa12..00000000000
--- a/chromium/content/common/message_port.h
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright 2017 The Chromium 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 CONTENT_COMMON_MESSAGE_PORT_H_
-#define CONTENT_COMMON_MESSAGE_PORT_H_
-
-#include <vector>
-
-#include "base/callback.h"
-#include "base/macros.h"
-#include "base/memory/ref_counted.h"
-#include "base/synchronization/lock.h"
-#include "content/common/content_export.h"
-#include "mojo/public/cpp/system/message_pipe.h"
-#include "mojo/public/cpp/system/watcher.h"
-
-namespace content {
-
-// MessagePort corresponds to a HTML MessagePort. It is a thin wrapper around a
-// Mojo MessagePipeHandle and provides methods for reading and writing messages.
-//
-// A MessagePort is only actively listening for incoming messages once
-// SetCallback has been called with a valid callback. If ClearCallback is
-// called (or if SetCallback is called with a null callback), then the
-// MessagePort will stop listening for incoming messages. The callback runs on
-// an unspecified background thread.
-//
-// Upon destruction, if the MessagePort is listening for incoming messages,
-// then the destructor will first synchronize with the background thread,
-// waiting for it to finish any in-process callback before closing the
-// underlying MessagePipeHandle. This synchronization ensures that any code
-// running in the callback can be sure to not worry about the MessagePort
-// becoming invalid during callback execution.
-//
-// MessagePort methods may be used from any thread; however, care must be taken
-// when using ReleaseHandle, ReleaseHandles or when destroying a MessagePort
-// instance. The MessagePort class does not synchronize those methods with
-// methods like PostMessage, GetMessage and SetCallback that use the underlying
-// MessagePipeHandle.
-//
-// TODO(darin): Make this class move-only once no longer used with Chrome IPC.
-//
-class CONTENT_EXPORT MessagePort {
- public:
- ~MessagePort();
- MessagePort();
-
- // Shallow copy, resulting in multiple references to the same port.
- MessagePort(const MessagePort& other);
- MessagePort& operator=(const MessagePort& other);
-
- explicit MessagePort(mojo::ScopedMessagePipeHandle handle);
-
- const mojo::ScopedMessagePipeHandle& GetHandle() const;
- mojo::ScopedMessagePipeHandle ReleaseHandle() const;
-
- static std::vector<mojo::ScopedMessagePipeHandle> ReleaseHandles(
- const std::vector<MessagePort>& ports);
-
- // Sends an encoded message (along with ports to transfer) to this port's
- // peer.
- void PostMessage(const uint8_t* encoded_message,
- size_t encoded_message_size,
- std::vector<MessagePort> ports);
-
- // Get the next available encoded message if any. Returns true if a message
- // was read.
- bool GetMessage(std::vector<uint8_t>* encoded_message,
- std::vector<MessagePort>* ports);
-
- // This callback will be invoked on a background thread when messages are
- // available to be read via GetMessage. It must not synchronously call back
- // into the MessagePort instance.
- void SetCallback(const base::Closure& callback);
-
- // Clears any callback specified by a prior call to SetCallback.
- void ClearCallback();
-
- private:
- class State : public base::RefCountedThreadSafe<State> {
- public:
- State();
- State(mojo::ScopedMessagePipeHandle handle);
-
- void StartWatching(const base::Closure& callback);
- void StopWatching();
-
- mojo::ScopedMessagePipeHandle TakeHandle();
-
- const mojo::ScopedMessagePipeHandle& handle() const { return handle_; }
-
- private:
- friend class base::RefCountedThreadSafe<State>;
-
- ~State();
-
- void ArmWatcher();
- void OnHandleReady(MojoResult result);
-
- static void CallOnHandleReady(uintptr_t context,
- MojoResult result,
- MojoHandleSignalsState signals_state,
- MojoWatcherNotificationFlags flags);
-
- // Guards access to the fields below.
- base::Lock lock_;
-
- mojo::ScopedWatcherHandle watcher_handle_;
- mojo::ScopedMessagePipeHandle handle_;
-
- // Callback to invoke when the State is notified about a change to
- // |handle_|'s signaling state.
- base::Closure callback_;
- };
- mutable scoped_refptr<State> state_;
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_MESSAGE_PORT_H_
diff --git a/chromium/content/common/message_port.mojom b/chromium/content/common/message_port.mojom
deleted file mode 100644
index e4ffe8eaf38..00000000000
--- a/chromium/content/common/message_port.mojom
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-module content.mojom;
-
-// This struct represents a message as it is sent across a MessagePort. A
-// MessagePort itself is represented as a raw mojo message pipe, and messages
-// on it are (in both directions) serialized versions of this struct.
-struct MessagePortMessage {
- // The actual message data, as encoded by blink::SerializedScriptValue.
- array<uint8> encoded_message;
- // Any ports being transfered as part of this message.
- array<handle<message_pipe>> ports;
-};
diff --git a/chromium/content/common/message_port_message.cc b/chromium/content/common/message_port_message.cc
deleted file mode 100644
index facde6f863c..00000000000
--- a/chromium/content/common/message_port_message.cc
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/message_port_message.h"
-
-namespace content {
-
-MessagePortMessage::MessagePortMessage() = default;
-MessagePortMessage::~MessagePortMessage() = default;
-
-} // namespace content
diff --git a/chromium/content/common/message_port_message.h b/chromium/content/common/message_port_message.h
deleted file mode 100644
index 086fe754868..00000000000
--- a/chromium/content/common/message_port_message.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2017 The Chromium 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 CONTENT_COMMON_MESSAGE_PORT_MESSAGE_H_
-#define CONTENT_COMMON_MESSAGE_PORT_MESSAGE_H_
-
-#include <vector>
-
-#include "base/containers/span.h"
-#include "mojo/public/cpp/system/message_pipe.h"
-
-namespace content {
-
-// This struct represents messages as they are posted over a message port. This
-// type can be serialized as a content::mojom::MessagePortMessage struct.
-struct MessagePortMessage {
- MessagePortMessage();
- ~MessagePortMessage();
-
- // To reduce copies when serializing |encoded_message| does not have to point
- // to |owned_encoded_message|. The serialization code completely ignores the
- // |owned_encoded_message| and just serializes whatever |encoded_message|
- // points to. When deserializing |owned_encoded_message| is set to the data
- // and |encoded_message| is set to point to |owned_encoded_message|.
- base::span<const uint8_t> encoded_message;
- std::vector<uint8_t> owned_encoded_message;
-
- // Any ports being transfered as part of this message.
- std::vector<mojo::ScopedMessagePipeHandle> ports;
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_MESSAGE_PORT_MESSAGE_H_
diff --git a/chromium/content/common/message_port_message_struct_traits.cc b/chromium/content/common/message_port_message_struct_traits.cc
deleted file mode 100644
index 355bbdab101..00000000000
--- a/chromium/content/common/message_port_message_struct_traits.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/message_port_message_struct_traits.h"
-
-#include "base/containers/span.h"
-
-namespace mojo {
-
-bool StructTraits<content::mojom::MessagePortMessage::DataView,
- content::MessagePortMessage>::
- Read(content::mojom::MessagePortMessage::DataView data,
- content::MessagePortMessage* out) {
- if (!data.ReadEncodedMessage(&out->owned_encoded_message) ||
- !data.ReadPorts(&out->ports))
- return false;
-
- out->encoded_message = out->owned_encoded_message;
- return true;
-}
-
-} // namespace mojo
diff --git a/chromium/content/common/message_port_message_struct_traits.h b/chromium/content/common/message_port_message_struct_traits.h
deleted file mode 100644
index 44d8bcf0e8b..00000000000
--- a/chromium/content/common/message_port_message_struct_traits.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2017 The Chromium 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 CONTENT_COMMON_MESSAGE_PORT_MESSAGE_STRUCT_TRAITS_H_
-#define CONTENT_COMMON_MESSAGE_PORT_MESSAGE_STRUCT_TRAITS_H_
-
-#include "base/containers/span.h"
-#include "content/common/message_port.mojom.h"
-#include "content/common/message_port_message.h"
-
-namespace mojo {
-
-template <>
-struct StructTraits<content::mojom::MessagePortMessage::DataView,
- content::MessagePortMessage> {
- static base::span<const uint8_t> encoded_message(
- content::MessagePortMessage& input) {
- return input.encoded_message;
- }
-
- static std::vector<mojo::ScopedMessagePipeHandle>& ports(
- content::MessagePortMessage& input) {
- return input.ports;
- }
-
- static bool Read(content::mojom::MessagePortMessage::DataView data,
- content::MessagePortMessage* out);
-};
-
-} // namespace mojo
-
-#endif // CONTENT_COMMON_MESSAGE_PORT_MESSAGE_STRUCT_TRAITS_H_
diff --git a/chromium/content/common/native_types.typemap b/chromium/content/common/native_types.typemap
index a8e0c0cd04a..cf3a0b0c440 100644
--- a/chromium/content/common/native_types.typemap
+++ b/chromium/content/common/native_types.typemap
@@ -53,6 +53,7 @@ public_deps = [
"//media/base/ipc",
"//net",
"//ppapi/features",
+ "//third_party/WebKit/common:blink_common",
"//ui/accessibility",
"//ui/base/ime:text_input_types",
"//ui/gfx/ipc",
@@ -85,6 +86,7 @@ type_mappings = [
"content.mojom.SyntheticPinch=content::SyntheticPinchGestureParams",
"content.mojom.SyntheticTap=content::SyntheticTapGestureParams",
"content.mojom.SyntheticPointerAction=content::SyntheticPointerActionListParams",
+ "content.mojom.TouchAction=cc::TouchAction",
"content.mojom.TouchActionOptional=cc::TouchAction",
"content.mojom.TouchState=blink::WebTouchPoint::State",
"content.mojom.WebPopupType=blink::WebPopupType",
diff --git a/chromium/content/common/navigation_params.cc b/chromium/content/common/navigation_params.cc
index e8b1a7f60a8..f1a53087139 100644
--- a/chromium/content/common/navigation_params.cc
+++ b/chromium/content/common/navigation_params.cc
@@ -35,7 +35,8 @@ CommonNavigationParams::CommonNavigationParams()
previews_state(PREVIEWS_UNSPECIFIED),
navigation_start(base::TimeTicks::Now()),
method("GET"),
- should_check_main_world_csp(CSPDisposition::CHECK) {}
+ should_check_main_world_csp(CSPDisposition::CHECK),
+ started_from_context_menu(false) {}
CommonNavigationParams::CommonNavigationParams(
const GURL& url,
@@ -53,7 +54,8 @@ CommonNavigationParams::CommonNavigationParams(
std::string method,
const scoped_refptr<ResourceRequestBody>& post_data,
base::Optional<SourceLocation> source_location,
- CSPDisposition should_check_main_world_csp)
+ CSPDisposition should_check_main_world_csp,
+ bool started_from_context_menu)
: url(url),
referrer(referrer),
transition(transition),
@@ -69,7 +71,8 @@ CommonNavigationParams::CommonNavigationParams(
method(method),
post_data(post_data),
source_location(source_location),
- should_check_main_world_csp(should_check_main_world_csp) {
+ should_check_main_world_csp(should_check_main_world_csp),
+ started_from_context_menu(started_from_context_menu) {
// |method != "POST"| should imply absence of |post_data|.
if (method != "POST" && post_data) {
NOTREACHED();
diff --git a/chromium/content/common/navigation_params.h b/chromium/content/common/navigation_params.h
index a73ae233c75..19c2acc137b 100644
--- a/chromium/content/common/navigation_params.h
+++ b/chromium/content/common/navigation_params.h
@@ -70,7 +70,8 @@ struct CONTENT_EXPORT CommonNavigationParams {
std::string method,
const scoped_refptr<ResourceRequestBody>& post_data,
base::Optional<SourceLocation> source_location,
- CSPDisposition should_check_main_world_csp);
+ CSPDisposition should_check_main_world_csp,
+ bool started_from_context_menu);
CommonNavigationParams(const CommonNavigationParams& other);
~CommonNavigationParams();
@@ -146,6 +147,9 @@ struct CONTENT_EXPORT CommonNavigationParams {
// world which has initiated the navigation should be passed.
// See https://crbug.com/702540
CSPDisposition should_check_main_world_csp;
+
+ // Whether or not this navigation was started from a context menu.
+ bool started_from_context_menu;
};
// Provided by the renderer ----------------------------------------------------
@@ -310,7 +314,7 @@ struct CONTENT_EXPORT RequestNavigationParams {
// For browser-initiated navigations, this is the unique id of the
// NavigationEntry being navigated to. (For renderer-initiated navigations it
// is 0.) If the load succeeds, then this nav_entry_id will be reflected in
- // the resulting FrameHostMsg_DidCommitProvisionalLoad message.
+ // the resulting FrameHostMsg_DidCommitProvisionalLoad_Params.
int nav_entry_id;
// Whether this is a history navigation in a newly created child frame, in
diff --git a/chromium/content/common/origin_trials/OWNERS b/chromium/content/common/origin_trials/OWNERS
index e6e219021b9..5ca549f1aa3 100644
--- a/chromium/content/common/origin_trials/OWNERS
+++ b/chromium/content/common/origin_trials/OWNERS
@@ -1,6 +1,7 @@
# This file also covers ownership of the following directories:
# //chrome/common/origin_trials/
# //content/renderer/origin_trials/
+# //third_party/WebKit/common/origin_trials/
# //tools/origin_trials/
chasej@chromium.org
diff --git a/chromium/content/common/origin_trials/trial_policy_impl.cc b/chromium/content/common/origin_trials/trial_policy_impl.cc
new file mode 100644
index 00000000000..9640757abea
--- /dev/null
+++ b/chromium/content/common/origin_trials/trial_policy_impl.cc
@@ -0,0 +1,37 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/origin_trials/trial_policy_impl.h"
+
+#include "base/feature_list.h"
+#include "content/public/common/content_client.h"
+#include "content/public/common/content_features.h"
+#include "content/public/common/origin_trial_policy.h"
+#include "content/public/common/origin_util.h"
+
+namespace content {
+
+bool TrialPolicyImpl::IsOriginTrialsSupported() const {
+ // In order for the validator to work these are all required.
+ return base::FeatureList::IsEnabled(features::kOriginTrials) && policy() &&
+ !GetPublicKey().empty();
+}
+base::StringPiece TrialPolicyImpl::GetPublicKey() const {
+ return policy()->GetPublicKey();
+}
+bool TrialPolicyImpl::IsFeatureDisabled(base::StringPiece feature) const {
+ return policy()->IsFeatureDisabled(feature);
+}
+bool TrialPolicyImpl::IsTokenDisabled(base::StringPiece token_signature) const {
+ return policy()->IsTokenDisabled(token_signature);
+}
+bool TrialPolicyImpl::IsOriginSecure(const GURL& url) const {
+ return ::content::IsOriginSecure(url);
+}
+
+const OriginTrialPolicy* TrialPolicyImpl::policy() const {
+ return GetContentClient()->GetOriginTrialPolicy();
+}
+
+} // namespace content
diff --git a/chromium/content/common/origin_trials/trial_policy_impl.h b/chromium/content/common/origin_trials/trial_policy_impl.h
new file mode 100644
index 00000000000..00556266b78
--- /dev/null
+++ b/chromium/content/common/origin_trials/trial_policy_impl.h
@@ -0,0 +1,36 @@
+// Copyright 2017 The Chromium 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 CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_POLICY_IMPL_H_
+#define CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_POLICY_IMPL_H_
+
+#include "base/strings/string_piece.h"
+#include "content/common/content_export.h"
+#include "third_party/WebKit/common/origin_trials/trial_policy.h"
+
+namespace content {
+
+class OriginTrialPolicy;
+
+// TrialPolicyImpl is an adaptor to fit the policy provided by the content
+// embedder via ContentClient to the interface allowed by the DEPS rules of
+// third_party/WebKit/common
+// TODO(avallee, kinuko): Plumb the the content embedder policy straight through
+// to the users in third_party/WebKit/common/origin_trials.
+class CONTENT_EXPORT TrialPolicyImpl : public blink::TrialPolicy {
+ public:
+ bool IsOriginTrialsSupported() const override;
+
+ base::StringPiece GetPublicKey() const override;
+ bool IsFeatureDisabled(base::StringPiece feature) const override;
+ bool IsTokenDisabled(base::StringPiece token_signature) const override;
+ bool IsOriginSecure(const GURL& url) const override;
+
+ private:
+ const OriginTrialPolicy* policy() const;
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_POLICY_IMPL_H_
diff --git a/chromium/content/common/origin_trials/trial_token.cc b/chromium/content/common/origin_trials/trial_token.cc
deleted file mode 100644
index c8f8cdda617..00000000000
--- a/chromium/content/common/origin_trials/trial_token.cc
+++ /dev/null
@@ -1,234 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/origin_trials/trial_token.h"
-
-#include <vector>
-
-#include "base/base64.h"
-#include "base/big_endian.h"
-#include "base/json/json_reader.h"
-#include "base/macros.h"
-#include "base/memory/ptr_util.h"
-#include "base/strings/string_piece.h"
-#include "base/time/time.h"
-#include "base/values.h"
-#include "third_party/WebKit/public/platform/WebOriginTrialTokenStatus.h"
-#include "third_party/boringssl/src/include/openssl/curve25519.h"
-#include "url/gurl.h"
-#include "url/origin.h"
-
-namespace content {
-
-namespace {
-
-// Version is a 1-byte field at offset 0.
-const size_t kVersionOffset = 0;
-const size_t kVersionSize = 1;
-
-// These constants define the Version 2 field sizes and offsets.
-const size_t kSignatureOffset = kVersionOffset + kVersionSize;
-const size_t kSignatureSize = 64;
-const size_t kPayloadLengthOffset = kSignatureOffset + kSignatureSize;
-const size_t kPayloadLengthSize = 4;
-const size_t kPayloadOffset = kPayloadLengthOffset + kPayloadLengthSize;
-
-// Version 2 is the only token version currently supported. Version 1 was
-// introduced in Chrome M50, and removed in M51. There were no experiments
-// enabled in the stable M50 release which would have used those tokens.
-const uint8_t kVersion2 = 2;
-
-} // namespace
-
-TrialToken::~TrialToken() {}
-
-// static
-std::unique_ptr<TrialToken> TrialToken::From(
- const std::string& token_text,
- base::StringPiece public_key,
- blink::WebOriginTrialTokenStatus* out_status) {
- DCHECK(out_status);
- std::string token_payload;
- std::string token_signature;
- *out_status =
- Extract(token_text, public_key, &token_payload, &token_signature);
- if (*out_status != blink::WebOriginTrialTokenStatus::kSuccess) {
- return nullptr;
- }
- std::unique_ptr<TrialToken> token = Parse(token_payload);
- if (token) {
- token->signature_ = token_signature;
- *out_status = blink::WebOriginTrialTokenStatus::kSuccess;
- } else {
- *out_status = blink::WebOriginTrialTokenStatus::kMalformed;
- }
- return token;
-}
-
-blink::WebOriginTrialTokenStatus TrialToken::IsValid(
- const url::Origin& origin,
- const base::Time& now) const {
- // The order of these checks is intentional. For example, will only report a
- // token as expired if it is valid for the origin.
- if (!ValidateOrigin(origin)) {
- return blink::WebOriginTrialTokenStatus::kWrongOrigin;
- }
- if (!ValidateDate(now)) {
- return blink::WebOriginTrialTokenStatus::kExpired;
- }
- return blink::WebOriginTrialTokenStatus::kSuccess;
-}
-
-// static
-blink::WebOriginTrialTokenStatus TrialToken::Extract(
- const std::string& token_text,
- base::StringPiece public_key,
- std::string* out_token_payload,
- std::string* out_token_signature) {
- if (token_text.empty()) {
- return blink::WebOriginTrialTokenStatus::kMalformed;
- }
-
- // Token is base64-encoded; decode first.
- std::string token_contents;
- if (!base::Base64Decode(token_text, &token_contents)) {
- return blink::WebOriginTrialTokenStatus::kMalformed;
- }
-
- // Only version 2 currently supported.
- if (token_contents.length() < (kVersionOffset + kVersionSize)) {
- return blink::WebOriginTrialTokenStatus::kMalformed;
- }
- uint8_t version = token_contents[kVersionOffset];
- if (version != kVersion2) {
- return blink::WebOriginTrialTokenStatus::kWrongVersion;
- }
-
- // Token must be large enough to contain a version, signature, and payload
- // length.
- if (token_contents.length() < (kPayloadLengthOffset + kPayloadLengthSize)) {
- return blink::WebOriginTrialTokenStatus::kMalformed;
- }
-
- // Extract the length of the signed data (Big-endian).
- uint32_t payload_length;
- base::ReadBigEndian(&(token_contents[kPayloadLengthOffset]), &payload_length);
-
- // Validate that the stated length matches the actual payload length.
- if (payload_length != token_contents.length() - kPayloadOffset) {
- return blink::WebOriginTrialTokenStatus::kMalformed;
- }
-
- // Extract the version-specific contents of the token.
- const char* token_bytes = token_contents.data();
- base::StringPiece version_piece(token_bytes + kVersionOffset, kVersionSize);
- base::StringPiece signature(token_bytes + kSignatureOffset, kSignatureSize);
- base::StringPiece payload_piece(token_bytes + kPayloadLengthOffset,
- kPayloadLengthSize + payload_length);
-
- // The data which is covered by the signature is (version + length + payload).
- std::string signed_data =
- version_piece.as_string() + payload_piece.as_string();
-
- // Validate the signature on the data before proceeding.
- if (!TrialToken::ValidateSignature(signature, signed_data, public_key)) {
- return blink::WebOriginTrialTokenStatus::kInvalidSignature;
- }
-
- // Return the payload and signature, as new strings.
- *out_token_payload = token_contents.substr(kPayloadOffset, payload_length);
- *out_token_signature = signature.as_string();
- return blink::WebOriginTrialTokenStatus::kSuccess;
-}
-
-// static
-std::unique_ptr<TrialToken> TrialToken::Parse(
- const std::string& token_payload) {
- std::unique_ptr<base::DictionaryValue> datadict =
- base::DictionaryValue::From(base::JSONReader::Read(token_payload));
- if (!datadict) {
- return nullptr;
- }
-
- std::string origin_string;
- std::string feature_name;
- int expiry_timestamp = 0;
- datadict->GetString("origin", &origin_string);
- datadict->GetString("feature", &feature_name);
- datadict->GetInteger("expiry", &expiry_timestamp);
-
- // Ensure that the origin is a valid (non-unique) origin URL.
- url::Origin origin = url::Origin(GURL(origin_string));
- if (origin.unique()) {
- return nullptr;
- }
-
- // The |isSubdomain| flag is optional. If found, ensure it is a valid boolean.
- bool is_subdomain = false;
- if (datadict->HasKey("isSubdomain")) {
- if (!datadict->GetBoolean("isSubdomain", &is_subdomain)) {
- return nullptr;
- }
- }
-
- // Ensure that the feature name is a valid string.
- if (feature_name.empty()) {
- return nullptr;
- }
-
- // Ensure that the expiry timestamp is a valid (positive) integer.
- if (expiry_timestamp <= 0) {
- return nullptr;
- }
-
- return base::WrapUnique(
- new TrialToken(origin, is_subdomain, feature_name, expiry_timestamp));
-}
-
-bool TrialToken::ValidateOrigin(const url::Origin& origin) const {
- if (match_subdomains_) {
- return origin.scheme() == origin_.scheme() &&
- origin.DomainIs(origin_.host()) &&
- origin.port() == origin_.port();
- }
- return origin == origin_;
-}
-
-bool TrialToken::ValidateFeatureName(base::StringPiece feature_name) const {
- return feature_name == feature_name_;
-}
-
-bool TrialToken::ValidateDate(const base::Time& now) const {
- return expiry_time_ > now;
-}
-
-// static
-bool TrialToken::ValidateSignature(base::StringPiece signature,
- const std::string& data,
- base::StringPiece public_key) {
- // Public key must be 32 bytes long for Ed25519.
- CHECK_EQ(public_key.length(), 32UL);
-
- // Signature must be 64 bytes long.
- if (signature.length() != 64) {
- return false;
- }
-
- int result = ED25519_verify(
- reinterpret_cast<const uint8_t*>(data.data()), data.length(),
- reinterpret_cast<const uint8_t*>(signature.data()),
- reinterpret_cast<const uint8_t*>(public_key.data()));
- return (result != 0);
-}
-
-TrialToken::TrialToken(const url::Origin& origin,
- bool match_subdomains,
- const std::string& feature_name,
- uint64_t expiry_timestamp)
- : origin_(origin),
- match_subdomains_(match_subdomains),
- feature_name_(feature_name),
- expiry_time_(base::Time::FromDoubleT(expiry_timestamp)) {}
-
-} // namespace content
diff --git a/chromium/content/common/origin_trials/trial_token.h b/chromium/content/common/origin_trials/trial_token.h
deleted file mode 100644
index 31daae3d7a1..00000000000
--- a/chromium/content/common/origin_trials/trial_token.h
+++ /dev/null
@@ -1,120 +0,0 @@
-// Copyright 2015 The Chromium 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 CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_H_
-#define CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_H_
-
-#include <memory>
-#include <string>
-
-#include "base/strings/string_piece.h"
-#include "base/time/time.h"
-#include "content/common/content_export.h"
-#include "url/origin.h"
-
-extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);
-
-namespace blink {
-enum class WebOriginTrialTokenStatus;
-}
-
-namespace content {
-
-// The Origin Trials Framework (OT) provides limited access to experimental
-// features, on a per-origin basis. This class defines the trial token data
-// structure, used to securely provide access to an experimental feature.
-//
-// Features are defined by string names, provided by the implementers. The OT
-// code does not maintain an enum or constant list for feature names. Instead,
-// it validates the name provided by the feature implementation against any
-// provided tokens.
-//
-// More documentation on the token format can be found at
-// https://docs.google.com/document/d/1v5fi0EUV_QHckVHVF2K4P72iNywnrJtNhNZ6i2NPt0M
-
-class CONTENT_EXPORT TrialToken {
- public:
- ~TrialToken();
-
- // If the string represents a signed well-formed token, a token object is
- // returned, and success is returned in the |out_status| parameter. Otherwise,
- // the |out_status| parameter indicates what was wrong with the string, and
- // nullptr is returned.
- // Note that success does not mean that the token is currently valid, or
- // appropriate for a given origin / feature. It only means that it is
- // correctly formatted and signed by the supplied public key, and can be
- // parsed.
- static std::unique_ptr<TrialToken> From(
- const std::string& token_text,
- base::StringPiece public_key,
- blink::WebOriginTrialTokenStatus* out_status);
-
- // Returns success if this token is appropriate for use by the given origin
- // and has not yet expired. Otherwise, the return value indicates why the
- // token is not valid.
- blink::WebOriginTrialTokenStatus IsValid(const url::Origin& origin,
- const base::Time& now) const;
-
- url::Origin origin() { return origin_; }
- bool match_subdomains() const { return match_subdomains_; }
- std::string feature_name() { return feature_name_; }
- base::Time expiry_time() { return expiry_time_; }
- std::string signature() { return signature_; }
-
- protected:
- // Tests can access the Parse method directly to validate it, and so are
- // declared as friends here. All other access to Parse should be made through
- // TrialToken::From, which will always also ensure that there is a valid
- // signature attached to the token.
- friend class TrialTokenTest;
- friend int ::LLVMFuzzerTestOneInput(const uint8_t*, size_t);
-
- // If the string represents a properly signed and well-formed token, success
- // is returned, with the token payload and signature returned in the
- // |out_token_payload| and |out_token_signature| parameters, respectively.
- // Otherwise,the return code indicates what was wrong with the string, and
- // |out_token_payload| and |out_token_signature| are unchanged.
- static blink::WebOriginTrialTokenStatus Extract(
- const std::string& token_text,
- base::StringPiece public_key,
- std::string* out_token_payload,
- std::string* out_token_signature);
-
- // Returns a token object if the string represents a well-formed JSON token
- // payload, or nullptr otherwise.
- static std::unique_ptr<TrialToken> Parse(const std::string& token_payload);
-
- bool ValidateOrigin(const url::Origin& origin) const;
- bool ValidateFeatureName(base::StringPiece feature_name) const;
- bool ValidateDate(const base::Time& now) const;
-
- static bool ValidateSignature(base::StringPiece signature_text,
- const std::string& data,
- base::StringPiece public_key);
-
- private:
- TrialToken(const url::Origin& origin,
- bool match_subdomains,
- const std::string& feature_name,
- uint64_t expiry_timestamp);
-
- // The origin for which this token is valid. Must be a secure origin.
- url::Origin origin_;
-
- // Indicates if the token should match all subdomains of the origin.
- bool match_subdomains_;
-
- // The name of the experimental feature which this token enables.
- std::string feature_name_;
-
- // The time until which this token should be considered valid.
- base::Time expiry_time_;
-
- // The signature identifying the fully signed contents of the token.
- std::string signature_;
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_H_
diff --git a/chromium/content/common/origin_trials/trial_token_unittest.cc b/chromium/content/common/origin_trials/trial_token_unittest.cc
deleted file mode 100644
index b1c5bc154fd..00000000000
--- a/chromium/content/common/origin_trials/trial_token_unittest.cc
+++ /dev/null
@@ -1,505 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/origin_trials/trial_token.h"
-
-#include <memory>
-
-#include "base/macros.h"
-#include "base/strings/string_piece.h"
-#include "base/strings/string_util.h"
-#include "base/test/simple_test_clock.h"
-#include "base/time/time.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/WebKit/public/platform/WebOriginTrialTokenStatus.h"
-#include "url/gurl.h"
-
-namespace content {
-
-namespace {
-
-// This is a sample public key for testing the API. The corresponding private
-// key (use this to generate new samples for this test file) is:
-//
-// 0x83, 0x67, 0xf4, 0xcd, 0x2a, 0x1f, 0x0e, 0x04, 0x0d, 0x43, 0x13,
-// 0x4c, 0x67, 0xc4, 0xf4, 0x28, 0xc9, 0x90, 0x15, 0x02, 0xe2, 0xba,
-// 0xfd, 0xbb, 0xfa, 0xbc, 0x92, 0x76, 0x8a, 0x2c, 0x4b, 0xc7, 0x75,
-// 0x10, 0xac, 0xf9, 0x3a, 0x1c, 0xb8, 0xa9, 0x28, 0x70, 0xd2, 0x9a,
-// 0xd0, 0x0b, 0x59, 0xe1, 0xac, 0x2b, 0xb7, 0xd5, 0xca, 0x1f, 0x64,
-// 0x90, 0x08, 0x8e, 0xa8, 0xe0, 0x56, 0x3a, 0x04, 0xd0
-//
-// This private key can also be found in tools/origin_trials/eftest.key in
-// binary form. Please update that if changing the key.
-//
-// To use this with a real browser, use --origin-trial-public-key with the
-// public key, base-64-encoded:
-// --origin-trial-public-key=dRCs+TocuKkocNKa0AtZ4awrt9XKH2SQCI6o4FY6BNA=
-const uint8_t kTestPublicKey[] = {
- 0x75, 0x10, 0xac, 0xf9, 0x3a, 0x1c, 0xb8, 0xa9, 0x28, 0x70, 0xd2,
- 0x9a, 0xd0, 0x0b, 0x59, 0xe1, 0xac, 0x2b, 0xb7, 0xd5, 0xca, 0x1f,
- 0x64, 0x90, 0x08, 0x8e, 0xa8, 0xe0, 0x56, 0x3a, 0x04, 0xd0,
-};
-
-// This is a valid, but incorrect, public key for testing signatures against.
-// The corresponding private key is:
-//
-// 0x21, 0xee, 0xfa, 0x81, 0x6a, 0xff, 0xdf, 0xb8, 0xc1, 0xdd, 0x75,
-// 0x05, 0x04, 0x29, 0x68, 0x67, 0x60, 0x85, 0x91, 0xd0, 0x50, 0x16,
-// 0x0a, 0xcf, 0xa2, 0x37, 0xa3, 0x2e, 0x11, 0x7a, 0x17, 0x96, 0x50,
-// 0x07, 0x4d, 0x76, 0x55, 0x56, 0x42, 0x17, 0x2d, 0x8a, 0x9c, 0x47,
-// 0x96, 0x25, 0xda, 0x70, 0xaa, 0xb9, 0xfd, 0x53, 0x5d, 0x51, 0x3e,
-// 0x16, 0xab, 0xb4, 0x86, 0xea, 0xf3, 0x35, 0xc6, 0xca
-const uint8_t kTestPublicKey2[] = {
- 0x50, 0x07, 0x4d, 0x76, 0x55, 0x56, 0x42, 0x17, 0x2d, 0x8a, 0x9c,
- 0x47, 0x96, 0x25, 0xda, 0x70, 0xaa, 0xb9, 0xfd, 0x53, 0x5d, 0x51,
- 0x3e, 0x16, 0xab, 0xb4, 0x86, 0xea, 0xf3, 0x35, 0xc6, 0xca,
-};
-
-// This is a good trial token, signed with the above test private key.
-// Generate this token with the command (in tools/origin_trials):
-// generate_token.py valid.example.com Frobulate --expire-timestamp=1458766277
-const char* kSampleToken =
- "Ap+Q/Qm0ELadZql+dlEGSwnAVsFZKgCEtUZg8idQC3uekkIeSZIY1tftoYdrwhqj"
- "7FO5L22sNvkZZnacLvmfNwsAAABZeyJvcmlnaW4iOiAiaHR0cHM6Ly92YWxpZC5l"
- "eGFtcGxlLmNvbTo0NDMiLCAiZmVhdHVyZSI6ICJGcm9idWxhdGUiLCAiZXhwaXJ5"
- "IjogMTQ1ODc2NjI3N30=";
-const uint8_t kSampleTokenSignature[] = {
- 0x9f, 0x90, 0xfd, 0x09, 0xb4, 0x10, 0xb6, 0x9d, 0x66, 0xa9, 0x7e,
- 0x76, 0x51, 0x06, 0x4b, 0x09, 0xc0, 0x56, 0xc1, 0x59, 0x2a, 0x00,
- 0x84, 0xb5, 0x46, 0x60, 0xf2, 0x27, 0x50, 0x0b, 0x7b, 0x9e, 0x92,
- 0x42, 0x1e, 0x49, 0x92, 0x18, 0xd6, 0xd7, 0xed, 0xa1, 0x87, 0x6b,
- 0xc2, 0x1a, 0xa3, 0xec, 0x53, 0xb9, 0x2f, 0x6d, 0xac, 0x36, 0xf9,
- 0x19, 0x66, 0x76, 0x9c, 0x2e, 0xf9, 0x9f, 0x37, 0x0b};
-
-// This is a good subdomain trial token, signed with the above test private key.
-// Generate this token with the command (in tools/origin_trials):
-// generate_token.py example.com Frobulate --is-subdomain
-// --expire-timestamp=1458766277
-const char* kSampleSubdomainToken =
- "Auu+j9nXAQoy5+t00MiWakZwFExcdNC8ENkRdK1gL4OMFHS0AbZCscslDTcP1fjN"
- "FjpbmQG+VCPk1NrldVXZng4AAABoeyJvcmlnaW4iOiAiaHR0cHM6Ly9leGFtcGxl"
- "LmNvbTo0NDMiLCAiaXNTdWJkb21haW4iOiB0cnVlLCAiZmVhdHVyZSI6ICJGcm9i"
- "dWxhdGUiLCAiZXhwaXJ5IjogMTQ1ODc2NjI3N30=";
-const uint8_t kSampleSubdomainTokenSignature[] = {
- 0xeb, 0xbe, 0x8f, 0xd9, 0xd7, 0x01, 0x0a, 0x32, 0xe7, 0xeb, 0x74,
- 0xd0, 0xc8, 0x96, 0x6a, 0x46, 0x70, 0x14, 0x4c, 0x5c, 0x74, 0xd0,
- 0xbc, 0x10, 0xd9, 0x11, 0x74, 0xad, 0x60, 0x2f, 0x83, 0x8c, 0x14,
- 0x74, 0xb4, 0x01, 0xb6, 0x42, 0xb1, 0xcb, 0x25, 0x0d, 0x37, 0x0f,
- 0xd5, 0xf8, 0xcd, 0x16, 0x3a, 0x5b, 0x99, 0x01, 0xbe, 0x54, 0x23,
- 0xe4, 0xd4, 0xda, 0xe5, 0x75, 0x55, 0xd9, 0x9e, 0x0e};
-
-// This is a good trial token, explicitly not a subdomain, signed with the above
-// test private key. Generate this token with the command:
-// generate_token.py valid.example.com Frobulate --no-subdomain
-// --expire-timestamp=1458766277
-const char* kSampleNonSubdomainToken =
- "AreD979D7tO0luSZTr1+/+J6E0SSj/GEUyLK41o1hXFzXw1R7Z1hCDHs0gXWVSu1"
- "lvH52Winvy39tHbsU2gJJQYAAABveyJvcmlnaW4iOiAiaHR0cHM6Ly92YWxpZC5l"
- "eGFtcGxlLmNvbTo0NDMiLCAiaXNTdWJkb21haW4iOiBmYWxzZSwgImZlYXR1cmUi"
- "OiAiRnJvYnVsYXRlIiwgImV4cGlyeSI6IDE0NTg3NjYyNzd9";
-const uint8_t kSampleNonSubdomainTokenSignature[] = {
- 0xb7, 0x83, 0xf7, 0xbf, 0x43, 0xee, 0xd3, 0xb4, 0x96, 0xe4, 0x99,
- 0x4e, 0xbd, 0x7e, 0xff, 0xe2, 0x7a, 0x13, 0x44, 0x92, 0x8f, 0xf1,
- 0x84, 0x53, 0x22, 0xca, 0xe3, 0x5a, 0x35, 0x85, 0x71, 0x73, 0x5f,
- 0x0d, 0x51, 0xed, 0x9d, 0x61, 0x08, 0x31, 0xec, 0xd2, 0x05, 0xd6,
- 0x55, 0x2b, 0xb5, 0x96, 0xf1, 0xf9, 0xd9, 0x68, 0xa7, 0xbf, 0x2d,
- 0xfd, 0xb4, 0x76, 0xec, 0x53, 0x68, 0x09, 0x25, 0x06};
-
-const char* kExpectedFeatureName = "Frobulate";
-const char* kExpectedOrigin = "https://valid.example.com";
-const char* kExpectedSubdomainOrigin = "https://example.com";
-const char* kExpectedMultipleSubdomainOrigin =
- "https://part1.part2.part3.example.com";
-const uint64_t kExpectedExpiry = 1458766277;
-
-// The token should not be valid for this origin, or for this feature.
-const char* kInvalidOrigin = "https://invalid.example.com";
-const char* kInsecureOrigin = "http://valid.example.com";
-const char* kIncorrectPortOrigin = "https://valid.example.com:444";
-const char* kIncorrectDomainOrigin = "https://valid.example2.com";
-const char* kInvalidTLDOrigin = "https://com";
-const char* kInvalidFeatureName = "Grokalyze";
-
-// The token should be valid if the current time is kValidTimestamp or earlier.
-double kValidTimestamp = 1458766276.0;
-
-// The token should be invalid if the current time is kInvalidTimestamp or
-// later.
-double kInvalidTimestamp = 1458766278.0;
-
-// Well-formed trial token with an invalid signature.
-const char* kInvalidSignatureToken =
- "Ap+Q/Qm0ELadZql+dlEGSwnAVsFZKgCEtUZg8idQC3uekkIeSZIY1tftoYdrwhqj"
- "7FO5L22sNvkZZnacLvmfNwsAAABaeyJvcmlnaW4iOiAiaHR0cHM6Ly92YWxpZC5l"
- "eGFtcGxlLmNvbTo0NDMiLCAiZmVhdHVyZSI6ICJGcm9idWxhdGV4IiwgImV4cGly"
- "eSI6IDE0NTg3NjYyNzd9";
-
-// Trial token truncated in the middle of the length field; too short to
-// possibly be valid.
-const char kTruncatedToken[] =
- "Ap+Q/Qm0ELadZql+dlEGSwnAVsFZKgCEtUZg8idQC3uekkIeSZIY1tftoYdrwhqj"
- "7FO5L22sNvkZZnacLvmfNwsA";
-
-// Trial token with an incorrectly-declared length, but with a valid signature.
-const char kIncorrectLengthToken[] =
- "Ao06eNl/CZuM88qurWKX4RfoVEpHcVHWxdOTrEXZkaC1GUHyb/8L4sthADiVWdc9"
- "kXFyF1BW5bbraqp6MBVr3wEAAABaeyJvcmlnaW4iOiAiaHR0cHM6Ly92YWxpZC5l"
- "eGFtcGxlLmNvbTo0NDMiLCAiZmVhdHVyZSI6ICJGcm9idWxhdGUiLCAiZXhwaXJ5"
- "IjogMTQ1ODc2NjI3N30=";
-
-// Trial token with a misidentified version (42).
-const char kIncorrectVersionToken[] =
- "KlH8wVLT5o59uDvlJESorMDjzgWnvG1hmIn/GiT9Ng3f45ratVeiXCNTeaJheOaG"
- "A6kX4ir4Amv8aHVC+OJHZQkAAABZeyJvcmlnaW4iOiAiaHR0cHM6Ly92YWxpZC5l"
- "eGFtcGxlLmNvbTo0NDMiLCAiZmVhdHVyZSI6ICJGcm9idWxhdGUiLCAiZXhwaXJ5"
- "IjogMTQ1ODc2NjI3N30=";
-
-const char kSampleTokenJSON[] =
- "{\"origin\": \"https://valid.example.com:443\", \"feature\": "
- "\"Frobulate\", \"expiry\": 1458766277}";
-
-const char kSampleNonSubdomainTokenJSON[] =
- "{\"origin\": \"https://valid.example.com:443\", \"isSubdomain\": false, "
- "\"feature\": \"Frobulate\", \"expiry\": 1458766277}";
-
-const char kSampleSubdomainTokenJSON[] =
- "{\"origin\": \"https://example.com:443\", \"isSubdomain\": true, "
- "\"feature\": \"Frobulate\", \"expiry\": 1458766277}";
-
-// Various ill-formed trial tokens. These should all fail to parse.
-const char* kInvalidTokens[] = {
- // Invalid - Not JSON at all
- "abcde",
- // Invalid JSON
- "{",
- // Not an object
- "\"abcde\"",
- "123.4",
- "[0, 1, 2]",
- // Missing keys
- "{}",
- "{\"something\": 1}",
- "{\"origin\": \"https://a.a\"}",
- "{\"origin\": \"https://a.a\", \"feature\": \"a\"}",
- "{\"origin\": \"https://a.a\", \"expiry\": 1458766277}",
- "{\"feature\": \"FeatureName\", \"expiry\": 1458766277}",
- // Incorrect types
- "{\"origin\": 1, \"feature\": \"a\", \"expiry\": 1458766277}",
- "{\"origin\": \"https://a.a\", \"feature\": 1, \"expiry\": 1458766277}",
- "{\"origin\": \"https://a.a\", \"feature\": \"a\", \"expiry\": \"1\"}",
- "{\"origin\": \"https://a.a\", \"isSubdomain\": \"true\", \"feature\": "
- "\"a\", \"expiry\": 1458766277}",
- "{\"origin\": \"https://a.a\", \"isSubdomain\": 1, \"feature\": \"a\", "
- "\"expiry\": 1458766277}",
- // Negative expiry timestamp
- "{\"origin\": \"https://a.a\", \"feature\": \"a\", \"expiry\": -1}",
- // Origin not a proper origin URL
- "{\"origin\": \"abcdef\", \"feature\": \"a\", \"expiry\": 1458766277}",
- "{\"origin\": \"data:text/plain,abcdef\", \"feature\": \"a\", \"expiry\": "
- "1458766277}",
- "{\"origin\": \"javascript:alert(1)\", \"feature\": \"a\", \"expiry\": "
- "1458766277}",
-};
-
-} // namespace
-
-class TrialTokenTest : public testing::TestWithParam<const char*> {
- public:
- TrialTokenTest()
- : expected_origin_(GURL(kExpectedOrigin)),
- expected_subdomain_origin_(GURL(kExpectedSubdomainOrigin)),
- expected_multiple_subdomain_origin_(
- GURL(kExpectedMultipleSubdomainOrigin)),
- invalid_origin_(GURL(kInvalidOrigin)),
- insecure_origin_(GURL(kInsecureOrigin)),
- incorrect_port_origin_(GURL(kIncorrectPortOrigin)),
- incorrect_domain_origin_(GURL(kIncorrectDomainOrigin)),
- invalid_tld_origin_(GURL(kInvalidTLDOrigin)),
- expected_expiry_(base::Time::FromDoubleT(kExpectedExpiry)),
- valid_timestamp_(base::Time::FromDoubleT(kValidTimestamp)),
- invalid_timestamp_(base::Time::FromDoubleT(kInvalidTimestamp)),
- expected_signature_(
- std::string(reinterpret_cast<const char*>(kSampleTokenSignature),
- arraysize(kSampleTokenSignature))),
- expected_subdomain_signature_(std::string(
- reinterpret_cast<const char*>(kSampleSubdomainTokenSignature),
- arraysize(kSampleSubdomainTokenSignature))),
- expected_nonsubdomain_signature_(std::string(
- reinterpret_cast<const char*>(kSampleNonSubdomainTokenSignature),
- arraysize(kSampleNonSubdomainTokenSignature))),
- correct_public_key_(
- base::StringPiece(reinterpret_cast<const char*>(kTestPublicKey),
- arraysize(kTestPublicKey))),
- incorrect_public_key_(
- base::StringPiece(reinterpret_cast<const char*>(kTestPublicKey2),
- arraysize(kTestPublicKey2))) {}
-
- protected:
- blink::WebOriginTrialTokenStatus Extract(const std::string& token_text,
- base::StringPiece public_key,
- std::string* token_payload,
- std::string* token_signature) {
- return TrialToken::Extract(token_text, public_key, token_payload,
- token_signature);
- }
-
- blink::WebOriginTrialTokenStatus ExtractIgnorePayload(
- const std::string& token_text,
- base::StringPiece public_key) {
- std::string token_payload;
- std::string token_signature;
- return Extract(token_text, public_key, &token_payload, &token_signature);
- }
-
- std::unique_ptr<TrialToken> Parse(const std::string& token_payload) {
- return TrialToken::Parse(token_payload);
- }
-
- bool ValidateOrigin(TrialToken* token, const url::Origin origin) {
- return token->ValidateOrigin(origin);
- }
-
- bool ValidateFeatureName(TrialToken* token, const char* feature_name) {
- return token->ValidateFeatureName(feature_name);
- }
-
- bool ValidateDate(TrialToken* token, const base::Time& now) {
- return token->ValidateDate(now);
- }
-
- base::StringPiece correct_public_key() { return correct_public_key_; }
- base::StringPiece incorrect_public_key() { return incorrect_public_key_; }
-
- const url::Origin expected_origin_;
- const url::Origin expected_subdomain_origin_;
- const url::Origin expected_multiple_subdomain_origin_;
- const url::Origin invalid_origin_;
- const url::Origin insecure_origin_;
- const url::Origin incorrect_port_origin_;
- const url::Origin incorrect_domain_origin_;
- const url::Origin invalid_tld_origin_;
-
- const base::Time expected_expiry_;
- const base::Time valid_timestamp_;
- const base::Time invalid_timestamp_;
-
- std::string expected_signature_;
- std::string expected_subdomain_signature_;
- std::string expected_nonsubdomain_signature_;
-
- private:
- base::StringPiece correct_public_key_;
- base::StringPiece incorrect_public_key_;
-};
-
-// Test the extraction of the signed payload from token strings. This includes
-// checking the included version identifier, payload length, and cryptographic
-// signature.
-
-// Test verification of signature and extraction of token JSON from signed
-// token.
-TEST_F(TrialTokenTest, ValidateValidSignature) {
- std::string token_payload;
- std::string token_signature;
- blink::WebOriginTrialTokenStatus status = Extract(
- kSampleToken, correct_public_key(), &token_payload, &token_signature);
- ASSERT_EQ(blink::WebOriginTrialTokenStatus::kSuccess, status);
- EXPECT_STREQ(kSampleTokenJSON, token_payload.c_str());
- EXPECT_EQ(expected_signature_, token_signature);
-}
-
-TEST_F(TrialTokenTest, ValidateSubdomainValidSignature) {
- std::string token_payload;
- std::string token_signature;
- blink::WebOriginTrialTokenStatus status =
- Extract(kSampleSubdomainToken, correct_public_key(), &token_payload,
- &token_signature);
- ASSERT_EQ(blink::WebOriginTrialTokenStatus::kSuccess, status);
- EXPECT_STREQ(kSampleSubdomainTokenJSON, token_payload.c_str());
- EXPECT_EQ(expected_subdomain_signature_, token_signature);
-}
-
-TEST_F(TrialTokenTest, ValidateNonSubdomainValidSignature) {
- std::string token_payload;
- std::string token_signature;
- blink::WebOriginTrialTokenStatus status =
- Extract(kSampleNonSubdomainToken, correct_public_key(), &token_payload,
- &token_signature);
- ASSERT_EQ(blink::WebOriginTrialTokenStatus::kSuccess, status);
- EXPECT_STREQ(kSampleNonSubdomainTokenJSON, token_payload.c_str());
- EXPECT_EQ(expected_nonsubdomain_signature_, token_signature);
-}
-
-TEST_F(TrialTokenTest, ValidateInvalidSignature) {
- blink::WebOriginTrialTokenStatus status =
- ExtractIgnorePayload(kInvalidSignatureToken, correct_public_key());
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kInvalidSignature, status);
-}
-
-TEST_F(TrialTokenTest, ValidateSignatureWithIncorrectKey) {
- blink::WebOriginTrialTokenStatus status =
- ExtractIgnorePayload(kSampleToken, incorrect_public_key());
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kInvalidSignature, status);
-}
-
-TEST_F(TrialTokenTest, ValidateEmptyToken) {
- blink::WebOriginTrialTokenStatus status =
- ExtractIgnorePayload("", correct_public_key());
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kMalformed, status);
-}
-
-TEST_F(TrialTokenTest, ValidateShortToken) {
- blink::WebOriginTrialTokenStatus status =
- ExtractIgnorePayload(kTruncatedToken, correct_public_key());
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kMalformed, status);
-}
-
-TEST_F(TrialTokenTest, ValidateUnsupportedVersion) {
- blink::WebOriginTrialTokenStatus status =
- ExtractIgnorePayload(kIncorrectVersionToken, correct_public_key());
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongVersion, status);
-}
-
-TEST_F(TrialTokenTest, ValidateSignatureWithIncorrectLength) {
- blink::WebOriginTrialTokenStatus status =
- ExtractIgnorePayload(kIncorrectLengthToken, correct_public_key());
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kMalformed, status);
-}
-
-// Test parsing of fields from JSON token.
-
-TEST_F(TrialTokenTest, ParseEmptyString) {
- std::unique_ptr<TrialToken> empty_token = Parse("");
- EXPECT_FALSE(empty_token);
-}
-
-TEST_P(TrialTokenTest, ParseInvalidString) {
- std::unique_ptr<TrialToken> empty_token = Parse(GetParam());
- EXPECT_FALSE(empty_token) << "Invalid trial token should not parse.";
-}
-
-INSTANTIATE_TEST_CASE_P(, TrialTokenTest, ::testing::ValuesIn(kInvalidTokens));
-
-TEST_F(TrialTokenTest, ParseValidToken) {
- std::unique_ptr<TrialToken> token = Parse(kSampleTokenJSON);
- ASSERT_TRUE(token);
- EXPECT_EQ(kExpectedFeatureName, token->feature_name());
- EXPECT_FALSE(token->match_subdomains());
- EXPECT_EQ(expected_origin_, token->origin());
- EXPECT_EQ(expected_expiry_, token->expiry_time());
-}
-
-TEST_F(TrialTokenTest, ParseValidNonSubdomainToken) {
- std::unique_ptr<TrialToken> token = Parse(kSampleNonSubdomainTokenJSON);
- ASSERT_TRUE(token);
- EXPECT_EQ(kExpectedFeatureName, token->feature_name());
- EXPECT_FALSE(token->match_subdomains());
- EXPECT_EQ(expected_origin_, token->origin());
- EXPECT_EQ(expected_expiry_, token->expiry_time());
-}
-
-TEST_F(TrialTokenTest, ParseValidSubdomainToken) {
- std::unique_ptr<TrialToken> token = Parse(kSampleSubdomainTokenJSON);
- ASSERT_TRUE(token);
- EXPECT_EQ(kExpectedFeatureName, token->feature_name());
- EXPECT_TRUE(token->match_subdomains());
- EXPECT_EQ(kExpectedSubdomainOrigin, token->origin().Serialize());
- EXPECT_EQ(expected_subdomain_origin_, token->origin());
- EXPECT_EQ(expected_expiry_, token->expiry_time());
-}
-
-TEST_F(TrialTokenTest, ValidateValidToken) {
- std::unique_ptr<TrialToken> token = Parse(kSampleTokenJSON);
- ASSERT_TRUE(token);
- EXPECT_TRUE(ValidateOrigin(token.get(), expected_origin_));
- EXPECT_FALSE(ValidateOrigin(token.get(), invalid_origin_));
- EXPECT_FALSE(ValidateOrigin(token.get(), insecure_origin_));
- EXPECT_FALSE(ValidateOrigin(token.get(), incorrect_port_origin_));
- EXPECT_FALSE(ValidateOrigin(token.get(), incorrect_domain_origin_));
- EXPECT_FALSE(ValidateOrigin(token.get(), invalid_tld_origin_));
- EXPECT_TRUE(ValidateFeatureName(token.get(), kExpectedFeatureName));
- EXPECT_FALSE(ValidateFeatureName(token.get(), kInvalidFeatureName));
- EXPECT_FALSE(ValidateFeatureName(
- token.get(), base::ToUpperASCII(kExpectedFeatureName).c_str()));
- EXPECT_FALSE(ValidateFeatureName(
- token.get(), base::ToLowerASCII(kExpectedFeatureName).c_str()));
- EXPECT_TRUE(ValidateDate(token.get(), valid_timestamp_));
- EXPECT_FALSE(ValidateDate(token.get(), invalid_timestamp_));
-}
-
-TEST_F(TrialTokenTest, ValidateValidSubdomainToken) {
- std::unique_ptr<TrialToken> token = Parse(kSampleSubdomainTokenJSON);
- ASSERT_TRUE(token);
- EXPECT_TRUE(ValidateOrigin(token.get(), expected_origin_));
- EXPECT_TRUE(ValidateOrigin(token.get(), expected_subdomain_origin_));
- EXPECT_TRUE(ValidateOrigin(token.get(), expected_multiple_subdomain_origin_));
- EXPECT_FALSE(ValidateOrigin(token.get(), insecure_origin_));
- EXPECT_FALSE(ValidateOrigin(token.get(), incorrect_port_origin_));
- EXPECT_FALSE(ValidateOrigin(token.get(), incorrect_domain_origin_));
- EXPECT_FALSE(ValidateOrigin(token.get(), invalid_tld_origin_));
-}
-
-TEST_F(TrialTokenTest, TokenIsValid) {
- std::unique_ptr<TrialToken> token = Parse(kSampleTokenJSON);
- ASSERT_TRUE(token);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kSuccess,
- token->IsValid(expected_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongOrigin,
- token->IsValid(invalid_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongOrigin,
- token->IsValid(insecure_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongOrigin,
- token->IsValid(incorrect_port_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kExpired,
- token->IsValid(expected_origin_, invalid_timestamp_));
-}
-
-TEST_F(TrialTokenTest, SubdomainTokenIsValid) {
- std::unique_ptr<TrialToken> token = Parse(kSampleSubdomainTokenJSON);
- ASSERT_TRUE(token);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kSuccess,
- token->IsValid(expected_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kSuccess,
- token->IsValid(expected_subdomain_origin_, valid_timestamp_));
- EXPECT_EQ(
- blink::WebOriginTrialTokenStatus::kSuccess,
- token->IsValid(expected_multiple_subdomain_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongOrigin,
- token->IsValid(incorrect_domain_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongOrigin,
- token->IsValid(insecure_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongOrigin,
- token->IsValid(incorrect_port_origin_, valid_timestamp_));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kExpired,
- token->IsValid(expected_origin_, invalid_timestamp_));
-}
-
-// Test overall extraction, to ensure output status matches returned token, and
-// signature is provided.
-TEST_F(TrialTokenTest, ExtractValidToken) {
- blink::WebOriginTrialTokenStatus status;
- std::unique_ptr<TrialToken> token =
- TrialToken::From(kSampleToken, correct_public_key(), &status);
- EXPECT_TRUE(token);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kSuccess, status);
- EXPECT_EQ(expected_signature_, token->signature());
-}
-
-TEST_F(TrialTokenTest, ExtractInvalidSignature) {
- blink::WebOriginTrialTokenStatus status;
- std::unique_ptr<TrialToken> token =
- TrialToken::From(kSampleToken, incorrect_public_key(), &status);
- EXPECT_FALSE(token);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kInvalidSignature, status);
-}
-
-TEST_F(TrialTokenTest, ExtractMalformedToken) {
- blink::WebOriginTrialTokenStatus status;
- std::unique_ptr<TrialToken> token =
- TrialToken::From(kIncorrectLengthToken, correct_public_key(), &status);
- EXPECT_FALSE(token);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kMalformed, status);
-}
-
-} // namespace content
diff --git a/chromium/content/common/origin_trials/trial_token_validator.cc b/chromium/content/common/origin_trials/trial_token_validator.cc
deleted file mode 100644
index 3412ed98bd2..00000000000
--- a/chromium/content/common/origin_trials/trial_token_validator.cc
+++ /dev/null
@@ -1,144 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/origin_trials/trial_token_validator.h"
-
-#include "base/feature_list.h"
-#include "base/memory/ptr_util.h"
-#include "base/time/time.h"
-#include "content/common/origin_trials/trial_token.h"
-#include "content/public/common/content_client.h"
-#include "content/public/common/content_features.h"
-#include "content/public/common/origin_trial_policy.h"
-#include "content/public/common/origin_util.h"
-#include "net/http/http_response_headers.h"
-#include "net/url_request/url_request.h"
-#include "third_party/WebKit/public/platform/WebOriginTrialTokenStatus.h"
-
-namespace content {
-
-blink::WebOriginTrialTokenStatus TrialTokenValidator::ValidateToken(
- const std::string& token,
- const url::Origin& origin,
- std::string* feature_name,
- base::Time current_time) {
- ContentClient* content_client = GetContentClient();
- const OriginTrialPolicy* origin_trial_policy =
- content_client->GetOriginTrialPolicy();
- if (!origin_trial_policy)
- return blink::WebOriginTrialTokenStatus::kNotSupported;
-
- // TODO(iclelland): Allow for multiple signing keys, and iterate over all
- // active keys here. https://crbug.com/543220
- base::StringPiece public_key = origin_trial_policy->GetPublicKey();
- if (public_key.empty())
- return blink::WebOriginTrialTokenStatus::kNotSupported;
-
- blink::WebOriginTrialTokenStatus status;
- std::unique_ptr<TrialToken> trial_token =
- TrialToken::From(token, public_key, &status);
- if (status != blink::WebOriginTrialTokenStatus::kSuccess)
- return status;
-
- status = trial_token->IsValid(origin, current_time);
- if (status != blink::WebOriginTrialTokenStatus::kSuccess)
- return status;
-
- if (origin_trial_policy->IsFeatureDisabled(trial_token->feature_name()))
- return blink::WebOriginTrialTokenStatus::kFeatureDisabled;
-
- if (origin_trial_policy->IsTokenDisabled(trial_token->signature()))
- return blink::WebOriginTrialTokenStatus::kTokenDisabled;
-
- *feature_name = trial_token->feature_name();
- return blink::WebOriginTrialTokenStatus::kSuccess;
-}
-
-bool TrialTokenValidator::RequestEnablesFeature(const net::URLRequest* request,
- base::StringPiece feature_name,
- base::Time current_time) {
- // TODO(mek): Possibly cache the features that are availble for request in
- // UserData associated with the request.
- return RequestEnablesFeature(request->url(), request->response_headers(),
- feature_name, current_time);
-}
-
-bool TrialTokenValidator::RequestEnablesFeature(
- const GURL& request_url,
- const net::HttpResponseHeaders* response_headers,
- base::StringPiece feature_name,
- base::Time current_time) {
- if (!base::FeatureList::IsEnabled(features::kOriginTrials))
- return false;
-
- if (!IsOriginSecure(request_url))
- return false;
-
- url::Origin origin(request_url);
- size_t iter = 0;
- std::string token;
- while (response_headers->EnumerateHeader(&iter, "Origin-Trial", &token)) {
- std::string token_feature;
- // TODO(mek): Log the validation errors to histograms?
- if (ValidateToken(token, origin, &token_feature, current_time) ==
- blink::WebOriginTrialTokenStatus::kSuccess)
- if (token_feature == feature_name)
- return true;
- }
- return false;
-}
-
-std::unique_ptr<TrialTokenValidator::FeatureToTokensMap>
-TrialTokenValidator::GetValidTokensFromHeaders(
- const url::Origin& origin,
- const net::HttpResponseHeaders* headers,
- base::Time current_time) {
- std::unique_ptr<FeatureToTokensMap> tokens(
- base::MakeUnique<FeatureToTokensMap>());
- if (!base::FeatureList::IsEnabled(features::kOriginTrials))
- return tokens;
-
- if (!IsOriginSecure(origin.GetURL()))
- return tokens;
-
- size_t iter = 0;
- std::string token;
- while (headers->EnumerateHeader(&iter, "Origin-Trial", &token)) {
- std::string token_feature;
- if (TrialTokenValidator::ValidateToken(token, origin, &token_feature,
- current_time) ==
- blink::WebOriginTrialTokenStatus::kSuccess) {
- (*tokens)[token_feature].push_back(token);
- }
- }
- return tokens;
-}
-
-std::unique_ptr<TrialTokenValidator::FeatureToTokensMap>
-TrialTokenValidator::GetValidTokens(const url::Origin& origin,
- const FeatureToTokensMap& tokens,
- base::Time current_time) {
- std::unique_ptr<FeatureToTokensMap> out_tokens(
- base::MakeUnique<FeatureToTokensMap>());
- if (!base::FeatureList::IsEnabled(features::kOriginTrials))
- return out_tokens;
-
- if (!IsOriginSecure(origin.GetURL()))
- return out_tokens;
-
- for (const auto& feature : tokens) {
- for (const std::string& token : feature.second) {
- std::string token_feature;
- if (TrialTokenValidator::ValidateToken(token, origin, &token_feature,
- current_time) ==
- blink::WebOriginTrialTokenStatus::kSuccess) {
- DCHECK_EQ(token_feature, feature.first);
- (*out_tokens)[feature.first].push_back(token);
- }
- }
- }
- return out_tokens;
-}
-
-} // namespace content
diff --git a/chromium/content/common/origin_trials/trial_token_validator.h b/chromium/content/common/origin_trials/trial_token_validator.h
deleted file mode 100644
index f5afb87cfac..00000000000
--- a/chromium/content/common/origin_trials/trial_token_validator.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2016 The Chromium 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 CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_VALIDATOR_H_
-#define CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_VALIDATOR_H_
-
-#include <map>
-#include <memory>
-#include <string>
-#include <vector>
-#include "base/strings/string_piece.h"
-#include "base/time/time.h"
-#include "content/common/content_export.h"
-#include "url/origin.h"
-
-namespace blink {
-enum class WebOriginTrialTokenStatus;
-}
-
-namespace net {
-class HttpResponseHeaders;
-class URLRequest;
-}
-
-namespace content {
-
-namespace TrialTokenValidator {
-
-using FeatureToTokensMap = std::map<std::string /* feature_name */,
- std::vector<std::string /* token */>>;
-
-// If token validates, |*feature_name| is set to the name of the feature the
-// token enables.
-// This method is thread-safe.
-CONTENT_EXPORT blink::WebOriginTrialTokenStatus ValidateToken(
- const std::string& token,
- const url::Origin& origin,
- std::string* feature_name,
- base::Time current_time);
-
-CONTENT_EXPORT bool RequestEnablesFeature(const net::URLRequest* request,
- base::StringPiece feature_name,
- base::Time current_time);
-
-CONTENT_EXPORT bool RequestEnablesFeature(
- const GURL& request_url,
- const net::HttpResponseHeaders* response_headers,
- base::StringPiece feature_name,
- base::Time current_time);
-
-// Returns all valid tokens in |headers|.
-CONTENT_EXPORT std::unique_ptr<FeatureToTokensMap> GetValidTokensFromHeaders(
- const url::Origin& origin,
- const net::HttpResponseHeaders* headers,
- base::Time current_time);
-
-// Returns all valid tokens in |tokens|. This method is used to re-validate
-// previously stored tokens.
-CONTENT_EXPORT std::unique_ptr<FeatureToTokensMap> GetValidTokens(
- const url::Origin& origin,
- const FeatureToTokensMap& tokens,
- base::Time current_time);
-
-} // namespace TrialTokenValidator
-
-} // namespace content
-
-#endif // CONTENT_COMMON_ORIGIN_TRIALS_TRIAL_TOKEN_VALIDATOR_H_
diff --git a/chromium/content/common/origin_trials/trial_token_validator_unittest.cc b/chromium/content/common/origin_trials/trial_token_validator_unittest.cc
deleted file mode 100644
index 830f5805019..00000000000
--- a/chromium/content/common/origin_trials/trial_token_validator_unittest.cc
+++ /dev/null
@@ -1,344 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/origin_trials/trial_token_validator.h"
-
-#include <memory>
-#include <set>
-#include <string>
-
-#include "base/macros.h"
-#include "base/strings/string_util.h"
-#include "base/test/simple_test_clock.h"
-#include "base/time/time.h"
-#include "content/public/common/content_client.h"
-#include "content/public/common/origin_trial_policy.h"
-#include "net/http/http_response_headers.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/WebKit/public/platform/WebOriginTrialTokenStatus.h"
-#include "url/gurl.h"
-
-namespace content {
-
-namespace {
-
-// This is a sample public key for testing the API. The corresponding private
-// key (use this to generate new samples for this test file) is:
-//
-// 0x83, 0x67, 0xf4, 0xcd, 0x2a, 0x1f, 0x0e, 0x04, 0x0d, 0x43, 0x13,
-// 0x4c, 0x67, 0xc4, 0xf4, 0x28, 0xc9, 0x90, 0x15, 0x02, 0xe2, 0xba,
-// 0xfd, 0xbb, 0xfa, 0xbc, 0x92, 0x76, 0x8a, 0x2c, 0x4b, 0xc7, 0x75,
-// 0x10, 0xac, 0xf9, 0x3a, 0x1c, 0xb8, 0xa9, 0x28, 0x70, 0xd2, 0x9a,
-// 0xd0, 0x0b, 0x59, 0xe1, 0xac, 0x2b, 0xb7, 0xd5, 0xca, 0x1f, 0x64,
-// 0x90, 0x08, 0x8e, 0xa8, 0xe0, 0x56, 0x3a, 0x04, 0xd0
-const uint8_t kTestPublicKey[] = {
- 0x75, 0x10, 0xac, 0xf9, 0x3a, 0x1c, 0xb8, 0xa9, 0x28, 0x70, 0xd2,
- 0x9a, 0xd0, 0x0b, 0x59, 0xe1, 0xac, 0x2b, 0xb7, 0xd5, 0xca, 0x1f,
- 0x64, 0x90, 0x08, 0x8e, 0xa8, 0xe0, 0x56, 0x3a, 0x04, 0xd0,
-};
-
-// 0x21, 0xee, 0xfa, 0x81, 0x6a, 0xff, 0xdf, 0xb8, 0xc1, 0xdd, 0x75,
-// 0x05, 0x04, 0x29, 0x68, 0x67, 0x60, 0x85, 0x91, 0xd0, 0x50, 0x16,
-// 0x0a, 0xcf, 0xa2, 0x37, 0xa3, 0x2e, 0x11, 0x7a, 0x17, 0x96, 0x50,
-// 0x07, 0x4d, 0x76, 0x55, 0x56, 0x42, 0x17, 0x2d, 0x8a, 0x9c, 0x47,
-// 0x96, 0x25, 0xda, 0x70, 0xaa, 0xb9, 0xfd, 0x53, 0x5d, 0x51, 0x3e,
-// 0x16, 0xab, 0xb4, 0x86, 0xea, 0xf3, 0x35, 0xc6, 0xca
-const uint8_t kTestPublicKey2[] = {
- 0x50, 0x07, 0x4d, 0x76, 0x55, 0x56, 0x42, 0x17, 0x2d, 0x8a, 0x9c,
- 0x47, 0x96, 0x25, 0xda, 0x70, 0xaa, 0xb9, 0xfd, 0x53, 0x5d, 0x51,
- 0x3e, 0x16, 0xab, 0xb4, 0x86, 0xea, 0xf3, 0x35, 0xc6, 0xca,
-};
-
-// This is a good trial token, signed with the above test private key.
-// TODO(iclelland): This token expires in 2033. Update it or find a way
-// to autogenerate it before then.
-// Generate this token with the command (in tools/origin_trials):
-// generate_token.py valid.example.com Frobulate --expire-timestamp=2000000000
-const char kSampleToken[] =
- "AuR/1mg+/w5ROLN54Ok20rApK3opgR7Tq9ZfzhATQmnCa+BtPA1RRw4Nigf336r+"
- "O4fM3Sa+MEd+5JcIgSZafw8AAABZeyJvcmlnaW4iOiAiaHR0cHM6Ly92YWxpZC5l"
- "eGFtcGxlLmNvbTo0NDMiLCAiZmVhdHVyZSI6ICJGcm9idWxhdGUiLCAiZXhwaXJ5"
- "IjogMjAwMDAwMDAwMH0=";
-const uint8_t kSampleTokenSignature[] = {
- 0xe4, 0x7f, 0xd6, 0x68, 0x3e, 0xff, 0x0e, 0x51, 0x38, 0xb3, 0x79,
- 0xe0, 0xe9, 0x36, 0xd2, 0xb0, 0x29, 0x2b, 0x7a, 0x29, 0x81, 0x1e,
- 0xd3, 0xab, 0xd6, 0x5f, 0xce, 0x10, 0x13, 0x42, 0x69, 0xc2, 0x6b,
- 0xe0, 0x6d, 0x3c, 0x0d, 0x51, 0x47, 0x0e, 0x0d, 0x8a, 0x07, 0xf7,
- 0xdf, 0xaa, 0xfe, 0x3b, 0x87, 0xcc, 0xdd, 0x26, 0xbe, 0x30, 0x47,
- 0x7e, 0xe4, 0x97, 0x08, 0x81, 0x26, 0x5a, 0x7f, 0x0f};
-
-// The token should be valid for this origin and for this feature.
-const char kAppropriateOrigin[] = "https://valid.example.com";
-const char kAppropriateFeatureName[] = "Frobulate";
-
-const char kInappropriateFeatureName[] = "Grokalyze";
-const char kInappropriateOrigin[] = "https://invalid.example.com";
-const char kInsecureOrigin[] = "http://valid.example.com";
-
-// Well-formed trial token with an invalid signature.
-// This token is a corruption of the above valid token.
-const char kInvalidSignatureToken[] =
- "AuR/1mg+/w5ROLN54Ok20rApK3opgR7Tq9ZfzhATQmnCa+BtPA1RRw4Nigf336r+"
- "RrOtlAwa0gPqqn+A8GTD3AQAAABZeyJvcmlnaW4iOiAiaHR0cHM6Ly92YWxpZC5l"
- "eGFtcGxlLmNvbTo0NDMiLCAiZmVhdHVyZSI6ICJGcm9idWxhdGUiLCAiZXhwaXJ5"
- "IjogMjAwMDAwMDAwMH0=";
-
-// Well-formed, but expired, trial token. (Expired in 2001)
-// Generate this token with the command (in tools/origin_trials):
-// generate_token.py valid.example.com Frobulate --expire-timestamp=1000000000
-const char kExpiredToken[] =
- "AmHPUIXMaXe9jWW8kJeDFXolVjT93p4XMnK4+jMYd2pjqtFcYB1bUmdD8PunQKM+"
- "RrOtlAwa0gPqqn+A8GTD3AQAAABZeyJvcmlnaW4iOiAiaHR0cHM6Ly92YWxpZC5l"
- "eGFtcGxlLmNvbTo0NDMiLCAiZmVhdHVyZSI6ICJGcm9idWxhdGUiLCAiZXhwaXJ5"
- "IjogMTAwMDAwMDAwMH0=";
-const uint8_t kExpiredTokenSignature[] = {
- 0x61, 0xcf, 0x50, 0x85, 0xcc, 0x69, 0x77, 0xbd, 0x8d, 0x65, 0xbc,
- 0x90, 0x97, 0x83, 0x15, 0x7a, 0x25, 0x56, 0x34, 0xfd, 0xde, 0x9e,
- 0x17, 0x32, 0x72, 0xb8, 0xfa, 0x33, 0x18, 0x77, 0x6a, 0x63, 0xaa,
- 0xd1, 0x5c, 0x60, 0x1d, 0x5b, 0x52, 0x67, 0x43, 0xf0, 0xfb, 0xa7,
- 0x40, 0xa3, 0x3e, 0x46, 0xb3, 0xad, 0x94, 0x0c, 0x1a, 0xd2, 0x03,
- 0xea, 0xaa, 0x7f, 0x80, 0xf0, 0x64, 0xc3, 0xdc, 0x04};
-
-const char kUnparsableToken[] = "abcde";
-
-// Well-formed token, for an insecure origin.
-// Generate this token with the command (in tools/origin_trials):
-// generate_token.py http://valid.example.com Frobulate
-// --expire-timestamp=2000000000
-const char kInsecureOriginToken[] =
- "AjfC47H1q8/Ho5ALFkjkwf9CBK6oUUeRTlFc50Dj+eZEyGGKFIY2WTxMBfy8cLc3"
- "E0nmFroDA3OmABmO5jMCFgkAAABXeyJvcmlnaW4iOiAiaHR0cDovL3ZhbGlkLmV4"
- "YW1wbGUuY29tOjgwIiwgImZlYXR1cmUiOiAiRnJvYnVsYXRlIiwgImV4cGlyeSI6"
- "IDIwMDAwMDAwMDB9";
-
-// This timestamp is set to a time after the expiry timestamp of kExpiredToken,
-// but before the expiry timestamp of kValidToken.
-double kNowTimestamp = 1500000000;
-
-class TestOriginTrialPolicy : public OriginTrialPolicy {
- public:
- base::StringPiece GetPublicKey() const override {
- return base::StringPiece(reinterpret_cast<const char*>(key_),
- arraysize(kTestPublicKey));
- }
- bool IsFeatureDisabled(base::StringPiece feature) const override {
- return disabled_features_.count(feature.as_string()) > 0;
- }
-
- // Test setup methods
- void SetPublicKey(const uint8_t* key) { key_ = key; }
- void DisableFeature(const std::string& feature) {
- disabled_features_.insert(feature);
- }
- void DisableToken(const std::string& token) {
- disabled_tokens_.insert(token);
- }
-
- protected:
- bool IsTokenDisabled(base::StringPiece token_signature) const override {
- return disabled_tokens_.count(token_signature.as_string()) > 0;
- }
-
- private:
- const uint8_t* key_ = nullptr;
- std::set<std::string> disabled_features_;
- std::set<std::string> disabled_tokens_;
-};
-
-class TestContentClient : public ContentClient {
- public:
- // ContentRendererClient methods
- OriginTrialPolicy* GetOriginTrialPolicy() override {
- return &origin_trial_policy_;
- }
- // Test setup methods
- void SetOriginTrialPublicKey(const uint8_t* key) {
- origin_trial_policy_.SetPublicKey(key);
- }
- void DisableFeature(const std::string& feature) {
- origin_trial_policy_.DisableFeature(feature);
- }
- void DisableToken(const std::string& token_signature) {
- origin_trial_policy_.DisableToken(token_signature);
- }
-
- private:
- TestOriginTrialPolicy origin_trial_policy_;
-};
-
-} // namespace
-
-class TrialTokenValidatorTest : public testing::Test {
- public:
- TrialTokenValidatorTest()
- : appropriate_origin_(GURL(kAppropriateOrigin)),
- inappropriate_origin_(GURL(kInappropriateOrigin)),
- insecure_origin_(GURL(kInsecureOrigin)),
- valid_token_signature_(
- std::string(reinterpret_cast<const char*>(kSampleTokenSignature),
- arraysize(kSampleTokenSignature))),
- expired_token_signature_(
- std::string(reinterpret_cast<const char*>(kExpiredTokenSignature),
- arraysize(kExpiredTokenSignature))),
- response_headers_(new net::HttpResponseHeaders("")) {
- SetPublicKey(kTestPublicKey);
- SetContentClient(&test_content_client_);
- }
-
- ~TrialTokenValidatorTest() override { SetContentClient(nullptr); }
-
- void SetPublicKey(const uint8_t* key) {
- test_content_client_.SetOriginTrialPublicKey(key);
- }
-
- void DisableFeature(const std::string& feature) {
- test_content_client_.DisableFeature(feature);
- }
-
- void DisableToken(const std::string& token_signature) {
- test_content_client_.DisableToken(token_signature);
- }
-
- base::Time Now() { return base::Time::FromDoubleT(kNowTimestamp); }
-
- const url::Origin appropriate_origin_;
- const url::Origin inappropriate_origin_;
- const url::Origin insecure_origin_;
-
- std::string valid_token_signature_;
- std::string expired_token_signature_;
-
- scoped_refptr<net::HttpResponseHeaders> response_headers_;
-
- private:
- TestContentClient test_content_client_;
-};
-
-TEST_F(TrialTokenValidatorTest, ValidateValidToken) {
- std::string feature;
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kSuccess,
- TrialTokenValidator::ValidateToken(
- kSampleToken, appropriate_origin_, &feature, Now()));
- EXPECT_EQ(kAppropriateFeatureName, feature);
-}
-
-TEST_F(TrialTokenValidatorTest, ValidateInappropriateOrigin) {
- std::string feature;
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongOrigin,
- TrialTokenValidator::ValidateToken(
- kSampleToken, inappropriate_origin_, &feature, Now()));
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kWrongOrigin,
- TrialTokenValidator::ValidateToken(kSampleToken, insecure_origin_,
- &feature, Now()));
-}
-
-TEST_F(TrialTokenValidatorTest, ValidateInvalidSignature) {
- std::string feature;
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kInvalidSignature,
- TrialTokenValidator::ValidateToken(
- kInvalidSignatureToken, appropriate_origin_, &feature, Now()));
-}
-
-TEST_F(TrialTokenValidatorTest, ValidateUnparsableToken) {
- std::string feature;
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kMalformed,
- TrialTokenValidator::ValidateToken(
- kUnparsableToken, appropriate_origin_, &feature, Now()));
-}
-
-TEST_F(TrialTokenValidatorTest, ValidateExpiredToken) {
- std::string feature;
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kExpired,
- TrialTokenValidator::ValidateToken(
- kExpiredToken, appropriate_origin_, &feature, Now()));
-}
-
-TEST_F(TrialTokenValidatorTest, ValidateValidTokenWithIncorrectKey) {
- std::string feature;
- SetPublicKey(kTestPublicKey2);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kInvalidSignature,
- TrialTokenValidator::ValidateToken(
- kSampleToken, appropriate_origin_, &feature, Now()));
-}
-
-TEST_F(TrialTokenValidatorTest, ValidatorRespectsDisabledFeatures) {
- std::string feature;
- // Disable an irrelevant feature; token should still validate
- DisableFeature(kInappropriateFeatureName);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kSuccess,
- TrialTokenValidator::ValidateToken(
- kSampleToken, appropriate_origin_, &feature, Now()));
- EXPECT_EQ(kAppropriateFeatureName, feature);
- // Disable the token's feature; it should no longer be valid
- DisableFeature(kAppropriateFeatureName);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kFeatureDisabled,
- TrialTokenValidator::ValidateToken(
- kSampleToken, appropriate_origin_, &feature, Now()));
-}
-
-TEST_F(TrialTokenValidatorTest, ValidatorRespectsDisabledTokens) {
- std::string feature;
- // Disable an irrelevant token; token should still validate
- DisableToken(expired_token_signature_);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kSuccess,
- TrialTokenValidator::ValidateToken(
- kSampleToken, appropriate_origin_, &feature, Now()));
- EXPECT_EQ(kAppropriateFeatureName, feature);
- // Disable the token; it should no longer be valid
- DisableToken(valid_token_signature_);
- EXPECT_EQ(blink::WebOriginTrialTokenStatus::kTokenDisabled,
- TrialTokenValidator::ValidateToken(
- kSampleToken, appropriate_origin_, &feature, Now()));
-}
-
-TEST_F(TrialTokenValidatorTest, ValidateRequestInsecure) {
- response_headers_->AddHeader(std::string("Origin-Trial: ") +
- kInsecureOriginToken);
- EXPECT_FALSE(TrialTokenValidator::RequestEnablesFeature(
- GURL(kInsecureOrigin), response_headers_.get(), kAppropriateFeatureName,
- Now()));
-}
-
-TEST_F(TrialTokenValidatorTest, ValidateRequestValidToken) {
- response_headers_->AddHeader(std::string("Origin-Trial: ") + kSampleToken);
- EXPECT_TRUE(TrialTokenValidator::RequestEnablesFeature(
- GURL(kAppropriateOrigin), response_headers_.get(),
- kAppropriateFeatureName, Now()));
-}
-
-TEST_F(TrialTokenValidatorTest, ValidateRequestNoTokens) {
- EXPECT_FALSE(TrialTokenValidator::RequestEnablesFeature(
- GURL(kAppropriateOrigin), response_headers_.get(),
- kAppropriateFeatureName, Now()));
-}
-
-TEST_F(TrialTokenValidatorTest, ValidateRequestMultipleHeaders) {
- response_headers_->AddHeader(std::string("Origin-Trial: ") + kSampleToken);
- response_headers_->AddHeader(std::string("Origin-Trial: ") + kExpiredToken);
- EXPECT_TRUE(TrialTokenValidator::RequestEnablesFeature(
- GURL(kAppropriateOrigin), response_headers_.get(),
- kAppropriateFeatureName, Now()));
- EXPECT_FALSE(TrialTokenValidator::RequestEnablesFeature(
- GURL(kAppropriateOrigin), response_headers_.get(),
- kInappropriateFeatureName, Now()));
- EXPECT_FALSE(TrialTokenValidator::RequestEnablesFeature(
- GURL(kInappropriateOrigin), response_headers_.get(),
- kAppropriateFeatureName, Now()));
-}
-
-TEST_F(TrialTokenValidatorTest, ValidateRequestMultipleHeaderValues) {
- response_headers_->AddHeader(std::string("Origin-Trial: ") + kExpiredToken +
- ", " + kSampleToken);
- EXPECT_TRUE(TrialTokenValidator::RequestEnablesFeature(
- GURL(kAppropriateOrigin), response_headers_.get(),
- kAppropriateFeatureName, Now()));
- EXPECT_FALSE(TrialTokenValidator::RequestEnablesFeature(
- GURL(kAppropriateOrigin), response_headers_.get(),
- kInappropriateFeatureName, Now()));
- EXPECT_FALSE(TrialTokenValidator::RequestEnablesFeature(
- GURL(kInappropriateOrigin), response_headers_.get(),
- kAppropriateFeatureName, Now()));
-}
-
-} // namespace content
diff --git a/chromium/content/common/p2p_messages.h b/chromium/content/common/p2p_messages.h
index 15716d0c77c..706308946ae 100644
--- a/chromium/content/common/p2p_messages.h
+++ b/chromium/content/common/p2p_messages.h
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_P2P_MESSAGES_H_
+#define CONTENT_COMMON_P2P_MESSAGES_H_
+
// IPC messages for the P2P Transport API.
-// Multiply-included message file, hence no include guard.
#include <stdint.h>
@@ -136,3 +138,5 @@ IPC_MESSAGE_CONTROL3(P2PHostMsg_SetOption,
int /* socket_id */,
content::P2PSocketOption /* socket option type */,
int /* value */)
+
+#endif // CONTENT_COMMON_P2P_MESSAGES_H_
diff --git a/chromium/content/common/page_messages.h b/chromium/content/common/page_messages.h
index 4fa9f056c3b..b1c511b4060 100644
--- a/chromium/content/common/page_messages.h
+++ b/chromium/content/common/page_messages.h
@@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_PAGE_MESSAGES_H_
+#define CONTENT_COMMON_PAGE_MESSAGES_H_
+
#include "content/common/page_message_enums.h"
#include "content/public/common/screen_info.h"
#include "ipc/ipc_message_macros.h"
#include "ui/gfx/geometry/rect.h"
// IPC messages for page-level actions.
-// Multiply-included message file, hence no include guard.
#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
@@ -56,3 +58,5 @@ IPC_MESSAGE_ROUTED1(PageMsg_UpdateScreenInfo,
// Adding a new message? Stick to the sort order above: first platform
// independent PageMsg, then ifdefs for platform specific PageMsg, then platform
// independent PageHostMsg, then ifdefs for platform specific PageHostMsg.
+
+#endif // CONTENT_COMMON_PAGE_MESSAGES_H_
diff --git a/chromium/content/common/page_state_serialization.cc b/chromium/content/common/page_state_serialization.cc
index 7eafd52efea..a379477d165 100644
--- a/chromium/content/common/page_state_serialization.cc
+++ b/chromium/content/common/page_state_serialization.cc
@@ -10,7 +10,6 @@
#include <limits>
#include "base/pickle.h"
-#include "base/strings/nullable_string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -38,12 +37,13 @@ void AppendDataToRequestBody(
void AppendFileRangeToRequestBody(
const scoped_refptr<ResourceRequestBody>& request_body,
- const base::NullableString16& file_path,
+ const base::Optional<base::string16>& file_path,
int file_start,
int file_length,
double file_modification_time) {
request_body->AppendFileRange(
- base::FilePath::FromUTF16Unsafe(file_path.string()),
+ file_path ? base::FilePath::FromUTF16Unsafe(*file_path)
+ : base::FilePath(),
static_cast<uint64_t>(file_start), static_cast<uint64_t>(file_length),
base::Time::FromDoubleT(file_modification_time));
}
@@ -70,17 +70,16 @@ void AppendBlobToRequestBody(
void AppendReferencedFilesFromHttpBody(
const std::vector<ResourceRequestBody::Element>& elements,
- std::vector<base::NullableString16>* referenced_files) {
+ std::vector<base::Optional<base::string16>>* referenced_files) {
for (size_t i = 0; i < elements.size(); ++i) {
if (elements[i].type() == ResourceRequestBody::Element::TYPE_FILE)
- referenced_files->push_back(
- base::NullableString16(elements[i].path().AsUTF16Unsafe(), false));
+ referenced_files->emplace_back(elements[i].path().AsUTF16Unsafe());
}
}
bool AppendReferencedFilesFromDocumentState(
- const std::vector<base::NullableString16>& document_state,
- std::vector<base::NullableString16>* referenced_files) {
+ const std::vector<base::Optional<base::string16>>& document_state,
+ std::vector<base::Optional<base::string16>>* referenced_files) {
if (document_state.empty())
return true;
@@ -100,7 +99,8 @@ bool AppendReferencedFilesFromDocumentState(
index++; // Skip over form key.
size_t item_count;
- if (!base::StringToSizeT(document_state[index++].string(), &item_count))
+ if (!document_state[index] ||
+ !base::StringToSizeT(*document_state[index++], &item_count))
return false;
while (item_count--) {
@@ -108,24 +108,25 @@ bool AppendReferencedFilesFromDocumentState(
return false;
index++; // Skip over name.
- const base::NullableString16& type = document_state[index++];
+ const base::Optional<base::string16>& type = document_state[index++];
if (index >= document_state.size())
return false;
size_t value_size;
- if (!base::StringToSizeT(document_state[index++].string(), &value_size))
+ if (!document_state[index] ||
+ !base::StringToSizeT(*document_state[index++], &value_size))
return false;
if (index + value_size > document_state.size() ||
index + value_size < index) // Check for overflow.
return false;
- if (base::EqualsASCII(type.string(), "file")) {
+ if (type && base::EqualsASCII(*type, "file")) {
if (value_size != 2)
return false;
- referenced_files->push_back(document_state[index++]);
+ referenced_files->emplace_back(document_state[index++]);
index++; // Skip over display name.
} else {
index += value_size;
@@ -137,7 +138,7 @@ bool AppendReferencedFilesFromDocumentState(
bool RecursivelyAppendReferencedFiles(
const ExplodedFrameState& frame_state,
- std::vector<base::NullableString16>* referenced_files) {
+ std::vector<base::Optional<base::string16>>* referenced_files) {
if (frame_state.http_body.request_body != nullptr) {
AppendReferencedFilesFromHttpBody(
*frame_state.http_body.request_body->elements(), referenced_files);
@@ -306,25 +307,30 @@ std::string ReadStdString(SerializeObject* obj) {
return std::string();
}
-// WriteString pickles the NullableString16 as <int length><char16* data>.
-// If length == -1, then the NullableString16 itself is null. Otherwise the
-// length is the number of char16 (not bytes) in the NullableString16.
-void WriteString(const base::NullableString16& str, SerializeObject* obj) {
- if (str.is_null()) {
+// Pickles a base::string16 as <int length>:<char*16 data> tuple>.
+void WriteString(const base::string16& str, SerializeObject* obj) {
+ const base::char16* data = str.data();
+ size_t length_in_bytes = str.length() * sizeof(base::char16);
+
+ CHECK_LT(length_in_bytes,
+ static_cast<size_t>(std::numeric_limits<int>::max()));
+ obj->pickle.WriteInt(length_in_bytes);
+ obj->pickle.WriteBytes(data, length_in_bytes);
+}
+
+// If str is a null optional, this simply pickles a length of -1. Otherwise,
+// delegates to the base::string16 overload.
+void WriteString(const base::Optional<base::string16>& str,
+ SerializeObject* obj) {
+ if (!str) {
obj->pickle.WriteInt(-1);
} else {
- const base::char16* data = str.string().data();
- size_t length_in_bytes = str.string().length() * sizeof(base::char16);
-
- CHECK_LT(length_in_bytes,
- static_cast<size_t>(std::numeric_limits<int>::max()));
- obj->pickle.WriteInt(length_in_bytes);
- obj->pickle.WriteBytes(data, length_in_bytes);
+ WriteString(*str, obj);
}
}
-// This reads a serialized NullableString16 from obj. If a string can't be
-// read, NULL is returned.
+// This reads a serialized base::Optional<base::string16> from obj. If a string
+// can't be read, NULL is returned.
const base::char16* ReadStringNoCopy(SerializeObject* obj, int* num_chars) {
int length_in_bytes;
if (!obj->iter.ReadInt(&length_in_bytes)) {
@@ -346,12 +352,13 @@ const base::char16* ReadStringNoCopy(SerializeObject* obj, int* num_chars) {
return reinterpret_cast<const base::char16*>(data);
}
-base::NullableString16 ReadString(SerializeObject* obj) {
+base::Optional<base::string16> ReadString(SerializeObject* obj) {
int num_chars;
const base::char16* chars = ReadStringNoCopy(obj, &num_chars);
- return chars ?
- base::NullableString16(base::string16(chars, num_chars), false) :
- base::NullableString16();
+ base::Optional<base::string16> result;
+ if (chars)
+ result.emplace(chars, num_chars);
+ return result;
}
template <typename T>
@@ -380,8 +387,8 @@ size_t ReadAndValidateVectorSize(SerializeObject* obj, size_t element_size) {
}
// Writes a Vector of strings into a SerializeObject for serialization.
-void WriteStringVector(
- const std::vector<base::NullableString16>& data, SerializeObject* obj) {
+void WriteStringVector(const std::vector<base::Optional<base::string16>>& data,
+ SerializeObject* obj) {
WriteAndValidateVectorSize(data, obj);
for (size_t i = 0; i < data.size(); ++i) {
WriteString(data[i], obj);
@@ -389,9 +396,9 @@ void WriteStringVector(
}
void ReadStringVector(SerializeObject* obj,
- std::vector<base::NullableString16>* result) {
+ std::vector<base::Optional<base::string16>>* result) {
size_t num_elements =
- ReadAndValidateVectorSize(obj, sizeof(base::NullableString16));
+ ReadAndValidateVectorSize(obj, sizeof(base::Optional<base::string16>));
result->resize(num_elements);
for (size_t i = 0; i < num_elements; ++i)
@@ -409,8 +416,7 @@ void WriteResourceRequestBody(const ResourceRequestBody& request_body,
break;
case ResourceRequestBody::Element::TYPE_FILE:
WriteInteger(blink::WebHTTPBody::Element::kTypeFile, obj);
- WriteString(
- base::NullableString16(element.path().AsUTF16Unsafe(), false), obj);
+ WriteString(element.path().AsUTF16Unsafe(), obj);
WriteInteger64(static_cast<int64_t>(element.offset()), obj);
WriteInteger64(static_cast<int64_t>(element.length()), obj);
WriteReal(element.expected_modification_time().ToDoubleT(), obj);
@@ -451,7 +457,7 @@ void ReadResourceRequestBody(
length);
}
} else if (type == blink::WebHTTPBody::Element::kTypeFile) {
- base::NullableString16 file_path = ReadString(obj);
+ base::Optional<base::string16> file_path = ReadString(obj);
int64_t file_start = ReadInteger64(obj);
int64_t file_length = ReadInteger64(obj);
double file_modification_time = ReadReal(obj);
@@ -536,10 +542,10 @@ void WriteFrameState(
WriteInteger(state.scroll_restoration_type, obj);
- bool has_state_object = !state.state_object.is_null();
+ bool has_state_object = state.state_object.has_value();
WriteBoolean(has_state_object, obj);
if (has_state_object)
- WriteString(state.state_object, obj);
+ WriteString(*state.state_object, obj);
WriteHttpBody(state.http_body, obj);
@@ -569,12 +575,9 @@ void ReadFrameState(
ReadString(obj); // Skip obsolete original url string field.
state->target = ReadString(obj);
- if (obj->version < 25 && !state->target.is_null()) {
- state->target = base::NullableString16(
- base::UTF8ToUTF16(UniqueNameHelper::UpdateLegacyNameFromV24(
- base::UTF16ToUTF8(state->target.string()),
- unique_name_replacements)),
- false);
+ if (obj->version < 25 && state->target) {
+ state->target = base::UTF8ToUTF16(UniqueNameHelper::UpdateLegacyNameFromV24(
+ base::UTF16ToUTF8(*state->target), unique_name_replacements));
}
if (obj->version < 15) {
ReadString(obj); // Skip obsolete parent field.
@@ -690,9 +693,7 @@ void ReadPageState(SerializeObject* obj, ExplodedPageState* state) {
if (obj->version == -1) {
GURL url = ReadGURL(obj);
// NOTE: GURL::possibly_invalid_spec() always returns valid UTF-8.
- state->top.url_string =
- base::NullableString16(
- base::UTF8ToUTF16(url.possibly_invalid_spec()), false);
+ state->top.url_string = base::UTF8ToUTF16(url.possibly_invalid_spec());
return;
}
diff --git a/chromium/content/common/page_state_serialization.h b/chromium/content/common/page_state_serialization.h
index 02afc8fb3ce..a04764fe451 100644
--- a/chromium/content/common/page_state_serialization.h
+++ b/chromium/content/common/page_state_serialization.h
@@ -10,7 +10,8 @@
#include <string>
#include <vector>
-#include "base/strings/nullable_string16.h"
+#include "base/optional.h"
+#include "base/strings/string16.h"
#include "build/build_config.h"
#include "content/common/content_export.h"
#include "content/public/common/resource_request_body.h"
@@ -24,7 +25,7 @@
namespace content {
struct CONTENT_EXPORT ExplodedHttpBody {
- base::NullableString16 http_content_type;
+ base::Optional<base::string16> http_content_type;
scoped_refptr<ResourceRequestBody> request_body;
bool contains_passwords;
@@ -33,11 +34,11 @@ struct CONTENT_EXPORT ExplodedHttpBody {
};
struct CONTENT_EXPORT ExplodedFrameState {
- base::NullableString16 url_string;
- base::NullableString16 referrer;
- base::NullableString16 target;
- base::NullableString16 state_object;
- std::vector<base::NullableString16> document_state;
+ base::Optional<base::string16> url_string;
+ base::Optional<base::string16> referrer;
+ base::Optional<base::string16> target;
+ base::Optional<base::string16> state_object;
+ std::vector<base::Optional<base::string16>> document_state;
blink::WebHistoryScrollRestorationType scroll_restoration_type;
bool did_save_scroll_or_scale_state;
gfx::PointF visual_viewport_scroll_offset;
@@ -63,7 +64,7 @@ struct CONTENT_EXPORT ExplodedPageState {
// extract referenced files from ExplodedHttpBody. |referenced_files|
// currently contains a list from all frames, but cannot be deserialized into
// the files referenced by each frame. See http://crbug.com/441966.
- std::vector<base::NullableString16> referenced_files;
+ std::vector<base::Optional<base::string16>> referenced_files;
ExplodedFrameState top;
ExplodedPageState();
diff --git a/chromium/content/common/page_state_serialization_unittest.cc b/chromium/content/common/page_state_serialization_unittest.cc
index 911f86c1f72..725d52caa1b 100644
--- a/chromium/content/common/page_state_serialization_unittest.cc
+++ b/chromium/content/common/page_state_serialization_unittest.cc
@@ -21,11 +21,6 @@
namespace content {
namespace {
-base::NullableString16 NS16(const char* s) {
- return s ? base::NullableString16(base::ASCIIToUTF16(s), false) :
- base::NullableString16();
-}
-
//-----------------------------------------------------------------------------
template <typename T>
@@ -99,15 +94,17 @@ class PageStateSerializationTest : public testing::Test {
public:
void PopulateFrameState(ExplodedFrameState* frame_state) {
// Invent some data for the various fields.
- frame_state->url_string = NS16("http://dev.chromium.org/");
- frame_state->referrer = NS16("https://www.google.com/search?q=dev.chromium.org");
+ frame_state->url_string = base::UTF8ToUTF16("http://dev.chromium.org/");
+ frame_state->referrer =
+ base::UTF8ToUTF16("https://www.google.com/search?q=dev.chromium.org");
frame_state->referrer_policy = blink::kWebReferrerPolicyAlways;
- frame_state->target = NS16("foo");
- frame_state->state_object = NS16(NULL);
- frame_state->document_state.push_back(NS16("1"));
- frame_state->document_state.push_back(NS16("q"));
- frame_state->document_state.push_back(NS16("text"));
- frame_state->document_state.push_back(NS16("dev.chromium.org"));
+ frame_state->target = base::UTF8ToUTF16("foo");
+ frame_state->state_object = base::nullopt;
+ frame_state->document_state.push_back(base::UTF8ToUTF16("1"));
+ frame_state->document_state.push_back(base::UTF8ToUTF16("q"));
+ frame_state->document_state.push_back(base::UTF8ToUTF16("text"));
+ frame_state->document_state.push_back(
+ base::UTF8ToUTF16("dev.chromium.org"));
frame_state->scroll_restoration_type =
blink::kWebHistoryScrollRestorationManual;
frame_state->visual_viewport_scroll_offset = gfx::PointF(10, 15);
@@ -117,12 +114,13 @@ class PageStateSerializationTest : public testing::Test {
frame_state->page_scale_factor = 2.0;
}
- void PopulateHttpBody(ExplodedHttpBody* http_body,
- std::vector<base::NullableString16>* referenced_files) {
+ void PopulateHttpBody(
+ ExplodedHttpBody* http_body,
+ std::vector<base::Optional<base::string16>>* referenced_files) {
http_body->request_body = new ResourceRequestBody();
http_body->request_body->set_identifier(12345);
http_body->contains_passwords = false;
- http_body->http_content_type = NS16("text/foo");
+ http_body->http_content_type = base::UTF8ToUTF16("text/foo");
std::string test_body("foo");
http_body->request_body->AppendBytes(test_body.data(), test_body.size());
@@ -131,18 +129,17 @@ class PageStateSerializationTest : public testing::Test {
http_body->request_body->AppendFileRange(base::FilePath(path), 100, 1024,
base::Time::FromDoubleT(9999.0));
- referenced_files->push_back(
- base::NullableString16(path.AsUTF16Unsafe(), false));
+ referenced_files->emplace_back(path.AsUTF16Unsafe());
}
void PopulateFrameStateForBackwardsCompatTest(
ExplodedFrameState* frame_state,
bool is_child) {
- frame_state->url_string = NS16("http://chromium.org/");
- frame_state->referrer = NS16("http://google.com/");
+ frame_state->url_string = base::UTF8ToUTF16("http://chromium.org/");
+ frame_state->referrer = base::UTF8ToUTF16("http://google.com/");
frame_state->referrer_policy = blink::kWebReferrerPolicyDefault;
if (!is_child)
- frame_state->target = NS16("target");
+ frame_state->target = base::UTF8ToUTF16("target");
frame_state->scroll_restoration_type =
blink::kWebHistoryScrollRestorationAuto;
frame_state->visual_viewport_scroll_offset = gfx::PointF(-1, -1);
@@ -151,18 +148,18 @@ class PageStateSerializationTest : public testing::Test {
frame_state->document_sequence_number = 456;
frame_state->page_scale_factor = 2.0f;
- frame_state->document_state.push_back(
- NS16("\n\r?% WebKit serialized form state version 8 \n\r=&"));
- frame_state->document_state.push_back(NS16("form key"));
- frame_state->document_state.push_back(NS16("1"));
- frame_state->document_state.push_back(NS16("foo"));
- frame_state->document_state.push_back(NS16("file"));
- frame_state->document_state.push_back(NS16("2"));
- frame_state->document_state.push_back(NS16("file.txt"));
- frame_state->document_state.push_back(NS16("displayName"));
+ frame_state->document_state.push_back(base::UTF8ToUTF16(
+ "\n\r?% WebKit serialized form state version 8 \n\r=&"));
+ frame_state->document_state.push_back(base::UTF8ToUTF16("form key"));
+ frame_state->document_state.push_back(base::UTF8ToUTF16("1"));
+ frame_state->document_state.push_back(base::UTF8ToUTF16("foo"));
+ frame_state->document_state.push_back(base::UTF8ToUTF16("file"));
+ frame_state->document_state.push_back(base::UTF8ToUTF16("2"));
+ frame_state->document_state.push_back(base::UTF8ToUTF16("file.txt"));
+ frame_state->document_state.push_back(base::UTF8ToUTF16("displayName"));
if (!is_child) {
- frame_state->http_body.http_content_type = NS16("foo/bar");
+ frame_state->http_body.http_content_type = base::UTF8ToUTF16("foo/bar");
frame_state->http_body.request_body = new ResourceRequestBody();
frame_state->http_body.request_body->set_identifier(789);
@@ -185,7 +182,7 @@ class PageStateSerializationTest : public testing::Test {
}
void PopulatePageStateForBackwardsCompatTest(ExplodedPageState* page_state) {
- page_state->referenced_files.push_back(NS16("file.txt"));
+ page_state->referenced_files.push_back(base::UTF8ToUTF16("file.txt"));
PopulateFrameStateForBackwardsCompatTest(&page_state->top, false);
}
diff --git a/chromium/content/common/platform_notification_messages.h b/chromium/content/common/platform_notification_messages.h
index 02bb9f3af97..cb37f10f449 100644
--- a/chromium/content/common/platform_notification_messages.h
+++ b/chromium/content/common/platform_notification_messages.h
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_PLATFORM_NOTIFICATION_MESSAGES_H_
+#define CONTENT_COMMON_PLATFORM_NOTIFICATION_MESSAGES_H_
+
// Messages for platform-native notifications using the Web Notification API.
-// Multiply-included message file, hence no include guard.
#include <stdint.h>
#include <string>
@@ -16,15 +18,15 @@
#include "ipc/ipc_message_macros.h"
// Singly-included section for type definitions.
-#ifndef CONTENT_COMMON_PLATFORM_NOTIFICATION_MESSAGES_H_
-#define CONTENT_COMMON_PLATFORM_NOTIFICATION_MESSAGES_H_
+#ifndef INTERNAL_CONTENT_COMMON_PLATFORM_NOTIFICATION_MESSAGES_H_
+#define INTERNAL_CONTENT_COMMON_PLATFORM_NOTIFICATION_MESSAGES_H_
// Defines the pair of [notification id] => [notification data] used when
// getting the notifications for a given Service Worker registration.
using PersistentNotificationInfo =
std::pair<std::string, content::PlatformNotificationData>;
-#endif // CONTENT_COMMON_PLATFORM_NOTIFICATION_MESSAGES_H_
+#endif // INTERNAL_CONTENT_COMMON_PLATFORM_NOTIFICATION_MESSAGES_H_
#define IPC_MESSAGE_START PlatformNotificationMsgStart
@@ -128,3 +130,5 @@ IPC_MESSAGE_CONTROL3(PlatformNotificationHostMsg_ClosePersistent,
GURL /* origin */,
std::string /* tag */,
std::string /* notification_id */)
+
+#endif // CONTENT_COMMON_PLATFORM_NOTIFICATION_MESSAGES_H_
diff --git a/chromium/content/common/presentation/presentation_struct_traits.cc b/chromium/content/common/presentation/presentation_struct_traits.cc
index 13b5b388b7e..2624bbf3611 100644
--- a/chromium/content/common/presentation/presentation_struct_traits.cc
+++ b/chromium/content/common/presentation/presentation_struct_traits.cc
@@ -47,14 +47,11 @@ bool UnionTraits<blink::mojom::PresentationConnectionMessageDataView,
Read(blink::mojom::PresentationConnectionMessageDataView data,
content::PresentationConnectionMessage* out) {
if (data.is_message()) {
- if (!data.ReadMessage(&(out->message)) ||
- out->message->length() >
- content::kMaxPresentationConnectionMessageSize) {
+ if (!data.ReadMessage(&(out->message))) {
return false;
}
} else {
- if (!data.ReadData(&(out->data)) ||
- out->data->size() > content::kMaxPresentationConnectionMessageSize) {
+ if (!data.ReadData(&(out->data))) {
return false;
}
}
diff --git a/chromium/content/common/quota_messages.h b/chromium/content/common/quota_messages.h
index 39006e1b6ee..5eec9b39f9a 100644
--- a/chromium/content/common/quota_messages.h
+++ b/chromium/content/common/quota_messages.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Multiply-included message file, hence no include guard.
+#ifndef CONTENT_COMMON_QUOTA_MESSAGES_H_
+#define CONTENT_COMMON_QUOTA_MESSAGES_H_
#include <stdint.h>
@@ -50,3 +51,5 @@ IPC_MESSAGE_CONTROL3(QuotaHostMsg_QueryStorageUsageAndQuota,
IPC_MESSAGE_CONTROL1(QuotaHostMsg_RequestStorageQuota,
content::StorageQuotaParams)
+
+#endif // CONTENT_COMMON_QUOTA_MESSAGES_H_
diff --git a/chromium/content/common/render_process_messages.h b/chromium/content/common/render_process_messages.h
index 7ae52ee7304..e30da603ea1 100644
--- a/chromium/content/common/render_process_messages.h
+++ b/chromium/content/common/render_process_messages.h
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_RENDER_PROCESS_MESSAGES_H_
+#define CONTENT_COMMON_RENDER_PROCESS_MESSAGES_H_
+
// Common IPC messages used for render processes.
-// Multiply-included message file, hence no include guard.
#include <stdint.h>
@@ -68,3 +70,5 @@ IPC_SYNC_MESSAGE_CONTROL1_3(RenderProcessHostMsg_LoadFont,
base::SharedMemoryHandle /* font data */,
uint32_t /* font id */)
#endif
+
+#endif // CONTENT_COMMON_RENDER_PROCESS_MESSAGES_H_
diff --git a/chromium/content/common/render_widget_surface_properties.cc b/chromium/content/common/render_widget_surface_properties.cc
index 254da9582a4..36509112543 100644
--- a/chromium/content/common/render_widget_surface_properties.cc
+++ b/chromium/content/common/render_widget_surface_properties.cc
@@ -9,7 +9,7 @@ namespace content {
// static
RenderWidgetSurfaceProperties
RenderWidgetSurfaceProperties::FromCompositorFrame(
- const cc::CompositorFrame& frame) {
+ const viz::CompositorFrame& frame) {
RenderWidgetSurfaceProperties properties;
properties.size = frame.size_in_pixels();
properties.device_scale_factor = frame.device_scale_factor();
diff --git a/chromium/content/common/render_widget_surface_properties.h b/chromium/content/common/render_widget_surface_properties.h
index 4fcbd9effc4..f35294dd77b 100644
--- a/chromium/content/common/render_widget_surface_properties.h
+++ b/chromium/content/common/render_widget_surface_properties.h
@@ -5,7 +5,7 @@
#ifndef CONTENT_COMMON_RENDER_WIDGET_SURFACE_PROPERTIES_H_
#define CONTENT_COMMON_RENDER_WIDGET_SURFACE_PROPERTIES_H_
-#include "cc/output/compositor_frame.h"
+#include "components/viz/common/quads/compositor_frame.h"
#include "content/common/content_export.h"
namespace content {
@@ -14,7 +14,7 @@ namespace content {
// CompositorFrames that the renderer submits to the same surface.
struct CONTENT_EXPORT RenderWidgetSurfaceProperties {
static RenderWidgetSurfaceProperties FromCompositorFrame(
- const cc::CompositorFrame& frame);
+ const viz::CompositorFrame& frame);
RenderWidgetSurfaceProperties();
RenderWidgetSurfaceProperties(const RenderWidgetSurfaceProperties& other);
@@ -33,7 +33,7 @@ struct CONTENT_EXPORT RenderWidgetSurfaceProperties {
float top_controls_shown_ratio = 0;
float bottom_controls_height = 0;
float bottom_controls_shown_ratio = 0;
- cc::Selection<gfx::SelectionBound> selection;
+ viz::Selection<gfx::SelectionBound> selection;
bool has_transparent_background = false;
#endif
};
diff --git a/chromium/content/common/render_widget_window_tree_client_factory.mojom b/chromium/content/common/render_widget_window_tree_client_factory.mojom
index 9a375cf499c..22cc65deeec 100644
--- a/chromium/content/common/render_widget_window_tree_client_factory.mojom
+++ b/chromium/content/common/render_widget_window_tree_client_factory.mojom
@@ -4,10 +4,24 @@
module content.mojom;
+import "mojo/common/unguessable_token.mojom";
import "services/ui/public/interfaces/window_tree.mojom";
+interface RenderWidgetWindowTreeClient {
+ // Asks the renderer to create a Window for the frame with the routing id
+ // |routing_id| and embeds the WindowTreeClient that was previously supplied
+ // to ScheduleEmbed().
+ Embed(uint32 frame_routing_id, mojo.common.mojom.UnguessableToken token);
+
+ // Called when a render frame has been destroyed. This is sent via mojom
+ // to handle to ensure there aren't race conditions because of message order
+ // delivery.
+ DestroyFrame(uint32 frame_routing_id);
+};
+
interface RenderWidgetWindowTreeClientFactory {
CreateWindowTreeClientForRenderWidget(
- uint32 routing_id,
- ui.mojom.WindowTreeClient& window_tree_client);
+ uint32 render_widget_host_routing_id,
+ ui.mojom.WindowTreeClient& window_tree_client,
+ RenderWidgetWindowTreeClient& render_widget_window_tree_client_request);
};
diff --git a/chromium/content/common/renderer.mojom b/chromium/content/common/renderer.mojom
index 642090b3150..91327fc65fc 100644
--- a/chromium/content/common/renderer.mojom
+++ b/chromium/content/common/renderer.mojom
@@ -6,8 +6,9 @@ module content.mojom;
import "content/common/native_types.mojom";
import "content/common/service_worker/embedded_worker.mojom";
-import "ipc/ipc.mojom";
+import "ipc/constants.mojom";
import "mojo/common/time.mojom";
+import "mojo/common/unguessable_token.mojom";
import "ui/gfx/geometry/mojo/geometry.mojom";
import "ui/gfx/mojo/icc_profile.mojom";
@@ -43,6 +44,14 @@ struct CreateViewParams {
// cases.
FrameReplicationState replicated_frame_state;
+ // Used for devtools instrumentation and trace-ability. The token is
+ // propagated to Blink's LocalFrame and both Blink and content/
+ // can tag calls and requests with this instrumentation token in order to
+ // attribute them to the context frame.
+ // |devtools_main_frame_token| is only defined by the browser and is never
+ // sent back from the renderer in the control calls.
+ mojo.common.mojom.UnguessableToken devtools_main_frame_token;
+
// The ID of the proxy object for the main frame in this view. It is only
// used if |swapped_out| is true.
int32 proxy_routing_id = IPC.mojom.kRoutingIdNone;
@@ -70,9 +79,6 @@ struct CreateViewParams {
// The page zoom level.
double page_zoom_level;
-
- // The ICC profile of the output color space to use for image decode.
- gfx.mojom.ICCProfile image_decode_color_space;
};
struct CreateFrameWidgetParams {
@@ -113,6 +119,14 @@ struct CreateFrameParams {
// the new frame's sandbox flags.
FrameReplicationState replication_state;
+ // Used for devtools instrumentation and trace-ability. The token is
+ // propagated to Blink's LocalFrame and both Blink and content/
+ // can tag calls and requests with this instrumentation token in order to
+ // attribute them to the context frame.
+ // |devtools_frame_token| is only defined by the browser and is never
+ // sent back from the renderer in the control calls.
+ mojo.common.mojom.UnguessableToken devtools_frame_token;
+
// When the new frame has a parent, |frame_owner_properties| holds the
// properties of the HTMLFrameOwnerElement from the parent process.
// Note that unlike FrameReplicationState, this is not replicated for remote
@@ -171,7 +185,7 @@ interface Renderer {
// EffectiveConnectionType is the connection type whose typical performance is
// most similar to the measured performance of the network in use.
// The downstream throughput is computed in kilobits per second. If an
- // estimate of the HTTP or transport RTT is unavailable, it will be set to
+ // estimate of the HTTP or transport RTT is unavailable, it will be set to
// net::nqe::internal::InvalidRTT(). If the throughput estimate is
// unavailable, it will be set to net::nqe::internal::kInvalidThroughput.
OnNetworkQualityChanged(EffectiveConnectionType effective_connection_type,
diff --git a/chromium/content/common/resize_params.h b/chromium/content/common/resize_params.h
index f0d51a82890..60ae351dd76 100644
--- a/chromium/content/common/resize_params.h
+++ b/chromium/content/common/resize_params.h
@@ -53,8 +53,9 @@ struct CONTENT_EXPORT ResizeParams {
// The display mode.
blink::WebDisplayMode display_mode;
- // If set, requests the renderer to reply with a ViewHostMsg_UpdateRect
- // with the ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK bit set in flags.
+ // If set, requests the renderer to reply with a
+ // ViewHostMsg_ResizeOrRepaint_ACK with the
+ // ViewHostMsg_ResizeOrRepaint_ACK_Flags::IS_RESIZE_ACK bit set in flags.
bool needs_resize_ack;
};
diff --git a/chromium/content/common/resource_messages.cc b/chromium/content/common/resource_messages.cc
index a6a439168d6..8d2fadbdd22 100644
--- a/chromium/content/common/resource_messages.cc
+++ b/chromium/content/common/resource_messages.cc
@@ -9,16 +9,6 @@
namespace IPC {
-void ParamTraits<scoped_refptr<net::HttpResponseHeaders>>::GetSize(
- base::PickleSizer* s, const param_type& p) {
- GetParamSize(s, p.get() != NULL);
- if (p.get()) {
- base::Pickle temp;
- p->Persist(&temp, net::HttpResponseHeaders::PERSIST_SANS_COOKIES);
- s->AddBytes(temp.payload_size());
- }
-}
-
void ParamTraits<scoped_refptr<net::HttpResponseHeaders>>::Write(
base::Pickle* m,
const param_type& p) {
@@ -48,15 +38,6 @@ void ParamTraits<scoped_refptr<net::HttpResponseHeaders> >::Log(
namespace {
-void GetCertSize(base::PickleSizer* s, net::X509Certificate* cert) {
- GetParamSize(s, !!cert);
- if (cert) {
- base::Pickle temp;
- cert->Persist(&temp);
- s->AddBytes(temp.payload_size());
- }
-}
-
void WriteCert(base::Pickle* m, net::X509Certificate* cert) {
WriteParam(m, !!cert);
if (cert)
@@ -79,33 +60,6 @@ bool ReadCert(const base::Pickle* m,
} // namespace
-void ParamTraits<net::SSLInfo>::GetSize(base::PickleSizer* s,
- const param_type& p) {
- GetParamSize(s, p.is_valid());
- if (!p.is_valid())
- return;
- GetCertSize(s, p.cert.get());
- GetCertSize(s, p.unverified_cert.get());
- GetParamSize(s, p.cert_status);
- GetParamSize(s, p.security_bits);
- GetParamSize(s, p.key_exchange_group);
- GetParamSize(s, p.connection_status);
- GetParamSize(s, p.is_issued_by_known_root);
- GetParamSize(s, p.pkp_bypassed);
- GetParamSize(s, p.client_cert_sent);
- GetParamSize(s, p.channel_id_sent);
- GetParamSize(s, p.token_binding_negotiated);
- GetParamSize(s, p.token_binding_key_param);
- GetParamSize(s, p.handshake_type);
- GetParamSize(s, p.public_key_hashes);
- GetParamSize(s, p.pinning_failure_log);
- GetParamSize(s, p.signed_certificate_timestamps);
- GetParamSize(s, p.ct_compliance_details_available);
- GetParamSize(s, p.ct_cert_policy_compliance);
- GetParamSize(s, p.ocsp_result.response_status);
- GetParamSize(s, p.ocsp_result.revocation_status);
-}
-
void ParamTraits<net::SSLInfo>::Write(base::Pickle* m, const param_type& p) {
WriteParam(m, p.is_valid());
if (!p.is_valid())
@@ -166,11 +120,6 @@ void ParamTraits<net::SSLInfo>::Log(const param_type& p, std::string* l) {
l->append("<SSLInfo>");
}
-void ParamTraits<net::HashValue>::GetSize(base::PickleSizer* s,
- const param_type& p) {
- GetParamSize(s, p.ToString());
-}
-
void ParamTraits<net::HashValue>::Write(base::Pickle* m, const param_type& p) {
WriteParam(m, p.ToString());
}
@@ -186,49 +135,6 @@ void ParamTraits<net::HashValue>::Log(const param_type& p, std::string* l) {
l->append("<HashValue>");
}
-void ParamTraits<storage::DataElement>::GetSize(base::PickleSizer* s,
- const param_type& p) {
- GetParamSize(s, static_cast<int>(p.type()));
- switch (p.type()) {
- case storage::DataElement::TYPE_BYTES: {
- s->AddData(static_cast<int>(p.length()));
- break;
- }
- case storage::DataElement::TYPE_BYTES_DESCRIPTION: {
- GetParamSize(s, p.length());
- break;
- }
- case storage::DataElement::TYPE_FILE: {
- GetParamSize(s, p.path());
- GetParamSize(s, p.offset());
- GetParamSize(s, p.length());
- GetParamSize(s, p.expected_modification_time());
- break;
- }
- case storage::DataElement::TYPE_FILE_FILESYSTEM: {
- GetParamSize(s, p.filesystem_url());
- GetParamSize(s, p.offset());
- GetParamSize(s, p.length());
- GetParamSize(s, p.expected_modification_time());
- break;
- }
- case storage::DataElement::TYPE_BLOB: {
- GetParamSize(s, p.blob_uuid());
- GetParamSize(s, p.offset());
- GetParamSize(s, p.length());
- break;
- }
- case storage::DataElement::TYPE_DISK_CACHE_ENTRY: {
- NOTREACHED() << "Can't be sent by IPC.";
- break;
- }
- case storage::DataElement::TYPE_UNKNOWN: {
- NOTREACHED();
- break;
- }
- }
-}
-
void ParamTraits<storage::DataElement>::Write(base::Pickle* m,
const param_type& p) {
WriteParam(m, static_cast<int>(p.type()));
@@ -355,19 +261,6 @@ void ParamTraits<storage::DataElement>::Log(const param_type& p,
l->append("<storage::DataElement>");
}
-void ParamTraits<scoped_refptr<content::ResourceDevToolsInfo>>::GetSize(
- base::PickleSizer* s, const param_type& p) {
- GetParamSize(s, p.get() != NULL);
- if (p.get()) {
- GetParamSize(s, p->http_status_code);
- GetParamSize(s, p->http_status_text);
- GetParamSize(s, p->request_headers);
- GetParamSize(s, p->response_headers);
- GetParamSize(s, p->request_headers_text);
- GetParamSize(s, p->response_headers_text);
- }
-}
-
void ParamTraits<scoped_refptr<content::ResourceDevToolsInfo>>::Write(
base::Pickle* m,
const param_type& p) {
@@ -412,30 +305,6 @@ void ParamTraits<scoped_refptr<content::ResourceDevToolsInfo> >::Log(
l->append(")");
}
-void ParamTraits<net::LoadTimingInfo>::GetSize(base::PickleSizer* s,
- const param_type& p) {
- GetParamSize(s, p.socket_log_id);
- GetParamSize(s, p.socket_reused);
- GetParamSize(s, p.request_start_time.is_null());
- if (p.request_start_time.is_null())
- return;
- GetParamSize(s, p.request_start_time);
- GetParamSize(s, p.request_start);
- GetParamSize(s, p.proxy_resolve_start);
- GetParamSize(s, p.proxy_resolve_end);
- GetParamSize(s, p.connect_timing.dns_start);
- GetParamSize(s, p.connect_timing.dns_end);
- GetParamSize(s, p.connect_timing.connect_start);
- GetParamSize(s, p.connect_timing.connect_end);
- GetParamSize(s, p.connect_timing.ssl_start);
- GetParamSize(s, p.connect_timing.ssl_end);
- GetParamSize(s, p.send_start);
- GetParamSize(s, p.send_end);
- GetParamSize(s, p.receive_headers_end);
- GetParamSize(s, p.push_start);
- GetParamSize(s, p.push_end);
-}
-
void ParamTraits<net::LoadTimingInfo>::Write(base::Pickle* m,
const param_type& p) {
WriteParam(m, p.socket_log_id);
@@ -529,17 +398,6 @@ void ParamTraits<net::LoadTimingInfo>::Log(const param_type& p,
l->append(")");
}
-void ParamTraits<scoped_refptr<content::ResourceRequestBody>>::GetSize(
- base::PickleSizer* s,
- const param_type& p) {
- GetParamSize(s, p.get() != NULL);
- if (p.get()) {
- GetParamSize(s, *p->elements());
- GetParamSize(s, p->identifier());
- GetParamSize(s, p->contains_sensitive_info());
- }
-}
-
void ParamTraits<scoped_refptr<content::ResourceRequestBody>>::Write(
base::Pickle* m,
const param_type& p) {
@@ -582,24 +440,6 @@ void ParamTraits<scoped_refptr<content::ResourceRequestBody>>::Log(
l->append("<ResourceRequestBody>");
}
-void ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>>::GetSize(
- base::PickleSizer* s,
- const param_type& p) {
- GetParamSize(s, p.get() != NULL);
- if (p.get()) {
- GetParamSize(s, static_cast<unsigned int>(p->version));
- GetParamSize(s, p->log_id);
- GetParamSize(s, p->timestamp);
- GetParamSize(s, p->extensions);
- GetParamSize(s, static_cast<unsigned int>(p->signature.hash_algorithm));
- GetParamSize(s,
- static_cast<unsigned int>(p->signature.signature_algorithm));
- GetParamSize(s, p->signature.signature_data);
- GetParamSize(s, static_cast<unsigned int>(p->origin));
- GetParamSize(s, p->log_description);
- }
-}
-
void ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>>::Write(
base::Pickle* m,
const param_type& p) {
diff --git a/chromium/content/common/resource_messages.h b/chromium/content/common/resource_messages.h
index 9d0417c1c40..f68a8b6c3e5 100644
--- a/chromium/content/common/resource_messages.h
+++ b/chromium/content/common/resource_messages.h
@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_RESOURCE_MESSAGES_H_
+#define CONTENT_COMMON_RESOURCE_MESSAGES_H_
+
// IPC messages for resource loading.
//
// NOTE: All messages must send an |int request_id| as their first parameter.
-// Multiply-included message file, hence no include guard.
-
#include <stdint.h>
#include "base/memory/shared_memory.h"
@@ -31,8 +32,8 @@
#include "net/url_request/redirect_info.h"
#include "third_party/WebKit/public/platform/WebMixedContentContextType.h"
-#ifndef CONTENT_COMMON_RESOURCE_MESSAGES_H_
-#define CONTENT_COMMON_RESOURCE_MESSAGES_H_
+#ifndef INTERNAL_CONTENT_COMMON_RESOURCE_MESSAGES_H_
+#define INTERNAL_CONTENT_COMMON_RESOURCE_MESSAGES_H_
namespace net {
struct LoadTimingInfo;
@@ -47,7 +48,6 @@ namespace IPC {
template <>
struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > {
typedef scoped_refptr<net::HttpResponseHeaders> param_type;
- static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -58,7 +58,6 @@ struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > {
template <>
struct CONTENT_EXPORT ParamTraits<net::SSLInfo> {
typedef net::SSLInfo param_type;
- static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -69,7 +68,6 @@ struct CONTENT_EXPORT ParamTraits<net::SSLInfo> {
template <>
struct CONTENT_EXPORT ParamTraits<net::HashValue> {
typedef net::HashValue param_type;
- static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -80,7 +78,6 @@ struct CONTENT_EXPORT ParamTraits<net::HashValue> {
template <>
struct CONTENT_EXPORT ParamTraits<storage::DataElement> {
typedef storage::DataElement param_type;
- static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -91,7 +88,6 @@ struct CONTENT_EXPORT ParamTraits<storage::DataElement> {
template <>
struct ParamTraits<scoped_refptr<content::ResourceDevToolsInfo> > {
typedef scoped_refptr<content::ResourceDevToolsInfo> param_type;
- static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -102,7 +98,6 @@ struct ParamTraits<scoped_refptr<content::ResourceDevToolsInfo> > {
template <>
struct ParamTraits<net::LoadTimingInfo> {
typedef net::LoadTimingInfo param_type;
- static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -113,7 +108,6 @@ struct ParamTraits<net::LoadTimingInfo> {
template <>
struct ParamTraits<scoped_refptr<content::ResourceRequestBody>> {
typedef scoped_refptr<content::ResourceRequestBody> param_type;
- static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -124,7 +118,6 @@ struct ParamTraits<scoped_refptr<content::ResourceRequestBody>> {
template <>
struct ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>> {
typedef scoped_refptr<net::ct::SignedCertificateTimestamp> param_type;
- static void GetSize(base::PickleSizer* s, const param_type& p);
static void Write(base::Pickle* m, const param_type& p);
static bool Read(const base::Pickle* m,
base::PickleIterator* iter,
@@ -134,8 +127,7 @@ struct ParamTraits<scoped_refptr<net::ct::SignedCertificateTimestamp>> {
} // namespace IPC
-#endif // CONTENT_COMMON_RESOURCE_MESSAGES_H_
-
+#endif // INTERNAL_CONTENT_COMMON_RESOURCE_MESSAGES_H_
#define IPC_MESSAGE_START ResourceMsgStart
#undef IPC_MESSAGE_EXPORT
@@ -191,6 +183,8 @@ IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseInfo)
IPC_STRUCT_TRAITS_MEMBER(mime_type)
IPC_STRUCT_TRAITS_MEMBER(charset)
IPC_STRUCT_TRAITS_MEMBER(has_major_certificate_errors)
+ IPC_STRUCT_TRAITS_MEMBER(is_legacy_symantec_cert)
+ IPC_STRUCT_TRAITS_MEMBER(cert_validity_start)
IPC_STRUCT_TRAITS_MEMBER(content_length)
IPC_STRUCT_TRAITS_MEMBER(encoded_data_length)
IPC_STRUCT_TRAITS_MEMBER(encoded_body_length)
@@ -276,14 +270,13 @@ IPC_STRUCT_TRAITS_BEGIN(content::ResourceRequest)
IPC_STRUCT_TRAITS_MEMBER(fetch_frame_type)
IPC_STRUCT_TRAITS_MEMBER(request_body)
IPC_STRUCT_TRAITS_MEMBER(download_to_file)
+ IPC_STRUCT_TRAITS_MEMBER(keepalive)
IPC_STRUCT_TRAITS_MEMBER(has_user_gesture)
IPC_STRUCT_TRAITS_MEMBER(enable_load_timing)
IPC_STRUCT_TRAITS_MEMBER(enable_upload_progress)
IPC_STRUCT_TRAITS_MEMBER(do_not_prompt_for_login)
IPC_STRUCT_TRAITS_MEMBER(render_frame_id)
IPC_STRUCT_TRAITS_MEMBER(is_main_frame)
- IPC_STRUCT_TRAITS_MEMBER(parent_is_main_frame)
- IPC_STRUCT_TRAITS_MEMBER(parent_render_frame_id)
IPC_STRUCT_TRAITS_MEMBER(transition_type)
IPC_STRUCT_TRAITS_MEMBER(should_replace_current_entry)
IPC_STRUCT_TRAITS_MEMBER(transferred_request_child_id)
@@ -415,3 +408,5 @@ IPC_MESSAGE_CONTROL3(ResourceHostMsg_DidChangePriority,
int /* request_id */,
net::RequestPriority,
int /* intra_priority_value */)
+
+#endif // CONTENT_COMMON_RESOURCE_MESSAGES_H_
diff --git a/chromium/content/common/sandbox_init_mac.cc b/chromium/content/common/sandbox_init_mac.cc
index 76b33bbc122..dca966f166e 100644
--- a/chromium/content/common/sandbox_init_mac.cc
+++ b/chromium/content/common/sandbox_init_mac.cc
@@ -8,34 +8,61 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/logging.h"
-#include "content/common/sandbox_mac.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/sandbox_init.h"
-#include "content/public/common/sandbox_type.h"
+#include "media/gpu/vt_video_decode_accelerator_mac.h"
#include "sandbox/mac/seatbelt.h"
+#include "services/service_manager/sandbox/mac/sandbox_mac.h"
+#include "services/service_manager/sandbox/sandbox_type.h"
+#include "ui/gl/init/gl_factory.h"
namespace content {
namespace {
-bool InitializeSandbox(int sandbox_type,
- const base::FilePath& allowed_dir,
- base::OnceClosure hook) {
+// NOTE: This function is the exact code for the entry point of mac sandbox
+// once it moves to service_manager/sandbox.
+bool InitializeSandboxInternal(service_manager::SandboxType sandbox_type,
+ const base::FilePath& allowed_dir,
+ base::OnceClosure hook) {
// Warm up APIs before turning on the sandbox.
- Sandbox::SandboxWarmup(sandbox_type);
+ service_manager::Sandbox::SandboxWarmup(sandbox_type);
// Execute the post warmup callback.
if (!hook.is_null())
std::move(hook).Run();
// Actually sandbox the process.
- return Sandbox::EnableSandbox(sandbox_type, allowed_dir);
+ return service_manager::Sandbox::EnableSandbox(sandbox_type, allowed_dir);
+}
+
+// Helper method to make a closure from a closure.
+base::OnceClosure MaybeWrapWithGPUSandboxHook(
+ service_manager::SandboxType sandbox_type,
+ base::OnceClosure original) {
+ if (sandbox_type != service_manager::SANDBOX_TYPE_GPU)
+ return original;
+
+ return base::Bind(
+ [](base::OnceClosure arg) {
+ // Preload either the desktop GL or the osmesa so, depending on the
+ // --use-gl flag.
+ gl::init::InitializeGLOneOff();
+
+ // Preload VideoToolbox.
+ media::InitializeVideoToolbox();
+
+ // Invoke original hook.
+ if (!arg.is_null())
+ std::move(arg).Run();
+ },
+ base::Passed(std::move(original)));
}
// Fill in |sandbox_type| and |allowed_dir| based on the command line, returns
// false if the current process type doesn't need to be sandboxed or if the
// sandbox was disabled from the command line.
-bool GetSandboxInfoFromCommandLine(int* sandbox_type,
+bool GetSandboxInfoFromCommandLine(service_manager::SandboxType* sandbox_type,
base::FilePath* allowed_dir) {
DCHECK(sandbox_type);
DCHECK(allowed_dir);
@@ -49,8 +76,8 @@ bool GetSandboxInfoFromCommandLine(int* sandbox_type,
command_line->GetSwitchValuePath(switches::kUtilityProcessAllowedDir);
}
- *sandbox_type = SandboxTypeFromCommandLine(*command_line);
- if (*sandbox_type == SANDBOX_TYPE_NO_SANDBOX)
+ *sandbox_type = service_manager::SandboxTypeFromCommandLine(*command_line);
+ if (service_manager::IsUnsandboxedSandboxType(*sandbox_type))
return false;
if (command_line->HasSwitch(switches::kV2SandboxedEnabled)) {
@@ -59,20 +86,26 @@ bool GetSandboxInfoFromCommandLine(int* sandbox_type,
return false;
}
- return *sandbox_type != SANDBOX_TYPE_INVALID;
+ return *sandbox_type != service_manager::SANDBOX_TYPE_INVALID;
}
} // namespace
-bool InitializeSandbox(int sandbox_type, const base::FilePath& allowed_dir) {
- return InitializeSandbox(sandbox_type, allowed_dir, base::OnceClosure());
+bool InitializeSandbox(service_manager::SandboxType sandbox_type,
+ const base::FilePath& allowed_dir) {
+ return InitializeSandboxInternal(
+ sandbox_type, allowed_dir,
+ MaybeWrapWithGPUSandboxHook(sandbox_type, base::OnceClosure()));
}
bool InitializeSandboxWithPostWarmupHook(base::OnceClosure hook) {
- int sandbox_type = 0;
+ service_manager::SandboxType sandbox_type =
+ service_manager::SANDBOX_TYPE_INVALID;
base::FilePath allowed_dir;
return !GetSandboxInfoFromCommandLine(&sandbox_type, &allowed_dir) ||
- InitializeSandbox(sandbox_type, allowed_dir, std::move(hook));
+ InitializeSandboxInternal(
+ sandbox_type, allowed_dir,
+ MaybeWrapWithGPUSandboxHook(sandbox_type, std::move(hook)));
}
bool InitializeSandbox() {
diff --git a/chromium/content/common/sandbox_init_win.cc b/chromium/content/common/sandbox_init_win.cc
index c234d9e6bdc..fe3ca8cbe78 100644
--- a/chromium/content/common/sandbox_init_win.cc
+++ b/chromium/content/common/sandbox_init_win.cc
@@ -4,18 +4,16 @@
#include "content/public/common/sandbox_init.h"
-#include "base/command_line.h"
#include "base/logging.h"
#include "content/common/sandbox_win.h"
-#include "content/public/common/content_switches.h"
#include "sandbox/win/src/sandbox.h"
#include "sandbox/win/src/sandbox_types.h"
+#include "services/service_manager/sandbox/sandbox_type.h"
namespace content {
-bool InitializeSandbox(sandbox::SandboxInterfaceInfo* sandbox_info) {
- const base::CommandLine& command_line =
- *base::CommandLine::ForCurrentProcess();
+bool InitializeSandbox(service_manager::SandboxType sandbox_type,
+ sandbox::SandboxInterfaceInfo* sandbox_info) {
sandbox::BrokerServices* broker_services = sandbox_info->broker_services;
if (broker_services) {
if (!InitBrokerServices(broker_services))
@@ -25,7 +23,7 @@ bool InitializeSandbox(sandbox::SandboxInterfaceInfo* sandbox_info) {
// process because it will initialize the sandbox broker, which requires the
// process to swap its window station. During this time all the UI will be
// broken. This has to run before threads and windows are created.
- if (!command_line.HasSwitch(switches::kNoSandbox)) {
+ if (!service_manager::IsUnsandboxedSandboxType(sandbox_type)) {
// Precreate the desktop and window station used by the renderers.
scoped_refptr<sandbox::TargetPolicy> policy =
broker_services->CreatePolicy();
@@ -35,11 +33,8 @@ bool InitializeSandbox(sandbox::SandboxInterfaceInfo* sandbox_info) {
return true;
}
- if (command_line.HasSwitch(switches::kNoSandbox))
- return true;
-
- sandbox::TargetServices* target_services = sandbox_info->target_services;
- return InitTargetServices(target_services);
+ return service_manager::IsUnsandboxedSandboxType(sandbox_type) ||
+ InitTargetServices(sandbox_info->target_services);
}
} // namespace content
diff --git a/chromium/content/common/sandbox_linux/bpf_cdm_policy_linux.cc b/chromium/content/common/sandbox_linux/bpf_cdm_policy_linux.cc
new file mode 100644
index 00000000000..7b61c7fea3e
--- /dev/null
+++ b/chromium/content/common/sandbox_linux/bpf_cdm_policy_linux.cc
@@ -0,0 +1,55 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/sandbox_linux/bpf_cdm_policy_linux.h"
+
+#include <errno.h>
+
+#include "build/build_config.h"
+#include "content/common/sandbox_linux/sandbox_linux.h"
+#include "sandbox/linux/bpf_dsl/bpf_dsl.h"
+#include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h"
+#include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h"
+#include "sandbox/linux/system_headers/linux_syscalls.h"
+
+using sandbox::SyscallSets;
+using sandbox::bpf_dsl::Allow;
+using sandbox::bpf_dsl::Error;
+using sandbox::bpf_dsl::ResultExpr;
+
+namespace content {
+
+CdmProcessPolicy::CdmProcessPolicy() {}
+CdmProcessPolicy::~CdmProcessPolicy() {}
+
+ResultExpr CdmProcessPolicy::EvaluateSyscall(int sysno) const {
+ switch (sysno) {
+ case __NR_ioctl:
+ return sandbox::RestrictIoctl();
+ // Allow the system calls below.
+ case __NR_fdatasync:
+ case __NR_fsync:
+#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
+ defined(__aarch64__)
+ case __NR_getrlimit:
+#endif
+#if defined(__i386__) || defined(__arm__)
+ case __NR_ugetrlimit:
+#endif
+ case __NR_mremap: // https://crbug.com/546204
+ case __NR_pread64:
+ case __NR_pwrite64:
+ case __NR_sysinfo:
+ case __NR_times:
+ case __NR_uname:
+ return Allow();
+ case __NR_sched_getaffinity:
+ return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno);
+ default:
+ // Default on the content baseline policy.
+ return SandboxBPFBasePolicy::EvaluateSyscall(sysno);
+ }
+}
+
+} // namespace content
diff --git a/chromium/content/common/sandbox_linux/bpf_cdm_policy_linux.h b/chromium/content/common/sandbox_linux/bpf_cdm_policy_linux.h
new file mode 100644
index 00000000000..8b98f02ce27
--- /dev/null
+++ b/chromium/content/common/sandbox_linux/bpf_cdm_policy_linux.h
@@ -0,0 +1,28 @@
+// Copyright 2017 The Chromium 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 CONTENT_COMMON_SANDBOX_LINUX_BPF_CDM_POLICY_LINUX_H_
+#define CONTENT_COMMON_SANDBOX_LINUX_BPF_CDM_POLICY_LINUX_H_
+
+#include "base/macros.h"
+#include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h"
+
+namespace content {
+
+// This policy can be used by the process hosting a Content Decryption Module.
+class CdmProcessPolicy : public SandboxBPFBasePolicy {
+ public:
+ CdmProcessPolicy();
+ ~CdmProcessPolicy() override;
+
+ sandbox::bpf_dsl::ResultExpr EvaluateSyscall(
+ int system_call_number) const override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CdmProcessPolicy);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_SANDBOX_LINUX_BPF_CDM_POLICY_LINUX_H_
diff --git a/chromium/content/common/sandbox_linux/bpf_cros_amd_gpu_policy_linux.cc b/chromium/content/common/sandbox_linux/bpf_cros_amd_gpu_policy_linux.cc
new file mode 100644
index 00000000000..a72d87e27b9
--- /dev/null
+++ b/chromium/content/common/sandbox_linux/bpf_cros_amd_gpu_policy_linux.cc
@@ -0,0 +1,171 @@
+// Copyright (c) 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/sandbox_linux/bpf_cros_amd_gpu_policy_linux.h"
+
+#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "base/logging.h"
+#include "sandbox/linux/bpf_dsl/bpf_dsl.h"
+#include "sandbox/linux/syscall_broker/broker_file_permission.h"
+#include "sandbox/linux/system_headers/linux_syscalls.h"
+
+using sandbox::bpf_dsl::Allow;
+using sandbox::bpf_dsl::Arg;
+using sandbox::bpf_dsl::Error;
+using sandbox::bpf_dsl::If;
+using sandbox::bpf_dsl::ResultExpr;
+using sandbox::syscall_broker::BrokerFilePermission;
+
+namespace content {
+
+namespace {
+
+inline bool IsChromeOS() {
+#if defined(OS_CHROMEOS)
+ return true;
+#else
+ return false;
+#endif
+}
+
+void AddAmdGpuWhitelist(std::vector<BrokerFilePermission>* permissions) {
+ static const char* kReadOnlyList[] = {"/etc/ld.so.cache",
+ "/usr/lib64/libEGL.so.1",
+ "/usr/lib64/libGLESv2.so.2"};
+ int listSize = arraysize(kReadOnlyList);
+
+ for (int i = 0; i < listSize; i++) {
+ permissions->push_back(BrokerFilePermission::ReadOnly(kReadOnlyList[i]));
+ }
+
+ static const char* kReadWriteList[] = {
+ "/dev/dri",
+ "/dev/dri/card0",
+ "/dev/dri/controlD64",
+ "/dev/dri/renderD128",
+ "/sys/class/drm/card0/device/config",
+ "/sys/class/drm/controlD64/device/config",
+ "/sys/class/drm/renderD128/device/config",
+ "/usr/share/libdrm/amdgpu.ids"};
+
+ listSize = arraysize(kReadWriteList);
+
+ for (int i = 0; i < listSize; i++) {
+ permissions->push_back(BrokerFilePermission::ReadWrite(kReadWriteList[i]));
+ }
+
+ static const char kCharDevices[] = "/sys/dev/char/";
+ permissions->push_back(BrokerFilePermission::ReadOnlyRecursive(kCharDevices));
+}
+
+class CrosAmdGpuBrokerProcessPolicy : public CrosAmdGpuProcessPolicy {
+ public:
+ static sandbox::bpf_dsl::Policy* Create() {
+ return new CrosAmdGpuBrokerProcessPolicy();
+ }
+ ~CrosAmdGpuBrokerProcessPolicy() override {}
+
+ ResultExpr EvaluateSyscall(int system_call_number) const override;
+
+ private:
+ CrosAmdGpuBrokerProcessPolicy() {}
+ DISALLOW_COPY_AND_ASSIGN(CrosAmdGpuBrokerProcessPolicy);
+};
+
+// A GPU broker policy is the same as a GPU policy with access, open,
+// openat and in the non-Chrome OS case unlink allowed.
+ResultExpr CrosAmdGpuBrokerProcessPolicy::EvaluateSyscall(int sysno) const {
+ switch (sysno) {
+ case __NR_faccessat:
+ case __NR_openat:
+#if !defined(__aarch64__)
+ case __NR_access:
+ case __NR_open:
+#if !defined(OS_CHROMEOS)
+ // The broker process needs to able to unlink the temporary
+ // files that it may create. This is used by DRI3.
+ case __NR_unlink:
+#endif // !defined(OS_CHROMEOS)
+#endif // !define(__aarch64__)
+ return Allow();
+ default:
+ return CrosAmdGpuProcessPolicy::EvaluateSyscall(sysno);
+ }
+}
+
+} // namespace
+
+CrosAmdGpuProcessPolicy::CrosAmdGpuProcessPolicy() {}
+
+CrosAmdGpuProcessPolicy::~CrosAmdGpuProcessPolicy() {}
+
+ResultExpr CrosAmdGpuProcessPolicy::EvaluateSyscall(int sysno) const {
+ switch (sysno) {
+ case __NR_fstatfs:
+ case __NR_sched_setscheduler:
+ case __NR_sysinfo:
+ case __NR_uname:
+#if !defined(__aarch64__)
+ case __NR_getdents:
+ case __NR_readlink:
+ case __NR_stat:
+#endif
+ return Allow();
+#if defined(__x86_64__)
+ // Allow only AF_UNIX for |domain|.
+ case __NR_socket:
+ case __NR_socketpair: {
+ const Arg<int> domain(0);
+ return If(domain == AF_UNIX, Allow()).Else(Error(EPERM));
+ }
+#endif
+ default:
+ // Default to the generic GPU policy.
+ return GpuProcessPolicy::EvaluateSyscall(sysno);
+ }
+}
+
+bool CrosAmdGpuProcessPolicy::PreSandboxHook() {
+ DCHECK(IsChromeOS());
+ // Create a new broker process.
+ DCHECK(!broker_process());
+
+ // Add AMD-specific files to whitelist in the broker.
+ std::vector<BrokerFilePermission> permissions;
+
+ AddAmdGpuWhitelist(&permissions);
+ InitGpuBrokerProcess(CrosAmdGpuBrokerProcessPolicy::Create, permissions);
+
+ const int dlopen_flag = RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE;
+
+ // Preload the amdgpu-dependent libraries.
+ errno = 0;
+ if (NULL == dlopen("libglapi.so", dlopen_flag)) {
+ LOG(ERROR) << "dlopen(libglapi.so) failed with error: " << dlerror();
+ return false;
+ }
+ if (NULL == dlopen("/usr/lib64/dri/swrast_dri.so", dlopen_flag)) {
+ LOG(ERROR) << "dlopen(swrast_dri.so) failed with error: " << dlerror();
+ return false;
+ }
+ if (NULL == dlopen("/usr/lib64/dri/radeonsi_dri.so", dlopen_flag)) {
+ LOG(ERROR) << "dlopen(radeonsi_dri.so) failed with error: " << dlerror();
+ return false;
+ }
+
+ return true;
+}
+
+} // namespace content
diff --git a/chromium/content/common/sandbox_linux/bpf_cros_amd_gpu_policy_linux.h b/chromium/content/common/sandbox_linux/bpf_cros_amd_gpu_policy_linux.h
new file mode 100644
index 00000000000..aed3a241fe0
--- /dev/null
+++ b/chromium/content/common/sandbox_linux/bpf_cros_amd_gpu_policy_linux.h
@@ -0,0 +1,29 @@
+// Copyright 2017 The Chromium 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 CONTENT_COMMON_SANDBOX_LINUX_BPF_CROS_AMD_GPU_POLICY_LINUX_H_
+#define CONTENT_COMMON_SANDBOX_LINUX_BPF_CROS_AMD_GPU_POLICY_LINUX_H_
+
+#include "base/macros.h"
+#include "content/common/sandbox_linux/bpf_gpu_policy_linux.h"
+
+namespace content {
+
+// This policy is for AMD GPUs running on Chrome OS.
+class CrosAmdGpuProcessPolicy : public GpuProcessPolicy {
+ public:
+ CrosAmdGpuProcessPolicy();
+ ~CrosAmdGpuProcessPolicy() override;
+
+ sandbox::bpf_dsl::ResultExpr EvaluateSyscall(
+ int system_call_number) const override;
+ bool PreSandboxHook() override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(CrosAmdGpuProcessPolicy);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_SANDBOX_LINUX_BPF_CROS_AMD_GPU_POLICY_LINUX_H_
diff --git a/chromium/content/common/sandbox_linux/bpf_pdf_compositor_policy_linux.cc b/chromium/content/common/sandbox_linux/bpf_pdf_compositor_policy_linux.cc
new file mode 100644
index 00000000000..88f28d12017
--- /dev/null
+++ b/chromium/content/common/sandbox_linux/bpf_pdf_compositor_policy_linux.cc
@@ -0,0 +1,55 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/sandbox_linux/bpf_pdf_compositor_policy_linux.h"
+
+#include <errno.h>
+
+#include "build/build_config.h"
+#include "content/common/sandbox_linux/sandbox_linux.h"
+#include "sandbox/linux/bpf_dsl/bpf_dsl.h"
+#include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h"
+#include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h"
+#include "sandbox/linux/system_headers/linux_syscalls.h"
+
+using sandbox::SyscallSets;
+using sandbox::bpf_dsl::Allow;
+using sandbox::bpf_dsl::Error;
+using sandbox::bpf_dsl::ResultExpr;
+
+namespace content {
+
+PdfCompositorProcessPolicy::PdfCompositorProcessPolicy() {}
+PdfCompositorProcessPolicy::~PdfCompositorProcessPolicy() {}
+
+ResultExpr PdfCompositorProcessPolicy::EvaluateSyscall(int sysno) const {
+ // TODO(weili): the current set of policy is exactly same as utility process
+ // policy. Check whether we can trim further.
+ switch (sysno) {
+ case __NR_ioctl:
+ return sandbox::RestrictIoctl();
+ // Allow the system calls below.
+ case __NR_fdatasync:
+ case __NR_fsync:
+#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
+ defined(__aarch64__)
+ case __NR_getrlimit:
+#endif
+#if defined(__i386__) || defined(__arm__)
+ case __NR_ugetrlimit:
+#endif
+ case __NR_mremap: // https://crbug.com/546204
+ case __NR_pread64:
+ case __NR_pwrite64:
+ case __NR_sysinfo:
+ case __NR_times:
+ case __NR_uname:
+ return Allow();
+ default:
+ // Default on the content baseline policy.
+ return SandboxBPFBasePolicy::EvaluateSyscall(sysno);
+ }
+}
+
+} // namespace content
diff --git a/chromium/content/common/sandbox_linux/bpf_pdf_compositor_policy_linux.h b/chromium/content/common/sandbox_linux/bpf_pdf_compositor_policy_linux.h
new file mode 100644
index 00000000000..02b9ead7e02
--- /dev/null
+++ b/chromium/content/common/sandbox_linux/bpf_pdf_compositor_policy_linux.h
@@ -0,0 +1,28 @@
+// Copyright 2017 The Chromium 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 CONTENT_COMMON_SANDBOX_LINUX_BPF_PDF_COMPOSITOR_POLICY_LINUX_H_
+#define CONTENT_COMMON_SANDBOX_LINUX_BPF_PDF_COMPOSITOR_POLICY_LINUX_H_
+
+#include "base/macros.h"
+#include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h"
+
+namespace content {
+
+// This policy can be used by pdf compositor utility processes.
+class PdfCompositorProcessPolicy : public SandboxBPFBasePolicy {
+ public:
+ PdfCompositorProcessPolicy();
+ ~PdfCompositorProcessPolicy() override;
+
+ sandbox::bpf_dsl::ResultExpr EvaluateSyscall(
+ int system_call_number) const override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(PdfCompositorProcessPolicy);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_SANDBOX_LINUX_BPF_PDF_COMPOSITOR_POLICY_LINUX_H_
diff --git a/chromium/content/common/sandbox_linux/bpf_renderer_policy_linux.cc b/chromium/content/common/sandbox_linux/bpf_renderer_policy_linux.cc
index 5f76e35b663..c2b7e823b05 100644
--- a/chromium/content/common/sandbox_linux/bpf_renderer_policy_linux.cc
+++ b/chromium/content/common/sandbox_linux/bpf_renderer_policy_linux.cc
@@ -100,8 +100,8 @@ ResultExpr RendererProcessPolicy::EvaluateSyscall(int sysno) const {
case __NR_sched_setscheduler:
return sandbox::RestrictSchedTarget(GetPolicyPid(), sysno);
case __NR_prlimit64:
- // See crbug.com/662450.
- return sandbox::RestrictPrlimitToGetrlimit(GetPolicyPid());
+ // See crbug.com/662450 and setrlimit comment above.
+ return sandbox::RestrictPrlimit(GetPolicyPid());
default:
// Default on the content baseline policy.
return SandboxBPFBasePolicy::EvaluateSyscall(sysno);
diff --git a/chromium/content/common/sandbox_linux/sandbox_linux.cc b/chromium/content/common/sandbox_linux/sandbox_linux.cc
index a6be233bd80..420a72e481c 100644
--- a/chromium/content/common/sandbox_linux/sandbox_linux.cc
+++ b/chromium/content/common/sandbox_linux/sandbox_linux.cc
@@ -37,7 +37,7 @@
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/sandbox_linux.h"
-#include "content/public/common/sandbox_type.h"
+#include "gpu/config/gpu_info.h"
#include "sandbox/linux/services/credentials.h"
#include "sandbox/linux/services/namespace_sandbox.h"
#include "sandbox/linux/services/proc_util.h"
@@ -45,6 +45,8 @@
#include "sandbox/linux/services/thread_helpers.h"
#include "sandbox/linux/services/yama.h"
#include "sandbox/linux/suid/client/setuid_sandbox_client.h"
+#include "services/service_manager/sandbox/sandbox_type.h"
+#include "third_party/angle/src/gpu_info_util/SystemInfo.h"
#if defined(ANY_OF_AMTLU_SANITIZER)
#include <sanitizer/common_interface_defs.h>
@@ -200,9 +202,9 @@ std::vector<int> LinuxSandbox::GetFileDescriptorsToClose() {
return fds;
}
-bool LinuxSandbox::InitializeSandbox() {
+bool LinuxSandbox::InitializeSandbox(const gpu::GPUInfo* gpu_info) {
LinuxSandbox* linux_sandbox = LinuxSandbox::GetInstance();
- return linux_sandbox->InitializeSandboxImpl();
+ return linux_sandbox->InitializeSandboxImpl(gpu_info);
}
void LinuxSandbox::StopThread(base::Thread* thread) {
@@ -233,13 +235,11 @@ int LinuxSandbox::GetStatus() {
// We report whether the sandbox will be activated when renderers, workers
// and PPAPI plugins go through sandbox initialization.
- if (seccomp_bpf_supported() &&
- SandboxSeccompBPF::ShouldEnableSeccompBPF(switches::kRendererProcess)) {
+ if (seccomp_bpf_supported()) {
sandbox_status_flags_ |= kSandboxLinuxSeccompBPF;
}
- if (seccomp_bpf_with_tsync_supported() &&
- SandboxSeccompBPF::ShouldEnableSeccompBPF(switches::kRendererProcess)) {
+ if (seccomp_bpf_with_tsync_supported()) {
sandbox_status_flags_ |= kSandboxLinuxSeccompTSYNC;
}
@@ -276,28 +276,33 @@ sandbox::SetuidSandboxClient*
}
// For seccomp-bpf, we use the SandboxSeccompBPF class.
-bool LinuxSandbox::StartSeccompBPF(const std::string& process_type) {
+bool LinuxSandbox::StartSeccompBPF(service_manager::SandboxType sandbox_type,
+ const gpu::GPUInfo* gpu_info) {
CHECK(!seccomp_bpf_started_);
CHECK(pre_initialized_);
- if (seccomp_bpf_supported()) {
- seccomp_bpf_started_ =
- SandboxSeccompBPF::StartSandbox(process_type, OpenProc(proc_fd_));
- }
+ if (!seccomp_bpf_supported())
+ return false;
- if (seccomp_bpf_started_) {
- LogSandboxStarted("seccomp-bpf");
- }
+ SandboxSeccompBPF::Options opts;
+ opts.use_amd_specific_policies =
+ gpu_info && angle::IsAMD(gpu_info->active_gpu().vendor_id);
+ if (!SandboxSeccompBPF::StartSandbox(sandbox_type, OpenProc(proc_fd_), opts))
+ return false;
- return seccomp_bpf_started_;
+ seccomp_bpf_started_ = true;
+ LogSandboxStarted("seccomp-bpf");
+ return true;
}
-bool LinuxSandbox::InitializeSandboxImpl() {
+bool LinuxSandbox::InitializeSandboxImpl(const gpu::GPUInfo* gpu_info) {
DCHECK(!initialize_sandbox_ran_);
initialize_sandbox_ran_ = true;
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
const std::string process_type =
command_line->GetSwitchValueASCII(switches::kProcessType);
+ service_manager::SandboxType sandbox_type =
+ service_manager::SandboxTypeFromCommandLine(*command_line);
// We need to make absolutely sure that our sandbox is "sealed" before
// returning.
@@ -308,7 +313,7 @@ bool LinuxSandbox::InitializeSandboxImpl() {
// Unretained() since the current object is a Singleton.
base::ScopedClosureRunner sandbox_promise_keeper(
base::BindOnce(&LinuxSandbox::CheckForBrokenPromises,
- base::Unretained(this), process_type));
+ base::Unretained(this), sandbox_type));
// No matter what, it's always an error to call InitializeSandbox() after
// threads have been created.
@@ -359,7 +364,7 @@ bool LinuxSandbox::InitializeSandboxImpl() {
LimitAddressSpace(process_type);
// Try to enable seccomp-bpf.
- bool seccomp_bpf_started = StartSeccompBPF(process_type);
+ bool seccomp_bpf_started = StartSeccompBPF(sandbox_type, gpu_info);
return seccomp_bpf_started;
}
@@ -383,9 +388,10 @@ bool LinuxSandbox::LimitAddressSpace(const std::string& process_type) {
(void) process_type;
#if !defined(ANY_OF_AMTLU_SANITIZER)
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
- if (SandboxTypeFromCommandLine(*command_line) == SANDBOX_TYPE_NO_SANDBOX)
+ if (service_manager::SandboxTypeFromCommandLine(*command_line) ==
+ service_manager::SANDBOX_TYPE_NO_SANDBOX) {
return false;
-
+ }
// Limit the address space to 4GB.
// This is in the hope of making some kernel exploits more complex and less
// reliable. It also limits sprays a little on 64 bits.
@@ -460,18 +466,17 @@ void LinuxSandbox::SealSandbox() {
}
}
-void LinuxSandbox::CheckForBrokenPromises(const std::string& process_type) {
- // Make sure that any promise made with GetStatus() wasn't broken.
- bool promised_seccomp_bpf_would_start = false;
- if (process_type == switches::kRendererProcess ||
- process_type == switches::kPpapiPluginProcess) {
- promised_seccomp_bpf_would_start =
- (sandbox_status_flags_ != kSandboxLinuxInvalid) &&
- (GetStatus() & kSandboxLinuxSeccompBPF);
- }
- if (promised_seccomp_bpf_would_start) {
- CHECK(seccomp_bpf_started_);
+void LinuxSandbox::CheckForBrokenPromises(
+ service_manager::SandboxType sandbox_type) {
+ if (sandbox_type != service_manager::SANDBOX_TYPE_RENDERER &&
+ sandbox_type != service_manager::SANDBOX_TYPE_PPAPI) {
+ return;
}
+ // Make sure that any promise made with GetStatus() wasn't broken.
+ bool promised_seccomp_bpf_would_start =
+ (sandbox_status_flags_ != kSandboxLinuxInvalid) &&
+ (GetStatus() & kSandboxLinuxSeccompBPF);
+ CHECK(!promised_seccomp_bpf_would_start || seccomp_bpf_started_);
}
void LinuxSandbox::StopThreadAndEnsureNotCounted(base::Thread* thread) const {
diff --git a/chromium/content/common/sandbox_linux/sandbox_linux.h b/chromium/content/common/sandbox_linux/sandbox_linux.h
index 6b155621190..684075c3bd7 100644
--- a/chromium/content/common/sandbox_linux/sandbox_linux.h
+++ b/chromium/content/common/sandbox_linux/sandbox_linux.h
@@ -14,6 +14,8 @@
#include "base/posix/global_descriptors.h"
#include "content/public/common/content_descriptors.h"
#include "content/public/common/sandbox_linux.h"
+#include "gpu/config/gpu_info.h"
+#include "services/service_manager/sandbox/sandbox_type.h"
#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
defined(THREAD_SANITIZER) || defined(LEAK_SANITIZER) || \
@@ -93,7 +95,7 @@ class LinuxSandbox {
// limitations. This will instantiate the LinuxSandbox singleton if it
// doesn't already exist.
// This function should only be called without any thread running.
- static bool InitializeSandbox();
+ static bool InitializeSandbox(const gpu::GPUInfo* gpu_info = NULL);
// Stop |thread| in a way that can be trusted by the sandbox.
static void StopThread(base::Thread* thread);
@@ -120,7 +122,8 @@ class LinuxSandbox {
// Check the policy and eventually start the seccomp-bpf sandbox. This should
// never be called with threads started. If we detect that threads have
// started we will crash.
- bool StartSeccompBPF(const std::string& process_type);
+ bool StartSeccompBPF(service_manager::SandboxType sandbox_type,
+ const gpu::GPUInfo* gpu_info);
// Limit the address space of the current process (and its children).
// to make some vulnerabilities harder to exploit.
@@ -147,7 +150,7 @@ class LinuxSandbox {
// Some methods are static and get an instance of the Singleton. These
// are the non-static implementations.
- bool InitializeSandboxImpl();
+ bool InitializeSandboxImpl(const gpu::GPUInfo* gpu_info);
void StopThreadImpl(base::Thread* thread);
// We must have been pre_initialized_ before using these.
bool seccomp_bpf_supported() const;
@@ -161,7 +164,7 @@ class LinuxSandbox {
void SealSandbox();
// GetStatus() makes promises as to how the sandbox will behave. This
// checks that no promises have been broken.
- void CheckForBrokenPromises(const std::string& process_type);
+ void CheckForBrokenPromises(service_manager::SandboxType sandbox_type);
// Stop |thread| and make sure it does not appear in /proc/self/tasks/
// anymore.
void StopThreadAndEnsureNotCounted(base::Thread* thread) const;
diff --git a/chromium/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.cc b/chromium/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.cc
index 9b27f9497f7..f8e866e1540 100644
--- a/chromium/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.cc
+++ b/chromium/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.cc
@@ -19,13 +19,17 @@
#include "content/public/common/content_switches.h"
#include "sandbox/linux/bpf_dsl/bpf_dsl.h"
#include "sandbox/sandbox_features.h"
+#include "services/service_manager/sandbox/sandbox_type.h"
#if BUILDFLAG(USE_SECCOMP_BPF)
#include "base/files/scoped_file.h"
#include "base/posix/eintr_wrapper.h"
+#include "content/common/sandbox_linux/bpf_cdm_policy_linux.h"
+#include "content/common/sandbox_linux/bpf_cros_amd_gpu_policy_linux.h"
#include "content/common/sandbox_linux/bpf_cros_arm_gpu_policy_linux.h"
#include "content/common/sandbox_linux/bpf_gpu_policy_linux.h"
+#include "content/common/sandbox_linux/bpf_pdf_compositor_policy_linux.h"
#include "content/common/sandbox_linux/bpf_ppapi_policy_linux.h"
#include "content/common/sandbox_linux/bpf_renderer_policy_linux.h"
#include "content/common/sandbox_linux/bpf_utility_policy_linux.h"
@@ -43,15 +47,15 @@ using sandbox::SyscallSets;
using sandbox::bpf_dsl::Allow;
using sandbox::bpf_dsl::ResultExpr;
-#else
+#else // BUILDFLAG(USE_SECCOMP_BPF)
// Make sure that seccomp-bpf does not get disabled by mistake. Also make sure
// that we think twice about this when adding a new architecture.
-#if !defined(ARCH_CPU_ARM64)
+#if !defined(ARCH_CPU_ARM64) && !defined(ARCH_CPU_MIPS64EL)
#error "Seccomp-bpf disabled on supported architecture!"
-#endif // !defined(ARCH_CPU_ARM64)
+#endif // !defined(ARCH_CPU_ARM64) && !defined(ARCH_CPU_MIPS64EL)
-#endif //
+#endif // BUILDFLAG(USE_SECCOMP_BPF)
namespace content {
@@ -59,15 +63,14 @@ namespace content {
namespace {
// This function takes ownership of |policy|.
-void StartSandboxWithPolicy(sandbox::bpf_dsl::Policy* policy,
+void StartSandboxWithPolicy(std::unique_ptr<sandbox::bpf_dsl::Policy> policy,
base::ScopedFD proc_fd) {
// Starting the sandbox is a one-way operation. The kernel doesn't allow
// us to unload a sandbox policy after it has been started. Nonetheless,
// in order to make the use of the "Sandbox" object easier, we allow for
// the object to be destroyed after the sandbox has been started. Note that
// doing so does not stop the sandbox.
- SandboxBPF sandbox(policy);
-
+ SandboxBPF sandbox(std::move(policy));
sandbox.SetProcFd(std::move(proc_fd));
CHECK(sandbox.StartSandbox(SandboxBPF::SeccompLevel::SINGLE_THREADED));
}
@@ -130,78 +133,91 @@ inline bool IsArchitectureArm() {
}
// If a BPF policy is engaged for |process_type|, run a few sanity checks.
-void RunSandboxSanityChecks(const std::string& process_type) {
- if (process_type == switches::kRendererProcess ||
- process_type == switches::kGpuProcess ||
- process_type == switches::kPpapiPluginProcess) {
- int syscall_ret;
- errno = 0;
-
- // Without the sandbox, this would EBADF.
- syscall_ret = fchmod(-1, 07777);
- CHECK_EQ(-1, syscall_ret);
- CHECK_EQ(EPERM, errno);
-
- // Run most of the sanity checks only in DEBUG mode to avoid a perf.
- // impact.
+void RunSandboxSanityChecks(service_manager::SandboxType sandbox_type) {
+ switch (sandbox_type) {
+ case service_manager::SANDBOX_TYPE_RENDERER:
+ case service_manager::SANDBOX_TYPE_GPU:
+ case service_manager::SANDBOX_TYPE_PPAPI:
+ case service_manager::SANDBOX_TYPE_PDF_COMPOSITOR:
+ case service_manager::SANDBOX_TYPE_CDM: {
+ int syscall_ret;
+ errno = 0;
+
+ // Without the sandbox, this would EBADF.
+ syscall_ret = fchmod(-1, 07777);
+ CHECK_EQ(-1, syscall_ret);
+ CHECK_EQ(EPERM, errno);
+
+// Run most of the sanity checks only in DEBUG mode to avoid a perf.
+// impact.
#if !defined(NDEBUG)
- // open() must be restricted.
- syscall_ret = open("/etc/passwd", O_RDONLY);
- CHECK_EQ(-1, syscall_ret);
- CHECK_EQ(SandboxBPFBasePolicy::GetFSDeniedErrno(), errno);
-
- // We should never allow the creation of netlink sockets.
- syscall_ret = socket(AF_NETLINK, SOCK_DGRAM, 0);
- CHECK_EQ(-1, syscall_ret);
- CHECK_EQ(EPERM, errno);
+ // open() must be restricted.
+ syscall_ret = open("/etc/passwd", O_RDONLY);
+ CHECK_EQ(-1, syscall_ret);
+ CHECK_EQ(SandboxBPFBasePolicy::GetFSDeniedErrno(), errno);
+
+ // We should never allow the creation of netlink sockets.
+ syscall_ret = socket(AF_NETLINK, SOCK_DGRAM, 0);
+ CHECK_EQ(-1, syscall_ret);
+ CHECK_EQ(EPERM, errno);
#endif // !defined(NDEBUG)
+ } break;
+ default:
+ // Otherwise, no checks required.
+ break;
}
}
-std::unique_ptr<SandboxBPFBasePolicy> GetGpuProcessSandbox() {
- const base::CommandLine& command_line =
- *base::CommandLine::ForCurrentProcess();
- if (IsChromeOS() && IsArchitectureArm()) {
- bool allow_sysv_shm =
- command_line.HasSwitch(switches::kGpuSandboxAllowSysVShm);
- return std::unique_ptr<SandboxBPFBasePolicy>(
- new CrosArmGpuProcessPolicy(allow_sysv_shm));
- } else {
- return std::unique_ptr<SandboxBPFBasePolicy>(new GpuProcessPolicy());
+std::unique_ptr<SandboxBPFBasePolicy> GetGpuProcessSandbox(
+ bool use_amd_specific_policies) {
+ if (IsChromeOS()) {
+ if (IsArchitectureArm()) {
+ return std::make_unique<CrosArmGpuProcessPolicy>(
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kGpuSandboxAllowSysVShm));
+ }
+ if (use_amd_specific_policies)
+ return std::make_unique<CrosAmdGpuProcessPolicy>();
}
+ return std::make_unique<GpuProcessPolicy>();
}
// Initialize the seccomp-bpf sandbox.
-bool StartBPFSandbox(const base::CommandLine& command_line,
- const std::string& process_type,
- base::ScopedFD proc_fd) {
+bool StartBPFSandbox(service_manager::SandboxType sandbox_type,
+ base::ScopedFD proc_fd,
+ const SandboxSeccompBPF::Options& options) {
std::unique_ptr<SandboxBPFBasePolicy> policy;
-
- if (process_type == switches::kGpuProcess) {
- policy.reset(GetGpuProcessSandbox().release());
- } else if (process_type == switches::kRendererProcess) {
- policy.reset(new RendererProcessPolicy);
- } else if (process_type == switches::kPpapiPluginProcess) {
- policy.reset(new PpapiProcessPolicy);
- } else if (process_type == switches::kUtilityProcess) {
- policy.reset(new UtilityProcessPolicy);
- } else {
- NOTREACHED();
- policy.reset(new AllowAllPolicy);
+ switch (sandbox_type) {
+ case service_manager::SANDBOX_TYPE_GPU:
+ policy = GetGpuProcessSandbox(options.use_amd_specific_policies);
+ break;
+ case service_manager::SANDBOX_TYPE_RENDERER:
+ policy = std::make_unique<RendererProcessPolicy>();
+ break;
+ case service_manager::SANDBOX_TYPE_PPAPI:
+ policy = std::make_unique<PpapiProcessPolicy>();
+ break;
+ case service_manager::SANDBOX_TYPE_UTILITY:
+ case service_manager::SANDBOX_TYPE_PROFILING:
+ policy = std::make_unique<UtilityProcessPolicy>();
+ break;
+ case service_manager::SANDBOX_TYPE_CDM:
+ policy = std::make_unique<CdmProcessPolicy>();
+ break;
+ case service_manager::SANDBOX_TYPE_PDF_COMPOSITOR:
+ policy = std::make_unique<PdfCompositorProcessPolicy>();
+ break;
+ case service_manager::SANDBOX_TYPE_NO_SANDBOX:
+ default:
+ NOTREACHED();
+ policy = std::make_unique<AllowAllPolicy>();
+ break;
}
-
CHECK(policy->PreSandboxHook());
- StartSandboxWithPolicy(policy.release(), std::move(proc_fd));
-
- RunSandboxSanityChecks(process_type);
+ StartSandboxWithPolicy(std::move(policy), std::move(proc_fd));
+ RunSandboxSanityChecks(sandbox_type);
return true;
}
-#else // defined(IN_NACL_HELPER)
-bool StartBPFSandbox(const base::CommandLine& command_line,
- const std::string& process_type) {
- NOTREACHED();
- return false;
-}
#endif // !defined(IN_NACL_HELPER)
#endif // !defined(OS_NACL_NONSFI)
@@ -211,30 +227,14 @@ bool StartBPFSandbox(const base::CommandLine& command_line,
// Is seccomp BPF globally enabled?
bool SandboxSeccompBPF::IsSeccompBPFDesired() {
- const base::CommandLine& command_line =
- *base::CommandLine::ForCurrentProcess();
- if (!command_line.HasSwitch(switches::kNoSandbox) &&
- !command_line.HasSwitch(switches::kDisableSeccompFilterSandbox)) {
- return true;
- } else {
- return false;
- }
-}
-
-#if !defined(OS_NACL_NONSFI)
-bool SandboxSeccompBPF::ShouldEnableSeccompBPF(
- const std::string& process_type) {
#if BUILDFLAG(USE_SECCOMP_BPF)
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
- if (process_type == switches::kGpuProcess)
- return !command_line.HasSwitch(switches::kDisableGpuSandbox);
-
- return true;
+ return !command_line.HasSwitch(switches::kNoSandbox) &&
+ !command_line.HasSwitch(switches::kDisableSeccompFilterSandbox);
#endif // USE_SECCOMP_BPF
return false;
}
-#endif // !defined(OS_NACL_NONSFI)
bool SandboxSeccompBPF::SupportsSandbox() {
#if BUILDFLAG(USE_SECCOMP_BPF)
@@ -245,6 +245,7 @@ bool SandboxSeccompBPF::SupportsSandbox() {
}
#if !defined(OS_NACL_NONSFI)
+
bool SandboxSeccompBPF::SupportsSandboxWithTsync() {
#if BUILDFLAG(USE_SECCOMP_BPF)
return SandboxBPF::SupportsSeccompSandbox(
@@ -253,25 +254,22 @@ bool SandboxSeccompBPF::SupportsSandboxWithTsync() {
return false;
}
-bool SandboxSeccompBPF::StartSandbox(const std::string& process_type,
- base::ScopedFD proc_fd) {
+bool SandboxSeccompBPF::StartSandbox(service_manager::SandboxType sandbox_type,
+ base::ScopedFD proc_fd,
+ const Options& options) {
#if BUILDFLAG(USE_SECCOMP_BPF)
- const base::CommandLine& command_line =
- *base::CommandLine::ForCurrentProcess();
-
- if (IsSeccompBPFDesired() && // Global switches policy.
- ShouldEnableSeccompBPF(process_type) && // Process-specific policy.
+ if (!IsUnsandboxedSandboxType(sandbox_type) &&
+ IsSeccompBPFDesired() && // Global switches policy.
SupportsSandbox()) {
// If the kernel supports the sandbox, and if the command line says we
// should enable it, enable it or die.
- bool started_sandbox =
- StartBPFSandbox(command_line, process_type, std::move(proc_fd));
- CHECK(started_sandbox);
+ CHECK(StartBPFSandbox(sandbox_type, std::move(proc_fd), options));
return true;
}
#endif
return false;
}
+
#endif // !defined(OS_NACL_NONSFI)
bool SandboxSeccompBPF::StartSandboxWithExternalPolicy(
@@ -280,7 +278,7 @@ bool SandboxSeccompBPF::StartSandboxWithExternalPolicy(
#if BUILDFLAG(USE_SECCOMP_BPF)
if (IsSeccompBPFDesired() && SupportsSandbox()) {
CHECK(policy);
- StartSandboxWithPolicy(policy.release(), std::move(proc_fd));
+ StartSandboxWithPolicy(std::move(policy), std::move(proc_fd));
return true;
}
#endif // BUILDFLAG(USE_SECCOMP_BPF)
@@ -291,9 +289,9 @@ bool SandboxSeccompBPF::StartSandboxWithExternalPolicy(
std::unique_ptr<sandbox::bpf_dsl::Policy>
SandboxSeccompBPF::GetBaselinePolicy() {
#if BUILDFLAG(USE_SECCOMP_BPF)
- return std::unique_ptr<sandbox::bpf_dsl::Policy>(new BaselinePolicy);
+ return std::make_unique<BaselinePolicy>();
#else
- return std::unique_ptr<sandbox::bpf_dsl::Policy>();
+ return nullptr;
#endif // BUILDFLAG(USE_SECCOMP_BPF)
}
#endif // !defined(OS_NACL_NONSFI)
diff --git a/chromium/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h b/chromium/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h
index a462dc95c19..a62300aca5d 100644
--- a/chromium/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h
+++ b/chromium/content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h
@@ -10,7 +10,9 @@
#include "base/files/scoped_file.h"
#include "base/macros.h"
+#include "build/build_config.h"
#include "sandbox/linux/bpf_dsl/policy.h"
+#include "services/service_manager/sandbox/sandbox_type.h"
namespace content {
@@ -19,22 +21,28 @@ namespace content {
// a public content/ API and uses a supplied policy.
class SandboxSeccompBPF {
public:
+ struct Options {
+ bool use_amd_specific_policies = false; // For ChromiumOs.
+ };
+
// This is the API to enable a seccomp-bpf sandbox for content/
// process-types:
// Is the sandbox globally enabled, can anything use it at all ?
// This looks at global command line flags to see if the sandbox
// should be enabled at all.
static bool IsSeccompBPFDesired();
- // Should the sandbox be enabled for process_type ?
- static bool ShouldEnableSeccompBPF(const std::string& process_type);
// Check if the kernel supports seccomp-bpf.
static bool SupportsSandbox();
+
+#if !defined(OS_NACL_NONSFI)
// Check if the kernel supports TSYNC (thread synchronization) with seccomp.
static bool SupportsSandboxWithTsync();
- // Start the sandbox and apply the policy for process_type, depending on
- // command line switches.
- static bool StartSandbox(const std::string& process_type,
- base::ScopedFD proc_fd);
+ // Start the sandbox and apply the policy for sandbox_type, depending on
+ // command line switches and options.
+ static bool StartSandbox(service_manager::SandboxType sandbox_type,
+ base::ScopedFD proc_fd,
+ const Options& options);
+#endif // !defined(OS_NACL_NONSFI)
// This is the API to enable a seccomp-bpf sandbox by using an
// external policy.
diff --git a/chromium/content/common/sandbox_mac.h b/chromium/content/common/sandbox_mac.h
deleted file mode 100644
index 93765ed63da..00000000000
--- a/chromium/content/common/sandbox_mac.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) 2012 The Chromium 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 CONTENT_COMMON_SANDBOX_MAC_H_
-#define CONTENT_COMMON_SANDBOX_MAC_H_
-
-#include <map>
-#include <string>
-
-#include "base/containers/hash_tables.h"
-#include "base/gtest_prod_util.h"
-#include "base/macros.h"
-#include "content/common/content_export.h"
-#include "content/public/common/sandbox_type.h"
-
-namespace base {
-class FilePath;
-}
-
-namespace content {
-
-class CONTENT_EXPORT Sandbox {
- public:
-
- // Warm up System APIs that empirically need to be accessed before the
- // sandbox is turned on. |sandbox_type| is the type of sandbox to warm up.
- // Valid |sandbox_type| values are defined by the enum SandboxType, or can be
- // defined by the embedder via
- // ContentClient::GetSandboxProfileForProcessType().
- static void SandboxWarmup(int sandbox_type);
-
- // Turns on the OS X sandbox for this process.
- // |sandbox_type| - type of Sandbox to use. See SandboxWarmup() for legal
- // values.
- // |allowed_dir| - directory to allow access to, currently the only sandbox
- // profile that supports this is SANDBOX_TYPE_UTILITY .
- //
- // Returns true on success, false if an error occurred enabling the sandbox.
- static bool EnableSandbox(int sandbox_type,
- const base::FilePath& allowed_dir);
-
- // Returns true if the sandbox has been enabled for the current process.
- static bool SandboxIsCurrentlyActive();
-
- // Convert provided path into a "canonical" path matching what the Sandbox
- // expects i.e. one without symlinks.
- // This path is not necessarily unique e.g. in the face of hardlinks.
- static base::FilePath GetCanonicalSandboxPath(const base::FilePath& path);
-
- static const char* kSandboxBrowserPID;
- static const char* kSandboxBundlePath;
- static const char* kSandboxChromeBundleId;
- static const char* kSandboxComponentPath;
- static const char* kSandboxDisableDenialLogging;
- static const char* kSandboxEnableLogging;
- static const char* kSandboxHomedirAsLiteral;
- static const char* kSandboxLoggingPathAsLiteral;
- static const char* kSandboxOSVersion;
- static const char* kSandboxPermittedDir;
-
- // TODO(kerrnel): this is only for the legacy sandbox.
- static const char* kSandboxElCapOrLater;
- static const char* kSandboxMacOS1013;
-
- private:
- FRIEND_TEST_ALL_PREFIXES(MacDirAccessSandboxTest, StringEscape);
- FRIEND_TEST_ALL_PREFIXES(MacDirAccessSandboxTest, RegexEscape);
- FRIEND_TEST_ALL_PREFIXES(MacDirAccessSandboxTest, SandboxAccess);
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(Sandbox);
-};
-
-} // namespace content
-
-#endif // CONTENT_COMMON_SANDBOX_MAC_H_
diff --git a/chromium/content/common/sandbox_mac.mm b/chromium/content/common/sandbox_mac.mm
deleted file mode 100644
index e9789fee555..00000000000
--- a/chromium/content/common/sandbox_mac.mm
+++ /dev/null
@@ -1,322 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/sandbox_mac.h"
-
-#import <Cocoa/Cocoa.h>
-#include <stddef.h>
-#include <stdint.h>
-
-#include <CoreFoundation/CFTimeZone.h>
-#include <signal.h>
-#include <sys/param.h>
-
-#include "base/command_line.h"
-#include "base/compiler_specific.h"
-#include "base/files/file_util.h"
-#include "base/files/scoped_file.h"
-#include "base/mac/bundle_locations.h"
-#include "base/mac/foundation_util.h"
-#include "base/mac/mac_util.h"
-#include "base/mac/scoped_cftyperef.h"
-#include "base/mac/scoped_nsautorelease_pool.h"
-#include "base/mac/scoped_nsobject.h"
-#include "base/macros.h"
-#include "base/rand_util.h"
-#include "base/strings/string16.h"
-#include "base/strings/string_piece.h"
-#include "base/strings/string_split.h"
-#include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
-#include "base/strings/sys_string_conversions.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/sys_info.h"
-#include "content/grit/content_resources.h"
-#include "content/public/common/content_client.h"
-#include "content/public/common/content_switches.h"
-#include "media/gpu/vt_video_decode_accelerator_mac.h"
-#include "sandbox/mac/sandbox_compiler.h"
-#include "third_party/icu/source/common/unicode/uchar.h"
-#include "ui/base/layout.h"
-#include "ui/gl/init/gl_factory.h"
-
-namespace content {
-namespace {
-
-// Is the sandbox currently active.
-bool gSandboxIsActive = false;
-
-struct SandboxTypeToResourceIDMapping {
- SandboxType sandbox_type;
- int sandbox_profile_resource_id;
-};
-
-// Mapping from sandbox process types to resource IDs containing the sandbox
-// profile for all process types known to content.
-// TODO(tsepez): Implement profile for SANDBOX_TYPE_NETWORK.
-SandboxTypeToResourceIDMapping kDefaultSandboxTypeToResourceIDMapping[] = {
- {SANDBOX_TYPE_NO_SANDBOX, -1},
- {SANDBOX_TYPE_RENDERER, IDR_RENDERER_SANDBOX_PROFILE},
- {SANDBOX_TYPE_UTILITY, IDR_UTILITY_SANDBOX_PROFILE},
- {SANDBOX_TYPE_GPU, IDR_GPU_SANDBOX_PROFILE},
- {SANDBOX_TYPE_PPAPI, IDR_PPAPI_SANDBOX_PROFILE},
- {SANDBOX_TYPE_NETWORK, -1},
-};
-
-static_assert(arraysize(kDefaultSandboxTypeToResourceIDMapping) == \
- size_t(SANDBOX_TYPE_AFTER_LAST_TYPE), \
- "sandbox type to resource id mapping incorrect");
-
-} // namespace
-
-// Static variable declarations.
-const char* Sandbox::kSandboxBrowserPID = "BROWSER_PID";
-const char* Sandbox::kSandboxBundlePath = "BUNDLE_PATH";
-const char* Sandbox::kSandboxChromeBundleId = "BUNDLE_ID";
-const char* Sandbox::kSandboxComponentPath = "COMPONENT_PATH";
-const char* Sandbox::kSandboxDisableDenialLogging =
- "DISABLE_SANDBOX_DENIAL_LOGGING";
-const char* Sandbox::kSandboxEnableLogging = "ENABLE_LOGGING";
-const char* Sandbox::kSandboxHomedirAsLiteral = "USER_HOMEDIR_AS_LITERAL";
-const char* Sandbox::kSandboxLoggingPathAsLiteral = "LOG_FILE_PATH";
-const char* Sandbox::kSandboxOSVersion = "OS_VERSION";
-const char* Sandbox::kSandboxPermittedDir = "PERMITTED_DIR";
-
-const char* Sandbox::kSandboxElCapOrLater = "ELCAP_OR_LATER";
-const char* Sandbox::kSandboxMacOS1013 = "MACOS_1013";
-
-// Warm up System APIs that empirically need to be accessed before the Sandbox
-// is turned on.
-// This method is layed out in blocks, each one containing a separate function
-// that needs to be warmed up. The OS version on which we found the need to
-// enable the function is also noted.
-// This function is tested on the following OS versions:
-// 10.5.6, 10.6.0
-
-// static
-void Sandbox::SandboxWarmup(int sandbox_type) {
- base::mac::ScopedNSAutoreleasePool scoped_pool;
-
- { // CGColorSpaceCreateWithName(), CGBitmapContextCreate() - 10.5.6
- base::ScopedCFTypeRef<CGColorSpaceRef> rgb_colorspace(
- CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB));
-
- // Allocate a 1x1 image.
- char data[4];
- base::ScopedCFTypeRef<CGContextRef> context(CGBitmapContextCreate(
- data,
- 1,
- 1,
- 8,
- 1 * 4,
- rgb_colorspace,
- kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
-
- // Load in the color profiles we'll need (as a side effect).
- ignore_result(base::mac::GetSRGBColorSpace());
- ignore_result(base::mac::GetSystemColorSpace());
-
- // CGColorSpaceCreateSystemDefaultCMYK - 10.6
- base::ScopedCFTypeRef<CGColorSpaceRef> cmyk_colorspace(
- CGColorSpaceCreateWithName(kCGColorSpaceGenericCMYK));
- }
-
- { // localtime() - 10.5.6
- time_t tv = {0};
- localtime(&tv);
- }
-
- { // Gestalt() tries to read /System/Library/CoreServices/SystemVersion.plist
- // on 10.5.6
- int32_t tmp;
- base::SysInfo::OperatingSystemVersionNumbers(&tmp, &tmp, &tmp);
- }
-
- { // CGImageSourceGetStatus() - 10.6
- // Create a png with just enough data to get everything warmed up...
- char png_header[] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A};
- NSData* data = [NSData dataWithBytes:png_header
- length:arraysize(png_header)];
- base::ScopedCFTypeRef<CGImageSourceRef> img(
- CGImageSourceCreateWithData((CFDataRef)data, NULL));
- CGImageSourceGetStatus(img);
- }
-
- {
- // Allow access to /dev/urandom.
- base::GetUrandomFD();
- }
-
- { // IOSurfaceLookup() - 10.7
- // Needed by zero-copy texture update framework - crbug.com/323338
- base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceLookup(0));
- }
-
- // Process-type dependent warm-up.
- if (sandbox_type == SANDBOX_TYPE_UTILITY) {
- // CFTimeZoneCopyZone() tries to read /etc and /private/etc/localtime - 10.8
- // Needed by Media Galleries API Picasa - crbug.com/151701
- CFTimeZoneCopySystem();
- }
-
- if (sandbox_type == SANDBOX_TYPE_GPU) {
- // Preload either the desktop GL or the osmesa so, depending on the
- // --use-gl flag.
- gl::init::InitializeGLOneOff();
-
- // Preload VideoToolbox.
- media::InitializeVideoToolbox();
- }
-
- if (sandbox_type == SANDBOX_TYPE_PPAPI) {
- // Preload AppKit color spaces used for Flash/ppapi. http://crbug.com/348304
- NSColor* color = [NSColor controlTextColor];
- [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
- }
-}
-
-// Load the appropriate template for the given sandbox type.
-// Returns the template as a string or an empty string on error.
-std::string LoadSandboxTemplate(int sandbox_type) {
- // We use a custom sandbox definition to lock things down as tightly as
- // possible.
- int sandbox_profile_resource_id = -1;
-
- // Find resource id for sandbox profile to use for the specific sandbox type.
- for (size_t i = 0;
- i < arraysize(kDefaultSandboxTypeToResourceIDMapping);
- ++i) {
- if (kDefaultSandboxTypeToResourceIDMapping[i].sandbox_type ==
- sandbox_type) {
- sandbox_profile_resource_id =
- kDefaultSandboxTypeToResourceIDMapping[i].sandbox_profile_resource_id;
- break;
- }
- }
- if (sandbox_profile_resource_id == -1) {
- // Check if the embedder knows about this sandbox process type.
- bool sandbox_type_found =
- GetContentClient()->GetSandboxProfileForSandboxType(
- sandbox_type, &sandbox_profile_resource_id);
- CHECK(sandbox_type_found) << "Unknown sandbox type " << sandbox_type;
- }
-
- base::StringPiece sandbox_definition =
- GetContentClient()->GetDataResource(
- sandbox_profile_resource_id, ui::SCALE_FACTOR_NONE);
- if (sandbox_definition.empty()) {
- LOG(FATAL) << "Failed to load the sandbox profile (resource id "
- << sandbox_profile_resource_id << ")";
- return std::string();
- }
-
- base::StringPiece common_sandbox_definition =
- GetContentClient()->GetDataResource(
- IDR_COMMON_SANDBOX_PROFILE, ui::SCALE_FACTOR_NONE);
- if (common_sandbox_definition.empty()) {
- LOG(FATAL) << "Failed to load the common sandbox profile";
- return std::string();
- }
-
- // Prefix sandbox_data with common_sandbox_prefix_data.
- std::string sandbox_profile = common_sandbox_definition.as_string();
- sandbox_definition.AppendToString(&sandbox_profile);
- return sandbox_profile;
-}
-
-// Turns on the OS X sandbox for this process.
-
-// static
-bool Sandbox::EnableSandbox(int sandbox_type,
- const base::FilePath& allowed_dir) {
- // Sanity - currently only SANDBOX_TYPE_UTILITY supports a directory being
- // passed in.
- if (sandbox_type < SANDBOX_TYPE_AFTER_LAST_TYPE &&
- sandbox_type != SANDBOX_TYPE_UTILITY) {
- DCHECK(allowed_dir.empty())
- << "Only SANDBOX_TYPE_UTILITY allows a custom directory parameter.";
- }
-
- std::string sandbox_data = LoadSandboxTemplate(sandbox_type);
- if (sandbox_data.empty()) {
- return false;
- }
-
- sandbox::SandboxCompiler compiler(sandbox_data);
-
- if (!allowed_dir.empty()) {
- // Add the sandbox parameters necessary to access the given directory.
- base::FilePath allowed_dir_canonical = GetCanonicalSandboxPath(allowed_dir);
- if (!compiler.InsertStringParam(kSandboxPermittedDir,
- allowed_dir_canonical.value()))
- return false;
- }
-
- // Enable verbose logging if enabled on the command line. (See common.sb
- // for details).
- const base::CommandLine* command_line =
- base::CommandLine::ForCurrentProcess();
- bool enable_logging =
- command_line->HasSwitch(switches::kEnableSandboxLogging);;
- if (!compiler.InsertBooleanParam(kSandboxEnableLogging, enable_logging))
- return false;
-
- // Without this, the sandbox will print a message to the system log every
- // time it denies a request. This floods the console with useless spew.
- if (!compiler.InsertBooleanParam(kSandboxDisableDenialLogging,
- !enable_logging))
- return false;
-
- // Splice the path of the user's home directory into the sandbox profile
- // (see renderer.sb for details).
- std::string home_dir = [NSHomeDirectory() fileSystemRepresentation];
-
- base::FilePath home_dir_canonical =
- GetCanonicalSandboxPath(base::FilePath(home_dir));
-
- if (!compiler.InsertStringParam(kSandboxHomedirAsLiteral,
- home_dir_canonical.value()))
- return false;
-
- bool elcap_or_later = base::mac::IsAtLeastOS10_11();
- if (!compiler.InsertBooleanParam(kSandboxElCapOrLater, elcap_or_later))
- return false;
-
- bool macos_1013 = base::mac::IsOS10_13();
- if (!compiler.InsertBooleanParam(kSandboxMacOS1013, macos_1013))
- return false;
-
- // Initialize sandbox.
- std::string error_str;
- bool success = compiler.CompileAndApplyProfile(&error_str);
- DLOG_IF(FATAL, !success) << "Failed to initialize sandbox: " << error_str;
- gSandboxIsActive = success;
- return success;
-}
-
-// static
-bool Sandbox::SandboxIsCurrentlyActive() {
- return gSandboxIsActive;
-}
-
-// static
-base::FilePath Sandbox::GetCanonicalSandboxPath(const base::FilePath& path) {
- base::ScopedFD fd(HANDLE_EINTR(open(path.value().c_str(), O_RDONLY)));
- if (!fd.is_valid()) {
- DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: "
- << path.value();
- return path;
- }
-
- base::FilePath::CharType canonical_path[MAXPATHLEN];
- if (HANDLE_EINTR(fcntl(fd.get(), F_GETPATH, canonical_path)) != 0) {
- DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: "
- << path.value();
- return path;
- }
-
- return base::FilePath(canonical_path);
-}
-
-} // namespace content
diff --git a/chromium/content/common/sandbox_mac_diraccess_unittest.mm b/chromium/content/common/sandbox_mac_diraccess_unittest.mm
index 9bb5a5cc9ff..d105d80d62b 100644
--- a/chromium/content/common/sandbox_mac_diraccess_unittest.mm
+++ b/chromium/content/common/sandbox_mac_diraccess_unittest.mm
@@ -19,8 +19,8 @@ extern "C" {
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/multiprocess_test.h"
-#include "content/common/sandbox_mac.h"
#include "sandbox/mac/sandbox_compiler.h"
+#include "services/service_manager/sandbox/mac/sandbox_mac.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"
@@ -72,7 +72,7 @@ TEST_F(MacDirAccessSandboxTest, SandboxAccess) {
// This step is important on OS X since the sandbox only understands "real"
// paths and the paths CreateNewTempDirectory() returns are empirically in
// /var which is a symlink to /private/var .
- tmp_dir = Sandbox::GetCanonicalSandboxPath(tmp_dir);
+ tmp_dir = service_manager::Sandbox::GetCanonicalSandboxPath(tmp_dir);
ScopedDirectory cleanup(&tmp_dir);
const char* sandbox_dir_cases[] = {
diff --git a/chromium/content/common/sandbox_mac_fontloading_unittest.mm b/chromium/content/common/sandbox_mac_fontloading_unittest.mm
index 4b0ef850070..b0b0c6309a7 100644
--- a/chromium/content/common/sandbox_mac_fontloading_unittest.mm
+++ b/chromium/content/common/sandbox_mac_fontloading_unittest.mm
@@ -15,6 +15,7 @@
#include "content/common/mac/font_descriptor.h"
#include "content/common/mac/font_loader.h"
#include "content/common/sandbox_mac_unittest_helper.h"
+#include "services/service_manager/sandbox/sandbox_type.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace content {
@@ -122,8 +123,9 @@ TEST_F(MacSandboxTest, FontLoadingTest) {
fileno(temp_file), static_cast<const char*>(result->font_data.memory()),
result->font_data_size);
- ASSERT_TRUE(RunTestInSandbox(SANDBOX_TYPE_RENDERER,
- "FontLoadingTestCase", temp_file_path.value().c_str()));
+ ASSERT_TRUE(RunTestInSandbox(service_manager::SANDBOX_TYPE_RENDERER,
+ "FontLoadingTestCase",
+ temp_file_path.value().c_str()));
temp_file_closer.reset();
ASSERT_TRUE(base::DeleteFile(temp_file_path, false));
}
diff --git a/chromium/content/common/sandbox_mac_system_access_unittest.mm b/chromium/content/common/sandbox_mac_system_access_unittest.mm
index 735bb995442..62f32a8de13 100644
--- a/chromium/content/common/sandbox_mac_system_access_unittest.mm
+++ b/chromium/content/common/sandbox_mac_system_access_unittest.mm
@@ -10,9 +10,9 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/strings/sys_string_conversions.h"
-#include "content/common/sandbox_mac.h"
#include "content/common/sandbox_mac_unittest_helper.h"
#include "crypto/openssl_util.h"
+#include "services/service_manager/sandbox/mac/sandbox_mac.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/boringssl/src/include/openssl/rand.h"
#import "ui/base/clipboard/clipboard_util_mac.h"
diff --git a/chromium/content/common/sandbox_mac_unittest_helper.h b/chromium/content/common/sandbox_mac_unittest_helper.h
index a3c06947759..1d42a1c7bf9 100644
--- a/chromium/content/common/sandbox_mac_unittest_helper.h
+++ b/chromium/content/common/sandbox_mac_unittest_helper.h
@@ -6,7 +6,8 @@
#define CONTENT_COMMON_SANDBOX_MAC_UNITTEST_HELPER_H_
#include "base/test/multiprocess_test.h"
-#include "content/common/sandbox_mac.h"
+#include "services/service_manager/sandbox/mac/sandbox_mac.h"
+#include "services/service_manager/sandbox/sandbox_type.h"
namespace content {
@@ -49,7 +50,7 @@ class MacSandboxTest : public base::MultiProcessTest {
// required.
// Returns true if the test passes, false if either of the functions in
// the corresponding MacSandboxTestCase return false.
- bool RunTestInSandbox(content::SandboxType sandbox_type,
+ bool RunTestInSandbox(service_manager::SandboxType sandbox_type,
const char* test_name,
const char* test_data);
diff --git a/chromium/content/common/sandbox_mac_unittest_helper.mm b/chromium/content/common/sandbox_mac_unittest_helper.mm
index 8fe486b107b..6767fa2b7e1 100644
--- a/chromium/content/common/sandbox_mac_unittest_helper.mm
+++ b/chromium/content/common/sandbox_mac_unittest_helper.mm
@@ -14,9 +14,9 @@ extern "C" {
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/process/kill.h"
-#include "content/common/sandbox_mac.h"
-#include "content/public/common/sandbox_type.h"
#include "content/test/test_content_client.h"
+#include "services/service_manager/sandbox/mac/sandbox_mac.h"
+#include "services/service_manager/sandbox/sandbox_type.h"
#include "testing/multiprocess_func_list.h"
namespace content {
@@ -54,13 +54,14 @@ bool MacSandboxTest::RunTestInAllSandboxTypes(const char* test_name,
const char* test_data) {
// Go through all the sandbox types, and run the test case in each of them
// if one fails, abort.
- for(int i = static_cast<int>(SANDBOX_TYPE_FIRST_TYPE);
- i < SANDBOX_TYPE_AFTER_LAST_TYPE;
- ++i) {
- if (IsUnsandboxedSandboxType(static_cast<SandboxType>(i)))
+ for (int i = static_cast<int>(service_manager::SANDBOX_TYPE_FIRST_TYPE);
+ i < service_manager::SANDBOX_TYPE_AFTER_LAST_TYPE; ++i) {
+ if (service_manager::IsUnsandboxedSandboxType(
+ static_cast<service_manager::SandboxType>(i))) {
continue;
-
- if (!RunTestInSandbox(static_cast<SandboxType>(i), test_name, test_data)) {
+ }
+ if (!RunTestInSandbox(static_cast<service_manager::SandboxType>(i),
+ test_name, test_data)) {
LOG(ERROR) << "Sandboxed test (" << test_name << ")"
<< "Failed in sandbox type " << i << "user data: ("
<< test_data << ")";
@@ -70,7 +71,7 @@ bool MacSandboxTest::RunTestInAllSandboxTypes(const char* test_name,
return true;
}
-bool MacSandboxTest::RunTestInSandbox(SandboxType sandbox_type,
+bool MacSandboxTest::RunTestInSandbox(service_manager::SandboxType sandbox_type,
const char* test_name,
const char* test_data) {
std::stringstream s;
@@ -129,7 +130,8 @@ MULTIPROCESS_TEST_MAIN(mac_sandbox_test_runner) {
LOG(ERROR) << "Sandbox type not specified";
return -1;
}
- SandboxType sandbox_type = static_cast<SandboxType>(atoi(sandbox_type_str));
+ auto sandbox_type =
+ static_cast<service_manager::SandboxType>(atoi(sandbox_type_str));
char* sandbox_test_name = getenv(kSandboxTestNameKey);
if (!sandbox_test_name) {
LOG(ERROR) << "Sandbox test name not specified";
@@ -154,9 +156,10 @@ MULTIPROCESS_TEST_MAIN(mac_sandbox_test_runner) {
return -1;
}
- Sandbox::SandboxWarmup(sandbox_type);
+ service_manager::Sandbox::SandboxWarmup(sandbox_type);
- if (!Sandbox::EnableSandbox(sandbox_type, base::FilePath())) {
+ if (!service_manager::Sandbox::EnableSandbox(sandbox_type,
+ base::FilePath())) {
LOG(ERROR) << "Failed to initialize sandbox " << sandbox_type;
return -1;
}
diff --git a/chromium/content/common/sandbox_policy_fuchsia.cc b/chromium/content/common/sandbox_policy_fuchsia.cc
new file mode 100644
index 00000000000..54826f98d7f
--- /dev/null
+++ b/chromium/content/common/sandbox_policy_fuchsia.cc
@@ -0,0 +1,32 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/sandbox_policy_fuchsia.h"
+
+#include <launchpad/launchpad.h>
+#include <zircon/processargs.h>
+
+#include "base/command_line.h"
+#include "base/process/launch.h"
+#include "content/public/common/content_switches.h"
+
+namespace content {
+
+void UpdateLaunchOptionsForSandbox(service_manager::SandboxType type,
+ base::LaunchOptions* options) {
+ // TODO(750938): Re-enable sandboxed sub-processes once we support things
+ // like resource file fetching by sandboxed processes.
+ // if
+ // (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoSandbox))
+ type = service_manager::SANDBOX_TYPE_NO_SANDBOX;
+
+ if (type != service_manager::SANDBOX_TYPE_NO_SANDBOX) {
+ options->clone_flags = LP_CLONE_FDIO_STDIO;
+ } else {
+ options->clone_flags = LP_CLONE_FDIO_NAMESPACE | LP_CLONE_DEFAULT_JOB |
+ LP_CLONE_FDIO_CWD | LP_CLONE_FDIO_STDIO;
+ }
+}
+
+} // namespace content
diff --git a/chromium/content/common/sandbox_policy_fuchsia.h b/chromium/content/common/sandbox_policy_fuchsia.h
new file mode 100644
index 00000000000..bd6e1a44549
--- /dev/null
+++ b/chromium/content/common/sandbox_policy_fuchsia.h
@@ -0,0 +1,25 @@
+// Copyright 2017 The Chromium 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 CONTENT_COMMON_SANDBOX_POLICY_FUCHSIA_H_
+#define CONTENT_COMMON_SANDBOX_POLICY_FUCHSIA_H_
+
+#include "services/service_manager/sandbox/sandbox_type.h"
+
+namespace base {
+struct LaunchOptions;
+} // namespace base
+
+namespace content {
+
+// Modifies the process launch |options| to achieve the level of isolation
+// appropriate for the sandbox |type|. The caller may then add any
+// descriptors or handles afterward to grant additional capabiltiies to the new
+// process.
+void UpdateLaunchOptionsForSandbox(service_manager::SandboxType type,
+ base::LaunchOptions* options);
+
+} // namespace content
+
+#endif // CONTENT_COMMON_SANDBOX_POLICY_FUCHSIA_H_
diff --git a/chromium/content/common/sandbox_win.cc b/chromium/content/common/sandbox_win.cc
index a98c8bd7646..3c8150376bb 100644
--- a/chromium/content/common/sandbox_win.cc
+++ b/chromium/content/common/sandbox_win.cc
@@ -43,6 +43,7 @@
#include "sandbox/win/src/sandbox_nt_util.h"
#include "sandbox/win/src/sandbox_policy_base.h"
#include "sandbox/win/src/win_utils.h"
+#include "services/service_manager/sandbox/sandbox_type.h"
#if !defined(NACL_WIN64)
#include "ui/gfx/win/direct_write.h" // nogncheck: unused #ifdef NACL_WIN64
@@ -739,7 +740,7 @@ sandbox::ResultCode StartSandboxedProcess(
ProcessDebugFlags(cmd_line);
- if (IsUnsandboxedSandboxType(delegate->GetSandboxType()) ||
+ if (service_manager::IsUnsandboxedSandboxType(delegate->GetSandboxType()) ||
browser_command_line.HasSwitch(switches::kNoSandbox) ||
cmd_line->HasSwitch(switches::kNoSandbox)) {
base::LaunchOptions options;
@@ -803,7 +804,9 @@ sandbox::ResultCode StartSandboxedProcess(
#if !defined(NACL_WIN64)
if (type_str == switches::kRendererProcess ||
- type_str == switches::kPpapiPluginProcess) {
+ type_str == switches::kPpapiPluginProcess ||
+ delegate->GetSandboxType() ==
+ service_manager::SANDBOX_TYPE_PDF_COMPOSITOR) {
AddDirectory(base::DIR_WINDOWS_FONTS, NULL, true,
sandbox::TargetPolicy::FILES_ALLOW_READONLY, policy.get());
}
diff --git a/chromium/content/common/service_worker/OWNERS b/chromium/content/common/service_worker/OWNERS
index c19de06c636..c334b1744ec 100644
--- a/chromium/content/common/service_worker/OWNERS
+++ b/chromium/content/common/service_worker/OWNERS
@@ -1,9 +1,4 @@
-falken@chromium.org
-horo@chromium.org
-mek@chromium.org
-michaeln@chromium.org
-nhiroki@chromium.org
-shimazu@chromium.org
+file://content/browser/service_worker/OWNERS
per-file *_messages*.h=set noparent
per-file *_messages*.h=file://ipc/SECURITY_OWNERS
diff --git a/chromium/content/common/service_worker/controller_service_worker.mojom b/chromium/content/common/service_worker/controller_service_worker.mojom
new file mode 100644
index 00000000000..a7d522edba9
--- /dev/null
+++ b/chromium/content/common/service_worker/controller_service_worker.mojom
@@ -0,0 +1,43 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module content.mojom;
+
+import "mojo/common/time.mojom";
+import "content/common/service_worker/service_worker_fetch_response_callback.mojom";
+import "third_party/WebKit/public/platform/modules/fetch/fetch_api_request.mojom";
+import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom";
+
+// S13nServiceWorker:
+// Represents a service worker that is a controller. One of its Mojo end
+// points (i.e. the caller end) is passed to the controllee in the renderer
+// process, and used from there. Its other Mojo end point (i.e. the destination
+// of the events) is currently implemented by BrowserSideControllerServiceWorker
+// in the browser-process, but eventually this should be implemented by the
+// controller service worker in the renderer-process so that the events
+// dispatched by the controllees can be directly sent there.
+//
+// The controllees use this interface to directly talk to the controller. This
+// implements a small subset of ServiceWorkerEventDispatcher, namely dispatch
+// methods for Fetch and PostMessage, because ordering must be preserved
+// between them: controller.postMessage(...), controller.fetch(‘...’); from
+// the page must result in a message event then fetch event dispatched to the
+// service worker. They are believed to be the only events whose ordering
+// guarantee is observable from the page context.
+//
+interface ControllerServiceWorker {
+ // Dispatches Fetch event for sub-resources. (Fetch for main resource is
+ // handled by ServiceWorkerEventDispatcher, as the fetch is initiated
+ // in the browser-process during the navigation)
+ // The callback is called once the event finishes, which means the event
+ // handler ran and all outstanding respondWith() and waitUntil() promises have
+ // settled. |response_callback| is called once the promise to respondWith()
+ // settles, or when the event handler ran without calling respondWith().
+ DispatchFetchEvent(blink.mojom.FetchAPIRequest request,
+ ServiceWorkerFetchResponseCallback response_callback)
+ => (blink.mojom.ServiceWorkerEventStatus status,
+ mojo.common.mojom.Time dispatch_event_time);
+
+ // TODO(kinuko): Add DispatchExtendableMessageEvent() as well.
+};
diff --git a/chromium/content/common/service_worker/embedded_worker_messages.h b/chromium/content/common/service_worker/embedded_worker_messages.h
index f7e2da6125c..f31fcd1e9f7 100644
--- a/chromium/content/common/service_worker/embedded_worker_messages.h
+++ b/chromium/content/common/service_worker/embedded_worker_messages.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Message definition file, included multiple times, hence no include guard.
+#ifndef CONTENT_COMMON_SERVICE_WORKER_EMBEDDED_WORKER_MESSAGES_H_
+#define CONTENT_COMMON_SERVICE_WORKER_EMBEDDED_WORKER_MESSAGES_H_
#include <stdint.h>
@@ -59,3 +60,5 @@ IPC_MESSAGE_CONTROL3(EmbeddedWorkerContextMsg_MessageToWorker,
int /* thread_id */,
int /* embedded_worker_id */,
IPC::Message /* message */)
+
+#endif // CONTENT_COMMON_SERVICE_WORKER_EMBEDDED_WORKER_MESSAGES_H_
diff --git a/chromium/content/common/service_worker/service_worker_container.mojom b/chromium/content/common/service_worker/service_worker_container.mojom
index 4d4599e6b23..a998621ffec 100644
--- a/chromium/content/common/service_worker/service_worker_container.mojom
+++ b/chromium/content/common/service_worker/service_worker_container.mojom
@@ -4,16 +4,66 @@
module content.mojom;
+import "content/common/service_worker/controller_service_worker.mojom";
+import "content/common/service_worker/service_worker_types.mojom";
+import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom";
+import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom";
+import "url/mojo/url.mojom";
+
// mojom::ServiceWorkerContainerHost is a browser-side interface. The renderer
// process uses this interface to request the browser process to do operations
// involving service worker registrations.
interface ServiceWorkerContainerHost {
- // TODO(leon.han): implement them.
- // Register();
- // GetRegistation();
- // GetRegistrations();
- // GetRegistrationForReady();
- // GetControllerServiceWorker();
+ // Corresponds to navigator.serviceWorker.register().
+ // Registers a service worker from |script_url| with |options|.
+ // On success, |error| is kNone with |registration| and |attributes| set.
+ // Otherwise, |error| and |error_msg| describe the failure.
+ Register(url.mojom.Url script_url,
+ blink.mojom.ServiceWorkerRegistrationOptions options)
+ => (blink.mojom.ServiceWorkerErrorType error,
+ string? error_msg,
+ blink.mojom.ServiceWorkerRegistrationObjectInfo? registration,
+ ServiceWorkerVersionAttributes? attributes);
+
+ // Corresponds to navigator.serviceWorker.getRegistration().
+ // Gets the service worker registration for the |client_url|.
+ // On success, |error| is kNone with |registration| and |attributes| set.
+ // Otherwise, |error| and |error_msg| describe the failure.
+ GetRegistration(url.mojom.Url client_url)
+ => (blink.mojom.ServiceWorkerErrorType error,
+ string? error_msg,
+ blink.mojom.ServiceWorkerRegistrationObjectInfo? registration,
+ ServiceWorkerVersionAttributes? attributes);
+
+ // Corresponds to navigator.serviceWorker.getRegistrations().
+ // Gets all service worker registrations which have the same origin with
+ // the ServiceWorkerContainer that this interface hosts.
+ // On success, |error| is kNone with |infos| and |attrs| set. Otherwise,
+ // |error| and |error_msg| describe the failure.
+ GetRegistrations()
+ => (blink.mojom.ServiceWorkerErrorType error,
+ string? error_msg,
+ array<blink.mojom.ServiceWorkerRegistrationObjectInfo>? infos,
+ array<ServiceWorkerVersionAttributes>? attrs);
+
+ // Corresponds to navigator.serviceWorker.ready.
+ // Returns the service worker registration for the ServiceWorkerContainer that
+ // this interface hosts, once such a registration exists and has an active
+ // service worker.
+ GetRegistrationForReady()
+ => (blink.mojom.ServiceWorkerRegistrationObjectInfo? registration,
+ ServiceWorkerVersionAttributes? attributes);
+
+ // S13nServiceWorker:
+ // Gets a Mojo end point to the controller ServiceWorker. This may start a
+ // service worker instance in a renderer process if the corresponding
+ // instance is not alive.
+ // This method must be called only by the controllees.
+ // If the browser fails to start the service worker it is propagated as a
+ // connection error of the returned pipe. The detailed error reasons are not
+ // reported to the controllees, but the browser process is responsible for
+ // properly handling the failure and recording the reasons.
+ GetControllerServiceWorker(ControllerServiceWorker& controller);
};
// mojom::ServiceWorkerContainer is a renderer-side interface.
diff --git a/chromium/content/common/service_worker/service_worker_event_dispatcher.mojom b/chromium/content/common/service_worker/service_worker_event_dispatcher.mojom
index d0f3873e8c6..709c64bcc34 100644
--- a/chromium/content/common/service_worker/service_worker_event_dispatcher.mojom
+++ b/chromium/content/common/service_worker/service_worker_event_dispatcher.mojom
@@ -4,6 +4,7 @@
module content.mojom;
+import "content/common/service_worker/service_worker_fetch_response_callback.mojom";
import "content/public/common/url_loader.mojom";
import "mojo/common/string16.mojom";
import "mojo/common/time.mojom";
@@ -12,7 +13,6 @@ import "third_party/WebKit/public/platform/modules/background_sync/background_sy
import "third_party/WebKit/public/platform/modules/fetch/fetch_api_request.mojom";
import "third_party/WebKit/public/platform/modules/payments/payment_app.mojom";
import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom";
-import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_stream_handle.mojom";
import "url/mojo/origin.mojom";
import "url/mojo/url.mojom";
@@ -53,35 +53,9 @@ struct ExtendableMessageEvent {
ExtendableMessageEventSource source;
};
-// Browser-side interface which is passed through DispatchFetchEvent. The
-// renderer uses this interface to respond to a fetch event.
-interface ServiceWorkerFetchResponseCallback {
- // Responds to the request with |response|. The body is empty.
- OnResponse(ServiceWorkerResponse response,
- mojo.common.mojom.Time dispatch_event_time);
- // Responds to the request with |response|. The body is returned as a blob.
- // TODO(kinuko): This should not be necessary once we properly support
- // transferring blob within |response|. See crbug.com/75523 for more details.
- OnResponseBlob(ServiceWorkerResponse response,
- storage.mojom.Blob body_as_blob,
- mojo.common.mojom.Time dispatch_event_time);
- // Responds to the request with |response|. The body is returned as a stream.
- OnResponseStream(ServiceWorkerResponse response,
- blink.mojom.ServiceWorkerStreamHandle body_as_stream,
- mojo.common.mojom.Time dispatch_event_time);
- // Provides no response to the request. The browser will fall back to the
- // network.
- OnFallback(mojo.common.mojom.Time dispatch_event_time);
-};
-
// An interface for dispatching events to a ServiceWorker. This interface is
-// implemented both in the renderer-side and browser-side for the time being.
-// - This is implemented by ServiceWorkerContextClient that lives in the
-// renderer-side to dispatch events from the browser-side.
-// - This is also implemented by BrowserSideServiceWorkerEventDispatcher that
-// lives in the browser-side, which is used to dispatch events directly from
-// the controllees that live in renderer(s). This code is only used when
-// IsServicificationEnabled() is true.
+// implemented by ServiceWorkerContextClient that lives in the renderer-side
+// to dispatch events from the browser-side.
//
// Those events expecting such response
// (blink.mojom.ServiceWorkerEventStatus, mojo.common.mojom.Time) are considered
@@ -95,20 +69,29 @@ interface ServiceWorkerEventDispatcher {
DispatchActivateEvent()
=> (blink.mojom.ServiceWorkerEventStatus status,
mojo.common.mojom.Time dispatch_event_time);
- DispatchBackgroundFetchAbortEvent(string id)
+
+ // These methods dispatch to the ServiceWorkerGlobalScope the events listed on
+ // https://wicg.github.io/background-fetch/#service-worker-global-events.
+ // The callbacks are called once the event handler has run and waitUntil()
+ // promise has settled. |developer_id| and |unique_id| are documented in
+ // content::BackgroundFetchRegistrationId.
+ DispatchBackgroundFetchAbortEvent(string developer_id)
=> (blink.mojom.ServiceWorkerEventStatus status,
mojo.common.mojom.Time dispatch_event_time);
- DispatchBackgroundFetchClickEvent(string id, BackgroundFetchState state)
+ DispatchBackgroundFetchClickEvent(string developer_id,
+ BackgroundFetchState state)
=> (blink.mojom.ServiceWorkerEventStatus status,
mojo.common.mojom.Time dispatch_event_time);
- DispatchBackgroundFetchFailEvent(string id,
+ DispatchBackgroundFetchFailEvent(string developer_id,
array<BackgroundFetchSettledFetch> fetches)
=> (blink.mojom.ServiceWorkerEventStatus status,
mojo.common.mojom.Time dispatch_event_time);
- DispatchBackgroundFetchedEvent(string id,
+ DispatchBackgroundFetchedEvent(string developer_id,
+ string unique_id,
array<BackgroundFetchSettledFetch> fetches)
=> (blink.mojom.ServiceWorkerEventStatus status,
mojo.common.mojom.Time dispatch_event_time);
+
// The callback is called once the event finishes, which means the event
// handler ran and all outstanding respondWith() and waitUntil() promises have
// settled. |response_callback| is called once the promise to respondWith()
diff --git a/chromium/content/common/service_worker/service_worker_event_dispatcher.typemap b/chromium/content/common/service_worker/service_worker_event_dispatcher.typemap
index 55cdfc01b58..2c7bc262d90 100644
--- a/chromium/content/common/service_worker/service_worker_event_dispatcher.typemap
+++ b/chromium/content/common/service_worker/service_worker_event_dispatcher.typemap
@@ -11,16 +11,11 @@ public_headers = [
"//content/public/common/platform_notification_data.h",
"//content/public/common/push_event_payload.h",
]
-sources = [
- "//content/common/service_worker/service_worker_status_code_traits.cc",
-]
traits_headers = [
"//content/common/platform_notification_messages.h",
"//content/common/service_worker/service_worker_messages.h",
- "//content/common/service_worker/service_worker_status_code_traits.h",
]
type_mappings = [
- "blink.mojom.ServiceWorkerEventStatus=::content::ServiceWorkerStatusCode",
"content.mojom.ExtendableMessageEventSource=::content::ExtendableMessageEventSource",
"content.mojom.PlatformNotificationData=::content::PlatformNotificationData",
"content.mojom.PushEventPayload=::content::PushEventPayload",
diff --git a/chromium/content/common/service_worker/service_worker_fetch_response_callback.mojom b/chromium/content/common/service_worker/service_worker_fetch_response_callback.mojom
new file mode 100644
index 00000000000..567c6ba6745
--- /dev/null
+++ b/chromium/content/common/service_worker/service_worker_fetch_response_callback.mojom
@@ -0,0 +1,35 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module content.mojom;
+
+import "mojo/common/time.mojom";
+import "storage/public/interfaces/blobs.mojom";
+import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_stream_handle.mojom";
+
+[Native]
+struct ServiceWorkerResponse;
+
+// Callback interface which is passed to a controller service worker through
+// DispatchFetchEvent (either via ServiceWorkerEventDispatcher or via
+// ControllerServiceWorker interface).
+// The receiver service worker uses this interface to respond to a fetch event.
+interface ServiceWorkerFetchResponseCallback {
+ // Responds to the request with |response|. The body is empty.
+ OnResponse(ServiceWorkerResponse response,
+ mojo.common.mojom.Time dispatch_event_time);
+ // Responds to the request with |response|. The body is returned as a blob.
+ // TODO(kinuko): This should not be necessary once we properly support
+ // transferring blob within |response|. See crbug.com/75523 for more details.
+ OnResponseBlob(ServiceWorkerResponse response,
+ storage.mojom.Blob body_as_blob,
+ mojo.common.mojom.Time dispatch_event_time);
+ // Responds to the request with |response|. The body is returned as a stream.
+ OnResponseStream(ServiceWorkerResponse response,
+ blink.mojom.ServiceWorkerStreamHandle body_as_stream,
+ mojo.common.mojom.Time dispatch_event_time);
+ // Provides no response to the request. The browser will fall back to the
+ // network.
+ OnFallback(mojo.common.mojom.Time dispatch_event_time);
+};
diff --git a/chromium/content/common/service_worker/service_worker_loader_helpers.cc b/chromium/content/common/service_worker/service_worker_loader_helpers.cc
new file mode 100644
index 00000000000..4be0245a591
--- /dev/null
+++ b/chromium/content/common/service_worker/service_worker_loader_helpers.cc
@@ -0,0 +1,87 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/service_worker/service_worker_loader_helpers.h"
+
+#include "base/strings/stringprintf.h"
+#include "content/common/service_worker/service_worker_utils.h"
+#include "content/public/common/content_features.h"
+#include "content/public/common/resource_request.h"
+#include "content/public/common/resource_response.h"
+#include "net/http/http_util.h"
+
+namespace content {
+
+// static
+std::unique_ptr<ServiceWorkerFetchRequest>
+ServiceWorkerLoaderHelpers::CreateFetchRequest(const ResourceRequest& request) {
+ std::unique_ptr<ServiceWorkerFetchRequest> new_request =
+ base::MakeUnique<ServiceWorkerFetchRequest>();
+ new_request->mode = request.fetch_request_mode;
+ new_request->is_main_resource_load =
+ ServiceWorkerUtils::IsMainResourceType(request.resource_type);
+ new_request->request_context_type = request.fetch_request_context_type;
+ new_request->frame_type = request.fetch_frame_type;
+ new_request->url = request.url;
+ new_request->method = request.method;
+ // |blob_uuid| and |blob_size| aren't used in MojoBlobs, so just clear them.
+ // The caller is responsible for setting the MojoBlob field |blob| if needed.
+ DCHECK(features::IsMojoBlobsEnabled());
+ new_request->blob_uuid.clear();
+ new_request->blob_size = 0;
+ new_request->credentials_mode = request.fetch_credentials_mode;
+ new_request->redirect_mode = request.fetch_redirect_mode;
+ new_request->is_reload = ui::PageTransitionCoreTypeIs(
+ request.transition_type, ui::PAGE_TRANSITION_RELOAD);
+ new_request->referrer =
+ Referrer(GURL(request.referrer), request.referrer_policy);
+ new_request->fetch_type = ServiceWorkerFetchType::FETCH;
+ return new_request;
+}
+
+// static
+void ServiceWorkerLoaderHelpers::SaveResponseHeaders(
+ const int status_code,
+ const std::string& status_text,
+ const ServiceWorkerHeaderMap& headers,
+ ResourceResponseHead* out_head) {
+ // Build a string instead of using HttpResponseHeaders::AddHeader on
+ // each header, since AddHeader has O(n^2) performance.
+ std::string buf(base::StringPrintf("HTTP/1.1 %d %s\r\n", status_code,
+ status_text.c_str()));
+ for (const auto& item : headers) {
+ buf.append(item.first);
+ buf.append(": ");
+ buf.append(item.second);
+ buf.append("\r\n");
+ }
+ buf.append("\r\n");
+
+ out_head->headers = new net::HttpResponseHeaders(
+ net::HttpUtil::AssembleRawHeaders(buf.c_str(), buf.size()));
+ if (out_head->mime_type.empty()) {
+ std::string mime_type;
+ out_head->headers->GetMimeType(&mime_type);
+ if (mime_type.empty())
+ mime_type = "text/plain";
+ out_head->mime_type = mime_type;
+ }
+}
+
+// static
+void ServiceWorkerLoaderHelpers::SaveResponseInfo(
+ const ServiceWorkerResponse& response,
+ ResourceResponseHead* out_head) {
+ out_head->was_fetched_via_service_worker = true;
+ out_head->was_fetched_via_foreign_fetch = false;
+ out_head->was_fallback_required_by_service_worker = false;
+ out_head->url_list_via_service_worker = response.url_list;
+ out_head->response_type_via_service_worker = response.response_type;
+ out_head->is_in_cache_storage = response.is_in_cache_storage;
+ out_head->cache_storage_cache_name = response.cache_storage_cache_name;
+ out_head->cors_exposed_header_names = response.cors_exposed_header_names;
+ out_head->did_service_worker_navigation_preload = false;
+}
+
+} // namespace content
diff --git a/chromium/content/common/service_worker/service_worker_loader_helpers.h b/chromium/content/common/service_worker/service_worker_loader_helpers.h
new file mode 100644
index 00000000000..9ec0a3e4699
--- /dev/null
+++ b/chromium/content/common/service_worker/service_worker_loader_helpers.h
@@ -0,0 +1,35 @@
+// Copyright 2017 The Chromium 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 CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_LOADER_HELPERS_H_
+#define CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_LOADER_HELPERS_H_
+
+#include "content/common/service_worker/service_worker_types.h"
+
+namespace content {
+
+struct ResourceRequest;
+struct ResourceResponseHead;
+
+// Helper functions for service worker classes that use URLLoader
+//(e.g., ServiceWorkerURLLoaderJob and ServiceWorkerSubresourceLoader).
+class ServiceWorkerLoaderHelpers {
+ public:
+ static std::unique_ptr<ServiceWorkerFetchRequest> CreateFetchRequest(
+ const ResourceRequest& request);
+
+ // Populates |out_head->headers| with the given |status_code|, |status_text|,
+ // and |headers|.
+ static void SaveResponseHeaders(const int status_code,
+ const std::string& status_text,
+ const ServiceWorkerHeaderMap& headers,
+ ResourceResponseHead* out_head);
+ // Populates |out_head| (except for headers) with given |response|.
+ static void SaveResponseInfo(const ServiceWorkerResponse& response,
+ ResourceResponseHead* out_head);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_LOADER_HELPERS_H_
diff --git a/chromium/content/common/service_worker/service_worker_messages.h b/chromium/content/common/service_worker/service_worker_messages.h
index f5dd1ca4568..1cff0666179 100644
--- a/chromium/content/common/service_worker/service_worker_messages.h
+++ b/chromium/content/common/service_worker/service_worker_messages.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Message definition file, included multiple times, hence no include guard.
+#ifndef CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_MESSAGES_H_
+#define CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_MESSAGES_H_
#include <stdint.h>
@@ -11,7 +12,6 @@
#include "base/strings/string16.h"
#include "base/time/time.h"
-#include "content/common/message_port.h"
#include "content/common/service_worker/service_worker_client_info.h"
#include "content/common/service_worker/service_worker_status_code.h"
#include "content/common/service_worker/service_worker_types.h"
@@ -20,8 +20,8 @@
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_param_traits.h"
#include "services/network/public/interfaces/fetch_api.mojom.h"
+#include "third_party/WebKit/common/message_port/message_port_channel.h"
#include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerError.h"
-#include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerEventResult.h"
#include "url/gurl.h"
#include "url/origin.h"
@@ -33,11 +33,8 @@
IPC_ENUM_TRAITS_MAX_VALUE(blink::mojom::ServiceWorkerErrorType,
blink::mojom::ServiceWorkerErrorType::kLast)
-IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerEventResult,
- blink::kWebServiceWorkerEventResultLast)
-
-IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerState,
- blink::kWebServiceWorkerStateLast)
+IPC_ENUM_TRAITS_MAX_VALUE(blink::mojom::ServiceWorkerState,
+ blink::mojom::ServiceWorkerState::kLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebServiceWorkerResponseError,
blink::kWebServiceWorkerResponseErrorLast)
@@ -110,16 +107,6 @@ IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerObjectInfo)
IPC_STRUCT_TRAITS_MEMBER(version_id)
IPC_STRUCT_TRAITS_END()
-IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerRegistrationOptions)
- IPC_STRUCT_TRAITS_MEMBER(scope)
-IPC_STRUCT_TRAITS_END()
-
-IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerRegistrationObjectInfo)
- IPC_STRUCT_TRAITS_MEMBER(handle_id)
- IPC_STRUCT_TRAITS_MEMBER(options)
- IPC_STRUCT_TRAITS_MEMBER(registration_id)
-IPC_STRUCT_TRAITS_END()
-
IPC_STRUCT_TRAITS_BEGIN(content::ServiceWorkerVersionAttributes)
IPC_STRUCT_TRAITS_MEMBER(installing)
IPC_STRUCT_TRAITS_MEMBER(waiting)
@@ -145,7 +132,7 @@ IPC_STRUCT_BEGIN(ServiceWorkerMsg_MessageToDocument_Params)
IPC_STRUCT_MEMBER(int, provider_id)
IPC_STRUCT_MEMBER(content::ServiceWorkerObjectInfo, service_worker_info)
IPC_STRUCT_MEMBER(base::string16, message)
- IPC_STRUCT_MEMBER(std::vector<content::MessagePort>, message_ports)
+ IPC_STRUCT_MEMBER(std::vector<blink::MessagePortChannel>, message_ports)
IPC_STRUCT_END()
IPC_STRUCT_TRAITS_BEGIN(content::PushEventPayload)
@@ -162,21 +149,11 @@ IPC_STRUCT_BEGIN(ServiceWorkerMsg_SetControllerServiceWorker_Params)
// |used_features| is the set of features that the worker has used.
// The values must be from blink::UseCounter::Feature enum.
IPC_STRUCT_MEMBER(std::set<uint32_t>, used_features)
-
- // Mojo endpoint to dispatch events to the controller.
- IPC_STRUCT_MEMBER(mojo::MessagePipeHandle, controller_event_dispatcher)
IPC_STRUCT_END()
//---------------------------------------------------------------------------
// Messages sent from the child process to the browser.
-IPC_MESSAGE_CONTROL5(ServiceWorkerHostMsg_RegisterServiceWorker,
- int /* thread_id */,
- int /* request_id */,
- int /* provider_id */,
- GURL /* script_url */,
- content::ServiceWorkerRegistrationOptions)
-
IPC_MESSAGE_CONTROL4(ServiceWorkerHostMsg_UpdateServiceWorker,
int /* thread_id */,
int /* request_id */,
@@ -189,22 +166,6 @@ IPC_MESSAGE_CONTROL4(ServiceWorkerHostMsg_UnregisterServiceWorker,
int /* provider_id */,
int64_t /* registration_id */)
-IPC_MESSAGE_CONTROL4(ServiceWorkerHostMsg_GetRegistration,
- int /* thread_id */,
- int /* request_id */,
- int /* provider_id */,
- GURL /* document_url */)
-
-IPC_MESSAGE_CONTROL3(ServiceWorkerHostMsg_GetRegistrations,
- int /* thread_id */,
- int /* request_id */,
- int /* provider_id */)
-
-IPC_MESSAGE_CONTROL3(ServiceWorkerHostMsg_GetRegistrationForReady,
- int /* thread_id */,
- int /* request_id */,
- int /* provider_id */)
-
// Asks the browser to enable/disable navigation preload for a registration.
IPC_MESSAGE_CONTROL5(ServiceWorkerHostMsg_EnableNavigationPreload,
int /* thread_id */,
@@ -235,7 +196,7 @@ IPC_MESSAGE_CONTROL5(
int /* provider_id */,
base::string16 /* message */,
url::Origin /* source_origin */,
- std::vector<content::MessagePort> /* sent_message_ports */)
+ std::vector<blink::MessagePortChannel> /* sent_message_ports */)
// Increments and decrements the ServiceWorker object's reference
// counting in the browser side. The ServiceWorker object is created
@@ -245,14 +206,6 @@ IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_IncrementServiceWorkerRefCount,
IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_DecrementServiceWorkerRefCount,
int /* handle_id */)
-// Increments and decrements the ServiceWorkerRegistration object's reference
-// counting in the browser side. The registration object is created with
-// ref-count==1 initially.
-IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_IncrementRegistrationRefCount,
- int /* registration_handle_id */)
-IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_DecrementRegistrationRefCount,
- int /* registration_handle_id */)
-
// Tells the browser to terminate a service worker. Used in layout tests to
// verify behavior when a service worker isn't running.
IPC_MESSAGE_CONTROL1(ServiceWorkerHostMsg_TerminateWorker,
@@ -273,7 +226,7 @@ IPC_MESSAGE_ROUTED3(
ServiceWorkerHostMsg_PostMessageToClient,
std::string /* uuid */,
base::string16 /* message */,
- std::vector<content::MessagePort> /* sent_message_ports */)
+ std::vector<blink::MessagePortChannel> /* sent_message_ports */)
// ServiceWorker -> Browser message to request that the ServiceWorkerStorage
// cache |data| associated with |url|.
@@ -323,13 +276,6 @@ IPC_MESSAGE_ROUTED1(ServiceWorkerHostMsg_ClaimClients,
// extract it and dispatch the message to the correct ServiceWorkerDispatcher
// on the correct thread.
-// Response to ServiceWorkerHostMsg_RegisterServiceWorker.
-IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerRegistered,
- int /* thread_id */,
- int /* request_id */,
- content::ServiceWorkerRegistrationObjectInfo,
- content::ServiceWorkerVersionAttributes)
-
// Response to ServiceWorkerHostMsg_UpdateServiceWorker.
IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_ServiceWorkerUpdated,
int /* thread_id */,
@@ -341,35 +287,6 @@ IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerUnregistered,
int /* request_id */,
bool /* is_success */)
-// Response to ServiceWorkerHostMsg_GetRegistration.
-IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_DidGetRegistration,
- int /* thread_id */,
- int /* request_id */,
- content::ServiceWorkerRegistrationObjectInfo,
- content::ServiceWorkerVersionAttributes)
-
-// Response to ServiceWorkerHostMsg_GetRegistrations.
-IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_DidGetRegistrations,
- int /* thread_id */,
- int /* request_id */,
- std::vector<content::ServiceWorkerRegistrationObjectInfo>,
- std::vector<content::ServiceWorkerVersionAttributes>)
-
-// Response to ServiceWorkerHostMsg_GetRegistrationForReady.
-IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_DidGetRegistrationForReady,
- int /* thread_id */,
- int /* request_id */,
- content::ServiceWorkerRegistrationObjectInfo,
- content::ServiceWorkerVersionAttributes)
-
-// Sent when any kind of registration error occurs during a
-// RegisterServiceWorker handler above.
-IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerRegistrationError,
- int /* thread_id */,
- int /* request_id */,
- blink::mojom::ServiceWorkerErrorType,
- base::string16 /* message */)
-
// Sent when any kind of update error occurs during a
// UpdateServiceWorker handler above.
IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerUpdateError,
@@ -386,27 +303,11 @@ IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerUnregistrationError,
blink::mojom::ServiceWorkerErrorType,
base::string16 /* message */)
-// Sent when any kind of registration error occurs during a
-// GetRegistration handler above.
-IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerGetRegistrationError,
- int /* thread_id */,
- int /* request_id */,
- blink::mojom::ServiceWorkerErrorType,
- base::string16 /* message */)
-
-// Sent when any kind of registration error occurs during a
-// GetRegistrations handler above.
-IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_ServiceWorkerGetRegistrationsError,
- int /* thread_id */,
- int /* request_id */,
- blink::mojom::ServiceWorkerErrorType,
- base::string16 /* message */)
-
// Informs the child process that the ServiceWorker's state has changed.
IPC_MESSAGE_CONTROL3(ServiceWorkerMsg_ServiceWorkerStateChanged,
int /* thread_id */,
int /* handle_id */,
- blink::WebServiceWorkerState)
+ blink::mojom::ServiceWorkerState)
// Tells the child process to set service workers for the given registration.
IPC_MESSAGE_CONTROL4(ServiceWorkerMsg_SetVersionAttributes,
@@ -508,3 +409,5 @@ IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_NavigateClientResponse,
IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_NavigateClientError,
int /* request_id */,
GURL /* url */)
+
+#endif // CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_MESSAGES_H_
diff --git a/chromium/content/common/service_worker/service_worker_provider.mojom b/chromium/content/common/service_worker/service_worker_provider.mojom
index b74a1da43ae..0198efeb6b5 100644
--- a/chromium/content/common/service_worker/service_worker_provider.mojom
+++ b/chromium/content/common/service_worker/service_worker_provider.mojom
@@ -7,6 +7,7 @@ module content.mojom;
import "content/common/service_worker/service_worker_container.mojom";
import "content/common/service_worker/service_worker_types.mojom";
import "content/public/common/url_loader_factory.mojom";
+import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom";
// Sent from the browser process to the renderer. Contains parameters for the
// constructor of ServiceWorkerNetworkProvider used for starting a service
@@ -15,7 +16,7 @@ struct ServiceWorkerProviderInfoForStartWorker {
int32 provider_id;
// |registration| and |attributes| are information about the service worker's
// registration used to populate ServiceWorkerGlobalScope#registration.
- ServiceWorkerRegistrationObjectInfo registration;
+ blink.mojom.ServiceWorkerRegistrationObjectInfo registration;
ServiceWorkerVersionAttributes attributes;
associated ServiceWorkerContainerHost host_ptr_info;
diff --git a/chromium/content/common/service_worker/service_worker_status_code_traits.cc b/chromium/content/common/service_worker/service_worker_status_code_traits.cc
deleted file mode 100644
index 65f26ae52e9..00000000000
--- a/chromium/content/common/service_worker/service_worker_status_code_traits.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/common/service_worker/service_worker_status_code_traits.h"
-
-#include "base/logging.h"
-#include "content/common/service_worker/service_worker_status_code.h"
-#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h"
-
-namespace mojo {
-
-// static
-blink::mojom::ServiceWorkerEventStatus EnumTraits<
- blink::mojom::ServiceWorkerEventStatus,
- content::ServiceWorkerStatusCode>::ToMojom(content::ServiceWorkerStatusCode
- input) {
- switch (input) {
- case content::SERVICE_WORKER_OK:
- return blink::mojom::ServiceWorkerEventStatus::COMPLETED;
- case content::SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED:
- return blink::mojom::ServiceWorkerEventStatus::REJECTED;
- case content::SERVICE_WORKER_ERROR_ABORT:
- return blink::mojom::ServiceWorkerEventStatus::ABORTED;
- default:
- NOTREACHED() << "Unexpected ServiceWorkerStatusCode: " << input;
- return blink::mojom::ServiceWorkerEventStatus::ABORTED;
- }
-}
-
-// static
-bool EnumTraits<blink::mojom::ServiceWorkerEventStatus,
- content::ServiceWorkerStatusCode>::
- FromMojom(blink::mojom::ServiceWorkerEventStatus input,
- content::ServiceWorkerStatusCode* out) {
- switch (input) {
- case blink::mojom::ServiceWorkerEventStatus::COMPLETED:
- *out = content::SERVICE_WORKER_OK;
- return true;
- case blink::mojom::ServiceWorkerEventStatus::REJECTED:
- *out = content::SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED;
- return true;
- case blink::mojom::ServiceWorkerEventStatus::ABORTED:
- *out = content::SERVICE_WORKER_ERROR_ABORT;
- return true;
- }
- NOTREACHED();
- return false;
-}
-
-} // namespace content
diff --git a/chromium/content/common/service_worker/service_worker_status_code_traits.h b/chromium/content/common/service_worker/service_worker_status_code_traits.h
deleted file mode 100644
index 98139c1becd..00000000000
--- a/chromium/content/common/service_worker/service_worker_status_code_traits.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2016 The Chromium 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 CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_STATUS_CODE_TRAITS_H_
-#define CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_STATUS_CODE_TRAITS_H_
-
-#include "content/common/service_worker/service_worker_status_code.h"
-#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_event_status.mojom.h"
-
-namespace mojo {
-
-template <>
-struct EnumTraits<blink::mojom::ServiceWorkerEventStatus,
- content::ServiceWorkerStatusCode> {
- static blink::mojom::ServiceWorkerEventStatus ToMojom(
- content::ServiceWorkerStatusCode input);
-
- static bool FromMojom(blink::mojom::ServiceWorkerEventStatus input,
- content::ServiceWorkerStatusCode* out);
-};
-
-} // namespace mojo
-
-#endif // CONTENT_COMMON_SERVICE_WORKER_SERVICE_WORKER_STATUS_CODE_TRAITS_H_
diff --git a/chromium/content/common/service_worker/service_worker_types.cc b/chromium/content/common/service_worker/service_worker_types.cc
index 96999ef6cd3..acd914b074d 100644
--- a/chromium/content/common/service_worker/service_worker_types.cc
+++ b/chromium/content/common/service_worker/service_worker_types.cc
@@ -135,7 +135,7 @@ size_t ServiceWorkerResponse::EstimatedStructSize() {
ServiceWorkerObjectInfo::ServiceWorkerObjectInfo()
: handle_id(kInvalidServiceWorkerHandleId),
- state(blink::kWebServiceWorkerStateUnknown),
+ state(blink::mojom::ServiceWorkerState::kUnknown),
version_id(kInvalidServiceWorkerVersionId) {}
bool ServiceWorkerObjectInfo::IsValid() const {
@@ -143,15 +143,6 @@ bool ServiceWorkerObjectInfo::IsValid() const {
version_id != kInvalidServiceWorkerVersionId;
}
-ServiceWorkerRegistrationOptions::ServiceWorkerRegistrationOptions(
- const GURL& scope)
- : scope(scope) {}
-
-ServiceWorkerRegistrationObjectInfo::ServiceWorkerRegistrationObjectInfo()
- : handle_id(kInvalidServiceWorkerRegistrationHandleId),
- registration_id(kInvalidServiceWorkerRegistrationId) {
-}
-
ServiceWorkerClientQueryOptions::ServiceWorkerClientQueryOptions()
: client_type(blink::kWebServiceWorkerClientTypeWindow),
include_uncontrolled(false) {}
diff --git a/chromium/content/common/service_worker/service_worker_types.h b/chromium/content/common/service_worker/service_worker_types.h
index 8129f9b48b2..123f986b037 100644
--- a/chromium/content/common/service_worker/service_worker_types.h
+++ b/chromium/content/common/service_worker/service_worker_types.h
@@ -23,7 +23,8 @@
#include "third_party/WebKit/public/platform/WebPageVisibilityState.h"
#include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerClientType.h"
#include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerResponseError.h"
-#include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWorkerState.h"
+#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_registration.mojom.h"
+#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_state.mojom.h"
#include "url/gurl.h"
// This file is to have common definitions that are to be shared by
@@ -49,8 +50,6 @@ extern const char kFetchScriptError[];
// Constants for invalid identifiers.
static const int kInvalidServiceWorkerHandleId = -1;
-static const int kInvalidServiceWorkerRegistrationHandleId = -1;
-static const int64_t kInvalidServiceWorkerRegistrationId = -1;
static const int64_t kInvalidServiceWorkerVersionId = -1;
static const int64_t kInvalidServiceWorkerResourceId = -1;
static const int kInvalidEmbeddedWorkerThreadId = -1;
@@ -181,26 +180,10 @@ struct CONTENT_EXPORT ServiceWorkerObjectInfo {
int handle_id;
GURL url;
- blink::WebServiceWorkerState state;
+ blink::mojom::ServiceWorkerState state;
int64_t version_id;
};
-// Represents options for register():
-// https://w3c.github.io/ServiceWorker/#dictdef-registrationoptions
-struct CONTENT_EXPORT ServiceWorkerRegistrationOptions {
- ServiceWorkerRegistrationOptions() = default;
- explicit ServiceWorkerRegistrationOptions(const GURL& scope);
- GURL scope;
- // TODO(yuryu): Other values will be added as they are supported later.
-};
-
-struct CONTENT_EXPORT ServiceWorkerRegistrationObjectInfo {
- ServiceWorkerRegistrationObjectInfo();
- int handle_id;
- ServiceWorkerRegistrationOptions options;
- int64_t registration_id;
-};
-
struct CONTENT_EXPORT ServiceWorkerVersionAttributes {
ServiceWorkerObjectInfo installing;
ServiceWorkerObjectInfo waiting;
diff --git a/chromium/content/common/service_worker/service_worker_types.mojom b/chromium/content/common/service_worker/service_worker_types.mojom
index 9aa4bf08e57..ae8c0bd40f0 100644
--- a/chromium/content/common/service_worker/service_worker_types.mojom
+++ b/chromium/content/common/service_worker/service_worker_types.mojom
@@ -19,12 +19,7 @@ enum ServiceWorkerProviderType {
SERVICE_WORKER_PROVIDER_FOR_CONTROLLER
};
-// Container for delivering the information about the ServiceWorkerRegistration.
-// Defined in service_worker_types.h.
-[Native]
-struct ServiceWorkerRegistrationObjectInfo;
-
-// Container for delivering the information about the installing, waiting and
+// Struct for delivering the information about the installing, waiting and
// active ServiceWorkers.
// Defined in service_worker_types.h.
[Native]
diff --git a/chromium/content/common/service_worker/service_worker_types.typemap b/chromium/content/common/service_worker/service_worker_types.typemap
index e1122fb182f..ed6313591de 100644
--- a/chromium/content/common/service_worker/service_worker_types.typemap
+++ b/chromium/content/common/service_worker/service_worker_types.typemap
@@ -16,6 +16,5 @@ sources = [
]
type_mappings = [
"content.mojom.ServiceWorkerProviderType=::content::ServiceWorkerProviderType",
- "content.mojom.ServiceWorkerRegistrationObjectInfo=::content::ServiceWorkerRegistrationObjectInfo",
"content.mojom.ServiceWorkerVersionAttributes=::content::ServiceWorkerVersionAttributes",
]
diff --git a/chromium/content/common/service_worker/service_worker_utils.cc b/chromium/content/common/service_worker/service_worker_utils.cc
index 56fead10b5f..92b9eee0d48 100644
--- a/chromium/content/common/service_worker/service_worker_utils.cc
+++ b/chromium/content/common/service_worker/service_worker_utils.cc
@@ -4,6 +4,7 @@
#include "content/common/service_worker/service_worker_utils.h"
+#include <sstream>
#include <string>
#include "base/command_line.h"
@@ -147,6 +148,14 @@ bool ServiceWorkerUtils::IsScriptStreamingEnabled() {
return base::FeatureList::IsEnabled(features::kServiceWorkerScriptStreaming);
}
+// static
+std::string ServiceWorkerUtils::ErrorTypeToString(
+ blink::mojom::ServiceWorkerErrorType error) {
+ std::ostringstream oss;
+ oss << error;
+ return oss.str();
+}
+
bool LongestScopeMatcher::MatchLongest(const GURL& scope) {
if (!ServiceWorkerUtils::ScopeMatches(scope, url_))
return false;
diff --git a/chromium/content/common/service_worker/service_worker_utils.h b/chromium/content/common/service_worker/service_worker_utils.h
index 3ffbd62bc08..3dbd936f8b6 100644
--- a/chromium/content/common/service_worker/service_worker_utils.h
+++ b/chromium/content/common/service_worker/service_worker_utils.h
@@ -13,6 +13,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/resource_type.h"
#include "content/public/common/service_worker_modes.h"
+#include "third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom.h"
#include "url/gurl.h"
namespace content {
@@ -60,6 +61,9 @@ class ServiceWorkerUtils {
static bool IsBrowserAssignedProviderId(int provider_id) {
return provider_id < kInvalidServiceWorkerProviderId;
}
+
+ static std::string ErrorTypeToString(
+ blink::mojom::ServiceWorkerErrorType error);
};
class CONTENT_EXPORT LongestScopeMatcher {
diff --git a/chromium/content/common/shared_worker/OWNERS b/chromium/content/common/shared_worker/OWNERS
new file mode 100644
index 00000000000..08850f42120
--- /dev/null
+++ b/chromium/content/common/shared_worker/OWNERS
@@ -0,0 +1,2 @@
+per-file *.mojom=set noparent
+per-file *.mojom=file://ipc/SECURITY_OWNERS
diff --git a/chromium/content/common/shared_worker/shared_worker.mojom b/chromium/content/common/shared_worker/shared_worker.mojom
new file mode 100644
index 00000000000..dc28305d15f
--- /dev/null
+++ b/chromium/content/common/shared_worker/shared_worker.mojom
@@ -0,0 +1,17 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module content.mojom;
+
+// Interface used by the host to control the shared worker.
+interface SharedWorker {
+ // Called to establish a new client connection to the shared worker. The
+ // |connection_id| parameter will be echoed back to the host via the
+ // OnConnected method.
+ Connect(int32 connection_id, handle<message_pipe> message_port);
+
+ // Called to terminate the shared worker. This results in the shared worker
+ // closing its end of the mojo connection.
+ Terminate();
+};
diff --git a/chromium/content/common/shared_worker/shared_worker_client.mojom b/chromium/content/common/shared_worker/shared_worker_client.mojom
new file mode 100644
index 00000000000..0ff30a396fe
--- /dev/null
+++ b/chromium/content/common/shared_worker/shared_worker_client.mojom
@@ -0,0 +1,27 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module content.mojom;
+
+import "third_party/WebKit/public/platform/web_feature.mojom";
+import "third_party/WebKit/public/web/shared_worker_creation_context_type.mojom";
+
+// An interface used by clients (e.g., the renderer where "new SharedWorker()"
+// was invoked) to observe events from a shared worker.
+interface SharedWorkerClient {
+ // Indicates that the shared worker process has started (or may have already
+ // been started). The shared worker script is not necessarily loaded yet.
+ // This event will be followed by either OnConnected or OnScriptLoadFailed.
+ OnCreated(blink.mojom.SharedWorkerCreationContextType creation_context_type);
+
+ // Indicates that the shared worker process is up and running, script loaded.
+ OnConnected(array<blink.mojom.WebFeature> features_used);
+
+ // Indicates that the shared worker script failed to load.
+ OnScriptLoadFailed();
+
+ // Indicates that the shared worker used a feature. This is intended to be
+ // logged by the client-side feature logging infrastructure.
+ OnFeatureUsed(blink.mojom.WebFeature feature);
+};
diff --git a/chromium/content/common/shared_worker/shared_worker_connector.mojom b/chromium/content/common/shared_worker/shared_worker_connector.mojom
new file mode 100644
index 00000000000..f0b663fb786
--- /dev/null
+++ b/chromium/content/common/shared_worker/shared_worker_connector.mojom
@@ -0,0 +1,20 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module content.mojom;
+
+import "content/common/shared_worker/shared_worker_client.mojom";
+import "content/common/shared_worker/shared_worker_info.mojom";
+import "third_party/WebKit/public/web/shared_worker_creation_context_type.mojom";
+
+// This interface is exposed to enable a client to create and connect to a
+// shared worker.
+interface SharedWorkerConnector {
+ // Connect to (and create if necessary) a SharedWorker specified by |info|.
+ // The SharedWorker will be terminated if all clients go away.
+ Connect(SharedWorkerInfo info,
+ SharedWorkerClient client,
+ blink.mojom.SharedWorkerCreationContextType creation_context_type,
+ handle<message_pipe> message_port);
+};
diff --git a/chromium/content/common/shared_worker/shared_worker_factory.mojom b/chromium/content/common/shared_worker/shared_worker_factory.mojom
new file mode 100644
index 00000000000..98ece293006
--- /dev/null
+++ b/chromium/content/common/shared_worker/shared_worker_factory.mojom
@@ -0,0 +1,27 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module content.mojom;
+
+import "content/common/shared_worker/shared_worker.mojom";
+import "content/common/shared_worker/shared_worker_host.mojom";
+import "content/common/shared_worker/shared_worker_info.mojom";
+import "third_party/WebKit/public/web/worker_content_settings_proxy.mojom";
+
+// This interface is used to instantiate a shared worker. It is exported from a
+// child process where the shared worker should run.
+interface SharedWorkerFactory {
+ // Create a new shared worker. The |host| interface receives events from the
+ // shared worker.
+ //
+ // TODO(darin): Eliminate |route_id| corresponding to legacy Chrome IPC,
+ // which is only needed for DevTools.
+ //
+ CreateSharedWorker(SharedWorkerInfo info,
+ bool pause_on_start,
+ int32 route_id,
+ blink.mojom.WorkerContentSettingsProxy content_settings,
+ SharedWorkerHost host,
+ SharedWorker& shared_worker);
+};
diff --git a/chromium/content/common/shared_worker/shared_worker_host.mojom b/chromium/content/common/shared_worker/shared_worker_host.mojom
new file mode 100644
index 00000000000..1a893fac15d
--- /dev/null
+++ b/chromium/content/common/shared_worker/shared_worker_host.mojom
@@ -0,0 +1,33 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module content.mojom;
+
+import "third_party/WebKit/public/platform/web_feature.mojom";
+
+// Each shared worker has a corresponding host. The host controls the lifetime
+// of the shared worker. This interface is used by the shared worker to talk to
+// its host.
+interface SharedWorkerHost {
+ // Called in response to SharedWorker's Connect method. The |connection_id|
+ // parameter is the same value passed to the Connect method.
+ OnConnected(int32 connection_id);
+
+ // Indicates that the shared worker self-closed. This should trigger the host
+ // to terminate the shared worker.
+ OnContextClosed();
+
+ // Indicates that the shared worker is ready for inspection.
+ OnReadyForInspection();
+
+ // Indicates that the script successfully loaded.
+ OnScriptLoaded();
+
+ // Indicates that the script failed to load.
+ OnScriptLoadFailed();
+
+ // Indicates that the shared worker used a feature. This is intended to be
+ // logged by the client-side feature logging infrastructure.
+ OnFeatureUsed(blink.mojom.WebFeature feature);
+};
diff --git a/chromium/content/common/shared_worker/shared_worker_info.mojom b/chromium/content/common/shared_worker/shared_worker_info.mojom
new file mode 100644
index 00000000000..0b415391433
--- /dev/null
+++ b/chromium/content/common/shared_worker/shared_worker_info.mojom
@@ -0,0 +1,22 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module content.mojom;
+
+import "third_party/WebKit/public/platform/address_space.mojom";
+import "third_party/WebKit/public/platform/content_security_policy.mojom";
+import "url/mojo/url.mojom";
+
+// Meta data that is necessary to create a new shared worker context. This
+// structure gets populated when a new SharedWorker object is created in the
+// parent context (e.g. Document), and passed onto the destination child
+// process where the shared worker runs.
+struct SharedWorkerInfo {
+ url.mojom.Url url;
+ string name;
+ string content_security_policy;
+ blink.mojom.ContentSecurityPolicyType content_security_policy_type;
+ blink.mojom.AddressSpace creation_address_space;
+ bool data_saver_enabled;
+};
diff --git a/chromium/content/common/site_isolation_policy.cc b/chromium/content/common/site_isolation_policy.cc
index 5612596aed6..8ee09a9c4f8 100644
--- a/chromium/content/common/site_isolation_policy.cc
+++ b/chromium/content/common/site_isolation_policy.cc
@@ -14,7 +14,8 @@ namespace content {
// static
bool SiteIsolationPolicy::UseDedicatedProcessesForAllSites() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kSitePerProcess);
+ switches::kSitePerProcess) ||
+ base::FeatureList::IsEnabled(features::kSitePerProcess);
}
// static
diff --git a/chromium/content/common/speech_recognition_messages.h b/chromium/content/common/speech_recognition_messages.h
index 1892fce4ba6..c004e5c01fd 100644
--- a/chromium/content/common/speech_recognition_messages.h
+++ b/chromium/content/common/speech_recognition_messages.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Multiply-included message file, hence no include guard.
+#ifndef CONTENT_COMMON_SPEECH_RECOGNITION_MESSAGES_H_
+#define CONTENT_COMMON_SPEECH_RECOGNITION_MESSAGES_H_
#include <stdint.h>
@@ -127,3 +128,5 @@ IPC_MESSAGE_ROUTED4(SpeechRecognitionMsg_AudioReceiverReady,
media::AudioParameters /* params */,
base::SharedMemoryHandle /* memory */,
base::SyncSocket::TransitDescriptor /* socket */)
+
+#endif // CONTENT_COMMON_SPEECH_RECOGNITION_MESSAGES_H_
diff --git a/chromium/content/common/swapped_out_messages.cc b/chromium/content/common/swapped_out_messages.cc
index 442cd3e1fe2..74b51acf7c9 100644
--- a/chromium/content/common/swapped_out_messages.cc
+++ b/chromium/content/common/swapped_out_messages.cc
@@ -19,7 +19,7 @@ bool SwappedOutMessages::CanSendWhileSwappedOut(const IPC::Message* msg) {
switch (msg->type()) {
// Handled by RenderWidgetHost.
case InputHostMsg_HandleInputEvent_ACK::ID:
- case ViewHostMsg_UpdateRect::ID:
+ case ViewHostMsg_ResizeOrRepaint_ACK::ID:
// Handled by RenderWidgetHostView.
case ViewHostMsg_SetNeedsBeginFrames::ID:
// Handled by RenderViewHost.
@@ -28,8 +28,6 @@ bool SwappedOutMessages::CanSendWhileSwappedOut(const IPC::Message* msg) {
case ViewHostMsg_Focus::ID:
case ViewHostMsg_ShowFullscreenWidget::ID:
case ViewHostMsg_ShowWidget::ID:
- // Handled by SharedWorkerMessageFilter.
- case ViewHostMsg_DocumentDetached::ID:
// Allow cross-process JavaScript calls.
case ViewHostMsg_RouteCloseEvent::ID:
// Send page scale factor reset notification upon cross-process navigations.
diff --git a/chromium/content/common/text_input_client_messages.h b/chromium/content/common/text_input_client_messages.h
index f66196cc6c5..c8c8c8e8bb0 100644
--- a/chromium/content/common/text_input_client_messages.h
+++ b/chromium/content/common/text_input_client_messages.h
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Multiply-included message file, hence no include guard
+#ifndef CONTENT_COMMON_TEXT_INPUT_CLIENT_MESSAGES_H_
+#define CONTENT_COMMON_TEXT_INPUT_CLIENT_MESSAGES_H_
#include <stddef.h>
@@ -66,3 +67,4 @@ IPC_MESSAGE_ROUTED2(TextInputClientReplyMsg_GotStringAtPoint,
gfx::Point)
#endif // defined(OS_MACOSX)
+#endif // CONTENT_COMMON_TEXT_INPUT_CLIENT_MESSAGES_H_
diff --git a/chromium/content/common/throttling_url_loader.cc b/chromium/content/common/throttling_url_loader.cc
index 88f560a59e7..ba68b0580a1 100644
--- a/chromium/content/common/throttling_url_loader.cc
+++ b/chromium/content/common/throttling_url_loader.cc
@@ -5,10 +5,86 @@
#include "content/common/throttling_url_loader.h"
#include "base/single_thread_task_runner.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "content/public/common/browser_side_navigation_policy.h"
namespace content {
+class ThrottlingURLLoader::ForwardingThrottleDelegate
+ : public URLLoaderThrottle::Delegate {
+ public:
+ ForwardingThrottleDelegate(ThrottlingURLLoader* loader,
+ URLLoaderThrottle* throttle)
+ : loader_(loader), throttle_(throttle) {}
+ ~ForwardingThrottleDelegate() override = default;
+
+ // URLLoaderThrottle::Delegate:
+ void CancelWithError(int error_code) override {
+ if (!loader_)
+ return;
+
+ ScopedDelegateCall scoped_delegate_call(this);
+ loader_->CancelWithError(error_code);
+ }
+
+ void Resume() override {
+ if (!loader_)
+ return;
+
+ ScopedDelegateCall scoped_delegate_call(this);
+ loader_->StopDeferringForThrottle(throttle_);
+ }
+
+ void PauseReadingBodyFromNet() override {
+ if (!loader_)
+ return;
+
+ ScopedDelegateCall scoped_delegate_call(this);
+ loader_->PauseReadingBodyFromNet(throttle_);
+ }
+
+ void ResumeReadingBodyFromNet() override {
+ if (!loader_)
+ return;
+
+ ScopedDelegateCall scoped_delegate_call(this);
+ loader_->ResumeReadingBodyFromNet(throttle_);
+ }
+
+ void Detach() { loader_ = nullptr; }
+
+ private:
+ // This class helps ThrottlingURLLoader to keep track of whether it is being
+ // called by its throttles.
+ // If ThrottlingURLLoader is destoyed while any of the throttles is calling
+ // into it, it delays destruction of the throttles. That way throttles don't
+ // need to worry about any delegate calls may destory them synchronously.
+ class ScopedDelegateCall {
+ public:
+ explicit ScopedDelegateCall(ForwardingThrottleDelegate* owner)
+ : owner_(owner) {
+ DCHECK(owner_->loader_);
+
+ owner_->loader_->inside_delegate_calls_++;
+ }
+
+ ~ScopedDelegateCall() {
+ // The loader may have been detached and destroyed.
+ if (owner_->loader_)
+ owner_->loader_->inside_delegate_calls_--;
+ }
+
+ private:
+ ForwardingThrottleDelegate* const owner_;
+ DISALLOW_COPY_AND_ASSIGN(ScopedDelegateCall);
+ };
+
+ ThrottlingURLLoader* loader_;
+ URLLoaderThrottle* const throttle_;
+
+ DISALLOW_COPY_AND_ASSIGN(ForwardingThrottleDelegate);
+};
+
ThrottlingURLLoader::StartInfo::StartInfo(
mojom::URLLoaderFactory* in_url_loader_factory,
int32_t in_routing_id,
@@ -85,7 +161,20 @@ std::unique_ptr<ThrottlingURLLoader> ThrottlingURLLoader::CreateLoaderAndStart(
return loader;
}
-ThrottlingURLLoader::~ThrottlingURLLoader() {}
+ThrottlingURLLoader::~ThrottlingURLLoader() {
+ if (inside_delegate_calls_ > 0) {
+ // A throttle is calling into this object. In this case, delay destruction
+ // of the throttles, so that throttles don't need to worry about any
+ // delegate calls may destory them synchronously.
+ for (auto& entry : throttles_)
+ entry.delegate->Detach();
+
+ auto throttles =
+ std::make_unique<std::vector<ThrottleEntry>>(std::move(throttles_));
+ base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE,
+ std::move(throttles));
+ }
+}
void ThrottlingURLLoader::FollowRedirect() {
if (url_loader_)
@@ -119,13 +208,9 @@ ThrottlingURLLoader::ThrottlingURLLoader(
: forwarding_client_(client),
client_binding_(this),
traffic_annotation_(traffic_annotation) {
- if (throttles.size() > 0) {
- // TODO(yzshen): Implement a URLLoaderThrottle subclass which handles a list
- // of URLLoaderThrottles.
- CHECK_EQ(1u, throttles.size());
- throttle_ = std::move(throttles[0]);
- throttle_->set_delegate(this);
- }
+ throttles_.reserve(throttles.size());
+ for (auto& throttle : throttles)
+ throttles_.emplace_back(this, std::move(throttle));
}
void ThrottlingURLLoader::Start(
@@ -142,11 +227,16 @@ void ThrottlingURLLoader::Start(
if (options & mojom::kURLLoadOptionSynchronous)
is_synchronous_ = true;
- if (throttle_) {
+ DCHECK(deferring_throttles_.empty());
+ if (!throttles_.empty()) {
bool deferred = false;
- throttle_->WillStartRequest(url_request, &deferred);
- if (loader_cancelled_)
- return;
+ for (auto& entry : throttles_) {
+ auto* throttle = entry.throttle.get();
+ bool throttle_deferred = false;
+ throttle->WillStartRequest(url_request, &throttle_deferred);
+ if (!HandleThrottleResult(throttle, throttle_deferred, &deferred))
+ return;
+ }
if (deferred) {
deferred_stage_ = DEFERRED_START;
@@ -179,20 +269,45 @@ void ThrottlingURLLoader::StartNow(
if (factory) {
DCHECK(!start_loader_callback);
- mojom::URLLoaderPtr url_loader;
- auto url_loader_request = mojo::MakeRequest(&url_loader);
- url_loader_ = std::move(url_loader);
factory->CreateLoaderAndStart(
- std::move(url_loader_request), routing_id, request_id, options,
+ mojo::MakeRequest(&url_loader_), routing_id, request_id, options,
url_request, std::move(client),
net::MutableNetworkTrafficAnnotationTag(traffic_annotation_));
} else {
- mojom::URLLoaderPtr url_loader;
- auto url_loader_request = mojo::MakeRequest(&url_loader);
- url_loader_ = std::move(url_loader);
std::move(start_loader_callback)
- .Run(std::move(url_loader_request), std::move(client));
+ .Run(mojo::MakeRequest(&url_loader_), std::move(client));
}
+
+ if (!pausing_reading_body_from_net_throttles_.empty())
+ url_loader_->PauseReadingBodyFromNet();
+
+ if (priority_info_) {
+ auto priority_info = std::move(priority_info_);
+ url_loader_->SetPriority(priority_info->priority,
+ priority_info->intra_priority_value);
+ }
+}
+
+bool ThrottlingURLLoader::HandleThrottleResult(URLLoaderThrottle* throttle,
+ bool throttle_deferred,
+ bool* should_defer) {
+ DCHECK(!deferring_throttles_.count(throttle));
+ if (loader_cancelled_)
+ return false;
+ *should_defer |= throttle_deferred;
+ if (throttle_deferred)
+ deferring_throttles_.insert(throttle);
+ return true;
+}
+
+void ThrottlingURLLoader::StopDeferringForThrottle(
+ URLLoaderThrottle* throttle) {
+ if (deferring_throttles_.find(throttle) == deferring_throttles_.end())
+ return;
+
+ deferring_throttles_.erase(throttle);
+ if (deferring_throttles_.empty() && !loader_cancelled_)
+ Resume();
}
void ThrottlingURLLoader::OnReceiveResponse(
@@ -201,12 +316,17 @@ void ThrottlingURLLoader::OnReceiveResponse(
mojom::DownloadedTempFilePtr downloaded_file) {
DCHECK_EQ(DEFERRED_NONE, deferred_stage_);
DCHECK(!loader_cancelled_);
+ DCHECK(deferring_throttles_.empty());
- if (throttle_) {
+ if (!throttles_.empty()) {
bool deferred = false;
- throttle_->WillProcessResponse(&deferred);
- if (loader_cancelled_)
- return;
+ for (auto& entry : throttles_) {
+ auto* throttle = entry.throttle.get();
+ bool throttle_deferred = false;
+ throttle->WillProcessResponse(&throttle_deferred);
+ if (!HandleThrottleResult(throttle, throttle_deferred, &deferred))
+ return;
+ }
if (deferred) {
deferred_stage_ = DEFERRED_RESPONSE;
@@ -226,12 +346,17 @@ void ThrottlingURLLoader::OnReceiveRedirect(
const ResourceResponseHead& response_head) {
DCHECK_EQ(DEFERRED_NONE, deferred_stage_);
DCHECK(!loader_cancelled_);
+ DCHECK(deferring_throttles_.empty());
- if (throttle_) {
+ if (!throttles_.empty()) {
bool deferred = false;
- throttle_->WillRedirectRequest(redirect_info, &deferred);
- if (loader_cancelled_)
- return;
+ for (auto& entry : throttles_) {
+ auto* throttle = entry.throttle.get();
+ bool throttle_deferred = false;
+ throttle->WillRedirectRequest(redirect_info, &throttle_deferred);
+ if (!HandleThrottleResult(throttle, throttle_deferred, &deferred))
+ return;
+ }
if (deferred) {
deferred_stage_ = DEFERRED_REDIRECT;
@@ -308,8 +433,6 @@ void ThrottlingURLLoader::OnClientConnectionError() {
}
void ThrottlingURLLoader::CancelWithError(int error_code) {
- // TODO(yzshen): Support a mode that cancellation also deletes the disk cache
- // entry.
if (loader_cancelled_)
return;
@@ -326,18 +449,14 @@ void ThrottlingURLLoader::Resume() {
if (loader_cancelled_ || deferred_stage_ == DEFERRED_NONE)
return;
- switch (deferred_stage_) {
+ auto prev_deferred_stage = deferred_stage_;
+ deferred_stage_ = DEFERRED_NONE;
+ switch (prev_deferred_stage) {
case DEFERRED_START: {
StartNow(start_info_->url_loader_factory, start_info_->routing_id,
start_info_->request_id, start_info_->options,
std::move(start_info_->start_loader_callback),
start_info_->url_request, std::move(start_info_->task_runner));
-
- if (priority_info_) {
- auto priority_info = std::move(priority_info_);
- url_loader_->SetPriority(priority_info->priority,
- priority_info->intra_priority_value);
- }
break;
}
case DEFERRED_REDIRECT: {
@@ -357,7 +476,42 @@ void ThrottlingURLLoader::Resume() {
NOTREACHED();
break;
}
- deferred_stage_ = DEFERRED_NONE;
}
+void ThrottlingURLLoader::PauseReadingBodyFromNet(URLLoaderThrottle* throttle) {
+ if (pausing_reading_body_from_net_throttles_.empty() && url_loader_)
+ url_loader_->PauseReadingBodyFromNet();
+
+ pausing_reading_body_from_net_throttles_.insert(throttle);
+}
+
+void ThrottlingURLLoader::ResumeReadingBodyFromNet(
+ URLLoaderThrottle* throttle) {
+ auto iter = pausing_reading_body_from_net_throttles_.find(throttle);
+ if (iter == pausing_reading_body_from_net_throttles_.end())
+ return;
+
+ pausing_reading_body_from_net_throttles_.erase(iter);
+ if (pausing_reading_body_from_net_throttles_.empty() && url_loader_)
+ url_loader_->ResumeReadingBodyFromNet();
+}
+
+ThrottlingURLLoader::ThrottleEntry::ThrottleEntry(
+ ThrottlingURLLoader* loader,
+ std::unique_ptr<URLLoaderThrottle> the_throttle)
+ : delegate(
+ base::MakeUnique<ForwardingThrottleDelegate>(loader,
+ the_throttle.get())),
+ throttle(std::move(the_throttle)) {
+ throttle->set_delegate(delegate.get());
+}
+
+ThrottlingURLLoader::ThrottleEntry::ThrottleEntry(ThrottleEntry&& other) =
+ default;
+
+ThrottlingURLLoader::ThrottleEntry::~ThrottleEntry() = default;
+
+ThrottlingURLLoader::ThrottleEntry& ThrottlingURLLoader::ThrottleEntry::
+operator=(ThrottleEntry&& other) = default;
+
} // namespace content
diff --git a/chromium/content/common/throttling_url_loader.h b/chromium/content/common/throttling_url_loader.h
index 686dc4b1d75..4ab2e389b45 100644
--- a/chromium/content/common/throttling_url_loader.h
+++ b/chromium/content/common/throttling_url_loader.h
@@ -31,13 +31,11 @@ class URLLoaderFactory;
// interfaces. It applies a list of URLLoaderThrottle instances which could
// defer, resume or cancel the URL loading. If the Mojo connection fails during
// the request it is canceled with net::ERR_FAILED.
-class CONTENT_EXPORT ThrottlingURLLoader : public mojom::URLLoaderClient,
- public URLLoaderThrottle::Delegate {
+class CONTENT_EXPORT ThrottlingURLLoader : public mojom::URLLoaderClient {
public:
// |factory| and |client| must stay alive during the lifetime of the returned
- // object.
- // Please note that the request may not start immediately since it could be
- // deferred by throttles.
+ // object. Please note that the request may not start immediately since it
+ // could be deferred by throttles.
static std::unique_ptr<ThrottlingURLLoader> CreateLoaderAndStart(
mojom::URLLoaderFactory* factory,
std::vector<std::unique_ptr<URLLoaderThrottle>> throttles,
@@ -74,7 +72,14 @@ class CONTENT_EXPORT ThrottlingURLLoader : public mojom::URLLoaderClient,
// Disconnects the client connection and releases the URLLoader.
void DisconnectClient();
+ // Sets the forwarding client to receive all subsequent notifications.
+ void set_forwarding_client(mojom::URLLoaderClient* client) {
+ forwarding_client_ = client;
+ }
+
private:
+ class ForwardingThrottleDelegate;
+
ThrottlingURLLoader(
std::vector<std::unique_ptr<URLLoaderThrottle>> throttles,
mojom::URLLoaderClient* client,
@@ -99,6 +104,19 @@ class CONTENT_EXPORT ThrottlingURLLoader : public mojom::URLLoaderClient,
const ResourceRequest& url_request,
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
+ // Processes the result of a URLLoaderThrottle call, adding the throttle to
+ // the blocking set if it deferred and updating |*should_defer| accordingly.
+ // Returns |true| if the request should continue to be processed (regardless
+ // of whether it's been deferred) or |false| if it's been cancelled.
+ bool HandleThrottleResult(URLLoaderThrottle* throttle,
+ bool throttle_deferred,
+ bool* should_defer);
+
+ // Stops a given throttle from deferring the request. If this was not the last
+ // deferring throttle, the request remains deferred. Otherwise it resumes
+ // progress.
+ void StopDeferringForThrottle(URLLoaderThrottle* throttle);
+
// mojom::URLLoaderClient implementation:
void OnReceiveResponse(const ResourceResponseHead& response_head,
const base::Optional<net::SSLInfo>& ssl_info,
@@ -117,9 +135,11 @@ class CONTENT_EXPORT ThrottlingURLLoader : public mojom::URLLoaderClient,
void OnClientConnectionError();
- // URLLoaderThrottle::Delegate:
- void CancelWithError(int error_code) override;
- void Resume() override;
+ void CancelWithError(int error_code);
+ void Resume();
+
+ void PauseReadingBodyFromNet(URLLoaderThrottle* throttle);
+ void ResumeReadingBodyFromNet(URLLoaderThrottle* throttle);
enum DeferredStage {
DEFERRED_NONE,
@@ -131,8 +151,28 @@ class CONTENT_EXPORT ThrottlingURLLoader : public mojom::URLLoaderClient,
bool loader_cancelled_ = false;
bool is_synchronous_ = false;
- std::unique_ptr<URLLoaderThrottle> throttle_;
+ struct ThrottleEntry {
+ ThrottleEntry(ThrottlingURLLoader* loader,
+ std::unique_ptr<URLLoaderThrottle> the_throttle);
+ ThrottleEntry(ThrottleEntry&& other);
+ ~ThrottleEntry();
+
+ ThrottleEntry& operator=(ThrottleEntry&& other);
+ std::unique_ptr<ForwardingThrottleDelegate> delegate;
+ std::unique_ptr<URLLoaderThrottle> throttle;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ThrottleEntry);
+ };
+
+ std::vector<ThrottleEntry> throttles_;
+ std::set<URLLoaderThrottle*> deferring_throttles_;
+ std::set<URLLoaderThrottle*> pausing_reading_body_from_net_throttles_;
+
+ // NOTE: This may point to a native implementation (instead of a Mojo proxy
+ // object). And it is possible that the implementation of |forwarding_client_|
+ // destroys this object synchronously when this object is calling into it.
mojom::URLLoaderClient* forwarding_client_;
mojo::Binding<mojom::URLLoaderClient> client_binding_;
@@ -199,6 +239,8 @@ class CONTENT_EXPORT ThrottlingURLLoader : public mojom::URLLoaderClient,
const net::NetworkTrafficAnnotationTag traffic_annotation_;
+ uint32_t inside_delegate_calls_ = 0;
+
DISALLOW_COPY_AND_ASSIGN(ThrottlingURLLoader);
};
diff --git a/chromium/content/common/throttling_url_loader_unittest.cc b/chromium/content/common/throttling_url_loader_unittest.cc
index aa418571cc2..33f3cbd395e 100644
--- a/chromium/content/common/throttling_url_loader_unittest.cc
+++ b/chromium/content/common/throttling_url_loader_unittest.cc
@@ -5,8 +5,8 @@
#include "content/common/throttling_url_loader.h"
#include "base/logging.h"
#include "base/macros.h"
-#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
+#include "base/test/scoped_task_environment.h"
#include "content/public/common/browser_side_navigation_policy.h"
#include "content/public/common/url_loader.mojom.h"
#include "content/public/common/url_loader_factory.mojom.h"
@@ -17,19 +17,31 @@
namespace content {
namespace {
-class TestURLLoaderFactory : public mojom::URLLoaderFactory {
+class TestURLLoaderFactory : public mojom::URLLoaderFactory,
+ public mojom::URLLoader {
public:
- TestURLLoaderFactory() : binding_(this) {
+ TestURLLoaderFactory() : binding_(this), url_loader_binding_(this) {
binding_.Bind(mojo::MakeRequest(&factory_ptr_));
}
mojom::URLLoaderFactoryPtr& factory_ptr() { return factory_ptr_; }
mojom::URLLoaderClientPtr& client_ptr() { return client_ptr_; }
+ mojo::Binding<mojom::URLLoader>& url_loader_binding() {
+ return url_loader_binding_;
+ }
size_t create_loader_and_start_called() const {
return create_loader_and_start_called_;
}
+ size_t pause_reading_body_from_net_called() const {
+ return pause_reading_body_from_net_called_;
+ }
+
+ size_t resume_reading_body_from_net_called() const {
+ return resume_reading_body_from_net_called_;
+ }
+
void NotifyClientOnReceiveResponse() {
client_ptr_->OnReceiveResponse(ResourceResponseHead(), base::nullopt,
nullptr);
@@ -59,14 +71,34 @@ class TestURLLoaderFactory : public mojom::URLLoaderFactory {
traffic_annotation) override {
create_loader_and_start_called_++;
+ DCHECK(!url_loader_binding_.is_bound())
+ << "TestURLLoaderFactory is not able to handle multiple requests.";
+ url_loader_binding_.Bind(std::move(request));
client_ptr_ = std::move(client);
}
void Clone(mojom::URLLoaderFactoryRequest request) override { NOTREACHED(); }
+ // mojom::URLLoader implementation.
+ void FollowRedirect() override {}
+
+ void SetPriority(net::RequestPriority priority,
+ int32_t intra_priority_value) override {}
+
+ void PauseReadingBodyFromNet() override {
+ pause_reading_body_from_net_called_++;
+ }
+
+ void ResumeReadingBodyFromNet() override {
+ resume_reading_body_from_net_called_++;
+ }
+
size_t create_loader_and_start_called_ = 0;
+ size_t pause_reading_body_from_net_called_ = 0;
+ size_t resume_reading_body_from_net_called_ = 0;
mojo::Binding<mojom::URLLoaderFactory> binding_;
+ mojo::Binding<mojom::URLLoader> url_loader_binding_;
mojom::URLLoaderFactoryPtr factory_ptr_;
mojom::URLLoaderClientPtr client_ptr_;
DISALLOW_COPY_AND_ASSIGN(TestURLLoaderFactory);
@@ -86,6 +118,10 @@ class TestURLLoaderClient : public mojom::URLLoaderClient {
size_t on_complete_called() const { return on_complete_called_; }
+ void set_on_received_response_callback(const base::Closure& callback) {
+ on_received_response_callback_ = callback;
+ }
+
using OnCompleteCallback = base::Callback<void(int error_code)>;
void set_on_complete_callback(const OnCompleteCallback& callback) {
on_complete_callback_ = callback;
@@ -98,6 +134,8 @@ class TestURLLoaderClient : public mojom::URLLoaderClient {
const base::Optional<net::SSLInfo>& ssl_info,
mojom::DownloadedTempFilePtr downloaded_file) override {
on_received_response_called_++;
+ if (on_received_response_callback_)
+ on_received_response_callback_.Run();
}
void OnReceiveRedirect(const net::RedirectInfo& redirect_info,
const ResourceResponseHead& response_head) override {
@@ -121,6 +159,7 @@ class TestURLLoaderClient : public mojom::URLLoaderClient {
size_t on_received_redirect_called_ = 0;
size_t on_complete_called_ = 0;
+ base::Closure on_received_response_callback_;
OnCompleteCallback on_complete_callback_;
DISALLOW_COPY_AND_ASSIGN(TestURLLoaderClient);
@@ -129,6 +168,13 @@ class TestURLLoaderClient : public mojom::URLLoaderClient {
class TestURLLoaderThrottle : public URLLoaderThrottle {
public:
TestURLLoaderThrottle() {}
+ explicit TestURLLoaderThrottle(const base::Closure& destruction_notifier)
+ : destruction_notifier_(destruction_notifier) {}
+
+ ~TestURLLoaderThrottle() override {
+ if (destruction_notifier_)
+ destruction_notifier_.Run();
+ }
using ThrottleCallback =
base::Callback<void(URLLoaderThrottle::Delegate* delegate, bool* defer)>;
@@ -186,17 +232,25 @@ class TestURLLoaderThrottle : public URLLoaderThrottle {
ThrottleCallback will_redirect_request_callback_;
ThrottleCallback will_process_response_callback_;
+ base::Closure destruction_notifier_;
+
DISALLOW_COPY_AND_ASSIGN(TestURLLoaderThrottle);
};
class ThrottlingURLLoaderTest : public testing::Test {
public:
- ThrottlingURLLoaderTest() {}
+ ThrottlingURLLoaderTest() : weak_factory_(this) {}
+
+ std::unique_ptr<ThrottlingURLLoader>& loader() { return loader_; }
+ TestURLLoaderThrottle* throttle() const { return throttle_; }
protected:
// testing::Test implementation.
void SetUp() override {
- auto throttle = base::MakeUnique<TestURLLoaderThrottle>();
+ auto throttle = base::MakeUnique<TestURLLoaderThrottle>(
+ base::Bind(&ThrottlingURLLoaderTest::ResetThrottleRawPointer,
+ weak_factory_.GetWeakPtr()));
+
throttle_ = throttle.get();
throttles_.push_back(std::move(throttle));
@@ -214,8 +268,10 @@ class ThrottlingURLLoaderTest : public testing::Test {
factory_.factory_ptr().FlushForTesting();
}
+ void ResetThrottleRawPointer() { throttle_ = nullptr; }
+
// Be the first member so it is destroyed last.
- base::MessageLoop message_loop_;
+ base::test::ScopedTaskEnvironment scoped_task_environment_;
std::unique_ptr<ThrottlingURLLoader> loader_;
std::vector<std::unique_ptr<URLLoaderThrottle>> throttles_;
@@ -226,6 +282,8 @@ class ThrottlingURLLoaderTest : public testing::Test {
// Owned by |throttles_| or |loader_|.
TestURLLoaderThrottle* throttle_ = nullptr;
+ base::WeakPtrFactory<ThrottlingURLLoaderTest> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(ThrottlingURLLoaderTest);
};
@@ -612,5 +670,236 @@ TEST_F(ThrottlingURLLoaderTest, ResumeNoOpIfAlreadyCanceled) {
EXPECT_EQ(1u, client_.on_complete_called());
}
+TEST_F(ThrottlingURLLoaderTest, MultipleThrottlesBasicSupport) {
+ throttles_.emplace_back(base::MakeUnique<TestURLLoaderThrottle>());
+ auto* throttle2 =
+ static_cast<TestURLLoaderThrottle*>(throttles_.back().get());
+ CreateLoaderAndStart();
+ factory_.NotifyClientOnReceiveResponse();
+
+ EXPECT_EQ(1u, throttle_->will_start_request_called());
+ EXPECT_EQ(1u, throttle2->will_start_request_called());
+}
+
+TEST_F(ThrottlingURLLoaderTest, BlockWithOneOfMultipleThrottles) {
+ throttles_.emplace_back(base::MakeUnique<TestURLLoaderThrottle>());
+ auto* throttle2 =
+ static_cast<TestURLLoaderThrottle*>(throttles_.back().get());
+ throttle2->set_will_start_request_callback(
+ base::Bind([](URLLoaderThrottle::Delegate* delegate, bool* defer) {
+ *defer = true;
+ }));
+
+ base::RunLoop loop;
+ client_.set_on_complete_callback(base::Bind(
+ [](base::RunLoop* loop, int error) {
+ EXPECT_EQ(net::OK, error);
+ loop->Quit();
+ },
+ &loop));
+
+ CreateLoaderAndStart();
+
+ EXPECT_EQ(1u, throttle_->will_start_request_called());
+ EXPECT_EQ(1u, throttle2->will_start_request_called());
+ EXPECT_EQ(0u, throttle_->will_redirect_request_called());
+ EXPECT_EQ(0u, throttle2->will_redirect_request_called());
+ EXPECT_EQ(0u, throttle_->will_process_response_called());
+ EXPECT_EQ(0u, throttle2->will_process_response_called());
+
+ EXPECT_EQ(0u, factory_.create_loader_and_start_called());
+
+ EXPECT_EQ(0u, client_.on_received_response_called());
+ EXPECT_EQ(0u, client_.on_received_redirect_called());
+ EXPECT_EQ(0u, client_.on_complete_called());
+
+ throttle2->delegate()->Resume();
+ factory_.factory_ptr().FlushForTesting();
+
+ EXPECT_EQ(1u, factory_.create_loader_and_start_called());
+
+ factory_.NotifyClientOnReceiveResponse();
+ factory_.NotifyClientOnComplete(net::OK);
+
+ loop.Run();
+
+ EXPECT_EQ(1u, throttle_->will_start_request_called());
+ EXPECT_EQ(1u, throttle2->will_start_request_called());
+ EXPECT_EQ(0u, throttle_->will_redirect_request_called());
+ EXPECT_EQ(0u, throttle2->will_redirect_request_called());
+ EXPECT_EQ(1u, throttle_->will_process_response_called());
+ EXPECT_EQ(1u, throttle2->will_process_response_called());
+
+ EXPECT_EQ(1u, client_.on_received_response_called());
+ EXPECT_EQ(0u, client_.on_received_redirect_called());
+ EXPECT_EQ(1u, client_.on_complete_called());
+}
+
+TEST_F(ThrottlingURLLoaderTest, BlockWithMultipleThrottles) {
+ throttles_.emplace_back(base::MakeUnique<TestURLLoaderThrottle>());
+ auto* throttle2 =
+ static_cast<TestURLLoaderThrottle*>(throttles_.back().get());
+
+ // Defers a request on both throttles.
+ throttle_->set_will_start_request_callback(
+ base::Bind([](URLLoaderThrottle::Delegate* delegate, bool* defer) {
+ *defer = true;
+ }));
+ throttle2->set_will_start_request_callback(
+ base::Bind([](URLLoaderThrottle::Delegate* delegate, bool* defer) {
+ *defer = true;
+ }));
+
+ base::RunLoop loop;
+ client_.set_on_complete_callback(base::Bind(
+ [](base::RunLoop* loop, int error) {
+ EXPECT_EQ(net::OK, error);
+ loop->Quit();
+ },
+ &loop));
+
+ CreateLoaderAndStart();
+
+ EXPECT_EQ(1u, throttle_->will_start_request_called());
+ EXPECT_EQ(1u, throttle2->will_start_request_called());
+ EXPECT_EQ(0u, throttle_->will_redirect_request_called());
+ EXPECT_EQ(0u, throttle2->will_redirect_request_called());
+ EXPECT_EQ(0u, throttle_->will_process_response_called());
+ EXPECT_EQ(0u, throttle2->will_process_response_called());
+
+ EXPECT_EQ(0u, factory_.create_loader_and_start_called());
+
+ EXPECT_EQ(0u, client_.on_received_response_called());
+ EXPECT_EQ(0u, client_.on_received_redirect_called());
+ EXPECT_EQ(0u, client_.on_complete_called());
+
+ throttle_->delegate()->Resume();
+
+ // Should still not have started because there's |throttle2| is still blocking
+ // the request.
+ factory_.factory_ptr().FlushForTesting();
+ EXPECT_EQ(0u, factory_.create_loader_and_start_called());
+
+ throttle2->delegate()->Resume();
+
+ // Now it should have started.
+ factory_.factory_ptr().FlushForTesting();
+ EXPECT_EQ(1u, factory_.create_loader_and_start_called());
+
+ factory_.NotifyClientOnReceiveResponse();
+ factory_.NotifyClientOnComplete(net::OK);
+
+ loop.Run();
+
+ EXPECT_EQ(1u, throttle_->will_start_request_called());
+ EXPECT_EQ(1u, throttle2->will_start_request_called());
+ EXPECT_EQ(0u, throttle_->will_redirect_request_called());
+ EXPECT_EQ(0u, throttle2->will_redirect_request_called());
+ EXPECT_EQ(1u, throttle_->will_process_response_called());
+ EXPECT_EQ(1u, throttle2->will_process_response_called());
+
+ EXPECT_EQ(1u, client_.on_received_response_called());
+ EXPECT_EQ(0u, client_.on_received_redirect_called());
+ EXPECT_EQ(1u, client_.on_complete_called());
+}
+
+TEST_F(ThrottlingURLLoaderTest, PauseResumeReadingBodyFromNet) {
+ throttles_.emplace_back(base::MakeUnique<TestURLLoaderThrottle>());
+ auto* throttle2 =
+ static_cast<TestURLLoaderThrottle*>(throttles_.back().get());
+
+ // Test that it is okay to call delegate->PauseReadingBodyFromNet() even
+ // before the loader is created.
+ throttle_->set_will_start_request_callback(
+ base::Bind([](URLLoaderThrottle::Delegate* delegate, bool* defer) {
+ delegate->PauseReadingBodyFromNet();
+ *defer = true;
+ }));
+ throttle2->set_will_start_request_callback(
+ base::Bind([](URLLoaderThrottle::Delegate* delegate, bool* defer) {
+ delegate->PauseReadingBodyFromNet();
+ }));
+
+ CreateLoaderAndStart();
+
+ throttle_->delegate()->Resume();
+
+ factory_.factory_ptr().FlushForTesting();
+ EXPECT_EQ(1u, factory_.create_loader_and_start_called());
+
+ // Make sure all URLLoader calls before this point are delivered to the impl
+ // side.
+ factory_.url_loader_binding().FlushForTesting();
+
+ // Although there were two calls to delegate->PauseReadingBodyFromNet(), only
+ // one URLLoader::PauseReadingBodyFromNet() Mojo call was made.
+ EXPECT_EQ(1u, factory_.pause_reading_body_from_net_called());
+ EXPECT_EQ(0u, factory_.resume_reading_body_from_net_called());
+
+ // Reading body from network is still paused by |throttle2|. Calling
+ // ResumeReadingBodyFromNet() on |throttle_| shouldn't have any effect.
+ throttle_->delegate()->ResumeReadingBodyFromNet();
+ factory_.url_loader_binding().FlushForTesting();
+ EXPECT_EQ(1u, factory_.pause_reading_body_from_net_called());
+ EXPECT_EQ(0u, factory_.resume_reading_body_from_net_called());
+
+ // Even if we call ResumeReadingBodyFromNet() on |throttle_| one more time.
+ throttle_->delegate()->ResumeReadingBodyFromNet();
+ factory_.url_loader_binding().FlushForTesting();
+ EXPECT_EQ(1u, factory_.pause_reading_body_from_net_called());
+ EXPECT_EQ(0u, factory_.resume_reading_body_from_net_called());
+
+ throttle2->delegate()->ResumeReadingBodyFromNet();
+ factory_.url_loader_binding().FlushForTesting();
+ EXPECT_EQ(1u, factory_.pause_reading_body_from_net_called());
+ EXPECT_EQ(1u, factory_.resume_reading_body_from_net_called());
+}
+
+TEST_F(ThrottlingURLLoaderTest, DestroyingThrottlingURLLoaderInDelegateCall) {
+ base::RunLoop run_loop1;
+ throttle_->set_will_process_response_callback(base::Bind(
+ [](const base::Closure& quit_closure,
+ URLLoaderThrottle::Delegate* delegate, bool* defer) {
+ *defer = true;
+ quit_closure.Run();
+ },
+ run_loop1.QuitClosure()));
+
+ base::RunLoop run_loop2;
+ client_.set_on_received_response_callback(base::Bind(
+ [](ThrottlingURLLoaderTest* test, const base::Closure& quit_closure) {
+ // Destroy the ThrottlingURLLoader while inside a delegate call from a
+ // throttle.
+ test->loader().reset();
+
+ // The throttle should stay alive.
+ EXPECT_NE(nullptr, test->throttle());
+
+ quit_closure.Run();
+ },
+ base::Unretained(this), run_loop2.QuitClosure()));
+
+ CreateLoaderAndStart();
+
+ factory_.NotifyClientOnReceiveResponse();
+
+ run_loop1.Run();
+
+ EXPECT_EQ(1u, throttle_->will_start_request_called());
+ EXPECT_EQ(0u, throttle_->will_redirect_request_called());
+ EXPECT_EQ(1u, throttle_->will_process_response_called());
+
+ throttle_->delegate()->Resume();
+ run_loop2.Run();
+
+ // The ThrottlingURLLoader should be gone.
+ EXPECT_EQ(nullptr, loader_);
+ // The throttle should stay alive and destroyed later.
+ EXPECT_NE(nullptr, throttle_);
+
+ scoped_task_environment_.RunUntilIdle();
+ EXPECT_EQ(nullptr, throttle_);
+}
+
} // namespace
} // namespace content
diff --git a/chromium/content/common/typemaps.gni b/chromium/content/common/typemaps.gni
index c5664d19a95..8ac58a5c262 100644
--- a/chromium/content/common/typemaps.gni
+++ b/chromium/content/common/typemaps.gni
@@ -4,6 +4,7 @@
typemaps = [
"//content/common/background_fetch/background_fetch_types.typemap",
+ "//content/common/frame_messages.typemap",
"//content/common/native_types.typemap",
"//content/common/media/media_devices.typemap",
"//content/common/media/media_stream.typemap",
diff --git a/chromium/content/common/unique_name_helper_unittest.cc b/chromium/content/common/unique_name_helper_unittest.cc
index ddf240d4852..12932e4c347 100644
--- a/chromium/content/common/unique_name_helper_unittest.cc
+++ b/chromium/content/common/unique_name_helper_unittest.cc
@@ -98,8 +98,7 @@ class TestFrameAdapter : public UniqueNameHelper::FrameAdapter {
// FrameState children is guaranteed to match the order of TestFrameAdapter
// children.
void PopulateLegacyFrameState(ExplodedFrameState* frame_state) const {
- frame_state->target =
- base::NullableString16(base::UTF8ToUTF16(GetLegacyName()), false);
+ frame_state->target = base::UTF8ToUTF16(GetLegacyName());
frame_state->children.resize(children_.size());
for (size_t i = 0; i < children_.size(); ++i)
children_[i]->PopulateLegacyFrameState(&frame_state->children[i]);
@@ -108,7 +107,8 @@ class TestFrameAdapter : public UniqueNameHelper::FrameAdapter {
// Recursively verify that FrameState and its children have matching unique
// names to this TestFrameAdapter.
void VerifyUpdatedFrameState(const ExplodedFrameState& frame_state) const {
- EXPECT_EQ(GetUniqueName(), base::UTF16ToUTF8(frame_state.target.string()));
+ EXPECT_EQ(GetUniqueName(),
+ base::UTF16ToUTF8(frame_state.target.value_or(base::string16())));
ASSERT_EQ(children_.size(), frame_state.children.size());
for (size_t i = 0; i < children_.size(); ++i) {
diff --git a/chromium/content/common/view_message_enums.h b/chromium/content/common/view_message_enums.h
index ddff44a710e..c2f4b455df1 100644
--- a/chromium/content/common/view_message_enums.h
+++ b/chromium/content/common/view_message_enums.h
@@ -8,8 +8,8 @@
#include "ipc/ipc_message_macros.h"
// Values that may be OR'd together to form the 'flags' parameter of a
-// ViewHostMsg_UpdateRect_Params structure.
-struct ViewHostMsg_UpdateRect_Flags {
+// ViewHostMsg_ResizeOrRepaint_ACK_Params structure.
+struct ViewHostMsg_ResizeOrRepaint_ACK_Flags {
enum {
IS_RESIZE_ACK = 1 << 0,
IS_REPAINT_ACK = 1 << 2,
diff --git a/chromium/content/common/view_messages.h b/chromium/content/common/view_messages.h
index ff00cec7a50..9184f48fde2 100644
--- a/chromium/content/common/view_messages.h
+++ b/chromium/content/common/view_messages.h
@@ -2,25 +2,30 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef CONTENT_COMMON_VIEW_MESSAGES_H_
+#define CONTENT_COMMON_VIEW_MESSAGES_H_
+
// IPC messages for page rendering.
-// Multiply-included message file, hence no include guard.
#include <stddef.h>
#include <stdint.h>
+#include <set>
+#include <string>
+#include <vector>
+
#include "base/memory/shared_memory.h"
#include "base/process/process.h"
#include "base/strings/string16.h"
#include "build/build_config.h"
#include "cc/ipc/cc_param_traits.h"
-#include "cc/output/compositor_frame.h"
#include "components/viz/common/frame_sinks/begin_frame_args.h"
+#include "components/viz/common/quads/compositor_frame.h"
#include "components/viz/common/quads/shared_bitmap.h"
#include "content/common/content_export.h"
#include "content/common/content_param_traits.h"
#include "content/common/date_time_suggestion.h"
#include "content/common/frame_replication_state.h"
-#include "content/common/message_port.h"
#include "content/common/navigation_gesture.h"
#include "content/common/resize_params.h"
#include "content/common/text_input_state.h"
@@ -49,8 +54,6 @@
#include "third_party/WebKit/public/web/WebMediaPlayerAction.h"
#include "third_party/WebKit/public/web/WebPluginAction.h"
#include "third_party/WebKit/public/web/WebPopupType.h"
-#include "third_party/WebKit/public/web/WebSharedWorkerCreationContextType.h"
-#include "third_party/WebKit/public/web/WebSharedWorkerCreationErrors.h"
#include "third_party/WebKit/public/web/WebTextDirection.h"
#include "ui/base/ime/text_input_mode.h"
#include "ui/base/ime/text_input_type.h"
@@ -86,8 +89,6 @@ IPC_ENUM_TRAITS_MAX_VALUE(blink::WebPopupType,
IPC_ENUM_TRAITS_MIN_MAX_VALUE(blink::WebScreenOrientationType,
blink::kWebScreenOrientationUndefined,
blink::WebScreenOrientationTypeLast)
-IPC_ENUM_TRAITS_MAX_VALUE(blink::WebWorkerCreationError,
- blink::kWebWorkerCreationErrorLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebTextDirection,
blink::WebTextDirection::kWebTextDirectionLast)
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebDisplayMode,
@@ -270,45 +271,6 @@ IPC_STRUCT_TRAITS_BEGIN(content::TextInputState)
IPC_STRUCT_TRAITS_MEMBER(reply_to_request)
IPC_STRUCT_TRAITS_END()
-IPC_STRUCT_BEGIN(ViewHostMsg_CreateWorker_Params)
- // URL for the worker script.
- IPC_STRUCT_MEMBER(GURL, url)
-
- // Name for a SharedWorker, otherwise empty string.
- IPC_STRUCT_MEMBER(base::string16, name)
-
- // Security policy used in the worker.
- IPC_STRUCT_MEMBER(base::string16, content_security_policy)
-
- // Security policy type used in the worker.
- IPC_STRUCT_MEMBER(blink::WebContentSecurityPolicyType, security_policy_type)
-
- // The ID of the parent document (unique within parent renderer).
- IPC_STRUCT_MEMBER(unsigned long long, document_id)
-
- // RenderFrame routing id used to send messages back to the parent.
- IPC_STRUCT_MEMBER(int, render_frame_route_id)
-
- // Address space of the context that created the worker.
- IPC_STRUCT_MEMBER(blink::WebAddressSpace, creation_address_space)
-
- // The type (secure or nonsecure) of the context that created the worker.
- IPC_STRUCT_MEMBER(blink::WebSharedWorkerCreationContextType,
- creation_context_type)
-
- // Whether Data-Saver is enabled or not.
- IPC_STRUCT_MEMBER(bool, data_saver_enabled)
-IPC_STRUCT_END()
-
-IPC_STRUCT_BEGIN(ViewHostMsg_CreateWorker_Reply)
- // The route id for the created worker.
- IPC_STRUCT_MEMBER(int, route_id)
-
- // The error that occurred, if the browser failed to create the
- // worker.
- IPC_STRUCT_MEMBER(blink::WebWorkerCreationError, error)
-IPC_STRUCT_END()
-
IPC_STRUCT_BEGIN(ViewHostMsg_DateTimeDialogValue_Params)
IPC_STRUCT_MEMBER(ui::TextInputType, dialog_type)
IPC_STRUCT_MEMBER(double, dialog_value)
@@ -326,7 +288,7 @@ IPC_STRUCT_BEGIN(ViewHostMsg_SelectionBounds_Params)
IPC_STRUCT_MEMBER(bool, is_anchor_first)
IPC_STRUCT_END()
-IPC_STRUCT_BEGIN(ViewHostMsg_UpdateRect_Params)
+IPC_STRUCT_BEGIN(ViewHostMsg_ResizeOrRepaint_ACK_Params)
// The size of the RenderView when this message was generated. This is
// included so the host knows how large the view is from the perspective of
// the renderer process. This is necessary in case a resize operation is in
@@ -336,10 +298,10 @@ IPC_STRUCT_BEGIN(ViewHostMsg_UpdateRect_Params)
// The following describes the various bits that may be set in flags:
//
- // ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK
+ // ViewHostMsg_ResizeOrRepaint_ACK_Flags::IS_RESIZE_ACK
// Indicates that this is a response to a ViewMsg_Resize message.
//
- // ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK
+ // ViewHostMsg_ResizeOrRepaint_ACK_Flags::IS_REPAINT_ACK
// Indicates that this is a response to a ViewMsg_Repaint message.
//
// If flags is zero, then this message corresponds to an unsolicited paint
@@ -347,6 +309,10 @@ IPC_STRUCT_BEGIN(ViewHostMsg_UpdateRect_Params)
// which would indicate that this paint message is an ACK for multiple
// request messages.
IPC_STRUCT_MEMBER(int, flags)
+
+ // A unique monotonically increasing sequence number used to identify this
+ // ACK.
+ IPC_STRUCT_MEMBER(uint64_t, sequence_number)
IPC_STRUCT_END()
// Messages sent from the browser to the renderer.
@@ -381,13 +347,19 @@ IPC_MESSAGE_ROUTED1(ViewMsg_UpdateWebPreferences,
// Expects a Close_ACK message when finished.
IPC_MESSAGE_ROUTED0(ViewMsg_Close)
-// Tells the render view to change its size. A ViewHostMsg_UpdateRect message
-// is generated in response provided new_size is not empty and not equal to
-// the view's current size. The generated ViewHostMsg_UpdateRect message will
-// have the IS_RESIZE_ACK flag set. It also receives the resizer rect so that
-// we don't have to fetch it every time WebKit asks for it.
+// Tells the render view to change its size. A ViewHostMsg_ResizeOrRepaint_ACK
+// message is generated in response provided new_size is not empty and not equal
+// to the view's current size. The generated ViewHostMsg_ResizeOrRepaint_ACK
+// message will have the IS_RESIZE_ACK flag set. It also receives the resizer
+// rect so that we don't have to fetch it every time WebKit asks for it.
IPC_MESSAGE_ROUTED1(ViewMsg_Resize, content::ResizeParams /* params */)
+// Tells the widget to use the provided viz::LocalSurfaceId to submit
+// CompositorFrames for autosize.
+IPC_MESSAGE_ROUTED2(ViewMsg_SetLocalSurfaceIdForAutoResize,
+ uint64_t /* sequence_number */,
+ viz::LocalSurfaceId /* local_surface_id */)
+
// Enables device emulation. See WebDeviceEmulationParams for description.
IPC_MESSAGE_ROUTED1(ViewMsg_EnableDeviceEmulation,
blink::WebDeviceEmulationParams /* params */)
@@ -653,10 +625,11 @@ IPC_MESSAGE_ROUTED1(ViewHostMsg_UpdateTargetURL,
IPC_MESSAGE_ROUTED1(ViewHostMsg_DocumentAvailableInMainFrame,
bool /* uses_temporary_zoom_level */)
-// Sent to update part of the view. In response to this message, the host
-// generates a ViewMsg_UpdateRect_ACK message.
-IPC_MESSAGE_ROUTED1(ViewHostMsg_UpdateRect,
- ViewHostMsg_UpdateRect_Params)
+// Sent as an acknowledgement to a previous resize request. This indicates that
+// the compositor has received a frame from the renderer corresponding to the
+// previous reszie request.
+IPC_MESSAGE_ROUTED1(ViewHostMsg_ResizeOrRepaint_ACK,
+ ViewHostMsg_ResizeOrRepaint_ACK_Params)
IPC_MESSAGE_ROUTED0(ViewHostMsg_Focus)
@@ -677,26 +650,6 @@ IPC_SYNC_MESSAGE_CONTROL1_2(ViewHostMsg_ResolveProxy,
bool /* result */,
std::string /* proxy list */)
-// A renderer sends this to the browser process when it wants to create a
-// worker. The browser will create the worker process if necessary, and
-// will return the route id on in the reply on success. On error returns
-// MSG_ROUTING_NONE and an error type.
-IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_CreateWorker,
- ViewHostMsg_CreateWorker_Params,
- ViewHostMsg_CreateWorker_Reply)
-
-// A renderer sends this to the browser process when a document has been
-// detached. The browser will use this to constrain the lifecycle of worker
-// processes (SharedWorkers are shut down when their last associated document
-// is detached).
-IPC_MESSAGE_CONTROL1(ViewHostMsg_DocumentDetached, uint64_t /* document_id */)
-
-// A renderer sends this to the browser process when it wants to connect to a
-// worker.
-IPC_MESSAGE_CONTROL2(ViewHostMsg_ConnectToWorker,
- int32_t /* worker_route_id */,
- content::MessagePort /* port */)
-
// Tells the browser that a specific Appcache manifest in the current page
// was accessed.
IPC_MESSAGE_ROUTED2(ViewHostMsg_AppCacheAccessed,
@@ -720,13 +673,6 @@ IPC_MESSAGE_ROUTED1(ViewHostMsg_DidContentsPreferredSizeChange,
IPC_MESSAGE_ROUTED1(ViewHostMsg_HasTouchEventHandlers,
bool /* has_handlers */)
-// A message from HTML-based UI. When (trusted) Javascript calls
-// send(message, args), this message is sent to the browser.
-IPC_MESSAGE_ROUTED3(ViewHostMsg_WebUISend,
- GURL /* source_url */,
- std::string /* message */,
- base::ListValue /* args */)
-
#if BUILDFLAG(ENABLE_PLUGINS)
// A renderer sends this to the browser process when it wants to access a PPAPI
// broker. In contrast to FrameHostMsg_OpenChannelToPpapiBroker, this is called
@@ -870,3 +816,5 @@ IPC_MESSAGE_ROUTED1(ViewMsg_GetRenderedTextCompleted, std::string)
// Adding a new message? Stick to the sort order above: first platform
// independent ViewMsg, then ifdefs for platform specific ViewMsg, then platform
// independent ViewHostMsg, then ifdefs for platform specific ViewHostMsg.
+
+#endif // CONTENT_COMMON_VIEW_MESSAGES_H_
diff --git a/chromium/content/common/web_database.mojom b/chromium/content/common/web_database.mojom
new file mode 100644
index 00000000000..875acfbe42c
--- /dev/null
+++ b/chromium/content/common/web_database.mojom
@@ -0,0 +1,66 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module content.mojom;
+
+import "mojo/common/file.mojom";
+import "mojo/common/string16.mojom";
+import "url/mojo/origin.mojom";
+
+// WebDatabase messages sent from the browser to the renderer.
+interface WebDatabase {
+ // Notifies the renderer process of the new database size.
+ UpdateSize(url.mojom.Origin origin,
+ mojo.common.mojom.String16 name,
+ int64 size);
+
+ // Asks the renderer process to close a database immediately.
+ CloseImmediately(url.mojom.Origin origin, mojo.common.mojom.String16 name);
+};
+
+interface WebDatabaseHost {
+ // Asks the browser process to open a DB file with the given name.
+ [Sync]
+ OpenFile(mojo.common.mojom.String16 vfs_file_name,
+ int32 desired_flags) => (mojo.common.mojom.File? file);
+
+ // Asks the browser process to delete a DB file.
+ [Sync]
+ DeleteFile(mojo.common.mojom.String16 vfs_file_name,
+ bool sync_dir) => (int32 sqlite_error_code);
+
+ // Asks the browser process to return the attributes of a DB file.
+ [Sync]
+ GetFileAttributes(mojo.common.mojom.String16 vfs_file_name) => (
+ int32 attributes);
+
+ // Asks the browser process to return the size of a DB file.
+ [Sync]
+ GetFileSize(mojo.common.mojom.String16 vfs_file_name) => (int64 size);
+
+ // Asks the browser set the size of a DB file.
+ [Sync]
+ SetFileSize(mojo.common.mojom.String16 vfs_file_name,
+ int64 expected_size) => (bool success);
+
+ // Asks the browser process for the amount of space available to an origin.
+ [Sync]
+ GetSpaceAvailable(url.mojom.Origin origin) => (int64 space_available);
+
+ // Notifies the browser process that a new database has been opened
+ Opened(url.mojom.Origin origin, mojo.common.mojom.String16 database_name,
+ mojo.common.mojom.String16 database_description, int64 estimated_size);
+
+ // Notifies the browser process that a database might have been modified
+ Modified(url.mojom.Origin origin, mojo.common.mojom.String16 database_name);
+
+ // Notifies the browser process that a database is about to close
+ Closed(url.mojom.Origin origin, mojo.common.mojom.String16 database_name);
+
+ // Sent when a sqlite error indicates the database is corrupt.
+ HandleSqliteError(url.mojom.Origin origin,
+ mojo.common.mojom.String16 database_name,
+ int32 error);
+
+};
diff --git a/chromium/content/common/widget.mojom b/chromium/content/common/widget.mojom
index 342a7f3f7d6..a002e4fbd02 100644
--- a/chromium/content/common/widget.mojom
+++ b/chromium/content/common/widget.mojom
@@ -6,7 +6,7 @@ module content.mojom;
import "content/common/input/input_handler.mojom";
-// Interface representing the Widget.
+// Interface exposed by the renderer for Widgets.
interface Widget {
- GetWidgetInputHandler(WidgetInputHandler& request);
+ SetupWidgetInputHandler(WidgetInputHandler& request, WidgetInputHandlerHost host);
};
diff --git a/chromium/content/common/worker_messages.h b/chromium/content/common/worker_messages.h
deleted file mode 100644
index 64fe00b62ef..00000000000
--- a/chromium/content/common/worker_messages.h
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Defines messages between the browser and worker process, as well as between
-// the renderer and worker process.
-
-// Multiply-included message file, hence no include guard.
-
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "base/strings/string16.h"
-#include "content/common/content_export.h"
-#include "content/common/content_param_traits.h"
-#include "content/common/message_port.h"
-#include "ipc/ipc_message_macros.h"
-#include "ipc/ipc_message_utils.h"
-#include "mojo/public/cpp/system/handle.h"
-#include "mojo/public/cpp/system/message_pipe.h"
-#include "url/gurl.h"
-
-#undef IPC_MESSAGE_EXPORT
-#define IPC_MESSAGE_EXPORT CONTENT_EXPORT
-#define IPC_MESSAGE_START WorkerMsgStart
-
-// Parameters structure for WorkerHostMsg_PostConsoleMessageToWorkerObject,
-// which has too many data parameters to be reasonably put in a predefined
-// IPC message. The data members directly correspond to parameters of
-// WebWorkerClient::postConsoleMessageToWorkerObject()
-IPC_STRUCT_BEGIN(WorkerHostMsg_PostConsoleMessageToWorkerObject_Params)
- IPC_STRUCT_MEMBER(int, source_identifier)
- IPC_STRUCT_MEMBER(int, message_type)
- IPC_STRUCT_MEMBER(int, message_level)
- IPC_STRUCT_MEMBER(base::string16, message)
- IPC_STRUCT_MEMBER(int, line_number)
- IPC_STRUCT_MEMBER(base::string16, source_url)
-IPC_STRUCT_END()
-
-// Parameter structure for WorkerProcessMsg_CreateWorker.
-IPC_STRUCT_BEGIN(WorkerProcessMsg_CreateWorker_Params)
- IPC_STRUCT_MEMBER(GURL, url)
- IPC_STRUCT_MEMBER(base::string16, name)
- IPC_STRUCT_MEMBER(base::string16, content_security_policy)
- IPC_STRUCT_MEMBER(blink::WebContentSecurityPolicyType, security_policy_type)
- IPC_STRUCT_MEMBER(blink::WebAddressSpace, creation_address_space)
- IPC_STRUCT_MEMBER(bool, pause_on_start)
- IPC_STRUCT_MEMBER(int, route_id)
- IPC_STRUCT_MEMBER(bool, data_saver_enabled)
- // For blink::mojom::SharedWorkerContentSettingsProxy
- IPC_STRUCT_MEMBER(mojo::MessagePipeHandle, content_settings_handle)
-IPC_STRUCT_END()
-
-//-----------------------------------------------------------------------------
-// WorkerProcess messages
-// These are messages sent from the browser to the worker process.
-IPC_MESSAGE_CONTROL1(WorkerProcessMsg_CreateWorker,
- WorkerProcessMsg_CreateWorker_Params)
-
-//-----------------------------------------------------------------------------
-// Worker messages
-// These are messages sent from the renderer process to the worker process.
-IPC_MESSAGE_ROUTED0(WorkerMsg_TerminateWorkerContext)
-
-IPC_MESSAGE_ROUTED2(WorkerMsg_Connect,
- int /* connection_request_id */,
- content::MessagePort /* sent_message_port */)
-
-IPC_MESSAGE_ROUTED0(WorkerMsg_WorkerObjectDestroyed)
-
-
-//-----------------------------------------------------------------------------
-// WorkerHost messages
-// These are messages sent from the worker (renderer process) to the worker
-// host (browser process).
-
-// Sent when the worker calls API that should be recored in UseCounter.
-// |feature| must be one of the values from blink::UseCounter::Feature
-// enum.
-IPC_MESSAGE_CONTROL2(WorkerHostMsg_CountFeature,
- int /* worker_route_id */,
- uint32_t /* feature */)
-
-IPC_MESSAGE_CONTROL1(WorkerHostMsg_WorkerContextClosed,
- int /* worker_route_id */)
-
-IPC_MESSAGE_CONTROL1(WorkerHostMsg_WorkerContextDestroyed,
- int /* worker_route_id */)
-
-// Renderer -> Browser message to indicate that the worker is ready for
-// inspection.
-IPC_MESSAGE_CONTROL1(WorkerHostMsg_WorkerReadyForInspection,
- int /* worker_route_id */)
-
-IPC_MESSAGE_CONTROL1(WorkerHostMsg_WorkerScriptLoaded,
- int /* worker_route_id */)
-
-IPC_MESSAGE_CONTROL1(WorkerHostMsg_WorkerScriptLoadFailed,
- int /* worker_route_id */)
-
-IPC_MESSAGE_CONTROL2(WorkerHostMsg_WorkerConnected,
- int /* connection_request_id */,
- int /* worker_route_id */)