summaryrefslogtreecommitdiffstats
path: root/chromium/webkit
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-08-08 14:30:41 +0200
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-08-12 13:49:54 +0200
commitab0a50979b9eb4dfa3320eff7e187e41efedf7a9 (patch)
tree498dfb8a97ff3361a9f7486863a52bb4e26bb898 /chromium/webkit
parent4ce69f7403811819800e7c5ae1318b2647e778d1 (diff)
Update Chromium to beta version 37.0.2062.68
Change-Id: I188e3b5aff1bec75566014291b654eb19f5bc8ca Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/webkit')
-rw-r--r--chromium/webkit/BUILD.gn27
-rw-r--r--chromium/webkit/DEPS1
-rw-r--r--chromium/webkit/OWNERS3
-rw-r--r--chromium/webkit/browser/BUILD.gn237
-rw-r--r--chromium/webkit/browser/appcache/appcache.cc2
-rw-r--r--chromium/webkit/browser/appcache/appcache.h17
-rw-r--r--chromium/webkit/browser/appcache/appcache_backend_impl.cc4
-rw-r--r--chromium/webkit/browser/appcache/appcache_backend_impl.h6
-rw-r--r--chromium/webkit/browser/appcache/appcache_database.cc45
-rw-r--r--chromium/webkit/browser/appcache/appcache_database.h57
-rw-r--r--chromium/webkit/browser/appcache/appcache_database_unittest.cc1177
-rw-r--r--chromium/webkit/browser/appcache/appcache_disk_cache.cc51
-rw-r--r--chromium/webkit/browser/appcache/appcache_disk_cache.h4
-rw-r--r--chromium/webkit/browser/appcache/appcache_entry.h6
-rw-r--r--chromium/webkit/browser/appcache/appcache_group.cc4
-rw-r--r--chromium/webkit/browser/appcache/appcache_group.h34
-rw-r--r--chromium/webkit/browser/appcache/appcache_group_unittest.cc302
-rw-r--r--chromium/webkit/browser/appcache/appcache_histograms.cc80
-rw-r--r--chromium/webkit/browser/appcache/appcache_histograms.h13
-rw-r--r--chromium/webkit/browser/appcache/appcache_host.cc60
-rw-r--r--chromium/webkit/browser/appcache/appcache_host.h73
-rw-r--r--chromium/webkit/browser/appcache/appcache_host_unittest.cc539
-rw-r--r--chromium/webkit/browser/appcache/appcache_interceptor.cc121
-rw-r--r--chromium/webkit/browser/appcache/appcache_interceptor.h80
-rw-r--r--chromium/webkit/browser/appcache/appcache_quota_client.cc4
-rw-r--r--chromium/webkit/browser/appcache/appcache_quota_client.h14
-rw-r--r--chromium/webkit/browser/appcache/appcache_quota_client_unittest.cc435
-rw-r--r--chromium/webkit/browser/appcache/appcache_request_handler.cc19
-rw-r--r--chromium/webkit/browser/appcache/appcache_request_handler.h6
-rw-r--r--chromium/webkit/browser/appcache/appcache_request_handler_unittest.cc973
-rw-r--r--chromium/webkit/browser/appcache/appcache_response.cc2
-rw-r--r--chromium/webkit/browser/appcache/appcache_response.h23
-rw-r--r--chromium/webkit/browser/appcache/appcache_response_unittest.cc717
-rw-r--r--chromium/webkit/browser/appcache/appcache_service.h196
-rw-r--r--chromium/webkit/browser/appcache/appcache_service_impl.cc (renamed from chromium/webkit/browser/appcache/appcache_service.cc)142
-rw-r--r--chromium/webkit/browser/appcache/appcache_service_impl.h227
-rw-r--r--chromium/webkit/browser/appcache/appcache_service_unittest.cc320
-rw-r--r--chromium/webkit/browser/appcache/appcache_storage.cc6
-rw-r--r--chromium/webkit/browser/appcache/appcache_storage.h39
-rw-r--r--chromium/webkit/browser/appcache/appcache_storage_impl.cc148
-rw-r--r--chromium/webkit/browser/appcache/appcache_storage_impl.h15
-rw-r--r--chromium/webkit/browser/appcache/appcache_storage_impl_unittest.cc1968
-rw-r--r--chromium/webkit/browser/appcache/appcache_storage_unittest.cc165
-rw-r--r--chromium/webkit/browser/appcache/appcache_test_helper.cc80
-rw-r--r--chromium/webkit/browser/appcache/appcache_test_helper.h46
-rw-r--r--chromium/webkit/browser/appcache/appcache_unittest.cc695
-rw-r--r--chromium/webkit/browser/appcache/appcache_update_job.cc363
-rw-r--r--chromium/webkit/browser/appcache/appcache_update_job.h55
-rw-r--r--chromium/webkit/browser/appcache/appcache_update_job_unittest.cc3692
-rw-r--r--chromium/webkit/browser/appcache/appcache_url_request_job.cc36
-rw-r--r--chromium/webkit/browser/appcache/appcache_url_request_job.h13
-rw-r--r--chromium/webkit/browser/appcache/appcache_url_request_job_unittest.cc816
-rw-r--r--chromium/webkit/browser/appcache/appcache_working_set.cc4
-rw-r--r--chromium/webkit/browser/appcache/manifest_parser.cc31
-rw-r--r--chromium/webkit/browser/appcache/manifest_parser.h16
-rw-r--r--chromium/webkit/browser/appcache/manifest_parser_unittest.cc472
-rw-r--r--chromium/webkit/browser/appcache/mock_appcache_policy.cc28
-rw-r--r--chromium/webkit/browser/appcache/mock_appcache_policy.h31
-rw-r--r--chromium/webkit/browser/appcache/mock_appcache_service.cc27
-rw-r--r--chromium/webkit/browser/appcache/mock_appcache_service.h48
-rw-r--r--chromium/webkit/browser/appcache/mock_appcache_storage.cc537
-rw-r--r--chromium/webkit/browser/appcache/mock_appcache_storage.h219
-rw-r--r--chromium/webkit/browser/appcache/mock_appcache_storage_unittest.cc630
-rw-r--r--chromium/webkit/browser/appcache/view_appcache_internals_job.cc670
-rw-r--r--chromium/webkit/browser/appcache/view_appcache_internals_job.h34
-rw-r--r--chromium/webkit/browser/blob/blob_data_handle.cc66
-rw-r--r--chromium/webkit/browser/blob/blob_data_handle.h35
-rw-r--r--chromium/webkit/browser/blob/blob_storage_context.h10
-rw-r--r--chromium/webkit/browser/blob/blob_storage_context_unittest.cc208
-rw-r--r--chromium/webkit/browser/blob/blob_storage_host.cc114
-rw-r--r--chromium/webkit/browser/blob/blob_storage_host.h71
-rw-r--r--chromium/webkit/browser/blob/blob_url_request_job.cc14
-rw-r--r--chromium/webkit/browser/blob/blob_url_request_job.h2
-rw-r--r--chromium/webkit/browser/blob/blob_url_request_job_factory.cc2
-rw-r--r--chromium/webkit/browser/blob/file_stream_reader.cc20
-rw-r--r--chromium/webkit/browser/blob/file_stream_reader.h6
-rw-r--r--chromium/webkit/browser/blob/local_file_stream_reader.cc25
-rw-r--r--chromium/webkit/browser/blob/local_file_stream_reader.h12
-rw-r--r--chromium/webkit/browser/blob/local_file_stream_reader_unittest.cc261
-rw-r--r--chromium/webkit/browser/blob/mock_blob_url_request_context.cc49
-rw-r--r--chromium/webkit/browser/blob/mock_blob_url_request_context.h58
-rw-r--r--chromium/webkit/browser/blob/view_blob_internals_job.cc12
-rw-r--r--chromium/webkit/browser/database/database_quota_client_unittest.cc285
-rw-r--r--chromium/webkit/browser/database/database_tracker.cc60
-rw-r--r--chromium/webkit/browser/database/database_tracker.h21
-rw-r--r--chromium/webkit/browser/database/database_tracker_unittest.cc877
-rw-r--r--chromium/webkit/browser/database/database_util.cc55
-rw-r--r--chromium/webkit/browser/database/database_util_unittest.cc74
-rw-r--r--chromium/webkit/browser/database/databases_table_unittest.cc148
-rw-r--r--chromium/webkit/browser/database/vfs_backend.cc61
-rw-r--r--chromium/webkit/browser/database/vfs_backend.h12
-rw-r--r--chromium/webkit/browser/fileapi/async_file_test_helper.cc270
-rw-r--r--chromium/webkit/browser/fileapi/async_file_test_helper.h109
-rw-r--r--chromium/webkit/browser/fileapi/async_file_util.h84
-rw-r--r--chromium/webkit/browser/fileapi/async_file_util_adapter.cc124
-rw-r--r--chromium/webkit/browser/fileapi/copy_or_move_file_validator.h6
-rw-r--r--chromium/webkit/browser/fileapi/copy_or_move_operation_delegate.cc168
-rw-r--r--chromium/webkit/browser/fileapi/copy_or_move_operation_delegate.h14
-rw-r--r--chromium/webkit/browser/fileapi/dragged_file_util.cc17
-rw-r--r--chromium/webkit/browser/fileapi/dragged_file_util.h4
-rw-r--r--chromium/webkit/browser/fileapi/dump_file_system.cc6
-rw-r--r--chromium/webkit/browser/fileapi/external_mount_points.cc52
-rw-r--r--chromium/webkit/browser/fileapi/external_mount_points.h17
-rw-r--r--chromium/webkit/browser/fileapi/external_mount_points_unittest.cc507
-rw-r--r--chromium/webkit/browser/fileapi/file_stream_writer.h5
-rw-r--r--chromium/webkit/browser/fileapi/file_system_backend.h35
-rw-r--r--chromium/webkit/browser/fileapi/file_system_context.cc152
-rw-r--r--chromium/webkit/browser/fileapi/file_system_context.h74
-rw-r--r--chromium/webkit/browser/fileapi/file_system_dir_url_request_job.cc35
-rw-r--r--chromium/webkit/browser/fileapi/file_system_dir_url_request_job.h7
-rw-r--r--chromium/webkit/browser/fileapi/file_system_file_stream_reader.cc9
-rw-r--r--chromium/webkit/browser/fileapi/file_system_file_stream_reader.h12
-rw-r--r--chromium/webkit/browser/fileapi/file_system_file_util.h48
-rw-r--r--chromium/webkit/browser/fileapi/file_system_operation.h67
-rw-r--r--chromium/webkit/browser/fileapi/file_system_operation_impl.cc73
-rw-r--r--chromium/webkit/browser/fileapi/file_system_operation_impl.h23
-rw-r--r--chromium/webkit/browser/fileapi/file_system_operation_runner.cc96
-rw-r--r--chromium/webkit/browser/fileapi/file_system_operation_runner.h53
-rw-r--r--chromium/webkit/browser/fileapi/file_system_options.cc6
-rw-r--r--chromium/webkit/browser/fileapi/file_system_options.h11
-rw-r--r--chromium/webkit/browser/fileapi/file_system_quota_client.cc24
-rw-r--r--chromium/webkit/browser/fileapi/file_system_quota_util.h18
-rw-r--r--chromium/webkit/browser/fileapi/file_system_url.cc70
-rw-r--r--chromium/webkit/browser/fileapi/file_system_url.h8
-rw-r--r--chromium/webkit/browser/fileapi/file_system_url_request_job.cc28
-rw-r--r--chromium/webkit/browser/fileapi/file_system_url_request_job.h10
-rw-r--r--chromium/webkit/browser/fileapi/file_system_url_request_job_factory.cc19
-rw-r--r--chromium/webkit/browser/fileapi/file_system_url_request_job_factory.h5
-rw-r--r--chromium/webkit/browser/fileapi/file_system_url_unittest.cc213
-rw-r--r--chromium/webkit/browser/fileapi/file_system_usage_cache.cc63
-rw-r--r--chromium/webkit/browser/fileapi/file_system_usage_cache.h9
-rw-r--r--chromium/webkit/browser/fileapi/file_system_usage_cache_unittest.cc158
-rw-r--r--chromium/webkit/browser/fileapi/file_writer_delegate.cc52
-rw-r--r--chromium/webkit/browser/fileapi/file_writer_delegate.h27
-rw-r--r--chromium/webkit/browser/fileapi/isolated_context.cc51
-rw-r--r--chromium/webkit/browser/fileapi/isolated_context.h4
-rw-r--r--chromium/webkit/browser/fileapi/isolated_context_unittest.cc345
-rw-r--r--chromium/webkit/browser/fileapi/isolated_file_system_backend.cc33
-rw-r--r--chromium/webkit/browser/fileapi/isolated_file_system_backend.h13
-rw-r--r--chromium/webkit/browser/fileapi/local_file_stream_writer.cc33
-rw-r--r--chromium/webkit/browser/fileapi/local_file_stream_writer.h11
-rw-r--r--chromium/webkit/browser/fileapi/local_file_stream_writer_unittest.cc176
-rw-r--r--chromium/webkit/browser/fileapi/local_file_util.cc104
-rw-r--r--chromium/webkit/browser/fileapi/local_file_util.h36
-rw-r--r--chromium/webkit/browser/fileapi/mock_file_change_observer.cc51
-rw-r--r--chromium/webkit/browser/fileapi/mock_file_change_observer.h103
-rw-r--r--chromium/webkit/browser/fileapi/mount_points.h1
-rw-r--r--chromium/webkit/browser/fileapi/native_file_util.cc178
-rw-r--r--chromium/webkit/browser/fileapi/native_file_util.h39
-rw-r--r--chromium/webkit/browser/fileapi/native_file_util_unittest.cc412
-rw-r--r--chromium/webkit/browser/fileapi/obfuscated_file_util.cc551
-rw-r--r--chromium/webkit/browser/fileapi/obfuscated_file_util.h107
-rw-r--r--chromium/webkit/browser/fileapi/plugin_private_file_system_backend.cc48
-rw-r--r--chromium/webkit/browser/fileapi/plugin_private_file_system_backend.h29
-rw-r--r--chromium/webkit/browser/fileapi/quota/open_file_handle.cc31
-rw-r--r--chromium/webkit/browser/fileapi/quota/open_file_handle.h31
-rw-r--r--chromium/webkit/browser/fileapi/quota/open_file_handle_context.cc46
-rw-r--r--chromium/webkit/browser/fileapi/quota/open_file_handle_context.h12
-rw-r--r--chromium/webkit/browser/fileapi/quota/quota_backend_impl.cc37
-rw-r--r--chromium/webkit/browser/fileapi/quota/quota_backend_impl.h8
-rw-r--r--chromium/webkit/browser/fileapi/quota/quota_backend_impl_unittest.cc248
-rw-r--r--chromium/webkit/browser/fileapi/quota/quota_reservation.cc38
-rw-r--r--chromium/webkit/browser/fileapi/quota/quota_reservation.h18
-rw-r--r--chromium/webkit/browser/fileapi/quota/quota_reservation_buffer.cc17
-rw-r--r--chromium/webkit/browser/fileapi/quota/quota_reservation_buffer.h5
-rw-r--r--chromium/webkit/browser/fileapi/quota/quota_reservation_manager.h10
-rw-r--r--chromium/webkit/browser/fileapi/quota/quota_reservation_manager_unittest.cc358
-rw-r--r--chromium/webkit/browser/fileapi/recursive_operation_delegate.cc31
-rw-r--r--chromium/webkit/browser/fileapi/recursive_operation_delegate.h18
-rw-r--r--chromium/webkit/browser/fileapi/remove_operation_delegate.cc21
-rw-r--r--chromium/webkit/browser/fileapi/remove_operation_delegate.h8
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_database_test_helper.cc99
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_database_test_helper.h28
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_directory_database.cc38
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_directory_database.h20
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_directory_database_unittest.cc681
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_file_stream_writer.cc17
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_file_stream_writer.h6
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_file_system_backend.cc30
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_file_system_backend.h14
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.cc77
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.h26
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_isolated_origin_database_unittest.cc41
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_origin_database.cc10
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_origin_database.h5
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_origin_database_unittest.cc308
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_prioritized_origin_database.cc30
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_prioritized_origin_database.h9
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_prioritized_origin_database_unittest.cc215
-rw-r--r--chromium/webkit/browser/fileapi/sandbox_quota_observer.cc6
-rw-r--r--chromium/webkit/browser/fileapi/test_file_set.cc76
-rw-r--r--chromium/webkit/browser/fileapi/test_file_set.h42
-rw-r--r--chromium/webkit/browser/fileapi/timed_task_helper_unittest.cc83
-rw-r--r--chromium/webkit/browser/fileapi/transient_file_util.cc10
-rw-r--r--chromium/webkit/browser/fileapi/transient_file_util.h4
-rw-r--r--chromium/webkit/browser/fileapi/upload_file_system_file_element_reader.cc117
-rw-r--r--chromium/webkit/browser/fileapi/upload_file_system_file_element_reader.h64
-rw-r--r--chromium/webkit/browser/quota/mock_quota_manager.cc199
-rw-r--r--chromium/webkit/browser/quota/mock_quota_manager.h206
-rw-r--r--chromium/webkit/browser/quota/mock_quota_manager_unittest.cc222
-rw-r--r--chromium/webkit/browser/quota/mock_special_storage_policy.cc47
-rw-r--r--chromium/webkit/browser/quota/mock_special_storage_policy.h101
-rw-r--r--chromium/webkit/browser/quota/mock_storage_client.cc186
-rw-r--r--chromium/webkit/browser/quota/mock_storage_client.h96
-rw-r--r--chromium/webkit/browser/quota/quota_database.cc18
-rw-r--r--chromium/webkit/browser/quota/quota_database.h10
-rw-r--r--chromium/webkit/browser/quota/quota_database_unittest.cc567
-rw-r--r--chromium/webkit/browser/quota/quota_manager.cc229
-rw-r--r--chromium/webkit/browser/quota/quota_manager.h80
-rw-r--r--chromium/webkit/browser/quota/quota_manager_proxy.cc160
-rw-r--r--chromium/webkit/browser/quota/quota_manager_proxy.h78
-rw-r--r--chromium/webkit/browser/quota/quota_manager_unittest.cc2165
-rw-r--r--chromium/webkit/browser/quota/quota_temporary_storage_evictor.h6
-rw-r--r--chromium/webkit/browser/quota/quota_temporary_storage_evictor_unittest.cc410
-rw-r--r--chromium/webkit/browser/quota/storage_monitor.cc379
-rw-r--r--chromium/webkit/browser/quota/storage_monitor.h180
-rw-r--r--chromium/webkit/browser/quota/storage_observer.cc65
-rw-r--r--chromium/webkit/browser/quota/storage_observer.h79
-rw-r--r--chromium/webkit/browser/quota/usage_tracker.cc34
-rw-r--r--chromium/webkit/browser/quota/usage_tracker.h12
-rw-r--r--chromium/webkit/browser/quota/usage_tracker_unittest.cc328
-rw-r--r--chromium/webkit/build/webkit_version.h.in9
-rw-r--r--chromium/webkit/child/BUILD.gn60
-rw-r--r--chromium/webkit/child/fling_animator_impl_android.cc148
-rw-r--r--chromium/webkit/child/fling_animator_impl_android.h58
-rw-r--r--chromium/webkit/child/fling_curve_configuration.cc55
-rw-r--r--chromium/webkit/child/fling_curve_configuration.h58
-rw-r--r--chromium/webkit/child/ftp_directory_listing_response_delegate.cc123
-rw-r--r--chromium/webkit/child/ftp_directory_listing_response_delegate.h53
-rw-r--r--chromium/webkit/child/multipart_response_delegate.h8
-rw-r--r--chromium/webkit/child/multipart_response_delegate_unittest.cc675
-rw-r--r--chromium/webkit/child/resource_loader_bridge.cc26
-rw-r--r--chromium/webkit/child/resource_loader_bridge.h196
-rw-r--r--chromium/webkit/child/touch_fling_gesture_curve.cc163
-rw-r--r--chromium/webkit/child/touch_fling_gesture_curve.h55
-rw-r--r--chromium/webkit/child/touch_fling_gesture_curve_unittest.cc71
-rw-r--r--chromium/webkit/child/web_discardable_memory_impl.cc48
-rw-r--r--chromium/webkit/child/web_discardable_memory_impl.h44
-rw-r--r--chromium/webkit/child/webfallbackthemeengine_impl.cc191
-rw-r--r--chromium/webkit/child/webfallbackthemeengine_impl.h39
-rw-r--r--chromium/webkit/child/webkit_child.gyp49
-rw-r--r--chromium/webkit/child/webkit_child_helpers.cc53
-rw-r--r--chromium/webkit/child/webkit_child_helpers.h21
-rw-r--r--chromium/webkit/child/webkitplatformsupport_child_impl.cc108
-rw-r--r--chromium/webkit/child/webkitplatformsupport_child_impl.h68
-rw-r--r--chromium/webkit/child/webkitplatformsupport_impl.cc947
-rw-r--r--chromium/webkit/child/webkitplatformsupport_impl.h156
-rw-r--r--chromium/webkit/child/websocketstreamhandle_bridge.h37
-rw-r--r--chromium/webkit/child/websocketstreamhandle_delegate.h44
-rw-r--r--chromium/webkit/child/websocketstreamhandle_impl.cc195
-rw-r--r--chromium/webkit/child/websocketstreamhandle_impl.h40
-rw-r--r--chromium/webkit/child/webthemeengine_impl_android.cc186
-rw-r--r--chromium/webkit/child/webthemeengine_impl_android.h26
-rw-r--r--chromium/webkit/child/webthemeengine_impl_default.cc185
-rw-r--r--chromium/webkit/child/webthemeengine_impl_default.h26
-rw-r--r--chromium/webkit/child/webthemeengine_impl_mac.cc61
-rw-r--r--chromium/webkit/child/webthemeengine_impl_mac.h25
-rw-r--r--chromium/webkit/child/webthemeengine_impl_win.cc1014
-rw-r--r--chromium/webkit/child/webthemeengine_impl_win.h49
-rw-r--r--chromium/webkit/child/webthread_impl.cc134
-rw-r--r--chromium/webkit/child/webthread_impl.h72
-rw-r--r--chromium/webkit/child/weburlloader_impl.cc857
-rw-r--r--chromium/webkit/child/weburlloader_impl.h50
-rw-r--r--chromium/webkit/child/weburlrequest_extradata_impl.cc24
-rw-r--r--chromium/webkit/child/weburlrequest_extradata_impl.h48
-rw-r--r--chromium/webkit/child/worker_task_runner.cc111
-rw-r--r--chromium/webkit/child/worker_task_runner.h59
-rw-r--r--chromium/webkit/child/worker_task_runner_unittest.cc56
-rw-r--r--chromium/webkit/common/BUILD.gn82
-rw-r--r--chromium/webkit/common/appcache/appcache_interfaces.cc34
-rw-r--r--chromium/webkit/common/appcache/appcache_interfaces.h113
-rw-r--r--chromium/webkit/common/blob/scoped_file.cc10
-rw-r--r--chromium/webkit/common/blob/shareable_file_reference_unittest.cc59
-rw-r--r--chromium/webkit/common/cursors/DEPS4
-rw-r--r--chromium/webkit/common/cursors/webcursor.cc261
-rw-r--r--chromium/webkit/common/cursors/webcursor.h195
-rw-r--r--chromium/webkit/common/cursors/webcursor_android.cc29
-rw-r--r--chromium/webkit/common/cursors/webcursor_aura.cc110
-rw-r--r--chromium/webkit/common/cursors/webcursor_aurawin.cc56
-rw-r--r--chromium/webkit/common/cursors/webcursor_aurax11.cc85
-rw-r--r--chromium/webkit/common/cursors/webcursor_gtk.cc222
-rw-r--r--chromium/webkit/common/cursors/webcursor_gtk_data.h311
-rw-r--r--chromium/webkit/common/cursors/webcursor_mac.mm395
-rw-r--r--chromium/webkit/common/cursors/webcursor_null.cc34
-rw-r--r--chromium/webkit/common/cursors/webcursor_unittest.cc244
-rw-r--r--chromium/webkit/common/cursors/webcursor_win.cc181
-rw-r--r--chromium/webkit/common/database/database_connections_unittest.cc143
-rw-r--r--chromium/webkit/common/database/database_identifier.cc13
-rw-r--r--chromium/webkit/common/database/database_identifier_unittest.cc245
-rw-r--r--chromium/webkit/common/fileapi/file_system_types.h10
-rw-r--r--chromium/webkit/common/fileapi/file_system_util.cc141
-rw-r--r--chromium/webkit/common/fileapi/file_system_util.h29
-rw-r--r--chromium/webkit/common/fileapi/file_system_util_unittest.cc263
-rw-r--r--chromium/webkit/common/gpu/BUILD.gn42
-rw-r--r--chromium/webkit/common/gpu/context_provider_in_process.cc39
-rw-r--r--chromium/webkit/common/gpu/context_provider_in_process.h15
-rw-r--r--chromium/webkit/common/gpu/context_provider_web_context.h26
-rw-r--r--chromium/webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc39
-rw-r--r--chromium/webkit/common/gpu/grcontext_for_webgraphicscontext3d.h3
-rw-r--r--chromium/webkit/common/gpu/test_context_provider_factory.cc38
-rw-r--r--chromium/webkit/common/gpu/test_context_provider_factory.h38
-rw-r--r--chromium/webkit/common/gpu/webgraphicscontext3d_impl.cc984
-rw-r--r--chromium/webkit/common/gpu/webgraphicscontext3d_impl.h598
-rw-r--r--chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc1063
-rw-r--r--chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h519
-rw-r--r--chromium/webkit/common/gpu/webgraphicscontext3d_provider_impl.cc27
-rw-r--r--chromium/webkit/common/gpu/webgraphicscontext3d_provider_impl.h36
-rw-r--r--chromium/webkit/common/gpu/webkit_gpu.gyp9
-rw-r--r--chromium/webkit/common/quota/quota_types.h1
-rw-r--r--chromium/webkit/common/resource_devtools_info.cc16
-rw-r--r--chromium/webkit/common/resource_devtools_info.h37
-rw-r--r--chromium/webkit/common/resource_request_body.cc45
-rw-r--r--chromium/webkit/common/resource_request_body.h65
-rw-r--r--chromium/webkit/common/resource_response_info.cc25
-rw-r--r--chromium/webkit/common/resource_response_info.h103
-rw-r--r--chromium/webkit/common/resource_type.cc2
-rw-r--r--chromium/webkit/common/resource_type.h5
-rw-r--r--chromium/webkit/common/user_agent/user_agent.cc133
-rw-r--r--chromium/webkit/common/user_agent/user_agent.h29
-rw-r--r--chromium/webkit/common/user_agent/user_agent_unittest.cc55
-rw-r--r--chromium/webkit/common/user_agent/user_agent_util.cc196
-rw-r--r--chromium/webkit/common/user_agent/user_agent_util.h40
-rw-r--r--chromium/webkit/common/user_agent/user_agent_util_ios.mm130
-rw-r--r--chromium/webkit/common/user_agent/webkit_user_agent.gyp88
-rw-r--r--chromium/webkit/common/user_agent/webkit_user_agent_export.h29
-rw-r--r--chromium/webkit/common/webkit_common.gyp55
-rw-r--r--chromium/webkit/common/webpreferences.cc45
-rw-r--r--chromium/webkit/common/webpreferences.h31
-rw-r--r--chromium/webkit/glue/inspector_strings.grd26
-rw-r--r--chromium/webkit/glue/resources/default_100_percent/amex.pngbin908 -> 0 bytes
-rw-r--r--chromium/webkit/glue/resources/default_100_percent/cc-generic.pngbin341 -> 0 bytes
-rw-r--r--chromium/webkit/glue/resources/default_100_percent/diners.pngbin945 -> 0 bytes
-rw-r--r--chromium/webkit/glue/resources/default_100_percent/discover.pngbin688 -> 0 bytes
-rw-r--r--chromium/webkit/glue/resources/default_100_percent/input_speech.pngbin517 -> 0 bytes
-rw-r--r--chromium/webkit/glue/resources/default_100_percent/input_speech_recording.pngbin578 -> 0 bytes
-rw-r--r--chromium/webkit/glue/resources/default_100_percent/input_speech_waiting.pngbin577 -> 0 bytes
-rw-r--r--chromium/webkit/glue/resources/default_100_percent/jcb.pngbin1014 -> 0 bytes
-rw-r--r--chromium/webkit/glue/resources/default_100_percent/mastercard.pngbin751 -> 0 bytes
-rw-r--r--chromium/webkit/glue/resources/default_100_percent/north_east_south_west_resize_cursor.pngbin167 -> 166 bytes
-rw-r--r--chromium/webkit/glue/resources/default_100_percent/north_resize_cursor.pngbin110 -> 108 bytes
-rw-r--r--chromium/webkit/glue/resources/default_100_percent/synthetic_touch_cursor.pngbin344 -> 0 bytes
-rw-r--r--chromium/webkit/glue/resources/default_100_percent/visa.pngbin626 -> 0 bytes
-rw-r--r--chromium/webkit/glue/resources/default_200_percent/amex.pngbin1676 -> 0 bytes
-rw-r--r--chromium/webkit/glue/resources/default_200_percent/discover.pngbin1558 -> 0 bytes
-rw-r--r--chromium/webkit/glue/resources/default_200_percent/mastercard.pngbin2014 -> 0 bytes
-rw-r--r--chromium/webkit/glue/resources/default_200_percent/visa.pngbin1259 -> 0 bytes
-rw-r--r--chromium/webkit/glue/resources/webkit_resources.grd111
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_am.xtb19
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_ar.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_bg.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_bn.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_ca.xtb19
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_cs.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_da.xtb15
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_de.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_el.xtb19
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_en-GB.xtb15
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_es-419.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_es.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_et.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_fa.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_fi.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_fil.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_fr.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_gu.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_hi.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_hr.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_hu.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_id.xtb21
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_it.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_iw.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_ja.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_kn.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_ko.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_lt.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_lv.xtb15
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_ml.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_mr.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_ms.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_nl.xtb15
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_no.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_pl.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_pt-BR.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_pt-PT.xtb19
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_ro.xtb45
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_ru.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_sk.xtb17
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_sl.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_sr.xtb21
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_sv.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_sw.xtb21
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_ta.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_te.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_th.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_tr.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_uk.xtb13
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_vi.xtb17
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_zh-CN.xtb15
-rw-r--r--chromium/webkit/glue/resources/webkit_strings_zh-TW.xtb23
-rw-r--r--chromium/webkit/glue/simple_webmimeregistry_impl.cc91
-rw-r--r--chromium/webkit/glue/simple_webmimeregistry_impl.h49
-rw-r--r--chromium/webkit/glue/webfileutilities_impl.cc85
-rw-r--r--chromium/webkit/glue/webfileutilities_impl.h42
-rw-r--r--chromium/webkit/glue/webkit_glue.cc35
-rw-r--r--chromium/webkit/glue/webkit_glue.gyp17
-rw-r--r--chromium/webkit/glue/webkit_glue.gypi132
-rw-r--r--chromium/webkit/glue/webkit_glue.h28
-rw-r--r--chromium/webkit/glue/webkit_glue_export.h29
-rw-r--r--chromium/webkit/glue/webkit_glue_unittest.cc87
-rw-r--r--chromium/webkit/glue/webkit_strings.grd111
-rw-r--r--chromium/webkit/renderer/compositor_bindings/DEPS3
-rw-r--r--chromium/webkit/renderer/compositor_bindings/OWNERS2
-rw-r--r--chromium/webkit/renderer/compositor_bindings/PRESUBMIT.py33
-rw-r--r--chromium/webkit/renderer/compositor_bindings/compositor_bindings.gyp84
-rw-r--r--chromium/webkit/renderer/compositor_bindings/compositor_bindings_dummy_unittest.cc11
-rw-r--r--chromium/webkit/renderer/compositor_bindings/compositor_bindings_tests.gyp29
-rw-r--r--chromium/webkit/renderer/compositor_bindings/scrollbar_impl.cc106
-rw-r--r--chromium/webkit/renderer/compositor_bindings/scrollbar_impl.h50
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_animation_curve_common.cc28
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_animation_curve_common.h18
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_animation_impl.cc113
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_animation_impl.h49
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_animation_unittest.cc45
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_blend_mode.h106
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_compositing_reasons.cc151
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_compositor_support_impl.cc122
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_compositor_support_impl.h56
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_content_layer_impl.cc84
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_content_layer_impl.h56
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_external_bitmap_impl.cc44
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_external_bitmap_impl.h47
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.cc130
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.h73
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.cc56
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.h49
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_filter_operations_impl.cc93
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_filter_operations_impl.h49
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_float_animation_curve_impl.cc57
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_float_animation_curve_impl.h51
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_float_animation_curve_unittest.cc233
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_image_layer_impl.cc41
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_image_layer_impl.h34
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_layer_impl.cc451
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_layer_impl.h156
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.cc128
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.h54
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds_unittest.cc203
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_nine_patch_layer_impl.cc57
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_nine_patch_layer_impl.h41
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_rendering_stats_impl.h21
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_scrollbar_layer_impl.cc58
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_scrollbar_layer_impl.h46
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_solid_color_layer_impl.cc27
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_solid_color_layer_impl.h34
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.cc35
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.h38
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_transform_animation_curve_impl.cc60
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_transform_animation_curve_impl.h50
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_transform_operations_impl.cc66
-rw-r--r--chromium/webkit/renderer/compositor_bindings/web_transform_operations_impl.h41
-rw-r--r--chromium/webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h30
-rw-r--r--chromium/webkit/renderer/cpp_bound_class.cc329
-rw-r--r--chromium/webkit/renderer/cpp_bound_class.h147
-rw-r--r--chromium/webkit/renderer/cpp_variant.cc268
-rw-r--r--chromium/webkit/renderer/cpp_variant.h116
-rw-r--r--chromium/webkit/renderer/cpp_variant_unittest.cc514
-rw-r--r--chromium/webkit/renderer/webkit_renderer.gyp34
-rw-r--r--chromium/webkit/renderer/webkit_renderer_export.h29
-rw-r--r--chromium/webkit/storage_browser.gyp21
-rw-r--r--chromium/webkit/storage_common.gyp3
-rw-r--r--chromium/webkit/tools/layout_tests/test_expectations.txt2
-rw-r--r--chromium/webkit/tools/layout_tests/test_expectations_asan.txt71
-rw-r--r--chromium/webkit/tools/layout_tests/test_expectations_w3c.txt14
-rw-r--r--chromium/webkit/webkit_resources.gyp2
474 files changed, 7183 insertions, 47775 deletions
diff --git a/chromium/webkit/BUILD.gn b/chromium/webkit/BUILD.gn
new file mode 100644
index 00000000000..ca1eae7550f
--- /dev/null
+++ b/chromium/webkit/BUILD.gn
@@ -0,0 +1,27 @@
+# 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.
+
+import("//tools/grit/grit_rule.gni")
+
+group("resources") {
+ deps = [
+ ":webkit_resources_action",
+ ":blink_common_resources",
+ ]
+}
+
+grit("webkit_resources_action") {
+ visibility = ":resources"
+ source = "glue/resources/webkit_resources.grd"
+}
+
+grit("blink_common_resources") {
+ visibility = ":resources"
+ source = "//third_party/WebKit/public/blink_resources.grd"
+}
+
+# webkit_strings in webkit_resources.gyp
+grit("strings") {
+ source = "glue/webkit_strings.grd"
+}
diff --git a/chromium/webkit/DEPS b/chromium/webkit/DEPS
index 4efa992e417..6e69dfd5620 100644
--- a/chromium/webkit/DEPS
+++ b/chromium/webkit/DEPS
@@ -9,6 +9,7 @@ include_rules = [
# For bridge/c/c_utility.h in npruntime_util.cc
"+bridge",
"+cc",
+ "-cc/surfaces",
"+grit", # For generated headers
"+skia",
"+third_party/angle",
diff --git a/chromium/webkit/OWNERS b/chromium/webkit/OWNERS
index 16808ebc506..a1327dd7360 100644
--- a/chromium/webkit/OWNERS
+++ b/chromium/webkit/OWNERS
@@ -2,4 +2,5 @@ darin@chromium.org
jamesr@chromium.org
kinuko@chromium.org
michaeln@chromium.org
-tony@chromium.org
+piman@chromium.org
+danakj@chromium.org
diff --git a/chromium/webkit/browser/BUILD.gn b/chromium/webkit/browser/BUILD.gn
new file mode 100644
index 00000000000..e06af088504
--- /dev/null
+++ b/chromium/webkit/browser/BUILD.gn
@@ -0,0 +1,237 @@
+# 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.
+
+config("storage_config") {
+ if (is_android) {
+ defines = [ "APPCACHE_USE_SIMPLE_CACHE" ]
+ }
+}
+
+component("storage") {
+ output_name = "webkit_storage_browser"
+ sources = [
+ "webkit_storage_browser_export.h",
+ "appcache/appcache.cc",
+ "appcache/appcache.h",
+ "appcache/appcache_backend_impl.cc",
+ "appcache/appcache_backend_impl.h",
+ "appcache/appcache_database.cc",
+ "appcache/appcache_database.h",
+ "appcache/appcache_disk_cache.cc",
+ "appcache/appcache_disk_cache.h",
+ "appcache/appcache_entry.h",
+ "appcache/appcache_executable_handler.h",
+ "appcache/appcache_group.cc",
+ "appcache/appcache_group.h",
+ "appcache/appcache_histograms.cc",
+ "appcache/appcache_histograms.h",
+ "appcache/appcache_host.cc",
+ "appcache/appcache_host.h",
+ "appcache/appcache_policy.h",
+ "appcache/appcache_quota_client.cc",
+ "appcache/appcache_quota_client.h",
+ "appcache/appcache_request_handler.cc",
+ "appcache/appcache_request_handler.h",
+ "appcache/appcache_response.cc",
+ "appcache/appcache_response.h",
+ "appcache/appcache_service_impl.cc",
+ "appcache/appcache_service_impl.h",
+ "appcache/appcache_service.h",
+ "appcache/appcache_storage.cc",
+ "appcache/appcache_storage.h",
+ "appcache/appcache_storage_impl.cc",
+ "appcache/appcache_storage_impl.h",
+ "appcache/appcache_working_set.cc",
+ "appcache/appcache_working_set.h",
+ "appcache/appcache_update_job.cc",
+ "appcache/appcache_update_job.h",
+ "appcache/appcache_url_request_job.cc",
+ "appcache/appcache_url_request_job.h",
+ "appcache/manifest_parser.cc",
+ "appcache/manifest_parser.h",
+ "blob/blob_data_handle.cc",
+ "blob/blob_data_handle.h",
+ "blob/blob_storage_context.cc",
+ "blob/blob_storage_context.h",
+ "blob/blob_url_request_job.cc",
+ "blob/blob_url_request_job.h",
+ "blob/blob_url_request_job_factory.cc",
+ "blob/blob_url_request_job_factory.h",
+ "blob/file_stream_reader.cc",
+ "blob/file_stream_reader.h",
+ "blob/local_file_stream_reader.cc",
+ "blob/local_file_stream_reader.h",
+ "blob/view_blob_internals_job.cc",
+ "blob/view_blob_internals_job.h",
+ "database/database_quota_client.cc",
+ "database/database_quota_client.h",
+ "database/database_tracker.cc",
+ "database/database_tracker.h",
+ "database/database_util.cc",
+ "database/database_util.h",
+ "database/databases_table.cc",
+ "database/databases_table.h",
+ "database/vfs_backend.cc",
+ "database/vfs_backend.h",
+ "fileapi/async_file_util.h",
+ "fileapi/async_file_util_adapter.cc",
+ "fileapi/async_file_util_adapter.h",
+ "fileapi/copy_or_move_file_validator.h",
+ "fileapi/copy_or_move_operation_delegate.cc",
+ "fileapi/copy_or_move_operation_delegate.h",
+ "fileapi/dragged_file_util.cc",
+ "fileapi/dragged_file_util.h",
+ "fileapi/external_mount_points.cc",
+ "fileapi/external_mount_points.h",
+ "fileapi/file_observers.h",
+ "fileapi/file_permission_policy.h",
+ "fileapi/file_stream_writer.h",
+ "fileapi/file_system_backend.h",
+ "fileapi/file_system_context.cc",
+ "fileapi/file_system_context.h",
+ "fileapi/file_system_dir_url_request_job.cc",
+ "fileapi/file_system_dir_url_request_job.h",
+ "fileapi/file_system_file_stream_reader.cc",
+ "fileapi/file_system_file_stream_reader.h",
+ "fileapi/file_system_file_util.cc",
+ "fileapi/file_system_file_util.h",
+ "fileapi/file_system_operation.h",
+ "fileapi/file_system_operation_context.cc",
+ "fileapi/file_system_operation_context.h",
+ "fileapi/file_system_operation_impl.cc",
+ "fileapi/file_system_operation_impl.h",
+ "fileapi/file_system_operation_runner.cc",
+ "fileapi/file_system_operation_runner.h",
+ "fileapi/file_system_options.cc",
+ "fileapi/file_system_options.h",
+ "fileapi/file_system_quota_client.cc",
+ "fileapi/file_system_quota_client.h",
+ "fileapi/file_system_quota_util.h",
+ "fileapi/file_system_url.cc",
+ "fileapi/file_system_url.h",
+ "fileapi/file_system_url_request_job.cc",
+ "fileapi/file_system_url_request_job.h",
+ "fileapi/file_system_url_request_job_factory.cc",
+ "fileapi/file_system_url_request_job_factory.h",
+ "fileapi/file_system_usage_cache.cc",
+ "fileapi/file_system_usage_cache.h",
+ "fileapi/file_writer_delegate.cc",
+ "fileapi/file_writer_delegate.h",
+ "fileapi/isolated_context.cc",
+ "fileapi/isolated_context.h",
+ "fileapi/isolated_file_system_backend.cc",
+ "fileapi/isolated_file_system_backend.h",
+ "fileapi/local_file_stream_writer.cc",
+ "fileapi/local_file_stream_writer.h",
+ "fileapi/local_file_util.cc",
+ "fileapi/local_file_util.h",
+ "fileapi/mount_points.cc",
+ "fileapi/mount_points.h",
+ "fileapi/native_file_util.cc",
+ "fileapi/native_file_util.h",
+ "fileapi/obfuscated_file_util.cc",
+ "fileapi/obfuscated_file_util.h",
+ "fileapi/open_file_system_mode.h",
+ "fileapi/plugin_private_file_system_backend.cc",
+ "fileapi/plugin_private_file_system_backend.h",
+ "fileapi/quota/open_file_handle.cc",
+ "fileapi/quota/open_file_handle.h",
+ "fileapi/quota/open_file_handle_context.cc",
+ "fileapi/quota/open_file_handle_context.h",
+ "fileapi/quota/quota_backend_impl.cc",
+ "fileapi/quota/quota_backend_impl.h",
+ "fileapi/quota/quota_reservation.cc",
+ "fileapi/quota/quota_reservation.h",
+ "fileapi/quota/quota_reservation_buffer.cc",
+ "fileapi/quota/quota_reservation_buffer.h",
+ "fileapi/quota/quota_reservation_manager.cc",
+ "fileapi/quota/quota_reservation_manager.h",
+ "fileapi/recursive_operation_delegate.cc",
+ "fileapi/recursive_operation_delegate.h",
+ "fileapi/remove_operation_delegate.cc",
+ "fileapi/remove_operation_delegate.h",
+ "fileapi/sandbox_directory_database.cc",
+ "fileapi/sandbox_directory_database.h",
+ "fileapi/sandbox_file_stream_writer.cc",
+ "fileapi/sandbox_file_stream_writer.h",
+ "fileapi/sandbox_file_system_backend.cc",
+ "fileapi/sandbox_file_system_backend.h",
+ "fileapi/sandbox_file_system_backend_delegate.cc",
+ "fileapi/sandbox_file_system_backend_delegate.h",
+ "fileapi/sandbox_isolated_origin_database.cc",
+ "fileapi/sandbox_isolated_origin_database.h",
+ "fileapi/sandbox_origin_database.cc",
+ "fileapi/sandbox_origin_database.h",
+ "fileapi/sandbox_origin_database_interface.cc",
+ "fileapi/sandbox_origin_database_interface.h",
+ "fileapi/sandbox_prioritized_origin_database.cc",
+ "fileapi/sandbox_prioritized_origin_database.h",
+ "fileapi/sandbox_quota_observer.cc",
+ "fileapi/sandbox_quota_observer.h",
+ "fileapi/task_runner_bound_observer_list.h",
+ "fileapi/timed_task_helper.cc",
+ "fileapi/timed_task_helper.h",
+ "fileapi/transient_file_util.cc",
+ "fileapi/transient_file_util.h",
+ "quota/quota_callbacks.h",
+ "quota/quota_client.h",
+ "quota/quota_database.cc",
+ "quota/quota_database.h",
+ "quota/quota_manager.cc",
+ "quota/quota_manager.h",
+ "quota/quota_manager_proxy.cc",
+ "quota/quota_manager_proxy.h",
+ "quota/quota_task.cc",
+ "quota/quota_task.h",
+ "quota/quota_temporary_storage_evictor.cc",
+ "quota/quota_temporary_storage_evictor.h",
+ "quota/special_storage_policy.cc",
+ "quota/special_storage_policy.h",
+ "quota/storage_monitor.cc",
+ "quota/storage_monitor.h",
+ "quota/storage_observer.cc",
+ "quota/storage_observer.h",
+ "quota/usage_tracker.cc",
+ "quota/usage_tracker.h",
+ ]
+
+ defines = [ "WEBKIT_STORAGE_BROWSER_IMPLEMENTATION" ]
+ configs += [ "//build/config/compiler:wexit_time_destructors" ]
+ direct_dependent_configs = [ ":storage_config" ]
+ if (is_win) {
+ cflags = [ "/wd4267" ] # TODO(jschuh): fix size_t to int truncations.
+ }
+
+ deps = [
+ "//base",
+ "//base:i18n",
+ "//base/third_party/dynamic_annotations",
+ "//net",
+ "//sql",
+ "//third_party/leveldatabase",
+ "//third_party/sqlite",
+ "//url",
+ "//webkit/common",
+ "//webkit/common:storage",
+ ]
+
+ # TODO(GYP) support chrome_multiple_dll
+ #['chrome_multiple_dll!=1', {
+ # 'dependencies': [
+ # '<(DEPTH)/third_party/WebKit/public/blink.gyp:blink',
+ # ],
+ #}],
+}
+
+executable("dump_file_system") {
+ sources = [
+ "fileapi/dump_file_system.cc",
+ ]
+
+ deps = [
+ ":storage",
+ "//base",
+ "//webkit/common:storage",
+ ]
+}
diff --git a/chromium/webkit/browser/appcache/appcache.cc b/chromium/webkit/browser/appcache/appcache.cc
index 2014298547a..9179a4090f7 100644
--- a/chromium/webkit/browser/appcache/appcache.cc
+++ b/chromium/webkit/browser/appcache/appcache.cc
@@ -181,7 +181,7 @@ void AppCache::InitializeWithDatabaseRecords(
for (size_t i = 0; i < whitelists.size(); ++i) {
const AppCacheDatabase::OnlineWhiteListRecord& record = whitelists.at(i);
online_whitelist_namespaces_.push_back(
- Namespace(NETWORK_NAMESPACE,
+ Namespace(APPCACHE_NETWORK_NAMESPACE,
record.namespace_url,
GURL(),
record.is_pattern));
diff --git a/chromium/webkit/browser/appcache/appcache.h b/chromium/webkit/browser/appcache/appcache.h
index ea13722a07b..54713b75a1f 100644
--- a/chromium/webkit/browser/appcache/appcache.h
+++ b/chromium/webkit/browser/appcache/appcache.h
@@ -22,6 +22,14 @@ namespace net {
class IOBuffer;
}
+namespace content {
+FORWARD_DECLARE_TEST(AppCacheTest, InitializeWithManifest);
+FORWARD_DECLARE_TEST(AppCacheTest, ToFromDatabaseRecords);
+class AppCacheTest;
+class AppCacheStorageImplTest;
+class AppCacheUpdateJobTest;
+}
+
namespace appcache {
class AppCacheExecutableHandler;
@@ -142,8 +150,9 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCache
private:
friend class AppCacheGroup;
friend class AppCacheHost;
- friend class AppCacheStorageImplTest;
- friend class AppCacheUpdateJobTest;
+ friend class content::AppCacheTest;
+ friend class content::AppCacheStorageImplTest;
+ friend class content::AppCacheUpdateJobTest;
friend class base::RefCounted<AppCache>;
~AppCache();
@@ -195,8 +204,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCache
// to notify storage when cache is deleted
AppCacheStorage* storage_;
- FRIEND_TEST_ALL_PREFIXES(AppCacheTest, InitializeWithManifest);
- FRIEND_TEST_ALL_PREFIXES(AppCacheTest, ToFromDatabaseRecords);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheTest, InitializeWithManifest);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheTest, ToFromDatabaseRecords);
DISALLOW_COPY_AND_ASSIGN(AppCache);
};
diff --git a/chromium/webkit/browser/appcache/appcache_backend_impl.cc b/chromium/webkit/browser/appcache/appcache_backend_impl.cc
index 17b0b0c6a60..376724e15ef 100644
--- a/chromium/webkit/browser/appcache/appcache_backend_impl.cc
+++ b/chromium/webkit/browser/appcache/appcache_backend_impl.cc
@@ -7,7 +7,7 @@
#include "base/stl_util.h"
#include "webkit/browser/appcache/appcache.h"
#include "webkit/browser/appcache/appcache_group.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
namespace appcache {
@@ -23,7 +23,7 @@ AppCacheBackendImpl::~AppCacheBackendImpl() {
service_->UnregisterBackend(this);
}
-void AppCacheBackendImpl::Initialize(AppCacheService* service,
+void AppCacheBackendImpl::Initialize(AppCacheServiceImpl* service,
AppCacheFrontend* frontend,
int process_id) {
DCHECK(!service_ && !frontend_ && frontend && service);
diff --git a/chromium/webkit/browser/appcache/appcache_backend_impl.h b/chromium/webkit/browser/appcache/appcache_backend_impl.h
index 0d1779fc30f..cc85a76cfcf 100644
--- a/chromium/webkit/browser/appcache/appcache_backend_impl.h
+++ b/chromium/webkit/browser/appcache/appcache_backend_impl.h
@@ -11,14 +11,14 @@
namespace appcache {
-class AppCacheService;
+class AppCacheServiceImpl;
class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheBackendImpl {
public:
AppCacheBackendImpl();
~AppCacheBackendImpl();
- void Initialize(AppCacheService* service,
+ void Initialize(AppCacheServiceImpl* service,
AppCacheFrontend* frontend,
int process_id);
@@ -64,7 +64,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheBackendImpl {
void TransferHostIn(int new_host_id, scoped_ptr<AppCacheHost> host);
private:
- AppCacheService* service_;
+ AppCacheServiceImpl* service_;
AppCacheFrontend* frontend_;
int process_id_;
HostMap hosts_;
diff --git a/chromium/webkit/browser/appcache/appcache_database.cc b/chromium/webkit/browser/appcache/appcache_database.cc
index 0980973d49e..a5349d8ca91 100644
--- a/chromium/webkit/browser/appcache/appcache_database.cc
+++ b/chromium/webkit/browser/appcache/appcache_database.cc
@@ -5,11 +5,13 @@
#include "webkit/browser/appcache/appcache_database.h"
#include "base/auto_reset.h"
+#include "base/bind.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
#include "sql/connection.h"
+#include "sql/error_delegate_util.h"
#include "sql/meta_table.h"
#include "sql/statement.h"
#include "sql/transaction.h"
@@ -200,19 +202,15 @@ AppCacheDatabase::NamespaceRecord::~NamespaceRecord() {
AppCacheDatabase::AppCacheDatabase(const base::FilePath& path)
- : db_file_path_(path), is_disabled_(false), is_recreating_(false) {
+ : db_file_path_(path),
+ is_disabled_(false),
+ is_recreating_(false),
+ was_corruption_detected_(false) {
}
AppCacheDatabase::~AppCacheDatabase() {
}
-void AppCacheDatabase::CloseConnection() {
- // We can't close the connection for an in-memory database w/o
- // losing all of the data, so we don't do that.
- if (!db_file_path_.empty())
- ResetConnectionAndTables();
-}
-
void AppCacheDatabase::Disable() {
VLOG(1) << "Disabling appcache database.";
is_disabled_ = true;
@@ -953,9 +951,10 @@ void AppCacheDatabase::ReadNamespaceRecords(
NamespaceRecordVector* intercepts,
NamespaceRecordVector* fallbacks) {
while (statement->Step()) {
- NamespaceType type = static_cast<NamespaceType>(statement->ColumnInt(2));
+ AppCacheNamespaceType type = static_cast<AppCacheNamespaceType>(
+ statement->ColumnInt(2));
NamespaceRecordVector* records =
- (type == FALLBACK_NAMESPACE) ? fallbacks : intercepts;
+ (type == APPCACHE_FALLBACK_NAMESPACE) ? fallbacks : intercepts;
records->push_back(NamespaceRecord());
ReadNamespaceRecord(statement, &records->back());
}
@@ -972,7 +971,7 @@ void AppCacheDatabase::ReadNamespaceRecord(
// Note: quick and dirty storage for the 'executable' bit w/o changing
// schemas, we use the high bit of 'type' field.
- record->namespace_.type = static_cast<NamespaceType>
+ record->namespace_.type = static_cast<AppCacheNamespaceType>
(type_with_executable_bit & 0x7ffffff);
record->namespace_.is_executable =
(type_with_executable_bit & 0x80000000) != 0;
@@ -1036,6 +1035,9 @@ bool AppCacheDatabase::LazyOpen(bool create_if_needed) {
}
AppCacheHistograms::CountInitResult(AppCacheHistograms::INIT_OK);
+ was_corruption_detected_ = false;
+ db_->set_error_callback(
+ base::Bind(&AppCacheDatabase::OnDatabaseError, base::Unretained(this)));
return true;
}
@@ -1127,8 +1129,9 @@ bool AppCacheDatabase::UpgradeSchema() {
}
// Move data from the old table to the new table, setting the
- // 'type' for all current records to the value for FALLBACK_NAMESPACE.
- DCHECK_EQ(0, static_cast<int>(FALLBACK_NAMESPACE));
+ // 'type' for all current records to the value for
+ // APPCACHE_FALLBACK_NAMESPACE.
+ DCHECK_EQ(0, static_cast<int>(APPCACHE_FALLBACK_NAMESPACE));
if (!db_->Execute(
"INSERT INTO Namespaces"
" SELECT cache_id, origin, 0, namespace_url, fallback_entry_url"
@@ -1195,13 +1198,14 @@ bool AppCacheDatabase::DeleteExistingAndCreateNewDatabase() {
// This also deletes the disk cache data.
base::FilePath directory = db_file_path_.DirName();
- if (!base::DeleteFile(directory, true) ||
- !base::CreateDirectory(directory)) {
+ if (!base::DeleteFile(directory, true))
return false;
- }
// Make sure the steps above actually deleted things.
- if (base::PathExists(db_file_path_))
+ if (base::PathExists(directory))
+ return false;
+
+ if (!base::CreateDirectory(directory))
return false;
// So we can't go recursive.
@@ -1212,4 +1216,11 @@ bool AppCacheDatabase::DeleteExistingAndCreateNewDatabase() {
return LazyOpen(true);
}
+void AppCacheDatabase::OnDatabaseError(int err, sql::Statement* stmt) {
+ was_corruption_detected_ |= sql::IsErrorCatastrophic(err);
+ if (!db_->ShouldIgnoreSqliteError(err))
+ DLOG(ERROR) << db_->GetErrorMessage();
+ // TODO: Maybe use non-catostrophic errors to trigger a full integrity check?
+}
+
} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/appcache_database.h b/chromium/webkit/browser/appcache/appcache_database.h
index d374cfd69a9..93bc1bfc3d6 100644
--- a/chromium/webkit/browser/appcache/appcache_database.h
+++ b/chromium/webkit/browser/appcache/appcache_database.h
@@ -25,6 +25,25 @@ class Statement;
class StatementID;
}
+namespace content {
+FORWARD_DECLARE_TEST(AppCacheDatabaseTest, CacheRecords);
+FORWARD_DECLARE_TEST(AppCacheDatabaseTest, EntryRecords);
+FORWARD_DECLARE_TEST(AppCacheDatabaseTest, QuickIntegrityCheck);
+FORWARD_DECLARE_TEST(AppCacheDatabaseTest, NamespaceRecords);
+FORWARD_DECLARE_TEST(AppCacheDatabaseTest, GroupRecords);
+FORWARD_DECLARE_TEST(AppCacheDatabaseTest, LazyOpen);
+FORWARD_DECLARE_TEST(AppCacheDatabaseTest, ExperimentalFlags);
+FORWARD_DECLARE_TEST(AppCacheDatabaseTest, OnlineWhiteListRecords);
+FORWARD_DECLARE_TEST(AppCacheDatabaseTest, ReCreate);
+FORWARD_DECLARE_TEST(AppCacheDatabaseTest, DeletableResponseIds);
+FORWARD_DECLARE_TEST(AppCacheDatabaseTest, OriginUsage);
+FORWARD_DECLARE_TEST(AppCacheDatabaseTest, UpgradeSchema3to5);
+FORWARD_DECLARE_TEST(AppCacheDatabaseTest, UpgradeSchema4to5);
+FORWARD_DECLARE_TEST(AppCacheDatabaseTest, WasCorrutionDetected);
+class AppCacheDatabaseTest;
+class AppCacheStorageImplTest;
+}
+
namespace appcache {
class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheDatabase {
@@ -83,9 +102,9 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheDatabase {
explicit AppCacheDatabase(const base::FilePath& path);
~AppCacheDatabase();
- void CloseConnection();
void Disable();
bool is_disabled() const { return is_disabled_; }
+ bool was_corruption_detected() const { return was_corruption_detected_; }
int64 GetOriginUsage(const GURL& origin);
bool GetAllOriginUsage(std::map<GURL, int64>* usage_map);
@@ -199,25 +218,33 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheDatabase {
// and bodies are stored, and then creates a new database file.
bool DeleteExistingAndCreateNewDatabase();
+ void OnDatabaseError(int err, sql::Statement* stmt);
+
base::FilePath db_file_path_;
scoped_ptr<sql::Connection> db_;
scoped_ptr<sql::MetaTable> meta_table_;
bool is_disabled_;
bool is_recreating_;
-
- FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, CacheRecords);
- FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, EntryRecords);
- FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, QuickIntegrityCheck);
- FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, NamespaceRecords);
- FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, GroupRecords);
- FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, LazyOpen);
- FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, ExperimentalFlags);
- FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, OnlineWhiteListRecords);
- FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, ReCreate);
- FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, DeletableResponseIds);
- FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, OriginUsage);
- FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, UpgradeSchema3to5);
- FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, UpgradeSchema4to5);
+ bool was_corruption_detected_;
+
+ friend class content::AppCacheDatabaseTest;
+ friend class content::AppCacheStorageImplTest;
+
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, CacheRecords);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, EntryRecords);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, QuickIntegrityCheck);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, NamespaceRecords);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, GroupRecords);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, LazyOpen);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, ExperimentalFlags);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest,
+ OnlineWhiteListRecords);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, ReCreate);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, DeletableResponseIds);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, OriginUsage);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, UpgradeSchema3to5);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, UpgradeSchema4to5);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, WasCorrutionDetected);
DISALLOW_COPY_AND_ASSIGN(AppCacheDatabase);
};
diff --git a/chromium/webkit/browser/appcache/appcache_database_unittest.cc b/chromium/webkit/browser/appcache/appcache_database_unittest.cc
deleted file mode 100644
index b5f4e40152a..00000000000
--- a/chromium/webkit/browser/appcache/appcache_database_unittest.cc
+++ /dev/null
@@ -1,1177 +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 "base/bind.h"
-#include "base/file_util.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/strings/stringprintf.h"
-#include "sql/connection.h"
-#include "sql/meta_table.h"
-#include "sql/statement.h"
-#include "sql/test/scoped_error_ignorer.h"
-#include "sql/test/test_helpers.h"
-#include "sql/transaction.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/sqlite/sqlite3.h"
-#include "webkit/browser/appcache/appcache_database.h"
-#include "webkit/browser/appcache/appcache_entry.h"
-
-namespace {
-
-const base::Time kZeroTime;
-
-} // namespace
-
-namespace appcache {
-
-class AppCacheDatabaseTest {};
-
-TEST(AppCacheDatabaseTest, LazyOpen) {
- // Use an empty file path to use an in-memory sqlite database.
- const base::FilePath kEmptyPath;
- AppCacheDatabase db(kEmptyPath);
-
- EXPECT_FALSE(db.LazyOpen(false));
- EXPECT_TRUE(db.LazyOpen(true));
-
- int64 group_id, cache_id, response_id, deleteable_response_rowid;
- group_id = cache_id = response_id = deleteable_response_rowid = 0;
- EXPECT_TRUE(db.FindLastStorageIds(&group_id, &cache_id, &response_id,
- &deleteable_response_rowid));
- EXPECT_EQ(0, group_id);
- EXPECT_EQ(0, cache_id);
- EXPECT_EQ(0, response_id);
- EXPECT_EQ(0, deleteable_response_rowid);
-
- std::set<GURL> origins;
- EXPECT_TRUE(db.FindOriginsWithGroups(&origins));
- EXPECT_TRUE(origins.empty());
-}
-
-TEST(AppCacheDatabaseTest, ReCreate) {
- // Real files on disk for this test.
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- const base::FilePath kDbFile = temp_dir.path().AppendASCII("appcache.db");
- const base::FilePath kNestedDir = temp_dir.path().AppendASCII("nested");
- const base::FilePath kOtherFile = kNestedDir.AppendASCII("other_file");
- EXPECT_TRUE(base::CreateDirectory(kNestedDir));
- EXPECT_EQ(3, file_util::WriteFile(kOtherFile, "foo", 3));
-
- AppCacheDatabase db(kDbFile);
- EXPECT_FALSE(db.LazyOpen(false));
- EXPECT_TRUE(db.LazyOpen(true));
-
- EXPECT_TRUE(base::PathExists(kDbFile));
- EXPECT_TRUE(base::DirectoryExists(kNestedDir));
- EXPECT_TRUE(base::PathExists(kOtherFile));
-
- EXPECT_TRUE(db.DeleteExistingAndCreateNewDatabase());
-
- EXPECT_TRUE(base::PathExists(kDbFile));
- EXPECT_FALSE(base::DirectoryExists(kNestedDir));
- EXPECT_FALSE(base::PathExists(kOtherFile));
-}
-
-#ifdef NDEBUG
-// Only run in release builds because sql::Connection and familiy
-// crank up DLOG(FATAL)'ness and this test presents it with
-// intentionally bad data which causes debug builds to exit instead
-// of run to completion. In release builds, errors the are delivered
-// to the consumer so we can test the error handling of the consumer.
-// TODO: crbug/328576
-TEST(AppCacheDatabaseTest, QuickIntegrityCheck) {
- // Real files on disk for this test too, a corrupt database file.
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- base::FilePath mock_dir = temp_dir.path().AppendASCII("mock");
- ASSERT_TRUE(base::CreateDirectory(mock_dir));
-
- const base::FilePath kDbFile = mock_dir.AppendASCII("appcache.db");
- const base::FilePath kOtherFile = mock_dir.AppendASCII("other_file");
- EXPECT_EQ(3, file_util::WriteFile(kOtherFile, "foo", 3));
-
- // First create a valid db file.
- AppCacheDatabase db(kDbFile);
- EXPECT_TRUE(db.LazyOpen(true));
- EXPECT_TRUE(base::PathExists(kOtherFile));
- EXPECT_TRUE(base::PathExists(kDbFile));
- db.CloseConnection();
-
- // Break it.
- ASSERT_TRUE(sql::test::CorruptSizeInHeader(kDbFile));
-
- // Reopening will notice the corruption and delete/recreate the directory.
- {
- sql::ScopedErrorIgnorer ignore_errors;
- ignore_errors.IgnoreError(SQLITE_CORRUPT);
- EXPECT_TRUE(db.LazyOpen(true));
- EXPECT_FALSE(base::PathExists(kOtherFile));
- EXPECT_TRUE(base::PathExists(kDbFile));
- ASSERT_TRUE(ignore_errors.CheckIgnoredErrors());
- }
-}
-#endif // NDEBUG
-
-TEST(AppCacheDatabaseTest, ExperimentalFlags) {
- const char kExperimentFlagsKey[] = "ExperimentFlags";
- std::string kInjectedFlags("exp1,exp2");
-
- // Real files on disk for this test.
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- const base::FilePath kDbFile = temp_dir.path().AppendASCII("appcache.db");
- const base::FilePath kOtherFile = temp_dir.path().AppendASCII("other_file");
- EXPECT_EQ(3, file_util::WriteFile(kOtherFile, "foo", 3));
- EXPECT_TRUE(base::PathExists(kOtherFile));
-
- AppCacheDatabase db(kDbFile);
- EXPECT_TRUE(db.LazyOpen(true));
-
- // Inject a non empty flags value, and verify it got there.
- EXPECT_TRUE(db.meta_table_->SetValue(kExperimentFlagsKey, kInjectedFlags));
- std::string flags;
- EXPECT_TRUE(db.meta_table_->GetValue(kExperimentFlagsKey, &flags));
- EXPECT_EQ(kInjectedFlags, flags);
- db.CloseConnection();
-
- // If flags don't match the expected value, empty string by default,
- // the database should be recreated and other files should be cleared out.
- EXPECT_TRUE(db.LazyOpen(false));
- EXPECT_TRUE(db.meta_table_->GetValue(kExperimentFlagsKey, &flags));
- EXPECT_TRUE(flags.empty());
- EXPECT_FALSE(base::PathExists(kOtherFile));
-}
-
-TEST(AppCacheDatabaseTest, EntryRecords) {
- const base::FilePath kEmptyPath;
- AppCacheDatabase db(kEmptyPath);
- EXPECT_TRUE(db.LazyOpen(true));
-
- sql::ScopedErrorIgnorer ignore_errors;
- // TODO(shess): Suppressing SQLITE_CONSTRAINT because the code
- // expects that and handles the resulting error. Consider revising
- // the code to use INSERT OR IGNORE (which would not throw
- // SQLITE_CONSTRAINT) and then check ChangeCount() to see if any
- // changes were made.
- ignore_errors.IgnoreError(SQLITE_CONSTRAINT);
-
- AppCacheDatabase::EntryRecord entry;
-
- entry.cache_id = 1;
- entry.url = GURL("http://blah/1");
- entry.flags = AppCacheEntry::MASTER;
- entry.response_id = 1;
- entry.response_size = 100;
- EXPECT_TRUE(db.InsertEntry(&entry));
- EXPECT_FALSE(db.InsertEntry(&entry));
-
- entry.cache_id = 2;
- entry.url = GURL("http://blah/2");
- entry.flags = AppCacheEntry::EXPLICIT;
- entry.response_id = 2;
- entry.response_size = 200;
- EXPECT_TRUE(db.InsertEntry(&entry));
-
- entry.cache_id = 2;
- entry.url = GURL("http://blah/3");
- entry.flags = AppCacheEntry::MANIFEST;
- entry.response_id = 3;
- entry.response_size = 300;
- EXPECT_TRUE(db.InsertEntry(&entry));
-
- std::vector<AppCacheDatabase::EntryRecord> found;
-
- EXPECT_TRUE(db.FindEntriesForCache(1, &found));
- EXPECT_EQ(1U, found.size());
- EXPECT_EQ(1, found[0].cache_id);
- EXPECT_EQ(GURL("http://blah/1"), found[0].url);
- EXPECT_EQ(AppCacheEntry::MASTER, found[0].flags);
- EXPECT_EQ(1, found[0].response_id);
- EXPECT_EQ(100, found[0].response_size);
- found.clear();
-
- EXPECT_TRUE(db.AddEntryFlags(GURL("http://blah/1"), 1,
- AppCacheEntry::FOREIGN));
- EXPECT_TRUE(db.FindEntriesForCache(1, &found));
- EXPECT_EQ(1U, found.size());
- EXPECT_EQ(AppCacheEntry::MASTER | AppCacheEntry::FOREIGN, found[0].flags);
- found.clear();
-
- EXPECT_TRUE(db.FindEntriesForCache(2, &found));
- EXPECT_EQ(2U, found.size());
- EXPECT_EQ(2, found[0].cache_id);
- EXPECT_EQ(GURL("http://blah/2"), found[0].url);
- EXPECT_EQ(AppCacheEntry::EXPLICIT, found[0].flags);
- EXPECT_EQ(2, found[0].response_id);
- EXPECT_EQ(200, found[0].response_size);
- EXPECT_EQ(2, found[1].cache_id);
- EXPECT_EQ(GURL("http://blah/3"), found[1].url);
- EXPECT_EQ(AppCacheEntry::MANIFEST, found[1].flags);
- EXPECT_EQ(3, found[1].response_id);
- EXPECT_EQ(300, found[1].response_size);
- found.clear();
-
- EXPECT_TRUE(db.DeleteEntriesForCache(2));
- EXPECT_TRUE(db.FindEntriesForCache(2, &found));
- EXPECT_TRUE(found.empty());
- found.clear();
-
- EXPECT_TRUE(db.DeleteEntriesForCache(1));
- EXPECT_FALSE(db.AddEntryFlags(GURL("http://blah/1"), 1,
- AppCacheEntry::FOREIGN));
-
- ASSERT_TRUE(ignore_errors.CheckIgnoredErrors());
-}
-
-TEST(AppCacheDatabaseTest, CacheRecords) {
- const base::FilePath kEmptyPath;
- AppCacheDatabase db(kEmptyPath);
- EXPECT_TRUE(db.LazyOpen(true));
-
- sql::ScopedErrorIgnorer ignore_errors;
- // TODO(shess): See EntryRecords test.
- ignore_errors.IgnoreError(SQLITE_CONSTRAINT);
-
- const AppCacheDatabase::CacheRecord kZeroRecord;
- AppCacheDatabase::CacheRecord record;
- EXPECT_FALSE(db.FindCache(1, &record));
-
- record.cache_id = 1;
- record.group_id = 1;
- record.online_wildcard = true;
- record.update_time = kZeroTime;
- record.cache_size = 100;
- EXPECT_TRUE(db.InsertCache(&record));
- EXPECT_FALSE(db.InsertCache(&record));
-
- record = kZeroRecord;
- EXPECT_TRUE(db.FindCache(1, &record));
- EXPECT_EQ(1, record.cache_id);
- EXPECT_EQ(1, record.group_id);
- EXPECT_TRUE(record.online_wildcard);
- EXPECT_TRUE(kZeroTime == record.update_time);
- EXPECT_EQ(100, record.cache_size);
-
- record = kZeroRecord;
- EXPECT_TRUE(db.FindCacheForGroup(1, &record));
- EXPECT_EQ(1, record.cache_id);
- EXPECT_EQ(1, record.group_id);
- EXPECT_TRUE(record.online_wildcard);
- EXPECT_TRUE(kZeroTime == record.update_time);
- EXPECT_EQ(100, record.cache_size);
-
- EXPECT_TRUE(db.DeleteCache(1));
- EXPECT_FALSE(db.FindCache(1, &record));
- EXPECT_FALSE(db.FindCacheForGroup(1, &record));
-
- EXPECT_TRUE(db.DeleteCache(1));
-
- ASSERT_TRUE(ignore_errors.CheckIgnoredErrors());
-}
-
-TEST(AppCacheDatabaseTest, GroupRecords) {
- const base::FilePath kEmptyPath;
- AppCacheDatabase db(kEmptyPath);
- EXPECT_TRUE(db.LazyOpen(true));
-
- sql::ScopedErrorIgnorer ignore_errors;
- // TODO(shess): See EntryRecords test.
- ignore_errors.IgnoreError(SQLITE_CONSTRAINT);
-
- const GURL kManifestUrl("http://blah/manifest");
- const GURL kOrigin(kManifestUrl.GetOrigin());
- const base::Time kLastAccessTime = base::Time::Now();
- const base::Time kCreationTime =
- kLastAccessTime - base::TimeDelta::FromDays(7);
-
- const AppCacheDatabase::GroupRecord kZeroRecord;
- AppCacheDatabase::GroupRecord record;
- std::vector<AppCacheDatabase::GroupRecord> records;
-
- // Behavior with an empty table
- EXPECT_FALSE(db.FindGroup(1, &record));
- EXPECT_FALSE(db.FindGroupForManifestUrl(kManifestUrl, &record));
- EXPECT_TRUE(db.DeleteGroup(1));
- EXPECT_TRUE(db.FindGroupsForOrigin(kOrigin, &records));
- EXPECT_TRUE(records.empty());
- EXPECT_FALSE(db.FindGroupForCache(1, &record));
-
- record.group_id = 1;
- record.manifest_url = kManifestUrl;
- record.origin = kOrigin;
- record.last_access_time = kLastAccessTime;
- record.creation_time = kCreationTime;
- EXPECT_TRUE(db.InsertGroup(&record));
- EXPECT_FALSE(db.InsertGroup(&record));
-
- record.group_id = 2;
- EXPECT_FALSE(db.InsertGroup(&record));
-
- record = kZeroRecord;
- EXPECT_TRUE(db.FindGroup(1, &record));
- EXPECT_EQ(1, record.group_id);
- EXPECT_EQ(kManifestUrl, record.manifest_url);
- EXPECT_EQ(kOrigin, record.origin);
- EXPECT_EQ(kCreationTime.ToInternalValue(),
- record.creation_time.ToInternalValue());
- EXPECT_EQ(kLastAccessTime.ToInternalValue(),
- record.last_access_time.ToInternalValue());
-
- record = kZeroRecord;
- EXPECT_TRUE(db.FindGroupForManifestUrl(kManifestUrl, &record));
- EXPECT_EQ(1, record.group_id);
- EXPECT_EQ(kManifestUrl, record.manifest_url);
- EXPECT_EQ(kOrigin, record.origin);
- EXPECT_EQ(kCreationTime.ToInternalValue(),
- record.creation_time.ToInternalValue());
- EXPECT_EQ(kLastAccessTime.ToInternalValue(),
- record.last_access_time.ToInternalValue());
-
- record.group_id = 2;
- record.manifest_url = kOrigin;
- record.origin = kOrigin;
- record.last_access_time = kLastAccessTime;
- record.creation_time = kCreationTime;
- EXPECT_TRUE(db.InsertGroup(&record));
-
- record = kZeroRecord;
- EXPECT_TRUE(db.FindGroupForManifestUrl(kOrigin, &record));
- EXPECT_EQ(2, record.group_id);
- EXPECT_EQ(kOrigin, record.manifest_url);
- EXPECT_EQ(kOrigin, record.origin);
- EXPECT_EQ(kCreationTime.ToInternalValue(),
- record.creation_time.ToInternalValue());
- EXPECT_EQ(kLastAccessTime.ToInternalValue(),
- record.last_access_time.ToInternalValue());
-
- EXPECT_TRUE(db.FindGroupsForOrigin(kOrigin, &records));
- EXPECT_EQ(2U, records.size());
- EXPECT_EQ(1, records[0].group_id);
- EXPECT_EQ(kManifestUrl, records[0].manifest_url);
- EXPECT_EQ(kOrigin, records[0].origin);
- EXPECT_EQ(2, records[1].group_id);
- EXPECT_EQ(kOrigin, records[1].manifest_url);
- EXPECT_EQ(kOrigin, records[1].origin);
-
- EXPECT_TRUE(db.DeleteGroup(1));
-
- records.clear();
- EXPECT_TRUE(db.FindGroupsForOrigin(kOrigin, &records));
- EXPECT_EQ(1U, records.size());
- EXPECT_EQ(2, records[0].group_id);
- EXPECT_EQ(kOrigin, records[0].manifest_url);
- EXPECT_EQ(kOrigin, records[0].origin);
- EXPECT_EQ(kCreationTime.ToInternalValue(),
- record.creation_time.ToInternalValue());
- EXPECT_EQ(kLastAccessTime.ToInternalValue(),
- record.last_access_time.ToInternalValue());
-
- std::set<GURL> origins;
- EXPECT_TRUE(db.FindOriginsWithGroups(&origins));
- EXPECT_EQ(1U, origins.size());
- EXPECT_EQ(kOrigin, *(origins.begin()));
-
- const GURL kManifest2("http://blah2/manifest");
- const GURL kOrigin2(kManifest2.GetOrigin());
- record.group_id = 1;
- record.manifest_url = kManifest2;
- record.origin = kOrigin2;
- EXPECT_TRUE(db.InsertGroup(&record));
-
- origins.clear();
- EXPECT_TRUE(db.FindOriginsWithGroups(&origins));
- EXPECT_EQ(2U, origins.size());
- EXPECT_TRUE(origins.end() != origins.find(kOrigin));
- EXPECT_TRUE(origins.end() != origins.find(kOrigin2));
-
- AppCacheDatabase::CacheRecord cache_record;
- cache_record.cache_id = 1;
- cache_record.group_id = 1;
- cache_record.online_wildcard = true;
- cache_record.update_time = kZeroTime;
- EXPECT_TRUE(db.InsertCache(&cache_record));
-
- record = kZeroRecord;
- EXPECT_TRUE(db.FindGroupForCache(1, &record));
- EXPECT_EQ(1, record.group_id);
- EXPECT_EQ(kManifest2, record.manifest_url);
- EXPECT_EQ(kOrigin2, record.origin);
-
- ASSERT_TRUE(ignore_errors.CheckIgnoredErrors());
-}
-
-TEST(AppCacheDatabaseTest, NamespaceRecords) {
- const base::FilePath kEmptyPath;
- AppCacheDatabase db(kEmptyPath);
- EXPECT_TRUE(db.LazyOpen(true));
-
- sql::ScopedErrorIgnorer ignore_errors;
- // TODO(shess): See EntryRecords test.
- ignore_errors.IgnoreError(SQLITE_CONSTRAINT);
-
- const GURL kFooNameSpace1("http://foo/namespace1");
- const GURL kFooNameSpace2("http://foo/namespace2");
- const GURL kFooFallbackEntry("http://foo/entry");
- const GURL kFooOrigin(kFooNameSpace1.GetOrigin());
- const GURL kBarNameSpace1("http://bar/namespace1");
- const GURL kBarNameSpace2("http://bar/namespace2");
- const GURL kBarFallbackEntry("http://bar/entry");
- const GURL kBarOrigin(kBarNameSpace1.GetOrigin());
-
- const AppCacheDatabase::NamespaceRecord kZeroRecord;
- AppCacheDatabase::NamespaceRecord record;
- std::vector<AppCacheDatabase::NamespaceRecord> intercepts;
- std::vector<AppCacheDatabase::NamespaceRecord> fallbacks;
-
- // Behavior with an empty table
- EXPECT_TRUE(db.FindNamespacesForCache(1, &intercepts, &fallbacks));
- EXPECT_TRUE(fallbacks.empty());
- EXPECT_TRUE(db.FindNamespacesForOrigin(kFooOrigin, &intercepts, &fallbacks));
- EXPECT_TRUE(fallbacks.empty());
- EXPECT_TRUE(db.DeleteNamespacesForCache(1));
-
- // Two records for two differenent caches in the Foo origin.
- record.cache_id = 1;
- record.origin = kFooOrigin;
- record.namespace_.namespace_url = kFooNameSpace1;
- record.namespace_.target_url = kFooFallbackEntry;
- EXPECT_TRUE(db.InsertNamespace(&record));
- EXPECT_FALSE(db.InsertNamespace(&record));
-
- record.cache_id = 2;
- record.origin = kFooOrigin;
- record.namespace_.namespace_url = kFooNameSpace2;
- record.namespace_.target_url = kFooFallbackEntry;
- EXPECT_TRUE(db.InsertNamespace(&record));
-
- fallbacks.clear();
- EXPECT_TRUE(db.FindNamespacesForCache(1, &intercepts, &fallbacks));
- EXPECT_EQ(1U, fallbacks.size());
- EXPECT_EQ(1, fallbacks[0].cache_id);
- EXPECT_EQ(kFooOrigin, fallbacks[0].origin);
- EXPECT_EQ(kFooNameSpace1, fallbacks[0].namespace_.namespace_url);
- EXPECT_EQ(kFooFallbackEntry, fallbacks[0].namespace_.target_url);
- EXPECT_FALSE(fallbacks[0].namespace_.is_pattern);
-
- fallbacks.clear();
- EXPECT_TRUE(db.FindNamespacesForCache(2, &intercepts, &fallbacks));
- EXPECT_EQ(1U, fallbacks.size());
- EXPECT_EQ(2, fallbacks[0].cache_id);
- EXPECT_EQ(kFooOrigin, fallbacks[0].origin);
- EXPECT_EQ(kFooNameSpace2, fallbacks[0].namespace_.namespace_url);
- EXPECT_EQ(kFooFallbackEntry, fallbacks[0].namespace_.target_url);
- EXPECT_FALSE(fallbacks[0].namespace_.is_pattern);
-
- fallbacks.clear();
- EXPECT_TRUE(db.FindNamespacesForOrigin(kFooOrigin, &intercepts, &fallbacks));
- EXPECT_EQ(2U, fallbacks.size());
- EXPECT_EQ(1, fallbacks[0].cache_id);
- EXPECT_EQ(kFooOrigin, fallbacks[0].origin);
- EXPECT_EQ(kFooNameSpace1, fallbacks[0].namespace_.namespace_url);
- EXPECT_EQ(kFooFallbackEntry, fallbacks[0].namespace_.target_url);
- EXPECT_FALSE(fallbacks[0].namespace_.is_pattern);
- EXPECT_EQ(2, fallbacks[1].cache_id);
- EXPECT_EQ(kFooOrigin, fallbacks[1].origin);
- EXPECT_EQ(kFooNameSpace2, fallbacks[1].namespace_.namespace_url);
- EXPECT_EQ(kFooFallbackEntry, fallbacks[1].namespace_.target_url);
- EXPECT_FALSE(fallbacks[1].namespace_.is_pattern);
-
- EXPECT_TRUE(db.DeleteNamespacesForCache(1));
- fallbacks.clear();
- EXPECT_TRUE(db.FindNamespacesForOrigin(kFooOrigin, &intercepts, &fallbacks));
- EXPECT_EQ(1U, fallbacks.size());
- EXPECT_EQ(2, fallbacks[0].cache_id);
- EXPECT_EQ(kFooOrigin, fallbacks[0].origin);
- EXPECT_EQ(kFooNameSpace2, fallbacks[0].namespace_.namespace_url);
- EXPECT_EQ(kFooFallbackEntry, fallbacks[0].namespace_.target_url);
- EXPECT_FALSE(fallbacks[0].namespace_.is_pattern);
-
- // Two more records for the same cache in the Bar origin.
- record.cache_id = 3;
- record.origin = kBarOrigin;
- record.namespace_.namespace_url = kBarNameSpace1;
- record.namespace_.target_url = kBarFallbackEntry;
- record.namespace_.is_pattern = true;
- EXPECT_TRUE(db.InsertNamespace(&record));
-
- record.cache_id = 3;
- record.origin = kBarOrigin;
- record.namespace_.namespace_url = kBarNameSpace2;
- record.namespace_.target_url = kBarFallbackEntry;
- record.namespace_.is_pattern = true;
- EXPECT_TRUE(db.InsertNamespace(&record));
-
- fallbacks.clear();
- EXPECT_TRUE(db.FindNamespacesForCache(3, &intercepts, &fallbacks));
- EXPECT_EQ(2U, fallbacks.size());
- EXPECT_TRUE(fallbacks[0].namespace_.is_pattern);
- EXPECT_TRUE(fallbacks[1].namespace_.is_pattern);
-
- fallbacks.clear();
- EXPECT_TRUE(db.FindNamespacesForOrigin(kBarOrigin, &intercepts, &fallbacks));
- EXPECT_EQ(2U, fallbacks.size());
- EXPECT_TRUE(fallbacks[0].namespace_.is_pattern);
- EXPECT_TRUE(fallbacks[1].namespace_.is_pattern);
-
- ASSERT_TRUE(ignore_errors.CheckIgnoredErrors());
-}
-
-TEST(AppCacheDatabaseTest, OnlineWhiteListRecords) {
- const base::FilePath kEmptyPath;
- AppCacheDatabase db(kEmptyPath);
- EXPECT_TRUE(db.LazyOpen(true));
-
- const GURL kFooNameSpace1("http://foo/namespace1");
- const GURL kFooNameSpace2("http://foo/namespace2");
- const GURL kBarNameSpace1("http://bar/namespace1");
-
- const AppCacheDatabase::OnlineWhiteListRecord kZeroRecord;
- AppCacheDatabase::OnlineWhiteListRecord record;
- std::vector<AppCacheDatabase::OnlineWhiteListRecord> records;
-
- // Behavior with an empty table
- EXPECT_TRUE(db.FindOnlineWhiteListForCache(1, &records));
- EXPECT_TRUE(records.empty());
- EXPECT_TRUE(db.DeleteOnlineWhiteListForCache(1));
-
- record.cache_id = 1;
- record.namespace_url = kFooNameSpace1;
- EXPECT_TRUE(db.InsertOnlineWhiteList(&record));
- record.namespace_url = kFooNameSpace2;
- record.is_pattern = true;
- EXPECT_TRUE(db.InsertOnlineWhiteList(&record));
- records.clear();
- EXPECT_TRUE(db.FindOnlineWhiteListForCache(1, &records));
- EXPECT_EQ(2U, records.size());
- EXPECT_EQ(1, records[0].cache_id);
- EXPECT_EQ(kFooNameSpace1, records[0].namespace_url);
- EXPECT_FALSE(records[0].is_pattern);
- EXPECT_EQ(1, records[1].cache_id);
- EXPECT_EQ(kFooNameSpace2, records[1].namespace_url);
- EXPECT_TRUE(records[1].is_pattern);
-
- record.cache_id = 2;
- record.namespace_url = kBarNameSpace1;
- EXPECT_TRUE(db.InsertOnlineWhiteList(&record));
- records.clear();
- EXPECT_TRUE(db.FindOnlineWhiteListForCache(2, &records));
- EXPECT_EQ(1U, records.size());
-
- EXPECT_TRUE(db.DeleteOnlineWhiteListForCache(1));
- records.clear();
- EXPECT_TRUE(db.FindOnlineWhiteListForCache(1, &records));
- EXPECT_TRUE(records.empty());
-}
-
-TEST(AppCacheDatabaseTest, DeletableResponseIds) {
- const base::FilePath kEmptyPath;
- AppCacheDatabase db(kEmptyPath);
- EXPECT_TRUE(db.LazyOpen(true));
-
- sql::ScopedErrorIgnorer ignore_errors;
- // TODO(shess): See EntryRecords test.
- ignore_errors.IgnoreError(SQLITE_CONSTRAINT);
-
- std::vector<int64> ids;
-
- EXPECT_TRUE(db.GetDeletableResponseIds(&ids, kint64max, 100));
- EXPECT_TRUE(ids.empty());
- ids.push_back(0);
- EXPECT_TRUE(db.DeleteDeletableResponseIds(ids));
- EXPECT_TRUE(db.InsertDeletableResponseIds(ids));
-
- ids.clear();
- EXPECT_TRUE(db.GetDeletableResponseIds(&ids, kint64max, 100));
- EXPECT_EQ(1U, ids.size());
- EXPECT_EQ(0, ids[0]);
-
- int64 unused, deleteable_response_rowid;
- unused = deleteable_response_rowid = 0;
- EXPECT_TRUE(db.FindLastStorageIds(&unused, &unused, &unused,
- &deleteable_response_rowid));
- EXPECT_EQ(1, deleteable_response_rowid);
-
-
- // Expected to fail due to the duplicate id, 0 is already in the table.
- ids.clear();
- ids.push_back(0);
- ids.push_back(1);
- EXPECT_FALSE(db.InsertDeletableResponseIds(ids));
-
- ids.clear();
- for (int i = 1; i < 10; ++i)
- ids.push_back(i);
- EXPECT_TRUE(db.InsertDeletableResponseIds(ids));
- EXPECT_TRUE(db.FindLastStorageIds(&unused, &unused, &unused,
- &deleteable_response_rowid));
- EXPECT_EQ(10, deleteable_response_rowid);
-
- ids.clear();
- EXPECT_TRUE(db.GetDeletableResponseIds(&ids, kint64max, 100));
- EXPECT_EQ(10U, ids.size());
- for (int i = 0; i < 10; ++i)
- EXPECT_EQ(i, ids[i]);
-
- // Ensure the limit is respected.
- ids.clear();
- EXPECT_TRUE(db.GetDeletableResponseIds(&ids, kint64max, 5));
- EXPECT_EQ(5U, ids.size());
- for (int i = 0; i < static_cast<int>(ids.size()); ++i)
- EXPECT_EQ(i, ids[i]);
-
- // Ensure the max_rowid is respected (the first rowid is 1).
- ids.clear();
- EXPECT_TRUE(db.GetDeletableResponseIds(&ids, 5, 100));
- EXPECT_EQ(5U, ids.size());
- for (int i = 0; i < static_cast<int>(ids.size()); ++i)
- EXPECT_EQ(i, ids[i]);
-
- // Ensure that we can delete from the table.
- EXPECT_TRUE(db.DeleteDeletableResponseIds(ids));
- ids.clear();
- EXPECT_TRUE(db.GetDeletableResponseIds(&ids, kint64max, 100));
- EXPECT_EQ(5U, ids.size());
- for (int i = 0; i < static_cast<int>(ids.size()); ++i)
- EXPECT_EQ(i + 5, ids[i]);
-
- ASSERT_TRUE(ignore_errors.CheckIgnoredErrors());
-}
-
-TEST(AppCacheDatabaseTest, OriginUsage) {
- const GURL kManifestUrl("http://blah/manifest");
- const GURL kManifestUrl2("http://blah/manifest2");
- const GURL kOrigin(kManifestUrl.GetOrigin());
- const GURL kOtherOriginManifestUrl("http://other/manifest");
- const GURL kOtherOrigin(kOtherOriginManifestUrl.GetOrigin());
-
- const base::FilePath kEmptyPath;
- AppCacheDatabase db(kEmptyPath);
- EXPECT_TRUE(db.LazyOpen(true));
-
- std::vector<AppCacheDatabase::CacheRecord> cache_records;
- EXPECT_EQ(0, db.GetOriginUsage(kOrigin));
- EXPECT_TRUE(db.FindCachesForOrigin(kOrigin, &cache_records));
- EXPECT_TRUE(cache_records.empty());
-
- AppCacheDatabase::GroupRecord group_record;
- group_record.group_id = 1;
- group_record.manifest_url = kManifestUrl;
- group_record.origin = kOrigin;
- EXPECT_TRUE(db.InsertGroup(&group_record));
- AppCacheDatabase::CacheRecord cache_record;
- cache_record.cache_id = 1;
- cache_record.group_id = 1;
- cache_record.online_wildcard = true;
- cache_record.update_time = kZeroTime;
- cache_record.cache_size = 100;
- EXPECT_TRUE(db.InsertCache(&cache_record));
-
- EXPECT_EQ(100, db.GetOriginUsage(kOrigin));
-
- group_record.group_id = 2;
- group_record.manifest_url = kManifestUrl2;
- group_record.origin = kOrigin;
- EXPECT_TRUE(db.InsertGroup(&group_record));
- cache_record.cache_id = 2;
- cache_record.group_id = 2;
- cache_record.online_wildcard = true;
- cache_record.update_time = kZeroTime;
- cache_record.cache_size = 1000;
- EXPECT_TRUE(db.InsertCache(&cache_record));
-
- EXPECT_EQ(1100, db.GetOriginUsage(kOrigin));
-
- group_record.group_id = 3;
- group_record.manifest_url = kOtherOriginManifestUrl;
- group_record.origin = kOtherOrigin;
- EXPECT_TRUE(db.InsertGroup(&group_record));
- cache_record.cache_id = 3;
- cache_record.group_id = 3;
- cache_record.online_wildcard = true;
- cache_record.update_time = kZeroTime;
- cache_record.cache_size = 5000;
- EXPECT_TRUE(db.InsertCache(&cache_record));
-
- EXPECT_EQ(5000, db.GetOriginUsage(kOtherOrigin));
-
- EXPECT_TRUE(db.FindCachesForOrigin(kOrigin, &cache_records));
- EXPECT_EQ(2U, cache_records.size());
- cache_records.clear();
- EXPECT_TRUE(db.FindCachesForOrigin(kOtherOrigin, &cache_records));
- EXPECT_EQ(1U, cache_records.size());
-
- std::map<GURL, int64> usage_map;
- EXPECT_TRUE(db.GetAllOriginUsage(&usage_map));
- EXPECT_EQ(2U, usage_map.size());
- EXPECT_EQ(1100, usage_map[kOrigin]);
- EXPECT_EQ(5000, usage_map[kOtherOrigin]);
-}
-
-#if defined(APPCACHE_USE_SIMPLE_CACHE)
-// There is no such upgrade path in this case.
-#else
-TEST(AppCacheDatabaseTest, UpgradeSchema3to5) {
- // Real file on disk for this test.
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- const base::FilePath kDbFile = temp_dir.path().AppendASCII("upgrade3.db");
-
- const GURL kMockOrigin("http://mockorigin/");
- const char kNamespaceUrlFormat[] = "namespace%d";
- const char kTargetUrlFormat[] = "target%d";
- const int kNumNamespaces = 10;
-
- // Create a v3 schema based database containing some fallback records.
- {
- const int kVersion3 = 3;
- const char kGroupsTable[] = "Groups";
- const char kCachesTable[] = "Caches";
- const char kEntriesTable[] = "Entries";
- const char kFallbackNameSpacesTable[] = "FallbackNameSpaces";
- const char kOnlineWhiteListsTable[] = "OnlineWhiteLists";
- const char kDeletableResponseIdsTable[] = "DeletableResponseIds";
-
- const struct {
- const char* table_name;
- const char* columns;
- } kTables3[] = {
- { kGroupsTable,
- "(group_id INTEGER PRIMARY KEY,"
- " origin TEXT,"
- " manifest_url TEXT,"
- " creation_time INTEGER,"
- " last_access_time INTEGER)" },
-
- { kCachesTable,
- "(cache_id INTEGER PRIMARY KEY,"
- " group_id INTEGER,"
- " online_wildcard INTEGER CHECK(online_wildcard IN (0, 1)),"
- " update_time INTEGER,"
- " cache_size INTEGER)" }, // intentionally not normalized
-
- { kEntriesTable,
- "(cache_id INTEGER,"
- " url TEXT,"
- " flags INTEGER,"
- " response_id INTEGER,"
- " response_size INTEGER)" },
-
- { kFallbackNameSpacesTable,
- "(cache_id INTEGER,"
- " origin TEXT," // intentionally not normalized
- " namespace_url TEXT,"
- " fallback_entry_url TEXT)" },
-
- { kOnlineWhiteListsTable,
- "(cache_id INTEGER,"
- " namespace_url TEXT)" },
-
- { kDeletableResponseIdsTable,
- "(response_id INTEGER NOT NULL)" },
- };
-
- const struct {
- const char* index_name;
- const char* table_name;
- const char* columns;
- bool unique;
- } kIndexes3[] = {
- { "GroupsOriginIndex",
- kGroupsTable,
- "(origin)",
- false },
-
- { "GroupsManifestIndex",
- kGroupsTable,
- "(manifest_url)",
- true },
-
- { "CachesGroupIndex",
- kCachesTable,
- "(group_id)",
- false },
-
- { "EntriesCacheIndex",
- kEntriesTable,
- "(cache_id)",
- false },
-
- { "EntriesCacheAndUrlIndex",
- kEntriesTable,
- "(cache_id, url)",
- true },
-
- { "EntriesResponseIdIndex",
- kEntriesTable,
- "(response_id)",
- true },
-
- { "FallbackNameSpacesCacheIndex",
- kFallbackNameSpacesTable,
- "(cache_id)",
- false },
-
- { "FallbackNameSpacesOriginIndex",
- kFallbackNameSpacesTable,
- "(origin)",
- false },
-
- { "FallbackNameSpacesCacheAndUrlIndex",
- kFallbackNameSpacesTable,
- "(cache_id, namespace_url)",
- true },
-
- { "OnlineWhiteListCacheIndex",
- kOnlineWhiteListsTable,
- "(cache_id)",
- false },
-
- { "DeletableResponsesIdIndex",
- kDeletableResponseIdsTable,
- "(response_id)",
- true },
- };
-
- const int kTableCount3 = ARRAYSIZE_UNSAFE(kTables3);
- const int kIndexCount3 = ARRAYSIZE_UNSAFE(kIndexes3);
-
- sql::Connection connection;
- EXPECT_TRUE(connection.Open(kDbFile));
-
- sql::Transaction transaction(&connection);
- EXPECT_TRUE(transaction.Begin());
-
- sql::MetaTable meta_table;
- EXPECT_TRUE(meta_table.Init(&connection, kVersion3, kVersion3));
-
- for (int i = 0; i < kTableCount3; ++i) {
- std::string sql("CREATE TABLE ");
- sql += kTables3[i].table_name;
- sql += kTables3[i].columns;
- EXPECT_TRUE(connection.Execute(sql.c_str()));
- }
-
- for (int i = 0; i < kIndexCount3; ++i) {
- std::string sql;
- if (kIndexes3[i].unique)
- sql += "CREATE UNIQUE INDEX ";
- else
- sql += "CREATE INDEX ";
- sql += kIndexes3[i].index_name;
- sql += " ON ";
- sql += kIndexes3[i].table_name;
- sql += kIndexes3[i].columns;
- EXPECT_TRUE(connection.Execute(sql.c_str()));
- }
-
- const char* kSql =
- "INSERT INTO FallbackNameSpaces"
- " (cache_id, origin, namespace_url, fallback_entry_url)"
- " VALUES (?, ?, ?, ?)";
-
- sql::Statement statement;
- statement.Assign(connection.GetUniqueStatement(kSql));
- EXPECT_TRUE(statement.is_valid());
- for (int i = 0; i < kNumNamespaces; ++i) {
- GURL namespace_url(
- kMockOrigin.Resolve(base::StringPrintf(kNamespaceUrlFormat, i)));
- GURL target_url(
- kMockOrigin.Resolve(base::StringPrintf(kTargetUrlFormat, i)));
- statement.BindInt64(0, i);
- statement.BindString(1, kMockOrigin.spec().c_str());
- statement.BindString(2, namespace_url.spec().c_str());
- statement.BindString(3, target_url.spec().c_str());
- ASSERT_TRUE(statement.Run());
- statement.Reset(true);
- }
-
- EXPECT_TRUE(transaction.Commit());
- }
-
- // Open that database and verify that it got updated.
- AppCacheDatabase db(kDbFile);
- EXPECT_TRUE(db.LazyOpen(true));
-
- EXPECT_FALSE(db.db_->DoesTableExist("FallbackNameSpaces"));
- EXPECT_FALSE(db.db_->DoesIndexExist("FallbackNamesSpacesCacheIndex"));
- EXPECT_FALSE(db.db_->DoesIndexExist("FallbackNameSpacesOriginIndex"));
- EXPECT_FALSE(db.db_->DoesIndexExist("FallbackNameSpacesCacheAndUrlIndex"));
-
- EXPECT_TRUE(db.db_->DoesTableExist("Namespaces"));
- EXPECT_TRUE(db.db_->DoesIndexExist("NamespacesCacheIndex"));
- EXPECT_TRUE(db.db_->DoesIndexExist("NamespacesOriginIndex"));
- EXPECT_TRUE(db.db_->DoesIndexExist("NamespacesCacheAndUrlIndex"));
- EXPECT_TRUE(db.db_->DoesColumnExist("Namespaces", "is_pattern"));
- EXPECT_TRUE(db.db_->DoesColumnExist("OnlineWhiteLists", "is_pattern"));
-
- EXPECT_EQ(5, db.meta_table_->GetVersionNumber());
- EXPECT_EQ(5, db.meta_table_->GetCompatibleVersionNumber());
-
- std::vector<AppCacheDatabase::NamespaceRecord> intercepts;
- std::vector<AppCacheDatabase::NamespaceRecord> fallbacks;
- EXPECT_TRUE(db.FindNamespacesForOrigin(kMockOrigin, &intercepts,
- &fallbacks));
- EXPECT_TRUE(intercepts.empty());
- EXPECT_EQ(kNumNamespaces, static_cast<int>(fallbacks.size()));
-
- for (int i = 0; i < kNumNamespaces; ++i) {
- GURL expected_namespace_url(
- kMockOrigin.Resolve(base::StringPrintf(kNamespaceUrlFormat, i)));
- GURL expected_target_url(
- kMockOrigin.Resolve(base::StringPrintf(kTargetUrlFormat, i)));
-
- EXPECT_EQ(i, fallbacks[i].cache_id);
- EXPECT_EQ(FALLBACK_NAMESPACE, fallbacks[i].namespace_.type);
- EXPECT_EQ(kMockOrigin, fallbacks[i].origin);
- EXPECT_EQ(expected_namespace_url, fallbacks[i].namespace_.namespace_url);
- EXPECT_EQ(expected_target_url, fallbacks[i].namespace_.target_url);
- EXPECT_FALSE(fallbacks[i].namespace_.is_pattern);
- }
-}
-#endif // !APPCACHE_USE_SIMPLE_CACHE
-
-#if defined(APPCACHE_USE_SIMPLE_CACHE)
-// There is no such upgrade path in this case.
-#else
-TEST(AppCacheDatabaseTest, UpgradeSchema4to5) {
- // Real file on disk for this test.
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- const base::FilePath kDbFile = temp_dir.path().AppendASCII("upgrade4.db");
-
- const GURL kMockOrigin("http://mockorigin/");
- const char kNamespaceUrlFormat[] = "namespace%d";
- const char kWhitelistUrlFormat[] = "whitelist%d";
- const char kTargetUrlFormat[] = "target%d";
- const int kNumNamespaces = 10;
- const int kWhitelistCacheId = 1;
-
- // Create a v4 schema based database containing some fallback records.
- {
- const int kVersion4 = 4;
- const char kGroupsTable[] = "Groups";
- const char kCachesTable[] = "Caches";
- const char kEntriesTable[] = "Entries";
- const char kNamespacesTable[] = "Namespaces";
- const char kOnlineWhiteListsTable[] = "OnlineWhiteLists";
- const char kDeletableResponseIdsTable[] = "DeletableResponseIds";
-
- struct TableInfo {
- const char* table_name;
- const char* columns;
- };
-
- struct IndexInfo {
- const char* index_name;
- const char* table_name;
- const char* columns;
- bool unique;
- };
-
- const TableInfo kTables4[] = {
- { kGroupsTable,
- "(group_id INTEGER PRIMARY KEY,"
- " origin TEXT,"
- " manifest_url TEXT,"
- " creation_time INTEGER,"
- " last_access_time INTEGER)" },
-
- { kCachesTable,
- "(cache_id INTEGER PRIMARY KEY,"
- " group_id INTEGER,"
- " online_wildcard INTEGER CHECK(online_wildcard IN (0, 1)),"
- " update_time INTEGER,"
- " cache_size INTEGER)" }, // intentionally not normalized
-
- { kEntriesTable,
- "(cache_id INTEGER,"
- " url TEXT,"
- " flags INTEGER,"
- " response_id INTEGER,"
- " response_size INTEGER)" },
-
- { kNamespacesTable,
- "(cache_id INTEGER,"
- " origin TEXT," // intentionally not normalized
- " type INTEGER,"
- " namespace_url TEXT,"
- " target_url TEXT)" },
-
- { kOnlineWhiteListsTable,
- "(cache_id INTEGER,"
- " namespace_url TEXT)" },
-
- { kDeletableResponseIdsTable,
- "(response_id INTEGER NOT NULL)" },
- };
-
- const IndexInfo kIndexes4[] = {
- { "GroupsOriginIndex",
- kGroupsTable,
- "(origin)",
- false },
-
- { "GroupsManifestIndex",
- kGroupsTable,
- "(manifest_url)",
- true },
-
- { "CachesGroupIndex",
- kCachesTable,
- "(group_id)",
- false },
-
- { "EntriesCacheIndex",
- kEntriesTable,
- "(cache_id)",
- false },
-
- { "EntriesCacheAndUrlIndex",
- kEntriesTable,
- "(cache_id, url)",
- true },
-
- { "EntriesResponseIdIndex",
- kEntriesTable,
- "(response_id)",
- true },
-
- { "NamespacesCacheIndex",
- kNamespacesTable,
- "(cache_id)",
- false },
-
- { "NamespacesOriginIndex",
- kNamespacesTable,
- "(origin)",
- false },
-
- { "NamespacesCacheAndUrlIndex",
- kNamespacesTable,
- "(cache_id, namespace_url)",
- true },
-
- { "OnlineWhiteListCacheIndex",
- kOnlineWhiteListsTable,
- "(cache_id)",
- false },
-
- { "DeletableResponsesIdIndex",
- kDeletableResponseIdsTable,
- "(response_id)",
- true },
- };
-
- const int kTableCount4 = ARRAYSIZE_UNSAFE(kTables4);
- const int kIndexCount4 = ARRAYSIZE_UNSAFE(kIndexes4);
-
- sql::Connection connection;
- EXPECT_TRUE(connection.Open(kDbFile));
-
- sql::Transaction transaction(&connection);
- EXPECT_TRUE(transaction.Begin());
-
- sql::MetaTable meta_table;
- EXPECT_TRUE(meta_table.Init(&connection, kVersion4, kVersion4));
-
- for (int i = 0; i < kTableCount4; ++i) {
- std::string sql("CREATE TABLE ");
- sql += kTables4[i].table_name;
- sql += kTables4[i].columns;
- EXPECT_TRUE(connection.Execute(sql.c_str()));
- }
-
- for (int i = 0; i < kIndexCount4; ++i) {
- std::string sql;
- if (kIndexes4[i].unique)
- sql += "CREATE UNIQUE INDEX ";
- else
- sql += "CREATE INDEX ";
- sql += kIndexes4[i].index_name;
- sql += " ON ";
- sql += kIndexes4[i].table_name;
- sql += kIndexes4[i].columns;
- EXPECT_TRUE(connection.Execute(sql.c_str()));
- }
-
- const char* kNamespacesSql =
- "INSERT INTO Namespaces"
- " (cache_id, origin, type, namespace_url, target_url)"
- " VALUES (?, ?, ?, ?, ?)";
- sql::Statement statement;
- statement.Assign(connection.GetUniqueStatement(kNamespacesSql));
- EXPECT_TRUE(statement.is_valid());
- for (int i = 0; i < kNumNamespaces; ++i) {
- GURL namespace_url(
- kMockOrigin.Resolve(base::StringPrintf(kNamespaceUrlFormat, i)));
- GURL target_url(
- kMockOrigin.Resolve(base::StringPrintf(kTargetUrlFormat, i)));
- statement.BindInt64(0, i);
- statement.BindString(1, kMockOrigin.spec().c_str());
- statement.BindInt(2, FALLBACK_NAMESPACE);
- statement.BindString(3, namespace_url.spec().c_str());
- statement.BindString(4, target_url.spec().c_str());
- ASSERT_TRUE(statement.Run());
- statement.Reset(true);
- }
-
- const char* kWhitelistsSql =
- "INSERT INTO OnlineWhiteLists"
- " (cache_id, namespace_url)"
- " VALUES (?, ?)";
- statement.Assign(connection.GetUniqueStatement(kWhitelistsSql));
- EXPECT_TRUE(statement.is_valid());
- for (int i = 0; i < kNumNamespaces; ++i) {
- GURL namespace_url(
- kMockOrigin.Resolve(base::StringPrintf(kWhitelistUrlFormat, i)));
- statement.BindInt64(0, kWhitelistCacheId);
- statement.BindString(1, namespace_url.spec().c_str());
- ASSERT_TRUE(statement.Run());
- statement.Reset(true);
- }
-
- EXPECT_TRUE(transaction.Commit());
- }
-
- // Open that database and verify that it got upgraded to v5.
- AppCacheDatabase db(kDbFile);
- EXPECT_TRUE(db.LazyOpen(true));
- EXPECT_TRUE(db.db_->DoesColumnExist("Namespaces", "is_pattern"));
- EXPECT_TRUE(db.db_->DoesColumnExist("OnlineWhiteLists", "is_pattern"));
- EXPECT_EQ(5, db.meta_table_->GetVersionNumber());
- EXPECT_EQ(5, db.meta_table_->GetCompatibleVersionNumber());
-
- std::vector<AppCacheDatabase::NamespaceRecord> intercepts;
- std::vector<AppCacheDatabase::NamespaceRecord> fallbacks;
- EXPECT_TRUE(db.FindNamespacesForOrigin(kMockOrigin, &intercepts,
- &fallbacks));
- EXPECT_TRUE(intercepts.empty());
- EXPECT_EQ(kNumNamespaces, static_cast<int>(fallbacks.size()));
-
- std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists;
- EXPECT_TRUE(db.FindOnlineWhiteListForCache(kWhitelistCacheId, &whitelists));
- EXPECT_EQ(kNumNamespaces, static_cast<int>(whitelists.size()));
-
- for (int i = 0; i < kNumNamespaces; ++i) {
- GURL expected_namespace_url(
- kMockOrigin.Resolve(base::StringPrintf(kNamespaceUrlFormat, i)));
- GURL expected_target_url(
- kMockOrigin.Resolve(base::StringPrintf(kTargetUrlFormat, i)));
- GURL expected_whitelist_url(
- kMockOrigin.Resolve(base::StringPrintf(kWhitelistUrlFormat, i)));
-
- EXPECT_EQ(i, fallbacks[i].cache_id);
- EXPECT_EQ(FALLBACK_NAMESPACE, fallbacks[i].namespace_.type);
- EXPECT_EQ(kMockOrigin, fallbacks[i].origin);
- EXPECT_EQ(expected_namespace_url, fallbacks[i].namespace_.namespace_url);
- EXPECT_EQ(expected_target_url, fallbacks[i].namespace_.target_url);
- EXPECT_FALSE(fallbacks[i].namespace_.is_pattern);
- EXPECT_EQ(expected_whitelist_url, whitelists[i].namespace_url);
- EXPECT_FALSE(whitelists[i].is_pattern);
- }
-}
-#endif // !APPCACHE_USE_SIMPLE_CACHE
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/appcache_disk_cache.cc b/chromium/webkit/browser/appcache/appcache_disk_cache.cc
index 4aa3e8ef182..9c16f98779e 100644
--- a/chromium/webkit/browser/appcache/appcache_disk_cache.cc
+++ b/chromium/webkit/browser/appcache/appcache_disk_cache.cc
@@ -49,9 +49,12 @@ class AppCacheDiskCache::CreateBackendCallbackShim
// wrapper around disk_cache::Entry.
class AppCacheDiskCache::EntryImpl : public Entry {
public:
- explicit EntryImpl(disk_cache::Entry* disk_cache_entry)
- : disk_cache_entry_(disk_cache_entry) {
+ EntryImpl(disk_cache::Entry* disk_cache_entry,
+ AppCacheDiskCache* owner)
+ : disk_cache_entry_(disk_cache_entry), owner_(owner) {
DCHECK(disk_cache_entry);
+ DCHECK(owner);
+ owner_->AddOpenEntry(this);
}
// Entry implementation.
@@ -59,6 +62,8 @@ class AppCacheDiskCache::EntryImpl : public Entry {
const net::CompletionCallback& callback) OVERRIDE {
if (offset < 0 || offset > kint32max)
return net::ERR_INVALID_ARGUMENT;
+ if (!disk_cache_entry_)
+ return net::ERR_ABORTED;
return disk_cache_entry_->ReadData(
index, static_cast<int>(offset), buf, buf_len, callback);
}
@@ -67,22 +72,37 @@ class AppCacheDiskCache::EntryImpl : public Entry {
const net::CompletionCallback& callback) OVERRIDE {
if (offset < 0 || offset > kint32max)
return net::ERR_INVALID_ARGUMENT;
+ if (!disk_cache_entry_)
+ return net::ERR_ABORTED;
const bool kTruncate = true;
return disk_cache_entry_->WriteData(
index, static_cast<int>(offset), buf, buf_len, callback, kTruncate);
}
virtual int64 GetSize(int index) OVERRIDE {
- return disk_cache_entry_->GetDataSize(index);
+ return disk_cache_entry_ ? disk_cache_entry_->GetDataSize(index) : 0L;
}
virtual void Close() OVERRIDE {
- disk_cache_entry_->Close();
+ if (disk_cache_entry_)
+ disk_cache_entry_->Close();
delete this;
}
+ void Abandon() {
+ owner_ = NULL;
+ disk_cache_entry_->Close();
+ disk_cache_entry_ = NULL;
+ }
+
private:
+ virtual ~EntryImpl() {
+ if (owner_)
+ owner_->RemoveOpenEntry(this);
+ }
+
disk_cache::Entry* disk_cache_entry_;
+ AppCacheDiskCache* owner_;
};
// Separate object to hold state for each Create, Delete, or Doom call
@@ -129,7 +149,7 @@ class AppCacheDiskCache::ActiveCall {
return net::ERR_IO_PENDING;
}
if (rv == net::OK && entry)
- *entry = new EntryImpl(entry_ptr_);
+ *entry = new EntryImpl(entry_ptr_, owner_);
delete this;
return rv;
}
@@ -137,7 +157,7 @@ class AppCacheDiskCache::ActiveCall {
void OnAsyncCompletion(int rv) {
owner_->RemoveActiveCall(this);
if (rv == net::OK && entry_)
- *entry_ = new EntryImpl(entry_ptr_);
+ *entry_ = new EntryImpl(entry_ptr_, owner_);
callback_.Run(rv);
callback_.Reset();
delete this;
@@ -154,13 +174,7 @@ AppCacheDiskCache::AppCacheDiskCache()
}
AppCacheDiskCache::~AppCacheDiskCache() {
- if (create_backend_callback_.get()) {
- create_backend_callback_->Cancel();
- create_backend_callback_ = NULL;
- OnCreateBackendComplete(net::ERR_ABORTED);
- }
- disk_cache_.reset();
- STLDeleteElements(&active_calls_);
+ Disable();
}
int AppCacheDiskCache::InitWithDiskBackend(
@@ -188,6 +202,17 @@ void AppCacheDiskCache::Disable() {
create_backend_callback_ = NULL;
OnCreateBackendComplete(net::ERR_ABORTED);
}
+
+ // We need to close open file handles in order to reinitalize the
+ // appcache system on the fly. File handles held in both entries and in
+ // the main disk_cache::Backend class need to be released.
+ for (OpenEntries::const_iterator iter = open_entries_.begin();
+ iter != open_entries_.end(); ++iter) {
+ (*iter)->Abandon();
+ }
+ open_entries_.clear();
+ disk_cache_.reset();
+ STLDeleteElements(&active_calls_);
}
int AppCacheDiskCache::CreateEntry(int64 key, Entry** entry,
diff --git a/chromium/webkit/browser/appcache/appcache_disk_cache.h b/chromium/webkit/browser/appcache/appcache_disk_cache.h
index bb1495cf597..d9f27d0fb09 100644
--- a/chromium/webkit/browser/appcache/appcache_disk_cache.h
+++ b/chromium/webkit/browser/appcache/appcache_disk_cache.h
@@ -75,6 +75,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheDiskCache
class ActiveCall;
typedef std::set<ActiveCall*> ActiveCalls;
+ typedef std::set<EntryImpl*> OpenEntries;
bool is_initializing() const {
return create_backend_callback_.get() != NULL;
@@ -86,12 +87,15 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheDiskCache
void OnCreateBackendComplete(int rv);
void AddActiveCall(ActiveCall* call) { active_calls_.insert(call); }
void RemoveActiveCall(ActiveCall* call) { active_calls_.erase(call); }
+ void AddOpenEntry(EntryImpl* entry) { open_entries_.insert(entry); }
+ void RemoveOpenEntry(EntryImpl* entry) { open_entries_.erase(entry); }
bool is_disabled_;
net::CompletionCallback init_callback_;
scoped_refptr<CreateBackendCallbackShim> create_backend_callback_;
PendingCalls pending_calls_;
ActiveCalls active_calls_;
+ OpenEntries open_entries_;
scoped_ptr<disk_cache::Backend> disk_cache_;
};
diff --git a/chromium/webkit/browser/appcache/appcache_entry.h b/chromium/webkit/browser/appcache/appcache_entry.h
index 01b5f6c04f7..fabaa6265a2 100644
--- a/chromium/webkit/browser/appcache/appcache_entry.h
+++ b/chromium/webkit/browser/appcache/appcache_entry.h
@@ -28,10 +28,10 @@ class AppCacheEntry {
};
AppCacheEntry()
- : types_(0), response_id_(kNoResponseId), response_size_(0) {}
+ : types_(0), response_id_(kAppCacheNoResponseId), response_size_(0) {}
explicit AppCacheEntry(int type)
- : types_(type), response_id_(kNoResponseId), response_size_(0) {}
+ : types_(type), response_id_(kAppCacheNoResponseId), response_size_(0) {}
AppCacheEntry(int type, int64 response_id)
: types_(type), response_id_(response_id), response_size_(0) {}
@@ -51,7 +51,7 @@ class AppCacheEntry {
int64 response_id() const { return response_id_; }
void set_response_id(int64 id) { response_id_ = id; }
- bool has_response_id() const { return response_id_ != kNoResponseId; }
+ bool has_response_id() const { return response_id_ != kAppCacheNoResponseId; }
int64 response_size() const { return response_size_; }
void set_response_size(int64 size) { response_size_ = size; }
diff --git a/chromium/webkit/browser/appcache/appcache_group.cc b/chromium/webkit/browser/appcache/appcache_group.cc
index e467516d031..f5ad43d9fa4 100644
--- a/chromium/webkit/browser/appcache/appcache_group.cc
+++ b/chromium/webkit/browser/appcache/appcache_group.cc
@@ -11,7 +11,7 @@
#include "base/message_loop/message_loop.h"
#include "webkit/browser/appcache/appcache.h"
#include "webkit/browser/appcache/appcache_host.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include "webkit/browser/appcache/appcache_storage.h"
#include "webkit/browser/appcache/appcache_update_job.h"
@@ -240,7 +240,7 @@ void AppCacheGroup::HostDestructionImminent(AppCacheHost* host) {
restart_update_task_.Cancel();
}
-void AppCacheGroup::SetUpdateStatus(UpdateStatus status) {
+void AppCacheGroup::SetUpdateAppCacheStatus(UpdateAppCacheStatus status) {
if (status == update_status_)
return;
diff --git a/chromium/webkit/browser/appcache/appcache_group.h b/chromium/webkit/browser/appcache/appcache_group.h
index 82f33ef041a..68cdb2ac44a 100644
--- a/chromium/webkit/browser/appcache/appcache_group.h
+++ b/chromium/webkit/browser/appcache/appcache_group.h
@@ -17,6 +17,16 @@
#include "url/gurl.h"
#include "webkit/browser/webkit_storage_browser_export.h"
+namespace content {
+FORWARD_DECLARE_TEST(AppCacheGroupTest, StartUpdate);
+FORWARD_DECLARE_TEST(AppCacheGroupTest, CancelUpdate);
+FORWARD_DECLARE_TEST(AppCacheGroupTest, QueueUpdate);
+FORWARD_DECLARE_TEST(AppCacheUpdateJobTest, AlreadyChecking);
+FORWARD_DECLARE_TEST(AppCacheUpdateJobTest, AlreadyDownloading);
+class AppCacheUpdateJobTest;
+class MockAppCacheStorage;
+}
+
namespace appcache {
class AppCache;
@@ -38,7 +48,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheGroup
virtual ~UpdateObserver() {}
};
- enum UpdateStatus {
+ enum UpdateAppCacheStatus {
IDLE,
CHECKING,
DOWNLOADING,
@@ -70,7 +80,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheGroup
void AddNewlyDeletableResponseIds(std::vector<int64>* response_ids);
- UpdateStatus update_status() const { return update_status_; }
+ UpdateAppCacheStatus update_status() const { return update_status_; }
// Starts an update via update() javascript API.
void StartUpdate() {
@@ -94,10 +104,10 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheGroup
private:
class HostObserver;
- friend class AppCacheUpdateJob;
- friend class AppCacheUpdateJobTest;
friend class base::RefCounted<AppCacheGroup>;
- friend class MockAppCacheStorage; // for old_caches()
+ friend class content::AppCacheUpdateJobTest;
+ friend class content::MockAppCacheStorage; // for old_caches()
+ friend class AppCacheUpdateJob;
~AppCacheGroup();
@@ -107,7 +117,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheGroup
static const int kUpdateRestartDelayMs = 1000;
AppCacheUpdateJob* update_job() { return update_job_; }
- void SetUpdateStatus(UpdateStatus status);
+ void SetUpdateAppCacheStatus(UpdateAppCacheStatus status);
void NotifyContentBlocked();
@@ -124,7 +134,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheGroup
const int64 group_id_;
const GURL manifest_url_;
base::Time creation_time_;
- UpdateStatus update_status_;
+ UpdateAppCacheStatus update_status_;
bool is_obsolete_;
bool is_being_deleted_;
std::vector<int64> newly_deletable_response_ids_;
@@ -153,11 +163,11 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheGroup
// True if we're in our destructor.
bool is_in_dtor_;
- FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, StartUpdate);
- FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, CancelUpdate);
- FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, QueueUpdate);
- FRIEND_TEST_ALL_PREFIXES(AppCacheUpdateJobTest, AlreadyChecking);
- FRIEND_TEST_ALL_PREFIXES(AppCacheUpdateJobTest, AlreadyDownloading);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheGroupTest, StartUpdate);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheGroupTest, CancelUpdate);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheGroupTest, QueueUpdate);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheUpdateJobTest, AlreadyChecking);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheUpdateJobTest, AlreadyDownloading);
DISALLOW_COPY_AND_ASSIGN(AppCacheGroup);
};
diff --git a/chromium/webkit/browser/appcache/appcache_group_unittest.cc b/chromium/webkit/browser/appcache/appcache_group_unittest.cc
deleted file mode 100644
index 3497c26c1bb..00000000000
--- a/chromium/webkit/browser/appcache/appcache_group_unittest.cc
+++ /dev/null
@@ -1,302 +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 <string>
-
-#include "base/message_loop/message_loop.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/appcache/appcache.h"
-#include "webkit/browser/appcache/appcache_group.h"
-#include "webkit/browser/appcache/appcache_host.h"
-#include "webkit/browser/appcache/appcache_update_job.h"
-#include "webkit/browser/appcache/mock_appcache_service.h"
-#include "webkit/common/appcache/appcache_interfaces.h"
-
-namespace {
-
-class TestAppCacheFrontend : public appcache::AppCacheFrontend {
- public:
- TestAppCacheFrontend()
- : last_host_id_(-1), last_cache_id_(-1),
- last_status_(appcache::OBSOLETE) {
- }
-
- virtual void OnCacheSelected(
- int host_id, const appcache::AppCacheInfo& info) OVERRIDE {
- last_host_id_ = host_id;
- last_cache_id_ = info.cache_id;
- last_status_ = info.status;
- }
-
- virtual void OnStatusChanged(const std::vector<int>& host_ids,
- appcache::Status status) OVERRIDE {
- }
-
- virtual void OnEventRaised(const std::vector<int>& host_ids,
- appcache::EventID event_id) OVERRIDE {
- }
-
- virtual void OnErrorEventRaised(const std::vector<int>& host_ids,
- const std::string& message) OVERRIDE {
- }
-
- virtual void OnProgressEventRaised(const std::vector<int>& host_ids,
- const GURL& url,
- int num_total, int num_complete) OVERRIDE {
- }
-
- virtual void OnLogMessage(int host_id, appcache::LogLevel log_level,
- const std::string& message) OVERRIDE {
- }
-
- virtual void OnContentBlocked(int host_id,
- const GURL& manifest_url) OVERRIDE {
- }
-
- int last_host_id_;
- int64 last_cache_id_;
- appcache::Status last_status_;
-};
-
-} // namespace anon
-
-namespace appcache {
-
-class TestUpdateObserver : public AppCacheGroup::UpdateObserver {
- public:
- TestUpdateObserver() : update_completed_(false), group_has_cache_(false) {
- }
-
- virtual void OnUpdateComplete(AppCacheGroup* group) OVERRIDE {
- update_completed_ = true;
- group_has_cache_ = group->HasCache();
- }
-
- virtual void OnContentBlocked(AppCacheGroup* group) {
- }
-
- bool update_completed_;
- bool group_has_cache_;
-};
-
-class TestAppCacheHost : public AppCacheHost {
- public:
- TestAppCacheHost(int host_id, AppCacheFrontend* frontend,
- AppCacheService* service)
- : AppCacheHost(host_id, frontend, service),
- update_completed_(false) {
- }
-
- virtual void OnUpdateComplete(AppCacheGroup* group) OVERRIDE {
- update_completed_ = true;
- }
-
- bool update_completed_;
-};
-
-class AppCacheGroupTest : public testing::Test {
- private:
- base::MessageLoop message_loop_;
-};
-
-TEST_F(AppCacheGroupTest, AddRemoveCache) {
- MockAppCacheService service;
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service.storage(), GURL("http://foo.com"), 111));
-
- base::Time now = base::Time::Now();
-
- scoped_refptr<AppCache> cache1(new AppCache(service.storage(), 111));
- cache1->set_complete(true);
- cache1->set_update_time(now);
- group->AddCache(cache1.get());
- EXPECT_EQ(cache1, group->newest_complete_cache());
-
- // Adding older cache does not change newest complete cache.
- scoped_refptr<AppCache> cache2(new AppCache(service.storage(), 222));
- cache2->set_complete(true);
- cache2->set_update_time(now - base::TimeDelta::FromDays(1));
- group->AddCache(cache2.get());
- EXPECT_EQ(cache1, group->newest_complete_cache());
-
- // Adding newer cache does change newest complete cache.
- scoped_refptr<AppCache> cache3(new AppCache(service.storage(), 333));
- cache3->set_complete(true);
- cache3->set_update_time(now + base::TimeDelta::FromDays(1));
- group->AddCache(cache3.get());
- EXPECT_EQ(cache3, group->newest_complete_cache());
-
- // Adding cache with same update time uses one with larger ID.
- scoped_refptr<AppCache> cache4(new AppCache(service.storage(), 444));
- cache4->set_complete(true);
- cache4->set_update_time(now + base::TimeDelta::FromDays(1)); // same as 3
- group->AddCache(cache4.get());
- EXPECT_EQ(cache4, group->newest_complete_cache());
-
- // smaller id
- scoped_refptr<AppCache> cache5(new AppCache(service.storage(), 55));
- cache5->set_complete(true);
- cache5->set_update_time(now + base::TimeDelta::FromDays(1)); // same as 4
- group->AddCache(cache5.get());
- EXPECT_EQ(cache4, group->newest_complete_cache()); // no change
-
- // Old caches can always be removed.
- group->RemoveCache(cache1.get());
- EXPECT_FALSE(cache1->owning_group());
- EXPECT_EQ(cache4, group->newest_complete_cache()); // newest unchanged
-
- // Remove rest of caches.
- group->RemoveCache(cache2.get());
- EXPECT_FALSE(cache2->owning_group());
- EXPECT_EQ(cache4, group->newest_complete_cache()); // newest unchanged
- group->RemoveCache(cache3.get());
- EXPECT_FALSE(cache3->owning_group());
- EXPECT_EQ(cache4, group->newest_complete_cache()); // newest unchanged
- group->RemoveCache(cache5.get());
- EXPECT_FALSE(cache5->owning_group());
- EXPECT_EQ(cache4, group->newest_complete_cache()); // newest unchanged
- group->RemoveCache(cache4.get()); // newest removed
- EXPECT_FALSE(cache4->owning_group());
- EXPECT_FALSE(group->newest_complete_cache()); // no more newest cache
-
- // Can remove newest cache if there are older caches.
- group->AddCache(cache1.get());
- EXPECT_EQ(cache1, group->newest_complete_cache());
- group->AddCache(cache4.get());
- EXPECT_EQ(cache4, group->newest_complete_cache());
- group->RemoveCache(cache4.get()); // remove newest
- EXPECT_FALSE(cache4->owning_group());
- EXPECT_FALSE(group->newest_complete_cache()); // newest removed
-}
-
-TEST_F(AppCacheGroupTest, CleanupUnusedGroup) {
- MockAppCacheService service;
- TestAppCacheFrontend frontend;
- AppCacheGroup* group =
- new AppCacheGroup(service.storage(), GURL("http://foo.com"), 111);
-
- AppCacheHost host1(1, &frontend, &service);
- AppCacheHost host2(2, &frontend, &service);
-
- base::Time now = base::Time::Now();
-
- AppCache* cache1 = new AppCache(service.storage(), 111);
- cache1->set_complete(true);
- cache1->set_update_time(now);
- group->AddCache(cache1);
- EXPECT_EQ(cache1, group->newest_complete_cache());
-
- host1.AssociateCompleteCache(cache1);
- EXPECT_EQ(frontend.last_host_id_, host1.host_id());
- EXPECT_EQ(frontend.last_cache_id_, cache1->cache_id());
- EXPECT_EQ(frontend.last_status_, appcache::IDLE);
-
- host2.AssociateCompleteCache(cache1);
- EXPECT_EQ(frontend.last_host_id_, host2.host_id());
- EXPECT_EQ(frontend.last_cache_id_, cache1->cache_id());
- EXPECT_EQ(frontend.last_status_, appcache::IDLE);
-
- AppCache* cache2 = new AppCache(service.storage(), 222);
- cache2->set_complete(true);
- cache2->set_update_time(now + base::TimeDelta::FromDays(1));
- group->AddCache(cache2);
- EXPECT_EQ(cache2, group->newest_complete_cache());
-
- // Unassociate all hosts from older cache.
- host1.AssociateNoCache(GURL());
- host2.AssociateNoCache(GURL());
- EXPECT_EQ(frontend.last_host_id_, host2.host_id());
- EXPECT_EQ(frontend.last_cache_id_, appcache::kNoCacheId);
- EXPECT_EQ(frontend.last_status_, appcache::UNCACHED);
-}
-
-TEST_F(AppCacheGroupTest, StartUpdate) {
- MockAppCacheService service;
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service.storage(), GURL("http://foo.com"), 111));
-
- // Set state to checking to prevent update job from executing fetches.
- group->update_status_ = AppCacheGroup::CHECKING;
- group->StartUpdate();
- AppCacheUpdateJob* update = group->update_job_;
- EXPECT_TRUE(update != NULL);
-
- // Start another update, check that same update job is in use.
- group->StartUpdateWithHost(NULL);
- EXPECT_EQ(update, group->update_job_);
-
- // Deleting the update should restore the group to IDLE.
- delete update;
- EXPECT_TRUE(group->update_job_ == NULL);
- EXPECT_EQ(AppCacheGroup::IDLE, group->update_status());
-}
-
-TEST_F(AppCacheGroupTest, CancelUpdate) {
- MockAppCacheService service;
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service.storage(), GURL("http://foo.com"), 111));
-
- // Set state to checking to prevent update job from executing fetches.
- group->update_status_ = AppCacheGroup::CHECKING;
- group->StartUpdate();
- AppCacheUpdateJob* update = group->update_job_;
- EXPECT_TRUE(update != NULL);
-
- // Deleting the group should cancel the update.
- TestUpdateObserver observer;
- group->AddUpdateObserver(&observer);
- group = NULL; // causes group to be deleted
- EXPECT_TRUE(observer.update_completed_);
- EXPECT_FALSE(observer.group_has_cache_);
-}
-
-TEST_F(AppCacheGroupTest, QueueUpdate) {
- MockAppCacheService service;
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service.storage(), GURL("http://foo.com"), 111));
-
- // Set state to checking to prevent update job from executing fetches.
- group->update_status_ = AppCacheGroup::CHECKING;
- group->StartUpdate();
- EXPECT_TRUE(group->update_job_);
-
- // Pretend group's update job is terminating so that next update is queued.
- group->update_job_->internal_state_ = AppCacheUpdateJob::REFETCH_MANIFEST;
- EXPECT_TRUE(group->update_job_->IsTerminating());
-
- TestAppCacheFrontend frontend;
- TestAppCacheHost host(1, &frontend, &service);
- host.new_master_entry_url_ = GURL("http://foo.com/bar.txt");
- group->StartUpdateWithNewMasterEntry(&host, host.new_master_entry_url_);
- EXPECT_FALSE(group->queued_updates_.empty());
-
- group->AddUpdateObserver(&host);
- EXPECT_FALSE(group->FindObserver(&host, group->observers_));
- EXPECT_TRUE(group->FindObserver(&host, group->queued_observers_));
-
- // Delete update to cause it to complete. Verify no update complete notice
- // sent to host.
- delete group->update_job_;
- EXPECT_EQ(AppCacheGroup::IDLE, group->update_status_);
- EXPECT_FALSE(group->restart_update_task_.IsCancelled());
- EXPECT_FALSE(host.update_completed_);
-
- // Start another update. Cancels task and will run queued updates.
- group->update_status_ = AppCacheGroup::CHECKING; // prevent actual fetches
- group->StartUpdate();
- EXPECT_TRUE(group->update_job_);
- EXPECT_TRUE(group->restart_update_task_.IsCancelled());
- EXPECT_TRUE(group->queued_updates_.empty());
- EXPECT_FALSE(group->update_job_->pending_master_entries_.empty());
- EXPECT_FALSE(group->FindObserver(&host, group->queued_observers_));
- EXPECT_TRUE(group->FindObserver(&host, group->observers_));
-
- // Delete update to cause it to complete. Verify host is notified.
- delete group->update_job_;
- EXPECT_EQ(AppCacheGroup::IDLE, group->update_status_);
- EXPECT_TRUE(group->restart_update_task_.IsCancelled());
- EXPECT_TRUE(host.update_completed_);
-}
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/appcache_histograms.cc b/chromium/webkit/browser/appcache/appcache_histograms.cc
index 36a12603a6c..b7299e658f3 100644
--- a/chromium/webkit/browser/appcache/appcache_histograms.cc
+++ b/chromium/webkit/browser/appcache/appcache_histograms.cc
@@ -8,6 +8,12 @@
namespace appcache {
+static std::string OriginToCustomHistogramSuffix(const GURL& origin_url) {
+ if (origin_url.host() == "docs.google.com")
+ return ".Docs";
+ return std::string();
+}
+
void AppCacheHistograms::CountInitResult(InitResultType init_result) {
UMA_HISTOGRAM_ENUMERATION(
"appcache.InitResult",
@@ -18,6 +24,28 @@ void AppCacheHistograms::CountReinitAttempt(bool repeated_attempt) {
UMA_HISTOGRAM_BOOLEAN("appcache.ReinitAttempt", repeated_attempt);
}
+void AppCacheHistograms::CountCorruptionDetected() {
+ UMA_HISTOGRAM_BOOLEAN("appcache.CorruptionDetected", true);
+}
+
+void AppCacheHistograms::CountUpdateJobResult(
+ AppCacheUpdateJob::ResultType result,
+ const GURL& origin_url) {
+ UMA_HISTOGRAM_ENUMERATION(
+ "appcache.UpdateJobResult",
+ result, AppCacheUpdateJob::NUM_UPDATE_JOB_RESULT_TYPES);
+
+ const std::string suffix = OriginToCustomHistogramSuffix(origin_url);
+ if (!suffix.empty()) {
+ base::LinearHistogram::FactoryGet(
+ "appcache.UpdateJobResult" + suffix,
+ 1,
+ AppCacheUpdateJob::NUM_UPDATE_JOB_RESULT_TYPES,
+ AppCacheUpdateJob::NUM_UPDATE_JOB_RESULT_TYPES + 1,
+ base::HistogramBase::kUmaTargetedHistogramFlag)->Add(result);
+ }
+}
+
void AppCacheHistograms::CountCheckResponseResult(
CheckResponseResultType result) {
UMA_HISTOGRAM_ENUMERATION(
@@ -25,6 +53,58 @@ void AppCacheHistograms::CountCheckResponseResult(
result, NUM_CHECK_RESPONSE_RESULT_TYPES);
}
+void AppCacheHistograms::CountResponseRetrieval(
+ bool success, bool is_main_resource, const GURL& origin_url) {
+ std::string label;
+ if (is_main_resource) {
+ label = "appcache.MainResourceResponseRetrieval";
+ UMA_HISTOGRAM_BOOLEAN(label, success);
+ } else {
+ label = "appcache.SubResourceResponseRetrieval";
+ UMA_HISTOGRAM_BOOLEAN(label, success);
+ }
+ const std::string suffix = OriginToCustomHistogramSuffix(origin_url);
+ if (!suffix.empty()) {
+ base::BooleanHistogram::FactoryGet(
+ label + suffix,
+ base::HistogramBase::kUmaTargetedHistogramFlag)->Add(success);
+ }
+}
+
+void AppCacheHistograms::LogUpdateFailureStats(
+ const GURL& origin_url,
+ int percent_complete,
+ bool was_stalled,
+ bool was_off_origin_resource_failure) {
+ const std::string suffix = OriginToCustomHistogramSuffix(origin_url);
+
+ std::string label = "appcache.UpdateProgressAtPointOfFaliure";
+ UMA_HISTOGRAM_PERCENTAGE(label, percent_complete);
+ if (!suffix.empty()) {
+ base::LinearHistogram::FactoryGet(
+ label + suffix,
+ 1, 101, 102,
+ base::HistogramBase::kUmaTargetedHistogramFlag)->Add(percent_complete);
+ }
+
+ label = "appcache.UpdateWasStalledAtPointOfFailure";
+ UMA_HISTOGRAM_BOOLEAN(label, was_stalled);
+ if (!suffix.empty()) {
+ base::BooleanHistogram::FactoryGet(
+ label + suffix,
+ base::HistogramBase::kUmaTargetedHistogramFlag)->Add(was_stalled);
+ }
+
+ label = "appcache.UpdateWasOffOriginAtPointOfFailure";
+ UMA_HISTOGRAM_BOOLEAN(label, was_off_origin_resource_failure);
+ if (!suffix.empty()) {
+ base::BooleanHistogram::FactoryGet(
+ label + suffix,
+ base::HistogramBase::kUmaTargetedHistogramFlag)->Add(
+ was_off_origin_resource_failure);
+ }
+}
+
void AppCacheHistograms::AddTaskQueueTimeSample(
const base::TimeDelta& duration) {
UMA_HISTOGRAM_TIMES("appcache.TaskQueueTime", duration);
diff --git a/chromium/webkit/browser/appcache/appcache_histograms.h b/chromium/webkit/browser/appcache/appcache_histograms.h
index 928200fe968..21cae36aa7a 100644
--- a/chromium/webkit/browser/appcache/appcache_histograms.h
+++ b/chromium/webkit/browser/appcache/appcache_histograms.h
@@ -6,6 +6,7 @@
#define WEBKIT_BROWSER_APPCACHE_APPCACHE_HISTOGRAMS_H_
#include "base/basictypes.h"
+#include "webkit/browser/appcache/appcache_update_job.h"
namespace base {
class TimeDelta;
@@ -21,14 +22,22 @@ class AppCacheHistograms {
};
static void CountInitResult(InitResultType init_result);
static void CountReinitAttempt(bool repeated_attempt);
-
+ static void CountCorruptionDetected();
+ static void CountUpdateJobResult(AppCacheUpdateJob::ResultType result,
+ const GURL& origin_url);
enum CheckResponseResultType {
RESPONSE_OK, MANIFEST_OUT_OF_DATE, RESPONSE_OUT_OF_DATE, ENTRY_NOT_FOUND,
READ_HEADERS_ERROR, READ_DATA_ERROR, UNEXPECTED_DATA_SIZE, CHECK_CANCELED,
NUM_CHECK_RESPONSE_RESULT_TYPES
};
static void CountCheckResponseResult(CheckResponseResultType result);
-
+ static void CountResponseRetrieval(
+ bool success, bool is_main_resource, const GURL& origin_url);
+ static void LogUpdateFailureStats(
+ const GURL& origin_url,
+ int percent_complete,
+ bool was_making_progress,
+ bool off_origin_resource_failure);
static void AddTaskQueueTimeSample(const base::TimeDelta& duration);
static void AddTaskRunTimeSample(const base::TimeDelta& duration);
static void AddCompletionQueueTimeSample(const base::TimeDelta& duration);
diff --git a/chromium/webkit/browser/appcache/appcache_host.cc b/chromium/webkit/browser/appcache/appcache_host.cc
index f3230df4383..b656b06cfd3 100644
--- a/chromium/webkit/browser/appcache/appcache_host.cc
+++ b/chromium/webkit/browser/appcache/appcache_host.cc
@@ -12,7 +12,7 @@
#include "webkit/browser/appcache/appcache_backend_impl.h"
#include "webkit/browser/appcache/appcache_policy.h"
#include "webkit/browser/appcache/appcache_request_handler.h"
-#include "webkit/browser/quota/quota_manager.h"
+#include "webkit/browser/quota/quota_manager_proxy.h"
namespace appcache {
@@ -20,7 +20,7 @@ namespace {
void FillCacheInfo(const AppCache* cache,
const GURL& manifest_url,
- Status status, AppCacheInfo* info) {
+ AppCacheStatus status, AppCacheInfo* info) {
info->manifest_url = manifest_url;
info->status = status;
@@ -43,12 +43,12 @@ void FillCacheInfo(const AppCache* cache,
} // Anonymous namespace
AppCacheHost::AppCacheHost(int host_id, AppCacheFrontend* frontend,
- AppCacheService* service)
+ AppCacheServiceImpl* service)
: host_id_(host_id),
- spawning_host_id_(kNoHostId), spawning_process_id_(0),
- parent_host_id_(kNoHostId), parent_process_id_(0),
- pending_main_resource_cache_id_(kNoCacheId),
- pending_selected_cache_id_(kNoCacheId),
+ spawning_host_id_(kAppCacheNoHostId), spawning_process_id_(0),
+ parent_host_id_(kAppCacheNoHostId), parent_process_id_(0),
+ pending_main_resource_cache_id_(kAppCacheNoCacheId),
+ pending_selected_cache_id_(kAppCacheNoCacheId),
frontend_(frontend), service_(service),
storage_(service->storage()),
pending_callback_param_(NULL),
@@ -101,7 +101,7 @@ void AppCacheHost::SelectCache(const GURL& document_url,
// MarkAsForeignEntry is called in that case, so that detection
// step is skipped here. See WebApplicationCacheHostImpl.cc
- if (cache_document_was_loaded_from != kNoCacheId) {
+ if (cache_document_was_loaded_from != kAppCacheNoCacheId) {
LoadSelectedCache(cache_document_was_loaded_from);
return;
}
@@ -114,9 +114,15 @@ void AppCacheHost::SelectCache(const GURL& document_url,
!policy->CanCreateAppCache(manifest_url, first_party_url_)) {
FinishCacheSelection(NULL, NULL);
std::vector<int> host_ids(1, host_id_);
- frontend_->OnEventRaised(host_ids, CHECKING_EVENT);
+ frontend_->OnEventRaised(host_ids, APPCACHE_CHECKING_EVENT);
frontend_->OnErrorEventRaised(
- host_ids, "Cache creation was blocked by the content policy");
+ host_ids,
+ AppCacheErrorDetails(
+ "Cache creation was blocked by the content policy",
+ APPCACHE_POLICY_ERROR,
+ GURL(),
+ 0,
+ false /*is_cross_origin*/));
frontend_->OnContentBlocked(host_id_, manifest_url);
return;
}
@@ -153,7 +159,7 @@ void AppCacheHost::SelectCacheForSharedWorker(int64 appcache_id) {
pending_get_status_callback_.is_null() &&
!is_selection_pending());
- if (appcache_id != kNoCacheId) {
+ if (appcache_id != kAppCacheNoCacheId) {
LoadSelectedCache(appcache_id);
return;
}
@@ -167,7 +173,7 @@ void AppCacheHost::MarkAsForeignEntry(const GURL& document_url,
storage()->MarkEntryAsForeign(
main_resource_was_namespace_entry_ ? namespace_entry_url_ : document_url,
cache_document_was_loaded_from);
- SelectCache(document_url, kNoCacheId, GURL());
+ SelectCache(document_url, kAppCacheNoCacheId, GURL());
}
void AppCacheHost::GetStatusWithCallback(const GetStatusCallback& callback,
@@ -307,26 +313,26 @@ void AppCacheHost::GetResourceList(
associated_cache_->ToResourceInfoVector(resource_infos);
}
-Status AppCacheHost::GetStatus() {
+AppCacheStatus AppCacheHost::GetStatus() {
// 6.9.8 Application cache API
AppCache* cache = associated_cache();
if (!cache)
- return UNCACHED;
+ return APPCACHE_STATUS_UNCACHED;
// A cache without an owning group represents the cache being constructed
// during the application cache update process.
if (!cache->owning_group())
- return DOWNLOADING;
+ return APPCACHE_STATUS_DOWNLOADING;
if (cache->owning_group()->is_obsolete())
- return OBSOLETE;
+ return APPCACHE_STATUS_OBSOLETE;
if (cache->owning_group()->update_status() == AppCacheGroup::CHECKING)
- return CHECKING;
+ return APPCACHE_STATUS_CHECKING;
if (cache->owning_group()->update_status() == AppCacheGroup::DOWNLOADING)
- return DOWNLOADING;
+ return APPCACHE_STATUS_DOWNLOADING;
if (swappable_cache_.get())
- return UPDATE_READY;
- return IDLE;
+ return APPCACHE_STATUS_UPDATE_READY;
+ return APPCACHE_STATUS_IDLE;
}
void AppCacheHost::LoadOrCreateGroup(const GURL& manifest_url) {
@@ -343,17 +349,17 @@ void AppCacheHost::OnGroupLoaded(AppCacheGroup* group,
}
void AppCacheHost::LoadSelectedCache(int64 cache_id) {
- DCHECK(cache_id != kNoCacheId);
+ DCHECK(cache_id != kAppCacheNoCacheId);
pending_selected_cache_id_ = cache_id;
storage()->LoadCache(cache_id, this);
}
void AppCacheHost::OnCacheLoaded(AppCache* cache, int64 cache_id) {
if (cache_id == pending_main_resource_cache_id_) {
- pending_main_resource_cache_id_ = kNoCacheId;
+ pending_main_resource_cache_id_ = kAppCacheNoCacheId;
main_resource_cache_ = cache;
} else if (cache_id == pending_selected_cache_id_) {
- pending_selected_cache_id_ = kNoCacheId;
+ pending_selected_cache_id_ = kAppCacheNoCacheId;
FinishCacheSelection(cache, NULL);
}
}
@@ -375,7 +381,7 @@ void AppCacheHost::FinishCacheSelection(
const char* kFormatString =
"Document was loaded from Application Cache with manifest %s";
frontend_->OnLogMessage(
- host_id_, LOG_INFO,
+ host_id_, APPCACHE_LOG_INFO,
base::StringPrintf(
kFormatString, owing_group->manifest_url().spec().c_str()));
AssociateCompleteCache(cache);
@@ -396,7 +402,7 @@ void AppCacheHost::FinishCacheSelection(
"Adding master entry to Application Cache with manifest %s" :
"Creating Application Cache with manifest %s";
frontend_->OnLogMessage(
- host_id_, LOG_INFO,
+ host_id_, APPCACHE_LOG_INFO,
base::StringPrintf(kFormatString,
group->manifest_url().spec().c_str()));
// The UpdateJob may produce one for us later.
@@ -468,7 +474,7 @@ void AppCacheHost::SetSwappableCache(AppCacheGroup* group) {
}
void AppCacheHost::LoadMainResourceCache(int64 cache_id) {
- DCHECK(cache_id != kNoCacheId);
+ DCHECK(cache_id != kAppCacheNoCacheId);
if (pending_main_resource_cache_id_ == cache_id ||
(main_resource_cache_.get() &&
main_resource_cache_->cache_id() == cache_id)) {
@@ -494,7 +500,7 @@ void AppCacheHost::PrepareForTransfer() {
DCHECK(!associated_cache());
DCHECK(!is_selection_pending());
DCHECK(!group_being_updated_);
- host_id_ = kNoHostId;
+ host_id_ = kAppCacheNoHostId;
frontend_ = NULL;
}
diff --git a/chromium/webkit/browser/appcache/appcache_host.h b/chromium/webkit/browser/appcache/appcache_host.h
index 7bbb1f2576d..0831f1571cc 100644
--- a/chromium/webkit/browser/appcache/appcache_host.h
+++ b/chromium/webkit/browser/appcache/appcache_host.h
@@ -11,7 +11,7 @@
#include "base/observer_list.h"
#include "url/gurl.h"
#include "webkit/browser/appcache/appcache_group.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include "webkit/browser/appcache/appcache_storage.h"
#include "webkit/browser/webkit_storage_browser_export.h"
#include "webkit/common/appcache/appcache_interfaces.h"
@@ -21,13 +21,34 @@ namespace net {
class URLRequest;
} // namespace net
+namespace content {
+FORWARD_DECLARE_TEST(AppCacheGroupTest, CleanupUnusedGroup);
+FORWARD_DECLARE_TEST(AppCacheGroupTest, QueueUpdate);
+FORWARD_DECLARE_TEST(AppCacheHostTest, Basic);
+FORWARD_DECLARE_TEST(AppCacheHostTest, SelectNoCache);
+FORWARD_DECLARE_TEST(AppCacheHostTest, ForeignEntry);
+FORWARD_DECLARE_TEST(AppCacheHostTest, FailedCacheLoad);
+FORWARD_DECLARE_TEST(AppCacheHostTest, FailedGroupLoad);
+FORWARD_DECLARE_TEST(AppCacheHostTest, SetSwappableCache);
+FORWARD_DECLARE_TEST(AppCacheHostTest, ForDedicatedWorker);
+FORWARD_DECLARE_TEST(AppCacheHostTest, SelectCacheAllowed);
+FORWARD_DECLARE_TEST(AppCacheHostTest, SelectCacheBlocked);
+FORWARD_DECLARE_TEST(AppCacheTest, CleanupUnusedCache);
+class AppCacheTest;
+class AppCacheHostTest;
+class AppCacheGroupTest;
+class AppCacheStorageImplTest;
+class AppCacheRequestHandlerTest;
+class AppCacheUpdateJobTest;
+}
+
namespace appcache {
class AppCache;
class AppCacheFrontend;
class AppCacheRequestHandler;
-typedef base::Callback<void(Status, void*)> GetStatusCallback;
+typedef base::Callback<void(AppCacheStatus, void*)> GetStatusCallback;
typedef base::Callback<void(bool, void*)> StartUpdateCallback;
typedef base::Callback<void(bool, void*)> SwapCacheCallback;
@@ -35,7 +56,7 @@ typedef base::Callback<void(bool, void*)> SwapCacheCallback;
class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheHost
: public AppCacheStorage::Delegate,
public AppCacheGroup::UpdateObserver,
- public AppCacheService::Observer {
+ public AppCacheServiceImpl::Observer {
public:
class WEBKIT_STORAGE_BROWSER_EXPORT Observer {
@@ -50,7 +71,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheHost
};
AppCacheHost(int host_id, AppCacheFrontend* frontend,
- AppCacheService* service);
+ AppCacheServiceImpl* service);
virtual ~AppCacheHost();
// Adds/removes an observer, the AppCacheHost does not take
@@ -140,13 +161,13 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheHost
}
int host_id() const { return host_id_; }
- AppCacheService* service() const { return service_; }
+ AppCacheServiceImpl* service() const { return service_; }
AppCacheStorage* storage() const { return storage_; }
AppCacheFrontend* frontend() const { return frontend_; }
AppCache* associated_cache() const { return associated_cache_.get(); }
bool is_selection_pending() const {
- return pending_selected_cache_id_ != kNoCacheId ||
+ return pending_selected_cache_id_ != kAppCacheNoCacheId ||
!pending_selected_manifest_url_.is_empty();
}
@@ -157,7 +178,12 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheHost
void CompleteTransfer(int host_id, AppCacheFrontend* frontend);
private:
- Status GetStatus();
+ friend class content::AppCacheHostTest;
+ friend class content::AppCacheStorageImplTest;
+ friend class content::AppCacheRequestHandlerTest;
+ friend class content::AppCacheUpdateJobTest;
+
+ AppCacheStatus GetStatus();
void LoadSelectedCache(int64 cache_id);
void LoadOrCreateGroup(const GURL& manifest_url);
@@ -168,7 +194,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheHost
virtual void OnCacheLoaded(AppCache* cache, int64 cache_id) OVERRIDE;
virtual void OnGroupLoaded(AppCacheGroup* group,
const GURL& manifest_url) OVERRIDE;
- // AppCacheService::Observer impl
+ // AppCacheServiceImpl::Observer impl
virtual void OnServiceReinitialized(
AppCacheStorageReference* old_storage_ref) OVERRIDE;
@@ -184,7 +210,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheHost
// Returns true if this host is for a dedicated worker context.
bool is_for_dedicated_worker() const {
- return parent_host_id_ != kNoHostId;
+ return parent_host_id_ != kAppCacheNoHostId;
}
// Returns the parent context's host instance. This is only valid
@@ -249,7 +275,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheHost
AppCacheFrontend* frontend_;
// Our central service object.
- AppCacheService* service_;
+ AppCacheServiceImpl* service_;
// And the equally central storage object, with a twist. In some error
// conditions the storage object gets recreated and reinitialized. The
@@ -291,21 +317,18 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheHost
// First party url to be used in policy checks.
GURL first_party_url_;
- friend class AppCacheStorageImplTest;
- friend class AppCacheRequestHandlerTest;
- friend class AppCacheUpdateJobTest;
- FRIEND_TEST_ALL_PREFIXES(AppCacheTest, CleanupUnusedCache);
- FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, CleanupUnusedGroup);
- FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, Basic);
- FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, SelectNoCache);
- FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, ForeignEntry);
- FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, FailedCacheLoad);
- FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, FailedGroupLoad);
- FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, SetSwappableCache);
- FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, ForDedicatedWorker);
- FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, SelectCacheAllowed);
- FRIEND_TEST_ALL_PREFIXES(AppCacheHostTest, SelectCacheBlocked);
- FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, QueueUpdate);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheGroupTest, CleanupUnusedGroup);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheGroupTest, QueueUpdate);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheHostTest, Basic);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheHostTest, SelectNoCache);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheHostTest, ForeignEntry);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheHostTest, FailedCacheLoad);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheHostTest, FailedGroupLoad);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheHostTest, SetSwappableCache);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheHostTest, ForDedicatedWorker);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheHostTest, SelectCacheAllowed);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheHostTest, SelectCacheBlocked);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheTest, CleanupUnusedCache);
DISALLOW_COPY_AND_ASSIGN(AppCacheHost);
};
diff --git a/chromium/webkit/browser/appcache/appcache_host_unittest.cc b/chromium/webkit/browser/appcache/appcache_host_unittest.cc
deleted file mode 100644
index 5e78ce8c5e2..00000000000
--- a/chromium/webkit/browser/appcache/appcache_host_unittest.cc
+++ /dev/null
@@ -1,539 +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 "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "net/url_request/url_request.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/appcache/appcache.h"
-#include "webkit/browser/appcache/appcache_backend_impl.h"
-#include "webkit/browser/appcache/appcache_group.h"
-#include "webkit/browser/appcache/appcache_host.h"
-#include "webkit/browser/appcache/mock_appcache_policy.h"
-#include "webkit/browser/appcache/mock_appcache_service.h"
-#include "webkit/browser/quota/quota_manager.h"
-
-namespace appcache {
-
-class AppCacheHostTest : public testing::Test {
- public:
- AppCacheHostTest() {
- get_status_callback_ =
- base::Bind(&AppCacheHostTest::GetStatusCallback,
- base::Unretained(this));
- start_update_callback_ =
- base::Bind(&AppCacheHostTest::StartUpdateCallback,
- base::Unretained(this));
- swap_cache_callback_ =
- base::Bind(&AppCacheHostTest::SwapCacheCallback,
- base::Unretained(this));
- }
-
- class MockFrontend : public AppCacheFrontend {
- public:
- MockFrontend()
- : last_host_id_(-222), last_cache_id_(-222),
- last_status_(appcache::OBSOLETE),
- last_status_changed_(appcache::OBSOLETE),
- last_event_id_(appcache::OBSOLETE_EVENT),
- content_blocked_(false) {
- }
-
- virtual void OnCacheSelected(
- int host_id, const appcache::AppCacheInfo& info) OVERRIDE {
- last_host_id_ = host_id;
- last_cache_id_ = info.cache_id;
- last_status_ = info.status;
- }
-
- virtual void OnStatusChanged(const std::vector<int>& host_ids,
- appcache::Status status) OVERRIDE {
- last_status_changed_ = status;
- }
-
- virtual void OnEventRaised(const std::vector<int>& host_ids,
- appcache::EventID event_id) OVERRIDE {
- last_event_id_ = event_id;
- }
-
- virtual void OnErrorEventRaised(const std::vector<int>& host_ids,
- const std::string& message) OVERRIDE {
- last_event_id_ = ERROR_EVENT;
- }
-
- virtual void OnProgressEventRaised(const std::vector<int>& host_ids,
- const GURL& url,
- int num_total,
- int num_complete) OVERRIDE {
- last_event_id_ = PROGRESS_EVENT;
- }
-
- virtual void OnLogMessage(int host_id,
- appcache::LogLevel log_level,
- const std::string& message) OVERRIDE {
- }
-
- virtual void OnContentBlocked(int host_id,
- const GURL& manifest_url) OVERRIDE {
- content_blocked_ = true;
- }
-
- int last_host_id_;
- int64 last_cache_id_;
- appcache::Status last_status_;
- appcache::Status last_status_changed_;
- appcache::EventID last_event_id_;
- bool content_blocked_;
- };
-
- class MockQuotaManagerProxy : public quota::QuotaManagerProxy {
- public:
- MockQuotaManagerProxy() : QuotaManagerProxy(NULL, NULL) {}
-
- // Not needed for our tests.
- virtual void RegisterClient(quota::QuotaClient* client) OVERRIDE {}
- virtual void NotifyStorageAccessed(quota::QuotaClient::ID client_id,
- const GURL& origin,
- quota::StorageType type) OVERRIDE {}
- virtual void NotifyStorageModified(quota::QuotaClient::ID client_id,
- const GURL& origin,
- quota::StorageType type,
- int64 delta) OVERRIDE {}
- virtual void SetUsageCacheEnabled(quota::QuotaClient::ID client_id,
- const GURL& origin,
- quota::StorageType type,
- bool enabled) OVERRIDE {}
- virtual void GetUsageAndQuota(
- base::SequencedTaskRunner* original_task_runner,
- const GURL& origin,
- quota::StorageType type,
- const GetUsageAndQuotaCallback& callback) OVERRIDE {}
-
- virtual void NotifyOriginInUse(const GURL& origin) OVERRIDE {
- inuse_[origin] += 1;
- }
-
- virtual void NotifyOriginNoLongerInUse(const GURL& origin) OVERRIDE {
- inuse_[origin] -= 1;
- }
-
- int GetInUseCount(const GURL& origin) {
- return inuse_[origin];
- }
-
- void reset() {
- inuse_.clear();
- }
-
- // Map from origin to count of inuse notifications.
- std::map<GURL, int> inuse_;
-
- protected:
- virtual ~MockQuotaManagerProxy() {}
- };
-
- void GetStatusCallback(Status status, void* param) {
- last_status_result_ = status;
- last_callback_param_ = param;
- }
-
- void StartUpdateCallback(bool result, void* param) {
- last_start_result_ = result;
- last_callback_param_ = param;
- }
-
- void SwapCacheCallback(bool result, void* param) {
- last_swap_result_ = result;
- last_callback_param_ = param;
- }
-
- base::MessageLoop message_loop_;
-
- // Mock classes for the 'host' to work with
- MockAppCacheService service_;
- MockFrontend mock_frontend_;
-
- // Mock callbacks we expect to receive from the 'host'
- appcache::GetStatusCallback get_status_callback_;
- appcache::StartUpdateCallback start_update_callback_;
- appcache::SwapCacheCallback swap_cache_callback_;
-
- Status last_status_result_;
- bool last_swap_result_;
- bool last_start_result_;
- void* last_callback_param_;
-};
-
-TEST_F(AppCacheHostTest, Basic) {
- // Construct a host and test what state it appears to be in.
- AppCacheHost host(1, &mock_frontend_, &service_);
- EXPECT_EQ(1, host.host_id());
- EXPECT_EQ(&service_, host.service());
- EXPECT_EQ(&mock_frontend_, host.frontend());
- EXPECT_EQ(NULL, host.associated_cache());
- EXPECT_FALSE(host.is_selection_pending());
-
- // See that the callbacks are delivered immediately
- // and respond as if there is no cache selected.
- last_status_result_ = OBSOLETE;
- host.GetStatusWithCallback(get_status_callback_, reinterpret_cast<void*>(1));
- EXPECT_EQ(UNCACHED, last_status_result_);
- EXPECT_EQ(reinterpret_cast<void*>(1), last_callback_param_);
-
- last_start_result_ = true;
- host.StartUpdateWithCallback(start_update_callback_,
- reinterpret_cast<void*>(2));
- EXPECT_FALSE(last_start_result_);
- EXPECT_EQ(reinterpret_cast<void*>(2), last_callback_param_);
-
- last_swap_result_ = true;
- host.SwapCacheWithCallback(swap_cache_callback_, reinterpret_cast<void*>(3));
- EXPECT_FALSE(last_swap_result_);
- EXPECT_EQ(reinterpret_cast<void*>(3), last_callback_param_);
-}
-
-TEST_F(AppCacheHostTest, SelectNoCache) {
- scoped_refptr<MockQuotaManagerProxy> mock_quota_proxy(
- new MockQuotaManagerProxy);
- service_.set_quota_manager_proxy(mock_quota_proxy.get());
-
- // Reset our mock frontend
- mock_frontend_.last_cache_id_ = -333;
- mock_frontend_.last_host_id_ = -333;
- mock_frontend_.last_status_ = OBSOLETE;
-
- const GURL kDocAndOriginUrl(GURL("http://whatever/").GetOrigin());
- {
- AppCacheHost host(1, &mock_frontend_, &service_);
- host.SelectCache(kDocAndOriginUrl, kNoCacheId, GURL());
- EXPECT_EQ(1, mock_quota_proxy->GetInUseCount(kDocAndOriginUrl));
-
- // We should have received an OnCacheSelected msg
- EXPECT_EQ(1, mock_frontend_.last_host_id_);
- EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_);
- EXPECT_EQ(UNCACHED, mock_frontend_.last_status_);
-
- // Otherwise, see that it respond as if there is no cache selected.
- EXPECT_EQ(1, host.host_id());
- EXPECT_EQ(&service_, host.service());
- EXPECT_EQ(&mock_frontend_, host.frontend());
- EXPECT_EQ(NULL, host.associated_cache());
- EXPECT_FALSE(host.is_selection_pending());
- EXPECT_TRUE(host.preferred_manifest_url().is_empty());
- }
- EXPECT_EQ(0, mock_quota_proxy->GetInUseCount(kDocAndOriginUrl));
- service_.set_quota_manager_proxy(NULL);
-}
-
-TEST_F(AppCacheHostTest, ForeignEntry) {
- // Reset our mock frontend
- mock_frontend_.last_cache_id_ = -333;
- mock_frontend_.last_host_id_ = -333;
- mock_frontend_.last_status_ = OBSOLETE;
-
- // Precondition, a cache with an entry that is not marked as foreign.
- const int kCacheId = 22;
- const GURL kDocumentURL("http://origin/document");
- scoped_refptr<AppCache> cache = new AppCache(service_.storage(), kCacheId);
- cache->AddEntry(kDocumentURL, AppCacheEntry(AppCacheEntry::EXPLICIT));
-
- AppCacheHost host(1, &mock_frontend_, &service_);
- host.MarkAsForeignEntry(kDocumentURL, kCacheId);
-
- // We should have received an OnCacheSelected msg for kNoCacheId.
- EXPECT_EQ(1, mock_frontend_.last_host_id_);
- EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_);
- EXPECT_EQ(UNCACHED, mock_frontend_.last_status_);
-
- // See that it respond as if there is no cache selected.
- EXPECT_EQ(1, host.host_id());
- EXPECT_EQ(&service_, host.service());
- EXPECT_EQ(&mock_frontend_, host.frontend());
- EXPECT_EQ(NULL, host.associated_cache());
- EXPECT_FALSE(host.is_selection_pending());
-
- // See that the entry was marked as foreign.
- EXPECT_TRUE(cache->GetEntry(kDocumentURL)->IsForeign());
-}
-
-TEST_F(AppCacheHostTest, ForeignFallbackEntry) {
- // Reset our mock frontend
- mock_frontend_.last_cache_id_ = -333;
- mock_frontend_.last_host_id_ = -333;
- mock_frontend_.last_status_ = OBSOLETE;
-
- // Precondition, a cache with a fallback entry that is not marked as foreign.
- const int kCacheId = 22;
- const GURL kFallbackURL("http://origin/fallback_resource");
- scoped_refptr<AppCache> cache = new AppCache(service_.storage(), kCacheId);
- cache->AddEntry(kFallbackURL, AppCacheEntry(AppCacheEntry::FALLBACK));
-
- AppCacheHost host(1, &mock_frontend_, &service_);
- host.NotifyMainResourceIsNamespaceEntry(kFallbackURL);
- host.MarkAsForeignEntry(GURL("http://origin/missing_document"), kCacheId);
-
- // We should have received an OnCacheSelected msg for kNoCacheId.
- EXPECT_EQ(1, mock_frontend_.last_host_id_);
- EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_);
- EXPECT_EQ(UNCACHED, mock_frontend_.last_status_);
-
- // See that the fallback entry was marked as foreign.
- EXPECT_TRUE(cache->GetEntry(kFallbackURL)->IsForeign());
-}
-
-TEST_F(AppCacheHostTest, FailedCacheLoad) {
- // Reset our mock frontend
- mock_frontend_.last_cache_id_ = -333;
- mock_frontend_.last_host_id_ = -333;
- mock_frontend_.last_status_ = OBSOLETE;
-
- AppCacheHost host(1, &mock_frontend_, &service_);
- EXPECT_FALSE(host.is_selection_pending());
-
- const int kMockCacheId = 333;
-
- // Put it in a state where we're waiting on a cache
- // load prior to finishing cache selection.
- host.pending_selected_cache_id_ = kMockCacheId;
- EXPECT_TRUE(host.is_selection_pending());
-
- // The callback should not occur until we finish cache selection.
- last_status_result_ = OBSOLETE;
- last_callback_param_ = reinterpret_cast<void*>(-1);
- host.GetStatusWithCallback(get_status_callback_, reinterpret_cast<void*>(1));
- EXPECT_EQ(OBSOLETE, last_status_result_);
- EXPECT_EQ(reinterpret_cast<void*>(-1), last_callback_param_);
-
- // Satisfy the load with NULL, a failure.
- host.OnCacheLoaded(NULL, kMockCacheId);
-
- // Cache selection should have finished
- EXPECT_FALSE(host.is_selection_pending());
- EXPECT_EQ(1, mock_frontend_.last_host_id_);
- EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_);
- EXPECT_EQ(UNCACHED, mock_frontend_.last_status_);
-
- // Callback should have fired upon completing the cache load too.
- EXPECT_EQ(UNCACHED, last_status_result_);
- EXPECT_EQ(reinterpret_cast<void*>(1), last_callback_param_);
-}
-
-TEST_F(AppCacheHostTest, FailedGroupLoad) {
- AppCacheHost host(1, &mock_frontend_, &service_);
-
- const GURL kMockManifestUrl("http://foo.bar/baz");
-
- // Put it in a state where we're waiting on a cache
- // load prior to finishing cache selection.
- host.pending_selected_manifest_url_ = kMockManifestUrl;
- EXPECT_TRUE(host.is_selection_pending());
-
- // The callback should not occur until we finish cache selection.
- last_status_result_ = OBSOLETE;
- last_callback_param_ = reinterpret_cast<void*>(-1);
- host.GetStatusWithCallback(get_status_callback_, reinterpret_cast<void*>(1));
- EXPECT_EQ(OBSOLETE, last_status_result_);
- EXPECT_EQ(reinterpret_cast<void*>(-1), last_callback_param_);
-
- // Satisfy the load will NULL, a failure.
- host.OnGroupLoaded(NULL, kMockManifestUrl);
-
- // Cache selection should have finished
- EXPECT_FALSE(host.is_selection_pending());
- EXPECT_EQ(1, mock_frontend_.last_host_id_);
- EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_);
- EXPECT_EQ(UNCACHED, mock_frontend_.last_status_);
-
- // Callback should have fired upon completing the group load.
- EXPECT_EQ(UNCACHED, last_status_result_);
- EXPECT_EQ(reinterpret_cast<void*>(1), last_callback_param_);
-}
-
-TEST_F(AppCacheHostTest, SetSwappableCache) {
- AppCacheHost host(1, &mock_frontend_, &service_);
- host.SetSwappableCache(NULL);
- EXPECT_FALSE(host.swappable_cache_.get());
-
- scoped_refptr<AppCacheGroup> group1(new AppCacheGroup(
- service_.storage(), GURL(), service_.storage()->NewGroupId()));
- host.SetSwappableCache(group1.get());
- EXPECT_FALSE(host.swappable_cache_.get());
-
- AppCache* cache1 = new AppCache(service_.storage(), 111);
- cache1->set_complete(true);
- group1->AddCache(cache1);
- host.SetSwappableCache(group1.get());
- EXPECT_EQ(cache1, host.swappable_cache_.get());
-
- mock_frontend_.last_host_id_ = -222; // to verify we received OnCacheSelected
-
- host.AssociateCompleteCache(cache1);
- EXPECT_FALSE(host.swappable_cache_.get()); // was same as associated cache
- EXPECT_EQ(appcache::IDLE, host.GetStatus());
- // verify OnCacheSelected was called
- EXPECT_EQ(host.host_id(), mock_frontend_.last_host_id_);
- EXPECT_EQ(cache1->cache_id(), mock_frontend_.last_cache_id_);
- EXPECT_EQ(appcache::IDLE, mock_frontend_.last_status_);
-
- AppCache* cache2 = new AppCache(service_.storage(), 222);
- cache2->set_complete(true);
- group1->AddCache(cache2);
- EXPECT_EQ(cache2, host.swappable_cache_.get()); // updated to newest
-
- scoped_refptr<AppCacheGroup> group2(
- new AppCacheGroup(service_.storage(), GURL("http://foo.com"),
- service_.storage()->NewGroupId()));
- AppCache* cache3 = new AppCache(service_.storage(), 333);
- cache3->set_complete(true);
- group2->AddCache(cache3);
-
- AppCache* cache4 = new AppCache(service_.storage(), 444);
- cache4->set_complete(true);
- group2->AddCache(cache4);
- EXPECT_EQ(cache2, host.swappable_cache_.get()); // unchanged
-
- host.AssociateCompleteCache(cache3);
- EXPECT_EQ(cache4, host.swappable_cache_.get()); // newest cache in group2
- EXPECT_FALSE(group1->HasCache()); // both caches in group1 have refcount 0
-
- host.AssociateNoCache(GURL());
- EXPECT_FALSE(host.swappable_cache_.get());
- EXPECT_FALSE(group2->HasCache()); // both caches in group2 have refcount 0
-
- // Host adds reference to newest cache when an update is complete.
- AppCache* cache5 = new AppCache(service_.storage(), 555);
- cache5->set_complete(true);
- group2->AddCache(cache5);
- host.group_being_updated_ = group2;
- host.OnUpdateComplete(group2.get());
- EXPECT_FALSE(host.group_being_updated_.get());
- EXPECT_EQ(cache5, host.swappable_cache_.get());
-
- group2->RemoveCache(cache5);
- EXPECT_FALSE(group2->HasCache());
- host.group_being_updated_ = group2;
- host.OnUpdateComplete(group2.get());
- EXPECT_FALSE(host.group_being_updated_.get());
- EXPECT_FALSE(host.swappable_cache_.get()); // group2 had no newest cache
-}
-
-TEST_F(AppCacheHostTest, ForDedicatedWorker) {
- const int kMockProcessId = 1;
- const int kParentHostId = 1;
- const int kWorkerHostId = 2;
-
- AppCacheBackendImpl backend_impl;
- backend_impl.Initialize(&service_, &mock_frontend_, kMockProcessId);
- backend_impl.RegisterHost(kParentHostId);
- backend_impl.RegisterHost(kWorkerHostId);
-
- AppCacheHost* parent_host = backend_impl.GetHost(kParentHostId);
- EXPECT_FALSE(parent_host->is_for_dedicated_worker());
-
- AppCacheHost* worker_host = backend_impl.GetHost(kWorkerHostId);
- worker_host->SelectCacheForWorker(kParentHostId, kMockProcessId);
- EXPECT_TRUE(worker_host->is_for_dedicated_worker());
- EXPECT_EQ(parent_host, worker_host->GetParentAppCacheHost());
-
- // We should have received an OnCacheSelected msg for the worker_host.
- // The host for workers always indicates 'no cache selected' regardless
- // of its parent's state. This is OK because the worker cannot access
- // the scriptable interface, the only function available is resource
- // loading (see appcache_request_handler_unittests those tests).
- EXPECT_EQ(kWorkerHostId, mock_frontend_.last_host_id_);
- EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_);
- EXPECT_EQ(UNCACHED, mock_frontend_.last_status_);
-
- // Simulate the parent being torn down.
- backend_impl.UnregisterHost(kParentHostId);
- parent_host = NULL;
- EXPECT_EQ(NULL, backend_impl.GetHost(kParentHostId));
- EXPECT_EQ(NULL, worker_host->GetParentAppCacheHost());
-}
-
-TEST_F(AppCacheHostTest, SelectCacheAllowed) {
- scoped_refptr<MockQuotaManagerProxy> mock_quota_proxy(
- new MockQuotaManagerProxy);
- MockAppCachePolicy mock_appcache_policy;
- mock_appcache_policy.can_create_return_value_ = true;
- service_.set_quota_manager_proxy(mock_quota_proxy.get());
- service_.set_appcache_policy(&mock_appcache_policy);
-
- // Reset our mock frontend
- mock_frontend_.last_cache_id_ = -333;
- mock_frontend_.last_host_id_ = -333;
- mock_frontend_.last_status_ = OBSOLETE;
- mock_frontend_.last_event_id_ = OBSOLETE_EVENT;
- mock_frontend_.content_blocked_ = false;
-
- const GURL kDocAndOriginUrl(GURL("http://whatever/").GetOrigin());
- const GURL kManifestUrl(GURL("http://whatever/cache.manifest"));
- {
- AppCacheHost host(1, &mock_frontend_, &service_);
- host.first_party_url_ = kDocAndOriginUrl;
- host.SelectCache(kDocAndOriginUrl, kNoCacheId, kManifestUrl);
- EXPECT_EQ(1, mock_quota_proxy->GetInUseCount(kDocAndOriginUrl));
-
- // MockAppCacheService::LoadOrCreateGroup is asynchronous, so we shouldn't
- // have received an OnCacheSelected msg yet.
- EXPECT_EQ(-333, mock_frontend_.last_host_id_);
- EXPECT_EQ(-333, mock_frontend_.last_cache_id_);
- EXPECT_EQ(OBSOLETE, mock_frontend_.last_status_);
- // No error events either
- EXPECT_EQ(OBSOLETE_EVENT, mock_frontend_.last_event_id_);
- EXPECT_FALSE(mock_frontend_.content_blocked_);
-
- EXPECT_TRUE(host.is_selection_pending());
- }
- EXPECT_EQ(0, mock_quota_proxy->GetInUseCount(kDocAndOriginUrl));
- service_.set_quota_manager_proxy(NULL);
-}
-
-TEST_F(AppCacheHostTest, SelectCacheBlocked) {
- scoped_refptr<MockQuotaManagerProxy> mock_quota_proxy(
- new MockQuotaManagerProxy);
- MockAppCachePolicy mock_appcache_policy;
- mock_appcache_policy.can_create_return_value_ = false;
- service_.set_quota_manager_proxy(mock_quota_proxy.get());
- service_.set_appcache_policy(&mock_appcache_policy);
-
- // Reset our mock frontend
- mock_frontend_.last_cache_id_ = -333;
- mock_frontend_.last_host_id_ = -333;
- mock_frontend_.last_status_ = OBSOLETE;
- mock_frontend_.last_event_id_ = OBSOLETE_EVENT;
- mock_frontend_.content_blocked_ = false;
-
- const GURL kDocAndOriginUrl(GURL("http://whatever/").GetOrigin());
- const GURL kManifestUrl(GURL("http://whatever/cache.manifest"));
- {
- AppCacheHost host(1, &mock_frontend_, &service_);
- host.first_party_url_ = kDocAndOriginUrl;
- host.SelectCache(kDocAndOriginUrl, kNoCacheId, kManifestUrl);
- EXPECT_EQ(1, mock_quota_proxy->GetInUseCount(kDocAndOriginUrl));
-
- // We should have received an OnCacheSelected msg
- EXPECT_EQ(1, mock_frontend_.last_host_id_);
- EXPECT_EQ(kNoCacheId, mock_frontend_.last_cache_id_);
- EXPECT_EQ(UNCACHED, mock_frontend_.last_status_);
-
- // Also, an error event was raised
- EXPECT_EQ(ERROR_EVENT, mock_frontend_.last_event_id_);
- EXPECT_TRUE(mock_frontend_.content_blocked_);
-
- // Otherwise, see that it respond as if there is no cache selected.
- EXPECT_EQ(1, host.host_id());
- EXPECT_EQ(&service_, host.service());
- EXPECT_EQ(&mock_frontend_, host.frontend());
- EXPECT_EQ(NULL, host.associated_cache());
- EXPECT_FALSE(host.is_selection_pending());
- EXPECT_TRUE(host.preferred_manifest_url().is_empty());
- }
- EXPECT_EQ(0, mock_quota_proxy->GetInUseCount(kDocAndOriginUrl));
- service_.set_quota_manager_proxy(NULL);
-}
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/appcache_interceptor.cc b/chromium/webkit/browser/appcache/appcache_interceptor.cc
deleted file mode 100644
index 20d7668bc47..00000000000
--- a/chromium/webkit/browser/appcache/appcache_interceptor.cc
+++ /dev/null
@@ -1,121 +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.
-
-#include "webkit/browser/appcache/appcache_interceptor.h"
-
-#include "webkit/browser/appcache/appcache_backend_impl.h"
-#include "webkit/browser/appcache/appcache_host.h"
-#include "webkit/browser/appcache/appcache_request_handler.h"
-#include "webkit/browser/appcache/appcache_service.h"
-#include "webkit/browser/appcache/appcache_url_request_job.h"
-#include "webkit/common/appcache/appcache_interfaces.h"
-
-namespace appcache {
-
-// static
-AppCacheInterceptor* AppCacheInterceptor::GetInstance() {
- return Singleton<AppCacheInterceptor>::get();
-}
-
-void AppCacheInterceptor::SetHandler(
- net::URLRequest* request, AppCacheRequestHandler* handler) {
- request->SetUserData(GetInstance(), handler); // request takes ownership
-}
-
-AppCacheRequestHandler* AppCacheInterceptor::GetHandler(
- net::URLRequest* request) {
- return reinterpret_cast<AppCacheRequestHandler*>(
- request->GetUserData(GetInstance()));
-}
-
-void AppCacheInterceptor::SetExtraRequestInfo(
- net::URLRequest* request, AppCacheService* service, int process_id,
- int host_id, ResourceType::Type resource_type) {
- if (!service || (host_id == kNoHostId))
- return;
-
- AppCacheBackendImpl* backend = service->GetBackend(process_id);
- if (!backend)
- return;
-
- // TODO(michaeln): An invalid host id is indicative of bad data
- // from a child process. How should we handle that here?
- AppCacheHost* host = backend->GetHost(host_id);
- if (!host)
- return;
-
- // Create a handler for this request and associate it with the request.
- AppCacheRequestHandler* handler =
- host->CreateRequestHandler(request, resource_type);
- if (handler)
- SetHandler(request, handler);
-}
-
-void AppCacheInterceptor::GetExtraResponseInfo(net::URLRequest* request,
- int64* cache_id,
- GURL* manifest_url) {
- DCHECK(*cache_id == kNoCacheId);
- DCHECK(manifest_url->is_empty());
- AppCacheRequestHandler* handler = GetHandler(request);
- if (handler)
- handler->GetExtraResponseInfo(cache_id, manifest_url);
-}
-
-void AppCacheInterceptor::PrepareForCrossSiteTransfer(
- net::URLRequest* request,
- int old_process_id) {
- AppCacheRequestHandler* handler = GetHandler(request);
- if (!handler)
- return;
- handler->PrepareForCrossSiteTransfer(old_process_id);
-}
-
-void AppCacheInterceptor::CompleteCrossSiteTransfer(
- net::URLRequest* request,
- int new_process_id,
- int new_host_id) {
- AppCacheRequestHandler* handler = GetHandler(request);
- if (!handler)
- return;
- DCHECK_NE(kNoHostId, new_host_id);
- handler->CompleteCrossSiteTransfer(new_process_id,
- new_host_id);
-}
-
-AppCacheInterceptor::AppCacheInterceptor() {
- net::URLRequest::Deprecated::RegisterRequestInterceptor(this);
-}
-
-AppCacheInterceptor::~AppCacheInterceptor() {
- net::URLRequest::Deprecated::UnregisterRequestInterceptor(this);
-}
-
-net::URLRequestJob* AppCacheInterceptor::MaybeIntercept(
- net::URLRequest* request, net::NetworkDelegate* network_delegate) {
- AppCacheRequestHandler* handler = GetHandler(request);
- if (!handler)
- return NULL;
- return handler->MaybeLoadResource(request, network_delegate);
-}
-
-net::URLRequestJob* AppCacheInterceptor::MaybeInterceptRedirect(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate,
- const GURL& location) {
- AppCacheRequestHandler* handler = GetHandler(request);
- if (!handler)
- return NULL;
- return handler->MaybeLoadFallbackForRedirect(
- request, network_delegate, location);
-}
-
-net::URLRequestJob* AppCacheInterceptor::MaybeInterceptResponse(
- net::URLRequest* request, net::NetworkDelegate* network_delegate) {
- AppCacheRequestHandler* handler = GetHandler(request);
- if (!handler)
- return NULL;
- return handler->MaybeLoadFallbackForResponse(request, network_delegate);
-}
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/appcache_interceptor.h b/chromium/webkit/browser/appcache/appcache_interceptor.h
deleted file mode 100644
index 9ae223cab82..00000000000
--- a/chromium/webkit/browser/appcache/appcache_interceptor.h
+++ /dev/null
@@ -1,80 +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.
-
-#ifndef WEBKIT_BROWSER_APPCACHE_APPCACHE_INTERCEPTOR_H_
-#define WEBKIT_BROWSER_APPCACHE_APPCACHE_INTERCEPTOR_H_
-
-#include "base/memory/singleton.h"
-#include "net/url_request/url_request.h"
-#include "url/gurl.h"
-#include "webkit/browser/webkit_storage_browser_export.h"
-#include "webkit/common/resource_type.h"
-
-namespace appcache {
-
-class AppCacheRequestHandler;
-class AppCacheService;
-
-// An interceptor to hijack requests and potentially service them out of
-// the appcache.
-class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheInterceptor
- : public net::URLRequest::Interceptor {
- public:
- // Registers a singleton instance with the net library.
- // Should be called early in the IO thread prior to initiating requests.
- static void EnsureRegistered() {
- CHECK(GetInstance());
- }
-
- // Must be called to make a request eligible for retrieval from an appcache.
- static void SetExtraRequestInfo(net::URLRequest* request,
- AppCacheService* service,
- int process_id,
- int host_id,
- ResourceType::Type resource_type);
-
- // May be called after response headers are complete to retrieve extra
- // info about the response.
- static void GetExtraResponseInfo(net::URLRequest* request,
- int64* cache_id,
- GURL* manifest_url);
-
- // Methods to support cross site navigations.
- static void PrepareForCrossSiteTransfer(net::URLRequest* request,
- int old_process_id);
- static void CompleteCrossSiteTransfer(net::URLRequest* request,
- int new_process_id,
- int new_host_id);
-
- static AppCacheInterceptor* GetInstance();
-
- protected:
- // Override from net::URLRequest::Interceptor:
- virtual net::URLRequestJob* MaybeIntercept(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate) OVERRIDE;
- virtual net::URLRequestJob* MaybeInterceptResponse(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate) OVERRIDE;
- virtual net::URLRequestJob* MaybeInterceptRedirect(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate,
- const GURL& location) OVERRIDE;
-
- private:
- friend struct DefaultSingletonTraits<AppCacheInterceptor>;
-
- AppCacheInterceptor();
- virtual ~AppCacheInterceptor();
-
- static void SetHandler(net::URLRequest* request,
- AppCacheRequestHandler* handler);
- static AppCacheRequestHandler* GetHandler(net::URLRequest* request);
-
- DISALLOW_COPY_AND_ASSIGN(AppCacheInterceptor);
-};
-
-} // namespace appcache
-
-#endif // WEBKIT_BROWSER_APPCACHE_APPCACHE_INTERCEPTOR_H_
diff --git a/chromium/webkit/browser/appcache/appcache_quota_client.cc b/chromium/webkit/browser/appcache/appcache_quota_client.cc
index ec44a28d780..039b5544bd9 100644
--- a/chromium/webkit/browser/appcache/appcache_quota_client.cc
+++ b/chromium/webkit/browser/appcache/appcache_quota_client.cc
@@ -10,7 +10,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
using quota::QuotaClient;
@@ -33,7 +33,7 @@ void RunFront(appcache::AppCacheQuotaClient::RequestQueue* queue) {
namespace appcache {
-AppCacheQuotaClient::AppCacheQuotaClient(AppCacheService* service)
+AppCacheQuotaClient::AppCacheQuotaClient(AppCacheServiceImpl* service)
: service_(service),
appcache_is_ready_(false),
quota_manager_is_destroyed_(false) {
diff --git a/chromium/webkit/browser/appcache/appcache_quota_client.h b/chromium/webkit/browser/appcache/appcache_quota_client.h
index c4901831e38..825f38e1658 100644
--- a/chromium/webkit/browser/appcache/appcache_quota_client.h
+++ b/chromium/webkit/browser/appcache/appcache_quota_client.h
@@ -19,9 +19,13 @@
#include "webkit/browser/webkit_storage_browser_export.h"
#include "webkit/common/quota/quota_types.h"
+namespace content {
+class AppCacheQuotaClientTest;
+}
+
namespace appcache {
-class AppCacheService;
+class AppCacheServiceImpl;
class AppCacheStorageImpl;
class AppCacheQuotaClientTest;
@@ -53,12 +57,12 @@ class AppCacheQuotaClient : public quota::QuotaClient {
virtual bool DoesSupport(quota::StorageType type) const OVERRIDE;
private:
- friend class AppCacheService; // for NotifyAppCacheIsDestroyed
+ friend class content::AppCacheQuotaClientTest;
+ friend class AppCacheServiceImpl; // for NotifyAppCacheIsDestroyed
friend class AppCacheStorageImpl; // for NotifyAppCacheIsReady
- friend class AppCacheQuotaClientTest;
WEBKIT_STORAGE_BROWSER_EXPORT
- explicit AppCacheQuotaClient(AppCacheService* service);
+ explicit AppCacheQuotaClient(AppCacheServiceImpl* service);
void DidDeleteAppCachesForOrigin(int rv);
void GetOriginsHelper(quota::StorageType type,
@@ -83,7 +87,7 @@ class AppCacheQuotaClient : public quota::QuotaClient {
DeletionCallback current_delete_request_callback_;
scoped_ptr<net::CancelableCompletionCallback> service_delete_callback_;
- AppCacheService* service_;
+ AppCacheServiceImpl* service_;
bool appcache_is_ready_;
bool quota_manager_is_destroyed_;
diff --git a/chromium/webkit/browser/appcache/appcache_quota_client_unittest.cc b/chromium/webkit/browser/appcache/appcache_quota_client_unittest.cc
deleted file mode 100644
index 5b7adeda009..00000000000
--- a/chromium/webkit/browser/appcache/appcache_quota_client_unittest.cc
+++ /dev/null
@@ -1,435 +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 <map>
-#include <set>
-
-#include "base/bind.h"
-#include "base/message_loop/message_loop_proxy.h"
-#include "base/run_loop.h"
-#include "net/base/net_errors.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/appcache/appcache_quota_client.h"
-#include "webkit/browser/appcache/mock_appcache_service.h"
-
-namespace appcache {
-
-// Declared to shorten the line lengths.
-static const quota::StorageType kTemp = quota::kStorageTypeTemporary;
-static const quota::StorageType kPerm = quota::kStorageTypePersistent;
-
-// Base class for our test fixtures.
-class AppCacheQuotaClientTest : public testing::Test {
- public:
- const GURL kOriginA;
- const GURL kOriginB;
- const GURL kOriginOther;
-
- AppCacheQuotaClientTest()
- : kOriginA("http://host"),
- kOriginB("http://host:8000"),
- kOriginOther("http://other"),
- usage_(0),
- delete_status_(quota::kQuotaStatusUnknown),
- num_get_origin_usage_completions_(0),
- num_get_origins_completions_(0),
- num_delete_origins_completions_(0),
- weak_factory_(this) {
- }
-
- int64 GetOriginUsage(
- quota::QuotaClient* client,
- const GURL& origin,
- quota::StorageType type) {
- usage_ = -1;
- AsyncGetOriginUsage(client, origin, type);
- base::RunLoop().RunUntilIdle();
- return usage_;
- }
-
- const std::set<GURL>& GetOriginsForType(
- quota::QuotaClient* client,
- quota::StorageType type) {
- origins_.clear();
- AsyncGetOriginsForType(client, type);
- base::RunLoop().RunUntilIdle();
- return origins_;
- }
-
- const std::set<GURL>& GetOriginsForHost(
- quota::QuotaClient* client,
- quota::StorageType type,
- const std::string& host) {
- origins_.clear();
- AsyncGetOriginsForHost(client, type, host);
- base::RunLoop().RunUntilIdle();
- return origins_;
- }
-
- quota::QuotaStatusCode DeleteOriginData(
- quota::QuotaClient* client,
- quota::StorageType type,
- const GURL& origin) {
- delete_status_ = quota::kQuotaStatusUnknown;
- AsyncDeleteOriginData(client, type, origin);
- base::RunLoop().RunUntilIdle();
- return delete_status_;
- }
-
- void AsyncGetOriginUsage(
- quota::QuotaClient* client,
- const GURL& origin,
- quota::StorageType type) {
- client->GetOriginUsage(
- origin, type,
- base::Bind(&AppCacheQuotaClientTest::OnGetOriginUsageComplete,
- weak_factory_.GetWeakPtr()));
- }
-
- void AsyncGetOriginsForType(
- quota::QuotaClient* client,
- quota::StorageType type) {
- client->GetOriginsForType(
- type,
- base::Bind(&AppCacheQuotaClientTest::OnGetOriginsComplete,
- weak_factory_.GetWeakPtr()));
- }
-
- void AsyncGetOriginsForHost(
- quota::QuotaClient* client,
- quota::StorageType type,
- const std::string& host) {
- client->GetOriginsForHost(
- type, host,
- base::Bind(&AppCacheQuotaClientTest::OnGetOriginsComplete,
- weak_factory_.GetWeakPtr()));
- }
-
- void AsyncDeleteOriginData(
- quota::QuotaClient* client,
- quota::StorageType type,
- const GURL& origin) {
- client->DeleteOriginData(
- origin, type,
- base::Bind(&AppCacheQuotaClientTest::OnDeleteOriginDataComplete,
- weak_factory_.GetWeakPtr()));
- }
-
- void SetUsageMapEntry(const GURL& origin, int64 usage) {
- mock_service_.storage()->usage_map_[origin] = usage;
- }
-
- AppCacheQuotaClient* CreateClient() {
- return new AppCacheQuotaClient(&mock_service_);
- }
-
- void Call_NotifyAppCacheReady(AppCacheQuotaClient* client) {
- client->NotifyAppCacheReady();
- }
-
- void Call_NotifyAppCacheDestroyed(AppCacheQuotaClient* client) {
- client->NotifyAppCacheDestroyed();
- }
-
- void Call_OnQuotaManagerDestroyed(AppCacheQuotaClient* client) {
- client->OnQuotaManagerDestroyed();
- }
-
- protected:
- void OnGetOriginUsageComplete(int64 usage) {
- ++num_get_origin_usage_completions_;
- usage_ = usage;
- }
-
- void OnGetOriginsComplete(const std::set<GURL>& origins) {
- ++num_get_origins_completions_;
- origins_ = origins;
- }
-
- void OnDeleteOriginDataComplete(quota::QuotaStatusCode status) {
- ++num_delete_origins_completions_;
- delete_status_ = status;
- }
-
- base::MessageLoop message_loop_;
- int64 usage_;
- std::set<GURL> origins_;
- quota::QuotaStatusCode delete_status_;
- int num_get_origin_usage_completions_;
- int num_get_origins_completions_;
- int num_delete_origins_completions_;
- MockAppCacheService mock_service_;
- base::WeakPtrFactory<AppCacheQuotaClientTest> weak_factory_;
-};
-
-
-TEST_F(AppCacheQuotaClientTest, BasicCreateDestroy) {
- AppCacheQuotaClient* client = CreateClient();
- Call_NotifyAppCacheReady(client);
- Call_OnQuotaManagerDestroyed(client);
- Call_NotifyAppCacheDestroyed(client);
-}
-
-TEST_F(AppCacheQuotaClientTest, EmptyService) {
- AppCacheQuotaClient* client = CreateClient();
- Call_NotifyAppCacheReady(client);
-
- EXPECT_EQ(0, GetOriginUsage(client, kOriginA, kTemp));
- EXPECT_EQ(0, GetOriginUsage(client, kOriginA, kPerm));
- EXPECT_TRUE(GetOriginsForType(client, kTemp).empty());
- EXPECT_TRUE(GetOriginsForType(client, kPerm).empty());
- EXPECT_TRUE(GetOriginsForHost(client, kTemp, kOriginA.host()).empty());
- EXPECT_TRUE(GetOriginsForHost(client, kPerm, kOriginA.host()).empty());
- EXPECT_EQ(quota::kQuotaStatusOk, DeleteOriginData(client, kTemp, kOriginA));
- EXPECT_EQ(quota::kQuotaStatusOk, DeleteOriginData(client, kPerm, kOriginA));
-
- Call_NotifyAppCacheDestroyed(client);
- Call_OnQuotaManagerDestroyed(client);
-}
-
-TEST_F(AppCacheQuotaClientTest, NoService) {
- AppCacheQuotaClient* client = CreateClient();
- Call_NotifyAppCacheReady(client);
- Call_NotifyAppCacheDestroyed(client);
-
- EXPECT_EQ(0, GetOriginUsage(client, kOriginA, kTemp));
- EXPECT_EQ(0, GetOriginUsage(client, kOriginA, kPerm));
- EXPECT_TRUE(GetOriginsForType(client, kTemp).empty());
- EXPECT_TRUE(GetOriginsForType(client, kPerm).empty());
- EXPECT_TRUE(GetOriginsForHost(client, kTemp, kOriginA.host()).empty());
- EXPECT_TRUE(GetOriginsForHost(client, kPerm, kOriginA.host()).empty());
- EXPECT_EQ(quota::kQuotaErrorAbort,
- DeleteOriginData(client, kTemp, kOriginA));
- EXPECT_EQ(quota::kQuotaErrorAbort,
- DeleteOriginData(client, kPerm, kOriginA));
-
- Call_OnQuotaManagerDestroyed(client);
-}
-
-TEST_F(AppCacheQuotaClientTest, GetOriginUsage) {
- AppCacheQuotaClient* client = CreateClient();
- Call_NotifyAppCacheReady(client);
-
- SetUsageMapEntry(kOriginA, 1000);
- EXPECT_EQ(1000, GetOriginUsage(client, kOriginA, kTemp));
- EXPECT_EQ(0, GetOriginUsage(client, kOriginA, kPerm));
-
- Call_NotifyAppCacheDestroyed(client);
- Call_OnQuotaManagerDestroyed(client);
-}
-
-TEST_F(AppCacheQuotaClientTest, GetOriginsForHost) {
- AppCacheQuotaClient* client = CreateClient();
- Call_NotifyAppCacheReady(client);
-
- EXPECT_EQ(kOriginA.host(), kOriginB.host());
- EXPECT_NE(kOriginA.host(), kOriginOther.host());
-
- std::set<GURL> origins = GetOriginsForHost(client, kTemp, kOriginA.host());
- EXPECT_TRUE(origins.empty());
-
- SetUsageMapEntry(kOriginA, 1000);
- SetUsageMapEntry(kOriginB, 10);
- SetUsageMapEntry(kOriginOther, 500);
-
- origins = GetOriginsForHost(client, kTemp, kOriginA.host());
- EXPECT_EQ(2ul, origins.size());
- EXPECT_TRUE(origins.find(kOriginA) != origins.end());
- EXPECT_TRUE(origins.find(kOriginB) != origins.end());
-
- origins = GetOriginsForHost(client, kTemp, kOriginOther.host());
- EXPECT_EQ(1ul, origins.size());
- EXPECT_TRUE(origins.find(kOriginOther) != origins.end());
-
- origins = GetOriginsForHost(client, kPerm, kOriginA.host());
- EXPECT_TRUE(origins.empty());
-
- Call_NotifyAppCacheDestroyed(client);
- Call_OnQuotaManagerDestroyed(client);
-}
-
-TEST_F(AppCacheQuotaClientTest, GetOriginsForType) {
- AppCacheQuotaClient* client = CreateClient();
- Call_NotifyAppCacheReady(client);
-
- EXPECT_TRUE(GetOriginsForType(client, kTemp).empty());
- EXPECT_TRUE(GetOriginsForType(client, kPerm).empty());
-
- SetUsageMapEntry(kOriginA, 1000);
- SetUsageMapEntry(kOriginB, 10);
-
- std::set<GURL> origins = GetOriginsForType(client, kTemp);
- EXPECT_EQ(2ul, origins.size());
- EXPECT_TRUE(origins.find(kOriginA) != origins.end());
- EXPECT_TRUE(origins.find(kOriginB) != origins.end());
-
- EXPECT_TRUE(GetOriginsForType(client, kPerm).empty());
-
- Call_NotifyAppCacheDestroyed(client);
- Call_OnQuotaManagerDestroyed(client);
-}
-
-TEST_F(AppCacheQuotaClientTest, DeleteOriginData) {
- AppCacheQuotaClient* client = CreateClient();
- Call_NotifyAppCacheReady(client);
-
- // Perm deletions are short circuited in the Client and
- // should not reach the AppCacheService.
- EXPECT_EQ(quota::kQuotaStatusOk,
- DeleteOriginData(client, kPerm, kOriginA));
- EXPECT_EQ(0, mock_service_.delete_called_count());
-
- EXPECT_EQ(quota::kQuotaStatusOk,
- DeleteOriginData(client, kTemp, kOriginA));
- EXPECT_EQ(1, mock_service_.delete_called_count());
-
- mock_service_.set_mock_delete_appcaches_for_origin_result(
- net::ERR_ABORTED);
- EXPECT_EQ(quota::kQuotaErrorAbort,
- DeleteOriginData(client, kTemp, kOriginA));
- EXPECT_EQ(2, mock_service_.delete_called_count());
-
- Call_OnQuotaManagerDestroyed(client);
- Call_NotifyAppCacheDestroyed(client);
-}
-
-TEST_F(AppCacheQuotaClientTest, PendingRequests) {
- AppCacheQuotaClient* client = CreateClient();
-
- SetUsageMapEntry(kOriginA, 1000);
- SetUsageMapEntry(kOriginB, 10);
- SetUsageMapEntry(kOriginOther, 500);
-
- // Queue up some reqeusts.
- AsyncGetOriginUsage(client, kOriginA, kPerm);
- AsyncGetOriginUsage(client, kOriginB, kTemp);
- AsyncGetOriginsForType(client, kPerm);
- AsyncGetOriginsForType(client, kTemp);
- AsyncGetOriginsForHost(client, kTemp, kOriginA.host());
- AsyncGetOriginsForHost(client, kTemp, kOriginOther.host());
- AsyncDeleteOriginData(client, kTemp, kOriginA);
- AsyncDeleteOriginData(client, kPerm, kOriginA);
- AsyncDeleteOriginData(client, kTemp, kOriginB);
-
- EXPECT_EQ(0, num_get_origin_usage_completions_);
- EXPECT_EQ(0, num_get_origins_completions_);
- EXPECT_EQ(0, num_delete_origins_completions_);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, num_get_origin_usage_completions_);
- EXPECT_EQ(0, num_get_origins_completions_);
- EXPECT_EQ(0, num_delete_origins_completions_);
-
- // Pending requests should get serviced when the appcache is ready.
- Call_NotifyAppCacheReady(client);
- EXPECT_EQ(2, num_get_origin_usage_completions_);
- EXPECT_EQ(4, num_get_origins_completions_);
- EXPECT_EQ(0, num_delete_origins_completions_);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(3, num_delete_origins_completions_); // deletes are really async
-
- // They should be serviced in order requested.
- EXPECT_EQ(10, usage_);
- EXPECT_EQ(1ul, origins_.size());
- EXPECT_TRUE(origins_.find(kOriginOther) != origins_.end());
-
- Call_NotifyAppCacheDestroyed(client);
- Call_OnQuotaManagerDestroyed(client);
-}
-
-TEST_F(AppCacheQuotaClientTest, DestroyServiceWithPending) {
- AppCacheQuotaClient* client = CreateClient();
-
- SetUsageMapEntry(kOriginA, 1000);
- SetUsageMapEntry(kOriginB, 10);
- SetUsageMapEntry(kOriginOther, 500);
-
- // Queue up some reqeusts prior to being ready.
- AsyncGetOriginUsage(client, kOriginA, kPerm);
- AsyncGetOriginUsage(client, kOriginB, kTemp);
- AsyncGetOriginsForType(client, kPerm);
- AsyncGetOriginsForType(client, kTemp);
- AsyncGetOriginsForHost(client, kTemp, kOriginA.host());
- AsyncGetOriginsForHost(client, kTemp, kOriginOther.host());
- AsyncDeleteOriginData(client, kTemp, kOriginA);
- AsyncDeleteOriginData(client, kPerm, kOriginA);
- AsyncDeleteOriginData(client, kTemp, kOriginB);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, num_get_origin_usage_completions_);
- EXPECT_EQ(0, num_get_origins_completions_);
- EXPECT_EQ(0, num_delete_origins_completions_);
-
- // Kill the service.
- Call_NotifyAppCacheDestroyed(client);
-
- // All should have been aborted and called completion.
- EXPECT_EQ(2, num_get_origin_usage_completions_);
- EXPECT_EQ(4, num_get_origins_completions_);
- EXPECT_EQ(3, num_delete_origins_completions_);
- EXPECT_EQ(0, usage_);
- EXPECT_TRUE(origins_.empty());
- EXPECT_EQ(quota::kQuotaErrorAbort, delete_status_);
-
- Call_OnQuotaManagerDestroyed(client);
-}
-
-TEST_F(AppCacheQuotaClientTest, DestroyQuotaManagerWithPending) {
- AppCacheQuotaClient* client = CreateClient();
-
- SetUsageMapEntry(kOriginA, 1000);
- SetUsageMapEntry(kOriginB, 10);
- SetUsageMapEntry(kOriginOther, 500);
-
- // Queue up some reqeusts prior to being ready.
- AsyncGetOriginUsage(client, kOriginA, kPerm);
- AsyncGetOriginUsage(client, kOriginB, kTemp);
- AsyncGetOriginsForType(client, kPerm);
- AsyncGetOriginsForType(client, kTemp);
- AsyncGetOriginsForHost(client, kTemp, kOriginA.host());
- AsyncGetOriginsForHost(client, kTemp, kOriginOther.host());
- AsyncDeleteOriginData(client, kTemp, kOriginA);
- AsyncDeleteOriginData(client, kPerm, kOriginA);
- AsyncDeleteOriginData(client, kTemp, kOriginB);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, num_get_origin_usage_completions_);
- EXPECT_EQ(0, num_get_origins_completions_);
- EXPECT_EQ(0, num_delete_origins_completions_);
-
- // Kill the quota manager.
- Call_OnQuotaManagerDestroyed(client);
- Call_NotifyAppCacheReady(client);
-
- // Callbacks should be deleted and not called.
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, num_get_origin_usage_completions_);
- EXPECT_EQ(0, num_get_origins_completions_);
- EXPECT_EQ(0, num_delete_origins_completions_);
-
- Call_NotifyAppCacheDestroyed(client);
-}
-
-TEST_F(AppCacheQuotaClientTest, DestroyWithDeleteInProgress) {
- AppCacheQuotaClient* client = CreateClient();
- Call_NotifyAppCacheReady(client);
-
- // Start an async delete.
- AsyncDeleteOriginData(client, kTemp, kOriginB);
- EXPECT_EQ(0, num_delete_origins_completions_);
-
- // Kill the service.
- Call_NotifyAppCacheDestroyed(client);
-
- // Should have been aborted.
- EXPECT_EQ(1, num_delete_origins_completions_);
- EXPECT_EQ(quota::kQuotaErrorAbort, delete_status_);
-
- // A real completion callback from the service should
- // be dropped if it comes in after NotifyAppCacheDestroyed.
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(1, num_delete_origins_completions_);
- EXPECT_EQ(quota::kQuotaErrorAbort, delete_status_);
-
- Call_OnQuotaManagerDestroyed(client);
-}
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/appcache_request_handler.cc b/chromium/webkit/browser/appcache/appcache_request_handler.cc
index 102c1843e60..0777044a2dd 100644
--- a/chromium/webkit/browser/appcache/appcache_request_handler.cc
+++ b/chromium/webkit/browser/appcache/appcache_request_handler.cc
@@ -62,7 +62,7 @@ AppCacheURLRequestJob* AppCacheRequestHandler::MaybeLoadResource(
// new resource, any values in those fields are no longer valid.
found_entry_ = AppCacheEntry();
found_fallback_entry_ = AppCacheEntry();
- found_cache_id_ = kNoCacheId;
+ found_cache_id_ = kAppCacheNoCacheId;
found_manifest_url_ = GURL();
found_network_namespace_ = false;
@@ -103,14 +103,14 @@ AppCacheURLRequestJob* AppCacheRequestHandler::MaybeLoadFallbackForRedirect(
// 6.9.6, step 4: If this results in a redirect to another origin,
// get the resource of the fallback entry.
job_ = new AppCacheURLRequestJob(request, network_delegate,
- storage(), host_);
+ storage(), host_, is_main_resource());
DeliverAppCachedResponse(
found_fallback_entry_, found_cache_id_, found_group_id_,
found_manifest_url_, true, found_namespace_entry_url_);
} else if (!found_network_namespace_) {
// 6.9.6, step 6: Fail the resource load.
job_ = new AppCacheURLRequestJob(request, network_delegate,
- storage(), host_);
+ storage(), host_, is_main_resource());
DeliverErrorResponse();
} else {
// 6.9.6 step 3 and 5: Fetch the resource normally.
@@ -156,7 +156,7 @@ AppCacheURLRequestJob* AppCacheRequestHandler::MaybeLoadFallbackForResponse(
// 6.9.6, step 4: If this results in a 4xx or 5xx status code
// or there were network errors, get the resource of the fallback entry.
job_ = new AppCacheURLRequestJob(request, network_delegate,
- storage(), host_);
+ storage(), host_, is_main_resource());
DeliverAppCachedResponse(
found_fallback_entry_, found_cache_id_, found_group_id_,
found_manifest_url_, true, found_namespace_entry_url_);
@@ -240,7 +240,7 @@ void AppCacheRequestHandler::MaybeLoadMainResource(
// We may have to wait for our storage query to complete, but
// this query can also complete syncrhonously.
job_ = new AppCacheURLRequestJob(request, network_delegate,
- storage(), host_);
+ storage(), host_, is_main_resource());
storage()->FindResponseForMainRequest(
request->url(), preferred_manifest_url, this);
}
@@ -274,7 +274,7 @@ void AppCacheRequestHandler::OnMainResponseFound(
return;
}
- if (ResourceType::IsFrame(resource_type_) && cache_id != kNoCacheId) {
+ if (ResourceType::IsFrame(resource_type_) && cache_id != kAppCacheNoCacheId) {
// AppCacheHost loads and holds a reference to the main resource cache
// for two reasons, firstly to preload the cache into the working set
// in advance of subresource loads happening, secondly to prevent the
@@ -314,17 +314,18 @@ void AppCacheRequestHandler::MaybeLoadSubResource(
// selected cache is loaded.
is_waiting_for_cache_selection_ = true;
job_ = new AppCacheURLRequestJob(request, network_delegate,
- storage(), host_);
+ storage(), host_, is_main_resource());
return;
}
if (!host_->associated_cache() ||
- !host_->associated_cache()->is_complete()) {
+ !host_->associated_cache()->is_complete() ||
+ host_->associated_cache()->owning_group()->is_being_deleted()) {
return;
}
job_ = new AppCacheURLRequestJob(request, network_delegate,
- storage(), host_);
+ storage(), host_, is_main_resource());
ContinueMaybeLoadSubResource();
}
diff --git a/chromium/webkit/browser/appcache/appcache_request_handler.h b/chromium/webkit/browser/appcache/appcache_request_handler.h
index 325313f9616..fd3d1ad7066 100644
--- a/chromium/webkit/browser/appcache/appcache_request_handler.h
+++ b/chromium/webkit/browser/appcache/appcache_request_handler.h
@@ -18,6 +18,10 @@ class URLRequest;
class URLRequestJob;
} // namespace net
+namespace content {
+class AppCacheRequestHandlerTest;
+}
+
namespace appcache {
class AppCacheURLRequestJob;
@@ -139,7 +143,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheRequestHandler
// from the old processes structures over to the new structures.
scoped_ptr<AppCacheHost> host_for_cross_site_transfer_;
- friend class AppCacheRequestHandlerTest;
+ friend class content::AppCacheRequestHandlerTest;
DISALLOW_COPY_AND_ASSIGN(AppCacheRequestHandler);
};
diff --git a/chromium/webkit/browser/appcache/appcache_request_handler_unittest.cc b/chromium/webkit/browser/appcache/appcache_request_handler_unittest.cc
deleted file mode 100644
index a931477aec5..00000000000
--- a/chromium/webkit/browser/appcache/appcache_request_handler_unittest.cc
+++ /dev/null
@@ -1,973 +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 <stack>
-#include <string>
-#include <vector>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/callback.h"
-#include "base/message_loop/message_loop.h"
-#include "base/synchronization/waitable_event.h"
-#include "base/threading/thread.h"
-#include "net/base/net_errors.h"
-#include "net/base/request_priority.h"
-#include "net/http/http_response_headers.h"
-#include "net/url_request/url_request.h"
-#include "net/url_request/url_request_context.h"
-#include "net/url_request/url_request_error_job.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/appcache/appcache.h"
-#include "webkit/browser/appcache/appcache_backend_impl.h"
-#include "webkit/browser/appcache/appcache_request_handler.h"
-#include "webkit/browser/appcache/appcache_url_request_job.h"
-#include "webkit/browser/appcache/mock_appcache_policy.h"
-#include "webkit/browser/appcache/mock_appcache_service.h"
-
-namespace appcache {
-
-static const int kMockProcessId = 1;
-
-class AppCacheRequestHandlerTest : public testing::Test {
- public:
- class MockFrontend : public AppCacheFrontend {
- public:
- virtual void OnCacheSelected(
- int host_id, const appcache::AppCacheInfo& info) OVERRIDE {}
-
- virtual void OnStatusChanged(const std::vector<int>& host_ids,
- appcache::Status status) OVERRIDE {}
-
- virtual void OnEventRaised(const std::vector<int>& host_ids,
- appcache::EventID event_id) OVERRIDE {}
-
- virtual void OnErrorEventRaised(const std::vector<int>& host_ids,
- const std::string& message) OVERRIDE {}
-
- virtual void OnProgressEventRaised(const std::vector<int>& host_ids,
- const GURL& url,
- int num_total,
- int num_complete) OVERRIDE {
- }
-
- virtual void OnLogMessage(int host_id,
- appcache::LogLevel log_level,
- const std::string& message) OVERRIDE {
- }
-
- virtual void OnContentBlocked(int host_id,
- const GURL& manifest_url) OVERRIDE {}
- };
-
- // Helper callback to run a test on our io_thread. The io_thread is spun up
- // once and reused for all tests.
- template <class Method>
- void MethodWrapper(Method method) {
- SetUpTest();
- (this->*method)();
- }
-
- // Subclasses to simulate particular responses so test cases can
- // exercise fallback code paths.
-
- class MockURLRequestDelegate : public net::URLRequest::Delegate {
- virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE {}
- virtual void OnReadCompleted(net::URLRequest* request,
- int bytes_read) OVERRIDE {
- }
- };
-
- class MockURLRequestJob : public net::URLRequestJob {
- public:
- MockURLRequestJob(net::URLRequest* request,
- net::NetworkDelegate* network_delegate,
- int response_code)
- : net::URLRequestJob(request, network_delegate),
- response_code_(response_code),
- has_response_info_(false) {}
- MockURLRequestJob(net::URLRequest* request,
- net::NetworkDelegate* network_delegate,
- const net::HttpResponseInfo& info)
- : net::URLRequestJob(request, network_delegate),
- response_code_(info.headers->response_code()),
- has_response_info_(true),
- response_info_(info) {}
-
- protected:
- virtual ~MockURLRequestJob() {}
- virtual void Start() OVERRIDE {
- NotifyHeadersComplete();
- }
- virtual int GetResponseCode() const OVERRIDE {
- return response_code_;
- }
- virtual void GetResponseInfo(
- net::HttpResponseInfo* info) OVERRIDE {
- if (!has_response_info_)
- return;
- *info = response_info_;
- }
-
- private:
- int response_code_;
- bool has_response_info_;
- net::HttpResponseInfo response_info_;
- };
-
- class MockURLRequest : public net::URLRequest {
- public:
- MockURLRequest(const GURL& url, net::URLRequestContext* context)
- : net::URLRequest(url, net::DEFAULT_PRIORITY, NULL, context) {}
-
- void SimulateResponseCode(int http_response_code) {
- mock_factory_job_ = new MockURLRequestJob(
- this, context()->network_delegate(), http_response_code);
- Start();
- DCHECK(!mock_factory_job_);
- // All our simulation needs to satisfy are the following two DCHECKs
- DCHECK(status().is_success());
- DCHECK_EQ(http_response_code, GetResponseCode());
- }
-
- void SimulateResponseInfo(const net::HttpResponseInfo& info) {
- mock_factory_job_ =
- new MockURLRequestJob(this, context()->network_delegate(), info);
- set_delegate(&delegate_); // needed to get the info back out
- Start();
- DCHECK(!mock_factory_job_);
- }
-
- MockURLRequestDelegate delegate_;
- };
-
- static net::URLRequestJob* MockHttpJobFactory(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate,
- const std::string& scheme) {
- if (mock_factory_job_) {
- net::URLRequestJob* temp = mock_factory_job_;
- mock_factory_job_ = NULL;
- return temp;
- } else {
- // Some of these tests trigger UpdateJobs which start URLRequests.
- // We short circuit those be returning error jobs.
- return new net::URLRequestErrorJob(request,
- network_delegate,
- net::ERR_INTERNET_DISCONNECTED);
- }
- }
-
- static void SetUpTestCase() {
- io_thread_.reset(new base::Thread("AppCacheRequestHandlerTest Thread"));
- base::Thread::Options options(base::MessageLoop::TYPE_IO, 0);
- io_thread_->StartWithOptions(options);
- }
-
- static void TearDownTestCase() {
- io_thread_.reset(NULL);
- }
-
- // Test harness --------------------------------------------------
-
- AppCacheRequestHandlerTest() : host_(NULL), orig_http_factory_(NULL) {}
-
- template <class Method>
- void RunTestOnIOThread(Method method) {
- test_finished_event_ .reset(new base::WaitableEvent(false, false));
- io_thread_->message_loop()->PostTask(
- FROM_HERE,
- base::Bind(&AppCacheRequestHandlerTest::MethodWrapper<Method>,
- base::Unretained(this), method));
- test_finished_event_->Wait();
- }
-
- void SetUpTest() {
- DCHECK(base::MessageLoop::current() == io_thread_->message_loop());
- orig_http_factory_ = net::URLRequest::Deprecated::RegisterProtocolFactory(
- "http", MockHttpJobFactory);
- mock_service_.reset(new MockAppCacheService);
- mock_service_->set_request_context(&empty_context_);
- mock_policy_.reset(new MockAppCachePolicy);
- mock_service_->set_appcache_policy(mock_policy_.get());
- mock_frontend_.reset(new MockFrontend);
- backend_impl_.reset(new AppCacheBackendImpl);
- backend_impl_->Initialize(mock_service_.get(), mock_frontend_.get(),
- kMockProcessId);
- const int kHostId = 1;
- backend_impl_->RegisterHost(kHostId);
- host_ = backend_impl_->GetHost(kHostId);
- }
-
- void TearDownTest() {
- DCHECK(base::MessageLoop::current() == io_thread_->message_loop());
- DCHECK(!mock_factory_job_);
- net::URLRequest::Deprecated::RegisterProtocolFactory(
- "http", orig_http_factory_);
- orig_http_factory_ = NULL;
- job_ = NULL;
- handler_.reset();
- request_.reset();
- backend_impl_.reset();
- mock_frontend_.reset();
- mock_service_.reset();
- mock_policy_.reset();
- host_ = NULL;
- }
-
- void TestFinished() {
- // We unwind the stack prior to finishing up to let stack
- // based objects get deleted.
- DCHECK(base::MessageLoop::current() == io_thread_->message_loop());
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&AppCacheRequestHandlerTest::TestFinishedUnwound,
- base::Unretained(this)));
- }
-
- void TestFinishedUnwound() {
- TearDownTest();
- test_finished_event_->Signal();
- }
-
- void PushNextTask(const base::Closure& task) {
- task_stack_.push(task);
- }
-
- void ScheduleNextTask() {
- DCHECK(base::MessageLoop::current() == io_thread_->message_loop());
- if (task_stack_.empty()) {
- TestFinished();
- return;
- }
- base::MessageLoop::current()->PostTask(FROM_HERE, task_stack_.top());
- task_stack_.pop();
- }
-
- // MainResource_Miss --------------------------------------------------
-
- void MainResource_Miss() {
- PushNextTask(
- base::Bind(&AppCacheRequestHandlerTest::Verify_MainResource_Miss,
- base::Unretained(this)));
-
- request_.reset(new MockURLRequest(GURL("http://blah/"), &empty_context_));
- handler_.reset(host_->CreateRequestHandler(request_.get(),
- ResourceType::MAIN_FRAME));
- EXPECT_TRUE(handler_.get());
-
- job_ = handler_->MaybeLoadResource(request_.get(),
- request_->context()->network_delegate());
- EXPECT_TRUE(job_.get());
- EXPECT_TRUE(job_->is_waiting());
-
- // We have to wait for completion of storage->FindResponseForMainRequest.
- ScheduleNextTask();
- }
-
- void Verify_MainResource_Miss() {
- EXPECT_FALSE(job_->is_waiting());
- EXPECT_TRUE(job_->is_delivering_network_response());
-
- int64 cache_id = kNoCacheId;
- GURL manifest_url;
- handler_->GetExtraResponseInfo(&cache_id, &manifest_url);
- EXPECT_EQ(kNoCacheId, cache_id);
- EXPECT_EQ(GURL(), manifest_url);
- EXPECT_EQ(0, handler_->found_group_id_);
-
- AppCacheURLRequestJob* fallback_job;
- fallback_job = handler_->MaybeLoadFallbackForRedirect(
- request_.get(),
- request_->context()->network_delegate(),
- GURL("http://blah/redirect"));
- EXPECT_FALSE(fallback_job);
- fallback_job = handler_->MaybeLoadFallbackForResponse(
- request_.get(), request_->context()->network_delegate());
- EXPECT_FALSE(fallback_job);
-
- EXPECT_TRUE(host_->preferred_manifest_url().is_empty());
-
- TestFinished();
- }
-
- // MainResource_Hit --------------------------------------------------
-
- void MainResource_Hit() {
- PushNextTask(
- base::Bind(&AppCacheRequestHandlerTest::Verify_MainResource_Hit,
- base::Unretained(this)));
-
- request_.reset(new MockURLRequest(GURL("http://blah/"), &empty_context_));
- handler_.reset(host_->CreateRequestHandler(request_.get(),
- ResourceType::MAIN_FRAME));
- EXPECT_TRUE(handler_.get());
-
- mock_storage()->SimulateFindMainResource(
- AppCacheEntry(AppCacheEntry::EXPLICIT, 1),
- GURL(), AppCacheEntry(),
- 1, 2, GURL("http://blah/manifest/"));
-
- job_ = handler_->MaybeLoadResource(request_.get(),
- request_->context()->network_delegate());
- EXPECT_TRUE(job_.get());
- EXPECT_TRUE(job_->is_waiting());
-
- // We have to wait for completion of storage->FindResponseForMainRequest.
- ScheduleNextTask();
- }
-
- void Verify_MainResource_Hit() {
- EXPECT_FALSE(job_->is_waiting());
- EXPECT_TRUE(job_->is_delivering_appcache_response());
-
- int64 cache_id = kNoCacheId;
- GURL manifest_url;
- handler_->GetExtraResponseInfo(&cache_id, &manifest_url);
- EXPECT_EQ(1, cache_id);
- EXPECT_EQ(GURL("http://blah/manifest/"), manifest_url);
- EXPECT_EQ(2, handler_->found_group_id_);
-
- AppCacheURLRequestJob* fallback_job;
- fallback_job = handler_->MaybeLoadFallbackForResponse(
- request_.get(), request_->context()->network_delegate());
- EXPECT_FALSE(fallback_job);
-
- EXPECT_EQ(GURL("http://blah/manifest/"),
- host_->preferred_manifest_url());
-
- TestFinished();
- }
-
- // MainResource_Fallback --------------------------------------------------
-
- void MainResource_Fallback() {
- PushNextTask(
- base::Bind(&AppCacheRequestHandlerTest::Verify_MainResource_Fallback,
- base::Unretained(this)));
-
- request_.reset(new MockURLRequest(GURL("http://blah/"), &empty_context_));
- handler_.reset(host_->CreateRequestHandler(request_.get(),
- ResourceType::MAIN_FRAME));
- EXPECT_TRUE(handler_.get());
-
- mock_storage()->SimulateFindMainResource(
- AppCacheEntry(),
- GURL("http://blah/fallbackurl"),
- AppCacheEntry(AppCacheEntry::EXPLICIT, 1),
- 1, 2, GURL("http://blah/manifest/"));
-
- job_ = handler_->MaybeLoadResource(request_.get(),
- request_->context()->network_delegate());
- EXPECT_TRUE(job_.get());
- EXPECT_TRUE(job_->is_waiting());
-
- // We have to wait for completion of storage->FindResponseForMainRequest.
- ScheduleNextTask();
- }
-
- void Verify_MainResource_Fallback() {
- EXPECT_FALSE(job_->is_waiting());
- EXPECT_TRUE(job_->is_delivering_network_response());
-
- // When the request is restarted, the existing job is dropped so a
- // real network job gets created. We expect NULL here which will cause
- // the net library to create a real job.
- job_ = handler_->MaybeLoadResource(request_.get(),
- request_->context()->network_delegate());
- EXPECT_FALSE(job_.get());
-
- // Simulate an http error of the real network job.
- request_->SimulateResponseCode(500);
-
- job_ = handler_->MaybeLoadFallbackForResponse(
- request_.get(), request_->context()->network_delegate());
- EXPECT_TRUE(job_.get());
- EXPECT_TRUE(job_->is_delivering_appcache_response());
-
- int64 cache_id = kNoCacheId;
- GURL manifest_url;
- handler_->GetExtraResponseInfo(&cache_id, &manifest_url);
- EXPECT_EQ(1, cache_id);
- EXPECT_EQ(GURL("http://blah/manifest/"), manifest_url);
- EXPECT_TRUE(host_->main_resource_was_namespace_entry_);
- EXPECT_EQ(GURL("http://blah/fallbackurl"), host_->namespace_entry_url_);
-
- EXPECT_EQ(GURL("http://blah/manifest/"),
- host_->preferred_manifest_url());
-
- TestFinished();
- }
-
- // MainResource_FallbackOverride --------------------------------------------
-
- void MainResource_FallbackOverride() {
- PushNextTask(base::Bind(
- &AppCacheRequestHandlerTest::Verify_MainResource_FallbackOverride,
- base::Unretained(this)));
-
- request_.reset(new MockURLRequest(GURL("http://blah/fallback-override"),
- &empty_context_));
- handler_.reset(host_->CreateRequestHandler(request_.get(),
- ResourceType::MAIN_FRAME));
- EXPECT_TRUE(handler_.get());
-
- mock_storage()->SimulateFindMainResource(
- AppCacheEntry(),
- GURL("http://blah/fallbackurl"),
- AppCacheEntry(AppCacheEntry::EXPLICIT, 1),
- 1, 2, GURL("http://blah/manifest/"));
-
- job_ = handler_->MaybeLoadResource(request_.get(),
- request_->context()->network_delegate());
- EXPECT_TRUE(job_.get());
- EXPECT_TRUE(job_->is_waiting());
-
- // We have to wait for completion of storage->FindResponseForMainRequest.
- ScheduleNextTask();
- }
-
- void Verify_MainResource_FallbackOverride() {
- EXPECT_FALSE(job_->is_waiting());
- EXPECT_TRUE(job_->is_delivering_network_response());
-
- // When the request is restarted, the existing job is dropped so a
- // real network job gets created. We expect NULL here which will cause
- // the net library to create a real job.
- job_ = handler_->MaybeLoadResource(request_.get(),
- request_->context()->network_delegate());
- EXPECT_FALSE(job_.get());
-
- // Simulate an http error of the real network job, but with custom
- // headers that override the fallback behavior.
- const char kOverrideHeaders[] =
- "HTTP/1.1 404 BOO HOO\0"
- "x-chromium-appcache-fallback-override: disallow-fallback\0"
- "\0";
- net::HttpResponseInfo info;
- info.headers = new net::HttpResponseHeaders(
- std::string(kOverrideHeaders, arraysize(kOverrideHeaders)));
- request_->SimulateResponseInfo(info);
-
- job_ = handler_->MaybeLoadFallbackForResponse(
- request_.get(), request_->context()->network_delegate());
- EXPECT_FALSE(job_.get());
-
- TestFinished();
- }
-
- // SubResource_Miss_WithNoCacheSelected ----------------------------------
-
- void SubResource_Miss_WithNoCacheSelected() {
- request_.reset(new MockURLRequest(GURL("http://blah/"), &empty_context_));
- handler_.reset(host_->CreateRequestHandler(request_.get(),
- ResourceType::SUB_RESOURCE));
-
- // We avoid creating handler when possible, sub-resource requests are not
- // subject to retrieval from an appcache when there's no associated cache.
- EXPECT_FALSE(handler_.get());
-
- TestFinished();
- }
-
- // SubResource_Miss_WithCacheSelected ----------------------------------
-
- void SubResource_Miss_WithCacheSelected() {
- // A sub-resource load where the resource is not in an appcache, or
- // in a network or fallback namespace, should result in a failed request.
- host_->AssociateCompleteCache(MakeNewCache());
-
- request_.reset(new MockURLRequest(GURL("http://blah/"), &empty_context_));
- handler_.reset(host_->CreateRequestHandler(request_.get(),
- ResourceType::SUB_RESOURCE));
- EXPECT_TRUE(handler_.get());
-
- job_ = handler_->MaybeLoadResource(request_.get(),
- request_->context()->network_delegate());
- EXPECT_TRUE(job_.get());
- EXPECT_TRUE(job_->is_delivering_error_response());
-
- AppCacheURLRequestJob* fallback_job;
- fallback_job = handler_->MaybeLoadFallbackForRedirect(
- request_.get(),
- request_->context()->network_delegate(),
- GURL("http://blah/redirect"));
- EXPECT_FALSE(fallback_job);
- fallback_job = handler_->MaybeLoadFallbackForResponse(
- request_.get(), request_->context()->network_delegate());
- EXPECT_FALSE(fallback_job);
-
- TestFinished();
- }
-
- // SubResource_Miss_WithWaitForCacheSelection -----------------------------
-
- void SubResource_Miss_WithWaitForCacheSelection() {
- // Precondition, the host is waiting on cache selection.
- scoped_refptr<AppCache> cache(MakeNewCache());
- host_->pending_selected_cache_id_ = cache->cache_id();
- host_->set_preferred_manifest_url(cache->owning_group()->manifest_url());
-
- request_.reset(new MockURLRequest(GURL("http://blah/"), &empty_context_));
- handler_.reset(host_->CreateRequestHandler(request_.get(),
- ResourceType::SUB_RESOURCE));
- EXPECT_TRUE(handler_.get());
- job_ = handler_->MaybeLoadResource(request_.get(),
- request_->context()->network_delegate());
- EXPECT_TRUE(job_.get());
- EXPECT_TRUE(job_->is_waiting());
-
- host_->FinishCacheSelection(cache.get(), NULL);
- EXPECT_FALSE(job_->is_waiting());
- EXPECT_TRUE(job_->is_delivering_error_response());
-
- AppCacheURLRequestJob* fallback_job;
- fallback_job = handler_->MaybeLoadFallbackForRedirect(
- request_.get(),
- request_->context()->network_delegate(),
- GURL("http://blah/redirect"));
- EXPECT_FALSE(fallback_job);
- fallback_job = handler_->MaybeLoadFallbackForResponse(
- request_.get(), request_->context()->network_delegate());
- EXPECT_FALSE(fallback_job);
-
- TestFinished();
- }
-
- // SubResource_Hit -----------------------------
-
- void SubResource_Hit() {
- host_->AssociateCompleteCache(MakeNewCache());
-
- mock_storage()->SimulateFindSubResource(
- AppCacheEntry(AppCacheEntry::EXPLICIT, 1), AppCacheEntry(), false);
-
- request_.reset(new MockURLRequest(GURL("http://blah/"), &empty_context_));
- handler_.reset(host_->CreateRequestHandler(request_.get(),
- ResourceType::SUB_RESOURCE));
- EXPECT_TRUE(handler_.get());
- job_ = handler_->MaybeLoadResource(request_.get(),
- request_->context()->network_delegate());
- EXPECT_TRUE(job_.get());
- EXPECT_TRUE(job_->is_delivering_appcache_response());
-
- AppCacheURLRequestJob* fallback_job;
- fallback_job = handler_->MaybeLoadFallbackForRedirect(
- request_.get(),
- request_->context()->network_delegate(),
- GURL("http://blah/redirect"));
- EXPECT_FALSE(fallback_job);
- fallback_job = handler_->MaybeLoadFallbackForResponse(
- request_.get(), request_->context()->network_delegate());
- EXPECT_FALSE(fallback_job);
-
- TestFinished();
- }
-
- // SubResource_RedirectFallback -----------------------------
-
- void SubResource_RedirectFallback() {
- // Redirects to resources in the a different origin are subject to
- // fallback namespaces.
- host_->AssociateCompleteCache(MakeNewCache());
-
- mock_storage()->SimulateFindSubResource(
- AppCacheEntry(), AppCacheEntry(AppCacheEntry::EXPLICIT, 1), false);
-
- request_.reset(new MockURLRequest(GURL("http://blah/"), &empty_context_));
- handler_.reset(host_->CreateRequestHandler(request_.get(),
- ResourceType::SUB_RESOURCE));
- EXPECT_TRUE(handler_.get());
- job_ = handler_->MaybeLoadResource(request_.get(),
- request_->context()->network_delegate());
- EXPECT_FALSE(job_.get());
-
- job_ = handler_->MaybeLoadFallbackForRedirect(
- request_.get(),
- request_->context()->network_delegate(),
- GURL("http://not_blah/redirect"));
- EXPECT_TRUE(job_.get());
- EXPECT_TRUE(job_->is_delivering_appcache_response());
-
- AppCacheURLRequestJob* fallback_job;
- fallback_job = handler_->MaybeLoadFallbackForResponse(
- request_.get(), request_->context()->network_delegate());
- EXPECT_FALSE(fallback_job);
-
- TestFinished();
- }
-
- // SubResource_NoRedirectFallback -----------------------------
-
- void SubResource_NoRedirectFallback() {
- // Redirects to resources in the same-origin are not subject to
- // fallback namespaces.
- host_->AssociateCompleteCache(MakeNewCache());
-
- mock_storage()->SimulateFindSubResource(
- AppCacheEntry(), AppCacheEntry(AppCacheEntry::EXPLICIT, 1), false);
-
- request_.reset(new MockURLRequest(GURL("http://blah/"), &empty_context_));
- handler_.reset(host_->CreateRequestHandler(request_.get(),
- ResourceType::SUB_RESOURCE));
- EXPECT_TRUE(handler_.get());
- job_ = handler_->MaybeLoadResource(request_.get(),
- request_->context()->network_delegate());
- EXPECT_FALSE(job_.get());
-
- AppCacheURLRequestJob* fallback_job;
- fallback_job = handler_->MaybeLoadFallbackForRedirect(
- request_.get(),
- request_->context()->network_delegate(),
- GURL("http://blah/redirect"));
- EXPECT_FALSE(fallback_job);
-
- request_->SimulateResponseCode(200);
- fallback_job = handler_->MaybeLoadFallbackForResponse(
- request_.get(), request_->context()->network_delegate());
- EXPECT_FALSE(fallback_job);
-
- TestFinished();
- }
-
- // SubResource_Network -----------------------------
-
- void SubResource_Network() {
- // A sub-resource load where the resource is in a network namespace,
- // should result in the system using a 'real' job to do the network
- // retrieval.
- host_->AssociateCompleteCache(MakeNewCache());
-
- mock_storage()->SimulateFindSubResource(
- AppCacheEntry(), AppCacheEntry(), true);
-
- request_.reset(new MockURLRequest(GURL("http://blah/"), &empty_context_));
- handler_.reset(host_->CreateRequestHandler(request_.get(),
- ResourceType::SUB_RESOURCE));
- EXPECT_TRUE(handler_.get());
- job_ = handler_->MaybeLoadResource(request_.get(),
- request_->context()->network_delegate());
- EXPECT_FALSE(job_.get());
-
- AppCacheURLRequestJob* fallback_job;
- fallback_job = handler_->MaybeLoadFallbackForRedirect(
- request_.get(),
- request_->context()->network_delegate(),
- GURL("http://blah/redirect"));
- EXPECT_FALSE(fallback_job);
- fallback_job = handler_->MaybeLoadFallbackForResponse(
- request_.get(), request_->context()->network_delegate());
- EXPECT_FALSE(fallback_job);
-
- TestFinished();
- }
-
- // DestroyedHost -----------------------------
-
- void DestroyedHost() {
- host_->AssociateCompleteCache(MakeNewCache());
-
- mock_storage()->SimulateFindSubResource(
- AppCacheEntry(AppCacheEntry::EXPLICIT, 1), AppCacheEntry(), false);
-
- request_.reset(new MockURLRequest(GURL("http://blah/"), &empty_context_));
- handler_.reset(host_->CreateRequestHandler(request_.get(),
- ResourceType::SUB_RESOURCE));
- EXPECT_TRUE(handler_.get());
-
- backend_impl_->UnregisterHost(1);
- host_ = NULL;
-
- EXPECT_FALSE(handler_->MaybeLoadResource(
- request_.get(), request_->context()->network_delegate()));
- EXPECT_FALSE(handler_->MaybeLoadFallbackForRedirect(
- request_.get(),
- request_->context()->network_delegate(),
- GURL("http://blah/redirect")));
- EXPECT_FALSE(handler_->MaybeLoadFallbackForResponse(
- request_.get(), request_->context()->network_delegate()));
-
- TestFinished();
- }
-
- // DestroyedHostWithWaitingJob -----------------------------
-
- void DestroyedHostWithWaitingJob() {
- // Precondition, the host is waiting on cache selection.
- host_->pending_selected_cache_id_ = 1;
-
- request_.reset(new MockURLRequest(GURL("http://blah/"), &empty_context_));
- handler_.reset(host_->CreateRequestHandler(request_.get(),
- ResourceType::SUB_RESOURCE));
- EXPECT_TRUE(handler_.get());
-
- job_ = handler_->MaybeLoadResource(request_.get(),
- request_->context()->network_delegate());
- EXPECT_TRUE(job_.get());
- EXPECT_TRUE(job_->is_waiting());
-
- backend_impl_->UnregisterHost(1);
- host_ = NULL;
- EXPECT_TRUE(job_->has_been_killed());
-
- EXPECT_FALSE(handler_->MaybeLoadResource(
- request_.get(), request_->context()->network_delegate()));
- EXPECT_FALSE(handler_->MaybeLoadFallbackForRedirect(
- request_.get(),
- request_->context()->network_delegate(),
- GURL("http://blah/redirect")));
- EXPECT_FALSE(handler_->MaybeLoadFallbackForResponse(
- request_.get(), request_->context()->network_delegate()));
-
- TestFinished();
- }
-
- // UnsupportedScheme -----------------------------
-
- void UnsupportedScheme() {
- // Precondition, the host is waiting on cache selection.
- host_->pending_selected_cache_id_ = 1;
-
- request_.reset(new MockURLRequest(GURL("ftp://blah/"), &empty_context_));
- handler_.reset(host_->CreateRequestHandler(request_.get(),
- ResourceType::SUB_RESOURCE));
- EXPECT_TRUE(handler_.get()); // we could redirect to http (conceivably)
-
- EXPECT_FALSE(handler_->MaybeLoadResource(
- request_.get(), request_->context()->network_delegate()));
- EXPECT_FALSE(handler_->MaybeLoadFallbackForRedirect(
- request_.get(),
- request_->context()->network_delegate(),
- GURL("ftp://blah/redirect")));
- EXPECT_FALSE(handler_->MaybeLoadFallbackForResponse(
- request_.get(), request_->context()->network_delegate()));
-
- TestFinished();
- }
-
- // CanceledRequest -----------------------------
-
- void CanceledRequest() {
- request_.reset(new MockURLRequest(GURL("http://blah/"), &empty_context_));
- handler_.reset(host_->CreateRequestHandler(request_.get(),
- ResourceType::MAIN_FRAME));
- EXPECT_TRUE(handler_.get());
-
- job_ = handler_->MaybeLoadResource(request_.get(),
- request_->context()->network_delegate());
- EXPECT_TRUE(job_.get());
- EXPECT_TRUE(job_->is_waiting());
- EXPECT_FALSE(job_->has_been_started());
-
- mock_factory_job_ = job_.get();
- request_->Start();
- EXPECT_TRUE(job_->has_been_started());
-
- request_->Cancel();
- EXPECT_TRUE(job_->has_been_killed());
-
- EXPECT_FALSE(handler_->MaybeLoadFallbackForResponse(
- request_.get(), request_->context()->network_delegate()));
-
- TestFinished();
- }
-
- // WorkerRequest -----------------------------
-
- void WorkerRequest() {
- EXPECT_TRUE(AppCacheRequestHandler::IsMainResourceType(
- ResourceType::MAIN_FRAME));
- EXPECT_TRUE(AppCacheRequestHandler::IsMainResourceType(
- ResourceType::SUB_FRAME));
- EXPECT_TRUE(AppCacheRequestHandler::IsMainResourceType(
- ResourceType::SHARED_WORKER));
- EXPECT_FALSE(AppCacheRequestHandler::IsMainResourceType(
- ResourceType::WORKER));
-
- request_.reset(new MockURLRequest(GURL("http://blah/"), &empty_context_));
-
- const int kParentHostId = host_->host_id();
- const int kWorkerHostId = 2;
- const int kAbandonedWorkerHostId = 3;
- const int kNonExsitingHostId = 700;
-
- backend_impl_->RegisterHost(kWorkerHostId);
- AppCacheHost* worker_host = backend_impl_->GetHost(kWorkerHostId);
- worker_host->SelectCacheForWorker(kParentHostId, kMockProcessId);
- handler_.reset(worker_host->CreateRequestHandler(
- request_.get(), ResourceType::SHARED_WORKER));
- EXPECT_TRUE(handler_.get());
- // Verify that the handler is associated with the parent host.
- EXPECT_EQ(host_, handler_->host_);
-
- // Create a new worker host, but associate it with a parent host that
- // does not exists to simulate the host having been torn down.
- backend_impl_->UnregisterHost(kWorkerHostId);
- backend_impl_->RegisterHost(kAbandonedWorkerHostId);
- worker_host = backend_impl_->GetHost(kAbandonedWorkerHostId);
- EXPECT_EQ(NULL, backend_impl_->GetHost(kNonExsitingHostId));
- worker_host->SelectCacheForWorker(kNonExsitingHostId, kMockProcessId);
- handler_.reset(worker_host->CreateRequestHandler(
- request_.get(), ResourceType::SHARED_WORKER));
- EXPECT_FALSE(handler_.get());
-
- TestFinished();
- }
-
- // MainResource_Blocked --------------------------------------------------
-
- void MainResource_Blocked() {
- PushNextTask(
- base::Bind(&AppCacheRequestHandlerTest::Verify_MainResource_Blocked,
- base::Unretained(this)));
-
- request_.reset(new MockURLRequest(GURL("http://blah/"), &empty_context_));
- handler_.reset(host_->CreateRequestHandler(request_.get(),
- ResourceType::MAIN_FRAME));
- EXPECT_TRUE(handler_.get());
-
- mock_policy_->can_load_return_value_ = false;
- mock_storage()->SimulateFindMainResource(
- AppCacheEntry(AppCacheEntry::EXPLICIT, 1),
- GURL(), AppCacheEntry(),
- 1, 2, GURL("http://blah/manifest/"));
-
- job_ = handler_->MaybeLoadResource(request_.get(),
- request_->context()->network_delegate());
- EXPECT_TRUE(job_.get());
- EXPECT_TRUE(job_->is_waiting());
-
- // We have to wait for completion of storage->FindResponseForMainRequest.
- ScheduleNextTask();
- }
-
- void Verify_MainResource_Blocked() {
- EXPECT_FALSE(job_->is_waiting());
- EXPECT_FALSE(job_->is_delivering_appcache_response());
-
- EXPECT_EQ(0, handler_->found_cache_id_);
- EXPECT_EQ(0, handler_->found_group_id_);
- EXPECT_TRUE(handler_->found_manifest_url_.is_empty());
- EXPECT_TRUE(host_->preferred_manifest_url().is_empty());
- EXPECT_TRUE(host_->main_resource_blocked_);
- EXPECT_TRUE(host_->blocked_manifest_url_ == GURL("http://blah/manifest/"));
-
- TestFinished();
- }
-
- // Test case helpers --------------------------------------------------
-
- AppCache* MakeNewCache() {
- AppCache* cache = new AppCache(
- mock_storage(), mock_storage()->NewCacheId());
- cache->set_complete(true);
- AppCacheGroup* group = new AppCacheGroup(
- mock_storage(), GURL("http://blah/manifest"),
- mock_storage()->NewGroupId());
- group->AddCache(cache);
- return cache;
- }
-
- MockAppCacheStorage* mock_storage() {
- return reinterpret_cast<MockAppCacheStorage*>(mock_service_->storage());
- }
-
- // Data members --------------------------------------------------
-
- scoped_ptr<base::WaitableEvent> test_finished_event_;
- std::stack<base::Closure> task_stack_;
- scoped_ptr<MockAppCacheService> mock_service_;
- scoped_ptr<AppCacheBackendImpl> backend_impl_;
- scoped_ptr<MockFrontend> mock_frontend_;
- scoped_ptr<MockAppCachePolicy> mock_policy_;
- AppCacheHost* host_;
- net::URLRequestContext empty_context_;
- scoped_ptr<MockURLRequest> request_;
- scoped_ptr<AppCacheRequestHandler> handler_;
- scoped_refptr<AppCacheURLRequestJob> job_;
- net::URLRequest::ProtocolFactory* orig_http_factory_;
-
- static scoped_ptr<base::Thread> io_thread_;
- static net::URLRequestJob* mock_factory_job_;
-};
-
-// static
-scoped_ptr<base::Thread> AppCacheRequestHandlerTest::io_thread_;
-net::URLRequestJob* AppCacheRequestHandlerTest::mock_factory_job_ = NULL;
-
-TEST_F(AppCacheRequestHandlerTest, MainResource_Miss) {
- RunTestOnIOThread(&AppCacheRequestHandlerTest::MainResource_Miss);
-}
-
-TEST_F(AppCacheRequestHandlerTest, MainResource_Hit) {
- RunTestOnIOThread(&AppCacheRequestHandlerTest::MainResource_Hit);
-}
-
-TEST_F(AppCacheRequestHandlerTest, MainResource_Fallback) {
- RunTestOnIOThread(&AppCacheRequestHandlerTest::MainResource_Fallback);
-}
-
-TEST_F(AppCacheRequestHandlerTest, MainResource_FallbackOverride) {
- RunTestOnIOThread(
- &AppCacheRequestHandlerTest::MainResource_FallbackOverride);
-}
-
-TEST_F(AppCacheRequestHandlerTest, SubResource_Miss_WithNoCacheSelected) {
- RunTestOnIOThread(
- &AppCacheRequestHandlerTest::SubResource_Miss_WithNoCacheSelected);
-}
-
-TEST_F(AppCacheRequestHandlerTest, SubResource_Miss_WithCacheSelected) {
- RunTestOnIOThread(
- &AppCacheRequestHandlerTest::SubResource_Miss_WithCacheSelected);
-}
-
-TEST_F(AppCacheRequestHandlerTest,
- SubResource_Miss_WithWaitForCacheSelection) {
- RunTestOnIOThread(
- &AppCacheRequestHandlerTest::SubResource_Miss_WithWaitForCacheSelection);
-}
-
-TEST_F(AppCacheRequestHandlerTest, SubResource_Hit) {
- RunTestOnIOThread(&AppCacheRequestHandlerTest::SubResource_Hit);
-}
-
-TEST_F(AppCacheRequestHandlerTest, SubResource_RedirectFallback) {
- RunTestOnIOThread(&AppCacheRequestHandlerTest::SubResource_RedirectFallback);
-}
-
-TEST_F(AppCacheRequestHandlerTest, SubResource_NoRedirectFallback) {
- RunTestOnIOThread(
- &AppCacheRequestHandlerTest::SubResource_NoRedirectFallback);
-}
-
-TEST_F(AppCacheRequestHandlerTest, SubResource_Network) {
- RunTestOnIOThread(&AppCacheRequestHandlerTest::SubResource_Network);
-}
-
-TEST_F(AppCacheRequestHandlerTest, DestroyedHost) {
- RunTestOnIOThread(&AppCacheRequestHandlerTest::DestroyedHost);
-}
-
-TEST_F(AppCacheRequestHandlerTest, DestroyedHostWithWaitingJob) {
- RunTestOnIOThread(&AppCacheRequestHandlerTest::DestroyedHostWithWaitingJob);
-}
-
-TEST_F(AppCacheRequestHandlerTest, UnsupportedScheme) {
- RunTestOnIOThread(&AppCacheRequestHandlerTest::UnsupportedScheme);
-}
-
-TEST_F(AppCacheRequestHandlerTest, CanceledRequest) {
- RunTestOnIOThread(&AppCacheRequestHandlerTest::CanceledRequest);
-}
-
-TEST_F(AppCacheRequestHandlerTest, WorkerRequest) {
- RunTestOnIOThread(&AppCacheRequestHandlerTest::WorkerRequest);
-}
-
-TEST_F(AppCacheRequestHandlerTest, MainResource_Blocked) {
- RunTestOnIOThread(&AppCacheRequestHandlerTest::MainResource_Blocked);
-}
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/appcache_response.cc b/chromium/webkit/browser/appcache/appcache_response.cc
index 9ba1dffde77..cd0d3847b85 100644
--- a/chromium/webkit/browser/appcache/appcache_response.cc
+++ b/chromium/webkit/browser/appcache/appcache_response.cc
@@ -55,7 +55,7 @@ AppCacheResponseInfo::AppCacheResponseInfo(
http_response_info_(http_info), response_data_size_(response_data_size),
storage_(storage) {
DCHECK(http_info);
- DCHECK(response_id != kNoResponseId);
+ DCHECK(response_id != kAppCacheNoResponseId);
storage_->working_set()->AddResponseInfo(this);
}
diff --git a/chromium/webkit/browser/appcache/appcache_response.h b/chromium/webkit/browser/appcache/appcache_response.h
index 610bdf4bc8b..d9695b34222 100644
--- a/chromium/webkit/browser/appcache/appcache_response.h
+++ b/chromium/webkit/browser/appcache/appcache_response.h
@@ -19,6 +19,10 @@ namespace net {
class IOBuffer;
}
+namespace content {
+class MockAppCacheStorage;
+}
+
namespace appcache {
class AppCacheStorage;
@@ -63,7 +67,7 @@ struct WEBKIT_STORAGE_BROWSER_EXPORT HttpResponseInfoIOBuffer
HttpResponseInfoIOBuffer();
explicit HttpResponseInfoIOBuffer(net::HttpResponseInfo* info);
- private:
+ protected:
friend class base::RefCountedThreadSafe<HttpResponseInfoIOBuffer>;
virtual ~HttpResponseInfoIOBuffer();
};
@@ -170,9 +174,9 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheResponseReader
protected:
friend class AppCacheStorageImpl;
- friend class MockAppCacheStorage;
+ friend class content::MockAppCacheStorage;
- // Should only be constructed by the storage class.
+ // Should only be constructed by the storage class and derivatives.
AppCacheResponseReader(int64 response_id,
int64 group_id,
AppCacheDiskCacheInterface* disk_cache);
@@ -226,9 +230,15 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheResponseWriter
// Returns the amount written, info and data.
int64 amount_written() { return info_size_ + write_position_; }
+ protected:
+ // Should only be constructed by the storage class and derivatives.
+ AppCacheResponseWriter(int64 response_id,
+ int64 group_id,
+ AppCacheDiskCacheInterface* disk_cache);
+
private:
friend class AppCacheStorageImpl;
- friend class MockAppCacheStorage;
+ friend class content::MockAppCacheStorage;
enum CreationPhase {
NO_ATTEMPT,
@@ -237,11 +247,6 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheResponseWriter
SECOND_ATTEMPT
};
- // Should only be constructed by the storage class.
- AppCacheResponseWriter(int64 response_id,
- int64 group_id,
- AppCacheDiskCacheInterface* disk_cache);
-
virtual void OnIOComplete(int result) OVERRIDE;
void ContinueWriteInfo();
void ContinueWriteData();
diff --git a/chromium/webkit/browser/appcache/appcache_response_unittest.cc b/chromium/webkit/browser/appcache/appcache_response_unittest.cc
deleted file mode 100644
index 1ed7783d7f6..00000000000
--- a/chromium/webkit/browser/appcache/appcache_response_unittest.cc
+++ /dev/null
@@ -1,717 +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 <stack>
-#include <string>
-#include <utility>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/callback.h"
-#include "base/compiler_specific.h"
-#include "base/pickle.h"
-#include "base/synchronization/waitable_event.h"
-#include "base/threading/thread.h"
-#include "net/base/io_buffer.h"
-#include "net/base/net_errors.h"
-#include "net/http/http_response_headers.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/mock_appcache_service.h"
-
-using net::IOBuffer;
-using net::WrappedIOBuffer;
-
-namespace appcache {
-
-static const int kNumBlocks = 4;
-static const int kBlockSize = 1024;
-static const int kNoSuchResponseId = 123;
-
-class AppCacheResponseTest : public testing::Test {
- public:
-
- // Test Harness -------------------------------------------------------------
-
- // Helper class used to verify test results
- class MockStorageDelegate : public AppCacheStorage::Delegate {
- public:
- explicit MockStorageDelegate(AppCacheResponseTest* test)
- : loaded_info_id_(0), test_(test) {
- }
-
- virtual void OnResponseInfoLoaded(AppCacheResponseInfo* info,
- int64 response_id) OVERRIDE {
- loaded_info_ = info;
- loaded_info_id_ = response_id;
- test_->ScheduleNextTask();
- }
-
- scoped_refptr<AppCacheResponseInfo> loaded_info_;
- int64 loaded_info_id_;
- AppCacheResponseTest* test_;
- };
-
- // Helper callback to run a test on our io_thread. The io_thread is spun up
- // once and reused for all tests.
- template <class Method>
- void MethodWrapper(Method method) {
- SetUpTest();
- (this->*method)();
- }
-
- static void SetUpTestCase() {
- io_thread_.reset(new base::Thread("AppCacheResponseTest Thread"));
- base::Thread::Options options(base::MessageLoop::TYPE_IO, 0);
- io_thread_->StartWithOptions(options);
- }
-
- static void TearDownTestCase() {
- io_thread_.reset(NULL);
- }
-
- AppCacheResponseTest() {}
-
- template <class Method>
- void RunTestOnIOThread(Method method) {
- test_finished_event_ .reset(new base::WaitableEvent(false, false));
- io_thread_->message_loop()->PostTask(
- FROM_HERE, base::Bind(&AppCacheResponseTest::MethodWrapper<Method>,
- base::Unretained(this), method));
- test_finished_event_->Wait();
- }
-
- void SetUpTest() {
- DCHECK(base::MessageLoop::current() == io_thread_->message_loop());
- DCHECK(task_stack_.empty());
- storage_delegate_.reset(new MockStorageDelegate(this));
- service_.reset(new MockAppCacheService());
- expected_read_result_ = 0;
- expected_write_result_ = 0;
- written_response_id_ = 0;
- should_delete_reader_in_completion_callback_ = false;
- should_delete_writer_in_completion_callback_ = false;
- reader_deletion_count_down_ = 0;
- writer_deletion_count_down_ = 0;
- read_callback_was_called_ = false;
- write_callback_was_called_ = false;
- }
-
- void TearDownTest() {
- DCHECK(base::MessageLoop::current() == io_thread_->message_loop());
- while (!task_stack_.empty())
- task_stack_.pop();
-
- reader_.reset();
- read_buffer_ = NULL;
- read_info_buffer_ = NULL;
- writer_.reset();
- write_buffer_ = NULL;
- write_info_buffer_ = NULL;
- storage_delegate_.reset();
- service_.reset();
- }
-
- void TestFinished() {
- // We unwind the stack prior to finishing up to let stack
- // based objects get deleted.
- DCHECK(base::MessageLoop::current() == io_thread_->message_loop());
- base::MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(&AppCacheResponseTest::TestFinishedUnwound,
- base::Unretained(this)));
- }
-
- void TestFinishedUnwound() {
- TearDownTest();
- test_finished_event_->Signal();
- }
-
- void PushNextTask(const base::Closure& task) {
- task_stack_.push(std::pair<base::Closure, bool>(task, false));
- }
-
- void PushNextTaskAsImmediate(const base::Closure& task) {
- task_stack_.push(std::pair<base::Closure, bool>(task, true));
- }
-
- void ScheduleNextTask() {
- DCHECK(base::MessageLoop::current() == io_thread_->message_loop());
- if (task_stack_.empty()) {
- TestFinished();
- return;
- }
- base::Closure task = task_stack_.top().first;
- bool immediate = task_stack_.top().second;
- task_stack_.pop();
- if (immediate)
- task.Run();
- else
- base::MessageLoop::current()->PostTask(FROM_HERE, task);
- }
-
- // Wrappers to call AppCacheResponseReader/Writer Read and Write methods
-
- void WriteBasicResponse() {
- static const char kHttpHeaders[] =
- "HTTP/1.0 200 OK\0Content-Length: 5\0\0";
- static const char* kHttpBody = "Hello";
- scoped_refptr<IOBuffer> body(new WrappedIOBuffer(kHttpBody));
- std::string raw_headers(kHttpHeaders, arraysize(kHttpHeaders));
- WriteResponse(
- MakeHttpResponseInfo(raw_headers), body.get(), strlen(kHttpBody));
- }
-
- int basic_response_size() { return 5; } // should match kHttpBody above
-
- void WriteResponse(net::HttpResponseInfo* head,
- IOBuffer* body, int body_len) {
- DCHECK(body);
- scoped_refptr<IOBuffer> body_ref(body);
- PushNextTask(base::Bind(&AppCacheResponseTest::WriteResponseBody,
- base::Unretained(this), body_ref, body_len));
- WriteResponseHead(head);
- }
-
- void WriteResponseHead(net::HttpResponseInfo* head) {
- EXPECT_FALSE(writer_->IsWritePending());
- expected_write_result_ = GetHttpResponseInfoSize(head);
- write_info_buffer_ = new HttpResponseInfoIOBuffer(head);
- writer_->WriteInfo(write_info_buffer_.get(),
- base::Bind(&AppCacheResponseTest::OnWriteInfoComplete,
- base::Unretained(this)));
- }
-
- void WriteResponseBody(scoped_refptr<IOBuffer> io_buffer, int buf_len) {
- EXPECT_FALSE(writer_->IsWritePending());
- write_buffer_ = io_buffer;
- expected_write_result_ = buf_len;
- writer_->WriteData(write_buffer_.get(),
- buf_len,
- base::Bind(&AppCacheResponseTest::OnWriteComplete,
- base::Unretained(this)));
- }
-
- void ReadResponseBody(scoped_refptr<IOBuffer> io_buffer, int buf_len) {
- EXPECT_FALSE(reader_->IsReadPending());
- read_buffer_ = io_buffer;
- expected_read_result_ = buf_len;
- reader_->ReadData(read_buffer_.get(),
- buf_len,
- base::Bind(&AppCacheResponseTest::OnReadComplete,
- base::Unretained(this)));
- }
-
- // AppCacheResponseReader / Writer completion callbacks
-
- void OnWriteInfoComplete(int result) {
- EXPECT_FALSE(writer_->IsWritePending());
- EXPECT_EQ(expected_write_result_, result);
- ScheduleNextTask();
- }
-
- void OnWriteComplete(int result) {
- EXPECT_FALSE(writer_->IsWritePending());
- write_callback_was_called_ = true;
- EXPECT_EQ(expected_write_result_, result);
- if (should_delete_writer_in_completion_callback_ &&
- --writer_deletion_count_down_ == 0) {
- writer_.reset();
- }
- ScheduleNextTask();
- }
-
- void OnReadInfoComplete(int result) {
- EXPECT_FALSE(reader_->IsReadPending());
- EXPECT_EQ(expected_read_result_, result);
- ScheduleNextTask();
- }
-
- void OnReadComplete(int result) {
- EXPECT_FALSE(reader_->IsReadPending());
- read_callback_was_called_ = true;
- EXPECT_EQ(expected_read_result_, result);
- if (should_delete_reader_in_completion_callback_ &&
- --reader_deletion_count_down_ == 0) {
- reader_.reset();
- }
- ScheduleNextTask();
- }
-
- // Helpers to work with HttpResponseInfo objects
-
- net::HttpResponseInfo* MakeHttpResponseInfo(const std::string& raw_headers) {
- net::HttpResponseInfo* info = new net::HttpResponseInfo;
- info->request_time = base::Time::Now();
- info->response_time = base::Time::Now();
- info->was_cached = false;
- info->headers = new net::HttpResponseHeaders(raw_headers);
- return info;
- }
-
- int GetHttpResponseInfoSize(const net::HttpResponseInfo* info) {
- Pickle pickle;
- return PickleHttpResonseInfo(&pickle, info);
- }
-
- bool CompareHttpResponseInfos(const net::HttpResponseInfo* info1,
- const net::HttpResponseInfo* info2) {
- Pickle pickle1;
- Pickle pickle2;
- PickleHttpResonseInfo(&pickle1, info1);
- PickleHttpResonseInfo(&pickle2, info2);
- return (pickle1.size() == pickle2.size()) &&
- (0 == memcmp(pickle1.data(), pickle2.data(), pickle1.size()));
- }
-
- int PickleHttpResonseInfo(Pickle* pickle, const net::HttpResponseInfo* info) {
- const bool kSkipTransientHeaders = true;
- const bool kTruncated = false;
- info->Persist(pickle, kSkipTransientHeaders, kTruncated);
- return pickle->size();
- }
-
- // Helpers to fill and verify blocks of memory with a value
-
- void FillData(char value, char* data, int data_len) {
- memset(data, value, data_len);
- }
-
- bool CheckData(char value, const char* data, int data_len) {
- for (int i = 0; i < data_len; ++i, ++data) {
- if (*data != value)
- return false;
- }
- return true;
- }
-
- // Individual Tests ---------------------------------------------------------
- // Most of the individual tests involve multiple async steps. Each test
- // is delineated with a section header.
-
-
- // ReadNonExistentResponse -------------------------------------------
- void ReadNonExistentResponse() {
- // 1. Attempt to ReadInfo
- // 2. Attempt to ReadData
-
- reader_.reset(service_->storage()->CreateResponseReader(
- GURL(), 0, kNoSuchResponseId));
-
- // Push tasks in reverse order
- PushNextTask(base::Bind(&AppCacheResponseTest::ReadNonExistentData,
- base::Unretained(this)));
- PushNextTask(base::Bind(&AppCacheResponseTest::ReadNonExistentInfo,
- base::Unretained(this)));
- ScheduleNextTask();
- }
-
- void ReadNonExistentInfo() {
- EXPECT_FALSE(reader_->IsReadPending());
- read_info_buffer_ = new HttpResponseInfoIOBuffer();
- reader_->ReadInfo(read_info_buffer_.get(),
- base::Bind(&AppCacheResponseTest::OnReadInfoComplete,
- base::Unretained(this)));
- EXPECT_TRUE(reader_->IsReadPending());
- expected_read_result_ = net::ERR_CACHE_MISS;
- }
-
- void ReadNonExistentData() {
- EXPECT_FALSE(reader_->IsReadPending());
- read_buffer_ = new IOBuffer(kBlockSize);
- reader_->ReadData(read_buffer_.get(),
- kBlockSize,
- base::Bind(&AppCacheResponseTest::OnReadComplete,
- base::Unretained(this)));
- EXPECT_TRUE(reader_->IsReadPending());
- expected_read_result_ = net::ERR_CACHE_MISS;
- }
-
- // LoadResponseInfo_Miss ----------------------------------------------------
- void LoadResponseInfo_Miss() {
- PushNextTask(base::Bind(&AppCacheResponseTest::LoadResponseInfo_Miss_Verify,
- base::Unretained(this)));
- service_->storage()->LoadResponseInfo(GURL(), 0, kNoSuchResponseId,
- storage_delegate_.get());
- }
-
- void LoadResponseInfo_Miss_Verify() {
- EXPECT_EQ(kNoSuchResponseId, storage_delegate_->loaded_info_id_);
- EXPECT_TRUE(!storage_delegate_->loaded_info_.get());
- TestFinished();
- }
-
- // LoadResponseInfo_Hit ----------------------------------------------------
- void LoadResponseInfo_Hit() {
- // This tests involves multiple async steps.
- // 1. Write a response headers and body to storage
- // a. headers
- // b. body
- // 2. Use LoadResponseInfo to read the response headers back out
- PushNextTask(base::Bind(&AppCacheResponseTest::LoadResponseInfo_Hit_Step2,
- base::Unretained(this)));
- writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0));
- written_response_id_ = writer_->response_id();
- WriteBasicResponse();
- }
-
- void LoadResponseInfo_Hit_Step2() {
- writer_.reset();
- PushNextTask(base::Bind(&AppCacheResponseTest::LoadResponseInfo_Hit_Verify,
- base::Unretained(this)));
- service_->storage()->LoadResponseInfo(GURL(), 0, written_response_id_,
- storage_delegate_.get());
- }
-
- void LoadResponseInfo_Hit_Verify() {
- EXPECT_EQ(written_response_id_, storage_delegate_->loaded_info_id_);
- EXPECT_TRUE(storage_delegate_->loaded_info_.get());
- EXPECT_TRUE(CompareHttpResponseInfos(
- write_info_buffer_->http_info.get(),
- storage_delegate_->loaded_info_->http_response_info()));
- EXPECT_EQ(basic_response_size(),
- storage_delegate_->loaded_info_->response_data_size());
- TestFinished();
- }
-
- // AmountWritten ----------------------------------------------------
-
- void AmountWritten() {
- static const char kHttpHeaders[] =
- "HTTP/1.0 200 OK\0\0";
- std::string raw_headers(kHttpHeaders, arraysize(kHttpHeaders));
- net::HttpResponseInfo* head = MakeHttpResponseInfo(raw_headers);
- int expected_amount_written =
- GetHttpResponseInfoSize(head) + kNumBlocks * kBlockSize;
-
- // Push tasks in reverse order.
- PushNextTask(base::Bind(&AppCacheResponseTest::Verify_AmountWritten,
- base::Unretained(this), expected_amount_written));
- for (int i = 0; i < kNumBlocks; ++i) {
- PushNextTask(base::Bind(&AppCacheResponseTest::WriteOneBlock,
- base::Unretained(this), kNumBlocks - i));
- }
- PushNextTask(base::Bind(&AppCacheResponseTest::WriteResponseHead,
- base::Unretained(this), head));
-
- writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0));
- written_response_id_ = writer_->response_id();
- ScheduleNextTask();
- }
-
- void Verify_AmountWritten(int expected_amount_written) {
- EXPECT_EQ(expected_amount_written, writer_->amount_written());
- TestFinished();
- }
-
-
- // WriteThenVariouslyReadResponse -------------------------------------------
-
- void WriteThenVariouslyReadResponse() {
- // This tests involves multiple async steps.
- // 1. First, write a large body using multiple writes, we don't bother
- // with a response head for this test.
- // 2. Read the entire body, using multiple reads
- // 3. Read the entire body, using one read.
- // 4. Attempt to read beyond the EOF.
- // 5. Read just a range.
- // 6. Attempt to read beyond EOF of a range.
-
- // Push tasks in reverse order
- PushNextTask(base::Bind(&AppCacheResponseTest::ReadRangeFullyBeyondEOF,
- base::Unretained(this)));
- PushNextTask(base::Bind(&AppCacheResponseTest::ReadRangePartiallyBeyondEOF,
- base::Unretained(this)));
- PushNextTask(base::Bind(&AppCacheResponseTest::ReadPastEOF,
- base::Unretained(this)));
- PushNextTask(base::Bind(&AppCacheResponseTest::ReadRange,
- base::Unretained(this)));
- PushNextTask(base::Bind(&AppCacheResponseTest::ReadPastEOF,
- base::Unretained(this)));
- PushNextTask(base::Bind(&AppCacheResponseTest::ReadAllAtOnce,
- base::Unretained(this)));
- PushNextTask(base::Bind(&AppCacheResponseTest::ReadInBlocks,
- base::Unretained(this)));
- PushNextTask(base::Bind(&AppCacheResponseTest::WriteOutBlocks,
- base::Unretained(this)));
-
- // Get them going.
- ScheduleNextTask();
- }
-
- void WriteOutBlocks() {
- writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0));
- written_response_id_ = writer_->response_id();
- for (int i = 0; i < kNumBlocks; ++i) {
- PushNextTask(base::Bind(&AppCacheResponseTest::WriteOneBlock,
- base::Unretained(this), kNumBlocks - i));
- }
- ScheduleNextTask();
- }
-
- void WriteOneBlock(int block_number) {
- scoped_refptr<IOBuffer> io_buffer(
- new IOBuffer(kBlockSize));
- FillData(block_number, io_buffer->data(), kBlockSize);
- WriteResponseBody(io_buffer, kBlockSize);
- }
-
- void ReadInBlocks() {
- writer_.reset();
- reader_.reset(service_->storage()->CreateResponseReader(
- GURL(), 0, written_response_id_));
- for (int i = 0; i < kNumBlocks; ++i) {
- PushNextTask(base::Bind(&AppCacheResponseTest::ReadOneBlock,
- base::Unretained(this), kNumBlocks - i));
- }
- ScheduleNextTask();
- }
-
- void ReadOneBlock(int block_number) {
- PushNextTask(base::Bind(&AppCacheResponseTest::VerifyOneBlock,
- base::Unretained(this), block_number));
- ReadResponseBody(new IOBuffer(kBlockSize), kBlockSize);
- }
-
- void VerifyOneBlock(int block_number) {
- EXPECT_TRUE(CheckData(block_number, read_buffer_->data(), kBlockSize));
- ScheduleNextTask();
- }
-
- void ReadAllAtOnce() {
- PushNextTask(base::Bind(&AppCacheResponseTest::VerifyAllAtOnce,
- base::Unretained(this)));
- reader_.reset(service_->storage()->CreateResponseReader(
- GURL(), 0, written_response_id_));
- int big_size = kNumBlocks * kBlockSize;
- ReadResponseBody(new IOBuffer(big_size), big_size);
- }
-
- void VerifyAllAtOnce() {
- char* p = read_buffer_->data();
- for (int i = 0; i < kNumBlocks; ++i, p += kBlockSize)
- EXPECT_TRUE(CheckData(i + 1, p, kBlockSize));
- ScheduleNextTask();
- }
-
- void ReadPastEOF() {
- EXPECT_FALSE(reader_->IsReadPending());
- read_buffer_ = new IOBuffer(kBlockSize);
- expected_read_result_ = 0;
- reader_->ReadData(read_buffer_.get(),
- kBlockSize,
- base::Bind(&AppCacheResponseTest::OnReadComplete,
- base::Unretained(this)));
- }
-
- void ReadRange() {
- PushNextTask(base::Bind(&AppCacheResponseTest::VerifyRange,
- base::Unretained(this)));
- reader_.reset(service_->storage()->CreateResponseReader(
- GURL(), 0, written_response_id_));
- reader_->SetReadRange(kBlockSize, kBlockSize);
- ReadResponseBody(new IOBuffer(kBlockSize), kBlockSize);
- }
-
- void VerifyRange() {
- EXPECT_TRUE(CheckData(2, read_buffer_->data(), kBlockSize));
- ScheduleNextTask(); // ReadPastEOF is scheduled next
- }
-
- void ReadRangePartiallyBeyondEOF() {
- PushNextTask(base::Bind(&AppCacheResponseTest::VerifyRangeBeyondEOF,
- base::Unretained(this)));
- reader_.reset(service_->storage()->CreateResponseReader(
- GURL(), 0, written_response_id_));
- reader_->SetReadRange(kBlockSize, kNumBlocks * kBlockSize);
- ReadResponseBody(new IOBuffer(kNumBlocks * kBlockSize),
- kNumBlocks * kBlockSize);
- expected_read_result_ = (kNumBlocks - 1) * kBlockSize;
- }
-
- void VerifyRangeBeyondEOF() {
- // Just verify the first 1k
- VerifyRange();
- }
-
- void ReadRangeFullyBeyondEOF() {
- reader_.reset(service_->storage()->CreateResponseReader(
- GURL(), 0, written_response_id_));
- reader_->SetReadRange((kNumBlocks * kBlockSize) + 1, kBlockSize);
- ReadResponseBody(new IOBuffer(kBlockSize), kBlockSize);
- expected_read_result_ = 0;
- }
-
- // IOChaining -------------------------------------------
- void IOChaining() {
- // 1. Write several blocks out initiating the subsequent write
- // from within the completion callback of the previous write.
- // 2. Read and verify several blocks in similarly chaining reads.
-
- // Push tasks in reverse order
- PushNextTaskAsImmediate(
- base::Bind(&AppCacheResponseTest::ReadInBlocksImmediately,
- base::Unretained(this)));
- PushNextTaskAsImmediate(
- base::Bind(&AppCacheResponseTest::WriteOutBlocksImmediately,
- base::Unretained(this)));
-
- // Get them going.
- ScheduleNextTask();
- }
-
- void WriteOutBlocksImmediately() {
- writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0));
- written_response_id_ = writer_->response_id();
- for (int i = 0; i < kNumBlocks; ++i) {
- PushNextTaskAsImmediate(
- base::Bind(&AppCacheResponseTest::WriteOneBlock,
- base::Unretained(this), kNumBlocks - i));
- }
- ScheduleNextTask();
- }
-
- void ReadInBlocksImmediately() {
- writer_.reset();
- reader_.reset(service_->storage()->CreateResponseReader(
- GURL(), 0, written_response_id_));
- for (int i = 0; i < kNumBlocks; ++i) {
- PushNextTaskAsImmediate(
- base::Bind(&AppCacheResponseTest::ReadOneBlockImmediately,
- base::Unretained(this),
- kNumBlocks - i));
- }
- ScheduleNextTask();
- }
-
- void ReadOneBlockImmediately(int block_number) {
- PushNextTaskAsImmediate(base::Bind(&AppCacheResponseTest::VerifyOneBlock,
- base::Unretained(this), block_number));
- ReadResponseBody(new IOBuffer(kBlockSize), kBlockSize);
- }
-
- // DeleteWithinCallbacks -------------------------------------------
- void DeleteWithinCallbacks() {
- // 1. Write out a few blocks normally, and upon
- // completion of the last write, delete the writer.
- // 2. Read in a few blocks normally, and upon completion
- // of the last read, delete the reader.
-
- should_delete_reader_in_completion_callback_ = true;
- reader_deletion_count_down_ = kNumBlocks;
- should_delete_writer_in_completion_callback_ = true;
- writer_deletion_count_down_ = kNumBlocks;
-
- PushNextTask(base::Bind(&AppCacheResponseTest::ReadInBlocks,
- base::Unretained(this)));
- PushNextTask(base::Bind(&AppCacheResponseTest::WriteOutBlocks,
- base::Unretained(this)));
- ScheduleNextTask();
- }
-
- // DeleteWithIOPending -------------------------------------------
- void DeleteWithIOPending() {
- // 1. Write a few blocks normally.
- // 2. Start a write, delete with it pending.
- // 3. Start a read, delete with it pending.
- PushNextTask(base::Bind(&AppCacheResponseTest::ReadThenDelete,
- base::Unretained(this)));
- PushNextTask(base::Bind(&AppCacheResponseTest::WriteThenDelete,
- base::Unretained(this)));
- PushNextTask(base::Bind(&AppCacheResponseTest::WriteOutBlocks,
- base::Unretained(this)));
- ScheduleNextTask();
- }
-
- void WriteThenDelete() {
- write_callback_was_called_ = false;
- WriteOneBlock(5);
- EXPECT_TRUE(writer_->IsWritePending());
- writer_.reset();
- ScheduleNextTask();
- }
-
- void ReadThenDelete() {
- read_callback_was_called_ = false;
- reader_.reset(service_->storage()->CreateResponseReader(
- GURL(), 0, written_response_id_));
- ReadResponseBody(new IOBuffer(kBlockSize), kBlockSize);
- EXPECT_TRUE(reader_->IsReadPending());
- reader_.reset();
-
- // Wait a moment to verify no callbacks.
- base::MessageLoop::current()->PostDelayedTask(
- FROM_HERE, base::Bind(&AppCacheResponseTest::VerifyNoCallbacks,
- base::Unretained(this)),
- base::TimeDelta::FromMilliseconds(10));
- }
-
- void VerifyNoCallbacks() {
- EXPECT_TRUE(!write_callback_was_called_);
- EXPECT_TRUE(!read_callback_was_called_);
- TestFinished();
- }
-
- // Data members
-
- scoped_ptr<base::WaitableEvent> test_finished_event_;
- scoped_ptr<MockStorageDelegate> storage_delegate_;
- scoped_ptr<MockAppCacheService> service_;
- std::stack<std::pair<base::Closure, bool> > task_stack_;
-
- scoped_ptr<AppCacheResponseReader> reader_;
- scoped_refptr<HttpResponseInfoIOBuffer> read_info_buffer_;
- scoped_refptr<IOBuffer> read_buffer_;
- int expected_read_result_;
- bool should_delete_reader_in_completion_callback_;
- int reader_deletion_count_down_;
- bool read_callback_was_called_;
-
- int64 written_response_id_;
- scoped_ptr<AppCacheResponseWriter> writer_;
- scoped_refptr<HttpResponseInfoIOBuffer> write_info_buffer_;
- scoped_refptr<IOBuffer> write_buffer_;
- int expected_write_result_;
- bool should_delete_writer_in_completion_callback_;
- int writer_deletion_count_down_;
- bool write_callback_was_called_;
-
- static scoped_ptr<base::Thread> io_thread_;
-};
-
-// static
-scoped_ptr<base::Thread> AppCacheResponseTest::io_thread_;
-
-TEST_F(AppCacheResponseTest, ReadNonExistentResponse) {
- RunTestOnIOThread(&AppCacheResponseTest::ReadNonExistentResponse);
-}
-
-TEST_F(AppCacheResponseTest, LoadResponseInfo_Miss) {
- RunTestOnIOThread(&AppCacheResponseTest::LoadResponseInfo_Miss);
-}
-
-TEST_F(AppCacheResponseTest, LoadResponseInfo_Hit) {
- RunTestOnIOThread(&AppCacheResponseTest::LoadResponseInfo_Hit);
-}
-
-TEST_F(AppCacheResponseTest, AmountWritten) {
- RunTestOnIOThread(&AppCacheResponseTest::AmountWritten);
-}
-
-TEST_F(AppCacheResponseTest, WriteThenVariouslyReadResponse) {
- RunTestOnIOThread(&AppCacheResponseTest::WriteThenVariouslyReadResponse);
-}
-
-TEST_F(AppCacheResponseTest, IOChaining) {
- RunTestOnIOThread(&AppCacheResponseTest::IOChaining);
-}
-
-TEST_F(AppCacheResponseTest, DeleteWithinCallbacks) {
- RunTestOnIOThread(&AppCacheResponseTest::DeleteWithinCallbacks);
-}
-
-TEST_F(AppCacheResponseTest, DeleteWithIOPending) {
- RunTestOnIOThread(&AppCacheResponseTest::DeleteWithIOPending);
-}
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/appcache_service.h b/chromium/webkit/browser/appcache/appcache_service.h
index 43e38b47b58..dc6e33b4308 100644
--- a/chromium/webkit/browser/appcache/appcache_service.h
+++ b/chromium/webkit/browser/appcache/appcache_service.h
@@ -8,36 +8,14 @@
#include <map>
#include <set>
-#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "base/observer_list.h"
-#include "net/base/completion_callback.h"
-#include "net/base/net_errors.h"
-#include "webkit/browser/appcache/appcache_storage.h"
#include "webkit/browser/webkit_storage_browser_export.h"
#include "webkit/common/appcache/appcache_interfaces.h"
-namespace net {
-class URLRequestContext;
-} // namespace net
-
-namespace base {
-class FilePath;
-class MessageLoopProxy;
-}
-
-namespace quota {
-class QuotaManagerProxy;
-class SpecialStoragePolicy;
-}
-
namespace appcache {
-class AppCacheBackendImpl;
-class AppCacheExecutableHandlerFactory;
-class AppCacheQuotaClient;
-class AppCachePolicy;
+class AppCacheStorage;
// Refcounted container to avoid copying the collection in callbacks.
struct WEBKIT_STORAGE_BROWSER_EXPORT AppCacheInfoCollection
@@ -51,186 +29,34 @@ struct WEBKIT_STORAGE_BROWSER_EXPORT AppCacheInfoCollection
virtual ~AppCacheInfoCollection();
};
-// Refcounted container to manage the lifetime of the old storage instance
-// during Reinitialization.
-class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheStorageReference :
- public base::RefCounted<AppCacheStorageReference> {
- public:
- AppCacheStorage* storage() const { return storage_.get(); }
- private:
- friend class AppCacheService;
- friend class base::RefCounted<AppCacheStorageReference>;
- AppCacheStorageReference(scoped_ptr<AppCacheStorage> storage);
- ~AppCacheStorageReference();
-
- scoped_ptr<AppCacheStorage> storage_;
-};
-
// Class that manages the application cache service. Sends notifications
-// to many frontends. One instance per user-profile. Each instance has
+// to many frontends. One instance per user-profile. Each instance has
// exclusive access to its cache_directory on disk.
class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheService {
public:
-
- class WEBKIT_STORAGE_BROWSER_EXPORT Observer {
- public:
- // An observer method to inform consumers of reinitialzation. Managing
- // the lifetime of the old storage instance is a delicate process.
- // Consumers can keep the old disabled instance alive by hanging on to the
- // ref provided.
- virtual void OnServiceReinitialized(
- AppCacheStorageReference* old_storage_ref) = 0;
- virtual ~Observer() {}
- };
-
- // If not using quota management, the proxy may be NULL.
- explicit AppCacheService(quota::QuotaManagerProxy* quota_manager_proxy);
- virtual ~AppCacheService();
-
- void Initialize(const base::FilePath& cache_directory,
- base::MessageLoopProxy* db_thread,
- base::MessageLoopProxy* cache_thread);
-
- void AddObserver(Observer* observer) {
- observers_.AddObserver(observer);
- }
-
- void RemoveObserver(Observer* observer) {
- observers_.RemoveObserver(observer);
- }
-
- // For use in a very specific failure mode to reboot the appcache system
- // without relaunching the browser.
- void Reinitialize();
-
- // Purges any memory not needed.
- void PurgeMemory() {
- if (storage_)
- storage_->PurgeMemory();
- }
+ virtual ~AppCacheService() { }
// Determines if a request for 'url' can be satisfied while offline.
// This method always completes asynchronously.
- void CanHandleMainResourceOffline(const GURL& url,
- const GURL& first_party,
- const net::CompletionCallback& callback);
+ virtual void CanHandleMainResourceOffline(const GURL& url,
+ const GURL& first_party,
+ const net::CompletionCallback&
+ callback) = 0;
// Populates 'collection' with info about all of the appcaches stored
// within the service, 'callback' is invoked upon completion. The service
// acquires a reference to the 'collection' until until completion.
// This method always completes asynchronously.
- void GetAllAppCacheInfo(AppCacheInfoCollection* collection,
- const net::CompletionCallback& callback);
+ virtual void GetAllAppCacheInfo(AppCacheInfoCollection* collection,
+ const net::CompletionCallback& callback) = 0;
// Deletes the group identified by 'manifest_url', 'callback' is
// invoked upon completion. Upon completion, the cache group and
// any resources within the group are no longer loadable and all
// subresource loads for pages associated with a deleted group
// will fail. This method always completes asynchronously.
- void DeleteAppCacheGroup(const GURL& manifest_url,
- const net::CompletionCallback& callback);
-
- // Deletes all appcaches for the origin, 'callback' is invoked upon
- // completion. This method always completes asynchronously.
- // (virtual for unit testing)
- virtual void DeleteAppCachesForOrigin(
- const GURL& origin, const net::CompletionCallback& callback);
-
- // Checks the integrity of 'response_id' by reading the headers and data.
- // If it cannot be read, the cache group for 'manifest_url' is deleted.
- void CheckAppCacheResponse(const GURL& manifest_url, int64 cache_id,
- int64 response_id);
-
- // Context for use during cache updates, should only be accessed
- // on the IO thread. We do NOT add a reference to the request context,
- // it is the callers responsibility to ensure that the pointer
- // remains valid while set.
- net::URLRequestContext* request_context() const { return request_context_; }
- void set_request_context(net::URLRequestContext* context) {
- request_context_ = context;
- }
-
- // The appcache policy, may be null, in which case access is always allowed.
- // The service does NOT assume ownership of the policy, it is the callers
- // responsibility to ensure that the pointer remains valid while set.
- AppCachePolicy* appcache_policy() const { return appcache_policy_; }
- void set_appcache_policy(AppCachePolicy* policy) {
- appcache_policy_ = policy;
- }
-
- // The factory may be null, in which case invocations of exe handlers
- // will result in an error response.
- // The service does NOT assume ownership of the factory, it is the callers
- // responsibility to ensure that the pointer remains valid while set.
- AppCacheExecutableHandlerFactory* handler_factory() const {
- return handler_factory_;
- }
- void set_handler_factory(
- AppCacheExecutableHandlerFactory* factory) {
- handler_factory_ = factory;
- }
-
- quota::SpecialStoragePolicy* special_storage_policy() const {
- return special_storage_policy_.get();
- }
- void set_special_storage_policy(quota::SpecialStoragePolicy* policy);
-
- quota::QuotaManagerProxy* quota_manager_proxy() const {
- return quota_manager_proxy_.get();
- }
-
- AppCacheQuotaClient* quota_client() const {
- return quota_client_;
- }
-
- // Each child process in chrome uses a distinct backend instance.
- // See chrome/browser/AppCacheDispatcherHost.
- void RegisterBackend(AppCacheBackendImpl* backend_impl);
- void UnregisterBackend(AppCacheBackendImpl* backend_impl);
- AppCacheBackendImpl* GetBackend(int id) const {
- BackendMap::const_iterator it = backends_.find(id);
- return (it != backends_.end()) ? it->second : NULL;
- }
-
- AppCacheStorage* storage() const { return storage_.get(); }
-
- // Disables the exit-time deletion of session-only data.
- void set_force_keep_session_state() { force_keep_session_state_ = true; }
- bool force_keep_session_state() const { return force_keep_session_state_; }
-
- protected:
- friend class AppCacheStorageImplTest;
- friend class AppCacheServiceTest;
-
- class AsyncHelper;
- class CanHandleOfflineHelper;
- class DeleteHelper;
- class DeleteOriginHelper;
- class GetInfoHelper;
- class CheckResponseHelper;
-
- typedef std::set<AsyncHelper*> PendingAsyncHelpers;
- typedef std::map<int, AppCacheBackendImpl*> BackendMap;
-
- base::FilePath cache_directory_;
- scoped_refptr<base::MessageLoopProxy> db_thread_;
- scoped_refptr<base::MessageLoopProxy> cache_thread_;
- AppCachePolicy* appcache_policy_;
- AppCacheQuotaClient* quota_client_;
- AppCacheExecutableHandlerFactory* handler_factory_;
- scoped_ptr<AppCacheStorage> storage_;
- scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
- scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
- PendingAsyncHelpers pending_helpers_;
- BackendMap backends_; // One 'backend' per child process.
- // Context for use during cache updates.
- net::URLRequestContext* request_context_;
- // If true, nothing (not even session-only data) should be deleted on exit.
- bool force_keep_session_state_;
- bool was_reinitialized_;
- ObserverList<Observer> observers_;
-
- DISALLOW_COPY_AND_ASSIGN(AppCacheService);
+ virtual void DeleteAppCacheGroup(const GURL& manifest_url,
+ const net::CompletionCallback& callback) = 0;
};
} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/appcache_service.cc b/chromium/webkit/browser/appcache/appcache_service_impl.cc
index c11631c62f6..3091a5cb5fa 100644
--- a/chromium/webkit/browser/appcache/appcache_service.cc
+++ b/chromium/webkit/browser/appcache/appcache_service_impl.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// 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 "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include <functional>
@@ -21,8 +21,8 @@
#include "webkit/browser/appcache/appcache_policy.h"
#include "webkit/browser/appcache/appcache_quota_client.h"
#include "webkit/browser/appcache/appcache_response.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include "webkit/browser/appcache/appcache_storage_impl.h"
-#include "webkit/browser/quota/quota_manager.h"
#include "webkit/browser/quota/special_storage_policy.h"
namespace appcache {
@@ -41,10 +41,10 @@ AppCacheInfoCollection::~AppCacheInfoCollection() {}
// AsyncHelper -------
-class AppCacheService::AsyncHelper
+class AppCacheServiceImpl::AsyncHelper
: public AppCacheStorage::Delegate {
public:
- AsyncHelper(AppCacheService* service,
+ AsyncHelper(AppCacheServiceImpl* service,
const net::CompletionCallback& callback)
: service_(service), callback_(callback) {
service_->pending_helpers_.insert(this);
@@ -68,11 +68,11 @@ class AppCacheService::AsyncHelper
callback_.Reset();
}
- AppCacheService* service_;
+ AppCacheServiceImpl* service_;
net::CompletionCallback callback_;
};
-void AppCacheService::AsyncHelper::Cancel() {
+void AppCacheServiceImpl::AsyncHelper::Cancel() {
if (!callback_.is_null()) {
callback_.Run(net::ERR_ABORTED);
callback_.Reset();
@@ -83,10 +83,10 @@ void AppCacheService::AsyncHelper::Cancel() {
// CanHandleOfflineHelper -------
-class AppCacheService::CanHandleOfflineHelper : AsyncHelper {
+class AppCacheServiceImpl::CanHandleOfflineHelper : AsyncHelper {
public:
CanHandleOfflineHelper(
- AppCacheService* service, const GURL& url,
+ AppCacheServiceImpl* service, const GURL& url,
const GURL& first_party, const net::CompletionCallback& callback)
: AsyncHelper(service, callback),
url_(url),
@@ -117,7 +117,7 @@ class AppCacheService::CanHandleOfflineHelper : AsyncHelper {
DISALLOW_COPY_AND_ASSIGN(CanHandleOfflineHelper);
};
-void AppCacheService::CanHandleOfflineHelper::OnMainResponseFound(
+void AppCacheServiceImpl::CanHandleOfflineHelper::OnMainResponseFound(
const GURL& url, const AppCacheEntry& entry,
const GURL& fallback_url, const AppCacheEntry& fallback_entry,
int64 cache_id, int64 group_id, const GURL& manifest_url) {
@@ -128,10 +128,10 @@ void AppCacheService::CanHandleOfflineHelper::OnMainResponseFound(
// DeleteHelper -------
-class AppCacheService::DeleteHelper : public AsyncHelper {
+class AppCacheServiceImpl::DeleteHelper : public AsyncHelper {
public:
DeleteHelper(
- AppCacheService* service, const GURL& manifest_url,
+ AppCacheServiceImpl* service, const GURL& manifest_url,
const net::CompletionCallback& callback)
: AsyncHelper(service, callback), manifest_url_(manifest_url) {
}
@@ -144,37 +144,40 @@ class AppCacheService::DeleteHelper : public AsyncHelper {
// AppCacheStorage::Delegate implementation.
virtual void OnGroupLoaded(
appcache::AppCacheGroup* group, const GURL& manifest_url) OVERRIDE;
- virtual void OnGroupMadeObsolete(
- appcache::AppCacheGroup* group, bool success) OVERRIDE;
+ virtual void OnGroupMadeObsolete(appcache::AppCacheGroup* group,
+ bool success,
+ int response_code) OVERRIDE;
GURL manifest_url_;
DISALLOW_COPY_AND_ASSIGN(DeleteHelper);
};
-void AppCacheService::DeleteHelper::OnGroupLoaded(
+void AppCacheServiceImpl::DeleteHelper::OnGroupLoaded(
appcache::AppCacheGroup* group, const GURL& manifest_url) {
if (group) {
group->set_being_deleted(true);
group->CancelUpdate();
- service_->storage()->MakeGroupObsolete(group, this);
+ service_->storage()->MakeGroupObsolete(group, this, 0);
} else {
CallCallback(net::ERR_FAILED);
delete this;
}
}
-void AppCacheService::DeleteHelper::OnGroupMadeObsolete(
- appcache::AppCacheGroup* group, bool success) {
+void AppCacheServiceImpl::DeleteHelper::OnGroupMadeObsolete(
+ appcache::AppCacheGroup* group,
+ bool success,
+ int response_code) {
CallCallback(success ? net::OK : net::ERR_FAILED);
delete this;
}
// DeleteOriginHelper -------
-class AppCacheService::DeleteOriginHelper : public AsyncHelper {
+class AppCacheServiceImpl::DeleteOriginHelper : public AsyncHelper {
public:
DeleteOriginHelper(
- AppCacheService* service, const GURL& origin,
+ AppCacheServiceImpl* service, const GURL& origin,
const net::CompletionCallback& callback)
: AsyncHelper(service, callback), origin_(origin),
num_caches_to_delete_(0), successes_(0), failures_(0) {
@@ -190,8 +193,9 @@ class AppCacheService::DeleteOriginHelper : public AsyncHelper {
virtual void OnAllInfo(AppCacheInfoCollection* collection) OVERRIDE;
virtual void OnGroupLoaded(
appcache::AppCacheGroup* group, const GURL& manifest_url) OVERRIDE;
- virtual void OnGroupMadeObsolete(
- appcache::AppCacheGroup* group, bool success) OVERRIDE;
+ virtual void OnGroupMadeObsolete(appcache::AppCacheGroup* group,
+ bool success,
+ int response_code) OVERRIDE;
void CacheCompleted(bool success);
@@ -203,7 +207,7 @@ class AppCacheService::DeleteOriginHelper : public AsyncHelper {
DISALLOW_COPY_AND_ASSIGN(DeleteOriginHelper);
};
-void AppCacheService::DeleteOriginHelper::OnAllInfo(
+void AppCacheServiceImpl::DeleteOriginHelper::OnAllInfo(
AppCacheInfoCollection* collection) {
if (!collection) {
// Failed to get a listing.
@@ -232,23 +236,25 @@ void AppCacheService::DeleteOriginHelper::OnAllInfo(
}
}
-void AppCacheService::DeleteOriginHelper::OnGroupLoaded(
+void AppCacheServiceImpl::DeleteOriginHelper::OnGroupLoaded(
appcache::AppCacheGroup* group, const GURL& manifest_url) {
if (group) {
group->set_being_deleted(true);
group->CancelUpdate();
- service_->storage()->MakeGroupObsolete(group, this);
+ service_->storage()->MakeGroupObsolete(group, this, 0);
} else {
CacheCompleted(false);
}
}
-void AppCacheService::DeleteOriginHelper::OnGroupMadeObsolete(
- appcache::AppCacheGroup* group, bool success) {
+void AppCacheServiceImpl::DeleteOriginHelper::OnGroupMadeObsolete(
+ appcache::AppCacheGroup* group,
+ bool success,
+ int response_code) {
CacheCompleted(success);
}
-void AppCacheService::DeleteOriginHelper::CacheCompleted(bool success) {
+void AppCacheServiceImpl::DeleteOriginHelper::CacheCompleted(bool success) {
if (success)
++successes_;
else
@@ -263,10 +269,10 @@ void AppCacheService::DeleteOriginHelper::CacheCompleted(bool success) {
// GetInfoHelper -------
-class AppCacheService::GetInfoHelper : AsyncHelper {
+class AppCacheServiceImpl::GetInfoHelper : AsyncHelper {
public:
GetInfoHelper(
- AppCacheService* service, AppCacheInfoCollection* collection,
+ AppCacheServiceImpl* service, AppCacheInfoCollection* collection,
const net::CompletionCallback& callback)
: AsyncHelper(service, callback), collection_(collection) {
}
@@ -284,7 +290,7 @@ class AppCacheService::GetInfoHelper : AsyncHelper {
DISALLOW_COPY_AND_ASSIGN(GetInfoHelper);
};
-void AppCacheService::GetInfoHelper::OnAllInfo(
+void AppCacheServiceImpl::GetInfoHelper::OnAllInfo(
AppCacheInfoCollection* collection) {
if (collection)
collection->infos_by_origin.swap(collection_->infos_by_origin);
@@ -294,10 +300,10 @@ void AppCacheService::GetInfoHelper::OnAllInfo(
// CheckResponseHelper -------
-class AppCacheService::CheckResponseHelper : AsyncHelper {
+class AppCacheServiceImpl::CheckResponseHelper : AsyncHelper {
public:
CheckResponseHelper(
- AppCacheService* service, const GURL& manifest_url, int64 cache_id,
+ AppCacheServiceImpl* service, const GURL& manifest_url, int64 cache_id,
int64 response_id)
: AsyncHelper(service, net::CompletionCallback()),
manifest_url_(manifest_url),
@@ -343,7 +349,7 @@ class AppCacheService::CheckResponseHelper : AsyncHelper {
DISALLOW_COPY_AND_ASSIGN(CheckResponseHelper);
};
-void AppCacheService::CheckResponseHelper::OnGroupLoaded(
+void AppCacheServiceImpl::CheckResponseHelper::OnGroupLoaded(
AppCacheGroup* group, const GURL& manifest_url) {
DCHECK_EQ(manifest_url_, manifest_url);
if (!group || !group->newest_complete_cache() || group->is_being_deleted() ||
@@ -380,7 +386,7 @@ void AppCacheService::CheckResponseHelper::OnGroupLoaded(
base::Unretained(this)));
}
-void AppCacheService::CheckResponseHelper::OnReadInfoComplete(int result) {
+void AppCacheServiceImpl::CheckResponseHelper::OnReadInfoComplete(int result) {
if (result < 0) {
AppCacheHistograms::CountCheckResponseResult(
AppCacheHistograms::READ_HEADERS_ERROR);
@@ -399,7 +405,7 @@ void AppCacheService::CheckResponseHelper::OnReadInfoComplete(int result) {
base::Unretained(this)));
}
-void AppCacheService::CheckResponseHelper::OnReadDataComplete(int result) {
+void AppCacheServiceImpl::CheckResponseHelper::OnReadDataComplete(int result) {
if (result > 0) {
// Keep reading until we've read thru everything or failed to read.
amount_data_read_ += result;
@@ -426,7 +432,6 @@ void AppCacheService::CheckResponseHelper::OnReadDataComplete(int result) {
delete this;
}
-
// AppCacheStorageReference ------
AppCacheStorageReference::AppCacheStorageReference(
@@ -434,21 +439,21 @@ AppCacheStorageReference::AppCacheStorageReference(
: storage_(storage.Pass()) {}
AppCacheStorageReference::~AppCacheStorageReference() {}
-// AppCacheService -------
+// AppCacheServiceImpl -------
-AppCacheService::AppCacheService(quota::QuotaManagerProxy* quota_manager_proxy)
+AppCacheServiceImpl::AppCacheServiceImpl(quota::QuotaManagerProxy*
+ quota_manager_proxy)
: appcache_policy_(NULL), quota_client_(NULL), handler_factory_(NULL),
quota_manager_proxy_(quota_manager_proxy),
request_context_(NULL),
- force_keep_session_state_(false),
- was_reinitialized_(false) {
+ force_keep_session_state_(false) {
if (quota_manager_proxy_.get()) {
quota_client_ = new AppCacheQuotaClient(this);
quota_manager_proxy_->RegisterClient(quota_client_);
}
}
-AppCacheService::~AppCacheService() {
+AppCacheServiceImpl::~AppCacheServiceImpl() {
DCHECK(backends_.empty());
std::for_each(pending_helpers_.begin(),
pending_helpers_.end(),
@@ -462,7 +467,7 @@ AppCacheService::~AppCacheService() {
storage_.reset();
}
-void AppCacheService::Initialize(const base::FilePath& cache_directory,
+void AppCacheServiceImpl::Initialize(const base::FilePath& cache_directory,
base::MessageLoopProxy* db_thread,
base::MessageLoopProxy* cache_thread) {
DCHECK(!storage_.get());
@@ -474,13 +479,36 @@ void AppCacheService::Initialize(const base::FilePath& cache_directory,
storage_.reset(storage);
}
-void AppCacheService::Reinitialize() {
- AppCacheHistograms::CountReinitAttempt(was_reinitialized_);
-
- // To avoid thrashing, we only do this once.
- if (was_reinitialized_)
+void AppCacheServiceImpl::ScheduleReinitialize() {
+ if (reinit_timer_.IsRunning())
return;
- was_reinitialized_ = true;
+
+ // Reinitialization only happens when corruption has been noticed.
+ // We don't want to thrash the disk but we also don't want to
+ // leave the appcache disabled for an indefinite period of time. Some
+ // users never shutdown the browser.
+
+ const base::TimeDelta kZeroDelta;
+ const base::TimeDelta kOneHour(base::TimeDelta::FromHours(1));
+ const base::TimeDelta k30Seconds(base::TimeDelta::FromSeconds(30));
+
+ // If the system managed to stay up for long enough, reset the
+ // delay so a new failure won't incur a long wait to get going again.
+ base::TimeDelta up_time = base::Time::Now() - last_reinit_time_;
+ if (next_reinit_delay_ != kZeroDelta && up_time > kOneHour)
+ next_reinit_delay_ = kZeroDelta;
+
+ reinit_timer_.Start(FROM_HERE, next_reinit_delay_,
+ this, &AppCacheServiceImpl::Reinitialize);
+
+ // Adjust the delay for next time.
+ base::TimeDelta increment = std::max(k30Seconds, next_reinit_delay_);
+ next_reinit_delay_ = std::min(next_reinit_delay_ + increment, kOneHour);
+}
+
+void AppCacheServiceImpl::Reinitialize() {
+ AppCacheHistograms::CountReinitAttempt(!last_reinit_time_.is_null());
+ last_reinit_time_ = base::Time::Now();
// Inform observers of about this and give them a chance to
// defer deletion of the old storage object.
@@ -492,7 +520,7 @@ void AppCacheService::Reinitialize() {
Initialize(cache_directory_, db_thread_, cache_thread_);
}
-void AppCacheService::CanHandleMainResourceOffline(
+void AppCacheServiceImpl::CanHandleMainResourceOffline(
const GURL& url,
const GURL& first_party,
const net::CompletionCallback& callback) {
@@ -501,7 +529,7 @@ void AppCacheService::CanHandleMainResourceOffline(
helper->Start();
}
-void AppCacheService::GetAllAppCacheInfo(
+void AppCacheServiceImpl::GetAllAppCacheInfo(
AppCacheInfoCollection* collection,
const net::CompletionCallback& callback) {
DCHECK(collection);
@@ -509,20 +537,20 @@ void AppCacheService::GetAllAppCacheInfo(
helper->Start();
}
-void AppCacheService::DeleteAppCacheGroup(
+void AppCacheServiceImpl::DeleteAppCacheGroup(
const GURL& manifest_url,
const net::CompletionCallback& callback) {
DeleteHelper* helper = new DeleteHelper(this, manifest_url, callback);
helper->Start();
}
-void AppCacheService::DeleteAppCachesForOrigin(
+void AppCacheServiceImpl::DeleteAppCachesForOrigin(
const GURL& origin, const net::CompletionCallback& callback) {
DeleteOriginHelper* helper = new DeleteOriginHelper(this, origin, callback);
helper->Start();
}
-void AppCacheService::CheckAppCacheResponse(const GURL& manifest_url,
+void AppCacheServiceImpl::CheckAppCacheResponse(const GURL& manifest_url,
int64 cache_id,
int64 response_id) {
CheckResponseHelper* helper = new CheckResponseHelper(
@@ -530,19 +558,19 @@ void AppCacheService::CheckAppCacheResponse(const GURL& manifest_url,
helper->Start();
}
-void AppCacheService::set_special_storage_policy(
+void AppCacheServiceImpl::set_special_storage_policy(
quota::SpecialStoragePolicy* policy) {
special_storage_policy_ = policy;
}
-void AppCacheService::RegisterBackend(
+void AppCacheServiceImpl::RegisterBackend(
AppCacheBackendImpl* backend_impl) {
DCHECK(backends_.find(backend_impl->process_id()) == backends_.end());
backends_.insert(
BackendMap::value_type(backend_impl->process_id(), backend_impl));
}
-void AppCacheService::UnregisterBackend(
+void AppCacheServiceImpl::UnregisterBackend(
AppCacheBackendImpl* backend_impl) {
backends_.erase(backend_impl->process_id());
}
diff --git a/chromium/webkit/browser/appcache/appcache_service_impl.h b/chromium/webkit/browser/appcache/appcache_service_impl.h
new file mode 100644
index 00000000000..12524ec6f6f
--- /dev/null
+++ b/chromium/webkit/browser/appcache/appcache_service_impl.h
@@ -0,0 +1,227 @@
+// 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 WEBKIT_BROWSER_APPCACHE_APPCACHE_SERVICE_IMPL_H_
+#define WEBKIT_BROWSER_APPCACHE_APPCACHE_SERVICE_IMPL_H_
+
+#include <map>
+#include <set>
+
+#include "base/gtest_prod_util.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/observer_list.h"
+#include "base/time/time.h"
+#include "base/timer/timer.h"
+#include "net/base/completion_callback.h"
+#include "net/base/net_errors.h"
+#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/quota/quota_manager_proxy.h"
+#include "webkit/browser/webkit_storage_browser_export.h"
+#include "webkit/common/appcache/appcache_interfaces.h"
+
+namespace net {
+class URLRequestContext;
+} // namespace net
+
+namespace base {
+class FilePath;
+class MessageLoopProxy;
+}
+
+namespace content {
+FORWARD_DECLARE_TEST(AppCacheServiceImplTest, ScheduleReinitialize);
+class AppCacheServiceImplTest;
+class AppCacheStorageImplTest;
+}
+
+namespace quota {
+class SpecialStoragePolicy;
+}
+
+namespace appcache {
+
+class AppCacheBackendImpl;
+class AppCacheExecutableHandlerFactory;
+class AppCacheQuotaClient;
+class AppCachePolicy;
+class AppCacheStorage;
+
+// Refcounted container to manage the lifetime of the old storage instance
+// during Reinitialization.
+class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheStorageReference
+ : public base::RefCounted<AppCacheStorageReference> {
+public:
+ AppCacheStorage* storage() const { return storage_.get(); }
+private:
+ friend class AppCacheServiceImpl;
+ friend class base::RefCounted<AppCacheStorageReference>;
+ AppCacheStorageReference(scoped_ptr<AppCacheStorage> storage);
+ ~AppCacheStorageReference();
+
+ scoped_ptr<AppCacheStorage> storage_;
+};
+
+// Class that manages the application cache service. Sends notifications
+// to many frontends. One instance per user-profile. Each instance has
+// exclusive access to its cache_directory on disk.
+class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheServiceImpl
+ : public AppCacheService {
+ public:
+
+ class WEBKIT_STORAGE_BROWSER_EXPORT Observer {
+ public:
+ // An observer method to inform consumers of reinitialzation. Managing
+ // the lifetime of the old storage instance is a delicate process.
+ // Consumers can keep the old disabled instance alive by hanging on to the
+ // ref provided.
+ virtual void OnServiceReinitialized(
+ AppCacheStorageReference* old_storage_ref) = 0;
+ virtual ~Observer() {}
+ };
+
+ // If not using quota management, the proxy may be NULL.
+ explicit AppCacheServiceImpl(quota::QuotaManagerProxy* quota_manager_proxy);
+ virtual ~AppCacheServiceImpl();
+
+ void Initialize(const base::FilePath& cache_directory,
+ base::MessageLoopProxy* db_thread,
+ base::MessageLoopProxy* cache_thread);
+
+ void AddObserver(Observer* observer) {
+ observers_.AddObserver(observer);
+ }
+
+ void RemoveObserver(Observer* observer) {
+ observers_.RemoveObserver(observer);
+ }
+
+ // For use in catastrophic failure modes to reboot the appcache system
+ // without relaunching the browser.
+ void ScheduleReinitialize();
+
+ // AppCacheService implementation:
+ virtual void CanHandleMainResourceOffline(
+ const GURL& url,
+ const GURL& first_party,
+ const net::CompletionCallback& callback) OVERRIDE;
+ virtual void GetAllAppCacheInfo(
+ AppCacheInfoCollection* collection,
+ const net::CompletionCallback& callback) OVERRIDE;
+ virtual void DeleteAppCacheGroup(
+ const GURL& manifest_url,
+ const net::CompletionCallback& callback) OVERRIDE;
+
+ // Deletes all appcaches for the origin, 'callback' is invoked upon
+ // completion. This method always completes asynchronously.
+ // (virtual for unit testing)
+ virtual void DeleteAppCachesForOrigin(
+ const GURL& origin, const net::CompletionCallback& callback);
+
+ // Checks the integrity of 'response_id' by reading the headers and data.
+ // If it cannot be read, the cache group for 'manifest_url' is deleted.
+ void CheckAppCacheResponse(const GURL& manifest_url, int64 cache_id,
+ int64 response_id);
+
+ // Context for use during cache updates, should only be accessed
+ // on the IO thread. We do NOT add a reference to the request context,
+ // it is the callers responsibility to ensure that the pointer
+ // remains valid while set.
+ net::URLRequestContext* request_context() const { return request_context_; }
+ void set_request_context(net::URLRequestContext* context) {
+ request_context_ = context;
+ }
+
+ // The appcache policy, may be null, in which case access is always allowed.
+ // The service does NOT assume ownership of the policy, it is the callers
+ // responsibility to ensure that the pointer remains valid while set.
+ AppCachePolicy* appcache_policy() const { return appcache_policy_; }
+ void set_appcache_policy(AppCachePolicy* policy) {
+ appcache_policy_ = policy;
+ }
+
+ // The factory may be null, in which case invocations of exe handlers
+ // will result in an error response.
+ // The service does NOT assume ownership of the factory, it is the callers
+ // responsibility to ensure that the pointer remains valid while set.
+ AppCacheExecutableHandlerFactory* handler_factory() const {
+ return handler_factory_;
+ }
+ void set_handler_factory(
+ AppCacheExecutableHandlerFactory* factory) {
+ handler_factory_ = factory;
+ }
+
+ quota::SpecialStoragePolicy* special_storage_policy() const {
+ return special_storage_policy_.get();
+ }
+ void set_special_storage_policy(quota::SpecialStoragePolicy* policy);
+
+ quota::QuotaManagerProxy* quota_manager_proxy() const {
+ return quota_manager_proxy_.get();
+ }
+
+ AppCacheQuotaClient* quota_client() const {
+ return quota_client_;
+ }
+
+ // Each child process in chrome uses a distinct backend instance.
+ // See chrome/browser/AppCacheDispatcherHost.
+ void RegisterBackend(AppCacheBackendImpl* backend_impl);
+ void UnregisterBackend(AppCacheBackendImpl* backend_impl);
+ AppCacheBackendImpl* GetBackend(int id) const {
+ BackendMap::const_iterator it = backends_.find(id);
+ return (it != backends_.end()) ? it->second : NULL;
+ }
+
+ AppCacheStorage* storage() const { return storage_.get(); }
+
+ // Disables the exit-time deletion of session-only data.
+ void set_force_keep_session_state() { force_keep_session_state_ = true; }
+ bool force_keep_session_state() const { return force_keep_session_state_; }
+
+ protected:
+ friend class content::AppCacheServiceImplTest;
+ friend class content::AppCacheStorageImplTest;
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheServiceImplTest,
+ ScheduleReinitialize);
+
+ class AsyncHelper;
+ class CanHandleOfflineHelper;
+ class DeleteHelper;
+ class DeleteOriginHelper;
+ class GetInfoHelper;
+ class CheckResponseHelper;
+
+ typedef std::set<AsyncHelper*> PendingAsyncHelpers;
+ typedef std::map<int, AppCacheBackendImpl*> BackendMap;
+
+ void Reinitialize();
+
+ base::FilePath cache_directory_;
+ scoped_refptr<base::MessageLoopProxy> db_thread_;
+ scoped_refptr<base::MessageLoopProxy> cache_thread_;
+ AppCachePolicy* appcache_policy_;
+ AppCacheQuotaClient* quota_client_;
+ AppCacheExecutableHandlerFactory* handler_factory_;
+ scoped_ptr<AppCacheStorage> storage_;
+ scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
+ scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_;
+ PendingAsyncHelpers pending_helpers_;
+ BackendMap backends_; // One 'backend' per child process.
+ // Context for use during cache updates.
+ net::URLRequestContext* request_context_;
+ // If true, nothing (not even session-only data) should be deleted on exit.
+ bool force_keep_session_state_;
+ base::Time last_reinit_time_;
+ base::TimeDelta next_reinit_delay_;
+ base::OneShotTimer<AppCacheServiceImpl> reinit_timer_;
+ ObserverList<Observer> observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppCacheServiceImpl);
+};
+
+} // namespace appcache
+
+#endif // WEBKIT_BROWSER_APPCACHE_APPCACHE_SERVICE_IMPL_H_
diff --git a/chromium/webkit/browser/appcache/appcache_service_unittest.cc b/chromium/webkit/browser/appcache/appcache_service_unittest.cc
deleted file mode 100644
index 75817930630..00000000000
--- a/chromium/webkit/browser/appcache/appcache_service_unittest.cc
+++ /dev/null
@@ -1,320 +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 <string>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/pickle.h"
-#include "base/run_loop.h"
-#include "net/base/completion_callback.h"
-#include "net/base/io_buffer.h"
-#include "net/http/http_response_headers.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/appcache_service.h"
-#include "webkit/browser/appcache/mock_appcache_storage.h"
-
-
-namespace appcache {
-namespace {
-
-const int64 kMockGroupId = 1;
-const int64 kMockCacheId = 1;
-const int64 kMockResponseId = 1;
-const int64 kMissingCacheId = 5;
-const int64 kMissingResponseId = 5;
-const char kMockHeaders[] =
- "HTTP/1.0 200 OK\0Content-Length: 5\0\0";
-const char kMockBody[] = "Hello";
-const int kMockBodySize = 5;
-
-class MockResponseReader : public AppCacheResponseReader {
- public:
- MockResponseReader(int64 response_id,
- net::HttpResponseInfo* info, int info_size,
- const char* data, int data_size)
- : AppCacheResponseReader(response_id, 0, NULL),
- info_(info), info_size_(info_size),
- data_(data), data_size_(data_size) {
- }
- virtual void ReadInfo(HttpResponseInfoIOBuffer* info_buf,
- const net::CompletionCallback& callback) OVERRIDE {
- info_buffer_ = info_buf;
- callback_ = callback; // Cleared on completion.
-
- int rv = info_.get() ? info_size_ : net::ERR_FAILED;
- info_buffer_->http_info.reset(info_.release());
- info_buffer_->response_data_size = data_size_;
- ScheduleUserCallback(rv);
- }
- virtual void ReadData(net::IOBuffer* buf, int buf_len,
- const net::CompletionCallback& callback) OVERRIDE {
- buffer_ = buf;
- buffer_len_ = buf_len;
- callback_ = callback; // Cleared on completion.
-
- if (!data_) {
- ScheduleUserCallback(net::ERR_CACHE_READ_FAILURE);
- return;
- }
- DCHECK(buf_len >= data_size_);
- memcpy(buf->data(), data_, data_size_);
- ScheduleUserCallback(data_size_);
- data_size_ = 0;
- }
-
- private:
- void ScheduleUserCallback(int result) {
- base::MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(&MockResponseReader::InvokeUserCompletionCallback,
- weak_factory_.GetWeakPtr(), result));
- }
-
- scoped_ptr<net::HttpResponseInfo> info_;
- int info_size_;
- const char* data_;
- int data_size_;
-};
-
-} // namespace
-
-
-class AppCacheServiceTest : public testing::Test {
- public:
- AppCacheServiceTest()
- : kOrigin("http://hello/"),
- kManifestUrl(kOrigin.Resolve("manifest")),
- service_(new AppCacheService(NULL)),
- delete_result_(net::OK), delete_completion_count_(0),
- deletion_callback_(
- base::Bind(&AppCacheServiceTest::OnDeleteAppCachesComplete,
- base::Unretained(this))) {
- // Setup to use mock storage.
- service_->storage_.reset(new MockAppCacheStorage(service_.get()));
- }
-
- void OnDeleteAppCachesComplete(int result) {
- delete_result_ = result;
- ++delete_completion_count_;
- }
-
- MockAppCacheStorage* mock_storage() {
- return static_cast<MockAppCacheStorage*>(service_->storage());
- }
-
- void ResetStorage() {
- service_->storage_.reset(new MockAppCacheStorage(service_.get()));
- }
-
- bool IsGroupStored(const GURL& manifest_url) {
- return mock_storage()->IsGroupForManifestStored(manifest_url);
- }
-
- int CountPendingHelpers() {
- return service_->pending_helpers_.size();
- }
-
- void SetupMockGroup() {
- scoped_ptr<net::HttpResponseInfo> info(MakeMockResponseInfo());
- const int kMockInfoSize = GetResponseInfoSize(info.get());
-
- // Create a mock group, cache, and entry and stuff them into mock storage.
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service_->storage(), kManifestUrl, kMockGroupId));
- scoped_refptr<AppCache> cache(
- new AppCache(service_->storage(), kMockCacheId));
- cache->AddEntry(
- kManifestUrl,
- AppCacheEntry(AppCacheEntry::MANIFEST, kMockResponseId,
- kMockInfoSize + kMockBodySize));
- cache->set_complete(true);
- group->AddCache(cache.get());
- mock_storage()->AddStoredGroup(group.get());
- mock_storage()->AddStoredCache(cache.get());
- }
-
- void SetupMockReader(
- bool valid_info, bool valid_data, bool valid_size) {
- net::HttpResponseInfo* info = valid_info ? MakeMockResponseInfo() : NULL;
- int info_size = info ? GetResponseInfoSize(info) : 0;
- const char* data = valid_data ? kMockBody : NULL;
- int data_size = valid_size ? kMockBodySize : 3;
- mock_storage()->SimulateResponseReader(
- new MockResponseReader(kMockResponseId, info, info_size,
- data, data_size));
- }
-
- net::HttpResponseInfo* MakeMockResponseInfo() {
- net::HttpResponseInfo* info = new net::HttpResponseInfo;
- info->request_time = base::Time::Now();
- info->response_time = base::Time::Now();
- info->was_cached = false;
- info->headers = new net::HttpResponseHeaders(
- std::string(kMockHeaders, arraysize(kMockHeaders)));
- return info;
- }
-
- int GetResponseInfoSize(const net::HttpResponseInfo* info) {
- Pickle pickle;
- return PickleResponseInfo(&pickle, info);
- }
-
- int PickleResponseInfo(Pickle* pickle, const net::HttpResponseInfo* info) {
- const bool kSkipTransientHeaders = true;
- const bool kTruncated = false;
- info->Persist(pickle, kSkipTransientHeaders, kTruncated);
- return pickle->size();
- }
-
- const GURL kOrigin;
- const GURL kManifestUrl;
-
- scoped_ptr<AppCacheService> service_;
- int delete_result_;
- int delete_completion_count_;
- net::CompletionCallback deletion_callback_;
-
- private:
- base::MessageLoop message_loop_;
-};
-
-TEST_F(AppCacheServiceTest, DeleteAppCachesForOrigin) {
- // Without giving mock storage simiulated info, should fail.
- service_->DeleteAppCachesForOrigin(kOrigin, deletion_callback_);
- EXPECT_EQ(0, delete_completion_count_);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(1, delete_completion_count_);
- EXPECT_EQ(net::ERR_FAILED, delete_result_);
- delete_completion_count_ = 0;
-
- // Should succeed given an empty info collection.
- mock_storage()->SimulateGetAllInfo(new AppCacheInfoCollection);
- service_->DeleteAppCachesForOrigin(kOrigin, deletion_callback_);
- EXPECT_EQ(0, delete_completion_count_);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(1, delete_completion_count_);
- EXPECT_EQ(net::OK, delete_result_);
- delete_completion_count_ = 0;
-
- scoped_refptr<AppCacheInfoCollection> info(new AppCacheInfoCollection);
-
- // Should succeed given a non-empty info collection.
- AppCacheInfo mock_manifest_1;
- AppCacheInfo mock_manifest_2;
- AppCacheInfo mock_manifest_3;
- mock_manifest_1.manifest_url = kOrigin.Resolve("manifest1");
- mock_manifest_2.manifest_url = kOrigin.Resolve("manifest2");
- mock_manifest_3.manifest_url = kOrigin.Resolve("manifest3");
- AppCacheInfoVector info_vector;
- info_vector.push_back(mock_manifest_1);
- info_vector.push_back(mock_manifest_2);
- info_vector.push_back(mock_manifest_3);
- info->infos_by_origin[kOrigin] = info_vector;
- mock_storage()->SimulateGetAllInfo(info.get());
- service_->DeleteAppCachesForOrigin(kOrigin, deletion_callback_);
- EXPECT_EQ(0, delete_completion_count_);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(1, delete_completion_count_);
- EXPECT_EQ(net::OK, delete_result_);
- delete_completion_count_ = 0;
-
- // Should fail if storage fails to delete.
- info->infos_by_origin[kOrigin] = info_vector;
- mock_storage()->SimulateGetAllInfo(info.get());
- mock_storage()->SimulateMakeGroupObsoleteFailure();
- service_->DeleteAppCachesForOrigin(kOrigin, deletion_callback_);
- EXPECT_EQ(0, delete_completion_count_);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(1, delete_completion_count_);
- EXPECT_EQ(net::ERR_FAILED, delete_result_);
- delete_completion_count_ = 0;
-
- // Should complete with abort error if the service is deleted
- // prior to a delete completion.
- service_->DeleteAppCachesForOrigin(kOrigin, deletion_callback_);
- EXPECT_EQ(0, delete_completion_count_);
- service_.reset(); // kill it
- EXPECT_EQ(1, delete_completion_count_);
- EXPECT_EQ(net::ERR_ABORTED, delete_result_);
- delete_completion_count_ = 0;
-
- // Let any tasks lingering from the sudden deletion run and verify
- // no other completion calls occur.
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, delete_completion_count_);
-}
-
-TEST_F(AppCacheServiceTest, CheckAppCacheResponse) {
- // Check a non-existing manifest.
- EXPECT_FALSE(IsGroupStored(kManifestUrl));
- service_->CheckAppCacheResponse(kManifestUrl, 1, 1);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, CountPendingHelpers());
- EXPECT_FALSE(IsGroupStored(kManifestUrl));
- ResetStorage();
-
- // Check a response that looks good.
- // Nothing should be deleted.
- SetupMockGroup();
- EXPECT_TRUE(IsGroupStored(kManifestUrl));
- SetupMockReader(true, true, true);
- service_->CheckAppCacheResponse(kManifestUrl, kMockCacheId, kMockResponseId);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, CountPendingHelpers());
- EXPECT_TRUE(IsGroupStored(kManifestUrl));
- ResetStorage();
-
- // Check a response for which there is no cache entry.
- // The group should get deleted.
- SetupMockGroup();
- service_->CheckAppCacheResponse(kManifestUrl, kMockCacheId,
- kMissingResponseId);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, CountPendingHelpers());
- EXPECT_FALSE(IsGroupStored(kManifestUrl));
- ResetStorage();
-
- // Check a response for which there is no manifest entry in a newer version
- // of the cache. Nothing should get deleted in this case.
- SetupMockGroup();
- service_->CheckAppCacheResponse(kManifestUrl, kMissingCacheId,
- kMissingResponseId);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, CountPendingHelpers());
- EXPECT_TRUE(IsGroupStored(kManifestUrl));
- ResetStorage();
-
- // Check a response with bad headers.
- SetupMockGroup();
- service_->CheckAppCacheResponse(kManifestUrl, kMockCacheId, kMockResponseId);
- SetupMockReader(false, true, true);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, CountPendingHelpers());
- EXPECT_FALSE(IsGroupStored(kManifestUrl));
- ResetStorage();
-
- // Check a response with bad data.
- SetupMockGroup();
- service_->CheckAppCacheResponse(kManifestUrl, kMockCacheId, kMockResponseId);
- SetupMockReader(true, false, true);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, CountPendingHelpers());
- EXPECT_FALSE(IsGroupStored(kManifestUrl));
- ResetStorage();
-
- // Check a response with truncated data.
- SetupMockGroup();
- service_->CheckAppCacheResponse(kManifestUrl, kMockCacheId, kMockResponseId);
- SetupMockReader(true, true, false);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, CountPendingHelpers());
- EXPECT_FALSE(IsGroupStored(kManifestUrl));
- ResetStorage();
-
- service_.reset(); // Clean up.
- base::RunLoop().RunUntilIdle();
-}
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/appcache_storage.cc b/chromium/webkit/browser/appcache/appcache_storage.cc
index 2482cfa45c7..ce4f01e1a36 100644
--- a/chromium/webkit/browser/appcache/appcache_storage.cc
+++ b/chromium/webkit/browser/appcache/appcache_storage.cc
@@ -8,16 +8,16 @@
#include "base/bind_helpers.h"
#include "base/stl_util.h"
#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include "webkit/browser/quota/quota_client.h"
-#include "webkit/browser/quota/quota_manager.h"
+#include "webkit/browser/quota/quota_manager_proxy.h"
namespace appcache {
// static
const int64 AppCacheStorage::kUnitializedId = -1;
-AppCacheStorage::AppCacheStorage(AppCacheService* service)
+AppCacheStorage::AppCacheStorage(AppCacheServiceImpl* service)
: last_cache_id_(kUnitializedId), last_group_id_(kUnitializedId),
last_response_id_(kUnitializedId), service_(service) {
}
diff --git a/chromium/webkit/browser/appcache/appcache_storage.h b/chromium/webkit/browser/appcache/appcache_storage.h
index 5917a418e24..41bbd552bfc 100644
--- a/chromium/webkit/browser/appcache/appcache_storage.h
+++ b/chromium/webkit/browser/appcache/appcache_storage.h
@@ -19,6 +19,14 @@
class GURL;
+namespace content {
+FORWARD_DECLARE_TEST(AppCacheStorageTest, DelegateReferences);
+FORWARD_DECLARE_TEST(AppCacheStorageTest, UsageMap);
+class AppCacheQuotaClientTest;
+class AppCacheResponseTest;
+class AppCacheStorageTest;
+}
+
namespace appcache {
class AppCache;
@@ -26,7 +34,7 @@ class AppCacheEntry;
class AppCacheGroup;
class AppCacheResponseReader;
class AppCacheResponseWriter;
-class AppCacheService;
+class AppCacheServiceImpl;
struct AppCacheInfoCollection;
struct HttpResponseInfoIOBuffer;
@@ -52,14 +60,16 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheStorage {
bool would_exceed_quota) {}
// If the operation fails, success will be false.
- virtual void OnGroupMadeObsolete(AppCacheGroup* group, bool success) {}
+ virtual void OnGroupMadeObsolete(AppCacheGroup* group,
+ bool success,
+ int response_code) {}
// If a load fails the 'response_info' will be NULL.
virtual void OnResponseInfoLoaded(
AppCacheResponseInfo* response_info, int64 response_id) {}
// If no response is found, entry.response_id() and
- // fallback_entry.response_id() will be kNoResponseId.
+ // fallback_entry.response_id() will be kAppCacheNoResponseId.
// If the response is the entry for an intercept or fallback
// namespace, the url of the namespece entry is returned.
// If a response is found, the cache id and manifest url of the
@@ -73,7 +83,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheStorage {
virtual ~Delegate() {}
};
- explicit AppCacheStorage(AppCacheService* service);
+ explicit AppCacheStorage(AppCacheServiceImpl* service);
virtual ~AppCacheStorage();
// Schedules a task to retrieve basic info about all groups and caches
@@ -140,8 +150,9 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheStorage {
// Schedules a task to update persistent storage and doom the group and all
// related caches and responses for deletion. Upon completion the in-memory
// instance is marked as obsolete and the delegate callback is called.
- virtual void MakeGroupObsolete(
- AppCacheGroup* group, Delegate* delegate) = 0;
+ virtual void MakeGroupObsolete(AppCacheGroup* group,
+ Delegate* delegate,
+ int response_code) = 0;
// Cancels all pending callbacks for the delegate. The delegate callbacks
// will not be invoked after, however any scheduled operations will still
@@ -173,8 +184,6 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheStorage {
virtual void DeleteResponses(
const GURL& manifest_url, const std::vector<int64>& response_ids) = 0;
- virtual void PurgeMemory() = 0;
-
// Generates unique storage ids for different object types.
int64 NewCacheId() {
return ++last_cache_id_;
@@ -190,12 +199,12 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheStorage {
const UsageMap* usage_map() { return &usage_map_; }
// Simple ptr back to the service object that owns us.
- AppCacheService* service() { return service_; }
+ AppCacheServiceImpl* service() { return service_; }
protected:
- friend class AppCacheQuotaClientTest;
- friend class AppCacheResponseTest;
- friend class AppCacheStorageTest;
+ friend class content::AppCacheQuotaClientTest;
+ friend class content::AppCacheResponseTest;
+ friend class content::AppCacheStorageTest;
// Helper to call a collection of delegates.
#define FOR_EACH_DELEGATE(delegates, func_and_args) \
@@ -303,15 +312,15 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheStorage {
UsageMap usage_map_; // maps origin to usage
AppCacheWorkingSet working_set_;
- AppCacheService* service_;
+ AppCacheServiceImpl* service_;
DelegateReferenceMap delegate_references_;
PendingResponseInfoLoads pending_info_loads_;
// The set of last ids must be retrieved from storage prior to being used.
static const int64 kUnitializedId;
- FRIEND_TEST_ALL_PREFIXES(AppCacheStorageTest, DelegateReferences);
- FRIEND_TEST_ALL_PREFIXES(AppCacheStorageTest, UsageMap);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheStorageTest, DelegateReferences);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheStorageTest, UsageMap);
DISALLOW_COPY_AND_ASSIGN(AppCacheStorage);
};
diff --git a/chromium/webkit/browser/appcache/appcache_storage_impl.cc b/chromium/webkit/browser/appcache/appcache_storage_impl.cc
index f762a1647b7..62563d7ff1b 100644
--- a/chromium/webkit/browser/appcache/appcache_storage_impl.cc
+++ b/chromium/webkit/browser/appcache/appcache_storage_impl.cc
@@ -27,9 +27,10 @@
#include "webkit/browser/appcache/appcache_histograms.h"
#include "webkit/browser/appcache/appcache_quota_client.h"
#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include "webkit/browser/quota/quota_client.h"
#include "webkit/browser/quota/quota_manager.h"
+#include "webkit/browser/quota/quota_manager_proxy.h"
#include "webkit/browser/quota/special_storage_policy.h"
namespace appcache {
@@ -173,7 +174,7 @@ class AppCacheStorageImpl::DatabaseTask
private:
void CallRun(base::TimeTicks schedule_time);
void CallRunCompleted(base::TimeTicks schedule_time);
- void CallDisableStorage();
+ void OnFatalError();
scoped_refptr<base::MessageLoopProxy> io_thread_;
};
@@ -208,10 +209,15 @@ void AppCacheStorageImpl::DatabaseTask::CallRun(
Run();
AppCacheHistograms::AddTaskRunTimeSample(
base::TimeTicks::Now() - run_time);
+
+ if (database_->was_corruption_detected()) {
+ AppCacheHistograms::CountCorruptionDetected();
+ database_->Disable();
+ }
if (database_->is_disabled()) {
io_thread_->PostTask(
FROM_HERE,
- base::Bind(&DatabaseTask::CallDisableStorage, this));
+ base::Bind(&DatabaseTask::OnFatalError, this));
}
}
io_thread_->PostTask(
@@ -236,10 +242,11 @@ void AppCacheStorageImpl::DatabaseTask::CallRunCompleted(
}
}
-void AppCacheStorageImpl::DatabaseTask::CallDisableStorage() {
+void AppCacheStorageImpl::DatabaseTask::OnFatalError() {
if (storage_) {
DCHECK(io_thread_->BelongsToCurrentThread());
storage_->Disable();
+ storage_->DeleteAndStartOver();
}
}
@@ -250,7 +257,14 @@ class AppCacheStorageImpl::InitTask : public DatabaseTask {
explicit InitTask(AppCacheStorageImpl* storage)
: DatabaseTask(storage), last_group_id_(0),
last_cache_id_(0), last_response_id_(0),
- last_deletable_response_rowid_(0) {}
+ last_deletable_response_rowid_(0) {
+ if (!storage->is_incognito_) {
+ db_file_path_ =
+ storage->cache_directory_.Append(kAppCacheDatabaseName);
+ disk_cache_directory_ =
+ storage->cache_directory_.Append(kDiskCacheDirectoryName);
+ }
+ }
// DatabaseTask:
virtual void Run() OVERRIDE;
@@ -260,6 +274,8 @@ class AppCacheStorageImpl::InitTask : public DatabaseTask {
virtual ~InitTask() {}
private:
+ base::FilePath db_file_path_;
+ base::FilePath disk_cache_directory_;
int64 last_group_id_;
int64 last_cache_id_;
int64 last_response_id_;
@@ -268,6 +284,17 @@ class AppCacheStorageImpl::InitTask : public DatabaseTask {
};
void AppCacheStorageImpl::InitTask::Run() {
+ // If there is no sql database, ensure there is no disk cache either.
+ if (!db_file_path_.empty() &&
+ !base::PathExists(db_file_path_) &&
+ base::DirectoryExists(disk_cache_directory_)) {
+ base::DeleteFile(disk_cache_directory_, true);
+ if (base::DirectoryExists(disk_cache_directory_)) {
+ database_->Disable(); // This triggers OnFatalError handling.
+ return;
+ }
+ }
+
database_->FindLastStorageIds(
&last_group_id_, &last_cache_id_, &last_response_id_,
&last_deletable_response_rowid_);
@@ -294,20 +321,6 @@ void AppCacheStorageImpl::InitTask::RunCompleted() {
storage_->service()->quota_client()->NotifyAppCacheReady();
}
-// CloseConnectionTask -------
-
-class AppCacheStorageImpl::CloseConnectionTask : public DatabaseTask {
- public:
- explicit CloseConnectionTask(AppCacheStorageImpl* storage)
- : DatabaseTask(storage) {}
-
- // DatabaseTask:
- virtual void Run() OVERRIDE { database_->CloseConnection(); }
-
- protected:
- virtual ~CloseConnectionTask() {}
-};
-
// DisableDatabaseTask -------
class AppCacheStorageImpl::DisableDatabaseTask : public DatabaseTask {
@@ -846,7 +859,7 @@ class NetworkNamespaceHelper {
WhiteListVector::const_iterator iter = records.begin();
while (iter != records.end()) {
namespaces->push_back(
- Namespace(NETWORK_NAMESPACE, iter->namespace_url, GURL(),
+ Namespace(APPCACHE_NETWORK_NAMESPACE, iter->namespace_url, GURL(),
iter->is_pattern));
++iter;
}
@@ -868,7 +881,7 @@ class AppCacheStorageImpl::FindMainResponseTask : public DatabaseTask {
const AppCacheWorkingSet::GroupMap* groups_in_use)
: DatabaseTask(storage), url_(url),
preferred_manifest_url_(preferred_manifest_url),
- cache_id_(kNoCacheId), group_id_(0) {
+ cache_id_(kAppCacheNoCacheId), group_id_(0) {
if (groups_in_use) {
for (AppCacheWorkingSet::GroupMap::const_iterator it =
groups_in_use->begin();
@@ -912,8 +925,6 @@ class AppCacheStorageImpl::FindMainResponseTask : public DatabaseTask {
GURL manifest_url_;
};
-
-
void AppCacheStorageImpl::FindMainResponseTask::Run() {
// NOTE: The heuristics around choosing amoungst multiple candidates
// is underspecified, and just plain not fully understood. This needs
@@ -927,7 +938,7 @@ void AppCacheStorageImpl::FindMainResponseTask::Run() {
// TODO(michaeln): come up with a 'preferred_manifest_url' in more cases
// - when navigating a frame whose current contents are from an appcache
// - when clicking an href in a frame that is appcached
- int64 preferred_cache_id = kNoCacheId;
+ int64 preferred_cache_id = kAppCacheNoCacheId;
if (!preferred_manifest_url_.is_empty()) {
AppCacheDatabase::GroupRecord preferred_group;
AppCacheDatabase::CacheRecord preferred_cache;
@@ -942,13 +953,13 @@ void AppCacheStorageImpl::FindMainResponseTask::Run() {
if (FindExactMatch(preferred_cache_id) ||
FindNamespaceMatch(preferred_cache_id)) {
// We found something.
- DCHECK(cache_id_ != kNoCacheId && !manifest_url_.is_empty() &&
+ DCHECK(cache_id_ != kAppCacheNoCacheId && !manifest_url_.is_empty() &&
group_id_ != 0);
return;
}
// We didn't find anything.
- DCHECK(cache_id_ == kNoCacheId && manifest_url_.is_empty() &&
+ DCHECK(cache_id_ == kAppCacheNoCacheId && manifest_url_.is_empty() &&
group_id_ == 0);
}
@@ -1060,7 +1071,7 @@ FindMainResponseTask::FindFirstValidNamespace(
group_id_ = group_record.group_id;
cache_id_ = (*iter)->cache_id;
namespace_entry_url_ = (*iter)->namespace_.target_url;
- if ((*iter)->namespace_.type == FALLBACK_NAMESPACE)
+ if ((*iter)->namespace_.type == APPCACHE_FALLBACK_NAMESPACE)
fallback_entry_ = AppCacheEntry(entry_record.flags,
entry_record.response_id);
else
@@ -1111,7 +1122,9 @@ void AppCacheStorageImpl::MarkEntryAsForeignTask::RunCompleted() {
class AppCacheStorageImpl::MakeGroupObsoleteTask : public DatabaseTask {
public:
- MakeGroupObsoleteTask(AppCacheStorageImpl* storage, AppCacheGroup* group);
+ MakeGroupObsoleteTask(AppCacheStorageImpl* storage,
+ AppCacheGroup* group,
+ int response_code);
// DatabaseTask:
virtual void Run() OVERRIDE;
@@ -1126,16 +1139,22 @@ class AppCacheStorageImpl::MakeGroupObsoleteTask : public DatabaseTask {
int64 group_id_;
GURL origin_;
bool success_;
+ int response_code_;
int64 new_origin_usage_;
std::vector<int64> newly_deletable_response_ids_;
};
AppCacheStorageImpl::MakeGroupObsoleteTask::MakeGroupObsoleteTask(
- AppCacheStorageImpl* storage, AppCacheGroup* group)
- : DatabaseTask(storage), group_(group), group_id_(group->group_id()),
+ AppCacheStorageImpl* storage,
+ AppCacheGroup* group,
+ int response_code)
+ : DatabaseTask(storage),
+ group_(group),
+ group_id_(group->group_id()),
origin_(group->manifest_url().GetOrigin()),
- success_(false), new_origin_usage_(-1) {
-}
+ success_(false),
+ response_code_(response_code),
+ new_origin_usage_(-1) {}
void AppCacheStorageImpl::MakeGroupObsoleteTask::Run() {
DCHECK(!success_);
@@ -1177,7 +1196,8 @@ void AppCacheStorageImpl::MakeGroupObsoleteTask::RunCompleted() {
storage_->working_set()->RemoveGroup(group_.get());
}
}
- FOR_EACH_DELEGATE(delegates_, OnGroupMadeObsolete(group_.get(), success_));
+ FOR_EACH_DELEGATE(
+ delegates_, OnGroupMadeObsolete(group_.get(), success_, response_code_));
group_ = NULL;
}
@@ -1291,7 +1311,7 @@ void AppCacheStorageImpl::UpdateGroupLastAccessTimeTask::Run() {
// AppCacheStorageImpl ---------------------------------------------------
-AppCacheStorageImpl::AppCacheStorageImpl(AppCacheService* service)
+AppCacheStorageImpl::AppCacheStorageImpl(AppCacheServiceImpl* service)
: AppCacheStorage(service),
is_incognito_(false),
is_response_deletion_scheduled_(false),
@@ -1539,8 +1559,8 @@ void AppCacheStorageImpl::DeliverShortCircuitedFindMainResponse(
CallOnMainResponseFound(
&delegates, url, found_entry,
GURL(), AppCacheEntry(),
- cache.get() ? cache->cache_id() : kNoCacheId,
- group.get() ? group->group_id() : kNoCacheId,
+ cache.get() ? cache->cache_id() : kAppCacheNoCacheId,
+ group.get() ? group->group_id() : kAppCacheNoCacheId,
group.get() ? group->manifest_url() : GURL());
}
}
@@ -1596,11 +1616,12 @@ void AppCacheStorageImpl::MarkEntryAsForeign(
pending_foreign_markings_.push_back(std::make_pair(entry_url, cache_id));
}
-void AppCacheStorageImpl::MakeGroupObsolete(
- AppCacheGroup* group, Delegate* delegate) {
+void AppCacheStorageImpl::MakeGroupObsolete(AppCacheGroup* group,
+ Delegate* delegate,
+ int response_code) {
DCHECK(group && delegate);
scoped_refptr<MakeGroupObsoleteTask> task(
- new MakeGroupObsoleteTask(this, group));
+ new MakeGroupObsoleteTask(this, group, response_code));
task->AddDelegate(GetOrCreateDelegateReference(delegate));
task->Schedule();
}
@@ -1641,11 +1662,6 @@ void AppCacheStorageImpl::DeleteResponses(
StartDeletingResponses(response_ids);
}
-void AppCacheStorageImpl::PurgeMemory() {
- scoped_refptr<CloseConnectionTask> task(new CloseConnectionTask(this));
- task->Schedule();
-}
-
void AppCacheStorageImpl::DelayedStartDeletingUnusedResponses() {
// Only if we haven't already begun.
if (!did_start_deleting_responses_) {
@@ -1792,9 +1808,6 @@ AppCacheDiskCache* AppCacheStorageImpl::disk_cache() {
base::Unretained(this)));
}
- // We should not keep this reference around.
- cache_thread_ = NULL;
-
if (rv != net::ERR_IO_PENDING)
OnDiskCacheInitialized(rv);
}
@@ -1810,21 +1823,38 @@ void AppCacheStorageImpl::OnDiskCacheInitialized(int rv) {
// really recover from. We handle it by temporarily disabling the appcache
// deleting the directory on disk and reinitializing the appcache system.
Disable();
- if (!is_incognito_ && rv != net::ERR_ABORTED) {
- VLOG(1) << "Deleting existing appcache data and starting over.";
- db_thread_->PostTaskAndReply(
- FROM_HERE,
- base::Bind(base::IgnoreResult(&base::DeleteFile),
- cache_directory_, true),
- base::Bind(&AppCacheStorageImpl::CallReinitialize,
- weak_factory_.GetWeakPtr()));
- }
+ if (rv != net::ERR_ABORTED)
+ DeleteAndStartOver();
+ }
+}
+
+void AppCacheStorageImpl::DeleteAndStartOver() {
+ DCHECK(is_disabled_);
+ if (!is_incognito_) {
+ VLOG(1) << "Deleting existing appcache data and starting over.";
+ // We can have tasks in flight to close file handles on both the db
+ // and cache threads, we need to allow those tasks to cycle thru
+ // prior to deleting the files and calling reinit.
+ cache_thread_->PostTaskAndReply(
+ FROM_HERE,
+ base::Bind(&base::DoNothing),
+ base::Bind(&AppCacheStorageImpl::DeleteAndStartOverPart2,
+ weak_factory_.GetWeakPtr()));
}
}
-void AppCacheStorageImpl::CallReinitialize() {
- service_->Reinitialize();
- // note: 'this' may be deleted during reinit.
+void AppCacheStorageImpl::DeleteAndStartOverPart2() {
+ db_thread_->PostTaskAndReply(
+ FROM_HERE,
+ base::Bind(base::IgnoreResult(&base::DeleteFile),
+ cache_directory_, true),
+ base::Bind(&AppCacheStorageImpl::CallScheduleReinitialize,
+ weak_factory_.GetWeakPtr()));
+}
+
+void AppCacheStorageImpl::CallScheduleReinitialize() {
+ service_->ScheduleReinitialize();
+ // note: 'this' may be deleted at this point.
}
} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/appcache_storage_impl.h b/chromium/webkit/browser/appcache/appcache_storage_impl.h
index 163001d5283..a5103a63619 100644
--- a/chromium/webkit/browser/appcache/appcache_storage_impl.h
+++ b/chromium/webkit/browser/appcache/appcache_storage_impl.h
@@ -21,6 +21,7 @@
#include "webkit/browser/webkit_storage_browser_export.h"
namespace content {
+class AppCacheStorageImplTest;
class ChromeAppCacheServiceTest;
}
@@ -28,7 +29,7 @@ namespace appcache {
class AppCacheStorageImpl : public AppCacheStorage {
public:
- explicit AppCacheStorageImpl(AppCacheService* service);
+ explicit AppCacheStorageImpl(AppCacheServiceImpl* service);
virtual ~AppCacheStorageImpl();
void Initialize(const base::FilePath& cache_directory,
@@ -55,7 +56,8 @@ class AppCacheStorageImpl : public AppCacheStorage {
virtual void MarkEntryAsForeign(const GURL& entry_url,
int64 cache_id) OVERRIDE;
virtual void MakeGroupObsolete(AppCacheGroup* group,
- Delegate* delegate) OVERRIDE;
+ Delegate* delegate,
+ int response_code) OVERRIDE;
virtual AppCacheResponseReader* CreateResponseReader(
const GURL& manifest_url, int64 group_id, int64 response_id) OVERRIDE;
virtual AppCacheResponseWriter* CreateResponseWriter(
@@ -64,17 +66,13 @@ class AppCacheStorageImpl : public AppCacheStorage {
const std::vector<int64>& response_ids) OVERRIDE;
virtual void DeleteResponses(const GURL& manifest_url,
const std::vector<int64>& response_ids) OVERRIDE;
- virtual void PurgeMemory() OVERRIDE;
private:
- friend class AppCacheStorageImplTest;
-
// The AppCacheStorageImpl class methods and datamembers may only be
// accessed on the IO thread. This class manufactures seperate DatabaseTasks
// which access the DB on a seperate background thread.
class DatabaseTask;
class InitTask;
- class CloseConnectionTask;
class DisableDatabaseTask;
class GetAllInfoTask;
class StoreOrLoadTask;
@@ -114,7 +112,9 @@ class AppCacheStorageImpl : public AppCacheStorage {
void OnDeletedOneResponse(int rv);
void OnDiskCacheInitialized(int rv);
- void CallReinitialize();
+ void DeleteAndStartOver();
+ void DeleteAndStartOverPart2();
+ void CallScheduleReinitialize();
// Sometimes we can respond without having to query the database.
bool FindResponseForMainRequestInGroup(
@@ -172,6 +172,7 @@ class AppCacheStorageImpl : public AppCacheStorage {
std::deque<base::Closure> pending_simple_tasks_;
base::WeakPtrFactory<AppCacheStorageImpl> weak_factory_;
+ friend class content::AppCacheStorageImplTest;
friend class content::ChromeAppCacheServiceTest;
};
diff --git a/chromium/webkit/browser/appcache/appcache_storage_impl_unittest.cc b/chromium/webkit/browser/appcache/appcache_storage_impl_unittest.cc
deleted file mode 100644
index d2ae51d0a37..00000000000
--- a/chromium/webkit/browser/appcache/appcache_storage_impl_unittest.cc
+++ /dev/null
@@ -1,1968 +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 <stack>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/callback.h"
-#include "base/file_util.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "base/synchronization/waitable_event.h"
-#include "base/threading/thread.h"
-#include "net/base/net_errors.h"
-#include "net/base/request_priority.h"
-#include "net/http/http_response_headers.h"
-#include "net/url_request/url_request_error_job.h"
-#include "net/url_request/url_request_job_factory_impl.h"
-#include "net/url_request/url_request_test_job.h"
-#include "net/url_request/url_request_test_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/appcache/appcache.h"
-#include "webkit/browser/appcache/appcache_backend_impl.h"
-#include "webkit/browser/appcache/appcache_database.h"
-#include "webkit/browser/appcache/appcache_entry.h"
-#include "webkit/browser/appcache/appcache_group.h"
-#include "webkit/browser/appcache/appcache_host.h"
-#include "webkit/browser/appcache/appcache_interceptor.h"
-#include "webkit/browser/appcache/appcache_request_handler.h"
-#include "webkit/browser/appcache/appcache_service.h"
-#include "webkit/browser/appcache/appcache_storage_impl.h"
-#include "webkit/browser/quota/quota_manager.h"
-
-namespace appcache {
-
-namespace {
-
-const base::Time kZeroTime;
-const GURL kManifestUrl("http://blah/manifest");
-const GURL kManifestUrl2("http://blah/manifest2");
-const GURL kManifestUrl3("http://blah/manifest3");
-const GURL kEntryUrl("http://blah/entry");
-const GURL kEntryUrl2("http://blah/entry2");
-const GURL kFallbackNamespace("http://blah/fallback_namespace/");
-const GURL kFallbackNamespace2("http://blah/fallback_namespace/longer");
-const GURL kFallbackTestUrl("http://blah/fallback_namespace/longer/test");
-const GURL kOnlineNamespace("http://blah/online_namespace");
-const GURL kOnlineNamespaceWithinFallback(
- "http://blah/fallback_namespace/online/");
-const GURL kInterceptNamespace("http://blah/intercept_namespace/");
-const GURL kInterceptNamespace2("http://blah/intercept_namespace/longer/");
-const GURL kInterceptTestUrl("http://blah/intercept_namespace/longer/test");
-const GURL kInterceptPatternNamespace("http://blah/intercept_pattern/*/bar");
-const GURL kInterceptPatternTestPositiveUrl(
- "http://blah/intercept_pattern/foo/bar");
-const GURL kInterceptPatternTestNegativeUrl(
- "http://blah/intercept_pattern/foo/not_bar");
-const GURL kFallbackPatternNamespace("http://blah/fallback_pattern/*/bar");
-const GURL kFallbackPatternTestPositiveUrl(
- "http://blah/fallback_pattern/foo/bar");
-const GURL kFallbackPatternTestNegativeUrl(
- "http://blah/fallback_pattern/foo/not_bar");
-const GURL kOrigin(kManifestUrl.GetOrigin());
-
-const int kManifestEntryIdOffset = 100;
-const int kFallbackEntryIdOffset = 1000;
-
-const GURL kDefaultEntryUrl("http://blah/makecacheandgroup_default_entry");
-const int kDefaultEntrySize = 10;
-const int kDefaultEntryIdOffset = 12345;
-
-const int kMockQuota = 5000;
-
-// The Reinitialize test needs some http accessible resources to run,
-// we mock stuff inprocess for that.
-class MockHttpServer {
- public:
- static GURL GetMockUrl(const std::string& path) {
- return GURL("http://mockhost/" + path);
- }
-
- static net::URLRequestJob* CreateJob(
- net::URLRequest* request, net::NetworkDelegate* network_delegate) {
- if (request->url().host() != "mockhost")
- return new net::URLRequestErrorJob(request, network_delegate, -100);
-
- std::string headers, body;
- GetMockResponse(request->url().path(), &headers, &body);
- return new net::URLRequestTestJob(
- request, network_delegate, headers, body, true);
- }
-
- private:
- static void GetMockResponse(const std::string& path,
- std::string* headers,
- std::string* body) {
- const char manifest_headers[] =
- "HTTP/1.1 200 OK\0"
- "Content-type: text/cache-manifest\0"
- "\0";
- const char page_headers[] =
- "HTTP/1.1 200 OK\0"
- "Content-type: text/html\0"
- "\0";
- const char not_found_headers[] =
- "HTTP/1.1 404 NOT FOUND\0"
- "\0";
-
- if (path == "/manifest") {
- (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
- (*body) = "CACHE MANIFEST\n";
- } else if (path == "/empty.html") {
- (*headers) = std::string(page_headers, arraysize(page_headers));
- (*body) = "";
- } else {
- (*headers) = std::string(not_found_headers,
- arraysize(not_found_headers));
- (*body) = "";
- }
- }
-};
-
-class MockHttpServerJobFactory
- : public net::URLRequestJobFactory::ProtocolHandler {
- public:
- virtual net::URLRequestJob* MaybeCreateJob(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate) const OVERRIDE {
- return MockHttpServer::CreateJob(request, network_delegate);
- }
-};
-
-class IOThread : public base::Thread {
- public:
- explicit IOThread(const char* name)
- : base::Thread(name) {
- }
-
- virtual ~IOThread() {
- Stop();
- }
-
- net::URLRequestContext* request_context() {
- return request_context_.get();
- }
-
- virtual void Init() OVERRIDE {
- scoped_ptr<net::URLRequestJobFactoryImpl> factory(
- new net::URLRequestJobFactoryImpl());
- factory->SetProtocolHandler("http", new MockHttpServerJobFactory);
- job_factory_ = factory.Pass();
- request_context_.reset(new net::TestURLRequestContext());
- request_context_->set_job_factory(job_factory_.get());
- AppCacheInterceptor::EnsureRegistered();
- }
-
- virtual void CleanUp() OVERRIDE {
- request_context_.reset();
- job_factory_.reset();
- }
-
- private:
- scoped_ptr<net::URLRequestJobFactory> job_factory_;
- scoped_ptr<net::URLRequestContext> request_context_;
-};
-
-scoped_ptr<IOThread> io_thread;
-scoped_ptr<base::Thread> db_thread;
-
-} // namespace
-
-class AppCacheStorageImplTest : public testing::Test {
- public:
- class MockStorageDelegate : public AppCacheStorage::Delegate {
- public:
- explicit MockStorageDelegate(AppCacheStorageImplTest* test)
- : loaded_cache_id_(0), stored_group_success_(false),
- would_exceed_quota_(false), obsoleted_success_(false),
- found_cache_id_(kNoCacheId), test_(test) {
- }
-
- virtual void OnCacheLoaded(AppCache* cache, int64 cache_id) OVERRIDE {
- loaded_cache_ = cache;
- loaded_cache_id_ = cache_id;
- test_->ScheduleNextTask();
- }
-
- virtual void OnGroupLoaded(AppCacheGroup* group,
- const GURL& manifest_url) OVERRIDE {
- loaded_group_ = group;
- loaded_manifest_url_ = manifest_url;
- loaded_groups_newest_cache_ = group ? group->newest_complete_cache()
- : NULL;
- test_->ScheduleNextTask();
- }
-
- virtual void OnGroupAndNewestCacheStored(
- AppCacheGroup* group, AppCache* newest_cache, bool success,
- bool would_exceed_quota) OVERRIDE {
- stored_group_ = group;
- stored_group_success_ = success;
- would_exceed_quota_ = would_exceed_quota;
- test_->ScheduleNextTask();
- }
-
- virtual void OnGroupMadeObsolete(AppCacheGroup* group,
- bool success) OVERRIDE {
- obsoleted_group_ = group;
- obsoleted_success_ = success;
- test_->ScheduleNextTask();
- }
-
- virtual void OnMainResponseFound(const GURL& url,
- const AppCacheEntry& entry,
- const GURL& namespace_entry_url,
- const AppCacheEntry& fallback_entry,
- int64 cache_id,
- int64 group_id,
- const GURL& manifest_url) OVERRIDE {
- found_url_ = url;
- found_entry_ = entry;
- found_namespace_entry_url_ = namespace_entry_url;
- found_fallback_entry_ = fallback_entry;
- found_cache_id_ = cache_id;
- found_group_id_ = group_id;
- found_manifest_url_ = manifest_url;
- test_->ScheduleNextTask();
- }
-
- scoped_refptr<AppCache> loaded_cache_;
- int64 loaded_cache_id_;
- scoped_refptr<AppCacheGroup> loaded_group_;
- GURL loaded_manifest_url_;
- scoped_refptr<AppCache> loaded_groups_newest_cache_;
- scoped_refptr<AppCacheGroup> stored_group_;
- bool stored_group_success_;
- bool would_exceed_quota_;
- scoped_refptr<AppCacheGroup> obsoleted_group_;
- bool obsoleted_success_;
- GURL found_url_;
- AppCacheEntry found_entry_;
- GURL found_namespace_entry_url_;
- AppCacheEntry found_fallback_entry_;
- int64 found_cache_id_;
- int64 found_group_id_;
- GURL found_manifest_url_;
- AppCacheStorageImplTest* test_;
- };
-
- class MockQuotaManager : public quota::QuotaManager {
- public:
- MockQuotaManager()
- : QuotaManager(true /* is_incognito */,
- base::FilePath(),
- io_thread->message_loop_proxy().get(),
- db_thread->message_loop_proxy().get(),
- NULL),
- async_(false) {}
-
- virtual void GetUsageAndQuota(
- const GURL& origin,
- quota::StorageType type,
- const GetUsageAndQuotaCallback& callback) OVERRIDE {
- EXPECT_EQ(kOrigin, origin);
- EXPECT_EQ(quota::kStorageTypeTemporary, type);
- if (async_) {
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&MockQuotaManager::CallCallback,
- base::Unretained(this),
- callback));
- return;
- }
- CallCallback(callback);
- }
-
- void CallCallback(const GetUsageAndQuotaCallback& callback) {
- callback.Run(quota::kQuotaStatusOk, 0, kMockQuota);
- }
-
- bool async_;
-
- protected:
- virtual ~MockQuotaManager() {}
- };
-
- class MockQuotaManagerProxy : public quota::QuotaManagerProxy {
- public:
- MockQuotaManagerProxy()
- : QuotaManagerProxy(NULL, NULL),
- notify_storage_accessed_count_(0),
- notify_storage_modified_count_(0),
- last_delta_(0),
- mock_manager_(new MockQuotaManager) {
- manager_ = mock_manager_.get();
- }
-
- virtual void NotifyStorageAccessed(quota::QuotaClient::ID client_id,
- const GURL& origin,
- quota::StorageType type) OVERRIDE {
- EXPECT_EQ(quota::QuotaClient::kAppcache, client_id);
- EXPECT_EQ(quota::kStorageTypeTemporary, type);
- ++notify_storage_accessed_count_;
- last_origin_ = origin;
- }
-
- virtual void NotifyStorageModified(quota::QuotaClient::ID client_id,
- const GURL& origin,
- quota::StorageType type,
- int64 delta) OVERRIDE {
- EXPECT_EQ(quota::QuotaClient::kAppcache, client_id);
- EXPECT_EQ(quota::kStorageTypeTemporary, type);
- ++notify_storage_modified_count_;
- last_origin_ = origin;
- last_delta_ = delta;
- }
-
- // Not needed for our tests.
- virtual void RegisterClient(quota::QuotaClient* client) OVERRIDE {}
- virtual void NotifyOriginInUse(const GURL& origin) OVERRIDE {}
- virtual void NotifyOriginNoLongerInUse(const GURL& origin) OVERRIDE {}
- virtual void SetUsageCacheEnabled(quota::QuotaClient::ID client_id,
- const GURL& origin,
- quota::StorageType type,
- bool enabled) OVERRIDE {}
- virtual void GetUsageAndQuota(
- base::SequencedTaskRunner* original_task_runner,
- const GURL& origin,
- quota::StorageType type,
- const GetUsageAndQuotaCallback& callback) OVERRIDE {}
-
- int notify_storage_accessed_count_;
- int notify_storage_modified_count_;
- GURL last_origin_;
- int last_delta_;
- scoped_refptr<MockQuotaManager> mock_manager_;
-
- protected:
- virtual ~MockQuotaManagerProxy() {}
- };
-
- template <class Method>
- void RunMethod(Method method) {
- (this->*method)();
- }
-
- // Helper callback to run a test on our io_thread. The io_thread is spun up
- // once and reused for all tests.
- template <class Method>
- void MethodWrapper(Method method) {
- SetUpTest();
-
- // Ensure InitTask execution prior to conducting a test.
- FlushDbThreadTasks();
-
- // We also have to wait for InitTask completion call to be performed
- // on the IO thread prior to running the test. Its guaranteed to be
- // queued by this time.
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&AppCacheStorageImplTest::RunMethod<Method>,
- base::Unretained(this),
- method));
- }
-
- static void SetUpTestCase() {
- // We start both threads as TYPE_IO because we also use the db_thead
- // for the disk_cache which needs to be of TYPE_IO.
- base::Thread::Options options(base::MessageLoop::TYPE_IO, 0);
- io_thread.reset(new IOThread("AppCacheTest.IOThread"));
- ASSERT_TRUE(io_thread->StartWithOptions(options));
- db_thread.reset(new base::Thread("AppCacheTest::DBThread"));
- ASSERT_TRUE(db_thread->StartWithOptions(options));
- }
-
- static void TearDownTestCase() {
- io_thread.reset(NULL);
- db_thread.reset(NULL);
- }
-
- // Test harness --------------------------------------------------
-
- AppCacheStorageImplTest() {
- }
-
- template <class Method>
- void RunTestOnIOThread(Method method) {
- test_finished_event_ .reset(new base::WaitableEvent(false, false));
- io_thread->message_loop()->PostTask(
- FROM_HERE, base::Bind(&AppCacheStorageImplTest::MethodWrapper<Method>,
- base::Unretained(this), method));
- test_finished_event_->Wait();
- }
-
- void SetUpTest() {
- DCHECK(base::MessageLoop::current() == io_thread->message_loop());
- service_.reset(new AppCacheService(NULL));
- service_->Initialize(
- base::FilePath(), db_thread->message_loop_proxy().get(), NULL);
- mock_quota_manager_proxy_ = new MockQuotaManagerProxy();
- service_->quota_manager_proxy_ = mock_quota_manager_proxy_;
- delegate_.reset(new MockStorageDelegate(this));
- }
-
- void TearDownTest() {
- DCHECK(base::MessageLoop::current() == io_thread->message_loop());
- storage()->CancelDelegateCallbacks(delegate());
- group_ = NULL;
- cache_ = NULL;
- cache2_ = NULL;
- mock_quota_manager_proxy_ = NULL;
- delegate_.reset();
- service_.reset();
- FlushDbThreadTasks();
- }
-
- void TestFinished() {
- // We unwind the stack prior to finishing up to let stack
- // based objects get deleted.
- DCHECK(base::MessageLoop::current() == io_thread->message_loop());
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&AppCacheStorageImplTest::TestFinishedUnwound,
- base::Unretained(this)));
- }
-
- void TestFinishedUnwound() {
- TearDownTest();
- test_finished_event_->Signal();
- }
-
- void PushNextTask(const base::Closure& task) {
- task_stack_.push(task);
- }
-
- void ScheduleNextTask() {
- DCHECK(base::MessageLoop::current() == io_thread->message_loop());
- if (task_stack_.empty()) {
- return;
- }
- base::MessageLoop::current()->PostTask(FROM_HERE, task_stack_.top());
- task_stack_.pop();
- }
-
- static void SignalEvent(base::WaitableEvent* event) {
- event->Signal();
- }
-
- void FlushDbThreadTasks() {
- // We pump a task thru the db thread to ensure any tasks previously
- // scheduled on that thread have been performed prior to return.
- base::WaitableEvent event(false, false);
- db_thread->message_loop()->PostTask(
- FROM_HERE, base::Bind(&AppCacheStorageImplTest::SignalEvent, &event));
- event.Wait();
- }
-
- // LoadCache_Miss ----------------------------------------------------
-
- void LoadCache_Miss() {
- // Attempt to load a cache that doesn't exist. Should
- // complete asynchronously.
- PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_LoadCache_Miss,
- base::Unretained(this)));
-
- storage()->LoadCache(111, delegate());
- EXPECT_NE(111, delegate()->loaded_cache_id_);
- }
-
- void Verify_LoadCache_Miss() {
- EXPECT_EQ(111, delegate()->loaded_cache_id_);
- EXPECT_FALSE(delegate()->loaded_cache_.get());
- EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_accessed_count_);
- EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_modified_count_);
- TestFinished();
- }
-
- // LoadCache_NearHit -------------------------------------------------
-
- void LoadCache_NearHit() {
- // Attempt to load a cache that is currently in use
- // and does not require loading from storage. This
- // load should complete syncly.
-
- // Setup some preconditions. Make an 'unstored' cache for
- // us to load. The ctor should put it in the working set.
- int64 cache_id = storage()->NewCacheId();
- scoped_refptr<AppCache> cache(new AppCache(storage(), cache_id));
-
- // Conduct the test.
- storage()->LoadCache(cache_id, delegate());
- EXPECT_EQ(cache_id, delegate()->loaded_cache_id_);
- EXPECT_EQ(cache.get(), delegate()->loaded_cache_.get());
- EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_accessed_count_);
- EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_modified_count_);
- TestFinished();
- }
-
- // CreateGroup --------------------------------------------
-
- void CreateGroupInEmptyOrigin() {
- // Attempt to load a group that doesn't exist, one should
- // be created for us, but not stored.
-
- // Since the origin has no groups, the storage class will respond
- // syncly.
- storage()->LoadOrCreateGroup(kManifestUrl, delegate());
- Verify_CreateGroup();
- }
-
- void CreateGroupInPopulatedOrigin() {
- // Attempt to load a group that doesn't exist, one should
- // be created for us, but not stored.
- PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_CreateGroup,
- base::Unretained(this)));
-
- // Since the origin has groups, storage class will have to
- // consult the database and completion will be async.
- storage()->usage_map_[kOrigin] = kDefaultEntrySize;
-
- storage()->LoadOrCreateGroup(kManifestUrl, delegate());
- EXPECT_FALSE(delegate()->loaded_group_.get());
- }
-
- void Verify_CreateGroup() {
- EXPECT_EQ(kManifestUrl, delegate()->loaded_manifest_url_);
- EXPECT_TRUE(delegate()->loaded_group_.get());
- EXPECT_TRUE(delegate()->loaded_group_->HasOneRef());
- EXPECT_FALSE(delegate()->loaded_group_->newest_complete_cache());
-
- // Should not have been stored in the database.
- AppCacheDatabase::GroupRecord record;
- EXPECT_FALSE(database()->FindGroup(
- delegate()->loaded_group_->group_id(), &record));
-
- EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_accessed_count_);
- EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_modified_count_);
-
- TestFinished();
- }
-
- // LoadGroupAndCache_FarHit --------------------------------------
-
- void LoadGroupAndCache_FarHit() {
- // Attempt to load a cache that is not currently in use
- // and does require loading from disk. This
- // load should complete asynchronously.
- PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_LoadCache_Far_Hit,
- base::Unretained(this)));
-
- // Setup some preconditions. Create a group and newest cache that
- // appear to be "stored" and "not currently in use".
- MakeCacheAndGroup(kManifestUrl, 1, 1, true);
- group_ = NULL;
- cache_ = NULL;
-
- // Conduct the cache load test, completes async
- storage()->LoadCache(1, delegate());
- }
-
- void Verify_LoadCache_Far_Hit() {
- EXPECT_TRUE(delegate()->loaded_cache_.get());
- EXPECT_TRUE(delegate()->loaded_cache_->HasOneRef());
- EXPECT_EQ(1, delegate()->loaded_cache_id_);
-
- // The group should also have been loaded.
- EXPECT_TRUE(delegate()->loaded_cache_->owning_group());
- EXPECT_TRUE(delegate()->loaded_cache_->owning_group()->HasOneRef());
- EXPECT_EQ(1, delegate()->loaded_cache_->owning_group()->group_id());
-
- EXPECT_EQ(1, mock_quota_manager_proxy_->notify_storage_accessed_count_);
- EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_modified_count_);
-
- // Drop things from the working set.
- delegate()->loaded_cache_ = NULL;
- EXPECT_FALSE(delegate()->loaded_group_.get());
-
- // Conduct the group load test, also complete asynchronously.
- PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_LoadGroup_Far_Hit,
- base::Unretained(this)));
-
- storage()->LoadOrCreateGroup(kManifestUrl, delegate());
- }
-
- void Verify_LoadGroup_Far_Hit() {
- EXPECT_TRUE(delegate()->loaded_group_.get());
- EXPECT_EQ(kManifestUrl, delegate()->loaded_manifest_url_);
- EXPECT_TRUE(delegate()->loaded_group_->newest_complete_cache());
- delegate()->loaded_groups_newest_cache_ = NULL;
- EXPECT_TRUE(delegate()->loaded_group_->HasOneRef());
- EXPECT_EQ(2, mock_quota_manager_proxy_->notify_storage_accessed_count_);
- EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_modified_count_);
- TestFinished();
- }
-
- // StoreNewGroup --------------------------------------
-
- void StoreNewGroup() {
- // Store a group and its newest cache. Should complete asynchronously.
- PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_StoreNewGroup,
- base::Unretained(this)));
-
- // Setup some preconditions. Create a group and newest cache that
- // appear to be "unstored".
- group_ = new AppCacheGroup(
- storage(), kManifestUrl, storage()->NewGroupId());
- cache_ = new AppCache(storage(), storage()->NewCacheId());
- cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, 1,
- kDefaultEntrySize));
- // Hold a ref to the cache simulate the UpdateJob holding that ref,
- // and hold a ref to the group to simulate the CacheHost holding that ref.
-
- // Have the quota manager retrun asynchronously for this test.
- mock_quota_manager_proxy_->mock_manager_->async_ = true;
-
- // Conduct the store test.
- storage()->StoreGroupAndNewestCache(group_.get(), cache_.get(), delegate());
- EXPECT_FALSE(delegate()->stored_group_success_);
- }
-
- void Verify_StoreNewGroup() {
- EXPECT_TRUE(delegate()->stored_group_success_);
- EXPECT_EQ(group_.get(), delegate()->stored_group_.get());
- EXPECT_EQ(cache_.get(), group_->newest_complete_cache());
- EXPECT_TRUE(cache_->is_complete());
-
- // Should have been stored in the database.
- AppCacheDatabase::GroupRecord group_record;
- AppCacheDatabase::CacheRecord cache_record;
- EXPECT_TRUE(database()->FindGroup(group_->group_id(), &group_record));
- EXPECT_TRUE(database()->FindCache(cache_->cache_id(), &cache_record));
-
- // Verify quota bookkeeping
- EXPECT_EQ(kDefaultEntrySize, storage()->usage_map_[kOrigin]);
- EXPECT_EQ(1, mock_quota_manager_proxy_->notify_storage_modified_count_);
- EXPECT_EQ(kOrigin, mock_quota_manager_proxy_->last_origin_);
- EXPECT_EQ(kDefaultEntrySize, mock_quota_manager_proxy_->last_delta_);
-
- TestFinished();
- }
-
- // StoreExistingGroup --------------------------------------
-
- void StoreExistingGroup() {
- // Store a group and its newest cache. Should complete asynchronously.
- PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_StoreExistingGroup,
- base::Unretained(this)));
-
- // Setup some preconditions. Create a group and old complete cache
- // that appear to be "stored"
- MakeCacheAndGroup(kManifestUrl, 1, 1, true);
- EXPECT_EQ(kDefaultEntrySize, storage()->usage_map_[kOrigin]);
-
- // And a newest unstored complete cache.
- cache2_ = new AppCache(storage(), 2);
- cache2_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::MASTER, 1,
- kDefaultEntrySize + 100));
-
- // Conduct the test.
- storage()->StoreGroupAndNewestCache(
- group_.get(), cache2_.get(), delegate());
- EXPECT_FALSE(delegate()->stored_group_success_);
- }
-
- void Verify_StoreExistingGroup() {
- EXPECT_TRUE(delegate()->stored_group_success_);
- EXPECT_EQ(group_.get(), delegate()->stored_group_.get());
- EXPECT_EQ(cache2_.get(), group_->newest_complete_cache());
- EXPECT_TRUE(cache2_->is_complete());
-
- // The new cache should have been stored in the database.
- AppCacheDatabase::GroupRecord group_record;
- AppCacheDatabase::CacheRecord cache_record;
- EXPECT_TRUE(database()->FindGroup(1, &group_record));
- EXPECT_TRUE(database()->FindCache(2, &cache_record));
-
- // The old cache should have been deleted
- EXPECT_FALSE(database()->FindCache(1, &cache_record));
-
- // Verify quota bookkeeping
- EXPECT_EQ(kDefaultEntrySize + 100, storage()->usage_map_[kOrigin]);
- EXPECT_EQ(1, mock_quota_manager_proxy_->notify_storage_modified_count_);
- EXPECT_EQ(kOrigin, mock_quota_manager_proxy_->last_origin_);
- EXPECT_EQ(100, mock_quota_manager_proxy_->last_delta_);
-
- TestFinished();
- }
-
- // StoreExistingGroupExistingCache -------------------------------
-
- void StoreExistingGroupExistingCache() {
- // Store a group with updates to its existing newest complete cache.
- // Setup some preconditions. Create a group and a complete cache that
- // appear to be "stored".
-
- // Setup some preconditions. Create a group and old complete cache
- // that appear to be "stored"
- MakeCacheAndGroup(kManifestUrl, 1, 1, true);
- EXPECT_EQ(kDefaultEntrySize, storage()->usage_map_[kOrigin]);
-
- // Change the cache.
- base::Time now = base::Time::Now();
- cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::MASTER, 1, 100));
- cache_->set_update_time(now);
-
- PushNextTask(base::Bind(
- &AppCacheStorageImplTest::Verify_StoreExistingGroupExistingCache,
- base::Unretained(this), now));
-
- // Conduct the test.
- EXPECT_EQ(cache_, group_->newest_complete_cache());
- storage()->StoreGroupAndNewestCache(group_.get(), cache_.get(), delegate());
- EXPECT_FALSE(delegate()->stored_group_success_);
- }
-
- void Verify_StoreExistingGroupExistingCache(
- base::Time expected_update_time) {
- EXPECT_TRUE(delegate()->stored_group_success_);
- EXPECT_EQ(cache_, group_->newest_complete_cache());
-
- AppCacheDatabase::CacheRecord cache_record;
- EXPECT_TRUE(database()->FindCache(1, &cache_record));
- EXPECT_EQ(1, cache_record.cache_id);
- EXPECT_EQ(1, cache_record.group_id);
- EXPECT_FALSE(cache_record.online_wildcard);
- EXPECT_TRUE(expected_update_time == cache_record.update_time);
- EXPECT_EQ(100 + kDefaultEntrySize, cache_record.cache_size);
-
- std::vector<AppCacheDatabase::EntryRecord> entry_records;
- EXPECT_TRUE(database()->FindEntriesForCache(1, &entry_records));
- EXPECT_EQ(2U, entry_records.size());
- if (entry_records[0].url == kDefaultEntryUrl)
- entry_records.erase(entry_records.begin());
- EXPECT_EQ(1 , entry_records[0].cache_id);
- EXPECT_EQ(kEntryUrl, entry_records[0].url);
- EXPECT_EQ(AppCacheEntry::MASTER, entry_records[0].flags);
- EXPECT_EQ(1, entry_records[0].response_id);
- EXPECT_EQ(100, entry_records[0].response_size);
-
- // Verify quota bookkeeping
- EXPECT_EQ(100 + kDefaultEntrySize, storage()->usage_map_[kOrigin]);
- EXPECT_EQ(1, mock_quota_manager_proxy_->notify_storage_modified_count_);
- EXPECT_EQ(kOrigin, mock_quota_manager_proxy_->last_origin_);
- EXPECT_EQ(100, mock_quota_manager_proxy_->last_delta_);
-
- TestFinished();
- }
-
- // FailStoreGroup --------------------------------------
-
- void FailStoreGroup() {
- // Store a group and its newest cache. Should complete asynchronously.
- PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_FailStoreGroup,
- base::Unretained(this)));
-
- // Setup some preconditions. Create a group and newest cache that
- // appear to be "unstored" and big enough to exceed the 5M limit.
- const int64 kTooBig = 10 * 1024 * 1024; // 10M
- group_ = new AppCacheGroup(
- storage(), kManifestUrl, storage()->NewGroupId());
- cache_ = new AppCache(storage(), storage()->NewCacheId());
- cache_->AddEntry(kManifestUrl,
- AppCacheEntry(AppCacheEntry::MANIFEST, 1, kTooBig));
- // Hold a ref to the cache simulate the UpdateJob holding that ref,
- // and hold a ref to the group to simulate the CacheHost holding that ref.
-
- // Conduct the store test.
- storage()->StoreGroupAndNewestCache(group_.get(), cache_.get(), delegate());
- EXPECT_FALSE(delegate()->stored_group_success_); // Expected to be async.
- }
-
- void Verify_FailStoreGroup() {
- EXPECT_FALSE(delegate()->stored_group_success_);
- EXPECT_TRUE(delegate()->would_exceed_quota_);
-
- // Should not have been stored in the database.
- AppCacheDatabase::GroupRecord group_record;
- AppCacheDatabase::CacheRecord cache_record;
- EXPECT_FALSE(database()->FindGroup(group_->group_id(), &group_record));
- EXPECT_FALSE(database()->FindCache(cache_->cache_id(), &cache_record));
-
- EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_accessed_count_);
- EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_modified_count_);
-
- TestFinished();
- }
-
- // MakeGroupObsolete -------------------------------
-
- void MakeGroupObsolete() {
- // Make a group obsolete, should complete asynchronously.
- PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_MakeGroupObsolete,
- base::Unretained(this)));
-
- // Setup some preconditions. Create a group and newest cache that
- // appears to be "stored" and "currently in use".
- MakeCacheAndGroup(kManifestUrl, 1, 1, true);
- EXPECT_EQ(kDefaultEntrySize, storage()->usage_map_[kOrigin]);
-
- // Also insert some related records.
- AppCacheDatabase::EntryRecord entry_record;
- entry_record.cache_id = 1;
- entry_record.flags = AppCacheEntry::FALLBACK;
- entry_record.response_id = 1;
- entry_record.url = kEntryUrl;
- EXPECT_TRUE(database()->InsertEntry(&entry_record));
-
- AppCacheDatabase::NamespaceRecord fallback_namespace_record;
- fallback_namespace_record.cache_id = 1;
- fallback_namespace_record.namespace_.target_url = kEntryUrl;
- fallback_namespace_record.namespace_.namespace_url = kFallbackNamespace;
- fallback_namespace_record.origin = kManifestUrl.GetOrigin();
- EXPECT_TRUE(database()->InsertNamespace(&fallback_namespace_record));
-
- AppCacheDatabase::OnlineWhiteListRecord online_whitelist_record;
- online_whitelist_record.cache_id = 1;
- online_whitelist_record.namespace_url = kOnlineNamespace;
- EXPECT_TRUE(database()->InsertOnlineWhiteList(&online_whitelist_record));
-
- // Conduct the test.
- storage()->MakeGroupObsolete(group_.get(), delegate());
- EXPECT_FALSE(group_->is_obsolete());
- }
-
- void Verify_MakeGroupObsolete() {
- EXPECT_TRUE(delegate()->obsoleted_success_);
- EXPECT_EQ(group_.get(), delegate()->obsoleted_group_.get());
- EXPECT_TRUE(group_->is_obsolete());
- EXPECT_TRUE(storage()->usage_map_.empty());
-
- // The cache and group have been deleted from the database.
- AppCacheDatabase::GroupRecord group_record;
- AppCacheDatabase::CacheRecord cache_record;
- EXPECT_FALSE(database()->FindGroup(1, &group_record));
- EXPECT_FALSE(database()->FindCache(1, &cache_record));
-
- // The related records should have been deleted too.
- std::vector<AppCacheDatabase::EntryRecord> entry_records;
- database()->FindEntriesForCache(1, &entry_records);
- EXPECT_TRUE(entry_records.empty());
- std::vector<AppCacheDatabase::NamespaceRecord> intercept_records;
- std::vector<AppCacheDatabase::NamespaceRecord> fallback_records;
- database()->FindNamespacesForCache(
- 1, &intercept_records, &fallback_records);
- EXPECT_TRUE(fallback_records.empty());
- std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelist_records;
- database()->FindOnlineWhiteListForCache(1, &whitelist_records);
- EXPECT_TRUE(whitelist_records.empty());
-
- // Verify quota bookkeeping
- EXPECT_TRUE(storage()->usage_map_.empty());
- EXPECT_EQ(1, mock_quota_manager_proxy_->notify_storage_modified_count_);
- EXPECT_EQ(kOrigin, mock_quota_manager_proxy_->last_origin_);
- EXPECT_EQ(-kDefaultEntrySize, mock_quota_manager_proxy_->last_delta_);
-
- TestFinished();
- }
-
- // MarkEntryAsForeign -------------------------------
-
- void MarkEntryAsForeign() {
- // Setup some preconditions. Create a cache with an entry
- // in storage and in the working set.
- MakeCacheAndGroup(kManifestUrl, 1, 1, true);
- cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT));
- AppCacheDatabase::EntryRecord entry_record;
- entry_record.cache_id = 1;
- entry_record.url = kEntryUrl;
- entry_record.flags = AppCacheEntry::EXPLICIT;
- entry_record.response_id = 0;
- EXPECT_TRUE(database()->InsertEntry(&entry_record));
- EXPECT_FALSE(cache_->GetEntry(kEntryUrl)->IsForeign());
-
- // Conduct the test.
- storage()->MarkEntryAsForeign(kEntryUrl, 1);
-
- // The entry in the working set should have been updated syncly.
- EXPECT_TRUE(cache_->GetEntry(kEntryUrl)->IsForeign());
- EXPECT_TRUE(cache_->GetEntry(kEntryUrl)->IsExplicit());
-
- // And the entry in storage should also be updated, but that
- // happens asynchronously on the db thread.
- FlushDbThreadTasks();
- AppCacheDatabase::EntryRecord entry_record2;
- EXPECT_TRUE(database()->FindEntry(1, kEntryUrl, &entry_record2));
- EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN,
- entry_record2.flags);
- TestFinished();
- }
-
- // MarkEntryAsForeignWithLoadInProgress -------------------------------
-
- void MarkEntryAsForeignWithLoadInProgress() {
- PushNextTask(base::Bind(
- &AppCacheStorageImplTest::Verify_MarkEntryAsForeignWithLoadInProgress,
- base::Unretained(this)));
-
- // Setup some preconditions. Create a cache with an entry
- // in storage, but not in the working set.
- MakeCacheAndGroup(kManifestUrl, 1, 1, true);
- cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT));
- AppCacheDatabase::EntryRecord entry_record;
- entry_record.cache_id = 1;
- entry_record.url = kEntryUrl;
- entry_record.flags = AppCacheEntry::EXPLICIT;
- entry_record.response_id = 0;
- EXPECT_TRUE(database()->InsertEntry(&entry_record));
- EXPECT_FALSE(cache_->GetEntry(kEntryUrl)->IsForeign());
- EXPECT_TRUE(cache_->HasOneRef());
- cache_ = NULL;
- group_ = NULL;
-
- // Conduct the test, start a cache load, and prior to completion
- // of that load, mark the entry as foreign.
- storage()->LoadCache(1, delegate());
- storage()->MarkEntryAsForeign(kEntryUrl, 1);
- }
-
- void Verify_MarkEntryAsForeignWithLoadInProgress() {
- EXPECT_EQ(1, delegate()->loaded_cache_id_);
- EXPECT_TRUE(delegate()->loaded_cache_.get());
-
- // The entry in the working set should have been updated upon load.
- EXPECT_TRUE(delegate()->loaded_cache_->GetEntry(kEntryUrl)->IsForeign());
- EXPECT_TRUE(delegate()->loaded_cache_->GetEntry(kEntryUrl)->IsExplicit());
-
- // And the entry in storage should also be updated.
- FlushDbThreadTasks();
- AppCacheDatabase::EntryRecord entry_record;
- EXPECT_TRUE(database()->FindEntry(1, kEntryUrl, &entry_record));
- EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN,
- entry_record.flags);
- TestFinished();
- }
-
- // FindNoMainResponse -------------------------------
-
- void FindNoMainResponse() {
- PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_FindNoMainResponse,
- base::Unretained(this)));
-
- // Conduct the test.
- storage()->FindResponseForMainRequest(kEntryUrl, GURL(), delegate());
- EXPECT_NE(kEntryUrl, delegate()->found_url_);
- }
-
- void Verify_FindNoMainResponse() {
- EXPECT_EQ(kEntryUrl, delegate()->found_url_);
- EXPECT_TRUE(delegate()->found_manifest_url_.is_empty());
- EXPECT_EQ(kNoCacheId, delegate()->found_cache_id_);
- EXPECT_EQ(kNoResponseId, delegate()->found_entry_.response_id());
- EXPECT_EQ(kNoResponseId, delegate()->found_fallback_entry_.response_id());
- EXPECT_TRUE(delegate()->found_namespace_entry_url_.is_empty());
- EXPECT_EQ(0, delegate()->found_entry_.types());
- EXPECT_EQ(0, delegate()->found_fallback_entry_.types());
- TestFinished();
- }
-
- // BasicFindMainResponse -------------------------------
-
- void BasicFindMainResponseInDatabase() {
- BasicFindMainResponse(true);
- }
-
- void BasicFindMainResponseInWorkingSet() {
- BasicFindMainResponse(false);
- }
-
- void BasicFindMainResponse(bool drop_from_working_set) {
- PushNextTask(base::Bind(
- &AppCacheStorageImplTest::Verify_BasicFindMainResponse,
- base::Unretained(this)));
-
- // Setup some preconditions. Create a complete cache with an entry
- // in storage.
- MakeCacheAndGroup(kManifestUrl, 2, 1, true);
- cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, 1));
- AppCacheDatabase::EntryRecord entry_record;
- entry_record.cache_id = 1;
- entry_record.url = kEntryUrl;
- entry_record.flags = AppCacheEntry::EXPLICIT;
- entry_record.response_id = 1;
- EXPECT_TRUE(database()->InsertEntry(&entry_record));
-
- // Optionally drop the cache/group pair from the working set.
- if (drop_from_working_set) {
- EXPECT_TRUE(cache_->HasOneRef());
- cache_ = NULL;
- EXPECT_TRUE(group_->HasOneRef());
- group_ = NULL;
- }
-
- // Conduct the test.
- storage()->FindResponseForMainRequest(kEntryUrl, GURL(), delegate());
- EXPECT_NE(kEntryUrl, delegate()->found_url_);
- }
-
- void Verify_BasicFindMainResponse() {
- EXPECT_EQ(kEntryUrl, delegate()->found_url_);
- EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_);
- EXPECT_EQ(1, delegate()->found_cache_id_);
- EXPECT_EQ(2, delegate()->found_group_id_);
- EXPECT_EQ(1, delegate()->found_entry_.response_id());
- EXPECT_TRUE(delegate()->found_entry_.IsExplicit());
- EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id());
- TestFinished();
- }
-
- // BasicFindMainFallbackResponse -------------------------------
-
- void BasicFindMainFallbackResponseInDatabase() {
- BasicFindMainFallbackResponse(true);
- }
-
- void BasicFindMainFallbackResponseInWorkingSet() {
- BasicFindMainFallbackResponse(false);
- }
-
- void BasicFindMainFallbackResponse(bool drop_from_working_set) {
- PushNextTask(base::Bind(
- &AppCacheStorageImplTest::Verify_BasicFindMainFallbackResponse,
- base::Unretained(this)));
-
- // Setup some preconditions. Create a complete cache with a
- // fallback namespace and entry.
- MakeCacheAndGroup(kManifestUrl, 2, 1, true);
- cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::FALLBACK, 1));
- cache_->AddEntry(kEntryUrl2, AppCacheEntry(AppCacheEntry::FALLBACK, 2));
- cache_->fallback_namespaces_.push_back(
- Namespace(FALLBACK_NAMESPACE, kFallbackNamespace2, kEntryUrl2, false));
- cache_->fallback_namespaces_.push_back(
- Namespace(FALLBACK_NAMESPACE, kFallbackNamespace, kEntryUrl, false));
- AppCacheDatabase::CacheRecord cache_record;
- std::vector<AppCacheDatabase::EntryRecord> entries;
- std::vector<AppCacheDatabase::NamespaceRecord> intercepts;
- std::vector<AppCacheDatabase::NamespaceRecord> fallbacks;
- std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists;
- cache_->ToDatabaseRecords(group_.get(),
- &cache_record,
- &entries,
- &intercepts,
- &fallbacks,
- &whitelists);
-
- std::vector<AppCacheDatabase::EntryRecord>::const_iterator iter =
- entries.begin();
- while (iter != entries.end()) {
- // MakeCacheAndGroup has inserted the default entry record already.
- if (iter->url != kDefaultEntryUrl)
- EXPECT_TRUE(database()->InsertEntry(&(*iter)));
- ++iter;
- }
-
- EXPECT_TRUE(database()->InsertNamespaceRecords(fallbacks));
- EXPECT_TRUE(database()->InsertOnlineWhiteListRecords(whitelists));
- if (drop_from_working_set) {
- EXPECT_TRUE(cache_->HasOneRef());
- cache_ = NULL;
- EXPECT_TRUE(group_->HasOneRef());
- group_ = NULL;
- }
-
- // Conduct the test. The test url is in both fallback namespace urls,
- // but should match the longer of the two.
- storage()->FindResponseForMainRequest(kFallbackTestUrl, GURL(), delegate());
- EXPECT_NE(kFallbackTestUrl, delegate()->found_url_);
- }
-
- void Verify_BasicFindMainFallbackResponse() {
- EXPECT_EQ(kFallbackTestUrl, delegate()->found_url_);
- EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_);
- EXPECT_EQ(1, delegate()->found_cache_id_);
- EXPECT_EQ(2, delegate()->found_group_id_);
- EXPECT_FALSE(delegate()->found_entry_.has_response_id());
- EXPECT_EQ(2, delegate()->found_fallback_entry_.response_id());
- EXPECT_EQ(kEntryUrl2, delegate()->found_namespace_entry_url_);
- EXPECT_TRUE(delegate()->found_fallback_entry_.IsFallback());
- TestFinished();
- }
-
- // BasicFindMainInterceptResponse -------------------------------
-
- void BasicFindMainInterceptResponseInDatabase() {
- BasicFindMainInterceptResponse(true);
- }
-
- void BasicFindMainInterceptResponseInWorkingSet() {
- BasicFindMainInterceptResponse(false);
- }
-
- void BasicFindMainInterceptResponse(bool drop_from_working_set) {
- PushNextTask(base::Bind(
- &AppCacheStorageImplTest::Verify_BasicFindMainInterceptResponse,
- base::Unretained(this)));
-
- // Setup some preconditions. Create a complete cache with an
- // intercept namespace and entry.
- MakeCacheAndGroup(kManifestUrl, 2, 1, true);
- cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::INTERCEPT, 1));
- cache_->AddEntry(kEntryUrl2, AppCacheEntry(AppCacheEntry::INTERCEPT, 2));
- cache_->intercept_namespaces_.push_back(
- Namespace(INTERCEPT_NAMESPACE, kInterceptNamespace2,
- kEntryUrl2, false));
- cache_->intercept_namespaces_.push_back(
- Namespace(INTERCEPT_NAMESPACE, kInterceptNamespace,
- kEntryUrl, false));
- AppCacheDatabase::CacheRecord cache_record;
- std::vector<AppCacheDatabase::EntryRecord> entries;
- std::vector<AppCacheDatabase::NamespaceRecord> intercepts;
- std::vector<AppCacheDatabase::NamespaceRecord> fallbacks;
- std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists;
- cache_->ToDatabaseRecords(group_.get(),
- &cache_record,
- &entries,
- &intercepts,
- &fallbacks,
- &whitelists);
-
- std::vector<AppCacheDatabase::EntryRecord>::const_iterator iter =
- entries.begin();
- while (iter != entries.end()) {
- // MakeCacheAndGroup has inserted the default entry record already
- if (iter->url != kDefaultEntryUrl)
- EXPECT_TRUE(database()->InsertEntry(&(*iter)));
- ++iter;
- }
-
- EXPECT_TRUE(database()->InsertNamespaceRecords(intercepts));
- EXPECT_TRUE(database()->InsertOnlineWhiteListRecords(whitelists));
- if (drop_from_working_set) {
- EXPECT_TRUE(cache_->HasOneRef());
- cache_ = NULL;
- EXPECT_TRUE(group_->HasOneRef());
- group_ = NULL;
- }
-
- // Conduct the test. The test url is in both intercept namespaces,
- // but should match the longer of the two.
- storage()->FindResponseForMainRequest(
- kInterceptTestUrl, GURL(), delegate());
- EXPECT_NE(kInterceptTestUrl, delegate()->found_url_);
- }
-
- void Verify_BasicFindMainInterceptResponse() {
- EXPECT_EQ(kInterceptTestUrl, delegate()->found_url_);
- EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_);
- EXPECT_EQ(1, delegate()->found_cache_id_);
- EXPECT_EQ(2, delegate()->found_group_id_);
- EXPECT_EQ(2, delegate()->found_entry_.response_id());
- EXPECT_TRUE(delegate()->found_entry_.IsIntercept());
- EXPECT_EQ(kEntryUrl2, delegate()->found_namespace_entry_url_);
- EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id());
- TestFinished();
- }
-
- // FindInterceptPatternMatch ----------------------------------------
-
- void FindInterceptPatternMatchInDatabase() {
- FindInterceptPatternMatch(true);
- }
-
- void FindInterceptPatternMatchInWorkingSet() {
- FindInterceptPatternMatch(false);
- }
-
- void FindInterceptPatternMatch(bool drop_from_working_set) {
- // Setup some preconditions. Create a complete cache with an
- // pattern matching intercept namespace and entry.
- MakeCacheAndGroup(kManifestUrl, 2, 1, true);
- cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::INTERCEPT, 1));
- cache_->intercept_namespaces_.push_back(
- Namespace(INTERCEPT_NAMESPACE, kInterceptPatternNamespace,
- kEntryUrl, true));
- AppCacheDatabase::CacheRecord cache_record;
- std::vector<AppCacheDatabase::EntryRecord> entries;
- std::vector<AppCacheDatabase::NamespaceRecord> intercepts;
- std::vector<AppCacheDatabase::NamespaceRecord> fallbacks;
- std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists;
- cache_->ToDatabaseRecords(group_.get(),
- &cache_record,
- &entries,
- &intercepts,
- &fallbacks,
- &whitelists);
-
- std::vector<AppCacheDatabase::EntryRecord>::const_iterator iter =
- entries.begin();
- while (iter != entries.end()) {
- // MakeCacheAndGroup has inserted the default entry record already
- if (iter->url != kDefaultEntryUrl)
- EXPECT_TRUE(database()->InsertEntry(&(*iter)));
- ++iter;
- }
-
- EXPECT_TRUE(database()->InsertNamespaceRecords(intercepts));
- if (drop_from_working_set) {
- EXPECT_TRUE(cache_->HasOneRef());
- cache_ = NULL;
- EXPECT_TRUE(group_->HasOneRef());
- group_ = NULL;
- }
-
- // First test something that does not match the pattern.
- PushNextTask(base::Bind(
- &AppCacheStorageImplTest::Verify_FindInterceptPatternMatchNegative,
- base::Unretained(this)));
- storage()->FindResponseForMainRequest(
- kInterceptPatternTestNegativeUrl, GURL(), delegate());
- EXPECT_EQ(GURL(), delegate()->found_url_); // Is always async.
- }
-
- void Verify_FindInterceptPatternMatchNegative() {
- EXPECT_EQ(kInterceptPatternTestNegativeUrl, delegate()->found_url_);
- EXPECT_TRUE(delegate()->found_manifest_url_.is_empty());
- EXPECT_EQ(kNoCacheId, delegate()->found_cache_id_);
- EXPECT_EQ(kNoResponseId, delegate()->found_entry_.response_id());
- EXPECT_EQ(kNoResponseId, delegate()->found_fallback_entry_.response_id());
- EXPECT_TRUE(delegate()->found_namespace_entry_url_.is_empty());
- EXPECT_EQ(0, delegate()->found_entry_.types());
- EXPECT_EQ(0, delegate()->found_fallback_entry_.types());
-
- // Then test something that matches.
- PushNextTask(base::Bind(
- &AppCacheStorageImplTest::Verify_FindInterceptPatternMatchPositive,
- base::Unretained(this)));
- storage()->FindResponseForMainRequest(
- kInterceptPatternTestPositiveUrl, GURL(), delegate());
- }
-
- void Verify_FindInterceptPatternMatchPositive() {
- EXPECT_EQ(kInterceptPatternTestPositiveUrl, delegate()->found_url_);
- EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_);
- EXPECT_EQ(1, delegate()->found_cache_id_);
- EXPECT_EQ(2, delegate()->found_group_id_);
- EXPECT_EQ(1, delegate()->found_entry_.response_id());
- EXPECT_TRUE(delegate()->found_entry_.IsIntercept());
- EXPECT_EQ(kEntryUrl, delegate()->found_namespace_entry_url_);
- EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id());
- TestFinished();
- }
-
- // FindFallbackPatternMatch -------------------------------
-
- void FindFallbackPatternMatchInDatabase() {
- FindFallbackPatternMatch(true);
- }
-
- void FindFallbackPatternMatchInWorkingSet() {
- FindFallbackPatternMatch(false);
- }
-
- void FindFallbackPatternMatch(bool drop_from_working_set) {
- // Setup some preconditions. Create a complete cache with a
- // pattern matching fallback namespace and entry.
- MakeCacheAndGroup(kManifestUrl, 2, 1, true);
- cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::FALLBACK, 1));
- cache_->fallback_namespaces_.push_back(
- Namespace(FALLBACK_NAMESPACE, kFallbackPatternNamespace,
- kEntryUrl, true));
- AppCacheDatabase::CacheRecord cache_record;
- std::vector<AppCacheDatabase::EntryRecord> entries;
- std::vector<AppCacheDatabase::NamespaceRecord> intercepts;
- std::vector<AppCacheDatabase::NamespaceRecord> fallbacks;
- std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists;
- cache_->ToDatabaseRecords(group_.get(),
- &cache_record,
- &entries,
- &intercepts,
- &fallbacks,
- &whitelists);
-
- std::vector<AppCacheDatabase::EntryRecord>::const_iterator iter =
- entries.begin();
- while (iter != entries.end()) {
- // MakeCacheAndGroup has inserted the default entry record already.
- if (iter->url != kDefaultEntryUrl)
- EXPECT_TRUE(database()->InsertEntry(&(*iter)));
- ++iter;
- }
-
- EXPECT_TRUE(database()->InsertNamespaceRecords(fallbacks));
- if (drop_from_working_set) {
- EXPECT_TRUE(cache_->HasOneRef());
- cache_ = NULL;
- EXPECT_TRUE(group_->HasOneRef());
- group_ = NULL;
- }
-
- // First test something that does not match the pattern.
- PushNextTask(base::Bind(
- &AppCacheStorageImplTest::Verify_FindFallbackPatternMatchNegative,
- base::Unretained(this)));
- storage()->FindResponseForMainRequest(
- kFallbackPatternTestNegativeUrl, GURL(), delegate());
- EXPECT_EQ(GURL(), delegate()->found_url_); // Is always async.
- }
-
- void Verify_FindFallbackPatternMatchNegative() {
- EXPECT_EQ(kFallbackPatternTestNegativeUrl, delegate()->found_url_);
- EXPECT_TRUE(delegate()->found_manifest_url_.is_empty());
- EXPECT_EQ(kNoCacheId, delegate()->found_cache_id_);
- EXPECT_EQ(kNoResponseId, delegate()->found_entry_.response_id());
- EXPECT_EQ(kNoResponseId, delegate()->found_fallback_entry_.response_id());
- EXPECT_TRUE(delegate()->found_namespace_entry_url_.is_empty());
- EXPECT_EQ(0, delegate()->found_entry_.types());
- EXPECT_EQ(0, delegate()->found_fallback_entry_.types());
-
- // Then test something that matches.
- PushNextTask(base::Bind(
- &AppCacheStorageImplTest::Verify_FindFallbackPatternMatchPositive,
- base::Unretained(this)));
- storage()->FindResponseForMainRequest(
- kFallbackPatternTestPositiveUrl, GURL(), delegate());
- }
-
- void Verify_FindFallbackPatternMatchPositive() {
- EXPECT_EQ(kFallbackPatternTestPositiveUrl, delegate()->found_url_);
- EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_);
- EXPECT_EQ(1, delegate()->found_cache_id_);
- EXPECT_EQ(2, delegate()->found_group_id_);
- EXPECT_EQ(1, delegate()->found_fallback_entry_.response_id());
- EXPECT_TRUE(delegate()->found_fallback_entry_.IsFallback());
- EXPECT_EQ(kEntryUrl, delegate()->found_namespace_entry_url_);
- EXPECT_FALSE(delegate()->found_entry_.has_response_id());
- TestFinished();
- }
-
- // FindMainResponseWithMultipleHits -------------------------------
-
- void FindMainResponseWithMultipleHits() {
- PushNextTask(base::Bind(
- &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits,
- base::Unretained(this)));
-
- // Setup some preconditions, create a few caches with an identical set
- // of entries and fallback namespaces. Only the last one remains in
- // the working set to simulate appearing as "in use".
- MakeMultipleHitCacheAndGroup(kManifestUrl, 1);
- MakeMultipleHitCacheAndGroup(kManifestUrl2, 2);
- MakeMultipleHitCacheAndGroup(kManifestUrl3, 3);
-
- // Conduct the test, we should find the response from the last cache
- // since it's "in use".
- storage()->FindResponseForMainRequest(kEntryUrl, GURL(), delegate());
- EXPECT_NE(kEntryUrl, delegate()->found_url_);
- }
-
- void MakeMultipleHitCacheAndGroup(const GURL& manifest_url, int id) {
- MakeCacheAndGroup(manifest_url, id, id, true);
- AppCacheDatabase::EntryRecord entry_record;
-
- // Add an entry for kEntryUrl
- entry_record.cache_id = id;
- entry_record.url = kEntryUrl;
- entry_record.flags = AppCacheEntry::EXPLICIT;
- entry_record.response_id = id;
- EXPECT_TRUE(database()->InsertEntry(&entry_record));
- cache_->AddEntry(
- entry_record.url,
- AppCacheEntry(entry_record.flags, entry_record.response_id));
-
- // Add an entry for the manifestUrl
- entry_record.cache_id = id;
- entry_record.url = manifest_url;
- entry_record.flags = AppCacheEntry::MANIFEST;
- entry_record.response_id = id + kManifestEntryIdOffset;
- EXPECT_TRUE(database()->InsertEntry(&entry_record));
- cache_->AddEntry(
- entry_record.url,
- AppCacheEntry(entry_record.flags, entry_record.response_id));
-
- // Add a fallback entry and namespace
- entry_record.cache_id = id;
- entry_record.url = kEntryUrl2;
- entry_record.flags = AppCacheEntry::FALLBACK;
- entry_record.response_id = id + kFallbackEntryIdOffset;
- EXPECT_TRUE(database()->InsertEntry(&entry_record));
- cache_->AddEntry(
- entry_record.url,
- AppCacheEntry(entry_record.flags, entry_record.response_id));
- AppCacheDatabase::NamespaceRecord fallback_namespace_record;
- fallback_namespace_record.cache_id = id;
- fallback_namespace_record.namespace_.target_url = entry_record.url;
- fallback_namespace_record.namespace_.namespace_url = kFallbackNamespace;
- fallback_namespace_record.origin = manifest_url.GetOrigin();
- EXPECT_TRUE(database()->InsertNamespace(&fallback_namespace_record));
- cache_->fallback_namespaces_.push_back(
- Namespace(FALLBACK_NAMESPACE, kFallbackNamespace, kEntryUrl2, false));
- }
-
- void Verify_FindMainResponseWithMultipleHits() {
- EXPECT_EQ(kEntryUrl, delegate()->found_url_);
- EXPECT_EQ(kManifestUrl3, delegate()->found_manifest_url_);
- EXPECT_EQ(3, delegate()->found_cache_id_);
- EXPECT_EQ(3, delegate()->found_group_id_);
- EXPECT_EQ(3, delegate()->found_entry_.response_id());
- EXPECT_TRUE(delegate()->found_entry_.IsExplicit());
- EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id());
-
- // Conduct another test perferring kManifestUrl
- delegate_.reset(new MockStorageDelegate(this));
- PushNextTask(base::Bind(
- &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits2,
- base::Unretained(this)));
- storage()->FindResponseForMainRequest(kEntryUrl, kManifestUrl, delegate());
- EXPECT_NE(kEntryUrl, delegate()->found_url_);
- }
-
- void Verify_FindMainResponseWithMultipleHits2() {
- EXPECT_EQ(kEntryUrl, delegate()->found_url_);
- EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_);
- EXPECT_EQ(1, delegate()->found_cache_id_);
- EXPECT_EQ(1, delegate()->found_group_id_);
- EXPECT_EQ(1, delegate()->found_entry_.response_id());
- EXPECT_TRUE(delegate()->found_entry_.IsExplicit());
- EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id());
-
- // Conduct the another test perferring kManifestUrl2
- delegate_.reset(new MockStorageDelegate(this));
- PushNextTask(base::Bind(
- &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits3,
- base::Unretained(this)));
- storage()->FindResponseForMainRequest(kEntryUrl, kManifestUrl2, delegate());
- EXPECT_NE(kEntryUrl, delegate()->found_url_);
- }
-
- void Verify_FindMainResponseWithMultipleHits3() {
- EXPECT_EQ(kEntryUrl, delegate()->found_url_);
- EXPECT_EQ(kManifestUrl2, delegate()->found_manifest_url_);
- EXPECT_EQ(2, delegate()->found_cache_id_);
- EXPECT_EQ(2, delegate()->found_group_id_);
- EXPECT_EQ(2, delegate()->found_entry_.response_id());
- EXPECT_TRUE(delegate()->found_entry_.IsExplicit());
- EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id());
-
- // Conduct another test with no preferred manifest that hits the fallback.
- delegate_.reset(new MockStorageDelegate(this));
- PushNextTask(base::Bind(
- &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits4,
- base::Unretained(this)));
- storage()->FindResponseForMainRequest(
- kFallbackTestUrl, GURL(), delegate());
- EXPECT_NE(kFallbackTestUrl, delegate()->found_url_);
- }
-
- void Verify_FindMainResponseWithMultipleHits4() {
- EXPECT_EQ(kFallbackTestUrl, delegate()->found_url_);
- EXPECT_EQ(kManifestUrl3, delegate()->found_manifest_url_);
- EXPECT_EQ(3, delegate()->found_cache_id_);
- EXPECT_EQ(3, delegate()->found_group_id_);
- EXPECT_FALSE(delegate()->found_entry_.has_response_id());
- EXPECT_EQ(3 + kFallbackEntryIdOffset,
- delegate()->found_fallback_entry_.response_id());
- EXPECT_TRUE(delegate()->found_fallback_entry_.IsFallback());
- EXPECT_EQ(kEntryUrl2, delegate()->found_namespace_entry_url_);
-
- // Conduct another test preferring kManifestUrl2 that hits the fallback.
- delegate_.reset(new MockStorageDelegate(this));
- PushNextTask(base::Bind(
- &AppCacheStorageImplTest::Verify_FindMainResponseWithMultipleHits5,
- base::Unretained(this)));
- storage()->FindResponseForMainRequest(
- kFallbackTestUrl, kManifestUrl2, delegate());
- EXPECT_NE(kFallbackTestUrl, delegate()->found_url_);
- }
-
- void Verify_FindMainResponseWithMultipleHits5() {
- EXPECT_EQ(kFallbackTestUrl, delegate()->found_url_);
- EXPECT_EQ(kManifestUrl2, delegate()->found_manifest_url_);
- EXPECT_EQ(2, delegate()->found_cache_id_);
- EXPECT_EQ(2, delegate()->found_group_id_);
- EXPECT_FALSE(delegate()->found_entry_.has_response_id());
- EXPECT_EQ(2 + kFallbackEntryIdOffset,
- delegate()->found_fallback_entry_.response_id());
- EXPECT_TRUE(delegate()->found_fallback_entry_.IsFallback());
- EXPECT_EQ(kEntryUrl2, delegate()->found_namespace_entry_url_);
-
- TestFinished();
- }
-
- // FindMainResponseExclusions -------------------------------
-
- void FindMainResponseExclusionsInDatabase() {
- FindMainResponseExclusions(true);
- }
-
- void FindMainResponseExclusionsInWorkingSet() {
- FindMainResponseExclusions(false);
- }
-
- void FindMainResponseExclusions(bool drop_from_working_set) {
- // Setup some preconditions. Create a complete cache with a
- // foreign entry, an online namespace, and a second online
- // namespace nested within a fallback namespace.
- MakeCacheAndGroup(kManifestUrl, 1, 1, true);
- cache_->AddEntry(kEntryUrl,
- AppCacheEntry(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN, 1));
- cache_->AddEntry(kEntryUrl2, AppCacheEntry(AppCacheEntry::FALLBACK, 2));
- cache_->fallback_namespaces_.push_back(
- Namespace(FALLBACK_NAMESPACE, kFallbackNamespace, kEntryUrl2, false));
- cache_->online_whitelist_namespaces_.push_back(
- Namespace(NETWORK_NAMESPACE, kOnlineNamespace,
- GURL(), false));
- cache_->online_whitelist_namespaces_.push_back(
- Namespace(NETWORK_NAMESPACE, kOnlineNamespaceWithinFallback,
- GURL(), false));
-
- AppCacheDatabase::EntryRecord entry_record;
- entry_record.cache_id = 1;
- entry_record.url = kEntryUrl;
- entry_record.flags = AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN;
- entry_record.response_id = 1;
- EXPECT_TRUE(database()->InsertEntry(&entry_record));
- AppCacheDatabase::OnlineWhiteListRecord whitelist_record;
- whitelist_record.cache_id = 1;
- whitelist_record.namespace_url = kOnlineNamespace;
- EXPECT_TRUE(database()->InsertOnlineWhiteList(&whitelist_record));
- AppCacheDatabase::NamespaceRecord fallback_namespace_record;
- fallback_namespace_record.cache_id = 1;
- fallback_namespace_record.namespace_.target_url = kEntryUrl2;
- fallback_namespace_record.namespace_.namespace_url = kFallbackNamespace;
- fallback_namespace_record.origin = kManifestUrl.GetOrigin();
- EXPECT_TRUE(database()->InsertNamespace(&fallback_namespace_record));
- whitelist_record.cache_id = 1;
- whitelist_record.namespace_url = kOnlineNamespaceWithinFallback;
- EXPECT_TRUE(database()->InsertOnlineWhiteList(&whitelist_record));
- if (drop_from_working_set) {
- cache_ = NULL;
- group_ = NULL;
- }
-
- // We should not find anything for the foreign entry.
- PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_ExclusionNotFound,
- base::Unretained(this), kEntryUrl, 1));
- storage()->FindResponseForMainRequest(kEntryUrl, GURL(), delegate());
- }
-
- void Verify_ExclusionNotFound(GURL expected_url, int phase) {
- EXPECT_EQ(expected_url, delegate()->found_url_);
- EXPECT_TRUE(delegate()->found_manifest_url_.is_empty());
- EXPECT_EQ(kNoCacheId, delegate()->found_cache_id_);
- EXPECT_EQ(0, delegate()->found_group_id_);
- EXPECT_EQ(kNoResponseId, delegate()->found_entry_.response_id());
- EXPECT_EQ(kNoResponseId, delegate()->found_fallback_entry_.response_id());
- EXPECT_TRUE(delegate()->found_namespace_entry_url_.is_empty());
- EXPECT_EQ(0, delegate()->found_entry_.types());
- EXPECT_EQ(0, delegate()->found_fallback_entry_.types());
-
- if (phase == 1) {
- // We should not find anything for the online namespace.
- PushNextTask(
- base::Bind(&AppCacheStorageImplTest::Verify_ExclusionNotFound,
- base::Unretained(this), kOnlineNamespace, 2));
- storage()->FindResponseForMainRequest(
- kOnlineNamespace, GURL(), delegate());
- return;
- }
- if (phase == 2) {
- // We should not find anything for the online namespace nested within
- // the fallback namespace.
- PushNextTask(base::Bind(
- &AppCacheStorageImplTest::Verify_ExclusionNotFound,
- base::Unretained(this), kOnlineNamespaceWithinFallback, 3));
- storage()->FindResponseForMainRequest(
- kOnlineNamespaceWithinFallback, GURL(), delegate());
- return;
- }
-
- TestFinished();
- }
-
- // Reinitialize -------------------------------
- // This test is somewhat of a system integration test.
- // It relies on running a mock http server on our IO thread,
- // and involves other appcache classes to get some code
- // coverage thruout when Reinitialize happens.
-
- class MockServiceObserver : public AppCacheService::Observer {
- public:
- explicit MockServiceObserver(AppCacheStorageImplTest* test)
- : test_(test) {}
-
- virtual void OnServiceReinitialized(
- AppCacheStorageReference* old_storage_ref) OVERRIDE {
- observed_old_storage_ = old_storage_ref;
- test_->ScheduleNextTask();
- }
-
- scoped_refptr<AppCacheStorageReference> observed_old_storage_;
- AppCacheStorageImplTest* test_;
- };
-
- class MockAppCacheFrontend : public AppCacheFrontend {
- public:
- MockAppCacheFrontend() : error_event_was_raised_(false) {}
-
- virtual void OnCacheSelected(
- int host_id, const appcache::AppCacheInfo& info) OVERRIDE {}
- virtual void OnStatusChanged(const std::vector<int>& host_ids,
- Status status) OVERRIDE {}
- virtual void OnEventRaised(const std::vector<int>& host_ids,
- EventID event_id) OVERRIDE {}
- virtual void OnProgressEventRaised(
- const std::vector<int>& host_ids,
- const GURL& url,
- int num_total, int num_complete) OVERRIDE {}
- virtual void OnErrorEventRaised(const std::vector<int>& host_ids,
- const std::string& message) OVERRIDE {
- error_event_was_raised_ = true;
- }
- virtual void OnLogMessage(int host_id, LogLevel log_level,
- const std::string& message) OVERRIDE {}
- virtual void OnContentBlocked(
- int host_id, const GURL& manifest_url) OVERRIDE {}
-
- bool error_event_was_raised_;
- };
-
- void Reinitialize1() {
- Reinitialize(1);
- }
-
- void Reinitialize2() {
- Reinitialize(2);
- }
-
- void Reinitialize(int test_case) {
- // Unlike all of the other tests, this one actually read/write files.
- ASSERT_TRUE(temp_directory_.CreateUniqueTempDir());
-
- // Create a corrupt/unopenable disk_cache index file.
- const std::string kCorruptData("deadbeef");
- base::FilePath disk_cache_directory =
- temp_directory_.path().AppendASCII("Cache");
- ASSERT_TRUE(base::CreateDirectory(disk_cache_directory));
- base::FilePath index_file = disk_cache_directory.AppendASCII("index");
- EXPECT_EQ(static_cast<int>(kCorruptData.length()),
- file_util::WriteFile(
- index_file, kCorruptData.data(), kCorruptData.length()));
-
- // Create records for a degenerate cached manifest that only contains
- // one entry for the manifest file resource.
- if (test_case == 2) {
- AppCacheDatabase db(temp_directory_.path().AppendASCII("Index"));
- GURL manifest_url = MockHttpServer::GetMockUrl("manifest");
-
- AppCacheDatabase::GroupRecord group_record;
- group_record.group_id = 1;
- group_record.manifest_url = manifest_url;
- group_record.origin = manifest_url.GetOrigin();
- EXPECT_TRUE(db.InsertGroup(&group_record));
- AppCacheDatabase::CacheRecord cache_record;
- cache_record.cache_id = 1;
- cache_record.group_id = 1;
- cache_record.online_wildcard = false;
- cache_record.update_time = kZeroTime;
- cache_record.cache_size = kDefaultEntrySize;
- EXPECT_TRUE(db.InsertCache(&cache_record));
- AppCacheDatabase::EntryRecord entry_record;
- entry_record.cache_id = 1;
- entry_record.url = manifest_url;
- entry_record.flags = AppCacheEntry::MANIFEST;
- entry_record.response_id = 1;
- entry_record.response_size = kDefaultEntrySize;
- EXPECT_TRUE(db.InsertEntry(&entry_record));
- }
-
- // Recreate the service to point at the db and corruption on disk.
- service_.reset(new AppCacheService(NULL));
- service_->set_request_context(io_thread->request_context());
- service_->Initialize(
- temp_directory_.path(),
- db_thread->message_loop_proxy().get(),
- db_thread->message_loop_proxy().get());
- mock_quota_manager_proxy_ = new MockQuotaManagerProxy();
- service_->quota_manager_proxy_ = mock_quota_manager_proxy_;
- delegate_.reset(new MockStorageDelegate(this));
-
- // Additional setup to observe reinitailize happens.
- observer_.reset(new MockServiceObserver(this));
- service_->AddObserver(observer_.get());
-
- // We continue after the init task is complete including the callback
- // on the current thread.
- FlushDbThreadTasks();
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&AppCacheStorageImplTest::Continue_Reinitialize,
- base::Unretained(this),
- test_case));
- }
-
- void Continue_Reinitialize(int test_case) {
- const int kMockProcessId = 1;
- backend_.reset(new AppCacheBackendImpl);
- backend_->Initialize(service_.get(), &frontend_, kMockProcessId);
-
- if (test_case == 1) {
- // Try to create a new appcache, the resulting update job will
- // eventually fail when it gets to disk cache initialization.
- backend_->RegisterHost(1);
- AppCacheHost* host1 = backend_->GetHost(1);
- const GURL kEmptyPageUrl(MockHttpServer::GetMockUrl("empty.html"));
- host1->first_party_url_ = kEmptyPageUrl;
- host1->SelectCache(kEmptyPageUrl,
- kNoCacheId,
- MockHttpServer::GetMockUrl("manifest"));
- } else {
- ASSERT_EQ(2, test_case);
- // Try to access the existing cache manifest.
- // The URLRequestJob will eventually fail when it gets to disk
- // cache initialization.
- backend_->RegisterHost(2);
- AppCacheHost* host2 = backend_->GetHost(2);
- GURL manifest_url = MockHttpServer::GetMockUrl("manifest");
- request_ = service()->request_context()->CreateRequest(
- manifest_url, net::DEFAULT_PRIORITY, NULL);
- AppCacheInterceptor::SetExtraRequestInfo(
- request_.get(), service_.get(),
- backend_->process_id(), host2->host_id(),
- ResourceType::MAIN_FRAME);
- request_->Start();
- }
-
- PushNextTask(base::Bind(
- &AppCacheStorageImplTest::Verify_Reinitialized,
- base::Unretained(this),
- test_case));
- }
-
- void Verify_Reinitialized(int test_case) {
- // Verify we got notified of reinit and a new storage instance is created,
- // and that the old data has been deleted.
- EXPECT_TRUE(observer_->observed_old_storage_.get());
- EXPECT_TRUE(observer_->observed_old_storage_->storage() != storage());
- EXPECT_FALSE(PathExists(
- temp_directory_.path().AppendASCII("Cache").AppendASCII("index")));
- EXPECT_FALSE(PathExists(
- temp_directory_.path().AppendASCII("Index")));
-
- // Verify that the hosts saw appropriate events.
- if (test_case == 1) {
- EXPECT_TRUE(frontend_.error_event_was_raised_);
- AppCacheHost* host1 = backend_->GetHost(1);
- EXPECT_FALSE(host1->associated_cache());
- EXPECT_FALSE(host1->group_being_updated_);
- EXPECT_TRUE(host1->disabled_storage_reference_.get());
- } else {
- ASSERT_EQ(2, test_case);
- AppCacheHost* host2 = backend_->GetHost(2);
- EXPECT_EQ(1, host2->main_resource_cache_->cache_id());
- EXPECT_TRUE(host2->disabled_storage_reference_.get());
- }
-
- // Cleanup and claim victory.
- service_->RemoveObserver(observer_.get());
- request_.reset();
- backend_.reset();
- observer_.reset();
- TestFinished();
- }
-
- // Test case helpers --------------------------------------------------
-
- AppCacheService* service() {
- return service_.get();
- }
-
- AppCacheStorageImpl* storage() {
- return static_cast<AppCacheStorageImpl*>(service()->storage());
- }
-
- AppCacheDatabase* database() {
- return storage()->database_;
- }
-
- MockStorageDelegate* delegate() {
- return delegate_.get();
- }
-
- void MakeCacheAndGroup(
- const GURL& manifest_url, int64 group_id, int64 cache_id,
- bool add_to_database) {
- AppCacheEntry default_entry(
- AppCacheEntry::EXPLICIT, cache_id + kDefaultEntryIdOffset,
- kDefaultEntrySize);
- group_ = new AppCacheGroup(storage(), manifest_url, group_id);
- cache_ = new AppCache(storage(), cache_id);
- cache_->AddEntry(kDefaultEntryUrl, default_entry);
- cache_->set_complete(true);
- group_->AddCache(cache_.get());
- if (add_to_database) {
- AppCacheDatabase::GroupRecord group_record;
- group_record.group_id = group_id;
- group_record.manifest_url = manifest_url;
- group_record.origin = manifest_url.GetOrigin();
- EXPECT_TRUE(database()->InsertGroup(&group_record));
- AppCacheDatabase::CacheRecord cache_record;
- cache_record.cache_id = cache_id;
- cache_record.group_id = group_id;
- cache_record.online_wildcard = false;
- cache_record.update_time = kZeroTime;
- cache_record.cache_size = kDefaultEntrySize;
- EXPECT_TRUE(database()->InsertCache(&cache_record));
- AppCacheDatabase::EntryRecord entry_record;
- entry_record.cache_id = cache_id;
- entry_record.url = kDefaultEntryUrl;
- entry_record.flags = default_entry.types();
- entry_record.response_id = default_entry.response_id();
- entry_record.response_size = default_entry.response_size();
- EXPECT_TRUE(database()->InsertEntry(&entry_record));
-
- storage()->usage_map_[manifest_url.GetOrigin()] =
- default_entry.response_size();
- }
- }
-
- // Data members --------------------------------------------------
-
- scoped_ptr<base::WaitableEvent> test_finished_event_;
- std::stack<base::Closure> task_stack_;
- scoped_ptr<AppCacheService> service_;
- scoped_ptr<MockStorageDelegate> delegate_;
- scoped_refptr<MockQuotaManagerProxy> mock_quota_manager_proxy_;
- scoped_refptr<AppCacheGroup> group_;
- scoped_refptr<AppCache> cache_;
- scoped_refptr<AppCache> cache2_;
-
- // Specifically for the Reinitalize test.
- base::ScopedTempDir temp_directory_;
- scoped_ptr<MockServiceObserver> observer_;
- MockAppCacheFrontend frontend_;
- scoped_ptr<AppCacheBackendImpl> backend_;
- scoped_ptr<net::URLRequest> request_;
-};
-
-
-TEST_F(AppCacheStorageImplTest, LoadCache_Miss) {
- RunTestOnIOThread(&AppCacheStorageImplTest::LoadCache_Miss);
-}
-
-TEST_F(AppCacheStorageImplTest, LoadCache_NearHit) {
- RunTestOnIOThread(&AppCacheStorageImplTest::LoadCache_NearHit);
-}
-
-TEST_F(AppCacheStorageImplTest, CreateGroupInEmptyOrigin) {
- RunTestOnIOThread(&AppCacheStorageImplTest::CreateGroupInEmptyOrigin);
-}
-
-TEST_F(AppCacheStorageImplTest, CreateGroupInPopulatedOrigin) {
- RunTestOnIOThread(&AppCacheStorageImplTest::CreateGroupInPopulatedOrigin);
-}
-
-TEST_F(AppCacheStorageImplTest, LoadGroupAndCache_FarHit) {
- RunTestOnIOThread(&AppCacheStorageImplTest::LoadGroupAndCache_FarHit);
-}
-
-TEST_F(AppCacheStorageImplTest, StoreNewGroup) {
- RunTestOnIOThread(&AppCacheStorageImplTest::StoreNewGroup);
-}
-
-TEST_F(AppCacheStorageImplTest, StoreExistingGroup) {
- RunTestOnIOThread(&AppCacheStorageImplTest::StoreExistingGroup);
-}
-
-TEST_F(AppCacheStorageImplTest, StoreExistingGroupExistingCache) {
- RunTestOnIOThread(&AppCacheStorageImplTest::StoreExistingGroupExistingCache);
-}
-
-TEST_F(AppCacheStorageImplTest, FailStoreGroup) {
- RunTestOnIOThread(&AppCacheStorageImplTest::FailStoreGroup);
-}
-
-TEST_F(AppCacheStorageImplTest, MakeGroupObsolete) {
- RunTestOnIOThread(&AppCacheStorageImplTest::MakeGroupObsolete);
-}
-
-TEST_F(AppCacheStorageImplTest, MarkEntryAsForeign) {
- RunTestOnIOThread(&AppCacheStorageImplTest::MarkEntryAsForeign);
-}
-
-TEST_F(AppCacheStorageImplTest, MarkEntryAsForeignWithLoadInProgress) {
- RunTestOnIOThread(
- &AppCacheStorageImplTest::MarkEntryAsForeignWithLoadInProgress);
-}
-
-TEST_F(AppCacheStorageImplTest, FindNoMainResponse) {
- RunTestOnIOThread(&AppCacheStorageImplTest::FindNoMainResponse);
-}
-
-TEST_F(AppCacheStorageImplTest, BasicFindMainResponseInDatabase) {
- RunTestOnIOThread(
- &AppCacheStorageImplTest::BasicFindMainResponseInDatabase);
-}
-
-TEST_F(AppCacheStorageImplTest, BasicFindMainResponseInWorkingSet) {
- RunTestOnIOThread(
- &AppCacheStorageImplTest::BasicFindMainResponseInWorkingSet);
-}
-
-TEST_F(AppCacheStorageImplTest, BasicFindMainFallbackResponseInDatabase) {
- RunTestOnIOThread(
- &AppCacheStorageImplTest::BasicFindMainFallbackResponseInDatabase);
-}
-
-TEST_F(AppCacheStorageImplTest, BasicFindMainFallbackResponseInWorkingSet) {
- RunTestOnIOThread(
- &AppCacheStorageImplTest::BasicFindMainFallbackResponseInWorkingSet);
-}
-
-TEST_F(AppCacheStorageImplTest, BasicFindMainInterceptResponseInDatabase) {
- RunTestOnIOThread(
- &AppCacheStorageImplTest::BasicFindMainInterceptResponseInDatabase);
-}
-
-TEST_F(AppCacheStorageImplTest, BasicFindMainInterceptResponseInWorkingSet) {
- RunTestOnIOThread(
- &AppCacheStorageImplTest::BasicFindMainInterceptResponseInWorkingSet);
-}
-
-TEST_F(AppCacheStorageImplTest, FindMainResponseWithMultipleHits) {
- RunTestOnIOThread(
- &AppCacheStorageImplTest::FindMainResponseWithMultipleHits);
-}
-
-TEST_F(AppCacheStorageImplTest, FindMainResponseExclusionsInDatabase) {
- RunTestOnIOThread(
- &AppCacheStorageImplTest::FindMainResponseExclusionsInDatabase);
-}
-
-TEST_F(AppCacheStorageImplTest, FindMainResponseExclusionsInWorkingSet) {
- RunTestOnIOThread(
- &AppCacheStorageImplTest::FindMainResponseExclusionsInWorkingSet);
-}
-
-TEST_F(AppCacheStorageImplTest, FindInterceptPatternMatchInWorkingSet) {
- RunTestOnIOThread(
- &AppCacheStorageImplTest::FindInterceptPatternMatchInWorkingSet);
-}
-
-TEST_F(AppCacheStorageImplTest, FindInterceptPatternMatchInDatabase) {
- RunTestOnIOThread(
- &AppCacheStorageImplTest::FindInterceptPatternMatchInDatabase);
-}
-
-TEST_F(AppCacheStorageImplTest, FindFallbackPatternMatchInWorkingSet) {
- RunTestOnIOThread(
- &AppCacheStorageImplTest::FindFallbackPatternMatchInWorkingSet);
-}
-
-TEST_F(AppCacheStorageImplTest, FindFallbackPatternMatchInDatabase) {
- RunTestOnIOThread(
- &AppCacheStorageImplTest::FindFallbackPatternMatchInDatabase);
-}
-
-TEST_F(AppCacheStorageImplTest, Reinitialize1) {
- RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize1);
-}
-
-TEST_F(AppCacheStorageImplTest, Reinitialize2) {
- RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2);
-}
-
-// That's all folks!
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/appcache_storage_unittest.cc b/chromium/webkit/browser/appcache/appcache_storage_unittest.cc
deleted file mode 100644
index 32bca0c434d..00000000000
--- a/chromium/webkit/browser/appcache/appcache_storage_unittest.cc
+++ /dev/null
@@ -1,165 +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 "base/message_loop/message_loop.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/appcache/appcache.h"
-#include "webkit/browser/appcache/appcache_group.h"
-#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/appcache_storage.h"
-#include "webkit/browser/appcache/mock_appcache_service.h"
-#include "webkit/browser/quota/mock_quota_manager.h"
-
-namespace appcache {
-
-namespace {
-const quota::StorageType kTemp = quota::kStorageTypeTemporary;
-}
-
-class AppCacheStorageTest : public testing::Test {
- public:
- class MockStorageDelegate : public AppCacheStorage::Delegate {
- public:
- };
-};
-
-TEST_F(AppCacheStorageTest, AddRemoveCache) {
- MockAppCacheService service;
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), 111));
-
- EXPECT_EQ(cache.get(),
- service.storage()->working_set()->GetCache(111));
-
- service.storage()->working_set()->RemoveCache(cache.get());
-
- EXPECT_TRUE(!service.storage()->working_set()->GetCache(111));
-
- // Removing non-existing cache from service should not fail.
- MockAppCacheService dummy;
- dummy.storage()->working_set()->RemoveCache(cache.get());
-}
-
-TEST_F(AppCacheStorageTest, AddRemoveGroup) {
- MockAppCacheService service;
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service.storage(), GURL(), 111));
-
- EXPECT_EQ(group.get(), service.storage()->working_set()->GetGroup(GURL()));
-
- service.storage()->working_set()->RemoveGroup(group.get());
-
- EXPECT_TRUE(!service.storage()->working_set()->GetGroup(GURL()));
-
- // Removing non-existing group from service should not fail.
- MockAppCacheService dummy;
- dummy.storage()->working_set()->RemoveGroup(group.get());
-}
-
-TEST_F(AppCacheStorageTest, AddRemoveResponseInfo) {
- MockAppCacheService service;
- scoped_refptr<AppCacheResponseInfo> info(
- new AppCacheResponseInfo(service.storage(), GURL(),
- 111, new net::HttpResponseInfo,
- kUnkownResponseDataSize));
-
- EXPECT_EQ(info.get(),
- service.storage()->working_set()->GetResponseInfo(111));
-
- service.storage()->working_set()->RemoveResponseInfo(info.get());
-
- EXPECT_TRUE(!service.storage()->working_set()->GetResponseInfo(111));
-
- // Removing non-existing info from service should not fail.
- MockAppCacheService dummy;
- dummy.storage()->working_set()->RemoveResponseInfo(info.get());
-}
-
-TEST_F(AppCacheStorageTest, DelegateReferences) {
- typedef scoped_refptr<AppCacheStorage::DelegateReference>
- ScopedDelegateReference;
- MockAppCacheService service;
- MockStorageDelegate delegate;
- ScopedDelegateReference delegate_reference1;
- ScopedDelegateReference delegate_reference2;
-
- EXPECT_FALSE(service.storage()->GetDelegateReference(&delegate));
-
- delegate_reference1 =
- service.storage()->GetOrCreateDelegateReference(&delegate);
- EXPECT_TRUE(delegate_reference1.get());
- EXPECT_TRUE(delegate_reference1->HasOneRef());
- EXPECT_TRUE(service.storage()->GetDelegateReference(&delegate));
- EXPECT_EQ(&delegate,
- service.storage()->GetDelegateReference(&delegate)->delegate);
- EXPECT_EQ(service.storage()->GetDelegateReference(&delegate),
- service.storage()->GetOrCreateDelegateReference(&delegate));
- delegate_reference1 = NULL;
- EXPECT_FALSE(service.storage()->GetDelegateReference(&delegate));
-
- delegate_reference1 =
- service.storage()->GetOrCreateDelegateReference(&delegate);
- service.storage()->CancelDelegateCallbacks(&delegate);
- EXPECT_TRUE(delegate_reference1.get());
- EXPECT_TRUE(delegate_reference1->HasOneRef());
- EXPECT_FALSE(delegate_reference1->delegate);
- EXPECT_FALSE(service.storage()->GetDelegateReference(&delegate));
-
- delegate_reference2 =
- service.storage()->GetOrCreateDelegateReference(&delegate);
- EXPECT_TRUE(delegate_reference2.get());
- EXPECT_TRUE(delegate_reference2->HasOneRef());
- EXPECT_EQ(&delegate, delegate_reference2->delegate);
- EXPECT_NE(delegate_reference1.get(), delegate_reference2.get());
-}
-
-TEST_F(AppCacheStorageTest, UsageMap) {
- const GURL kOrigin("http://origin/");
- const GURL kOrigin2("http://origin2/");
-
- MockAppCacheService service;
- scoped_refptr<quota::MockQuotaManagerProxy> mock_proxy(
- new quota::MockQuotaManagerProxy(NULL, NULL));
- service.set_quota_manager_proxy(mock_proxy.get());
-
- service.storage()->UpdateUsageMapAndNotify(kOrigin, 0);
- EXPECT_EQ(0, mock_proxy->notify_storage_modified_count());
-
- service.storage()->UpdateUsageMapAndNotify(kOrigin, 10);
- EXPECT_EQ(1, mock_proxy->notify_storage_modified_count());
- EXPECT_EQ(10, mock_proxy->last_notified_delta());
- EXPECT_EQ(kOrigin, mock_proxy->last_notified_origin());
- EXPECT_EQ(kTemp, mock_proxy->last_notified_type());
-
- service.storage()->UpdateUsageMapAndNotify(kOrigin, 100);
- EXPECT_EQ(2, mock_proxy->notify_storage_modified_count());
- EXPECT_EQ(90, mock_proxy->last_notified_delta());
- EXPECT_EQ(kOrigin, mock_proxy->last_notified_origin());
- EXPECT_EQ(kTemp, mock_proxy->last_notified_type());
-
- service.storage()->UpdateUsageMapAndNotify(kOrigin, 0);
- EXPECT_EQ(3, mock_proxy->notify_storage_modified_count());
- EXPECT_EQ(-100, mock_proxy->last_notified_delta());
- EXPECT_EQ(kOrigin, mock_proxy->last_notified_origin());
- EXPECT_EQ(kTemp, mock_proxy->last_notified_type());
-
- service.storage()->NotifyStorageAccessed(kOrigin2);
- EXPECT_EQ(0, mock_proxy->notify_storage_accessed_count());
-
- service.storage()->usage_map_[kOrigin2] = 1;
- service.storage()->NotifyStorageAccessed(kOrigin2);
- EXPECT_EQ(1, mock_proxy->notify_storage_accessed_count());
- EXPECT_EQ(kOrigin2, mock_proxy->last_notified_origin());
- EXPECT_EQ(kTemp, mock_proxy->last_notified_type());
-
- service.storage()->usage_map_.clear();
- service.storage()->usage_map_[kOrigin] = 5000;
- service.storage()->ClearUsageMapAndNotify();
- EXPECT_EQ(4, mock_proxy->notify_storage_modified_count());
- EXPECT_EQ(-5000, mock_proxy->last_notified_delta());
- EXPECT_EQ(kOrigin, mock_proxy->last_notified_origin());
- EXPECT_EQ(kTemp, mock_proxy->last_notified_type());
- EXPECT_TRUE(service.storage()->usage_map_.empty());
-}
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/appcache_test_helper.cc b/chromium/webkit/browser/appcache/appcache_test_helper.cc
deleted file mode 100644
index f457d40a938..00000000000
--- a/chromium/webkit/browser/appcache/appcache_test_helper.cc
+++ /dev/null
@@ -1,80 +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.
-
-#include "webkit/browser/appcache/appcache_test_helper.h"
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/message_loop/message_loop.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/appcache/appcache.h"
-#include "webkit/browser/appcache/appcache_entry.h"
-#include "webkit/browser/appcache/appcache_group.h"
-#include "webkit/browser/appcache/appcache_service.h"
-
-namespace appcache {
-
-AppCacheTestHelper::AppCacheTestHelper()
- : group_id_(0),
- appcache_id_(0),
- response_id_(0),
- origins_(NULL) {}
-
-AppCacheTestHelper::~AppCacheTestHelper() {}
-
-void AppCacheTestHelper::OnGroupAndNewestCacheStored(
- AppCacheGroup* /*group*/,
- AppCache* /*newest_cache*/,
- bool success,
- bool /*would_exceed_quota*/) {
- ASSERT_TRUE(success);
- base::MessageLoop::current()->Quit();
-}
-
-void AppCacheTestHelper::AddGroupAndCache(AppCacheService* appcache_service,
- const GURL& manifest_url) {
- AppCacheGroup* appcache_group =
- new AppCacheGroup(appcache_service->storage(),
- manifest_url,
- ++group_id_);
- AppCache* appcache = new AppCache(appcache_service->storage(),
- ++appcache_id_);
- AppCacheEntry entry(AppCacheEntry::MANIFEST,
- ++response_id_);
- appcache->AddEntry(manifest_url, entry);
- appcache->set_complete(true);
- appcache_group->AddCache(appcache);
- appcache_service->storage()->StoreGroupAndNewestCache(appcache_group,
- appcache,
- this);
- // OnGroupAndNewestCacheStored will quit the message loop.
- base::MessageLoop::current()->Run();
-}
-
-void AppCacheTestHelper::GetOriginsWithCaches(AppCacheService* appcache_service,
- std::set<GURL>* origins) {
- appcache_info_ = new AppCacheInfoCollection;
- origins_ = origins;
- appcache_service->GetAllAppCacheInfo(
- appcache_info_.get(),
- base::Bind(&AppCacheTestHelper::OnGotAppCacheInfo,
- base::Unretained(this)));
-
- // OnGotAppCacheInfo will quit the message loop.
- base::MessageLoop::current()->Run();
-}
-
-void AppCacheTestHelper::OnGotAppCacheInfo(int rv) {
- typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin;
-
- origins_->clear();
- for (InfoByOrigin::const_iterator origin =
- appcache_info_->infos_by_origin.begin();
- origin != appcache_info_->infos_by_origin.end(); ++origin) {
- origins_->insert(origin->first);
- }
- base::MessageLoop::current()->Quit();
-}
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/appcache_test_helper.h b/chromium/webkit/browser/appcache/appcache_test_helper.h
deleted file mode 100644
index 4e21cb3ca7c..00000000000
--- a/chromium/webkit/browser/appcache/appcache_test_helper.h
+++ /dev/null
@@ -1,46 +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.
-
-#ifndef WEBKIT_BROWSER_APPCACHE_APPCACHE_TEST_HELPER_H_
-#define WEBKIT_BROWSER_APPCACHE_APPCACHE_TEST_HELPER_H_
-
-#include <set>
-
-#include "webkit/browser/appcache/appcache_storage.h"
-
-namespace appcache {
-
-class AppCacheService;
-
-// Helper class for inserting data into a ChromeAppCacheService and reading it
-// back.
-class AppCacheTestHelper : public appcache::AppCacheStorage::Delegate {
- public:
- AppCacheTestHelper();
- virtual ~AppCacheTestHelper();
- void AddGroupAndCache(AppCacheService* appcache_service,
- const GURL& manifest_url);
-
- void GetOriginsWithCaches(AppCacheService* appcache_service,
- std::set<GURL>* origins);
- private:
- virtual void OnGroupAndNewestCacheStored(
- appcache::AppCacheGroup* group,
- appcache::AppCache* newest_cache,
- bool success,
- bool would_exceed_quota) OVERRIDE;
- void OnGotAppCacheInfo(int rv);
-
- int group_id_;
- int appcache_id_;
- int response_id_;
- scoped_refptr<appcache::AppCacheInfoCollection> appcache_info_;
- std::set<GURL>* origins_; // not owned
-
- DISALLOW_COPY_AND_ASSIGN(AppCacheTestHelper);
-};
-
-} // namespace appcache
-
-#endif // WEBKIT_BROWSER_APPCACHE_APPCACHE_TEST_HELPER_H_
diff --git a/chromium/webkit/browser/appcache/appcache_unittest.cc b/chromium/webkit/browser/appcache/appcache_unittest.cc
deleted file mode 100644
index c0e49204c6f..00000000000
--- a/chromium/webkit/browser/appcache/appcache_unittest.cc
+++ /dev/null
@@ -1,695 +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 "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/appcache/appcache.h"
-#include "webkit/browser/appcache/appcache_host.h"
-#include "webkit/browser/appcache/mock_appcache_service.h"
-
-namespace appcache {
-
-namespace {
-
-class MockAppCacheFrontend : public AppCacheFrontend {
- public:
- virtual void OnCacheSelected(
- int host_id, const appcache::AppCacheInfo& info) OVERRIDE {}
- virtual void OnStatusChanged(const std::vector<int>& host_ids,
- Status status) OVERRIDE {}
- virtual void OnEventRaised(const std::vector<int>& host_ids,
- EventID event_id) OVERRIDE {}
- virtual void OnProgressEventRaised(
- const std::vector<int>& host_ids,
- const GURL& url,
- int num_total, int num_complete) OVERRIDE {}
- virtual void OnErrorEventRaised(const std::vector<int>& host_ids,
- const std::string& message) OVERRIDE {}
- virtual void OnLogMessage(int host_id, LogLevel log_level,
- const std::string& message) OVERRIDE {}
- virtual void OnContentBlocked(
- int host_id, const GURL& manifest_url) OVERRIDE {}
-};
-
-} // namespace
-
-class AppCacheTest : public testing::Test {
-};
-
-TEST(AppCacheTest, CleanupUnusedCache) {
- MockAppCacheService service;
- MockAppCacheFrontend frontend;
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), 111));
- cache->set_complete(true);
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service.storage(), GURL("http://blah/manifest"), 111));
- group->AddCache(cache.get());
-
- AppCacheHost host1(1, &frontend, &service);
- AppCacheHost host2(2, &frontend, &service);
-
- host1.AssociateCompleteCache(cache.get());
- host2.AssociateCompleteCache(cache.get());
-
- host1.AssociateNoCache(GURL());
- host2.AssociateNoCache(GURL());
-}
-
-TEST(AppCacheTest, AddModifyRemoveEntry) {
- MockAppCacheService service;
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), 111));
-
- EXPECT_TRUE(cache->entries().empty());
- EXPECT_EQ(0L, cache->cache_size());
-
- const GURL kFooUrl("http://foo.com");
- const int64 kFooResponseId = 1;
- const int64 kFooSize = 100;
- AppCacheEntry entry1(AppCacheEntry::MASTER, kFooResponseId, kFooSize);
- cache->AddEntry(kFooUrl, entry1);
- EXPECT_EQ(entry1.types(), cache->GetEntry(kFooUrl)->types());
- EXPECT_EQ(1UL, cache->entries().size());
- EXPECT_EQ(kFooSize, cache->cache_size());
-
- const GURL kBarUrl("http://bar.com");
- const int64 kBarResponseId = 2;
- const int64 kBarSize = 200;
- AppCacheEntry entry2(AppCacheEntry::FALLBACK, kBarResponseId, kBarSize);
- EXPECT_TRUE(cache->AddOrModifyEntry(kBarUrl, entry2));
- EXPECT_EQ(entry2.types(), cache->GetEntry(kBarUrl)->types());
- EXPECT_EQ(2UL, cache->entries().size());
- EXPECT_EQ(kFooSize + kBarSize, cache->cache_size());
-
- // Expected to return false when an existing entry is modified.
- AppCacheEntry entry3(AppCacheEntry::EXPLICIT);
- EXPECT_FALSE(cache->AddOrModifyEntry(kFooUrl, entry3));
- EXPECT_EQ((AppCacheEntry::MASTER | AppCacheEntry::EXPLICIT),
- cache->GetEntry(kFooUrl)->types());
- // Only the type should be modified.
- EXPECT_EQ(kFooResponseId, cache->GetEntry(kFooUrl)->response_id());
- EXPECT_EQ(kFooSize, cache->GetEntry(kFooUrl)->response_size());
- EXPECT_EQ(kFooSize + kBarSize, cache->cache_size());
-
- EXPECT_EQ(entry2.types(), cache->GetEntry(kBarUrl)->types()); // unchanged
-
- cache->RemoveEntry(kBarUrl);
- EXPECT_EQ(kFooSize, cache->cache_size());
- cache->RemoveEntry(kFooUrl);
- EXPECT_EQ(0L, cache->cache_size());
- EXPECT_TRUE(cache->entries().empty());
-}
-
-TEST(AppCacheTest, InitializeWithManifest) {
- MockAppCacheService service;
-
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), 1234));
- EXPECT_TRUE(cache->fallback_namespaces_.empty());
- EXPECT_TRUE(cache->online_whitelist_namespaces_.empty());
- EXPECT_FALSE(cache->online_whitelist_all_);
-
- Manifest manifest;
- manifest.explicit_urls.insert("http://one.com");
- manifest.explicit_urls.insert("http://two.com");
- manifest.fallback_namespaces.push_back(
- Namespace(FALLBACK_NAMESPACE, GURL("http://fb1.com"),
- GURL("http://fbone.com"), true));
- manifest.online_whitelist_namespaces.push_back(
- Namespace(NETWORK_NAMESPACE, GURL("http://w1.com"), GURL(), false));
- manifest.online_whitelist_namespaces.push_back(
- Namespace(NETWORK_NAMESPACE, GURL("http://w2.com"), GURL(), false));
- manifest.online_whitelist_all = true;
-
- cache->InitializeWithManifest(&manifest);
- const std::vector<Namespace>& fallbacks =
- cache->fallback_namespaces_;
- size_t expected = 1;
- EXPECT_EQ(expected, fallbacks.size());
- EXPECT_EQ(GURL("http://fb1.com"), fallbacks[0].namespace_url);
- EXPECT_EQ(GURL("http://fbone.com"), fallbacks[0].target_url);
- EXPECT_TRUE(fallbacks[0].is_pattern);
- const NamespaceVector& whitelist = cache->online_whitelist_namespaces_;
- expected = 2;
- EXPECT_EQ(expected, whitelist.size());
- EXPECT_EQ(GURL("http://w1.com"), whitelist[0].namespace_url);
- EXPECT_EQ(GURL("http://w2.com"), whitelist[1].namespace_url);
- EXPECT_TRUE(cache->online_whitelist_all_);
-
- // Ensure collections in manifest were taken over by the cache rather than
- // copied.
- EXPECT_TRUE(manifest.fallback_namespaces.empty());
- EXPECT_TRUE(manifest.online_whitelist_namespaces.empty());
-}
-
-TEST(AppCacheTest, FindResponseForRequest) {
- MockAppCacheService service;
-
- const GURL kOnlineNamespaceUrl("http://blah/online_namespace");
- const GURL kFallbackEntryUrl1("http://blah/fallback_entry1");
- const GURL kFallbackNamespaceUrl1("http://blah/fallback_namespace/");
- const GURL kFallbackEntryUrl2("http://blah/fallback_entry2");
- const GURL kFallbackNamespaceUrl2("http://blah/fallback_namespace/longer");
- const GURL kManifestUrl("http://blah/manifest");
- const GURL kForeignExplicitEntryUrl("http://blah/foreign");
- const GURL kInOnlineNamespaceUrl(
- "http://blah/online_namespace/network");
- const GURL kExplicitInOnlineNamespaceUrl(
- "http://blah/online_namespace/explicit");
- const GURL kFallbackTestUrl1("http://blah/fallback_namespace/1");
- const GURL kFallbackTestUrl2("http://blah/fallback_namespace/longer2");
- const GURL kInterceptNamespace("http://blah/intercept_namespace/");
- const GURL kInterceptNamespaceWithinFallback(
- "http://blah/fallback_namespace/intercept_namespace/");
- const GURL kInterceptNamespaceEntry("http://blah/intercept_entry");
- const GURL kOnlineNamespaceWithinOtherNamespaces(
- "http://blah/fallback_namespace/intercept_namespace/1/online");
-
- const int64 kFallbackResponseId1 = 1;
- const int64 kFallbackResponseId2 = 2;
- const int64 kManifestResponseId = 3;
- const int64 kForeignExplicitResponseId = 4;
- const int64 kExplicitInOnlineNamespaceResponseId = 5;
- const int64 kInterceptResponseId = 6;
-
- Manifest manifest;
- manifest.online_whitelist_namespaces.push_back(
- Namespace(NETWORK_NAMESPACE, kOnlineNamespaceUrl,
- GURL(), false));
- manifest.online_whitelist_namespaces.push_back(
- Namespace(NETWORK_NAMESPACE, kOnlineNamespaceWithinOtherNamespaces,
- GURL(), false));
- manifest.fallback_namespaces.push_back(
- Namespace(FALLBACK_NAMESPACE, kFallbackNamespaceUrl1,
- kFallbackEntryUrl1, false));
- manifest.fallback_namespaces.push_back(
- Namespace(FALLBACK_NAMESPACE, kFallbackNamespaceUrl2,
- kFallbackEntryUrl2, false));
- manifest.intercept_namespaces.push_back(
- Namespace(INTERCEPT_NAMESPACE, kInterceptNamespace,
- kInterceptNamespaceEntry, false));
- manifest.intercept_namespaces.push_back(
- Namespace(INTERCEPT_NAMESPACE, kInterceptNamespaceWithinFallback,
- kInterceptNamespaceEntry, false));
-
- // Create a cache with some namespaces and entries.
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), 1234));
- cache->InitializeWithManifest(&manifest);
- cache->AddEntry(
- kFallbackEntryUrl1,
- AppCacheEntry(AppCacheEntry::FALLBACK, kFallbackResponseId1));
- cache->AddEntry(
- kFallbackEntryUrl2,
- AppCacheEntry(AppCacheEntry::FALLBACK, kFallbackResponseId2));
- cache->AddEntry(
- kManifestUrl,
- AppCacheEntry(AppCacheEntry::MANIFEST, kManifestResponseId));
- cache->AddEntry(
- kForeignExplicitEntryUrl,
- AppCacheEntry(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN,
- kForeignExplicitResponseId));
- cache->AddEntry(
- kExplicitInOnlineNamespaceUrl,
- AppCacheEntry(AppCacheEntry::EXPLICIT,
- kExplicitInOnlineNamespaceResponseId));
- cache->AddEntry(
- kInterceptNamespaceEntry,
- AppCacheEntry(AppCacheEntry::INTERCEPT, kInterceptResponseId));
- cache->set_complete(true);
-
- // See that we get expected results from FindResponseForRequest
-
- bool found = false;
- AppCacheEntry entry;
- AppCacheEntry fallback_entry;
- GURL intercept_namespace;
- GURL fallback_namespace;
- bool network_namespace = false;
-
- found = cache->FindResponseForRequest(GURL("http://blah/miss"),
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_FALSE(found);
-
- found = cache->FindResponseForRequest(kForeignExplicitEntryUrl,
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_TRUE(found);
- EXPECT_EQ(kForeignExplicitResponseId, entry.response_id());
- EXPECT_FALSE(fallback_entry.has_response_id());
- EXPECT_FALSE(network_namespace);
-
- entry = AppCacheEntry(); // reset
-
- found = cache->FindResponseForRequest(kManifestUrl,
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_TRUE(found);
- EXPECT_EQ(kManifestResponseId, entry.response_id());
- EXPECT_FALSE(fallback_entry.has_response_id());
- EXPECT_FALSE(network_namespace);
-
- entry = AppCacheEntry(); // reset
-
- found = cache->FindResponseForRequest(kInOnlineNamespaceUrl,
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_TRUE(found);
- EXPECT_FALSE(entry.has_response_id());
- EXPECT_FALSE(fallback_entry.has_response_id());
- EXPECT_TRUE(network_namespace);
-
- network_namespace = false; // reset
-
- found = cache->FindResponseForRequest(kExplicitInOnlineNamespaceUrl,
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_TRUE(found);
- EXPECT_EQ(kExplicitInOnlineNamespaceResponseId, entry.response_id());
- EXPECT_FALSE(fallback_entry.has_response_id());
- EXPECT_FALSE(network_namespace);
-
- entry = AppCacheEntry(); // reset
-
- found = cache->FindResponseForRequest(kFallbackTestUrl1,
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_TRUE(found);
- EXPECT_FALSE(entry.has_response_id());
- EXPECT_EQ(kFallbackResponseId1, fallback_entry.response_id());
- EXPECT_EQ(kFallbackEntryUrl1,
- cache->GetFallbackEntryUrl(fallback_namespace));
- EXPECT_FALSE(network_namespace);
-
- fallback_entry = AppCacheEntry(); // reset
-
- found = cache->FindResponseForRequest(kFallbackTestUrl2,
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_TRUE(found);
- EXPECT_FALSE(entry.has_response_id());
- EXPECT_EQ(kFallbackResponseId2, fallback_entry.response_id());
- EXPECT_EQ(kFallbackEntryUrl2,
- cache->GetFallbackEntryUrl(fallback_namespace));
- EXPECT_FALSE(network_namespace);
-
- fallback_entry = AppCacheEntry(); // reset
-
- found = cache->FindResponseForRequest(kOnlineNamespaceWithinOtherNamespaces,
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_TRUE(found);
- EXPECT_FALSE(entry.has_response_id());
- EXPECT_FALSE(fallback_entry.has_response_id());
- EXPECT_TRUE(network_namespace);
-
- fallback_entry = AppCacheEntry(); // reset
-
- found = cache->FindResponseForRequest(
- kOnlineNamespaceWithinOtherNamespaces.Resolve("online_resource"),
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_TRUE(found);
- EXPECT_FALSE(entry.has_response_id());
- EXPECT_FALSE(fallback_entry.has_response_id());
- EXPECT_TRUE(network_namespace);
-
- fallback_namespace = GURL();
-
- found = cache->FindResponseForRequest(
- kInterceptNamespace.Resolve("intercept_me"),
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_TRUE(found);
- EXPECT_EQ(kInterceptResponseId, entry.response_id());
- EXPECT_EQ(kInterceptNamespaceEntry,
- cache->GetInterceptEntryUrl(intercept_namespace));
- EXPECT_FALSE(fallback_entry.has_response_id());
- EXPECT_TRUE(fallback_namespace.is_empty());
- EXPECT_FALSE(network_namespace);
-
- entry = AppCacheEntry(); // reset
-
- found = cache->FindResponseForRequest(
- kInterceptNamespaceWithinFallback.Resolve("intercept_me"),
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_TRUE(found);
- EXPECT_EQ(kInterceptResponseId, entry.response_id());
- EXPECT_EQ(kInterceptNamespaceEntry,
- cache->GetInterceptEntryUrl(intercept_namespace));
- EXPECT_FALSE(fallback_entry.has_response_id());
- EXPECT_TRUE(fallback_namespace.is_empty());
- EXPECT_FALSE(network_namespace);
-}
-
-TEST(AppCacheTest, FindInterceptPatternResponseForRequest) {
- MockAppCacheService service;
-
- // Setup an appcache with an intercept namespace that uses pattern matching.
- const GURL kInterceptNamespaceBase("http://blah/intercept_namespace/");
- const GURL kInterceptPatternNamespace(
- kInterceptNamespaceBase.Resolve("*.hit*"));
- const GURL kInterceptNamespaceEntry("http://blah/intercept_resource");
- const int64 kInterceptResponseId = 1;
- Manifest manifest;
- manifest.intercept_namespaces.push_back(
- Namespace(INTERCEPT_NAMESPACE, kInterceptPatternNamespace,
- kInterceptNamespaceEntry, true));
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), 1234));
- cache->InitializeWithManifest(&manifest);
- cache->AddEntry(
- kInterceptNamespaceEntry,
- AppCacheEntry(AppCacheEntry::INTERCEPT, kInterceptResponseId));
- cache->set_complete(true);
-
- // See that the pattern match works.
- bool found = false;
- AppCacheEntry entry;
- AppCacheEntry fallback_entry;
- GURL intercept_namespace;
- GURL fallback_namespace;
- bool network_namespace = false;
-
- found = cache->FindResponseForRequest(
- GURL("http://blah/miss"),
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_FALSE(found);
-
- found = cache->FindResponseForRequest(
- GURL("http://blah/intercept_namespace/another_miss"),
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_FALSE(found);
-
- found = cache->FindResponseForRequest(
- GURL("http://blah/intercept_namespace/path.hit"),
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_TRUE(found);
- EXPECT_EQ(kInterceptResponseId, entry.response_id());
- EXPECT_EQ(kInterceptNamespaceEntry,
- cache->GetInterceptEntryUrl(intercept_namespace));
- EXPECT_FALSE(fallback_entry.has_response_id());
- EXPECT_TRUE(fallback_namespace.is_empty());
- EXPECT_FALSE(network_namespace);
-
- entry = AppCacheEntry(); // reset
-
- found = cache->FindResponseForRequest(
- GURL("http://blah/intercept_namespace/longer/path.hit?arg=ok"),
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_TRUE(found);
- EXPECT_EQ(kInterceptResponseId, entry.response_id());
- EXPECT_EQ(kInterceptNamespaceEntry,
- cache->GetInterceptEntryUrl(intercept_namespace));
- EXPECT_FALSE(fallback_entry.has_response_id());
- EXPECT_TRUE(fallback_namespace.is_empty());
- EXPECT_FALSE(network_namespace);
-}
-
-TEST(AppCacheTest, FindFallbackPatternResponseForRequest) {
- MockAppCacheService service;
-
- // Setup an appcache with a fallback namespace that uses pattern matching.
- const GURL kFallbackNamespaceBase("http://blah/fallback_namespace/");
- const GURL kFallbackPatternNamespace(
- kFallbackNamespaceBase.Resolve("*.hit*"));
- const GURL kFallbackNamespaceEntry("http://blah/fallback_resource");
- const int64 kFallbackResponseId = 1;
- Manifest manifest;
- manifest.fallback_namespaces.push_back(
- Namespace(FALLBACK_NAMESPACE, kFallbackPatternNamespace,
- kFallbackNamespaceEntry, true));
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), 1234));
- cache->InitializeWithManifest(&manifest);
- cache->AddEntry(
- kFallbackNamespaceEntry,
- AppCacheEntry(AppCacheEntry::FALLBACK, kFallbackResponseId));
- cache->set_complete(true);
-
- // See that the pattern match works.
- bool found = false;
- AppCacheEntry entry;
- AppCacheEntry fallback_entry;
- GURL intercept_namespace;
- GURL fallback_namespace;
- bool network_namespace = false;
-
- found = cache->FindResponseForRequest(
- GURL("http://blah/miss"),
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_FALSE(found);
-
- found = cache->FindResponseForRequest(
- GURL("http://blah/fallback_namespace/another_miss"),
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_FALSE(found);
-
- found = cache->FindResponseForRequest(
- GURL("http://blah/fallback_namespace/path.hit"),
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_TRUE(found);
- EXPECT_FALSE(entry.has_response_id());
- EXPECT_EQ(kFallbackResponseId, fallback_entry.response_id());
- EXPECT_EQ(kFallbackNamespaceEntry,
- cache->GetFallbackEntryUrl(fallback_namespace));
- EXPECT_FALSE(network_namespace);
-
- fallback_entry = AppCacheEntry();
- fallback_namespace = GURL();
-
- found = cache->FindResponseForRequest(
- GURL("http://blah/fallback_namespace/longer/path.hit?arg=ok"),
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_TRUE(found);
- EXPECT_FALSE(entry.has_response_id());
- EXPECT_EQ(kFallbackResponseId, fallback_entry.response_id());
- EXPECT_EQ(kFallbackNamespaceEntry,
- cache->GetFallbackEntryUrl(fallback_namespace));
- EXPECT_TRUE(intercept_namespace.is_empty());
- EXPECT_FALSE(network_namespace);
-}
-
-
-TEST(AppCacheTest, FindNetworkNamespacePatternResponseForRequest) {
- MockAppCacheService service;
-
- // Setup an appcache with a network namespace that uses pattern matching.
- const GURL kNetworkNamespaceBase("http://blah/network_namespace/");
- const GURL kNetworkPatternNamespace(
- kNetworkNamespaceBase.Resolve("*.hit*"));
- Manifest manifest;
- manifest.online_whitelist_namespaces.push_back(
- Namespace(NETWORK_NAMESPACE, kNetworkPatternNamespace,
- GURL(), true));
- manifest.online_whitelist_all = false;
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), 1234));
- cache->InitializeWithManifest(&manifest);
- cache->set_complete(true);
-
- // See that the pattern match works.
- bool found = false;
- AppCacheEntry entry;
- AppCacheEntry fallback_entry;
- GURL intercept_namespace;
- GURL fallback_namespace;
- bool network_namespace = false;
-
- found = cache->FindResponseForRequest(
- GURL("http://blah/miss"),
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_FALSE(found);
-
- found = cache->FindResponseForRequest(
- GURL("http://blah/network_namespace/path.hit"),
- &entry, &intercept_namespace,
- &fallback_entry, &fallback_namespace,
- &network_namespace);
- EXPECT_TRUE(found);
- EXPECT_TRUE(network_namespace);
- EXPECT_FALSE(entry.has_response_id());
- EXPECT_FALSE(fallback_entry.has_response_id());
-}
-
-TEST(AppCacheTest, ToFromDatabaseRecords) {
- // Setup a cache with some entries.
- const int64 kCacheId = 1234;
- const int64 kGroupId = 4321;
- const GURL kManifestUrl("http://foo.com/manifest");
- const GURL kInterceptUrl("http://foo.com/intercept.html");
- const GURL kFallbackUrl("http://foo.com/fallback.html");
- const GURL kWhitelistUrl("http://foo.com/whitelist*");
- const std::string kData(
- "CACHE MANIFEST\r"
- "CHROMIUM-INTERCEPT:\r"
- "/intercept return /intercept.html\r"
- "FALLBACK:\r"
- "/ /fallback.html\r"
- "NETWORK:\r"
- "/whitelist* isPattern\r"
- "*\r");
- MockAppCacheService service;
- scoped_refptr<AppCacheGroup> group =
- new AppCacheGroup(service.storage(), kManifestUrl, kGroupId);
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId));
- Manifest manifest;
- EXPECT_TRUE(
- ParseManifest(kManifestUrl, kData.c_str(), kData.length(), manifest));
- cache->InitializeWithManifest(&manifest);
- EXPECT_EQ(NETWORK_NAMESPACE, cache->online_whitelist_namespaces_[0].type);
- EXPECT_TRUE(cache->online_whitelist_namespaces_[0].is_pattern);
- EXPECT_EQ(kWhitelistUrl,
- cache->online_whitelist_namespaces_[0].namespace_url);
- cache->AddEntry(
- kManifestUrl,
- AppCacheEntry(AppCacheEntry::MANIFEST, 1, 1));
- cache->AddEntry(
- kInterceptUrl,
- AppCacheEntry(AppCacheEntry::INTERCEPT, 3, 3));
- cache->AddEntry(
- kFallbackUrl,
- AppCacheEntry(AppCacheEntry::FALLBACK, 2, 2));
-
- // Get it to produce database records and verify them.
- AppCacheDatabase::CacheRecord cache_record;
- std::vector<AppCacheDatabase::EntryRecord> entries;
- std::vector<AppCacheDatabase::NamespaceRecord> intercepts;
- std::vector<AppCacheDatabase::NamespaceRecord> fallbacks;
- std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists;
- cache->ToDatabaseRecords(group.get(),
- &cache_record,
- &entries,
- &intercepts,
- &fallbacks,
- &whitelists);
- EXPECT_EQ(kCacheId, cache_record.cache_id);
- EXPECT_EQ(kGroupId, cache_record.group_id);
- EXPECT_TRUE(cache_record.online_wildcard);
- EXPECT_EQ(1 + 2 + 3, cache_record.cache_size);
- EXPECT_EQ(3u, entries.size());
- EXPECT_EQ(1u, intercepts.size());
- EXPECT_EQ(1u, fallbacks.size());
- EXPECT_EQ(1u, whitelists.size());
- cache = NULL;
-
- // Create a new AppCache and populate it with those records and verify.
- cache = new AppCache(service.storage(), kCacheId);
- cache->InitializeWithDatabaseRecords(
- cache_record, entries, intercepts,
- fallbacks, whitelists);
- EXPECT_TRUE(cache->online_whitelist_all_);
- EXPECT_EQ(3u, cache->entries().size());
- EXPECT_TRUE(cache->GetEntry(kManifestUrl));
- EXPECT_TRUE(cache->GetEntry(kInterceptUrl));
- EXPECT_TRUE(cache->GetEntry(kFallbackUrl));
- EXPECT_EQ(kInterceptUrl,
- cache->GetInterceptEntryUrl(GURL("http://foo.com/intercept")));
- EXPECT_EQ(kFallbackUrl,
- cache->GetFallbackEntryUrl(GURL("http://foo.com/")));
- EXPECT_EQ(1 + 2 + 3, cache->cache_size());
- EXPECT_EQ(NETWORK_NAMESPACE, cache->online_whitelist_namespaces_[0].type);
- EXPECT_TRUE(cache->online_whitelist_namespaces_[0].is_pattern);
- EXPECT_EQ(kWhitelistUrl,
- cache->online_whitelist_namespaces_[0].namespace_url);
-}
-
-TEST(AppCacheTest, IsNamespaceMatch) {
- Namespace prefix;
- prefix.namespace_url = GURL("http://foo.com/prefix");
- prefix.is_pattern = false;
- EXPECT_TRUE(prefix.IsMatch(
- GURL("http://foo.com/prefix_and_anothing_goes")));
- EXPECT_FALSE(prefix.IsMatch(
- GURL("http://foo.com/nope")));
-
- Namespace bar_no_star;
- bar_no_star.namespace_url = GURL("http://foo.com/bar");
- bar_no_star.is_pattern = true;
- EXPECT_TRUE(bar_no_star.IsMatch(
- GURL("http://foo.com/bar")));
- EXPECT_FALSE(bar_no_star.IsMatch(
- GURL("http://foo.com/bar/nope")));
-
- Namespace bar_star;
- bar_star.namespace_url = GURL("http://foo.com/bar/*");
- bar_star.is_pattern = true;
- EXPECT_TRUE(bar_star.IsMatch(
- GURL("http://foo.com/bar/")));
- EXPECT_TRUE(bar_star.IsMatch(
- GURL("http://foo.com/bar/should_match")));
- EXPECT_FALSE(bar_star.IsMatch(
- GURL("http://foo.com/not_bar/should_not_match")));
-
- Namespace star_bar_star;
- star_bar_star.namespace_url = GURL("http://foo.com/*/bar/*");
- star_bar_star.is_pattern = true;
- EXPECT_TRUE(star_bar_star.IsMatch(
- GURL("http://foo.com/any/bar/should_match")));
- EXPECT_TRUE(star_bar_star.IsMatch(
- GURL("http://foo.com/any/bar/")));
- EXPECT_FALSE(star_bar_star.IsMatch(
- GURL("http://foo.com/any/not_bar/no_match")));
-
- Namespace query_star_edit;
- query_star_edit.namespace_url = GURL("http://foo.com/query?id=*&verb=edit*");
- query_star_edit.is_pattern = true;
- EXPECT_TRUE(query_star_edit.IsMatch(
- GURL("http://foo.com/query?id=1234&verb=edit&option=blue")));
- EXPECT_TRUE(query_star_edit.IsMatch(
- GURL("http://foo.com/query?id=12345&option=blue&verb=edit")));
- EXPECT_FALSE(query_star_edit.IsMatch(
- GURL("http://foo.com/query?id=12345&option=blue&verb=print")));
- EXPECT_TRUE(query_star_edit.IsMatch(
- GURL("http://foo.com/query?id=123&verb=print&verb=edit")));
-
- Namespace star_greediness;
- star_greediness.namespace_url = GURL("http://foo.com/*/b");
- star_greediness.is_pattern = true;
- EXPECT_TRUE(star_greediness.IsMatch(
- GURL("http://foo.com/a/b")));
- EXPECT_TRUE(star_greediness.IsMatch(
- GURL("http://foo.com/a/wxy/z/b")));
- EXPECT_TRUE(star_greediness.IsMatch(
- GURL("http://foo.com/a/b/b")));
- EXPECT_TRUE(star_greediness.IsMatch(
- GURL("http://foo.com/b/b")));
- EXPECT_TRUE(star_greediness.IsMatch(
- GURL("http://foo.com/a/b/b/b/b/b")));
- EXPECT_TRUE(star_greediness.IsMatch(
- GURL("http://foo.com/a/b/b/b/a/b")));
- EXPECT_TRUE(star_greediness.IsMatch(
- GURL("http://foo.com/a/b/01234567890abcdef/b")));
- EXPECT_TRUE(star_greediness.IsMatch(
- GURL("http://foo.com/a/b/01234567890abcdef/b01234567890abcdef/b")));
- EXPECT_TRUE(star_greediness.IsMatch(
- GURL("http://foo.com/a/b/01234567890abcdef_eat_some_more_characters_"
- "/and_even_more_for_the_heck_of_it/01234567890abcdef/b")));
-}
-
-} // namespace appacache
diff --git a/chromium/webkit/browser/appcache/appcache_update_job.cc b/chromium/webkit/browser/appcache/appcache_update_job.cc
index 17e3bef6da6..0c5593c1deb 100644
--- a/chromium/webkit/browser/appcache/appcache_update_job.cc
+++ b/chromium/webkit/browser/appcache/appcache_update_job.cc
@@ -26,6 +26,17 @@ static const int kBufferSize = 32768;
static const size_t kMaxConcurrentUrlFetches = 2;
static const int kMax503Retries = 3;
+static std::string FormatUrlErrorMessage(
+ const char* format, const GURL& url,
+ AppCacheUpdateJob::ResultType error,
+ int response_code) {
+ // Show the net response code if we have one.
+ int code = response_code;
+ if (error != AppCacheUpdateJob::SERVER_ERROR)
+ code = static_cast<int>(error);
+ return base::StringPrintf(format, code, url.spec().c_str());
+}
+
// Helper class for collecting hosts per frontend when sending notifications
// so that only one notification is sent for all hosts using the same frontend.
class HostNotifier {
@@ -47,7 +58,7 @@ class HostNotifier {
}
}
- void SendNotifications(EventID event_id) {
+ void SendNotifications(AppCacheEventID event_id) {
for (NotifyHostMap::iterator it = hosts_to_notify.begin();
it != hosts_to_notify.end(); ++it) {
AppCacheFrontend* frontend = it->first;
@@ -65,12 +76,23 @@ class HostNotifier {
}
}
- void SendErrorNotifications(const std::string& error_message) {
- DCHECK(!error_message.empty());
+ void SendErrorNotifications(const AppCacheErrorDetails& details) {
+ DCHECK(!details.message.empty());
for (NotifyHostMap::iterator it = hosts_to_notify.begin();
it != hosts_to_notify.end(); ++it) {
AppCacheFrontend* frontend = it->first;
- frontend->OnErrorEventRaised(it->second, error_message);
+ frontend->OnErrorEventRaised(it->second, details);
+ }
+ }
+
+ void SendLogMessage(const std::string& message) {
+ for (NotifyHostMap::iterator it = hosts_to_notify.begin();
+ it != hosts_to_notify.end(); ++it) {
+ AppCacheFrontend* frontend = it->first;
+ for (HostIds::iterator id = it->second.begin();
+ id != it->second.end(); ++id) {
+ frontend->OnLogMessage(*id, APPCACHE_LOG_WARNING, message);
+ }
}
}
@@ -101,7 +123,9 @@ AppCacheUpdateJob::URLFetcher::URLFetcher(const GURL& url,
retry_503_attempts_(0),
buffer_(new net::IOBuffer(kBufferSize)),
request_(job->service_->request_context()
- ->CreateRequest(url, net::DEFAULT_PRIORITY, this)) {}
+ ->CreateRequest(url, net::DEFAULT_PRIORITY, this, NULL)),
+ result_(UPDATE_OK),
+ redirect_response_code_(-1) {}
AppCacheUpdateJob::URLFetcher::~URLFetcher() {
}
@@ -119,15 +143,22 @@ void AppCacheUpdateJob::URLFetcher::OnReceivedRedirect(
net::URLRequest* request, const GURL& new_url, bool* defer_redirect) {
DCHECK(request_ == request);
// Redirect is not allowed by the update process.
+ job_->MadeProgress();
+ redirect_response_code_ = request->GetResponseCode();
request->Cancel();
+ result_ = REDIRECT_ERROR;
OnResponseCompleted();
}
void AppCacheUpdateJob::URLFetcher::OnResponseStarted(
net::URLRequest *request) {
DCHECK(request == request_);
- if (request->status().is_success() &&
- (request->GetResponseCode() / 100) == 2) {
+ int response_code = -1;
+ if (request->status().is_success()) {
+ response_code = request->GetResponseCode();
+ job_->MadeProgress();
+ }
+ if ((response_code / 100) == 2) {
// See http://code.google.com/p/chromium/issues/detail?id=69594
// We willfully violate the HTML5 spec at this point in order
@@ -140,7 +171,9 @@ void AppCacheUpdateJob::URLFetcher::OnResponseStarted(
url_.GetOrigin() != job_->manifest_url_.GetOrigin()) {
if (request->response_headers()->
HasHeaderValue("cache-control", "no-store")) {
+ DCHECK_EQ(-1, redirect_response_code_);
request->Cancel();
+ result_ = SERVER_ERROR; // Not the best match?
OnResponseCompleted();
return;
}
@@ -160,6 +193,10 @@ void AppCacheUpdateJob::URLFetcher::OnResponseStarted(
ReadResponseData();
}
} else {
+ if (response_code > 0)
+ result_ = SERVER_ERROR;
+ else
+ result_ = NETWORK_ERROR;
OnResponseCompleted();
}
}
@@ -169,6 +206,7 @@ void AppCacheUpdateJob::URLFetcher::OnReadCompleted(
DCHECK(request_ == request);
bool data_consumed = true;
if (request->status().is_success() && bytes_read > 0) {
+ job_->MadeProgress();
data_consumed = ConsumeResponseData(bytes_read);
if (data_consumed) {
bytes_read = 0;
@@ -183,8 +221,10 @@ void AppCacheUpdateJob::URLFetcher::OnReadCompleted(
}
}
}
- if (data_consumed && !request->status().is_io_pending())
+ if (data_consumed && !request->status().is_io_pending()) {
+ DCHECK_EQ(UPDATE_OK, result_);
OnResponseCompleted();
+ }
}
void AppCacheUpdateJob::URLFetcher::AddConditionalHeaders(
@@ -216,6 +256,7 @@ void AppCacheUpdateJob::URLFetcher::AddConditionalHeaders(
void AppCacheUpdateJob::URLFetcher::OnWriteComplete(int result) {
if (result < 0) {
request_->Cancel();
+ result_ = DISKCACHE_ERROR;
OnResponseCompleted();
return;
}
@@ -256,6 +297,9 @@ bool AppCacheUpdateJob::URLFetcher::ConsumeResponseData(int bytes_read) {
}
void AppCacheUpdateJob::URLFetcher::OnResponseCompleted() {
+ if (request_->status().is_success())
+ job_->MadeProgress();
+
// Retry for 503s where retry-after is 0.
if (request_->status().is_success() &&
request_->GetResponseCode() == 503 &&
@@ -289,13 +333,14 @@ bool AppCacheUpdateJob::URLFetcher::MaybeRetryRequest() {
return false;
}
++retry_503_attempts_;
+ result_ = UPDATE_OK;
request_ = job_->service_->request_context()->CreateRequest(
- url_, net::DEFAULT_PRIORITY, this);
+ url_, net::DEFAULT_PRIORITY, this, NULL);
Start();
return true;
}
-AppCacheUpdateJob::AppCacheUpdateJob(AppCacheService* service,
+AppCacheUpdateJob::AppCacheUpdateJob(AppCacheServiceImpl* service,
AppCacheGroup* group)
: service_(service),
manifest_url_(group->manifest_url()),
@@ -305,6 +350,7 @@ AppCacheUpdateJob::AppCacheUpdateJob(AppCacheService* service,
master_entries_completed_(0),
url_fetches_completed_(0),
manifest_fetcher_(NULL),
+ manifest_has_valid_mime_type_(false),
stored_state_(UNSTORED),
storage_(service->storage()) {
service_->AddObserver(this);
@@ -323,7 +369,7 @@ AppCacheUpdateJob::~AppCacheUpdateJob() {
DCHECK(master_entry_fetches_.empty());
if (group_)
- group_->SetUpdateStatus(AppCacheGroup::IDLE);
+ group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE);
}
void AppCacheUpdateJob::StartUpdate(AppCacheHost* host,
@@ -352,13 +398,13 @@ void AppCacheUpdateJob::StartUpdate(AppCacheHost* host,
}
// Notify host (if any) if already checking or downloading.
- AppCacheGroup::UpdateStatus update_status = group_->update_status();
+ AppCacheGroup::UpdateAppCacheStatus update_status = group_->update_status();
if (update_status == AppCacheGroup::CHECKING ||
update_status == AppCacheGroup::DOWNLOADING) {
if (host) {
- NotifySingleHost(host, CHECKING_EVENT);
+ NotifySingleHost(host, APPCACHE_CHECKING_EVENT);
if (update_status == AppCacheGroup::DOWNLOADING)
- NotifySingleHost(host, DOWNLOADING_EVENT);
+ NotifySingleHost(host, APPCACHE_DOWNLOADING_EVENT);
// Add to fetch list or an existing entry if already fetched.
if (!new_master_resource.is_empty()) {
@@ -370,14 +416,15 @@ void AppCacheUpdateJob::StartUpdate(AppCacheHost* host,
}
// Begin update process for the group.
- group_->SetUpdateStatus(AppCacheGroup::CHECKING);
+ MadeProgress();
+ group_->SetUpdateAppCacheStatus(AppCacheGroup::CHECKING);
if (group_->HasCache()) {
update_type_ = UPGRADE_ATTEMPT;
- NotifyAllAssociatedHosts(CHECKING_EVENT);
+ NotifyAllAssociatedHosts(APPCACHE_CHECKING_EVENT);
} else {
update_type_ = CACHE_ATTEMPT;
DCHECK(host);
- NotifySingleHost(host, CHECKING_EVENT);
+ NotifySingleHost(host, APPCACHE_CHECKING_EVENT);
}
if (!new_master_resource.is_empty()) {
@@ -396,14 +443,19 @@ AppCacheResponseWriter* AppCacheUpdateJob::CreateResponseWriter() {
return writer;
}
-void AppCacheUpdateJob::HandleCacheFailure(const std::string& error_message) {
+void AppCacheUpdateJob::HandleCacheFailure(
+ const AppCacheErrorDetails& error_details,
+ ResultType result,
+ const GURL& failed_resource_url) {
// 6.9.4 cache failure steps 2-8.
DCHECK(internal_state_ != CACHE_FAILURE);
- DCHECK(!error_message.empty());
+ DCHECK(!error_details.message.empty());
+ DCHECK(result != UPDATE_OK);
internal_state_ = CACHE_FAILURE;
+ LogHistogramStats(result, failed_resource_url);
CancelAllUrlFetches();
- CancelAllMasterEntryFetches(error_message);
- NotifyAllError(error_message);
+ CancelAllMasterEntryFetches(error_details);
+ NotifyAllError(error_details);
DiscardInprogressCache();
internal_state_ = COMPLETED;
DeleteSoon(); // To unwind the stack prior to deletion.
@@ -450,6 +502,10 @@ void AppCacheUpdateJob::HandleManifestFetchCompleted(
if (request->status().is_success()) {
response_code = request->GetResponseCode();
is_valid_response_code = (response_code / 100 == 2);
+
+ std::string mime_type;
+ request->GetMimeType(&mime_type);
+ manifest_has_valid_mime_type_ = (mime_type == "text/cache-manifest");
}
if (is_valid_response_code) {
@@ -464,28 +520,47 @@ void AppCacheUpdateJob::HandleManifestFetchCompleted(
ContinueHandleManifestFetchCompleted(false);
} else if ((response_code == 404 || response_code == 410) &&
update_type_ == UPGRADE_ATTEMPT) {
- storage_->MakeGroupObsolete(group_, this); // async
+ storage_->MakeGroupObsolete(group_, this, response_code); // async
} else {
const char* kFormatString = "Manifest fetch failed (%d) %s";
- std::string message = base::StringPrintf(kFormatString, response_code,
- manifest_url_.spec().c_str());
- HandleCacheFailure(message);
+ std::string message = FormatUrlErrorMessage(
+ kFormatString, manifest_url_, fetcher->result(), response_code);
+ HandleCacheFailure(AppCacheErrorDetails(message,
+ appcache::APPCACHE_MANIFEST_ERROR,
+ manifest_url_,
+ response_code,
+ false /*is_cross_origin*/),
+ fetcher->result(),
+ GURL());
}
}
void AppCacheUpdateJob::OnGroupMadeObsolete(AppCacheGroup* group,
- bool success) {
+ bool success,
+ int response_code) {
DCHECK(master_entry_fetches_.empty());
- CancelAllMasterEntryFetches("The cache has been made obsolete, "
- "the manifest file returned 404 or 410");
+ CancelAllMasterEntryFetches(AppCacheErrorDetails(
+ "The cache has been made obsolete, "
+ "the manifest file returned 404 or 410",
+ appcache::APPCACHE_MANIFEST_ERROR,
+ GURL(),
+ response_code,
+ false /*is_cross_origin*/));
if (success) {
DCHECK(group->is_obsolete());
- NotifyAllAssociatedHosts(OBSOLETE_EVENT);
+ NotifyAllAssociatedHosts(APPCACHE_OBSOLETE_EVENT);
internal_state_ = COMPLETED;
MaybeCompleteUpdate();
} else {
// Treat failure to mark group obsolete as a cache failure.
- HandleCacheFailure("Failed to mark the cache as obsolete");
+ HandleCacheFailure(AppCacheErrorDetails(
+ "Failed to mark the cache as obsolete",
+ APPCACHE_UNKNOWN_ERROR,
+ GURL(),
+ 0,
+ false /*is_cross_origin*/),
+ DB_ERROR,
+ GURL());
}
}
@@ -504,11 +579,20 @@ void AppCacheUpdateJob::ContinueHandleManifestFetchCompleted(bool changed) {
Manifest manifest;
if (!ParseManifest(manifest_url_, manifest_data_.data(),
- manifest_data_.length(), manifest)) {
+ manifest_data_.length(),
+ manifest_has_valid_mime_type_ ?
+ PARSE_MANIFEST_ALLOWING_INTERCEPTS :
+ PARSE_MANIFEST_PER_STANDARD,
+ manifest)) {
const char* kFormatString = "Failed to parse manifest %s";
const std::string message = base::StringPrintf(kFormatString,
manifest_url_.spec().c_str());
- HandleCacheFailure(message);
+ HandleCacheFailure(
+ AppCacheErrorDetails(
+ message, APPCACHE_SIGNATURE_ERROR, GURL(), 0,
+ false /*is_cross_origin*/),
+ APPCACHE_MANIFEST_ERROR,
+ GURL());
VLOG(1) << message;
return;
}
@@ -530,8 +614,16 @@ void AppCacheUpdateJob::ContinueHandleManifestFetchCompleted(bool changed) {
}
}
- group_->SetUpdateStatus(AppCacheGroup::DOWNLOADING);
- NotifyAllAssociatedHosts(DOWNLOADING_EVENT);
+ if (manifest.did_ignore_intercept_namespaces) {
+ // Must be done after associating all pending master hosts.
+ std::string message(
+ "Ignoring the INTERCEPT section of the application cache manifest "
+ "because the content type is not text/cache-manifest");
+ LogConsoleMessageToAll(message);
+ }
+
+ group_->SetUpdateAppCacheStatus(AppCacheGroup::DOWNLOADING);
+ NotifyAllAssociatedHosts(APPCACHE_DOWNLOADING_EVENT);
FetchUrls();
FetchMasterEntries();
MaybeCompleteUpdate(); // if not done, continues when async fetches complete
@@ -547,7 +639,9 @@ void AppCacheUpdateJob::HandleUrlFetchCompleted(URLFetcher* fetcher) {
++url_fetches_completed_;
int response_code = request->status().is_success()
- ? request->GetResponseCode() : -1;
+ ? request->GetResponseCode()
+ : fetcher->redirect_response_code();
+
AppCacheEntry& entry = url_file_list_.find(url)->second;
if (response_code / 100 == 2) {
@@ -580,9 +674,36 @@ void AppCacheUpdateJob::HandleUrlFetchCompleted(URLFetcher* fetcher) {
inprogress_cache_->AddOrModifyEntry(url, entry);
} else {
const char* kFormatString = "Resource fetch failed (%d) %s";
- const std::string message = base::StringPrintf(kFormatString,
- response_code, url.spec().c_str());
- HandleCacheFailure(message);
+ std::string message = FormatUrlErrorMessage(
+ kFormatString, url, fetcher->result(), response_code);
+ ResultType result = fetcher->result();
+ bool is_cross_origin = url.GetOrigin() != manifest_url_.GetOrigin();
+ switch (result) {
+ case DISKCACHE_ERROR:
+ HandleCacheFailure(
+ AppCacheErrorDetails(
+ message, APPCACHE_UNKNOWN_ERROR, GURL(), 0,
+ is_cross_origin),
+ result,
+ url);
+ break;
+ case NETWORK_ERROR:
+ HandleCacheFailure(
+ AppCacheErrorDetails(message, APPCACHE_RESOURCE_ERROR, url, 0,
+ is_cross_origin),
+ result,
+ url);
+ break;
+ default:
+ HandleCacheFailure(AppCacheErrorDetails(message,
+ APPCACHE_RESOURCE_ERROR,
+ url,
+ response_code,
+ is_cross_origin),
+ result,
+ url);
+ break;
+ }
return;
}
} else if (response_code == 404 || response_code == 410) {
@@ -664,10 +785,15 @@ void AppCacheUpdateJob::HandleMasterEntryFetchCompleted(
}
hosts.clear();
- const char* kFormatString = "Master entry fetch failed (%d) %s";
- const std::string message = base::StringPrintf(kFormatString,
- response_code, request->url().spec().c_str());
- host_notifier.SendErrorNotifications(message);
+ const char* kFormatString = "Manifest fetch failed (%d) %s";
+ std::string message = FormatUrlErrorMessage(
+ kFormatString, request->url(), fetcher->result(), response_code);
+ host_notifier.SendErrorNotifications(
+ AppCacheErrorDetails(message,
+ appcache::APPCACHE_MANIFEST_ERROR,
+ request->url(),
+ response_code,
+ false /*is_cross_origin*/));
// In downloading case, update result is different if all master entries
// failed vs. only some failing.
@@ -678,7 +804,13 @@ void AppCacheUpdateJob::HandleMasterEntryFetchCompleted(
// Section 6.9.4, step 22.3.
if (update_type_ == CACHE_ATTEMPT && pending_master_entries_.empty()) {
- HandleCacheFailure(message);
+ HandleCacheFailure(AppCacheErrorDetails(message,
+ appcache::APPCACHE_MANIFEST_ERROR,
+ request->url(),
+ response_code,
+ false /*is_cross_origin*/),
+ fetcher->result(),
+ GURL());
return;
}
}
@@ -719,7 +851,26 @@ void AppCacheUpdateJob::HandleManifestRefetchCompleted(
<< " error: " << request->status().error()
<< " response code: " << response_code;
ScheduleUpdateRetry(kRerunDelayMs);
- HandleCacheFailure("Manifest changed during update, scheduling retry");
+ if (response_code == 200) {
+ HandleCacheFailure(AppCacheErrorDetails("Manifest changed during update",
+ APPCACHE_CHANGED_ERROR,
+ GURL(),
+ 0,
+ false /*is_cross_origin*/),
+ APPCACHE_MANIFEST_ERROR,
+ GURL());
+ } else {
+ const char* kFormatString = "Manifest re-fetch failed (%d) %s";
+ std::string message = FormatUrlErrorMessage(
+ kFormatString, manifest_url_, fetcher->result(), response_code);
+ HandleCacheFailure(AppCacheErrorDetails(message,
+ appcache::APPCACHE_MANIFEST_ERROR,
+ GURL(),
+ response_code,
+ false /*is_cross_origin*/),
+ fetcher->result(),
+ GURL());
+ }
}
}
@@ -733,7 +884,14 @@ void AppCacheUpdateJob::OnManifestInfoWriteComplete(int result) {
base::Bind(&AppCacheUpdateJob::OnManifestDataWriteComplete,
base::Unretained(this)));
} else {
- HandleCacheFailure("Failed to write the manifest headers to storage");
+ HandleCacheFailure(
+ AppCacheErrorDetails("Failed to write the manifest headers to storage",
+ APPCACHE_UNKNOWN_ERROR,
+ GURL(),
+ 0,
+ false /*is_cross_origin*/),
+ DISKCACHE_ERROR,
+ GURL());
}
}
@@ -746,7 +904,14 @@ void AppCacheUpdateJob::OnManifestDataWriteComplete(int result) {
duplicate_response_ids_.push_back(entry.response_id());
StoreGroupAndCache();
} else {
- HandleCacheFailure("Failed to write the manifest data to storage");
+ HandleCacheFailure(
+ AppCacheErrorDetails("Failed to write the manifest data to storage",
+ APPCACHE_UNKNOWN_ERROR,
+ GURL(),
+ 0,
+ false /*is_cross_origin*/),
+ DISKCACHE_ERROR,
+ GURL());
}
}
@@ -774,25 +939,36 @@ void AppCacheUpdateJob::OnGroupAndNewestCacheStored(AppCacheGroup* group,
stored_state_ = STORED;
MaybeCompleteUpdate(); // will definitely complete
} else {
+ stored_state_ = UNSTORED;
+
// Restore inprogress_cache_ to get the proper events delivered
// and the proper cleanup to occur.
if (newest_cache != group->newest_complete_cache())
inprogress_cache_ = newest_cache;
+ ResultType result = DB_ERROR;
+ AppCacheErrorReason reason = APPCACHE_UNKNOWN_ERROR;
std::string message("Failed to commit new cache to storage");
- if (would_exceed_quota)
+ if (would_exceed_quota) {
message.append(", would exceed quota");
- HandleCacheFailure(message);
+ result = APPCACHE_QUOTA_ERROR;
+ reason = appcache::APPCACHE_QUOTA_ERROR;
+ }
+ HandleCacheFailure(
+ AppCacheErrorDetails(message, reason, GURL(), 0,
+ false /*is_cross_origin*/),
+ result,
+ GURL());
}
}
void AppCacheUpdateJob::NotifySingleHost(AppCacheHost* host,
- EventID event_id) {
+ AppCacheEventID event_id) {
std::vector<int> ids(1, host->host_id());
host->frontend()->OnEventRaised(ids, event_id);
}
-void AppCacheUpdateJob::NotifyAllAssociatedHosts(EventID event_id) {
+void AppCacheUpdateJob::NotifyAllAssociatedHosts(AppCacheEventID event_id) {
HostNotifier host_notifier;
AddAllAssociatedHostsToNotifier(&host_notifier);
host_notifier.SendNotifications(event_id);
@@ -810,10 +986,16 @@ void AppCacheUpdateJob::NotifyAllFinalProgress() {
NotifyAllProgress(GURL());
}
-void AppCacheUpdateJob::NotifyAllError(const std::string& error_message) {
+void AppCacheUpdateJob::NotifyAllError(const AppCacheErrorDetails& details) {
HostNotifier host_notifier;
AddAllAssociatedHostsToNotifier(&host_notifier);
- host_notifier.SendErrorNotifications(error_message);
+ host_notifier.SendErrorNotifications(details);
+}
+
+void AppCacheUpdateJob::LogConsoleMessageToAll(const std::string& message) {
+ HostNotifier host_notifier;
+ AddAllAssociatedHostsToNotifier(&host_notifier);
+ host_notifier.SendLogMessage(message);
}
void AppCacheUpdateJob::AddAllAssociatedHostsToNotifier(
@@ -866,8 +1048,15 @@ void AppCacheUpdateJob::CheckIfManifestChanged() {
// http://code.google.com/p/chromium/issues/detail?id=95101
if (service_->storage() == storage_) {
// Use a local variable because service_ is reset in HandleCacheFailure.
- AppCacheService* service = service_;
- HandleCacheFailure("Manifest entry not found in existing cache");
+ AppCacheServiceImpl* service = service_;
+ HandleCacheFailure(
+ AppCacheErrorDetails("Manifest entry not found in existing cache",
+ APPCACHE_UNKNOWN_ERROR,
+ GURL(),
+ 0,
+ false /*is_cross_origin*/),
+ DB_ERROR,
+ GURL());
AppCacheHistograms::AddMissingManifestEntrySample();
service->DeleteAppCacheGroup(manifest_url_, net::CompletionCallback());
}
@@ -1108,7 +1297,7 @@ void AppCacheUpdateJob::FetchMasterEntries() {
}
void AppCacheUpdateJob::CancelAllMasterEntryFetches(
- const std::string& error_message) {
+ const AppCacheErrorDetails& error_details) {
// For now, cancel all in-progress fetches for master entries and pretend
// all master entries fetches have completed.
// TODO(jennb): Delete this when update no longer fetches master entries
@@ -1144,7 +1333,7 @@ void AppCacheUpdateJob::CancelAllMasterEntryFetches(
master_entries_to_fetch_.erase(master_entries_to_fetch_.begin());
}
- host_notifier.SendErrorNotifications(error_message);
+ host_notifier.SendErrorNotifications(error_details);
}
bool AppCacheUpdateJob::MaybeLoadFromNewestCache(const GURL& url,
@@ -1254,7 +1443,7 @@ void AppCacheUpdateJob::MaybeCompleteUpdate() {
}
}
// 6.9.4 steps 7.3-7.7.
- NotifyAllAssociatedHosts(NO_UPDATE_EVENT);
+ NotifyAllAssociatedHosts(APPCACHE_NO_UPDATE_EVENT);
DiscardDuplicateResponses();
internal_state_ = COMPLETED;
break;
@@ -1266,11 +1455,12 @@ void AppCacheUpdateJob::MaybeCompleteUpdate() {
DCHECK(stored_state_ == STORED);
NotifyAllFinalProgress();
if (update_type_ == CACHE_ATTEMPT)
- NotifyAllAssociatedHosts(CACHED_EVENT);
+ NotifyAllAssociatedHosts(APPCACHE_CACHED_EVENT);
else
- NotifyAllAssociatedHosts(UPDATE_READY_EVENT);
+ NotifyAllAssociatedHosts(APPCACHE_UPDATE_READY_EVENT);
DiscardDuplicateResponses();
internal_state_ = COMPLETED;
+ LogHistogramStats(UPDATE_OK, GURL());
break;
case CACHE_FAILURE:
NOTREACHED(); // See HandleCacheFailure
@@ -1294,6 +1484,8 @@ void AppCacheUpdateJob::ScheduleUpdateRetry(int delay_ms) {
void AppCacheUpdateJob::Cancel() {
internal_state_ = CANCELLED;
+ LogHistogramStats(CANCELLED_ERROR, GURL());
+
if (manifest_fetcher_) {
delete manifest_fetcher_;
manifest_fetcher_ = NULL;
@@ -1335,15 +1527,26 @@ void AppCacheUpdateJob::ClearPendingMasterEntries() {
}
void AppCacheUpdateJob::DiscardInprogressCache() {
+ if (stored_state_ == STORING) {
+ // We can make no assumptions about whether the StoreGroupAndCacheTask
+ // actually completed or not. This condition should only be reachable
+ // during shutdown. Free things up and return to do no harm.
+ inprogress_cache_ = NULL;
+ added_master_entries_.clear();
+ return;
+ }
+
storage_->DoomResponses(manifest_url_, stored_response_ids_);
if (!inprogress_cache_.get()) {
// We have to undo the changes we made, if any, to the existing cache.
- for (std::vector<GURL>::iterator iter = added_master_entries_.begin();
- iter != added_master_entries_.end(); ++iter) {
- DCHECK(group_->newest_complete_cache());
- group_->newest_complete_cache()->RemoveEntry(*iter);
+ if (group_ && group_->newest_complete_cache()) {
+ for (std::vector<GURL>::iterator iter = added_master_entries_.begin();
+ iter != added_master_entries_.end(); ++iter) {
+ group_->newest_complete_cache()->RemoveEntry(*iter);
+ }
}
+ added_master_entries_.clear();
return;
}
@@ -1352,12 +1555,44 @@ void AppCacheUpdateJob::DiscardInprogressCache() {
(*hosts.begin())->AssociateNoCache(GURL());
inprogress_cache_ = NULL;
+ added_master_entries_.clear();
}
void AppCacheUpdateJob::DiscardDuplicateResponses() {
storage_->DoomResponses(manifest_url_, duplicate_response_ids_);
}
+void AppCacheUpdateJob::LogHistogramStats(
+ ResultType result, const GURL& failed_resource_url) {
+ AppCacheHistograms::CountUpdateJobResult(result, manifest_url_.GetOrigin());
+ if (result == UPDATE_OK)
+ return;
+
+ int percent_complete = 0;
+ if (url_file_list_.size() > 0) {
+ size_t actual_fetches_completed = url_fetches_completed_;
+ if (!failed_resource_url.is_empty() && actual_fetches_completed)
+ --actual_fetches_completed;
+ percent_complete = (static_cast<double>(actual_fetches_completed) /
+ static_cast<double>(url_file_list_.size())) * 100.0;
+ percent_complete = std::min(percent_complete, 99);
+ }
+
+ bool was_making_progress =
+ base::Time::Now() - last_progress_time_ <
+ base::TimeDelta::FromMinutes(5);
+
+ bool off_origin_resource_failure =
+ !failed_resource_url.is_empty() &&
+ (failed_resource_url.GetOrigin() != manifest_url_.GetOrigin());
+
+ AppCacheHistograms::LogUpdateFailureStats(
+ manifest_url_.GetOrigin(),
+ percent_complete,
+ was_making_progress,
+ off_origin_resource_failure);
+}
+
void AppCacheUpdateJob::DeleteSoon() {
ClearPendingMasterEntries();
manifest_response_writer_.reset();
@@ -1367,7 +1602,7 @@ void AppCacheUpdateJob::DeleteSoon() {
// Break the connection with the group so the group cannot call delete
// on this object after we've posted a task to delete ourselves.
- group_->SetUpdateStatus(AppCacheGroup::IDLE);
+ group_->SetUpdateAppCacheStatus(AppCacheGroup::IDLE);
group_ = NULL;
base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
diff --git a/chromium/webkit/browser/appcache/appcache_update_job.h b/chromium/webkit/browser/appcache/appcache_update_job.h
index 0b88be649e8..ba155411d52 100644
--- a/chromium/webkit/browser/appcache/appcache_update_job.h
+++ b/chromium/webkit/browser/appcache/appcache_update_job.h
@@ -13,6 +13,7 @@
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
+#include "base/time/time.h"
#include "net/base/completion_callback.h"
#include "net/http/http_response_headers.h"
#include "net/url_request/url_request.h"
@@ -20,11 +21,17 @@
#include "webkit/browser/appcache/appcache.h"
#include "webkit/browser/appcache/appcache_host.h"
#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
#include "webkit/browser/appcache/appcache_storage.h"
#include "webkit/browser/webkit_storage_browser_export.h"
#include "webkit/common/appcache/appcache_interfaces.h"
+namespace content {
+FORWARD_DECLARE_TEST(AppCacheGroupTest, QueueUpdate);
+class AppCacheGroupTest;
+class AppCacheUpdateJobTest;
+}
+
namespace appcache {
class HostNotifier;
@@ -33,9 +40,16 @@ class HostNotifier;
class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob
: public AppCacheStorage::Delegate,
public AppCacheHost::Observer,
- public AppCacheService::Observer {
+ public AppCacheServiceImpl::Observer {
public:
- AppCacheUpdateJob(AppCacheService* service, AppCacheGroup* group);
+ // Used for uma stats only for now, so new values are append only.
+ enum ResultType {
+ UPDATE_OK, DB_ERROR, DISKCACHE_ERROR, APPCACHE_QUOTA_ERROR, REDIRECT_ERROR,
+ APPCACHE_MANIFEST_ERROR, NETWORK_ERROR, SERVER_ERROR, CANCELLED_ERROR,
+ NUM_UPDATE_JOB_RESULT_TYPES
+ };
+
+ AppCacheUpdateJob(AppCacheServiceImpl* service, AppCacheGroup* group);
virtual ~AppCacheUpdateJob();
// Triggers the update process or adds more info if this update is already
@@ -43,7 +57,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob
void StartUpdate(AppCacheHost* host, const GURL& new_master_resource);
private:
- friend class AppCacheUpdateJobTest;
+ friend class content::AppCacheGroupTest;
+ friend class content::AppCacheUpdateJobTest;
class URLFetcher;
// Master entries have multiple hosts, for example, the same page is opened
@@ -118,6 +133,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob
void set_existing_entry(const AppCacheEntry& entry) {
existing_entry_ = entry;
}
+ ResultType result() const { return result_; }
+ int redirect_response_code() const { return redirect_response_code_; }
private:
// URLRequest::Delegate overrides
@@ -144,6 +161,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob
AppCacheEntry existing_entry_;
scoped_refptr<net::HttpResponseHeaders> existing_response_headers_;
std::string manifest_data_;
+ ResultType result_;
+ int redirect_response_code_;
scoped_ptr<AppCacheResponseWriter> response_writer_;
}; // class URLFetcher
@@ -156,17 +175,21 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob
AppCache* newest_cache,
bool success,
bool would_exceed_quota) OVERRIDE;
- virtual void OnGroupMadeObsolete(AppCacheGroup* group, bool success) OVERRIDE;
+ virtual void OnGroupMadeObsolete(AppCacheGroup* group,
+ bool success,
+ int response_code) OVERRIDE;
// Methods for AppCacheHost::Observer.
virtual void OnCacheSelectionComplete(AppCacheHost* host) OVERRIDE {} // N/A
virtual void OnDestructionImminent(AppCacheHost* host) OVERRIDE;
- // Methods for AppCacheService::Observer.
+ // Methods for AppCacheServiceImpl::Observer.
virtual void OnServiceReinitialized(
AppCacheStorageReference* old_storage) OVERRIDE;
- void HandleCacheFailure(const std::string& error_message);
+ void HandleCacheFailure(const AppCacheErrorDetails& details,
+ ResultType result,
+ const GURL& failed_resource_url);
void FetchManifest(bool is_first_fetch);
void HandleManifestFetchCompleted(URLFetcher* fetcher);
@@ -181,11 +204,12 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob
void StoreGroupAndCache();
- void NotifySingleHost(AppCacheHost* host, EventID event_id);
- void NotifyAllAssociatedHosts(EventID event_id);
+ void NotifySingleHost(AppCacheHost* host, AppCacheEventID event_id);
+ void NotifyAllAssociatedHosts(AppCacheEventID event_id);
void NotifyAllProgress(const GURL& url);
void NotifyAllFinalProgress();
- void NotifyAllError(const std::string& error_message);
+ void NotifyAllError(const AppCacheErrorDetails& detals);
+ void LogConsoleMessageToAll(const std::string& message);
void AddAllAssociatedHostsToNotifier(HostNotifier* notifier);
// Checks if manifest is byte for byte identical with the manifest
@@ -212,7 +236,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob
void AddMasterEntryToFetchList(AppCacheHost* host, const GURL& url,
bool is_new);
void FetchMasterEntries();
- void CancelAllMasterEntryFetches(const std::string& error_message);
+ void CancelAllMasterEntryFetches(const AppCacheErrorDetails& details);
// Asynchronously loads the entry from the newest complete cache if the
// HTTP caching semantics allow.
@@ -236,13 +260,16 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob
void DiscardInprogressCache();
void DiscardDuplicateResponses();
+ void LogHistogramStats(ResultType result, const GURL& failed_resource_url);
+ void MadeProgress() { last_progress_time_ = base::Time::Now(); }
+
// Deletes this object after letting the stack unwind.
void DeleteSoon();
bool IsTerminating() { return internal_state_ >= REFETCH_MANIFEST ||
stored_state_ != UNSTORED; }
- AppCacheService* service_;
+ AppCacheServiceImpl* service_;
const GURL manifest_url_; // here for easier access
// Defined prior to refs to AppCaches and Groups because destruction
@@ -256,6 +283,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob
UpdateType update_type_;
InternalUpdateState internal_state_;
+ base::Time last_progress_time_;
PendingMasters pending_master_entries_;
size_t master_entries_completed_;
@@ -292,6 +320,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob
scoped_refptr<net::IOBuffer> read_manifest_buffer_;
std::string loaded_manifest_data_;
scoped_ptr<AppCacheResponseReader> manifest_response_reader_;
+ bool manifest_has_valid_mime_type_;
// New master entries added to the cache by this job, used to cleanup
// in error conditions.
@@ -313,7 +342,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheUpdateJob
AppCacheStorage* storage_;
- FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, QueueUpdate);
+ FRIEND_TEST_ALL_PREFIXES(content::AppCacheGroupTest, QueueUpdate);
DISALLOW_COPY_AND_ASSIGN(AppCacheUpdateJob);
};
diff --git a/chromium/webkit/browser/appcache/appcache_update_job_unittest.cc b/chromium/webkit/browser/appcache/appcache_update_job_unittest.cc
deleted file mode 100644
index 3468758944f..00000000000
--- a/chromium/webkit/browser/appcache/appcache_update_job_unittest.cc
+++ /dev/null
@@ -1,3692 +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 "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/stl_util.h"
-#include "base/synchronization/waitable_event.h"
-#include "base/threading/thread.h"
-#include "net/base/net_errors.h"
-#include "net/http/http_response_headers.h"
-#include "net/url_request/url_request_error_job.h"
-#include "net/url_request/url_request_job_factory_impl.h"
-#include "net/url_request/url_request_test_job.h"
-#include "net/url_request/url_request_test_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/appcache/appcache_group.h"
-#include "webkit/browser/appcache/appcache_host.h"
-#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/appcache_update_job.h"
-#include "webkit/browser/appcache/mock_appcache_service.h"
-
-namespace appcache {
-class AppCacheUpdateJobTest;
-
-namespace {
-
-const char kManifest1Contents[] =
- "CACHE MANIFEST\n"
- "explicit1\n"
- "FALLBACK:\n"
- "fallback1 fallback1a\n"
- "NETWORK:\n"
- "*\n";
-
-// There are a handful of http accessible resources that we need to conduct
-// these tests. Instead of running a seperate server to host these resources,
-// we mock them up.
-class MockHttpServer {
- public:
- static GURL GetMockUrl(const std::string& path) {
- return GURL("http://mockhost/" + path);
- }
-
- static GURL GetMockHttpsUrl(const std::string& path) {
- return GURL("https://mockhost/" + path);
- }
-
- static GURL GetMockCrossOriginHttpsUrl(const std::string& path) {
- return GURL("https://cross_origin_host/" + path);
- }
-
- static net::URLRequestJob* JobFactory(
- net::URLRequest* request, net::NetworkDelegate* network_delegate) {
- if (request->url().host() != "mockhost" &&
- request->url().host() != "cross_origin_host")
- return new net::URLRequestErrorJob(request, network_delegate, -100);
-
- std::string headers, body;
- GetMockResponse(request->url().path(), &headers, &body);
- return new net::URLRequestTestJob(
- request, network_delegate, headers, body, true);
- }
-
- private:
- static void GetMockResponse(const std::string& path,
- std::string* headers,
- std::string* body) {
- const char ok_headers[] =
- "HTTP/1.1 200 OK\0"
- "\0";
- const char error_headers[] =
- "HTTP/1.1 500 BOO HOO\0"
- "\0";
- const char manifest_headers[] =
- "HTTP/1.1 200 OK\0"
- "Content-type: text/cache-manifest\0"
- "\0";
- const char not_modified_headers[] =
- "HTTP/1.1 304 NOT MODIFIED\0"
- "\0";
- const char gone_headers[] =
- "HTTP/1.1 410 GONE\0"
- "\0";
- const char not_found_headers[] =
- "HTTP/1.1 404 NOT FOUND\0"
- "\0";
- const char no_store_headers[] =
- "HTTP/1.1 200 OK\0"
- "Cache-Control: no-store\0"
- "\0";
-
- if (path == "/files/missing-mime-manifest") {
- (*headers) = std::string(ok_headers, arraysize(ok_headers));
- (*body) = "CACHE MANIFEST\n";
- } else if (path == "/files/bad-manifest") {
- (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
- (*body) = "BAD CACHE MANIFEST";
- } else if (path == "/files/empty1") {
- (*headers) = std::string(ok_headers, arraysize(ok_headers));
- (*body) = "";
- } else if (path == "/files/empty-file-manifest") {
- (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
- (*body) = "CACHE MANIFEST\n"
- "empty1\n";
- } else if (path == "/files/empty-manifest") {
- (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
- (*body) = "CACHE MANIFEST\n";
- } else if (path == "/files/explicit1") {
- (*headers) = std::string(ok_headers, arraysize(ok_headers));
- (*body) = "explicit1";
- } else if (path == "/files/explicit2") {
- (*headers) = std::string(ok_headers, arraysize(ok_headers));
- (*body) = "explicit2";
- } else if (path == "/files/fallback1a") {
- (*headers) = std::string(ok_headers, arraysize(ok_headers));
- (*body) = "fallback1a";
- } else if (path == "/files/intercept1a") {
- (*headers) = std::string(ok_headers, arraysize(ok_headers));
- (*body) = "intercept1a";
- } else if (path == "/files/gone") {
- (*headers) = std::string(gone_headers, arraysize(gone_headers));
- (*body) = "";
- } else if (path == "/files/manifest1") {
- (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
- (*body) = kManifest1Contents;
- } else if (path == "/files/manifest1-with-notmodified") {
- (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
- (*body) = kManifest1Contents;
- (*body).append("CACHE:\n"
- "notmodified\n");
- } else if (path == "/files/manifest-fb-404") {
- (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
- (*body) = "CACHE MANIFEST\n"
- "explicit1\n"
- "FALLBACK:\n"
- "fallback1 fallback1a\n"
- "fallback404 fallback-404\n"
- "NETWORK:\n"
- "online1\n";
- } else if (path == "/files/manifest-merged-types") {
- (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
- (*body) = "CACHE MANIFEST\n"
- "explicit1\n"
- "# manifest is also an explicit entry\n"
- "manifest-merged-types\n"
- "FALLBACK:\n"
- "# fallback is also explicit entry\n"
- "fallback1 explicit1\n"
- "NETWORK:\n"
- "online1\n";
- } else if (path == "/files/manifest-with-404") {
- (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
- (*body) = "CACHE MANIFEST\n"
- "explicit-404\n"
- "explicit1\n"
- "explicit2\n"
- "explicit3\n"
- "FALLBACK:\n"
- "fallback1 fallback1a\n"
- "NETWORK:\n"
- "online1\n";
- } else if (path == "/files/manifest-with-intercept") {
- (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
- (*body) = "CACHE MANIFEST\n"
- "CHROMIUM-INTERCEPT:\n"
- "intercept1 return intercept1a\n";
- } else if (path == "/files/notmodified") {
- (*headers) = std::string(not_modified_headers,
- arraysize(not_modified_headers));
- (*body) = "";
- } else if (path == "/files/servererror") {
- (*headers) = std::string(error_headers,
- arraysize(error_headers));
- (*body) = "error";
- } else if (path == "/files/valid_cross_origin_https_manifest") {
- (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
- (*body) = "CACHE MANIFEST\n"
- "https://cross_origin_host/files/explicit1\n";
- } else if (path == "/files/invalid_cross_origin_https_manifest") {
- (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
- (*body) = "CACHE MANIFEST\n"
- "https://cross_origin_host/files/no-store-headers\n";
- } else if (path == "/files/no-store-headers") {
- (*headers) = std::string(no_store_headers, arraysize(no_store_headers));
- (*body) = "no-store";
- } else {
- (*headers) = std::string(not_found_headers,
- arraysize(not_found_headers));
- (*body) = "";
- }
- }
-};
-
-class MockHttpServerJobFactory
- : public net::URLRequestJobFactory::ProtocolHandler {
- public:
- virtual net::URLRequestJob* MaybeCreateJob(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate) const OVERRIDE {
- return MockHttpServer::JobFactory(request, network_delegate);
- }
-};
-
-inline bool operator==(const Namespace& lhs, const Namespace& rhs) {
- return lhs.type == rhs.type &&
- lhs.namespace_url == rhs.namespace_url &&
- lhs.target_url == rhs.target_url;
-}
-
-} // namespace
-
-class MockFrontend : public AppCacheFrontend {
- public:
- MockFrontend()
- : ignore_progress_events_(false), verify_progress_events_(false),
- last_progress_total_(-1), last_progress_complete_(-1),
- start_update_trigger_(CHECKING_EVENT), update_(NULL) {
- }
-
- virtual void OnCacheSelected(
- int host_id, const appcache::AppCacheInfo& info) OVERRIDE {
- }
-
- virtual void OnStatusChanged(const std::vector<int>& host_ids,
- Status status) OVERRIDE {
- }
-
- virtual void OnEventRaised(const std::vector<int>& host_ids,
- EventID event_id) OVERRIDE {
- raised_events_.push_back(RaisedEvent(host_ids, event_id));
-
- // Trigger additional updates if requested.
- if (event_id == start_update_trigger_ && update_) {
- for (std::vector<AppCacheHost*>::iterator it = update_hosts_.begin();
- it != update_hosts_.end(); ++it) {
- AppCacheHost* host = *it;
- update_->StartUpdate(host,
- (host ? host->pending_master_entry_url() : GURL()));
- }
- update_hosts_.clear(); // only trigger once
- }
- }
-
- virtual void OnErrorEventRaised(const std::vector<int>& host_ids,
- const std::string& message) OVERRIDE {
- error_message_ = message;
- OnEventRaised(host_ids, ERROR_EVENT);
- }
-
- virtual void OnProgressEventRaised(const std::vector<int>& host_ids,
- const GURL& url,
- int num_total,
- int num_complete) OVERRIDE {
- if (!ignore_progress_events_)
- OnEventRaised(host_ids, PROGRESS_EVENT);
-
- if (verify_progress_events_) {
- EXPECT_GE(num_total, num_complete);
- EXPECT_GE(num_complete, 0);
-
- if (last_progress_total_ == -1) {
- // Should start at zero.
- EXPECT_EQ(0, num_complete);
- } else {
- // Total should be stable and complete should bump up by one at a time.
- EXPECT_EQ(last_progress_total_, num_total);
- EXPECT_EQ(last_progress_complete_ + 1, num_complete);
- }
-
- // Url should be valid for all except the 'final' event.
- if (num_total == num_complete)
- EXPECT_TRUE(url.is_empty());
- else
- EXPECT_TRUE(url.is_valid());
-
- last_progress_total_ = num_total;
- last_progress_complete_ = num_complete;
- }
- }
-
- virtual void OnLogMessage(int host_id,
- appcache::LogLevel log_level,
- const std::string& message) OVERRIDE {
- }
-
- virtual void OnContentBlocked(int host_id,
- const GURL& manifest_url) OVERRIDE {
- }
-
- void AddExpectedEvent(const std::vector<int>& host_ids, EventID event_id) {
- DCHECK(!ignore_progress_events_ || event_id != PROGRESS_EVENT);
- expected_events_.push_back(RaisedEvent(host_ids, event_id));
- }
-
- void SetIgnoreProgressEvents(bool ignore) {
- // Some tests involve joining new hosts to an already running update job
- // or intentionally failing. The timing and sequencing of the progress
- // events generated by an update job are dependent on the behavior of
- // an external HTTP server. For jobs that do not run fully till completion,
- // due to either joining late or early exit, we skip monitoring the
- // progress events to avoid flakiness.
- ignore_progress_events_ = ignore;
- }
-
- void SetVerifyProgressEvents(bool verify) {
- verify_progress_events_ = verify;
- }
-
- void TriggerAdditionalUpdates(EventID trigger_event,
- AppCacheUpdateJob* update) {
- start_update_trigger_ = trigger_event;
- update_ = update;
- }
-
- void AdditionalUpdateHost(AppCacheHost* host) {
- update_hosts_.push_back(host);
- }
-
- typedef std::vector<int> HostIds;
- typedef std::pair<HostIds, EventID> RaisedEvent;
- typedef std::vector<RaisedEvent> RaisedEvents;
- RaisedEvents raised_events_;
- std::string error_message_;
-
- // Set the expected events if verification needs to happen asynchronously.
- RaisedEvents expected_events_;
- std::string expected_error_message_;
-
- bool ignore_progress_events_;
-
- bool verify_progress_events_;
- int last_progress_total_;
- int last_progress_complete_;
-
- // Add ability for frontend to add master entries to an inprogress update.
- EventID start_update_trigger_;
- AppCacheUpdateJob* update_;
- std::vector<AppCacheHost*> update_hosts_;
-};
-
-// Helper factories to simulate redirected URL responses for tests.
-class RedirectFactory : public net::URLRequestJobFactory::ProtocolHandler {
- public:
- virtual net::URLRequestJob* MaybeCreateJob(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate) const OVERRIDE {
- return new net::URLRequestTestJob(
- request,
- network_delegate,
- net::URLRequestTestJob::test_redirect_headers(),
- net::URLRequestTestJob::test_data_1(),
- true);
- }
-};
-
-// Helper class to simulate a URL that returns retry or success.
-class RetryRequestTestJob : public net::URLRequestTestJob {
- public:
- enum RetryHeader {
- NO_RETRY_AFTER,
- NONZERO_RETRY_AFTER,
- RETRY_AFTER_0,
- };
-
- static const GURL kRetryUrl;
-
- // Call this at the start of each retry test.
- static void Initialize(int num_retry_responses, RetryHeader header,
- int expected_requests) {
- num_requests_ = 0;
- num_retries_ = num_retry_responses;
- retry_after_ = header;
- expected_requests_ = expected_requests;
- }
-
- // Verifies results at end of test and resets counters.
- static void Verify() {
- EXPECT_EQ(expected_requests_, num_requests_);
- num_requests_ = 0;
- expected_requests_ = 0;
- }
-
- static net::URLRequestJob* RetryFactory(
- net::URLRequest* request, net::NetworkDelegate* network_delegate) {
- ++num_requests_;
- if (num_retries_ > 0 && request->original_url() == kRetryUrl) {
- --num_retries_;
- return new RetryRequestTestJob(
- request, network_delegate, RetryRequestTestJob::retry_headers(), 503);
- } else {
- return new RetryRequestTestJob(
- request,
- network_delegate,
- RetryRequestTestJob::manifest_headers(), 200);
- }
- }
-
- virtual int GetResponseCode() const OVERRIDE { return response_code_; }
-
- private:
- virtual ~RetryRequestTestJob() {}
-
- static std::string retry_headers() {
- const char no_retry_after[] =
- "HTTP/1.1 503 BOO HOO\0"
- "\0";
- const char nonzero[] =
- "HTTP/1.1 503 BOO HOO\0"
- "Retry-After: 60\0"
- "\0";
- const char retry_after_0[] =
- "HTTP/1.1 503 BOO HOO\0"
- "Retry-After: 0\0"
- "\0";
-
- switch (retry_after_) {
- case NO_RETRY_AFTER:
- return std::string(no_retry_after, arraysize(no_retry_after));
- case NONZERO_RETRY_AFTER:
- return std::string(nonzero, arraysize(nonzero));
- case RETRY_AFTER_0:
- default:
- return std::string(retry_after_0, arraysize(retry_after_0));
- }
- }
-
- static std::string manifest_headers() {
- const char headers[] =
- "HTTP/1.1 200 OK\0"
- "Content-type: text/cache-manifest\0"
- "\0";
- return std::string(headers, arraysize(headers));
- }
-
- static std::string data() {
- return std::string("CACHE MANIFEST\r"
- "http://retry\r"); // must be same as kRetryUrl
- }
-
- RetryRequestTestJob(net::URLRequest* request,
- net::NetworkDelegate* network_delegate,
- const std::string& headers,
- int response_code)
- : net::URLRequestTestJob(
- request, network_delegate, headers, data(), true),
- response_code_(response_code) {
- }
-
- int response_code_;
-
- static int num_requests_;
- static int num_retries_;
- static RetryHeader retry_after_;
- static int expected_requests_;
-};
-
-class RetryRequestTestJobFactory
- : public net::URLRequestJobFactory::ProtocolHandler {
- public:
- virtual net::URLRequestJob* MaybeCreateJob(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate) const OVERRIDE {
- return RetryRequestTestJob::RetryFactory(request, network_delegate);
- }
-};
-
-// static
-const GURL RetryRequestTestJob::kRetryUrl("http://retry");
-int RetryRequestTestJob::num_requests_ = 0;
-int RetryRequestTestJob::num_retries_;
-RetryRequestTestJob::RetryHeader RetryRequestTestJob::retry_after_;
-int RetryRequestTestJob::expected_requests_ = 0;
-
-// Helper class to check for certain HTTP headers.
-class HttpHeadersRequestTestJob : public net::URLRequestTestJob {
- public:
- // Call this at the start of each HTTP header-related test.
- static void Initialize(const std::string& expect_if_modified_since,
- const std::string& expect_if_none_match) {
- expect_if_modified_since_ = expect_if_modified_since;
- expect_if_none_match_ = expect_if_none_match;
- }
-
- // Verifies results at end of test and resets class.
- static void Verify() {
- if (!expect_if_modified_since_.empty())
- EXPECT_TRUE(saw_if_modified_since_);
- if (!expect_if_none_match_.empty())
- EXPECT_TRUE(saw_if_none_match_);
-
- // Reset.
- expect_if_modified_since_.clear();
- saw_if_modified_since_ = false;
- expect_if_none_match_.clear();
- saw_if_none_match_ = false;
- already_checked_ = false;
- }
-
- static net::URLRequestJob* IfModifiedSinceFactory(
- net::URLRequest* request, net::NetworkDelegate* network_delegate) {
- if (!already_checked_) {
- already_checked_ = true; // only check once for a test
- const net::HttpRequestHeaders& extra_headers =
- request->extra_request_headers();
- std::string header_value;
- saw_if_modified_since_ =
- extra_headers.GetHeader(
- net::HttpRequestHeaders::kIfModifiedSince, &header_value) &&
- header_value == expect_if_modified_since_;
-
- saw_if_none_match_ =
- extra_headers.GetHeader(
- net::HttpRequestHeaders::kIfNoneMatch, &header_value) &&
- header_value == expect_if_none_match_;
- }
- return MockHttpServer::JobFactory(request, network_delegate);
- }
-
- protected:
- virtual ~HttpHeadersRequestTestJob() {}
-
- private:
- static std::string expect_if_modified_since_;
- static bool saw_if_modified_since_;
- static std::string expect_if_none_match_;
- static bool saw_if_none_match_;
- static bool already_checked_;
-};
-
-// static
-std::string HttpHeadersRequestTestJob::expect_if_modified_since_;
-bool HttpHeadersRequestTestJob::saw_if_modified_since_ = false;
-std::string HttpHeadersRequestTestJob::expect_if_none_match_;
-bool HttpHeadersRequestTestJob::saw_if_none_match_ = false;
-bool HttpHeadersRequestTestJob::already_checked_ = false;
-
-class IfModifiedSinceJobFactory
- : public net::URLRequestJobFactory::ProtocolHandler {
- public:
- virtual net::URLRequestJob* MaybeCreateJob(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate) const OVERRIDE {
- return HttpHeadersRequestTestJob::IfModifiedSinceFactory(
- request, network_delegate);
- }
-};
-
-class IOThread : public base::Thread {
- public:
- explicit IOThread(const char* name)
- : base::Thread(name) {
- }
-
- virtual ~IOThread() {
- Stop();
- }
-
- net::URLRequestContext* request_context() {
- return request_context_.get();
- }
-
- void SetNewJobFactory(net::URLRequestJobFactory* job_factory) {
- DCHECK(job_factory);
- job_factory_.reset(job_factory);
- request_context_->set_job_factory(job_factory_.get());
- }
-
- virtual void Init() OVERRIDE {
- scoped_ptr<net::URLRequestJobFactoryImpl> factory(
- new net::URLRequestJobFactoryImpl());
- factory->SetProtocolHandler("http", new MockHttpServerJobFactory);
- factory->SetProtocolHandler("https", new MockHttpServerJobFactory);
- job_factory_ = factory.Pass();
- request_context_.reset(new net::TestURLRequestContext());
- request_context_->set_job_factory(job_factory_.get());
- }
-
- virtual void CleanUp() OVERRIDE {
- request_context_.reset();
- job_factory_.reset();
- }
-
- private:
- scoped_ptr<net::URLRequestJobFactory> job_factory_;
- scoped_ptr<net::URLRequestContext> request_context_;
-};
-
-class AppCacheUpdateJobTest : public testing::Test,
- public AppCacheGroup::UpdateObserver {
- public:
- AppCacheUpdateJobTest()
- : do_checks_after_update_finished_(false),
- expect_group_obsolete_(false),
- expect_group_has_cache_(false),
- expect_group_is_being_deleted_(false),
- expect_old_cache_(NULL),
- expect_newest_cache_(NULL),
- expect_non_null_update_time_(false),
- tested_manifest_(NONE),
- tested_manifest_path_override_(NULL) {
- io_thread_.reset(new IOThread("AppCacheUpdateJob IO test thread"));
- base::Thread::Options options(base::MessageLoop::TYPE_IO, 0);
- io_thread_->StartWithOptions(options);
- }
-
- // Use a separate IO thread to run a test. Thread will be destroyed
- // when it goes out of scope.
- template <class Method>
- void RunTestOnIOThread(Method method) {
- event_.reset(new base::WaitableEvent(false, false));
- io_thread_->message_loop()->PostTask(
- FROM_HERE, base::Bind(method, base::Unretained(this)));
-
- // Wait until task is done before exiting the test.
- event_->Wait();
- }
-
- void StartCacheAttemptTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(service_->storage(), GURL("http://failme"),
- service_->storage()->NewGroupId());
-
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend mock_frontend;
- AppCacheHost host(1, &mock_frontend, service_.get());
-
- update->StartUpdate(&host, GURL());
-
- // Verify state.
- EXPECT_EQ(AppCacheUpdateJob::CACHE_ATTEMPT, update->update_type_);
- EXPECT_EQ(AppCacheUpdateJob::FETCH_MANIFEST, update->internal_state_);
- EXPECT_EQ(AppCacheGroup::CHECKING, group_->update_status());
-
- // Verify notifications.
- MockFrontend::RaisedEvents& events = mock_frontend.raised_events_;
- size_t expected = 1;
- EXPECT_EQ(expected, events.size());
- EXPECT_EQ(expected, events[0].first.size());
- EXPECT_EQ(host.host_id(), events[0].first[0]);
- EXPECT_EQ(CHECKING_EVENT, events[0].second);
-
- // Abort as we're not testing actual URL fetches in this test.
- delete update;
- UpdateFinished();
- }
-
- void StartUpgradeAttemptTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- {
- MakeService();
- group_ = new AppCacheGroup(service_->storage(), GURL("http://failme"),
- service_->storage()->NewGroupId());
-
- // Give the group some existing caches.
- AppCache* cache1 = MakeCacheForGroup(1, 111);
- AppCache* cache2 = MakeCacheForGroup(2, 222);
-
- // Associate some hosts with caches in the group.
- MockFrontend mock_frontend1;
- MockFrontend mock_frontend2;
- MockFrontend mock_frontend3;
-
- AppCacheHost host1(1, &mock_frontend1, service_.get());
- host1.AssociateCompleteCache(cache1);
-
- AppCacheHost host2(2, &mock_frontend2, service_.get());
- host2.AssociateCompleteCache(cache2);
-
- AppCacheHost host3(3, &mock_frontend1, service_.get());
- host3.AssociateCompleteCache(cache1);
-
- AppCacheHost host4(4, &mock_frontend3, service_.get());
-
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
- update->StartUpdate(&host4, GURL());
-
- // Verify state after starting an update.
- EXPECT_EQ(AppCacheUpdateJob::UPGRADE_ATTEMPT, update->update_type_);
- EXPECT_EQ(AppCacheUpdateJob::FETCH_MANIFEST, update->internal_state_);
- EXPECT_EQ(AppCacheGroup::CHECKING, group_->update_status());
-
- // Verify notifications.
- MockFrontend::RaisedEvents& events = mock_frontend1.raised_events_;
- size_t expected = 1;
- EXPECT_EQ(expected, events.size());
- expected = 2; // 2 hosts using frontend1
- EXPECT_EQ(expected, events[0].first.size());
- MockFrontend::HostIds& host_ids = events[0].first;
- EXPECT_TRUE(std::find(host_ids.begin(), host_ids.end(), host1.host_id())
- != host_ids.end());
- EXPECT_TRUE(std::find(host_ids.begin(), host_ids.end(), host3.host_id())
- != host_ids.end());
- EXPECT_EQ(CHECKING_EVENT, events[0].second);
-
- events = mock_frontend2.raised_events_;
- expected = 1;
- EXPECT_EQ(expected, events.size());
- EXPECT_EQ(expected, events[0].first.size()); // 1 host using frontend2
- EXPECT_EQ(host2.host_id(), events[0].first[0]);
- EXPECT_EQ(CHECKING_EVENT, events[0].second);
-
- events = mock_frontend3.raised_events_;
- EXPECT_TRUE(events.empty());
-
- // Abort as we're not testing actual URL fetches in this test.
- delete update;
- }
- UpdateFinished();
- }
-
- void CacheAttemptFetchManifestFailTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(service_->storage(), GURL("http://failme"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- update->StartUpdate(host, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- update->manifest_fetcher_->request()->CancelWithError(-100);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = false;
- frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
- CHECKING_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void UpgradeFetchManifestFailTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(service_->storage(), GURL("http://failme"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(1, 111);
- MockFrontend* frontend1 = MakeMockFrontend();
- MockFrontend* frontend2 = MakeMockFrontend();
- AppCacheHost* host1 = MakeHost(1, frontend1);
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host1->AssociateCompleteCache(cache);
- host2->AssociateCompleteCache(cache);
-
- update->StartUpdate(NULL, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- update->manifest_fetcher_->request()->CancelWithError(-100);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_newest_cache_ = cache; // newest cache unaffected by update
- MockFrontend::HostIds ids1(1, host1->host_id());
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, ERROR_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, CHECKING_EVENT);
- frontend2->AddExpectedEvent(ids2, ERROR_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void ManifestRedirectTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- net::URLRequestJobFactoryImpl* new_factory(
- new net::URLRequestJobFactoryImpl);
- new_factory->SetProtocolHandler("http", new RedirectFactory);
- io_thread_->SetNewJobFactory(new_factory);
-
- MakeService();
- group_ = new AppCacheGroup(service_->storage(), GURL("http://testme"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- update->StartUpdate(host, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = false; // redirect is like a failed request
- frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
- CHECKING_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void ManifestMissingMimeTypeTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(),
- MockHttpServer::GetMockUrl("files/missing-mime-manifest"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 33);
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- host->AssociateCompleteCache(cache);
-
- frontend->SetVerifyProgressEvents(true);
-
- update->StartUpdate(NULL, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_old_cache_ = cache;
- tested_manifest_ = EMPTY_MANIFEST;
- tested_manifest_path_override_ = "files/missing-mime-manifest";
- MockFrontend::HostIds ids(1, host->host_id());
- frontend->AddExpectedEvent(ids, CHECKING_EVENT);
- frontend->AddExpectedEvent(ids, DOWNLOADING_EVENT);
- frontend->AddExpectedEvent(ids, PROGRESS_EVENT); // final
- frontend->AddExpectedEvent(ids, UPDATE_READY_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void ManifestNotFoundTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), MockHttpServer::GetMockUrl("files/nosuchfile"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(1, 111);
- MockFrontend* frontend1 = MakeMockFrontend();
- MockFrontend* frontend2 = MakeMockFrontend();
- AppCacheHost* host1 = MakeHost(1, frontend1);
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host1->AssociateCompleteCache(cache);
- host2->AssociateCompleteCache(cache);
-
- update->StartUpdate(NULL, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = true;
- expect_group_has_cache_ = true;
- expect_newest_cache_ = cache; // newest cache unaffected by update
- MockFrontend::HostIds ids1(1, host1->host_id());
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, OBSOLETE_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, CHECKING_EVENT);
- frontend2->AddExpectedEvent(ids2, OBSOLETE_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void ManifestGoneTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), MockHttpServer::GetMockUrl("files/gone"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- update->StartUpdate(host, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = false;
- frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
- CHECKING_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void CacheAttemptNotModifiedTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), MockHttpServer::GetMockUrl("files/notmodified"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- update->StartUpdate(host, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = false; // treated like cache failure
- frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
- CHECKING_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void UpgradeNotModifiedTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), MockHttpServer::GetMockUrl("files/notmodified"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(1, 111);
- MockFrontend* frontend1 = MakeMockFrontend();
- MockFrontend* frontend2 = MakeMockFrontend();
- AppCacheHost* host1 = MakeHost(1, frontend1);
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host1->AssociateCompleteCache(cache);
- host2->AssociateCompleteCache(cache);
-
- update->StartUpdate(NULL, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_newest_cache_ = cache; // newest cache unaffected by update
- MockFrontend::HostIds ids1(1, host1->host_id());
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, NO_UPDATE_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, CHECKING_EVENT);
- frontend2->AddExpectedEvent(ids2, NO_UPDATE_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void UpgradeManifestDataUnchangedTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- // Create response writer to get a response id.
- response_writer_.reset(
- service_->storage()->CreateResponseWriter(group_->manifest_url(),
- group_->group_id()));
-
- AppCache* cache = MakeCacheForGroup(1, response_writer_->response_id());
- MockFrontend* frontend1 = MakeMockFrontend();
- MockFrontend* frontend2 = MakeMockFrontend();
- AppCacheHost* host1 = MakeHost(1, frontend1);
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host1->AssociateCompleteCache(cache);
- host2->AssociateCompleteCache(cache);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_newest_cache_ = cache; // newest cache unaffected by update
- MockFrontend::HostIds ids1(1, host1->host_id());
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, NO_UPDATE_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, CHECKING_EVENT);
- frontend2->AddExpectedEvent(ids2, NO_UPDATE_EVENT);
-
- // Seed storage with expected manifest data.
- const std::string seed_data(kManifest1Contents);
- scoped_refptr<net::StringIOBuffer> io_buffer(
- new net::StringIOBuffer(seed_data));
- response_writer_->WriteData(
- io_buffer.get(),
- seed_data.length(),
- base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData,
- base::Unretained(this)));
-
- // Start update after data write completes asynchronously.
- }
-
- // See http://code.google.com/p/chromium/issues/detail?id=95101
- void Bug95101Test() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), MockHttpServer::GetMockUrl("files/empty-manifest"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- // Create a malformed cache with a missing manifest entry.
- GURL wrong_manifest_url =
- MockHttpServer::GetMockUrl("files/missing-mime-manifest");
- AppCache* cache = MakeCacheForGroup(1, wrong_manifest_url, 111);
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- host->AssociateCompleteCache(cache);
-
- update->StartUpdate(NULL, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_is_being_deleted_ = true;
- expect_group_has_cache_ = true;
- expect_newest_cache_ = cache; // newest cache unaffected by update
- MockFrontend::HostIds id(1, host->host_id());
- frontend->AddExpectedEvent(id, CHECKING_EVENT);
- frontend->AddExpectedEvent(id, ERROR_EVENT);
- frontend->expected_error_message_ =
- "Manifest entry not found in existing cache";
- WaitForUpdateToFinish();
- }
-
- void StartUpdateAfterSeedingStorageData(int result) {
- ASSERT_GT(result, 0);
- response_writer_.reset();
-
- AppCacheUpdateJob* update = group_->update_job_;
- update->StartUpdate(NULL, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- WaitForUpdateToFinish();
- }
-
- void BasicCacheAttemptSuccessTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- GURL manifest_url = MockHttpServer::GetMockUrl("files/manifest1");
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), manifest_url,
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- update->StartUpdate(host, GURL());
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- tested_manifest_ = MANIFEST1;
- frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
- CHECKING_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void DownloadInterceptEntriesTest() {
- // Ensures we download intercept entries too.
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
- GURL manifest_url =
- MockHttpServer::GetMockUrl("files/manifest-with-intercept");
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), manifest_url,
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- update->StartUpdate(host, GURL());
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- tested_manifest_ = MANIFEST_WITH_INTERCEPT;
- frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
- CHECKING_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void BasicUpgradeSuccessTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- // Create a response writer to get a response id.
- response_writer_.reset(
- service_->storage()->CreateResponseWriter(group_->manifest_url(),
- group_->group_id()));
-
- AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(),
- response_writer_->response_id());
- MockFrontend* frontend1 = MakeMockFrontend();
- MockFrontend* frontend2 = MakeMockFrontend();
- AppCacheHost* host1 = MakeHost(1, frontend1);
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host1->AssociateCompleteCache(cache);
- host2->AssociateCompleteCache(cache);
- frontend1->SetVerifyProgressEvents(true);
- frontend2->SetVerifyProgressEvents(true);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_old_cache_ = cache;
- tested_manifest_ = MANIFEST1;
- MockFrontend::HostIds ids1(1, host1->host_id());
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT); // final
- frontend1->AddExpectedEvent(ids1, UPDATE_READY_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, CHECKING_EVENT);
- frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT);
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT);
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT);
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // final
- frontend2->AddExpectedEvent(ids2, UPDATE_READY_EVENT);
-
- // Seed storage with expected manifest data different from manifest1.
- const std::string seed_data("different");
- scoped_refptr<net::StringIOBuffer> io_buffer(
- new net::StringIOBuffer(seed_data));
- response_writer_->WriteData(
- io_buffer.get(),
- seed_data.length(),
- base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData,
- base::Unretained(this)));
-
- // Start update after data write completes asynchronously.
- }
-
- void UpgradeLoadFromNewestCacheTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 42);
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- host->AssociateCompleteCache(cache);
-
- // Give the newest cache an entry that is in storage.
- response_writer_.reset(
- service_->storage()->CreateResponseWriter(group_->manifest_url(),
- group_->group_id()));
- cache->AddEntry(MockHttpServer::GetMockUrl("files/explicit1"),
- AppCacheEntry(AppCacheEntry::EXPLICIT,
- response_writer_->response_id()));
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_old_cache_ = cache;
- expect_response_ids_.insert(
- std::map<GURL, int64>::value_type(
- MockHttpServer::GetMockUrl("files/explicit1"),
- response_writer_->response_id()));
- tested_manifest_ = MANIFEST1;
- MockFrontend::HostIds ids(1, host->host_id());
- frontend->AddExpectedEvent(ids, CHECKING_EVENT);
- frontend->AddExpectedEvent(ids, DOWNLOADING_EVENT);
- frontend->AddExpectedEvent(ids, PROGRESS_EVENT);
- frontend->AddExpectedEvent(ids, PROGRESS_EVENT);
- frontend->AddExpectedEvent(ids, PROGRESS_EVENT); // final
- frontend->AddExpectedEvent(ids, UPDATE_READY_EVENT);
-
- // Seed storage with expected http response info for entry. Allow reuse.
- const char data[] =
- "HTTP/1.1 200 OK\0"
- "Cache-Control: max-age=8675309\0"
- "\0";
- net::HttpResponseHeaders* headers =
- new net::HttpResponseHeaders(std::string(data, arraysize(data)));
- net::HttpResponseInfo* response_info = new net::HttpResponseInfo();
- response_info->request_time = base::Time::Now();
- response_info->response_time = base::Time::Now();
- response_info->headers = headers; // adds ref to headers
- scoped_refptr<HttpResponseInfoIOBuffer> io_buffer(
- new HttpResponseInfoIOBuffer(response_info)); // adds ref to info
- response_writer_->WriteInfo(
- io_buffer.get(),
- base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData,
- base::Unretained(this)));
-
- // Start update after data write completes asynchronously.
- }
-
- void UpgradeNoLoadFromNewestCacheTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 42);
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- host->AssociateCompleteCache(cache);
-
- // Give the newest cache an entry that is in storage.
- response_writer_.reset(
- service_->storage()->CreateResponseWriter(group_->manifest_url(),
- group_->group_id()));
- cache->AddEntry(MockHttpServer::GetMockUrl("files/explicit1"),
- AppCacheEntry(AppCacheEntry::EXPLICIT,
- response_writer_->response_id()));
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_old_cache_ = cache;
- tested_manifest_ = MANIFEST1;
- MockFrontend::HostIds ids(1, host->host_id());
- frontend->AddExpectedEvent(ids, CHECKING_EVENT);
- frontend->AddExpectedEvent(ids, DOWNLOADING_EVENT);
- frontend->AddExpectedEvent(ids, PROGRESS_EVENT);
- frontend->AddExpectedEvent(ids, PROGRESS_EVENT);
- frontend->AddExpectedEvent(ids, PROGRESS_EVENT); // final
- frontend->AddExpectedEvent(ids, UPDATE_READY_EVENT);
-
- // Seed storage with expected http response info for entry. Do NOT
- // allow reuse by setting an expires header in the past.
- const char data[] =
- "HTTP/1.1 200 OK\0"
- "Expires: Thu, 01 Dec 1994 16:00:00 GMT\0"
- "\0";
- net::HttpResponseHeaders* headers =
- new net::HttpResponseHeaders(std::string(data, arraysize(data)));
- net::HttpResponseInfo* response_info = new net::HttpResponseInfo();
- response_info->request_time = base::Time::Now();
- response_info->response_time = base::Time::Now();
- response_info->headers = headers; // adds ref to headers
- scoped_refptr<HttpResponseInfoIOBuffer> io_buffer(
- new HttpResponseInfoIOBuffer(response_info)); // adds ref to info
- response_writer_->WriteInfo(
- io_buffer.get(),
- base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData,
- base::Unretained(this)));
-
- // Start update after data write completes asynchronously.
- }
-
- void UpgradeLoadFromNewestCacheVaryHeaderTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 42);
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- host->AssociateCompleteCache(cache);
-
- // Give the newest cache an entry that is in storage.
- response_writer_.reset(
- service_->storage()->CreateResponseWriter(group_->manifest_url(),
- group_->group_id()));
- cache->AddEntry(MockHttpServer::GetMockUrl("files/explicit1"),
- AppCacheEntry(AppCacheEntry::EXPLICIT,
- response_writer_->response_id()));
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_old_cache_ = cache;
- tested_manifest_ = MANIFEST1;
- MockFrontend::HostIds ids(1, host->host_id());
- frontend->AddExpectedEvent(ids, CHECKING_EVENT);
- frontend->AddExpectedEvent(ids, DOWNLOADING_EVENT);
- frontend->AddExpectedEvent(ids, PROGRESS_EVENT);
- frontend->AddExpectedEvent(ids, PROGRESS_EVENT);
- frontend->AddExpectedEvent(ids, PROGRESS_EVENT); // final
- frontend->AddExpectedEvent(ids, UPDATE_READY_EVENT);
-
- // Seed storage with expected http response info for entry: a vary header.
- const char data[] =
- "HTTP/1.1 200 OK\0"
- "Cache-Control: max-age=8675309\0"
- "Vary: blah\0"
- "\0";
- net::HttpResponseHeaders* headers =
- new net::HttpResponseHeaders(std::string(data, arraysize(data)));
- net::HttpResponseInfo* response_info = new net::HttpResponseInfo();
- response_info->request_time = base::Time::Now();
- response_info->response_time = base::Time::Now();
- response_info->headers = headers; // adds ref to headers
- scoped_refptr<HttpResponseInfoIOBuffer> io_buffer(
- new HttpResponseInfoIOBuffer(response_info)); // adds ref to info
- response_writer_->WriteInfo(
- io_buffer.get(),
- base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData,
- base::Unretained(this)));
-
- // Start update after data write completes asynchronously.
- }
-
- void UpgradeSuccessMergedTypesTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(service_->storage(),
- MockHttpServer::GetMockUrl("files/manifest-merged-types"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 42);
- MockFrontend* frontend1 = MakeMockFrontend();
- MockFrontend* frontend2 = MakeMockFrontend();
- AppCacheHost* host1 = MakeHost(1, frontend1);
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host1->AssociateCompleteCache(cache);
- host2->AssociateCompleteCache(cache);
-
- // Give the newest cache a master entry that is also one of the explicit
- // entries in the manifest.
- cache->AddEntry(MockHttpServer::GetMockUrl("files/explicit1"),
- AppCacheEntry(AppCacheEntry::MASTER, 111));
-
- update->StartUpdate(NULL, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_old_cache_ = cache;
- tested_manifest_ = MANIFEST_MERGED_TYPES;
- MockFrontend::HostIds ids1(1, host1->host_id());
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT); // explicit1
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT); // manifest
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT); // final
- frontend1->AddExpectedEvent(ids1, UPDATE_READY_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, CHECKING_EVENT);
- frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT);
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT);
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT);
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // final
- frontend2->AddExpectedEvent(ids2, UPDATE_READY_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void CacheAttemptFailUrlFetchTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(service_->storage(),
- MockHttpServer::GetMockUrl("files/manifest-with-404"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- update->StartUpdate(host, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = false; // 404 explicit url is cache failure
- frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
- CHECKING_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void UpgradeFailUrlFetchTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(service_->storage(),
- MockHttpServer::GetMockUrl("files/manifest-fb-404"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 99);
- MockFrontend* frontend1 = MakeMockFrontend();
- MockFrontend* frontend2 = MakeMockFrontend();
- frontend1->SetIgnoreProgressEvents(true);
- frontend2->SetIgnoreProgressEvents(true);
- AppCacheHost* host1 = MakeHost(1, frontend1);
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host1->AssociateCompleteCache(cache);
- host2->AssociateCompleteCache(cache);
-
- update->StartUpdate(NULL, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_newest_cache_ = cache; // newest cache unaffectd by failed update
- MockFrontend::HostIds ids1(1, host1->host_id());
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
- frontend1->AddExpectedEvent(ids1, ERROR_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, CHECKING_EVENT);
- frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT);
- frontend2->AddExpectedEvent(ids2, ERROR_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void UpgradeFailMasterUrlFetchTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- tested_manifest_path_override_ = "files/manifest1-with-notmodified";
-
- MakeService();
- const GURL kManifestUrl =
- MockHttpServer::GetMockUrl(tested_manifest_path_override_);
- group_ = new AppCacheGroup(
- service_->storage(), kManifestUrl,
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 25);
- MockFrontend* frontend1 = MakeMockFrontend();
- MockFrontend* frontend2 = MakeMockFrontend();
- AppCacheHost* host1 = MakeHost(1, frontend1);
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host1->AssociateCompleteCache(cache);
- host2->AssociateCompleteCache(cache);
-
- // Give the newest cache some existing entries; one will fail with a 404.
- cache->AddEntry(
- MockHttpServer::GetMockUrl("files/notfound"),
- AppCacheEntry(AppCacheEntry::MASTER, 222));
- cache->AddEntry(
- MockHttpServer::GetMockUrl("files/explicit2"),
- AppCacheEntry(AppCacheEntry::MASTER | AppCacheEntry::FOREIGN, 333));
- cache->AddEntry(
- MockHttpServer::GetMockUrl("files/servererror"),
- AppCacheEntry(AppCacheEntry::MASTER, 444));
- cache->AddEntry(
- MockHttpServer::GetMockUrl("files/notmodified"),
- AppCacheEntry(AppCacheEntry::EXPLICIT, 555));
-
- // Seed the response_info working set with canned data for
- // files/servererror and for files/notmodified to test that the
- // existing entries for those resource are reused by the update job.
- const char kData[] =
- "HTTP/1.1 200 OK\0"
- "Last-Modified: Sat, 29 Oct 1994 19:43:31 GMT\0"
- "\0";
- const std::string kRawHeaders(kData, arraysize(kData));
- MakeAppCacheResponseInfo(kManifestUrl, 444, kRawHeaders);
- MakeAppCacheResponseInfo(kManifestUrl, 555, kRawHeaders);
-
- update->StartUpdate(NULL, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_old_cache_ = cache;
- tested_manifest_ = MANIFEST1;
- expect_extra_entries_.insert(AppCache::EntryMap::value_type(
- MockHttpServer::GetMockUrl("files/explicit2"),
- AppCacheEntry(AppCacheEntry::MASTER))); // foreign flag is dropped
- expect_extra_entries_.insert(AppCache::EntryMap::value_type(
- MockHttpServer::GetMockUrl("files/servererror"),
- AppCacheEntry(AppCacheEntry::MASTER)));
- expect_extra_entries_.insert(AppCache::EntryMap::value_type(
- MockHttpServer::GetMockUrl("files/notmodified"),
- AppCacheEntry(AppCacheEntry::EXPLICIT)));
- expect_response_ids_.insert(std::map<GURL, int64>::value_type(
- MockHttpServer::GetMockUrl("files/servererror"), 444)); // copied
- expect_response_ids_.insert(std::map<GURL, int64>::value_type(
- MockHttpServer::GetMockUrl("files/notmodified"), 555)); // copied
- MockFrontend::HostIds ids1(1, host1->host_id());
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT); // explicit1
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT); // fallback1a
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT); // notfound
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT); // explicit2
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT); // servererror
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT); // notmodified
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT); // final
- frontend1->AddExpectedEvent(ids1, UPDATE_READY_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, CHECKING_EVENT);
- frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT);
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // explicit1
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // fallback1a
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // notfound
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // explicit2
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // servererror
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // notmodified
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // final
- frontend2->AddExpectedEvent(ids2, UPDATE_READY_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void EmptyManifestTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), MockHttpServer::GetMockUrl("files/empty-manifest"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 33);
- MockFrontend* frontend1 = MakeMockFrontend();
- MockFrontend* frontend2 = MakeMockFrontend();
- AppCacheHost* host1 = MakeHost(1, frontend1);
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host1->AssociateCompleteCache(cache);
- host2->AssociateCompleteCache(cache);
-
- frontend1->SetVerifyProgressEvents(true);
-
- update->StartUpdate(NULL, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_old_cache_ = cache;
- tested_manifest_ = EMPTY_MANIFEST;
- MockFrontend::HostIds ids1(1, host1->host_id());
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT); // final
- frontend1->AddExpectedEvent(ids1, UPDATE_READY_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, CHECKING_EVENT);
- frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT);
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // final
- frontend2->AddExpectedEvent(ids2, UPDATE_READY_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void EmptyFileTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(service_->storage(),
- MockHttpServer::GetMockUrl("files/empty-file-manifest"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 22);
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- host->AssociateCompleteCache(cache);
- frontend->SetVerifyProgressEvents(true);
-
- update->StartUpdate(host, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- tested_manifest_ = EMPTY_FILE_MANIFEST;
- MockFrontend::HostIds ids1(1, host->host_id());
- frontend->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
- frontend->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend->AddExpectedEvent(ids1, PROGRESS_EVENT); // final
- frontend->AddExpectedEvent(ids1, UPDATE_READY_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void RetryRequestTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- // Set some large number of times to return retry.
- // Expect 1 manifest fetch and 3 retries.
- RetryRequestTestJob::Initialize(5, RetryRequestTestJob::RETRY_AFTER_0, 4);
- net::URLRequestJobFactoryImpl* new_factory(
- new net::URLRequestJobFactoryImpl);
- new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory);
- io_thread_->SetNewJobFactory(new_factory);
-
- MakeService();
- group_ = new AppCacheGroup(service_->storage(),
- RetryRequestTestJob::kRetryUrl,
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- update->StartUpdate(host, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = false;
- frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
- CHECKING_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void RetryNoRetryAfterTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- // Set some large number of times to return retry.
- // Expect 1 manifest fetch and 0 retries.
- RetryRequestTestJob::Initialize(5, RetryRequestTestJob::NO_RETRY_AFTER, 1);
- net::URLRequestJobFactoryImpl* new_factory(
- new net::URLRequestJobFactoryImpl);
- new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory);
- io_thread_->SetNewJobFactory(new_factory);
-
- MakeService();
- group_ = new AppCacheGroup(service_->storage(),
- RetryRequestTestJob::kRetryUrl,
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- update->StartUpdate(host, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = false;
- frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
- CHECKING_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void RetryNonzeroRetryAfterTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- // Set some large number of times to return retry.
- // Expect 1 request and 0 retry attempts.
- RetryRequestTestJob::Initialize(
- 5, RetryRequestTestJob::NONZERO_RETRY_AFTER, 1);
- net::URLRequestJobFactoryImpl* new_factory(
- new net::URLRequestJobFactoryImpl);
- new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory);
- io_thread_->SetNewJobFactory(new_factory);
-
- MakeService();
- group_ = new AppCacheGroup(service_->storage(),
- RetryRequestTestJob::kRetryUrl,
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- update->StartUpdate(host, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = false;
- frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
- CHECKING_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void RetrySuccessTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- // Set 2 as the retry limit (does not exceed the max).
- // Expect 1 manifest fetch, 2 retries, 1 url fetch, 1 manifest refetch.
- RetryRequestTestJob::Initialize(2, RetryRequestTestJob::RETRY_AFTER_0, 5);
- net::URLRequestJobFactoryImpl* new_factory(
- new net::URLRequestJobFactoryImpl);
- new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory);
- io_thread_->SetNewJobFactory(new_factory);
-
- MakeService();
- group_ = new AppCacheGroup(service_->storage(),
- RetryRequestTestJob::kRetryUrl,
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- update->StartUpdate(host, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
- CHECKING_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void RetryUrlTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- // Set 1 as the retry limit (does not exceed the max).
- // Expect 1 manifest fetch, 1 url fetch, 1 url retry, 1 manifest refetch.
- RetryRequestTestJob::Initialize(1, RetryRequestTestJob::RETRY_AFTER_0, 4);
- net::URLRequestJobFactoryImpl* new_factory(
- new net::URLRequestJobFactoryImpl);
- new_factory->SetProtocolHandler("http", new RetryRequestTestJobFactory);
- io_thread_->SetNewJobFactory(new_factory);
-
- MakeService();
- group_ = new AppCacheGroup(service_->storage(), GURL("http://retryurl"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- update->StartUpdate(host, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
- CHECKING_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void FailStoreNewestCacheTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- MockAppCacheStorage* storage =
- reinterpret_cast<MockAppCacheStorage*>(service_->storage());
- storage->SimulateStoreGroupAndNewestCacheFailure();
-
- group_ = new AppCacheGroup(
- service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- update->StartUpdate(host, GURL());
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = false; // storage failed
- frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
- CHECKING_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void UpgradeFailStoreNewestCacheTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- MockAppCacheStorage* storage =
- reinterpret_cast<MockAppCacheStorage*>(service_->storage());
- storage->SimulateStoreGroupAndNewestCacheFailure();
-
- group_ = new AppCacheGroup(
- service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 11);
- MockFrontend* frontend1 = MakeMockFrontend();
- MockFrontend* frontend2 = MakeMockFrontend();
- AppCacheHost* host1 = MakeHost(1, frontend1);
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host1->AssociateCompleteCache(cache);
- host2->AssociateCompleteCache(cache);
-
- update->StartUpdate(NULL, GURL());
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_newest_cache_ = cache; // unchanged
- MockFrontend::HostIds ids1(1, host1->host_id());
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend1->AddExpectedEvent(ids1, ERROR_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, CHECKING_EVENT);
- frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT);
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT);
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT);
- frontend2->AddExpectedEvent(ids2, ERROR_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void MasterEntryFailStoreNewestCacheTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- MockAppCacheStorage* storage =
- reinterpret_cast<MockAppCacheStorage*>(service_->storage());
- storage->SimulateStoreGroupAndNewestCacheFailure();
-
- const GURL kManifestUrl = MockHttpServer::GetMockUrl("files/notmodified");
- const int64 kManifestResponseId = 11;
-
- // Seed the response_info working set with canned data for
- // files/servererror and for files/notmodified to test that the
- // existing entries for those resource are reused by the update job.
- const char kData[] =
- "HTTP/1.1 200 OK\0"
- "Content-type: text/cache-manifest\0"
- "Last-Modified: Sat, 29 Oct 1994 19:43:31 GMT\0"
- "\0";
- const std::string kRawHeaders(kData, arraysize(kData));
- MakeAppCacheResponseInfo(kManifestUrl, kManifestResponseId, kRawHeaders);
-
- group_ = new AppCacheGroup(
- service_->storage(), kManifestUrl,
- service_->storage()->NewGroupId());
- scoped_refptr<AppCache> cache(
- MakeCacheForGroup(service_->storage()->NewCacheId(),
- kManifestResponseId));
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- host->first_party_url_ = kManifestUrl;
- host->SelectCache(MockHttpServer::GetMockUrl("files/empty1"),
- kNoCacheId, kManifestUrl);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- tested_manifest_ = EMPTY_MANIFEST;
- tested_manifest_path_override_ = "files/notmodified";
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_newest_cache_ = cache.get(); // unchanged
- MockFrontend::HostIds ids1(1, host->host_id());
- frontend->AddExpectedEvent(ids1, ERROR_EVENT);
- frontend->expected_error_message_ =
- "Failed to commit new cache to storage";
-
- WaitForUpdateToFinish();
- }
-
- void UpgradeFailMakeGroupObsoleteTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- MockAppCacheStorage* storage =
- reinterpret_cast<MockAppCacheStorage*>(service_->storage());
- storage->SimulateMakeGroupObsoleteFailure();
-
- group_ = new AppCacheGroup(
- service_->storage(), MockHttpServer::GetMockUrl("files/nosuchfile"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(1, 111);
- MockFrontend* frontend1 = MakeMockFrontend();
- MockFrontend* frontend2 = MakeMockFrontend();
- AppCacheHost* host1 = MakeHost(1, frontend1);
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host1->AssociateCompleteCache(cache);
- host2->AssociateCompleteCache(cache);
-
- update->StartUpdate(NULL, GURL());
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_newest_cache_ = cache; // newest cache unaffected by update
- MockFrontend::HostIds ids1(1, host1->host_id());
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, ERROR_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, CHECKING_EVENT);
- frontend2->AddExpectedEvent(ids2, ERROR_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void MasterEntryFetchManifestFailTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(service_->storage(), GURL("http://failme"), 111);
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- host->new_master_entry_url_ = GURL("http://failme/blah");
- update->StartUpdate(host, host->new_master_entry_url_);
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- update->manifest_fetcher_->request()->CancelWithError(-100);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = false;
- MockFrontend::HostIds ids1(1, host->host_id());
- frontend->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend->AddExpectedEvent(ids1, ERROR_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void MasterEntryBadManifestTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(service_->storage(),
- MockHttpServer::GetMockUrl("files/bad-manifest"), 111);
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- host->new_master_entry_url_ = MockHttpServer::GetMockUrl("files/blah");
- update->StartUpdate(host, host->new_master_entry_url_);
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = false;
- MockFrontend::HostIds ids1(1, host->host_id());
- frontend->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend->AddExpectedEvent(ids1, ERROR_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void MasterEntryManifestNotFoundTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(),
- MockHttpServer::GetMockUrl("files/nosuchfile"),
- 111);
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- host->new_master_entry_url_ = MockHttpServer::GetMockUrl("files/blah");
-
- update->StartUpdate(host, host->new_master_entry_url_);
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = false;
- MockFrontend::HostIds ids1(1, host->host_id());
- frontend->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend->AddExpectedEvent(ids1, ERROR_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void MasterEntryFailUrlFetchTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(service_->storage(),
- MockHttpServer::GetMockUrl("files/manifest-fb-404"), 111);
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- frontend->SetIgnoreProgressEvents(true);
- AppCacheHost* host = MakeHost(1, frontend);
- host->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/explicit1");
-
- update->StartUpdate(host, host->new_master_entry_url_);
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = false; // 404 fallback url is cache failure
- MockFrontend::HostIds ids1(1, host->host_id());
- frontend->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
- frontend->AddExpectedEvent(ids1, ERROR_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void MasterEntryAllFailTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(),
- MockHttpServer::GetMockUrl("files/manifest1"),
- 111);
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend1 = MakeMockFrontend();
- frontend1->SetIgnoreProgressEvents(true);
- AppCacheHost* host1 = MakeHost(1, frontend1);
- host1->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/nosuchfile");
- update->StartUpdate(host1, host1->new_master_entry_url_);
-
- MockFrontend* frontend2 = MakeMockFrontend();
- frontend2->SetIgnoreProgressEvents(true);
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host2->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/servererror");
- update->StartUpdate(host2, host2->new_master_entry_url_);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = false; // all pending masters failed
- MockFrontend::HostIds ids1(1, host1->host_id());
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
- frontend1->AddExpectedEvent(ids1, ERROR_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, CHECKING_EVENT);
- frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT);
- frontend2->AddExpectedEvent(ids2, ERROR_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void UpgradeMasterEntryAllFailTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(),
- MockHttpServer::GetMockUrl("files/manifest1"),
- 111);
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 42);
- MockFrontend* frontend1 = MakeMockFrontend();
- AppCacheHost* host1 = MakeHost(1, frontend1);
- host1->AssociateCompleteCache(cache);
-
- MockFrontend* frontend2 = MakeMockFrontend();
- frontend2->SetIgnoreProgressEvents(true);
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host2->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/nosuchfile");
- update->StartUpdate(host2, host2->new_master_entry_url_);
-
- MockFrontend* frontend3 = MakeMockFrontend();
- frontend3->SetIgnoreProgressEvents(true);
- AppCacheHost* host3 = MakeHost(3, frontend3);
- host3->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/servererror");
- update->StartUpdate(host3, host3->new_master_entry_url_);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_old_cache_ = cache;
- tested_manifest_ = MANIFEST1;
- MockFrontend::HostIds ids1(1, host1->host_id());
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT); // final
- frontend1->AddExpectedEvent(ids1, UPDATE_READY_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT);
- frontend2->AddExpectedEvent(ids2, ERROR_EVENT);
- MockFrontend::HostIds ids3(1, host3->host_id());
- frontend3->AddExpectedEvent(ids3, CHECKING_EVENT);
- frontend3->AddExpectedEvent(ids3, DOWNLOADING_EVENT);
- frontend3->AddExpectedEvent(ids3, ERROR_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void MasterEntrySomeFailTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(),
- MockHttpServer::GetMockUrl("files/manifest1"),
- 111);
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend1 = MakeMockFrontend();
- frontend1->SetIgnoreProgressEvents(true);
- AppCacheHost* host1 = MakeHost(1, frontend1);
- host1->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/nosuchfile");
- update->StartUpdate(host1, host1->new_master_entry_url_);
-
- MockFrontend* frontend2 = MakeMockFrontend();
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host2->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/explicit2");
- update->StartUpdate(host2, host2->new_master_entry_url_);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true; // as long as one pending master succeeds
- tested_manifest_ = MANIFEST1;
- expect_extra_entries_.insert(AppCache::EntryMap::value_type(
- MockHttpServer::GetMockUrl("files/explicit2"),
- AppCacheEntry(AppCacheEntry::MASTER)));
- MockFrontend::HostIds ids1(1, host1->host_id());
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
- frontend1->AddExpectedEvent(ids1, ERROR_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, CHECKING_EVENT);
- frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT);
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT);
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT);
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // final
- frontend2->AddExpectedEvent(ids2, CACHED_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void UpgradeMasterEntrySomeFailTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(),
- MockHttpServer::GetMockUrl("files/manifest1"),
- 111);
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 42);
- MockFrontend* frontend1 = MakeMockFrontend();
- AppCacheHost* host1 = MakeHost(1, frontend1);
- host1->AssociateCompleteCache(cache);
-
- MockFrontend* frontend2 = MakeMockFrontend();
- frontend2->SetIgnoreProgressEvents(true);
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host2->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/nosuchfile");
- update->StartUpdate(host2, host2->new_master_entry_url_);
-
- MockFrontend* frontend3 = MakeMockFrontend();
- AppCacheHost* host3 = MakeHost(3, frontend3);
- host3->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/explicit2");
- update->StartUpdate(host3, host3->new_master_entry_url_);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_old_cache_ = cache;
- tested_manifest_ = MANIFEST1;
- expect_extra_entries_.insert(AppCache::EntryMap::value_type(
- MockHttpServer::GetMockUrl("files/explicit2"),
- AppCacheEntry(AppCacheEntry::MASTER)));
- MockFrontend::HostIds ids1(1, host1->host_id());
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT); // final
- frontend1->AddExpectedEvent(ids1, UPDATE_READY_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT);
- frontend2->AddExpectedEvent(ids2, ERROR_EVENT);
- MockFrontend::HostIds ids3(1, host3->host_id());
- frontend3->AddExpectedEvent(ids3, CHECKING_EVENT);
- frontend3->AddExpectedEvent(ids3, DOWNLOADING_EVENT);
- frontend3->AddExpectedEvent(ids3, PROGRESS_EVENT);
- frontend3->AddExpectedEvent(ids3, PROGRESS_EVENT);
- frontend3->AddExpectedEvent(ids3, PROGRESS_EVENT); // final
- frontend3->AddExpectedEvent(ids3, UPDATE_READY_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void MasterEntryNoUpdateTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(service_->storage(),
- MockHttpServer::GetMockUrl("files/notmodified"), 111);
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(1, 111);
- MockFrontend* frontend1 = MakeMockFrontend();
- AppCacheHost* host1 = MakeHost(1, frontend1);
- host1->AssociateCompleteCache(cache);
-
- // Give cache an existing entry that can also be fetched.
- cache->AddEntry(MockHttpServer::GetMockUrl("files/explicit2"),
- AppCacheEntry(AppCacheEntry::EXPLICIT, 222));
-
- // Reset the update time to null so we can verify it gets
- // modified in this test case by the UpdateJob.
- cache->set_update_time(base::Time());
-
- MockFrontend* frontend2 = MakeMockFrontend();
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host2->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/explicit1");
- update->StartUpdate(host2, host2->new_master_entry_url_);
-
- AppCacheHost* host3 = MakeHost(3, frontend2); // same frontend as host2
- host3->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/explicit2");
- update->StartUpdate(host3, host3->new_master_entry_url_);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_newest_cache_ = cache; // newest cache still the same cache
- expect_non_null_update_time_ = true;
- tested_manifest_ = PENDING_MASTER_NO_UPDATE;
- MockFrontend::HostIds ids1(1, host1->host_id());
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, NO_UPDATE_EVENT);
- MockFrontend::HostIds ids3(1, host3->host_id());
- frontend2->AddExpectedEvent(ids3, CHECKING_EVENT);
- MockFrontend::HostIds ids2and3;
- ids2and3.push_back(host2->host_id());
- ids2and3.push_back(host3->host_id());
- frontend2->AddExpectedEvent(ids2and3, NO_UPDATE_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void StartUpdateMidCacheAttemptTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), MockHttpServer::GetMockUrl("files/manifest1"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend1 = MakeMockFrontend();
- AppCacheHost* host1 = MakeHost(1, frontend1);
- host1->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/explicit2");
- update->StartUpdate(host1, host1->new_master_entry_url_);
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up additional updates to be started while update is in progress.
- MockFrontend* frontend2 = MakeMockFrontend();
- frontend2->SetIgnoreProgressEvents(true);
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host2->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/nosuchfile");
-
- MockFrontend* frontend3 = MakeMockFrontend();
- AppCacheHost* host3 = MakeHost(3, frontend3);
- host3->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/explicit1");
-
- MockFrontend* frontend4 = MakeMockFrontend();
- AppCacheHost* host4 = MakeHost(4, frontend4);
- host4->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/explicit2");
-
- MockFrontend* frontend5 = MakeMockFrontend();
- AppCacheHost* host5 = MakeHost(5, frontend5); // no master entry url
-
- frontend1->TriggerAdditionalUpdates(DOWNLOADING_EVENT, update);
- frontend1->AdditionalUpdateHost(host2); // fetch will fail
- frontend1->AdditionalUpdateHost(host3); // same as an explicit entry
- frontend1->AdditionalUpdateHost(host4); // same as another master entry
- frontend1->AdditionalUpdateHost(NULL); // no host
- frontend1->AdditionalUpdateHost(host5); // no master entry url
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- tested_manifest_ = MANIFEST1;
- expect_extra_entries_.insert(AppCache::EntryMap::value_type(
- MockHttpServer::GetMockUrl("files/explicit2"),
- AppCacheEntry(AppCacheEntry::MASTER)));
- MockFrontend::HostIds ids1(1, host1->host_id());
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT); // final
- frontend1->AddExpectedEvent(ids1, CACHED_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, CHECKING_EVENT);
- frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT);
- frontend2->AddExpectedEvent(ids2, ERROR_EVENT);
- MockFrontend::HostIds ids3(1, host3->host_id());
- frontend3->AddExpectedEvent(ids3, CHECKING_EVENT);
- frontend3->AddExpectedEvent(ids3, DOWNLOADING_EVENT);
- frontend3->AddExpectedEvent(ids3, PROGRESS_EVENT);
- frontend3->AddExpectedEvent(ids3, PROGRESS_EVENT);
- frontend3->AddExpectedEvent(ids3, PROGRESS_EVENT); // final
- frontend3->AddExpectedEvent(ids3, CACHED_EVENT);
- MockFrontend::HostIds ids4(1, host4->host_id());
- frontend4->AddExpectedEvent(ids4, CHECKING_EVENT);
- frontend4->AddExpectedEvent(ids4, DOWNLOADING_EVENT);
- frontend4->AddExpectedEvent(ids4, PROGRESS_EVENT);
- frontend4->AddExpectedEvent(ids4, PROGRESS_EVENT);
- frontend4->AddExpectedEvent(ids4, PROGRESS_EVENT); // final
- frontend4->AddExpectedEvent(ids4, CACHED_EVENT);
-
- // Host 5 is not associated with cache so no progress/cached events.
- MockFrontend::HostIds ids5(1, host5->host_id());
- frontend5->AddExpectedEvent(ids5, CHECKING_EVENT);
- frontend5->AddExpectedEvent(ids5, DOWNLOADING_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void StartUpdateMidNoUpdateTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), MockHttpServer::GetMockUrl("files/notmodified"),
- service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(1, 111);
- MockFrontend* frontend1 = MakeMockFrontend();
- AppCacheHost* host1 = MakeHost(1, frontend1);
- host1->AssociateCompleteCache(cache);
-
- // Give cache an existing entry.
- cache->AddEntry(MockHttpServer::GetMockUrl("files/explicit2"),
- AppCacheEntry(AppCacheEntry::EXPLICIT, 222));
-
- // Start update with a pending master entry that will fail to give us an
- // event to trigger other updates.
- MockFrontend* frontend2 = MakeMockFrontend();
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host2->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/nosuchfile");
- update->StartUpdate(host2, host2->new_master_entry_url_);
- EXPECT_TRUE(update->manifest_fetcher_ != NULL);
-
- // Set up additional updates to be started while update is in progress.
- MockFrontend* frontend3 = MakeMockFrontend();
- AppCacheHost* host3 = MakeHost(3, frontend3);
- host3->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/explicit1");
-
- MockFrontend* frontend4 = MakeMockFrontend();
- AppCacheHost* host4 = MakeHost(4, frontend4); // no master entry url
-
- MockFrontend* frontend5 = MakeMockFrontend();
- AppCacheHost* host5 = MakeHost(5, frontend5);
- host5->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/explicit2"); // existing entry
-
- MockFrontend* frontend6 = MakeMockFrontend();
- AppCacheHost* host6 = MakeHost(6, frontend6);
- host6->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/explicit1");
-
- frontend2->TriggerAdditionalUpdates(ERROR_EVENT, update);
- frontend2->AdditionalUpdateHost(host3);
- frontend2->AdditionalUpdateHost(NULL); // no host
- frontend2->AdditionalUpdateHost(host4); // no master entry url
- frontend2->AdditionalUpdateHost(host5); // same as existing cache entry
- frontend2->AdditionalUpdateHost(host6); // same as another master entry
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_newest_cache_ = cache; // newest cache unaffected by update
- tested_manifest_ = PENDING_MASTER_NO_UPDATE;
- MockFrontend::HostIds ids1(1, host1->host_id()); // prior associated host
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, NO_UPDATE_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, ERROR_EVENT);
- MockFrontend::HostIds ids3(1, host3->host_id());
- frontend3->AddExpectedEvent(ids3, CHECKING_EVENT);
- frontend3->AddExpectedEvent(ids3, NO_UPDATE_EVENT);
- MockFrontend::HostIds ids4(1, host4->host_id()); // unassociated w/cache
- frontend4->AddExpectedEvent(ids4, CHECKING_EVENT);
- MockFrontend::HostIds ids5(1, host5->host_id());
- frontend5->AddExpectedEvent(ids5, CHECKING_EVENT);
- frontend5->AddExpectedEvent(ids5, NO_UPDATE_EVENT);
- MockFrontend::HostIds ids6(1, host6->host_id());
- frontend6->AddExpectedEvent(ids6, CHECKING_EVENT);
- frontend6->AddExpectedEvent(ids6, NO_UPDATE_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void StartUpdateMidDownloadTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(),
- MockHttpServer::GetMockUrl("files/manifest1"),
- 111);
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 42);
- MockFrontend* frontend1 = MakeMockFrontend();
- AppCacheHost* host1 = MakeHost(1, frontend1);
- host1->AssociateCompleteCache(cache);
-
- update->StartUpdate(NULL, GURL());
-
- // Set up additional updates to be started while update is in progress.
- MockFrontend* frontend2 = MakeMockFrontend();
- AppCacheHost* host2 = MakeHost(2, frontend2);
- host2->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/explicit1");
-
- MockFrontend* frontend3 = MakeMockFrontend();
- AppCacheHost* host3 = MakeHost(3, frontend3);
- host3->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/explicit2");
-
- MockFrontend* frontend4 = MakeMockFrontend();
- AppCacheHost* host4 = MakeHost(4, frontend4); // no master entry url
-
- MockFrontend* frontend5 = MakeMockFrontend();
- AppCacheHost* host5 = MakeHost(5, frontend5);
- host5->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/explicit2");
-
- frontend1->TriggerAdditionalUpdates(PROGRESS_EVENT, update);
- frontend1->AdditionalUpdateHost(host2); // same as entry in manifest
- frontend1->AdditionalUpdateHost(NULL); // no host
- frontend1->AdditionalUpdateHost(host3); // new master entry
- frontend1->AdditionalUpdateHost(host4); // no master entry url
- frontend1->AdditionalUpdateHost(host5); // same as another master entry
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- tested_manifest_ = MANIFEST1;
- expect_extra_entries_.insert(AppCache::EntryMap::value_type(
- MockHttpServer::GetMockUrl("files/explicit2"),
- AppCacheEntry(AppCacheEntry::MASTER)));
- MockFrontend::HostIds ids1(1, host1->host_id()); // prior associated host
- frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend1->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT); // final
- frontend1->AddExpectedEvent(ids1, UPDATE_READY_EVENT);
- MockFrontend::HostIds ids2(1, host2->host_id());
- frontend2->AddExpectedEvent(ids2, CHECKING_EVENT);
- frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT);
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT);
- frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // final
- frontend2->AddExpectedEvent(ids2, UPDATE_READY_EVENT);
- MockFrontend::HostIds ids3(1, host3->host_id());
- frontend3->AddExpectedEvent(ids3, CHECKING_EVENT);
- frontend3->AddExpectedEvent(ids3, DOWNLOADING_EVENT);
- frontend3->AddExpectedEvent(ids3, PROGRESS_EVENT);
- frontend3->AddExpectedEvent(ids3, PROGRESS_EVENT); // final
- frontend3->AddExpectedEvent(ids3, UPDATE_READY_EVENT);
- MockFrontend::HostIds ids4(1, host4->host_id()); // unassociated w/cache
- frontend4->AddExpectedEvent(ids4, CHECKING_EVENT);
- frontend4->AddExpectedEvent(ids4, DOWNLOADING_EVENT);
- MockFrontend::HostIds ids5(1, host5->host_id());
- frontend5->AddExpectedEvent(ids5, CHECKING_EVENT);
- frontend5->AddExpectedEvent(ids5, DOWNLOADING_EVENT);
- frontend5->AddExpectedEvent(ids5, PROGRESS_EVENT);
- frontend5->AddExpectedEvent(ids5, PROGRESS_EVENT); // final
- frontend5->AddExpectedEvent(ids5, UPDATE_READY_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void QueueMasterEntryTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(),
- MockHttpServer::GetMockUrl("files/manifest1"),
- 111);
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- // Pretend update job has been running and is about to terminate.
- group_->update_status_ = AppCacheGroup::DOWNLOADING;
- update->internal_state_ = AppCacheUpdateJob::REFETCH_MANIFEST;
- EXPECT_TRUE(update->IsTerminating());
-
- // Start an update. Should be queued.
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- host->new_master_entry_url_ =
- MockHttpServer::GetMockUrl("files/explicit2");
- update->StartUpdate(host, host->new_master_entry_url_);
- EXPECT_TRUE(update->pending_master_entries_.empty());
- EXPECT_FALSE(group_->queued_updates_.empty());
-
- // Delete update, causing it to finish, which should trigger a new update
- // for the queued host and master entry after a delay.
- delete update;
- EXPECT_FALSE(group_->restart_update_task_.IsCancelled());
-
- // Set up checks for when queued update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- tested_manifest_ = MANIFEST1;
- expect_extra_entries_.insert(AppCache::EntryMap::value_type(
- host->new_master_entry_url_, AppCacheEntry(AppCacheEntry::MASTER)));
- MockFrontend::HostIds ids1(1, host->host_id());
- frontend->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
- frontend->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend->AddExpectedEvent(ids1, PROGRESS_EVENT); // final
- frontend->AddExpectedEvent(ids1, CACHED_EVENT);
-
- // Group status will be IDLE so cannot call WaitForUpdateToFinish.
- group_->AddUpdateObserver(this);
- }
-
- void IfModifiedSinceTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- net::URLRequestJobFactoryImpl* new_factory(
- new net::URLRequestJobFactoryImpl);
- new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory);
- io_thread_->SetNewJobFactory(new_factory);
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), GURL("http://headertest"), 111);
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- // First test against a cache attempt. Will start manifest fetch
- // synchronously.
- HttpHeadersRequestTestJob::Initialize(std::string(), std::string());
- MockFrontend mock_frontend;
- AppCacheHost host(1, &mock_frontend, service_.get());
- update->StartUpdate(&host, GURL());
- HttpHeadersRequestTestJob::Verify();
- delete update;
-
- // Now simulate a refetch manifest request. Will start fetch request
- // synchronously.
- const char data[] =
- "HTTP/1.1 200 OK\0"
- "\0";
- net::HttpResponseHeaders* headers =
- new net::HttpResponseHeaders(std::string(data, arraysize(data)));
- net::HttpResponseInfo* response_info = new net::HttpResponseInfo();
- response_info->headers = headers; // adds ref to headers
-
- HttpHeadersRequestTestJob::Initialize(std::string(), std::string());
- update = new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
- group_->update_status_ = AppCacheGroup::DOWNLOADING;
- update->manifest_response_info_.reset(response_info);
- update->internal_state_ = AppCacheUpdateJob::REFETCH_MANIFEST;
- update->FetchManifest(false); // not first request
- HttpHeadersRequestTestJob::Verify();
- delete update;
-
- // Change the headers to include a Last-Modified header. Manifest refetch
- // should include If-Modified-Since header.
- const char data2[] =
- "HTTP/1.1 200 OK\0"
- "Last-Modified: Sat, 29 Oct 1994 19:43:31 GMT\0"
- "\0";
- net::HttpResponseHeaders* headers2 =
- new net::HttpResponseHeaders(std::string(data2, arraysize(data2)));
- response_info = new net::HttpResponseInfo();
- response_info->headers = headers2;
-
- HttpHeadersRequestTestJob::Initialize("Sat, 29 Oct 1994 19:43:31 GMT",
- std::string());
- update = new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
- group_->update_status_ = AppCacheGroup::DOWNLOADING;
- update->manifest_response_info_.reset(response_info);
- update->internal_state_ = AppCacheUpdateJob::REFETCH_MANIFEST;
- update->FetchManifest(false); // not first request
- HttpHeadersRequestTestJob::Verify();
- delete update;
-
- UpdateFinished();
- }
-
- void IfModifiedSinceUpgradeTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- HttpHeadersRequestTestJob::Initialize("Sat, 29 Oct 1994 19:43:31 GMT",
- std::string());
- net::URLRequestJobFactoryImpl* new_factory(
- new net::URLRequestJobFactoryImpl);
- new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory);
- io_thread_->SetNewJobFactory(new_factory);
-
- MakeService();
- group_ =new AppCacheGroup(
- service_->storage(),
- MockHttpServer::GetMockUrl("files/manifest1"),
- 111);
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- // Give the newest cache a manifest enry that is in storage.
- response_writer_.reset(
- service_->storage()->CreateResponseWriter(group_->manifest_url(),
- group_->group_id()));
-
- AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(),
- response_writer_->response_id());
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- host->AssociateCompleteCache(cache);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_old_cache_ = cache;
- tested_manifest_ = MANIFEST1;
- MockFrontend::HostIds ids1(1, host->host_id());
- frontend->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
- frontend->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend->AddExpectedEvent(ids1, PROGRESS_EVENT); // final
- frontend->AddExpectedEvent(ids1, UPDATE_READY_EVENT);
-
- // Seed storage with expected manifest response info that will cause
- // an If-Modified-Since header to be put in the manifest fetch request.
- const char data[] =
- "HTTP/1.1 200 OK\0"
- "Last-Modified: Sat, 29 Oct 1994 19:43:31 GMT\0"
- "\0";
- net::HttpResponseHeaders* headers =
- new net::HttpResponseHeaders(std::string(data, arraysize(data)));
- net::HttpResponseInfo* response_info = new net::HttpResponseInfo();
- response_info->headers = headers; // adds ref to headers
- scoped_refptr<HttpResponseInfoIOBuffer> io_buffer(
- new HttpResponseInfoIOBuffer(response_info)); // adds ref to info
- response_writer_->WriteInfo(
- io_buffer.get(),
- base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData,
- base::Unretained(this)));
-
- // Start update after data write completes asynchronously.
- }
-
- void IfNoneMatchUpgradeTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- HttpHeadersRequestTestJob::Initialize(std::string(), "\"LadeDade\"");
- net::URLRequestJobFactoryImpl* new_factory(
- new net::URLRequestJobFactoryImpl);
- new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory);
- io_thread_->SetNewJobFactory(new_factory);
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(),
- MockHttpServer::GetMockUrl("files/manifest1"),
- 111);
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- // Give the newest cache a manifest enry that is in storage.
- response_writer_.reset(
- service_->storage()->CreateResponseWriter(group_->manifest_url(),
- group_->group_id()));
-
- AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(),
- response_writer_->response_id());
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- host->AssociateCompleteCache(cache);
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- expect_old_cache_ = cache;
- tested_manifest_ = MANIFEST1;
- MockFrontend::HostIds ids1(1, host->host_id());
- frontend->AddExpectedEvent(ids1, CHECKING_EVENT);
- frontend->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
- frontend->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend->AddExpectedEvent(ids1, PROGRESS_EVENT);
- frontend->AddExpectedEvent(ids1, PROGRESS_EVENT); // final
- frontend->AddExpectedEvent(ids1, UPDATE_READY_EVENT);
-
- // Seed storage with expected manifest response info that will cause
- // an If-None-Match header to be put in the manifest fetch request.
- const char data[] =
- "HTTP/1.1 200 OK\0"
- "ETag: \"LadeDade\"\0"
- "\0";
- net::HttpResponseHeaders* headers =
- new net::HttpResponseHeaders(std::string(data, arraysize(data)));
- net::HttpResponseInfo* response_info = new net::HttpResponseInfo();
- response_info->headers = headers; // adds ref to headers
- scoped_refptr<HttpResponseInfoIOBuffer> io_buffer(
- new HttpResponseInfoIOBuffer(response_info)); // adds ref to info
- response_writer_->WriteInfo(
- io_buffer.get(),
- base::Bind(&AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData,
- base::Unretained(this)));
-
- // Start update after data write completes asynchronously.
- }
-
- void IfNoneMatchRefetchTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- HttpHeadersRequestTestJob::Initialize(std::string(), "\"LadeDade\"");
- net::URLRequestJobFactoryImpl* new_factory(
- new net::URLRequestJobFactoryImpl);
- new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory);
- io_thread_->SetNewJobFactory(new_factory);
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), GURL("http://headertest"), 111);
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- // Simulate a refetch manifest request that uses an ETag header.
- const char data[] =
- "HTTP/1.1 200 OK\0"
- "ETag: \"LadeDade\"\0"
- "\0";
- net::HttpResponseHeaders* headers =
- new net::HttpResponseHeaders(std::string(data, arraysize(data)));
- net::HttpResponseInfo* response_info = new net::HttpResponseInfo();
- response_info->headers = headers; // adds ref to headers
-
- group_->update_status_ = AppCacheGroup::DOWNLOADING;
- update->manifest_response_info_.reset(response_info);
- update->internal_state_ = AppCacheUpdateJob::REFETCH_MANIFEST;
- update->FetchManifest(false); // not first request
- HttpHeadersRequestTestJob::Verify();
- delete update;
-
- UpdateFinished();
- }
-
- void MultipleHeadersRefetchTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- // Verify that code is correct when building multiple extra headers.
- HttpHeadersRequestTestJob::Initialize(
- "Sat, 29 Oct 1994 19:43:31 GMT", "\"LadeDade\"");
- net::URLRequestJobFactoryImpl* new_factory(
- new net::URLRequestJobFactoryImpl);
- new_factory->SetProtocolHandler("http", new IfModifiedSinceJobFactory);
- io_thread_->SetNewJobFactory(new_factory);
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), GURL("http://headertest"), 111);
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- // Simulate a refetch manifest request that uses an ETag header.
- const char data[] =
- "HTTP/1.1 200 OK\0"
- "Last-Modified: Sat, 29 Oct 1994 19:43:31 GMT\0"
- "ETag: \"LadeDade\"\0"
- "\0";
- net::HttpResponseHeaders* headers =
- new net::HttpResponseHeaders(std::string(data, arraysize(data)));
- net::HttpResponseInfo* response_info = new net::HttpResponseInfo();
- response_info->headers = headers; // adds ref to headers
-
- group_->update_status_ = AppCacheGroup::DOWNLOADING;
- update->manifest_response_info_.reset(response_info);
- update->internal_state_ = AppCacheUpdateJob::REFETCH_MANIFEST;
- update->FetchManifest(false); // not first request
- HttpHeadersRequestTestJob::Verify();
- delete update;
-
- UpdateFinished();
- }
-
- void CrossOriginHttpsSuccessTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- GURL manifest_url = MockHttpServer::GetMockHttpsUrl(
- "files/valid_cross_origin_https_manifest");
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), manifest_url, service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- update->StartUpdate(host, GURL());
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = true;
- tested_manifest_ = NONE;
- MockFrontend::HostIds host_ids(1, host->host_id());
- frontend->AddExpectedEvent(host_ids, CHECKING_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void CrossOriginHttpsDeniedTest() {
- ASSERT_EQ(base::MessageLoop::TYPE_IO, base::MessageLoop::current()->type());
-
- GURL manifest_url = MockHttpServer::GetMockHttpsUrl(
- "files/invalid_cross_origin_https_manifest");
-
- MakeService();
- group_ = new AppCacheGroup(
- service_->storage(), manifest_url, service_->storage()->NewGroupId());
- AppCacheUpdateJob* update =
- new AppCacheUpdateJob(service_.get(), group_.get());
- group_->update_job_ = update;
-
- MockFrontend* frontend = MakeMockFrontend();
- AppCacheHost* host = MakeHost(1, frontend);
- update->StartUpdate(host, GURL());
-
- // Set up checks for when update job finishes.
- do_checks_after_update_finished_ = true;
- expect_group_obsolete_ = false;
- expect_group_has_cache_ = false;
- tested_manifest_ = NONE;
- MockFrontend::HostIds host_ids(1, host->host_id());
- frontend->AddExpectedEvent(host_ids, CHECKING_EVENT);
-
- WaitForUpdateToFinish();
- }
-
- void WaitForUpdateToFinish() {
- if (group_->update_status() == AppCacheGroup::IDLE)
- UpdateFinished();
- else
- group_->AddUpdateObserver(this);
- }
-
- virtual void OnUpdateComplete(AppCacheGroup* group) OVERRIDE {
- ASSERT_EQ(group_, group);
- protect_newest_cache_ = group->newest_complete_cache();
- UpdateFinished();
- }
-
- void UpdateFinished() {
- // We unwind the stack prior to finishing up to let stack-based objects
- // get deleted.
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&AppCacheUpdateJobTest::UpdateFinishedUnwound,
- base::Unretained(this)));
- }
-
- void UpdateFinishedUnwound() {
- EXPECT_EQ(AppCacheGroup::IDLE, group_->update_status());
- EXPECT_TRUE(group_->update_job() == NULL);
- if (do_checks_after_update_finished_)
- VerifyExpectations();
-
- // Clean up everything that was created on the IO thread.
- protect_newest_cache_ = NULL;
- group_ = NULL;
- STLDeleteContainerPointers(hosts_.begin(), hosts_.end());
- STLDeleteContainerPointers(frontends_.begin(), frontends_.end());
- response_infos_.clear();
- service_.reset(NULL);
-
- event_->Signal();
- }
-
- void MakeService() {
- service_.reset(new MockAppCacheService());
- service_->set_request_context(io_thread_->request_context());
- }
-
- AppCache* MakeCacheForGroup(int64 cache_id, int64 manifest_response_id) {
- return MakeCacheForGroup(cache_id, group_->manifest_url(),
- manifest_response_id);
- }
-
- AppCache* MakeCacheForGroup(int64 cache_id, const GURL& manifest_entry_url,
- int64 manifest_response_id) {
- AppCache* cache = new AppCache(service_->storage(), cache_id);
- cache->set_complete(true);
- cache->set_update_time(base::Time::Now());
- group_->AddCache(cache);
-
- // Add manifest entry to cache.
- cache->AddEntry(manifest_entry_url,
- AppCacheEntry(AppCacheEntry::MANIFEST, manifest_response_id));
-
- return cache;
- }
-
- AppCacheHost* MakeHost(int host_id, AppCacheFrontend* frontend) {
- AppCacheHost* host = new AppCacheHost(host_id, frontend, service_.get());
- hosts_.push_back(host);
- return host;
- }
-
- AppCacheResponseInfo* MakeAppCacheResponseInfo(
- const GURL& manifest_url, int64 response_id,
- const std::string& raw_headers) {
- net::HttpResponseInfo* http_info = new net::HttpResponseInfo();
- http_info->headers = new net::HttpResponseHeaders(raw_headers);
- scoped_refptr<AppCacheResponseInfo> info(
- new AppCacheResponseInfo(service_->storage(), manifest_url,
- response_id, http_info, 0));
- response_infos_.push_back(info);
- return info.get();
- }
-
- MockFrontend* MakeMockFrontend() {
- MockFrontend* frontend = new MockFrontend();
- frontends_.push_back(frontend);
- return frontend;
- }
-
- // Verifies conditions about the group and notifications after an update
- // has finished. Cannot verify update job internals as update is deleted.
- void VerifyExpectations() {
- RetryRequestTestJob::Verify();
- HttpHeadersRequestTestJob::Verify();
-
- EXPECT_EQ(expect_group_obsolete_, group_->is_obsolete());
- EXPECT_EQ(expect_group_is_being_deleted_, group_->is_being_deleted());
-
- if (expect_group_has_cache_) {
- EXPECT_TRUE(group_->newest_complete_cache() != NULL);
-
- if (expect_non_null_update_time_)
- EXPECT_TRUE(!group_->newest_complete_cache()->update_time().is_null());
-
- if (expect_old_cache_) {
- EXPECT_NE(expect_old_cache_, group_->newest_complete_cache());
- EXPECT_TRUE(group_->old_caches().end() !=
- std::find(group_->old_caches().begin(),
- group_->old_caches().end(), expect_old_cache_));
- }
- if (expect_newest_cache_) {
- EXPECT_EQ(expect_newest_cache_, group_->newest_complete_cache());
- EXPECT_TRUE(group_->old_caches().end() ==
- std::find(group_->old_caches().begin(),
- group_->old_caches().end(), expect_newest_cache_));
- } else {
- // Tests that don't know which newest cache to expect contain updates
- // that succeed (because the update creates a new cache whose pointer
- // is unknown to the test). Check group and newest cache were stored
- // when update succeeds.
- MockAppCacheStorage* storage =
- reinterpret_cast<MockAppCacheStorage*>(service_->storage());
- EXPECT_TRUE(storage->IsGroupStored(group_.get()));
- EXPECT_TRUE(storage->IsCacheStored(group_->newest_complete_cache()));
-
- // Check that all entries in the newest cache were stored.
- const AppCache::EntryMap& entries =
- group_->newest_complete_cache()->entries();
- for (AppCache::EntryMap::const_iterator it = entries.begin();
- it != entries.end(); ++it) {
- EXPECT_NE(kNoResponseId, it->second.response_id());
-
- // Check that any copied entries have the expected response id
- // and that entries that are not copied have a different response id.
- std::map<GURL, int64>::iterator found =
- expect_response_ids_.find(it->first);
- if (found != expect_response_ids_.end()) {
- EXPECT_EQ(found->second, it->second.response_id());
- } else if (expect_old_cache_) {
- AppCacheEntry* old_entry = expect_old_cache_->GetEntry(it->first);
- if (old_entry)
- EXPECT_NE(old_entry->response_id(), it->second.response_id());
- }
- }
- }
- } else {
- EXPECT_TRUE(group_->newest_complete_cache() == NULL);
- }
-
- // Check expected events.
- for (size_t i = 0; i < frontends_.size(); ++i) {
- MockFrontend* frontend = frontends_[i];
-
- MockFrontend::RaisedEvents& expected_events = frontend->expected_events_;
- MockFrontend::RaisedEvents& actual_events = frontend->raised_events_;
- EXPECT_EQ(expected_events.size(), actual_events.size());
-
- // Check each expected event.
- for (size_t j = 0;
- j < expected_events.size() && j < actual_events.size(); ++j) {
- EXPECT_EQ(expected_events[j].second, actual_events[j].second);
-
- MockFrontend::HostIds& expected_ids = expected_events[j].first;
- MockFrontend::HostIds& actual_ids = actual_events[j].first;
- EXPECT_EQ(expected_ids.size(), actual_ids.size());
-
- for (size_t k = 0; k < expected_ids.size(); ++k) {
- int id = expected_ids[k];
- EXPECT_TRUE(std::find(actual_ids.begin(), actual_ids.end(), id) !=
- actual_ids.end());
- }
- }
-
- if (!frontend->expected_error_message_.empty()) {
- EXPECT_EQ(frontend->expected_error_message_,
- frontend->error_message_);
- }
- }
-
- // Verify expected cache contents last as some checks are asserts
- // and will abort the test if they fail.
- if (tested_manifest_) {
- AppCache* cache = group_->newest_complete_cache();
- ASSERT_TRUE(cache != NULL);
- EXPECT_EQ(group_, cache->owning_group());
- EXPECT_TRUE(cache->is_complete());
-
- switch (tested_manifest_) {
- case MANIFEST1:
- VerifyManifest1(cache);
- break;
- case MANIFEST_MERGED_TYPES:
- VerifyManifestMergedTypes(cache);
- break;
- case EMPTY_MANIFEST:
- VerifyEmptyManifest(cache);
- break;
- case EMPTY_FILE_MANIFEST:
- VerifyEmptyFileManifest(cache);
- break;
- case PENDING_MASTER_NO_UPDATE:
- VerifyMasterEntryNoUpdate(cache);
- break;
- case MANIFEST_WITH_INTERCEPT:
- VerifyManifestWithIntercept(cache);
- break;
- case NONE:
- default:
- break;
- }
- }
- }
-
- void VerifyManifest1(AppCache* cache) {
- size_t expected = 3 + expect_extra_entries_.size();
- EXPECT_EQ(expected, cache->entries().size());
- const char* kManifestPath = tested_manifest_path_override_ ?
- tested_manifest_path_override_ :
- "files/manifest1";
- AppCacheEntry* entry =
- cache->GetEntry(MockHttpServer::GetMockUrl(kManifestPath));
- ASSERT_TRUE(entry);
- EXPECT_EQ(AppCacheEntry::MANIFEST, entry->types());
- entry = cache->GetEntry(MockHttpServer::GetMockUrl("files/explicit1"));
- ASSERT_TRUE(entry);
- EXPECT_TRUE(entry->IsExplicit());
- entry = cache->GetEntry(
- MockHttpServer::GetMockUrl("files/fallback1a"));
- ASSERT_TRUE(entry);
- EXPECT_EQ(AppCacheEntry::FALLBACK, entry->types());
-
- for (AppCache::EntryMap::iterator i = expect_extra_entries_.begin();
- i != expect_extra_entries_.end(); ++i) {
- entry = cache->GetEntry(i->first);
- ASSERT_TRUE(entry);
- EXPECT_EQ(i->second.types(), entry->types());
- }
-
- expected = 1;
- ASSERT_EQ(expected, cache->fallback_namespaces_.size());
- EXPECT_TRUE(cache->fallback_namespaces_[0] ==
- Namespace(
- FALLBACK_NAMESPACE,
- MockHttpServer::GetMockUrl("files/fallback1"),
- MockHttpServer::GetMockUrl("files/fallback1a"),
- false));
-
- EXPECT_TRUE(cache->online_whitelist_namespaces_.empty());
- EXPECT_TRUE(cache->online_whitelist_all_);
-
- EXPECT_TRUE(cache->update_time_ > base::Time());
- }
-
- void VerifyManifestMergedTypes(AppCache* cache) {
- size_t expected = 2;
- EXPECT_EQ(expected, cache->entries().size());
- AppCacheEntry* entry = cache->GetEntry(
- MockHttpServer::GetMockUrl("files/manifest-merged-types"));
- ASSERT_TRUE(entry);
- EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::MANIFEST,
- entry->types());
- entry = cache->GetEntry(MockHttpServer::GetMockUrl("files/explicit1"));
- ASSERT_TRUE(entry);
- EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::FALLBACK |
- AppCacheEntry::MASTER, entry->types());
-
- expected = 1;
- ASSERT_EQ(expected, cache->fallback_namespaces_.size());
- EXPECT_TRUE(cache->fallback_namespaces_[0] ==
- Namespace(
- FALLBACK_NAMESPACE,
- MockHttpServer::GetMockUrl("files/fallback1"),
- MockHttpServer::GetMockUrl("files/explicit1"),
- false));
-
- EXPECT_EQ(expected, cache->online_whitelist_namespaces_.size());
- EXPECT_TRUE(cache->online_whitelist_namespaces_[0] ==
- Namespace(
- NETWORK_NAMESPACE,
- MockHttpServer::GetMockUrl("files/online1"),
- GURL(), false));
- EXPECT_FALSE(cache->online_whitelist_all_);
-
- EXPECT_TRUE(cache->update_time_ > base::Time());
- }
-
- void VerifyEmptyManifest(AppCache* cache) {
- const char* kManifestPath = tested_manifest_path_override_ ?
- tested_manifest_path_override_ :
- "files/empty-manifest";
- size_t expected = 1;
- EXPECT_EQ(expected, cache->entries().size());
- AppCacheEntry* entry = cache->GetEntry(
- MockHttpServer::GetMockUrl(kManifestPath));
- ASSERT_TRUE(entry);
- EXPECT_EQ(AppCacheEntry::MANIFEST, entry->types());
-
- EXPECT_TRUE(cache->fallback_namespaces_.empty());
- EXPECT_TRUE(cache->online_whitelist_namespaces_.empty());
- EXPECT_FALSE(cache->online_whitelist_all_);
-
- EXPECT_TRUE(cache->update_time_ > base::Time());
- }
-
- void VerifyEmptyFileManifest(AppCache* cache) {
- EXPECT_EQ(size_t(2), cache->entries().size());
- AppCacheEntry* entry = cache->GetEntry(
- MockHttpServer::GetMockUrl("files/empty-file-manifest"));
- ASSERT_TRUE(entry);
- EXPECT_EQ(AppCacheEntry::MANIFEST, entry->types());
-
- entry = cache->GetEntry(
- MockHttpServer::GetMockUrl("files/empty1"));
- ASSERT_TRUE(entry);
- EXPECT_EQ(AppCacheEntry::EXPLICIT, entry->types());
- EXPECT_TRUE(entry->has_response_id());
-
- EXPECT_TRUE(cache->fallback_namespaces_.empty());
- EXPECT_TRUE(cache->online_whitelist_namespaces_.empty());
- EXPECT_FALSE(cache->online_whitelist_all_);
-
- EXPECT_TRUE(cache->update_time_ > base::Time());
- }
-
- void VerifyMasterEntryNoUpdate(AppCache* cache) {
- EXPECT_EQ(size_t(3), cache->entries().size());
- AppCacheEntry* entry = cache->GetEntry(
- MockHttpServer::GetMockUrl("files/notmodified"));
- ASSERT_TRUE(entry);
- EXPECT_EQ(AppCacheEntry::MANIFEST, entry->types());
-
- entry = cache->GetEntry(
- MockHttpServer::GetMockUrl("files/explicit1"));
- ASSERT_TRUE(entry);
- EXPECT_EQ(AppCacheEntry::MASTER, entry->types());
- EXPECT_TRUE(entry->has_response_id());
-
- entry = cache->GetEntry(
- MockHttpServer::GetMockUrl("files/explicit2"));
- ASSERT_TRUE(entry);
- EXPECT_EQ(AppCacheEntry::EXPLICIT | AppCacheEntry::MASTER, entry->types());
- EXPECT_TRUE(entry->has_response_id());
-
- EXPECT_TRUE(cache->fallback_namespaces_.empty());
- EXPECT_TRUE(cache->online_whitelist_namespaces_.empty());
- EXPECT_FALSE(cache->online_whitelist_all_);
-
- EXPECT_TRUE(cache->update_time_ > base::Time());
- }
-
- void VerifyManifestWithIntercept(AppCache* cache) {
- EXPECT_EQ(2u, cache->entries().size());
- const char* kManifestPath = "files/manifest-with-intercept";
- AppCacheEntry* entry =
- cache->GetEntry(MockHttpServer::GetMockUrl(kManifestPath));
- ASSERT_TRUE(entry);
- EXPECT_EQ(AppCacheEntry::MANIFEST, entry->types());
- entry = cache->GetEntry(MockHttpServer::GetMockUrl("files/intercept1a"));
- ASSERT_TRUE(entry);
- EXPECT_TRUE(entry->IsIntercept());
- EXPECT_TRUE(cache->online_whitelist_namespaces_.empty());
- EXPECT_FALSE(cache->online_whitelist_all_);
- EXPECT_TRUE(cache->update_time_ > base::Time());
- }
-
- private:
- // Various manifest files used in this test.
- enum TestedManifest {
- NONE,
- MANIFEST1,
- MANIFEST_MERGED_TYPES,
- EMPTY_MANIFEST,
- EMPTY_FILE_MANIFEST,
- PENDING_MASTER_NO_UPDATE,
- MANIFEST_WITH_INTERCEPT
- };
-
- scoped_ptr<IOThread> io_thread_;
-
- scoped_ptr<MockAppCacheService> service_;
- scoped_refptr<AppCacheGroup> group_;
- scoped_refptr<AppCache> protect_newest_cache_;
- scoped_ptr<base::WaitableEvent> event_;
-
- scoped_ptr<AppCacheResponseWriter> response_writer_;
-
- // Hosts used by an async test that need to live until update job finishes.
- // Otherwise, test can put host on the stack instead of here.
- std::vector<AppCacheHost*> hosts_;
-
- // Response infos used by an async test that need to live until update job
- // finishes.
- std::vector<scoped_refptr<AppCacheResponseInfo> > response_infos_;
-
- // Flag indicating if test cares to verify the update after update finishes.
- bool do_checks_after_update_finished_;
- bool expect_group_obsolete_;
- bool expect_group_has_cache_;
- bool expect_group_is_being_deleted_;
- AppCache* expect_old_cache_;
- AppCache* expect_newest_cache_;
- bool expect_non_null_update_time_;
- std::vector<MockFrontend*> frontends_; // to check expected events
- TestedManifest tested_manifest_;
- const char* tested_manifest_path_override_;
- AppCache::EntryMap expect_extra_entries_;
- std::map<GURL, int64> expect_response_ids_;
-};
-
-TEST_F(AppCacheUpdateJobTest, AlreadyChecking) {
- MockAppCacheService service;
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service.storage(), GURL("http://manifesturl.com"),
- service.storage()->NewGroupId()));
-
- AppCacheUpdateJob update(&service, group.get());
-
- // Pretend group is in checking state.
- group->update_job_ = &update;
- group->update_status_ = AppCacheGroup::CHECKING;
-
- update.StartUpdate(NULL, GURL());
- EXPECT_EQ(AppCacheGroup::CHECKING, group->update_status());
-
- MockFrontend mock_frontend;
- AppCacheHost host(1, &mock_frontend, &service);
- update.StartUpdate(&host, GURL());
-
- MockFrontend::RaisedEvents events = mock_frontend.raised_events_;
- size_t expected = 1;
- EXPECT_EQ(expected, events.size());
- EXPECT_EQ(expected, events[0].first.size());
- EXPECT_EQ(host.host_id(), events[0].first[0]);
- EXPECT_EQ(CHECKING_EVENT, events[0].second);
- EXPECT_EQ(AppCacheGroup::CHECKING, group->update_status());
-}
-
-TEST_F(AppCacheUpdateJobTest, AlreadyDownloading) {
- MockAppCacheService service;
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service.storage(), GURL("http://manifesturl.com"),
- service.storage()->NewGroupId()));
-
- AppCacheUpdateJob update(&service, group.get());
-
- // Pretend group is in downloading state.
- group->update_job_ = &update;
- group->update_status_ = AppCacheGroup::DOWNLOADING;
-
- update.StartUpdate(NULL, GURL());
- EXPECT_EQ(AppCacheGroup::DOWNLOADING, group->update_status());
-
- MockFrontend mock_frontend;
- AppCacheHost host(1, &mock_frontend, &service);
- update.StartUpdate(&host, GURL());
-
- MockFrontend::RaisedEvents events = mock_frontend.raised_events_;
- size_t expected = 2;
- EXPECT_EQ(expected, events.size());
- expected = 1;
- EXPECT_EQ(expected, events[0].first.size());
- EXPECT_EQ(host.host_id(), events[0].first[0]);
- EXPECT_EQ(CHECKING_EVENT, events[0].second);
-
- EXPECT_EQ(expected, events[1].first.size());
- EXPECT_EQ(host.host_id(), events[1].first[0]);
- EXPECT_EQ(appcache::DOWNLOADING_EVENT, events[1].second);
-
- EXPECT_EQ(AppCacheGroup::DOWNLOADING, group->update_status());
-}
-
-TEST_F(AppCacheUpdateJobTest, StartCacheAttempt) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::StartCacheAttemptTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, StartUpgradeAttempt) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::StartUpgradeAttemptTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, CacheAttemptFetchManifestFail) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::CacheAttemptFetchManifestFailTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, UpgradeFetchManifestFail) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::UpgradeFetchManifestFailTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, ManifestRedirect) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::ManifestRedirectTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, ManifestMissingMimeTypeTest) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::ManifestMissingMimeTypeTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, ManifestNotFound) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::ManifestNotFoundTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, ManifestGone) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::ManifestGoneTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, CacheAttemptNotModified) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::CacheAttemptNotModifiedTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, UpgradeNotModified) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::UpgradeNotModifiedTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, UpgradeManifestDataUnchanged) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::UpgradeManifestDataUnchangedTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, Bug95101Test) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::Bug95101Test);
-}
-
-TEST_F(AppCacheUpdateJobTest, BasicCacheAttemptSuccess) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::BasicCacheAttemptSuccessTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, DownloadInterceptEntriesTest) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::DownloadInterceptEntriesTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, BasicUpgradeSuccess) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::BasicUpgradeSuccessTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, UpgradeLoadFromNewestCache) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::UpgradeLoadFromNewestCacheTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, UpgradeNoLoadFromNewestCache) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::UpgradeNoLoadFromNewestCacheTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, UpgradeLoadFromNewestCacheVaryHeader) {
- RunTestOnIOThread(
- &AppCacheUpdateJobTest::UpgradeLoadFromNewestCacheVaryHeaderTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, UpgradeSuccessMergedTypes) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::UpgradeSuccessMergedTypesTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, CacheAttemptFailUrlFetch) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::CacheAttemptFailUrlFetchTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, UpgradeFailUrlFetch) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::UpgradeFailUrlFetchTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, UpgradeFailMasterUrlFetch) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::UpgradeFailMasterUrlFetchTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, EmptyManifest) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::EmptyManifestTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, EmptyFile) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::EmptyFileTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, RetryRequest) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::RetryRequestTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, RetryNoRetryAfter) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::RetryNoRetryAfterTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, RetryNonzeroRetryAfter) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::RetryNonzeroRetryAfterTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, RetrySuccess) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::RetrySuccessTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, RetryUrl) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::RetryUrlTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, FailStoreNewestCache) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::FailStoreNewestCacheTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, MasterEntryFailStoreNewestCacheTest) {
- RunTestOnIOThread(
- &AppCacheUpdateJobTest::MasterEntryFailStoreNewestCacheTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, UpgradeFailStoreNewestCache) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::UpgradeFailStoreNewestCacheTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, UpgradeFailMakeGroupObsolete) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::UpgradeFailMakeGroupObsoleteTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, MasterEntryFetchManifestFail) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::MasterEntryFetchManifestFailTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, MasterEntryBadManifest) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::MasterEntryBadManifestTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, MasterEntryManifestNotFound) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::MasterEntryManifestNotFoundTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, MasterEntryFailUrlFetch) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::MasterEntryFailUrlFetchTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, MasterEntryAllFail) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::MasterEntryAllFailTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, UpgradeMasterEntryAllFail) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::UpgradeMasterEntryAllFailTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, MasterEntrySomeFail) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::MasterEntrySomeFailTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, UpgradeMasterEntrySomeFail) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::UpgradeMasterEntrySomeFailTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, MasterEntryNoUpdate) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::MasterEntryNoUpdateTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, StartUpdateMidCacheAttempt) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::StartUpdateMidCacheAttemptTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, StartUpdateMidNoUpdate) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::StartUpdateMidNoUpdateTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, StartUpdateMidDownload) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::StartUpdateMidDownloadTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, QueueMasterEntry) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::QueueMasterEntryTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, IfModifiedSince) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::IfModifiedSinceTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, IfModifiedSinceUpgrade) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::IfModifiedSinceUpgradeTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, IfNoneMatchUpgrade) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::IfNoneMatchUpgradeTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, IfNoneMatchRefetch) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::IfNoneMatchRefetchTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, MultipleHeadersRefetch) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::MultipleHeadersRefetchTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsSuccess) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsSuccessTest);
-}
-
-TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) {
- RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest);
-}
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/appcache_url_request_job.cc b/chromium/webkit/browser/appcache/appcache_url_request_job.cc
index 759d757d6f0..2cdcb779a50 100644
--- a/chromium/webkit/browser/appcache/appcache_url_request_job.cc
+++ b/chromium/webkit/browser/appcache/appcache_url_request_job.cc
@@ -25,7 +25,7 @@
#include "webkit/browser/appcache/appcache_group.h"
#include "webkit/browser/appcache/appcache_histograms.h"
#include "webkit/browser/appcache/appcache_host.h"
-#include "webkit/browser/appcache/appcache_service.h"
+#include "webkit/browser/appcache/appcache_service_impl.h"
namespace appcache {
@@ -33,13 +33,15 @@ AppCacheURLRequestJob::AppCacheURLRequestJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate,
AppCacheStorage* storage,
- AppCacheHost* host)
+ AppCacheHost* host,
+ bool is_main_resource)
: net::URLRequestJob(request, network_delegate),
host_(host),
storage_(storage),
has_been_started_(false), has_been_killed_(false),
delivery_type_(AWAITING_DELIVERY_ORDERS),
- group_id_(0), cache_id_(kNoCacheId), is_fallback_(false),
+ group_id_(0), cache_id_(kAppCacheNoCacheId), is_fallback_(false),
+ is_main_resource_(is_main_resource),
cache_entry_not_found_(false),
weak_factory_(this) {
DCHECK(storage_);
@@ -254,7 +256,8 @@ void AppCacheURLRequestJob::OnExecutableResponseCallback(
void AppCacheURLRequestJob::BeginErrorDelivery(const char* message) {
if (host_)
- host_->frontend()->OnLogMessage(host_->host_id(), LOG_ERROR, message);
+ host_->frontend()->OnLogMessage(host_->host_id(), APPCACHE_LOG_ERROR,
+ message);
delivery_type_ = ERROR_DELIVERY;
storage_ = NULL;
BeginDelivery();
@@ -287,6 +290,8 @@ void AppCacheURLRequestJob::OnResponseInfoLoaded(
// from the appcache.
storage_->service()->CheckAppCacheResponse(manifest_url_, cache_id_,
entry_.response_id());
+ AppCacheHistograms::CountResponseRetrieval(
+ false, is_main_resource_, manifest_url_.GetOrigin());
}
cache_entry_not_found_ = true;
NotifyRestartRequired();
@@ -310,8 +315,7 @@ void AppCacheURLRequestJob::SetupRangeResponse() {
return;
}
- DCHECK(range_requested_.HasFirstBytePosition() &&
- range_requested_.HasLastBytePosition());
+ DCHECK(range_requested_.IsValid());
int offset = static_cast<int>(range_requested_.first_byte_position());
int length = static_cast<int>(range_requested_.last_byte_position() -
range_requested_.first_byte_position() + 1);
@@ -321,35 +325,27 @@ void AppCacheURLRequestJob::SetupRangeResponse() {
// Make a copy of the full response headers and fix them up
// for the range we'll be returning.
- const char kLengthHeader[] = "Content-Length";
- const char kRangeHeader[] = "Content-Range";
- const char kPartialStatusLine[] = "HTTP/1.1 206 Partial Content";
range_response_info_.reset(
new net::HttpResponseInfo(*info_->http_response_info()));
net::HttpResponseHeaders* headers = range_response_info_->headers.get();
- headers->RemoveHeader(kLengthHeader);
- headers->RemoveHeader(kRangeHeader);
- headers->ReplaceStatusLine(kPartialStatusLine);
- headers->AddHeader(
- base::StringPrintf("%s: %d", kLengthHeader, length));
- headers->AddHeader(
- base::StringPrintf("%s: bytes %d-%d/%d",
- kRangeHeader,
- offset,
- offset + length - 1,
- resource_size));
+ headers->UpdateWithNewRange(
+ range_requested_, resource_size, true /* replace status line */);
}
void AppCacheURLRequestJob::OnReadComplete(int result) {
DCHECK(is_delivering_appcache_response());
if (result == 0) {
NotifyDone(net::URLRequestStatus());
+ AppCacheHistograms::CountResponseRetrieval(
+ true, is_main_resource_, manifest_url_.GetOrigin());
} else if (result < 0) {
if (storage_->service()->storage() == storage_) {
storage_->service()->CheckAppCacheResponse(manifest_url_, cache_id_,
entry_.response_id());
}
NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, result));
+ AppCacheHistograms::CountResponseRetrieval(
+ false, is_main_resource_, manifest_url_.GetOrigin());
} else {
SetStatus(net::URLRequestStatus()); // Clear the IO_PENDING status
}
diff --git a/chromium/webkit/browser/appcache/appcache_url_request_job.h b/chromium/webkit/browser/appcache/appcache_url_request_job.h
index 87df368764f..01c80a115eb 100644
--- a/chromium/webkit/browser/appcache/appcache_url_request_job.h
+++ b/chromium/webkit/browser/appcache/appcache_url_request_job.h
@@ -16,6 +16,11 @@
#include "webkit/browser/appcache/appcache_storage.h"
#include "webkit/browser/webkit_storage_browser_export.h"
+namespace content {
+class AppCacheRequestHandlerTest;
+class AppCacheURLRequestJobTest;
+}
+
namespace net {
class GrowableIOBuffer;
};
@@ -33,7 +38,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheURLRequestJob
AppCacheURLRequestJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate,
AppCacheStorage* storage,
- AppCacheHost* host);
+ AppCacheHost* host,
+ bool is_main_resource);
// Informs the job of what response it should deliver. Only one of these
// methods should be called, and only once per job. A job will sit idle and
@@ -91,8 +97,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheURLRequestJob
virtual ~AppCacheURLRequestJob();
private:
- friend class AppCacheRequestHandlerTest;
- friend class AppCacheURLRequestJobTest;
+ friend class content::AppCacheRequestHandlerTest;
+ friend class content::AppCacheURLRequestJobTest;
enum DeliveryType {
AWAITING_DELIVERY_ORDERS,
@@ -158,6 +164,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheURLRequestJob
int64 cache_id_;
AppCacheEntry entry_;
bool is_fallback_;
+ bool is_main_resource_; // Used for histogram logging.
bool cache_entry_not_found_;
scoped_refptr<AppCacheResponseInfo> info_;
scoped_refptr<net::GrowableIOBuffer> handler_source_buffer_;
diff --git a/chromium/webkit/browser/appcache/appcache_url_request_job_unittest.cc b/chromium/webkit/browser/appcache/appcache_url_request_job_unittest.cc
deleted file mode 100644
index 3f9675a96ca..00000000000
--- a/chromium/webkit/browser/appcache/appcache_url_request_job_unittest.cc
+++ /dev/null
@@ -1,816 +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.
-
-#include <stack>
-#include <utility>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/callback.h"
-#include "base/compiler_specific.h"
-#include "base/pickle.h"
-#include "base/synchronization/waitable_event.h"
-#include "base/threading/thread.h"
-#include "net/base/io_buffer.h"
-#include "net/base/net_errors.h"
-#include "net/base/request_priority.h"
-#include "net/http/http_response_headers.h"
-#include "net/url_request/url_request.h"
-#include "net/url_request/url_request_context.h"
-#include "net/url_request/url_request_error_job.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/appcache_url_request_job.h"
-#include "webkit/browser/appcache/mock_appcache_service.h"
-
-using net::IOBuffer;
-using net::WrappedIOBuffer;
-
-namespace appcache {
-
-static const char kHttpBasicHeaders[] =
- "HTTP/1.0 200 OK\0Content-Length: 5\0\0";
-static const char kHttpBasicBody[] = "Hello";
-
-static const int kNumBlocks = 4;
-static const int kBlockSize = 1024;
-
-class AppCacheURLRequestJobTest : public testing::Test {
- public:
-
- // Test Harness -------------------------------------------------------------
- // TODO(michaeln): share this test harness with AppCacheResponseTest
-
- class MockStorageDelegate : public AppCacheStorage::Delegate {
- public:
- explicit MockStorageDelegate(AppCacheURLRequestJobTest* test)
- : loaded_info_id_(0), test_(test) {
- }
-
- virtual void OnResponseInfoLoaded(AppCacheResponseInfo* info,
- int64 response_id) OVERRIDE {
- loaded_info_ = info;
- loaded_info_id_ = response_id;
- test_->ScheduleNextTask();
- }
-
- scoped_refptr<AppCacheResponseInfo> loaded_info_;
- int64 loaded_info_id_;
- AppCacheURLRequestJobTest* test_;
- };
-
- class MockURLRequestDelegate : public net::URLRequest::Delegate {
- public:
- explicit MockURLRequestDelegate(AppCacheURLRequestJobTest* test)
- : test_(test),
- received_data_(new net::IOBuffer(kNumBlocks * kBlockSize)),
- did_receive_headers_(false), amount_received_(0),
- kill_after_amount_received_(0), kill_with_io_pending_(false) {
- }
-
- virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE {
- amount_received_ = 0;
- did_receive_headers_ = false;
- if (request->status().is_success()) {
- EXPECT_TRUE(request->response_headers());
- did_receive_headers_ = true;
- received_info_ = request->response_info();
- ReadSome(request);
- } else {
- RequestComplete();
- }
- }
-
- virtual void OnReadCompleted(net::URLRequest* request,
- int bytes_read) OVERRIDE {
- if (bytes_read > 0) {
- amount_received_ += bytes_read;
-
- if (kill_after_amount_received_ && !kill_with_io_pending_) {
- if (amount_received_ >= kill_after_amount_received_) {
- request->Cancel();
- return;
- }
- }
-
- ReadSome(request);
-
- if (kill_after_amount_received_ && kill_with_io_pending_) {
- if (amount_received_ >= kill_after_amount_received_) {
- request->Cancel();
- return;
- }
- }
- } else {
- RequestComplete();
- }
- }
-
- void ReadSome(net::URLRequest* request) {
- DCHECK(amount_received_ + kBlockSize <= kNumBlocks * kBlockSize);
- scoped_refptr<IOBuffer> wrapped_buffer(
- new net::WrappedIOBuffer(received_data_->data() + amount_received_));
- int bytes_read = 0;
- EXPECT_FALSE(
- request->Read(wrapped_buffer.get(), kBlockSize, &bytes_read));
- EXPECT_EQ(0, bytes_read);
- }
-
- void RequestComplete() {
- test_->ScheduleNextTask();
- }
-
- AppCacheURLRequestJobTest* test_;
- net::HttpResponseInfo received_info_;
- scoped_refptr<net::IOBuffer> received_data_;
- bool did_receive_headers_;
- int amount_received_;
- int kill_after_amount_received_;
- bool kill_with_io_pending_;
- };
-
- static net::URLRequestJob* MockHttpJobFactory(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate,
- const std::string& scheme) {
- if (mock_factory_job_) {
- net::URLRequestJob* temp = mock_factory_job_;
- mock_factory_job_ = NULL;
- return temp;
- } else {
- return new net::URLRequestErrorJob(request,
- network_delegate,
- net::ERR_INTERNET_DISCONNECTED);
- }
- }
-
- // Helper callback to run a test on our io_thread. The io_thread is spun up
- // once and reused for all tests.
- template <class Method>
- void MethodWrapper(Method method) {
- SetUpTest();
- (this->*method)();
- }
-
- static void SetUpTestCase() {
- io_thread_.reset(new base::Thread("AppCacheURLRequestJobTest Thread"));
- base::Thread::Options options(base::MessageLoop::TYPE_IO, 0);
- io_thread_->StartWithOptions(options);
- }
-
- static void TearDownTestCase() {
- io_thread_.reset(NULL);
- }
-
- AppCacheURLRequestJobTest() {}
-
- template <class Method>
- void RunTestOnIOThread(Method method) {
- test_finished_event_ .reset(new base::WaitableEvent(false, false));
- io_thread_->message_loop()->PostTask(
- FROM_HERE, base::Bind(&AppCacheURLRequestJobTest::MethodWrapper<Method>,
- base::Unretained(this), method));
- test_finished_event_->Wait();
- }
-
- void SetUpTest() {
- DCHECK(base::MessageLoop::current() == io_thread_->message_loop());
- DCHECK(task_stack_.empty());
- orig_http_factory_ = net::URLRequest::Deprecated::RegisterProtocolFactory(
- "http", MockHttpJobFactory);
- url_request_delegate_.reset(new MockURLRequestDelegate(this));
- storage_delegate_.reset(new MockStorageDelegate(this));
- service_.reset(new MockAppCacheService());
- expected_read_result_ = 0;
- expected_write_result_ = 0;
- written_response_id_ = 0;
- reader_deletion_count_down_ = 0;
- writer_deletion_count_down_ = 0;
- }
-
- void TearDownTest() {
- DCHECK(base::MessageLoop::current() == io_thread_->message_loop());
- net::URLRequest::Deprecated::RegisterProtocolFactory("http",
- orig_http_factory_);
- orig_http_factory_ = NULL;
- request_.reset();
- url_request_delegate_.reset();
- DCHECK(!mock_factory_job_);
-
- while (!task_stack_.empty())
- task_stack_.pop();
-
- reader_.reset();
- read_buffer_ = NULL;
- read_info_buffer_ = NULL;
- writer_.reset();
- write_buffer_ = NULL;
- write_info_buffer_ = NULL;
- storage_delegate_.reset();
- service_.reset();
- }
-
- void TestFinished() {
- // We unwind the stack prior to finishing up to let stack
- // based objects get deleted.
- DCHECK(base::MessageLoop::current() == io_thread_->message_loop());
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&AppCacheURLRequestJobTest::TestFinishedUnwound,
- base::Unretained(this)));
- }
-
- void TestFinishedUnwound() {
- TearDownTest();
- test_finished_event_->Signal();
- }
-
- void PushNextTask(const base::Closure& task) {
- task_stack_.push(std::pair<base::Closure, bool>(task, false));
- }
-
- void PushNextTaskAsImmediate(const base::Closure& task) {
- task_stack_.push(std::pair<base::Closure, bool>(task, true));
- }
-
- void ScheduleNextTask() {
- DCHECK(base::MessageLoop::current() == io_thread_->message_loop());
- if (task_stack_.empty()) {
- TestFinished();
- return;
- }
- base::Closure task =task_stack_.top().first;
- bool immediate = task_stack_.top().second;
- task_stack_.pop();
- if (immediate)
- task.Run();
- else
- base::MessageLoop::current()->PostTask(FROM_HERE, task);
- }
-
- // Wrappers to call AppCacheResponseReader/Writer Read and Write methods
-
- void WriteBasicResponse() {
- scoped_refptr<IOBuffer> body(new WrappedIOBuffer(kHttpBasicBody));
- std::string raw_headers(kHttpBasicHeaders, arraysize(kHttpBasicHeaders));
- WriteResponse(
- MakeHttpResponseInfo(raw_headers), body.get(), strlen(kHttpBasicBody));
- }
-
- void WriteResponse(net::HttpResponseInfo* head,
- IOBuffer* body, int body_len) {
- DCHECK(body);
- scoped_refptr<IOBuffer> body_ref(body);
- PushNextTask(base::Bind(&AppCacheURLRequestJobTest::WriteResponseBody,
- base::Unretained(this), body_ref, body_len));
- WriteResponseHead(head);
- }
-
- void WriteResponseHead(net::HttpResponseInfo* head) {
- EXPECT_FALSE(writer_->IsWritePending());
- expected_write_result_ = GetHttpResponseInfoSize(head);
- write_info_buffer_ = new HttpResponseInfoIOBuffer(head);
- writer_->WriteInfo(
- write_info_buffer_.get(),
- base::Bind(&AppCacheURLRequestJobTest::OnWriteInfoComplete,
- base::Unretained(this)));
- }
-
- void WriteResponseBody(scoped_refptr<IOBuffer> io_buffer, int buf_len) {
- EXPECT_FALSE(writer_->IsWritePending());
- write_buffer_ = io_buffer;
- expected_write_result_ = buf_len;
- writer_->WriteData(write_buffer_.get(),
- buf_len,
- base::Bind(&AppCacheURLRequestJobTest::OnWriteComplete,
- base::Unretained(this)));
- }
-
- void ReadResponseBody(scoped_refptr<IOBuffer> io_buffer, int buf_len) {
- EXPECT_FALSE(reader_->IsReadPending());
- read_buffer_ = io_buffer;
- expected_read_result_ = buf_len;
- reader_->ReadData(read_buffer_.get(),
- buf_len,
- base::Bind(&AppCacheURLRequestJobTest::OnReadComplete,
- base::Unretained(this)));
- }
-
- // AppCacheResponseReader / Writer completion callbacks
-
- void OnWriteInfoComplete(int result) {
- EXPECT_FALSE(writer_->IsWritePending());
- EXPECT_EQ(expected_write_result_, result);
- ScheduleNextTask();
- }
-
- void OnWriteComplete(int result) {
- EXPECT_FALSE(writer_->IsWritePending());
- EXPECT_EQ(expected_write_result_, result);
- ScheduleNextTask();
- }
-
- void OnReadInfoComplete(int result) {
- EXPECT_FALSE(reader_->IsReadPending());
- EXPECT_EQ(expected_read_result_, result);
- ScheduleNextTask();
- }
-
- void OnReadComplete(int result) {
- EXPECT_FALSE(reader_->IsReadPending());
- EXPECT_EQ(expected_read_result_, result);
- ScheduleNextTask();
- }
-
- // Helpers to work with HttpResponseInfo objects
-
- net::HttpResponseInfo* MakeHttpResponseInfo(const std::string& raw_headers) {
- net::HttpResponseInfo* info = new net::HttpResponseInfo;
- info->request_time = base::Time::Now();
- info->response_time = base::Time::Now();
- info->was_cached = false;
- info->headers = new net::HttpResponseHeaders(raw_headers);
- return info;
- }
-
- int GetHttpResponseInfoSize(const net::HttpResponseInfo* info) {
- Pickle pickle;
- return PickleHttpResonseInfo(&pickle, info);
- }
-
- bool CompareHttpResponseInfos(const net::HttpResponseInfo* info1,
- const net::HttpResponseInfo* info2) {
- Pickle pickle1;
- Pickle pickle2;
- PickleHttpResonseInfo(&pickle1, info1);
- PickleHttpResonseInfo(&pickle2, info2);
- return (pickle1.size() == pickle2.size()) &&
- (0 == memcmp(pickle1.data(), pickle2.data(), pickle1.size()));
- }
-
- int PickleHttpResonseInfo(Pickle* pickle, const net::HttpResponseInfo* info) {
- const bool kSkipTransientHeaders = true;
- const bool kTruncated = false;
- info->Persist(pickle, kSkipTransientHeaders, kTruncated);
- return pickle->size();
- }
-
- // Helpers to fill and verify blocks of memory with a value
-
- void FillData(char value, char* data, int data_len) {
- memset(data, value, data_len);
- }
-
- bool CheckData(char value, const char* data, int data_len) {
- for (int i = 0; i < data_len; ++i, ++data) {
- if (*data != value)
- return false;
- }
- return true;
- }
-
- // Individual Tests ---------------------------------------------------------
- // Some of the individual tests involve multiple async steps. Each test
- // is delineated with a section header.
-
- // Basic -------------------------------------------------------------------
- void Basic() {
- AppCacheStorage* storage = service_->storage();
- net::URLRequest request(
- GURL("http://blah/"), net::DEFAULT_PRIORITY, NULL, &empty_context_);
- scoped_refptr<AppCacheURLRequestJob> job;
-
- // Create an instance and see that it looks as expected.
-
- job = new AppCacheURLRequestJob(
- &request, NULL, storage, NULL);
- EXPECT_TRUE(job->is_waiting());
- EXPECT_FALSE(job->is_delivering_appcache_response());
- EXPECT_FALSE(job->is_delivering_network_response());
- EXPECT_FALSE(job->is_delivering_error_response());
- EXPECT_FALSE(job->has_been_started());
- EXPECT_FALSE(job->has_been_killed());
- EXPECT_EQ(GURL(), job->manifest_url());
- EXPECT_EQ(kNoCacheId, job->cache_id());
- EXPECT_FALSE(job->entry().has_response_id());
-
- TestFinished();
- }
-
- // DeliveryOrders -----------------------------------------------------
- void DeliveryOrders() {
- AppCacheStorage* storage = service_->storage();
- net::URLRequest request(
- GURL("http://blah/"), net::DEFAULT_PRIORITY, NULL, &empty_context_);
- scoped_refptr<AppCacheURLRequestJob> job;
-
- // Create an instance, give it a delivery order and see that
- // it looks as expected.
-
- job = new AppCacheURLRequestJob(&request, NULL, storage, NULL);
- job->DeliverErrorResponse();
- EXPECT_TRUE(job->is_delivering_error_response());
- EXPECT_FALSE(job->has_been_started());
-
- job = new AppCacheURLRequestJob(&request, NULL, storage, NULL);
- job->DeliverNetworkResponse();
- EXPECT_TRUE(job->is_delivering_network_response());
- EXPECT_FALSE(job->has_been_started());
-
- job = new AppCacheURLRequestJob(&request, NULL, storage, NULL);
- const GURL kManifestUrl("http://blah/");
- const int64 kCacheId(1);
- const int64 kGroupId(1);
- const AppCacheEntry kEntry(AppCacheEntry::EXPLICIT, 1);
- job->DeliverAppCachedResponse(kManifestUrl, kCacheId, kGroupId,
- kEntry, false);
- EXPECT_FALSE(job->is_waiting());
- EXPECT_TRUE(job->is_delivering_appcache_response());
- EXPECT_FALSE(job->has_been_started());
- EXPECT_EQ(kManifestUrl, job->manifest_url());
- EXPECT_EQ(kCacheId, job->cache_id());
- EXPECT_EQ(kGroupId, job->group_id());
- EXPECT_EQ(kEntry.types(), job->entry().types());
- EXPECT_EQ(kEntry.response_id(), job->entry().response_id());
-
- TestFinished();
- }
-
- // DeliverNetworkResponse --------------------------------------------------
-
- void DeliverNetworkResponse() {
- // This test has async steps.
- PushNextTask(
- base::Bind(&AppCacheURLRequestJobTest::VerifyDeliverNetworkResponse,
- base::Unretained(this)));
-
- AppCacheStorage* storage = service_->storage();
- request_ = empty_context_.CreateRequest(GURL("http://blah/"),
- net::DEFAULT_PRIORITY,
- url_request_delegate_.get());
-
- // Setup to create an AppCacheURLRequestJob with orders to deliver
- // a network response.
- mock_factory_job_ = new AppCacheURLRequestJob(
- request_.get(), NULL, storage, NULL);
- mock_factory_job_->DeliverNetworkResponse();
- EXPECT_TRUE(mock_factory_job_->is_delivering_network_response());
- EXPECT_FALSE(mock_factory_job_->has_been_started());
-
- // Start the request.
- request_->Start();
-
- // The job should have been picked up.
- EXPECT_FALSE(mock_factory_job_);
- // Completion is async.
- }
-
- void VerifyDeliverNetworkResponse() {
- EXPECT_EQ(request_->status().error(),
- net::ERR_INTERNET_DISCONNECTED);
- TestFinished();
- }
-
- // DeliverErrorResponse --------------------------------------------------
-
- void DeliverErrorResponse() {
- // This test has async steps.
- PushNextTask(
- base::Bind(&AppCacheURLRequestJobTest::VerifyDeliverErrorResponse,
- base::Unretained(this)));
-
- AppCacheStorage* storage = service_->storage();
- request_ = empty_context_.CreateRequest(GURL("http://blah/"),
- net::DEFAULT_PRIORITY,
- url_request_delegate_.get());
-
- // Setup to create an AppCacheURLRequestJob with orders to deliver
- // a network response.
- mock_factory_job_ = new AppCacheURLRequestJob(
- request_.get(), NULL, storage, NULL);
- mock_factory_job_->DeliverErrorResponse();
- EXPECT_TRUE(mock_factory_job_->is_delivering_error_response());
- EXPECT_FALSE(mock_factory_job_->has_been_started());
-
- // Start the request.
- request_->Start();
-
- // The job should have been picked up.
- EXPECT_FALSE(mock_factory_job_);
- // Completion is async.
- }
-
- void VerifyDeliverErrorResponse() {
- EXPECT_EQ(request_->status().error(), net::ERR_FAILED);
- TestFinished();
- }
-
- // DeliverSmallAppCachedResponse --------------------------------------
- // "Small" being small enough to read completely in a single
- // request->Read call.
-
- void DeliverSmallAppCachedResponse() {
- // This test has several async steps.
- // 1. Write a small response to response storage.
- // 2. Use net::URLRequest to retrieve it.
- // 3. Verify we received what we expected to receive.
-
- PushNextTask(base::Bind(
- &AppCacheURLRequestJobTest::VerifyDeliverSmallAppCachedResponse,
- base::Unretained(this)));
- PushNextTask(
- base::Bind(&AppCacheURLRequestJobTest::RequestAppCachedResource,
- base::Unretained(this), false));
-
- writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0));
- written_response_id_ = writer_->response_id();
- WriteBasicResponse();
- // Continues async
- }
-
- void RequestAppCachedResource(bool start_after_delivery_orders) {
- AppCacheStorage* storage = service_->storage();
- request_ = empty_context_.CreateRequest(GURL("http://blah/"),
- net::DEFAULT_PRIORITY,
- url_request_delegate_.get());
-
- // Setup to create an AppCacheURLRequestJob with orders to deliver
- // a network response.
- scoped_refptr<AppCacheURLRequestJob> job(new AppCacheURLRequestJob(
- request_.get(), NULL, storage, NULL));
-
- if (start_after_delivery_orders) {
- job->DeliverAppCachedResponse(
- GURL(), 0, 111,
- AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_),
- false);
- EXPECT_TRUE(job->is_delivering_appcache_response());
- }
-
- // Start the request.
- EXPECT_FALSE(job->has_been_started());
- mock_factory_job_ = job.get();
- request_->Start();
- EXPECT_FALSE(mock_factory_job_);
- EXPECT_TRUE(job->has_been_started());
-
- if (!start_after_delivery_orders) {
- job->DeliverAppCachedResponse(
- GURL(), 0, 111,
- AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_),
- false);
- EXPECT_TRUE(job->is_delivering_appcache_response());
- }
-
- // Completion is async.
- }
-
- void VerifyDeliverSmallAppCachedResponse() {
- EXPECT_TRUE(request_->status().is_success());
- EXPECT_TRUE(CompareHttpResponseInfos(
- write_info_buffer_->http_info.get(),
- &url_request_delegate_->received_info_));
- EXPECT_EQ(5, url_request_delegate_->amount_received_);
- EXPECT_EQ(0, memcmp(kHttpBasicBody,
- url_request_delegate_->received_data_->data(),
- strlen(kHttpBasicBody)));
- TestFinished();
- }
-
- // DeliverLargeAppCachedResponse --------------------------------------
- // "Large" enough to require multiple calls to request->Read to complete.
-
- void DeliverLargeAppCachedResponse() {
- // This test has several async steps.
- // 1. Write a large response to response storage.
- // 2. Use net::URLRequest to retrieve it.
- // 3. Verify we received what we expected to receive.
-
- PushNextTask(base::Bind(
- &AppCacheURLRequestJobTest::VerifyDeliverLargeAppCachedResponse,
- base::Unretained(this)));
- PushNextTask(base::Bind(
- &AppCacheURLRequestJobTest::RequestAppCachedResource,
- base::Unretained(this), true));
-
- writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0));
- written_response_id_ = writer_->response_id();
- WriteLargeResponse();
- // Continues async
- }
-
- void WriteLargeResponse() {
- // 3, 1k blocks
- static const char kHttpHeaders[] =
- "HTTP/1.0 200 OK\0Content-Length: 3072\0\0";
- scoped_refptr<IOBuffer> body(new IOBuffer(kBlockSize * 3));
- char* p = body->data();
- for (int i = 0; i < 3; ++i, p += kBlockSize)
- FillData(i + 1, p, kBlockSize);
- std::string raw_headers(kHttpHeaders, arraysize(kHttpHeaders));
- WriteResponse(
- MakeHttpResponseInfo(raw_headers), body.get(), kBlockSize * 3);
- }
-
- void VerifyDeliverLargeAppCachedResponse() {
- EXPECT_TRUE(request_->status().is_success());
- EXPECT_TRUE(CompareHttpResponseInfos(
- write_info_buffer_->http_info.get(),
- &url_request_delegate_->received_info_));
- EXPECT_EQ(3072, url_request_delegate_->amount_received_);
- char* p = url_request_delegate_->received_data_->data();
- for (int i = 0; i < 3; ++i, p += kBlockSize)
- EXPECT_TRUE(CheckData(i + 1, p, kBlockSize));
- TestFinished();
- }
-
- // DeliverPartialResponse --------------------------------------
-
- void DeliverPartialResponse() {
- // This test has several async steps.
- // 1. Write a small response to response storage.
- // 2. Use net::URLRequest to retrieve it a subset using a range request
- // 3. Verify we received what we expected to receive.
- PushNextTask(base::Bind(
- &AppCacheURLRequestJobTest::VerifyDeliverPartialResponse,
- base::Unretained(this)));
- PushNextTask(base::Bind(
- &AppCacheURLRequestJobTest::MakeRangeRequest, base::Unretained(this)));
- writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0));
- written_response_id_ = writer_->response_id();
- WriteBasicResponse();
- // Continues async
- }
-
- void MakeRangeRequest() {
- AppCacheStorage* storage = service_->storage();
- request_ = empty_context_.CreateRequest(GURL("http://blah/"),
- net::DEFAULT_PRIORITY,
- url_request_delegate_.get());
-
- // Request a range, the 3 middle chars out of 'Hello'
- net::HttpRequestHeaders extra_headers;
- extra_headers.SetHeader("Range", "bytes= 1-3");
- request_->SetExtraRequestHeaders(extra_headers);
-
- // Create job with orders to deliver an appcached entry.
- scoped_refptr<AppCacheURLRequestJob> job(new AppCacheURLRequestJob(
- request_.get(), NULL, storage, NULL));
- job->DeliverAppCachedResponse(
- GURL(), 0, 111,
- AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_),
- false);
- EXPECT_TRUE(job->is_delivering_appcache_response());
-
- // Start the request.
- EXPECT_FALSE(job->has_been_started());
- mock_factory_job_ = job.get();
- request_->Start();
- EXPECT_FALSE(mock_factory_job_);
- EXPECT_TRUE(job->has_been_started());
- // Completion is async.
- }
-
- void VerifyDeliverPartialResponse() {
- EXPECT_TRUE(request_->status().is_success());
- EXPECT_EQ(3, url_request_delegate_->amount_received_);
- EXPECT_EQ(0, memcmp(kHttpBasicBody + 1,
- url_request_delegate_->received_data_->data(),
- 3));
- net::HttpResponseHeaders* headers =
- url_request_delegate_->received_info_.headers.get();
- EXPECT_EQ(206, headers->response_code());
- EXPECT_EQ(3, headers->GetContentLength());
- int64 range_start, range_end, object_size;
- EXPECT_TRUE(
- headers->GetContentRange(&range_start, &range_end, &object_size));
- EXPECT_EQ(1, range_start);
- EXPECT_EQ(3, range_end);
- EXPECT_EQ(5, object_size);
- TestFinished();
- }
-
- // CancelRequest --------------------------------------
-
- void CancelRequest() {
- // This test has several async steps.
- // 1. Write a large response to response storage.
- // 2. Use net::URLRequest to retrieve it.
- // 3. Cancel the request after data starts coming in.
-
- PushNextTask(base::Bind(
- &AppCacheURLRequestJobTest::VerifyCancel, base::Unretained(this)));
- PushNextTask(base::Bind(
- &AppCacheURLRequestJobTest::RequestAppCachedResource,
- base::Unretained(this), true));
-
- writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0));
- written_response_id_ = writer_->response_id();
- WriteLargeResponse();
-
- url_request_delegate_->kill_after_amount_received_ = kBlockSize;
- url_request_delegate_->kill_with_io_pending_ = false;
- // Continues async
- }
-
- void VerifyCancel() {
- EXPECT_EQ(net::URLRequestStatus::CANCELED,
- request_->status().status());
- TestFinished();
- }
-
- // CancelRequestWithIOPending --------------------------------------
-
- void CancelRequestWithIOPending() {
- // This test has several async steps.
- // 1. Write a large response to response storage.
- // 2. Use net::URLRequest to retrieve it.
- // 3. Cancel the request after data starts coming in.
-
- PushNextTask(base::Bind(
- &AppCacheURLRequestJobTest::VerifyCancel, base::Unretained(this)));
- PushNextTask(base::Bind(
- &AppCacheURLRequestJobTest::RequestAppCachedResource,
- base::Unretained(this), true));
-
- writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0));
- written_response_id_ = writer_->response_id();
- WriteLargeResponse();
-
- url_request_delegate_->kill_after_amount_received_ = kBlockSize;
- url_request_delegate_->kill_with_io_pending_ = true;
- // Continues async
- }
-
-
- // Data members --------------------------------------------------------
-
- scoped_ptr<base::WaitableEvent> test_finished_event_;
- scoped_ptr<MockStorageDelegate> storage_delegate_;
- scoped_ptr<MockAppCacheService> service_;
- std::stack<std::pair<base::Closure, bool> > task_stack_;
-
- scoped_ptr<AppCacheResponseReader> reader_;
- scoped_refptr<HttpResponseInfoIOBuffer> read_info_buffer_;
- scoped_refptr<IOBuffer> read_buffer_;
- int expected_read_result_;
- int reader_deletion_count_down_;
-
- int64 written_response_id_;
- scoped_ptr<AppCacheResponseWriter> writer_;
- scoped_refptr<HttpResponseInfoIOBuffer> write_info_buffer_;
- scoped_refptr<IOBuffer> write_buffer_;
- int expected_write_result_;
- int writer_deletion_count_down_;
-
- net::URLRequest::ProtocolFactory* orig_http_factory_;
- net::URLRequestContext empty_context_;
- scoped_ptr<net::URLRequest> request_;
- scoped_ptr<MockURLRequestDelegate> url_request_delegate_;
-
- static scoped_ptr<base::Thread> io_thread_;
- static AppCacheURLRequestJob* mock_factory_job_;
-};
-
-// static
-scoped_ptr<base::Thread> AppCacheURLRequestJobTest::io_thread_;
-AppCacheURLRequestJob* AppCacheURLRequestJobTest::mock_factory_job_ = NULL;
-
-TEST_F(AppCacheURLRequestJobTest, Basic) {
- RunTestOnIOThread(&AppCacheURLRequestJobTest::Basic);
-}
-
-TEST_F(AppCacheURLRequestJobTest, DeliveryOrders) {
- RunTestOnIOThread(&AppCacheURLRequestJobTest::DeliveryOrders);
-}
-
-TEST_F(AppCacheURLRequestJobTest, DeliverNetworkResponse) {
- RunTestOnIOThread(&AppCacheURLRequestJobTest::DeliverNetworkResponse);
-}
-
-TEST_F(AppCacheURLRequestJobTest, DeliverErrorResponse) {
- RunTestOnIOThread(&AppCacheURLRequestJobTest::DeliverErrorResponse);
-}
-
-TEST_F(AppCacheURLRequestJobTest, DeliverSmallAppCachedResponse) {
- RunTestOnIOThread(&AppCacheURLRequestJobTest::DeliverSmallAppCachedResponse);
-}
-
-TEST_F(AppCacheURLRequestJobTest, DeliverLargeAppCachedResponse) {
- RunTestOnIOThread(&AppCacheURLRequestJobTest::DeliverLargeAppCachedResponse);
-}
-
-TEST_F(AppCacheURLRequestJobTest, DeliverPartialResponse) {
- RunTestOnIOThread(&AppCacheURLRequestJobTest::DeliverPartialResponse);
-}
-
-TEST_F(AppCacheURLRequestJobTest, CancelRequest) {
- RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequest);
-}
-
-TEST_F(AppCacheURLRequestJobTest, CancelRequestWithIOPending) {
- RunTestOnIOThread(&AppCacheURLRequestJobTest::CancelRequestWithIOPending);
-}
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/appcache_working_set.cc b/chromium/webkit/browser/appcache/appcache_working_set.cc
index ea05110e268..2b9a70cccc9 100644
--- a/chromium/webkit/browser/appcache/appcache_working_set.cc
+++ b/chromium/webkit/browser/appcache/appcache_working_set.cc
@@ -32,7 +32,7 @@ void AppCacheWorkingSet::Disable() {
void AppCacheWorkingSet::AddCache(AppCache* cache) {
if (is_disabled_)
return;
- DCHECK(cache->cache_id() != kNoCacheId);
+ DCHECK(cache->cache_id() != kAppCacheNoCacheId);
int64 cache_id = cache->cache_id();
DCHECK(caches_.find(cache_id) == caches_.end());
caches_.insert(CacheMap::value_type(cache_id, cache));
@@ -67,7 +67,7 @@ void AppCacheWorkingSet::RemoveGroup(AppCacheGroup* group) {
void AppCacheWorkingSet::AddResponseInfo(AppCacheResponseInfo* info) {
if (is_disabled_)
return;
- DCHECK(info->response_id() != kNoResponseId);
+ DCHECK(info->response_id() != kAppCacheNoResponseId);
int64 response_id = info->response_id();
DCHECK(response_infos_.find(response_id) == response_infos_.end());
response_infos_.insert(ResponseInfoMap::value_type(response_id, info));
diff --git a/chromium/webkit/browser/appcache/manifest_parser.cc b/chromium/webkit/browser/appcache/manifest_parser.cc
index be44127631b..f43d8890312 100644
--- a/chromium/webkit/browser/appcache/manifest_parser.cc
+++ b/chromium/webkit/browser/appcache/manifest_parser.cc
@@ -70,12 +70,15 @@ enum InterceptVerb {
UNKNOWN_VERB,
};
-Manifest::Manifest() : online_whitelist_all(false) {}
+Manifest::Manifest()
+ : online_whitelist_all(false),
+ did_ignore_intercept_namespaces(false) {
+}
Manifest::~Manifest() {}
bool ParseManifest(const GURL& manifest_url, const char* data, int length,
- Manifest& manifest) {
+ ParseMode parse_mode, Manifest& manifest) {
// This is an implementation of the parsing algorithm specified in
// the HTML5 offline web application docs:
// http://www.w3.org/TR/html5/offline.html
@@ -92,6 +95,7 @@ bool ParseManifest(const GURL& manifest_url, const char* data, int length,
DCHECK(manifest.fallback_namespaces.empty());
DCHECK(manifest.online_whitelist_namespaces.empty());
DCHECK(!manifest.online_whitelist_all);
+ DCHECK(!manifest.did_ignore_intercept_namespaces);
Mode mode = EXPLICIT;
@@ -187,7 +191,7 @@ bool ParseManifest(const GURL& manifest_url, const char* data, int length,
++line_p;
base::string16 url16;
- WideToUTF16(line.c_str(), line_p - line.c_str(), &url16);
+ base::WideToUTF16(line.c_str(), line_p - line.c_str(), &url16);
GURL url = manifest_url.Resolve(url16);
if (!url.is_valid())
continue;
@@ -215,9 +219,14 @@ bool ParseManifest(const GURL& manifest_url, const char* data, int length,
} else {
bool is_pattern = HasPatternMatchingAnnotation(line_p, line_end);
manifest.online_whitelist_namespaces.push_back(
- Namespace(NETWORK_NAMESPACE, url, GURL(), is_pattern));
+ Namespace(APPCACHE_NETWORK_NAMESPACE, url, GURL(), is_pattern));
}
} else if (mode == INTERCEPT) {
+ if (parse_mode != PARSE_MANIFEST_ALLOWING_INTERCEPTS) {
+ manifest.did_ignore_intercept_namespaces = true;
+ continue;
+ }
+
// Lines of the form,
// <urlnamespace> <intercept_type> <targeturl>
const wchar_t* line_p = line.c_str();
@@ -232,7 +241,7 @@ bool ParseManifest(const GURL& manifest_url, const char* data, int length,
continue; // There was no whitespace separating the URLs.
base::string16 namespace_url16;
- WideToUTF16(line.c_str(), line_p - line.c_str(), &namespace_url16);
+ base::WideToUTF16(line.c_str(), line_p - line.c_str(), &namespace_url16);
GURL namespace_url = manifest_url.Resolve(namespace_url16);
if (!namespace_url.is_valid())
continue;
@@ -279,7 +288,8 @@ bool ParseManifest(const GURL& manifest_url, const char* data, int length,
++line_p;
base::string16 target_url16;
- WideToUTF16(target_url_start, line_p - target_url_start, &target_url16);
+ base::WideToUTF16(target_url_start, line_p - target_url_start,
+ &target_url16);
GURL target_url = manifest_url.Resolve(target_url16);
if (!target_url.is_valid())
continue;
@@ -294,7 +304,7 @@ bool ParseManifest(const GURL& manifest_url, const char* data, int length,
bool is_pattern = HasPatternMatchingAnnotation(line_p, line_end);
manifest.intercept_namespaces.push_back(
- Namespace(INTERCEPT_NAMESPACE, namespace_url,
+ Namespace(APPCACHE_INTERCEPT_NAMESPACE, namespace_url,
target_url, is_pattern, verb == EXECUTE));
} else if (mode == FALLBACK) {
const wchar_t* line_p = line.c_str();
@@ -310,7 +320,7 @@ bool ParseManifest(const GURL& manifest_url, const char* data, int length,
}
base::string16 namespace_url16;
- WideToUTF16(line.c_str(), line_p - line.c_str(), &namespace_url16);
+ base::WideToUTF16(line.c_str(), line_p - line.c_str(), &namespace_url16);
GURL namespace_url = manifest_url.Resolve(namespace_url16);
if (!namespace_url.is_valid())
continue;
@@ -336,7 +346,8 @@ bool ParseManifest(const GURL& manifest_url, const char* data, int length,
++line_p;
base::string16 fallback_url16;
- WideToUTF16(fallback_start, line_p - fallback_start, &fallback_url16);
+ base::WideToUTF16(fallback_start, line_p - fallback_start,
+ &fallback_url16);
GURL fallback_url = manifest_url.Resolve(fallback_url16);
if (!fallback_url.is_valid())
continue;
@@ -357,7 +368,7 @@ bool ParseManifest(const GURL& manifest_url, const char* data, int length,
// Store regardless of duplicate namespace URL. Only first match
// will ever be used.
manifest.fallback_namespaces.push_back(
- Namespace(FALLBACK_NAMESPACE, namespace_url,
+ Namespace(APPCACHE_FALLBACK_NAMESPACE, namespace_url,
fallback_url, is_pattern));
} else {
NOTREACHED();
diff --git a/chromium/webkit/browser/appcache/manifest_parser.h b/chromium/webkit/browser/appcache/manifest_parser.h
index 44661ef1fa0..c8d5f00a913 100644
--- a/chromium/webkit/browser/appcache/manifest_parser.h
+++ b/chromium/webkit/browser/appcache/manifest_parser.h
@@ -52,12 +52,20 @@ struct WEBKIT_STORAGE_BROWSER_EXPORT Manifest {
NamespaceVector fallback_namespaces;
NamespaceVector online_whitelist_namespaces;
bool online_whitelist_all;
+ bool did_ignore_intercept_namespaces;
};
-WEBKIT_STORAGE_BROWSER_EXPORT bool ParseManifest(const GURL& manifest_url,
- const char* data,
- int length,
- Manifest& manifest);
+enum ParseMode {
+ PARSE_MANIFEST_PER_STANDARD,
+ PARSE_MANIFEST_ALLOWING_INTERCEPTS
+};
+
+WEBKIT_STORAGE_BROWSER_EXPORT bool ParseManifest(
+ const GURL& manifest_url,
+ const char* data,
+ int length,
+ ParseMode parse_mode,
+ Manifest& manifest);
} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/manifest_parser_unittest.cc b/chromium/webkit/browser/appcache/manifest_parser_unittest.cc
deleted file mode 100644
index 4df076f9864..00000000000
--- a/chromium/webkit/browser/appcache/manifest_parser_unittest.cc
+++ /dev/null
@@ -1,472 +0,0 @@
-// Copyright (c) 2010 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 <string>
-
-#include "testing/gtest/include/gtest/gtest.h"
-#include "url/gurl.h"
-#include "webkit/browser/appcache/manifest_parser.h"
-
-namespace appcache {
-
-class AppCacheManifestParserTest : public testing::Test {
-};
-
-TEST(AppCacheManifestParserTest, NoData) {
- GURL url;
- Manifest manifest;
- EXPECT_FALSE(ParseManifest(url, "", 0, manifest));
- EXPECT_FALSE(ParseManifest(url, "CACHE MANIFEST\r", 0, manifest)); // 0 len
-}
-
-TEST(AppCacheManifestParserTest, CheckSignature) {
- GURL url;
- Manifest manifest;
-
- const std::string kBadSignatures[] = {
- "foo",
- "CACHE MANIFEST;V2\r", // not followed by whitespace
- "CACHE MANIFEST#bad\r", // no whitespace before comment
- "cache manifest ", // wrong case
- "#CACHE MANIFEST\r", // comment
- "xCACHE MANIFEST\n", // bad first char
- " CACHE MANIFEST\r", // begins with whitespace
- "\xEF\xBE\xBF" "CACHE MANIFEST\r", // bad UTF-8 BOM value
- };
-
- for (size_t i = 0; i < arraysize(kBadSignatures); ++i) {
- const std::string bad = kBadSignatures[i];
- EXPECT_FALSE(ParseManifest(url, bad.c_str(), bad.length(), manifest));
- }
-
- const std::string kGoodSignatures[] = {
- "CACHE MANIFEST",
- "CACHE MANIFEST ",
- "CACHE MANIFEST\r",
- "CACHE MANIFEST\n",
- "CACHE MANIFEST\r\n",
- "CACHE MANIFEST\t# ignore me\r",
- "CACHE MANIFEST ignore\r\n",
- "CHROMIUM CACHE MANIFEST\r\n",
- "\xEF\xBB\xBF" "CACHE MANIFEST \r\n", // BOM present
- };
-
- for (size_t i = 0; i < arraysize(kGoodSignatures); ++i) {
- const std::string good = kGoodSignatures[i];
- EXPECT_TRUE(ParseManifest(url, good.c_str(), good.length(), manifest));
- }
-}
-
-TEST(AppCacheManifestParserTest, NoManifestUrl) {
- Manifest manifest;
- const std::string kData("CACHE MANIFEST\r"
- "relative/tobase.com\r"
- "http://absolute.com/addme.com");
- const GURL kUrl;
- EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest));
- EXPECT_TRUE(manifest.explicit_urls.empty());
- EXPECT_TRUE(manifest.fallback_namespaces.empty());
- EXPECT_TRUE(manifest.online_whitelist_namespaces.empty());
- EXPECT_FALSE(manifest.online_whitelist_all);
-}
-
-TEST(AppCacheManifestParserTest, ExplicitUrls) {
- Manifest manifest;
- const GURL kUrl("http://www.foo.com");
- const std::string kData("CACHE MANIFEST\r"
- "relative/one\r"
- "# some comment\r"
- "http://www.foo.com/two#strip\r\n"
- "NETWORK:\r"
- " \t CACHE:\r"
- "HTTP://www.diff.com/three\r"
- "FALLBACK:\r"
- " \t # another comment with leading whitespace\n"
- "IGNORE:\r"
- "http://www.foo.com/ignore\r"
- "CACHE: \r"
- "garbage:#!@\r"
- "https://www.foo.com/diffscheme \t \r"
- " \t relative/four#stripme\n\r"
- "*\r");
-
- EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest));
- EXPECT_TRUE(manifest.fallback_namespaces.empty());
- EXPECT_TRUE(manifest.online_whitelist_namespaces.empty());
- EXPECT_FALSE(manifest.online_whitelist_all);
-
- base::hash_set<std::string> urls = manifest.explicit_urls;
- const size_t kExpected = 5;
- ASSERT_EQ(kExpected, urls.size());
- EXPECT_TRUE(urls.find("http://www.foo.com/relative/one") != urls.end());
- EXPECT_TRUE(urls.find("http://www.foo.com/two") != urls.end());
- EXPECT_TRUE(urls.find("http://www.diff.com/three") != urls.end());
- EXPECT_TRUE(urls.find("http://www.foo.com/relative/four") != urls.end());
-
- // Wildcard is treated as a relative URL in explicit section.
- EXPECT_TRUE(urls.find("http://www.foo.com/*") != urls.end());
-}
-
-TEST(AppCacheManifestParserTest, WhitelistUrls) {
- Manifest manifest;
- const GURL kUrl("http://www.bar.com");
- const std::string kData("CACHE MANIFEST\r"
- "NETWORK:\r"
- "relative/one\r"
- "# a comment\r"
- "http://www.bar.com/two\r"
- "HTTP://www.diff.com/three#strip\n\r"
- "FALLBACK:\r"
- "garbage\r"
- "UNKNOWN:\r"
- "http://www.bar.com/ignore\r"
- "CACHE:\r"
- "NETWORK:\r"
- "https://www.wrongscheme.com\n"
- "relative/four#stripref \t \r"
- "http://www.five.com\r\n"
- "*foo\r");
-
- EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest));
- EXPECT_TRUE(manifest.explicit_urls.empty());
- EXPECT_TRUE(manifest.fallback_namespaces.empty());
- EXPECT_TRUE(manifest.intercept_namespaces.empty());
- EXPECT_FALSE(manifest.online_whitelist_all);
-
- const NamespaceVector& online = manifest.online_whitelist_namespaces;
- const size_t kExpected = 6;
- ASSERT_EQ(kExpected, online.size());
- EXPECT_EQ(NETWORK_NAMESPACE, online[0].type);
- EXPECT_FALSE(online[0].is_pattern);
- EXPECT_TRUE(online[0].target_url.is_empty());
- EXPECT_EQ(GURL("http://www.bar.com/relative/one"), online[0].namespace_url);
- EXPECT_EQ(GURL("http://www.bar.com/two"), online[1].namespace_url);
- EXPECT_EQ(GURL("http://www.diff.com/three"), online[2].namespace_url);
- EXPECT_EQ(GURL("http://www.bar.com/relative/four"), online[3].namespace_url);
- EXPECT_EQ(GURL("http://www.five.com"), online[4].namespace_url);
- EXPECT_EQ(GURL("http://www.bar.com/*foo"), online[5].namespace_url);
-}
-
-TEST(AppCacheManifestParserTest, FallbackUrls) {
- Manifest manifest;
- const GURL kUrl("http://glorp.com");
- const std::string kData("CACHE MANIFEST\r"
- "# a comment\r"
- "CACHE:\r"
- "NETWORK:\r"
- "UNKNOWN:\r"
- "FALLBACK:\r"
- "relative/one \t \t http://glorp.com/onefb \t \r"
- "*\r"
- "https://glorp.com/wrong http://glorp.com/wrongfb\r"
- "http://glorp.com/two#strip relative/twofb\r"
- "HTTP://glorp.com/three relative/threefb#strip\n"
- "http://glorp.com/three http://glorp.com/three-dup\r"
- "http://glorp.com/solo \t \r\n"
- "http://diff.com/ignore http://glorp.com/wronghost\r"
- "http://glorp.com/wronghost http://diff.com/ohwell\r"
- "relative/badscheme ftp://glorp.com/ignored\r"
- "garbage\r\n"
- "CACHE:\r"
- "# only fallback urls in this test\r"
- "FALLBACK:\n"
- "relative/four#strip relative/fourfb#strip\r"
- "http://www.glorp.com/notsame relative/skipped\r");
-
- EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest));
- EXPECT_TRUE(manifest.explicit_urls.empty());
- EXPECT_TRUE(manifest.online_whitelist_namespaces.empty());
- EXPECT_FALSE(manifest.online_whitelist_all);
-
- const NamespaceVector& fallbacks = manifest.fallback_namespaces;
- const size_t kExpected = 5;
- ASSERT_EQ(kExpected, fallbacks.size());
- EXPECT_EQ(FALLBACK_NAMESPACE, fallbacks[0].type);
- EXPECT_EQ(FALLBACK_NAMESPACE, fallbacks[1].type);
- EXPECT_EQ(FALLBACK_NAMESPACE, fallbacks[2].type);
- EXPECT_EQ(FALLBACK_NAMESPACE, fallbacks[3].type);
- EXPECT_EQ(FALLBACK_NAMESPACE, fallbacks[4].type);
- EXPECT_EQ(GURL("http://glorp.com/relative/one"),
- fallbacks[0].namespace_url);
- EXPECT_EQ(GURL("http://glorp.com/onefb"),
- fallbacks[0].target_url);
- EXPECT_EQ(GURL("http://glorp.com/two"),
- fallbacks[1].namespace_url);
- EXPECT_EQ(GURL("http://glorp.com/relative/twofb"),
- fallbacks[1].target_url);
- EXPECT_EQ(GURL("http://glorp.com/three"),
- fallbacks[2].namespace_url);
- EXPECT_EQ(GURL("http://glorp.com/relative/threefb"),
- fallbacks[2].target_url);
- EXPECT_EQ(GURL("http://glorp.com/three"), // duplicates are stored
- fallbacks[3].namespace_url);
- EXPECT_EQ(GURL("http://glorp.com/three-dup"),
- fallbacks[3].target_url);
- EXPECT_EQ(GURL("http://glorp.com/relative/four"),
- fallbacks[4].namespace_url);
- EXPECT_EQ(GURL("http://glorp.com/relative/fourfb"),
- fallbacks[4].target_url);
-
- EXPECT_TRUE(manifest.intercept_namespaces.empty());
-}
-
-TEST(AppCacheManifestParserTest, FallbackUrlsWithPort) {
- Manifest manifest;
- const GURL kUrl("http://www.portme.com:1234");
- const std::string kData("CACHE MANIFEST\r"
- "FALLBACK:\r"
- "http://www.portme.com:1234/one relative/onefb\r"
- "HTTP://www.portme.com:9876/wrong http://www.portme.com:1234/ignore\r"
- "http://www.portme.com:1234/stillwrong http://www.portme.com:42/boo\r"
- "relative/two relative/twofb\r"
- "http://www.portme.com:1234/three HTTP://www.portme.com:1234/threefb\r"
- "http://www.portme.com/noport http://www.portme.com:1234/skipped\r"
- "http://www.portme.com:1234/skipme http://www.portme.com/noport\r");
-
- EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest));
- EXPECT_TRUE(manifest.explicit_urls.empty());
- EXPECT_TRUE(manifest.online_whitelist_namespaces.empty());
- EXPECT_FALSE(manifest.online_whitelist_all);
-
- const NamespaceVector& fallbacks = manifest.fallback_namespaces;
- const size_t kExpected = 3;
- ASSERT_EQ(kExpected, fallbacks.size());
- EXPECT_EQ(FALLBACK_NAMESPACE, fallbacks[0].type);
- EXPECT_EQ(FALLBACK_NAMESPACE, fallbacks[1].type);
- EXPECT_EQ(FALLBACK_NAMESPACE, fallbacks[2].type);
- EXPECT_EQ(GURL("http://www.portme.com:1234/one"),
- fallbacks[0].namespace_url);
- EXPECT_EQ(GURL("http://www.portme.com:1234/relative/onefb"),
- fallbacks[0].target_url);
- EXPECT_EQ(GURL("http://www.portme.com:1234/relative/two"),
- fallbacks[1].namespace_url);
- EXPECT_EQ(GURL("http://www.portme.com:1234/relative/twofb"),
- fallbacks[1].target_url);
- EXPECT_EQ(GURL("http://www.portme.com:1234/three"),
- fallbacks[2].namespace_url);
- EXPECT_EQ(GURL("http://www.portme.com:1234/threefb"),
- fallbacks[2].target_url);
-
- EXPECT_TRUE(manifest.intercept_namespaces.empty());
-}
-
-TEST(AppCacheManifestParserTest, InterceptUrls) {
- Manifest manifest;
- const GURL kUrl("http://www.portme.com:1234");
- const std::string kData("CHROMIUM CACHE MANIFEST\r"
- "CHROMIUM-INTERCEPT:\r"
- "http://www.portme.com:1234/one return relative/int1\r"
- "HTTP://www.portme.com:9/wrong return http://www.portme.com:1234/ignore\r"
- "http://www.portme.com:1234/wrong return http://www.portme.com:9/boo\r"
- "relative/two return relative/int2\r"
- "relative/three wrong relative/threefb\r"
- "http://www.portme.com:1234/three return HTTP://www.portme.com:1234/int3\r"
- "http://www.portme.com/noport return http://www.portme.com:1234/skipped\r"
- "http://www.portme.com:1234/skipme return http://www.portme.com/noport\r"
- "relative/wrong/again missing/intercept_type\r");
-
- EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest));
- EXPECT_TRUE(manifest.fallback_namespaces.empty());
- EXPECT_TRUE(manifest.explicit_urls.empty());
- EXPECT_TRUE(manifest.online_whitelist_namespaces.empty());
- EXPECT_FALSE(manifest.online_whitelist_all);
-
- const NamespaceVector& intercepts = manifest.intercept_namespaces;
- const size_t kExpected = 3;
- ASSERT_EQ(kExpected, intercepts.size());
- EXPECT_EQ(INTERCEPT_NAMESPACE, intercepts[0].type);
- EXPECT_EQ(INTERCEPT_NAMESPACE, intercepts[1].type);
- EXPECT_EQ(INTERCEPT_NAMESPACE, intercepts[2].type);
- EXPECT_EQ(GURL("http://www.portme.com:1234/one"),
- intercepts[0].namespace_url);
- EXPECT_EQ(GURL("http://www.portme.com:1234/relative/int1"),
- intercepts[0].target_url);
- EXPECT_EQ(GURL("http://www.portme.com:1234/relative/two"),
- intercepts[1].namespace_url);
- EXPECT_EQ(GURL("http://www.portme.com:1234/relative/int2"),
- intercepts[1].target_url);
- EXPECT_EQ(GURL("http://www.portme.com:1234/three"),
- intercepts[2].namespace_url);
- EXPECT_EQ(GURL("http://www.portme.com:1234/int3"),
- intercepts[2].target_url);
-}
-
-TEST(AppCacheManifestParserTest, ComboUrls) {
- Manifest manifest;
- const GURL kUrl("http://combo.com:42");
- const std::string kData("CACHE MANIFEST\r"
- "relative/explicit-1\r"
- "# some comment\r"
- "http://combo.com:99/explicit-2#strip\r"
- "NETWORK:\r"
- "http://combo.com/whitelist-1\r"
- "HTTP://www.diff.com/whitelist-2#strip\r"
- "*\r"
- "CACHE:\n\r"
- "http://www.diff.com/explicit-3\r"
- "FALLBACK:\r"
- "http://combo.com:42/fallback-1 http://combo.com:42/fallback-1b\r"
- "relative/fallback-2 relative/fallback-2b\r"
- "UNKNOWN:\r\n"
- "http://combo.com/ignoreme\r"
- "relative/still-ignored\r"
- "NETWORK:\r\n"
- "relative/whitelist-3#strip\r"
- "http://combo.com:99/whitelist-4\r");
- EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest));
- EXPECT_TRUE(manifest.online_whitelist_all);
-
- base::hash_set<std::string> urls = manifest.explicit_urls;
- size_t expected = 3;
- ASSERT_EQ(expected, urls.size());
- EXPECT_TRUE(urls.find("http://combo.com:42/relative/explicit-1") !=
- urls.end());
- EXPECT_TRUE(urls.find("http://combo.com:99/explicit-2") != urls.end());
- EXPECT_TRUE(urls.find("http://www.diff.com/explicit-3") != urls.end());
-
- const NamespaceVector& online = manifest.online_whitelist_namespaces;
- expected = 4;
- ASSERT_EQ(expected, online.size());
- EXPECT_EQ(GURL("http://combo.com/whitelist-1"),
- online[0].namespace_url);
- EXPECT_EQ(GURL("http://www.diff.com/whitelist-2"),
- online[1].namespace_url);
- EXPECT_EQ(GURL("http://combo.com:42/relative/whitelist-3"),
- online[2].namespace_url);
- EXPECT_EQ(GURL("http://combo.com:99/whitelist-4"),
- online[3].namespace_url);
-
- const NamespaceVector& fallbacks = manifest.fallback_namespaces;
- expected = 2;
- ASSERT_EQ(expected, fallbacks.size());
- EXPECT_EQ(FALLBACK_NAMESPACE, fallbacks[0].type);
- EXPECT_EQ(FALLBACK_NAMESPACE, fallbacks[1].type);
- EXPECT_EQ(GURL("http://combo.com:42/fallback-1"),
- fallbacks[0].namespace_url);
- EXPECT_EQ(GURL("http://combo.com:42/fallback-1b"),
- fallbacks[0].target_url);
- EXPECT_EQ(GURL("http://combo.com:42/relative/fallback-2"),
- fallbacks[1].namespace_url);
- EXPECT_EQ(GURL("http://combo.com:42/relative/fallback-2b"),
- fallbacks[1].target_url);
-
- EXPECT_TRUE(manifest.intercept_namespaces.empty());
-}
-
-TEST(AppCacheManifestParserTest, UnusualUtf8) {
- Manifest manifest;
- const GURL kUrl("http://bad.com");
- const std::string kData("CACHE MANIFEST\r"
- "\xC0" "invalidutf8\r"
- "nonbmp" "\xF1\x84\xAB\xBC\r");
- EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest));
-
- base::hash_set<std::string> urls = manifest.explicit_urls;
- EXPECT_TRUE(urls.find("http://bad.com/%EF%BF%BDinvalidutf8") != urls.end());
- EXPECT_TRUE(urls.find("http://bad.com/nonbmp%F1%84%AB%BC") != urls.end());
-}
-
-TEST(AppCacheManifestParserTest, IgnoreAfterSpace) {
- Manifest manifest;
- const GURL kUrl("http://smorg.borg");
- const std::string kData(
- "CACHE MANIFEST\r"
- "resource.txt this stuff after the white space should be ignored\r");
- EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest));
-
- base::hash_set<std::string> urls = manifest.explicit_urls;
- EXPECT_TRUE(urls.find("http://smorg.borg/resource.txt") != urls.end());
-}
-
-TEST(AppCacheManifestParserTest, DifferentOriginUrlWithSecureScheme) {
- Manifest manifest;
- const GURL kUrl("https://www.foo.com");
- const std::string kData("CACHE MANIFEST\r"
- "CACHE: \r"
- "relative/secureschemesameorigin\r"
- "https://www.foo.com/secureschemesameorigin\r"
- "http://www.xyz.com/secureschemedifforigin\r"
- "https://www.xyz.com/secureschemedifforigin\r");
-
- EXPECT_TRUE(ParseManifest(kUrl, kData.c_str(), kData.length(), manifest));
- EXPECT_TRUE(manifest.fallback_namespaces.empty());
- EXPECT_TRUE(manifest.online_whitelist_namespaces.empty());
-
- base::hash_set<std::string> urls = manifest.explicit_urls;
- const size_t kExpected = 3;
- ASSERT_EQ(kExpected, urls.size());
- EXPECT_TRUE(urls.find("https://www.foo.com/relative/secureschemesameorigin")
- != urls.end());
- EXPECT_TRUE(urls.find("https://www.foo.com/secureschemesameorigin") !=
- urls.end());
- EXPECT_FALSE(urls.find("http://www.xyz.com/secureschemedifforigin") !=
- urls.end());
- EXPECT_TRUE(urls.find("https://www.xyz.com/secureschemedifforigin") !=
- urls.end());
-}
-
-TEST(AppCacheManifestParserTest, PatternMatching) {
- const GURL kUrl("http://foo.com/manifest");
- const std::string kManifestBody(
- "CACHE MANIFEST\r"
- "CACHE: \r"
- "http://foo.com/page.html\r"
- "CHROMIUM-INTERCEPT:\r"
- "http://foo.com/intercept_prefix return /prefix\r"
- "http://foo.com/intercept_pattern return /pattern isPattern\r"
- "http://foo.com/*/intercept_pattern?query return /pattern isPattern\r"
- "FALLBACK:\r"
- "http://foo.com/fallback_prefix /prefix wrongAnnotation\r"
- "http://foo.com/fallback_pattern* /pattern\tisPattern \r"
- "NETWORK:\r"
- "*\r"
- "isPattern\r" // should not be interpretted as a pattern
- "http://foo.com/network_pattern* isPattern\r");
-
-
- Manifest manifest;
- EXPECT_TRUE(ParseManifest(kUrl, kManifestBody.c_str(),
- kManifestBody.length(), manifest));
- EXPECT_TRUE(manifest.online_whitelist_all);
- EXPECT_EQ(1u, manifest.explicit_urls.size());
- EXPECT_EQ(3u, manifest.intercept_namespaces.size());
- EXPECT_EQ(2u, manifest.fallback_namespaces.size());
- EXPECT_EQ(2u, manifest.online_whitelist_namespaces.size());
- EXPECT_EQ(INTERCEPT_NAMESPACE, manifest.intercept_namespaces[0].type);
- EXPECT_EQ(FALLBACK_NAMESPACE, manifest.fallback_namespaces[0].type);
- EXPECT_EQ(NETWORK_NAMESPACE, manifest.online_whitelist_namespaces[0].type);
- EXPECT_FALSE(manifest.intercept_namespaces[0].is_pattern);
- EXPECT_TRUE(manifest.intercept_namespaces[1].is_pattern);
- EXPECT_TRUE(manifest.intercept_namespaces[2].is_pattern);
- EXPECT_FALSE(manifest.fallback_namespaces[0].is_pattern);
- EXPECT_TRUE(manifest.fallback_namespaces[1].is_pattern);
- EXPECT_FALSE(manifest.online_whitelist_namespaces[0].is_pattern);
- EXPECT_TRUE(manifest.online_whitelist_namespaces[1].is_pattern);
- EXPECT_EQ(
- GURL("http://foo.com/*/intercept_pattern?query"),
- manifest.intercept_namespaces[2].namespace_url);
- EXPECT_EQ(
- GURL("http://foo.com/pattern"),
- manifest.intercept_namespaces[2].target_url);
- EXPECT_EQ(
- GURL("http://foo.com/fallback_pattern*"),
- manifest.fallback_namespaces[1].namespace_url);
- EXPECT_EQ(
- GURL("http://foo.com/pattern"),
- manifest.fallback_namespaces[1].target_url);
- EXPECT_EQ(
- GURL("http://foo.com/isPattern"),
- manifest.online_whitelist_namespaces[0].namespace_url);
- EXPECT_EQ(
- GURL(),
- manifest.online_whitelist_namespaces[0].target_url);
- EXPECT_EQ(
- GURL("http://foo.com/network_pattern*"),
- manifest.online_whitelist_namespaces[1].namespace_url);
- EXPECT_EQ(
- GURL(),
- manifest.online_whitelist_namespaces[1].target_url);
-}
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/mock_appcache_policy.cc b/chromium/webkit/browser/appcache/mock_appcache_policy.cc
deleted file mode 100644
index b74d754da44..00000000000
--- a/chromium/webkit/browser/appcache/mock_appcache_policy.cc
+++ /dev/null
@@ -1,28 +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.
-
-#include "webkit/browser/appcache/mock_appcache_policy.h"
-
-namespace appcache {
-
-MockAppCachePolicy::MockAppCachePolicy()
- : can_load_return_value_(true), can_create_return_value_(true) {
-}
-
-MockAppCachePolicy::~MockAppCachePolicy() {
-}
-
-bool MockAppCachePolicy::CanLoadAppCache(const GURL& manifest_url,
- const GURL& first_party) {
- requested_manifest_url_ = manifest_url;
- return can_load_return_value_;
-}
-
-bool MockAppCachePolicy::CanCreateAppCache(const GURL& manifest_url,
- const GURL& first_party) {
- requested_manifest_url_ = manifest_url;
- return can_create_return_value_;
-}
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/mock_appcache_policy.h b/chromium/webkit/browser/appcache/mock_appcache_policy.h
deleted file mode 100644
index a65e0672f1b..00000000000
--- a/chromium/webkit/browser/appcache/mock_appcache_policy.h
+++ /dev/null
@@ -1,31 +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.
-
-#ifndef WEBKIT_BROWSER_APPCACHE_MOCK_APPCACHE_POLICY_H_
-#define WEBKIT_BROWSER_APPCACHE_MOCK_APPCACHE_POLICY_H_
-
-#include "base/compiler_specific.h"
-#include "url/gurl.h"
-#include "webkit/browser/appcache/appcache_policy.h"
-
-namespace appcache {
-
-class MockAppCachePolicy : public AppCachePolicy {
- public:
- MockAppCachePolicy();
- virtual ~MockAppCachePolicy();
-
- virtual bool CanLoadAppCache(const GURL& manifest_url,
- const GURL& first_party) OVERRIDE;
- virtual bool CanCreateAppCache(const GURL& manifest_url,
- const GURL& first_party) OVERRIDE;
-
- bool can_load_return_value_;
- bool can_create_return_value_;
- GURL requested_manifest_url_;
-};
-
-} // namespace appcache
-
-#endif // WEBKIT_BROWSER_APPCACHE_MOCK_APPCACHE_POLICY_H_
diff --git a/chromium/webkit/browser/appcache/mock_appcache_service.cc b/chromium/webkit/browser/appcache/mock_appcache_service.cc
deleted file mode 100644
index fa3d26f0020..00000000000
--- a/chromium/webkit/browser/appcache/mock_appcache_service.cc
+++ /dev/null
@@ -1,27 +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.
-
-#include "webkit/browser/appcache/mock_appcache_service.h"
-
-#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
-
-namespace appcache {
-
-static void DeferredCallCallback(
- const net::CompletionCallback& callback, int rv) {
- callback.Run(rv);
-}
-
-void MockAppCacheService::DeleteAppCachesForOrigin(
- const GURL& origin, const net::CompletionCallback& callback) {
- ++delete_called_count_;
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&DeferredCallCallback,
- callback,
- mock_delete_appcaches_for_origin_result_));
-}
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/mock_appcache_service.h b/chromium/webkit/browser/appcache/mock_appcache_service.h
deleted file mode 100644
index 4c8cfa56736..00000000000
--- a/chromium/webkit/browser/appcache/mock_appcache_service.h
+++ /dev/null
@@ -1,48 +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.
-
-#ifndef WEBKIT_BROWSER_APPCACHE_MOCK_APPCACHE_SERVICE_H_
-#define WEBKIT_BROWSER_APPCACHE_MOCK_APPCACHE_SERVICE_H_
-
-#include "base/compiler_specific.h"
-#include "webkit/browser/appcache/appcache_service.h"
-#include "webkit/browser/appcache/mock_appcache_storage.h"
-#include "webkit/browser/quota/quota_manager.h"
-
-namespace appcache {
-
-// For use by unit tests.
-class MockAppCacheService : public AppCacheService {
- public:
- MockAppCacheService()
- : AppCacheService(NULL),
- mock_delete_appcaches_for_origin_result_(net::OK),
- delete_called_count_(0) {
- storage_.reset(new MockAppCacheStorage(this));
- }
-
- // Just returns a canned completion code without actually
- // removing groups and caches in our mock storage instance.
- virtual void DeleteAppCachesForOrigin(
- const GURL& origin,
- const net::CompletionCallback& callback) OVERRIDE;
-
- void set_quota_manager_proxy(quota::QuotaManagerProxy* proxy) {
- quota_manager_proxy_ = proxy;
- }
-
- void set_mock_delete_appcaches_for_origin_result(int rv) {
- mock_delete_appcaches_for_origin_result_ = rv;
- }
-
- int delete_called_count() const { return delete_called_count_; }
-
- private:
- int mock_delete_appcaches_for_origin_result_;
- int delete_called_count_;
-};
-
-} // namespace appcache
-
-#endif // WEBKIT_BROWSER_APPCACHE_MOCK_APPCACHE_SERVICE_H_
diff --git a/chromium/webkit/browser/appcache/mock_appcache_storage.cc b/chromium/webkit/browser/appcache/mock_appcache_storage.cc
deleted file mode 100644
index 27f0a634c9c..00000000000
--- a/chromium/webkit/browser/appcache/mock_appcache_storage.cc
+++ /dev/null
@@ -1,537 +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.
-
-#include "webkit/browser/appcache/mock_appcache_storage.h"
-
-#include "base/bind.h"
-#include "base/logging.h"
-#include "base/memory/ref_counted.h"
-#include "base/message_loop/message_loop.h"
-#include "base/stl_util.h"
-#include "webkit/browser/appcache/appcache.h"
-#include "webkit/browser/appcache/appcache_entry.h"
-#include "webkit/browser/appcache/appcache_group.h"
-#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/appcache_service.h"
-
-// This is a quick and easy 'mock' implementation of the storage interface
-// that doesn't put anything to disk.
-//
-// We simply add an extra reference to objects when they're put in storage,
-// and remove the extra reference when they are removed from storage.
-// Responses are never really removed from the in-memory disk cache.
-// Delegate callbacks are made asyncly to appropiately mimic what will
-// happen with a real disk-backed storage impl that involves IO on a
-// background thread.
-
-namespace appcache {
-
-MockAppCacheStorage::MockAppCacheStorage(AppCacheService* service)
- : AppCacheStorage(service),
- simulate_make_group_obsolete_failure_(false),
- simulate_store_group_and_newest_cache_failure_(false),
- simulate_find_main_resource_(false),
- simulate_find_sub_resource_(false),
- simulated_found_cache_id_(kNoCacheId),
- simulated_found_group_id_(0),
- simulated_found_network_namespace_(false),
- weak_factory_(this) {
- last_cache_id_ = 0;
- last_group_id_ = 0;
- last_response_id_ = 0;
-}
-
-MockAppCacheStorage::~MockAppCacheStorage() {
-}
-
-void MockAppCacheStorage::GetAllInfo(Delegate* delegate) {
- ScheduleTask(
- base::Bind(&MockAppCacheStorage::ProcessGetAllInfo,
- weak_factory_.GetWeakPtr(),
- make_scoped_refptr(GetOrCreateDelegateReference(delegate))));
-}
-
-void MockAppCacheStorage::LoadCache(int64 id, Delegate* delegate) {
- DCHECK(delegate);
- AppCache* cache = working_set_.GetCache(id);
- if (ShouldCacheLoadAppearAsync(cache)) {
- ScheduleTask(
- base::Bind(&MockAppCacheStorage::ProcessLoadCache,
- weak_factory_.GetWeakPtr(), id,
- make_scoped_refptr(GetOrCreateDelegateReference(delegate))));
- return;
- }
- ProcessLoadCache(id, GetOrCreateDelegateReference(delegate));
-}
-
-void MockAppCacheStorage::LoadOrCreateGroup(
- const GURL& manifest_url, Delegate* delegate) {
- DCHECK(delegate);
- AppCacheGroup* group = working_set_.GetGroup(manifest_url);
- if (ShouldGroupLoadAppearAsync(group)) {
- ScheduleTask(
- base::Bind(&MockAppCacheStorage::ProcessLoadOrCreateGroup,
- weak_factory_.GetWeakPtr(), manifest_url,
- make_scoped_refptr(GetOrCreateDelegateReference(delegate))));
- return;
- }
- ProcessLoadOrCreateGroup(
- manifest_url, GetOrCreateDelegateReference(delegate));
-}
-
-void MockAppCacheStorage::StoreGroupAndNewestCache(
- AppCacheGroup* group, AppCache* newest_cache, Delegate* delegate) {
- DCHECK(group && delegate && newest_cache);
-
- // Always make this operation look async.
- ScheduleTask(
- base::Bind(&MockAppCacheStorage::ProcessStoreGroupAndNewestCache,
- weak_factory_.GetWeakPtr(), make_scoped_refptr(group),
- make_scoped_refptr(newest_cache),
- make_scoped_refptr(GetOrCreateDelegateReference(delegate))));
-}
-
-void MockAppCacheStorage::FindResponseForMainRequest(
- const GURL& url, const GURL& preferred_manifest_url, Delegate* delegate) {
- DCHECK(delegate);
-
- // Note: MockAppCacheStorage does not respect the preferred_manifest_url.
-
- // Always make this operation look async.
- ScheduleTask(
- base::Bind(&MockAppCacheStorage::ProcessFindResponseForMainRequest,
- weak_factory_.GetWeakPtr(), url,
- make_scoped_refptr(GetOrCreateDelegateReference(delegate))));
-}
-
-void MockAppCacheStorage::FindResponseForSubRequest(
- AppCache* cache, const GURL& url,
- AppCacheEntry* found_entry, AppCacheEntry* found_fallback_entry,
- bool* found_network_namespace) {
- DCHECK(cache && cache->is_complete());
-
- // This layer of indirection is here to facilitate testing.
- if (simulate_find_sub_resource_) {
- *found_entry = simulated_found_entry_;
- *found_fallback_entry = simulated_found_fallback_entry_;
- *found_network_namespace = simulated_found_network_namespace_;
- simulate_find_sub_resource_ = false;
- return;
- }
-
- GURL fallback_namespace_not_used;
- GURL intercept_namespace_not_used;
- cache->FindResponseForRequest(
- url, found_entry, &intercept_namespace_not_used,
- found_fallback_entry, &fallback_namespace_not_used,
- found_network_namespace);
-}
-
-void MockAppCacheStorage::MarkEntryAsForeign(
- const GURL& entry_url, int64 cache_id) {
- AppCache* cache = working_set_.GetCache(cache_id);
- if (cache) {
- AppCacheEntry* entry = cache->GetEntry(entry_url);
- DCHECK(entry);
- if (entry)
- entry->add_types(AppCacheEntry::FOREIGN);
- }
-}
-
-void MockAppCacheStorage::MakeGroupObsolete(
- AppCacheGroup* group, Delegate* delegate) {
- DCHECK(group && delegate);
-
- // Always make this method look async.
- ScheduleTask(
- base::Bind(&MockAppCacheStorage::ProcessMakeGroupObsolete,
- weak_factory_.GetWeakPtr(), make_scoped_refptr(group),
- make_scoped_refptr(GetOrCreateDelegateReference(delegate))));
-}
-
-AppCacheResponseReader* MockAppCacheStorage::CreateResponseReader(
- const GURL& manifest_url, int64 group_id, int64 response_id) {
- if (simulated_reader_)
- return simulated_reader_.release();
- return new AppCacheResponseReader(response_id, group_id, disk_cache());
-}
-
-AppCacheResponseWriter* MockAppCacheStorage::CreateResponseWriter(
- const GURL& manifest_url, int64 group_id) {
- return new AppCacheResponseWriter(NewResponseId(), group_id, disk_cache());
-}
-
-void MockAppCacheStorage::DoomResponses(
- const GURL& manifest_url, const std::vector<int64>& response_ids) {
- DeleteResponses(manifest_url, response_ids);
-}
-
-void MockAppCacheStorage::DeleteResponses(
- const GURL& manifest_url, const std::vector<int64>& response_ids) {
- // We don't bother with actually removing responses from the disk-cache,
- // just keep track of which ids have been doomed or deleted
- std::vector<int64>::const_iterator it = response_ids.begin();
- while (it != response_ids.end()) {
- doomed_response_ids_.insert(*it);
- ++it;
- }
-}
-
-void MockAppCacheStorage::ProcessGetAllInfo(
- scoped_refptr<DelegateReference> delegate_ref) {
- if (delegate_ref->delegate)
- delegate_ref->delegate->OnAllInfo(simulated_appcache_info_.get());
-}
-
-void MockAppCacheStorage::ProcessLoadCache(
- int64 id, scoped_refptr<DelegateReference> delegate_ref) {
- AppCache* cache = working_set_.GetCache(id);
- if (delegate_ref->delegate)
- delegate_ref->delegate->OnCacheLoaded(cache, id);
-}
-
-void MockAppCacheStorage::ProcessLoadOrCreateGroup(
- const GURL& manifest_url, scoped_refptr<DelegateReference> delegate_ref) {
- scoped_refptr<AppCacheGroup> group(working_set_.GetGroup(manifest_url));
-
- // Newly created groups are not put in the stored_groups collection
- // until StoreGroupAndNewestCache is called.
- if (!group.get())
- group = new AppCacheGroup(service_->storage(), manifest_url, NewGroupId());
-
- if (delegate_ref->delegate)
- delegate_ref->delegate->OnGroupLoaded(group.get(), manifest_url);
-}
-
-void MockAppCacheStorage::ProcessStoreGroupAndNewestCache(
- scoped_refptr<AppCacheGroup> group,
- scoped_refptr<AppCache> newest_cache,
- scoped_refptr<DelegateReference> delegate_ref) {
- Delegate* delegate = delegate_ref->delegate;
- if (simulate_store_group_and_newest_cache_failure_) {
- if (delegate)
- delegate->OnGroupAndNewestCacheStored(
- group.get(), newest_cache.get(), false, false);
- return;
- }
-
- AddStoredGroup(group.get());
- if (newest_cache.get() != group->newest_complete_cache()) {
- newest_cache->set_complete(true);
- group->AddCache(newest_cache.get());
- AddStoredCache(newest_cache.get());
-
- // Copy the collection prior to removal, on final release
- // of a cache the group's collection will change.
- AppCacheGroup::Caches copy = group->old_caches();
- RemoveStoredCaches(copy);
- }
-
- if (delegate)
- delegate->OnGroupAndNewestCacheStored(
- group.get(), newest_cache.get(), true, false);
-}
-
-namespace {
-
-struct FoundCandidate {
- GURL namespace_entry_url;
- AppCacheEntry entry;
- int64 cache_id;
- int64 group_id;
- GURL manifest_url;
- bool is_cache_in_use;
-
- FoundCandidate()
- : cache_id(kNoCacheId), group_id(0), is_cache_in_use(false) {}
-};
-
-void MaybeTakeNewNamespaceEntry(
- NamespaceType namespace_type,
- const AppCacheEntry &entry,
- const GURL& namespace_url,
- bool cache_is_in_use,
- FoundCandidate* best_candidate,
- GURL* best_candidate_namespace,
- AppCache* cache,
- AppCacheGroup* group) {
- DCHECK(entry.has_response_id());
-
- bool take_new_entry = true;
-
- // Does the new candidate entry trump our current best candidate?
- if (best_candidate->entry.has_response_id()) {
- // Longer namespace prefix matches win.
- size_t candidate_length =
- namespace_url.spec().length();
- size_t best_length =
- best_candidate_namespace->spec().length();
-
- if (candidate_length > best_length) {
- take_new_entry = true;
- } else if (candidate_length == best_length &&
- cache_is_in_use && !best_candidate->is_cache_in_use) {
- take_new_entry = true;
- } else {
- take_new_entry = false;
- }
- }
-
- if (take_new_entry) {
- if (namespace_type == FALLBACK_NAMESPACE) {
- best_candidate->namespace_entry_url =
- cache->GetFallbackEntryUrl(namespace_url);
- } else {
- best_candidate->namespace_entry_url =
- cache->GetInterceptEntryUrl(namespace_url);
- }
- best_candidate->entry = entry;
- best_candidate->cache_id = cache->cache_id();
- best_candidate->group_id = group->group_id();
- best_candidate->manifest_url = group->manifest_url();
- best_candidate->is_cache_in_use = cache_is_in_use;
- *best_candidate_namespace = namespace_url;
- }
-}
-} // namespace
-
-void MockAppCacheStorage::ProcessFindResponseForMainRequest(
- const GURL& url, scoped_refptr<DelegateReference> delegate_ref) {
- if (simulate_find_main_resource_) {
- simulate_find_main_resource_ = false;
- if (delegate_ref->delegate) {
- delegate_ref->delegate->OnMainResponseFound(
- url, simulated_found_entry_,
- simulated_found_fallback_url_, simulated_found_fallback_entry_,
- simulated_found_cache_id_, simulated_found_group_id_,
- simulated_found_manifest_url_);
- }
- return;
- }
-
- // This call has no persistent side effects, if the delegate has gone
- // away, we can just bail out early.
- if (!delegate_ref->delegate)
- return;
-
- // TODO(michaeln): The heuristics around choosing amoungst
- // multiple candidates is under specified, and just plain
- // not fully understood. Refine these over time. In particular,
- // * prefer candidates from newer caches
- // * take into account the cache associated with the document
- // that initiated the navigation
- // * take into account the cache associated with the document
- // currently residing in the frame being navigated
- FoundCandidate found_candidate;
- GURL found_intercept_candidate_namespace;
- FoundCandidate found_fallback_candidate;
- GURL found_fallback_candidate_namespace;
-
- for (StoredGroupMap::const_iterator it = stored_groups_.begin();
- it != stored_groups_.end(); ++it) {
- AppCacheGroup* group = it->second.get();
- AppCache* cache = group->newest_complete_cache();
- if (group->is_obsolete() || !cache ||
- (url.GetOrigin() != group->manifest_url().GetOrigin())) {
- continue;
- }
-
- AppCacheEntry found_entry;
- AppCacheEntry found_fallback_entry;
- GURL found_intercept_namespace;
- GURL found_fallback_namespace;
- bool ignore_found_network_namespace = false;
- bool found = cache->FindResponseForRequest(
- url, &found_entry, &found_intercept_namespace,
- &found_fallback_entry, &found_fallback_namespace,
- &ignore_found_network_namespace);
-
- // 6.11.1 Navigating across documents, Step 10.
- // Network namespacing doesn't apply to main resource loads,
- // and foreign entries are excluded.
- if (!found || ignore_found_network_namespace ||
- (found_entry.has_response_id() && found_entry.IsForeign()) ||
- (found_fallback_entry.has_response_id() &&
- found_fallback_entry.IsForeign())) {
- continue;
- }
-
- // We have a bias for hits from caches that are in use.
- bool is_in_use = IsCacheStored(cache) && !cache->HasOneRef();
-
- if (found_entry.has_response_id() &&
- found_intercept_namespace.is_empty()) {
- found_candidate.namespace_entry_url = GURL();
- found_candidate.entry = found_entry;
- found_candidate.cache_id = cache->cache_id();
- found_candidate.group_id = group->group_id();
- found_candidate.manifest_url = group->manifest_url();
- found_candidate.is_cache_in_use = is_in_use;
- if (is_in_use)
- break; // We break out of the loop with this direct hit.
- } else if (found_entry.has_response_id() &&
- !found_intercept_namespace.is_empty()) {
- MaybeTakeNewNamespaceEntry(
- INTERCEPT_NAMESPACE,
- found_entry, found_intercept_namespace, is_in_use,
- &found_candidate, &found_intercept_candidate_namespace,
- cache, group);
- } else {
- DCHECK(found_fallback_entry.has_response_id());
- MaybeTakeNewNamespaceEntry(
- FALLBACK_NAMESPACE,
- found_fallback_entry, found_fallback_namespace, is_in_use,
- &found_fallback_candidate, &found_fallback_candidate_namespace,
- cache, group);
- }
- }
-
- // Found a direct hit or an intercept namespace hit.
- if (found_candidate.entry.has_response_id()) {
- delegate_ref->delegate->OnMainResponseFound(
- url, found_candidate.entry, found_candidate.namespace_entry_url,
- AppCacheEntry(), found_candidate.cache_id, found_candidate.group_id,
- found_candidate.manifest_url);
- return;
- }
-
- // Found a fallback namespace.
- if (found_fallback_candidate.entry.has_response_id()) {
- delegate_ref->delegate->OnMainResponseFound(
- url, AppCacheEntry(),
- found_fallback_candidate.namespace_entry_url,
- found_fallback_candidate.entry,
- found_fallback_candidate.cache_id,
- found_fallback_candidate.group_id,
- found_fallback_candidate.manifest_url);
- return;
- }
-
- // Didn't find anything.
- delegate_ref->delegate->OnMainResponseFound(
- url, AppCacheEntry(), GURL(), AppCacheEntry(), kNoCacheId, 0, GURL());
-}
-
-void MockAppCacheStorage::ProcessMakeGroupObsolete(
- scoped_refptr<AppCacheGroup> group,
- scoped_refptr<DelegateReference> delegate_ref) {
- if (simulate_make_group_obsolete_failure_) {
- if (delegate_ref->delegate)
- delegate_ref->delegate->OnGroupMadeObsolete(group.get(), false);
- return;
- }
-
- RemoveStoredGroup(group.get());
- if (group->newest_complete_cache())
- RemoveStoredCache(group->newest_complete_cache());
-
- // Copy the collection prior to removal, on final release
- // of a cache the group's collection will change.
- AppCacheGroup::Caches copy = group->old_caches();
- RemoveStoredCaches(copy);
-
- group->set_obsolete(true);
-
- // Also remove from the working set, caches for an 'obsolete' group
- // may linger in use, but the group itself cannot be looked up by
- // 'manifest_url' in the working set any longer.
- working_set()->RemoveGroup(group.get());
-
- if (delegate_ref->delegate)
- delegate_ref->delegate->OnGroupMadeObsolete(group.get(), true);
-}
-
-void MockAppCacheStorage::ScheduleTask(const base::Closure& task) {
- pending_tasks_.push_back(task);
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&MockAppCacheStorage::RunOnePendingTask,
- weak_factory_.GetWeakPtr()));
-}
-
-void MockAppCacheStorage::RunOnePendingTask() {
- DCHECK(!pending_tasks_.empty());
- base::Closure task = pending_tasks_.front();
- pending_tasks_.pop_front();
- task.Run();
-}
-
-void MockAppCacheStorage::AddStoredCache(AppCache* cache) {
- int64 cache_id = cache->cache_id();
- if (stored_caches_.find(cache_id) == stored_caches_.end()) {
- stored_caches_.insert(
- StoredCacheMap::value_type(cache_id, make_scoped_refptr(cache)));
- }
-}
-
-void MockAppCacheStorage::RemoveStoredCache(AppCache* cache) {
- // Do not remove from the working set, active caches are still usable
- // and may be looked up by id until they fall out of use.
- stored_caches_.erase(cache->cache_id());
-}
-
-void MockAppCacheStorage::RemoveStoredCaches(
- const AppCacheGroup::Caches& caches) {
- AppCacheGroup::Caches::const_iterator it = caches.begin();
- while (it != caches.end()) {
- RemoveStoredCache(*it);
- ++it;
- }
-}
-
-void MockAppCacheStorage::AddStoredGroup(AppCacheGroup* group) {
- const GURL& url = group->manifest_url();
- if (stored_groups_.find(url) == stored_groups_.end()) {
- stored_groups_.insert(
- StoredGroupMap::value_type(url, make_scoped_refptr(group)));
- }
-}
-
-void MockAppCacheStorage::RemoveStoredGroup(AppCacheGroup* group) {
- stored_groups_.erase(group->manifest_url());
-}
-
-bool MockAppCacheStorage::ShouldGroupLoadAppearAsync(
- const AppCacheGroup* group) {
- // We'll have to query the database to see if a group for the
- // manifest_url exists on disk. So return true for async.
- if (!group)
- return true;
-
- // Groups without a newest cache can't have been put to disk yet, so
- // we can synchronously return a reference we have in the working set.
- if (!group->newest_complete_cache())
- return false;
-
- // The LoadGroup interface implies also loading the newest cache, so
- // if loading the newest cache should appear async, so too must the
- // loading of this group.
- if (!ShouldCacheLoadAppearAsync(group->newest_complete_cache()))
- return false;
-
-
- // If any of the old caches are "in use", then the group must also
- // be memory resident and not require async loading.
- const AppCacheGroup::Caches& old_caches = group->old_caches();
- AppCacheGroup::Caches::const_iterator it = old_caches.begin();
- while (it != old_caches.end()) {
- // "in use" caches don't require async loading
- if (!ShouldCacheLoadAppearAsync(*it))
- return false;
- ++it;
- }
-
- return true;
-}
-
-bool MockAppCacheStorage::ShouldCacheLoadAppearAsync(const AppCache* cache) {
- if (!cache)
- return true;
-
- // If the 'stored' ref is the only ref, real storage will have to load from
- // the database.
- return IsCacheStored(cache) && cache->HasOneRef();
-}
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/mock_appcache_storage.h b/chromium/webkit/browser/appcache/mock_appcache_storage.h
deleted file mode 100644
index 94ae958d4a9..00000000000
--- a/chromium/webkit/browser/appcache/mock_appcache_storage.h
+++ /dev/null
@@ -1,219 +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.
-
-#ifndef WEBKIT_BROWSER_APPCACHE_MOCK_APPCACHE_STORAGE_H_
-#define WEBKIT_BROWSER_APPCACHE_MOCK_APPCACHE_STORAGE_H_
-
-#include <deque>
-#include <map>
-#include <vector>
-
-#include "base/callback.h"
-#include "base/containers/hash_tables.h"
-#include "base/gtest_prod_util.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
-#include "webkit/browser/appcache/appcache.h"
-#include "webkit/browser/appcache/appcache_disk_cache.h"
-#include "webkit/browser/appcache/appcache_group.h"
-#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/appcache_storage.h"
-
-namespace appcache {
-
-// For use in unit tests.
-// Note: This class is also being used to bootstrap our development efforts.
-// We can get layout tests up and running, and back fill with real storage
-// somewhat in parallel.
-class MockAppCacheStorage : public AppCacheStorage {
- public:
- explicit MockAppCacheStorage(AppCacheService* service);
- virtual ~MockAppCacheStorage();
-
- virtual void GetAllInfo(Delegate* delegate) OVERRIDE;
- virtual void LoadCache(int64 id, Delegate* delegate) OVERRIDE;
- virtual void LoadOrCreateGroup(const GURL& manifest_url,
- Delegate* delegate) OVERRIDE;
- virtual void StoreGroupAndNewestCache(AppCacheGroup* group,
- AppCache* newest_cache,
- Delegate* delegate) OVERRIDE;
- virtual void FindResponseForMainRequest(const GURL& url,
- const GURL& preferred_manifest_url,
- Delegate* delegate) OVERRIDE;
- virtual void FindResponseForSubRequest(
- AppCache* cache, const GURL& url,
- AppCacheEntry* found_entry, AppCacheEntry* found_fallback_entry,
- bool * found_network_namespace) OVERRIDE;
- virtual void MarkEntryAsForeign(const GURL& entry_url,
- int64 cache_id) OVERRIDE;
- virtual void MakeGroupObsolete(AppCacheGroup* group,
- Delegate* delegate) OVERRIDE;
- virtual AppCacheResponseReader* CreateResponseReader(
- const GURL& manifest_url, int64 group_id, int64 response_id) OVERRIDE;
- virtual AppCacheResponseWriter* CreateResponseWriter(
- const GURL& manifest_url, int64 group_id) OVERRIDE;
- virtual void DoomResponses(
- const GURL& manifest_url,
- const std::vector<int64>& response_ids) OVERRIDE;
- virtual void DeleteResponses(
- const GURL& manifest_url,
- const std::vector<int64>& response_ids) OVERRIDE;
- virtual void PurgeMemory() OVERRIDE {}
-
- private:
- friend class AppCacheRequestHandlerTest;
- friend class AppCacheServiceTest;
- friend class AppCacheUpdateJobTest;
-
- typedef base::hash_map<int64, scoped_refptr<AppCache> > StoredCacheMap;
- typedef std::map<GURL, scoped_refptr<AppCacheGroup> > StoredGroupMap;
- typedef std::set<int64> DoomedResponseIds;
-
- void ProcessGetAllInfo(scoped_refptr<DelegateReference> delegate_ref);
- void ProcessLoadCache(
- int64 id, scoped_refptr<DelegateReference> delegate_ref);
- void ProcessLoadOrCreateGroup(
- const GURL& manifest_url, scoped_refptr<DelegateReference> delegate_ref);
- void ProcessStoreGroupAndNewestCache(
- scoped_refptr<AppCacheGroup> group, scoped_refptr<AppCache> newest_cache,
- scoped_refptr<DelegateReference> delegate_ref);
- void ProcessMakeGroupObsolete(
- scoped_refptr<AppCacheGroup> group,
- scoped_refptr<DelegateReference> delegate_ref);
- void ProcessFindResponseForMainRequest(
- const GURL& url, scoped_refptr<DelegateReference> delegate_ref);
-
- void ScheduleTask(const base::Closure& task);
- void RunOnePendingTask();
-
- void AddStoredCache(AppCache* cache);
- void RemoveStoredCache(AppCache* cache);
- void RemoveStoredCaches(const AppCacheGroup::Caches& caches);
- bool IsCacheStored(const AppCache* cache) {
- return stored_caches_.find(cache->cache_id()) != stored_caches_.end();
- }
-
- void AddStoredGroup(AppCacheGroup* group);
- void RemoveStoredGroup(AppCacheGroup* group);
- bool IsGroupStored(const AppCacheGroup* group) {
- return IsGroupForManifestStored(group->manifest_url());
- }
- bool IsGroupForManifestStored(const GURL& manifest_url) {
- return stored_groups_.find(manifest_url) != stored_groups_.end();
- }
-
- // These helpers determine when certain operations should complete
- // asynchronously vs synchronously to faithfully mimic, or mock,
- // the behavior of the real implemenation of the AppCacheStorage
- // interface.
- bool ShouldGroupLoadAppearAsync(const AppCacheGroup* group);
- bool ShouldCacheLoadAppearAsync(const AppCache* cache);
-
- // Lazily constructed in-memory disk cache.
- AppCacheDiskCache* disk_cache() {
- if (!disk_cache_) {
- const int kMaxCacheSize = 10 * 1024 * 1024;
- disk_cache_.reset(new AppCacheDiskCache);
- disk_cache_->InitWithMemBackend(kMaxCacheSize, net::CompletionCallback());
- }
- return disk_cache_.get();
- }
-
- // Simulate failures for testing. Once set all subsequent calls
- // to MakeGroupObsolete or StorageGroupAndNewestCache will fail.
- void SimulateMakeGroupObsoleteFailure() {
- simulate_make_group_obsolete_failure_ = true;
- }
- void SimulateStoreGroupAndNewestCacheFailure() {
- simulate_store_group_and_newest_cache_failure_ = true;
- }
-
- // Simulate FindResponseFor results for testing. These
- // provided values will be return on the next call to
- // the corresponding Find method, subsequent calls are
- // unaffected.
- void SimulateFindMainResource(
- const AppCacheEntry& entry,
- const GURL& fallback_url,
- const AppCacheEntry& fallback_entry,
- int64 cache_id,
- int64 group_id,
- const GURL& manifest_url) {
- simulate_find_main_resource_ = true;
- simulate_find_sub_resource_ = false;
- simulated_found_entry_ = entry;
- simulated_found_fallback_url_ = fallback_url;
- simulated_found_fallback_entry_ = fallback_entry;
- simulated_found_cache_id_ = cache_id;
- simulated_found_group_id_ = group_id;
- simulated_found_manifest_url_ = manifest_url,
- simulated_found_network_namespace_ = false; // N/A to main resource loads
- }
- void SimulateFindSubResource(
- const AppCacheEntry& entry,
- const AppCacheEntry& fallback_entry,
- bool network_namespace) {
- simulate_find_main_resource_ = false;
- simulate_find_sub_resource_ = true;
- simulated_found_entry_ = entry;
- simulated_found_fallback_entry_ = fallback_entry;
- simulated_found_cache_id_ = kNoCacheId; // N/A to sub resource loads
- simulated_found_manifest_url_ = GURL(); // N/A to sub resource loads
- simulated_found_group_id_ = 0; // N/A to sub resource loads
- simulated_found_network_namespace_ = network_namespace;
- }
-
- void SimulateGetAllInfo(AppCacheInfoCollection* info) {
- simulated_appcache_info_ = info;
- }
-
- void SimulateResponseReader(AppCacheResponseReader* reader) {
- simulated_reader_.reset(reader);
- }
-
- StoredCacheMap stored_caches_;
- StoredGroupMap stored_groups_;
- DoomedResponseIds doomed_response_ids_;
- scoped_ptr<AppCacheDiskCache> disk_cache_;
- std::deque<base::Closure> pending_tasks_;
-
- bool simulate_make_group_obsolete_failure_;
- bool simulate_store_group_and_newest_cache_failure_;
-
- bool simulate_find_main_resource_;
- bool simulate_find_sub_resource_;
- AppCacheEntry simulated_found_entry_;
- AppCacheEntry simulated_found_fallback_entry_;
- int64 simulated_found_cache_id_;
- int64 simulated_found_group_id_;
- GURL simulated_found_fallback_url_;
- GURL simulated_found_manifest_url_;
- bool simulated_found_network_namespace_;
- scoped_refptr<AppCacheInfoCollection> simulated_appcache_info_;
- scoped_ptr<AppCacheResponseReader> simulated_reader_;
-
- base::WeakPtrFactory<MockAppCacheStorage> weak_factory_;
-
- FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, BasicFindMainResponse);
- FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest,
- BasicFindMainFallbackResponse);
- FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, CreateGroup);
- FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, FindMainResponseExclusions);
- FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest,
- FindMainResponseWithMultipleCandidates);
- FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, LoadCache_FarHit);
- FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, LoadGroupAndCache_FarHit);
- FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, MakeGroupObsolete);
- FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, StoreNewGroup);
- FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest, StoreExistingGroup);
- FRIEND_TEST_ALL_PREFIXES(MockAppCacheStorageTest,
- StoreExistingGroupExistingCache);
- FRIEND_TEST_ALL_PREFIXES(AppCacheServiceTest, DeleteAppCachesForOrigin);
-
- DISALLOW_COPY_AND_ASSIGN(MockAppCacheStorage);
-};
-
-} // namespace appcache
-
-#endif // WEBKIT_BROWSER_APPCACHE_MOCK_APPCACHE_STORAGE_H_
diff --git a/chromium/webkit/browser/appcache/mock_appcache_storage_unittest.cc b/chromium/webkit/browser/appcache/mock_appcache_storage_unittest.cc
deleted file mode 100644
index 0e187bd2b3c..00000000000
--- a/chromium/webkit/browser/appcache/mock_appcache_storage_unittest.cc
+++ /dev/null
@@ -1,630 +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 "base/run_loop.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/appcache/appcache.h"
-#include "webkit/browser/appcache/appcache_group.h"
-#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/appcache_storage.h"
-#include "webkit/browser/appcache/mock_appcache_service.h"
-
-namespace appcache {
-
-class MockAppCacheStorageTest : public testing::Test {
- public:
- class MockStorageDelegate : public AppCacheStorage::Delegate {
- public:
- explicit MockStorageDelegate()
- : loaded_cache_id_(0), stored_group_success_(false),
- obsoleted_success_(false), found_cache_id_(kNoCacheId) {
- }
-
- virtual void OnCacheLoaded(AppCache* cache, int64 cache_id) OVERRIDE {
- loaded_cache_ = cache;
- loaded_cache_id_ = cache_id;
- }
-
- virtual void OnGroupLoaded(AppCacheGroup* group,
- const GURL& manifest_url) OVERRIDE {
- loaded_group_ = group;
- loaded_manifest_url_ = manifest_url;
- }
-
- virtual void OnGroupAndNewestCacheStored(
- AppCacheGroup* group, AppCache* newest_cache, bool success,
- bool would_exceed_quota) OVERRIDE {
- stored_group_ = group;
- stored_group_success_ = success;
- }
-
- virtual void OnGroupMadeObsolete(AppCacheGroup* group,
- bool success) OVERRIDE {
- obsoleted_group_ = group;
- obsoleted_success_ = success;
- }
-
- virtual void OnMainResponseFound(const GURL& url,
- const AppCacheEntry& entry,
- const GURL& fallback_url,
- const AppCacheEntry& fallback_entry,
- int64 cache_id,
- int64 group_id,
- const GURL& manifest_url) OVERRIDE {
- found_url_ = url;
- found_entry_ = entry;
- found_fallback_url_ = fallback_url;
- found_fallback_entry_ = fallback_entry;
- found_cache_id_ = cache_id;
- found_manifest_url_ = manifest_url;
- }
-
- scoped_refptr<AppCache> loaded_cache_;
- int64 loaded_cache_id_;
- scoped_refptr<AppCacheGroup> loaded_group_;
- GURL loaded_manifest_url_;
- scoped_refptr<AppCacheGroup> stored_group_;
- bool stored_group_success_;
- scoped_refptr<AppCacheGroup> obsoleted_group_;
- bool obsoleted_success_;
- GURL found_url_;
- AppCacheEntry found_entry_;
- GURL found_fallback_url_;
- AppCacheEntry found_fallback_entry_;
- int64 found_cache_id_;
- GURL found_manifest_url_;
- };
-
- private:
- base::MessageLoop message_loop_;
-};
-
-TEST_F(MockAppCacheStorageTest, LoadCache_Miss) {
- // Attempt to load a cache that doesn't exist. Should
- // complete asyncly.
- MockAppCacheService service;
- MockStorageDelegate delegate;
- service.storage()->LoadCache(111, &delegate);
- EXPECT_NE(111, delegate.loaded_cache_id_);
- base::RunLoop().RunUntilIdle(); // Do async task execution.
- EXPECT_EQ(111, delegate.loaded_cache_id_);
- EXPECT_FALSE(delegate.loaded_cache_.get());
-}
-
-TEST_F(MockAppCacheStorageTest, LoadCache_NearHit) {
- // Attempt to load a cache that is currently in use
- // and does not require loading from disk. This
- // load should complete syncly.
- MockAppCacheService service;
-
- // Setup some preconditions. Make an 'unstored' cache for
- // us to load. The ctor should put it in the working set.
- int64 cache_id = service.storage()->NewCacheId();
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id));
-
- // Conduct the test.
- MockStorageDelegate delegate;
- service.storage()->LoadCache(cache_id, &delegate);
- EXPECT_EQ(cache_id, delegate.loaded_cache_id_);
- EXPECT_EQ(cache.get(), delegate.loaded_cache_.get());
-}
-
-TEST_F(MockAppCacheStorageTest, CreateGroup) {
- // Attempt to load/create a group that doesn't exist.
- // Should complete asyncly.
- MockAppCacheService service;
- MockAppCacheStorage* storage =
- reinterpret_cast<MockAppCacheStorage*>(service.storage());
- MockStorageDelegate delegate;
- GURL manifest_url("http://blah/");
- service.storage()->LoadOrCreateGroup(manifest_url, &delegate);
- EXPECT_NE(manifest_url, delegate.loaded_manifest_url_);
- EXPECT_FALSE(delegate.loaded_group_.get());
- base::RunLoop().RunUntilIdle(); // Do async task execution.
- EXPECT_EQ(manifest_url, delegate.loaded_manifest_url_);
- EXPECT_TRUE(delegate.loaded_group_.get());
- EXPECT_TRUE(delegate.loaded_group_->HasOneRef());
- EXPECT_FALSE(delegate.loaded_group_->newest_complete_cache());
- EXPECT_TRUE(storage->stored_groups_.empty());
-}
-
-TEST_F(MockAppCacheStorageTest, LoadGroup_NearHit) {
- // Attempt to load a group that is currently in use
- // and does not require loading from disk. This
- // load should complete syncly.
- MockAppCacheService service;
- MockStorageDelegate delegate;
-
- // Setup some preconditions. Create a group that appears
- // to be "unstored" and "currently in use".
- GURL manifest_url("http://blah/");
- service.storage()->LoadOrCreateGroup(manifest_url, &delegate);
- base::RunLoop().RunUntilIdle(); // Do async task execution.
- EXPECT_EQ(manifest_url, delegate.loaded_manifest_url_);
- EXPECT_TRUE(delegate.loaded_group_.get());
-
- // Reset our delegate, and take a reference to the new group.
- scoped_refptr<AppCacheGroup> group;
- group.swap(delegate.loaded_group_);
- delegate.loaded_manifest_url_ = GURL();
-
- // Conduct the test.
- service.storage()->LoadOrCreateGroup(manifest_url, &delegate);
- EXPECT_EQ(manifest_url, delegate.loaded_manifest_url_);
- EXPECT_EQ(group.get(), delegate.loaded_group_.get());
-}
-
-TEST_F(MockAppCacheStorageTest, LoadGroupAndCache_FarHit) {
- // Attempt to load a cache that is not currently in use
- // and does require loading from disk. This
- // load should complete asyncly.
- MockAppCacheService service;
- MockAppCacheStorage* storage =
- reinterpret_cast<MockAppCacheStorage*>(service.storage());
-
- // Setup some preconditions. Create a group and newest cache that
- // appears to be "stored" and "not currently in use".
- GURL manifest_url("http://blah/");
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service.storage(), manifest_url, 111));
- int64 cache_id = storage->NewCacheId();
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id));
- cache->set_complete(true);
- group->AddCache(cache.get());
- storage->AddStoredGroup(group.get());
- storage->AddStoredCache(cache.get());
-
- // Drop the references from above so the only refs to these
- // objects are from within the storage class. This is to make
- // these objects appear as "not currently in use".
- AppCache* cache_ptr = cache.get();
- AppCacheGroup* group_ptr = group.get();
- cache = NULL;
- group = NULL;
-
- // Setup a delegate to receive completion callbacks.
- MockStorageDelegate delegate;
-
- // Conduct the cache load test.
- EXPECT_NE(cache_id, delegate.loaded_cache_id_);
- EXPECT_NE(cache_ptr, delegate.loaded_cache_.get());
- storage->LoadCache(cache_id, &delegate);
- EXPECT_NE(cache_id, delegate.loaded_cache_id_);
- EXPECT_NE(cache_ptr, delegate.loaded_cache_.get());
- base::RunLoop().RunUntilIdle(); // Do async task execution.
- EXPECT_EQ(cache_id, delegate.loaded_cache_id_);
- EXPECT_EQ(cache_ptr, delegate.loaded_cache_.get());
- delegate.loaded_cache_ = NULL;
-
- // Conduct the group load test.
- EXPECT_NE(manifest_url, delegate.loaded_manifest_url_);
- EXPECT_FALSE(delegate.loaded_group_.get());
- storage->LoadOrCreateGroup(manifest_url, &delegate);
- EXPECT_NE(manifest_url, delegate.loaded_manifest_url_);
- EXPECT_FALSE(delegate.loaded_group_.get());
- base::RunLoop().RunUntilIdle(); // Do async task execution.
- EXPECT_EQ(manifest_url, delegate.loaded_manifest_url_);
- EXPECT_EQ(group_ptr, delegate.loaded_group_.get());
-}
-
-TEST_F(MockAppCacheStorageTest, StoreNewGroup) {
- // Store a group and its newest cache. Should complete asyncly.
- MockAppCacheService service;
- MockAppCacheStorage* storage =
- reinterpret_cast<MockAppCacheStorage*>(service.storage());
-
- // Setup some preconditions. Create a group and newest cache that
- // appears to be "unstored".
- GURL manifest_url("http://blah/");
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service.storage(), manifest_url, 111));
- int64 cache_id = storage->NewCacheId();
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id));
- // Hold a ref to the cache simulate the UpdateJob holding that ref,
- // and hold a ref to the group to simulate the CacheHost holding that ref.
-
- // Conduct the store test.
- MockStorageDelegate delegate;
- EXPECT_TRUE(storage->stored_caches_.empty());
- EXPECT_TRUE(storage->stored_groups_.empty());
- storage->StoreGroupAndNewestCache(group.get(), cache.get(), &delegate);
- EXPECT_FALSE(delegate.stored_group_success_);
- EXPECT_TRUE(storage->stored_caches_.empty());
- EXPECT_TRUE(storage->stored_groups_.empty());
- base::RunLoop().RunUntilIdle(); // Do async task execution.
- EXPECT_TRUE(delegate.stored_group_success_);
- EXPECT_FALSE(storage->stored_caches_.empty());
- EXPECT_FALSE(storage->stored_groups_.empty());
- EXPECT_EQ(cache, group->newest_complete_cache());
- EXPECT_TRUE(cache->is_complete());
-}
-
-TEST_F(MockAppCacheStorageTest, StoreExistingGroup) {
- // Store a group and its newest cache. Should complete asyncly.
- MockAppCacheService service;
- MockAppCacheStorage* storage =
- reinterpret_cast<MockAppCacheStorage*>(service.storage());
-
- // Setup some preconditions. Create a group and old complete cache
- // that appear to be "stored", and a newest unstored complete cache.
- GURL manifest_url("http://blah/");
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service.storage(), manifest_url, 111));
- int64 old_cache_id = storage->NewCacheId();
- scoped_refptr<AppCache> old_cache(
- new AppCache(service.storage(), old_cache_id));
- old_cache->set_complete(true);
- group->AddCache(old_cache.get());
- storage->AddStoredGroup(group.get());
- storage->AddStoredCache(old_cache.get());
- int64 new_cache_id = storage->NewCacheId();
- scoped_refptr<AppCache> new_cache(
- new AppCache(service.storage(), new_cache_id));
- // Hold our refs to simulate the UpdateJob holding these refs.
-
- // Conduct the test.
- MockStorageDelegate delegate;
- EXPECT_EQ(size_t(1), storage->stored_caches_.size());
- EXPECT_EQ(size_t(1), storage->stored_groups_.size());
- EXPECT_TRUE(storage->IsCacheStored(old_cache.get()));
- EXPECT_FALSE(storage->IsCacheStored(new_cache.get()));
- storage->StoreGroupAndNewestCache(group.get(), new_cache.get(), &delegate);
- EXPECT_FALSE(delegate.stored_group_success_);
- EXPECT_EQ(size_t(1), storage->stored_caches_.size());
- EXPECT_EQ(size_t(1), storage->stored_groups_.size());
- EXPECT_TRUE(storage->IsCacheStored(old_cache.get()));
- EXPECT_FALSE(storage->IsCacheStored(new_cache.get()));
- base::RunLoop().RunUntilIdle(); // Do async task execution.
- EXPECT_TRUE(delegate.stored_group_success_);
- EXPECT_EQ(size_t(1), storage->stored_caches_.size());
- EXPECT_EQ(size_t(1), storage->stored_groups_.size());
- EXPECT_FALSE(storage->IsCacheStored(old_cache.get()));
- EXPECT_TRUE(storage->IsCacheStored(new_cache.get()));
- EXPECT_EQ(new_cache.get(), group->newest_complete_cache());
- EXPECT_TRUE(new_cache->is_complete());
-}
-
-TEST_F(MockAppCacheStorageTest, StoreExistingGroupExistingCache) {
- // Store a group with updates to its existing newest complete cache.
- MockAppCacheService service;
- MockAppCacheStorage* storage =
- reinterpret_cast<MockAppCacheStorage*>(service.storage());
-
- // Setup some preconditions. Create a group and a complete cache that
- // appear to be "stored".
- GURL manifest_url("http://blah");
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service.storage(), manifest_url, 111));
- int64 cache_id = storage->NewCacheId();
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id));
- cache->set_complete(true);
- group->AddCache(cache.get());
- storage->AddStoredGroup(group.get());
- storage->AddStoredCache(cache.get());
- // Hold our refs to simulate the UpdateJob holding these refs.
-
- // Change the group's newest cache.
- EXPECT_EQ(cache, group->newest_complete_cache());
- GURL entry_url("http://blah/blah");
- cache->AddEntry(entry_url, AppCacheEntry(AppCacheEntry::MASTER));
-
- // Conduct the test.
- MockStorageDelegate delegate;
- EXPECT_EQ(size_t(1), storage->stored_caches_.size());
- EXPECT_EQ(size_t(1), storage->stored_groups_.size());
- EXPECT_TRUE(storage->IsCacheStored(cache.get()));
- storage->StoreGroupAndNewestCache(group.get(), cache.get(), &delegate);
- EXPECT_FALSE(delegate.stored_group_success_);
- EXPECT_EQ(size_t(1), storage->stored_caches_.size());
- EXPECT_EQ(size_t(1), storage->stored_groups_.size());
- base::RunLoop().RunUntilIdle(); // Do async task execution.
- EXPECT_TRUE(delegate.stored_group_success_);
- EXPECT_EQ(size_t(1), storage->stored_caches_.size());
- EXPECT_EQ(size_t(1), storage->stored_groups_.size());
- EXPECT_TRUE(storage->IsCacheStored(cache.get()));
- EXPECT_EQ(cache, group->newest_complete_cache());
- EXPECT_TRUE(cache->GetEntry(entry_url));
-}
-
-TEST_F(MockAppCacheStorageTest, MakeGroupObsolete) {
- // Make a group obsolete, should complete asyncly.
- MockAppCacheService service;
- MockAppCacheStorage* storage =
- reinterpret_cast<MockAppCacheStorage*>(service.storage());
-
- // Setup some preconditions. Create a group and newest cache that
- // appears to be "stored" and "currently in use".
- GURL manifest_url("http://blah/");
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service.storage(), manifest_url, 111));
- int64 cache_id = storage->NewCacheId();
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id));
- cache->set_complete(true);
- group->AddCache(cache.get());
- storage->AddStoredGroup(group.get());
- storage->AddStoredCache(cache.get());
- // Hold our refs to simulate the UpdateJob holding these refs.
-
- // Conduct the test.
- MockStorageDelegate delegate;
- EXPECT_FALSE(group->is_obsolete());
- EXPECT_EQ(size_t(1), storage->stored_caches_.size());
- EXPECT_EQ(size_t(1), storage->stored_groups_.size());
- EXPECT_FALSE(cache->HasOneRef());
- EXPECT_FALSE(group->HasOneRef());
- storage->MakeGroupObsolete(group.get(), &delegate);
- EXPECT_FALSE(group->is_obsolete());
- EXPECT_EQ(size_t(1), storage->stored_caches_.size());
- EXPECT_EQ(size_t(1), storage->stored_groups_.size());
- EXPECT_FALSE(cache->HasOneRef());
- EXPECT_FALSE(group->HasOneRef());
- base::RunLoop().RunUntilIdle(); // Do async task execution.
- EXPECT_TRUE(delegate.obsoleted_success_);
- EXPECT_EQ(group.get(), delegate.obsoleted_group_.get());
- EXPECT_TRUE(group->is_obsolete());
- EXPECT_TRUE(storage->stored_caches_.empty());
- EXPECT_TRUE(storage->stored_groups_.empty());
- EXPECT_TRUE(cache->HasOneRef());
- EXPECT_FALSE(group->HasOneRef());
- delegate.obsoleted_group_ = NULL;
- cache = NULL;
- EXPECT_TRUE(group->HasOneRef());
-}
-
-TEST_F(MockAppCacheStorageTest, MarkEntryAsForeign) {
- // Should complete syncly.
- MockAppCacheService service;
- MockAppCacheStorage* storage =
- reinterpret_cast<MockAppCacheStorage*>(service.storage());
-
- // Setup some preconditions. Create a cache with an entry.
- GURL entry_url("http://blah/entry");
- int64 cache_id = storage->NewCacheId();
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), cache_id));
- cache->AddEntry(entry_url, AppCacheEntry(AppCacheEntry::EXPLICIT));
-
- // Conduct the test.
- MockStorageDelegate delegate;
- EXPECT_FALSE(cache->GetEntry(entry_url)->IsForeign());
- storage->MarkEntryAsForeign(entry_url, cache_id);
- EXPECT_TRUE(cache->GetEntry(entry_url)->IsForeign());
- EXPECT_TRUE(cache->GetEntry(entry_url)->IsExplicit());
-}
-
-TEST_F(MockAppCacheStorageTest, FindNoMainResponse) {
- // Should complete asyncly.
- MockAppCacheService service;
- MockAppCacheStorage* storage =
- reinterpret_cast<MockAppCacheStorage*>(service.storage());
-
- // Conduct the test.
- MockStorageDelegate delegate;
- GURL url("http://blah/some_url");
- EXPECT_NE(url, delegate.found_url_);
- storage->FindResponseForMainRequest(url, GURL(), &delegate);
- EXPECT_NE(url, delegate.found_url_);
- base::RunLoop().RunUntilIdle(); // Do async task execution.
- EXPECT_EQ(url, delegate.found_url_);
- EXPECT_TRUE(delegate.found_manifest_url_.is_empty());
- EXPECT_EQ(kNoCacheId, delegate.found_cache_id_);
- EXPECT_EQ(kNoResponseId, delegate.found_entry_.response_id());
- EXPECT_EQ(kNoResponseId, delegate.found_fallback_entry_.response_id());
- EXPECT_TRUE(delegate.found_fallback_url_.is_empty());
- EXPECT_EQ(0, delegate.found_entry_.types());
- EXPECT_EQ(0, delegate.found_fallback_entry_.types());
-}
-
-TEST_F(MockAppCacheStorageTest, BasicFindMainResponse) {
- // Should complete asyncly.
- MockAppCacheService service;
- MockAppCacheStorage* storage =
- reinterpret_cast<MockAppCacheStorage*>(service.storage());
-
- // Setup some preconditions. Create a complete cache with an entry.
- const int64 kCacheId = storage->NewCacheId();
- const GURL kEntryUrl("http://blah/entry");
- const GURL kManifestUrl("http://blah/manifest");
- const int64 kResponseId = 1;
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId));
- cache->AddEntry(
- kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, kResponseId));
- cache->set_complete(true);
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service.storage(), kManifestUrl, 111));
- group->AddCache(cache.get());
- storage->AddStoredGroup(group.get());
- storage->AddStoredCache(cache.get());
-
- // Conduct the test.
- MockStorageDelegate delegate;
- EXPECT_NE(kEntryUrl, delegate.found_url_);
- storage->FindResponseForMainRequest(kEntryUrl, GURL(), &delegate);
- EXPECT_NE(kEntryUrl, delegate.found_url_);
- base::RunLoop().RunUntilIdle(); // Do async task execution.
- EXPECT_EQ(kEntryUrl, delegate.found_url_);
- EXPECT_EQ(kManifestUrl, delegate.found_manifest_url_);
- EXPECT_EQ(kCacheId, delegate.found_cache_id_);
- EXPECT_EQ(kResponseId, delegate.found_entry_.response_id());
- EXPECT_TRUE(delegate.found_entry_.IsExplicit());
- EXPECT_FALSE(delegate.found_fallback_entry_.has_response_id());
-}
-
-TEST_F(MockAppCacheStorageTest, BasicFindMainFallbackResponse) {
- // Should complete asyncly.
- MockAppCacheService service;
- MockAppCacheStorage* storage =
- reinterpret_cast<MockAppCacheStorage*>(service.storage());
-
- // Setup some preconditions. Create a complete cache with a
- // fallback namespace and entry.
- const int64 kCacheId = storage->NewCacheId();
- const GURL kFallbackEntryUrl1("http://blah/fallback_entry1");
- const GURL kFallbackNamespaceUrl1("http://blah/fallback_namespace/");
- const GURL kFallbackEntryUrl2("http://blah/fallback_entry2");
- const GURL kFallbackNamespaceUrl2("http://blah/fallback_namespace/longer");
- const GURL kManifestUrl("http://blah/manifest");
- const int64 kResponseId1 = 1;
- const int64 kResponseId2 = 2;
-
- Manifest manifest;
- manifest.fallback_namespaces.push_back(
- Namespace(FALLBACK_NAMESPACE, kFallbackNamespaceUrl1,
- kFallbackEntryUrl1, false));
- manifest.fallback_namespaces.push_back(
- Namespace(FALLBACK_NAMESPACE, kFallbackNamespaceUrl2,
- kFallbackEntryUrl2, false));
-
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId));
- cache->InitializeWithManifest(&manifest);
- cache->AddEntry(kFallbackEntryUrl1,
- AppCacheEntry(AppCacheEntry::FALLBACK, kResponseId1));
- cache->AddEntry(kFallbackEntryUrl2,
- AppCacheEntry(AppCacheEntry::FALLBACK, kResponseId2));
- cache->set_complete(true);
-
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service.storage(), kManifestUrl, 111));
- group->AddCache(cache.get());
- storage->AddStoredGroup(group.get());
- storage->AddStoredCache(cache.get());
-
- // The test url is in both fallback namespace urls, but should match
- // the longer of the two.
- const GURL kTestUrl("http://blah/fallback_namespace/longer/test");
-
- // Conduct the test.
- MockStorageDelegate delegate;
- EXPECT_NE(kTestUrl, delegate.found_url_);
- storage->FindResponseForMainRequest(kTestUrl, GURL(), &delegate);
- EXPECT_NE(kTestUrl, delegate.found_url_);
- base::RunLoop().RunUntilIdle(); // Do async task execution.
- EXPECT_EQ(kTestUrl, delegate.found_url_);
- EXPECT_EQ(kManifestUrl, delegate.found_manifest_url_);
- EXPECT_EQ(kCacheId, delegate.found_cache_id_);
- EXPECT_FALSE(delegate.found_entry_.has_response_id());
- EXPECT_EQ(kResponseId2, delegate.found_fallback_entry_.response_id());
- EXPECT_EQ(kFallbackEntryUrl2, delegate.found_fallback_url_);
- EXPECT_TRUE(delegate.found_fallback_entry_.IsFallback());
-}
-
-TEST_F(MockAppCacheStorageTest, FindMainResponseWithMultipleCandidates) {
- // Should complete asyncly.
- MockAppCacheService service;
- MockAppCacheStorage* storage =
- reinterpret_cast<MockAppCacheStorage*>(service.storage());
-
- // Setup some preconditions. Create 2 complete caches with an entry
- // for the same url.
-
- const GURL kEntryUrl("http://blah/entry");
- const int64 kCacheId1 = storage->NewCacheId();
- const int64 kCacheId2 = storage->NewCacheId();
- const GURL kManifestUrl1("http://blah/manifest1");
- const GURL kManifestUrl2("http://blah/manifest2");
- const int64 kResponseId1 = 1;
- const int64 kResponseId2 = 2;
-
- // The first cache.
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId1));
- cache->AddEntry(
- kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, kResponseId1));
- cache->set_complete(true);
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service.storage(), kManifestUrl1, 111));
- group->AddCache(cache.get());
- storage->AddStoredGroup(group.get());
- storage->AddStoredCache(cache.get());
- // Drop our references to cache1 so it appears as "not in use".
- cache = NULL;
- group = NULL;
-
- // The second cache.
- cache = new AppCache(service.storage(), kCacheId2);
- cache->AddEntry(
- kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, kResponseId2));
- cache->set_complete(true);
- group = new AppCacheGroup(service.storage(), kManifestUrl2, 222);
- group->AddCache(cache.get());
- storage->AddStoredGroup(group.get());
- storage->AddStoredCache(cache.get());
-
- // Conduct the test, we should find the response from the second cache
- // since it's "in use".
- MockStorageDelegate delegate;
- EXPECT_NE(kEntryUrl, delegate.found_url_);
- storage->FindResponseForMainRequest(kEntryUrl, GURL(), &delegate);
- EXPECT_NE(kEntryUrl, delegate.found_url_);
- base::RunLoop().RunUntilIdle(); // Do async task execution.
- EXPECT_EQ(kEntryUrl, delegate.found_url_);
- EXPECT_EQ(kManifestUrl2, delegate.found_manifest_url_);
- EXPECT_EQ(kCacheId2, delegate.found_cache_id_);
- EXPECT_EQ(kResponseId2, delegate.found_entry_.response_id());
- EXPECT_TRUE(delegate.found_entry_.IsExplicit());
- EXPECT_FALSE(delegate.found_fallback_entry_.has_response_id());
-}
-
-TEST_F(MockAppCacheStorageTest, FindMainResponseExclusions) {
- // Should complete asyncly.
- MockAppCacheService service;
- MockAppCacheStorage* storage =
- reinterpret_cast<MockAppCacheStorage*>(service.storage());
-
- // Setup some preconditions. Create a complete cache with a
- // foreign entry and an online namespace.
-
- const int64 kCacheId = storage->NewCacheId();
- const GURL kEntryUrl("http://blah/entry");
- const GURL kManifestUrl("http://blah/manifest");
- const GURL kOnlineNamespaceUrl("http://blah/online_namespace");
- const int64 kResponseId = 1;
-
- Manifest manifest;
- manifest.online_whitelist_namespaces.push_back(
- Namespace(NETWORK_NAMESPACE, kOnlineNamespaceUrl,
- GURL(), false));
- scoped_refptr<AppCache> cache(new AppCache(service.storage(), kCacheId));
- cache->InitializeWithManifest(&manifest);
- cache->AddEntry(
- kEntryUrl,
- AppCacheEntry(AppCacheEntry::EXPLICIT | AppCacheEntry::FOREIGN,
- kResponseId));
- cache->set_complete(true);
- scoped_refptr<AppCacheGroup> group(
- new AppCacheGroup(service.storage(), kManifestUrl, 111));
- group->AddCache(cache.get());
- storage->AddStoredGroup(group.get());
- storage->AddStoredCache(cache.get());
-
- MockStorageDelegate delegate;
-
- // We should not find anything for the foreign entry.
- EXPECT_NE(kEntryUrl, delegate.found_url_);
- storage->FindResponseForMainRequest(kEntryUrl, GURL(), &delegate);
- EXPECT_NE(kEntryUrl, delegate.found_url_);
- base::RunLoop().RunUntilIdle(); // Do async task execution.
- EXPECT_EQ(kEntryUrl, delegate.found_url_);
- EXPECT_TRUE(delegate.found_manifest_url_.is_empty());
- EXPECT_EQ(kNoCacheId, delegate.found_cache_id_);
- EXPECT_EQ(kNoResponseId, delegate.found_entry_.response_id());
- EXPECT_EQ(kNoResponseId, delegate.found_fallback_entry_.response_id());
- EXPECT_TRUE(delegate.found_fallback_url_.is_empty());
- EXPECT_EQ(0, delegate.found_entry_.types());
- EXPECT_EQ(0, delegate.found_fallback_entry_.types());
-
- // We should not find anything for the online namespace.
- EXPECT_NE(kOnlineNamespaceUrl, delegate.found_url_);
- storage->FindResponseForMainRequest(kOnlineNamespaceUrl, GURL(), &delegate);
- EXPECT_NE(kOnlineNamespaceUrl, delegate.found_url_);
- base::RunLoop().RunUntilIdle(); // Do async task execution.
- EXPECT_EQ(kOnlineNamespaceUrl, delegate.found_url_);
- EXPECT_TRUE(delegate.found_manifest_url_.is_empty());
- EXPECT_EQ(kNoCacheId, delegate.found_cache_id_);
- EXPECT_EQ(kNoResponseId, delegate.found_entry_.response_id());
- EXPECT_EQ(kNoResponseId, delegate.found_fallback_entry_.response_id());
- EXPECT_TRUE(delegate.found_fallback_url_.is_empty());
- EXPECT_EQ(0, delegate.found_entry_.types());
- EXPECT_EQ(0, delegate.found_fallback_entry_.types());
-}
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/view_appcache_internals_job.cc b/chromium/webkit/browser/appcache/view_appcache_internals_job.cc
deleted file mode 100644
index 8867b75fda2..00000000000
--- a/chromium/webkit/browser/appcache/view_appcache_internals_job.cc
+++ /dev/null
@@ -1,670 +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 "webkit/browser/appcache/view_appcache_internals_job.h"
-
-#include <algorithm>
-#include <string>
-
-#include "base/base64.h"
-#include "base/bind.h"
-#include "base/format_macros.h"
-#include "base/i18n/time_formatting.h"
-#include "base/logging.h"
-#include "base/memory/weak_ptr.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
-#include "base/strings/utf_string_conversions.h"
-#include "net/base/escape.h"
-#include "net/base/io_buffer.h"
-#include "net/base/net_errors.h"
-#include "net/http/http_response_headers.h"
-#include "net/url_request/url_request.h"
-#include "net/url_request/url_request_simple_job.h"
-#include "net/url_request/view_cache_helper.h"
-#include "webkit/browser/appcache/appcache.h"
-#include "webkit/browser/appcache/appcache_group.h"
-#include "webkit/browser/appcache/appcache_policy.h"
-#include "webkit/browser/appcache/appcache_response.h"
-#include "webkit/browser/appcache/appcache_service.h"
-
-namespace appcache {
-namespace {
-
-const char kErrorMessage[] = "Error in retrieving Application Caches.";
-const char kEmptyAppCachesMessage[] = "No available Application Caches.";
-const char kManifestNotFoundMessage[] = "Manifest not found.";
-const char kManifest[] = "Manifest: ";
-const char kSize[] = "Size: ";
-const char kCreationTime[] = "Creation Time: ";
-const char kLastAccessTime[] = "Last Access Time: ";
-const char kLastUpdateTime[] = "Last Update Time: ";
-const char kFormattedDisabledAppCacheMsg[] =
- "<b><i><font color=\"FF0000\">"
- "This Application Cache is disabled by policy.</font></i></b><br/>";
-const char kRemoveCacheLabel[] = "Remove";
-const char kViewCacheLabel[] = "View Entries";
-const char kRemoveCacheCommand[] = "remove-cache";
-const char kViewCacheCommand[] = "view-cache";
-const char kViewEntryCommand[] = "view-entry";
-
-void EmitPageStart(std::string* out) {
- out->append(
- "<!DOCTYPE HTML>\n"
- "<html><title>AppCache Internals</title>\n"
- "<meta http-equiv=\"Content-Security-Policy\""
- " content=\"object-src 'none'; script-src 'none'\">\n"
- "<style>\n"
- "body { font-family: sans-serif; font-size: 0.8em; }\n"
- "tt, code, pre { font-family: WebKitHack, monospace; }\n"
- "form { display: inline; }\n"
- ".subsection_body { margin: 10px 0 10px 2em; }\n"
- ".subsection_title { font-weight: bold; }\n"
- "</style>\n"
- "</head><body>\n");
-}
-
-void EmitPageEnd(std::string* out) {
- out->append("</body></html>\n");
-}
-
-void EmitListItem(const std::string& label,
- const std::string& data,
- std::string* out) {
- out->append("<li>");
- out->append(net::EscapeForHTML(label));
- out->append(net::EscapeForHTML(data));
- out->append("</li>\n");
-}
-
-void EmitAnchor(const std::string& url, const std::string& text,
- std::string* out) {
- out->append("<a href=\"");
- out->append(net::EscapeForHTML(url));
- out->append("\">");
- out->append(net::EscapeForHTML(text));
- out->append("</a>");
-}
-
-void EmitCommandAnchor(const char* label,
- const GURL& base_url,
- const char* command,
- const char* param,
- std::string* out) {
- std::string query(command);
- query.push_back('=');
- query.append(param);
- GURL::Replacements replacements;
- replacements.SetQuery(query.data(),
- url_parse::Component(0, query.length()));
- GURL command_url = base_url.ReplaceComponents(replacements);
- EmitAnchor(command_url.spec(), label, out);
-}
-
-void EmitAppCacheInfo(const GURL& base_url,
- AppCacheService* service,
- const AppCacheInfo* info,
- std::string* out) {
- std::string manifest_url_base64;
- base::Base64Encode(info->manifest_url.spec(), &manifest_url_base64);
-
- out->append("\n<p>");
- out->append(kManifest);
- EmitAnchor(info->manifest_url.spec(), info->manifest_url.spec(), out);
- out->append("<br/>\n");
- if (!service->appcache_policy()->CanLoadAppCache(
- info->manifest_url, info->manifest_url)) {
- out->append(kFormattedDisabledAppCacheMsg);
- }
- out->append("\n<br/>\n");
- EmitCommandAnchor(kRemoveCacheLabel, base_url,
- kRemoveCacheCommand, manifest_url_base64.c_str(), out);
- out->append("&nbsp;&nbsp;");
- EmitCommandAnchor(kViewCacheLabel, base_url,
- kViewCacheCommand, manifest_url_base64.c_str(), out);
- out->append("\n<br/>\n");
- out->append("<ul>");
- EmitListItem(
- kSize,
- UTF16ToUTF8(FormatBytesUnlocalized(info->size)),
- out);
- EmitListItem(
- kCreationTime,
- UTF16ToUTF8(TimeFormatFriendlyDateAndTime(info->creation_time)),
- out);
- EmitListItem(
- kLastUpdateTime,
- UTF16ToUTF8(TimeFormatFriendlyDateAndTime(info->last_update_time)),
- out);
- EmitListItem(
- kLastAccessTime,
- UTF16ToUTF8(TimeFormatFriendlyDateAndTime(info->last_access_time)),
- out);
- out->append("</ul></p></br>\n");
-}
-
-void EmitAppCacheInfoVector(
- const GURL& base_url,
- AppCacheService* service,
- const AppCacheInfoVector& appcaches,
- std::string* out) {
- for (std::vector<AppCacheInfo>::const_iterator info =
- appcaches.begin();
- info != appcaches.end(); ++info) {
- EmitAppCacheInfo(base_url, service, &(*info), out);
- }
-}
-
-void EmitTableData(const std::string& data, bool align_right, bool bold,
- std::string* out) {
- if (align_right)
- out->append("<td align='right'>");
- else
- out->append("<td>");
- if (bold)
- out->append("<b>");
- out->append(data);
- if (bold)
- out->append("</b>");
- out->append("</td>");
-}
-
-std::string FormFlagsString(const AppCacheResourceInfo& info) {
- std::string str;
- if (info.is_manifest)
- str.append("Manifest, ");
- if (info.is_master)
- str.append("Master, ");
- if (info.is_intercept)
- str.append("Intercept, ");
- if (info.is_fallback)
- str.append("Fallback, ");
- if (info.is_explicit)
- str.append("Explicit, ");
- if (info.is_foreign)
- str.append("Foreign, ");
- return str;
-}
-
-std::string FormViewEntryAnchor(const GURL& base_url,
- const GURL& manifest_url, const GURL& entry_url,
- int64 response_id,
- int64 group_id) {
- std::string manifest_url_base64;
- std::string entry_url_base64;
- std::string response_id_string;
- std::string group_id_string;
- base::Base64Encode(manifest_url.spec(), &manifest_url_base64);
- base::Base64Encode(entry_url.spec(), &entry_url_base64);
- response_id_string = base::Int64ToString(response_id);
- group_id_string = base::Int64ToString(group_id);
-
- std::string query(kViewEntryCommand);
- query.push_back('=');
- query.append(manifest_url_base64);
- query.push_back('|');
- query.append(entry_url_base64);
- query.push_back('|');
- query.append(response_id_string);
- query.push_back('|');
- query.append(group_id_string);
-
- GURL::Replacements replacements;
- replacements.SetQuery(query.data(),
- url_parse::Component(0, query.length()));
- GURL view_entry_url = base_url.ReplaceComponents(replacements);
-
- std::string anchor;
- EmitAnchor(view_entry_url.spec(), entry_url.spec(), &anchor);
- return anchor;
-}
-
-void EmitAppCacheResourceInfoVector(
- const GURL& base_url,
- const GURL& manifest_url,
- const AppCacheResourceInfoVector& resource_infos,
- int64 group_id,
- std::string* out) {
- out->append("<table border='0'>\n");
- out->append("<tr>");
- EmitTableData("Flags", false, true, out);
- EmitTableData("URL", false, true, out);
- EmitTableData("Size (headers and data)", true, true, out);
- out->append("</tr>\n");
- for (AppCacheResourceInfoVector::const_iterator
- iter = resource_infos.begin();
- iter != resource_infos.end(); ++iter) {
- out->append("<tr>");
- EmitTableData(FormFlagsString(*iter), false, false, out);
- EmitTableData(FormViewEntryAnchor(base_url, manifest_url,
- iter->url, iter->response_id,
- group_id),
- false, false, out);
- EmitTableData(UTF16ToUTF8(FormatBytesUnlocalized(iter->size)),
- true, false, out);
- out->append("</tr>\n");
- }
- out->append("</table>\n");
-}
-
-void EmitResponseHeaders(net::HttpResponseHeaders* headers, std::string* out) {
- out->append("<hr><pre>");
- out->append(net::EscapeForHTML(headers->GetStatusLine()));
- out->push_back('\n');
-
- void* iter = NULL;
- std::string name, value;
- while (headers->EnumerateHeaderLines(&iter, &name, &value)) {
- out->append(net::EscapeForHTML(name));
- out->append(": ");
- out->append(net::EscapeForHTML(value));
- out->push_back('\n');
- }
- out->append("</pre>");
-}
-
-void EmitHexDump(const char *buf, size_t buf_len, size_t total_len,
- std::string* out) {
- out->append("<hr><pre>");
- base::StringAppendF(out, "Showing %d of %d bytes\n\n",
- static_cast<int>(buf_len), static_cast<int>(total_len));
- net::ViewCacheHelper::HexDump(buf, buf_len, out);
- if (buf_len < total_len)
- out->append("\nNote: data is truncated...");
- out->append("</pre>");
-}
-
-GURL DecodeBase64URL(const std::string& base64) {
- std::string url;
- base::Base64Decode(base64, &url);
- return GURL(url);
-}
-
-bool ParseQuery(const std::string& query,
- std::string* command, std::string* value) {
- size_t position = query.find("=");
- if (position == std::string::npos)
- return false;
- *command = query.substr(0, position);
- *value = query.substr(position + 1);
- return !command->empty() && !value->empty();
-}
-
-bool SortByManifestUrl(const AppCacheInfo& lhs,
- const AppCacheInfo& rhs) {
- return lhs.manifest_url.spec() < rhs.manifest_url.spec();
-}
-
-bool SortByResourceUrl(const AppCacheResourceInfo& lhs,
- const AppCacheResourceInfo& rhs) {
- return lhs.url.spec() < rhs.url.spec();
-}
-
-GURL ClearQuery(const GURL& url) {
- GURL::Replacements replacements;
- replacements.ClearQuery();
- return url.ReplaceComponents(replacements);
-}
-
-// Simple base class for the job subclasses defined here.
-class BaseInternalsJob : public net::URLRequestSimpleJob,
- public AppCacheService::Observer {
- protected:
- BaseInternalsJob(net::URLRequest* request,
- net::NetworkDelegate* network_delegate,
- AppCacheService* service)
- : URLRequestSimpleJob(request, network_delegate),
- appcache_service_(service),
- appcache_storage_(service->storage()) {
- appcache_service_->AddObserver(this);
- }
-
- virtual ~BaseInternalsJob() {
- appcache_service_->RemoveObserver(this);
- }
-
- virtual void OnServiceReinitialized(
- AppCacheStorageReference* old_storage_ref) OVERRIDE {
- if (old_storage_ref->storage() == appcache_storage_)
- disabled_storage_reference_ = old_storage_ref;
- }
-
- AppCacheService* appcache_service_;
- AppCacheStorage* appcache_storage_;
- scoped_refptr<AppCacheStorageReference> disabled_storage_reference_;
-};
-
-// Job that lists all appcaches in the system.
-class MainPageJob : public BaseInternalsJob {
- public:
- MainPageJob(net::URLRequest* request,
- net::NetworkDelegate* network_delegate,
- AppCacheService* service)
- : BaseInternalsJob(request, network_delegate, service),
- weak_factory_(this) {
- }
-
- virtual void Start() OVERRIDE {
- DCHECK(request_);
- info_collection_ = new AppCacheInfoCollection;
- appcache_service_->GetAllAppCacheInfo(
- info_collection_.get(),
- base::Bind(&MainPageJob::OnGotInfoComplete,
- weak_factory_.GetWeakPtr()));
- }
-
- // Produces a page containing the listing
- virtual int GetData(std::string* mime_type,
- std::string* charset,
- std::string* out,
- const net::CompletionCallback& callback) const OVERRIDE {
- mime_type->assign("text/html");
- charset->assign("UTF-8");
-
- out->clear();
- EmitPageStart(out);
- if (!info_collection_.get()) {
- out->append(kErrorMessage);
- } else if (info_collection_->infos_by_origin.empty()) {
- out->append(kEmptyAppCachesMessage);
- } else {
- typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin;
- AppCacheInfoVector appcaches;
- for (InfoByOrigin::const_iterator origin =
- info_collection_->infos_by_origin.begin();
- origin != info_collection_->infos_by_origin.end(); ++origin) {
- appcaches.insert(appcaches.end(),
- origin->second.begin(), origin->second.end());
- }
- std::sort(appcaches.begin(), appcaches.end(), SortByManifestUrl);
-
- GURL base_url = ClearQuery(request_->url());
- EmitAppCacheInfoVector(base_url, appcache_service_, appcaches, out);
- }
- EmitPageEnd(out);
- return net::OK;
- }
-
- private:
- virtual ~MainPageJob() {}
-
- void OnGotInfoComplete(int rv) {
- if (rv != net::OK)
- info_collection_ = NULL;
- StartAsync();
- }
-
- scoped_refptr<AppCacheInfoCollection> info_collection_;
- base::WeakPtrFactory<MainPageJob> weak_factory_;
- DISALLOW_COPY_AND_ASSIGN(MainPageJob);
-};
-
-// Job that redirects back to the main appcache internals page.
-class RedirectToMainPageJob : public BaseInternalsJob {
- public:
- RedirectToMainPageJob(net::URLRequest* request,
- net::NetworkDelegate* network_delegate,
- AppCacheService* service)
- : BaseInternalsJob(request, network_delegate, service) {}
-
- virtual int GetData(std::string* mime_type,
- std::string* charset,
- std::string* data,
- const net::CompletionCallback& callback) const OVERRIDE {
- return net::OK; // IsRedirectResponse induces a redirect.
- }
-
- virtual bool IsRedirectResponse(GURL* location,
- int* http_status_code) OVERRIDE {
- *location = ClearQuery(request_->url());
- *http_status_code = 307;
- return true;
- }
-
- protected:
- virtual ~RedirectToMainPageJob() {}
-};
-
-// Job that removes an appcache and then redirects back to the main page.
-class RemoveAppCacheJob : public RedirectToMainPageJob {
- public:
- RemoveAppCacheJob(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate,
- AppCacheService* service,
- const GURL& manifest_url)
- : RedirectToMainPageJob(request, network_delegate, service),
- manifest_url_(manifest_url),
- weak_factory_(this) {
- }
-
- virtual void Start() OVERRIDE {
- DCHECK(request_);
-
- appcache_service_->DeleteAppCacheGroup(
- manifest_url_,base::Bind(&RemoveAppCacheJob::OnDeleteAppCacheComplete,
- weak_factory_.GetWeakPtr()));
- }
-
- private:
- virtual ~RemoveAppCacheJob() {}
-
- void OnDeleteAppCacheComplete(int rv) {
- StartAsync(); // Causes the base class to redirect.
- }
-
- GURL manifest_url_;
- base::WeakPtrFactory<RemoveAppCacheJob> weak_factory_;
-};
-
-
-// Job shows the details of a particular manifest url.
-class ViewAppCacheJob : public BaseInternalsJob,
- public AppCacheStorage::Delegate {
- public:
- ViewAppCacheJob(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate,
- AppCacheService* service,
- const GURL& manifest_url)
- : BaseInternalsJob(request, network_delegate, service),
- manifest_url_(manifest_url) {}
-
- virtual void Start() OVERRIDE {
- DCHECK(request_);
- appcache_storage_->LoadOrCreateGroup(manifest_url_, this);
- }
-
- // Produces a page containing the entries listing.
- virtual int GetData(std::string* mime_type,
- std::string* charset,
- std::string* out,
- const net::CompletionCallback& callback) const OVERRIDE {
- mime_type->assign("text/html");
- charset->assign("UTF-8");
- out->clear();
- EmitPageStart(out);
- if (appcache_info_.manifest_url.is_empty()) {
- out->append(kManifestNotFoundMessage);
- } else {
- GURL base_url = ClearQuery(request_->url());
- EmitAppCacheInfo(base_url, appcache_service_, &appcache_info_, out);
- EmitAppCacheResourceInfoVector(base_url,
- manifest_url_,
- resource_infos_,
- appcache_info_.group_id,
- out);
- }
- EmitPageEnd(out);
- return net::OK;
- }
-
- private:
- virtual ~ViewAppCacheJob() {
- appcache_storage_->CancelDelegateCallbacks(this);
- }
-
- // AppCacheStorage::Delegate override
- virtual void OnGroupLoaded(
- AppCacheGroup* group, const GURL& manifest_url) OVERRIDE {
- DCHECK_EQ(manifest_url_, manifest_url);
- if (group && group->newest_complete_cache()) {
- appcache_info_.manifest_url = manifest_url;
- appcache_info_.group_id = group->group_id();
- appcache_info_.size = group->newest_complete_cache()->cache_size();
- appcache_info_.creation_time = group->creation_time();
- appcache_info_.last_update_time =
- group->newest_complete_cache()->update_time();
- appcache_info_.last_access_time = base::Time::Now();
- group->newest_complete_cache()->ToResourceInfoVector(&resource_infos_);
- std::sort(resource_infos_.begin(), resource_infos_.end(),
- SortByResourceUrl);
- }
- StartAsync();
- }
-
- GURL manifest_url_;
- AppCacheInfo appcache_info_;
- AppCacheResourceInfoVector resource_infos_;
- DISALLOW_COPY_AND_ASSIGN(ViewAppCacheJob);
-};
-
-// Job that shows the details of a particular cached resource.
-class ViewEntryJob : public BaseInternalsJob,
- public AppCacheStorage::Delegate {
- public:
- ViewEntryJob(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate,
- AppCacheService* service,
- const GURL& manifest_url,
- const GURL& entry_url,
- int64 response_id, int64 group_id)
- : BaseInternalsJob(request, network_delegate, service),
- manifest_url_(manifest_url), entry_url_(entry_url),
- response_id_(response_id), group_id_(group_id), amount_read_(0) {
- }
-
- virtual void Start() OVERRIDE {
- DCHECK(request_);
- appcache_storage_->LoadResponseInfo(
- manifest_url_, group_id_, response_id_, this);
- }
-
- // Produces a page containing the response headers and data.
- virtual int GetData(std::string* mime_type,
- std::string* charset,
- std::string* out,
- const net::CompletionCallback& callback) const OVERRIDE {
- mime_type->assign("text/html");
- charset->assign("UTF-8");
- out->clear();
- EmitPageStart(out);
- EmitAnchor(entry_url_.spec(), entry_url_.spec(), out);
- out->append("<br/>\n");
- if (response_info_.get()) {
- if (response_info_->http_response_info())
- EmitResponseHeaders(response_info_->http_response_info()->headers.get(),
- out);
- else
- out->append("Failed to read response headers.<br>");
-
- if (response_data_.get()) {
- EmitHexDump(response_data_->data(),
- amount_read_,
- response_info_->response_data_size(),
- out);
- } else {
- out->append("Failed to read response data.<br>");
- }
- } else {
- out->append("Failed to read response headers and data.<br>");
- }
- EmitPageEnd(out);
- return net::OK;
- }
-
- private:
- virtual ~ViewEntryJob() {
- appcache_storage_->CancelDelegateCallbacks(this);
- }
-
- virtual void OnResponseInfoLoaded(
- AppCacheResponseInfo* response_info, int64 response_id) OVERRIDE {
- if (!response_info) {
- StartAsync();
- return;
- }
- response_info_ = response_info;
-
- // Read the response data, truncating if its too large.
- const int64 kLimit = 100 * 1000;
- int64 amount_to_read =
- std::min(kLimit, response_info->response_data_size());
- response_data_ = new net::IOBuffer(amount_to_read);
-
- reader_.reset(appcache_storage_->CreateResponseReader(
- manifest_url_, group_id_, response_id_));
- reader_->ReadData(
- response_data_.get(),
- amount_to_read,
- base::Bind(&ViewEntryJob::OnReadComplete, base::Unretained(this)));
- }
-
- void OnReadComplete(int result) {
- reader_.reset();
- amount_read_ = result;
- if (result < 0)
- response_data_ = NULL;
- StartAsync();
- }
-
- GURL manifest_url_;
- GURL entry_url_;
- int64 response_id_;
- int64 group_id_;
- scoped_refptr<AppCacheResponseInfo> response_info_;
- scoped_refptr<net::IOBuffer> response_data_;
- int amount_read_;
- scoped_ptr<AppCacheResponseReader> reader_;
-};
-
-} // namespace
-
-net::URLRequestJob* ViewAppCacheInternalsJobFactory::CreateJobForRequest(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate,
- AppCacheService* service) {
- if (!request->url().has_query())
- return new MainPageJob(request, network_delegate, service);
-
- std::string command;
- std::string param;
- ParseQuery(request->url().query(), &command, &param);
-
- if (command == kRemoveCacheCommand)
- return new RemoveAppCacheJob(request, network_delegate, service,
- DecodeBase64URL(param));
-
- if (command == kViewCacheCommand)
- return new ViewAppCacheJob(request, network_delegate, service,
- DecodeBase64URL(param));
-
- std::vector<std::string> tokens;
- int64 response_id;
- int64 group_id;
- if (command == kViewEntryCommand && Tokenize(param, "|", &tokens) == 4u &&
- base::StringToInt64(tokens[2], &response_id) &&
- base::StringToInt64(tokens[3], &group_id)) {
- return new ViewEntryJob(request, network_delegate, service,
- DecodeBase64URL(tokens[0]), // manifest url
- DecodeBase64URL(tokens[1]), // entry url
- response_id, group_id);
- }
-
- return new RedirectToMainPageJob(request, network_delegate, service);
-}
-
-} // namespace appcache
diff --git a/chromium/webkit/browser/appcache/view_appcache_internals_job.h b/chromium/webkit/browser/appcache/view_appcache_internals_job.h
deleted file mode 100644
index d247c3ea6a8..00000000000
--- a/chromium/webkit/browser/appcache/view_appcache_internals_job.h
+++ /dev/null
@@ -1,34 +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.
-
-#ifndef WEBKIT_BROWSER_APPCACHE_VIEW_APPCACHE_INTERNALS_JOB_H_
-#define WEBKIT_BROWSER_APPCACHE_VIEW_APPCACHE_INTERNALS_JOB_H_
-
-#include "base/basictypes.h"
-#include "webkit/browser/webkit_storage_browser_export.h"
-
-namespace net {
-class NetworkDelegate;
-class URLRequest;
-class URLRequestJob;
-}
-
-namespace appcache {
-
-class AppCacheService;
-
-class WEBKIT_STORAGE_BROWSER_EXPORT ViewAppCacheInternalsJobFactory {
- public:
- static net::URLRequestJob* CreateJobForRequest(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate,
- AppCacheService* service);
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(ViewAppCacheInternalsJobFactory);
-};
-
-} // namespace appcache
-
-#endif // WEBKIT_BROWSER_APPCACHE_VIEW_APPCACHE_INTERNALS_JOB_H_
diff --git a/chromium/webkit/browser/blob/blob_data_handle.cc b/chromium/webkit/browser/blob/blob_data_handle.cc
index fd0ae54db73..8ccba746c2b 100644
--- a/chromium/webkit/browser/blob/blob_data_handle.cc
+++ b/chromium/webkit/browser/blob/blob_data_handle.cc
@@ -13,44 +13,56 @@
namespace webkit_blob {
-BlobDataHandle::BlobDataHandle(BlobData* blob_data, BlobStorageContext* context,
- base::SequencedTaskRunner* task_runner)
+BlobDataHandle::BlobDataHandleShared::BlobDataHandleShared(
+ BlobData* blob_data,
+ BlobStorageContext* context,
+ base::SequencedTaskRunner* task_runner)
: blob_data_(blob_data),
- context_(context->AsWeakPtr()),
- io_task_runner_(task_runner) {
- // Ensures the uuid remains registered and the underlying data is not deleted.
- DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
+ context_(context->AsWeakPtr()) {
context_->IncrementBlobRefCount(blob_data->uuid());
- blob_data_->AddRef();
}
-BlobDataHandle::~BlobDataHandle() {
- if (io_task_runner_->RunsTasksOnCurrentThread()) {
- // Note: Do not test context_ or alter the blob_data_ refcount
- // on the wrong thread.
- if (context_.get())
- context_->DecrementBlobRefCount(blob_data_->uuid());
- blob_data_->Release();
- return;
- }
+BlobData* BlobDataHandle::BlobDataHandleShared::data() const {
+ return blob_data_;
+}
- io_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&DeleteHelper, context_, base::Unretained(blob_data_)));
+const std::string& BlobDataHandle::BlobDataHandleShared::uuid() const {
+ return blob_data_->uuid();
+}
+
+BlobDataHandle::BlobDataHandleShared::~BlobDataHandleShared() {
+ if (context_.get())
+ context_->DecrementBlobRefCount(blob_data_->uuid());
+}
+
+BlobDataHandle::BlobDataHandle(BlobData* blob_data,
+ BlobStorageContext* context,
+ base::SequencedTaskRunner* task_runner)
+ : io_task_runner_(task_runner),
+ shared_(new BlobDataHandleShared(blob_data, context, task_runner)) {
+ DCHECK(io_task_runner_);
+ DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
+}
+
+BlobDataHandle::BlobDataHandle(const BlobDataHandle& other) {
+ io_task_runner_ = other.io_task_runner_;
+ shared_ = other.shared_;
+}
+
+BlobDataHandle::~BlobDataHandle() {
+ BlobDataHandleShared* raw = shared_.get();
+ raw->AddRef();
+ shared_ = 0;
+ io_task_runner_->ReleaseSoon(FROM_HERE, raw);
}
BlobData* BlobDataHandle::data() const {
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
- return blob_data_;
+ return shared_->data();
}
-// static
-void BlobDataHandle::DeleteHelper(
- base::WeakPtr<BlobStorageContext> context,
- BlobData* blob_data) {
- if (context.get())
- context->DecrementBlobRefCount(blob_data->uuid());
- blob_data->Release();
+std::string BlobDataHandle::uuid() const {
+ return shared_->uuid();
}
} // namespace webkit_blob
diff --git a/chromium/webkit/browser/blob/blob_data_handle.h b/chromium/webkit/browser/blob/blob_data_handle.h
index 5f870f2731a..917a0b38e8e 100644
--- a/chromium/webkit/browser/blob/blob_data_handle.h
+++ b/chromium/webkit/browser/blob/blob_data_handle.h
@@ -28,23 +28,42 @@ class BlobStorageContext;
class WEBKIT_STORAGE_BROWSER_EXPORT BlobDataHandle
: public base::SupportsUserData::Data {
public:
+ BlobDataHandle(const BlobDataHandle& other); // May be copied on any thread.
virtual ~BlobDataHandle(); // Maybe be deleted on any thread.
BlobData* data() const; // May only be accessed on the IO thread.
+ std::string uuid() const; // May be accessed on any thread.
+
private:
+ class BlobDataHandleShared
+ : public base::RefCountedThreadSafe<BlobDataHandleShared> {
+ public:
+ BlobDataHandleShared(BlobData* blob_data,
+ BlobStorageContext* context,
+ base::SequencedTaskRunner* task_runner);
+
+ BlobData* data() const;
+ const std::string& uuid() const;
+
+ private:
+ friend class base::DeleteHelper<BlobDataHandleShared>;
+ friend class base::RefCountedThreadSafe<BlobDataHandleShared>;
+ friend class BlobDataHandle;
+
+ virtual ~BlobDataHandleShared();
+
+ scoped_refptr<BlobData> blob_data_;
+ base::WeakPtr<BlobStorageContext> context_;
+
+ DISALLOW_COPY_AND_ASSIGN(BlobDataHandleShared);
+ };
+
friend class BlobStorageContext;
BlobDataHandle(BlobData* blob_data, BlobStorageContext* context,
base::SequencedTaskRunner* task_runner);
- static void DeleteHelper(
- base::WeakPtr<BlobStorageContext> context,
- BlobData* blob_data);
-
- BlobData* blob_data_; // Intentionally a raw ptr to a non-thread-safe ref.
- base::WeakPtr<BlobStorageContext> context_;
scoped_refptr<base::SequencedTaskRunner> io_task_runner_;
-
- DISALLOW_COPY_AND_ASSIGN(BlobDataHandle);
+ scoped_refptr<BlobDataHandleShared> shared_;
};
} // namespace webkit_blob
diff --git a/chromium/webkit/browser/blob/blob_storage_context.h b/chromium/webkit/browser/blob/blob_storage_context.h
index 619e2830dbb..a753c59c3bb 100644
--- a/chromium/webkit/browser/blob/blob_storage_context.h
+++ b/chromium/webkit/browser/blob/blob_storage_context.h
@@ -22,6 +22,10 @@ class FilePath;
class Time;
}
+namespace content {
+class BlobStorageHost;
+}
+
namespace webkit_blob {
class BlobDataHandle;
@@ -48,8 +52,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT BlobStorageContext
void RevokePublicBlobURL(const GURL& url);
private:
- friend class BlobDataHandle;
- friend class BlobStorageHost;
+ friend class content::BlobStorageHost;
+ friend class BlobDataHandle::BlobDataHandleShared;
friend class ViewBlobInternalsJob;
enum EntryFlags {
@@ -101,7 +105,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT BlobStorageContext
BlobMap blob_map_;
BlobURLMap public_blob_urls_;
- // Used to keep track of how much memory is being utitlized for blob data,
+ // Used to keep track of how much memory is being utilized for blob data,
// we count only the items of TYPE_DATA which are held in memory and not
// items of TYPE_FILE.
int64 memory_usage_;
diff --git a/chromium/webkit/browser/blob/blob_storage_context_unittest.cc b/chromium/webkit/browser/blob/blob_storage_context_unittest.cc
deleted file mode 100644
index e2c115c21a1..00000000000
--- a/chromium/webkit/browser/blob/blob_storage_context_unittest.cc
+++ /dev/null
@@ -1,208 +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.
-
-#include "base/files/file_path.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "base/time/time.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/blob/blob_data_handle.h"
-#include "webkit/browser/blob/blob_storage_context.h"
-#include "webkit/browser/blob/blob_storage_host.h"
-
-namespace webkit_blob {
-
-namespace {
-void SetupBasicBlob(BlobStorageHost* host, const std::string& id) {
- EXPECT_TRUE(host->StartBuildingBlob(id));
- BlobData::Item item;
- item.SetToBytes("1", 1);
- EXPECT_TRUE(host->AppendBlobDataItem(id, item));
- EXPECT_TRUE(host->FinishBuildingBlob(id, "text/plain"));
- EXPECT_FALSE(host->StartBuildingBlob(id));
-}
-} // namespace
-
-TEST(BlobStorageContextTest, IncrementDecrementRef) {
- BlobStorageContext context;
- BlobStorageHost host(&context);
- base::MessageLoop fake_io_message_loop;
-
- // Build up a basic blob.
- const std::string kId("id");
- SetupBasicBlob(&host, kId);
-
- // Make sure it's there, finish building implies a ref of one.
- scoped_ptr<BlobDataHandle> blob_data_handle;
- blob_data_handle = context.GetBlobDataFromUUID(kId);
- EXPECT_TRUE(blob_data_handle);
- blob_data_handle.reset();
-
- // Make sure its still there after inc/dec.
- EXPECT_TRUE(host.IncrementBlobRefCount(kId));
- EXPECT_TRUE(host.DecrementBlobRefCount(kId));
- blob_data_handle = context.GetBlobDataFromUUID(kId);
- EXPECT_TRUE(blob_data_handle);
- blob_data_handle.reset();
-
- // Make sure it goes away in the end.
- EXPECT_TRUE(host.DecrementBlobRefCount(kId));
- blob_data_handle = context.GetBlobDataFromUUID(kId);
- EXPECT_FALSE(blob_data_handle);
- EXPECT_FALSE(host.DecrementBlobRefCount(kId));
- EXPECT_FALSE(host.IncrementBlobRefCount(kId));
-}
-
-TEST(BlobStorageContextTest, BlobDataHandle) {
- BlobStorageContext context;
- BlobStorageHost host(&context);
- base::MessageLoop fake_io_message_loop;
-
- // Build up a basic blob.
- const std::string kId("id");
- SetupBasicBlob(&host, kId);
-
- // Get a handle to it.
- scoped_ptr<BlobDataHandle> blob_data_handle =
- context.GetBlobDataFromUUID(kId);
- EXPECT_TRUE(blob_data_handle);
-
- // Drop the host's ref to it.
- EXPECT_TRUE(host.DecrementBlobRefCount(kId));
-
- // Should still be there due to the handle.
- scoped_ptr<BlobDataHandle> another_handle =
- context.GetBlobDataFromUUID(kId);
- EXPECT_TRUE(another_handle);
-
- // Should disappear after dropping both handles.
- blob_data_handle.reset();
- another_handle.reset();
- blob_data_handle = context.GetBlobDataFromUUID(kId);
- EXPECT_FALSE(blob_data_handle);
-}
-
-TEST(BlobStorageContextTest, CompoundBlobs) {
- const std::string kId1("id1");
- const std::string kId2("id2");
- const std::string kId2Prime("id2.prime");
-
- base::MessageLoop fake_io_message_loop;
-
- // Setup a set of blob data for testing.
- base::Time time1, time2;
- base::Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT", &time1);
- base::Time::FromString("Mon, 14 Nov 1994, 11:30:49 GMT", &time2);
-
- scoped_refptr<BlobData> blob_data1(new BlobData(kId1));
- blob_data1->AppendData("Data1");
- blob_data1->AppendData("Data2");
- blob_data1->AppendFile(base::FilePath(FILE_PATH_LITERAL("File1.txt")),
- 10, 1024, time1);
-
- scoped_refptr<BlobData> blob_data2(new BlobData(kId2));
- blob_data2->AppendData("Data3");
- blob_data2->AppendBlob(kId1, 8, 100);
- blob_data2->AppendFile(base::FilePath(FILE_PATH_LITERAL("File2.txt")),
- 0, 20, time2);
-
- scoped_refptr<BlobData> canonicalized_blob_data2(new BlobData(kId2Prime));
- canonicalized_blob_data2->AppendData("Data3");
- canonicalized_blob_data2->AppendData("a2___", 2);
- canonicalized_blob_data2->AppendFile(
- base::FilePath(FILE_PATH_LITERAL("File1.txt")),
- 10, 98, time1);
- canonicalized_blob_data2->AppendFile(
- base::FilePath(FILE_PATH_LITERAL("File2.txt")), 0, 20, time2);
-
- BlobStorageContext context;
- scoped_ptr<BlobDataHandle> blob_data_handle;
-
- // Test a blob referring to only data and a file.
- blob_data_handle = context.AddFinishedBlob(blob_data1.get());
- ASSERT_TRUE(blob_data_handle.get());
- EXPECT_TRUE(*(blob_data_handle->data()) == *blob_data1.get());
-
- // Test a blob composed in part with another blob.
- blob_data_handle = context.AddFinishedBlob(blob_data2.get());
- ASSERT_TRUE(blob_data_handle.get());
- EXPECT_TRUE(*(blob_data_handle->data()) == *canonicalized_blob_data2.get());
-}
-
-TEST(BlobStorageContextTest, PublicBlobUrls) {
- BlobStorageContext context;
- BlobStorageHost host(&context);
- base::MessageLoop fake_io_message_loop;
-
- // Build up a basic blob.
- const std::string kId("id");
- SetupBasicBlob(&host, kId);
-
- // Now register a url for that blob.
- GURL kUrl("blob:id");
- EXPECT_TRUE(host.RegisterPublicBlobURL(kUrl, kId));
- scoped_ptr<BlobDataHandle> blob_data_handle =
- context.GetBlobDataFromPublicURL(kUrl);
- ASSERT_TRUE(blob_data_handle.get());
- EXPECT_EQ(kId, blob_data_handle->data()->uuid());
- blob_data_handle.reset();
-
- // The url registration should keep the blob alive even after
- // explicit references are dropped.
- EXPECT_TRUE(host.DecrementBlobRefCount(kId));
- blob_data_handle = context.GetBlobDataFromPublicURL(kUrl);
- EXPECT_TRUE(blob_data_handle);
- blob_data_handle.reset();
-
- // Finally get rid of the url registration and the blob.
- EXPECT_TRUE(host.RevokePublicBlobURL(kUrl));
- blob_data_handle = context.GetBlobDataFromPublicURL(kUrl);
- EXPECT_TRUE(!blob_data_handle.get());
- EXPECT_FALSE(host.RevokePublicBlobURL(kUrl));
-}
-
-TEST(BlobStorageContextTest, HostCleanup) {
- BlobStorageContext context;
- scoped_ptr<BlobStorageHost> host(new BlobStorageHost(&context));
- base::MessageLoop fake_io_message_loop;
-
- // Build up a basic blob and register a url
- const std::string kId("id");
- GURL kUrl("blob:id");
- SetupBasicBlob(host.get(), kId);
- EXPECT_TRUE(host->RegisterPublicBlobURL(kUrl, kId));
-
- // All should disappear upon host deletion.
- host.reset();
- scoped_ptr<BlobDataHandle> handle = context.GetBlobDataFromPublicURL(kUrl);
- EXPECT_TRUE(!handle.get());
- handle = context.GetBlobDataFromUUID(kId);
- EXPECT_TRUE(!handle.get());
-}
-
-TEST(BlobStorageContextTest, EarlyContextDeletion) {
- scoped_ptr<BlobStorageContext> context(new BlobStorageContext);
- BlobStorageHost host(context.get());
- base::MessageLoop fake_io_message_loop;
-
- // Deleting the context should not induce crashes.
- context.reset();
-
- const std::string kId("id");
- GURL kUrl("blob:id");
- EXPECT_FALSE(host.StartBuildingBlob(kId));
- BlobData::Item item;
- item.SetToBytes("1", 1);
- EXPECT_FALSE(host.AppendBlobDataItem(kId, item));
- EXPECT_FALSE(host.FinishBuildingBlob(kId, "text/plain"));
- EXPECT_FALSE(host.RegisterPublicBlobURL(kUrl, kId));
- EXPECT_FALSE(host.IncrementBlobRefCount(kId));
- EXPECT_FALSE(host.DecrementBlobRefCount(kId));
- EXPECT_FALSE(host.RevokePublicBlobURL(kUrl));
-}
-
-// TODO(michaeln): tests for the depcrecated url stuff
-
-} // namespace webkit_blob
diff --git a/chromium/webkit/browser/blob/blob_storage_host.cc b/chromium/webkit/browser/blob/blob_storage_host.cc
deleted file mode 100644
index c253a82e8d5..00000000000
--- a/chromium/webkit/browser/blob/blob_storage_host.cc
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright (c) 2013 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 "webkit/browser/blob/blob_storage_host.h"
-
-#include "base/sequenced_task_runner.h"
-#include "base/strings/string_util.h"
-#include "url/gurl.h"
-#include "webkit/browser/blob/blob_data_handle.h"
-#include "webkit/browser/blob/blob_storage_context.h"
-
-namespace webkit_blob {
-
-BlobStorageHost::BlobStorageHost(BlobStorageContext* context)
- : context_(context->AsWeakPtr()) {
-}
-
-BlobStorageHost::~BlobStorageHost() {
- if (!context_.get())
- return;
- for (std::set<GURL>::iterator iter = public_blob_urls_.begin();
- iter != public_blob_urls_.end(); ++iter) {
- context_->RevokePublicBlobURL(*iter);
- }
- for (BlobReferenceMap::iterator iter = blobs_inuse_map_.begin();
- iter != blobs_inuse_map_.end(); ++iter) {
- for (int i = 0; i < iter->second; ++i)
- context_->DecrementBlobRefCount(iter->first);
- }
-}
-
-bool BlobStorageHost::StartBuildingBlob(const std::string& uuid) {
- if (!context_.get() || uuid.empty() || context_->IsInUse(uuid))
- return false;
- context_->StartBuildingBlob(uuid);
- blobs_inuse_map_[uuid] = 1;
- return true;
-}
-
-bool BlobStorageHost::AppendBlobDataItem(
- const std::string& uuid, const BlobData::Item& data_item) {
- if (!context_.get() || !IsBeingBuiltInHost(uuid))
- return false;
- context_->AppendBlobDataItem(uuid, data_item);
- return true;
-}
-
-bool BlobStorageHost::CancelBuildingBlob(const std::string& uuid) {
- if (!context_.get() || !IsBeingBuiltInHost(uuid))
- return false;
- blobs_inuse_map_.erase(uuid);
- context_->CancelBuildingBlob(uuid);
- return true;
-}
-
-bool BlobStorageHost::FinishBuildingBlob(
- const std::string& uuid, const std::string& content_type) {
- if (!context_.get() || !IsBeingBuiltInHost(uuid))
- return false;
- context_->FinishBuildingBlob(uuid, content_type);
- return true;
-}
-
-bool BlobStorageHost::IncrementBlobRefCount(const std::string& uuid) {
- if (!context_.get() || !context_->IsInUse(uuid) ||
- context_->IsBeingBuilt(uuid))
- return false;
- context_->IncrementBlobRefCount(uuid);
- blobs_inuse_map_[uuid] += 1;
- return true;
-}
-
-bool BlobStorageHost::DecrementBlobRefCount(const std::string& uuid) {
- if (!context_.get() || !IsInUseInHost(uuid))
- return false;
- context_->DecrementBlobRefCount(uuid);
- blobs_inuse_map_[uuid] -= 1;
- if (blobs_inuse_map_[uuid] == 0)
- blobs_inuse_map_.erase(uuid);
- return true;
-}
-
-bool BlobStorageHost::RegisterPublicBlobURL(
- const GURL& blob_url, const std::string& uuid) {
- if (!context_.get() || !IsInUseInHost(uuid) ||
- context_->IsUrlRegistered(blob_url))
- return false;
- context_->RegisterPublicBlobURL(blob_url, uuid);
- public_blob_urls_.insert(blob_url);
- return true;
-}
-
-bool BlobStorageHost::RevokePublicBlobURL(const GURL& blob_url) {
- if (!context_.get() || !IsUrlRegisteredInHost(blob_url))
- return false;
- context_->RevokePublicBlobURL(blob_url);
- public_blob_urls_.erase(blob_url);
- return true;
-}
-
-bool BlobStorageHost::IsInUseInHost(const std::string& uuid) {
- return blobs_inuse_map_.find(uuid) != blobs_inuse_map_.end();
-}
-
-bool BlobStorageHost::IsBeingBuiltInHost(const std::string& uuid) {
- return IsInUseInHost(uuid) && context_->IsBeingBuilt(uuid);
-}
-
-bool BlobStorageHost::IsUrlRegisteredInHost(const GURL& blob_url) {
- return public_blob_urls_.find(blob_url) != public_blob_urls_.end();
-}
-
-} // namespace webkit_blob
diff --git a/chromium/webkit/browser/blob/blob_storage_host.h b/chromium/webkit/browser/blob/blob_storage_host.h
deleted file mode 100644
index 5296ae105e8..00000000000
--- a/chromium/webkit/browser/blob/blob_storage_host.h
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright (c) 2013 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 WEBKIT_BROWSER_BLOB_BLOB_STORAGE_HOST_H_
-#define WEBKIT_BROWSER_BLOB_BLOB_STORAGE_HOST_H_
-
-#include <map>
-#include <set>
-#include <string>
-
-#include "base/compiler_specific.h"
-#include "base/memory/weak_ptr.h"
-#include "webkit/browser/webkit_storage_browser_export.h"
-#include "webkit/common/blob/blob_data.h"
-
-class GURL;
-
-namespace webkit_blob {
-
-class BlobDataHandle;
-class BlobStorageHost;
-class BlobStorageContext;
-
-// This class handles the logistics of blob storage for a single child process.
-// There is one instance per child process. When the child process
-// terminates all blob references attibutable to that process go away upon
-// destruction of the instance. The class is single threaded and should
-// only be used on the IO thread.
-class WEBKIT_STORAGE_BROWSER_EXPORT BlobStorageHost {
- public:
- explicit BlobStorageHost(BlobStorageContext* context);
- ~BlobStorageHost();
-
- // Methods to support the IPC message protocol.
- // A false return indicates a problem with the inputs
- // like a non-existent or pre-existent uuid or url.
- bool StartBuildingBlob(const std::string& uuid) WARN_UNUSED_RESULT;
- bool AppendBlobDataItem(const std::string& uuid,
- const BlobData::Item& data_item) WARN_UNUSED_RESULT;
- bool CancelBuildingBlob(const std::string& uuid) WARN_UNUSED_RESULT;
- bool FinishBuildingBlob(const std::string& uuid,
- const std::string& type) WARN_UNUSED_RESULT;
- bool IncrementBlobRefCount(const std::string& uuid) WARN_UNUSED_RESULT;
- bool DecrementBlobRefCount(const std::string& uuid) WARN_UNUSED_RESULT;
- bool RegisterPublicBlobURL(const GURL& blob_url,
- const std::string& uuid) WARN_UNUSED_RESULT;
- bool RevokePublicBlobURL(const GURL& blob_url) WARN_UNUSED_RESULT;
-
- private:
- typedef std::map<std::string, int> BlobReferenceMap;
-
- bool IsInUseInHost(const std::string& uuid);
- bool IsBeingBuiltInHost(const std::string& uuid);
- bool IsUrlRegisteredInHost(const GURL& blob_url);
-
- // Collection of blob ids and a count of how many usages
- // of that id are attributable to this consumer.
- BlobReferenceMap blobs_inuse_map_;
-
- // The set of public blob urls coined by this consumer.
- std::set<GURL> public_blob_urls_;
-
- base::WeakPtr<BlobStorageContext> context_;
-
- DISALLOW_COPY_AND_ASSIGN(BlobStorageHost);
-};
-
-} // namespace webkit_blob
-
-#endif // WEBKIT_BROWSER_BLOB_BLOB_STORAGE_HOST_H_
diff --git a/chromium/webkit/browser/blob/blob_url_request_job.cc b/chromium/webkit/browser/blob/blob_url_request_job.cc
index 4b89636d6bf..f1040f5dc65 100644
--- a/chromium/webkit/browser/blob/blob_url_request_job.cc
+++ b/chromium/webkit/browser/blob/blob_url_request_job.cc
@@ -10,10 +10,12 @@
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/files/file_util_proxy.h"
+#include "base/format_macros.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/stringprintf.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/http/http_request_headers.h"
@@ -509,6 +511,18 @@ void BlobURLRequestJob::HeadersCompleted(net::HttpStatusCode status_code) {
content_length_header.append(": ");
content_length_header.append(base::Int64ToString(remaining_bytes_));
headers->AddHeader(content_length_header);
+ if (status_code == net::HTTP_PARTIAL_CONTENT) {
+ DCHECK(byte_range_set_);
+ DCHECK(byte_range_.IsValid());
+ std::string content_range_header(net::HttpResponseHeaders::kContentRange);
+ content_range_header.append(": bytes ");
+ content_range_header.append(base::StringPrintf(
+ "%" PRId64 "-%" PRId64,
+ byte_range_.first_byte_position(), byte_range_.last_byte_position()));
+ content_range_header.append("/");
+ content_range_header.append(base::StringPrintf("%" PRId64, total_size_));
+ headers->AddHeader(content_range_header);
+ }
if (!blob_data_->content_type().empty()) {
std::string content_type_header(net::HttpRequestHeaders::kContentType);
content_type_header.append(": ");
diff --git a/chromium/webkit/browser/blob/blob_url_request_job.h b/chromium/webkit/browser/blob/blob_url_request_job.h
index 238958fff8e..81a5a3e6ee9 100644
--- a/chromium/webkit/browser/blob/blob_url_request_job.h
+++ b/chromium/webkit/browser/blob/blob_url_request_job.h
@@ -9,7 +9,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "base/platform_file.h"
#include "net/http/http_byte_range.h"
#include "net/http/http_status_code.h"
#include "net/url_request/url_request_job.h"
@@ -18,7 +17,6 @@
namespace base {
class MessageLoopProxy;
-struct PlatformFileInfo;
}
namespace fileapi {
diff --git a/chromium/webkit/browser/blob/blob_url_request_job_factory.cc b/chromium/webkit/browser/blob/blob_url_request_job_factory.cc
index f36e0a54556..73efe4c21a4 100644
--- a/chromium/webkit/browser/blob/blob_url_request_job_factory.cc
+++ b/chromium/webkit/browser/blob/blob_url_request_job_factory.cc
@@ -35,7 +35,7 @@ scoped_ptr<net::URLRequest> BlobProtocolHandler::CreateBlobRequest(
net::URLRequest::Delegate* request_delegate) {
const GURL kBlobUrl("blob://see_user_data/");
scoped_ptr<net::URLRequest> request = request_context->CreateRequest(
- kBlobUrl, net::DEFAULT_PRIORITY, request_delegate);
+ kBlobUrl, net::DEFAULT_PRIORITY, request_delegate, NULL);
SetRequestedBlobDataHandle(request.get(), blob_data_handle.Pass());
return request.Pass();
}
diff --git a/chromium/webkit/browser/blob/file_stream_reader.cc b/chromium/webkit/browser/blob/file_stream_reader.cc
new file mode 100644
index 00000000000..6b66478de89
--- /dev/null
+++ b/chromium/webkit/browser/blob/file_stream_reader.cc
@@ -0,0 +1,20 @@
+// 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 "webkit/browser/blob/file_stream_reader.h"
+
+#include "base/time/time.h"
+
+namespace webkit_blob {
+
+// Verify if the underlying file has not been modified.
+bool FileStreamReader::VerifySnapshotTime(
+ const base::Time& expected_modification_time,
+ const base::File::Info& file_info) {
+ return expected_modification_time.is_null() ||
+ expected_modification_time.ToTimeT() ==
+ file_info.last_modified.ToTimeT();
+}
+
+} // namespace webkit_blob
diff --git a/chromium/webkit/browser/blob/file_stream_reader.h b/chromium/webkit/browser/blob/file_stream_reader.h
index d60dfdbd91c..832c5d5dc66 100644
--- a/chromium/webkit/browser/blob/file_stream_reader.h
+++ b/chromium/webkit/browser/blob/file_stream_reader.h
@@ -7,6 +7,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/files/file.h"
#include "net/base/completion_callback.h"
#include "webkit/browser/webkit_storage_browser_export.h"
@@ -56,6 +57,11 @@ class FileStreamReader {
int64 initial_offset,
const base::Time& expected_modification_time);
+ // Verify if the underlying file has not been modified.
+ WEBKIT_STORAGE_BROWSER_EXPORT static bool VerifySnapshotTime(
+ const base::Time& expected_modification_time,
+ const base::File::Info& file_info);
+
// It is valid to delete the reader at any time. If the stream is deleted
// while it has a pending read, its callback will not be called.
virtual ~FileStreamReader() {}
diff --git a/chromium/webkit/browser/blob/local_file_stream_reader.cc b/chromium/webkit/browser/blob/local_file_stream_reader.cc
index 0686821ac24..18b1826b62e 100644
--- a/chromium/webkit/browser/blob/local_file_stream_reader.cc
+++ b/chromium/webkit/browser/blob/local_file_stream_reader.cc
@@ -8,7 +8,6 @@
#include "base/files/file_util_proxy.h"
#include "base/location.h"
#include "base/logging.h"
-#include "base/platform_file.h"
#include "base/task_runner.h"
#include "net/base/file_stream.h"
#include "net/base/io_buffer.h"
@@ -18,17 +17,9 @@ namespace webkit_blob {
namespace {
-const int kOpenFlagsForRead = base::PLATFORM_FILE_OPEN |
- base::PLATFORM_FILE_READ |
- base::PLATFORM_FILE_ASYNC;
-
-// Verify if the underlying file has not been modified.
-bool VerifySnapshotTime(const base::Time& expected_modification_time,
- const base::PlatformFileInfo& file_info) {
- return expected_modification_time.is_null() ||
- expected_modification_time.ToTimeT() ==
- file_info.last_modified.ToTimeT();
-}
+const int kOpenFlagsForRead = base::File::FLAG_OPEN |
+ base::File::FLAG_READ |
+ base::File::FLAG_ASYNC;
} // namespace
@@ -97,7 +88,7 @@ void LocalFileStreamReader::DidVerifyForOpen(
return;
}
- stream_impl_.reset(new net::FileStream(NULL, task_runner_));
+ stream_impl_.reset(new net::FileStream(task_runner_));
const int result = stream_impl_->Open(
file_path_, kOpenFlagsForRead,
base::Bind(&LocalFileStreamReader::DidOpenFileStream,
@@ -158,14 +149,14 @@ void LocalFileStreamReader::DidOpenForRead(
void LocalFileStreamReader::DidGetFileInfoForGetLength(
const net::Int64CompletionCallback& callback,
- base::PlatformFileError error,
- const base::PlatformFileInfo& file_info) {
+ base::File::Error error,
+ const base::File::Info& file_info) {
if (file_info.is_directory) {
callback.Run(net::ERR_FILE_NOT_FOUND);
return;
}
- if (error != base::PLATFORM_FILE_OK) {
- callback.Run(net::PlatformFileErrorToNetError(error));
+ if (error != base::File::FILE_OK) {
+ callback.Run(net::FileErrorToNetError(error));
return;
}
if (!VerifySnapshotTime(expected_modification_time_, file_info)) {
diff --git a/chromium/webkit/browser/blob/local_file_stream_reader.h b/chromium/webkit/browser/blob/local_file_stream_reader.h
index 18a5424514a..c96cb5a7862 100644
--- a/chromium/webkit/browser/blob/local_file_stream_reader.h
+++ b/chromium/webkit/browser/blob/local_file_stream_reader.h
@@ -7,9 +7,9 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/memory/weak_ptr.h"
-#include "base/platform_file.h"
#include "base/time/time.h"
#include "webkit/browser/blob/file_stream_reader.h"
#include "webkit/browser/webkit_storage_browser_export.h"
@@ -18,6 +18,10 @@ namespace base {
class TaskRunner;
}
+namespace content {
+class LocalFileStreamReaderTest;
+}
+
namespace net {
class FileStream;
}
@@ -39,7 +43,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT LocalFileStreamReader
private:
friend class FileStreamReader;
- friend class LocalFileStreamReaderTest;
+ friend class content::LocalFileStreamReaderTest;
LocalFileStreamReader(base::TaskRunner* task_runner,
const base::FilePath& file_path,
@@ -60,8 +64,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT LocalFileStreamReader
int open_result);
void DidGetFileInfoForGetLength(const net::Int64CompletionCallback& callback,
- base::PlatformFileError error,
- const base::PlatformFileInfo& file_info);
+ base::File::Error error,
+ const base::File::Info& file_info);
scoped_refptr<base::TaskRunner> task_runner_;
scoped_ptr<net::FileStream> stream_impl_;
diff --git a/chromium/webkit/browser/blob/local_file_stream_reader_unittest.cc b/chromium/webkit/browser/blob/local_file_stream_reader_unittest.cc
deleted file mode 100644
index 87c77fc8def..00000000000
--- a/chromium/webkit/browser/blob/local_file_stream_reader_unittest.cc
+++ /dev/null
@@ -1,261 +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 "webkit/browser/blob/local_file_stream_reader.h"
-
-#include <string>
-
-#include "base/file_util.h"
-#include "base/files/file_path.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/platform_file.h"
-#include "base/run_loop.h"
-#include "base/threading/thread.h"
-#include "net/base/io_buffer.h"
-#include "net/base/net_errors.h"
-#include "net/base/test_completion_callback.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace webkit_blob {
-
-namespace {
-
-const char kTestData[] = "0123456789";
-const int kTestDataSize = arraysize(kTestData) - 1;
-
-void ReadFromReader(LocalFileStreamReader* reader,
- std::string* data, size_t size,
- int* result) {
- ASSERT_TRUE(reader != NULL);
- ASSERT_TRUE(result != NULL);
- *result = net::OK;
- net::TestCompletionCallback callback;
- size_t total_bytes_read = 0;
- while (total_bytes_read < size) {
- scoped_refptr<net::IOBufferWithSize> buf(
- new net::IOBufferWithSize(size - total_bytes_read));
- int rv = reader->Read(buf.get(), buf->size(), callback.callback());
- if (rv == net::ERR_IO_PENDING)
- rv = callback.WaitForResult();
- if (rv < 0)
- *result = rv;
- if (rv <= 0)
- break;
- total_bytes_read += rv;
- data->append(buf->data(), rv);
- }
-}
-
-void NeverCalled(int) { ADD_FAILURE(); }
-void EmptyCallback() {}
-
-void QuitLoop() {
- base::MessageLoop::current()->Quit();
-}
-
-} // namespace
-
-class LocalFileStreamReaderTest : public testing::Test {
- public:
- LocalFileStreamReaderTest()
- : file_thread_("FileUtilProxyTestFileThread") {}
-
- virtual void SetUp() OVERRIDE {
- ASSERT_TRUE(file_thread_.Start());
- ASSERT_TRUE(dir_.CreateUniqueTempDir());
-
- file_util::WriteFile(test_path(), kTestData, kTestDataSize);
- base::PlatformFileInfo info;
- ASSERT_TRUE(base::GetFileInfo(test_path(), &info));
- test_file_modification_time_ = info.last_modified;
- }
-
- virtual void TearDown() OVERRIDE {
- // Give another chance for deleted streams to perform Close.
- base::RunLoop().RunUntilIdle();
- file_thread_.Stop();
- base::RunLoop().RunUntilIdle();
- }
-
- protected:
- LocalFileStreamReader* CreateFileReader(
- const base::FilePath& path,
- int64 initial_offset,
- const base::Time& expected_modification_time) {
- return new LocalFileStreamReader(
- file_task_runner(),
- path,
- initial_offset,
- expected_modification_time);
- }
-
- void TouchTestFile() {
- base::Time new_modified_time =
- test_file_modification_time() - base::TimeDelta::FromSeconds(1);
- ASSERT_TRUE(base::TouchFile(test_path(),
- test_file_modification_time(),
- new_modified_time));
- }
-
- base::MessageLoopProxy* file_task_runner() const {
- return file_thread_.message_loop_proxy().get();
- }
-
- base::FilePath test_dir() const { return dir_.path(); }
- base::FilePath test_path() const { return dir_.path().AppendASCII("test"); }
- base::Time test_file_modification_time() const {
- return test_file_modification_time_;
- }
-
- void EnsureFileTaskFinished() {
- file_task_runner()->PostTaskAndReply(
- FROM_HERE, base::Bind(&EmptyCallback), base::Bind(&QuitLoop));
- base::MessageLoop::current()->Run();
- }
-
- private:
- base::MessageLoopForIO message_loop_;
- base::Thread file_thread_;
- base::ScopedTempDir dir_;
- base::Time test_file_modification_time_;
-};
-
-TEST_F(LocalFileStreamReaderTest, NonExistent) {
- base::FilePath nonexistent_path = test_dir().AppendASCII("nonexistent");
- scoped_ptr<LocalFileStreamReader> reader(
- CreateFileReader(nonexistent_path, 0, base::Time()));
- int result = 0;
- std::string data;
- ReadFromReader(reader.get(), &data, 10, &result);
- ASSERT_EQ(net::ERR_FILE_NOT_FOUND, result);
- ASSERT_EQ(0U, data.size());
-}
-
-TEST_F(LocalFileStreamReaderTest, Empty) {
- base::FilePath empty_path = test_dir().AppendASCII("empty");
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
- base::PlatformFile file = base::CreatePlatformFile(
- empty_path,
- base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_READ,
- NULL, &error);
- ASSERT_EQ(base::PLATFORM_FILE_OK, error);
- ASSERT_NE(base::kInvalidPlatformFileValue, file);
- base::ClosePlatformFile(file);
-
- scoped_ptr<LocalFileStreamReader> reader(
- CreateFileReader(empty_path, 0, base::Time()));
- int result = 0;
- std::string data;
- ReadFromReader(reader.get(), &data, 10, &result);
- ASSERT_EQ(net::OK, result);
- ASSERT_EQ(0U, data.size());
-
- net::TestInt64CompletionCallback callback;
- int64 length_result = reader->GetLength(callback.callback());
- if (length_result == net::ERR_IO_PENDING)
- length_result = callback.WaitForResult();
- ASSERT_EQ(0, result);
-}
-
-TEST_F(LocalFileStreamReaderTest, GetLengthNormal) {
- scoped_ptr<LocalFileStreamReader> reader(
- CreateFileReader(test_path(), 0, test_file_modification_time()));
- net::TestInt64CompletionCallback callback;
- int64 result = reader->GetLength(callback.callback());
- if (result == net::ERR_IO_PENDING)
- result = callback.WaitForResult();
- ASSERT_EQ(kTestDataSize, result);
-}
-
-TEST_F(LocalFileStreamReaderTest, GetLengthAfterModified) {
- // Touch file so that the file's modification time becomes different
- // from what we expect.
- TouchTestFile();
-
- scoped_ptr<LocalFileStreamReader> reader(
- CreateFileReader(test_path(), 0, test_file_modification_time()));
- net::TestInt64CompletionCallback callback;
- int64 result = reader->GetLength(callback.callback());
- if (result == net::ERR_IO_PENDING)
- result = callback.WaitForResult();
- ASSERT_EQ(net::ERR_UPLOAD_FILE_CHANGED, result);
-
- // With NULL expected modification time this should work.
- reader.reset(CreateFileReader(test_path(), 0, base::Time()));
- result = reader->GetLength(callback.callback());
- if (result == net::ERR_IO_PENDING)
- result = callback.WaitForResult();
- ASSERT_EQ(kTestDataSize, result);
-}
-
-TEST_F(LocalFileStreamReaderTest, GetLengthWithOffset) {
- scoped_ptr<LocalFileStreamReader> reader(
- CreateFileReader(test_path(), 3, base::Time()));
- net::TestInt64CompletionCallback callback;
- int64 result = reader->GetLength(callback.callback());
- if (result == net::ERR_IO_PENDING)
- result = callback.WaitForResult();
- // Initial offset does not affect the result of GetLength.
- ASSERT_EQ(kTestDataSize, result);
-}
-
-TEST_F(LocalFileStreamReaderTest, ReadNormal) {
- scoped_ptr<LocalFileStreamReader> reader(
- CreateFileReader(test_path(), 0, test_file_modification_time()));
- int result = 0;
- std::string data;
- ReadFromReader(reader.get(), &data, kTestDataSize, &result);
- ASSERT_EQ(net::OK, result);
- ASSERT_EQ(kTestData, data);
-}
-
-TEST_F(LocalFileStreamReaderTest, ReadAfterModified) {
- // Touch file so that the file's modification time becomes different
- // from what we expect.
- TouchTestFile();
-
- scoped_ptr<LocalFileStreamReader> reader(
- CreateFileReader(test_path(), 0, test_file_modification_time()));
- int result = 0;
- std::string data;
- ReadFromReader(reader.get(), &data, kTestDataSize, &result);
- ASSERT_EQ(net::ERR_UPLOAD_FILE_CHANGED, result);
- ASSERT_EQ(0U, data.size());
-
- // With NULL expected modification time this should work.
- data.clear();
- reader.reset(CreateFileReader(test_path(), 0, base::Time()));
- ReadFromReader(reader.get(), &data, kTestDataSize, &result);
- ASSERT_EQ(net::OK, result);
- ASSERT_EQ(kTestData, data);
-}
-
-TEST_F(LocalFileStreamReaderTest, ReadWithOffset) {
- scoped_ptr<LocalFileStreamReader> reader(
- CreateFileReader(test_path(), 3, base::Time()));
- int result = 0;
- std::string data;
- ReadFromReader(reader.get(), &data, kTestDataSize, &result);
- ASSERT_EQ(net::OK, result);
- ASSERT_EQ(&kTestData[3], data);
-}
-
-TEST_F(LocalFileStreamReaderTest, DeleteWithUnfinishedRead) {
- scoped_ptr<LocalFileStreamReader> reader(
- CreateFileReader(test_path(), 0, base::Time()));
-
- net::TestCompletionCallback callback;
- scoped_refptr<net::IOBufferWithSize> buf(
- new net::IOBufferWithSize(kTestDataSize));
- int rv = reader->Read(buf.get(), buf->size(), base::Bind(&NeverCalled));
- ASSERT_TRUE(rv == net::ERR_IO_PENDING || rv >= 0);
-
- // Delete immediately.
- // Should not crash; nor should NeverCalled be callback.
- reader.reset();
- EnsureFileTaskFinished();
-}
-
-} // namespace webkit_blob
diff --git a/chromium/webkit/browser/blob/mock_blob_url_request_context.cc b/chromium/webkit/browser/blob/mock_blob_url_request_context.cc
deleted file mode 100644
index 1794a58eb62..00000000000
--- a/chromium/webkit/browser/blob/mock_blob_url_request_context.cc
+++ /dev/null
@@ -1,49 +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 "webkit/browser/blob/mock_blob_url_request_context.h"
-
-#include "webkit/browser/blob/blob_storage_context.h"
-#include "webkit/browser/blob/blob_url_request_job.h"
-#include "webkit/browser/blob/blob_url_request_job_factory.h"
-#include "webkit/common/blob/blob_data.h"
-
-
-namespace webkit_blob {
-
-MockBlobURLRequestContext::MockBlobURLRequestContext(
- fileapi::FileSystemContext* file_system_context)
- : blob_storage_context_(new BlobStorageContext) {
- // Job factory owns the protocol handler.
- job_factory_.SetProtocolHandler(
- "blob", new BlobProtocolHandler(blob_storage_context_.get(),
- file_system_context,
- base::MessageLoopProxy::current()));
- set_job_factory(&job_factory_);
-}
-
-MockBlobURLRequestContext::~MockBlobURLRequestContext() {
-}
-
-ScopedTextBlob::ScopedTextBlob(
- const MockBlobURLRequestContext& request_context,
- const std::string& blob_id,
- const std::string& data)
- : blob_id_(blob_id),
- context_(request_context.blob_storage_context()) {
- DCHECK(context_);
- scoped_refptr<BlobData> blob_data(new BlobData(blob_id_));
- if (!data.empty())
- blob_data->AppendData(data);
- handle_ = context_->AddFinishedBlob(blob_data);
-}
-
-ScopedTextBlob::~ScopedTextBlob() {
-}
-
-scoped_ptr<BlobDataHandle> ScopedTextBlob::GetBlobDataHandle() {
- return context_->GetBlobDataFromUUID(blob_id_);
-}
-
-} // namespace webkit_blob
diff --git a/chromium/webkit/browser/blob/mock_blob_url_request_context.h b/chromium/webkit/browser/blob/mock_blob_url_request_context.h
deleted file mode 100644
index a5d1acc8a4c..00000000000
--- a/chromium/webkit/browser/blob/mock_blob_url_request_context.h
+++ /dev/null
@@ -1,58 +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 WEBKIT_BLOB_MOCK_BLOB_URL_REQUEST_CONTEXT_H_
-#define WEBKIT_BLOB_MOCK_BLOB_URL_REQUEST_CONTEXT_H_
-
-#include "net/url_request/url_request_context.h"
-#include "net/url_request/url_request_job.h"
-#include "net/url_request/url_request_job_factory_impl.h"
-
-namespace fileapi {
-class FileSystemContext;
-}
-
-namespace webkit_blob {
-
-class BlobDataHandle;
-class BlobStorageContext;
-
-class MockBlobURLRequestContext : public net::URLRequestContext {
- public:
- MockBlobURLRequestContext(fileapi::FileSystemContext* file_system_context);
- virtual ~MockBlobURLRequestContext();
-
- BlobStorageContext* blob_storage_context() const {
- return blob_storage_context_.get();
- }
-
- private:
- net::URLRequestJobFactoryImpl job_factory_;
- scoped_ptr<BlobStorageContext> blob_storage_context_;
-
- DISALLOW_COPY_AND_ASSIGN(MockBlobURLRequestContext);
-};
-
-class ScopedTextBlob {
- public:
- // Registers a blob with the given |id| that contains |data|.
- ScopedTextBlob(const MockBlobURLRequestContext& request_context,
- const std::string& blob_id,
- const std::string& data);
- ~ScopedTextBlob();
-
- // Returns a BlobDataHandle referring to the scoped blob.
- scoped_ptr<BlobDataHandle> GetBlobDataHandle();
-
- private:
- const std::string blob_id_;
- BlobStorageContext* context_;
- scoped_ptr<BlobDataHandle> handle_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedTextBlob);
-};
-
-} // namespace webkit_blob
-
-#endif // WEBKIT_BLOB_MOCK_BLOB_URL_REQUEST_CONTEXT_H_
diff --git a/chromium/webkit/browser/blob/view_blob_internals_job.cc b/chromium/webkit/browser/blob/view_blob_internals_job.cc
index fa9e82a12d7..86a3a8774c7 100644
--- a/chromium/webkit/browser/blob/view_blob_internals_job.cc
+++ b/chromium/webkit/browser/blob/view_blob_internals_job.cc
@@ -182,12 +182,12 @@ void ViewBlobInternalsJob::GenerateHTMLForBlobData(const BlobData& blob_data,
bool has_multi_items = blob_data.items().size() > 1;
if (has_multi_items) {
AddHTMLListItem(kCount,
- UTF16ToUTF8(base::FormatNumber(blob_data.items().size())), out);
+ base::UTF16ToUTF8(base::FormatNumber(blob_data.items().size())), out);
}
for (size_t i = 0; i < blob_data.items().size(); ++i) {
if (has_multi_items) {
- AddHTMLListItem(kIndex, UTF16ToUTF8(base::FormatNumber(i)), out);
+ AddHTMLListItem(kIndex, base::UTF16ToUTF8(base::FormatNumber(i)), out);
StartHTMLList(out);
}
const BlobData::Item& item = blob_data.items().at(i);
@@ -202,7 +202,7 @@ void ViewBlobInternalsJob::GenerateHTMLForBlobData(const BlobData& blob_data,
net::EscapeForHTML(item.path().AsUTF8Unsafe()),
out);
if (!item.expected_modification_time().is_null()) {
- AddHTMLListItem(kModificationTime, UTF16ToUTF8(
+ AddHTMLListItem(kModificationTime, base::UTF16ToUTF8(
TimeFormatFriendlyDateAndTime(item.expected_modification_time())),
out);
}
@@ -214,7 +214,7 @@ void ViewBlobInternalsJob::GenerateHTMLForBlobData(const BlobData& blob_data,
AddHTMLListItem(kType, "filesystem", out);
AddHTMLListItem(kURL, item.filesystem_url().spec(), out);
if (!item.expected_modification_time().is_null()) {
- AddHTMLListItem(kModificationTime, UTF16ToUTF8(
+ AddHTMLListItem(kModificationTime, base::UTF16ToUTF8(
TimeFormatFriendlyDateAndTime(item.expected_modification_time())),
out);
}
@@ -224,11 +224,11 @@ void ViewBlobInternalsJob::GenerateHTMLForBlobData(const BlobData& blob_data,
break;
}
if (item.offset()) {
- AddHTMLListItem(kOffset, UTF16ToUTF8(base::FormatNumber(
+ AddHTMLListItem(kOffset, base::UTF16ToUTF8(base::FormatNumber(
static_cast<int64>(item.offset()))), out);
}
if (static_cast<int64>(item.length()) != -1) {
- AddHTMLListItem(kLength, UTF16ToUTF8(base::FormatNumber(
+ AddHTMLListItem(kLength, base::UTF16ToUTF8(base::FormatNumber(
static_cast<int64>(item.length()))), out);
}
diff --git a/chromium/webkit/browser/database/database_quota_client_unittest.cc b/chromium/webkit/browser/database/database_quota_client_unittest.cc
deleted file mode 100644
index 3d4f71aef53..00000000000
--- a/chromium/webkit/browser/database/database_quota_client_unittest.cc
+++ /dev/null
@@ -1,285 +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 <map>
-
-#include "base/bind.h"
-#include "base/files/file_path.h"
-#include "base/message_loop/message_loop_proxy.h"
-#include "base/run_loop.h"
-#include "base/strings/utf_string_conversions.h"
-#include "net/base/completion_callback.h"
-#include "net/base/net_errors.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/database/database_quota_client.h"
-#include "webkit/browser/database/database_tracker.h"
-#include "webkit/browser/database/database_util.h"
-#include "webkit/common/database/database_identifier.h"
-
-namespace webkit_database {
-
-// Declared to shorten the line lengths.
-static const quota::StorageType kTemp = quota::kStorageTypeTemporary;
-static const quota::StorageType kPerm = quota::kStorageTypePersistent;
-
-// Mock tracker class the mocks up those methods of the tracker
-// that are used by the QuotaClient.
-class MockDatabaseTracker : public DatabaseTracker {
- public:
- MockDatabaseTracker()
- : DatabaseTracker(base::FilePath(), false, NULL, NULL, NULL),
- delete_called_count_(0),
- async_delete_(false) {}
-
- virtual bool GetOriginInfo(
- const std::string& origin_identifier,
- OriginInfo* info) OVERRIDE {
- std::map<GURL, MockOriginInfo>::const_iterator found =
- mock_origin_infos_.find(
- webkit_database::GetOriginFromIdentifier(origin_identifier));
- if (found == mock_origin_infos_.end())
- return false;
- *info = OriginInfo(found->second);
- return true;
- }
-
- virtual bool GetAllOriginIdentifiers(
- std::vector<std::string>* origins_identifiers) OVERRIDE {
- std::map<GURL, MockOriginInfo>::const_iterator iter;
- for (iter = mock_origin_infos_.begin();
- iter != mock_origin_infos_.end();
- ++iter) {
- origins_identifiers->push_back(iter->second.GetOriginIdentifier());
- }
- return true;
- }
-
- virtual bool GetAllOriginsInfo(
- std::vector<OriginInfo>* origins_info) OVERRIDE {
- std::map<GURL, MockOriginInfo>::const_iterator iter;
- for (iter = mock_origin_infos_.begin();
- iter != mock_origin_infos_.end();
- ++iter) {
- origins_info->push_back(OriginInfo(iter->second));
- }
- return true;
- }
-
- virtual int DeleteDataForOrigin(
- const std::string& origin_identifier,
- const net::CompletionCallback& callback) OVERRIDE {
- ++delete_called_count_;
- if (async_delete()) {
- base::MessageLoopProxy::current()->PostTask(
- FROM_HERE,
- base::Bind(&MockDatabaseTracker::AsyncDeleteDataForOrigin, this,
- callback));
- return net::ERR_IO_PENDING;
- }
- return net::OK;
- }
-
- void AsyncDeleteDataForOrigin(const net::CompletionCallback& callback) {
- callback.Run(net::OK);
- }
-
- void AddMockDatabase(const GURL& origin, const char* name, int size) {
- MockOriginInfo& info = mock_origin_infos_[origin];
- info.set_origin(webkit_database::GetIdentifierFromOrigin(origin));
- info.AddMockDatabase(ASCIIToUTF16(name), size);
- }
-
- int delete_called_count() { return delete_called_count_; }
- bool async_delete() { return async_delete_; }
- void set_async_delete(bool async) { async_delete_ = async; }
-
- protected:
- virtual ~MockDatabaseTracker() {}
-
- private:
- class MockOriginInfo : public OriginInfo {
- public:
- void set_origin(const std::string& origin_identifier) {
- origin_identifier_ = origin_identifier;
- }
-
- void AddMockDatabase(const base::string16& name, int size) {
- EXPECT_TRUE(database_info_.find(name) == database_info_.end());
- database_info_[name].first = size;
- total_size_ += size;
- }
- };
-
- int delete_called_count_;
- bool async_delete_;
- std::map<GURL, MockOriginInfo> mock_origin_infos_;
-};
-
-
-// Base class for our test fixtures.
-class DatabaseQuotaClientTest : public testing::Test {
- public:
- const GURL kOriginA;
- const GURL kOriginB;
- const GURL kOriginOther;
-
- DatabaseQuotaClientTest()
- : kOriginA("http://host"),
- kOriginB("http://host:8000"),
- kOriginOther("http://other"),
- usage_(0),
- mock_tracker_(new MockDatabaseTracker),
- weak_factory_(this) {
- }
-
- int64 GetOriginUsage(
- quota::QuotaClient* client,
- const GURL& origin,
- quota::StorageType type) {
- usage_ = 0;
- client->GetOriginUsage(
- origin, type,
- base::Bind(&DatabaseQuotaClientTest::OnGetOriginUsageComplete,
- weak_factory_.GetWeakPtr()));
- base::RunLoop().RunUntilIdle();
- return usage_;
- }
-
- const std::set<GURL>& GetOriginsForType(
- quota::QuotaClient* client,
- quota::StorageType type) {
- origins_.clear();
- client->GetOriginsForType(
- type,
- base::Bind(&DatabaseQuotaClientTest::OnGetOriginsComplete,
- weak_factory_.GetWeakPtr()));
- base::RunLoop().RunUntilIdle();
- return origins_;
- }
-
- const std::set<GURL>& GetOriginsForHost(
- quota::QuotaClient* client,
- quota::StorageType type,
- const std::string& host) {
- origins_.clear();
- client->GetOriginsForHost(
- type, host,
- base::Bind(&DatabaseQuotaClientTest::OnGetOriginsComplete,
- weak_factory_.GetWeakPtr()));
- base::RunLoop().RunUntilIdle();
- return origins_;
- }
-
- bool DeleteOriginData(
- quota::QuotaClient* client,
- quota::StorageType type,
- const GURL& origin) {
- delete_status_ = quota::kQuotaStatusUnknown;
- client->DeleteOriginData(
- origin, type,
- base::Bind(&DatabaseQuotaClientTest::OnDeleteOriginDataComplete,
- weak_factory_.GetWeakPtr()));
- base::RunLoop().RunUntilIdle();
- return delete_status_ == quota::kQuotaStatusOk;
- }
-
- MockDatabaseTracker* mock_tracker() { return mock_tracker_.get(); }
-
-
- private:
- void OnGetOriginUsageComplete(int64 usage) {
- usage_ = usage;
- }
-
- void OnGetOriginsComplete(const std::set<GURL>& origins) {
- origins_ = origins;
- }
-
- void OnDeleteOriginDataComplete(quota::QuotaStatusCode status) {
- delete_status_ = status;
- }
-
- base::MessageLoop message_loop_;
- int64 usage_;
- std::set<GURL> origins_;
- quota::QuotaStatusCode delete_status_;
- scoped_refptr<MockDatabaseTracker> mock_tracker_;
- base::WeakPtrFactory<DatabaseQuotaClientTest> weak_factory_;
-};
-
-
-TEST_F(DatabaseQuotaClientTest, GetOriginUsage) {
- DatabaseQuotaClient client(base::MessageLoopProxy::current().get(),
- mock_tracker());
-
- EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp));
- EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kPerm));
-
- mock_tracker()->AddMockDatabase(kOriginA, "fooDB", 1000);
- EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp));
- EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kPerm));
-
- EXPECT_EQ(0, GetOriginUsage(&client, kOriginB, kPerm));
- EXPECT_EQ(0, GetOriginUsage(&client, kOriginB, kTemp));
-}
-
-TEST_F(DatabaseQuotaClientTest, GetOriginsForHost) {
- DatabaseQuotaClient client(base::MessageLoopProxy::current().get(),
- mock_tracker());
-
- EXPECT_EQ(kOriginA.host(), kOriginB.host());
- EXPECT_NE(kOriginA.host(), kOriginOther.host());
-
- std::set<GURL> origins = GetOriginsForHost(&client, kTemp, kOriginA.host());
- EXPECT_TRUE(origins.empty());
-
- mock_tracker()->AddMockDatabase(kOriginA, "fooDB", 1000);
- origins = GetOriginsForHost(&client, kTemp, kOriginA.host());
- EXPECT_EQ(origins.size(), 1ul);
- EXPECT_TRUE(origins.find(kOriginA) != origins.end());
-
- mock_tracker()->AddMockDatabase(kOriginB, "barDB", 1000);
- origins = GetOriginsForHost(&client, kTemp, kOriginA.host());
- EXPECT_EQ(origins.size(), 2ul);
- EXPECT_TRUE(origins.find(kOriginA) != origins.end());
- EXPECT_TRUE(origins.find(kOriginB) != origins.end());
-
- EXPECT_TRUE(GetOriginsForHost(&client, kPerm, kOriginA.host()).empty());
- EXPECT_TRUE(GetOriginsForHost(&client, kTemp, kOriginOther.host()).empty());
-}
-
-TEST_F(DatabaseQuotaClientTest, GetOriginsForType) {
- DatabaseQuotaClient client(base::MessageLoopProxy::current().get(),
- mock_tracker());
-
- EXPECT_TRUE(GetOriginsForType(&client, kTemp).empty());
- EXPECT_TRUE(GetOriginsForType(&client, kPerm).empty());
-
- mock_tracker()->AddMockDatabase(kOriginA, "fooDB", 1000);
- std::set<GURL> origins = GetOriginsForType(&client, kTemp);
- EXPECT_EQ(origins.size(), 1ul);
- EXPECT_TRUE(origins.find(kOriginA) != origins.end());
-
- EXPECT_TRUE(GetOriginsForType(&client, kPerm).empty());
-}
-
-TEST_F(DatabaseQuotaClientTest, DeleteOriginData) {
- DatabaseQuotaClient client(base::MessageLoopProxy::current().get(),
- mock_tracker());
-
- // Perm deletions are short circuited in the Client and
- // should not reach the DatabaseTracker.
- EXPECT_TRUE(DeleteOriginData(&client, kPerm, kOriginA));
- EXPECT_EQ(0, mock_tracker()->delete_called_count());
-
- mock_tracker()->set_async_delete(false);
- EXPECT_TRUE(DeleteOriginData(&client, kTemp, kOriginA));
- EXPECT_EQ(1, mock_tracker()->delete_called_count());
-
- mock_tracker()->set_async_delete(true);
- EXPECT_TRUE(DeleteOriginData(&client, kTemp, kOriginA));
- EXPECT_EQ(2, mock_tracker()->delete_called_count());
-}
-
-} // namespace webkit_database
diff --git a/chromium/webkit/browser/database/database_tracker.cc b/chromium/webkit/browser/database/database_tracker.cc
index ae4adc9748f..ab1f6fd2806 100644
--- a/chromium/webkit/browser/database/database_tracker.cc
+++ b/chromium/webkit/browser/database/database_tracker.cc
@@ -10,9 +10,9 @@
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/file_util.h"
+#include "base/files/file.h"
#include "base/files/file_enumerator.h"
#include "base/message_loop/message_loop_proxy.h"
-#include "base/platform_file.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "net/base/net_errors.h"
@@ -23,7 +23,7 @@
#include "webkit/browser/database/database_quota_client.h"
#include "webkit/browser/database/database_util.h"
#include "webkit/browser/database/databases_table.h"
-#include "webkit/browser/quota/quota_manager.h"
+#include "webkit/browser/quota/quota_manager_proxy.h"
#include "webkit/browser/quota/special_storage_policy.h"
#include "webkit/common/database/database_identifier.h"
@@ -691,7 +691,7 @@ int DatabaseTracker::DeleteDataModifiedSince(
for (std::vector<DatabaseDetails>::const_iterator db = details.begin();
db != details.end(); ++db) {
base::FilePath db_file = GetFullDBFilePath(*ori, db->database_name);
- base::PlatformFileInfo file_info;
+ base::File::Info file_info;
base::GetFileInfo(db_file, &file_info);
if (file_info.last_modified < cutoff)
continue;
@@ -741,42 +741,42 @@ int DatabaseTracker::DeleteDataForOrigin(
return net::OK;
}
-void DatabaseTracker::GetIncognitoFileHandle(
- const base::string16& vfs_file_name,
- base::PlatformFile* file_handle) const {
+const base::File* DatabaseTracker::GetIncognitoFile(
+ const base::string16& vfs_file_name) const {
DCHECK(is_incognito_);
FileHandlesMap::const_iterator it =
incognito_file_handles_.find(vfs_file_name);
if (it != incognito_file_handles_.end())
- *file_handle = it->second;
- else
- *file_handle = base::kInvalidPlatformFileValue;
+ return it->second;
+
+ return NULL;
}
-void DatabaseTracker::SaveIncognitoFileHandle(
+const base::File* DatabaseTracker::SaveIncognitoFile(
const base::string16& vfs_file_name,
- const base::PlatformFile& file_handle) {
+ base::File file) {
DCHECK(is_incognito_);
- DCHECK(incognito_file_handles_.find(vfs_file_name) ==
- incognito_file_handles_.end());
- if (file_handle != base::kInvalidPlatformFileValue)
- incognito_file_handles_[vfs_file_name] = file_handle;
+ if (!file.IsValid())
+ return NULL;
+
+ base::File* to_insert = new base::File(file.Pass());
+ std::pair<FileHandlesMap::iterator, bool> rv =
+ incognito_file_handles_.insert(std::make_pair(vfs_file_name, to_insert));
+ DCHECK(rv.second);
+ return rv.first->second;
}
-bool DatabaseTracker::CloseIncognitoFileHandle(
+void DatabaseTracker::CloseIncognitoFileHandle(
const base::string16& vfs_file_name) {
DCHECK(is_incognito_);
DCHECK(incognito_file_handles_.find(vfs_file_name) !=
incognito_file_handles_.end());
- bool handle_closed = false;
FileHandlesMap::iterator it = incognito_file_handles_.find(vfs_file_name);
if (it != incognito_file_handles_.end()) {
- handle_closed = base::ClosePlatformFile(it->second);
- if (handle_closed)
- incognito_file_handles_.erase(it);
+ delete it->second;
+ incognito_file_handles_.erase(it);
}
- return handle_closed;
}
bool DatabaseTracker::HasSavedIncognitoFileHandle(
@@ -789,8 +789,9 @@ void DatabaseTracker::DeleteIncognitoDBDirectory() {
is_initialized_ = false;
for (FileHandlesMap::iterator it = incognito_file_handles_.begin();
- it != incognito_file_handles_.end(); it++)
- base::ClosePlatformFile(it->second);
+ it != incognito_file_handles_.end(); it++) {
+ delete it->second;
+ }
base::FilePath incognito_db_dir =
profile_path_.Append(kIncognitoDatabaseDirectoryName);
@@ -828,14 +829,11 @@ void DatabaseTracker::ClearSessionOnlyOrigins() {
for (std::vector<base::string16>::iterator database = databases.begin();
database != databases.end(); ++database) {
- base::PlatformFile file_handle = base::CreatePlatformFile(
- GetFullDBFilePath(*origin, *database),
- base::PLATFORM_FILE_OPEN_ALWAYS |
- base::PLATFORM_FILE_SHARE_DELETE |
- base::PLATFORM_FILE_DELETE_ON_CLOSE |
- base::PLATFORM_FILE_READ,
- NULL, NULL);
- base::ClosePlatformFile(file_handle);
+ base::File file(GetFullDBFilePath(*origin, *database),
+ base::File::FLAG_OPEN_ALWAYS |
+ base::File::FLAG_SHARE_DELETE |
+ base::File::FLAG_DELETE_ON_CLOSE |
+ base::File::FLAG_READ);
}
DeleteOrigin(*origin, true);
}
diff --git a/chromium/webkit/browser/database/database_tracker.h b/chromium/webkit/browser/database/database_tracker.h
index 8223d1ca9ea..4d4e567e1f6 100644
--- a/chromium/webkit/browser/database/database_tracker.h
+++ b/chromium/webkit/browser/database/database_tracker.h
@@ -9,12 +9,12 @@
#include <set>
#include <utility>
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
-#include "base/platform_file.h"
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
@@ -26,6 +26,11 @@ namespace base {
class MessageLoopProxy;
}
+namespace content {
+class DatabaseTracker_TestHelper_Test;
+class MockDatabaseTracker;
+}
+
namespace sql {
class Connection;
class MetaTable;
@@ -164,11 +169,10 @@ class WEBKIT_STORAGE_BROWSER_EXPORT DatabaseTracker
bool IsIncognitoProfile() const { return is_incognito_; }
- void GetIncognitoFileHandle(const base::string16& vfs_file_path,
- base::PlatformFile* file_handle) const;
- void SaveIncognitoFileHandle(const base::string16& vfs_file_path,
- const base::PlatformFile& file_handle);
- bool CloseIncognitoFileHandle(const base::string16& vfs_file_path);
+ const base::File* GetIncognitoFile(const base::string16& vfs_file_path) const;
+ const base::File* SaveIncognitoFile(const base::string16& vfs_file_path,
+ base::File file);
+ void CloseIncognitoFileHandle(const base::string16& vfs_file_path);
bool HasSavedIncognitoFileHandle(const base::string16& vfs_file_path) const;
// Shutdown the database tracker, deleting database files if the tracker is
@@ -179,12 +183,13 @@ class WEBKIT_STORAGE_BROWSER_EXPORT DatabaseTracker
private:
friend class base::RefCountedThreadSafe<DatabaseTracker>;
- friend class MockDatabaseTracker; // for testing
+ friend class content::DatabaseTracker_TestHelper_Test;
+ friend class content::MockDatabaseTracker; // for testing
typedef std::map<std::string, std::set<base::string16> > DatabaseSet;
typedef std::vector<std::pair<net::CompletionCallback, DatabaseSet> >
PendingDeletionCallbacks;
- typedef std::map<base::string16, base::PlatformFile> FileHandlesMap;
+ typedef std::map<base::string16, base::File*> FileHandlesMap;
typedef std::map<std::string, base::string16> OriginDirectoriesMap;
class CachedOriginInfo : public OriginInfo {
diff --git a/chromium/webkit/browser/database/database_tracker_unittest.cc b/chromium/webkit/browser/database/database_tracker_unittest.cc
deleted file mode 100644
index bb931d4cbf4..00000000000
--- a/chromium/webkit/browser/database/database_tracker_unittest.cc
+++ /dev/null
@@ -1,877 +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 "base/file_util.h"
-#include "base/files/file_path.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "base/message_loop/message_loop_proxy.h"
-#include "base/platform_file.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/time/time.h"
-#include "net/base/net_errors.h"
-#include "net/base/test_completion_callback.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/sqlite/sqlite3.h"
-#include "webkit/browser/database/database_tracker.h"
-#include "webkit/browser/quota/mock_special_storage_policy.h"
-#include "webkit/browser/quota/quota_manager.h"
-#include "webkit/common/database/database_identifier.h"
-
-namespace {
-
-const char kOrigin1Url[] = "http://origin1";
-const char kOrigin2Url[] = "http://protected_origin2";
-
-class TestObserver : public webkit_database::DatabaseTracker::Observer {
- public:
- TestObserver()
- : new_notification_received_(false),
- observe_size_changes_(true),
- observe_scheduled_deletions_(true) {
- }
- TestObserver(bool observe_size_changes, bool observe_scheduled_deletions)
- : new_notification_received_(false),
- observe_size_changes_(observe_size_changes),
- observe_scheduled_deletions_(observe_scheduled_deletions) {
- }
-
- virtual ~TestObserver() {}
- virtual void OnDatabaseSizeChanged(const std::string& origin_identifier,
- const base::string16& database_name,
- int64 database_size) OVERRIDE {
- if (!observe_size_changes_)
- return;
- new_notification_received_ = true;
- origin_identifier_ = origin_identifier;
- database_name_ = database_name;
- database_size_ = database_size;
- }
- virtual void OnDatabaseScheduledForDeletion(
- const std::string& origin_identifier,
- const base::string16& database_name) OVERRIDE {
- if (!observe_scheduled_deletions_)
- return;
- new_notification_received_ = true;
- origin_identifier_ = origin_identifier;
- database_name_ = database_name;
- }
- bool DidReceiveNewNotification() {
- bool temp_new_notification_received = new_notification_received_;
- new_notification_received_ = false;
- return temp_new_notification_received;
- }
- std::string GetNotificationOriginIdentifier() {
- return origin_identifier_;
- }
- base::string16 GetNotificationDatabaseName() { return database_name_; }
- int64 GetNotificationDatabaseSize() { return database_size_; }
-
- private:
- bool new_notification_received_;
- bool observe_size_changes_;
- bool observe_scheduled_deletions_;
- std::string origin_identifier_;
- base::string16 database_name_;
- int64 database_size_;
-};
-
-void CheckNotificationReceived(TestObserver* observer,
- const std::string& expected_origin_identifier,
- const base::string16& expected_database_name,
- int64 expected_database_size) {
- EXPECT_TRUE(observer->DidReceiveNewNotification());
- EXPECT_EQ(expected_origin_identifier,
- observer->GetNotificationOriginIdentifier());
- EXPECT_EQ(expected_database_name,
- observer->GetNotificationDatabaseName());
- EXPECT_EQ(expected_database_size,
- observer->GetNotificationDatabaseSize());
-}
-
-class TestQuotaManagerProxy : public quota::QuotaManagerProxy {
- public:
- TestQuotaManagerProxy()
- : QuotaManagerProxy(NULL, NULL),
- registered_client_(NULL) {
- }
-
- virtual void RegisterClient(quota::QuotaClient* client) OVERRIDE {
- EXPECT_FALSE(registered_client_);
- registered_client_ = client;
- }
-
- virtual void NotifyStorageAccessed(quota::QuotaClient::ID client_id,
- const GURL& origin,
- quota::StorageType type) OVERRIDE {
- EXPECT_EQ(quota::QuotaClient::kDatabase, client_id);
- EXPECT_EQ(quota::kStorageTypeTemporary, type);
- accesses_[origin] += 1;
- }
-
- virtual void NotifyStorageModified(quota::QuotaClient::ID client_id,
- const GURL& origin,
- quota::StorageType type,
- int64 delta) OVERRIDE {
- EXPECT_EQ(quota::QuotaClient::kDatabase, client_id);
- EXPECT_EQ(quota::kStorageTypeTemporary, type);
- modifications_[origin].first += 1;
- modifications_[origin].second += delta;
- }
-
- // Not needed for our tests.
- virtual void NotifyOriginInUse(const GURL& origin) OVERRIDE {}
- virtual void NotifyOriginNoLongerInUse(const GURL& origin) OVERRIDE {}
- virtual void SetUsageCacheEnabled(quota::QuotaClient::ID client_id,
- const GURL& origin,
- quota::StorageType type,
- bool enabled) OVERRIDE {}
- virtual void GetUsageAndQuota(
- base::SequencedTaskRunner* original_task_runner,
- const GURL& origin,
- quota::StorageType type,
- const GetUsageAndQuotaCallback& callback) OVERRIDE {}
-
- void SimulateQuotaManagerDestroyed() {
- if (registered_client_) {
- registered_client_->OnQuotaManagerDestroyed();
- registered_client_ = NULL;
- }
- }
-
- bool WasAccessNotified(const GURL& origin) {
- return accesses_[origin] != 0;
- }
-
- bool WasModificationNotified(const GURL& origin, int64 amount) {
- return modifications_[origin].first != 0 &&
- modifications_[origin].second == amount;
- }
-
- void reset() {
- accesses_.clear();
- modifications_.clear();
- }
-
- quota::QuotaClient* registered_client_;
-
- // Map from origin to count of access notifications.
- std::map<GURL, int> accesses_;
-
- // Map from origin to <count, sum of deltas>
- std::map<GURL, std::pair<int, int64> > modifications_;
-
- protected:
- virtual ~TestQuotaManagerProxy() {
- EXPECT_FALSE(registered_client_);
- }
-};
-
-
-bool EnsureFileOfSize(const base::FilePath& file_path, int64 length) {
- base::PlatformFileError error_code(base::PLATFORM_FILE_ERROR_FAILED);
- base::PlatformFile file =
- base::CreatePlatformFile(
- file_path,
- base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE,
- NULL,
- &error_code);
- if (error_code != base::PLATFORM_FILE_OK)
- return false;
- if (!base::TruncatePlatformFile(file, length))
- error_code = base::PLATFORM_FILE_ERROR_FAILED;
- base::ClosePlatformFile(file);
- return error_code == base::PLATFORM_FILE_OK;
-}
-
-} // namespace
-
-namespace webkit_database {
-
-// We declare a helper class, and make it a friend of DatabaseTracker using
-// the FRIEND_TEST() macro, and we implement all tests we want to run as
-// static methods of this class. Then we make our TEST() targets call these
-// static functions. This allows us to run each test in normal mode and
-// incognito mode without writing the same code twice.
-class DatabaseTracker_TestHelper_Test {
- public:
- static void TestDeleteOpenDatabase(bool incognito_mode) {
- // Initialize the tracker database.
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy =
- new quota::MockSpecialStoragePolicy;
- special_storage_policy->AddProtected(GURL(kOrigin2Url));
- scoped_refptr<DatabaseTracker> tracker(
- new DatabaseTracker(temp_dir.path(),
- incognito_mode,
- special_storage_policy.get(),
- NULL,
- NULL));
-
- // Create and open three databases.
- int64 database_size = 0;
- const std::string kOrigin1 =
- webkit_database::GetIdentifierFromOrigin(GURL(kOrigin1Url));
- const std::string kOrigin2 =
- webkit_database::GetIdentifierFromOrigin(GURL(kOrigin2Url));
- const base::string16 kDB1 = ASCIIToUTF16("db1");
- const base::string16 kDB2 = ASCIIToUTF16("db2");
- const base::string16 kDB3 = ASCIIToUTF16("db3");
- const base::string16 kDescription = ASCIIToUTF16("database_description");
-
- tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0,
- &database_size);
- tracker->DatabaseOpened(kOrigin2, kDB2, kDescription, 0,
- &database_size);
- tracker->DatabaseOpened(kOrigin2, kDB3, kDescription, 0,
- &database_size);
-
- EXPECT_TRUE(base::CreateDirectory(
- tracker->DatabaseDirectory().Append(base::FilePath::FromUTF16Unsafe(
- tracker->GetOriginDirectory(kOrigin1)))));
- EXPECT_TRUE(base::CreateDirectory(
- tracker->DatabaseDirectory().Append(base::FilePath::FromUTF16Unsafe(
- tracker->GetOriginDirectory(kOrigin2)))));
- EXPECT_EQ(1, file_util::WriteFile(
- tracker->GetFullDBFilePath(kOrigin1, kDB1), "a", 1));
- EXPECT_EQ(2, file_util::WriteFile(
- tracker->GetFullDBFilePath(kOrigin2, kDB2), "aa", 2));
- EXPECT_EQ(3, file_util::WriteFile(
- tracker->GetFullDBFilePath(kOrigin2, kDB3), "aaa", 3));
- tracker->DatabaseModified(kOrigin1, kDB1);
- tracker->DatabaseModified(kOrigin2, kDB2);
- tracker->DatabaseModified(kOrigin2, kDB3);
-
- // Delete db1. Should also delete origin1.
- TestObserver observer;
- tracker->AddObserver(&observer);
- net::TestCompletionCallback callback;
- int result = tracker->DeleteDatabase(kOrigin1, kDB1, callback.callback());
- EXPECT_EQ(net::ERR_IO_PENDING, result);
- ASSERT_FALSE(callback.have_result());
- EXPECT_TRUE(observer.DidReceiveNewNotification());
- EXPECT_EQ(kOrigin1, observer.GetNotificationOriginIdentifier());
- EXPECT_EQ(kDB1, observer.GetNotificationDatabaseName());
- tracker->DatabaseClosed(kOrigin1, kDB1);
- result = callback.GetResult(result);
- EXPECT_EQ(net::OK, result);
- EXPECT_FALSE(base::PathExists(
- tracker->DatabaseDirectory().AppendASCII(kOrigin1)));
-
- // Recreate db1.
- tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0,
- &database_size);
- EXPECT_TRUE(base::CreateDirectory(
- tracker->DatabaseDirectory().Append(base::FilePath::FromUTF16Unsafe(
- tracker->GetOriginDirectory(kOrigin1)))));
- EXPECT_EQ(1, file_util::WriteFile(
- tracker->GetFullDBFilePath(kOrigin1, kDB1), "a", 1));
- tracker->DatabaseModified(kOrigin1, kDB1);
-
- // Setup file modification times. db1 and db2 are modified now, db3 three
- // days ago.
- base::Time now = base::Time::Now();
- EXPECT_TRUE(base::TouchFile(tracker->GetFullDBFilePath(kOrigin1, kDB1),
- now, now));
- EXPECT_TRUE(base::TouchFile(tracker->GetFullDBFilePath(kOrigin2, kDB2),
- now, now));
- base::Time three_days_ago = now - base::TimeDelta::FromDays(3);
- EXPECT_TRUE(base::TouchFile(tracker->GetFullDBFilePath(kOrigin2, kDB3),
- three_days_ago, three_days_ago));
-
- // Delete databases modified since yesterday. db2 is whitelisted.
- base::Time yesterday = base::Time::Now();
- yesterday -= base::TimeDelta::FromDays(1);
- result = tracker->DeleteDataModifiedSince(
- yesterday, callback.callback());
- EXPECT_EQ(net::ERR_IO_PENDING, result);
- ASSERT_FALSE(callback.have_result());
- EXPECT_TRUE(observer.DidReceiveNewNotification());
- tracker->DatabaseClosed(kOrigin1, kDB1);
- tracker->DatabaseClosed(kOrigin2, kDB2);
- result = callback.GetResult(result);
- EXPECT_EQ(net::OK, result);
- EXPECT_FALSE(base::PathExists(
- tracker->DatabaseDirectory().AppendASCII(kOrigin1)));
- EXPECT_TRUE(
- base::PathExists(tracker->GetFullDBFilePath(kOrigin2, kDB2)));
- EXPECT_TRUE(
- base::PathExists(tracker->GetFullDBFilePath(kOrigin2, kDB3)));
-
- tracker->DatabaseClosed(kOrigin2, kDB3);
- tracker->RemoveObserver(&observer);
- }
-
- static void TestDatabaseTracker(bool incognito_mode) {
- // Initialize the tracker database.
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy =
- new quota::MockSpecialStoragePolicy;
- special_storage_policy->AddProtected(GURL(kOrigin2Url));
- scoped_refptr<DatabaseTracker> tracker(
- new DatabaseTracker(temp_dir.path(),
- incognito_mode,
- special_storage_policy.get(),
- NULL,
- NULL));
-
- // Add two observers.
- TestObserver observer1;
- TestObserver observer2;
- tracker->AddObserver(&observer1);
- tracker->AddObserver(&observer2);
-
- // Open three new databases.
- int64 database_size = 0;
- const std::string kOrigin1 =
- webkit_database::GetIdentifierFromOrigin(GURL(kOrigin1Url));
- const std::string kOrigin2 =
- webkit_database::GetIdentifierFromOrigin(GURL(kOrigin2Url));
- const base::string16 kDB1 = ASCIIToUTF16("db1");
- const base::string16 kDB2 = ASCIIToUTF16("db2");
- const base::string16 kDB3 = ASCIIToUTF16("db3");
- const base::string16 kDescription = ASCIIToUTF16("database_description");
-
- // Get the info for kOrigin1 and kOrigin2
- DatabaseTracker::CachedOriginInfo* origin1_info =
- tracker->GetCachedOriginInfo(kOrigin1);
- DatabaseTracker::CachedOriginInfo* origin2_info =
- tracker->GetCachedOriginInfo(kOrigin1);
- EXPECT_TRUE(origin1_info);
- EXPECT_TRUE(origin2_info);
-
-
- tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0,
- &database_size);
- EXPECT_EQ(0, database_size);
- tracker->DatabaseOpened(kOrigin2, kDB2, kDescription, 0,
- &database_size);
- EXPECT_EQ(0, database_size);
- tracker->DatabaseOpened(kOrigin1, kDB3, kDescription, 0,
- &database_size);
- EXPECT_EQ(0, database_size);
-
- // Write some data to each file and check that the listeners are
- // called with the appropriate values.
- EXPECT_TRUE(base::CreateDirectory(
- tracker->DatabaseDirectory().Append(base::FilePath::FromUTF16Unsafe(
- tracker->GetOriginDirectory(kOrigin1)))));
- EXPECT_TRUE(base::CreateDirectory(
- tracker->DatabaseDirectory().Append(base::FilePath::FromUTF16Unsafe(
- tracker->GetOriginDirectory(kOrigin2)))));
- EXPECT_EQ(1, file_util::WriteFile(
- tracker->GetFullDBFilePath(kOrigin1, kDB1), "a", 1));
- EXPECT_EQ(2, file_util::WriteFile(
- tracker->GetFullDBFilePath(kOrigin2, kDB2), "aa", 2));
- EXPECT_EQ(4, file_util::WriteFile(
- tracker->GetFullDBFilePath(kOrigin1, kDB3), "aaaa", 4));
- tracker->DatabaseModified(kOrigin1, kDB1);
- CheckNotificationReceived(&observer1, kOrigin1, kDB1, 1);
- CheckNotificationReceived(&observer2, kOrigin1, kDB1, 1);
- tracker->DatabaseModified(kOrigin2, kDB2);
- CheckNotificationReceived(&observer1, kOrigin2, kDB2, 2);
- CheckNotificationReceived(&observer2, kOrigin2, kDB2, 2);
- tracker->DatabaseModified(kOrigin1, kDB3);
- CheckNotificationReceived(&observer1, kOrigin1, kDB3, 4);
- CheckNotificationReceived(&observer2, kOrigin1, kDB3, 4);
-
- // Close all databases
- tracker->DatabaseClosed(kOrigin1, kDB1);
- tracker->DatabaseClosed(kOrigin2, kDB2);
- tracker->DatabaseClosed(kOrigin1, kDB3);
-
- // Open an existing database and check the reported size
- tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0,
- &database_size);
- EXPECT_EQ(1, database_size);
- tracker->DatabaseClosed(kOrigin1, kDB1);
-
- // Remove an observer; this should clear all caches.
- tracker->RemoveObserver(&observer2);
-
- // Close the tracker database and clear all caches.
- // Then make sure that DatabaseOpened() still returns the correct result.
- tracker->CloseTrackerDatabaseAndClearCaches();
- tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0,
- &database_size);
- EXPECT_EQ(1, database_size);
- tracker->DatabaseClosed(kOrigin1, kDB1);
-
- // Remove all observers.
- tracker->RemoveObserver(&observer1);
-
- // Trying to delete a database in use should fail
- tracker->DatabaseOpened(kOrigin1, kDB3, kDescription, 0,
- &database_size);
- EXPECT_FALSE(tracker->DeleteClosedDatabase(kOrigin1, kDB3));
- origin1_info = tracker->GetCachedOriginInfo(kOrigin1);
- EXPECT_TRUE(origin1_info);
- EXPECT_EQ(4, origin1_info->GetDatabaseSize(kDB3));
- tracker->DatabaseClosed(kOrigin1, kDB3);
-
- // Delete a database and make sure the space used by that origin is updated
- EXPECT_TRUE(tracker->DeleteClosedDatabase(kOrigin1, kDB3));
- origin1_info = tracker->GetCachedOriginInfo(kOrigin1);
- EXPECT_TRUE(origin1_info);
- EXPECT_EQ(1, origin1_info->GetDatabaseSize(kDB1));
- EXPECT_EQ(0, origin1_info->GetDatabaseSize(kDB3));
-
- // Get all data for all origins
- std::vector<OriginInfo> origins_info;
- EXPECT_TRUE(tracker->GetAllOriginsInfo(&origins_info));
- EXPECT_EQ(size_t(2), origins_info.size());
- EXPECT_EQ(kOrigin1, origins_info[0].GetOriginIdentifier());
- EXPECT_EQ(1, origins_info[0].TotalSize());
- EXPECT_EQ(1, origins_info[0].GetDatabaseSize(kDB1));
- EXPECT_EQ(0, origins_info[0].GetDatabaseSize(kDB3));
-
- EXPECT_EQ(kOrigin2, origins_info[1].GetOriginIdentifier());
- EXPECT_EQ(2, origins_info[1].TotalSize());
-
- // Trying to delete an origin with databases in use should fail
- tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0,
- &database_size);
- EXPECT_FALSE(tracker->DeleteOrigin(kOrigin1, false));
- origin1_info = tracker->GetCachedOriginInfo(kOrigin1);
- EXPECT_TRUE(origin1_info);
- EXPECT_EQ(1, origin1_info->GetDatabaseSize(kDB1));
- tracker->DatabaseClosed(kOrigin1, kDB1);
-
- // Delete an origin that doesn't have any database in use
- EXPECT_TRUE(tracker->DeleteOrigin(kOrigin1, false));
- origins_info.clear();
- EXPECT_TRUE(tracker->GetAllOriginsInfo(&origins_info));
- EXPECT_EQ(size_t(1), origins_info.size());
- EXPECT_EQ(kOrigin2, origins_info[0].GetOriginIdentifier());
-
- origin1_info = tracker->GetCachedOriginInfo(kOrigin1);
- EXPECT_TRUE(origin1_info);
- EXPECT_EQ(0, origin1_info->TotalSize());
- }
-
- static void DatabaseTrackerQuotaIntegration() {
- const GURL kOrigin(kOrigin1Url);
- const std::string kOriginId =
- webkit_database::GetIdentifierFromOrigin(kOrigin);
- const base::string16 kName = ASCIIToUTF16("name");
- const base::string16 kDescription = ASCIIToUTF16("description");
-
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
-
- // Initialize the tracker with a QuotaManagerProxy
- scoped_refptr<TestQuotaManagerProxy> test_quota_proxy(
- new TestQuotaManagerProxy);
- scoped_refptr<DatabaseTracker> tracker(
- new DatabaseTracker(temp_dir.path(),
- false /* incognito */,
- NULL,
- test_quota_proxy.get(),
- NULL));
- EXPECT_TRUE(test_quota_proxy->registered_client_);
-
- // Create a database and modify it a couple of times, close it,
- // then delete it. Observe the tracker notifies accordingly.
-
- int64 database_size = 0;
- tracker->DatabaseOpened(kOriginId, kName, kDescription, 0,
- &database_size);
- EXPECT_TRUE(test_quota_proxy->WasAccessNotified(kOrigin));
- test_quota_proxy->reset();
-
- base::FilePath db_file(tracker->GetFullDBFilePath(kOriginId, kName));
- EXPECT_TRUE(base::CreateDirectory(db_file.DirName()));
- EXPECT_TRUE(EnsureFileOfSize(db_file, 10));
- tracker->DatabaseModified(kOriginId, kName);
- EXPECT_TRUE(test_quota_proxy->WasModificationNotified(kOrigin, 10));
- test_quota_proxy->reset();
-
- EXPECT_TRUE(EnsureFileOfSize(db_file, 100));
- tracker->DatabaseModified(kOriginId, kName);
- EXPECT_TRUE(test_quota_proxy->WasModificationNotified(kOrigin, 90));
- test_quota_proxy->reset();
-
- tracker->DatabaseClosed(kOriginId, kName);
- EXPECT_TRUE(test_quota_proxy->WasAccessNotified(kOrigin));
- EXPECT_EQ(net::OK, tracker->DeleteDatabase(
- kOriginId, kName, net::CompletionCallback()));
- EXPECT_TRUE(test_quota_proxy->WasModificationNotified(kOrigin, -100));
- test_quota_proxy->reset();
-
- // Create a database and modify it, try to delete it while open,
- // then close it (at which time deletion will actually occur).
- // Observe the tracker notifies accordingly.
-
- tracker->DatabaseOpened(kOriginId, kName, kDescription, 0,
- &database_size);
- EXPECT_TRUE(test_quota_proxy->WasAccessNotified(kOrigin));
- test_quota_proxy->reset();
-
- db_file = tracker->GetFullDBFilePath(kOriginId, kName);
- EXPECT_TRUE(base::CreateDirectory(db_file.DirName()));
- EXPECT_TRUE(EnsureFileOfSize(db_file, 100));
- tracker->DatabaseModified(kOriginId, kName);
- EXPECT_TRUE(test_quota_proxy->WasModificationNotified(kOrigin, 100));
- test_quota_proxy->reset();
-
- EXPECT_EQ(net::ERR_IO_PENDING,
- tracker->DeleteDatabase(kOriginId, kName,
- net::CompletionCallback()));
- EXPECT_FALSE(test_quota_proxy->WasModificationNotified(kOrigin, -100));
-
- tracker->DatabaseClosed(kOriginId, kName);
- EXPECT_TRUE(test_quota_proxy->WasAccessNotified(kOrigin));
- EXPECT_TRUE(test_quota_proxy->WasModificationNotified(kOrigin, -100));
- test_quota_proxy->reset();
-
- // Create a database and up the file size without telling
- // the tracker about the modification, than simulate a
- // a renderer crash.
- // Observe the tracker notifies accordingly.
-
- tracker->DatabaseOpened(kOriginId, kName, kDescription, 0,
- &database_size);
- EXPECT_TRUE(test_quota_proxy->WasAccessNotified(kOrigin));
- test_quota_proxy->reset();
- db_file = tracker->GetFullDBFilePath(kOriginId, kName);
- EXPECT_TRUE(base::CreateDirectory(db_file.DirName()));
- EXPECT_TRUE(EnsureFileOfSize(db_file, 100));
- DatabaseConnections crashed_renderer_connections;
- crashed_renderer_connections.AddConnection(kOriginId, kName);
- EXPECT_FALSE(test_quota_proxy->WasModificationNotified(kOrigin, 100));
- tracker->CloseDatabases(crashed_renderer_connections);
- EXPECT_TRUE(test_quota_proxy->WasModificationNotified(kOrigin, 100));
-
- // Cleanup.
- crashed_renderer_connections.RemoveAllConnections();
- test_quota_proxy->SimulateQuotaManagerDestroyed();
- }
-
- static void DatabaseTrackerClearSessionOnlyDatabasesOnExit() {
- int64 database_size = 0;
- const std::string kOrigin1 =
- webkit_database::GetIdentifierFromOrigin(GURL(kOrigin1Url));
- const std::string kOrigin2 =
- webkit_database::GetIdentifierFromOrigin(GURL(kOrigin2Url));
- const base::string16 kDB1 = ASCIIToUTF16("db1");
- const base::string16 kDB2 = ASCIIToUTF16("db2");
- const base::string16 kDescription = ASCIIToUTF16("database_description");
-
- // Initialize the tracker database.
- base::MessageLoop message_loop;
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- base::FilePath origin1_db_dir;
- base::FilePath origin2_db_dir;
- {
- scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy =
- new quota::MockSpecialStoragePolicy;
- special_storage_policy->AddSessionOnly(GURL(kOrigin2Url));
- scoped_refptr<DatabaseTracker> tracker(
- new DatabaseTracker(temp_dir.path(),
- false,
- special_storage_policy.get(),
- NULL,
- base::MessageLoopProxy::current().get()));
-
- // Open two new databases.
- tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0,
- &database_size);
- EXPECT_EQ(0, database_size);
- tracker->DatabaseOpened(kOrigin2, kDB2, kDescription, 0,
- &database_size);
- EXPECT_EQ(0, database_size);
-
- // Write some data to each file.
- base::FilePath db_file;
- db_file = tracker->GetFullDBFilePath(kOrigin1, kDB1);
- EXPECT_TRUE(base::CreateDirectory(db_file.DirName()));
- EXPECT_TRUE(EnsureFileOfSize(db_file, 1));
-
- db_file = tracker->GetFullDBFilePath(kOrigin2, kDB2);
- EXPECT_TRUE(base::CreateDirectory(db_file.DirName()));
- EXPECT_TRUE(EnsureFileOfSize(db_file, 2));
-
- // Store the origin database directories as long as they still exist.
- origin1_db_dir = tracker->GetFullDBFilePath(kOrigin1, kDB1).DirName();
- origin2_db_dir = tracker->GetFullDBFilePath(kOrigin2, kDB2).DirName();
-
- tracker->DatabaseModified(kOrigin1, kDB1);
- tracker->DatabaseModified(kOrigin2, kDB2);
-
- // Close all databases.
- tracker->DatabaseClosed(kOrigin1, kDB1);
- tracker->DatabaseClosed(kOrigin2, kDB2);
-
- tracker->Shutdown();
- }
-
- // At this point, the database tracker should be gone. Create a new one.
- scoped_refptr<DatabaseTracker> tracker(
- new DatabaseTracker(temp_dir.path(), false, NULL, NULL, NULL));
-
- // Get all data for all origins.
- std::vector<OriginInfo> origins_info;
- EXPECT_TRUE(tracker->GetAllOriginsInfo(&origins_info));
- // kOrigin1 was not session-only, so it survived. kOrigin2 was session-only
- // and it got deleted.
- EXPECT_EQ(size_t(1), origins_info.size());
- EXPECT_EQ(kOrigin1, origins_info[0].GetOriginIdentifier());
- EXPECT_TRUE(
- base::PathExists(tracker->GetFullDBFilePath(kOrigin1, kDB1)));
- EXPECT_EQ(base::FilePath(), tracker->GetFullDBFilePath(kOrigin2, kDB2));
-
- // The origin directory of kOrigin1 remains, but the origin directory of
- // kOrigin2 is deleted.
- EXPECT_TRUE(base::PathExists(origin1_db_dir));
- EXPECT_FALSE(base::PathExists(origin2_db_dir));
- }
-
- static void DatabaseTrackerSetForceKeepSessionState() {
- int64 database_size = 0;
- const std::string kOrigin1 =
- webkit_database::GetIdentifierFromOrigin(GURL(kOrigin1Url));
- const std::string kOrigin2 =
- webkit_database::GetIdentifierFromOrigin(GURL(kOrigin2Url));
- const base::string16 kDB1 = ASCIIToUTF16("db1");
- const base::string16 kDB2 = ASCIIToUTF16("db2");
- const base::string16 kDescription = ASCIIToUTF16("database_description");
-
- // Initialize the tracker database.
- base::MessageLoop message_loop;
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- base::FilePath origin1_db_dir;
- base::FilePath origin2_db_dir;
- {
- scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy =
- new quota::MockSpecialStoragePolicy;
- special_storage_policy->AddSessionOnly(GURL(kOrigin2Url));
- scoped_refptr<DatabaseTracker> tracker(
- new DatabaseTracker(temp_dir.path(),
- false,
- special_storage_policy.get(),
- NULL,
- base::MessageLoopProxy::current().get()));
- tracker->SetForceKeepSessionState();
-
- // Open two new databases.
- tracker->DatabaseOpened(kOrigin1, kDB1, kDescription, 0,
- &database_size);
- EXPECT_EQ(0, database_size);
- tracker->DatabaseOpened(kOrigin2, kDB2, kDescription, 0,
- &database_size);
- EXPECT_EQ(0, database_size);
-
- // Write some data to each file.
- base::FilePath db_file;
- db_file = tracker->GetFullDBFilePath(kOrigin1, kDB1);
- EXPECT_TRUE(base::CreateDirectory(db_file.DirName()));
- EXPECT_TRUE(EnsureFileOfSize(db_file, 1));
-
- db_file = tracker->GetFullDBFilePath(kOrigin2, kDB2);
- EXPECT_TRUE(base::CreateDirectory(db_file.DirName()));
- EXPECT_TRUE(EnsureFileOfSize(db_file, 2));
-
- // Store the origin database directories as long as they still exist.
- origin1_db_dir = tracker->GetFullDBFilePath(kOrigin1, kDB1).DirName();
- origin2_db_dir = tracker->GetFullDBFilePath(kOrigin2, kDB2).DirName();
-
- tracker->DatabaseModified(kOrigin1, kDB1);
- tracker->DatabaseModified(kOrigin2, kDB2);
-
- // Close all databases.
- tracker->DatabaseClosed(kOrigin1, kDB1);
- tracker->DatabaseClosed(kOrigin2, kDB2);
-
- tracker->Shutdown();
- }
-
- // At this point, the database tracker should be gone. Create a new one.
- scoped_refptr<DatabaseTracker> tracker(
- new DatabaseTracker(temp_dir.path(), false, NULL, NULL, NULL));
-
- // Get all data for all origins.
- std::vector<OriginInfo> origins_info;
- EXPECT_TRUE(tracker->GetAllOriginsInfo(&origins_info));
- // No origins were deleted.
- EXPECT_EQ(size_t(2), origins_info.size());
- EXPECT_TRUE(
- base::PathExists(tracker->GetFullDBFilePath(kOrigin1, kDB1)));
- EXPECT_TRUE(
- base::PathExists(tracker->GetFullDBFilePath(kOrigin2, kDB2)));
-
- EXPECT_TRUE(base::PathExists(origin1_db_dir));
- EXPECT_TRUE(base::PathExists(origin2_db_dir));
- }
-
- static void EmptyDatabaseNameIsValid() {
- const GURL kOrigin(kOrigin1Url);
- const std::string kOriginId =
- webkit_database::GetIdentifierFromOrigin(kOrigin);
- const base::string16 kEmptyName;
- const base::string16 kDescription(ASCIIToUTF16("description"));
- const base::string16 kChangedDescription(
- ASCIIToUTF16("changed_description"));
-
- // Initialize a tracker database, no need to put it on disk.
- const bool kUseInMemoryTrackerDatabase = true;
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- scoped_refptr<DatabaseTracker> tracker(
- new DatabaseTracker(temp_dir.path(), kUseInMemoryTrackerDatabase,
- NULL, NULL, NULL));
-
- // Starts off with no databases.
- std::vector<OriginInfo> infos;
- EXPECT_TRUE(tracker->GetAllOriginsInfo(&infos));
- EXPECT_TRUE(infos.empty());
-
- // Create a db with an empty name.
- int64 database_size = -1;
- tracker->DatabaseOpened(kOriginId, kEmptyName, kDescription, 0,
- &database_size);
- EXPECT_EQ(0, database_size);
- tracker->DatabaseModified(kOriginId, kEmptyName);
- EXPECT_TRUE(tracker->GetAllOriginsInfo(&infos));
- EXPECT_EQ(1u, infos.size());
- EXPECT_EQ(kDescription, infos[0].GetDatabaseDescription(kEmptyName));
- EXPECT_FALSE(tracker->GetFullDBFilePath(kOriginId, kEmptyName).empty());
- tracker->DatabaseOpened(kOriginId, kEmptyName, kChangedDescription, 0,
- &database_size);
- infos.clear();
- EXPECT_TRUE(tracker->GetAllOriginsInfo(&infos));
- EXPECT_EQ(1u, infos.size());
- EXPECT_EQ(kChangedDescription, infos[0].GetDatabaseDescription(kEmptyName));
- tracker->DatabaseClosed(kOriginId, kEmptyName);
- tracker->DatabaseClosed(kOriginId, kEmptyName);
-
- // Deleting it should return to the initial state.
- EXPECT_EQ(net::OK, tracker->DeleteDatabase(kOriginId, kEmptyName,
- net::CompletionCallback()));
- infos.clear();
- EXPECT_TRUE(tracker->GetAllOriginsInfo(&infos));
- EXPECT_TRUE(infos.empty());
- }
-
- static void HandleSqliteError() {
- const GURL kOrigin(kOrigin1Url);
- const std::string kOriginId =
- webkit_database::GetIdentifierFromOrigin(kOrigin);
- const base::string16 kName(ASCIIToUTF16("name"));
- const base::string16 kDescription(ASCIIToUTF16("description"));
-
- // Initialize a tracker database, no need to put it on disk.
- const bool kUseInMemoryTrackerDatabase = true;
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- scoped_refptr<DatabaseTracker> tracker(
- new DatabaseTracker(temp_dir.path(), kUseInMemoryTrackerDatabase,
- NULL, NULL, NULL));
-
- // Setup to observe OnScheduledForDelete notifications.
- TestObserver observer(false, true);
- tracker->AddObserver(&observer);
-
- // Verify does no harm when there is no such database.
- tracker->HandleSqliteError(kOriginId, kName, SQLITE_CORRUPT);
- EXPECT_FALSE(tracker->IsDatabaseScheduledForDeletion(kOriginId, kName));
- EXPECT_FALSE(observer.DidReceiveNewNotification());
-
- // --------------------------------------------------------
- // Create a record of a database in the tracker db and create
- // a spoof_db_file on disk in the expected location.
- int64 database_size = 0;
- tracker->DatabaseOpened(kOriginId, kName, kDescription, 0,
- &database_size);
- base::FilePath spoof_db_file = tracker->GetFullDBFilePath(kOriginId, kName);
- EXPECT_FALSE(tracker->GetFullDBFilePath(kOriginId, kName).empty());
- EXPECT_TRUE(base::CreateDirectory(spoof_db_file.DirName()));
- EXPECT_TRUE(EnsureFileOfSize(spoof_db_file, 1));
-
- // Verify does no harm with a non-error is reported.
- tracker->HandleSqliteError(kOriginId, kName, SQLITE_OK);
- EXPECT_FALSE(tracker->IsDatabaseScheduledForDeletion(kOriginId, kName));
- EXPECT_FALSE(observer.DidReceiveNewNotification());
-
- // Verify that with a connection open, the db is scheduled for deletion,
- // but that the file still exists.
- tracker->HandleSqliteError(kOriginId, kName, SQLITE_CORRUPT);
- EXPECT_TRUE(tracker->IsDatabaseScheduledForDeletion(kOriginId, kName));
- EXPECT_TRUE(observer.DidReceiveNewNotification());
- EXPECT_TRUE(base::PathExists(spoof_db_file));
-
- // Verify that once closed, the file is deleted and the record in the
- // tracker db is removed.
- tracker->DatabaseClosed(kOriginId, kName);
- EXPECT_FALSE(base::PathExists(spoof_db_file));
- EXPECT_TRUE(tracker->GetFullDBFilePath(kOriginId, kName).empty());
-
- // --------------------------------------------------------
- // Create another record of a database in the tracker db and create
- // a spoof_db_file on disk in the expected location.
- tracker->DatabaseOpened(kOriginId, kName, kDescription, 0,
- &database_size);
- base::FilePath spoof_db_file2 = tracker->GetFullDBFilePath(kOriginId, kName);
- EXPECT_FALSE(tracker->GetFullDBFilePath(kOriginId, kName).empty());
- EXPECT_NE(spoof_db_file, spoof_db_file2);
- EXPECT_TRUE(base::CreateDirectory(spoof_db_file2.DirName()));
- EXPECT_TRUE(EnsureFileOfSize(spoof_db_file2, 1));
-
- // Verify that with no connection open, the db is deleted immediately.
- tracker->DatabaseClosed(kOriginId, kName);
- tracker->HandleSqliteError(kOriginId, kName, SQLITE_CORRUPT);
- EXPECT_FALSE(tracker->IsDatabaseScheduledForDeletion(kOriginId, kName));
- EXPECT_FALSE(observer.DidReceiveNewNotification());
- EXPECT_TRUE(tracker->GetFullDBFilePath(kOriginId, kName).empty());
- EXPECT_FALSE(base::PathExists(spoof_db_file2));
-
- tracker->RemoveObserver(&observer);
- }
-};
-
-TEST(DatabaseTrackerTest, DeleteOpenDatabase) {
- DatabaseTracker_TestHelper_Test::TestDeleteOpenDatabase(false);
-}
-
-TEST(DatabaseTrackerTest, DeleteOpenDatabaseIncognitoMode) {
- DatabaseTracker_TestHelper_Test::TestDeleteOpenDatabase(true);
-}
-
-TEST(DatabaseTrackerTest, DatabaseTracker) {
- DatabaseTracker_TestHelper_Test::TestDatabaseTracker(false);
-}
-
-TEST(DatabaseTrackerTest, DatabaseTrackerIncognitoMode) {
- DatabaseTracker_TestHelper_Test::TestDatabaseTracker(true);
-}
-
-TEST(DatabaseTrackerTest, DatabaseTrackerQuotaIntegration) {
- // There is no difference in behavior between incognito and not.
- DatabaseTracker_TestHelper_Test::DatabaseTrackerQuotaIntegration();
-}
-
-TEST(DatabaseTrackerTest, DatabaseTrackerClearSessionOnlyDatabasesOnExit) {
- // Only works for regular mode.
- DatabaseTracker_TestHelper_Test::
- DatabaseTrackerClearSessionOnlyDatabasesOnExit();
-}
-
-TEST(DatabaseTrackerTest, DatabaseTrackerSetForceKeepSessionState) {
- // Only works for regular mode.
- DatabaseTracker_TestHelper_Test::DatabaseTrackerSetForceKeepSessionState();
-}
-
-TEST(DatabaseTrackerTest, EmptyDatabaseNameIsValid) {
- DatabaseTracker_TestHelper_Test::EmptyDatabaseNameIsValid();
-}
-
-TEST(DatabaseTrackerTest, HandleSqliteError) {
- DatabaseTracker_TestHelper_Test::HandleSqliteError();
-}
-
-} // namespace webkit_database
diff --git a/chromium/webkit/browser/database/database_util.cc b/chromium/webkit/browser/database/database_util.cc
index f037638b208..14a54551ae7 100644
--- a/chromium/webkit/browser/database/database_util.cc
+++ b/chromium/webkit/browser/database/database_util.cc
@@ -8,9 +8,30 @@
#include "base/strings/utf_string_conversions.h"
#include "webkit/browser/database/database_tracker.h"
#include "webkit/browser/database/vfs_backend.h"
+#include "webkit/common/database/database_identifier.h"
namespace webkit_database {
+namespace {
+
+bool IsSafeSuffix(const base::string16& suffix) {
+ base::char16 prev_c = 0;
+ for (base::string16::const_iterator it = suffix.begin();
+ it < suffix.end(); ++it) {
+ base::char16 c = *it;
+ if (!(IsAsciiAlpha(c) || IsAsciiDigit(c) ||
+ c == '-' || c == '.' || c == '_')) {
+ return false;
+ }
+ if (c == '.' && prev_c == '.')
+ return false;
+ prev_c = c;
+ }
+ return true;
+}
+
+}
+
const char DatabaseUtil::kJournalFileSuffix[] = "-journal";
bool DatabaseUtil::CrackVfsFileName(const base::string16& vfs_file_name,
@@ -31,18 +52,27 @@ bool DatabaseUtil::CrackVfsFileName(const base::string16& vfs_file_name,
return false;
}
- if (origin_identifier) {
- *origin_identifier = UTF16ToASCII(
+ std::string origin_id = base::UTF16ToASCII(
vfs_file_name.substr(0, first_slash_index));
- }
+ if (!IsValidOriginIdentifier(origin_id))
+ return false;
+
+ base::string16 suffix = vfs_file_name.substr(
+ last_pound_index + 1, vfs_file_name.length() - last_pound_index - 1);
+ if (!IsSafeSuffix(suffix))
+ return false;
+
+ if (origin_identifier)
+ *origin_identifier = origin_id;
+
if (database_name) {
*database_name = vfs_file_name.substr(
first_slash_index + 1, last_pound_index - first_slash_index - 1);
}
- if (sqlite_suffix) {
- *sqlite_suffix = vfs_file_name.substr(
- last_pound_index + 1, vfs_file_name.length() - last_pound_index - 1);
- }
+
+ if (sqlite_suffix)
+ *sqlite_suffix = suffix;
+
return true;
}
@@ -61,7 +91,7 @@ base::FilePath DatabaseUtil::GetFullFilePathForVfsFile(
if (!full_path.empty() && !sqlite_suffix.empty()) {
DCHECK(full_path.Extension().empty());
full_path = full_path.InsertBeforeExtensionASCII(
- UTF16ToASCII(sqlite_suffix));
+ base::UTF16ToASCII(sqlite_suffix));
}
// Watch out for directory traversal attempts from a compromised renderer.
if (full_path.value().find(FILE_PATH_LITERAL("..")) !=
@@ -72,14 +102,7 @@ base::FilePath DatabaseUtil::GetFullFilePathForVfsFile(
bool DatabaseUtil::IsValidOriginIdentifier(
const std::string& origin_identifier) {
- std::string dotdot = "..";
- char forbidden[] = {'\\', '/', '\0'};
-
- std::string::size_type pos = origin_identifier.find(dotdot);
- if (pos == std::string::npos)
- pos = origin_identifier.find_first_of(forbidden, 0, arraysize(forbidden));
-
- return pos == std::string::npos;
+ return GetOriginFromIdentifier(origin_identifier).is_valid();
}
} // namespace webkit_database
diff --git a/chromium/webkit/browser/database/database_util_unittest.cc b/chromium/webkit/browser/database/database_util_unittest.cc
deleted file mode 100644
index e776b79010f..00000000000
--- a/chromium/webkit/browser/database/database_util_unittest.cc
+++ /dev/null
@@ -1,74 +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.
-
-#include "base/strings/string_piece.h"
-#include "base/strings/utf_string_conversions.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/database/database_util.h"
-#include "webkit/common/database/database_identifier.h"
-
-using webkit_database::DatabaseUtil;
-
-static void TestVfsFilePath(bool expected_result,
- const char* vfs_file_name,
- const char* expected_origin_identifier = "",
- const char* expected_database_name = "",
- const char* expected_sqlite_suffix = "") {
- std::string origin_identifier;
- base::string16 database_name;
- base::string16 sqlite_suffix;
- EXPECT_EQ(expected_result,
- DatabaseUtil::CrackVfsFileName(ASCIIToUTF16(vfs_file_name),
- &origin_identifier,
- &database_name,
- &sqlite_suffix));
- EXPECT_EQ(expected_origin_identifier, origin_identifier);
- EXPECT_EQ(ASCIIToUTF16(expected_database_name), database_name);
- EXPECT_EQ(ASCIIToUTF16(expected_sqlite_suffix), sqlite_suffix);
-}
-
-static GURL ToAndFromOriginIdentifier(const GURL origin_url) {
- std::string id = webkit_database::GetIdentifierFromOrigin(origin_url);
- return webkit_database::GetOriginFromIdentifier(id);
-}
-
-static void TestValidOriginIdentifier(bool expected_result,
- const std::string& id) {
- EXPECT_EQ(expected_result,
- DatabaseUtil::IsValidOriginIdentifier(id));
-}
-
-namespace webkit_database {
-
-// Test DatabaseUtil::CrackVfsFilePath on various inputs.
-TEST(DatabaseUtilTest, CrackVfsFilePathTest) {
- TestVfsFilePath(true, "origin/#", "origin", "", "");
- TestVfsFilePath(true, "origin/#suffix", "origin", "", "suffix");
- TestVfsFilePath(true, "origin/db_name#", "origin", "db_name", "");
- TestVfsFilePath(true, "origin/db_name#suffix", "origin", "db_name", "suffix");
- TestVfsFilePath(false, "origindb_name#");
- TestVfsFilePath(false, "origindb_name#suffix");
- TestVfsFilePath(false, "origin/db_name");
- TestVfsFilePath(false, "origin#db_name/suffix");
- TestVfsFilePath(false, "/db_name#");
- TestVfsFilePath(false, "/db_name#suffix");
-}
-
-TEST(DatabaseUtilTest, OriginIdentifiers) {
- const GURL kFileOrigin(GURL("file:///").GetOrigin());
- const GURL kHttpOrigin(GURL("http://bar/").GetOrigin());
- EXPECT_EQ(kFileOrigin, ToAndFromOriginIdentifier(kFileOrigin));
- EXPECT_EQ(kHttpOrigin, ToAndFromOriginIdentifier(kHttpOrigin));
-}
-
-TEST(DatabaseUtilTest, IsValidOriginIdentifier) {
- TestValidOriginIdentifier(true, "http_bar_0");
- TestValidOriginIdentifier(true, "");
- TestValidOriginIdentifier(false, "bad..id");
- TestValidOriginIdentifier(false, "bad/id");
- TestValidOriginIdentifier(false, "bad\\id");
- TestValidOriginIdentifier(false, std::string("bad\0id", 6));
-}
-
-} // namespace webkit_database
diff --git a/chromium/webkit/browser/database/databases_table_unittest.cc b/chromium/webkit/browser/database/databases_table_unittest.cc
deleted file mode 100644
index 09023f9c82b..00000000000
--- a/chromium/webkit/browser/database/databases_table_unittest.cc
+++ /dev/null
@@ -1,148 +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 "base/bind.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "sql/connection.h"
-#include "sql/statement.h"
-#include "sql/test/scoped_error_ignorer.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/sqlite/sqlite3.h"
-#include "webkit/browser/database/databases_table.h"
-
-namespace webkit_database {
-
-static void CheckDetailsAreEqual(const DatabaseDetails& d1,
- const DatabaseDetails& d2) {
- EXPECT_EQ(d1.origin_identifier, d2.origin_identifier);
- EXPECT_EQ(d1.database_name, d2.database_name);
- EXPECT_EQ(d1.description, d2.description);
- EXPECT_EQ(d1.estimated_size, d2.estimated_size);
-}
-
-static bool DatabasesTableIsEmpty(sql::Connection* db) {
- sql::Statement statement(db->GetCachedStatement(
- SQL_FROM_HERE, "SELECT COUNT(*) FROM Databases"));
- return (statement.is_valid() && statement.Step() && !statement.ColumnInt(0));
-}
-
-TEST(DatabasesTableTest, TestIt) {
- // Initialize the 'Databases' table.
- sql::Connection db;
-
- sql::ScopedErrorIgnorer ignore_errors;
- // TODO(shess): Suppressing SQLITE_CONSTRAINT because the code
- // expects that and handles the resulting error. Consider revising
- // the code to use INSERT OR IGNORE (which would not throw
- // SQLITE_CONSTRAINT) and then check ChangeCount() to see if any
- // changes were made.
- ignore_errors.IgnoreError(SQLITE_CONSTRAINT);
-
- // Initialize the temp dir and the 'Databases' table.
- EXPECT_TRUE(db.OpenInMemory());
- DatabasesTable databases_table(&db);
- EXPECT_TRUE(databases_table.Init());
-
- // The 'Databases' table should be empty.
- EXPECT_TRUE(DatabasesTableIsEmpty(&db));
-
- // Create the details for a databases.
- DatabaseDetails details_in1;
- DatabaseDetails details_out1;
- details_in1.origin_identifier = "origin1";
- details_in1.database_name = ASCIIToUTF16("db1");
- details_in1.description = ASCIIToUTF16("description_db1");
- details_in1.estimated_size = 100;
-
- // Updating details for this database should fail.
- EXPECT_FALSE(databases_table.UpdateDatabaseDetails(details_in1));
- EXPECT_FALSE(databases_table.GetDatabaseDetails(
- details_in1.origin_identifier,
- details_in1.database_name,
- &details_out1));
-
- // Inserting details for this database should pass.
- EXPECT_TRUE(databases_table.InsertDatabaseDetails(details_in1));
- EXPECT_TRUE(databases_table.GetDatabaseDetails(
- details_in1.origin_identifier,
- details_in1.database_name,
- &details_out1));
- EXPECT_EQ(1, databases_table.GetDatabaseID(details_in1.origin_identifier,
- details_in1.database_name));
-
- // Check that the details were correctly written to the database.
- CheckDetailsAreEqual(details_in1, details_out1);
-
- // Check that inserting a duplicate row fails.
- EXPECT_FALSE(databases_table.InsertDatabaseDetails(details_in1));
-
- // Insert details for another database with the same origin.
- DatabaseDetails details_in2;
- details_in2.origin_identifier = "origin1";
- details_in2.database_name = ASCIIToUTF16("db2");
- details_in2.description = ASCIIToUTF16("description_db2");
- details_in2.estimated_size = 200;
- EXPECT_TRUE(databases_table.InsertDatabaseDetails(details_in2));
- EXPECT_EQ(2, databases_table.GetDatabaseID(details_in2.origin_identifier,
- details_in2.database_name));
-
- // Insert details for a third database with a different origin.
- DatabaseDetails details_in3;
- details_in3.origin_identifier = "origin2";
- details_in3.database_name = ASCIIToUTF16("db3");
- details_in3.description = ASCIIToUTF16("description_db3");
- details_in3.estimated_size = 300;
- EXPECT_TRUE(databases_table.InsertDatabaseDetails(details_in3));
- EXPECT_EQ(3, databases_table.GetDatabaseID(details_in3.origin_identifier,
- details_in3.database_name));
-
- // There should be no database with origin "origin3".
- std::vector<DatabaseDetails> details_out_origin3;
- EXPECT_TRUE(databases_table.GetAllDatabaseDetailsForOriginIdentifier(
- "origin3", &details_out_origin3));
- EXPECT_TRUE(details_out_origin3.empty());
-
- // There should be only two databases with origin "origin1".
- std::vector<DatabaseDetails> details_out_origin1;
- EXPECT_TRUE(databases_table.GetAllDatabaseDetailsForOriginIdentifier(
- details_in1.origin_identifier, &details_out_origin1));
- EXPECT_EQ(size_t(2), details_out_origin1.size());
- CheckDetailsAreEqual(details_in1, details_out_origin1[0]);
- CheckDetailsAreEqual(details_in2, details_out_origin1[1]);
-
- // Get the list of all origins: should be "origin1" and "origin2".
- std::vector<std::string> origins_out;
- EXPECT_TRUE(databases_table.GetAllOriginIdentifiers(&origins_out));
- EXPECT_EQ(size_t(2), origins_out.size());
- EXPECT_EQ(details_in1.origin_identifier, origins_out[0]);
- EXPECT_EQ(details_in3.origin_identifier, origins_out[1]);
-
- // Delete an origin and check that it's no longer in the table.
- origins_out.clear();
- EXPECT_TRUE(databases_table.DeleteOriginIdentifier(
- details_in3.origin_identifier));
- EXPECT_TRUE(databases_table.GetAllOriginIdentifiers(&origins_out));
- EXPECT_EQ(size_t(1), origins_out.size());
- EXPECT_EQ(details_in1.origin_identifier, origins_out[0]);
-
- // Deleting an origin that doesn't have any record in this table should fail.
- EXPECT_FALSE(databases_table.DeleteOriginIdentifier("unknown_origin"));
-
- // Delete the details for 'db1' and check that they're no longer there.
- EXPECT_TRUE(databases_table.DeleteDatabaseDetails(
- details_in1.origin_identifier, details_in1.database_name));
- EXPECT_FALSE(databases_table.GetDatabaseDetails(
- details_in1.origin_identifier,
- details_in1.database_name,
- &details_out1));
-
- // Check that trying to delete a record that doesn't exist fails.
- EXPECT_FALSE(databases_table.DeleteDatabaseDetails(
- "unknown_origin", ASCIIToUTF16("unknown_database")));
-
- ASSERT_TRUE(ignore_errors.CheckIgnoredErrors());
-}
-
-} // namespace webkit_database
diff --git a/chromium/webkit/browser/database/vfs_backend.cc b/chromium/webkit/browser/database/vfs_backend.cc
index 3f51c2e2e7d..019e8b96dcb 100644
--- a/chromium/webkit/browser/database/vfs_backend.cc
+++ b/chromium/webkit/browser/database/vfs_backend.cc
@@ -55,67 +55,60 @@ bool VfsBackend::OpenFileFlagsAreConsistent(int desired_flags) {
}
// static
-void VfsBackend::OpenFile(const base::FilePath& file_path,
- int desired_flags,
- base::PlatformFile* file_handle) {
+base::File VfsBackend::OpenFile(const base::FilePath& file_path,
+ int desired_flags) {
DCHECK(!file_path.empty());
// Verify the flags for consistency and create the database
// directory if it doesn't exist.
if (!OpenFileFlagsAreConsistent(desired_flags) ||
- !base::CreateDirectory(file_path.DirName()))
- return;
+ !base::CreateDirectory(file_path.DirName())) {
+ return base::File();
+ }
int flags = 0;
- flags |= base::PLATFORM_FILE_READ;
+ flags |= base::File::FLAG_READ;
if (desired_flags & SQLITE_OPEN_READWRITE)
- flags |= base::PLATFORM_FILE_WRITE;
+ flags |= base::File::FLAG_WRITE;
- if (!(desired_flags & SQLITE_OPEN_MAIN_DB)) {
- flags |= base::PLATFORM_FILE_EXCLUSIVE_READ |
- base::PLATFORM_FILE_EXCLUSIVE_WRITE;
- }
+ if (!(desired_flags & SQLITE_OPEN_MAIN_DB))
+ flags |= base::File::FLAG_EXCLUSIVE_READ | base::File::FLAG_EXCLUSIVE_WRITE;
flags |= ((desired_flags & SQLITE_OPEN_CREATE) ?
- base::PLATFORM_FILE_OPEN_ALWAYS : base::PLATFORM_FILE_OPEN);
+ base::File::FLAG_OPEN_ALWAYS : base::File::FLAG_OPEN);
- if (desired_flags & SQLITE_OPEN_EXCLUSIVE) {
- flags |= base::PLATFORM_FILE_EXCLUSIVE_READ |
- base::PLATFORM_FILE_EXCLUSIVE_WRITE;
- }
+ if (desired_flags & SQLITE_OPEN_EXCLUSIVE)
+ flags |= base::File::FLAG_EXCLUSIVE_READ | base::File::FLAG_EXCLUSIVE_WRITE;
if (desired_flags & SQLITE_OPEN_DELETEONCLOSE) {
- flags |= base::PLATFORM_FILE_TEMPORARY | base::PLATFORM_FILE_HIDDEN |
- base::PLATFORM_FILE_DELETE_ON_CLOSE;
+ flags |= base::File::FLAG_TEMPORARY | base::File::FLAG_HIDDEN |
+ base::File::FLAG_DELETE_ON_CLOSE;
}
// This flag will allow us to delete the file later on from the browser
// process.
- flags |= base::PLATFORM_FILE_SHARE_DELETE;
+ flags |= base::File::FLAG_SHARE_DELETE;
// Try to open/create the DB file.
- *file_handle =
- base::CreatePlatformFile(file_path, flags, NULL, NULL);
+ return base::File(file_path, flags);
}
// static
-void VfsBackend::OpenTempFileInDirectory(
- const base::FilePath& dir_path,
- int desired_flags,
- base::PlatformFile* file_handle) {
+base::File VfsBackend::OpenTempFileInDirectory(const base::FilePath& dir_path,
+ int desired_flags) {
// We should be able to delete temp files when they're closed
// and create them as needed
if (!(desired_flags & SQLITE_OPEN_DELETEONCLOSE) ||
!(desired_flags & SQLITE_OPEN_CREATE)) {
- return;
+ return base::File();
}
// Get a unique temp file name in the database directory.
base::FilePath temp_file_path;
if (!base::CreateTemporaryFileInDir(dir_path, &temp_file_path))
- return;
+ return base::File();
- OpenFile(temp_file_path, desired_flags, file_handle);
+ return OpenFile(temp_file_path, desired_flags);
}
// static
@@ -128,14 +121,12 @@ int VfsBackend::DeleteFile(const base::FilePath& file_path, bool sync_dir) {
int error_code = SQLITE_OK;
#if defined(OS_POSIX)
if (sync_dir) {
- base::PlatformFile dir_fd = base::CreatePlatformFile(
- file_path.DirName(), base::PLATFORM_FILE_READ, NULL, NULL);
- if (dir_fd == base::kInvalidPlatformFileValue) {
- error_code = SQLITE_CANTOPEN;
- } else {
- if (fsync(dir_fd))
+ base::File dir(file_path.DirName(), base::File::FLAG_READ);
+ if (dir.IsValid()) {
+ if (!dir.Flush())
error_code = SQLITE_IOERR_DIR_FSYNC;
- base::ClosePlatformFile(dir_fd);
+ } else {
+ error_code = SQLITE_CANTOPEN;
}
}
#endif
diff --git a/chromium/webkit/browser/database/vfs_backend.h b/chromium/webkit/browser/database/vfs_backend.h
index 6bc4e168e73..1fb63c95994 100644
--- a/chromium/webkit/browser/database/vfs_backend.h
+++ b/chromium/webkit/browser/database/vfs_backend.h
@@ -5,7 +5,7 @@
#ifndef WEBKIT_BROWSER_DATABASE_VFS_BACKEND_H_
#define WEBKIT_BROWSER_DATABASE_VFS_BACKEND_H_
-#include "base/platform_file.h"
+#include "base/files/file.h"
#include "base/process/process.h"
#include "base/strings/string16.h"
#include "webkit/browser/webkit_storage_browser_export.h"
@@ -18,13 +18,11 @@ namespace webkit_database {
class WEBKIT_STORAGE_BROWSER_EXPORT VfsBackend {
public:
- static void OpenFile(const base::FilePath& file_path,
- int desired_flags,
- base::PlatformFile* file_handle);
+ static base::File OpenFile(const base::FilePath& file_path,
+ int desired_flags);
- static void OpenTempFileInDirectory(const base::FilePath& dir_path,
- int desired_flags,
- base::PlatformFile* file_handle);
+ static base::File OpenTempFileInDirectory(const base::FilePath& dir_path,
+ int desired_flags);
static int DeleteFile(const base::FilePath& file_path, bool sync_dir);
diff --git a/chromium/webkit/browser/fileapi/async_file_test_helper.cc b/chromium/webkit/browser/fileapi/async_file_test_helper.cc
deleted file mode 100644
index 50fd7cda34c..00000000000
--- a/chromium/webkit/browser/fileapi/async_file_test_helper.cc
+++ /dev/null
@@ -1,270 +0,0 @@
-// Copyright (c) 2013 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 "base/bind.h"
-#include "base/file_util.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/run_loop.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/fileapi/async_file_test_helper.h"
-#include "webkit/browser/fileapi/file_system_backend.h"
-#include "webkit/browser/fileapi/file_system_context.h"
-#include "webkit/browser/fileapi/file_system_operation_runner.h"
-#include "webkit/browser/fileapi/file_system_url.h"
-#include "webkit/browser/quota/quota_manager.h"
-#include "webkit/common/fileapi/file_system_util.h"
-
-namespace fileapi {
-
-namespace {
-
-typedef FileSystemOperation::FileEntryList FileEntryList;
-
-void AssignAndQuit(base::RunLoop* run_loop,
- base::PlatformFileError* result_out,
- base::PlatformFileError result) {
- *result_out = result;
- run_loop->Quit();
-}
-
-base::Callback<void(base::PlatformFileError)>
-AssignAndQuitCallback(base::RunLoop* run_loop,
- base::PlatformFileError* result) {
- return base::Bind(&AssignAndQuit, run_loop, base::Unretained(result));
-}
-
-void GetMetadataCallback(base::RunLoop* run_loop,
- base::PlatformFileError* result_out,
- base::PlatformFileInfo* file_info_out,
- base::PlatformFileError result,
- const base::PlatformFileInfo& file_info) {
- *result_out = result;
- if (file_info_out)
- *file_info_out = file_info;
- run_loop->Quit();
-}
-
-void CreateSnapshotFileCallback(
- base::RunLoop* run_loop,
- base::PlatformFileError* result_out,
- base::FilePath* platform_path_out,
- base::PlatformFileError result,
- const base::PlatformFileInfo& file_info,
- const base::FilePath& platform_path,
- const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
- DCHECK(!file_ref.get());
- *result_out = result;
- if (platform_path_out)
- *platform_path_out = platform_path;
- run_loop->Quit();
-}
-
-void ReadDirectoryCallback(base::RunLoop* run_loop,
- base::PlatformFileError* result_out,
- FileEntryList* entries_out,
- base::PlatformFileError result,
- const FileEntryList& entries,
- bool has_more) {
- *result_out = result;
- *entries_out = entries;
- if (result != base::PLATFORM_FILE_OK || !has_more)
- run_loop->Quit();
-}
-
-void DidGetUsageAndQuota(quota::QuotaStatusCode* status_out,
- int64* usage_out,
- int64* quota_out,
- quota::QuotaStatusCode status,
- int64 usage,
- int64 quota) {
- if (status_out)
- *status_out = status;
- if (usage_out)
- *usage_out = usage;
- if (quota_out)
- *quota_out = quota;
-}
-
-} // namespace
-
-const int64 AsyncFileTestHelper::kDontCheckSize = -1;
-
-base::PlatformFileError AsyncFileTestHelper::Copy(
- FileSystemContext* context,
- const FileSystemURL& src,
- const FileSystemURL& dest) {
- return CopyWithProgress(context, src, dest, CopyProgressCallback());
-}
-
-base::PlatformFileError AsyncFileTestHelper::CopyWithProgress(
- FileSystemContext* context,
- const FileSystemURL& src,
- const FileSystemURL& dest,
- const CopyProgressCallback& progress_callback) {
- base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
- base::RunLoop run_loop;
- context->operation_runner()->Copy(
- src, dest, FileSystemOperation::OPTION_NONE, progress_callback,
- AssignAndQuitCallback(&run_loop, &result));
- run_loop.Run();
- return result;
-}
-
-base::PlatformFileError AsyncFileTestHelper::Move(
- FileSystemContext* context,
- const FileSystemURL& src,
- const FileSystemURL& dest) {
- base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
- base::RunLoop run_loop;
- context->operation_runner()->Move(
- src, dest, FileSystemOperation::OPTION_NONE,
- AssignAndQuitCallback(&run_loop, &result));
- run_loop.Run();
- return result;
-}
-
-base::PlatformFileError AsyncFileTestHelper::Remove(
- FileSystemContext* context,
- const FileSystemURL& url,
- bool recursive) {
- base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
- base::RunLoop run_loop;
- context->operation_runner()->Remove(
- url, recursive, AssignAndQuitCallback(&run_loop, &result));
- run_loop.Run();
- return result;
-}
-
-base::PlatformFileError AsyncFileTestHelper::ReadDirectory(
- FileSystemContext* context,
- const FileSystemURL& url,
- FileEntryList* entries) {
- base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
- DCHECK(entries);
- entries->clear();
- base::RunLoop run_loop;
- context->operation_runner()->ReadDirectory(
- url, base::Bind(&ReadDirectoryCallback, &run_loop, &result, entries));
- run_loop.Run();
- return result;
-}
-
-base::PlatformFileError AsyncFileTestHelper::CreateDirectory(
- FileSystemContext* context,
- const FileSystemURL& url) {
- base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
- base::RunLoop run_loop;
- context->operation_runner()->CreateDirectory(
- url,
- false /* exclusive */,
- false /* recursive */,
- AssignAndQuitCallback(&run_loop, &result));
- run_loop.Run();
- return result;
-}
-
-base::PlatformFileError AsyncFileTestHelper::CreateFile(
- FileSystemContext* context,
- const FileSystemURL& url) {
- base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
- base::RunLoop run_loop;
- context->operation_runner()->CreateFile(
- url, false /* exclusive */,
- AssignAndQuitCallback(&run_loop, &result));
- run_loop.Run();
- return result;
-}
-
-base::PlatformFileError AsyncFileTestHelper::CreateFileWithData(
- FileSystemContext* context,
- const FileSystemURL& url,
- const char* buf,
- int buf_size) {
- base::ScopedTempDir dir;
- if (!dir.CreateUniqueTempDir())
- return base::PLATFORM_FILE_ERROR_FAILED;
- base::FilePath local_path = dir.path().AppendASCII("tmp");
- if (buf_size != file_util::WriteFile(local_path, buf, buf_size))
- return base::PLATFORM_FILE_ERROR_FAILED;
- base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
- base::RunLoop run_loop;
- context->operation_runner()->CopyInForeignFile(
- local_path, url, AssignAndQuitCallback(&run_loop, &result));
- run_loop.Run();
- return result;
-}
-
-base::PlatformFileError AsyncFileTestHelper::TruncateFile(
- FileSystemContext* context,
- const FileSystemURL& url,
- size_t size) {
- base::RunLoop run_loop;
- base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
- context->operation_runner()->Truncate(
- url, size, AssignAndQuitCallback(&run_loop, &result));
- run_loop.Run();
- return result;
-}
-
-base::PlatformFileError AsyncFileTestHelper::GetMetadata(
- FileSystemContext* context,
- const FileSystemURL& url,
- base::PlatformFileInfo* file_info) {
- base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
- base::RunLoop run_loop;
- context->operation_runner()->GetMetadata(
- url, base::Bind(&GetMetadataCallback, &run_loop, &result,
- file_info));
- run_loop.Run();
- return result;
-}
-
-base::PlatformFileError AsyncFileTestHelper::GetPlatformPath(
- FileSystemContext* context,
- const FileSystemURL& url,
- base::FilePath* platform_path) {
- base::PlatformFileError result = base::PLATFORM_FILE_ERROR_FAILED;
- base::RunLoop run_loop;
- context->operation_runner()->CreateSnapshotFile(
- url, base::Bind(&CreateSnapshotFileCallback, &run_loop, &result,
- platform_path));
- run_loop.Run();
- return result;
-}
-
-bool AsyncFileTestHelper::FileExists(
- FileSystemContext* context,
- const FileSystemURL& url,
- int64 expected_size) {
- base::PlatformFileInfo file_info;
- base::PlatformFileError result = GetMetadata(context, url, &file_info);
- if (result != base::PLATFORM_FILE_OK || file_info.is_directory)
- return false;
- return expected_size == kDontCheckSize || file_info.size == expected_size;
-}
-
-bool AsyncFileTestHelper::DirectoryExists(
- FileSystemContext* context,
- const FileSystemURL& url) {
- base::PlatformFileInfo file_info;
- base::PlatformFileError result = GetMetadata(context, url, &file_info);
- return (result == base::PLATFORM_FILE_OK) && file_info.is_directory;
-}
-
-quota::QuotaStatusCode AsyncFileTestHelper::GetUsageAndQuota(
- quota::QuotaManager* quota_manager,
- const GURL& origin,
- FileSystemType type,
- int64* usage,
- int64* quota) {
- quota::QuotaStatusCode status = quota::kQuotaStatusUnknown;
- quota_manager->GetUsageAndQuota(
- origin,
- FileSystemTypeToQuotaStorageType(type),
- base::Bind(&DidGetUsageAndQuota, &status, usage, quota));
- base::RunLoop().RunUntilIdle();
- return status;
-}
-
-} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/async_file_test_helper.h b/chromium/webkit/browser/fileapi/async_file_test_helper.h
deleted file mode 100644
index 168400fd0ef..00000000000
--- a/chromium/webkit/browser/fileapi/async_file_test_helper.h
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright (c) 2013 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 WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_TEST_HELPER_H_
-#define WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_TEST_HELPER_H_
-
-#include "base/basictypes.h"
-#include "webkit/browser/fileapi/file_system_operation.h"
-#include "webkit/common/fileapi/file_system_types.h"
-#include "webkit/common/quota/quota_status_code.h"
-
-namespace quota {
-class QuotaManager;
-}
-
-namespace fileapi {
-
-class FileSystemContext;
-class FileSystemURL;
-
-// A helper class to perform async file operations in a synchronous way.
-class AsyncFileTestHelper {
- public:
- typedef FileSystemOperation::FileEntryList FileEntryList;
- typedef FileSystemOperation::CopyProgressCallback CopyProgressCallback;
-
- static const int64 kDontCheckSize;
-
- // Performs Copy from |src| to |dest| and returns the status code.
- static base::PlatformFileError Copy(FileSystemContext* context,
- const FileSystemURL& src,
- const FileSystemURL& dest);
-
- // Same as Copy, but this supports |progress_callback|.
- static base::PlatformFileError CopyWithProgress(
- FileSystemContext* context,
- const FileSystemURL& src,
- const FileSystemURL& dest,
- const CopyProgressCallback& progress_callback);
-
- // Performs Move from |src| to |dest| and returns the status code.
- static base::PlatformFileError Move(FileSystemContext* context,
- const FileSystemURL& src,
- const FileSystemURL& dest);
-
- // Removes the given |url|.
- static base::PlatformFileError Remove(FileSystemContext* context,
- const FileSystemURL& url,
- bool recursive);
-
- // Performs ReadDirectory on |url|.
- static base::PlatformFileError ReadDirectory(FileSystemContext* context,
- const FileSystemURL& url,
- FileEntryList* entries);
-
- // Creates a directory at |url|.
- static base::PlatformFileError CreateDirectory(FileSystemContext* context,
- const FileSystemURL& url);
-
- // Creates a file at |url|.
- static base::PlatformFileError CreateFile(FileSystemContext* context,
- const FileSystemURL& url);
-
- // Creates a file at |url| and fills with |buf|.
- static base::PlatformFileError CreateFileWithData(
- FileSystemContext* context,
- const FileSystemURL& url,
- const char* buf,
- int buf_size);
-
- // Truncates the file |url| to |size|.
- static base::PlatformFileError TruncateFile(FileSystemContext* context,
- const FileSystemURL& url,
- size_t size);
-
- // Retrieves PlatformFileInfo for |url| and populates |file_info|.
- static base::PlatformFileError GetMetadata(FileSystemContext* context,
- const FileSystemURL& url,
- base::PlatformFileInfo* file_info);
-
- // Retrieves FilePath for |url| and populates |platform_path|.
- static base::PlatformFileError GetPlatformPath(FileSystemContext* context,
- const FileSystemURL& url,
- base::FilePath* platform_path);
-
- // Returns true if a file exists at |url| with |size|. If |size| is
- // kDontCheckSize it doesn't check the file size (but just check its
- // existence).
- static bool FileExists(FileSystemContext* context,
- const FileSystemURL& url,
- int64 size);
-
- // Returns true if a directory exists at |url|.
- static bool DirectoryExists(FileSystemContext* context,
- const FileSystemURL& url);
-
- // Returns usage and quota. It's valid to pass NULL to |usage| and/or |quota|.
- static quota::QuotaStatusCode GetUsageAndQuota(
- quota::QuotaManager* quota_manager,
- const GURL& origin,
- FileSystemType type,
- int64* usage,
- int64* quota);
-};
-
-} // namespace fileapi
-
-#endif // WEBKIT_BROWSER_FILEAPI_ASYNC_FILE_TEST_HELPER_H_
diff --git a/chromium/webkit/browser/fileapi/async_file_util.h b/chromium/webkit/browser/fileapi/async_file_util.h
index c1e6d1e4725..bde03395c65 100644
--- a/chromium/webkit/browser/fileapi/async_file_util.h
+++ b/chromium/webkit/browser/fileapi/async_file_util.h
@@ -9,9 +9,9 @@
#include "base/basictypes.h"
#include "base/callback_forward.h"
+#include "base/files/file.h"
#include "base/files/file_util_proxy.h"
#include "base/memory/scoped_ptr.h"
-#include "base/platform_file.h"
#include "webkit/browser/fileapi/file_system_operation.h"
#include "webkit/browser/webkit_storage_browser_export.h"
#include "webkit/common/fileapi/directory_entry.h"
@@ -47,34 +47,32 @@ class FileSystemURL;
//
class AsyncFileUtil {
public:
- typedef base::Callback<
- void(base::PlatformFileError result)> StatusCallback;
+ typedef base::Callback<void(base::File::Error result)> StatusCallback;
// |on_close_callback| will be called after the |file| is closed in the
// child process. |on_close_callback|.is_null() can be true, if no operation
// is needed on closing the file.
typedef base::Callback<
- void(base::PlatformFileError result,
- base::PassPlatformFile file,
+ void(base::File file,
const base::Closure& on_close_callback)> CreateOrOpenCallback;
typedef base::Callback<
- void(base::PlatformFileError result,
+ void(base::File::Error result,
bool created)> EnsureFileExistsCallback;
typedef base::Callback<
- void(base::PlatformFileError result,
- const base::PlatformFileInfo& file_info)> GetFileInfoCallback;
+ void(base::File::Error result,
+ const base::File::Info& file_info)> GetFileInfoCallback;
typedef std::vector<DirectoryEntry> EntryList;
typedef base::Callback<
- void(base::PlatformFileError result,
+ void(base::File::Error result,
const EntryList& file_list,
bool has_more)> ReadDirectoryCallback;
typedef base::Callback<
- void(base::PlatformFileError result,
- const base::PlatformFileInfo& file_info,
+ void(base::File::Error result,
+ const base::File::Info& file_info,
const base::FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref)>
CreateSnapshotFileCallback;
@@ -94,9 +92,9 @@ class AsyncFileUtil {
virtual ~AsyncFileUtil() {}
// Creates or opens a file with the given flags.
- // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create
+ // If File::FLAG_CREATE is set in |file_flags| it always tries to create
// a new file at the given |url| and calls back with
- // PLATFORM_FILE_ERROR_FILE_EXISTS if the |url| already exists.
+ // File::FILE_ERROR_FILE_EXISTS if the |url| already exists.
//
// FileSystemOperationImpl::OpenFile calls this.
// This is used only by Pepper/NaCl File API.
@@ -113,9 +111,9 @@ class AsyncFileUtil {
// FileSystemOperationImpl::CreateFile calls this.
//
// This reports following error code via |callback|:
- // - PLATFORM_FILE_OK and created==true if a file has not existed and
+ // - File::FILE_OK and created==true if a file has not existed and
// is created at |url|.
- // - PLATFORM_FILE_OK and created==false if the file already exists.
+ // - File::FILE_OK and created==false if the file already exists.
// - Other error code (with created=false) if a file hasn't existed yet
// and there was an error while creating a new file.
//
@@ -129,11 +127,11 @@ class AsyncFileUtil {
// FileSystemOperationImpl::CreateDirectory calls this.
//
// This reports following error code via |callback|:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if the |url|'s parent directory
+ // - File::FILE_ERROR_NOT_FOUND if the |url|'s parent directory
// does not exist and |recursive| is false.
- // - PLATFORM_FILE_ERROR_EXISTS if a directory already exists at |url|
+ // - File::FILE_ERROR_EXISTS if a directory already exists at |url|
// and |exclusive| is true.
- // - PLATFORM_FILE_ERROR_EXISTS if a file already exists at |url|
+ // - File::FILE_ERROR_EXISTS if a file already exists at |url|
// (regardless of |exclusive| value).
// - Other error code if it failed to create a directory.
//
@@ -149,7 +147,7 @@ class AsyncFileUtil {
// FileSystemOperationImpl::GetMetadata calls this.
//
// This reports following error code via |callback|:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if the file doesn't exist.
+ // - File::FILE_ERROR_NOT_FOUND if the file doesn't exist.
// - Other error code if there was an error while retrieving the file info.
//
virtual void GetFileInfo(
@@ -171,8 +169,8 @@ class AsyncFileUtil {
// are 'a' and 'b', but not '/path/to/dir/a' and '/path/to/dir/b'.)
//
// This reports following error code via |callback|:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if the target directory doesn't exist.
- // - PLATFORM_FILE_ERROR_NOT_A_DIRECTORY if an entry exists at |url| but
+ // - File::FILE_ERROR_NOT_FOUND if the target directory doesn't exist.
+ // - File::FILE_ERROR_NOT_A_DIRECTORY if an entry exists at |url| but
// is a file (not a directory).
//
virtual void ReadDirectory(
@@ -201,7 +199,7 @@ class AsyncFileUtil {
// FileSystemOperationImpl::Truncate calls this.
//
// This reports following error code via |callback|:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if the file doesn't exist.
+ // - File::FILE_ERROR_NOT_FOUND if the file doesn't exist.
//
virtual void Truncate(
scoped_ptr<FileSystemOperationContext> context,
@@ -222,12 +220,12 @@ class AsyncFileUtil {
// FileSystemOperationImpl::Copy calls this for same-filesystem copy case.
//
// This reports following error code via |callback|:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_url|
+ // - File::FILE_ERROR_NOT_FOUND if |src_url|
// or the parent directory of |dest_url| does not exist.
- // - PLATFORM_FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
- // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
+ // - File::FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
+ // - File::FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
// is not a file.
- // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and
+ // - File::FILE_ERROR_FAILED if |dest_url| does not exist and
// its parent path is a file.
//
virtual void CopyFileLocal(
@@ -245,12 +243,12 @@ class AsyncFileUtil {
// FileSystemOperationImpl::Move calls this for same-filesystem move case.
//
// This reports following error code via |callback|:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_url|
+ // - File::FILE_ERROR_NOT_FOUND if |src_url|
// or the parent directory of |dest_url| does not exist.
- // - PLATFORM_FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
- // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
+ // - File::FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
+ // - File::FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
// is not a file.
- // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and
+ // - File::FILE_ERROR_FAILED if |dest_url| does not exist and
// its parent path is a file.
//
virtual void MoveFileLocal(
@@ -266,11 +264,11 @@ class AsyncFileUtil {
// cases.
//
// This reports following error code via |callback|:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_file_path|
+ // - File::FILE_ERROR_NOT_FOUND if |src_file_path|
// or the parent directory of |dest_url| does not exist.
- // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
+ // - File::FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
// is not a file.
- // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and
+ // - File::FILE_ERROR_FAILED if |dest_url| does not exist and
// its parent path is a file.
//
virtual void CopyInForeignFile(
@@ -284,8 +282,8 @@ class AsyncFileUtil {
// FileSystemOperationImpl::RemoveFile calls this.
//
// This reports following error code via |callback|:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist.
- // - PLATFORM_FILE_ERROR_NOT_A_FILE if |url| is not a file.
+ // - File::FILE_ERROR_NOT_FOUND if |url| does not exist.
+ // - File::FILE_ERROR_NOT_A_FILE if |url| is not a file.
//
virtual void DeleteFile(
scoped_ptr<FileSystemOperationContext> context,
@@ -297,9 +295,9 @@ class AsyncFileUtil {
// FileSystemOperationImpl::RemoveDirectory calls this.
//
// This reports following error code via |callback|:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist.
- // - PLATFORM_FILE_ERROR_NOT_A_DIRECTORY if |url| is not a directory.
- // - PLATFORM_FILE_ERROR_NOT_EMPTY if |url| is not empty.
+ // - File::FILE_ERROR_NOT_FOUND if |url| does not exist.
+ // - File::FILE_ERROR_NOT_A_DIRECTORY if |url| is not a directory.
+ // - File::FILE_ERROR_NOT_EMPTY if |url| is not empty.
//
virtual void DeleteDirectory(
scoped_ptr<FileSystemOperationContext> context,
@@ -314,11 +312,11 @@ class AsyncFileUtil {
// deletion can be implemented more efficiently than calling DeleteFile() and
// DeleteDirectory() for each files/directories.
// This method is optional, so if not supported,
- // PLATFORM_ERROR_INVALID_OPERATION should be returned via |callback|.
+ // File::FILE_ERROR_INVALID_OPERATION should be returned via |callback|.
//
// This reports following error code via |callback|:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist.
- // - PLATFORM_ERROR_INVALID_OPERATION if this operation is not supported.
+ // - File::FILE_ERROR_NOT_FOUND if |url| does not exist.
+ // - File::FILE_ERROR_INVALID_OPERATION if this operation is not supported.
virtual void DeleteRecursively(
scoped_ptr<FileSystemOperationContext> context,
const FileSystemURL& url,
@@ -349,8 +347,8 @@ class AsyncFileUtil {
// FileSystemOperationImpl::CreateSnapshotFile calls this.
//
// This reports following error code via |callback|:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist.
- // - PLATFORM_FILE_ERROR_NOT_A_FILE if |url| exists but is a directory.
+ // - File::FILE_ERROR_NOT_FOUND if |url| does not exist.
+ // - File::FILE_ERROR_NOT_A_FILE if |url| exists but is a directory.
//
// The field values of |file_info| are undefined (implementation
// dependent) in error cases, and the caller should always
diff --git a/chromium/webkit/browser/fileapi/async_file_util_adapter.cc b/chromium/webkit/browser/fileapi/async_file_util_adapter.cc
index b25ddf24967..5a99effbd6f 100644
--- a/chromium/webkit/browser/fileapi/async_file_util_adapter.cc
+++ b/chromium/webkit/browser/fileapi/async_file_util_adapter.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/sequenced_task_runner.h"
#include "base/task_runner_util.h"
+#include "base/thread_task_runner_handle.h"
#include "webkit/browser/fileapi/file_system_context.h"
#include "webkit/browser/fileapi/file_system_file_util.h"
#include "webkit/browser/fileapi/file_system_operation_context.h"
@@ -19,7 +20,6 @@
using base::Bind;
using base::Callback;
using base::Owned;
-using base::PlatformFileError;
using base::Unretained;
using webkit_blob::ShareableFileReference;
@@ -29,7 +29,7 @@ namespace {
class EnsureFileExistsHelper {
public:
- EnsureFileExistsHelper() : error_(base::PLATFORM_FILE_OK), created_(false) {}
+ EnsureFileExistsHelper() : error_(base::File::FILE_OK), created_(false) {}
void RunWork(FileSystemFileUtil* file_util,
FileSystemOperationContext* context,
@@ -42,7 +42,7 @@ class EnsureFileExistsHelper {
}
private:
- base::PlatformFileError error_;
+ base::File::Error error_;
bool created_;
DISALLOW_COPY_AND_ASSIGN(EnsureFileExistsHelper);
};
@@ -50,7 +50,7 @@ class EnsureFileExistsHelper {
class GetFileInfoHelper {
public:
GetFileInfoHelper()
- : error_(base::PLATFORM_FILE_OK) {}
+ : error_(base::File::FILE_OK) {}
void GetFileInfo(FileSystemFileUtil* file_util,
FileSystemOperationContext* context,
@@ -76,64 +76,67 @@ class GetFileInfoHelper {
}
private:
- base::PlatformFileError error_;
- base::PlatformFileInfo file_info_;
+ base::File::Error error_;
+ base::File::Info file_info_;
base::FilePath platform_path_;
webkit_blob::ScopedFile scoped_file_;
DISALLOW_COPY_AND_ASSIGN(GetFileInfoHelper);
};
-class ReadDirectoryHelper {
- public:
- ReadDirectoryHelper() : error_(base::PLATFORM_FILE_OK) {}
-
- void RunWork(FileSystemFileUtil* file_util,
- FileSystemOperationContext* context,
- const FileSystemURL& url) {
- base::PlatformFileInfo file_info;
- base::FilePath platform_path;
- PlatformFileError error = file_util->GetFileInfo(
- context, url, &file_info, &platform_path);
- if (error != base::PLATFORM_FILE_OK) {
- error_ = error;
- return;
- }
- if (!file_info.is_directory) {
- error_ = base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY;
- return;
- }
-
- scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> file_enum(
- file_util->CreateFileEnumerator(context, url));
-
- base::FilePath current;
- while (!(current = file_enum->Next()).empty()) {
- DirectoryEntry entry;
- entry.is_directory = file_enum->IsDirectory();
- entry.name = VirtualPath::BaseName(current).value();
- entry.size = file_enum->Size();
- entry.last_modified_time = file_enum->LastModifiedTime();
- entries_.push_back(entry);
- }
- error_ = base::PLATFORM_FILE_OK;
+void ReadDirectoryHelper(FileSystemFileUtil* file_util,
+ FileSystemOperationContext* context,
+ const FileSystemURL& url,
+ base::SingleThreadTaskRunner* origin_loop,
+ const AsyncFileUtil::ReadDirectoryCallback& callback) {
+ base::File::Info file_info;
+ base::FilePath platform_path;
+ base::File::Error error = file_util->GetFileInfo(
+ context, url, &file_info, &platform_path);
+
+ if (error == base::File::FILE_OK && !file_info.is_directory)
+ error = base::File::FILE_ERROR_NOT_A_DIRECTORY;
+
+ std::vector<DirectoryEntry> entries;
+ if (error != base::File::FILE_OK) {
+ origin_loop->PostTask(
+ FROM_HERE, base::Bind(callback, error, entries, false /* has_more */));
+ return;
}
- void Reply(const AsyncFileUtil::ReadDirectoryCallback& callback) {
- callback.Run(error_, entries_, false /* has_more */);
+ // Note: Increasing this value may make some tests in LayoutTests meaningless.
+ // (Namely, read-directory-many.html and read-directory-sync-many.html are
+ // assuming that they are reading much more entries than this constant.)
+ const size_t kResultChunkSize = 100;
+
+ scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> file_enum(
+ file_util->CreateFileEnumerator(context, url));
+
+ base::FilePath current;
+ while (!(current = file_enum->Next()).empty()) {
+ DirectoryEntry entry;
+ entry.is_directory = file_enum->IsDirectory();
+ entry.name = VirtualPath::BaseName(current).value();
+ entry.size = file_enum->Size();
+ entry.last_modified_time = file_enum->LastModifiedTime();
+ entries.push_back(entry);
+
+ if (entries.size() == kResultChunkSize) {
+ origin_loop->PostTask(
+ FROM_HERE, base::Bind(callback, base::File::FILE_OK, entries,
+ true /* has_more */));
+ entries.clear();
+ }
}
-
- private:
- base::PlatformFileError error_;
- std::vector<DirectoryEntry> entries_;
- DISALLOW_COPY_AND_ASSIGN(ReadDirectoryHelper);
-};
+ origin_loop->PostTask(
+ FROM_HERE, base::Bind(callback, base::File::FILE_OK, entries,
+ false /* has_more */));
+}
void RunCreateOrOpenCallback(
+ FileSystemOperationContext* context,
const AsyncFileUtil::CreateOrOpenCallback& callback,
- base::PlatformFileError result,
- base::PassPlatformFile file,
- bool created) {
- callback.Run(result, file, base::Closure());
+ base::File file) {
+ callback.Run(file.Pass(), base::Closure());
}
} // namespace
@@ -153,14 +156,12 @@ void AsyncFileUtilAdapter::CreateOrOpen(
int file_flags,
const CreateOrOpenCallback& callback) {
FileSystemOperationContext* context_ptr = context.release();
- const bool success = base::FileUtilProxy::RelayCreateOrOpen(
+ base::PostTaskAndReplyWithResult(
context_ptr->task_runner(),
+ FROM_HERE,
Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(sync_file_util_.get()),
context_ptr, url, file_flags),
- Bind(&FileSystemFileUtil::Close, Unretained(sync_file_util_.get()),
- base::Owned(context_ptr)),
- Bind(&RunCreateOrOpenCallback, callback));
- DCHECK(success);
+ Bind(&RunCreateOrOpenCallback, base::Owned(context_ptr), callback));
}
void AsyncFileUtilAdapter::EnsureFileExists(
@@ -212,12 +213,11 @@ void AsyncFileUtilAdapter::ReadDirectory(
const FileSystemURL& url,
const ReadDirectoryCallback& callback) {
FileSystemOperationContext* context_ptr = context.release();
- ReadDirectoryHelper* helper = new ReadDirectoryHelper;
- const bool success = context_ptr->task_runner()->PostTaskAndReply(
+ const bool success = context_ptr->task_runner()->PostTask(
FROM_HERE,
- Bind(&ReadDirectoryHelper::RunWork, Unretained(helper),
- sync_file_util_.get(), base::Owned(context_ptr), url),
- Bind(&ReadDirectoryHelper::Reply, Owned(helper), callback));
+ Bind(&ReadDirectoryHelper,
+ sync_file_util_.get(), base::Owned(context_ptr), url,
+ base::ThreadTaskRunnerHandle::Get(), callback));
DCHECK(success);
}
@@ -332,7 +332,7 @@ void AsyncFileUtilAdapter::DeleteRecursively(
scoped_ptr<FileSystemOperationContext> context,
const FileSystemURL& url,
const StatusCallback& callback) {
- callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
+ callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
}
void AsyncFileUtilAdapter::CreateSnapshotFile(
diff --git a/chromium/webkit/browser/fileapi/copy_or_move_file_validator.h b/chromium/webkit/browser/fileapi/copy_or_move_file_validator.h
index 2bd4df17b7a..5312fb0e0c0 100644
--- a/chromium/webkit/browser/fileapi/copy_or_move_file_validator.h
+++ b/chromium/webkit/browser/fileapi/copy_or_move_file_validator.h
@@ -6,7 +6,7 @@
#define WEBKIT_BROWSER_FILEAPI_COPY_OR_MOVE_FILE_VALIDATOR_H_
#include "base/callback.h"
-#include "base/platform_file.h"
+#include "base/files/file.h"
#include "webkit/browser/webkit_storage_browser_export.h"
namespace base {
@@ -20,8 +20,8 @@ class FileSystemURL;
class WEBKIT_STORAGE_BROWSER_EXPORT CopyOrMoveFileValidator {
public:
// Callback that is invoked when validation completes. A result of
- // base::PLATFORM_FILE_OK means the file validated.
- typedef base::Callback<void(base::PlatformFileError result)> ResultCallback;
+ // base::File::FILE_OK means the file validated.
+ typedef base::Callback<void(base::File::Error result)> ResultCallback;
virtual ~CopyOrMoveFileValidator() {}
diff --git a/chromium/webkit/browser/fileapi/copy_or_move_operation_delegate.cc b/chromium/webkit/browser/fileapi/copy_or_move_operation_delegate.cc
index 967b5c28f0d..699e3e3c171 100644
--- a/chromium/webkit/browser/fileapi/copy_or_move_operation_delegate.cc
+++ b/chromium/webkit/browser/fileapi/copy_or_move_operation_delegate.cc
@@ -128,14 +128,14 @@ class SnapshotCopyOrMoveImpl
private:
void RunAfterCreateSnapshot(
const CopyOrMoveOperationDelegate::StatusCallback& callback,
- base::PlatformFileError error,
- const base::PlatformFileInfo& file_info,
+ base::File::Error error,
+ const base::File::Info& file_info,
const base::FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
if (cancel_requested_)
- error = base::PLATFORM_FILE_ERROR_ABORT;
+ error = base::File::FILE_ERROR_ABORT;
- if (error != base::PLATFORM_FILE_OK) {
+ if (error != base::File::FILE_OK) {
callback.Run(error);
return;
}
@@ -147,7 +147,7 @@ class SnapshotCopyOrMoveImpl
if (!validator_factory_) {
// No validation is needed.
RunAfterPreWriteValidation(platform_path, file_info, file_ref, callback,
- base::PLATFORM_FILE_OK);
+ base::File::FILE_OK);
return;
}
@@ -161,14 +161,14 @@ class SnapshotCopyOrMoveImpl
void RunAfterPreWriteValidation(
const base::FilePath& platform_path,
- const base::PlatformFileInfo& file_info,
+ const base::File::Info& file_info,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref,
const CopyOrMoveOperationDelegate::StatusCallback& callback,
- base::PlatformFileError error) {
+ base::File::Error error) {
if (cancel_requested_)
- error = base::PLATFORM_FILE_ERROR_ABORT;
+ error = base::File::FILE_ERROR_ABORT;
- if (error != base::PLATFORM_FILE_OK) {
+ if (error != base::File::FILE_OK) {
callback.Run(error);
return;
}
@@ -182,14 +182,14 @@ class SnapshotCopyOrMoveImpl
}
void RunAfterCopyInForeignFile(
- const base::PlatformFileInfo& file_info,
+ const base::File::Info& file_info,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref,
const CopyOrMoveOperationDelegate::StatusCallback& callback,
- base::PlatformFileError error) {
+ base::File::Error error) {
if (cancel_requested_)
- error = base::PLATFORM_FILE_ERROR_ABORT;
+ error = base::File::FILE_ERROR_ABORT;
- if (error != base::PLATFORM_FILE_OK) {
+ if (error != base::File::FILE_OK) {
callback.Run(error);
return;
}
@@ -197,7 +197,7 @@ class SnapshotCopyOrMoveImpl
file_progress_callback_.Run(file_info.size);
if (option_ == FileSystemOperation::OPTION_NONE) {
- RunAfterTouchFile(callback, base::PLATFORM_FILE_OK);
+ RunAfterTouchFile(callback, base::File::FILE_OK);
return;
}
@@ -210,11 +210,11 @@ class SnapshotCopyOrMoveImpl
void RunAfterTouchFile(
const CopyOrMoveOperationDelegate::StatusCallback& callback,
- base::PlatformFileError error) {
+ base::File::Error error) {
// Even if TouchFile is failed, just ignore it.
if (cancel_requested_) {
- callback.Run(base::PLATFORM_FILE_ERROR_ABORT);
+ callback.Run(base::File::FILE_ERROR_ABORT);
return;
}
@@ -222,7 +222,7 @@ class SnapshotCopyOrMoveImpl
// validation.
if (!validator_) {
// No validation is needed.
- RunAfterPostWriteValidation(callback, base::PLATFORM_FILE_OK);
+ RunAfterPostWriteValidation(callback, base::File::FILE_OK);
return;
}
@@ -233,13 +233,13 @@ class SnapshotCopyOrMoveImpl
void RunAfterPostWriteValidation(
const CopyOrMoveOperationDelegate::StatusCallback& callback,
- base::PlatformFileError error) {
+ base::File::Error error) {
if (cancel_requested_) {
- callback.Run(base::PLATFORM_FILE_ERROR_ABORT);
+ callback.Run(base::File::FILE_ERROR_ABORT);
return;
}
- if (error != base::PLATFORM_FILE_OK) {
+ if (error != base::File::FILE_OK) {
// Failed to validate. Remove the destination file.
operation_runner_->Remove(
dest_url_, true /* recursive */,
@@ -249,7 +249,7 @@ class SnapshotCopyOrMoveImpl
}
if (operation_type_ == CopyOrMoveOperationDelegate::OPERATION_COPY) {
- callback.Run(base::PLATFORM_FILE_OK);
+ callback.Run(base::File::FILE_OK);
return;
}
@@ -264,20 +264,20 @@ class SnapshotCopyOrMoveImpl
void RunAfterRemoveSourceForMove(
const CopyOrMoveOperationDelegate::StatusCallback& callback,
- base::PlatformFileError error) {
+ base::File::Error error) {
if (cancel_requested_)
- error = base::PLATFORM_FILE_ERROR_ABORT;
+ error = base::File::FILE_ERROR_ABORT;
- if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND)
- error = base::PLATFORM_FILE_OK;
+ if (error == base::File::FILE_ERROR_NOT_FOUND)
+ error = base::File::FILE_OK;
callback.Run(error);
}
void DidRemoveDestForError(
- base::PlatformFileError prior_error,
+ base::File::Error prior_error,
const CopyOrMoveOperationDelegate::StatusCallback& callback,
- base::PlatformFileError error) {
- if (error != base::PLATFORM_FILE_OK) {
+ base::File::Error error) {
+ if (error != base::File::FILE_OK) {
VLOG(1) << "Error removing destination file after validation error: "
<< error;
}
@@ -307,14 +307,14 @@ class SnapshotCopyOrMoveImpl
void PostWriteValidationAfterCreateSnapshotFile(
const CopyOrMoveOperationDelegate::StatusCallback& callback,
- base::PlatformFileError error,
- const base::PlatformFileInfo& file_info,
+ base::File::Error error,
+ const base::File::Info& file_info,
const base::FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
if (cancel_requested_)
- error = base::PLATFORM_FILE_ERROR_ABORT;
+ error = base::File::FILE_ERROR_ABORT;
- if (error != base::PLATFORM_FILE_OK) {
+ if (error != base::File::FILE_OK) {
callback.Run(error);
return;
}
@@ -333,7 +333,7 @@ class SnapshotCopyOrMoveImpl
void DidPostWriteValidation(
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref,
const CopyOrMoveOperationDelegate::StatusCallback& callback,
- base::PlatformFileError error) {
+ base::File::Error error) {
callback.Run(error);
}
@@ -406,19 +406,19 @@ class StreamCopyOrMoveImpl
private:
void RunAfterGetMetadataForSource(
const CopyOrMoveOperationDelegate::StatusCallback& callback,
- base::PlatformFileError error,
- const base::PlatformFileInfo& file_info) {
+ base::File::Error error,
+ const base::File::Info& file_info) {
if (cancel_requested_)
- error = base::PLATFORM_FILE_ERROR_ABORT;
+ error = base::File::FILE_ERROR_ABORT;
- if (error != base::PLATFORM_FILE_OK) {
+ if (error != base::File::FILE_OK) {
callback.Run(error);
return;
}
if (file_info.is_directory) {
// If not a directory, failed with appropriate error code.
- callback.Run(base::PLATFORM_FILE_ERROR_NOT_A_FILE);
+ callback.Run(base::File::FILE_ERROR_NOT_A_FILE);
return;
}
@@ -433,11 +433,11 @@ class StreamCopyOrMoveImpl
void RunAfterCreateFileForDestination(
const CopyOrMoveOperationDelegate::StatusCallback& callback,
const base::Time& last_modified,
- base::PlatformFileError error) {
+ base::File::Error error) {
if (cancel_requested_)
- error = base::PLATFORM_FILE_ERROR_ABORT;
+ error = base::File::FILE_ERROR_ABORT;
- if (error != base::PLATFORM_FILE_OK) {
+ if (error != base::File::FILE_OK) {
callback.Run(error);
return;
}
@@ -462,17 +462,17 @@ class StreamCopyOrMoveImpl
void RunAfterStreamCopy(
const CopyOrMoveOperationDelegate::StatusCallback& callback,
const base::Time& last_modified,
- base::PlatformFileError error) {
+ base::File::Error error) {
if (cancel_requested_)
- error = base::PLATFORM_FILE_ERROR_ABORT;
+ error = base::File::FILE_ERROR_ABORT;
- if (error != base::PLATFORM_FILE_OK) {
+ if (error != base::File::FILE_OK) {
callback.Run(error);
return;
}
if (option_ == FileSystemOperation::OPTION_NONE) {
- RunAfterTouchFile(callback, base::PLATFORM_FILE_OK);
+ RunAfterTouchFile(callback, base::File::FILE_OK);
return;
}
@@ -484,15 +484,15 @@ class StreamCopyOrMoveImpl
void RunAfterTouchFile(
const CopyOrMoveOperationDelegate::StatusCallback& callback,
- base::PlatformFileError error) {
+ base::File::Error error) {
// Even if TouchFile is failed, just ignore it.
if (cancel_requested_) {
- callback.Run(base::PLATFORM_FILE_ERROR_ABORT);
+ callback.Run(base::File::FILE_ERROR_ABORT);
return;
}
if (operation_type_ == CopyOrMoveOperationDelegate::OPERATION_COPY) {
- callback.Run(base::PLATFORM_FILE_OK);
+ callback.Run(base::File::FILE_OK);
return;
}
@@ -507,11 +507,11 @@ class StreamCopyOrMoveImpl
void RunAfterRemoveForMove(
const CopyOrMoveOperationDelegate::StatusCallback& callback,
- base::PlatformFileError error) {
+ base::File::Error error) {
if (cancel_requested_)
- error = base::PLATFORM_FILE_ERROR_ABORT;
- if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND)
- error = base::PLATFORM_FILE_OK;
+ error = base::File::FILE_ERROR_ABORT;
+ if (error == base::File::FILE_ERROR_NOT_FOUND)
+ error = base::File::FILE_OK;
callback.Run(error);
}
@@ -579,12 +579,12 @@ void CopyOrMoveOperationDelegate::StreamCopyHelper::Read(
void CopyOrMoveOperationDelegate::StreamCopyHelper::DidRead(
const StatusCallback& callback, int result) {
if (cancel_requested_) {
- callback.Run(base::PLATFORM_FILE_ERROR_ABORT);
+ callback.Run(base::File::FILE_ERROR_ABORT);
return;
}
if (result < 0) {
- callback.Run(NetErrorToPlatformFileError(result));
+ callback.Run(NetErrorToFileError(result));
return;
}
@@ -593,7 +593,7 @@ void CopyOrMoveOperationDelegate::StreamCopyHelper::DidRead(
if (need_flush_)
Flush(callback, true /* is_eof */);
else
- callback.Run(base::PLATFORM_FILE_OK);
+ callback.Run(base::File::FILE_OK);
return;
}
@@ -618,12 +618,12 @@ void CopyOrMoveOperationDelegate::StreamCopyHelper::DidWrite(
scoped_refptr<net::DrainableIOBuffer> buffer,
int result) {
if (cancel_requested_) {
- callback.Run(base::PLATFORM_FILE_ERROR_ABORT);
+ callback.Run(base::File::FILE_ERROR_ABORT);
return;
}
if (result < 0) {
- callback.Run(NetErrorToPlatformFileError(result));
+ callback.Run(NetErrorToFileError(result));
return;
}
@@ -663,13 +663,13 @@ void CopyOrMoveOperationDelegate::StreamCopyHelper::Flush(
void CopyOrMoveOperationDelegate::StreamCopyHelper::DidFlush(
const StatusCallback& callback, bool is_eof, int result) {
if (cancel_requested_) {
- callback.Run(base::PLATFORM_FILE_ERROR_ABORT);
+ callback.Run(base::File::FILE_ERROR_ABORT);
return;
}
previous_flush_offset_ = num_copied_bytes_;
if (is_eof)
- callback.Run(NetErrorToPlatformFileError(result));
+ callback.Run(NetErrorToFileError(result));
else
Read(callback);
}
@@ -707,13 +707,15 @@ void CopyOrMoveOperationDelegate::RunRecursively() {
// It is an error to try to copy/move an entry into its child.
if (same_file_system_ && src_root_.path().IsParent(dest_root_.path())) {
- callback_.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
+ callback_.Run(base::File::FILE_ERROR_INVALID_OPERATION);
return;
}
- // It is an error to copy/move an entry into the same path.
if (same_file_system_ && src_root_.path() == dest_root_.path()) {
- callback_.Run(base::PLATFORM_FILE_ERROR_EXISTS);
+ // In JS API this should return error, but we return success because Pepper
+ // wants to return success and we have a code path that returns error in
+ // Blink for JS (http://crbug.com/329517).
+ callback_.Run(base::File::FILE_OK);
return;
}
@@ -741,11 +743,11 @@ void CopyOrMoveOperationDelegate::ProcessFile(
weak_factory_.GetWeakPtr(), src_url));
} else {
// Cross filesystem case.
- base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
+ base::File::Error error = base::File::FILE_ERROR_FAILED;
CopyOrMoveFileValidatorFactory* validator_factory =
file_system_context()->GetCopyOrMoveFileValidatorFactory(
dest_root_.type(), &error);
- if (error != base::PLATFORM_FILE_OK) {
+ if (error != base::File::FILE_OK) {
callback.Run(error);
return;
}
@@ -810,7 +812,7 @@ void CopyOrMoveOperationDelegate::PostProcessDirectory(
const StatusCallback& callback) {
if (option_ == FileSystemOperation::OPTION_NONE) {
PostProcessDirectoryAfterTouchFile(
- src_url, callback, base::PLATFORM_FILE_OK);
+ src_url, callback, base::File::FILE_OK);
return;
}
@@ -833,11 +835,11 @@ void CopyOrMoveOperationDelegate::DidCopyOrMoveFile(
const FileSystemURL& dest_url,
const StatusCallback& callback,
CopyOrMoveImpl* impl,
- base::PlatformFileError error) {
+ base::File::Error error) {
running_copy_set_.erase(impl);
delete impl;
- if (!progress_callback_.is_null() && error == base::PLATFORM_FILE_OK) {
+ if (!progress_callback_.is_null() && error == base::File::FILE_OK) {
progress_callback_.Run(
FileSystemOperation::END_COPY_ENTRY, src_url, dest_url, 0);
}
@@ -847,13 +849,13 @@ void CopyOrMoveOperationDelegate::DidCopyOrMoveFile(
void CopyOrMoveOperationDelegate::DidTryRemoveDestRoot(
const StatusCallback& callback,
- base::PlatformFileError error) {
- if (error == base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY) {
- callback_.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
+ base::File::Error error) {
+ if (error == base::File::FILE_ERROR_NOT_A_DIRECTORY) {
+ callback_.Run(base::File::FILE_ERROR_INVALID_OPERATION);
return;
}
- if (error != base::PLATFORM_FILE_OK &&
- error != base::PLATFORM_FILE_ERROR_NOT_FOUND) {
+ if (error != base::File::FILE_OK &&
+ error != base::File::FILE_ERROR_NOT_FOUND) {
callback_.Run(error);
return;
}
@@ -879,8 +881,8 @@ void CopyOrMoveOperationDelegate::DidCreateDirectory(
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
const StatusCallback& callback,
- base::PlatformFileError error) {
- if (!progress_callback_.is_null() && error == base::PLATFORM_FILE_OK) {
+ base::File::Error error) {
+ if (!progress_callback_.is_null() && error == base::File::FILE_OK) {
progress_callback_.Run(
FileSystemOperation::END_COPY_ENTRY, src_url, dest_url, 0);
}
@@ -891,12 +893,12 @@ void CopyOrMoveOperationDelegate::DidCreateDirectory(
void CopyOrMoveOperationDelegate::PostProcessDirectoryAfterGetMetadata(
const FileSystemURL& src_url,
const StatusCallback& callback,
- base::PlatformFileError error,
- const base::PlatformFileInfo& file_info) {
- if (error != base::PLATFORM_FILE_OK) {
+ base::File::Error error,
+ const base::File::Info& file_info) {
+ if (error != base::File::FILE_OK) {
// Ignore the error, and run post process which should run after TouchFile.
PostProcessDirectoryAfterTouchFile(
- src_url, callback, base::PLATFORM_FILE_OK);
+ src_url, callback, base::File::FILE_OK);
return;
}
@@ -911,11 +913,11 @@ void CopyOrMoveOperationDelegate::PostProcessDirectoryAfterGetMetadata(
void CopyOrMoveOperationDelegate::PostProcessDirectoryAfterTouchFile(
const FileSystemURL& src_url,
const StatusCallback& callback,
- base::PlatformFileError error) {
+ base::File::Error error) {
// Even if the TouchFile is failed, just ignore it.
if (operation_type_ == OPERATION_COPY) {
- callback.Run(base::PLATFORM_FILE_OK);
+ callback.Run(base::File::FILE_OK);
return;
}
@@ -931,9 +933,9 @@ void CopyOrMoveOperationDelegate::PostProcessDirectoryAfterTouchFile(
void CopyOrMoveOperationDelegate::DidRemoveSourceForMove(
const StatusCallback& callback,
- base::PlatformFileError error) {
- if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND)
- error = base::PLATFORM_FILE_OK;
+ base::File::Error error) {
+ if (error == base::File::FILE_ERROR_NOT_FOUND)
+ error = base::File::FILE_OK;
callback.Run(error);
}
diff --git a/chromium/webkit/browser/fileapi/copy_or_move_operation_delegate.h b/chromium/webkit/browser/fileapi/copy_or_move_operation_delegate.h
index 2247c87202e..bb0c1f96ebc 100644
--- a/chromium/webkit/browser/fileapi/copy_or_move_operation_delegate.h
+++ b/chromium/webkit/browser/fileapi/copy_or_move_operation_delegate.h
@@ -119,26 +119,26 @@ class CopyOrMoveOperationDelegate
const FileSystemURL& dest_url,
const StatusCallback& callback,
CopyOrMoveImpl* impl,
- base::PlatformFileError error);
+ base::File::Error error);
void DidTryRemoveDestRoot(const StatusCallback& callback,
- base::PlatformFileError error);
+ base::File::Error error);
void ProcessDirectoryInternal(const FileSystemURL& src_url,
const FileSystemURL& dest_url,
const StatusCallback& callback);
void DidCreateDirectory(const FileSystemURL& src_url,
const FileSystemURL& dest_url,
const StatusCallback& callback,
- base::PlatformFileError error);
+ base::File::Error error);
void PostProcessDirectoryAfterGetMetadata(
const FileSystemURL& src_url,
const StatusCallback& callback,
- base::PlatformFileError error,
- const base::PlatformFileInfo& file_info);
+ base::File::Error error,
+ const base::File::Info& file_info);
void PostProcessDirectoryAfterTouchFile(const FileSystemURL& src_url,
const StatusCallback& callback,
- base::PlatformFileError error);
+ base::File::Error error);
void DidRemoveSourceForMove(const StatusCallback& callback,
- base::PlatformFileError error);
+ base::File::Error error);
void OnCopyFileProgress(const FileSystemURL& src_url, int64 size);
FileSystemURL CreateDestURL(const FileSystemURL& src_url) const;
diff --git a/chromium/webkit/browser/fileapi/dragged_file_util.cc b/chromium/webkit/browser/fileapi/dragged_file_util.cc
index 3e81242532f..0243b3d15d8 100644
--- a/chromium/webkit/browser/fileapi/dragged_file_util.cc
+++ b/chromium/webkit/browser/fileapi/dragged_file_util.cc
@@ -15,9 +15,6 @@
#include "webkit/browser/fileapi/native_file_util.h"
#include "webkit/common/blob/shareable_file_reference.h"
-using base::PlatformFileError;
-using base::PlatformFileInfo;
-
namespace fileapi {
typedef IsolatedContext::MountPointInfo FileInfo;
@@ -51,7 +48,7 @@ class SetFileEnumerator : public FileSystemFileUtil::AbstractFileEnumerator {
private:
std::vector<FileInfo> files_;
std::vector<FileInfo>::const_iterator file_iter_;
- base::PlatformFileInfo file_info_;
+ base::File::Info file_info_;
};
} // namespace
@@ -60,10 +57,10 @@ class SetFileEnumerator : public FileSystemFileUtil::AbstractFileEnumerator {
DraggedFileUtil::DraggedFileUtil() {}
-PlatformFileError DraggedFileUtil::GetFileInfo(
+base::File::Error DraggedFileUtil::GetFileInfo(
FileSystemOperationContext* context,
const FileSystemURL& url,
- PlatformFileInfo* file_info,
+ base::File::Info* file_info,
base::FilePath* platform_path) {
DCHECK(file_info);
std::string filesystem_id;
@@ -77,15 +74,15 @@ PlatformFileError DraggedFileUtil::GetFileInfo(
file_info->is_directory = true;
file_info->is_symbolic_link = false;
file_info->size = 0;
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_OK;
}
- base::PlatformFileError error =
+ base::File::Error error =
NativeFileUtil::GetFileInfo(url.path(), file_info);
if (base::IsLink(url.path()) && !base::FilePath().IsParent(url.path())) {
// Don't follow symlinks unless it's the one that are selected by the user.
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
}
- if (error == base::PLATFORM_FILE_OK)
+ if (error == base::File::FILE_OK)
*platform_path = url.path();
return error;
}
diff --git a/chromium/webkit/browser/fileapi/dragged_file_util.h b/chromium/webkit/browser/fileapi/dragged_file_util.h
index 22c538e1b34..8807fc1883a 100644
--- a/chromium/webkit/browser/fileapi/dragged_file_util.h
+++ b/chromium/webkit/browser/fileapi/dragged_file_util.h
@@ -23,10 +23,10 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE DraggedFileUtil
virtual ~DraggedFileUtil() {}
// FileSystemFileUtil overrides.
- virtual base::PlatformFileError GetFileInfo(
+ virtual base::File::Error GetFileInfo(
FileSystemOperationContext* context,
const FileSystemURL& url,
- base::PlatformFileInfo* file_info,
+ base::File::Info* file_info,
base::FilePath* platform_path) OVERRIDE;
virtual scoped_ptr<AbstractFileEnumerator> CreateFileEnumerator(
FileSystemOperationContext* context,
diff --git a/chromium/webkit/browser/fileapi/dump_file_system.cc b/chromium/webkit/browser/fileapi/dump_file_system.cc
index a1ffa4a19c6..b7d3b13df10 100644
--- a/chromium/webkit/browser/fileapi/dump_file_system.cc
+++ b/chromium/webkit/browser/fileapi/dump_file_system.cc
@@ -75,7 +75,7 @@ static void DumpDirectoryTree(const std::string& origin_name,
if (!base::DirectoryExists(origin_dir))
return;
- SandboxDirectoryDatabase directory_db(origin_dir);
+ SandboxDirectoryDatabase directory_db(origin_dir, NULL);
SandboxDirectoryDatabase::FileId root_id;
if (!directory_db.GetFileWithPath(StringToFilePath("/"), &root_id))
return;
@@ -133,7 +133,7 @@ static void DumpDirectoryTree(const std::string& origin_name,
static void DumpOrigin(const base::FilePath& file_system_dir,
const std::string& origin_name) {
- SandboxOriginDatabase origin_db(file_system_dir);
+ SandboxOriginDatabase origin_db(file_system_dir, NULL);
base::FilePath origin_dir;
if (!origin_db.HasOriginPath(origin_name)) {
ShowMessageAndExit("Origin " + origin_name + " is not in " +
@@ -148,7 +148,7 @@ static void DumpOrigin(const base::FilePath& file_system_dir,
}
static void DumpFileSystem(const base::FilePath& file_system_dir) {
- SandboxOriginDatabase origin_db(file_system_dir);
+ SandboxOriginDatabase origin_db(file_system_dir, NULL);
std::vector<SandboxOriginDatabase::OriginRecord> origins;
origin_db.ListAllOrigins(&origins);
for (size_t i = 0; i < origins.size(); i++) {
diff --git a/chromium/webkit/browser/fileapi/external_mount_points.cc b/chromium/webkit/browser/fileapi/external_mount_points.cc
index 42b6de7754c..3acfd7f3353 100644
--- a/chromium/webkit/browser/fileapi/external_mount_points.cc
+++ b/chromium/webkit/browser/fileapi/external_mount_points.cc
@@ -30,6 +30,11 @@ base::FilePath NormalizeFilePath(const base::FilePath& path) {
return base::FilePath(path_str).NormalizePathSeparators();
}
+bool IsOverlappingMountPathForbidden(fileapi::FileSystemType type) {
+ return type != fileapi::kFileSystemTypeNativeMedia &&
+ type != fileapi::kFileSystemTypeDeviceMedia;
+}
+
// Wrapper around ref-counted ExternalMountPoints that will be used to lazily
// create and initialize LazyInstance system ExternalMountPoints.
class SystemMountPointsLazyWrapper {
@@ -101,11 +106,11 @@ bool ExternalMountPoints::RegisterFileSystem(
base::AutoLock locker(lock_);
base::FilePath path = NormalizeFilePath(path_in);
- if (!ValidateNewMountPoint(mount_name, path))
+ if (!ValidateNewMountPoint(mount_name, type, path))
return false;
instance_map_[mount_name] = new Instance(type, path, mount_option);
- if (!path.empty())
+ if (!path.empty() && IsOverlappingMountPathForbidden(type))
path_to_name_map_.insert(std::make_pair(path, mount_name));
return true;
}
@@ -122,7 +127,8 @@ bool ExternalMountPoints::RevokeFileSystem(const std::string& mount_name) {
if (found == instance_map_.end())
return false;
Instance* instance = found->second;
- path_to_name_map_.erase(NormalizeFilePath(instance->path()));
+ if (IsOverlappingMountPathForbidden(instance->type()))
+ path_to_name_map_.erase(NormalizeFilePath(instance->path()));
delete found->second;
instance_map_.erase(found);
return true;
@@ -143,6 +149,7 @@ bool ExternalMountPoints::CrackVirtualPath(
const base::FilePath& virtual_path,
std::string* mount_name,
FileSystemType* type,
+ std::string* cracked_id,
base::FilePath* path,
FileSystemMountOption* mount_option) const {
DCHECK(mount_name);
@@ -288,21 +295,24 @@ FileSystemURL ExternalMountPoints::CrackFileSystemURL(
std::string mount_name;
FileSystemType cracked_type;
+ std::string cracked_id;
base::FilePath cracked_path;
FileSystemMountOption cracked_mount_option;
if (!CrackVirtualPath(virtual_path, &mount_name, &cracked_type,
- &cracked_path, &cracked_mount_option)) {
+ &cracked_id, &cracked_path, &cracked_mount_option)) {
return FileSystemURL();
}
return FileSystemURL(
url.origin(), url.mount_type(), url.virtual_path(),
!url.filesystem_id().empty() ? url.filesystem_id() : mount_name,
- cracked_type, cracked_path, mount_name, cracked_mount_option);
+ cracked_type, cracked_path,
+ cracked_id.empty() ? mount_name : cracked_id, cracked_mount_option);
}
bool ExternalMountPoints::ValidateNewMountPoint(const std::string& mount_name,
+ FileSystemType type,
const base::FilePath& path) {
lock_.AssertAcquired();
@@ -323,22 +333,28 @@ bool ExternalMountPoints::ValidateNewMountPoint(const std::string& mount_name,
if (path.ReferencesParent() || !path.IsAbsolute())
return false;
- // Check there the new path does not overlap with one of the existing ones.
- std::map<base::FilePath, std::string>::reverse_iterator potential_parent(
- path_to_name_map_.upper_bound(path));
- if (potential_parent != path_to_name_map_.rend()) {
- if (potential_parent->first == path ||
- potential_parent->first.IsParent(path)) {
- return false;
+ if (IsOverlappingMountPathForbidden(type)) {
+ // Check there the new path does not overlap with one of the existing ones.
+ std::map<base::FilePath, std::string>::reverse_iterator potential_parent(
+ path_to_name_map_.upper_bound(path));
+ if (potential_parent != path_to_name_map_.rend()) {
+ if (potential_parent->first == path ||
+ potential_parent->first.IsParent(path)) {
+ return false;
+ }
+ }
+
+ std::map<base::FilePath, std::string>::iterator potential_child =
+ path_to_name_map_.upper_bound(path);
+ if (potential_child != path_to_name_map_.end()) {
+ if (potential_child->first == path ||
+ path.IsParent(potential_child->first)) {
+ return false;
+ }
}
}
- std::map<base::FilePath, std::string>::iterator potential_child =
- path_to_name_map_.upper_bound(path);
- if (potential_child == path_to_name_map_.end())
- return true;
- return !(potential_child->first == path) &&
- !path.IsParent(potential_child->first);
+ return true;
}
} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/external_mount_points.h b/chromium/webkit/browser/fileapi/external_mount_points.h
index 9fb3cc36cc3..7891375dcfe 100644
--- a/chromium/webkit/browser/fileapi/external_mount_points.h
+++ b/chromium/webkit/browser/fileapi/external_mount_points.h
@@ -21,10 +21,8 @@ class FilePath;
}
namespace fileapi {
-class FileSystemURL;
-}
-namespace fileapi {
+class FileSystemURL;
// Manages external filesystem namespaces that are identified by 'mount name'
// and are persisted until RevokeFileSystem is called.
@@ -53,7 +51,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT ExternalMountPoints
//
// Overlapping mount points in a single MountPoints instance are not allowed.
// Adding mount point whose path overlaps with an existing mount point will
- // fail.
+ // fail except for media galleries, which do not count toward registered
+ // paths for overlap calculation.
//
// If not empty, |path| must be absolute. It is allowed for the path to be
// empty, but |GetVirtualPath| will not work for those mount points.
@@ -74,6 +73,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT ExternalMountPoints
const base::FilePath& virtual_path,
std::string* mount_name,
FileSystemType* type,
+ std::string* cracked_id,
base::FilePath* path,
FileSystemMountOption* mount_option) const OVERRIDE;
virtual FileSystemURL CrackURL(const GURL& url) const OVERRIDE;
@@ -93,6 +93,11 @@ class WEBKIT_STORAGE_BROWSER_EXPORT ExternalMountPoints
// Returns false if the path cannot be resolved (e.g. if the path is not
// part of any registered filesystem).
//
+ // Media gallery type file systems do not count for this calculation. i.e.
+ // if only a media gallery is registered for the path, false will be returned.
+ // If a media gallery and another file system are registered for related
+ // paths, only the other registration is taken into account.
+ //
// Returned virtual_path will have normalized path separators.
bool GetVirtualPath(const base::FilePath& absolute_path,
base::FilePath* virtual_path) const;
@@ -132,10 +137,12 @@ class WEBKIT_STORAGE_BROWSER_EXPORT ExternalMountPoints
// - there is no registered mount point with mount_name
// - path does not contain a reference to a parent
// - path is absolute
- // - path does not overlap with an existing mount point path.
+ // - path does not overlap with an existing mount point path unless it is a
+ // media gallery type.
//
// |lock_| should be taken before calling this method.
bool ValidateNewMountPoint(const std::string& mount_name,
+ FileSystemType type,
const base::FilePath& path);
// This lock needs to be obtained when accessing the instance_map_.
diff --git a/chromium/webkit/browser/fileapi/external_mount_points_unittest.cc b/chromium/webkit/browser/fileapi/external_mount_points_unittest.cc
deleted file mode 100644
index fa5d8d1de46..00000000000
--- a/chromium/webkit/browser/fileapi/external_mount_points_unittest.cc
+++ /dev/null
@@ -1,507 +0,0 @@
-// Copyright (c) 2013 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 "webkit/browser/fileapi/external_mount_points.h"
-
-#include <string>
-
-#include "base/files/file_path.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/fileapi/file_system_url.h"
-
-#define FPL FILE_PATH_LITERAL
-
-#if defined(FILE_PATH_USES_DRIVE_LETTERS)
-#define DRIVE FPL("C:")
-#else
-#define DRIVE
-#endif
-
-using fileapi::FileSystemURL;
-
-namespace {
-
-TEST(ExternalMountPointsTest, AddMountPoint) {
- scoped_refptr<fileapi::ExternalMountPoints> mount_points(
- fileapi::ExternalMountPoints::CreateRefCounted());
-
- struct TestCase {
- // The mount point's name.
- const char* const name;
- // The mount point's path.
- const base::FilePath::CharType* const path;
- // Whether the mount point registration should succeed.
- bool success;
- // Path returned by GetRegisteredPath. NULL if the method is expected to
- // fail.
- const base::FilePath::CharType* const registered_path;
- };
-
- const TestCase kTestCases[] = {
- // Valid mount point.
- { "test", DRIVE FPL("/foo/test"), true, DRIVE FPL("/foo/test") },
- // Valid mount point with only one path component.
- { "bbb", DRIVE FPL("/bbb"), true, DRIVE FPL("/bbb") },
- // Existing mount point path is substring of the mount points path.
- { "test11", DRIVE FPL("/foo/test11"), true, DRIVE FPL("/foo/test11") },
- // Path substring of an existing path.
- { "test1", DRIVE FPL("/foo/test1"), true, DRIVE FPL("/foo/test1") },
- // Empty mount point name and path.
- { "", DRIVE FPL(""), false, NULL },
- // Empty mount point name.
- { "", DRIVE FPL("/ddd"), false, NULL },
- // Empty mount point path.
- { "empty_path", FPL(""), true, FPL("") },
- // Name different from path's base name.
- { "not_base_name", DRIVE FPL("/x/y/z"), true, DRIVE FPL("/x/y/z") },
- // References parent.
- { "invalid", DRIVE FPL("../foo/invalid"), false, NULL },
- // Relative path.
- { "relative", DRIVE FPL("foo/relative"), false, NULL },
- // Existing mount point path.
- { "path_exists", DRIVE FPL("/foo/test"), false, NULL },
- // Mount point with the same name exists.
- { "test", DRIVE FPL("/foo/a/test_name_exists"), false,
- DRIVE FPL("/foo/test") },
- // Child of an existing mount point.
- { "a1", DRIVE FPL("/foo/test/a"), false, NULL },
- // Parent of an existing mount point.
- { "foo1", DRIVE FPL("/foo"), false, NULL },
- // Bit bigger depth.
- { "g", DRIVE FPL("/foo/a/b/c/d/e/f/g"), true,
- DRIVE FPL("/foo/a/b/c/d/e/f/g") },
- // Sibling mount point (with similar name) exists.
- { "ff", DRIVE FPL("/foo/a/b/c/d/e/ff"), true,
- DRIVE FPL("/foo/a/b/c/d/e/ff") },
- // Lexicographically last among existing mount points.
- { "yyy", DRIVE FPL("/zzz/yyy"), true, DRIVE FPL("/zzz/yyy") },
- // Parent of the lexicographically last mount point.
- { "zzz1", DRIVE FPL("/zzz"), false, NULL },
- // Child of the lexicographically last mount point.
- { "xxx1", DRIVE FPL("/zzz/yyy/xxx"), false, NULL },
- // Lexicographically first among existing mount points.
- { "b", DRIVE FPL("/a/b"), true, DRIVE FPL("/a/b") },
- // Parent of lexicographically first mount point.
- { "a2", DRIVE FPL("/a"), false, NULL },
- // Child of lexicographically last mount point.
- { "c1", DRIVE FPL("/a/b/c"), false, NULL },
- // Parent to all of the mount points.
- { "root", DRIVE FPL("/"), false, NULL },
- // Path contains .. component.
- { "funky", DRIVE FPL("/tt/fun/../funky"), false, NULL },
- // Windows separators.
-#if defined(FILE_PATH_USES_WIN_SEPARATORS)
- { "win", DRIVE FPL("\\try\\separators\\win"), true,
- DRIVE FPL("\\try\\separators\\win") },
- { "win1", DRIVE FPL("\\try/separators\\win1"), true,
- DRIVE FPL("\\try/separators\\win1") },
- { "win2", DRIVE FPL("\\try/separators\\win"), false, NULL },
-#else
- { "win", DRIVE FPL("\\separators\\win"), false, NULL },
- { "win1", DRIVE FPL("\\try/separators\\win1"), false, NULL },
-#endif
- // Win separators, but relative path.
- { "win2", DRIVE FPL("try\\separators\\win2"), false, NULL },
- };
-
- // Test adding mount points.
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) {
- EXPECT_EQ(kTestCases[i].success,
- mount_points->RegisterFileSystem(
- kTestCases[i].name,
- fileapi::kFileSystemTypeNativeLocal,
- fileapi::FileSystemMountOption(),
- base::FilePath(kTestCases[i].path)))
- << "Adding mount point: " << kTestCases[i].name << " with path "
- << kTestCases[i].path;
- }
-
- // Test that final mount point presence state is as expected.
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) {
- base::FilePath found_path;
- EXPECT_EQ(kTestCases[i].registered_path != NULL,
- mount_points->GetRegisteredPath(kTestCases[i].name, &found_path))
- << "Test case: " << i;
-
- if (kTestCases[i].registered_path) {
- base::FilePath expected_path(kTestCases[i].registered_path);
- EXPECT_EQ(expected_path.NormalizePathSeparators(), found_path);
- }
- }
-}
-
-TEST(ExternalMountPointsTest, GetVirtualPath) {
- scoped_refptr<fileapi::ExternalMountPoints> mount_points(
- fileapi::ExternalMountPoints::CreateRefCounted());
-
- mount_points->RegisterFileSystem("c",
- fileapi::kFileSystemTypeNativeLocal,
- fileapi::FileSystemMountOption(),
- base::FilePath(DRIVE FPL("/a/b/c")));
- // Note that "/a/b/c" < "/a/b/c(1)" < "/a/b/c/".
- mount_points->RegisterFileSystem("c(1)",
- fileapi::kFileSystemTypeNativeLocal,
- fileapi::FileSystemMountOption(),
- base::FilePath(DRIVE FPL("/a/b/c(1)")));
- mount_points->RegisterFileSystem("x",
- fileapi::kFileSystemTypeNativeLocal,
- fileapi::FileSystemMountOption(),
- base::FilePath(DRIVE FPL("/z/y/x")));
- mount_points->RegisterFileSystem("o",
- fileapi::kFileSystemTypeNativeLocal,
- fileapi::FileSystemMountOption(),
- base::FilePath(DRIVE FPL("/m/n/o")));
- // A mount point whose name does not match its path base name.
- mount_points->RegisterFileSystem("mount",
- fileapi::kFileSystemTypeNativeLocal,
- fileapi::FileSystemMountOption(),
- base::FilePath(DRIVE FPL("/root/foo")));
- // A mount point with an empty path.
- mount_points->RegisterFileSystem("empty_path",
- fileapi::kFileSystemTypeNativeLocal,
- fileapi::FileSystemMountOption(),
- base::FilePath());
-
- struct TestCase {
- const base::FilePath::CharType* const local_path;
- bool success;
- const base::FilePath::CharType* const virtual_path;
- };
-
- const TestCase kTestCases[] = {
- // Empty path.
- { FPL(""), false, FPL("") },
- // No registered mount point (but is parent to a mount point).
- { DRIVE FPL("/a/b"), false, FPL("") },
- // No registered mount point (but is parent to a mount point).
- { DRIVE FPL("/z/y"), false, FPL("") },
- // No registered mount point (but is parent to a mount point).
- { DRIVE FPL("/m/n"), false, FPL("") },
- // No registered mount point.
- { DRIVE FPL("/foo/mount"), false, FPL("") },
- // An existing mount point path is substring.
- { DRIVE FPL("/a/b/c1"), false, FPL("") },
- // No leading /.
- { DRIVE FPL("a/b/c"), false, FPL("") },
- // Sibling to a root path.
- { DRIVE FPL("/a/b/d/e"), false, FPL("") },
- // Sibling to a root path.
- { DRIVE FPL("/z/y/v/u"), false, FPL("") },
- // Sibling to a root path.
- { DRIVE FPL("/m/n/p/q"), false, FPL("") },
- // Mount point root path.
- { DRIVE FPL("/a/b/c"), true, FPL("c") },
- // Mount point root path.
- { DRIVE FPL("/z/y/x"), true, FPL("x") },
- // Mount point root path.
- { DRIVE FPL("/m/n/o"), true, FPL("o") },
- // Mount point child path.
- { DRIVE FPL("/a/b/c/d/e"), true, FPL("c/d/e") },
- // Mount point child path.
- { DRIVE FPL("/z/y/x/v/u"), true, FPL("x/v/u") },
- // Mount point child path.
- { DRIVE FPL("/m/n/o/p/q"), true, FPL("o/p/q") },
- // Name doesn't match mount point path base name.
- { DRIVE FPL("/root/foo/a/b/c"), true, FPL("mount/a/b/c") },
- { DRIVE FPL("/root/foo"), true, FPL("mount") },
- // Mount point contains character whose ASCII code is smaller than file path
- // separator's.
- { DRIVE FPL("/a/b/c(1)/d/e"), true, FPL("c(1)/d/e") },
-#if defined(FILE_PATH_USES_WIN_SEPARATORS)
- // Path with win separators mixed in.
- { DRIVE FPL("/a\\b\\c/d"), true, FPL("c/d") },
-#endif
- };
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) {
- // Initialize virtual path with a value.
- base::FilePath virtual_path(DRIVE FPL("/mount"));
- base::FilePath local_path(kTestCases[i].local_path);
- EXPECT_EQ(kTestCases[i].success,
- mount_points->GetVirtualPath(local_path, &virtual_path))
- << "Resolving " << kTestCases[i].local_path;
-
- // There are no guarantees for |virtual_path| value if |GetVirtualPath|
- // fails.
- if (!kTestCases[i].success)
- continue;
-
- base::FilePath expected_virtual_path(kTestCases[i].virtual_path);
- EXPECT_EQ(expected_virtual_path.NormalizePathSeparators(), virtual_path)
- << "Resolving " << kTestCases[i].local_path;
- }
-}
-
-TEST(ExternalMountPointsTest, HandlesFileSystemMountType) {
- scoped_refptr<fileapi::ExternalMountPoints> mount_points(
- fileapi::ExternalMountPoints::CreateRefCounted());
-
- const GURL test_origin("http://chromium.org");
- const base::FilePath test_path(FPL("/mount"));
-
- // Should handle External File System.
- EXPECT_TRUE(mount_points->HandlesFileSystemMountType(
- fileapi::kFileSystemTypeExternal));
-
- // Shouldn't handle the rest.
- EXPECT_FALSE(mount_points->HandlesFileSystemMountType(
- fileapi::kFileSystemTypeIsolated));
- EXPECT_FALSE(mount_points->HandlesFileSystemMountType(
- fileapi::kFileSystemTypeTemporary));
- EXPECT_FALSE(mount_points->HandlesFileSystemMountType(
- fileapi::kFileSystemTypePersistent));
- EXPECT_FALSE(mount_points->HandlesFileSystemMountType(
- fileapi::kFileSystemTypeTest));
- // Not even if it's external subtype.
- EXPECT_FALSE(mount_points->HandlesFileSystemMountType(
- fileapi::kFileSystemTypeNativeLocal));
- EXPECT_FALSE(mount_points->HandlesFileSystemMountType(
- fileapi::kFileSystemTypeRestrictedNativeLocal));
- EXPECT_FALSE(mount_points->HandlesFileSystemMountType(
- fileapi::kFileSystemTypeDrive));
- EXPECT_FALSE(mount_points->HandlesFileSystemMountType(
- fileapi::kFileSystemTypeSyncable));
-}
-
-TEST(ExternalMountPointsTest, CreateCrackedFileSystemURL) {
- scoped_refptr<fileapi::ExternalMountPoints> mount_points(
- fileapi::ExternalMountPoints::CreateRefCounted());
-
- const GURL kTestOrigin("http://chromium.org");
-
- mount_points->RegisterFileSystem("c",
- fileapi::kFileSystemTypeNativeLocal,
- fileapi::FileSystemMountOption(),
- base::FilePath(DRIVE FPL("/a/b/c")));
- mount_points->RegisterFileSystem("c(1)",
- fileapi::kFileSystemTypeDrive,
- fileapi::FileSystemMountOption(),
- base::FilePath(DRIVE FPL("/a/b/c(1)")));
- mount_points->RegisterFileSystem("empty_path",
- fileapi::kFileSystemTypeSyncable,
- fileapi::FileSystemMountOption(),
- base::FilePath());
- mount_points->RegisterFileSystem("mount",
- fileapi::kFileSystemTypeDrive,
- fileapi::FileSystemMountOption(),
- base::FilePath(DRIVE FPL("/root")));
-
- // Try cracking invalid GURL.
- FileSystemURL invalid = mount_points->CrackURL(GURL("http://chromium.og"));
- EXPECT_FALSE(invalid.is_valid());
-
- // Try cracking isolated path.
- FileSystemURL isolated = mount_points->CreateCrackedFileSystemURL(
- kTestOrigin, fileapi::kFileSystemTypeIsolated, base::FilePath(FPL("c")));
- EXPECT_FALSE(isolated.is_valid());
-
- // Try native local which is not cracked.
- FileSystemURL native_local = mount_points->CreateCrackedFileSystemURL(
- kTestOrigin,
- fileapi::kFileSystemTypeNativeLocal,
- base::FilePath(FPL("c")));
- EXPECT_FALSE(native_local.is_valid());
-
- struct TestCase {
- const base::FilePath::CharType* const path;
- bool expect_valid;
- fileapi::FileSystemType expect_type;
- const base::FilePath::CharType* const expect_path;
- const char* const expect_fs_id;
- };
-
- const TestCase kTestCases[] = {
- { FPL("c/d/e"),
- true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" },
- { FPL("c(1)/d/e"),
- true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/a/b/c(1)/d/e"), "c(1)" },
- { FPL("c(1)"),
- true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/a/b/c(1)"), "c(1)" },
- { FPL("empty_path/a"),
- true, fileapi::kFileSystemTypeSyncable, FPL("a"), "empty_path" },
- { FPL("empty_path"),
- true, fileapi::kFileSystemTypeSyncable, FPL(""), "empty_path" },
- { FPL("mount/a/b"),
- true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root/a/b"), "mount" },
- { FPL("mount"),
- true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root"), "mount" },
- { FPL("cc"),
- false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
- { FPL(""),
- false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
- { FPL(".."),
- false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
- // Absolte paths.
- { FPL("/c/d/e"),
- false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
- { FPL("/c(1)/d/e"),
- false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
- { FPL("/empty_path"),
- false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
- // PAth references parent.
- { FPL("c/d/../e"),
- false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
- { FPL("/empty_path/a/../b"),
- false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
-#if defined(FILE_PATH_USES_WIN_SEPARATORS)
- { FPL("c/d\\e"),
- true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" },
- { FPL("mount\\a\\b"),
- true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root/a/b"), "mount" },
-#endif
- };
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) {
- FileSystemURL cracked = mount_points->CreateCrackedFileSystemURL(
- kTestOrigin,
- fileapi::kFileSystemTypeExternal,
- base::FilePath(kTestCases[i].path));
-
- EXPECT_EQ(kTestCases[i].expect_valid, cracked.is_valid())
- << "Test case index: " << i;
-
- if (!kTestCases[i].expect_valid)
- continue;
-
- EXPECT_EQ(kTestOrigin, cracked.origin())
- << "Test case index: " << i;
- EXPECT_EQ(kTestCases[i].expect_type, cracked.type())
- << "Test case index: " << i;
- EXPECT_EQ(base::FilePath(
- kTestCases[i].expect_path).NormalizePathSeparators(), cracked.path())
- << "Test case index: " << i;
- EXPECT_EQ(base::FilePath(kTestCases[i].path).NormalizePathSeparators(),
- cracked.virtual_path())
- << "Test case index: " << i;
- EXPECT_EQ(kTestCases[i].expect_fs_id, cracked.filesystem_id())
- << "Test case index: " << i;
- EXPECT_EQ(fileapi::kFileSystemTypeExternal, cracked.mount_type())
- << "Test case index: " << i;
- }
-}
-
-TEST(ExternalMountPointsTest, CrackVirtualPath) {
- scoped_refptr<fileapi::ExternalMountPoints> mount_points(
- fileapi::ExternalMountPoints::CreateRefCounted());
-
- const GURL kTestOrigin("http://chromium.org");
-
- mount_points->RegisterFileSystem("c",
- fileapi::kFileSystemTypeNativeLocal,
- fileapi::FileSystemMountOption(),
- base::FilePath(DRIVE FPL("/a/b/c")));
- mount_points->RegisterFileSystem("c(1)",
- fileapi::kFileSystemTypeDrive,
- fileapi::FileSystemMountOption(),
- base::FilePath(DRIVE FPL("/a/b/c(1)")));
- mount_points->RegisterFileSystem("empty_path",
- fileapi::kFileSystemTypeSyncable,
- fileapi::FileSystemMountOption(),
- base::FilePath());
- mount_points->RegisterFileSystem("mount",
- fileapi::kFileSystemTypeDrive,
- fileapi::FileSystemMountOption(),
- base::FilePath(DRIVE FPL("/root")));
-
- struct TestCase {
- const base::FilePath::CharType* const path;
- bool expect_valid;
- fileapi::FileSystemType expect_type;
- const base::FilePath::CharType* const expect_path;
- const char* const expect_name;
- };
-
- const TestCase kTestCases[] = {
- { FPL("c/d/e"),
- true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" },
- { FPL("c(1)/d/e"),
- true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/a/b/c(1)/d/e"), "c(1)" },
- { FPL("c(1)"),
- true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/a/b/c(1)"), "c(1)" },
- { FPL("empty_path/a"),
- true, fileapi::kFileSystemTypeSyncable, FPL("a"), "empty_path" },
- { FPL("empty_path"),
- true, fileapi::kFileSystemTypeSyncable, FPL(""), "empty_path" },
- { FPL("mount/a/b"),
- true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root/a/b"), "mount" },
- { FPL("mount"),
- true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root"), "mount" },
- { FPL("cc"),
- false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
- { FPL(""),
- false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
- { FPL(".."),
- false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
- // Absolte paths.
- { FPL("/c/d/e"),
- false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
- { FPL("/c(1)/d/e"),
- false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
- { FPL("/empty_path"),
- false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
- // PAth references parent.
- { FPL("c/d/../e"),
- false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
- { FPL("/empty_path/a/../b"),
- false, fileapi::kFileSystemTypeUnknown, FPL(""), "" },
-#if defined(FILE_PATH_USES_WIN_SEPARATORS)
- { FPL("c/d\\e"),
- true, fileapi::kFileSystemTypeNativeLocal, DRIVE FPL("/a/b/c/d/e"), "c" },
- { FPL("mount\\a\\b"),
- true, fileapi::kFileSystemTypeDrive, DRIVE FPL("/root/a/b"), "mount" },
-#endif
- };
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) {
- std::string cracked_name;
- fileapi::FileSystemType cracked_type;
- base::FilePath cracked_path;
- fileapi::FileSystemMountOption cracked_option;
- EXPECT_EQ(kTestCases[i].expect_valid,
- mount_points->CrackVirtualPath(base::FilePath(kTestCases[i].path),
- &cracked_name, &cracked_type, &cracked_path, &cracked_option))
- << "Test case index: " << i;
-
- if (!kTestCases[i].expect_valid)
- continue;
-
- EXPECT_EQ(kTestCases[i].expect_type, cracked_type)
- << "Test case index: " << i;
- EXPECT_EQ(base::FilePath(
- kTestCases[i].expect_path).NormalizePathSeparators(), cracked_path)
- << "Test case index: " << i;
- EXPECT_EQ(kTestCases[i].expect_name, cracked_name)
- << "Test case index: " << i;
- }
-}
-
-TEST(ExternalMountPointsTest, MountOption) {
- scoped_refptr<fileapi::ExternalMountPoints> mount_points(
- fileapi::ExternalMountPoints::CreateRefCounted());
-
- mount_points->RegisterFileSystem(
- "nosync",
- fileapi::kFileSystemTypeNativeLocal,
- fileapi::FileSystemMountOption(fileapi::COPY_SYNC_OPTION_NO_SYNC),
- base::FilePath(DRIVE FPL("/nosync")));
- mount_points->RegisterFileSystem(
- "sync",
- fileapi::kFileSystemTypeNativeLocal,
- fileapi::FileSystemMountOption(fileapi::COPY_SYNC_OPTION_SYNC),
- base::FilePath(DRIVE FPL("/sync")));
-
- std::string name;
- fileapi::FileSystemType type;
- fileapi::FileSystemMountOption option;
- base::FilePath path;
- EXPECT_TRUE(mount_points->CrackVirtualPath(
- base::FilePath(FPL("nosync/file")), &name, &type, &path, &option));
- EXPECT_EQ(fileapi::COPY_SYNC_OPTION_NO_SYNC, option.copy_sync_option());
- EXPECT_TRUE(mount_points->CrackVirtualPath(
- base::FilePath(FPL("sync/file")), &name, &type, &path, &option));
- EXPECT_EQ(fileapi::COPY_SYNC_OPTION_SYNC, option.copy_sync_option());
-}
-
-} // namespace
-
diff --git a/chromium/webkit/browser/fileapi/file_stream_writer.h b/chromium/webkit/browser/fileapi/file_stream_writer.h
index 1ebdfb9191a..3a30ab26e05 100644
--- a/chromium/webkit/browser/fileapi/file_stream_writer.h
+++ b/chromium/webkit/browser/fileapi/file_stream_writer.h
@@ -23,12 +23,15 @@ namespace fileapi {
// A generic interface for writing to a file-like object.
class FileStreamWriter {
public:
+ enum OpenOrCreate { OPEN_EXISTING_FILE, CREATE_NEW_FILE };
+
// Creates a writer for the existing file in the path |file_path| starting
// from |initial_offset|. Uses |task_runner| for async file operations.
WEBKIT_STORAGE_BROWSER_EXPORT static FileStreamWriter* CreateForLocalFile(
base::TaskRunner* task_runner,
const base::FilePath& file_path,
- int64 initial_offset);
+ int64 initial_offset,
+ OpenOrCreate open_or_create);
// Closes the file. If there's an in-flight operation, it is canceled (i.e.,
// the callback function associated with the operation is not called).
diff --git a/chromium/webkit/browser/fileapi/file_system_backend.h b/chromium/webkit/browser/fileapi/file_system_backend.h
index 048c86d2a3b..f6cca94b703 100644
--- a/chromium/webkit/browser/fileapi/file_system_backend.h
+++ b/chromium/webkit/browser/fileapi/file_system_backend.h
@@ -9,9 +9,9 @@
#include <vector>
#include "base/callback_forward.h"
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
-#include "base/platform_file.h"
#include "webkit/browser/fileapi/file_permission_policy.h"
#include "webkit/browser/fileapi/open_file_system_mode.h"
#include "webkit/browser/webkit_storage_browser_export.h"
@@ -44,7 +44,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemBackend {
// Callback for InitializeFileSystem.
typedef base::Callback<void(const GURL& root_url,
const std::string& name,
- base::PlatformFileError error)>
+ base::File::Error error)>
OpenFileSystemCallback;
virtual ~FileSystemBackend() {}
@@ -57,26 +57,24 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemBackend {
// do additional initialization which depends on FileSystemContext here.
virtual void Initialize(FileSystemContext* context) = 0;
- // Opens the filesystem for the given |origin_url| and |type|.
- // This verifies if it is allowed to request (or create) the filesystem
- // and if it can access (or create) the root directory.
- // If |mode| is CREATE_IF_NONEXISTENT calling this may also create
- // the root directory (and/or related database entries etc) for
- // the filesystem if it doesn't exist.
- virtual void OpenFileSystem(
- const GURL& origin_url,
- FileSystemType type,
- OpenFileSystemMode mode,
- const OpenFileSystemCallback& callback) = 0;
+ // Resolves the filesystem root URL and the name for the given |url|.
+ // This verifies if it is allowed to request (or create) the filesystem and if
+ // it can access (or create) the root directory.
+ // If |mode| is CREATE_IF_NONEXISTENT calling this may also create the root
+ // directory (and/or related database entries etc) for the filesystem if it
+ // doesn't exist.
+ virtual void ResolveURL(const FileSystemURL& url,
+ OpenFileSystemMode mode,
+ const OpenFileSystemCallback& callback) = 0;
// Returns the specialized AsyncFileUtil for this backend.
virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) = 0;
// Returns the specialized CopyOrMoveFileValidatorFactory for this backend
- // and |type|. If |error_code| is PLATFORM_FILE_OK and the result is NULL,
+ // and |type|. If |error_code| is File::FILE_OK and the result is NULL,
// then no validator is required.
virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory(
- FileSystemType type, base::PlatformFileError* error_code) = 0;
+ FileSystemType type, base::File::Error* error_code) = 0;
// Returns a new instance of the specialized FileSystemOperation for this
// backend based on the given triplet of |origin_url|, |file_system_type|
@@ -87,7 +85,12 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemBackend {
virtual FileSystemOperation* CreateFileSystemOperation(
const FileSystemURL& url,
FileSystemContext* context,
- base::PlatformFileError* error_code) const = 0;
+ base::File::Error* error_code) const = 0;
+
+ // Returns true if Blobs accessing |url| should use FileStreamReader.
+ // If false, Blobs are accessed using a snapshot file by calling
+ // AsyncFileUtil::CreateSnapshotFile.
+ virtual bool SupportsStreaming(const FileSystemURL& url) const = 0;
// Creates a new file stream reader for a given filesystem URL |url| with an
// offset |offset|. |expected_modification_time| specifies the expected last
diff --git a/chromium/webkit/browser/fileapi/file_system_context.cc b/chromium/webkit/browser/fileapi/file_system_context.cc
index 869410498c9..0df0a1dfced 100644
--- a/chromium/webkit/browser/fileapi/file_system_context.cc
+++ b/chromium/webkit/browser/fileapi/file_system_context.cc
@@ -8,6 +8,7 @@
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/task_runner_util.h"
+#include "net/url_request/url_request.h"
#include "url/gurl.h"
#include "webkit/browser/blob/file_stream_reader.h"
#include "webkit/browser/fileapi/copy_or_move_file_validator.h"
@@ -25,7 +26,7 @@
#include "webkit/browser/fileapi/mount_points.h"
#include "webkit/browser/fileapi/quota/quota_reservation.h"
#include "webkit/browser/fileapi/sandbox_file_system_backend.h"
-#include "webkit/browser/quota/quota_manager.h"
+#include "webkit/browser/quota/quota_manager_proxy.h"
#include "webkit/browser/quota/special_storage_policy.h"
#include "webkit/common/fileapi/file_system_info.h"
#include "webkit/common/fileapi/file_system_util.h"
@@ -47,13 +48,32 @@ void DidGetMetadataForResolveURL(
const base::FilePath& path,
const FileSystemContext::ResolveURLCallback& callback,
const FileSystemInfo& info,
- base::PlatformFileError error,
- const base::PlatformFileInfo& file_info) {
- if (error != base::PLATFORM_FILE_OK) {
- callback.Run(error, FileSystemInfo(), base::FilePath(), false);
+ base::File::Error error,
+ const base::File::Info& file_info) {
+ if (error != base::File::FILE_OK) {
+ if (error == base::File::FILE_ERROR_NOT_FOUND) {
+ callback.Run(base::File::FILE_OK, info, path,
+ FileSystemContext::RESOLVED_ENTRY_NOT_FOUND);
+ } else {
+ callback.Run(error, FileSystemInfo(), base::FilePath(),
+ FileSystemContext::RESOLVED_ENTRY_NOT_FOUND);
+ }
return;
}
- callback.Run(error, info, path, file_info.is_directory);
+ callback.Run(error, info, path, file_info.is_directory ?
+ FileSystemContext::RESOLVED_ENTRY_DIRECTORY :
+ FileSystemContext::RESOLVED_ENTRY_FILE);
+}
+
+void RelayResolveURLCallback(
+ scoped_refptr<base::MessageLoopProxy> message_loop,
+ const FileSystemContext::ResolveURLCallback& callback,
+ base::File::Error result,
+ const FileSystemInfo& info,
+ const base::FilePath& file_path,
+ FileSystemContext::ResolvedEntryType type) {
+ message_loop->PostTask(
+ FROM_HERE, base::Bind(callback, result, info, file_path, type));
}
} // namespace
@@ -69,21 +89,26 @@ int FileSystemContext::GetPermissionPolicy(FileSystemType type) {
case kFileSystemTypeDrive:
case kFileSystemTypeNativeForPlatformApp:
case kFileSystemTypeNativeLocal:
+ case kFileSystemTypeCloudDevice:
+ case kFileSystemTypeProvided:
+ case kFileSystemTypeDeviceMediaAsFileStorage:
return FILE_PERMISSION_USE_FILE_PERMISSION;
case kFileSystemTypeRestrictedNativeLocal:
return FILE_PERMISSION_READ_ONLY |
FILE_PERMISSION_USE_FILE_PERMISSION;
- // Following types are only accessed via IsolatedFileSystem, and
- // don't have their own permission policies.
case kFileSystemTypeDeviceMedia:
- case kFileSystemTypeDragged:
- case kFileSystemTypeForTransientFile:
case kFileSystemTypeIphoto:
case kFileSystemTypeItunes:
case kFileSystemTypeNativeMedia:
case kFileSystemTypePicasa:
+ return FILE_PERMISSION_USE_FILE_PERMISSION;
+
+ // Following types are only accessed via IsolatedFileSystem, and
+ // don't have their own permission policies.
+ case kFileSystemTypeDragged:
+ case kFileSystemTypeForTransientFile:
case kFileSystemTypePluginPrivate:
return FILE_PERMISSION_ALWAYS_DENY;
@@ -112,6 +137,7 @@ FileSystemContext::FileSystemContext(
quota::SpecialStoragePolicy* special_storage_policy,
quota::QuotaManagerProxy* quota_manager_proxy,
ScopedVector<FileSystemBackend> additional_backends,
+ const std::vector<URLRequestAutoMountHandler>& auto_mount_handlers,
const base::FilePath& partition_path,
const FileSystemOptions& options)
: io_task_runner_(io_task_runner),
@@ -132,6 +158,7 @@ FileSystemContext::FileSystemContext(
special_storage_policy,
options)),
additional_backends_(additional_backends.Pass()),
+ auto_mount_handlers_(auto_mount_handlers),
external_mount_points_(external_mount_points),
partition_path_(partition_path),
is_incognito_(options.is_incognito()),
@@ -169,7 +196,7 @@ FileSystemContext::FileSystemContext(
url_crackers_.push_back(IsolatedContext::GetInstance());
}
-bool FileSystemContext::DeleteDataForOriginOnFileThread(
+bool FileSystemContext::DeleteDataForOriginOnFileTaskRunner(
const GURL& origin_url) {
DCHECK(default_file_task_runner()->RunsTasksOnCurrentThread());
DCHECK(origin_url == origin_url.GetOrigin());
@@ -181,9 +208,9 @@ bool FileSystemContext::DeleteDataForOriginOnFileThread(
FileSystemBackend* backend = iter->second;
if (!backend->GetQuotaUtil())
continue;
- if (backend->GetQuotaUtil()->DeleteOriginDataOnFileThread(
+ if (backend->GetQuotaUtil()->DeleteOriginDataOnFileTaskRunner(
this, quota_manager_proxy(), origin_url, iter->first)
- != base::PLATFORM_FILE_OK) {
+ != base::File::FILE_OK) {
// Continue the loop, but record the failure.
success = false;
}
@@ -232,9 +259,9 @@ AsyncFileUtil* FileSystemContext::GetAsyncFileUtil(
CopyOrMoveFileValidatorFactory*
FileSystemContext::GetCopyOrMoveFileValidatorFactory(
- FileSystemType type, base::PlatformFileError* error_code) const {
+ FileSystemType type, base::File::Error* error_code) const {
DCHECK(error_code);
- *error_code = base::PLATFORM_FILE_OK;
+ *error_code = base::File::FILE_OK;
FileSystemBackend* backend = GetFileSystemBackend(type);
if (!backend)
return NULL;
@@ -296,53 +323,69 @@ void FileSystemContext::OpenFileSystem(
if (!FileSystemContext::IsSandboxFileSystem(type)) {
// Disallow opening a non-sandboxed filesystem.
- callback.Run(GURL(), std::string(), base::PLATFORM_FILE_ERROR_SECURITY);
+ callback.Run(GURL(), std::string(), base::File::FILE_ERROR_SECURITY);
return;
}
FileSystemBackend* backend = GetFileSystemBackend(type);
if (!backend) {
- callback.Run(GURL(), std::string(), base::PLATFORM_FILE_ERROR_SECURITY);
+ callback.Run(GURL(), std::string(), base::File::FILE_ERROR_SECURITY);
return;
}
- backend->OpenFileSystem(origin_url, type, mode, callback);
+ backend->ResolveURL(
+ CreateCrackedFileSystemURL(origin_url, type, base::FilePath()),
+ mode,
+ callback);
}
void FileSystemContext::ResolveURL(
const FileSystemURL& url,
const ResolveURLCallback& callback) {
- DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
DCHECK(!callback.is_null());
- if (!FileSystemContext::IsSandboxFileSystem(url.type())) {
-#ifdef OS_CHROMEOS
- // Do not have to open a non-sandboxed filesystem.
- // TODO(nhiroki): For now we assume this path is called only on ChromeOS,
- // but this assumption may be broken in the future and we should handle
- // more generally. http://crbug.com/304062.
- FileSystemInfo info = GetFileSystemInfoForChromeOS(url.origin());
- DidOpenFileSystemForResolveURL(
- url, callback, info.root_url, info.name, base::PLATFORM_FILE_OK);
- return;
-#endif
- callback.Run(base::PLATFORM_FILE_ERROR_SECURITY,
- FileSystemInfo(), base::FilePath(), false);
+ // If not on IO thread, forward before passing the task to the backend.
+ if (!io_task_runner_->RunsTasksOnCurrentThread()) {
+ ResolveURLCallback relay_callback =
+ base::Bind(&RelayResolveURLCallback,
+ base::MessageLoopProxy::current(), callback);
+ io_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&FileSystemContext::ResolveURL, this, url, relay_callback));
return;
}
FileSystemBackend* backend = GetFileSystemBackend(url.type());
if (!backend) {
- callback.Run(base::PLATFORM_FILE_ERROR_SECURITY,
- FileSystemInfo(), base::FilePath(), false);
+ callback.Run(base::File::FILE_ERROR_SECURITY,
+ FileSystemInfo(), base::FilePath(),
+ FileSystemContext::RESOLVED_ENTRY_NOT_FOUND);
return;
}
- backend->OpenFileSystem(
- url.origin(), url.type(),
+ backend->ResolveURL(
+ url,
OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT,
base::Bind(&FileSystemContext::DidOpenFileSystemForResolveURL,
- this, url, callback));
+ this,
+ url,
+ callback));
+}
+
+void FileSystemContext::AttemptAutoMountForURLRequest(
+ const net::URLRequest* url_request,
+ const std::string& storage_domain,
+ const StatusCallback& callback) {
+ FileSystemURL filesystem_url(url_request->url());
+ if (filesystem_url.type() == kFileSystemTypeExternal) {
+ for (size_t i = 0; i < auto_mount_handlers_.size(); i++) {
+ if (auto_mount_handlers_[i].Run(url_request, filesystem_url,
+ storage_domain, callback)) {
+ return;
+ }
+ }
+ }
+ callback.Run(base::File::FILE_ERROR_NOT_FOUND);
}
void FileSystemContext::DeleteFileSystem(
@@ -355,11 +398,11 @@ void FileSystemContext::DeleteFileSystem(
FileSystemBackend* backend = GetFileSystemBackend(type);
if (!backend) {
- callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
+ callback.Run(base::File::FILE_ERROR_SECURITY);
return;
}
if (!backend->GetQuotaUtil()) {
- callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
+ callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
return;
}
@@ -367,7 +410,7 @@ void FileSystemContext::DeleteFileSystem(
default_file_task_runner(),
FROM_HERE,
// It is safe to pass Unretained(quota_util) since context owns it.
- base::Bind(&FileSystemQuotaUtil::DeleteOriginDataOnFileThread,
+ base::Bind(&FileSystemQuotaUtil::DeleteOriginDataOnFileTaskRunner,
base::Unretained(backend->GetQuotaUtil()),
make_scoped_refptr(this),
base::Unretained(quota_manager_proxy()),
@@ -436,6 +479,20 @@ bool FileSystemContext::CanServeURLRequest(const FileSystemURL& url) const {
return !is_incognito_ || !FileSystemContext::IsSandboxFileSystem(url.type());
}
+bool FileSystemContext::ShouldFlushOnWriteCompletion(
+ FileSystemType type) const {
+ if (IsSandboxFileSystem(type)) {
+ // Disable Flush() for each write operation on SandboxFileSystems since it
+ // hurts the performance, assuming the FileSystems are stored in a local
+ // disk, we don't need to keep calling fsync() for it.
+ // On the other hand, other FileSystems that may stored on a removable media
+ // should be Flush()ed as soon as a write operation is completed, so that
+ // written data is saved over sudden media removal.
+ return false;
+ }
+ return true;
+}
+
void FileSystemContext::OpenPluginPrivateFileSystem(
const GURL& origin_url,
FileSystemType type,
@@ -460,21 +517,21 @@ void FileSystemContext::DeleteOnCorrectThread() const {
}
FileSystemOperation* FileSystemContext::CreateFileSystemOperation(
- const FileSystemURL& url, base::PlatformFileError* error_code) {
+ const FileSystemURL& url, base::File::Error* error_code) {
if (!url.is_valid()) {
if (error_code)
- *error_code = base::PLATFORM_FILE_ERROR_INVALID_URL;
+ *error_code = base::File::FILE_ERROR_INVALID_URL;
return NULL;
}
FileSystemBackend* backend = GetFileSystemBackend(url.type());
if (!backend) {
if (error_code)
- *error_code = base::PLATFORM_FILE_ERROR_FAILED;
+ *error_code = base::File::FILE_ERROR_FAILED;
return NULL;
}
- base::PlatformFileError fs_error = base::PLATFORM_FILE_OK;
+ base::File::Error fs_error = base::File::FILE_OK;
FileSystemOperation* operation =
backend->CreateFileSystemOperation(url, this, &fs_error);
@@ -542,11 +599,12 @@ void FileSystemContext::DidOpenFileSystemForResolveURL(
const FileSystemContext::ResolveURLCallback& callback,
const GURL& filesystem_root,
const std::string& filesystem_name,
- base::PlatformFileError error) {
+ base::File::Error error) {
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
- if (error != base::PLATFORM_FILE_OK) {
- callback.Run(error, FileSystemInfo(), base::FilePath(), false);
+ if (error != base::File::FILE_OK) {
+ callback.Run(error, FileSystemInfo(), base::FilePath(),
+ FileSystemContext::RESOLVED_ENTRY_NOT_FOUND);
return;
}
diff --git a/chromium/webkit/browser/fileapi/file_system_context.h b/chromium/webkit/browser/fileapi/file_system_context.h
index 2ceb96fb1aa..428ef601149 100644
--- a/chromium/webkit/browser/fileapi/file_system_context.h
+++ b/chromium/webkit/browser/fileapi/file_system_context.h
@@ -10,10 +10,10 @@
#include <vector>
#include "base/callback.h"
+#include "base/files/file.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
-#include "base/platform_file.h"
#include "base/sequenced_task_runner_helpers.h"
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/browser/fileapi/open_file_system_mode.h"
@@ -38,6 +38,10 @@ class QuotaManagerProxy;
class SpecialStoragePolicy;
}
+namespace net {
+class URLRequest;
+}
+
namespace webkit_blob {
class BlobURLRequestJobTest;
class FileStreamReader;
@@ -65,6 +69,18 @@ class SandboxFileSystemBackend;
struct DefaultContextDeleter;
struct FileSystemInfo;
+// An auto mount handler will attempt to mount the file system requested in
+// |url_request|. If the URL is for this auto mount handler, it returns true
+// and calls |callback| when the attempt is complete. If the auto mounter
+// does not recognize the URL, it returns false and does not call |callback|.
+// Called on the IO thread.
+typedef base::Callback<bool(
+ const net::URLRequest* url_request,
+ const FileSystemURL& filesystem_url,
+ const std::string& storage_domain,
+ const base::Callback<void(base::File::Error result)>& callback)>
+ URLRequestAutoMountHandler;
+
// This class keeps and provides a file system context for FileSystem API.
// An instance of this class is created and owned by profile.
class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
@@ -95,6 +111,10 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
// to serve filesystem requests for non-regular types.
// If none is given, this context only handles HTML5 Sandbox FileSystem
// and Drag-and-drop Isolated FileSystem requests.
+ //
+ // |auto_mount_handlers| are used to resolve calls to
+ // AttemptAutoMountForURLRequest. Only external filesystems are auto mounted
+ // when a filesystem: URL request is made.
FileSystemContext(
base::SingleThreadTaskRunner* io_task_runner,
base::SequencedTaskRunner* file_task_runner,
@@ -102,12 +122,11 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
quota::SpecialStoragePolicy* special_storage_policy,
quota::QuotaManagerProxy* quota_manager_proxy,
ScopedVector<FileSystemBackend> additional_backends,
+ const std::vector<URLRequestAutoMountHandler>& auto_mount_handlers,
const base::FilePath& partition_path,
const FileSystemOptions& options);
- // TODO(nhiroki): Rename *OnFileThread methods since these are no longer on
- // FILE thread.
- bool DeleteDataForOriginOnFileThread(const GURL& origin_url);
+ bool DeleteDataForOriginOnFileTaskRunner(const GURL& origin_url);
// Creates a new QuotaReservation for the given |origin_url| and |type|.
// Returns NULL if |type| does not support quota or reservation fails.
@@ -133,10 +152,10 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) const;
// Returns the appropriate CopyOrMoveFileValidatorFactory for the given
- // |type|. If |error_code| is PLATFORM_FILE_OK and the result is NULL,
+ // |type|. If |error_code| is File::FILE_OK and the result is NULL,
// then no validator is required.
CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory(
- FileSystemType type, base::PlatformFileError* error_code) const;
+ FileSystemType type, base::File::Error* error_code) const;
// Returns the file system backend instance for the given |type|.
// This may return NULL if it is given an invalid or unsupported filesystem
@@ -165,17 +184,22 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
// Used for OpenFileSystem.
typedef base::Callback<void(const GURL& root,
const std::string& name,
- base::PlatformFileError result)>
+ base::File::Error result)>
OpenFileSystemCallback;
// Used for ResolveURL.
- typedef base::Callback<void(base::PlatformFileError result,
+ enum ResolvedEntryType {
+ RESOLVED_ENTRY_FILE,
+ RESOLVED_ENTRY_DIRECTORY,
+ RESOLVED_ENTRY_NOT_FOUND,
+ };
+ typedef base::Callback<void(base::File::Error result,
const FileSystemInfo& info,
const base::FilePath& file_path,
- bool is_directory)> ResolveURLCallback;
+ ResolvedEntryType type)> ResolveURLCallback;
// Used for DeleteFileSystem and OpenPluginPrivateFileSystem.
- typedef base::Callback<void(base::PlatformFileError result)> StatusCallback;
+ typedef base::Callback<void(base::File::Error result)> StatusCallback;
// Opens the filesystem for the given |origin_url| and |type|, and dispatches
// |callback| on completion.
@@ -188,13 +212,23 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
OpenFileSystemMode mode,
const OpenFileSystemCallback& callback);
- // Opens the filesystem for the given |url| as read-only, and then checks the
- // existence of the file entry referred by the URL. This should be called on
- // the IO thread.
+ // Opens the filesystem for the given |url| as read-only, if the filesystem
+ // backend referred by the URL allows opening by resolveURL. Otherwise it
+ // fails with FILE_ERROR_SECURITY. The entry pointed by the URL can be
+ // absent; in that case RESOLVED_ENTRY_NOT_FOUND type is returned to the
+ // callback for indicating the absence. Can be called from any thread with
+ // a message loop. |callback| is invoked on the caller thread.
void ResolveURL(
const FileSystemURL& url,
const ResolveURLCallback& callback);
+ // Attempts to mount the filesystem needed to satisfy |url_request| made
+ // from |storage_domain|. If an appropriate file system is not found,
+ // callback will return an error.
+ void AttemptAutoMountForURLRequest(const net::URLRequest* url_request,
+ const std::string& storage_domain,
+ const StatusCallback& callback);
+
// Deletes the filesystem for the given |origin_url| and |type|. This should
// be called on the IO thread.
void DeleteFileSystem(
@@ -257,6 +291,10 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
// (E.g. this returns false if the context is created for incognito mode)
bool CanServeURLRequest(const FileSystemURL& url) const;
+ // Returns true if a file in the file system should be flushed for each write
+ // completion.
+ bool ShouldFlushOnWriteCompletion(FileSystemType type) const;
+
// This must be used to open 'plugin private' filesystem.
// See "plugin_private_file_system_backend.h" for more details.
void OpenPluginPrivateFileSystem(
@@ -275,10 +313,10 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
friend class FileSystemOperationRunner;
// For sandbox_backend().
- friend class SandboxFileSystemTestHelper;
+ friend class content::SandboxFileSystemTestHelper;
// For plugin_private_backend().
- friend class PluginPrivateFileSystemBackendTest;
+ friend class content::PluginPrivateFileSystemBackendTest;
// Deleters.
friend struct DefaultContextDeleter;
@@ -298,7 +336,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
// Called by FileSystemOperationRunner.
FileSystemOperation* CreateFileSystemOperation(
const FileSystemURL& url,
- base::PlatformFileError* error_code);
+ base::File::Error* error_code);
// For non-cracked isolated and external mount points, returns a FileSystemURL
// created by cracking |url|. The url is cracked using MountPoints registered
@@ -318,7 +356,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
const ResolveURLCallback& callback,
const GURL& filesystem_root,
const std::string& filesystem_name,
- base::PlatformFileError error);
+ base::File::Error error);
// Returns a FileSystemBackend, used only by test code.
SandboxFileSystemBackend* sandbox_backend() const {
@@ -345,6 +383,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemContext
scoped_ptr<PluginPrivateFileSystemBackend> plugin_private_backend_;
ScopedVector<FileSystemBackend> additional_backends_;
+ std::vector<URLRequestAutoMountHandler> auto_mount_handlers_;
+
// Registered file system backends.
// The map must be constructed in the constructor since it can be accessed
// on multiple threads.
diff --git a/chromium/webkit/browser/fileapi/file_system_dir_url_request_job.cc b/chromium/webkit/browser/fileapi/file_system_dir_url_request_job.cc
index 7589b3732a0..97fe83f5ea2 100644
--- a/chromium/webkit/browser/fileapi/file_system_dir_url_request_job.cc
+++ b/chromium/webkit/browser/fileapi/file_system_dir_url_request_job.cc
@@ -9,7 +9,6 @@
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/message_loop/message_loop.h"
-#include "base/platform_file.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
@@ -35,8 +34,10 @@ namespace fileapi {
FileSystemDirURLRequestJob::FileSystemDirURLRequestJob(
URLRequest* request,
NetworkDelegate* network_delegate,
+ const std::string& storage_domain,
FileSystemContext* file_system_context)
: URLRequestJob(request, network_delegate),
+ storage_domain_(storage_domain),
file_system_context_(file_system_context),
weak_factory_(this) {
}
@@ -81,11 +82,19 @@ void FileSystemDirURLRequestJob::StartAsync() {
if (!request_)
return;
url_ = file_system_context_->CrackURL(request_->url());
+ if (!url_.is_valid()) {
+ file_system_context_->AttemptAutoMountForURLRequest(
+ request_,
+ storage_domain_,
+ base::Bind(&FileSystemDirURLRequestJob::DidAttemptAutoMount,
+ weak_factory_.GetWeakPtr()));
+ return;
+ }
if (!file_system_context_->CanServeURLRequest(url_)) {
// In incognito mode the API is not usable and there should be no data.
if (url_.is_valid() && VirtualPath::IsRootPath(url_.virtual_path())) {
// Return an empty directory if the filesystem root is queried.
- DidReadDirectory(base::PLATFORM_FILE_OK,
+ DidReadDirectory(base::File::FILE_OK,
std::vector<DirectoryEntry>(),
false);
return;
@@ -99,13 +108,23 @@ void FileSystemDirURLRequestJob::StartAsync() {
base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this));
}
+void FileSystemDirURLRequestJob::DidAttemptAutoMount(base::File::Error result) {
+ if (result >= 0 &&
+ file_system_context_->CrackURL(request_->url()).is_valid()) {
+ StartAsync();
+ } else {
+ NotifyDone(URLRequestStatus(URLRequestStatus::FAILED,
+ net::ERR_FILE_NOT_FOUND));
+ }
+}
+
void FileSystemDirURLRequestJob::DidReadDirectory(
- base::PlatformFileError result,
+ base::File::Error result,
const std::vector<DirectoryEntry>& entries,
bool has_more) {
- if (result != base::PLATFORM_FILE_OK) {
+ if (result != base::File::FILE_OK) {
int rv = net::ERR_FILE_NOT_FOUND;
- if (result == base::PLATFORM_FILE_ERROR_INVALID_URL)
+ if (result == base::File::FILE_ERROR_INVALID_URL)
rv = net::ERR_INVALID_URL;
NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv));
return;
@@ -132,11 +151,7 @@ void FileSystemDirURLRequestJob::DidReadDirectory(
it->last_modified_time));
}
- if (has_more) {
- file_system_context_->operation_runner()->ReadDirectory(
- url_,
- base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this));
- } else {
+ if (!has_more) {
set_expected_content_size(data_.size());
NotifyHeadersComplete();
}
diff --git a/chromium/webkit/browser/fileapi/file_system_dir_url_request_job.h b/chromium/webkit/browser/fileapi/file_system_dir_url_request_job.h
index 933550ef4ac..67e9df38d58 100644
--- a/chromium/webkit/browser/fileapi/file_system_dir_url_request_job.h
+++ b/chromium/webkit/browser/fileapi/file_system_dir_url_request_job.h
@@ -8,10 +8,10 @@
#include <string>
#include <vector>
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop_proxy.h"
-#include "base/platform_file.h"
#include "net/url_request/url_request_job.h"
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/browser/webkit_storage_browser_export.h"
@@ -28,6 +28,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileSystemDirURLRequestJob
FileSystemDirURLRequestJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate,
+ const std::string& storage_domain,
FileSystemContext* file_system_context);
// URLRequestJob methods:
@@ -49,12 +50,14 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileSystemDirURLRequestJob
virtual ~FileSystemDirURLRequestJob();
void StartAsync();
- void DidReadDirectory(base::PlatformFileError result,
+ void DidAttemptAutoMount(base::File::Error result);
+ void DidReadDirectory(base::File::Error result,
const std::vector<DirectoryEntry>& entries,
bool has_more);
std::string data_;
FileSystemURL url_;
+ const std::string storage_domain_;
FileSystemContext* file_system_context_;
base::WeakPtrFactory<FileSystemDirURLRequestJob> weak_factory_;
diff --git a/chromium/webkit/browser/fileapi/file_system_file_stream_reader.cc b/chromium/webkit/browser/fileapi/file_system_file_stream_reader.cc
index f5427b7620f..330d011e910 100644
--- a/chromium/webkit/browser/fileapi/file_system_file_stream_reader.cc
+++ b/chromium/webkit/browser/fileapi/file_system_file_stream_reader.cc
@@ -5,7 +5,6 @@
#include "webkit/browser/fileapi/file_system_file_stream_reader.h"
#include "base/files/file_util_proxy.h"
-#include "base/platform_file.h"
#include "base/single_thread_task_runner.h"
#include "net/base/file_stream.h"
#include "net/base/io_buffer.h"
@@ -117,16 +116,16 @@ int FileSystemFileStreamReader::CreateSnapshot(
void FileSystemFileStreamReader::DidCreateSnapshot(
const base::Closure& callback,
const net::CompletionCallback& error_callback,
- base::PlatformFileError file_error,
- const base::PlatformFileInfo& file_info,
+ base::File::Error file_error,
+ const base::File::Info& file_info,
const base::FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
DCHECK(has_pending_create_snapshot_);
DCHECK(!local_file_reader_.get());
has_pending_create_snapshot_ = false;
- if (file_error != base::PLATFORM_FILE_OK) {
- error_callback.Run(net::PlatformFileErrorToNetError(file_error));
+ if (file_error != base::File::FILE_OK) {
+ error_callback.Run(net::FileErrorToNetError(file_error));
return;
}
diff --git a/chromium/webkit/browser/fileapi/file_system_file_stream_reader.h b/chromium/webkit/browser/fileapi/file_system_file_stream_reader.h
index 3a90663ed95..361502237eb 100644
--- a/chromium/webkit/browser/fileapi/file_system_file_stream_reader.h
+++ b/chromium/webkit/browser/fileapi/file_system_file_stream_reader.h
@@ -6,8 +6,8 @@
#define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_FILE_STREAM_READER_H_
#include "base/bind.h"
+#include "base/files/file.h"
#include "base/memory/ref_counted.h"
-#include "base/platform_file.h"
#include "base/time/time.h"
#include "webkit/browser/blob/file_stream_reader.h"
#include "webkit/browser/fileapi/file_system_url.h"
@@ -19,6 +19,10 @@ class FilePath;
class SequencedTaskRunner;
}
+namespace content {
+class FileSystemFileStreamReaderTest;
+}
+
namespace fileapi {
class FileSystemContext;
@@ -41,7 +45,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileSystemFileStreamReader
private:
friend class webkit_blob::FileStreamReader;
- friend class FileSystemFileStreamReaderTest;
+ friend class content::FileSystemFileStreamReaderTest;
FileSystemFileStreamReader(FileSystemContext* file_system_context,
const FileSystemURL& url,
@@ -53,8 +57,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileSystemFileStreamReader
void DidCreateSnapshot(
const base::Closure& callback,
const net::CompletionCallback& error_callback,
- base::PlatformFileError file_error,
- const base::PlatformFileInfo& file_info,
+ base::File::Error file_error,
+ const base::File::Info& file_info,
const base::FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref);
diff --git a/chromium/webkit/browser/fileapi/file_system_file_util.h b/chromium/webkit/browser/fileapi/file_system_file_util.h
index 5a4d730b5c8..7957bbb29a9 100644
--- a/chromium/webkit/browser/fileapi/file_system_file_util.h
+++ b/chromium/webkit/browser/fileapi/file_system_file_util.h
@@ -5,9 +5,9 @@
#ifndef WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_
#define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_FILE_UTIL_H_
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
-#include "base/platform_file.h"
#include "webkit/browser/fileapi/file_system_operation.h"
#include "webkit/browser/webkit_storage_browser_export.h"
#include "webkit/common/blob/scoped_file.h"
@@ -60,29 +60,21 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemFileUtil {
// Creates or opens a file with the given flags.
// See header comments for AsyncFileUtil::CreateOrOpen() for more details.
// This is used only by Pepper/NaCl File API.
- virtual base::PlatformFileError CreateOrOpen(
+ virtual base::File CreateOrOpen(
FileSystemOperationContext* context,
const FileSystemURL& url,
- int file_flags,
- base::PlatformFile* file_handle,
- bool* created) = 0;
-
- // Closes the given file handle.
- // This is used only for Pepper/NaCl File API.
- virtual base::PlatformFileError Close(
- FileSystemOperationContext* context,
- base::PlatformFile file) = 0;
+ int file_flags) = 0;
// Ensures that the given |url| exist. This creates a empty new file
// at |url| if the |url| does not exist.
// See header comments for AsyncFileUtil::EnsureFileExists() for more details.
- virtual base::PlatformFileError EnsureFileExists(
+ virtual base::File::Error EnsureFileExists(
FileSystemOperationContext* context,
const FileSystemURL& url, bool* created) = 0;
// Creates directory at given url.
// See header comments for AsyncFileUtil::CreateDirectory() for more details.
- virtual base::PlatformFileError CreateDirectory(
+ virtual base::File::Error CreateDirectory(
FileSystemOperationContext* context,
const FileSystemURL& url,
bool exclusive,
@@ -90,10 +82,10 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemFileUtil {
// Retrieves the information about a file.
// See header comments for AsyncFileUtil::GetFileInfo() for more details.
- virtual base::PlatformFileError GetFileInfo(
+ virtual base::File::Error GetFileInfo(
FileSystemOperationContext* context,
const FileSystemURL& url,
- base::PlatformFileInfo* file_info,
+ base::File::Info* file_info,
base::FilePath* platform_path) = 0;
// Returns a pointer to a new instance of AbstractFileEnumerator which is
@@ -110,14 +102,14 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemFileUtil {
// Maps |file_system_url| given |context| into |local_file_path|
// which represents physical file location on the host OS.
// This may not always make sense for all subclasses.
- virtual base::PlatformFileError GetLocalFilePath(
+ virtual base::File::Error GetLocalFilePath(
FileSystemOperationContext* context,
const FileSystemURL& file_system_url,
base::FilePath* local_file_path) = 0;
// Updates the file metadata information.
// See header comments for AsyncFileUtil::Touch() for more details.
- virtual base::PlatformFileError Touch(
+ virtual base::File::Error Touch(
FileSystemOperationContext* context,
const FileSystemURL& url,
const base::Time& last_access_time,
@@ -125,7 +117,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemFileUtil {
// Truncates a file to the given length.
// See header comments for AsyncFileUtil::Truncate() for more details.
- virtual base::PlatformFileError Truncate(
+ virtual base::File::Error Truncate(
FileSystemOperationContext* context,
const FileSystemURL& url,
int64 length) = 0;
@@ -135,15 +127,15 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemFileUtil {
// For |option|, please see file_system_operation.h
//
// This returns:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_url|
+ // - File::FILE_ERROR_NOT_FOUND if |src_url|
// or the parent directory of |dest_url| does not exist.
- // - PLATFORM_FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
- // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
+ // - File::FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
+ // - File::FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
// is not a file.
- // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and
+ // - File::FILE_ERROR_FAILED if |dest_url| does not exist and
// its parent path is a file.
//
- virtual base::PlatformFileError CopyOrMoveFile(
+ virtual base::File::Error CopyOrMoveFile(
FileSystemOperationContext* context,
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
@@ -153,20 +145,20 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemFileUtil {
// Copies in a single file from a different filesystem.
// See header comments for AsyncFileUtil::CopyInForeignFile() for
// more details.
- virtual base::PlatformFileError CopyInForeignFile(
+ virtual base::File::Error CopyInForeignFile(
FileSystemOperationContext* context,
const base::FilePath& src_file_path,
const FileSystemURL& dest_url) = 0;
// Deletes a single file.
// See header comments for AsyncFileUtil::DeleteFile() for more details.
- virtual base::PlatformFileError DeleteFile(
+ virtual base::File::Error DeleteFile(
FileSystemOperationContext* context,
const FileSystemURL& url) = 0;
// Deletes a single empty directory.
// See header comments for AsyncFileUtil::DeleteDirectory() for more details.
- virtual base::PlatformFileError DeleteDirectory(
+ virtual base::File::Error DeleteDirectory(
FileSystemOperationContext* context,
const FileSystemURL& url) = 0;
@@ -178,8 +170,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemFileUtil {
virtual webkit_blob::ScopedFile CreateSnapshotFile(
FileSystemOperationContext* context,
const FileSystemURL& url,
- base::PlatformFileError* error,
- base::PlatformFileInfo* file_info,
+ base::File::Error* error,
+ base::File::Info* file_info,
base::FilePath* platform_path) = 0;
protected:
diff --git a/chromium/webkit/browser/fileapi/file_system_operation.h b/chromium/webkit/browser/fileapi/file_system_operation.h
index ded87f71ec2..4261a2bd39a 100644
--- a/chromium/webkit/browser/fileapi/file_system_operation.h
+++ b/chromium/webkit/browser/fileapi/file_system_operation.h
@@ -8,8 +8,8 @@
#include <vector>
#include "base/callback.h"
+#include "base/files/file.h"
#include "base/files/file_path.h"
-#include "base/platform_file.h"
#include "base/process/process.h"
#include "webkit/browser/fileapi/file_system_operation_context.h"
#include "webkit/browser/webkit_storage_browser_export.h"
@@ -66,20 +66,19 @@ class FileSystemOperation {
virtual ~FileSystemOperation() {}
// Used for CreateFile(), etc. |result| is the return code of the operation.
- typedef base::Callback<void(base::PlatformFileError result)> StatusCallback;
+ typedef base::Callback<void(base::File::Error result)> StatusCallback;
// Used for GetMetadata(). |result| is the return code of the operation,
// |file_info| is the obtained file info.
typedef base::Callback<
- void(base::PlatformFileError result,
- const base::PlatformFileInfo& file_info)> GetMetadataCallback;
+ void(base::File::Error result,
+ const base::File::Info& file_info)> GetMetadataCallback;
- // Used for OpenFile(). |result| is the return code of the operation.
- // |on_close_callback| will be called after the file is closed in the child
- // process. It can be null, if no operation is needed on closing a file.
+ // Used for OpenFile(). |on_close_callback| will be called after the file is
+ // closed in the child process. It can be null, if no operation is needed on
+ // closing a file.
typedef base::Callback<
- void(base::PlatformFileError result,
- base::PlatformFile file,
+ void(base::File file,
const base::Closure& on_close_callback)> OpenFileCallback;
// Used for ReadDirectoryCallback.
@@ -89,7 +88,7 @@ class FileSystemOperation {
// |file_list| is the list of files read, and |has_more| is true if some files
// are yet to be read.
typedef base::Callback<
- void(base::PlatformFileError result,
+ void(base::File::Error result,
const FileEntryList& file_list,
bool has_more)> ReadDirectoryCallback;
@@ -115,8 +114,8 @@ class FileSystemOperation {
// Please see the comment for ShareableFileReference for details.
//
typedef base::Callback<
- void(base::PlatformFileError result,
- const base::PlatformFileInfo& file_info,
+ void(base::File::Error result,
+ const base::File::Info& file_info,
const base::FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref)>
SnapshotFileCallback;
@@ -221,7 +220,7 @@ class FileSystemOperation {
};
// Used for Write().
- typedef base::Callback<void(base::PlatformFileError result,
+ typedef base::Callback<void(base::File::Error result,
int64 bytes,
bool complete)> WriteCallback;
@@ -329,11 +328,11 @@ class FileSystemOperation {
//
// // Dispatch ABORT error for the current operation by invoking
// // the callback function for the ongoing operation,
- // operation_callback.Run(base::PLATFORM_FILE_ERROR_ABORT, ...);
+ // operation_callback.Run(base::File::FILE_ERROR_ABORT, ...);
//
// // Dispatch 'success' for the cancel (or dispatch appropriate
// // error code with DidFail() if the cancel has somehow failed).
- // cancel_callback.Run(base::PLATFORM_FILE_OK);
+ // cancel_callback.Run(base::File::FILE_OK);
// }
//
// Note that, for reporting failure, the callback function passed to a
@@ -352,7 +351,7 @@ class FileSystemOperation {
const StatusCallback& callback) = 0;
// Opens a file at |path| with |file_flags|, where flags are OR'ed
- // values of base::PlatformFileFlags.
+ // values of base::File::Flags.
//
// This function is used only by Pepper as of writing.
virtual void OpenFile(const FileSystemURL& path,
@@ -373,11 +372,11 @@ class FileSystemOperation {
// Copies in a single file from a different filesystem.
//
// This returns:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_file_path|
+ // - File::FILE_ERROR_NOT_FOUND if |src_file_path|
// or the parent directory of |dest_url| does not exist.
- // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
+ // - File::FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
// is not a file.
- // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and
+ // - File::FILE_ERROR_FAILED if |dest_url| does not exist and
// its parent path is a file.
//
virtual void CopyInForeignFile(const base::FilePath& src_local_disk_path,
@@ -387,8 +386,8 @@ class FileSystemOperation {
// Removes a single file.
//
// This returns:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist.
- // - PLATFORM_FILE_ERROR_NOT_A_FILE if |url| is not a file.
+ // - File::FILE_ERROR_NOT_FOUND if |url| does not exist.
+ // - File::FILE_ERROR_NOT_A_FILE if |url| is not a file.
//
virtual void RemoveFile(const FileSystemURL& url,
const StatusCallback& callback) = 0;
@@ -396,9 +395,9 @@ class FileSystemOperation {
// Removes a single empty directory.
//
// This returns:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist.
- // - PLATFORM_FILE_ERROR_NOT_A_DIRECTORY if |url| is not a directory.
- // - PLATFORM_FILE_ERROR_NOT_EMPTY if |url| is not empty.
+ // - File::FILE_ERROR_NOT_FOUND if |url| does not exist.
+ // - File::FILE_ERROR_NOT_A_DIRECTORY if |url| is not a directory.
+ // - File::FILE_ERROR_NOT_EMPTY if |url| is not empty.
//
virtual void RemoveDirectory(const FileSystemURL& url,
const StatusCallback& callback) = 0;
@@ -413,12 +412,12 @@ class FileSystemOperation {
// optional.
//
// This returns:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_url|
+ // - File::FILE_ERROR_NOT_FOUND if |src_url|
// or the parent directory of |dest_url| does not exist.
- // - PLATFORM_FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
- // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
+ // - File::FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
+ // - File::FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
// is not a file.
- // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and
+ // - File::FILE_ERROR_FAILED if |dest_url| does not exist and
// its parent path is a file.
//
virtual void CopyFileLocal(const FileSystemURL& src_url,
@@ -434,12 +433,12 @@ class FileSystemOperation {
// comment for details.
//
// This returns:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_url|
+ // - File::FILE_ERROR_NOT_FOUND if |src_url|
// or the parent directory of |dest_url| does not exist.
- // - PLATFORM_FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
- // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
+ // - File::FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
+ // - File::FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
// is not a file.
- // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and
+ // - File::FILE_ERROR_FAILED if |dest_url| does not exist and
// its parent path is a file.
//
virtual void MoveFileLocal(const FileSystemURL& src_url,
@@ -450,9 +449,9 @@ class FileSystemOperation {
// Synchronously gets the platform path for the given |url|.
// This may fail if the given |url|'s filesystem type is neither
// temporary nor persistent.
- // In such a case, base::PLATFORM_FILE_ERROR_INVALID_OPERATION will be
+ // In such a case, base::File::FILE_ERROR_INVALID_OPERATION will be
// returned.
- virtual base::PlatformFileError SyncGetPlatformPath(
+ virtual base::File::Error SyncGetPlatformPath(
const FileSystemURL& url,
base::FilePath* platform_path) = 0;
diff --git a/chromium/webkit/browser/fileapi/file_system_operation_impl.cc b/chromium/webkit/browser/fileapi/file_system_operation_impl.cc
index 180e1205b4e..0f6728cbb5b 100644
--- a/chromium/webkit/browser/fileapi/file_system_operation_impl.cc
+++ b/chromium/webkit/browser/fileapi/file_system_operation_impl.cc
@@ -21,7 +21,7 @@
#include "webkit/browser/fileapi/file_writer_delegate.h"
#include "webkit/browser/fileapi/remove_operation_delegate.h"
#include "webkit/browser/fileapi/sandbox_file_system_backend.h"
-#include "webkit/browser/quota/quota_manager.h"
+#include "webkit/browser/quota/quota_manager_proxy.h"
#include "webkit/common/blob/shareable_file_reference.h"
#include "webkit/common/fileapi/file_system_types.h"
#include "webkit/common/fileapi/file_system_util.h"
@@ -50,7 +50,7 @@ void FileSystemOperationImpl::CreateFile(const FileSystemURL& url,
url,
base::Bind(&FileSystemOperationImpl::DoCreateFile,
weak_factory_.GetWeakPtr(), url, callback, exclusive),
- base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED));
+ base::Bind(callback, base::File::FILE_ERROR_FAILED));
}
void FileSystemOperationImpl::CreateDirectory(const FileSystemURL& url,
@@ -63,7 +63,7 @@ void FileSystemOperationImpl::CreateDirectory(const FileSystemURL& url,
base::Bind(&FileSystemOperationImpl::DoCreateDirectory,
weak_factory_.GetWeakPtr(), url, callback,
exclusive, recursive),
- base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED));
+ base::Bind(callback, base::File::FILE_ERROR_FAILED));
}
void FileSystemOperationImpl::Copy(
@@ -182,7 +182,7 @@ void FileSystemOperationImpl::Truncate(const FileSystemURL& url, int64 length,
url,
base::Bind(&FileSystemOperationImpl::DoTruncate,
weak_factory_.GetWeakPtr(), url, callback, length),
- base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED));
+ base::Bind(callback, base::File::FILE_ERROR_FAILED));
}
void FileSystemOperationImpl::TouchFile(const FileSystemURL& url,
@@ -203,9 +203,8 @@ void FileSystemOperationImpl::OpenFile(const FileSystemURL& url,
DCHECK(SetPendingOperationType(kOperationOpenFile));
if (file_flags &
- (base::PLATFORM_FILE_TEMPORARY | base::PLATFORM_FILE_HIDDEN)) {
- callback.Run(base::PLATFORM_FILE_ERROR_FAILED,
- base::kInvalidPlatformFileValue,
+ (base::File::FLAG_TEMPORARY | base::File::FLAG_HIDDEN)) {
+ callback.Run(base::File(base::File::FILE_ERROR_FAILED),
base::Closure());
return;
}
@@ -214,8 +213,7 @@ void FileSystemOperationImpl::OpenFile(const FileSystemURL& url,
base::Bind(&FileSystemOperationImpl::DoOpenFile,
weak_factory_.GetWeakPtr(),
url, callback, file_flags),
- base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED,
- base::kInvalidPlatformFileValue,
+ base::Bind(callback, Passed(base::File(base::File::FILE_ERROR_FAILED)),
base::Closure()));
}
@@ -257,7 +255,7 @@ void FileSystemOperationImpl::CopyInForeignFile(
base::Bind(&FileSystemOperationImpl::DoCopyInForeignFile,
weak_factory_.GetWeakPtr(), src_local_disk_file_path, dest_url,
callback),
- base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED));
+ base::Bind(callback, base::File::FILE_ERROR_FAILED));
}
void FileSystemOperationImpl::RemoveFile(
@@ -294,7 +292,7 @@ void FileSystemOperationImpl::CopyFileLocal(
base::Bind(&FileSystemOperationImpl::DoCopyFileLocal,
weak_factory_.GetWeakPtr(), src_url, dest_url, option,
progress_callback, callback),
- base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED));
+ base::Bind(callback, base::File::FILE_ERROR_FAILED));
}
void FileSystemOperationImpl::MoveFileLocal(
@@ -309,19 +307,19 @@ void FileSystemOperationImpl::MoveFileLocal(
base::Bind(&FileSystemOperationImpl::DoMoveFileLocal,
weak_factory_.GetWeakPtr(),
src_url, dest_url, option, callback),
- base::Bind(callback, base::PLATFORM_FILE_ERROR_FAILED));
+ base::Bind(callback, base::File::FILE_ERROR_FAILED));
}
-base::PlatformFileError FileSystemOperationImpl::SyncGetPlatformPath(
+base::File::Error FileSystemOperationImpl::SyncGetPlatformPath(
const FileSystemURL& url,
base::FilePath* platform_path) {
DCHECK(SetPendingOperationType(kOperationGetLocalPath));
if (!file_system_context()->IsSandboxFileSystem(url.type()))
- return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
+ return base::File::FILE_ERROR_INVALID_OPERATION;
FileSystemFileUtil* file_util =
file_system_context()->sandbox_delegate()->sync_file_util();
file_util->GetLocalFilePath(operation_context_.get(), url, platform_path);
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_OK;
}
FileSystemOperationImpl::FileSystemOperationImpl(
@@ -456,9 +454,9 @@ void FileSystemOperationImpl::DoOpenFile(const FileSystemURL& url,
void FileSystemOperationImpl::DidEnsureFileExistsExclusive(
const StatusCallback& callback,
- base::PlatformFileError rv, bool created) {
- if (rv == base::PLATFORM_FILE_OK && !created) {
- callback.Run(base::PLATFORM_FILE_ERROR_EXISTS);
+ base::File::Error rv, bool created) {
+ if (rv == base::File::FILE_OK && !created) {
+ callback.Run(base::File::FILE_ERROR_EXISTS);
} else {
DidFinishOperation(callback, rv);
}
@@ -466,21 +464,21 @@ void FileSystemOperationImpl::DidEnsureFileExistsExclusive(
void FileSystemOperationImpl::DidEnsureFileExistsNonExclusive(
const StatusCallback& callback,
- base::PlatformFileError rv, bool /* created */) {
+ base::File::Error rv, bool /* created */) {
DidFinishOperation(callback, rv);
}
void FileSystemOperationImpl::DidFinishOperation(
const StatusCallback& callback,
- base::PlatformFileError rv) {
+ base::File::Error rv) {
if (!cancel_callback_.is_null()) {
StatusCallback cancel_callback = cancel_callback_;
callback.Run(rv);
// Return OK only if we succeeded to stop the operation.
- cancel_callback.Run(rv == base::PLATFORM_FILE_ERROR_ABORT ?
- base::PLATFORM_FILE_OK :
- base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
+ cancel_callback.Run(rv == base::File::FILE_ERROR_ABORT ?
+ base::File::FILE_OK :
+ base::File::FILE_ERROR_INVALID_OPERATION);
} else {
callback.Run(rv);
}
@@ -488,27 +486,27 @@ void FileSystemOperationImpl::DidFinishOperation(
void FileSystemOperationImpl::DidDirectoryExists(
const StatusCallback& callback,
- base::PlatformFileError rv,
- const base::PlatformFileInfo& file_info) {
- if (rv == base::PLATFORM_FILE_OK && !file_info.is_directory)
- rv = base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY;
+ base::File::Error rv,
+ const base::File::Info& file_info) {
+ if (rv == base::File::FILE_OK && !file_info.is_directory)
+ rv = base::File::FILE_ERROR_NOT_A_DIRECTORY;
callback.Run(rv);
}
void FileSystemOperationImpl::DidFileExists(
const StatusCallback& callback,
- base::PlatformFileError rv,
- const base::PlatformFileInfo& file_info) {
- if (rv == base::PLATFORM_FILE_OK && file_info.is_directory)
- rv = base::PLATFORM_FILE_ERROR_NOT_A_FILE;
+ base::File::Error rv,
+ const base::File::Info& file_info) {
+ if (rv == base::File::FILE_OK && file_info.is_directory)
+ rv = base::File::FILE_ERROR_NOT_A_FILE;
callback.Run(rv);
}
void FileSystemOperationImpl::DidDeleteRecursively(
const FileSystemURL& url,
const StatusCallback& callback,
- base::PlatformFileError rv) {
- if (rv == base::PLATFORM_FILE_ERROR_INVALID_OPERATION) {
+ base::File::Error rv) {
+ if (rv == base::File::FILE_ERROR_INVALID_OPERATION) {
// Recursive removal is not supported on this platform.
DCHECK(!recursive_operation_delegate_);
recursive_operation_delegate_.reset(
@@ -526,7 +524,7 @@ void FileSystemOperationImpl::DidDeleteRecursively(
void FileSystemOperationImpl::DidWrite(
const FileSystemURL& url,
const WriteCallback& write_callback,
- base::PlatformFileError rv,
+ base::File::Error rv,
int64 bytes,
FileWriterDelegate::WriteProgressStatus write_status) {
const bool complete = (
@@ -540,15 +538,14 @@ void FileSystemOperationImpl::DidWrite(
StatusCallback cancel_callback = cancel_callback_;
write_callback.Run(rv, bytes, complete);
if (!cancel_callback.is_null())
- cancel_callback.Run(base::PLATFORM_FILE_OK);
+ cancel_callback.Run(base::File::FILE_OK);
}
void FileSystemOperationImpl::DidOpenFile(
const OpenFileCallback& callback,
- base::PlatformFileError rv,
- base::PassPlatformFile file,
+ base::File file,
const base::Closure& on_close_callback) {
- callback.Run(rv, file.ReleaseValue(), on_close_callback);
+ callback.Run(file.Pass(), on_close_callback);
}
bool FileSystemOperationImpl::SetPendingOperationType(OperationType type) {
diff --git a/chromium/webkit/browser/fileapi/file_system_operation_impl.h b/chromium/webkit/browser/fileapi/file_system_operation_impl.h
index 06259950ce2..5d93cb3b8b2 100644
--- a/chromium/webkit/browser/fileapi/file_system_operation_impl.h
+++ b/chromium/webkit/browser/fileapi/file_system_operation_impl.h
@@ -90,7 +90,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemOperationImpl
const FileSystemURL& dest_url,
CopyOrMoveOption option,
const StatusCallback& callback) OVERRIDE;
- virtual base::PlatformFileError SyncGetPlatformPath(
+ virtual base::File::Error SyncGetPlatformPath(
const FileSystemURL& url,
base::FilePath* platform_path) OVERRIDE;
@@ -151,33 +151,32 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemOperationImpl
// Callback for CreateFile for |exclusive|=true cases.
void DidEnsureFileExistsExclusive(const StatusCallback& callback,
- base::PlatformFileError rv,
+ base::File::Error rv,
bool created);
// Callback for CreateFile for |exclusive|=false cases.
void DidEnsureFileExistsNonExclusive(const StatusCallback& callback,
- base::PlatformFileError rv,
+ base::File::Error rv,
bool created);
void DidFinishOperation(const StatusCallback& callback,
- base::PlatformFileError rv);
+ base::File::Error rv);
void DidDirectoryExists(const StatusCallback& callback,
- base::PlatformFileError rv,
- const base::PlatformFileInfo& file_info);
+ base::File::Error rv,
+ const base::File::Info& file_info);
void DidFileExists(const StatusCallback& callback,
- base::PlatformFileError rv,
- const base::PlatformFileInfo& file_info);
+ base::File::Error rv,
+ const base::File::Info& file_info);
void DidDeleteRecursively(const FileSystemURL& url,
const StatusCallback& callback,
- base::PlatformFileError rv);
+ base::File::Error rv);
void DidWrite(const FileSystemURL& url,
const WriteCallback& callback,
- base::PlatformFileError rv,
+ base::File::Error rv,
int64 bytes,
FileWriterDelegate::WriteProgressStatus write_status);
void DidOpenFile(const OpenFileCallback& callback,
- base::PlatformFileError rv,
- base::PassPlatformFile file,
+ base::File file,
const base::Closure& on_close_callback);
// Used only for internal assertions.
diff --git a/chromium/webkit/browser/fileapi/file_system_operation_runner.cc b/chromium/webkit/browser/fileapi/file_system_operation_runner.cc
index d552a783193..1d588a77dbd 100644
--- a/chromium/webkit/browser/fileapi/file_system_operation_runner.cc
+++ b/chromium/webkit/browser/fileapi/file_system_operation_runner.cc
@@ -43,7 +43,7 @@ OperationID FileSystemOperationRunner::CreateFile(
const FileSystemURL& url,
bool exclusive,
const StatusCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(url, &error);
@@ -66,7 +66,7 @@ OperationID FileSystemOperationRunner::CreateDirectory(
bool exclusive,
bool recursive,
const StatusCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(url, &error);
BeginOperationScoper scope;
@@ -89,7 +89,7 @@ OperationID FileSystemOperationRunner::Copy(
CopyOrMoveOption option,
const CopyProgressCallback& progress_callback,
const StatusCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(dest_url, &error);
BeginOperationScoper scope;
@@ -116,7 +116,7 @@ OperationID FileSystemOperationRunner::Move(
const FileSystemURL& dest_url,
CopyOrMoveOption option,
const StatusCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(dest_url, &error);
BeginOperationScoper scope;
@@ -137,7 +137,7 @@ OperationID FileSystemOperationRunner::Move(
OperationID FileSystemOperationRunner::DirectoryExists(
const FileSystemURL& url,
const StatusCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(url, &error);
BeginOperationScoper scope;
@@ -157,7 +157,7 @@ OperationID FileSystemOperationRunner::DirectoryExists(
OperationID FileSystemOperationRunner::FileExists(
const FileSystemURL& url,
const StatusCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(url, &error);
BeginOperationScoper scope;
@@ -177,13 +177,13 @@ OperationID FileSystemOperationRunner::FileExists(
OperationID FileSystemOperationRunner::GetMetadata(
const FileSystemURL& url,
const GetMetadataCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(url, &error);
BeginOperationScoper scope;
OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr());
if (!operation) {
- DidGetMetadata(handle, callback, error, base::PlatformFileInfo());
+ DidGetMetadata(handle, callback, error, base::File::Info());
return handle.id;
}
PrepareForRead(handle.id, url);
@@ -197,7 +197,7 @@ OperationID FileSystemOperationRunner::GetMetadata(
OperationID FileSystemOperationRunner::ReadDirectory(
const FileSystemURL& url,
const ReadDirectoryCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(url, &error);
BeginOperationScoper scope;
@@ -218,7 +218,7 @@ OperationID FileSystemOperationRunner::ReadDirectory(
OperationID FileSystemOperationRunner::Remove(
const FileSystemURL& url, bool recursive,
const StatusCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(url, &error);
BeginOperationScoper scope;
@@ -241,7 +241,7 @@ OperationID FileSystemOperationRunner::Write(
scoped_ptr<webkit_blob::BlobDataHandle> blob,
int64 offset,
const WriteCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(url, &error);
@@ -256,12 +256,16 @@ OperationID FileSystemOperationRunner::Write(
file_system_context_->CreateFileStreamWriter(url, offset));
if (!writer) {
// Write is not supported.
- DidWrite(handle, callback, base::PLATFORM_FILE_ERROR_SECURITY, 0, true);
+ DidWrite(handle, callback, base::File::FILE_ERROR_SECURITY, 0, true);
return handle.id;
}
+ FileWriterDelegate::FlushPolicy flush_policy =
+ file_system_context_->ShouldFlushOnWriteCompletion(url.type())
+ ? FileWriterDelegate::FLUSH_ON_COMPLETION
+ : FileWriterDelegate::NO_FLUSH_ON_COMPLETION;
scoped_ptr<FileWriterDelegate> writer_delegate(
- new FileWriterDelegate(writer.Pass()));
+ new FileWriterDelegate(writer.Pass(), flush_policy));
scoped_ptr<net::URLRequest> blob_request(
webkit_blob::BlobProtocolHandler::CreateBlobRequest(
@@ -280,7 +284,7 @@ OperationID FileSystemOperationRunner::Write(
OperationID FileSystemOperationRunner::Truncate(
const FileSystemURL& url, int64 length,
const StatusCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(url, &error);
BeginOperationScoper scope;
@@ -308,7 +312,7 @@ void FileSystemOperationRunner::Cancel(
FileSystemOperation* operation = operations_.Lookup(id);
if (!operation) {
// There is no operation with |id|.
- callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
+ callback.Run(base::File::FILE_ERROR_INVALID_OPERATION);
return;
}
operation->Cancel(callback);
@@ -319,7 +323,7 @@ OperationID FileSystemOperationRunner::TouchFile(
const base::Time& last_access_time,
const base::Time& last_modified_time,
const StatusCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(url, &error);
BeginOperationScoper scope;
@@ -340,22 +344,21 @@ OperationID FileSystemOperationRunner::OpenFile(
const FileSystemURL& url,
int file_flags,
const OpenFileCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(url, &error);
BeginOperationScoper scope;
OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr());
if (!operation) {
- DidOpenFile(handle, callback, error, base::kInvalidPlatformFileValue,
- base::Closure());
+ DidOpenFile(handle, callback, base::File(error), base::Closure());
return handle.id;
}
if (file_flags &
- (base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_OPEN_ALWAYS |
- base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_OPEN_TRUNCATED |
- base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_WRITE |
- base::PLATFORM_FILE_DELETE_ON_CLOSE |
- base::PLATFORM_FILE_WRITE_ATTRIBUTES)) {
+ (base::File::FLAG_CREATE | base::File::FLAG_OPEN_ALWAYS |
+ base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_OPEN_TRUNCATED |
+ base::File::FLAG_WRITE | base::File::FLAG_EXCLUSIVE_WRITE |
+ base::File::FLAG_DELETE_ON_CLOSE |
+ base::File::FLAG_WRITE_ATTRIBUTES)) {
PrepareForWrite(handle.id, url);
} else {
PrepareForRead(handle.id, url);
@@ -370,13 +373,13 @@ OperationID FileSystemOperationRunner::OpenFile(
OperationID FileSystemOperationRunner::CreateSnapshotFile(
const FileSystemURL& url,
const SnapshotFileCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(url, &error);
BeginOperationScoper scope;
OperationHandle handle = BeginOperation(operation, scope.AsWeakPtr());
if (!operation) {
- DidCreateSnapshot(handle, callback, error, base::PlatformFileInfo(),
+ DidCreateSnapshot(handle, callback, error, base::File::Info(),
base::FilePath(), NULL);
return handle.id;
}
@@ -392,7 +395,7 @@ OperationID FileSystemOperationRunner::CopyInForeignFile(
const base::FilePath& src_local_disk_path,
const FileSystemURL& dest_url,
const StatusCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(dest_url, &error);
BeginOperationScoper scope;
@@ -411,7 +414,7 @@ OperationID FileSystemOperationRunner::CopyInForeignFile(
OperationID FileSystemOperationRunner::RemoveFile(
const FileSystemURL& url,
const StatusCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(url, &error);
BeginOperationScoper scope;
@@ -430,7 +433,7 @@ OperationID FileSystemOperationRunner::RemoveFile(
OperationID FileSystemOperationRunner::RemoveDirectory(
const FileSystemURL& url,
const StatusCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(url, &error);
BeginOperationScoper scope;
@@ -452,7 +455,7 @@ OperationID FileSystemOperationRunner::CopyFileLocal(
CopyOrMoveOption option,
const CopyFileProgressCallback& progress_callback,
const StatusCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(src_url, &error);
BeginOperationScoper scope;
@@ -473,7 +476,7 @@ OperationID FileSystemOperationRunner::MoveFileLocal(
const FileSystemURL& dest_url,
CopyOrMoveOption option,
const StatusCallback& callback) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
FileSystemOperation* operation =
file_system_context_->CreateFileSystemOperation(src_url, &error);
BeginOperationScoper scope;
@@ -489,10 +492,10 @@ OperationID FileSystemOperationRunner::MoveFileLocal(
return handle.id;
}
-base::PlatformFileError FileSystemOperationRunner::SyncGetPlatformPath(
+base::File::Error FileSystemOperationRunner::SyncGetPlatformPath(
const FileSystemURL& url,
base::FilePath* platform_path) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
scoped_ptr<FileSystemOperation> operation(
file_system_context_->CreateFileSystemOperation(url, &error));
if (!operation.get())
@@ -507,7 +510,7 @@ FileSystemOperationRunner::FileSystemOperationRunner(
void FileSystemOperationRunner::DidFinish(
const OperationHandle& handle,
const StatusCallback& callback,
- base::PlatformFileError rv) {
+ base::File::Error rv) {
if (handle.scope) {
finished_operations_.insert(handle.id);
base::MessageLoopProxy::current()->PostTask(
@@ -522,8 +525,8 @@ void FileSystemOperationRunner::DidFinish(
void FileSystemOperationRunner::DidGetMetadata(
const OperationHandle& handle,
const GetMetadataCallback& callback,
- base::PlatformFileError rv,
- const base::PlatformFileInfo& file_info) {
+ base::File::Error rv,
+ const base::File::Info& file_info) {
if (handle.scope) {
finished_operations_.insert(handle.id);
base::MessageLoopProxy::current()->PostTask(
@@ -538,7 +541,7 @@ void FileSystemOperationRunner::DidGetMetadata(
void FileSystemOperationRunner::DidReadDirectory(
const OperationHandle& handle,
const ReadDirectoryCallback& callback,
- base::PlatformFileError rv,
+ base::File::Error rv,
const std::vector<DirectoryEntry>& entries,
bool has_more) {
if (handle.scope) {
@@ -550,14 +553,14 @@ void FileSystemOperationRunner::DidReadDirectory(
return;
}
callback.Run(rv, entries, has_more);
- if (rv != base::PLATFORM_FILE_OK || !has_more)
+ if (rv != base::File::FILE_OK || !has_more)
FinishOperation(handle.id);
}
void FileSystemOperationRunner::DidWrite(
const OperationHandle& handle,
const WriteCallback& callback,
- base::PlatformFileError rv,
+ base::File::Error rv,
int64 bytes,
bool complete) {
if (handle.scope) {
@@ -568,33 +571,32 @@ void FileSystemOperationRunner::DidWrite(
return;
}
callback.Run(rv, bytes, complete);
- if (rv != base::PLATFORM_FILE_OK || complete)
+ if (rv != base::File::FILE_OK || complete)
FinishOperation(handle.id);
}
void FileSystemOperationRunner::DidOpenFile(
const OperationHandle& handle,
const OpenFileCallback& callback,
- base::PlatformFileError rv,
- base::PlatformFile file,
+ base::File file,
const base::Closure& on_close_callback) {
if (handle.scope) {
finished_operations_.insert(handle.id);
base::MessageLoopProxy::current()->PostTask(
FROM_HERE, base::Bind(&FileSystemOperationRunner::DidOpenFile,
- AsWeakPtr(), handle, callback, rv, file,
+ AsWeakPtr(), handle, callback, Passed(&file),
on_close_callback));
return;
}
- callback.Run(rv, file, on_close_callback);
+ callback.Run(file.Pass(), on_close_callback);
FinishOperation(handle.id);
}
void FileSystemOperationRunner::DidCreateSnapshot(
const OperationHandle& handle,
const SnapshotFileCallback& callback,
- base::PlatformFileError rv,
- const base::PlatformFileInfo& file_info,
+ base::File::Error rv,
+ const base::File::Info& file_info,
const base::FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
if (handle.scope) {
@@ -679,7 +681,7 @@ void FileSystemOperationRunner::FinishOperation(OperationID id) {
if (found_cancel != stray_cancel_callbacks_.end()) {
// This cancel has been requested after the operation has finished,
// so report that we failed to stop it.
- found_cancel->second.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
+ found_cancel->second.Run(base::File::FILE_ERROR_INVALID_OPERATION);
stray_cancel_callbacks_.erase(found_cancel);
}
}
diff --git a/chromium/webkit/browser/fileapi/file_system_operation_runner.h b/chromium/webkit/browser/fileapi/file_system_operation_runner.h
index fba6b1cab96..e943f287454 100644
--- a/chromium/webkit/browser/fileapi/file_system_operation_runner.h
+++ b/chromium/webkit/browser/fileapi/file_system_operation_runner.h
@@ -161,11 +161,11 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemOperationRunner
// Copies in a single file from a different filesystem.
//
// This returns:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_file_path|
+ // - File::FILE_ERROR_NOT_FOUND if |src_file_path|
// or the parent directory of |dest_url| does not exist.
- // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
+ // - File::FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
// is not a file.
- // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and
+ // - File::FILE_ERROR_FAILED if |dest_url| does not exist and
// its parent path is a file.
//
OperationID CopyInForeignFile(const base::FilePath& src_local_disk_path,
@@ -175,8 +175,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemOperationRunner
// Removes a single file.
//
// This returns:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist.
- // - PLATFORM_FILE_ERROR_NOT_A_FILE if |url| is not a file.
+ // - File::FILE_ERROR_NOT_FOUND if |url| does not exist.
+ // - File::FILE_ERROR_NOT_A_FILE if |url| is not a file.
//
OperationID RemoveFile(const FileSystemURL& url,
const StatusCallback& callback);
@@ -184,9 +184,9 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemOperationRunner
// Removes a single empty directory.
//
// This returns:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |url| does not exist.
- // - PLATFORM_FILE_ERROR_NOT_A_DIRECTORY if |url| is not a directory.
- // - PLATFORM_FILE_ERROR_NOT_EMPTY if |url| is not empty.
+ // - File::FILE_ERROR_NOT_FOUND if |url| does not exist.
+ // - File::FILE_ERROR_NOT_A_DIRECTORY if |url| is not a directory.
+ // - File::FILE_ERROR_NOT_EMPTY if |url| is not empty.
//
OperationID RemoveDirectory(const FileSystemURL& url,
const StatusCallback& callback);
@@ -198,12 +198,12 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemOperationRunner
// details.
//
// This returns:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_url|
+ // - File::FILE_ERROR_NOT_FOUND if |src_url|
// or the parent directory of |dest_url| does not exist.
- // - PLATFORM_FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
- // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
+ // - File::FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
+ // - File::FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
// is not a file.
- // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and
+ // - File::FILE_ERROR_FAILED if |dest_url| does not exist and
// its parent path is a file.
//
OperationID CopyFileLocal(const FileSystemURL& src_url,
@@ -218,12 +218,12 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemOperationRunner
// For |option|, see file_system_operation.h for details.
//
// This returns:
- // - PLATFORM_FILE_ERROR_NOT_FOUND if |src_url|
+ // - File::FILE_ERROR_NOT_FOUND if |src_url|
// or the parent directory of |dest_url| does not exist.
- // - PLATFORM_FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
- // - PLATFORM_FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
+ // - File::FILE_ERROR_NOT_A_FILE if |src_url| exists but is not a file.
+ // - File::FILE_ERROR_INVALID_OPERATION if |dest_url| exists and
// is not a file.
- // - PLATFORM_FILE_ERROR_FAILED if |dest_url| does not exist and
+ // - File::FILE_ERROR_FAILED if |dest_url| does not exist and
// its parent path is a file.
//
OperationID MoveFileLocal(const FileSystemURL& src_url,
@@ -234,8 +234,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemOperationRunner
// This is called only by pepper plugin as of writing to synchronously get
// the underlying platform path to upload a file in the sandboxed filesystem
// (e.g. TEMPORARY or PERSISTENT).
- base::PlatformFileError SyncGetPlatformPath(const FileSystemURL& url,
- base::FilePath* platform_path);
+ base::File::Error SyncGetPlatformPath(const FileSystemURL& url,
+ base::FilePath* platform_path);
private:
class BeginOperationScoper;
@@ -253,32 +253,31 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemOperationRunner
void DidFinish(const OperationHandle& handle,
const StatusCallback& callback,
- base::PlatformFileError rv);
+ base::File::Error rv);
void DidGetMetadata(const OperationHandle& handle,
const GetMetadataCallback& callback,
- base::PlatformFileError rv,
- const base::PlatformFileInfo& file_info);
+ base::File::Error rv,
+ const base::File::Info& file_info);
void DidReadDirectory(const OperationHandle& handle,
const ReadDirectoryCallback& callback,
- base::PlatformFileError rv,
+ base::File::Error rv,
const std::vector<DirectoryEntry>& entries,
bool has_more);
void DidWrite(const OperationHandle& handle,
const WriteCallback& callback,
- base::PlatformFileError rv,
+ base::File::Error rv,
int64 bytes,
bool complete);
void DidOpenFile(
const OperationHandle& handle,
const OpenFileCallback& callback,
- base::PlatformFileError rv,
- base::PlatformFile file,
+ base::File file,
const base::Closure& on_close_callback);
void DidCreateSnapshot(
const OperationHandle& handle,
const SnapshotFileCallback& callback,
- base::PlatformFileError rv,
- const base::PlatformFileInfo& file_info,
+ base::File::Error rv,
+ const base::File::Info& file_info,
const base::FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref);
diff --git a/chromium/webkit/browser/fileapi/file_system_options.cc b/chromium/webkit/browser/fileapi/file_system_options.cc
index 4100b5d1e0e..bef2f52371a 100644
--- a/chromium/webkit/browser/fileapi/file_system_options.cc
+++ b/chromium/webkit/browser/fileapi/file_system_options.cc
@@ -8,9 +8,11 @@ namespace fileapi {
FileSystemOptions::FileSystemOptions(
ProfileMode profile_mode,
- const std::vector<std::string>& additional_allowed_schemes)
+ const std::vector<std::string>& additional_allowed_schemes,
+ leveldb::Env* env_override)
: profile_mode_(profile_mode),
- additional_allowed_schemes_(additional_allowed_schemes) {
+ additional_allowed_schemes_(additional_allowed_schemes),
+ env_override_(env_override) {
}
FileSystemOptions::~FileSystemOptions() {
diff --git a/chromium/webkit/browser/fileapi/file_system_options.h b/chromium/webkit/browser/fileapi/file_system_options.h
index b6e78efce61..25133dac21c 100644
--- a/chromium/webkit/browser/fileapi/file_system_options.h
+++ b/chromium/webkit/browser/fileapi/file_system_options.h
@@ -10,6 +10,10 @@
#include "webkit/browser/webkit_storage_browser_export.h"
+namespace leveldb {
+class Env;
+}
+
namespace fileapi {
// Provides runtime options that may change FileSystem API behavior.
@@ -26,9 +30,11 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemOptions {
// (PROFILE_MODE_NORMAL).
// |additional_allowed_schemes| specifies schemes that are allowed
// to access FileSystem API in addition to "http" and "https".
+ // Non-NULL |env_override| overrides internal LevelDB environment.
FileSystemOptions(
ProfileMode profile_mode,
- const std::vector<std::string>& additional_allowed_schemes);
+ const std::vector<std::string>& additional_allowed_schemes,
+ leveldb::Env* env_override);
~FileSystemOptions();
@@ -43,9 +49,12 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemOptions {
return additional_allowed_schemes_;
}
+ leveldb::Env* env_override() const { return env_override_; }
+
private:
const ProfileMode profile_mode_;
const std::vector<std::string> additional_allowed_schemes_;
+ leveldb::Env* env_override_;
};
} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/file_system_quota_client.cc b/chromium/webkit/browser/fileapi/file_system_quota_client.cc
index 76725df31a8..3dce21886a5 100644
--- a/chromium/webkit/browser/fileapi/file_system_quota_client.cc
+++ b/chromium/webkit/browser/fileapi/file_system_quota_client.cc
@@ -30,7 +30,7 @@ namespace fileapi {
namespace {
-void GetOriginsForTypeOnFileThread(
+void GetOriginsForTypeOnFileTaskRunner(
FileSystemContext* context,
StorageType storage_type,
std::set<GURL>* origins_ptr) {
@@ -40,10 +40,10 @@ void GetOriginsForTypeOnFileThread(
FileSystemQuotaUtil* quota_util = context->GetQuotaUtil(type);
if (!quota_util)
return;
- quota_util->GetOriginsForTypeOnFileThread(type, origins_ptr);
+ quota_util->GetOriginsForTypeOnFileTaskRunner(type, origins_ptr);
}
-void GetOriginsForHostOnFileThread(
+void GetOriginsForHostOnFileTaskRunner(
FileSystemContext* context,
StorageType storage_type,
const std::string& host,
@@ -54,7 +54,7 @@ void GetOriginsForHostOnFileThread(
FileSystemQuotaUtil* quota_util = context->GetQuotaUtil(type);
if (!quota_util)
return;
- quota_util->GetOriginsForHostOnFileThread(type, host, origins_ptr);
+ quota_util->GetOriginsForHostOnFileTaskRunner(type, host, origins_ptr);
}
void DidGetOrigins(
@@ -63,17 +63,17 @@ void DidGetOrigins(
callback.Run(*origins_ptr);
}
-quota::QuotaStatusCode DeleteOriginOnFileThread(
+quota::QuotaStatusCode DeleteOriginOnFileTaskRunner(
FileSystemContext* context,
const GURL& origin,
FileSystemType type) {
FileSystemBackend* provider = context->GetFileSystemBackend(type);
if (!provider || !provider->GetQuotaUtil())
return quota::kQuotaErrorNotSupported;
- base::PlatformFileError result =
- provider->GetQuotaUtil()->DeleteOriginDataOnFileThread(
+ base::File::Error result =
+ provider->GetQuotaUtil()->DeleteOriginDataOnFileTaskRunner(
context, context->quota_manager_proxy(), origin, type);
- if (result == base::PLATFORM_FILE_OK)
+ if (result == base::File::FILE_OK)
return quota::kQuotaStatusOk;
return quota::kQuotaErrorInvalidModification;
}
@@ -122,7 +122,7 @@ void FileSystemQuotaClient::GetOriginUsage(
file_task_runner(),
FROM_HERE,
// It is safe to pass Unretained(quota_util) since context owns it.
- base::Bind(&FileSystemQuotaUtil::GetOriginUsageOnFileThread,
+ base::Bind(&FileSystemQuotaUtil::GetOriginUsageOnFileTaskRunner,
base::Unretained(quota_util),
file_system_context_,
origin_url,
@@ -145,7 +145,7 @@ void FileSystemQuotaClient::GetOriginsForType(
std::set<GURL>* origins_ptr = new std::set<GURL>();
file_task_runner()->PostTaskAndReply(
FROM_HERE,
- base::Bind(&GetOriginsForTypeOnFileThread,
+ base::Bind(&GetOriginsForTypeOnFileTaskRunner,
file_system_context_,
storage_type,
base::Unretained(origins_ptr)),
@@ -170,7 +170,7 @@ void FileSystemQuotaClient::GetOriginsForHost(
std::set<GURL>* origins_ptr = new std::set<GURL>();
file_task_runner()->PostTaskAndReply(
FROM_HERE,
- base::Bind(&GetOriginsForHostOnFileThread,
+ base::Bind(&GetOriginsForHostOnFileTaskRunner,
file_system_context_,
storage_type,
host,
@@ -190,7 +190,7 @@ void FileSystemQuotaClient::DeleteOriginData(
base::PostTaskAndReplyWithResult(
file_task_runner(),
FROM_HERE,
- base::Bind(&DeleteOriginOnFileThread,
+ base::Bind(&DeleteOriginOnFileTaskRunner,
file_system_context_,
origin,
fs_type),
diff --git a/chromium/webkit/browser/fileapi/file_system_quota_util.h b/chromium/webkit/browser/fileapi/file_system_quota_util.h
index e3930862f87..7e6badf0694 100644
--- a/chromium/webkit/browser/fileapi/file_system_quota_util.h
+++ b/chromium/webkit/browser/fileapi/file_system_quota_util.h
@@ -9,7 +9,7 @@
#include <string>
#include "base/basictypes.h"
-#include "base/platform_file.h"
+#include "base/files/file.h"
#include "url/gurl.h"
#include "webkit/browser/fileapi/task_runner_bound_observer_list.h"
#include "webkit/browser/webkit_storage_browser_export.h"
@@ -38,21 +38,23 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemQuotaUtil {
// Deletes the data on the origin and reports the amount of deleted data
// to the quota manager via |proxy|.
- virtual base::PlatformFileError DeleteOriginDataOnFileThread(
+ virtual base::File::Error DeleteOriginDataOnFileTaskRunner(
FileSystemContext* context,
quota::QuotaManagerProxy* proxy,
const GURL& origin_url,
FileSystemType type) = 0;
- virtual void GetOriginsForTypeOnFileThread(fileapi::FileSystemType type,
- std::set<GURL>* origins) = 0;
+ virtual void GetOriginsForTypeOnFileTaskRunner(
+ fileapi::FileSystemType type,
+ std::set<GURL>* origins) = 0;
- virtual void GetOriginsForHostOnFileThread(fileapi::FileSystemType type,
- const std::string& host,
- std::set<GURL>* origins) = 0;
+ virtual void GetOriginsForHostOnFileTaskRunner(
+ fileapi::FileSystemType type,
+ const std::string& host,
+ std::set<GURL>* origins) = 0;
// Returns the amount of data used for the origin for usage tracking.
- virtual int64 GetOriginUsageOnFileThread(
+ virtual int64 GetOriginUsageOnFileTaskRunner(
fileapi::FileSystemContext* file_system_context,
const GURL& origin_url,
fileapi::FileSystemType type) = 0;
diff --git a/chromium/webkit/browser/fileapi/file_system_url.cc b/chromium/webkit/browser/fileapi/file_system_url.cc
index b045ed3f5d3..7e879b3dbba 100644
--- a/chromium/webkit/browser/fileapi/file_system_url.cc
+++ b/chromium/webkit/browser/fileapi/file_system_url.cc
@@ -36,67 +36,6 @@ FileSystemURL FileSystemURL::CreateForTest(const GURL& origin,
return FileSystemURL(origin, mount_type, virtual_path);
}
-// static
-bool FileSystemURL::ParseFileSystemSchemeURL(
- const GURL& url,
- GURL* origin_url,
- FileSystemType* mount_type,
- base::FilePath* virtual_path) {
- GURL origin;
- FileSystemType file_system_type = kFileSystemTypeUnknown;
-
- if (!url.is_valid() || !url.SchemeIsFileSystem())
- return false;
-
- const struct {
- FileSystemType type;
- const char* dir;
- } kValidTypes[] = {
- { kFileSystemTypePersistent, kPersistentDir },
- { kFileSystemTypeTemporary, kTemporaryDir },
- { kFileSystemTypeIsolated, kIsolatedDir },
- { kFileSystemTypeExternal, kExternalDir },
- { kFileSystemTypeTest, kTestDir },
- };
-
- // A path of the inner_url contains only mount type part (e.g. "/temporary").
- DCHECK(url.inner_url());
- std::string inner_path = url.inner_url()->path();
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kValidTypes); ++i) {
- if (inner_path == kValidTypes[i].dir) {
- file_system_type = kValidTypes[i].type;
- break;
- }
- }
-
- if (file_system_type == kFileSystemTypeUnknown)
- return false;
-
- std::string path = net::UnescapeURLComponent(url.path(),
- net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS |
- net::UnescapeRule::CONTROL_CHARS);
-
- // Ensure the path is relative.
- while (!path.empty() && path[0] == '/')
- path.erase(0, 1);
-
- base::FilePath converted_path = base::FilePath::FromUTF8Unsafe(path);
-
- // All parent references should have been resolved in the renderer.
- if (converted_path.ReferencesParent())
- return false;
-
- if (origin_url)
- *origin_url = url.GetOrigin();
- if (mount_type)
- *mount_type = file_system_type;
- if (virtual_path)
- *virtual_path = converted_path.NormalizePathSeparators().
- StripTrailingSeparators();
-
- return true;
-}
-
FileSystemURL::FileSystemURL(const GURL& url)
: mount_type_(kFileSystemTypeUnknown),
type_(kFileSystemTypeUnknown),
@@ -148,7 +87,14 @@ GURL FileSystemURL::ToGURL() const {
if (url.empty())
return GURL();
- url.append(virtual_path_.AsUTF8Unsafe());
+ // Exactly match with DOMFileSystemBase::createFileSystemURL()'s encoding
+ // behavior, where the path is escaped by KURL::encodeWithURLEscapeSequences
+ // which is essentially encodeURIComponent except '/'.
+ std::string escaped = net::EscapeQueryParamValue(
+ virtual_path_.NormalizePathSeparatorsTo('/').AsUTF8Unsafe(),
+ false /* use_plus */);
+ ReplaceSubstringsAfterOffset(&escaped, 0, "%2F", "/");
+ url.append(escaped);
// Build nested GURL.
return GURL(url);
diff --git a/chromium/webkit/browser/fileapi/file_system_url.h b/chromium/webkit/browser/fileapi/file_system_url.h
index c00231d80d3..ead076254b1 100644
--- a/chromium/webkit/browser/fileapi/file_system_url.h
+++ b/chromium/webkit/browser/fileapi/file_system_url.h
@@ -8,7 +8,7 @@
#include <set>
#include <string>
-#include "base/platform_file.h"
+#include "base/files/file_path.h"
#include "url/gurl.h"
#include "webkit/browser/webkit_storage_browser_export.h"
#include "webkit/common/fileapi/file_system_mount_option.h"
@@ -87,12 +87,6 @@ class WEBKIT_STORAGE_BROWSER_EXPORT FileSystemURL {
FileSystemType mount_type,
const base::FilePath& virtual_path);
- // Parses filesystem scheme |url| into uncracked FileSystemURL components.
- static bool ParseFileSystemSchemeURL(const GURL& url,
- GURL* origin,
- FileSystemType* mount_type,
- base::FilePath* virtual_path);
-
// Returns true if this instance represents a valid FileSystem URL.
bool is_valid() const { return is_valid_; }
diff --git a/chromium/webkit/browser/fileapi/file_system_url_request_job.cc b/chromium/webkit/browser/fileapi/file_system_url_request_job.cc
index 57db3006557..d8f610d5744 100644
--- a/chromium/webkit/browser/fileapi/file_system_url_request_job.cc
+++ b/chromium/webkit/browser/fileapi/file_system_url_request_job.cc
@@ -12,7 +12,6 @@
#include "base/files/file_util_proxy.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_proxy.h"
-#include "base/platform_file.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "build/build_config.h"
@@ -57,8 +56,10 @@ static net::HttpResponseHeaders* CreateHttpResponseHeaders() {
FileSystemURLRequestJob::FileSystemURLRequestJob(
URLRequest* request,
NetworkDelegate* network_delegate,
+ const std::string& storage_domain,
FileSystemContext* file_system_context)
: URLRequestJob(request, network_delegate),
+ storage_domain_(storage_domain),
file_system_context_(file_system_context),
is_directory_(false),
remaining_bytes_(0),
@@ -157,6 +158,14 @@ void FileSystemURLRequestJob::StartAsync() {
return;
DCHECK(!reader_.get());
url_ = file_system_context_->CrackURL(request_->url());
+ if (!url_.is_valid()) {
+ file_system_context_->AttemptAutoMountForURLRequest(
+ request_,
+ storage_domain_,
+ base::Bind(&FileSystemURLRequestJob::DidAttemptAutoMount,
+ weak_factory_.GetWeakPtr()));
+ return;
+ }
if (!file_system_context_->CanServeURLRequest(url_)) {
// In incognito mode the API is not usable and there should be no data.
NotifyFailed(net::ERR_FILE_NOT_FOUND);
@@ -168,11 +177,20 @@ void FileSystemURLRequestJob::StartAsync() {
weak_factory_.GetWeakPtr()));
}
+void FileSystemURLRequestJob::DidAttemptAutoMount(base::File::Error result) {
+ if (result >= 0 &&
+ file_system_context_->CrackURL(request_->url()).is_valid()) {
+ StartAsync();
+ } else {
+ NotifyFailed(net::ERR_FILE_NOT_FOUND);
+ }
+}
+
void FileSystemURLRequestJob::DidGetMetadata(
- base::PlatformFileError error_code,
- const base::PlatformFileInfo& file_info) {
- if (error_code != base::PLATFORM_FILE_OK) {
- NotifyFailed(error_code == base::PLATFORM_FILE_ERROR_INVALID_URL ?
+ base::File::Error error_code,
+ const base::File::Info& file_info) {
+ if (error_code != base::File::FILE_OK) {
+ NotifyFailed(error_code == base::File::FILE_ERROR_INVALID_URL ?
net::ERR_INVALID_URL : net::ERR_FILE_NOT_FOUND);
return;
}
diff --git a/chromium/webkit/browser/fileapi/file_system_url_request_job.h b/chromium/webkit/browser/fileapi/file_system_url_request_job.h
index a784d629251..29b42a5f060 100644
--- a/chromium/webkit/browser/fileapi/file_system_url_request_job.h
+++ b/chromium/webkit/browser/fileapi/file_system_url_request_job.h
@@ -7,10 +7,10 @@
#include <string>
+#include "base/files/file.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "base/platform_file.h"
#include "net/http/http_byte_range.h"
#include "net/url_request/url_request_job.h"
#include "webkit/browser/fileapi/file_system_url.h"
@@ -36,6 +36,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileSystemURLRequestJob
FileSystemURLRequestJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate,
+ const std::string& storage_domain,
FileSystemContext* file_system_context);
// URLRequestJob methods:
@@ -60,12 +61,13 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileSystemURLRequestJob
virtual ~FileSystemURLRequestJob();
void StartAsync();
- void DidGetMetadata(
- base::PlatformFileError error_code,
- const base::PlatformFileInfo& file_info);
+ void DidAttemptAutoMount(base::File::Error result);
+ void DidGetMetadata(base::File::Error error_code,
+ const base::File::Info& file_info);
void DidRead(int result);
void NotifyFailed(int rv);
+ const std::string storage_domain_;
FileSystemContext* file_system_context_;
scoped_ptr<webkit_blob::FileStreamReader> reader_;
FileSystemURL url_;
diff --git a/chromium/webkit/browser/fileapi/file_system_url_request_job_factory.cc b/chromium/webkit/browser/fileapi/file_system_url_request_job_factory.cc
index 76ae7c9ac05..3add372e5e6 100644
--- a/chromium/webkit/browser/fileapi/file_system_url_request_job_factory.cc
+++ b/chromium/webkit/browser/fileapi/file_system_url_request_job_factory.cc
@@ -19,7 +19,8 @@ namespace {
class FileSystemProtocolHandler
: public net::URLRequestJobFactory::ProtocolHandler {
public:
- explicit FileSystemProtocolHandler(FileSystemContext* context);
+ FileSystemProtocolHandler(const std::string& storage_domain,
+ FileSystemContext* context);
virtual ~FileSystemProtocolHandler();
virtual net::URLRequestJob* MaybeCreateJob(
@@ -27,6 +28,8 @@ class FileSystemProtocolHandler
net::NetworkDelegate* network_delegate) const OVERRIDE;
private:
+ const std::string storage_domain_;
+
// No scoped_refptr because |file_system_context_| is owned by the
// ProfileIOData, which also owns this ProtocolHandler.
FileSystemContext* const file_system_context_;
@@ -35,8 +38,10 @@ class FileSystemProtocolHandler
};
FileSystemProtocolHandler::FileSystemProtocolHandler(
+ const std::string& storage_domain,
FileSystemContext* context)
- : file_system_context_(context) {
+ : storage_domain_(storage_domain),
+ file_system_context_(context) {
DCHECK(file_system_context_);
}
@@ -51,18 +56,18 @@ net::URLRequestJob* FileSystemProtocolHandler::MaybeCreateJob(
// redirects back here, by adding a / to the URL.
if (!path.empty() && path[path.size() - 1] == '/') {
return new FileSystemDirURLRequestJob(
- request, network_delegate, file_system_context_);
+ request, network_delegate, storage_domain_, file_system_context_);
}
return new FileSystemURLRequestJob(
- request, network_delegate, file_system_context_);
+ request, network_delegate, storage_domain_, file_system_context_);
}
} // anonymous namespace
-net::URLRequestJobFactory::ProtocolHandler*
-CreateFileSystemProtocolHandler(FileSystemContext* context) {
+net::URLRequestJobFactory::ProtocolHandler* CreateFileSystemProtocolHandler(
+ const std::string& storage_domain, FileSystemContext* context) {
DCHECK(context);
- return new FileSystemProtocolHandler(context);
+ return new FileSystemProtocolHandler(storage_domain, context);
}
} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/file_system_url_request_job_factory.h b/chromium/webkit/browser/fileapi/file_system_url_request_job_factory.h
index 5bd3c0f91a6..bcc55dca443 100644
--- a/chromium/webkit/browser/fileapi/file_system_url_request_job_factory.h
+++ b/chromium/webkit/browser/fileapi/file_system_url_request_job_factory.h
@@ -5,6 +5,8 @@
#ifndef WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_URL_REQUEST_JOB_FACTORY_H_
#define WEBKIT_BROWSER_FILEAPI_FILE_SYSTEM_URL_REQUEST_JOB_FACTORY_H_
+#include <string>
+
#include "net/url_request/url_request_job_factory.h"
#include "webkit/browser/webkit_storage_browser_export.h"
@@ -21,7 +23,8 @@ class FileSystemContext;
// Currently, this is only used by ProfileIOData which owns |context| and the
// ProtocolHandler.
WEBKIT_STORAGE_BROWSER_EXPORT net::URLRequestJobFactory::ProtocolHandler*
- CreateFileSystemProtocolHandler(FileSystemContext* context);
+ CreateFileSystemProtocolHandler(const std::string& storage_domain,
+ FileSystemContext* context);
} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/file_system_url_unittest.cc b/chromium/webkit/browser/fileapi/file_system_url_unittest.cc
deleted file mode 100644
index c5a632c735c..00000000000
--- a/chromium/webkit/browser/fileapi/file_system_url_unittest.cc
+++ /dev/null
@@ -1,213 +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 "webkit/browser/fileapi/file_system_url.h"
-
-#include "base/files/file_path.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "url/gurl.h"
-#include "webkit/common/fileapi/file_system_types.h"
-#include "webkit/common/fileapi/file_system_util.h"
-
-#define FPL FILE_PATH_LITERAL
-
-#if defined(FILE_PATH_USES_DRIVE_LETTERS)
-#define DRIVE FPL("C:")
-#else
-#define DRIVE FPL("/a/")
-#endif
-
-namespace fileapi {
-
-namespace {
-
-FileSystemURL CreateFileSystemURL(const std::string& url_string) {
- FileSystemURL url = FileSystemURL::CreateForTest(GURL(url_string));
- EXPECT_TRUE(url.type() != kFileSystemTypeExternal &&
- url.type() != kFileSystemTypeIsolated);
- return url;
-}
-
-std::string NormalizedUTF8Path(const base::FilePath& path) {
- return path.NormalizePathSeparators().AsUTF8Unsafe();
-}
-
-} // namespace
-
-TEST(FileSystemURLTest, ParsePersistent) {
- FileSystemURL url = CreateFileSystemURL(
- "filesystem:http://chromium.org/persistent/directory/file");
- ASSERT_TRUE(url.is_valid());
- EXPECT_EQ("http://chromium.org/", url.origin().spec());
- EXPECT_EQ(kFileSystemTypePersistent, url.type());
- EXPECT_EQ(FPL("file"), VirtualPath::BaseName(url.path()).value());
- EXPECT_EQ(FPL("directory"), url.path().DirName().value());
-}
-
-TEST(FileSystemURLTest, ParseTemporary) {
- FileSystemURL url = CreateFileSystemURL(
- "filesystem:http://chromium.org/temporary/directory/file");
- ASSERT_TRUE(url.is_valid());
- EXPECT_EQ("http://chromium.org/", url.origin().spec());
- EXPECT_EQ(kFileSystemTypeTemporary, url.type());
- EXPECT_EQ(FPL("file"), VirtualPath::BaseName(url.path()).value());
- EXPECT_EQ(FPL("directory"), url.path().DirName().value());
-}
-
-TEST(FileSystemURLTest, EnsureFilePathIsRelative) {
- FileSystemURL url = CreateFileSystemURL(
- "filesystem:http://chromium.org/temporary/////directory/file");
- ASSERT_TRUE(url.is_valid());
- EXPECT_EQ("http://chromium.org/", url.origin().spec());
- EXPECT_EQ(kFileSystemTypeTemporary, url.type());
- EXPECT_EQ(FPL("file"), VirtualPath::BaseName(url.path()).value());
- EXPECT_EQ(FPL("directory"), url.path().DirName().value());
- EXPECT_FALSE(url.path().IsAbsolute());
-}
-
-TEST(FileSystemURLTest, RejectBadSchemes) {
- EXPECT_FALSE(CreateFileSystemURL("http://chromium.org/").is_valid());
- EXPECT_FALSE(CreateFileSystemURL("https://chromium.org/").is_valid());
- EXPECT_FALSE(CreateFileSystemURL("file:///foo/bar").is_valid());
- EXPECT_FALSE(CreateFileSystemURL("foobar:///foo/bar").is_valid());
-}
-
-TEST(FileSystemURLTest, UnescapePath) {
- FileSystemURL url = CreateFileSystemURL(
- "filesystem:http://chromium.org/persistent/%7Echromium/space%20bar");
- ASSERT_TRUE(url.is_valid());
- EXPECT_EQ(FPL("space bar"), VirtualPath::BaseName(url.path()).value());
- EXPECT_EQ(FPL("~chromium"), url.path().DirName().value());
-}
-
-TEST(FileSystemURLTest, RejectBadType) {
- EXPECT_FALSE(CreateFileSystemURL(
- "filesystem:http://c.org/foobar/file").is_valid());
- EXPECT_FALSE(CreateFileSystemURL(
- "filesystem:http://c.org/temporaryfoo/file").is_valid());
-}
-
-TEST(FileSystemURLTest, RejectMalformedURL) {
- EXPECT_FALSE(CreateFileSystemURL("filesystem:///foobar/file").is_valid());
- EXPECT_FALSE(CreateFileSystemURL("filesystem:foobar/file").is_valid());
-}
-
-TEST(FileSystemURLTest, CompareURLs) {
- const GURL urls[] = {
- GURL("filesystem:http://chromium.org/temporary/dir a/file a"),
- GURL("filesystem:http://chromium.org/temporary/dir a/file a"),
- GURL("filesystem:http://chromium.org/temporary/dir a/file b"),
- GURL("filesystem:http://chromium.org/temporary/dir a/file aa"),
- GURL("filesystem:http://chromium.org/temporary/dir b/file a"),
- GURL("filesystem:http://chromium.org/temporary/dir aa/file b"),
- GURL("filesystem:http://chromium.com/temporary/dir a/file a"),
- GURL("filesystem:https://chromium.org/temporary/dir a/file a")
- };
-
- FileSystemURL::Comparator compare;
- for (size_t i = 0; i < arraysize(urls); ++i) {
- for (size_t j = 0; j < arraysize(urls); ++j) {
- SCOPED_TRACE(testing::Message() << i << " < " << j);
- EXPECT_EQ(urls[i] < urls[j],
- compare(FileSystemURL::CreateForTest(urls[i]),
- FileSystemURL::CreateForTest(urls[j])));
- }
- }
-
- const FileSystemURL a = CreateFileSystemURL(
- "filesystem:http://chromium.org/temporary/dir a/file a");
- const FileSystemURL b = CreateFileSystemURL(
- "filesystem:http://chromium.org/persistent/dir a/file a");
- EXPECT_EQ(a.type() < b.type(), compare(a, b));
- EXPECT_EQ(b.type() < a.type(), compare(b, a));
-}
-
-TEST(FileSystemURLTest, IsParent) {
- const std::string root1 = GetFileSystemRootURI(
- GURL("http://example.com"), kFileSystemTypeTemporary).spec();
- const std::string root2 = GetFileSystemRootURI(
- GURL("http://example.com"), kFileSystemTypePersistent).spec();
- const std::string root3 = GetFileSystemRootURI(
- GURL("http://chromium.org"), kFileSystemTypeTemporary).spec();
-
- const std::string parent("dir");
- const std::string child("dir/child");
- const std::string other("other");
-
- // True cases.
- EXPECT_TRUE(CreateFileSystemURL(root1 + parent).IsParent(
- CreateFileSystemURL(root1 + child)));
- EXPECT_TRUE(CreateFileSystemURL(root2 + parent).IsParent(
- CreateFileSystemURL(root2 + child)));
-
- // False cases: the path is not a child.
- EXPECT_FALSE(CreateFileSystemURL(root1 + parent).IsParent(
- CreateFileSystemURL(root1 + other)));
- EXPECT_FALSE(CreateFileSystemURL(root1 + parent).IsParent(
- CreateFileSystemURL(root1 + parent)));
- EXPECT_FALSE(CreateFileSystemURL(root1 + child).IsParent(
- CreateFileSystemURL(root1 + parent)));
-
- // False case: different types.
- EXPECT_FALSE(CreateFileSystemURL(root1 + parent).IsParent(
- CreateFileSystemURL(root2 + child)));
-
- // False case: different origins.
- EXPECT_FALSE(CreateFileSystemURL(root1 + parent).IsParent(
- CreateFileSystemURL(root3 + child)));
-}
-
-TEST(FileSystemURLTest, ToGURL) {
- EXPECT_TRUE(FileSystemURL().ToGURL().is_empty());
- const char* kTestURL[] = {
- "filesystem:http://chromium.org/persistent/directory/file0",
- "filesystem:http://chromium.org/temporary/directory/file1",
- "filesystem:http://chromium.org/isolated/directory/file2",
- "filesystem:http://chromium.org/external/directory/file2",
- "filesystem:http://chromium.org/test/directory/file3",
- };
-
- for (size_t i = 0; i < arraysize(kTestURL); ++i) {
- EXPECT_EQ(
- kTestURL[i],
- FileSystemURL::CreateForTest(GURL(kTestURL[i])).ToGURL().spec());
- }
-}
-
-TEST(FileSystemURLTest, DebugString) {
- const GURL kOrigin("http://example.com");
- const base::FilePath kPath(FPL("dir/file"));
-
- const FileSystemURL kURL1 = FileSystemURL::CreateForTest(
- kOrigin, kFileSystemTypeTemporary, kPath);
- EXPECT_EQ("filesystem:http://example.com/temporary/" +
- NormalizedUTF8Path(kPath),
- kURL1.DebugString());
-}
-
-TEST(FileSystemURLTest, IsInSameFileSystem) {
- FileSystemURL url_foo_temp_a = FileSystemURL::CreateForTest(
- GURL("http://foo"), kFileSystemTypeTemporary,
- base::FilePath::FromUTF8Unsafe("a"));
- FileSystemURL url_foo_temp_b = FileSystemURL::CreateForTest(
- GURL("http://foo"), kFileSystemTypeTemporary,
- base::FilePath::FromUTF8Unsafe("b"));
- FileSystemURL url_foo_perm_a = FileSystemURL::CreateForTest(
- GURL("http://foo"), kFileSystemTypePersistent,
- base::FilePath::FromUTF8Unsafe("a"));
- FileSystemURL url_bar_temp_a = FileSystemURL::CreateForTest(
- GURL("http://bar"), kFileSystemTypeTemporary,
- base::FilePath::FromUTF8Unsafe("a"));
- FileSystemURL url_bar_perm_a = FileSystemURL::CreateForTest(
- GURL("http://bar"), kFileSystemTypePersistent,
- base::FilePath::FromUTF8Unsafe("a"));
-
- EXPECT_TRUE(url_foo_temp_a.IsInSameFileSystem(url_foo_temp_a));
- EXPECT_TRUE(url_foo_temp_a.IsInSameFileSystem(url_foo_temp_b));
- EXPECT_FALSE(url_foo_temp_a.IsInSameFileSystem(url_foo_perm_a));
- EXPECT_FALSE(url_foo_temp_a.IsInSameFileSystem(url_bar_temp_a));
- EXPECT_FALSE(url_foo_temp_a.IsInSameFileSystem(url_bar_perm_a));
-}
-
-} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/file_system_usage_cache.cc b/chromium/webkit/browser/fileapi/file_system_usage_cache.cc
index 56b1fb43566..89c6db1665f 100644
--- a/chromium/webkit/browser/fileapi/file_system_usage_cache.cc
+++ b/chromium/webkit/browser/fileapi/file_system_usage_cache.cc
@@ -94,7 +94,7 @@ bool FileSystemUsageCache::DecrementDirty(
DCHECK(CalledOnValidThread());
bool is_valid = true;
uint32 dirty = 0;
- int64 usage = 0;;
+ int64 usage = 0;
if (!Read(usage_file_path, &is_valid, &dirty, &usage) || dirty <= 0)
return false;
@@ -162,12 +162,7 @@ bool FileSystemUsageCache::Delete(const base::FilePath& usage_file_path) {
void FileSystemUsageCache::CloseCacheFiles() {
TRACE_EVENT0("FileSystem", "UsageCache::CloseCacheFiles");
DCHECK(CalledOnValidThread());
- for (CacheFiles::iterator itr = cache_files_.begin();
- itr != cache_files_.end(); ++itr) {
- if (itr->second != base::kInvalidPlatformFileValue)
- base::ClosePlatformFile(itr->second);
- }
- cache_files_.clear();
+ STLDeleteValues(&cache_files_);
timer_.reset();
}
@@ -228,63 +223,59 @@ bool FileSystemUsageCache::Write(const base::FilePath& usage_file_path,
return true;
}
-bool FileSystemUsageCache::GetPlatformFile(const base::FilePath& file_path,
- base::PlatformFile* file) {
+base::File* FileSystemUsageCache::GetFile(const base::FilePath& file_path) {
DCHECK(CalledOnValidThread());
if (cache_files_.size() >= kMaxHandleCacheSize)
CloseCacheFiles();
ScheduleCloseTimer();
+ base::File* new_file = NULL;
std::pair<CacheFiles::iterator, bool> inserted =
- cache_files_.insert(
- std::make_pair(file_path, base::kInvalidPlatformFileValue));
- if (!inserted.second) {
- *file = inserted.first->second;
- return true;
- }
-
- base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
- base::PlatformFile platform_file =
- base::CreatePlatformFile(file_path,
- base::PLATFORM_FILE_OPEN_ALWAYS |
- base::PLATFORM_FILE_READ |
- base::PLATFORM_FILE_WRITE,
- NULL, &error);
- if (error != base::PLATFORM_FILE_OK) {
+ cache_files_.insert(std::make_pair(file_path, new_file));
+ if (!inserted.second)
+ return inserted.first->second;
+
+ new_file = new base::File(file_path,
+ base::File::FLAG_OPEN_ALWAYS |
+ base::File::FLAG_READ |
+ base::File::FLAG_WRITE);
+ if (!new_file->IsValid()) {
cache_files_.erase(inserted.first);
- return false;
+ delete new_file;
+ return NULL;
}
- inserted.first->second = platform_file;
- *file = platform_file;
- return true;
+ inserted.first->second = new_file;
+ return new_file;
}
bool FileSystemUsageCache::ReadBytes(const base::FilePath& file_path,
char* buffer,
int64 buffer_size) {
DCHECK(CalledOnValidThread());
- base::PlatformFile file;
- if (!GetPlatformFile(file_path, &file))
+ base::File* file = GetFile(file_path);
+ if (!file)
return false;
- return base::ReadPlatformFile(file, 0, buffer, buffer_size) == buffer_size;
+ return file->Read(0, buffer, buffer_size) == buffer_size;
}
bool FileSystemUsageCache::WriteBytes(const base::FilePath& file_path,
const char* buffer,
int64 buffer_size) {
DCHECK(CalledOnValidThread());
- base::PlatformFile file;
- if (!GetPlatformFile(file_path, &file))
+ base::File* file = GetFile(file_path);
+ if (!file)
return false;
- return base::WritePlatformFile(file, 0, buffer, buffer_size) == buffer_size;
+ return file->Write(0, buffer, buffer_size) == buffer_size;
}
bool FileSystemUsageCache::FlushFile(const base::FilePath& file_path) {
TRACE_EVENT0("FileSystem", "UsageCache::FlushFile");
DCHECK(CalledOnValidThread());
- base::PlatformFile file = base::kInvalidPlatformFileValue;
- return GetPlatformFile(file_path, &file) && base::FlushPlatformFile(file);
+ base::File* file = GetFile(file_path);
+ if (!file)
+ return false;
+ return file->Flush();
}
void FileSystemUsageCache::ScheduleCloseTimer() {
diff --git a/chromium/webkit/browser/fileapi/file_system_usage_cache.h b/chromium/webkit/browser/fileapi/file_system_usage_cache.h
index c3950a58561..d4451e3882f 100644
--- a/chromium/webkit/browser/fileapi/file_system_usage_cache.h
+++ b/chromium/webkit/browser/fileapi/file_system_usage_cache.h
@@ -8,10 +8,10 @@
#include <map>
#include "base/basictypes.h"
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "base/platform_file.h"
#include "base/sequenced_task_runner.h"
#include "webkit/browser/webkit_storage_browser_export.h"
@@ -61,7 +61,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileSystemUsageCache {
static const int kUsageFileHeaderSize;
private:
- typedef std::map<base::FilePath, base::PlatformFile> CacheFiles;
+ typedef std::map<base::FilePath, base::File*> CacheFiles;
// Read the size, validity and the "dirty" entry described in the .usage file.
// Returns less than zero if no .usage file is available.
@@ -75,8 +75,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileSystemUsageCache {
int32 dirty,
int64 fs_usage);
- bool GetPlatformFile(const base::FilePath& file_path,
- base::PlatformFile* file);
+ base::File* GetFile(const base::FilePath& file_path);
bool ReadBytes(const base::FilePath& file_path,
char* buffer,
@@ -92,7 +91,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileSystemUsageCache {
bool CalledOnValidThread();
scoped_ptr<TimedTaskHelper> timer_;
- std::map<base::FilePath, base::PlatformFile> cache_files_;
+ CacheFiles cache_files_;
scoped_refptr<base::SequencedTaskRunner> task_runner_;
diff --git a/chromium/webkit/browser/fileapi/file_system_usage_cache_unittest.cc b/chromium/webkit/browser/fileapi/file_system_usage_cache_unittest.cc
deleted file mode 100644
index 1b99d9c10d2..00000000000
--- a/chromium/webkit/browser/fileapi/file_system_usage_cache_unittest.cc
+++ /dev/null
@@ -1,158 +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 "webkit/browser/fileapi/file_system_usage_cache.h"
-
-#include "base/basictypes.h"
-#include "base/file_util.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/message_loop/message_loop.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace fileapi {
-
-class FileSystemUsageCacheTest : public testing::Test {
- public:
- FileSystemUsageCacheTest()
- : usage_cache_(base::MessageLoopProxy::current().get()) {}
-
- virtual void SetUp() {
- ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
- }
-
- protected:
- base::FilePath GetUsageFilePath() {
- return data_dir_.path().Append(FileSystemUsageCache::kUsageFileName);
- }
-
- FileSystemUsageCache* usage_cache() {
- return &usage_cache_;
- }
-
- private:
- base::MessageLoop message_loop_;
- base::ScopedTempDir data_dir_;
- FileSystemUsageCache usage_cache_;
-
- DISALLOW_COPY_AND_ASSIGN(FileSystemUsageCacheTest);
-};
-
-TEST_F(FileSystemUsageCacheTest, CreateTest) {
- base::FilePath usage_file_path = GetUsageFilePath();
- EXPECT_TRUE(usage_cache()->UpdateUsage(usage_file_path, 0));
-}
-
-TEST_F(FileSystemUsageCacheTest, SetSizeTest) {
- static const int64 size = 240122;
- base::FilePath usage_file_path = GetUsageFilePath();
- int64 usage = 0;
- ASSERT_TRUE(usage_cache()->UpdateUsage(usage_file_path, size));
- EXPECT_TRUE(usage_cache()->GetUsage(usage_file_path, &usage));
- EXPECT_EQ(size, usage);
-}
-
-TEST_F(FileSystemUsageCacheTest, SetLargeSizeTest) {
- static const int64 size = kint64max;
- base::FilePath usage_file_path = GetUsageFilePath();
- int64 usage = 0;
- ASSERT_TRUE(usage_cache()->UpdateUsage(usage_file_path, size));
- EXPECT_TRUE(usage_cache()->GetUsage(usage_file_path, &usage));
- EXPECT_EQ(size, usage);
-}
-
-TEST_F(FileSystemUsageCacheTest, IncAndGetSizeTest) {
- base::FilePath usage_file_path = GetUsageFilePath();
- uint32 dirty = 0;
- int64 usage = 0;
- ASSERT_TRUE(usage_cache()->UpdateUsage(usage_file_path, 98214));
- ASSERT_TRUE(usage_cache()->IncrementDirty(usage_file_path));
- EXPECT_TRUE(usage_cache()->GetDirty(usage_file_path, &dirty));
- EXPECT_EQ(1u, dirty);
- EXPECT_TRUE(usage_cache()->GetUsage(usage_file_path, &usage));
- EXPECT_EQ(98214, usage);
-}
-
-TEST_F(FileSystemUsageCacheTest, DecAndGetSizeTest) {
- static const int64 size = 71839;
- base::FilePath usage_file_path = GetUsageFilePath();
- int64 usage = 0;
- ASSERT_TRUE(usage_cache()->UpdateUsage(usage_file_path, size));
- // DecrementDirty for dirty = 0 is invalid. It returns false.
- ASSERT_FALSE(usage_cache()->DecrementDirty(usage_file_path));
- EXPECT_TRUE(usage_cache()->GetUsage(usage_file_path, &usage));
- EXPECT_EQ(size, usage);
-}
-
-TEST_F(FileSystemUsageCacheTest, IncDecAndGetSizeTest) {
- static const int64 size = 198491;
- base::FilePath usage_file_path = GetUsageFilePath();
- int64 usage = 0;
- ASSERT_TRUE(usage_cache()->UpdateUsage(usage_file_path, size));
- ASSERT_TRUE(usage_cache()->IncrementDirty(usage_file_path));
- ASSERT_TRUE(usage_cache()->DecrementDirty(usage_file_path));
- EXPECT_TRUE(usage_cache()->GetUsage(usage_file_path, &usage));
- EXPECT_EQ(size, usage);
-}
-
-TEST_F(FileSystemUsageCacheTest, DecIncAndGetSizeTest) {
- base::FilePath usage_file_path = GetUsageFilePath();
- uint32 dirty = 0;
- int64 usage = 0;
- ASSERT_TRUE(usage_cache()->UpdateUsage(usage_file_path, 854238));
- // DecrementDirty for dirty = 0 is invalid. It returns false.
- ASSERT_FALSE(usage_cache()->DecrementDirty(usage_file_path));
- ASSERT_TRUE(usage_cache()->IncrementDirty(usage_file_path));
- // It tests DecrementDirty (which returns false) has no effect, i.e
- // does not make dirty = -1 after DecrementDirty.
- EXPECT_TRUE(usage_cache()->GetDirty(usage_file_path, &dirty));
- EXPECT_EQ(1u, dirty);
- EXPECT_TRUE(usage_cache()->GetUsage(usage_file_path, &usage));
- EXPECT_EQ(854238, usage);
-}
-
-TEST_F(FileSystemUsageCacheTest, ManyIncsSameDecsAndGetSizeTest) {
- static const int64 size = 82412;
- base::FilePath usage_file_path = GetUsageFilePath();
- int64 usage = 0;
- ASSERT_TRUE(usage_cache()->UpdateUsage(usage_file_path, size));
- for (int i = 0; i < 20; i++)
- ASSERT_TRUE(usage_cache()->IncrementDirty(usage_file_path));
- for (int i = 0; i < 20; i++)
- ASSERT_TRUE(usage_cache()->DecrementDirty(usage_file_path));
- EXPECT_TRUE(usage_cache()->GetUsage(usage_file_path, &usage));
- EXPECT_EQ(size, usage);
-}
-
-TEST_F(FileSystemUsageCacheTest, ManyIncsLessDecsAndGetSizeTest) {
- uint32 dirty = 0;
- int64 usage = 0;
- base::FilePath usage_file_path = GetUsageFilePath();
- ASSERT_TRUE(usage_cache()->UpdateUsage(usage_file_path, 19319));
- for (int i = 0; i < 20; i++)
- ASSERT_TRUE(usage_cache()->IncrementDirty(usage_file_path));
- for (int i = 0; i < 19; i++)
- ASSERT_TRUE(usage_cache()->DecrementDirty(usage_file_path));
- EXPECT_TRUE(usage_cache()->GetDirty(usage_file_path, &dirty));
- EXPECT_EQ(1u, dirty);
- EXPECT_TRUE(usage_cache()->GetUsage(usage_file_path, &usage));
- EXPECT_EQ(19319, usage);
-}
-
-TEST_F(FileSystemUsageCacheTest, GetSizeWithoutCacheFileTest) {
- int64 usage = 0;
- base::FilePath usage_file_path = GetUsageFilePath();
- EXPECT_FALSE(usage_cache()->GetUsage(usage_file_path, &usage));
-}
-
-TEST_F(FileSystemUsageCacheTest, IncrementDirtyWithoutCacheFileTest) {
- base::FilePath usage_file_path = GetUsageFilePath();
- EXPECT_FALSE(usage_cache()->IncrementDirty(usage_file_path));
-}
-
-TEST_F(FileSystemUsageCacheTest, DecrementDirtyWithoutCacheFileTest) {
- base::FilePath usage_file_path = GetUsageFilePath();
- EXPECT_FALSE(usage_cache()->IncrementDirty(usage_file_path));
-}
-
-} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/file_writer_delegate.cc b/chromium/webkit/browser/fileapi/file_writer_delegate.cc
index 295cd642ab1..83112780cb9 100644
--- a/chromium/webkit/browser/fileapi/file_writer_delegate.cc
+++ b/chromium/webkit/browser/fileapi/file_writer_delegate.cc
@@ -21,9 +21,11 @@ namespace fileapi {
static const int kReadBufSize = 32768;
FileWriterDelegate::FileWriterDelegate(
- scoped_ptr<FileStreamWriter> file_stream_writer)
+ scoped_ptr<FileStreamWriter> file_stream_writer,
+ FlushPolicy flush_policy)
: file_stream_writer_(file_stream_writer.Pass()),
writing_started_(false),
+ flush_policy_(flush_policy),
bytes_written_backlog_(0),
bytes_written_(0),
bytes_read_(0),
@@ -54,7 +56,7 @@ void FileWriterDelegate::Cancel() {
// Return true to finish immediately if we have no pending writes.
// Otherwise we'll do the final cleanup in the Cancel callback.
if (status != net::ERR_IO_PENDING) {
- write_callback_.Run(base::PLATFORM_FILE_ERROR_ABORT, 0,
+ write_callback_.Run(base::File::FILE_ERROR_ABORT, 0,
GetCompletionStatusOnError());
}
}
@@ -63,33 +65,33 @@ void FileWriterDelegate::OnReceivedRedirect(net::URLRequest* request,
const GURL& new_url,
bool* defer_redirect) {
NOTREACHED();
- OnError(base::PLATFORM_FILE_ERROR_SECURITY);
+ OnError(base::File::FILE_ERROR_SECURITY);
}
void FileWriterDelegate::OnAuthRequired(net::URLRequest* request,
net::AuthChallengeInfo* auth_info) {
NOTREACHED();
- OnError(base::PLATFORM_FILE_ERROR_SECURITY);
+ OnError(base::File::FILE_ERROR_SECURITY);
}
void FileWriterDelegate::OnCertificateRequested(
net::URLRequest* request,
net::SSLCertRequestInfo* cert_request_info) {
NOTREACHED();
- OnError(base::PLATFORM_FILE_ERROR_SECURITY);
+ OnError(base::File::FILE_ERROR_SECURITY);
}
void FileWriterDelegate::OnSSLCertificateError(net::URLRequest* request,
const net::SSLInfo& ssl_info,
bool fatal) {
NOTREACHED();
- OnError(base::PLATFORM_FILE_ERROR_SECURITY);
+ OnError(base::File::FILE_ERROR_SECURITY);
}
void FileWriterDelegate::OnResponseStarted(net::URLRequest* request) {
DCHECK_EQ(request_.get(), request);
if (!request->status().is_success() || request->GetResponseCode() != 200) {
- OnError(base::PLATFORM_FILE_ERROR_FAILED);
+ OnError(base::File::FILE_ERROR_FAILED);
return;
}
Read();
@@ -99,7 +101,7 @@ void FileWriterDelegate::OnReadCompleted(net::URLRequest* request,
int bytes_read) {
DCHECK_EQ(request_.get(), request);
if (!request->status().is_success()) {
- OnError(base::PLATFORM_FILE_ERROR_FAILED);
+ OnError(base::File::FILE_ERROR_FAILED);
return;
}
OnDataReceived(bytes_read);
@@ -114,7 +116,7 @@ void FileWriterDelegate::Read() {
base::Bind(&FileWriterDelegate::OnDataReceived,
weak_factory_.GetWeakPtr(), bytes_read_));
} else if (!request_->status().is_io_pending()) {
- OnError(base::PLATFORM_FILE_ERROR_FAILED);
+ OnError(base::File::FILE_ERROR_FAILED);
}
}
@@ -145,7 +147,7 @@ void FileWriterDelegate::Write() {
base::Bind(&FileWriterDelegate::OnDataWritten,
weak_factory_.GetWeakPtr(), write_response));
} else if (net::ERR_IO_PENDING != write_response) {
- OnError(NetErrorToPlatformFileError(write_response));
+ OnError(NetErrorToFileError(write_response));
}
}
@@ -159,7 +161,7 @@ void FileWriterDelegate::OnDataWritten(int write_response) {
else
Write();
} else {
- OnError(NetErrorToPlatformFileError(write_response));
+ OnError(NetErrorToFileError(write_response));
}
}
@@ -168,14 +170,14 @@ FileWriterDelegate::GetCompletionStatusOnError() const {
return writing_started_ ? ERROR_WRITE_STARTED : ERROR_WRITE_NOT_STARTED;
}
-void FileWriterDelegate::OnError(base::PlatformFileError error) {
+void FileWriterDelegate::OnError(base::File::Error error) {
if (request_) {
request_->set_delegate(NULL);
request_->Cancel();
}
if (writing_started_)
- FlushForCompletion(error, 0, ERROR_WRITE_STARTED);
+ MaybeFlushForCompletion(error, 0, ERROR_WRITE_STARTED);
else
write_callback_.Run(error, 0, ERROR_WRITE_NOT_STARTED);
}
@@ -192,10 +194,10 @@ void FileWriterDelegate::OnProgress(int bytes_written, bool done) {
bytes_written_backlog_ = 0;
if (done) {
- FlushForCompletion(base::PLATFORM_FILE_OK, bytes_written,
- SUCCESS_COMPLETED);
+ MaybeFlushForCompletion(base::File::FILE_OK, bytes_written,
+ SUCCESS_COMPLETED);
} else {
- write_callback_.Run(base::PLATFORM_FILE_OK, bytes_written,
+ write_callback_.Run(base::File::FILE_OK, bytes_written,
SUCCESS_IO_PENDING);
}
return;
@@ -204,14 +206,20 @@ void FileWriterDelegate::OnProgress(int bytes_written, bool done) {
}
void FileWriterDelegate::OnWriteCancelled(int status) {
- write_callback_.Run(base::PLATFORM_FILE_ERROR_ABORT, 0,
+ write_callback_.Run(base::File::FILE_ERROR_ABORT, 0,
GetCompletionStatusOnError());
}
-void FileWriterDelegate::FlushForCompletion(
- base::PlatformFileError error,
+void FileWriterDelegate::MaybeFlushForCompletion(
+ base::File::Error error,
int bytes_written,
WriteProgressStatus progress_status) {
+ if (flush_policy_ == NO_FLUSH_ON_COMPLETION) {
+ write_callback_.Run(error, bytes_written, progress_status);
+ return;
+ }
+ DCHECK_EQ(FLUSH_ON_COMPLETION, flush_policy_);
+
int flush_error = file_stream_writer_->Flush(
base::Bind(&FileWriterDelegate::OnFlushed, weak_factory_.GetWeakPtr(),
error, bytes_written, progress_status));
@@ -219,14 +227,14 @@ void FileWriterDelegate::FlushForCompletion(
OnFlushed(error, bytes_written, progress_status, flush_error);
}
-void FileWriterDelegate::OnFlushed(base::PlatformFileError error,
+void FileWriterDelegate::OnFlushed(base::File::Error error,
int bytes_written,
WriteProgressStatus progress_status,
int flush_error) {
- if (error == base::PLATFORM_FILE_OK && flush_error != net::OK) {
+ if (error == base::File::FILE_OK && flush_error != net::OK) {
// If the Flush introduced an error, overwrite the status.
// Otherwise, keep the original error status.
- error = NetErrorToPlatformFileError(flush_error);
+ error = NetErrorToFileError(flush_error);
progress_status = GetCompletionStatusOnError();
}
write_callback_.Run(error, bytes_written, progress_status);
diff --git a/chromium/webkit/browser/fileapi/file_writer_delegate.h b/chromium/webkit/browser/fileapi/file_writer_delegate.h
index f7ce16dfb6f..c0464283fd4 100644
--- a/chromium/webkit/browser/fileapi/file_writer_delegate.h
+++ b/chromium/webkit/browser/fileapi/file_writer_delegate.h
@@ -5,10 +5,10 @@
#ifndef WEBKIT_BROWSER_FILEAPI_FILE_WRITER_DELEGATE_H_
#define WEBKIT_BROWSER_FILEAPI_FILE_WRITER_DELEGATE_H_
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "base/platform_file.h"
#include "base/time/time.h"
#include "net/base/file_stream.h"
#include "net/base/io_buffer.h"
@@ -22,6 +22,11 @@ class FileStreamWriter;
class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileWriterDelegate
: public net::URLRequest::Delegate {
public:
+ enum FlushPolicy {
+ FLUSH_ON_COMPLETION,
+ NO_FLUSH_ON_COMPLETION,
+ };
+
enum WriteProgressStatus {
SUCCESS_IO_PENDING,
SUCCESS_COMPLETED,
@@ -29,12 +34,13 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileWriterDelegate
ERROR_WRITE_NOT_STARTED,
};
- typedef base::Callback<void(base::PlatformFileError result,
+ typedef base::Callback<void(base::File::Error result,
int64 bytes,
WriteProgressStatus write_status)>
DelegateWriteCallback;
- explicit FileWriterDelegate(scoped_ptr<FileStreamWriter> file_writer);
+ FileWriterDelegate(scoped_ptr<FileStreamWriter> file_writer,
+ FlushPolicy flush_policy);
virtual ~FileWriterDelegate();
void Start(scoped_ptr<net::URLRequest> request,
@@ -63,19 +69,19 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileWriterDelegate
private:
void OnGetFileInfoAndStartRequest(
scoped_ptr<net::URLRequest> request,
- base::PlatformFileError error,
- const base::PlatformFileInfo& file_info);
+ base::File::Error error,
+ const base::File::Info& file_info);
void Read();
void OnDataReceived(int bytes_read);
void Write();
void OnDataWritten(int write_response);
- void OnError(base::PlatformFileError error);
+ void OnError(base::File::Error error);
void OnProgress(int bytes_read, bool done);
void OnWriteCancelled(int status);
- void FlushForCompletion(base::PlatformFileError error,
- int bytes_written,
- WriteProgressStatus progress_status);
- void OnFlushed(base::PlatformFileError error,
+ void MaybeFlushForCompletion(base::File::Error error,
+ int bytes_written,
+ WriteProgressStatus progress_status);
+ void OnFlushed(base::File::Error error,
int bytes_written,
WriteProgressStatus progress_status,
int flush_error);
@@ -86,6 +92,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE FileWriterDelegate
scoped_ptr<FileStreamWriter> file_stream_writer_;
base::Time last_progress_event_time_;
bool writing_started_;
+ FlushPolicy flush_policy_;
int bytes_written_backlog_;
int bytes_written_;
int bytes_read_;
diff --git a/chromium/webkit/browser/fileapi/isolated_context.cc b/chromium/webkit/browser/fileapi/isolated_context.cc
index 74716104154..a187a05e0cd 100644
--- a/chromium/webkit/browser/fileapi/isolated_context.cc
+++ b/chromium/webkit/browser/fileapi/isolated_context.cc
@@ -41,21 +41,10 @@ base::FilePath::StringType GetRegisterNameForPath(const base::FilePath& path) {
}
bool IsSinglePathIsolatedFileSystem(FileSystemType type) {
- switch (type) {
- // As of writing dragged file system is the only filesystem
- // which could have multiple top-level paths.
- case kFileSystemTypeDragged:
- return false;
-
- case kFileSystemTypeUnknown:
- NOTREACHED();
- return true;
-
- default:
- return true;
- }
- NOTREACHED();
- return true;
+ DCHECK_NE(kFileSystemTypeUnknown, type);
+ // As of writing dragged file system is the only filesystem which could have
+ // multiple top-level paths.
+ return type != kFileSystemTypeDragged;
}
static base::LazyInstance<IsolatedContext>::Leaky g_isolated_context =
@@ -117,7 +106,9 @@ class IsolatedContext::Instance {
// IsolatedContext::RegisterFileSystemForPath() or
// IsolatedContext::RegisterFileSystemForVirtualPath().
// Most of isolated file system contexts should be of this type.
- Instance(FileSystemType type, const MountPointInfo& file_info,
+ Instance(FileSystemType type,
+ const std::string& filesystem_id,
+ const MountPointInfo& file_info,
PathType path_type);
// For a multi-paths isolated file system. As of writing only file system
@@ -128,6 +119,7 @@ class IsolatedContext::Instance {
~Instance();
FileSystemType type() const { return type_; }
+ const std::string& filesystem_id() const { return filesystem_id_; }
const MountPointInfo& file_info() const { return file_info_; }
const std::set<MountPointInfo>& files() const { return files_; }
int ref_counts() const { return ref_counts_; }
@@ -142,6 +134,7 @@ class IsolatedContext::Instance {
private:
const FileSystemType type_;
+ const std::string filesystem_id_;
// For single-path instance.
const MountPointInfo file_info_;
@@ -158,9 +151,11 @@ class IsolatedContext::Instance {
};
IsolatedContext::Instance::Instance(FileSystemType type,
+ const std::string& filesystem_id,
const MountPointInfo& file_info,
Instance::PathType path_type)
: type_(type),
+ filesystem_id_(filesystem_id),
file_info_(file_info),
path_type_(path_type),
ref_counts_(0) {
@@ -229,6 +224,7 @@ std::string IsolatedContext::RegisterDraggedFileSystem(
std::string IsolatedContext::RegisterFileSystemForPath(
FileSystemType type,
+ const std::string& filesystem_id,
const base::FilePath& path_in,
std::string* register_name) {
base::FilePath path(path_in.NormalizePathSeparators());
@@ -244,11 +240,12 @@ std::string IsolatedContext::RegisterFileSystemForPath(
}
base::AutoLock locker(lock_);
- std::string filesystem_id = GetNewFileSystemId();
- instance_map_[filesystem_id] = new Instance(type, MountPointInfo(name, path),
- Instance::PLATFORM_PATH);
- path_to_id_map_[path].insert(filesystem_id);
- return filesystem_id;
+ std::string new_id = GetNewFileSystemId();
+ instance_map_[new_id] = new Instance(type, filesystem_id,
+ MountPointInfo(name, path),
+ Instance::PLATFORM_PATH);
+ path_to_id_map_[path].insert(new_id);
+ return new_id;
}
std::string IsolatedContext::RegisterFileSystemForVirtualPath(
@@ -262,6 +259,7 @@ std::string IsolatedContext::RegisterFileSystemForVirtualPath(
std::string filesystem_id = GetNewFileSystemId();
instance_map_[filesystem_id] = new Instance(
type,
+ std::string(), // filesystem_id
MountPointInfo(register_name, cracked_path_prefix),
Instance::VIRTUAL_PATH);
path_to_id_map_[path].insert(filesystem_id);
@@ -292,6 +290,7 @@ bool IsolatedContext::CrackVirtualPath(
const base::FilePath& virtual_path,
std::string* id_or_name,
FileSystemType* type,
+ std::string* cracked_id,
base::FilePath* path,
FileSystemMountOption* mount_option) const {
DCHECK(id_or_name);
@@ -325,6 +324,8 @@ bool IsolatedContext::CrackVirtualPath(
const Instance* instance = found_instance->second;
if (type)
*type = instance->type();
+ if (cracked_id)
+ *cracked_id = instance->filesystem_id();
if (component_iter == components.end()) {
// The virtual root case.
@@ -431,18 +432,22 @@ FileSystemURL IsolatedContext::CrackFileSystemURL(
return FileSystemURL();
std::string mount_name;
+ std::string cracked_mount_name;
FileSystemType cracked_type;
base::FilePath cracked_path;
FileSystemMountOption cracked_mount_option;
if (!CrackVirtualPath(url.path(), &mount_name, &cracked_type,
- &cracked_path, &cracked_mount_option)) {
+ &cracked_mount_name, &cracked_path,
+ &cracked_mount_option)) {
return FileSystemURL();
}
return FileSystemURL(
url.origin(), url.mount_type(), url.virtual_path(),
!url.filesystem_id().empty() ? url.filesystem_id() : mount_name,
- cracked_type, cracked_path, mount_name, cracked_mount_option);
+ cracked_type, cracked_path,
+ cracked_mount_name.empty() ? mount_name : cracked_mount_name,
+ cracked_mount_option);
}
bool IsolatedContext::UnregisterFileSystem(const std::string& filesystem_id) {
diff --git a/chromium/webkit/browser/fileapi/isolated_context.h b/chromium/webkit/browser/fileapi/isolated_context.h
index 2a4ae47dd0d..213082d5c36 100644
--- a/chromium/webkit/browser/fileapi/isolated_context.h
+++ b/chromium/webkit/browser/fileapi/isolated_context.h
@@ -93,12 +93,13 @@ class WEBKIT_STORAGE_BROWSER_EXPORT IsolatedContext : public MountPoints {
std::string RegisterDraggedFileSystem(const FileInfoSet& files);
// Registers a new isolated filesystem for a given |path| of filesystem
- // |type| filesystem and returns a new filesystem ID.
+ // |type| filesystem with |filesystem_id| and returns a new filesystem ID.
// |path| must be an absolute path which has no parent references ('..').
// If |register_name| is non-null and has non-empty string the path is
// registered as the given |register_name|, otherwise it is populated
// with the name internally assigned to the path.
std::string RegisterFileSystemForPath(FileSystemType type,
+ const std::string& filesystem_id,
const base::FilePath& path,
std::string* register_name);
@@ -148,6 +149,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT IsolatedContext : public MountPoints {
const base::FilePath& virtual_path,
std::string* filesystem_id,
FileSystemType* type,
+ std::string* cracked_id,
base::FilePath* path,
FileSystemMountOption* mount_option) const OVERRIDE;
virtual FileSystemURL CrackURL(const GURL& url) const OVERRIDE;
diff --git a/chromium/webkit/browser/fileapi/isolated_context_unittest.cc b/chromium/webkit/browser/fileapi/isolated_context_unittest.cc
deleted file mode 100644
index 156181d6210..00000000000
--- a/chromium/webkit/browser/fileapi/isolated_context_unittest.cc
+++ /dev/null
@@ -1,345 +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 <string>
-
-#include "base/basictypes.h"
-#include "base/logging.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/fileapi/file_system_url.h"
-#include "webkit/browser/fileapi/isolated_context.h"
-
-#define FPL(x) FILE_PATH_LITERAL(x)
-
-#if defined(FILE_PATH_USES_DRIVE_LETTERS)
-#define DRIVE FPL("C:")
-#else
-#define DRIVE
-#endif
-
-namespace fileapi {
-
-typedef IsolatedContext::MountPointInfo FileInfo;
-
-namespace {
-
-const base::FilePath kTestPaths[] = {
- base::FilePath(DRIVE FPL("/a/b.txt")),
- base::FilePath(DRIVE FPL("/c/d/e")),
- base::FilePath(DRIVE FPL("/h/")),
- base::FilePath(DRIVE FPL("/")),
-#if defined(FILE_PATH_USES_WIN_SEPARATORS)
- base::FilePath(DRIVE FPL("\\foo\\bar")),
- base::FilePath(DRIVE FPL("\\")),
-#endif
- // For duplicated base name test.
- base::FilePath(DRIVE FPL("/")),
- base::FilePath(DRIVE FPL("/f/e")),
- base::FilePath(DRIVE FPL("/f/b.txt")),
-};
-
-} // namespace
-
-class IsolatedContextTest : public testing::Test {
- public:
- IsolatedContextTest() {
- for (size_t i = 0; i < arraysize(kTestPaths); ++i)
- fileset_.insert(kTestPaths[i].NormalizePathSeparators());
- }
-
- virtual void SetUp() {
- IsolatedContext::FileInfoSet files;
- for (size_t i = 0; i < arraysize(kTestPaths); ++i) {
- std::string name;
- ASSERT_TRUE(
- files.AddPath(kTestPaths[i].NormalizePathSeparators(), &name));
- names_.push_back(name);
- }
- id_ = IsolatedContext::GetInstance()->RegisterDraggedFileSystem(files);
- IsolatedContext::GetInstance()->AddReference(id_);
- ASSERT_FALSE(id_.empty());
- }
-
- virtual void TearDown() {
- IsolatedContext::GetInstance()->RemoveReference(id_);
- }
-
- IsolatedContext* isolated_context() const {
- return IsolatedContext::GetInstance();
- }
-
- protected:
- std::string id_;
- std::multiset<base::FilePath> fileset_;
- std::vector<std::string> names_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(IsolatedContextTest);
-};
-
-TEST_F(IsolatedContextTest, RegisterAndRevokeTest) {
- // See if the returned top-level entries match with what we registered.
- std::vector<FileInfo> toplevels;
- ASSERT_TRUE(isolated_context()->GetDraggedFileInfo(id_, &toplevels));
- ASSERT_EQ(fileset_.size(), toplevels.size());
- for (size_t i = 0; i < toplevels.size(); ++i) {
- ASSERT_TRUE(fileset_.find(toplevels[i].path) != fileset_.end());
- }
-
- // See if the name of each registered kTestPaths (that is what we
- // register in SetUp() by RegisterDraggedFileSystem) is properly cracked as
- // a valid virtual path in the isolated filesystem.
- for (size_t i = 0; i < arraysize(kTestPaths); ++i) {
- base::FilePath virtual_path = isolated_context()->CreateVirtualRootPath(id_)
- .AppendASCII(names_[i]);
- std::string cracked_id;
- base::FilePath cracked_path;
- FileSystemType cracked_type;
- FileSystemMountOption cracked_option;
- ASSERT_TRUE(isolated_context()->CrackVirtualPath(
- virtual_path, &cracked_id, &cracked_type, &cracked_path,
- &cracked_option));
- ASSERT_EQ(kTestPaths[i].NormalizePathSeparators().value(),
- cracked_path.value());
- ASSERT_EQ(id_, cracked_id);
- ASSERT_EQ(kFileSystemTypeDragged, cracked_type);
- }
-
- // Make sure GetRegisteredPath returns false for id_ since it is
- // registered for dragged files.
- base::FilePath path;
- ASSERT_FALSE(isolated_context()->GetRegisteredPath(id_, &path));
-
- // Deref the current one and registering a new one.
- isolated_context()->RemoveReference(id_);
-
- std::string id2 = isolated_context()->RegisterFileSystemForPath(
- kFileSystemTypeNativeLocal, base::FilePath(DRIVE FPL("/foo")), NULL);
-
- // Make sure the GetDraggedFileInfo returns false for both ones.
- ASSERT_FALSE(isolated_context()->GetDraggedFileInfo(id2, &toplevels));
- ASSERT_FALSE(isolated_context()->GetDraggedFileInfo(id_, &toplevels));
-
- // Make sure the GetRegisteredPath returns true only for the new one.
- ASSERT_FALSE(isolated_context()->GetRegisteredPath(id_, &path));
- ASSERT_TRUE(isolated_context()->GetRegisteredPath(id2, &path));
-
- // Try registering three more file systems for the same path as id2.
- std::string id3 = isolated_context()->RegisterFileSystemForPath(
- kFileSystemTypeNativeLocal, path, NULL);
- std::string id4 = isolated_context()->RegisterFileSystemForPath(
- kFileSystemTypeNativeLocal, path, NULL);
- std::string id5 = isolated_context()->RegisterFileSystemForPath(
- kFileSystemTypeNativeLocal, path, NULL);
-
- // Remove file system for id4.
- isolated_context()->AddReference(id4);
- isolated_context()->RemoveReference(id4);
-
- // Only id4 should become invalid now.
- ASSERT_TRUE(isolated_context()->GetRegisteredPath(id2, &path));
- ASSERT_TRUE(isolated_context()->GetRegisteredPath(id3, &path));
- ASSERT_FALSE(isolated_context()->GetRegisteredPath(id4, &path));
- ASSERT_TRUE(isolated_context()->GetRegisteredPath(id5, &path));
-
- // Revoke file system id5, after adding multiple references.
- isolated_context()->AddReference(id5);
- isolated_context()->AddReference(id5);
- isolated_context()->AddReference(id5);
- isolated_context()->RevokeFileSystem(id5);
-
- // No matter how many references we add id5 must be invalid now.
- ASSERT_TRUE(isolated_context()->GetRegisteredPath(id2, &path));
- ASSERT_TRUE(isolated_context()->GetRegisteredPath(id3, &path));
- ASSERT_FALSE(isolated_context()->GetRegisteredPath(id4, &path));
- ASSERT_FALSE(isolated_context()->GetRegisteredPath(id5, &path));
-
- // Revoke the file systems by path.
- isolated_context()->RevokeFileSystemByPath(path);
-
- // Now all the file systems associated to the path must be invalid.
- ASSERT_FALSE(isolated_context()->GetRegisteredPath(id2, &path));
- ASSERT_FALSE(isolated_context()->GetRegisteredPath(id3, &path));
- ASSERT_FALSE(isolated_context()->GetRegisteredPath(id4, &path));
- ASSERT_FALSE(isolated_context()->GetRegisteredPath(id5, &path));
-}
-
-TEST_F(IsolatedContextTest, CrackWithRelativePaths) {
- const struct {
- base::FilePath::StringType path;
- bool valid;
- } relatives[] = {
- { FPL("foo"), true },
- { FPL("foo/bar"), true },
- { FPL(".."), false },
- { FPL("foo/.."), false },
- { FPL("foo/../bar"), false },
-#if defined(FILE_PATH_USES_WIN_SEPARATORS)
-# define SHOULD_FAIL_WITH_WIN_SEPARATORS false
-#else
-# define SHOULD_FAIL_WITH_WIN_SEPARATORS true
-#endif
- { FPL("foo\\..\\baz"), SHOULD_FAIL_WITH_WIN_SEPARATORS },
- { FPL("foo/..\\baz"), SHOULD_FAIL_WITH_WIN_SEPARATORS },
- };
-
- for (size_t i = 0; i < arraysize(kTestPaths); ++i) {
- for (size_t j = 0; j < ARRAYSIZE_UNSAFE(relatives); ++j) {
- SCOPED_TRACE(testing::Message() << "Testing "
- << kTestPaths[i].value() << " " << relatives[j].path);
- base::FilePath virtual_path =
- isolated_context()->CreateVirtualRootPath(id_).AppendASCII(
- names_[i]).Append(relatives[j].path);
- std::string cracked_id;
- base::FilePath cracked_path;
- FileSystemType cracked_type;
- FileSystemMountOption cracked_option;
- if (!relatives[j].valid) {
- ASSERT_FALSE(isolated_context()->CrackVirtualPath(
- virtual_path, &cracked_id, &cracked_type, &cracked_path,
- &cracked_option));
- continue;
- }
- ASSERT_TRUE(isolated_context()->CrackVirtualPath(
- virtual_path, &cracked_id, &cracked_type, &cracked_path,
- &cracked_option));
- ASSERT_EQ(kTestPaths[i].Append(relatives[j].path)
- .NormalizePathSeparators().value(),
- cracked_path.value());
- ASSERT_EQ(id_, cracked_id);
- ASSERT_EQ(kFileSystemTypeDragged, cracked_type);
- }
- }
-}
-
-TEST_F(IsolatedContextTest, CrackURLWithRelativePaths) {
- const struct {
- base::FilePath::StringType path;
- bool valid;
- } relatives[] = {
- { FPL("foo"), true },
- { FPL("foo/bar"), true },
- { FPL(".."), false },
- { FPL("foo/.."), false },
- { FPL("foo/../bar"), false },
-#if defined(FILE_PATH_USES_WIN_SEPARATORS)
-# define SHOULD_FAIL_WITH_WIN_SEPARATORS false
-#else
-# define SHOULD_FAIL_WITH_WIN_SEPARATORS true
-#endif
- { FPL("foo\\..\\baz"), SHOULD_FAIL_WITH_WIN_SEPARATORS },
- { FPL("foo/..\\baz"), SHOULD_FAIL_WITH_WIN_SEPARATORS },
- };
-
- for (size_t i = 0; i < arraysize(kTestPaths); ++i) {
- for (size_t j = 0; j < ARRAYSIZE_UNSAFE(relatives); ++j) {
- SCOPED_TRACE(testing::Message() << "Testing "
- << kTestPaths[i].value() << " " << relatives[j].path);
- base::FilePath virtual_path =
- isolated_context()->CreateVirtualRootPath(id_).AppendASCII(
- names_[i]).Append(relatives[j].path);
-
- FileSystemURL cracked = isolated_context()->CreateCrackedFileSystemURL(
- GURL("http://chromium.org"), kFileSystemTypeIsolated, virtual_path);
-
- ASSERT_EQ(relatives[j].valid, cracked.is_valid());
-
- if (!relatives[j].valid)
- continue;
- ASSERT_EQ(GURL("http://chromium.org"), cracked.origin());
- ASSERT_EQ(kTestPaths[i].Append(relatives[j].path)
- .NormalizePathSeparators().value(),
- cracked.path().value());
- ASSERT_EQ(virtual_path.NormalizePathSeparators(), cracked.virtual_path());
- ASSERT_EQ(id_, cracked.filesystem_id());
- ASSERT_EQ(kFileSystemTypeDragged, cracked.type());
- ASSERT_EQ(kFileSystemTypeIsolated, cracked.mount_type());
- }
- }
-}
-
-TEST_F(IsolatedContextTest, TestWithVirtualRoot) {
- std::string cracked_id;
- base::FilePath cracked_path;
- FileSystemMountOption cracked_option;
-
- // Trying to crack virtual root "/" returns true but with empty cracked path
- // as "/" of the isolated filesystem is a pure virtual directory
- // that has no corresponding platform directory.
- base::FilePath virtual_path = isolated_context()->CreateVirtualRootPath(id_);
- ASSERT_TRUE(isolated_context()->CrackVirtualPath(
- virtual_path, &cracked_id, NULL, &cracked_path, &cracked_option));
- ASSERT_EQ(FPL(""), cracked_path.value());
- ASSERT_EQ(id_, cracked_id);
-
- // Trying to crack "/foo" should fail (because "foo" is not the one
- // included in the kTestPaths).
- virtual_path = isolated_context()->CreateVirtualRootPath(
- id_).AppendASCII("foo");
- ASSERT_FALSE(isolated_context()->CrackVirtualPath(
- virtual_path, &cracked_id, NULL, &cracked_path, &cracked_option));
-}
-
-TEST_F(IsolatedContextTest, CanHandleURL) {
- const GURL test_origin("http://chromium.org");
- const base::FilePath test_path(FPL("/mount"));
-
- // Should handle isolated file system.
- EXPECT_TRUE(isolated_context()->HandlesFileSystemMountType(
- fileapi::kFileSystemTypeIsolated));
-
- // Shouldn't handle the rest.
- EXPECT_FALSE(isolated_context()->HandlesFileSystemMountType(
- fileapi::kFileSystemTypeExternal));
- EXPECT_FALSE(isolated_context()->HandlesFileSystemMountType(
- fileapi::kFileSystemTypeTemporary));
- EXPECT_FALSE(isolated_context()->HandlesFileSystemMountType(
- fileapi::kFileSystemTypePersistent));
- EXPECT_FALSE(isolated_context()->HandlesFileSystemMountType(
- fileapi::kFileSystemTypeTest));
- // Not even if it's isolated subtype.
- EXPECT_FALSE(isolated_context()->HandlesFileSystemMountType(
- fileapi::kFileSystemTypeNativeLocal));
- EXPECT_FALSE(isolated_context()->HandlesFileSystemMountType(
- fileapi::kFileSystemTypeDragged));
- EXPECT_FALSE(isolated_context()->HandlesFileSystemMountType(
- fileapi::kFileSystemTypeNativeMedia));
- EXPECT_FALSE(isolated_context()->HandlesFileSystemMountType(
- fileapi::kFileSystemTypeDeviceMedia));
-}
-
-TEST_F(IsolatedContextTest, VirtualFileSystemTests) {
- // Should be able to register empty and non-absolute paths
- std::string empty_fsid = isolated_context()->RegisterFileSystemForVirtualPath(
- fileapi::kFileSystemTypeIsolated, "_", base::FilePath());
- std::string relative_fsid =
- isolated_context()->RegisterFileSystemForVirtualPath(
- fileapi::kFileSystemTypeIsolated, "_",
- base::FilePath(FPL("relpath")));
- ASSERT_FALSE(empty_fsid.empty());
- ASSERT_FALSE(relative_fsid.empty());
-
- // Make sure that filesystem root is not prepended to cracked virtual paths.
- base::FilePath database_root = base::FilePath(DRIVE FPL("/database_path"));
- std::string database_fsid =
- isolated_context()->RegisterFileSystemForVirtualPath(
- fileapi::kFileSystemTypeIsolated, "_", database_root);
-
- base::FilePath test_virtual_path =
- base::FilePath().AppendASCII("virtualdir").AppendASCII("virtualfile.txt");
-
- base::FilePath whole_virtual_path =
- isolated_context()->CreateVirtualRootPath(database_fsid)
- .AppendASCII("_").Append(test_virtual_path);
-
- std::string cracked_id;
- base::FilePath cracked_path;
- FileSystemMountOption cracked_option;
- ASSERT_TRUE(isolated_context()->CrackVirtualPath(
- whole_virtual_path, &cracked_id, NULL, &cracked_path, &cracked_option));
- ASSERT_EQ(database_fsid, cracked_id);
- ASSERT_EQ(test_virtual_path, cracked_path);
-}
-
-} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/isolated_file_system_backend.cc b/chromium/webkit/browser/fileapi/isolated_file_system_backend.cc
index f83ae15d8f3..33c22cb77e7 100644
--- a/chromium/webkit/browser/fileapi/isolated_file_system_backend.cc
+++ b/chromium/webkit/browser/fileapi/isolated_file_system_backend.cc
@@ -11,7 +11,6 @@
#include "base/files/file_util_proxy.h"
#include "base/logging.h"
#include "base/message_loop/message_loop_proxy.h"
-#include "base/platform_file.h"
#include "base/sequenced_task_runner.h"
#include "webkit/browser/blob/file_stream_reader.h"
#include "webkit/browser/fileapi/async_file_util_adapter.h"
@@ -57,18 +56,17 @@ bool IsolatedFileSystemBackend::CanHandleType(FileSystemType type) const {
void IsolatedFileSystemBackend::Initialize(FileSystemContext* context) {
}
-void IsolatedFileSystemBackend::OpenFileSystem(
- const GURL& origin_url,
- FileSystemType type,
+void IsolatedFileSystemBackend::ResolveURL(
+ const FileSystemURL& url,
OpenFileSystemMode mode,
const OpenFileSystemCallback& callback) {
- // We never allow opening a new isolated FileSystem via usual OpenFileSystem.
+ // We never allow opening a new isolated FileSystem via usual ResolveURL.
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
base::Bind(callback,
- GetFileSystemRootURI(origin_url, type),
- GetFileSystemName(origin_url, type),
- base::PLATFORM_FILE_ERROR_SECURITY));
+ GURL(),
+ std::string(),
+ base::File::FILE_ERROR_SECURITY));
}
AsyncFileUtil* IsolatedFileSystemBackend::GetAsyncFileUtil(
@@ -88,20 +86,25 @@ AsyncFileUtil* IsolatedFileSystemBackend::GetAsyncFileUtil(
CopyOrMoveFileValidatorFactory*
IsolatedFileSystemBackend::GetCopyOrMoveFileValidatorFactory(
- FileSystemType type, base::PlatformFileError* error_code) {
+ FileSystemType type, base::File::Error* error_code) {
DCHECK(error_code);
- *error_code = base::PLATFORM_FILE_OK;
+ *error_code = base::File::FILE_OK;
return NULL;
}
FileSystemOperation* IsolatedFileSystemBackend::CreateFileSystemOperation(
const FileSystemURL& url,
FileSystemContext* context,
- base::PlatformFileError* error_code) const {
+ base::File::Error* error_code) const {
return FileSystemOperation::Create(
url, context, make_scoped_ptr(new FileSystemOperationContext(context)));
}
+bool IsolatedFileSystemBackend::SupportsStreaming(
+ const fileapi::FileSystemURL& url) const {
+ return false;
+}
+
scoped_ptr<webkit_blob::FileStreamReader>
IsolatedFileSystemBackend::CreateFileStreamReader(
const FileSystemURL& url,
@@ -118,8 +121,12 @@ scoped_ptr<FileStreamWriter> IsolatedFileSystemBackend::CreateFileStreamWriter(
const FileSystemURL& url,
int64 offset,
FileSystemContext* context) const {
- return scoped_ptr<FileStreamWriter>(FileStreamWriter::CreateForLocalFile(
- context->default_file_task_runner(), url.path(), offset));
+ return scoped_ptr<FileStreamWriter>(
+ FileStreamWriter::CreateForLocalFile(
+ context->default_file_task_runner(),
+ url.path(),
+ offset,
+ FileStreamWriter::OPEN_EXISTING_FILE));
}
FileSystemQuotaUtil* IsolatedFileSystemBackend::GetQuotaUtil() {
diff --git a/chromium/webkit/browser/fileapi/isolated_file_system_backend.h b/chromium/webkit/browser/fileapi/isolated_file_system_backend.h
index aa038442dc6..1c2edfddd27 100644
--- a/chromium/webkit/browser/fileapi/isolated_file_system_backend.h
+++ b/chromium/webkit/browser/fileapi/isolated_file_system_backend.h
@@ -20,19 +20,18 @@ class IsolatedFileSystemBackend : public FileSystemBackend {
// FileSystemBackend implementation.
virtual bool CanHandleType(FileSystemType type) const OVERRIDE;
virtual void Initialize(FileSystemContext* context) OVERRIDE;
- virtual void OpenFileSystem(
- const GURL& origin_url,
- FileSystemType type,
- OpenFileSystemMode mode,
- const OpenFileSystemCallback& callback) OVERRIDE;
+ virtual void ResolveURL(const FileSystemURL& url,
+ OpenFileSystemMode mode,
+ const OpenFileSystemCallback& callback) OVERRIDE;
virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE;
virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory(
FileSystemType type,
- base::PlatformFileError* error_code) OVERRIDE;
+ base::File::Error* error_code) OVERRIDE;
virtual FileSystemOperation* CreateFileSystemOperation(
const FileSystemURL& url,
FileSystemContext* context,
- base::PlatformFileError* error_code) const OVERRIDE;
+ base::File::Error* error_code) const OVERRIDE;
+ virtual bool SupportsStreaming(const FileSystemURL& url) const OVERRIDE;
virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader(
const FileSystemURL& url,
int64 offset,
diff --git a/chromium/webkit/browser/fileapi/local_file_stream_writer.cc b/chromium/webkit/browser/fileapi/local_file_stream_writer.cc
index 1796de5f4e8..22864c0ef12 100644
--- a/chromium/webkit/browser/fileapi/local_file_stream_writer.cc
+++ b/chromium/webkit/browser/fileapi/local_file_stream_writer.cc
@@ -14,17 +14,22 @@ namespace fileapi {
namespace {
-const int kOpenFlagsForWrite = base::PLATFORM_FILE_OPEN |
- base::PLATFORM_FILE_WRITE |
- base::PLATFORM_FILE_ASYNC;
+const int kOpenFlagsForWrite = base::File::FLAG_OPEN |
+ base::File::FLAG_WRITE |
+ base::File::FLAG_ASYNC;
+const int kCreateFlagsForWrite = base::File::FLAG_CREATE |
+ base::File::FLAG_WRITE |
+ base::File::FLAG_ASYNC;
} // namespace
FileStreamWriter* FileStreamWriter::CreateForLocalFile(
base::TaskRunner* task_runner,
const base::FilePath& file_path,
- int64 initial_offset) {
- return new LocalFileStreamWriter(task_runner, file_path, initial_offset);
+ int64 initial_offset,
+ OpenOrCreate open_or_create) {
+ return new LocalFileStreamWriter(
+ task_runner, file_path, initial_offset, open_or_create);
}
LocalFileStreamWriter::~LocalFileStreamWriter() {
@@ -81,8 +86,10 @@ int LocalFileStreamWriter::Flush(const net::CompletionCallback& callback) {
LocalFileStreamWriter::LocalFileStreamWriter(base::TaskRunner* task_runner,
const base::FilePath& file_path,
- int64 initial_offset)
+ int64 initial_offset,
+ OpenOrCreate open_or_create)
: file_path_(file_path),
+ open_or_create_(open_or_create),
initial_offset_(initial_offset),
task_runner_(task_runner),
has_pending_operation_(false),
@@ -94,10 +101,20 @@ int LocalFileStreamWriter::InitiateOpen(
DCHECK(has_pending_operation_);
DCHECK(!stream_impl_.get());
- stream_impl_.reset(new net::FileStream(NULL, task_runner_));
+ stream_impl_.reset(new net::FileStream(task_runner_));
+
+ int open_flags = 0;
+ switch (open_or_create_) {
+ case OPEN_EXISTING_FILE:
+ open_flags = kOpenFlagsForWrite;
+ break;
+ case CREATE_NEW_FILE:
+ open_flags = kCreateFlagsForWrite;
+ break;
+ }
return stream_impl_->Open(file_path_,
- kOpenFlagsForWrite,
+ open_flags,
base::Bind(&LocalFileStreamWriter::DidOpen,
weak_factory_.GetWeakPtr(),
error_callback,
diff --git a/chromium/webkit/browser/fileapi/local_file_stream_writer.h b/chromium/webkit/browser/fileapi/local_file_stream_writer.h
index dce428a56bd..47bea5d410b 100644
--- a/chromium/webkit/browser/fileapi/local_file_stream_writer.h
+++ b/chromium/webkit/browser/fileapi/local_file_stream_writer.h
@@ -13,11 +13,14 @@
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "base/platform_file.h"
#include "base/task_runner.h"
#include "webkit/browser/fileapi/file_stream_writer.h"
#include "webkit/browser/webkit_storage_browser_export.h"
+namespace content {
+class LocalFileStreamWriterTest;
+}
+
namespace net {
class FileStream;
}
@@ -37,11 +40,12 @@ class WEBKIT_STORAGE_BROWSER_EXPORT LocalFileStreamWriter
virtual int Flush(const net::CompletionCallback& callback) OVERRIDE;
private:
+ friend class content::LocalFileStreamWriterTest;
friend class FileStreamWriter;
- friend class LocalFileStreamWriterTest;
LocalFileStreamWriter(base::TaskRunner* task_runner,
const base::FilePath& file_path,
- int64 initial_offset);
+ int64 initial_offset,
+ OpenOrCreate open_or_create);
// Opens |file_path_| and if it succeeds, proceeds to InitiateSeek().
// If failed, the error code is returned by calling |error_callback|.
@@ -78,6 +82,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT LocalFileStreamWriter
// Initialization parameters.
const base::FilePath file_path_;
+ OpenOrCreate open_or_create_;
const int64 initial_offset_;
scoped_refptr<base::TaskRunner> task_runner_;
diff --git a/chromium/webkit/browser/fileapi/local_file_stream_writer_unittest.cc b/chromium/webkit/browser/fileapi/local_file_stream_writer_unittest.cc
deleted file mode 100644
index 96bccf64b26..00000000000
--- a/chromium/webkit/browser/fileapi/local_file_stream_writer_unittest.cc
+++ /dev/null
@@ -1,176 +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 "webkit/browser/fileapi/local_file_stream_writer.h"
-
-#include <string>
-
-#include "base/callback.h"
-#include "base/file_util.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "base/run_loop.h"
-#include "base/threading/thread.h"
-#include "net/base/io_buffer.h"
-#include "net/base/test_completion_callback.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace fileapi {
-
-class LocalFileStreamWriterTest : public testing::Test {
- public:
- LocalFileStreamWriterTest()
- : file_thread_("FileUtilProxyTestFileThread") {}
-
- virtual void SetUp() OVERRIDE {
- ASSERT_TRUE(file_thread_.Start());
- ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
- }
-
- virtual void TearDown() OVERRIDE {
- // Give another chance for deleted streams to perform Close.
- base::RunLoop().RunUntilIdle();
- file_thread_.Stop();
- base::RunLoop().RunUntilIdle();
- }
-
- protected:
- base::FilePath Path(const std::string& name) {
- return temp_dir_.path().AppendASCII(name);
- }
-
- int WriteStringToWriter(LocalFileStreamWriter* writer,
- const std::string& data) {
- scoped_refptr<net::StringIOBuffer> buffer(new net::StringIOBuffer(data));
- scoped_refptr<net::DrainableIOBuffer> drainable(
- new net::DrainableIOBuffer(buffer.get(), buffer->size()));
-
- while (drainable->BytesRemaining() > 0) {
- net::TestCompletionCallback callback;
- int result = writer->Write(
- drainable.get(), drainable->BytesRemaining(), callback.callback());
- if (result == net::ERR_IO_PENDING)
- result = callback.WaitForResult();
- if (result <= 0)
- return result;
- drainable->DidConsume(result);
- }
- return net::OK;
- }
-
- std::string GetFileContent(const base::FilePath& path) {
- std::string content;
- base::ReadFileToString(path, &content);
- return content;
- }
-
- base::FilePath CreateFileWithContent(const std::string& name,
- const std::string& data) {
- base::FilePath path = Path(name);
- file_util::WriteFile(path, data.c_str(), data.size());
- return path;
- }
-
- base::MessageLoopProxy* file_task_runner() const {
- return file_thread_.message_loop_proxy().get();
- }
-
- LocalFileStreamWriter* CreateWriter(const base::FilePath& path,
- int64 offset) {
- return new LocalFileStreamWriter(file_task_runner(), path, offset);
- }
-
- private:
- base::MessageLoopForIO message_loop_;
- base::Thread file_thread_;
- base::ScopedTempDir temp_dir_;
-};
-
-void NeverCalled(int unused) {
- ADD_FAILURE();
-}
-
-TEST_F(LocalFileStreamWriterTest, Write) {
- base::FilePath path = CreateFileWithContent("file_a", std::string());
- scoped_ptr<LocalFileStreamWriter> writer(CreateWriter(path, 0));
- EXPECT_EQ(net::OK, WriteStringToWriter(writer.get(), "foo"));
- EXPECT_EQ(net::OK, WriteStringToWriter(writer.get(), "bar"));
- writer.reset();
- base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(base::PathExists(path));
- EXPECT_EQ("foobar", GetFileContent(path));
-}
-
-TEST_F(LocalFileStreamWriterTest, WriteMiddle) {
- base::FilePath path = CreateFileWithContent("file_a", "foobar");
- scoped_ptr<LocalFileStreamWriter> writer(CreateWriter(path, 2));
- EXPECT_EQ(net::OK, WriteStringToWriter(writer.get(), "xxx"));
- writer.reset();
- base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(base::PathExists(path));
- EXPECT_EQ("foxxxr", GetFileContent(path));
-}
-
-TEST_F(LocalFileStreamWriterTest, WriteEnd) {
- base::FilePath path = CreateFileWithContent("file_a", "foobar");
- scoped_ptr<LocalFileStreamWriter> writer(CreateWriter(path, 6));
- EXPECT_EQ(net::OK, WriteStringToWriter(writer.get(), "xxx"));
- writer.reset();
- base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(base::PathExists(path));
- EXPECT_EQ("foobarxxx", GetFileContent(path));
-}
-
-TEST_F(LocalFileStreamWriterTest, WriteFailForNonexistingFile) {
- base::FilePath path = Path("file_a");
- ASSERT_FALSE(base::PathExists(path));
- scoped_ptr<LocalFileStreamWriter> writer(CreateWriter(path, 0));
- EXPECT_EQ(net::ERR_FILE_NOT_FOUND, WriteStringToWriter(writer.get(), "foo"));
- writer.reset();
- base::RunLoop().RunUntilIdle();
- EXPECT_FALSE(base::PathExists(path));
-}
-
-TEST_F(LocalFileStreamWriterTest, CancelBeforeOperation) {
- base::FilePath path = Path("file_a");
- scoped_ptr<LocalFileStreamWriter> writer(CreateWriter(path, 0));
- // Cancel immediately fails when there's no in-flight operation.
- int cancel_result = writer->Cancel(base::Bind(&NeverCalled));
- EXPECT_EQ(net::ERR_UNEXPECTED, cancel_result);
-}
-
-TEST_F(LocalFileStreamWriterTest, CancelAfterFinishedOperation) {
- base::FilePath path = CreateFileWithContent("file_a", std::string());
- scoped_ptr<LocalFileStreamWriter> writer(CreateWriter(path, 0));
- EXPECT_EQ(net::OK, WriteStringToWriter(writer.get(), "foo"));
-
- // Cancel immediately fails when there's no in-flight operation.
- int cancel_result = writer->Cancel(base::Bind(&NeverCalled));
- EXPECT_EQ(net::ERR_UNEXPECTED, cancel_result);
-
- writer.reset();
- base::RunLoop().RunUntilIdle();
- // Write operation is already completed.
- EXPECT_TRUE(base::PathExists(path));
- EXPECT_EQ("foo", GetFileContent(path));
-}
-
-TEST_F(LocalFileStreamWriterTest, CancelWrite) {
- base::FilePath path = CreateFileWithContent("file_a", "foobar");
- scoped_ptr<LocalFileStreamWriter> writer(CreateWriter(path, 0));
-
- scoped_refptr<net::StringIOBuffer> buffer(new net::StringIOBuffer("xxx"));
- int result =
- writer->Write(buffer.get(), buffer->size(), base::Bind(&NeverCalled));
- ASSERT_EQ(net::ERR_IO_PENDING, result);
-
- net::TestCompletionCallback callback;
- writer->Cancel(callback.callback());
- int cancel_result = callback.WaitForResult();
- EXPECT_EQ(net::OK, cancel_result);
-}
-
-} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/local_file_util.cc b/chromium/webkit/browser/fileapi/local_file_util.cc
index 8f47859a187..3b823aa99f6 100644
--- a/chromium/webkit/browser/fileapi/local_file_util.cc
+++ b/chromium/webkit/browser/fileapi/local_file_util.cc
@@ -22,8 +22,6 @@ AsyncFileUtil* AsyncFileUtil::CreateForLocalFileSystem() {
return new AsyncFileUtilAdapter(new LocalFileUtil());
}
-using base::PlatformFileError;
-
class LocalFileEnumerator : public FileSystemFileUtil::AbstractFileEnumerator {
public:
LocalFileEnumerator(const base::FilePath& platform_root_path,
@@ -78,64 +76,58 @@ LocalFileUtil::LocalFileUtil() {}
LocalFileUtil::~LocalFileUtil() {}
-PlatformFileError LocalFileUtil::CreateOrOpen(
+base::File LocalFileUtil::CreateOrOpen(
FileSystemOperationContext* context,
- const FileSystemURL& url, int file_flags,
- base::PlatformFile* file_handle, bool* created) {
- *created = false;
+ const FileSystemURL& url, int file_flags) {
base::FilePath file_path;
- PlatformFileError error = GetLocalFilePath(context, url, &file_path);
- if (error != base::PLATFORM_FILE_OK)
- return error;
+ base::File::Error error = GetLocalFilePath(context, url, &file_path);
+ if (error != base::File::FILE_OK)
+ return base::File(error);
// Disallow opening files in symlinked paths.
if (base::IsLink(file_path))
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
- return NativeFileUtil::CreateOrOpen(
- file_path, file_flags, file_handle, created);
-}
+ return base::File(base::File::FILE_ERROR_NOT_FOUND);
-PlatformFileError LocalFileUtil::Close(FileSystemOperationContext* context,
- base::PlatformFile file) {
- return NativeFileUtil::Close(file);
+ return NativeFileUtil::CreateOrOpen(file_path, file_flags);
}
-PlatformFileError LocalFileUtil::EnsureFileExists(
+base::File::Error LocalFileUtil::EnsureFileExists(
FileSystemOperationContext* context,
const FileSystemURL& url,
bool* created) {
base::FilePath file_path;
- PlatformFileError error = GetLocalFilePath(context, url, &file_path);
- if (error != base::PLATFORM_FILE_OK)
+ base::File::Error error = GetLocalFilePath(context, url, &file_path);
+ if (error != base::File::FILE_OK)
return error;
return NativeFileUtil::EnsureFileExists(file_path, created);
}
-PlatformFileError LocalFileUtil::CreateDirectory(
+base::File::Error LocalFileUtil::CreateDirectory(
FileSystemOperationContext* context,
const FileSystemURL& url,
bool exclusive,
bool recursive) {
base::FilePath file_path;
- PlatformFileError error = GetLocalFilePath(context, url, &file_path);
- if (error != base::PLATFORM_FILE_OK)
+ base::File::Error error = GetLocalFilePath(context, url, &file_path);
+ if (error != base::File::FILE_OK)
return error;
return NativeFileUtil::CreateDirectory(file_path, exclusive, recursive);
}
-PlatformFileError LocalFileUtil::GetFileInfo(
+base::File::Error LocalFileUtil::GetFileInfo(
FileSystemOperationContext* context,
const FileSystemURL& url,
- base::PlatformFileInfo* file_info,
+ base::File::Info* file_info,
base::FilePath* platform_file_path) {
base::FilePath file_path;
- PlatformFileError error = GetLocalFilePath(context, url, &file_path);
- if (error != base::PLATFORM_FILE_OK)
+ base::File::Error error = GetLocalFilePath(context, url, &file_path);
+ if (error != base::File::FILE_OK)
return error;
// We should not follow symbolic links in sandboxed file system.
if (base::IsLink(file_path))
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
+
error = NativeFileUtil::GetFileInfo(file_path, file_info);
- if (error == base::PLATFORM_FILE_OK)
+ if (error == base::File::FILE_OK)
*platform_file_path = file_path;
return error;
}
@@ -146,7 +138,7 @@ scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> LocalFileUtil::
const FileSystemURL& root_url) {
base::FilePath file_path;
if (GetLocalFilePath(context, root_url, &file_path) !=
- base::PLATFORM_FILE_OK) {
+ base::File::FILE_OK) {
return make_scoped_ptr(new EmptyFileEnumerator)
.PassAs<FileSystemFileUtil::AbstractFileEnumerator>();
}
@@ -156,7 +148,7 @@ scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> LocalFileUtil::
.PassAs<FileSystemFileUtil::AbstractFileEnumerator>();
}
-PlatformFileError LocalFileUtil::GetLocalFilePath(
+base::File::Error LocalFileUtil::GetLocalFilePath(
FileSystemOperationContext* context,
const FileSystemURL& url,
base::FilePath* local_file_path) {
@@ -164,49 +156,49 @@ PlatformFileError LocalFileUtil::GetLocalFilePath(
DCHECK(url.is_valid());
if (url.path().empty()) {
// Root direcory case, which should not be accessed.
- return base::PLATFORM_FILE_ERROR_ACCESS_DENIED;
+ return base::File::FILE_ERROR_ACCESS_DENIED;
}
*local_file_path = url.path();
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_OK;
}
-PlatformFileError LocalFileUtil::Touch(
+base::File::Error LocalFileUtil::Touch(
FileSystemOperationContext* context,
const FileSystemURL& url,
const base::Time& last_access_time,
const base::Time& last_modified_time) {
base::FilePath file_path;
- PlatformFileError error = GetLocalFilePath(context, url, &file_path);
- if (error != base::PLATFORM_FILE_OK)
+ base::File::Error error = GetLocalFilePath(context, url, &file_path);
+ if (error != base::File::FILE_OK)
return error;
return NativeFileUtil::Touch(file_path, last_access_time, last_modified_time);
}
-PlatformFileError LocalFileUtil::Truncate(
+base::File::Error LocalFileUtil::Truncate(
FileSystemOperationContext* context,
const FileSystemURL& url,
int64 length) {
base::FilePath file_path;
- PlatformFileError error = GetLocalFilePath(context, url, &file_path);
- if (error != base::PLATFORM_FILE_OK)
+ base::File::Error error = GetLocalFilePath(context, url, &file_path);
+ if (error != base::File::FILE_OK)
return error;
return NativeFileUtil::Truncate(file_path, length);
}
-PlatformFileError LocalFileUtil::CopyOrMoveFile(
+base::File::Error LocalFileUtil::CopyOrMoveFile(
FileSystemOperationContext* context,
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
CopyOrMoveOption option,
bool copy) {
base::FilePath src_file_path;
- PlatformFileError error = GetLocalFilePath(context, src_url, &src_file_path);
- if (error != base::PLATFORM_FILE_OK)
+ base::File::Error error = GetLocalFilePath(context, src_url, &src_file_path);
+ if (error != base::File::FILE_OK)
return error;
base::FilePath dest_file_path;
error = GetLocalFilePath(context, dest_url, &dest_file_path);
- if (error != base::PLATFORM_FILE_OK)
+ if (error != base::File::FILE_OK)
return error;
return NativeFileUtil::CopyOrMoveFile(
@@ -214,17 +206,17 @@ PlatformFileError LocalFileUtil::CopyOrMoveFile(
fileapi::NativeFileUtil::CopyOrMoveModeForDestination(dest_url, copy));
}
-PlatformFileError LocalFileUtil::CopyInForeignFile(
+base::File::Error LocalFileUtil::CopyInForeignFile(
FileSystemOperationContext* context,
const base::FilePath& src_file_path,
const FileSystemURL& dest_url) {
if (src_file_path.empty())
- return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
+ return base::File::FILE_ERROR_INVALID_OPERATION;
base::FilePath dest_file_path;
- PlatformFileError error =
+ base::File::Error error =
GetLocalFilePath(context, dest_url, &dest_file_path);
- if (error != base::PLATFORM_FILE_OK)
+ if (error != base::File::FILE_OK)
return error;
return NativeFileUtil::CopyOrMoveFile(
src_file_path, dest_file_path, FileSystemOperation::OPTION_NONE,
@@ -232,22 +224,22 @@ PlatformFileError LocalFileUtil::CopyInForeignFile(
true /* copy */));
}
-PlatformFileError LocalFileUtil::DeleteFile(
+base::File::Error LocalFileUtil::DeleteFile(
FileSystemOperationContext* context,
const FileSystemURL& url) {
base::FilePath file_path;
- PlatformFileError error = GetLocalFilePath(context, url, &file_path);
- if (error != base::PLATFORM_FILE_OK)
+ base::File::Error error = GetLocalFilePath(context, url, &file_path);
+ if (error != base::File::FILE_OK)
return error;
return NativeFileUtil::DeleteFile(file_path);
}
-PlatformFileError LocalFileUtil::DeleteDirectory(
+base::File::Error LocalFileUtil::DeleteDirectory(
FileSystemOperationContext* context,
const FileSystemURL& url) {
base::FilePath file_path;
- PlatformFileError error = GetLocalFilePath(context, url, &file_path);
- if (error != base::PLATFORM_FILE_OK)
+ base::File::Error error = GetLocalFilePath(context, url, &file_path);
+ if (error != base::File::FILE_OK)
return error;
return NativeFileUtil::DeleteDirectory(file_path);
}
@@ -255,14 +247,14 @@ PlatformFileError LocalFileUtil::DeleteDirectory(
webkit_blob::ScopedFile LocalFileUtil::CreateSnapshotFile(
FileSystemOperationContext* context,
const FileSystemURL& url,
- base::PlatformFileError* error,
- base::PlatformFileInfo* file_info,
+ base::File::Error* error,
+ base::File::Info* file_info,
base::FilePath* platform_path) {
DCHECK(file_info);
// We're just returning the local file information.
*error = GetFileInfo(context, url, file_info, platform_path);
- if (*error == base::PLATFORM_FILE_OK && file_info->is_directory)
- *error = base::PLATFORM_FILE_ERROR_NOT_A_FILE;
+ if (*error == base::File::FILE_OK && file_info->is_directory)
+ *error = base::File::FILE_ERROR_NOT_A_FILE;
return webkit_blob::ScopedFile();
}
diff --git a/chromium/webkit/browser/fileapi/local_file_util.h b/chromium/webkit/browser/fileapi/local_file_util.h
index 21efc72ffe4..18199ad6f56 100644
--- a/chromium/webkit/browser/fileapi/local_file_util.h
+++ b/chromium/webkit/browser/fileapi/local_file_util.h
@@ -8,7 +8,6 @@
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
-#include "base/platform_file.h"
#include "webkit/browser/fileapi/file_system_file_util.h"
#include "webkit/browser/webkit_storage_browser_export.h"
@@ -30,65 +29,60 @@ class WEBKIT_STORAGE_BROWSER_EXPORT LocalFileUtil
LocalFileUtil();
virtual ~LocalFileUtil();
- virtual base::PlatformFileError CreateOrOpen(
+ virtual base::File CreateOrOpen(
FileSystemOperationContext* context,
const FileSystemURL& url,
- int file_flags,
- base::PlatformFile* file_handle,
- bool* created) OVERRIDE;
- virtual base::PlatformFileError Close(
- FileSystemOperationContext* context,
- base::PlatformFile file) OVERRIDE;
- virtual base::PlatformFileError EnsureFileExists(
+ int file_flags) OVERRIDE;
+ virtual base::File::Error EnsureFileExists(
FileSystemOperationContext* context,
const FileSystemURL& url, bool* created) OVERRIDE;
- virtual base::PlatformFileError CreateDirectory(
+ virtual base::File::Error CreateDirectory(
FileSystemOperationContext* context,
const FileSystemURL& url,
bool exclusive,
bool recursive) OVERRIDE;
- virtual base::PlatformFileError GetFileInfo(
+ virtual base::File::Error GetFileInfo(
FileSystemOperationContext* context,
const FileSystemURL& url,
- base::PlatformFileInfo* file_info,
+ base::File::Info* file_info,
base::FilePath* platform_file) OVERRIDE;
virtual scoped_ptr<AbstractFileEnumerator> CreateFileEnumerator(
FileSystemOperationContext* context,
const FileSystemURL& root_url) OVERRIDE;
- virtual base::PlatformFileError GetLocalFilePath(
+ virtual base::File::Error GetLocalFilePath(
FileSystemOperationContext* context,
const FileSystemURL& file_system_url,
base::FilePath* local_file_path) OVERRIDE;
- virtual base::PlatformFileError Touch(
+ virtual base::File::Error Touch(
FileSystemOperationContext* context,
const FileSystemURL& url,
const base::Time& last_access_time,
const base::Time& last_modified_time) OVERRIDE;
- virtual base::PlatformFileError Truncate(
+ virtual base::File::Error Truncate(
FileSystemOperationContext* context,
const FileSystemURL& url,
int64 length) OVERRIDE;
- virtual base::PlatformFileError CopyOrMoveFile(
+ virtual base::File::Error CopyOrMoveFile(
FileSystemOperationContext* context,
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
CopyOrMoveOption option,
bool copy) OVERRIDE;
- virtual base::PlatformFileError CopyInForeignFile(
+ virtual base::File::Error CopyInForeignFile(
FileSystemOperationContext* context,
const base::FilePath& src_file_path,
const FileSystemURL& dest_url) OVERRIDE;
- virtual base::PlatformFileError DeleteFile(
+ virtual base::File::Error DeleteFile(
FileSystemOperationContext* context,
const FileSystemURL& url) OVERRIDE;
- virtual base::PlatformFileError DeleteDirectory(
+ virtual base::File::Error DeleteDirectory(
FileSystemOperationContext* context,
const FileSystemURL& url) OVERRIDE;
virtual webkit_blob::ScopedFile CreateSnapshotFile(
FileSystemOperationContext* context,
const FileSystemURL& url,
- base::PlatformFileError* error,
- base::PlatformFileInfo* file_info,
+ base::File::Error* error,
+ base::File::Info* file_info,
base::FilePath* platform_path) OVERRIDE;
private:
diff --git a/chromium/webkit/browser/fileapi/mock_file_change_observer.cc b/chromium/webkit/browser/fileapi/mock_file_change_observer.cc
deleted file mode 100644
index 74791f5ebd2..00000000000
--- a/chromium/webkit/browser/fileapi/mock_file_change_observer.cc
+++ /dev/null
@@ -1,51 +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 "webkit/browser/fileapi/mock_file_change_observer.h"
-
-namespace fileapi {
-
-MockFileChangeObserver::MockFileChangeObserver()
- : create_file_count_(0),
- create_file_from_count_(0),
- remove_file_count_(0),
- modify_file_count_(0),
- create_directory_count_(0),
- remove_directory_count_(0) {}
-
-MockFileChangeObserver::~MockFileChangeObserver() {}
-
-// static
-ChangeObserverList MockFileChangeObserver::CreateList(
- MockFileChangeObserver* observer) {
- ChangeObserverList list;
- return list.AddObserver(observer, base::MessageLoopProxy::current().get());
-}
-
-void MockFileChangeObserver::OnCreateFile(const FileSystemURL& url) {
- create_file_count_++;
-}
-
-void MockFileChangeObserver::OnCreateFileFrom(const FileSystemURL& url,
- const FileSystemURL& src) {
- create_file_from_count_++;
-}
-
-void MockFileChangeObserver::OnRemoveFile(const FileSystemURL& url) {
- remove_file_count_++;
-}
-
-void MockFileChangeObserver::OnModifyFile(const FileSystemURL& url) {
- modify_file_count_++;
-}
-
-void MockFileChangeObserver::OnCreateDirectory(const FileSystemURL& url) {
- create_directory_count_++;
-}
-
-void MockFileChangeObserver::OnRemoveDirectory(const FileSystemURL& url) {
- remove_directory_count_++;
-}
-
-} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/mock_file_change_observer.h b/chromium/webkit/browser/fileapi/mock_file_change_observer.h
deleted file mode 100644
index 3835323d2a5..00000000000
--- a/chromium/webkit/browser/fileapi/mock_file_change_observer.h
+++ /dev/null
@@ -1,103 +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 WEBKIT_BROWSER_FILEAPI_MOCK_FILE_CHANGE_OBSERVER_H_
-#define WEBKIT_BROWSER_FILEAPI_MOCK_FILE_CHANGE_OBSERVER_H_
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "webkit/browser/fileapi/file_observers.h"
-#include "webkit/browser/fileapi/file_system_url.h"
-#include "webkit/browser/fileapi/task_runner_bound_observer_list.h"
-
-namespace fileapi {
-
-// Mock file change observer.
-class MockFileChangeObserver : public FileChangeObserver {
- public:
- MockFileChangeObserver();
- virtual ~MockFileChangeObserver();
-
- // Creates a ChangeObserverList which only contains given |observer|.
- static ChangeObserverList CreateList(MockFileChangeObserver* observer);
-
- // FileChangeObserver overrides.
- virtual void OnCreateFile(const FileSystemURL& url) OVERRIDE;
- virtual void OnCreateFileFrom(const FileSystemURL& url,
- const FileSystemURL& src) OVERRIDE;
- virtual void OnRemoveFile(const FileSystemURL& url) OVERRIDE;
- virtual void OnModifyFile(const FileSystemURL& url) OVERRIDE;
- virtual void OnCreateDirectory(const FileSystemURL& url) OVERRIDE;
- virtual void OnRemoveDirectory(const FileSystemURL& url) OVERRIDE;
-
- void ResetCount() {
- create_file_count_ = 0;
- create_file_from_count_ = 0;
- remove_file_count_ = 0;
- modify_file_count_ = 0;
- create_directory_count_ = 0;
- remove_directory_count_ = 0;
- }
-
- bool HasNoChange() const {
- return create_file_count_ == 0 &&
- create_file_from_count_ == 0 &&
- remove_file_count_ == 0 &&
- modify_file_count_ == 0 &&
- create_directory_count_ == 0 &&
- remove_directory_count_ == 0;
- }
-
- int create_file_count() const { return create_file_count_; }
- int create_file_from_count() const { return create_file_from_count_; }
- int remove_file_count() const { return remove_file_count_; }
- int modify_file_count() const { return modify_file_count_; }
- int create_directory_count() const { return create_directory_count_; }
- int remove_directory_count() const { return remove_directory_count_; }
-
- int get_and_reset_create_file_count() {
- int tmp = create_file_count_;
- create_file_count_ = 0;
- return tmp;
- }
- int get_and_reset_create_file_from_count() {
- int tmp = create_file_from_count_;
- create_file_from_count_ = 0;
- return tmp;
- }
- int get_and_reset_remove_file_count() {
- int tmp = remove_file_count_;
- remove_file_count_ = 0;
- return tmp;
- }
- int get_and_reset_modify_file_count() {
- int tmp = modify_file_count_;
- modify_file_count_ = 0;
- return tmp;
- }
- int get_and_reset_create_directory_count() {
- int tmp = create_directory_count_;
- create_directory_count_ = 0;
- return tmp;
- }
- int get_and_reset_remove_directory_count() {
- int tmp = remove_directory_count_;
- remove_directory_count_ = 0;
- return tmp;
- }
-
- private:
- int create_file_count_;
- int create_file_from_count_;
- int remove_file_count_;
- int modify_file_count_;
- int create_directory_count_;
- int remove_directory_count_;
-
- DISALLOW_COPY_AND_ASSIGN(MockFileChangeObserver);
-};
-
-} // namespace fileapi
-
-#endif // WEBKIT_BROWSER_FILEAPI_MOCK_FILE_CHANGE_OBSERVER_H_
diff --git a/chromium/webkit/browser/fileapi/mount_points.h b/chromium/webkit/browser/fileapi/mount_points.h
index 4ebf6e7ec3b..d206ab9a1b4 100644
--- a/chromium/webkit/browser/fileapi/mount_points.h
+++ b/chromium/webkit/browser/fileapi/mount_points.h
@@ -87,6 +87,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT MountPoints {
virtual bool CrackVirtualPath(const base::FilePath& virtual_path,
std::string* mount_name,
FileSystemType* type,
+ std::string* cracked_id,
base::FilePath* path,
FileSystemMountOption* mount_option) const = 0;
diff --git a/chromium/webkit/browser/fileapi/native_file_util.cc b/chromium/webkit/browser/fileapi/native_file_util.cc
index 9754d6c64a8..c0229943b9a 100644
--- a/chromium/webkit/browser/fileapi/native_file_util.cc
+++ b/chromium/webkit/browser/fileapi/native_file_util.cc
@@ -5,9 +5,9 @@
#include "webkit/browser/fileapi/native_file_util.h"
#include "base/file_util.h"
+#include "base/files/file.h"
#include "base/files/file_enumerator.h"
#include "base/memory/scoped_ptr.h"
-#include "net/base/file_stream.h"
#include "webkit/browser/fileapi/file_system_operation_context.h"
#include "webkit/browser/fileapi/file_system_url.h"
@@ -37,15 +37,14 @@ bool SetPlatformSpecificDirectoryPermissions(const base::FilePath& dir_path) {
// Copies a file |from| to |to|, and ensure the written content is synced to
// the disk. This is essentially base::CopyFile followed by fsync().
bool CopyFileAndSync(const base::FilePath& from, const base::FilePath& to) {
- net::FileStream infile(NULL);
- if (infile.OpenSync(from,
- base::PLATFORM_FILE_OPEN | base:: PLATFORM_FILE_READ) < 0) {
+ base::File infile(from, base::File::FLAG_OPEN | base::File::FLAG_READ);
+ if (!infile.IsValid()) {
return false;
}
- net::FileStream outfile(NULL);
- if (outfile.OpenSync(to,
- base::PLATFORM_FILE_CREATE_ALWAYS | base:: PLATFORM_FILE_WRITE) < 0) {
+ base::File outfile(to,
+ base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
+ if (!outfile.IsValid()) {
return false;
}
@@ -53,27 +52,26 @@ bool CopyFileAndSync(const base::FilePath& from, const base::FilePath& to) {
std::vector<char> buffer(kBufferSize);
for (;;) {
- int bytes_read = infile.ReadSync(&buffer[0], kBufferSize);
+ int bytes_read = infile.ReadAtCurrentPos(&buffer[0], kBufferSize);
if (bytes_read < 0)
return false;
if (bytes_read == 0)
break;
for (int bytes_written = 0; bytes_written < bytes_read; ) {
- int bytes_written_partial = outfile.WriteSync(&buffer[bytes_written],
- bytes_read - bytes_written);
+ int bytes_written_partial = outfile.WriteAtCurrentPos(
+ &buffer[bytes_written], bytes_read - bytes_written);
if (bytes_written_partial < 0)
return false;
bytes_written += bytes_written_partial;
}
}
- return outfile.FlushSync() >= 0;
+ return outfile.Flush();
}
} // namespace
using base::PlatformFile;
-using base::PlatformFileError;
class NativeFileEnumerator : public FileSystemFileUtil::AbstractFileEnumerator {
public:
@@ -123,69 +121,65 @@ NativeFileUtil::CopyOrMoveMode NativeFileUtil::CopyOrMoveModeForDestination(
return MOVE;
}
-PlatformFileError NativeFileUtil::CreateOrOpen(
- const base::FilePath& path, int file_flags,
- PlatformFile* file_handle, bool* created) {
+base::File NativeFileUtil::CreateOrOpen(const base::FilePath& path,
+ int file_flags) {
if (!base::DirectoryExists(path.DirName())) {
// If its parent does not exist, should return NOT_FOUND error.
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File(base::File::FILE_ERROR_NOT_FOUND);
}
+
+ // TODO(rvargas): Check |file_flags| instead. See bug 356358.
if (base::DirectoryExists(path))
- return base::PLATFORM_FILE_ERROR_NOT_A_FILE;
- PlatformFileError error_code = base::PLATFORM_FILE_OK;
- *file_handle = base::CreatePlatformFile(path, file_flags,
- created, &error_code);
- return error_code;
-}
+ return base::File(base::File::FILE_ERROR_NOT_A_FILE);
-PlatformFileError NativeFileUtil::Close(PlatformFile file_handle) {
- if (!base::ClosePlatformFile(file_handle))
- return base::PLATFORM_FILE_ERROR_FAILED;
- return base::PLATFORM_FILE_OK;
+ return base::File(path, file_flags);
}
-PlatformFileError NativeFileUtil::EnsureFileExists(
+base::File::Error NativeFileUtil::EnsureFileExists(
const base::FilePath& path,
bool* created) {
if (!base::DirectoryExists(path.DirName()))
// If its parent does not exist, should return NOT_FOUND error.
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
- PlatformFileError error_code = base::PLATFORM_FILE_OK;
+ return base::File::FILE_ERROR_NOT_FOUND;
+
// Tries to create the |path| exclusively. This should fail
- // with base::PLATFORM_FILE_ERROR_EXISTS if the path already exists.
- PlatformFile handle = base::CreatePlatformFile(
- path,
- base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_READ,
- created, &error_code);
- if (error_code == base::PLATFORM_FILE_ERROR_EXISTS) {
+ // with base::File::FILE_ERROR_EXISTS if the path already exists.
+ base::File file(path, base::File::FLAG_CREATE | base::File::FLAG_READ);
+
+ if (file.IsValid()) {
+ if (created)
+ *created = file.created();
+ return base::File::FILE_OK;
+ }
+
+ base::File::Error error_code = file.error_details();
+ if (error_code == base::File::FILE_ERROR_EXISTS) {
// Make sure created_ is false.
if (created)
*created = false;
- error_code = base::PLATFORM_FILE_OK;
+ error_code = base::File::FILE_OK;
}
- if (handle != base::kInvalidPlatformFileValue)
- base::ClosePlatformFile(handle);
return error_code;
}
-PlatformFileError NativeFileUtil::CreateDirectory(
+base::File::Error NativeFileUtil::CreateDirectory(
const base::FilePath& path,
bool exclusive,
bool recursive) {
// If parent dir of file doesn't exist.
if (!recursive && !base::PathExists(path.DirName()))
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
bool path_exists = base::PathExists(path);
if (exclusive && path_exists)
- return base::PLATFORM_FILE_ERROR_EXISTS;
+ return base::File::FILE_ERROR_EXISTS;
// If file exists at the path.
if (path_exists && !base::DirectoryExists(path))
- return base::PLATFORM_FILE_ERROR_EXISTS;
+ return base::File::FILE_ERROR_EXISTS;
if (!base::CreateDirectory(path))
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
if (!SetPlatformSpecificDirectoryPermissions(path)) {
// Since some file systems don't support permission setting, we do not treat
@@ -194,17 +188,18 @@ PlatformFileError NativeFileUtil::CreateDirectory(
<< path.AsUTF8Unsafe();
}
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_OK;
}
-PlatformFileError NativeFileUtil::GetFileInfo(
+base::File::Error NativeFileUtil::GetFileInfo(
const base::FilePath& path,
- base::PlatformFileInfo* file_info) {
+ base::File::Info* file_info) {
if (!base::PathExists(path))
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
+
if (!base::GetFileInfo(path, file_info))
- return base::PLATFORM_FILE_ERROR_FAILED;
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_ERROR_FAILED;
+ return base::File::FILE_OK;
}
scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator>
@@ -216,32 +211,25 @@ scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator>
.PassAs<FileSystemFileUtil::AbstractFileEnumerator>();
}
-PlatformFileError NativeFileUtil::Touch(
+base::File::Error NativeFileUtil::Touch(
const base::FilePath& path,
const base::Time& last_access_time,
const base::Time& last_modified_time) {
if (!base::TouchFile(path, last_access_time, last_modified_time))
- return base::PLATFORM_FILE_ERROR_FAILED;
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_ERROR_FAILED;
+ return base::File::FILE_OK;
}
-PlatformFileError NativeFileUtil::Truncate(
- const base::FilePath& path, int64 length) {
- PlatformFileError error_code(base::PLATFORM_FILE_ERROR_FAILED);
- PlatformFile file =
- base::CreatePlatformFile(
- path,
- base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE,
- NULL,
- &error_code);
- if (error_code != base::PLATFORM_FILE_OK) {
- return error_code;
- }
- DCHECK_NE(base::kInvalidPlatformFileValue, file);
- if (!base::TruncatePlatformFile(file, length))
- error_code = base::PLATFORM_FILE_ERROR_FAILED;
- base::ClosePlatformFile(file);
- return error_code;
+base::File::Error NativeFileUtil::Truncate(const base::FilePath& path,
+ int64 length) {
+ base::File file(path, base::File::FLAG_OPEN | base::File::FLAG_WRITE);
+ if (!file.IsValid())
+ return file.error_details();
+
+ if (!file.SetLength(length))
+ return base::File::FILE_ERROR_FAILED;
+
+ return base::File::FILE_OK;
}
bool NativeFileUtil::PathExists(const base::FilePath& path) {
@@ -252,45 +240,45 @@ bool NativeFileUtil::DirectoryExists(const base::FilePath& path) {
return base::DirectoryExists(path);
}
-PlatformFileError NativeFileUtil::CopyOrMoveFile(
+base::File::Error NativeFileUtil::CopyOrMoveFile(
const base::FilePath& src_path,
const base::FilePath& dest_path,
FileSystemOperation::CopyOrMoveOption option,
CopyOrMoveMode mode) {
- base::PlatformFileInfo info;
- base::PlatformFileError error = NativeFileUtil::GetFileInfo(src_path, &info);
- if (error != base::PLATFORM_FILE_OK)
+ base::File::Info info;
+ base::File::Error error = NativeFileUtil::GetFileInfo(src_path, &info);
+ if (error != base::File::FILE_OK)
return error;
if (info.is_directory)
- return base::PLATFORM_FILE_ERROR_NOT_A_FILE;
+ return base::File::FILE_ERROR_NOT_A_FILE;
base::Time last_modified = info.last_modified;
error = NativeFileUtil::GetFileInfo(dest_path, &info);
- if (error != base::PLATFORM_FILE_OK &&
- error != base::PLATFORM_FILE_ERROR_NOT_FOUND)
+ if (error != base::File::FILE_OK &&
+ error != base::File::FILE_ERROR_NOT_FOUND)
return error;
if (info.is_directory)
- return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
- if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND) {
+ return base::File::FILE_ERROR_INVALID_OPERATION;
+ if (error == base::File::FILE_ERROR_NOT_FOUND) {
error = NativeFileUtil::GetFileInfo(dest_path.DirName(), &info);
- if (error != base::PLATFORM_FILE_OK)
+ if (error != base::File::FILE_OK)
return error;
if (!info.is_directory)
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
}
switch (mode) {
case COPY_NOSYNC:
if (!base::CopyFile(src_path, dest_path))
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
break;
case COPY_SYNC:
if (!CopyFileAndSync(src_path, dest_path))
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
break;
case MOVE:
if (!base::Move(src_path, dest_path))
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
break;
}
@@ -299,29 +287,29 @@ PlatformFileError NativeFileUtil::CopyOrMoveFile(
if (option == FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED)
base::TouchFile(dest_path, last_modified, last_modified);
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_OK;
}
-PlatformFileError NativeFileUtil::DeleteFile(const base::FilePath& path) {
+base::File::Error NativeFileUtil::DeleteFile(const base::FilePath& path) {
if (!base::PathExists(path))
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
if (base::DirectoryExists(path))
- return base::PLATFORM_FILE_ERROR_NOT_A_FILE;
+ return base::File::FILE_ERROR_NOT_A_FILE;
if (!base::DeleteFile(path, false))
- return base::PLATFORM_FILE_ERROR_FAILED;
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_ERROR_FAILED;
+ return base::File::FILE_OK;
}
-PlatformFileError NativeFileUtil::DeleteDirectory(const base::FilePath& path) {
+base::File::Error NativeFileUtil::DeleteDirectory(const base::FilePath& path) {
if (!base::PathExists(path))
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
if (!base::DirectoryExists(path))
- return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY;
+ return base::File::FILE_ERROR_NOT_A_DIRECTORY;
if (!base::IsDirectoryEmpty(path))
- return base::PLATFORM_FILE_ERROR_NOT_EMPTY;
+ return base::File::FILE_ERROR_NOT_EMPTY;
if (!base::DeleteFile(path, false))
- return base::PLATFORM_FILE_ERROR_FAILED;
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_ERROR_FAILED;
+ return base::File::FILE_OK;
}
} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/native_file_util.h b/chromium/webkit/browser/fileapi/native_file_util.h
index 4c36e5ff951..bd875814344 100644
--- a/chromium/webkit/browser/fileapi/native_file_util.h
+++ b/chromium/webkit/browser/fileapi/native_file_util.h
@@ -5,10 +5,10 @@
#ifndef WEBKIT_BROWSER_FILEAPI_NATIVE_FILE_UTIL_H_
#define WEBKIT_BROWSER_FILEAPI_NATIVE_FILE_UTIL_H_
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/file_util_proxy.h"
#include "base/memory/scoped_ptr.h"
-#include "base/platform_file.h"
#include "webkit/browser/fileapi/file_system_file_util.h"
#include "webkit/browser/webkit_storage_browser_export.h"
@@ -38,36 +38,31 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE NativeFileUtil {
static CopyOrMoveMode CopyOrMoveModeForDestination(
const FileSystemURL& dest_url, bool copy);
- static base::PlatformFileError CreateOrOpen(
- const base::FilePath& path,
- int file_flags,
- base::PlatformFile* file_handle,
- bool* created);
- static base::PlatformFileError Close(base::PlatformFile file);
- static base::PlatformFileError EnsureFileExists(const base::FilePath& path,
- bool* created);
- static base::PlatformFileError CreateDirectory(const base::FilePath& path,
- bool exclusive,
- bool recursive);
- static base::PlatformFileError GetFileInfo(const base::FilePath& path,
- base::PlatformFileInfo* file_info);
+ static base::File CreateOrOpen(const base::FilePath& path, int file_flags);
+ static base::File::Error EnsureFileExists(const base::FilePath& path,
+ bool* created);
+ static base::File::Error CreateDirectory(const base::FilePath& path,
+ bool exclusive,
+ bool recursive);
+ static base::File::Error GetFileInfo(const base::FilePath& path,
+ base::File::Info* file_info);
static scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator>
CreateFileEnumerator(const base::FilePath& root_path,
bool recursive);
- static base::PlatformFileError Touch(const base::FilePath& path,
- const base::Time& last_access_time,
- const base::Time& last_modified_time);
- static base::PlatformFileError Truncate(const base::FilePath& path,
- int64 length);
+ static base::File::Error Touch(const base::FilePath& path,
+ const base::Time& last_access_time,
+ const base::Time& last_modified_time);
+ static base::File::Error Truncate(const base::FilePath& path,
+ int64 length);
static bool PathExists(const base::FilePath& path);
static bool DirectoryExists(const base::FilePath& path);
- static base::PlatformFileError CopyOrMoveFile(
+ static base::File::Error CopyOrMoveFile(
const base::FilePath& src_path,
const base::FilePath& dest_path,
FileSystemOperation::CopyOrMoveOption option,
CopyOrMoveMode mode);
- static base::PlatformFileError DeleteFile(const base::FilePath& path);
- static base::PlatformFileError DeleteDirectory(const base::FilePath& path);
+ static base::File::Error DeleteFile(const base::FilePath& path);
+ static base::File::Error DeleteDirectory(const base::FilePath& path);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(NativeFileUtil);
diff --git a/chromium/webkit/browser/fileapi/native_file_util_unittest.cc b/chromium/webkit/browser/fileapi/native_file_util_unittest.cc
deleted file mode 100644
index 73b3e257025..00000000000
--- a/chromium/webkit/browser/fileapi/native_file_util_unittest.cc
+++ /dev/null
@@ -1,412 +0,0 @@
-// Copyright (c) 2013 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 <set>
-
-#include "base/file_util.h"
-#include "base/files/file_path.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/platform_file.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/fileapi/native_file_util.h"
-
-namespace fileapi {
-
-class NativeFileUtilTest : public testing::Test {
- public:
- NativeFileUtilTest() {}
-
- virtual void SetUp() {
- ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
- }
-
- protected:
- base::FilePath Path() {
- return data_dir_.path();
- }
-
- base::FilePath Path(const char* file_name) {
- return data_dir_.path().AppendASCII(file_name);
- }
-
- bool FileExists(const base::FilePath& path) {
- return base::PathExists(path) &&
- !base::DirectoryExists(path);
- }
-
- int64 GetSize(const base::FilePath& path) {
- base::PlatformFileInfo info;
- base::GetFileInfo(path, &info);
- return info.size;
- }
-
- private:
- base::ScopedTempDir data_dir_;
-
- DISALLOW_COPY_AND_ASSIGN(NativeFileUtilTest);
-};
-
-TEST_F(NativeFileUtilTest, CreateCloseAndDeleteFile) {
- base::FilePath file_name = Path("test_file");
- base::PlatformFile file_handle;
- bool created = false;
- int flags = base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_ASYNC;
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::CreateOrOpen(file_name,
- base::PLATFORM_FILE_CREATE | flags,
- &file_handle, &created));
- ASSERT_TRUE(created);
-
- EXPECT_TRUE(base::PathExists(file_name));
- EXPECT_TRUE(NativeFileUtil::PathExists(file_name));
- EXPECT_EQ(0, GetSize(file_name));
- EXPECT_NE(base::kInvalidPlatformFileValue, file_handle);
-
- ASSERT_EQ(base::PLATFORM_FILE_OK, NativeFileUtil::Close(file_handle));
-
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::CreateOrOpen(file_name,
- base::PLATFORM_FILE_OPEN | flags,
- &file_handle, &created));
- ASSERT_FALSE(created);
- ASSERT_EQ(base::PLATFORM_FILE_OK, NativeFileUtil::Close(file_handle));
-
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::DeleteFile(file_name));
- EXPECT_FALSE(base::PathExists(file_name));
- EXPECT_FALSE(NativeFileUtil::PathExists(file_name));
-}
-
-TEST_F(NativeFileUtilTest, EnsureFileExists) {
- base::FilePath file_name = Path("foobar");
- bool created = false;
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::EnsureFileExists(file_name, &created));
- ASSERT_TRUE(created);
-
- EXPECT_TRUE(FileExists(file_name));
- EXPECT_EQ(0, GetSize(file_name));
-
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::EnsureFileExists(file_name, &created));
- EXPECT_FALSE(created);
-}
-
-TEST_F(NativeFileUtilTest, CreateAndDeleteDirectory) {
- base::FilePath dir_name = Path("test_dir");
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::CreateDirectory(dir_name,
- false /* exclusive */,
- false /* recursive */));
-
- EXPECT_TRUE(NativeFileUtil::DirectoryExists(dir_name));
- EXPECT_TRUE(base::DirectoryExists(dir_name));
-
- ASSERT_EQ(base::PLATFORM_FILE_ERROR_EXISTS,
- NativeFileUtil::CreateDirectory(dir_name,
- true /* exclusive */,
- false /* recursive */));
-
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::DeleteDirectory(dir_name));
- EXPECT_FALSE(base::DirectoryExists(dir_name));
- EXPECT_FALSE(NativeFileUtil::DirectoryExists(dir_name));
-}
-
-TEST_F(NativeFileUtilTest, TouchFileAndGetFileInfo) {
- base::FilePath file_name = Path("test_file");
- base::PlatformFileInfo native_info;
- ASSERT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND,
- NativeFileUtil::GetFileInfo(file_name, &native_info));
-
- bool created = false;
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::EnsureFileExists(file_name, &created));
- ASSERT_TRUE(created);
-
- base::PlatformFileInfo info;
- ASSERT_TRUE(base::GetFileInfo(file_name, &info));
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::GetFileInfo(file_name, &native_info));
- ASSERT_EQ(info.size, native_info.size);
- ASSERT_EQ(info.is_directory, native_info.is_directory);
- ASSERT_EQ(info.is_symbolic_link, native_info.is_symbolic_link);
- ASSERT_EQ(info.last_modified, native_info.last_modified);
- ASSERT_EQ(info.last_accessed, native_info.last_accessed);
- ASSERT_EQ(info.creation_time, native_info.creation_time);
-
- const base::Time new_accessed =
- info.last_accessed + base::TimeDelta::FromHours(10);
- const base::Time new_modified =
- info.last_modified + base::TimeDelta::FromHours(5);
-
- EXPECT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::Touch(file_name,
- new_accessed, new_modified));
-
- ASSERT_TRUE(base::GetFileInfo(file_name, &info));
- EXPECT_EQ(new_accessed, info.last_accessed);
- EXPECT_EQ(new_modified, info.last_modified);
-}
-
-TEST_F(NativeFileUtilTest, CreateFileEnumerator) {
- base::FilePath path_1 = Path("dir1");
- base::FilePath path_2 = Path("file1");
- base::FilePath path_11 = Path("dir1").AppendASCII("file11");
- base::FilePath path_12 = Path("dir1").AppendASCII("dir12");
- base::FilePath path_121 =
- Path("dir1").AppendASCII("dir12").AppendASCII("file121");
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::CreateDirectory(path_1, false, false));
- bool created = false;
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::EnsureFileExists(path_2, &created));
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::EnsureFileExists(path_11, &created));
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::CreateDirectory(path_12, false, false));
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::EnsureFileExists(path_121, &created));
-
- {
- scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> enumerator =
- NativeFileUtil::CreateFileEnumerator(Path(), false);
- std::set<base::FilePath> set;
- set.insert(path_1);
- set.insert(path_2);
- for (base::FilePath path = enumerator->Next(); !path.empty();
- path = enumerator->Next())
- EXPECT_EQ(1U, set.erase(path));
- EXPECT_TRUE(set.empty());
- }
-
- {
- scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> enumerator =
- NativeFileUtil::CreateFileEnumerator(Path(), true);
- std::set<base::FilePath> set;
- set.insert(path_1);
- set.insert(path_2);
- set.insert(path_11);
- set.insert(path_12);
- set.insert(path_121);
- for (base::FilePath path = enumerator->Next(); !path.empty();
- path = enumerator->Next())
- EXPECT_EQ(1U, set.erase(path));
- EXPECT_TRUE(set.empty());
- }
-}
-
-TEST_F(NativeFileUtilTest, Truncate) {
- base::FilePath file_name = Path("truncated");
- bool created = false;
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::EnsureFileExists(file_name, &created));
- ASSERT_TRUE(created);
-
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::Truncate(file_name, 1020));
-
- EXPECT_TRUE(FileExists(file_name));
- EXPECT_EQ(1020, GetSize(file_name));
-}
-
-TEST_F(NativeFileUtilTest, CopyFile) {
- base::FilePath from_file = Path("fromfile");
- base::FilePath to_file1 = Path("tofile1");
- base::FilePath to_file2 = Path("tofile2");
- const NativeFileUtil::CopyOrMoveMode nosync = NativeFileUtil::COPY_NOSYNC;
- const NativeFileUtil::CopyOrMoveMode sync = NativeFileUtil::COPY_SYNC;
- bool created = false;
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::EnsureFileExists(from_file, &created));
- ASSERT_TRUE(created);
-
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::Truncate(from_file, 1020));
-
- EXPECT_TRUE(FileExists(from_file));
- EXPECT_EQ(1020, GetSize(from_file));
-
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::CopyOrMoveFile(
- from_file, to_file1, FileSystemOperation::OPTION_NONE, nosync));
-
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::CopyOrMoveFile(
- from_file, to_file2, FileSystemOperation::OPTION_NONE, sync));
-
- EXPECT_TRUE(FileExists(from_file));
- EXPECT_EQ(1020, GetSize(from_file));
- EXPECT_TRUE(FileExists(to_file1));
- EXPECT_EQ(1020, GetSize(to_file1));
- EXPECT_TRUE(FileExists(to_file2));
- EXPECT_EQ(1020, GetSize(to_file2));
-
- base::FilePath dir = Path("dir");
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::CreateDirectory(dir, false, false));
- ASSERT_TRUE(base::DirectoryExists(dir));
- base::FilePath to_dir_file = dir.AppendASCII("file");
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::CopyOrMoveFile(
- from_file, to_dir_file,
- FileSystemOperation::OPTION_NONE, nosync));
- EXPECT_TRUE(FileExists(to_dir_file));
- EXPECT_EQ(1020, GetSize(to_dir_file));
-
- // Following tests are error checking.
- // Source doesn't exist.
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND,
- NativeFileUtil::CopyOrMoveFile(
- Path("nonexists"), Path("file"),
- FileSystemOperation::OPTION_NONE, nosync));
-
- // Source is not a file.
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_FILE,
- NativeFileUtil::CopyOrMoveFile(
- dir, Path("file"), FileSystemOperation::OPTION_NONE, nosync));
- // Destination is not a file.
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION,
- NativeFileUtil::CopyOrMoveFile(
- from_file, dir, FileSystemOperation::OPTION_NONE, nosync));
- // Destination's parent doesn't exist.
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND,
- NativeFileUtil::CopyOrMoveFile(
- from_file, Path("nodir").AppendASCII("file"),
- FileSystemOperation::OPTION_NONE, nosync));
- // Destination's parent is a file.
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND,
- NativeFileUtil::CopyOrMoveFile(
- from_file, Path("tofile1").AppendASCII("file"),
- FileSystemOperation::OPTION_NONE, nosync));
-}
-
-TEST_F(NativeFileUtilTest, MoveFile) {
- base::FilePath from_file = Path("fromfile");
- base::FilePath to_file = Path("tofile");
- const NativeFileUtil::CopyOrMoveMode move = NativeFileUtil::MOVE;
- bool created = false;
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::EnsureFileExists(from_file, &created));
- ASSERT_TRUE(created);
-
- ASSERT_EQ(base::PLATFORM_FILE_OK, NativeFileUtil::Truncate(from_file, 1020));
-
- EXPECT_TRUE(FileExists(from_file));
- EXPECT_EQ(1020, GetSize(from_file));
-
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::CopyOrMoveFile(
- from_file, to_file, FileSystemOperation::OPTION_NONE, move));
-
- EXPECT_FALSE(FileExists(from_file));
- EXPECT_TRUE(FileExists(to_file));
- EXPECT_EQ(1020, GetSize(to_file));
-
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::EnsureFileExists(from_file, &created));
- ASSERT_TRUE(FileExists(from_file));
- ASSERT_EQ(base::PLATFORM_FILE_OK, NativeFileUtil::Truncate(from_file, 1020));
-
- base::FilePath dir = Path("dir");
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::CreateDirectory(dir, false, false));
- ASSERT_TRUE(base::DirectoryExists(dir));
- base::FilePath to_dir_file = dir.AppendASCII("file");
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::CopyOrMoveFile(
- from_file, to_dir_file,
- FileSystemOperation::OPTION_NONE, move));
- EXPECT_FALSE(FileExists(from_file));
- EXPECT_TRUE(FileExists(to_dir_file));
- EXPECT_EQ(1020, GetSize(to_dir_file));
-
- // Following is error checking.
- // Source doesn't exist.
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND,
- NativeFileUtil::CopyOrMoveFile(
- Path("nonexists"), Path("file"),
- FileSystemOperation::OPTION_NONE, move));
-
- // Source is not a file.
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_FILE,
- NativeFileUtil::CopyOrMoveFile(
- dir, Path("file"), FileSystemOperation::OPTION_NONE, move));
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::EnsureFileExists(from_file, &created));
- ASSERT_TRUE(FileExists(from_file));
- // Destination is not a file.
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION,
- NativeFileUtil::CopyOrMoveFile(
- from_file, dir, FileSystemOperation::OPTION_NONE, move));
-
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::EnsureFileExists(from_file, &created));
- ASSERT_TRUE(FileExists(from_file));
- // Destination's parent doesn't exist.
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND,
- NativeFileUtil::CopyOrMoveFile(
- from_file, Path("nodir").AppendASCII("file"),
- FileSystemOperation::OPTION_NONE, move));
- // Destination's parent is a file.
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND,
- NativeFileUtil::CopyOrMoveFile(
- from_file, Path("tofile1").AppendASCII("file"),
- FileSystemOperation::OPTION_NONE, move));
-}
-
-TEST_F(NativeFileUtilTest, PreserveLastModified) {
- base::FilePath from_file = Path("fromfile");
- base::FilePath to_file1 = Path("tofile1");
- base::FilePath to_file2 = Path("tofile2");
- base::FilePath to_file3 = Path("tofile3");
- bool created = false;
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::EnsureFileExists(from_file, &created));
- ASSERT_TRUE(created);
- EXPECT_TRUE(FileExists(from_file));
-
- base::PlatformFileInfo file_info1;
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::GetFileInfo(from_file, &file_info1));
-
- // Test for copy (nosync).
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::CopyOrMoveFile(
- from_file, to_file1,
- FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED,
- NativeFileUtil::COPY_NOSYNC));
-
- base::PlatformFileInfo file_info2;
- ASSERT_TRUE(FileExists(to_file1));
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::GetFileInfo(to_file1, &file_info2));
- EXPECT_EQ(file_info1.last_modified, file_info2.last_modified);
-
- // Test for copy (sync).
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::CopyOrMoveFile(
- from_file, to_file2,
- FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED,
- NativeFileUtil::COPY_SYNC));
-
- ASSERT_TRUE(FileExists(to_file2));
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::GetFileInfo(to_file1, &file_info2));
- EXPECT_EQ(file_info1.last_modified, file_info2.last_modified);
-
- // Test for move.
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::CopyOrMoveFile(
- from_file, to_file3,
- FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED,
- NativeFileUtil::MOVE));
-
- ASSERT_TRUE(FileExists(to_file3));
- ASSERT_EQ(base::PLATFORM_FILE_OK,
- NativeFileUtil::GetFileInfo(to_file2, &file_info2));
- EXPECT_EQ(file_info1.last_modified, file_info2.last_modified);
-}
-
-} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/obfuscated_file_util.cc b/chromium/webkit/browser/fileapi/obfuscated_file_util.cc
index c324f10800a..73722d4c829 100644
--- a/chromium/webkit/browser/fileapi/obfuscated_file_util.cc
+++ b/chromium/webkit/browser/fileapi/obfuscated_file_util.cc
@@ -105,9 +105,6 @@ enum IsolatedOriginStatus {
} // namespace
-using base::PlatformFile;
-using base::PlatformFileError;
-
class ObfuscatedFileEnumerator
: public FileSystemFileUtil::AbstractFileEnumerator {
public:
@@ -145,11 +142,11 @@ class ObfuscatedFileEnumerator
FileInfo file_info;
base::FilePath platform_file_path;
- base::PlatformFileError error =
+ base::File::Error error =
obfuscated_file_util_->GetFileInfoInternal(
db_, context_, root_url_, current_file_id_,
&file_info, &current_platform_file_info_, &platform_file_path);
- if (error != base::PLATFORM_FILE_OK)
+ if (error != base::File::FILE_OK)
return Next();
base::FilePath virtual_path =
@@ -205,7 +202,7 @@ class ObfuscatedFileEnumerator
base::FilePath current_parent_virtual_path_;
FileId current_file_id_;
- base::PlatformFileInfo current_platform_file_info_;
+ base::File::Info current_platform_file_info_;
};
class ObfuscatedOriginEnumerator
@@ -255,12 +252,14 @@ class ObfuscatedOriginEnumerator
ObfuscatedFileUtil::ObfuscatedFileUtil(
quota::SpecialStoragePolicy* special_storage_policy,
const base::FilePath& file_system_directory,
+ leveldb::Env* env_override,
base::SequencedTaskRunner* file_task_runner,
const GetTypeStringForURLCallback& get_type_string_for_url,
const std::set<std::string>& known_type_strings,
SandboxFileSystemBackendDelegate* sandbox_delegate)
: special_storage_policy_(special_storage_policy),
file_system_directory_(file_system_directory),
+ env_override_(env_override),
db_flush_delay_seconds_(10 * 60), // 10 mins.
file_task_runner_(file_task_runner),
get_type_string_for_url_(get_type_string_for_url),
@@ -272,52 +271,42 @@ ObfuscatedFileUtil::~ObfuscatedFileUtil() {
DropDatabases();
}
-PlatformFileError ObfuscatedFileUtil::CreateOrOpen(
+base::File ObfuscatedFileUtil::CreateOrOpen(
FileSystemOperationContext* context,
- const FileSystemURL& url, int file_flags,
- PlatformFile* file_handle, bool* created) {
- PlatformFileError error = CreateOrOpenInternal(context, url, file_flags,
- file_handle, created);
- if (*file_handle != base::kInvalidPlatformFileValue &&
- file_flags & base::PLATFORM_FILE_WRITE &&
+ const FileSystemURL& url, int file_flags) {
+ base::File file = CreateOrOpenInternal(context, url, file_flags);
+ if (file.IsValid() && file_flags & base::File::FLAG_WRITE &&
context->quota_limit_type() == quota::kQuotaLimitTypeUnlimited &&
sandbox_delegate_) {
- DCHECK_EQ(base::PLATFORM_FILE_OK, error);
sandbox_delegate_->StickyInvalidateUsageCache(url.origin(), url.type());
}
- return error;
+ return file.Pass();
}
-PlatformFileError ObfuscatedFileUtil::Close(
- FileSystemOperationContext* context,
- base::PlatformFile file) {
- return NativeFileUtil::Close(file);
-}
-
-PlatformFileError ObfuscatedFileUtil::EnsureFileExists(
+base::File::Error ObfuscatedFileUtil::EnsureFileExists(
FileSystemOperationContext* context,
const FileSystemURL& url,
bool* created) {
SandboxDirectoryDatabase* db = GetDirectoryDatabase(url, true);
if (!db)
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
FileId file_id;
if (db->GetFileWithPath(url.path(), &file_id)) {
FileInfo file_info;
if (!db->GetFileInfo(file_id, &file_info)) {
NOTREACHED();
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
}
if (file_info.is_directory())
- return base::PLATFORM_FILE_ERROR_NOT_A_FILE;
+ return base::File::FILE_ERROR_NOT_A_FILE;
if (created)
*created = false;
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_OK;
}
FileId parent_id;
if (!db->GetFileWithPath(VirtualPath::DirName(url.path()), &parent_id))
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
FileInfo file_info;
InitFileInfo(&file_info, parent_id,
@@ -325,10 +314,10 @@ PlatformFileError ObfuscatedFileUtil::EnsureFileExists(
int64 growth = UsageForPath(file_info.name.size());
if (!AllocateQuota(context, growth))
- return base::PLATFORM_FILE_ERROR_NO_SPACE;
- PlatformFileError error = CreateFile(
- context, base::FilePath(), url, &file_info, 0, NULL);
- if (created && base::PLATFORM_FILE_OK == error) {
+ return base::File::FILE_ERROR_NO_SPACE;
+ base::File::Error error = CreateFile(context, base::FilePath(), url,
+ &file_info);
+ if (created && base::File::FILE_OK == error) {
*created = true;
UpdateUsage(context, url, growth);
context->change_observers()->Notify(
@@ -337,27 +326,27 @@ PlatformFileError ObfuscatedFileUtil::EnsureFileExists(
return error;
}
-PlatformFileError ObfuscatedFileUtil::CreateDirectory(
+base::File::Error ObfuscatedFileUtil::CreateDirectory(
FileSystemOperationContext* context,
const FileSystemURL& url,
bool exclusive,
bool recursive) {
SandboxDirectoryDatabase* db = GetDirectoryDatabase(url, true);
if (!db)
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
FileId file_id;
if (db->GetFileWithPath(url.path(), &file_id)) {
FileInfo file_info;
if (exclusive)
- return base::PLATFORM_FILE_ERROR_EXISTS;
+ return base::File::FILE_ERROR_EXISTS;
if (!db->GetFileInfo(file_id, &file_info)) {
NOTREACHED();
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
}
if (!file_info.is_directory())
- return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY;
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_ERROR_NOT_A_DIRECTORY;
+ return base::File::FILE_OK;
}
std::vector<base::FilePath::StringType> components;
@@ -372,9 +361,9 @@ PlatformFileError ObfuscatedFileUtil::CreateDirectory(
break;
}
if (!db->IsDirectory(parent_id))
- return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY;
+ return base::File::FILE_ERROR_NOT_A_DIRECTORY;
if (!recursive && components.size() - index > 1)
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
bool first = true;
for (; index < components.size(); ++index) {
FileInfo file_info;
@@ -385,9 +374,9 @@ PlatformFileError ObfuscatedFileUtil::CreateDirectory(
file_info.parent_id = parent_id;
int64 growth = UsageForPath(file_info.name.size());
if (!AllocateQuota(context, growth))
- return base::PLATFORM_FILE_ERROR_NO_SPACE;
- base::PlatformFileError error = db->AddFileInfo(file_info, &parent_id);
- if (error != base::PLATFORM_FILE_OK)
+ return base::File::FILE_ERROR_NO_SPACE;
+ base::File::Error error = db->AddFileInfo(file_info, &parent_id);
+ if (error != base::File::FILE_OK)
return error;
UpdateUsage(context, url, growth);
context->change_observers()->Notify(
@@ -397,20 +386,20 @@ PlatformFileError ObfuscatedFileUtil::CreateDirectory(
TouchDirectory(db, file_info.parent_id);
}
}
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_OK;
}
-PlatformFileError ObfuscatedFileUtil::GetFileInfo(
+base::File::Error ObfuscatedFileUtil::GetFileInfo(
FileSystemOperationContext* context,
const FileSystemURL& url,
- base::PlatformFileInfo* file_info,
+ base::File::Info* file_info,
base::FilePath* platform_file_path) {
SandboxDirectoryDatabase* db = GetDirectoryDatabase(url, false);
if (!db)
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
FileId file_id;
if (!db->GetFileWithPath(url.path(), &file_id))
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
FileInfo local_info;
return GetFileInfoInternal(db, context, url,
file_id, &local_info,
@@ -424,72 +413,72 @@ scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator>
return CreateFileEnumerator(context, root_url, false /* recursive */);
}
-PlatformFileError ObfuscatedFileUtil::GetLocalFilePath(
+base::File::Error ObfuscatedFileUtil::GetLocalFilePath(
FileSystemOperationContext* context,
const FileSystemURL& url,
base::FilePath* local_path) {
SandboxDirectoryDatabase* db = GetDirectoryDatabase(url, false);
if (!db)
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
FileId file_id;
if (!db->GetFileWithPath(url.path(), &file_id))
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
FileInfo file_info;
if (!db->GetFileInfo(file_id, &file_info) || file_info.is_directory()) {
NOTREACHED();
// Directories have no local file path.
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
}
*local_path = DataPathToLocalPath(url, file_info.data_path);
if (local_path->empty())
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_OK;
}
-PlatformFileError ObfuscatedFileUtil::Touch(
+base::File::Error ObfuscatedFileUtil::Touch(
FileSystemOperationContext* context,
const FileSystemURL& url,
const base::Time& last_access_time,
const base::Time& last_modified_time) {
SandboxDirectoryDatabase* db = GetDirectoryDatabase(url, false);
if (!db)
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
FileId file_id;
if (!db->GetFileWithPath(url.path(), &file_id))
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
FileInfo file_info;
if (!db->GetFileInfo(file_id, &file_info)) {
NOTREACHED();
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
}
if (file_info.is_directory()) {
if (!db->UpdateModificationTime(file_id, last_modified_time))
- return base::PLATFORM_FILE_ERROR_FAILED;
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_ERROR_FAILED;
+ return base::File::FILE_OK;
}
return NativeFileUtil::Touch(
DataPathToLocalPath(url, file_info.data_path),
last_access_time, last_modified_time);
}
-PlatformFileError ObfuscatedFileUtil::Truncate(
+base::File::Error ObfuscatedFileUtil::Truncate(
FileSystemOperationContext* context,
const FileSystemURL& url,
int64 length) {
- base::PlatformFileInfo file_info;
+ base::File::Info file_info;
base::FilePath local_path;
- base::PlatformFileError error =
+ base::File::Error error =
GetFileInfo(context, url, &file_info, &local_path);
- if (error != base::PLATFORM_FILE_OK)
+ if (error != base::File::FILE_OK)
return error;
int64 growth = length - file_info.size;
if (!AllocateQuota(context, growth))
- return base::PLATFORM_FILE_ERROR_NO_SPACE;
+ return base::File::FILE_ERROR_NO_SPACE;
error = NativeFileUtil::Truncate(local_path, length);
- if (error == base::PLATFORM_FILE_OK) {
+ if (error == base::File::FILE_OK) {
UpdateUsage(context, url, growth);
context->change_observers()->Notify(
&FileChangeObserver::OnModifyFile, MakeTuple(url));
@@ -497,7 +486,7 @@ PlatformFileError ObfuscatedFileUtil::Truncate(
return error;
}
-PlatformFileError ObfuscatedFileUtil::CopyOrMoveFile(
+base::File::Error ObfuscatedFileUtil::CopyOrMoveFile(
FileSystemOperationContext* context,
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
@@ -509,46 +498,46 @@ PlatformFileError ObfuscatedFileUtil::CopyOrMoveFile(
SandboxDirectoryDatabase* db = GetDirectoryDatabase(src_url, true);
if (!db)
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
FileId src_file_id;
if (!db->GetFileWithPath(src_url.path(), &src_file_id))
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
FileId dest_file_id;
bool overwrite = db->GetFileWithPath(dest_url.path(),
&dest_file_id);
FileInfo src_file_info;
- base::PlatformFileInfo src_platform_file_info;
+ base::File::Info src_platform_file_info;
base::FilePath src_local_path;
- base::PlatformFileError error = GetFileInfoInternal(
+ base::File::Error error = GetFileInfoInternal(
db, context, src_url, src_file_id,
&src_file_info, &src_platform_file_info, &src_local_path);
- if (error != base::PLATFORM_FILE_OK)
+ if (error != base::File::FILE_OK)
return error;
if (src_file_info.is_directory())
- return base::PLATFORM_FILE_ERROR_NOT_A_FILE;
+ return base::File::FILE_ERROR_NOT_A_FILE;
FileInfo dest_file_info;
- base::PlatformFileInfo dest_platform_file_info; // overwrite case only
+ base::File::Info dest_platform_file_info; // overwrite case only
base::FilePath dest_local_path; // overwrite case only
if (overwrite) {
- base::PlatformFileError error = GetFileInfoInternal(
+ base::File::Error error = GetFileInfoInternal(
db, context, dest_url, dest_file_id,
&dest_file_info, &dest_platform_file_info, &dest_local_path);
- if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND)
+ if (error == base::File::FILE_ERROR_NOT_FOUND)
overwrite = false; // fallback to non-overwrite case
- else if (error != base::PLATFORM_FILE_OK)
+ else if (error != base::File::FILE_OK)
return error;
else if (dest_file_info.is_directory())
- return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
+ return base::File::FILE_ERROR_INVALID_OPERATION;
}
if (!overwrite) {
FileId dest_parent_id;
if (!db->GetFileWithPath(VirtualPath::DirName(dest_url.path()),
&dest_parent_id)) {
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
}
dest_file_info = src_file_info;
@@ -567,7 +556,7 @@ PlatformFileError ObfuscatedFileUtil::CopyOrMoveFile(
else
growth += UsageForPath(dest_file_info.name.size());
if (!AllocateQuota(context, growth))
- return base::PLATFORM_FILE_ERROR_NO_SPACE;
+ return base::File::FILE_ERROR_NO_SPACE;
/*
* Copy-with-overwrite
@@ -583,7 +572,7 @@ PlatformFileError ObfuscatedFileUtil::CopyOrMoveFile(
* Move-without-overwrite
* Just update metadata
*/
- error = base::PLATFORM_FILE_ERROR_FAILED;
+ error = base::File::FILE_ERROR_FAILED;
if (copy) {
if (overwrite) {
error = NativeFileUtil::CopyOrMoveFile(
@@ -593,28 +582,27 @@ PlatformFileError ObfuscatedFileUtil::CopyOrMoveFile(
fileapi::NativeFileUtil::CopyOrMoveModeForDestination(
dest_url, true /* copy */));
} else { // non-overwrite
- error = CreateFile(context, src_local_path,
- dest_url, &dest_file_info, 0, NULL);
+ error = CreateFile(context, src_local_path, dest_url, &dest_file_info);
}
} else {
if (overwrite) {
if (db->OverwritingMoveFile(src_file_id, dest_file_id)) {
- if (base::PLATFORM_FILE_OK !=
+ if (base::File::FILE_OK !=
NativeFileUtil::DeleteFile(dest_local_path))
LOG(WARNING) << "Leaked a backing file.";
- error = base::PLATFORM_FILE_OK;
+ error = base::File::FILE_OK;
} else {
- error = base::PLATFORM_FILE_ERROR_FAILED;
+ error = base::File::FILE_ERROR_FAILED;
}
} else { // non-overwrite
if (db->UpdateFileInfo(src_file_id, dest_file_info))
- error = base::PLATFORM_FILE_OK;
+ error = base::File::FILE_OK;
else
- error = base::PLATFORM_FILE_ERROR_FAILED;
+ error = base::File::FILE_ERROR_FAILED;
}
}
- if (error != base::PLATFORM_FILE_OK)
+ if (error != base::File::FILE_OK)
return error;
if (overwrite) {
@@ -639,44 +627,44 @@ PlatformFileError ObfuscatedFileUtil::CopyOrMoveFile(
return error;
}
-PlatformFileError ObfuscatedFileUtil::CopyInForeignFile(
+base::File::Error ObfuscatedFileUtil::CopyInForeignFile(
FileSystemOperationContext* context,
const base::FilePath& src_file_path,
const FileSystemURL& dest_url) {
SandboxDirectoryDatabase* db = GetDirectoryDatabase(dest_url, true);
if (!db)
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
- base::PlatformFileInfo src_platform_file_info;
+ base::File::Info src_platform_file_info;
if (!base::GetFileInfo(src_file_path, &src_platform_file_info))
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
FileId dest_file_id;
bool overwrite = db->GetFileWithPath(dest_url.path(),
&dest_file_id);
FileInfo dest_file_info;
- base::PlatformFileInfo dest_platform_file_info; // overwrite case only
+ base::File::Info dest_platform_file_info; // overwrite case only
if (overwrite) {
base::FilePath dest_local_path;
- base::PlatformFileError error = GetFileInfoInternal(
+ base::File::Error error = GetFileInfoInternal(
db, context, dest_url, dest_file_id,
&dest_file_info, &dest_platform_file_info, &dest_local_path);
- if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND)
+ if (error == base::File::FILE_ERROR_NOT_FOUND)
overwrite = false; // fallback to non-overwrite case
- else if (error != base::PLATFORM_FILE_OK)
+ else if (error != base::File::FILE_OK)
return error;
else if (dest_file_info.is_directory())
- return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
+ return base::File::FILE_ERROR_INVALID_OPERATION;
}
if (!overwrite) {
FileId dest_parent_id;
if (!db->GetFileWithPath(VirtualPath::DirName(dest_url.path()),
&dest_parent_id)) {
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
}
if (!dest_file_info.is_directory())
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
InitFileInfo(&dest_file_info, dest_parent_id,
VirtualPath::BaseName(dest_url.path()).value());
}
@@ -687,9 +675,9 @@ PlatformFileError ObfuscatedFileUtil::CopyInForeignFile(
else
growth += UsageForPath(dest_file_info.name.size());
if (!AllocateQuota(context, growth))
- return base::PLATFORM_FILE_ERROR_NO_SPACE;
+ return base::File::FILE_ERROR_NO_SPACE;
- base::PlatformFileError error;
+ base::File::Error error;
if (overwrite) {
base::FilePath dest_local_path =
DataPathToLocalPath(dest_url, dest_file_info.data_path);
@@ -699,11 +687,10 @@ PlatformFileError ObfuscatedFileUtil::CopyInForeignFile(
fileapi::NativeFileUtil::CopyOrMoveModeForDestination(dest_url,
true /* copy */));
} else {
- error = CreateFile(context, src_file_path,
- dest_url, &dest_file_info, 0, NULL);
+ error = CreateFile(context, src_file_path, dest_url, &dest_file_info);
}
- if (error != base::PLATFORM_FILE_OK)
+ if (error != base::File::FILE_OK)
return error;
if (overwrite) {
@@ -716,36 +703,36 @@ PlatformFileError ObfuscatedFileUtil::CopyInForeignFile(
UpdateUsage(context, dest_url, growth);
TouchDirectory(db, dest_file_info.parent_id);
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_OK;
}
-PlatformFileError ObfuscatedFileUtil::DeleteFile(
+base::File::Error ObfuscatedFileUtil::DeleteFile(
FileSystemOperationContext* context,
const FileSystemURL& url) {
SandboxDirectoryDatabase* db = GetDirectoryDatabase(url, true);
if (!db)
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
FileId file_id;
if (!db->GetFileWithPath(url.path(), &file_id))
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
FileInfo file_info;
- base::PlatformFileInfo platform_file_info;
+ base::File::Info platform_file_info;
base::FilePath local_path;
- base::PlatformFileError error = GetFileInfoInternal(
+ base::File::Error error = GetFileInfoInternal(
db, context, url, file_id, &file_info, &platform_file_info, &local_path);
- if (error != base::PLATFORM_FILE_ERROR_NOT_FOUND &&
- error != base::PLATFORM_FILE_OK)
+ if (error != base::File::FILE_ERROR_NOT_FOUND &&
+ error != base::File::FILE_OK)
return error;
if (file_info.is_directory())
- return base::PLATFORM_FILE_ERROR_NOT_A_FILE;
+ return base::File::FILE_ERROR_NOT_A_FILE;
int64 growth = -UsageForPath(file_info.name.size()) - platform_file_info.size;
AllocateQuota(context, growth);
if (!db->RemoveFileInfo(file_id)) {
NOTREACHED();
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
}
UpdateUsage(context, url, growth);
TouchDirectory(db, file_info.parent_id);
@@ -753,54 +740,54 @@ PlatformFileError ObfuscatedFileUtil::DeleteFile(
context->change_observers()->Notify(
&FileChangeObserver::OnRemoveFile, MakeTuple(url));
- if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND)
- return base::PLATFORM_FILE_OK;
+ if (error == base::File::FILE_ERROR_NOT_FOUND)
+ return base::File::FILE_OK;
error = NativeFileUtil::DeleteFile(local_path);
- if (base::PLATFORM_FILE_OK != error)
+ if (base::File::FILE_OK != error)
LOG(WARNING) << "Leaked a backing file.";
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_OK;
}
-PlatformFileError ObfuscatedFileUtil::DeleteDirectory(
+base::File::Error ObfuscatedFileUtil::DeleteDirectory(
FileSystemOperationContext* context,
const FileSystemURL& url) {
SandboxDirectoryDatabase* db = GetDirectoryDatabase(url, true);
if (!db)
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
FileId file_id;
if (!db->GetFileWithPath(url.path(), &file_id))
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
FileInfo file_info;
if (!db->GetFileInfo(file_id, &file_info)) {
NOTREACHED();
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
}
if (!file_info.is_directory())
- return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY;
+ return base::File::FILE_ERROR_NOT_A_DIRECTORY;
if (!db->RemoveFileInfo(file_id))
- return base::PLATFORM_FILE_ERROR_NOT_EMPTY;
+ return base::File::FILE_ERROR_NOT_EMPTY;
int64 growth = -UsageForPath(file_info.name.size());
AllocateQuota(context, growth);
UpdateUsage(context, url, growth);
TouchDirectory(db, file_info.parent_id);
context->change_observers()->Notify(
&FileChangeObserver::OnRemoveDirectory, MakeTuple(url));
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_OK;
}
webkit_blob::ScopedFile ObfuscatedFileUtil::CreateSnapshotFile(
FileSystemOperationContext* context,
const FileSystemURL& url,
- base::PlatformFileError* error,
- base::PlatformFileInfo* file_info,
+ base::File::Error* error,
+ base::File::Info* file_info,
base::FilePath* platform_path) {
// We're just returning the local file information.
*error = GetFileInfo(context, url, file_info, platform_path);
- if (*error == base::PLATFORM_FILE_OK && file_info->is_directory) {
- *file_info = base::PlatformFileInfo();
- *error = base::PLATFORM_FILE_ERROR_NOT_A_FILE;
+ if (*error == base::File::FILE_OK && file_info->is_directory) {
+ *file_info = base::File::Info();
+ *error = base::File::FILE_ERROR_NOT_A_FILE;
}
return webkit_blob::ScopedFile();
}
@@ -846,19 +833,19 @@ base::FilePath ObfuscatedFileUtil::GetDirectoryForOriginAndType(
const GURL& origin,
const std::string& type_string,
bool create,
- base::PlatformFileError* error_code) {
+ base::File::Error* error_code) {
base::FilePath origin_dir = GetDirectoryForOrigin(origin, create, error_code);
if (origin_dir.empty())
return base::FilePath();
if (type_string.empty())
return origin_dir;
base::FilePath path = origin_dir.AppendASCII(type_string);
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
if (!base::DirectoryExists(path) &&
(!create || !base::CreateDirectory(path))) {
error = create ?
- base::PLATFORM_FILE_ERROR_FAILED :
- base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ base::File::FILE_ERROR_FAILED :
+ base::File::FILE_ERROR_NOT_FOUND;
}
if (error_code)
@@ -869,12 +856,12 @@ base::FilePath ObfuscatedFileUtil::GetDirectoryForOriginAndType(
bool ObfuscatedFileUtil::DeleteDirectoryForOriginAndType(
const GURL& origin,
const std::string& type_string) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
base::FilePath origin_type_path = GetDirectoryForOriginAndType(
origin, type_string, false, &error);
if (origin_type_path.empty())
return true;
- if (error != base::PLATFORM_FILE_ERROR_NOT_FOUND) {
+ if (error != base::File::FILE_ERROR_NOT_FOUND) {
// TODO(dmikurube): Consider the return value of DestroyDirectoryDatabase.
// We ignore its error now since 1) it doesn't matter the final result, and
// 2) it always returns false in Windows because of LevelDB's
@@ -940,12 +927,12 @@ bool ObfuscatedFileUtil::DestroyDirectoryDatabase(
delete database;
}
- PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
base::FilePath path = GetDirectoryForOriginAndType(
origin, type_string, false, &error);
- if (path.empty() || error == base::PLATFORM_FILE_ERROR_NOT_FOUND)
+ if (path.empty() || error == base::File::FILE_ERROR_NOT_FOUND)
return true;
- return SandboxDirectoryDatabase::DestroyDatabase(path);
+ return SandboxDirectoryDatabase::DestroyDatabase(path, env_override_);
}
// static
@@ -955,7 +942,8 @@ int64 ObfuscatedFileUtil::ComputeFilePathCost(const base::FilePath& path) {
void ObfuscatedFileUtil::MaybePrepopulateDatabase(
const std::vector<std::string>& type_strings_to_prepopulate) {
- SandboxPrioritizedOriginDatabase database(file_system_directory_);
+ SandboxPrioritizedOriginDatabase database(file_system_directory_,
+ env_override_);
std::string origin_string = database.GetPrimaryOrigin();
if (origin_string.empty() || !database.HasOriginPath(origin_string))
return;
@@ -968,12 +956,13 @@ void ObfuscatedFileUtil::MaybePrepopulateDatabase(
// Only handles known types.
if (!ContainsKey(known_type_strings_, type_string))
continue;
- PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
+ base::File::Error error = base::File::FILE_ERROR_FAILED;
base::FilePath path = GetDirectoryForOriginAndType(
origin, type_string, false, &error);
- if (error != base::PLATFORM_FILE_OK)
+ if (error != base::File::FILE_OK)
continue;
- scoped_ptr<SandboxDirectoryDatabase> db(new SandboxDirectoryDatabase(path));
+ scoped_ptr<SandboxDirectoryDatabase> db(
+ new SandboxDirectoryDatabase(path, env_override_));
if (db->Init(SandboxDirectoryDatabase::FAIL_ON_CORRUPTION)) {
directories_[GetDirectoryDatabaseKey(origin, type_string)] = db.release();
MarkUsed();
@@ -987,7 +976,7 @@ void ObfuscatedFileUtil::MaybePrepopulateDatabase(
base::FilePath ObfuscatedFileUtil::GetDirectoryForURL(
const FileSystemURL& url,
bool create,
- base::PlatformFileError* error_code) {
+ base::File::Error* error_code) {
return GetDirectoryForOriginAndType(
url.origin(), CallGetTypeStringForURL(url), create, error_code);
}
@@ -998,13 +987,13 @@ std::string ObfuscatedFileUtil::CallGetTypeStringForURL(
return get_type_string_for_url_.Run(url);
}
-PlatformFileError ObfuscatedFileUtil::GetFileInfoInternal(
+base::File::Error ObfuscatedFileUtil::GetFileInfoInternal(
SandboxDirectoryDatabase* db,
FileSystemOperationContext* context,
const FileSystemURL& url,
FileId file_id,
FileInfo* local_info,
- base::PlatformFileInfo* file_info,
+ base::File::Info* file_info,
base::FilePath* platform_file_path) {
DCHECK(db);
DCHECK(context);
@@ -1013,7 +1002,7 @@ PlatformFileError ObfuscatedFileUtil::GetFileInfoInternal(
if (!db->GetFileInfo(file_id, local_info)) {
NOTREACHED();
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
}
if (local_info->is_directory()) {
@@ -1023,117 +1012,131 @@ PlatformFileError ObfuscatedFileUtil::GetFileInfoInternal(
file_info->last_modified = local_info->modification_time;
*platform_file_path = base::FilePath();
// We don't fill in ctime or atime.
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_OK;
}
if (local_info->data_path.empty())
- return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
+ return base::File::FILE_ERROR_INVALID_OPERATION;
base::FilePath local_path = DataPathToLocalPath(url, local_info->data_path);
- base::PlatformFileError error = NativeFileUtil::GetFileInfo(
+ base::File::Error error = NativeFileUtil::GetFileInfo(
local_path, file_info);
// We should not follow symbolic links in sandboxed file system.
if (base::IsLink(local_path)) {
LOG(WARNING) << "Found a symbolic file.";
- error = base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ error = base::File::FILE_ERROR_NOT_FOUND;
}
- if (error == base::PLATFORM_FILE_OK) {
+ if (error == base::File::FILE_OK) {
*platform_file_path = local_path;
- } else if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND) {
+ } else if (error == base::File::FILE_ERROR_NOT_FOUND) {
LOG(WARNING) << "Lost a backing file.";
InvalidateUsageCache(context, url.origin(), url.type());
if (!db->RemoveFileInfo(file_id))
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
}
return error;
}
-PlatformFileError ObfuscatedFileUtil::CreateFile(
+base::File ObfuscatedFileUtil::CreateAndOpenFile(
FileSystemOperationContext* context,
- const base::FilePath& src_file_path,
const FileSystemURL& dest_url,
- FileInfo* dest_file_info, int file_flags, PlatformFile* handle) {
- if (handle)
- *handle = base::kInvalidPlatformFileValue;
+ FileInfo* dest_file_info, int file_flags) {
SandboxDirectoryDatabase* db = GetDirectoryDatabase(dest_url, true);
- PlatformFileError error = base::PLATFORM_FILE_OK;
- base::FilePath root = GetDirectoryForURL(dest_url, false, &error);
- if (error != base::PLATFORM_FILE_OK)
- return error;
+ base::FilePath root, dest_local_path;
+ base::File::Error error = GenerateNewLocalPath(db, context, dest_url, &root,
+ &dest_local_path);
+ if (error != base::File::FILE_OK)
+ return base::File(error);
+
+ if (base::PathExists(dest_local_path)) {
+ if (!base::DeleteFile(dest_local_path, true /* recursive */))
+ return base::File(base::File::FILE_ERROR_FAILED);
+ LOG(WARNING) << "A stray file detected";
+ InvalidateUsageCache(context, dest_url.origin(), dest_url.type());
+ }
+
+ base::File file = NativeFileUtil::CreateOrOpen(dest_local_path, file_flags);
+ if (!file.IsValid())
+ return file.Pass();
- base::FilePath dest_local_path;
- error = GenerateNewLocalPath(db, context, dest_url, &dest_local_path);
- if (error != base::PLATFORM_FILE_OK)
+ if (!file.created()) {
+ file.Close();
+ base::DeleteFile(dest_local_path, false /* recursive */);
+ return base::File(base::File::FILE_ERROR_FAILED);
+ }
+
+ error = CommitCreateFile(root, dest_local_path, db, dest_file_info);
+ if (error != base::File::FILE_OK) {
+ file.Close();
+ base::DeleteFile(dest_local_path, false /* recursive */);
+ return base::File(error);
+ }
+
+ return file.Pass();
+}
+
+base::File::Error ObfuscatedFileUtil::CreateFile(
+ FileSystemOperationContext* context,
+ const base::FilePath& src_file_path,
+ const FileSystemURL& dest_url,
+ FileInfo* dest_file_info) {
+ SandboxDirectoryDatabase* db = GetDirectoryDatabase(dest_url, true);
+
+ base::FilePath root, dest_local_path;
+ base::File::Error error = GenerateNewLocalPath(db, context, dest_url, &root,
+ &dest_local_path);
+ if (error != base::File::FILE_OK)
return error;
bool created = false;
- if (!src_file_path.empty()) {
- DCHECK(!file_flags);
- DCHECK(!handle);
+ if (src_file_path.empty()) {
+ if (base::PathExists(dest_local_path)) {
+ if (!base::DeleteFile(dest_local_path, true /* recursive */))
+ return base::File::FILE_ERROR_FAILED;
+ LOG(WARNING) << "A stray file detected";
+ InvalidateUsageCache(context, dest_url.origin(), dest_url.type());
+ }
+
+ error = NativeFileUtil::EnsureFileExists(dest_local_path, &created);
+ } else {
error = NativeFileUtil::CopyOrMoveFile(
src_file_path, dest_local_path,
FileSystemOperation::OPTION_NONE,
fileapi::NativeFileUtil::CopyOrMoveModeForDestination(dest_url,
true /* copy */));
created = true;
- } else {
- if (base::PathExists(dest_local_path)) {
- if (!base::DeleteFile(dest_local_path, true /* recursive */)) {
- NOTREACHED();
- return base::PLATFORM_FILE_ERROR_FAILED;
- }
- LOG(WARNING) << "A stray file detected";
- InvalidateUsageCache(context, dest_url.origin(), dest_url.type());
- }
-
- if (handle) {
- error = NativeFileUtil::CreateOrOpen(
- dest_local_path, file_flags, handle, &created);
- // If this succeeds, we must close handle on any subsequent error.
- } else {
- DCHECK(!file_flags); // file_flags is only used by CreateOrOpen.
- error = NativeFileUtil::EnsureFileExists(dest_local_path, &created);
- }
}
- if (error != base::PLATFORM_FILE_OK)
+ if (error != base::File::FILE_OK)
return error;
+ if (!created)
+ return base::File::FILE_ERROR_FAILED;
- if (!created) {
- NOTREACHED();
- if (handle) {
- DCHECK_NE(base::kInvalidPlatformFileValue, *handle);
- base::ClosePlatformFile(*handle);
- base::DeleteFile(dest_local_path, false /* recursive */);
- *handle = base::kInvalidPlatformFileValue;
- }
- return base::PLATFORM_FILE_ERROR_FAILED;
- }
+ return CommitCreateFile(root, dest_local_path, db, dest_file_info);
+}
+base::File::Error ObfuscatedFileUtil::CommitCreateFile(
+ const base::FilePath& root,
+ const base::FilePath& local_path,
+ SandboxDirectoryDatabase* db,
+ FileInfo* dest_file_info) {
// This removes the root, including the trailing slash, leaving a relative
// path.
dest_file_info->data_path = base::FilePath(
- dest_local_path.value().substr(root.value().length() + 1));
+ local_path.value().substr(root.value().length() + 1));
FileId file_id;
- error = db->AddFileInfo(*dest_file_info, &file_id);
- if (error != base::PLATFORM_FILE_OK) {
- if (handle) {
- DCHECK_NE(base::kInvalidPlatformFileValue, *handle);
- base::ClosePlatformFile(*handle);
- *handle = base::kInvalidPlatformFileValue;
- }
- base::DeleteFile(dest_local_path, false /* recursive */);
+ base::File::Error error = db->AddFileInfo(*dest_file_info, &file_id);
+ if (error != base::File::FILE_OK)
return error;
- }
- TouchDirectory(db, dest_file_info->parent_id);
- return base::PLATFORM_FILE_OK;
+ TouchDirectory(db, dest_file_info->parent_id);
+ return base::File::FILE_OK;
}
base::FilePath ObfuscatedFileUtil::DataPathToLocalPath(
const FileSystemURL& url, const base::FilePath& data_path) {
- PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
base::FilePath root = GetDirectoryForURL(url, false, &error);
- if (error != base::PLATFORM_FILE_OK)
+ if (error != base::File::FILE_OK)
return base::FilePath();
return root.Append(data_path);
}
@@ -1166,26 +1169,27 @@ SandboxDirectoryDatabase* ObfuscatedFileUtil::GetDirectoryDatabase(
return iter->second;
}
- PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
base::FilePath path = GetDirectoryForURL(url, create, &error);
- if (error != base::PLATFORM_FILE_OK) {
+ if (error != base::File::FILE_OK) {
LOG(WARNING) << "Failed to get origin+type directory: "
<< url.DebugString() << " error:" << error;
return NULL;
}
MarkUsed();
- SandboxDirectoryDatabase* database = new SandboxDirectoryDatabase(path);
+ SandboxDirectoryDatabase* database =
+ new SandboxDirectoryDatabase(path, env_override_);
directories_[key] = database;
return database;
}
base::FilePath ObfuscatedFileUtil::GetDirectoryForOrigin(
- const GURL& origin, bool create, base::PlatformFileError* error_code) {
+ const GURL& origin, bool create, base::File::Error* error_code) {
if (!InitOriginDatabase(origin, create)) {
if (error_code) {
*error_code = create ?
- base::PLATFORM_FILE_ERROR_FAILED :
- base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ base::File::FILE_ERROR_FAILED :
+ base::File::FILE_ERROR_NOT_FOUND;
}
return base::FilePath();
}
@@ -1195,12 +1199,12 @@ base::FilePath ObfuscatedFileUtil::GetDirectoryForOrigin(
bool exists_in_db = origin_database_->HasOriginPath(id);
if (!exists_in_db && !create) {
if (error_code)
- *error_code = base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ *error_code = base::File::FILE_ERROR_NOT_FOUND;
return base::FilePath();
}
if (!origin_database_->GetPathForOrigin(id, &directory_name)) {
if (error_code)
- *error_code = base::PLATFORM_FILE_ERROR_FAILED;
+ *error_code = base::File::FILE_ERROR_FAILED;
return base::FilePath();
}
@@ -1209,7 +1213,7 @@ base::FilePath ObfuscatedFileUtil::GetDirectoryForOrigin(
if (!exists_in_db && exists_in_fs) {
if (!base::DeleteFile(path, true)) {
if (error_code)
- *error_code = base::PLATFORM_FILE_ERROR_FAILED;
+ *error_code = base::File::FILE_ERROR_FAILED;
return base::FilePath();
}
exists_in_fs = false;
@@ -1219,14 +1223,14 @@ base::FilePath ObfuscatedFileUtil::GetDirectoryForOrigin(
if (!create || !base::CreateDirectory(path)) {
if (error_code)
*error_code = create ?
- base::PLATFORM_FILE_ERROR_FAILED :
- base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ base::File::FILE_ERROR_FAILED :
+ base::File::FILE_ERROR_NOT_FOUND;
return base::FilePath();
}
}
if (error_code)
- *error_code = base::PLATFORM_FILE_OK;
+ *error_code = base::File::FILE_OK;
return path;
}
@@ -1275,7 +1279,8 @@ bool ObfuscatedFileUtil::InitOriginDatabase(const GURL& origin_hint,
}
SandboxPrioritizedOriginDatabase* prioritized_origin_database =
- new SandboxPrioritizedOriginDatabase(file_system_directory_);
+ new SandboxPrioritizedOriginDatabase(file_system_directory_,
+ env_override_);
origin_database_.reset(prioritized_origin_database);
if (origin_hint.is_empty() || !HasIsolatedStorage(origin_hint))
@@ -1301,113 +1306,113 @@ bool ObfuscatedFileUtil::InitOriginDatabase(const GURL& origin_hint,
return true;
}
-PlatformFileError ObfuscatedFileUtil::GenerateNewLocalPath(
+base::File::Error ObfuscatedFileUtil::GenerateNewLocalPath(
SandboxDirectoryDatabase* db,
FileSystemOperationContext* context,
const FileSystemURL& url,
+ base::FilePath* root,
base::FilePath* local_path) {
DCHECK(local_path);
int64 number;
if (!db || !db->GetNextInteger(&number))
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
- PlatformFileError error = base::PLATFORM_FILE_OK;
- base::FilePath new_local_path = GetDirectoryForURL(url, false, &error);
- if (error != base::PLATFORM_FILE_OK)
- return base::PLATFORM_FILE_ERROR_FAILED;
+ base::File::Error error = base::File::FILE_OK;
+ *root = GetDirectoryForURL(url, false, &error);
+ if (error != base::File::FILE_OK)
+ return error;
// We use the third- and fourth-to-last digits as the directory.
int64 directory_number = number % 10000 / 100;
- new_local_path = new_local_path.AppendASCII(
+ base::FilePath new_local_path = root->AppendASCII(
base::StringPrintf("%02" PRId64, directory_number));
error = NativeFileUtil::CreateDirectory(
new_local_path, false /* exclusive */, false /* recursive */);
- if (error != base::PLATFORM_FILE_OK)
+ if (error != base::File::FILE_OK)
return error;
*local_path =
new_local_path.AppendASCII(base::StringPrintf("%08" PRId64, number));
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_OK;
}
-PlatformFileError ObfuscatedFileUtil::CreateOrOpenInternal(
+base::File ObfuscatedFileUtil::CreateOrOpenInternal(
FileSystemOperationContext* context,
- const FileSystemURL& url, int file_flags,
- PlatformFile* file_handle, bool* created) {
- DCHECK(!(file_flags & (base::PLATFORM_FILE_DELETE_ON_CLOSE |
- base::PLATFORM_FILE_HIDDEN | base::PLATFORM_FILE_EXCLUSIVE_READ |
- base::PLATFORM_FILE_EXCLUSIVE_WRITE)));
+ const FileSystemURL& url, int file_flags) {
+ DCHECK(!(file_flags & (base::File::FLAG_DELETE_ON_CLOSE |
+ base::File::FLAG_HIDDEN | base::File::FLAG_EXCLUSIVE_READ |
+ base::File::FLAG_EXCLUSIVE_WRITE)));
SandboxDirectoryDatabase* db = GetDirectoryDatabase(url, true);
if (!db)
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File(base::File::FILE_ERROR_FAILED);
FileId file_id;
if (!db->GetFileWithPath(url.path(), &file_id)) {
// The file doesn't exist.
- if (!(file_flags & (base::PLATFORM_FILE_CREATE |
- base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_OPEN_ALWAYS)))
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ if (!(file_flags & (base::File::FLAG_CREATE |
+ base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_OPEN_ALWAYS))) {
+ return base::File(base::File::FILE_ERROR_NOT_FOUND);
+ }
FileId parent_id;
- if (!db->GetFileWithPath(VirtualPath::DirName(url.path()),
- &parent_id))
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ if (!db->GetFileWithPath(VirtualPath::DirName(url.path()), &parent_id))
+ return base::File(base::File::FILE_ERROR_NOT_FOUND);
FileInfo file_info;
InitFileInfo(&file_info, parent_id,
VirtualPath::BaseName(url.path()).value());
int64 growth = UsageForPath(file_info.name.size());
if (!AllocateQuota(context, growth))
- return base::PLATFORM_FILE_ERROR_NO_SPACE;
- PlatformFileError error = CreateFile(
- context, base::FilePath(),
- url, &file_info, file_flags, file_handle);
- if (created && base::PLATFORM_FILE_OK == error) {
- *created = true;
+ return base::File(base::File::FILE_ERROR_NO_SPACE);
+ base::File file = CreateAndOpenFile(context, url, &file_info, file_flags);
+ if (file.IsValid()) {
UpdateUsage(context, url, growth);
context->change_observers()->Notify(
&FileChangeObserver::OnCreateFile, MakeTuple(url));
}
- return error;
+ return file.Pass();
}
- if (file_flags & base::PLATFORM_FILE_CREATE)
- return base::PLATFORM_FILE_ERROR_EXISTS;
+ if (file_flags & base::File::FLAG_CREATE)
+ return base::File(base::File::FILE_ERROR_EXISTS);
- base::PlatformFileInfo platform_file_info;
+ base::File::Info platform_file_info;
base::FilePath local_path;
FileInfo file_info;
- base::PlatformFileError error = GetFileInfoInternal(
+ base::File::Error error = GetFileInfoInternal(
db, context, url, file_id, &file_info, &platform_file_info, &local_path);
- if (error != base::PLATFORM_FILE_OK)
- return error;
+ if (error != base::File::FILE_OK)
+ return base::File(error);
if (file_info.is_directory())
- return base::PLATFORM_FILE_ERROR_NOT_A_FILE;
+ return base::File(base::File::FILE_ERROR_NOT_A_FILE);
int64 delta = 0;
- if (file_flags & (base::PLATFORM_FILE_CREATE_ALWAYS |
- base::PLATFORM_FILE_OPEN_TRUNCATED)) {
+ if (file_flags & (base::File::FLAG_CREATE_ALWAYS |
+ base::File::FLAG_OPEN_TRUNCATED)) {
// The file exists and we're truncating.
delta = -platform_file_info.size;
AllocateQuota(context, delta);
}
- error = NativeFileUtil::CreateOrOpen(
- local_path, file_flags, file_handle, created);
- if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND) {
- // TODO(tzik): Also invalidate on-memory usage cache in UsageTracker.
- // TODO(tzik): Delete database entry after ensuring the file lost.
- InvalidateUsageCache(context, url.origin(), url.type());
- LOG(WARNING) << "Lost a backing file.";
- error = base::PLATFORM_FILE_ERROR_FAILED;
+ base::File file = NativeFileUtil::CreateOrOpen(local_path, file_flags);
+ if (!file.IsValid()) {
+ error = file.error_details();
+ if (error == base::File::FILE_ERROR_NOT_FOUND) {
+ // TODO(tzik): Also invalidate on-memory usage cache in UsageTracker.
+ // TODO(tzik): Delete database entry after ensuring the file lost.
+ InvalidateUsageCache(context, url.origin(), url.type());
+ LOG(WARNING) << "Lost a backing file.";
+ return base::File(base::File::FILE_ERROR_FAILED);
+ }
+ return file.Pass();
}
// If truncating we need to update the usage.
- if (error == base::PLATFORM_FILE_OK && delta) {
+ if (delta) {
UpdateUsage(context, url, delta);
context->change_observers()->Notify(
&FileChangeObserver::OnModifyFile, MakeTuple(url));
}
- return error;
+ return file.Pass();
}
bool ObfuscatedFileUtil::HasIsolatedStorage(const GURL& origin) {
diff --git a/chromium/webkit/browser/fileapi/obfuscated_file_util.h b/chromium/webkit/browser/fileapi/obfuscated_file_util.h
index 05d55308d84..ada4e6f955a 100644
--- a/chromium/webkit/browser/fileapi/obfuscated_file_util.h
+++ b/chromium/webkit/browser/fileapi/obfuscated_file_util.h
@@ -11,11 +11,11 @@
#include <vector>
#include "base/callback_forward.h"
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/file_util_proxy.h"
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
-#include "base/platform_file.h"
#include "webkit/browser/fileapi/file_system_file_util.h"
#include "webkit/browser/fileapi/file_system_url.h"
#include "webkit/browser/fileapi/sandbox_directory_database.h"
@@ -29,6 +29,11 @@ class SequencedTaskRunner;
class TimeTicks;
}
+namespace content {
+class ObfuscatedFileUtilTest;
+class QuotaBackendImplTest;
+}
+
namespace quota {
class SpecialStoragePolicy;
}
@@ -99,6 +104,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE ObfuscatedFileUtil
ObfuscatedFileUtil(
quota::SpecialStoragePolicy* special_storage_policy,
const base::FilePath& file_system_directory,
+ leveldb::Env* env_override,
base::SequencedTaskRunner* file_task_runner,
const GetTypeStringForURLCallback& get_type_string_for_url,
const std::set<std::string>& known_type_strings,
@@ -106,65 +112,60 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE ObfuscatedFileUtil
virtual ~ObfuscatedFileUtil();
// FileSystemFileUtil overrides.
- virtual base::PlatformFileError CreateOrOpen(
+ virtual base::File CreateOrOpen(
FileSystemOperationContext* context,
const FileSystemURL& url,
- int file_flags,
- base::PlatformFile* file_handle,
- bool* created) OVERRIDE;
- virtual base::PlatformFileError Close(
- FileSystemOperationContext* context,
- base::PlatformFile file) OVERRIDE;
- virtual base::PlatformFileError EnsureFileExists(
+ int file_flags) OVERRIDE;
+ virtual base::File::Error EnsureFileExists(
FileSystemOperationContext* context,
const FileSystemURL& url, bool* created) OVERRIDE;
- virtual base::PlatformFileError CreateDirectory(
+ virtual base::File::Error CreateDirectory(
FileSystemOperationContext* context,
const FileSystemURL& url,
bool exclusive,
bool recursive) OVERRIDE;
- virtual base::PlatformFileError GetFileInfo(
+ virtual base::File::Error GetFileInfo(
FileSystemOperationContext* context,
const FileSystemURL& url,
- base::PlatformFileInfo* file_info,
+ base::File::Info* file_info,
base::FilePath* platform_file) OVERRIDE;
virtual scoped_ptr<AbstractFileEnumerator> CreateFileEnumerator(
FileSystemOperationContext* context,
const FileSystemURL& root_url) OVERRIDE;
- virtual base::PlatformFileError GetLocalFilePath(
+ virtual base::File::Error GetLocalFilePath(
FileSystemOperationContext* context,
const FileSystemURL& file_system_url,
base::FilePath* local_path) OVERRIDE;
- virtual base::PlatformFileError Touch(
+ virtual base::File::Error Touch(
FileSystemOperationContext* context,
const FileSystemURL& url,
const base::Time& last_access_time,
const base::Time& last_modified_time) OVERRIDE;
- virtual base::PlatformFileError Truncate(
+ virtual base::File::Error Truncate(
FileSystemOperationContext* context,
const FileSystemURL& url,
int64 length) OVERRIDE;
- virtual base::PlatformFileError CopyOrMoveFile(
+ virtual base::File::Error CopyOrMoveFile(
FileSystemOperationContext* context,
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
CopyOrMoveOption option,
bool copy) OVERRIDE;
- virtual base::PlatformFileError CopyInForeignFile(
+ virtual base::File::Error CopyInForeignFile(
FileSystemOperationContext* context,
const base::FilePath& src_file_path,
const FileSystemURL& dest_url) OVERRIDE;
- virtual base::PlatformFileError DeleteFile(
+ virtual base::File::Error DeleteFile(
FileSystemOperationContext* context,
const FileSystemURL& url) OVERRIDE;
- virtual base::PlatformFileError DeleteDirectory(
+ virtual base::File::Error DeleteDirectory(
FileSystemOperationContext* context,
const FileSystemURL& url) OVERRIDE;
virtual webkit_blob::ScopedFile CreateSnapshotFile(
FileSystemOperationContext* context,
const FileSystemURL& url,
- base::PlatformFileError* error,
- base::PlatformFileInfo* file_info,
+ base::File::Error* error,
+ base::File::Info* file_info,
base::FilePath* platform_path) OVERRIDE;
// Same as the other CreateFileEnumerator, but with recursive support.
@@ -191,7 +192,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE ObfuscatedFileUtil
const GURL& origin,
const std::string& type_string,
bool create,
- base::PlatformFileError* error_code);
+ base::File::Error* error_code);
// Deletes the topmost directory specific to this origin and type. This will
// delete its directory database.
@@ -229,17 +230,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE ObfuscatedFileUtil
typedef SandboxDirectoryDatabase::FileInfo FileInfo;
friend class ObfuscatedFileEnumerator;
- friend class ObfuscatedFileUtilTest;
- friend class QuotaBackendImplTest;
- FRIEND_TEST_ALL_PREFIXES(ObfuscatedFileUtilTest, MaybeDropDatabasesAliveCase);
- FRIEND_TEST_ALL_PREFIXES(ObfuscatedFileUtilTest,
- MaybeDropDatabasesAlreadyDeletedCase);
- FRIEND_TEST_ALL_PREFIXES(ObfuscatedFileUtilTest,
- DestroyDirectoryDatabase_Isolated);
- FRIEND_TEST_ALL_PREFIXES(ObfuscatedFileUtilTest,
- GetDirectoryDatabase_Isolated);
- FRIEND_TEST_ALL_PREFIXES(ObfuscatedFileUtilTest,
- MigrationBackFromIsolated);
+ friend class content::ObfuscatedFileUtilTest;
+ friend class content::QuotaBackendImplTest;
// Helper method to create an obfuscated file util for regular
// (temporary, persistent) file systems. Used only for testing.
@@ -247,43 +239,52 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE ObfuscatedFileUtil
static ObfuscatedFileUtil* CreateForTesting(
quota::SpecialStoragePolicy* special_storage_policy,
const base::FilePath& file_system_directory,
+ leveldb::Env* env_override,
base::SequencedTaskRunner* file_task_runner);
base::FilePath GetDirectoryForURL(
const FileSystemURL& url,
bool create,
- base::PlatformFileError* error_code);
+ base::File::Error* error_code);
// This just calls get_type_string_for_url_ callback that is given in ctor.
std::string CallGetTypeStringForURL(const FileSystemURL& url);
- base::PlatformFileError GetFileInfoInternal(
+ base::File::Error GetFileInfoInternal(
SandboxDirectoryDatabase* db,
FileSystemOperationContext* context,
const FileSystemURL& url,
FileId file_id,
FileInfo* local_info,
- base::PlatformFileInfo* file_info,
+ base::File::Info* file_info,
base::FilePath* platform_file_path);
// Creates a new file, both the underlying backing file and the entry in the
// database. |dest_file_info| is an in-out parameter. Supply the name and
// parent_id; data_path is ignored. On success, data_path will
// always be set to the relative path [from the root of the type-specific
- // filesystem directory] of a NEW backing file, and handle, if supplied, will
- // hold open PlatformFile for the backing file, which the caller is
- // responsible for closing. If you supply a path in |source_path|, it will be
- // used as a source from which to COPY data.
- // Caveat: do not supply handle if you're also supplying a data path. It was
- // easier not to support this, and no code has needed it so far, so it will
- // DCHECK and handle will hold base::kInvalidPlatformFileValue.
- base::PlatformFileError CreateFile(
+ // filesystem directory] of a NEW backing file. Returns the new file.
+ base::File CreateAndOpenFile(
FileSystemOperationContext* context,
- const base::FilePath& source_file_path,
const FileSystemURL& dest_url,
FileInfo* dest_file_info,
- int file_flags,
- base::PlatformFile* handle);
+ int file_flags);
+
+ // The same as CreateAndOpenFile except that a file is not returned and if a
+ // path is provided in |source_path|, it will be used as a source from which
+ // to COPY data.
+ base::File::Error CreateFile(
+ FileSystemOperationContext* context,
+ const base::FilePath& source_file_path,
+ const FileSystemURL& dest_url,
+ FileInfo* dest_file_info);
+
+ // Updates |db| and |dest_file_info| at the end of creating a new file.
+ base::File::Error CommitCreateFile(
+ const base::FilePath& root,
+ const base::FilePath& local_path,
+ SandboxDirectoryDatabase* db,
+ FileInfo* dest_file_info);
// This converts from a relative path [as is stored in the FileInfo.data_path
// field] to an absolute platform path that can be given to the native
@@ -305,7 +306,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE ObfuscatedFileUtil
// contain both the filesystem type subdirectories.
base::FilePath GetDirectoryForOrigin(const GURL& origin,
bool create,
- base::PlatformFileError* error_code);
+ base::File::Error* error_code);
void InvalidateUsageCache(FileSystemOperationContext* context,
const GURL& origin,
@@ -318,18 +319,17 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE ObfuscatedFileUtil
// for initializing database if it's not empty.
bool InitOriginDatabase(const GURL& origin_hint, bool create);
- base::PlatformFileError GenerateNewLocalPath(
+ base::File::Error GenerateNewLocalPath(
SandboxDirectoryDatabase* db,
FileSystemOperationContext* context,
const FileSystemURL& url,
+ base::FilePath* root,
base::FilePath* local_path);
- base::PlatformFileError CreateOrOpenInternal(
+ base::File CreateOrOpenInternal(
FileSystemOperationContext* context,
const FileSystemURL& url,
- int file_flags,
- base::PlatformFile* file_handle,
- bool* created);
+ int file_flags);
bool HasIsolatedStorage(const GURL& origin);
@@ -338,6 +338,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE ObfuscatedFileUtil
scoped_ptr<SandboxOriginDatabaseInterface> origin_database_;
scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
base::FilePath file_system_directory_;
+ leveldb::Env* env_override_;
// Used to delete database after a certain period of inactivity.
int64 db_flush_delay_seconds_;
diff --git a/chromium/webkit/browser/fileapi/plugin_private_file_system_backend.cc b/chromium/webkit/browser/fileapi/plugin_private_file_system_backend.cc
index 0426bd24911..2c8ed3bac8f 100644
--- a/chromium/webkit/browser/fileapi/plugin_private_file_system_backend.cc
+++ b/chromium/webkit/browser/fileapi/plugin_private_file_system_backend.cc
@@ -66,18 +66,18 @@ const base::FilePath::CharType* kFileSystemDirectory =
const base::FilePath::CharType* kPluginPrivateDirectory =
FILE_PATH_LITERAL("Plugins");
-base::PlatformFileError OpenFileSystemOnFileThread(
+base::File::Error OpenFileSystemOnFileTaskRunner(
ObfuscatedFileUtil* file_util,
PluginPrivateFileSystemBackend::FileSystemIDToPluginMap* plugin_map,
const GURL& origin_url,
const std::string& filesystem_id,
const std::string& plugin_id,
OpenFileSystemMode mode) {
- base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
+ base::File::Error error = base::File::FILE_ERROR_FAILED;
const bool create = (mode == OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT);
file_util->GetDirectoryForOriginAndType(
origin_url, plugin_id, create, &error);
- if (error == base::PLATFORM_FILE_OK)
+ if (error == base::File::FILE_OK)
plugin_map->RegisterFileSystem(filesystem_id, plugin_id);
return error;
}
@@ -98,7 +98,7 @@ PluginPrivateFileSystemBackend::PluginPrivateFileSystemBackend(
file_util_.reset(
new AsyncFileUtilAdapter(new ObfuscatedFileUtil(
special_storage_policy,
- base_path_,
+ base_path_, file_system_options.env_override(),
file_task_runner,
base::Bind(&FileSystemIDToPluginMap::GetPluginIDForURL,
base::Owned(plugin_map_)),
@@ -123,14 +123,14 @@ void PluginPrivateFileSystemBackend::OpenPrivateFileSystem(
const StatusCallback& callback) {
if (!CanHandleType(type) || file_system_options_.is_incognito()) {
base::MessageLoopProxy::current()->PostTask(
- FROM_HERE, base::Bind(callback, base::PLATFORM_FILE_ERROR_SECURITY));
+ FROM_HERE, base::Bind(callback, base::File::FILE_ERROR_SECURITY));
return;
}
PostTaskAndReplyWithResult(
file_task_runner_.get(),
FROM_HERE,
- base::Bind(&OpenFileSystemOnFileThread,
+ base::Bind(&OpenFileSystemOnFileTaskRunner,
obfuscated_file_util(), plugin_map_,
origin_url, filesystem_id, plugin_id, mode),
callback);
@@ -143,17 +143,16 @@ bool PluginPrivateFileSystemBackend::CanHandleType(FileSystemType type) const {
void PluginPrivateFileSystemBackend::Initialize(FileSystemContext* context) {
}
-void PluginPrivateFileSystemBackend::OpenFileSystem(
- const GURL& origin_url,
- FileSystemType type,
+void PluginPrivateFileSystemBackend::ResolveURL(
+ const FileSystemURL& url,
OpenFileSystemMode mode,
const OpenFileSystemCallback& callback) {
// We never allow opening a new plugin-private filesystem via usual
- // OpenFileSystem.
+ // ResolveURL.
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
base::Bind(callback, GURL(), std::string(),
- base::PLATFORM_FILE_ERROR_SECURITY));
+ base::File::FILE_ERROR_SECURITY));
}
AsyncFileUtil*
@@ -164,21 +163,26 @@ PluginPrivateFileSystemBackend::GetAsyncFileUtil(FileSystemType type) {
CopyOrMoveFileValidatorFactory*
PluginPrivateFileSystemBackend::GetCopyOrMoveFileValidatorFactory(
FileSystemType type,
- base::PlatformFileError* error_code) {
+ base::File::Error* error_code) {
DCHECK(error_code);
- *error_code = base::PLATFORM_FILE_OK;
+ *error_code = base::File::FILE_OK;
return NULL;
}
FileSystemOperation* PluginPrivateFileSystemBackend::CreateFileSystemOperation(
const FileSystemURL& url,
FileSystemContext* context,
- base::PlatformFileError* error_code) const {
+ base::File::Error* error_code) const {
scoped_ptr<FileSystemOperationContext> operation_context(
new FileSystemOperationContext(context));
return FileSystemOperation::Create(url, context, operation_context.Pass());
}
+bool PluginPrivateFileSystemBackend::SupportsStreaming(
+ const fileapi::FileSystemURL& url) const {
+ return false;
+}
+
scoped_ptr<webkit_blob::FileStreamReader>
PluginPrivateFileSystemBackend::CreateFileStreamReader(
const FileSystemURL& url,
@@ -200,22 +204,22 @@ FileSystemQuotaUtil* PluginPrivateFileSystemBackend::GetQuotaUtil() {
return this;
}
-base::PlatformFileError
-PluginPrivateFileSystemBackend::DeleteOriginDataOnFileThread(
+base::File::Error
+PluginPrivateFileSystemBackend::DeleteOriginDataOnFileTaskRunner(
FileSystemContext* context,
quota::QuotaManagerProxy* proxy,
const GURL& origin_url,
FileSystemType type) {
if (!CanHandleType(type))
- return base::PLATFORM_FILE_ERROR_SECURITY;
+ return base::File::FILE_ERROR_SECURITY;
bool result = obfuscated_file_util()->DeleteDirectoryForOriginAndType(
origin_url, std::string());
if (result)
- return base::PLATFORM_FILE_OK;
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_OK;
+ return base::File::FILE_ERROR_FAILED;
}
-void PluginPrivateFileSystemBackend::GetOriginsForTypeOnFileThread(
+void PluginPrivateFileSystemBackend::GetOriginsForTypeOnFileTaskRunner(
FileSystemType type,
std::set<GURL>* origins) {
if (!CanHandleType(type))
@@ -227,7 +231,7 @@ void PluginPrivateFileSystemBackend::GetOriginsForTypeOnFileThread(
origins->insert(origin);
}
-void PluginPrivateFileSystemBackend::GetOriginsForHostOnFileThread(
+void PluginPrivateFileSystemBackend::GetOriginsForHostOnFileTaskRunner(
FileSystemType type,
const std::string& host,
std::set<GURL>* origins) {
@@ -242,7 +246,7 @@ void PluginPrivateFileSystemBackend::GetOriginsForHostOnFileThread(
}
}
-int64 PluginPrivateFileSystemBackend::GetOriginUsageOnFileThread(
+int64 PluginPrivateFileSystemBackend::GetOriginUsageOnFileTaskRunner(
FileSystemContext* context,
const GURL& origin_url,
FileSystemType type) {
diff --git a/chromium/webkit/browser/fileapi/plugin_private_file_system_backend.h b/chromium/webkit/browser/fileapi/plugin_private_file_system_backend.h
index d41f4b7eced..35612b16747 100644
--- a/chromium/webkit/browser/fileapi/plugin_private_file_system_backend.h
+++ b/chromium/webkit/browser/fileapi/plugin_private_file_system_backend.h
@@ -18,6 +18,10 @@ namespace base {
class SequencedTaskRunner;
}
+namespace content {
+class PluginPrivateFileSystemBackendTest;
+}
+
namespace quota {
class SpecialStoragePolicy;
}
@@ -31,7 +35,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT PluginPrivateFileSystemBackend
public FileSystemQuotaUtil {
public:
class FileSystemIDToPluginMap;
- typedef base::Callback<void(base::PlatformFileError result)> StatusCallback;
+ typedef base::Callback<void(base::File::Error result)> StatusCallback;
PluginPrivateFileSystemBackend(
base::SequencedTaskRunner* file_task_runner,
@@ -57,19 +61,18 @@ class WEBKIT_STORAGE_BROWSER_EXPORT PluginPrivateFileSystemBackend
// FileSystemBackend overrides.
virtual bool CanHandleType(FileSystemType type) const OVERRIDE;
virtual void Initialize(FileSystemContext* context) OVERRIDE;
- virtual void OpenFileSystem(
- const GURL& origin_url,
- FileSystemType type,
- OpenFileSystemMode mode,
- const OpenFileSystemCallback& callback) OVERRIDE;
+ virtual void ResolveURL(const FileSystemURL& url,
+ OpenFileSystemMode mode,
+ const OpenFileSystemCallback& callback) OVERRIDE;
virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE;
virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory(
FileSystemType type,
- base::PlatformFileError* error_code) OVERRIDE;
+ base::File::Error* error_code) OVERRIDE;
virtual FileSystemOperation* CreateFileSystemOperation(
const FileSystemURL& url,
FileSystemContext* context,
- base::PlatformFileError* error_code) const OVERRIDE;
+ base::File::Error* error_code) const OVERRIDE;
+ virtual bool SupportsStreaming(const FileSystemURL& url) const OVERRIDE;
virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader(
const FileSystemURL& url,
int64 offset,
@@ -82,19 +85,19 @@ class WEBKIT_STORAGE_BROWSER_EXPORT PluginPrivateFileSystemBackend
virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE;
// FileSystemQuotaUtil overrides.
- virtual base::PlatformFileError DeleteOriginDataOnFileThread(
+ virtual base::File::Error DeleteOriginDataOnFileTaskRunner(
FileSystemContext* context,
quota::QuotaManagerProxy* proxy,
const GURL& origin_url,
FileSystemType type) OVERRIDE;
- virtual void GetOriginsForTypeOnFileThread(
+ virtual void GetOriginsForTypeOnFileTaskRunner(
FileSystemType type,
std::set<GURL>* origins) OVERRIDE;
- virtual void GetOriginsForHostOnFileThread(
+ virtual void GetOriginsForHostOnFileTaskRunner(
FileSystemType type,
const std::string& host,
std::set<GURL>* origins) OVERRIDE;
- virtual int64 GetOriginUsageOnFileThread(
+ virtual int64 GetOriginUsageOnFileTaskRunner(
FileSystemContext* context,
const GURL& origin_url,
FileSystemType type) OVERRIDE;
@@ -122,7 +125,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT PluginPrivateFileSystemBackend
FileSystemType type) const OVERRIDE;
private:
- friend class PluginPrivateFileSystemBackendTest;
+ friend class content::PluginPrivateFileSystemBackendTest;
ObfuscatedFileUtil* obfuscated_file_util();
const base::FilePath& base_path() const { return base_path_; }
diff --git a/chromium/webkit/browser/fileapi/quota/open_file_handle.cc b/chromium/webkit/browser/fileapi/quota/open_file_handle.cc
index f0f69c66587..27f50b1351f 100644
--- a/chromium/webkit/browser/fileapi/quota/open_file_handle.cc
+++ b/chromium/webkit/browser/fileapi/quota/open_file_handle.cc
@@ -13,21 +13,36 @@ OpenFileHandle::~OpenFileHandle() {
DCHECK(sequence_checker_.CalledOnValidSequencedThread());
}
-int64 OpenFileHandle::UpdateMaxWrittenOffset(int64 offset) {
+void OpenFileHandle::UpdateMaxWrittenOffset(int64 offset) {
DCHECK(sequence_checker_.CalledOnValidSequencedThread());
- int64 new_file_size = 0;
- int64 growth = 0;
- context_->UpdateMaxWrittenOffset(offset, &new_file_size, &growth);
-
+ int64 growth = context_->UpdateMaxWrittenOffset(offset);
if (growth > 0)
reservation_->ConsumeReservation(growth);
+}
+
+void OpenFileHandle::AddAppendModeWriteAmount(int64 amount) {
+ DCHECK(sequence_checker_.CalledOnValidSequencedThread());
+ if (amount <= 0)
+ return;
- return new_file_size;
+ context_->AddAppendModeWriteAmount(amount);
+ reservation_->ConsumeReservation(amount);
}
-int64 OpenFileHandle::base_file_size() const {
- return context_->base_file_size();
+int64 OpenFileHandle::GetEstimatedFileSize() const {
+ DCHECK(sequence_checker_.CalledOnValidSequencedThread());
+ return context_->GetEstimatedFileSize();
+}
+
+int64 OpenFileHandle::GetMaxWrittenOffset() const {
+ DCHECK(sequence_checker_.CalledOnValidSequencedThread());
+ return context_->GetMaxWrittenOffset();
+}
+
+const base::FilePath& OpenFileHandle::platform_path() const {
+ DCHECK(sequence_checker_.CalledOnValidSequencedThread());
+ return context_->platform_path();
}
OpenFileHandle::OpenFileHandle(QuotaReservation* reservation,
diff --git a/chromium/webkit/browser/fileapi/quota/open_file_handle.h b/chromium/webkit/browser/fileapi/quota/open_file_handle.h
index 79f1380a437..2bd7e93713a 100644
--- a/chromium/webkit/browser/fileapi/quota/open_file_handle.h
+++ b/chromium/webkit/browser/fileapi/quota/open_file_handle.h
@@ -10,6 +10,10 @@
#include "base/memory/weak_ptr.h"
#include "webkit/browser/webkit_storage_browser_export.h"
+namespace base {
+class FilePath;
+}
+
namespace fileapi {
class QuotaReservation;
@@ -24,13 +28,28 @@ class WEBKIT_STORAGE_BROWSER_EXPORT OpenFileHandle {
~OpenFileHandle();
// Updates cached file size and consumes quota for that.
- // This should be called for each modified file before calling RefreshQuota
- // and file close.
- // Returns updated base file size that should be used to measure quota
- // consumption by difference to this.
- int64 UpdateMaxWrittenOffset(int64 offset);
+ // Both this and AddAppendModeWriteAmount should be called for each modified
+ // file before calling QuotaReservation::RefreshQuota and before closing the
+ // file.
+ void UpdateMaxWrittenOffset(int64 offset);
+
+ // Notifies that |amount| of data is written to the file in append mode, and
+ // consumes quota for that.
+ // Both this and UpdateMaxWrittenOffset should be called for each modified
+ // file before calling QuotaReservation::RefreshQuota and before closing the
+ // file.
+ void AddAppendModeWriteAmount(int64 amount);
+
+ // Returns the estimated file size for the quota consumption calculation.
+ // The client must consume its reserved quota when it writes data to the file
+ // beyond the estimated file size.
+ // The estimated file size is greater than or equal to actual file size after
+ // all clients report their file usage, and is monotonically increasing over
+ // OpenFileHandle object life cycle, so that client may cache the value.
+ int64 GetEstimatedFileSize() const;
- int64 base_file_size() const;
+ int64 GetMaxWrittenOffset() const;
+ const base::FilePath& platform_path() const;
private:
friend class QuotaReservationBuffer;
diff --git a/chromium/webkit/browser/fileapi/quota/open_file_handle_context.cc b/chromium/webkit/browser/fileapi/quota/open_file_handle_context.cc
index 0928fff7ee2..57e284fd961 100644
--- a/chromium/webkit/browser/fileapi/quota/open_file_handle_context.cc
+++ b/chromium/webkit/browser/fileapi/quota/open_file_handle_context.cc
@@ -14,6 +14,7 @@ OpenFileHandleContext::OpenFileHandleContext(
QuotaReservationBuffer* reservation_buffer)
: initial_file_size_(0),
maximum_written_offset_(0),
+ append_mode_write_amount_(0),
platform_path_(platform_path),
reservation_buffer_(reservation_buffer) {
DCHECK(sequence_checker_.CalledOnValidSequencedThread());
@@ -22,19 +23,29 @@ OpenFileHandleContext::OpenFileHandleContext(
maximum_written_offset_ = initial_file_size_;
}
-void OpenFileHandleContext::UpdateMaxWrittenOffset(
- int64 offset,
- int64* new_file_size,
- int64* growth) {
+int64 OpenFileHandleContext::UpdateMaxWrittenOffset(int64 offset) {
DCHECK(sequence_checker_.CalledOnValidSequencedThread());
- if (offset > maximum_written_offset_) {
- *growth = offset - maximum_written_offset_;
- maximum_written_offset_ = offset;
- } else {
- *growth = 0;
- }
-
- *new_file_size = maximum_written_offset_;
+ if (offset <= maximum_written_offset_)
+ return 0;
+
+ int64 growth = offset - maximum_written_offset_;
+ maximum_written_offset_ = offset;
+ return growth;
+}
+
+void OpenFileHandleContext::AddAppendModeWriteAmount(int64 amount) {
+ DCHECK(sequence_checker_.CalledOnValidSequencedThread());
+ append_mode_write_amount_ += amount;
+}
+
+int64 OpenFileHandleContext::GetEstimatedFileSize() const {
+ DCHECK(sequence_checker_.CalledOnValidSequencedThread());
+ return maximum_written_offset_ + append_mode_write_amount_;
+}
+
+int64 OpenFileHandleContext::GetMaxWrittenOffset() const {
+ DCHECK(sequence_checker_.CalledOnValidSequencedThread());
+ return maximum_written_offset_;
}
OpenFileHandleContext::~OpenFileHandleContext() {
@@ -46,14 +57,15 @@ OpenFileHandleContext::~OpenFileHandleContext() {
base::GetFileSize(platform_path_, &file_size);
int64 usage_delta = file_size - initial_file_size_;
- // |quota_consumption| may be greater than the recorded file growth when a
- // plugin crashed before reporting its consumption.
+ // |reserved_quota_consumption| may be greater than the recorded file growth
+ // when a plugin crashed before reporting its consumption.
// In this case, the reserved quota for the plugin should be handled as
// consumed quota.
- int64 quota_consumption =
- std::max(maximum_written_offset_, file_size) - initial_file_size_;
+ int64 reserved_quota_consumption =
+ std::max(GetEstimatedFileSize(), file_size) - initial_file_size_;
- reservation_buffer_->CommitFileGrowth(quota_consumption, usage_delta);
+ reservation_buffer_->CommitFileGrowth(
+ reserved_quota_consumption, usage_delta);
reservation_buffer_->DetachOpenFileHandleContext(this);
}
diff --git a/chromium/webkit/browser/fileapi/quota/open_file_handle_context.h b/chromium/webkit/browser/fileapi/quota/open_file_handle_context.h
index 4b5d3cc75cd..5b0cbcb9ca9 100644
--- a/chromium/webkit/browser/fileapi/quota/open_file_handle_context.h
+++ b/chromium/webkit/browser/fileapi/quota/open_file_handle_context.h
@@ -11,7 +11,6 @@
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
-#include "base/platform_file.h"
#include "url/gurl.h"
#include "webkit/browser/webkit_storage_browser_export.h"
#include "webkit/common/fileapi/file_system_types.h"
@@ -29,15 +28,17 @@ class OpenFileHandleContext : public base::RefCounted<OpenFileHandleContext> {
OpenFileHandleContext(const base::FilePath& platform_path,
QuotaReservationBuffer* reservation_buffer);
- void UpdateMaxWrittenOffset(int64 offset,
- int64* new_file_size,
- int64* growth);
+ // Updates the max written offset and returns the amount of growth.
+ int64 UpdateMaxWrittenOffset(int64 offset);
+
+ void AddAppendModeWriteAmount(int64 amount);
const base::FilePath& platform_path() const {
return platform_path_;
}
- int64 base_file_size() const { return maximum_written_offset_; }
+ int64 GetEstimatedFileSize() const;
+ int64 GetMaxWrittenOffset() const;
private:
friend class base::RefCounted<OpenFileHandleContext>;
@@ -45,6 +46,7 @@ class OpenFileHandleContext : public base::RefCounted<OpenFileHandleContext> {
int64 initial_file_size_;
int64 maximum_written_offset_;
+ int64 append_mode_write_amount_;
base::FilePath platform_path_;
scoped_refptr<QuotaReservationBuffer> reservation_buffer_;
diff --git a/chromium/webkit/browser/fileapi/quota/quota_backend_impl.cc b/chromium/webkit/browser/fileapi/quota/quota_backend_impl.cc
index 41cc95297d8..de0b3ac0369 100644
--- a/chromium/webkit/browser/fileapi/quota/quota_backend_impl.cc
+++ b/chromium/webkit/browser/fileapi/quota/quota_backend_impl.cc
@@ -9,10 +9,11 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/logging.h"
+#include "base/numerics/safe_conversions.h"
#include "base/sequenced_task_runner.h"
#include "webkit/browser/fileapi/file_system_usage_cache.h"
#include "webkit/browser/quota/quota_client.h"
-#include "webkit/browser/quota/quota_manager.h"
+#include "webkit/browser/quota/quota_manager_proxy.h"
#include "webkit/common/fileapi/file_system_util.h"
namespace fileapi {
@@ -39,7 +40,7 @@ void QuotaBackendImpl::ReserveQuota(const GURL& origin,
DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
DCHECK(origin.is_valid());
if (!delta) {
- callback.Run(base::PLATFORM_FILE_OK);
+ callback.Run(base::File::FILE_OK, 0);
return;
}
DCHECK(quota_manager_proxy_);
@@ -70,7 +71,7 @@ void QuotaBackendImpl::CommitQuotaUsage(const GURL& origin,
return;
ReserveQuotaInternal(QuotaReservationInfo(origin, type, delta));
base::FilePath path;
- if (GetUsageCachePath(origin, type, &path) != base::PLATFORM_FILE_OK)
+ if (GetUsageCachePath(origin, type, &path) != base::File::FILE_OK)
return;
bool result = file_system_usage_cache_->AtomicUpdateUsageByDelta(path, delta);
DCHECK(result);
@@ -81,7 +82,7 @@ void QuotaBackendImpl::IncrementDirtyCount(const GURL& origin,
DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
DCHECK(origin.is_valid());
base::FilePath path;
- if (GetUsageCachePath(origin, type, &path) != base::PLATFORM_FILE_OK)
+ if (GetUsageCachePath(origin, type, &path) != base::File::FILE_OK)
return;
DCHECK(file_system_usage_cache_);
file_system_usage_cache_->IncrementDirty(path);
@@ -92,7 +93,7 @@ void QuotaBackendImpl::DecrementDirtyCount(const GURL& origin,
DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
DCHECK(origin.is_valid());
base::FilePath path;
- if (GetUsageCachePath(origin, type, &path) != base::PLATFORM_FILE_OK)
+ if (GetUsageCachePath(origin, type, &path) != base::File::FILE_OK)
return;
DCHECK(file_system_usage_cache_);
file_system_usage_cache_->DecrementDirty(path);
@@ -104,22 +105,30 @@ void QuotaBackendImpl::DidGetUsageAndQuotaForReserveQuota(
quota::QuotaStatusCode status, int64 usage, int64 quota) {
DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
DCHECK(info.origin.is_valid());
+ DCHECK_LE(0, usage);
+ DCHECK_LE(0, quota);
if (status != quota::kQuotaStatusOk) {
- callback.Run(base::PLATFORM_FILE_ERROR_FAILED);
+ callback.Run(base::File::FILE_ERROR_FAILED, 0);
return;
}
- if (quota < usage + info.delta) {
- callback.Run(base::PLATFORM_FILE_ERROR_NO_SPACE);
- return;
+ QuotaReservationInfo normalized_info = info;
+ if (info.delta > 0) {
+ int64 new_usage =
+ base::saturated_cast<int64>(usage + static_cast<uint64>(info.delta));
+ if (quota < new_usage)
+ new_usage = quota;
+ normalized_info.delta = std::max(static_cast<int64>(0), new_usage - usage);
}
- ReserveQuotaInternal(info);
- if (callback.Run(base::PLATFORM_FILE_OK))
+ ReserveQuotaInternal(normalized_info);
+ if (callback.Run(base::File::FILE_OK, normalized_info.delta))
return;
// The requester could not accept the reserved quota. Revert it.
ReserveQuotaInternal(
- QuotaReservationInfo(info.origin, info.type, -info.delta));
+ QuotaReservationInfo(normalized_info.origin,
+ normalized_info.type,
+ -normalized_info.delta));
}
void QuotaBackendImpl::ReserveQuotaInternal(const QuotaReservationInfo& info) {
@@ -131,14 +140,14 @@ void QuotaBackendImpl::ReserveQuotaInternal(const QuotaReservationInfo& info) {
FileSystemTypeToQuotaStorageType(info.type), info.delta);
}
-base::PlatformFileError QuotaBackendImpl::GetUsageCachePath(
+base::File::Error QuotaBackendImpl::GetUsageCachePath(
const GURL& origin,
FileSystemType type,
base::FilePath* usage_file_path) {
DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
DCHECK(origin.is_valid());
DCHECK(usage_file_path);
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
*usage_file_path =
SandboxFileSystemBackendDelegate::GetUsageCachePathForOriginAndType(
obfuscated_file_util_, origin, type, &error);
diff --git a/chromium/webkit/browser/fileapi/quota/quota_backend_impl.h b/chromium/webkit/browser/fileapi/quota/quota_backend_impl.h
index 10c38e7ea7c..ec4c45ac18b 100644
--- a/chromium/webkit/browser/fileapi/quota/quota_backend_impl.h
+++ b/chromium/webkit/browser/fileapi/quota/quota_backend_impl.h
@@ -16,6 +16,10 @@ namespace base {
class SequencedTaskRunner;
}
+namespace content {
+class QuotaBackendImplTest;
+}
+
namespace quota {
class QuotaManagerProxy;
}
@@ -60,7 +64,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT QuotaBackendImpl
FileSystemType type) OVERRIDE;
private:
- friend class QuotaBackendImplTest;
+ friend class content::QuotaBackendImplTest;
struct QuotaReservationInfo {
QuotaReservationInfo(const GURL& origin, FileSystemType type, int64 delta);
@@ -80,7 +84,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT QuotaBackendImpl
void ReserveQuotaInternal(
const QuotaReservationInfo& info);
- base::PlatformFileError GetUsageCachePath(
+ base::File::Error GetUsageCachePath(
const GURL& origin,
FileSystemType type,
base::FilePath* usage_file_path);
diff --git a/chromium/webkit/browser/fileapi/quota/quota_backend_impl_unittest.cc b/chromium/webkit/browser/fileapi/quota/quota_backend_impl_unittest.cc
deleted file mode 100644
index 75e8db8fe8c..00000000000
--- a/chromium/webkit/browser/fileapi/quota/quota_backend_impl_unittest.cc
+++ /dev/null
@@ -1,248 +0,0 @@
-// Copyright 2013 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 "webkit/browser/fileapi/quota/quota_backend_impl.h"
-
-#include <string>
-
-#include "base/files/scoped_temp_dir.h"
-#include "base/message_loop/message_loop.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/fileapi/file_system_usage_cache.h"
-#include "webkit/browser/fileapi/obfuscated_file_util.h"
-#include "webkit/browser/quota/quota_manager.h"
-
-namespace fileapi {
-
-namespace {
-
-const char kOrigin[] = "http://example.com";
-
-bool DidReserveQuota(bool accepted,
- base::PlatformFileError* error_out,
- base::PlatformFileError error) {
- DCHECK(error_out);
- *error_out = error;
- return accepted;
-}
-
-class MockQuotaManagerProxy : public quota::QuotaManagerProxy {
- public:
- MockQuotaManagerProxy()
- : QuotaManagerProxy(NULL, NULL),
- storage_modified_count_(0),
- usage_(0), quota_(0) {}
-
- // We don't mock them.
- virtual void NotifyOriginInUse(const GURL& origin) OVERRIDE {}
- virtual void NotifyOriginNoLongerInUse(const GURL& origin) OVERRIDE {}
- virtual void SetUsageCacheEnabled(quota::QuotaClient::ID client_id,
- const GURL& origin,
- quota::StorageType type,
- bool enabled) OVERRIDE {}
-
- virtual void NotifyStorageModified(
- quota::QuotaClient::ID client_id,
- const GURL& origin,
- quota::StorageType type,
- int64 delta) OVERRIDE {
- ++storage_modified_count_;
- usage_ += delta;
- ASSERT_LT(usage_, quota_);
- }
-
- virtual void GetUsageAndQuota(
- base::SequencedTaskRunner* original_task_runner,
- const GURL& origin,
- quota::StorageType type,
- const GetUsageAndQuotaCallback& callback) OVERRIDE {
- callback.Run(quota::kQuotaStatusOk, usage_, quota_);
- }
-
- int storage_modified_count() { return storage_modified_count_; }
- int64 usage() { return usage_; }
- void set_usage(int64 usage) { usage_ = usage; }
- void set_quota(int64 quota) { quota_ = quota; }
-
- protected:
- virtual ~MockQuotaManagerProxy() {}
-
- private:
- int storage_modified_count_;
- int64 usage_;
- int64 quota_;
-
- DISALLOW_COPY_AND_ASSIGN(MockQuotaManagerProxy);
-};
-
-} // namespace
-
-class QuotaBackendImplTest : public testing::Test {
- public:
- QuotaBackendImplTest()
- : file_system_usage_cache_(file_task_runner()),
- quota_manager_proxy_(new MockQuotaManagerProxy) {}
-
- virtual void SetUp() OVERRIDE {
- ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
- file_util_.reset(ObfuscatedFileUtil::CreateForTesting(
- NULL, data_dir_.path(), file_task_runner()));
- backend_.reset(new QuotaBackendImpl(file_task_runner(),
- file_util_.get(),
- &file_system_usage_cache_,
- quota_manager_proxy_.get()));
- }
-
- virtual void TearDown() OVERRIDE {
- backend_.reset();
- quota_manager_proxy_ = NULL;
- file_util_.reset();
- message_loop_.RunUntilIdle();
- }
-
- protected:
- void InitializeForOriginAndType(const GURL& origin, FileSystemType type) {
- ASSERT_TRUE(file_util_->InitOriginDatabase(origin, true /* create */));
- ASSERT_TRUE(file_util_->origin_database_ != NULL);
-
- std::string type_string =
- SandboxFileSystemBackendDelegate::GetTypeString(type);
- base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
- base::FilePath path = file_util_->GetDirectoryForOriginAndType(
- origin, type_string, true /* create */, &error);
- ASSERT_EQ(base::PLATFORM_FILE_OK, error);
-
- ASSERT_TRUE(file_system_usage_cache_.UpdateUsage(
- GetUsageCachePath(origin, type), 0));
- }
-
- base::SequencedTaskRunner* file_task_runner() {
- return base::MessageLoopProxy::current().get();
- }
-
- base::FilePath GetUsageCachePath(const GURL& origin, FileSystemType type) {
- base::FilePath path;
- base::PlatformFileError error =
- backend_->GetUsageCachePath(origin, type, &path);
- EXPECT_EQ(base::PLATFORM_FILE_OK, error);
- EXPECT_FALSE(path.empty());
- return path;
- }
-
- base::MessageLoop message_loop_;
- base::ScopedTempDir data_dir_;
- scoped_ptr<ObfuscatedFileUtil> file_util_;
- FileSystemUsageCache file_system_usage_cache_;
- scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_;
- scoped_ptr<QuotaBackendImpl> backend_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(QuotaBackendImplTest);
-};
-
-TEST_F(QuotaBackendImplTest, ReserveQuota_Basic) {
- FileSystemType type = fileapi::kFileSystemTypeTemporary;
- InitializeForOriginAndType(GURL(kOrigin), type);
- quota_manager_proxy_->set_quota(10000);
-
- const int64 kDelta1 = 1000;
- base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
- backend_->ReserveQuota(GURL(kOrigin), type, kDelta1,
- base::Bind(&DidReserveQuota, true, &error));
- EXPECT_EQ(base::PLATFORM_FILE_OK, error);
- EXPECT_EQ(kDelta1, quota_manager_proxy_->usage());
-
- const int64 kDelta2 = -300;
- error = base::PLATFORM_FILE_ERROR_FAILED;
- backend_->ReserveQuota(GURL(kOrigin), type, kDelta2,
- base::Bind(&DidReserveQuota, true, &error));
- EXPECT_EQ(base::PLATFORM_FILE_OK, error);
- EXPECT_EQ(kDelta1 + kDelta2, quota_manager_proxy_->usage());
-
- EXPECT_EQ(2, quota_manager_proxy_->storage_modified_count());
-}
-
-TEST_F(QuotaBackendImplTest, ReserveQuota_NoSpace) {
- FileSystemType type = fileapi::kFileSystemTypeTemporary;
- InitializeForOriginAndType(GURL(kOrigin), type);
- quota_manager_proxy_->set_quota(100);
-
- const int64 kDelta = 1000;
- base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
- backend_->ReserveQuota(GURL(kOrigin), type, kDelta,
- base::Bind(&DidReserveQuota, true, &error));
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, error);
- EXPECT_EQ(0, quota_manager_proxy_->usage());
-
- EXPECT_EQ(0, quota_manager_proxy_->storage_modified_count());
-}
-
-TEST_F(QuotaBackendImplTest, ReserveQuota_Revert) {
- FileSystemType type = fileapi::kFileSystemTypeTemporary;
- InitializeForOriginAndType(GURL(kOrigin), type);
- quota_manager_proxy_->set_quota(10000);
-
- const int64 kDelta = 1000;
- base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
- backend_->ReserveQuota(GURL(kOrigin), type, kDelta,
- base::Bind(&DidReserveQuota, false, &error));
- EXPECT_EQ(base::PLATFORM_FILE_OK, error);
- EXPECT_EQ(0, quota_manager_proxy_->usage());
-
- EXPECT_EQ(2, quota_manager_proxy_->storage_modified_count());
-}
-
-TEST_F(QuotaBackendImplTest, ReleaseReservedQuota) {
- FileSystemType type = fileapi::kFileSystemTypeTemporary;
- InitializeForOriginAndType(GURL(kOrigin), type);
- const int64 kInitialUsage = 2000;
- quota_manager_proxy_->set_usage(kInitialUsage);
- quota_manager_proxy_->set_quota(10000);
-
- const int64 kSize = 1000;
- backend_->ReleaseReservedQuota(GURL(kOrigin), type, kSize);
- EXPECT_EQ(kInitialUsage - kSize, quota_manager_proxy_->usage());
-
- EXPECT_EQ(1, quota_manager_proxy_->storage_modified_count());
-}
-
-TEST_F(QuotaBackendImplTest, CommitQuotaUsage) {
- FileSystemType type = fileapi::kFileSystemTypeTemporary;
- InitializeForOriginAndType(GURL(kOrigin), type);
- quota_manager_proxy_->set_quota(10000);
- base::FilePath path = GetUsageCachePath(GURL(kOrigin), type);
-
- const int64 kDelta1 = 1000;
- backend_->CommitQuotaUsage(GURL(kOrigin), type, kDelta1);
- EXPECT_EQ(kDelta1, quota_manager_proxy_->usage());
- int64 usage = 0;
- EXPECT_TRUE(file_system_usage_cache_.GetUsage(path, &usage));
- EXPECT_EQ(kDelta1, usage);
-
- const int64 kDelta2 = -300;
- backend_->CommitQuotaUsage(GURL(kOrigin), type, kDelta2);
- EXPECT_EQ(kDelta1 + kDelta2, quota_manager_proxy_->usage());
- usage = 0;
- EXPECT_TRUE(file_system_usage_cache_.GetUsage(path, &usage));
- EXPECT_EQ(kDelta1 + kDelta2, usage);
-
- EXPECT_EQ(2, quota_manager_proxy_->storage_modified_count());
-}
-
-TEST_F(QuotaBackendImplTest, DirtyCount) {
- FileSystemType type = fileapi::kFileSystemTypeTemporary;
- InitializeForOriginAndType(GURL(kOrigin), type);
- base::FilePath path = GetUsageCachePath(GURL(kOrigin), type);
-
- backend_->IncrementDirtyCount(GURL(kOrigin), type);
- uint32 dirty = 0;
- ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty));
- EXPECT_EQ(1u, dirty);
-
- backend_->DecrementDirtyCount(GURL(kOrigin), type);
- ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty));
- EXPECT_EQ(0u, dirty);
-}
-
-} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/quota/quota_reservation.cc b/chromium/webkit/browser/fileapi/quota/quota_reservation.cc
index c5a22ab2614..f199b35fbf0 100644
--- a/chromium/webkit/browser/fileapi/quota/quota_reservation.cc
+++ b/chromium/webkit/browser/fileapi/quota/quota_reservation.cc
@@ -15,6 +15,7 @@ void QuotaReservation::RefreshReservation(
const StatusCallback& callback) {
DCHECK(sequence_checker_.CalledOnValidSequencedThread());
DCHECK(!running_refresh_request_);
+ DCHECK(!client_crashed_);
if (!reservation_manager())
return;
@@ -24,7 +25,7 @@ void QuotaReservation::RefreshReservation(
origin(), type(), size - remaining_quota_,
base::Bind(&QuotaReservation::AdaptDidUpdateReservedQuota,
weak_ptr_factory_.GetWeakPtr(),
- size, callback));
+ remaining_quota_, callback));
if (running_refresh_request_)
remaining_quota_ = 0;
@@ -33,11 +34,13 @@ void QuotaReservation::RefreshReservation(
scoped_ptr<OpenFileHandle> QuotaReservation::GetOpenFileHandle(
const base::FilePath& platform_path) {
DCHECK(sequence_checker_.CalledOnValidSequencedThread());
+ DCHECK(!client_crashed_);
return reservation_buffer_->GetOpenFileHandle(this, platform_path);
}
void QuotaReservation::OnClientCrash() {
DCHECK(sequence_checker_.CalledOnValidSequencedThread());
+ client_crashed_ = true;
if (remaining_quota_) {
reservation_buffer_->PutReservationToBuffer(remaining_quota_);
@@ -48,7 +51,9 @@ void QuotaReservation::OnClientCrash() {
void QuotaReservation::ConsumeReservation(int64 size) {
DCHECK(sequence_checker_.CalledOnValidSequencedThread());
DCHECK_LT(0, size);
- DCHECK_LT(size, remaining_quota_);
+ DCHECK_LE(size, remaining_quota_);
+ if (client_crashed_)
+ return;
remaining_quota_ -= size;
reservation_buffer_->PutReservationToBuffer(size);
@@ -68,7 +73,8 @@ FileSystemType QuotaReservation::type() const {
QuotaReservation::QuotaReservation(
QuotaReservationBuffer* reservation_buffer)
- : running_refresh_request_(false),
+ : client_crashed_(false),
+ running_refresh_request_(false),
remaining_quota_(0),
reservation_buffer_(reservation_buffer),
weak_ptr_factory_(this) {
@@ -87,27 +93,35 @@ QuotaReservation::~QuotaReservation() {
// static
bool QuotaReservation::AdaptDidUpdateReservedQuota(
const base::WeakPtr<QuotaReservation>& reservation,
- int64 new_reserved_size,
+ int64 previous_size,
const StatusCallback& callback,
- base::PlatformFileError error) {
+ base::File::Error error,
+ int64 delta) {
if (!reservation)
return false;
- reservation->DidUpdateReservedQuota(new_reserved_size, callback, error);
- return true;
+ return reservation->DidUpdateReservedQuota(
+ previous_size, callback, error, delta);
}
-void QuotaReservation::DidUpdateReservedQuota(
- int64 new_reserved_size,
+bool QuotaReservation::DidUpdateReservedQuota(
+ int64 previous_size,
const StatusCallback& callback,
- base::PlatformFileError error) {
+ base::File::Error error,
+ int64 delta) {
DCHECK(sequence_checker_.CalledOnValidSequencedThread());
DCHECK(running_refresh_request_);
running_refresh_request_ = false;
- if (error == base::PLATFORM_FILE_OK)
- remaining_quota_ = new_reserved_size;
+ if (client_crashed_) {
+ callback.Run(base::File::FILE_ERROR_ABORT);
+ return false;
+ }
+
+ if (error == base::File::FILE_OK)
+ remaining_quota_ = previous_size + delta;
callback.Run(error);
+ return true;
}
} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/quota/quota_reservation.h b/chromium/webkit/browser/fileapi/quota/quota_reservation.h
index d534a0dcc2c..9233a243b97 100644
--- a/chromium/webkit/browser/fileapi/quota/quota_reservation.h
+++ b/chromium/webkit/browser/fileapi/quota/quota_reservation.h
@@ -6,6 +6,7 @@
#define WEBKIT_BROWSER_FILEAPI_QUOTA_QUOTA_RESERVATION_H_
#include "base/basictypes.h"
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
@@ -24,10 +25,12 @@ class OpenFileHandle;
class WEBKIT_STORAGE_BROWSER_EXPORT QuotaReservation
: public base::RefCounted<QuotaReservation> {
public:
- typedef base::Callback<void(base::PlatformFileError error)> StatusCallback;
+ typedef base::Callback<void(base::File::Error error)> StatusCallback;
// Reclaims unused quota and reserves another |size| of quota. So that the
- // resulting new |remaining_quota| will be same as |size|.
+ // resulting new |remaining_quota_| will be same as |size| as far as available
+ // space is enough. |remaining_quota_| may be less than |size| if there is
+ // not enough space available.
// Invokes |callback| upon completion.
void RefreshReservation(int64 size, const StatusCallback& callback);
@@ -66,13 +69,16 @@ class WEBKIT_STORAGE_BROWSER_EXPORT QuotaReservation
static bool AdaptDidUpdateReservedQuota(
const base::WeakPtr<QuotaReservation>& reservation,
- int64 new_reserved_size,
+ int64 previous_size,
const StatusCallback& callback,
- base::PlatformFileError error);
- void DidUpdateReservedQuota(int64 new_reserved_size,
+ base::File::Error error,
+ int64 delta);
+ bool DidUpdateReservedQuota(int64 previous_size,
const StatusCallback& callback,
- base::PlatformFileError error);
+ base::File::Error error,
+ int64 delta);
+ bool client_crashed_;
bool running_refresh_request_;
int64 remaining_quota_;
diff --git a/chromium/webkit/browser/fileapi/quota/quota_reservation_buffer.cc b/chromium/webkit/browser/fileapi/quota/quota_reservation_buffer.cc
index 14ea0d0cd81..9e443190c9d 100644
--- a/chromium/webkit/browser/fileapi/quota/quota_reservation_buffer.cc
+++ b/chromium/webkit/browser/fileapi/quota/quota_reservation_buffer.cc
@@ -39,23 +39,23 @@ scoped_ptr<OpenFileHandle> QuotaReservationBuffer::GetOpenFileHandle(
return make_scoped_ptr(new OpenFileHandle(reservation, *open_file));
}
-void QuotaReservationBuffer::CommitFileGrowth(int64 quota_consumption,
+void QuotaReservationBuffer::CommitFileGrowth(int64 reserved_quota_consumption,
int64 usage_delta) {
DCHECK(sequence_checker_.CalledOnValidSequencedThread());
if (!reservation_manager_)
return;
reservation_manager_->CommitQuotaUsage(origin_, type_, usage_delta);
- if (quota_consumption > 0) {
- if (quota_consumption > reserved_quota_) {
+ if (reserved_quota_consumption > 0) {
+ if (reserved_quota_consumption > reserved_quota_) {
LOG(ERROR) << "Detected over consumption of the storage quota beyond its"
<< " reservation";
- quota_consumption = reserved_quota_;
+ reserved_quota_consumption = reserved_quota_;
}
- reserved_quota_ -= quota_consumption;
+ reserved_quota_ -= reserved_quota_consumption;
reservation_manager_->ReleaseReservedQuota(
- origin_, type_, quota_consumption);
+ origin_, type_, reserved_quota_consumption);
}
}
@@ -92,9 +92,10 @@ bool QuotaReservationBuffer::DecrementDirtyCount(
base::WeakPtr<QuotaReservationManager> reservation_manager,
const GURL& origin,
FileSystemType type,
- base::PlatformFileError error) {
+ base::File::Error error,
+ int64 delta_unused) {
DCHECK(origin.is_valid());
- if (error == base::PLATFORM_FILE_OK && reservation_manager) {
+ if (error == base::File::FILE_OK && reservation_manager) {
reservation_manager->DecrementDirtyCount(origin, type);
return true;
}
diff --git a/chromium/webkit/browser/fileapi/quota/quota_reservation_buffer.h b/chromium/webkit/browser/fileapi/quota/quota_reservation_buffer.h
index 9a11fa5f842..0d87a99518a 100644
--- a/chromium/webkit/browser/fileapi/quota/quota_reservation_buffer.h
+++ b/chromium/webkit/browser/fileapi/quota/quota_reservation_buffer.h
@@ -8,10 +8,10 @@
#include <map>
#include "base/basictypes.h"
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
-#include "base/platform_file.h"
#include "url/gurl.h"
#include "webkit/browser/webkit_storage_browser_export.h"
#include "webkit/common/fileapi/file_system_types.h"
@@ -60,7 +60,8 @@ class QuotaReservationBuffer : public base::RefCounted<QuotaReservationBuffer> {
base::WeakPtr<QuotaReservationManager> reservation_manager,
const GURL& origin,
FileSystemType type,
- base::PlatformFileError error);
+ base::File::Error error,
+ int64 delta);
typedef std::map<base::FilePath, OpenFileHandleContext*>
OpenFileHandleContextByPath;
diff --git a/chromium/webkit/browser/fileapi/quota/quota_reservation_manager.h b/chromium/webkit/browser/fileapi/quota/quota_reservation_manager.h
index 07beacc3277..6dc66ec4345 100644
--- a/chromium/webkit/browser/fileapi/quota/quota_reservation_manager.h
+++ b/chromium/webkit/browser/fileapi/quota/quota_reservation_manager.h
@@ -10,13 +10,17 @@
#include "base/basictypes.h"
#include "base/callback_forward.h"
+#include "base/files/file.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
-#include "base/platform_file.h"
#include "url/gurl.h"
#include "webkit/browser/webkit_storage_browser_export.h"
#include "webkit/common/fileapi/file_system_types.h"
+namespace content {
+class QuotaReservationManagerTest;
+}
+
namespace fileapi {
class QuotaReservation;
@@ -28,7 +32,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT QuotaReservationManager {
public:
// Callback for ReserveQuota. When this callback returns false, ReserveQuota
// operation should be reverted.
- typedef base::Callback<bool(base::PlatformFileError error)>
+ typedef base::Callback<bool(base::File::Error error, int64 delta)>
ReserveQuotaCallback;
// An abstraction of backing quota system.
@@ -83,7 +87,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT QuotaReservationManager {
friend class QuotaReservation;
friend class QuotaReservationBuffer;
- friend class QuotaReservationManagerTest;
+ friend class content::QuotaReservationManagerTest;
void ReserveQuota(const GURL& origin,
FileSystemType type,
diff --git a/chromium/webkit/browser/fileapi/quota/quota_reservation_manager_unittest.cc b/chromium/webkit/browser/fileapi/quota/quota_reservation_manager_unittest.cc
deleted file mode 100644
index 6cdc062d16a..00000000000
--- a/chromium/webkit/browser/fileapi/quota/quota_reservation_manager_unittest.cc
+++ /dev/null
@@ -1,358 +0,0 @@
-// Copyright 2013 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 "webkit/browser/fileapi/quota/quota_reservation_manager.h"
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/file_util.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/message_loop/message_loop.h"
-#include "base/run_loop.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/fileapi/quota/open_file_handle.h"
-#include "webkit/browser/fileapi/quota/quota_reservation.h"
-
-namespace fileapi {
-
-namespace {
-
-const char kOrigin[] = "http://example.com";
-const FileSystemType kType = kFileSystemTypeTemporary;
-const int64 kInitialFileSize = 30;
-
-typedef QuotaReservationManager::ReserveQuotaCallback ReserveQuotaCallback;
-
-class FakeBackend : public QuotaReservationManager::QuotaBackend {
- public:
- FakeBackend()
- : on_memory_usage_(0),
- on_disk_usage_(0) {}
- virtual ~FakeBackend() {}
-
- virtual void ReserveQuota(const GURL& origin,
- FileSystemType type,
- int64 delta,
- const ReserveQuotaCallback& callback) OVERRIDE {
- EXPECT_EQ(GURL(kOrigin), origin);
- EXPECT_EQ(kType, type);
- on_memory_usage_ += delta;
- base::MessageLoopProxy::current()->PostTask(
- FROM_HERE,
- base::Bind(base::IgnoreResult(callback), base::PLATFORM_FILE_OK));
- }
-
- virtual void ReleaseReservedQuota(const GURL& origin,
- FileSystemType type,
- int64 size) OVERRIDE {
- EXPECT_LE(0, size);
- EXPECT_EQ(GURL(kOrigin), origin);
- EXPECT_EQ(kType, type);
- on_memory_usage_ -= size;
- }
-
- virtual void CommitQuotaUsage(const GURL& origin,
- FileSystemType type,
- int64 delta) OVERRIDE {
- EXPECT_EQ(GURL(kOrigin), origin);
- EXPECT_EQ(kType, type);
- on_disk_usage_ += delta;
- }
-
- virtual void IncrementDirtyCount(const GURL& origin,
- FileSystemType type) OVERRIDE {}
- virtual void DecrementDirtyCount(const GURL& origin,
- FileSystemType type) OVERRIDE {}
-
- int64 on_memory_usage() { return on_memory_usage_; }
- int64 on_disk_usage() { return on_disk_usage_; }
-
- private:
- int64 on_memory_usage_;
- int64 on_disk_usage_;
-
- DISALLOW_COPY_AND_ASSIGN(FakeBackend);
-};
-
-void ExpectSuccess(bool* done, base::PlatformFileError error) {
- EXPECT_FALSE(*done);
- *done = true;
- EXPECT_EQ(base::PLATFORM_FILE_OK, error);
-}
-
-void RefreshQuota(QuotaReservation* reservation, int64 size) {
- DCHECK(reservation);
-
- bool done = false;
- reservation->RefreshReservation(size, base::Bind(&ExpectSuccess, &done));
- base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(done);
-}
-
-} // namespace
-
-class QuotaReservationManagerTest : public testing::Test {
- public:
- QuotaReservationManagerTest() {}
- virtual ~QuotaReservationManagerTest() {}
-
- virtual void SetUp() OVERRIDE {
- ASSERT_TRUE(work_dir_.CreateUniqueTempDir());
- file_path_ = work_dir_.path().Append(FILE_PATH_LITERAL("hoge"));
- SetFileSize(kInitialFileSize);
-
- scoped_ptr<QuotaReservationManager::QuotaBackend> backend(new FakeBackend);
- reservation_manager_.reset(new QuotaReservationManager(backend.Pass()));
- }
-
- virtual void TearDown() OVERRIDE {
- reservation_manager_.reset();
- }
-
- int64 GetFileSize() {
- int64 size = 0;
- base::GetFileSize(file_path_, &size);
- return size;
- }
-
- void SetFileSize(int64 size) {
- bool created = false;
- base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
- base::PlatformFile file = CreatePlatformFile(
- file_path_,
- base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE,
- &created, &error);
- ASSERT_EQ(base::PLATFORM_FILE_OK, error);
- ASSERT_TRUE(base::TruncatePlatformFile(file, size));
- ASSERT_TRUE(base::ClosePlatformFile(file));
- }
-
- void ExtendFileTo(int64 size) {
- if (GetFileSize() < size)
- SetFileSize(size);
- }
-
- FakeBackend* fake_backend() {
- return static_cast<FakeBackend*>(reservation_manager_->backend_.get());
- }
-
- QuotaReservationManager* reservation_manager() {
- return reservation_manager_.get();
- }
-
- const base::FilePath& file_path() const {
- return file_path_;
- }
-
- private:
- base::MessageLoop message_loop_;
- base::ScopedTempDir work_dir_;
- base::FilePath file_path_;
- scoped_ptr<QuotaReservationManager> reservation_manager_;
-
- DISALLOW_COPY_AND_ASSIGN(QuotaReservationManagerTest);
-};
-
-TEST_F(QuotaReservationManagerTest, BasicTest) {
- GURL origin(kOrigin);
- FileSystemType type = kType;
-
- // Create Reservation channel for the origin and type.
- // Reservation holds remaining quota reservation and provides a method to
- // refresh it.
- scoped_refptr<QuotaReservation> reservation =
- reservation_manager()->CreateReservation(origin, type);
- EXPECT_EQ(0, reservation->remaining_quota());
-
- RefreshQuota(reservation, 100);
- EXPECT_EQ(100, reservation->remaining_quota());
-
- {
- // For each open file for write, the client should create OpenFileHandle
- // object.
- // It's OK to create multiple OpenFileHandle for single file.
- scoped_ptr<OpenFileHandle> open_file =
- reservation->GetOpenFileHandle(file_path());
-
- // Before reserved quota ran out, the client can perform any number of
- // operation for the file.
- // The client should calculate how much quota is consumed by itself.
- int64 remaining_quota = reservation->remaining_quota();
- int64 base_file_size = open_file->base_file_size();
- int64 max_written_offset = base_file_size;
- ExtendFileTo(90);
- max_written_offset = 90;
- remaining_quota -= max_written_offset - base_file_size;
-
- // When the reserved quota ran out, the client can request quota refresh
- // through Reservation. Before requesting another portion of quota, the
- // client should report maximum written offset for each modified files.
- open_file->UpdateMaxWrittenOffset(max_written_offset);
- EXPECT_EQ(remaining_quota, reservation->remaining_quota());
-
- RefreshQuota(reservation, 100);
- EXPECT_EQ(100, reservation->remaining_quota());
- }
-
- EXPECT_EQ(90, GetFileSize());
- EXPECT_EQ(100, fake_backend()->on_memory_usage());
- EXPECT_EQ(90 - kInitialFileSize, fake_backend()->on_disk_usage());
-
- reservation = NULL;
-
- EXPECT_EQ(90, GetFileSize());
- EXPECT_EQ(0, fake_backend()->on_memory_usage());
- EXPECT_EQ(90 - kInitialFileSize, fake_backend()->on_disk_usage());
-}
-
-TEST_F(QuotaReservationManagerTest, MultipleWriter) {
- GURL origin(kOrigin);
- FileSystemType type = kType;
-
- scoped_refptr<QuotaReservation> reservation =
- reservation_manager()->CreateReservation(origin, type);
- EXPECT_EQ(0, reservation->remaining_quota());
-
- RefreshQuota(reservation, 100);
- EXPECT_EQ(100, reservation->remaining_quota());
-
- {
- scoped_ptr<OpenFileHandle> open_file1 =
- reservation->GetOpenFileHandle(file_path());
- scoped_ptr<OpenFileHandle> open_file2 =
- reservation->GetOpenFileHandle(file_path());
-
- int64 remaining_quota = reservation->remaining_quota();
-
- int64 base_file_size_for_file1 = open_file1->base_file_size();
- int64 max_written_offset_for_file1 = base_file_size_for_file1;
-
- int64 base_file_size_for_file2 = open_file2->base_file_size();
- int64 max_written_offset_for_file2 = base_file_size_for_file2;
-
- // Each writer should maintain max_written_offset and base_file_size
- // independently even if there are multiple writers for the same file.
- max_written_offset_for_file1 = 50;
- ExtendFileTo(max_written_offset_for_file1);
- remaining_quota -= max_written_offset_for_file1 - base_file_size_for_file1;
- base_file_size_for_file1 = max_written_offset_for_file1;
-
- max_written_offset_for_file2 = 90;
- ExtendFileTo(max_written_offset_for_file2);
- remaining_quota -= max_written_offset_for_file2 - base_file_size_for_file2;
- base_file_size_for_file2 = max_written_offset_for_file2;
-
- // Before requesting quota refresh, each writer should report their
- // maximum_written_offset. UpdateMaxWrittenOffset returns updated
- // base_file_size that the writer should calculate quota consumption based
- // on that.
- base_file_size_for_file1 =
- open_file1->UpdateMaxWrittenOffset(max_written_offset_for_file1);
- max_written_offset_for_file1 = base_file_size_for_file1;
- EXPECT_EQ(100 - (50 - kInitialFileSize), reservation->remaining_quota());
-
- base_file_size_for_file2 =
- open_file2->UpdateMaxWrittenOffset(max_written_offset_for_file2);
- max_written_offset_for_file2 = base_file_size_for_file2;
- EXPECT_EQ(100 - (50 - kInitialFileSize) - (90 - 50),
- reservation->remaining_quota());
-
- RefreshQuota(reservation, 100);
- EXPECT_EQ(100, reservation->remaining_quota());
- }
-
- EXPECT_EQ(90, GetFileSize());
- EXPECT_EQ(100, fake_backend()->on_memory_usage());
- EXPECT_EQ(90 - kInitialFileSize, fake_backend()->on_disk_usage());
-
- reservation = NULL;
-
- EXPECT_EQ(90, GetFileSize());
- EXPECT_EQ(0, fake_backend()->on_memory_usage());
- EXPECT_EQ(90 - kInitialFileSize, fake_backend()->on_disk_usage());
-}
-
-TEST_F(QuotaReservationManagerTest, MultipleClient) {
- GURL origin(kOrigin);
- FileSystemType type = kType;
-
- scoped_refptr<QuotaReservation> reservation1 =
- reservation_manager()->CreateReservation(origin, type);
- EXPECT_EQ(0, reservation1->remaining_quota());
- RefreshQuota(reservation1, 100);
- EXPECT_EQ(100, reservation1->remaining_quota());
-
- scoped_refptr<QuotaReservation> reservation2 =
- reservation_manager()->CreateReservation(origin, type);
- EXPECT_EQ(0, reservation2->remaining_quota());
- RefreshQuota(reservation2, 500);
- EXPECT_EQ(500, reservation2->remaining_quota());
-
- // Attach a file to both of two reservations.
- scoped_ptr<OpenFileHandle> open_file1 =
- reservation1->GetOpenFileHandle(file_path());
- scoped_ptr<OpenFileHandle> open_file2 =
- reservation2->GetOpenFileHandle(file_path());
-
- // Each client should manage reserved quota and its consumption separately.
- int64 remaining_quota1 = reservation1->remaining_quota();
- int64 base_file_size1 = open_file1->base_file_size();
- int64 max_written_offset1 = base_file_size1;
-
- int64 remaining_quota2 = reservation2->remaining_quota();
- int64 base_file_size2 = open_file2->base_file_size();
- int64 max_written_offset2 = base_file_size2;
-
- max_written_offset1 = 50;
- remaining_quota1 -= max_written_offset1 - base_file_size1;
- base_file_size1 = max_written_offset1;
- ExtendFileTo(max_written_offset1);
-
- max_written_offset2 = 400;
- remaining_quota2 -= max_written_offset2 - base_file_size2;
- base_file_size2 = max_written_offset2;
- ExtendFileTo(max_written_offset2);
-
- // For multiple Reservation case, RefreshQuota needs usage report only from
- // associated OpenFile's.
- base_file_size1 =
- open_file1->UpdateMaxWrittenOffset(max_written_offset1);
- max_written_offset1 = base_file_size1;
- EXPECT_EQ(100 - (50 - kInitialFileSize), reservation1->remaining_quota());
-
- RefreshQuota(reservation1, 200);
- EXPECT_EQ(200, reservation1->remaining_quota());
-
- base_file_size2 =
- open_file2->UpdateMaxWrittenOffset(max_written_offset2);
- max_written_offset2 = base_file_size2;
- EXPECT_EQ(500 - (400 - 50), reservation2->remaining_quota());
-
- RefreshQuota(reservation2, 150);
- EXPECT_EQ(150, reservation2->remaining_quota());
-
- open_file1.reset();
- open_file2.reset();
-
- EXPECT_EQ(400, GetFileSize());
- EXPECT_EQ(200 + 150, fake_backend()->on_memory_usage());
- EXPECT_EQ(400 - kInitialFileSize, fake_backend()->on_disk_usage());
-
- reservation1 = NULL;
-
- EXPECT_EQ(400, GetFileSize());
- EXPECT_EQ(150, fake_backend()->on_memory_usage());
- EXPECT_EQ(400 - kInitialFileSize, fake_backend()->on_disk_usage());
-
- reservation2 = NULL;
-
- EXPECT_EQ(400, GetFileSize());
- EXPECT_EQ(0, fake_backend()->on_memory_usage());
- EXPECT_EQ(400 - kInitialFileSize, fake_backend()->on_disk_usage());
-}
-
-// TODO(tzik): Add Truncate test.
-// TODO(tzik): Add PluginCrash test and DropReservationManager test.
-
-} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/recursive_operation_delegate.cc b/chromium/webkit/browser/fileapi/recursive_operation_delegate.cc
index 7adc59680b0..d1d85e0d85a 100644
--- a/chromium/webkit/browser/fileapi/recursive_operation_delegate.cc
+++ b/chromium/webkit/browser/fileapi/recursive_operation_delegate.cc
@@ -54,13 +54,13 @@ void RecursiveOperationDelegate::OnCancel() {
void RecursiveOperationDelegate::DidTryProcessFile(
const FileSystemURL& root,
- base::PlatformFileError error) {
+ base::File::Error error) {
DCHECK(pending_directory_stack_.empty());
DCHECK(pending_files_.empty());
DCHECK_EQ(1, inflight_operations_);
--inflight_operations_;
- if (canceled_ || error != base::PLATFORM_FILE_ERROR_NOT_A_FILE) {
+ if (canceled_ || error != base::File::FILE_ERROR_NOT_A_FILE) {
Done(error);
return;
}
@@ -86,14 +86,14 @@ void RecursiveOperationDelegate::ProcessNextDirectory() {
}
void RecursiveOperationDelegate::DidProcessDirectory(
- base::PlatformFileError error) {
+ base::File::Error error) {
DCHECK(pending_files_.empty());
DCHECK(!pending_directory_stack_.empty());
DCHECK(!pending_directory_stack_.top().empty());
DCHECK_EQ(1, inflight_operations_);
--inflight_operations_;
- if (canceled_ || error != base::PLATFORM_FILE_OK) {
+ if (canceled_ || error != base::File::FILE_OK) {
Done(error);
return;
}
@@ -108,14 +108,13 @@ void RecursiveOperationDelegate::DidProcessDirectory(
void RecursiveOperationDelegate::DidReadDirectory(
const FileSystemURL& parent,
- base::PlatformFileError error,
+ base::File::Error error,
const FileEntryList& entries,
bool has_more) {
- DCHECK(pending_files_.empty());
DCHECK(!pending_directory_stack_.empty());
DCHECK_EQ(0, inflight_operations_);
- if (canceled_ || error != base::PLATFORM_FILE_OK) {
+ if (canceled_ || error != base::File::FILE_OK) {
Done(error);
return;
}
@@ -167,9 +166,9 @@ void RecursiveOperationDelegate::ProcessPendingFiles() {
}
void RecursiveOperationDelegate::DidProcessFile(
- base::PlatformFileError error) {
+ base::File::Error error) {
--inflight_operations_;
- if (error != base::PLATFORM_FILE_OK) {
+ if (error != base::File::FILE_OK) {
// If an error occurs, invoke Done immediately (even if there remain
// running operations). It is because in the callback, this instance is
// deleted.
@@ -186,7 +185,7 @@ void RecursiveOperationDelegate::ProcessSubDirectory() {
DCHECK_EQ(0, inflight_operations_);
if (canceled_) {
- Done(base::PLATFORM_FILE_ERROR_ABORT);
+ Done(base::File::FILE_ERROR_ABORT);
return;
}
@@ -200,7 +199,7 @@ void RecursiveOperationDelegate::ProcessSubDirectory() {
pending_directory_stack_.pop();
if (pending_directory_stack_.empty()) {
// All files/directories are processed.
- Done(base::PLATFORM_FILE_OK);
+ Done(base::File::FILE_OK);
return;
}
@@ -213,7 +212,7 @@ void RecursiveOperationDelegate::ProcessSubDirectory() {
}
void RecursiveOperationDelegate::DidPostProcessDirectory(
- base::PlatformFileError error) {
+ base::File::Error error) {
DCHECK(pending_files_.empty());
DCHECK(!pending_directory_stack_.empty());
DCHECK(!pending_directory_stack_.top().empty());
@@ -221,7 +220,7 @@ void RecursiveOperationDelegate::DidPostProcessDirectory(
--inflight_operations_;
pending_directory_stack_.top().pop();
- if (canceled_ || error != base::PLATFORM_FILE_OK) {
+ if (canceled_ || error != base::File::FILE_OK) {
Done(error);
return;
}
@@ -229,9 +228,9 @@ void RecursiveOperationDelegate::DidPostProcessDirectory(
ProcessSubDirectory();
}
-void RecursiveOperationDelegate::Done(base::PlatformFileError error) {
- if (canceled_ && error == base::PLATFORM_FILE_OK) {
- callback_.Run(base::PLATFORM_FILE_ERROR_ABORT);
+void RecursiveOperationDelegate::Done(base::File::Error error) {
+ if (canceled_ && error == base::File::FILE_OK) {
+ callback_.Run(base::File::FILE_ERROR_ABORT);
} else {
callback_.Run(error);
}
diff --git a/chromium/webkit/browser/fileapi/recursive_operation_delegate.h b/chromium/webkit/browser/fileapi/recursive_operation_delegate.h
index 08e30507bce..11f8da04433 100644
--- a/chromium/webkit/browser/fileapi/recursive_operation_delegate.h
+++ b/chromium/webkit/browser/fileapi/recursive_operation_delegate.h
@@ -67,7 +67,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT RecursiveOperationDelegate
//
// First, this tries to call ProcessFile with |root| regardless whether it is
// actually a file or a directory. If it is a directory, ProcessFile should
- // return PLATFORM_FILE_NOT_A_FILE.
+ // return File::FILE_NOT_A_FILE.
//
// For each directory, the recursive operation works as follows:
// ProcessDirectory is called first for the directory.
@@ -88,7 +88,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT RecursiveOperationDelegate
// |
// +- b4_file
// Then traverse order is:
- // ProcessFile(a_dir) (This should return PLATFORM_FILE_NOT_A_FILE).
+ // ProcessFile(a_dir) (This should return File::FILE_NOT_A_FILE).
// ProcessDirectory(a_dir).
// ProcessFile(b3_file), ProcessFile(b4_file). (in parallel).
// ProcessDirectory(b1_dir).
@@ -103,7 +103,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT RecursiveOperationDelegate
// PostProcessDirectory(b2_dir)
// PostProcessDirectory(a_dir)
//
- // |callback| is fired with base::PLATFORM_FILE_OK when every file/directory
+ // |callback| is fired with base::File::FILE_OK when every file/directory
// under |root| is processed, or fired earlier when any suboperation fails.
void StartRecursiveOperation(const FileSystemURL& root,
const StatusCallback& callback);
@@ -121,20 +121,20 @@ class WEBKIT_STORAGE_BROWSER_EXPORT RecursiveOperationDelegate
private:
void DidTryProcessFile(const FileSystemURL& root,
- base::PlatformFileError error);
+ base::File::Error error);
void ProcessNextDirectory();
- void DidProcessDirectory(base::PlatformFileError error);
+ void DidProcessDirectory(base::File::Error error);
void DidReadDirectory(const FileSystemURL& parent,
- base::PlatformFileError error,
+ base::File::Error error,
const FileEntryList& entries,
bool has_more);
void ProcessPendingFiles();
- void DidProcessFile(base::PlatformFileError error);
+ void DidProcessFile(base::File::Error error);
void ProcessSubDirectory();
- void DidPostProcessDirectory(base::PlatformFileError error);
+ void DidPostProcessDirectory(base::File::Error error);
// Called when all recursive operation is done (or an error occurs).
- void Done(base::PlatformFileError error);
+ void Done(base::File::Error error);
FileSystemContext* file_system_context_;
StatusCallback callback_;
diff --git a/chromium/webkit/browser/fileapi/remove_operation_delegate.cc b/chromium/webkit/browser/fileapi/remove_operation_delegate.cc
index 4819f0164e5..6c7b2defdf2 100644
--- a/chromium/webkit/browser/fileapi/remove_operation_delegate.cc
+++ b/chromium/webkit/browser/fileapi/remove_operation_delegate.cc
@@ -41,7 +41,7 @@ void RemoveOperationDelegate::ProcessFile(const FileSystemURL& url,
void RemoveOperationDelegate::ProcessDirectory(const FileSystemURL& url,
const StatusCallback& callback) {
- callback.Run(base::PLATFORM_FILE_OK);
+ callback.Run(base::File::FILE_OK);
}
void RemoveOperationDelegate::PostProcessDirectory(
@@ -49,10 +49,9 @@ void RemoveOperationDelegate::PostProcessDirectory(
operation_runner()->RemoveDirectory(url, callback);
}
-void RemoveOperationDelegate::DidTryRemoveFile(
- base::PlatformFileError error) {
- if (error != base::PLATFORM_FILE_ERROR_NOT_A_FILE &&
- error != base::PLATFORM_FILE_ERROR_SECURITY) {
+void RemoveOperationDelegate::DidTryRemoveFile(base::File::Error error) {
+ if (error != base::File::FILE_ERROR_NOT_A_FILE &&
+ error != base::File::FILE_ERROR_SECURITY) {
callback_.Run(error);
return;
}
@@ -63,18 +62,18 @@ void RemoveOperationDelegate::DidTryRemoveFile(
}
void RemoveOperationDelegate::DidTryRemoveDirectory(
- base::PlatformFileError remove_file_error,
- base::PlatformFileError remove_directory_error) {
+ base::File::Error remove_file_error,
+ base::File::Error remove_directory_error) {
callback_.Run(
- remove_directory_error == base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY ?
+ remove_directory_error == base::File::FILE_ERROR_NOT_A_DIRECTORY ?
remove_file_error :
remove_directory_error);
}
void RemoveOperationDelegate::DidRemoveFile(const StatusCallback& callback,
- base::PlatformFileError error) {
- if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND) {
- callback.Run(base::PLATFORM_FILE_OK);
+ base::File::Error error) {
+ if (error == base::File::FILE_ERROR_NOT_FOUND) {
+ callback.Run(base::File::FILE_OK);
return;
}
callback.Run(error);
diff --git a/chromium/webkit/browser/fileapi/remove_operation_delegate.h b/chromium/webkit/browser/fileapi/remove_operation_delegate.h
index 22d25cb9833..ee0252a7b73 100644
--- a/chromium/webkit/browser/fileapi/remove_operation_delegate.h
+++ b/chromium/webkit/browser/fileapi/remove_operation_delegate.h
@@ -29,11 +29,11 @@ class RemoveOperationDelegate : public RecursiveOperationDelegate {
const StatusCallback& callback) OVERRIDE;
private:
- void DidTryRemoveFile(base::PlatformFileError error);
- void DidTryRemoveDirectory(base::PlatformFileError remove_file_error,
- base::PlatformFileError remove_directory_error);
+ void DidTryRemoveFile(base::File::Error error);
+ void DidTryRemoveDirectory(base::File::Error remove_file_error,
+ base::File::Error remove_directory_error);
void DidRemoveFile(const StatusCallback& callback,
- base::PlatformFileError error);
+ base::File::Error error);
FileSystemURL url_;
StatusCallback callback_;
diff --git a/chromium/webkit/browser/fileapi/sandbox_database_test_helper.cc b/chromium/webkit/browser/fileapi/sandbox_database_test_helper.cc
deleted file mode 100644
index 5c9176c0878..00000000000
--- a/chromium/webkit/browser/fileapi/sandbox_database_test_helper.cc
+++ /dev/null
@@ -1,99 +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 "webkit/browser/fileapi/sandbox_database_test_helper.h"
-
-#include <algorithm>
-#include <functional>
-#include <vector>
-
-#include "base/file_util.h"
-#include "base/files/file_enumerator.h"
-#include "base/stl_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/common/fileapi/file_system_util.h"
-
-namespace fileapi {
-
-void CorruptDatabase(const base::FilePath& db_path,
- leveldb::FileType type,
- ptrdiff_t offset,
- size_t size) {
- base::FileEnumerator file_enum(db_path, false /* not recursive */,
- base::FileEnumerator::DIRECTORIES | base::FileEnumerator::FILES);
- base::FilePath file_path;
- base::FilePath picked_file_path;
- uint64 picked_file_number = kuint64max;
-
- while (!(file_path = file_enum.Next()).empty()) {
- uint64 number = kuint64max;
- leveldb::FileType file_type;
- EXPECT_TRUE(leveldb::ParseFileName(FilePathToString(file_path.BaseName()),
- &number, &file_type));
- if (file_type == type &&
- (picked_file_number == kuint64max || picked_file_number < number)) {
- picked_file_path = file_path;
- picked_file_number = number;
- }
- }
-
- EXPECT_FALSE(picked_file_path.empty());
- EXPECT_NE(kuint64max, picked_file_number);
-
- bool created = true;
- base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
- base::PlatformFile file =
- CreatePlatformFile(picked_file_path,
- base::PLATFORM_FILE_OPEN |
- base::PLATFORM_FILE_READ |
- base::PLATFORM_FILE_WRITE,
- &created, &error);
- EXPECT_EQ(base::PLATFORM_FILE_OK, error);
- EXPECT_FALSE(created);
-
- base::PlatformFileInfo file_info;
- EXPECT_TRUE(base::GetPlatformFileInfo(file, &file_info));
- if (offset < 0)
- offset += file_info.size;
- EXPECT_GE(offset, 0);
- EXPECT_LE(offset, file_info.size);
-
- size = std::min(size, static_cast<size_t>(file_info.size - offset));
-
- std::vector<char> buf(size);
- int read_size = base::ReadPlatformFile(file, offset,
- vector_as_array(&buf), buf.size());
- EXPECT_LT(0, read_size);
- EXPECT_GE(buf.size(), static_cast<size_t>(read_size));
- buf.resize(read_size);
-
- std::transform(buf.begin(), buf.end(), buf.begin(),
- std::logical_not<char>());
-
- int written_size = base::WritePlatformFile(file, offset,
- vector_as_array(&buf), buf.size());
- EXPECT_GT(written_size, 0);
- EXPECT_EQ(buf.size(), static_cast<size_t>(written_size));
-
- base::ClosePlatformFile(file);
-}
-
-void DeleteDatabaseFile(const base::FilePath& db_path,
- leveldb::FileType type) {
- base::FileEnumerator file_enum(db_path, false /* not recursive */,
- base::FileEnumerator::DIRECTORIES | base::FileEnumerator::FILES);
- base::FilePath file_path;
- while (!(file_path = file_enum.Next()).empty()) {
- uint64 number = kuint64max;
- leveldb::FileType file_type;
- EXPECT_TRUE(leveldb::ParseFileName(FilePathToString(file_path.BaseName()),
- &number, &file_type));
- if (file_type == type) {
- base::DeleteFile(file_path, false);
- // We may have multiple files for the same type, so don't break here.
- }
- }
-}
-
-} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/sandbox_database_test_helper.h b/chromium/webkit/browser/fileapi/sandbox_database_test_helper.h
deleted file mode 100644
index 1635c2fd265..00000000000
--- a/chromium/webkit/browser/fileapi/sandbox_database_test_helper.h
+++ /dev/null
@@ -1,28 +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 WEBKIT_BROWSER_FILEAPI_SANDBOX_DATABASE_TEST_HELPER_H_
-#define WEBKIT_BROWSER_FILEAPI_SANDBOX_DATABASE_TEST_HELPER_H_
-
-#include <cstddef>
-
-#include "third_party/leveldatabase/src/db/filename.h"
-
-namespace base {
-class FilePath;
-}
-
-namespace fileapi {
-
-void CorruptDatabase(const base::FilePath& db_path,
- leveldb::FileType type,
- ptrdiff_t offset,
- size_t size);
-
-void DeleteDatabaseFile(const base::FilePath& db_path,
- leveldb::FileType type);
-
-} // namespace fileapi
-
-#endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_DATABASE_TEST_HELPER_H_
diff --git a/chromium/webkit/browser/fileapi/sandbox_directory_database.cc b/chromium/webkit/browser/fileapi/sandbox_directory_database.cc
index dd376116eef..75aa691d523 100644
--- a/chromium/webkit/browser/fileapi/sandbox_directory_database.cc
+++ b/chromium/webkit/browser/fileapi/sandbox_directory_database.cc
@@ -243,7 +243,7 @@ bool DatabaseCheckHelper::ScanDatabase() {
return false;
// Ensure the backing file exists as a normal file.
- base::PlatformFileInfo platform_file_info;
+ base::File::Info platform_file_info;
if (!base::GetFileInfo(
path_.Append(file_info.data_path), &platform_file_info) ||
platform_file_info.is_directory ||
@@ -410,8 +410,10 @@ SandboxDirectoryDatabase::FileInfo::~FileInfo() {
}
SandboxDirectoryDatabase::SandboxDirectoryDatabase(
- const base::FilePath& filesystem_data_directory)
- : filesystem_data_directory_(filesystem_data_directory) {
+ const base::FilePath& filesystem_data_directory,
+ leveldb::Env* env_override)
+ : filesystem_data_directory_(filesystem_data_directory),
+ env_override_(env_override) {
}
SandboxDirectoryDatabase::~SandboxDirectoryDatabase() {
@@ -518,10 +520,10 @@ bool SandboxDirectoryDatabase::GetFileInfo(FileId file_id, FileInfo* info) {
return false;
}
-base::PlatformFileError SandboxDirectoryDatabase::AddFileInfo(
+base::File::Error SandboxDirectoryDatabase::AddFileInfo(
const FileInfo& info, FileId* file_id) {
if (!Init(REPAIR_ON_CORRUPTION))
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
DCHECK(file_id);
std::string child_key = GetChildLookupKey(info.parent_id, info.name);
std::string child_id_string;
@@ -529,16 +531,16 @@ base::PlatformFileError SandboxDirectoryDatabase::AddFileInfo(
db_->Get(leveldb::ReadOptions(), child_key, &child_id_string);
if (status.ok()) {
LOG(ERROR) << "File exists already!";
- return base::PLATFORM_FILE_ERROR_EXISTS;
+ return base::File::FILE_ERROR_EXISTS;
}
if (!status.IsNotFound()) {
HandleError(FROM_HERE, status);
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
}
if (!IsDirectory(info.parent_id)) {
LOG(ERROR) << "New parent directory is a file!";
- return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY;
+ return base::File::FILE_ERROR_NOT_A_DIRECTORY;
}
// This would be a fine place to limit the number of files in a directory, if
@@ -546,21 +548,21 @@ base::PlatformFileError SandboxDirectoryDatabase::AddFileInfo(
FileId temp_id;
if (!GetLastFileId(&temp_id))
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
++temp_id;
leveldb::WriteBatch batch;
if (!AddFileInfoHelper(info, temp_id, &batch))
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
batch.Put(LastFileIdKey(), base::Int64ToString(temp_id));
status = db_->Write(leveldb::WriteOptions(), &batch);
if (!status.ok()) {
HandleError(FROM_HERE, status);
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
}
*file_id = temp_id;
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_OK;
}
bool SandboxDirectoryDatabase::RemoveFileInfo(FileId file_id) {
@@ -699,9 +701,13 @@ bool SandboxDirectoryDatabase::GetNextInteger(int64* next) {
}
// static
-bool SandboxDirectoryDatabase::DestroyDatabase(const base::FilePath& path) {
+bool SandboxDirectoryDatabase::DestroyDatabase(const base::FilePath& path,
+ leveldb::Env* env_override) {
std::string name = FilePathToString(path.Append(kDirectoryDatabaseName));
- leveldb::Status status = leveldb::DestroyDB(name, leveldb::Options());
+ leveldb::Options options;
+ if (env_override)
+ options.env = env_override;
+ leveldb::Status status = leveldb::DestroyDB(name, options);
if (status.ok())
return true;
LOG(WARNING) << "Failed to destroy a database with status " <<
@@ -719,6 +725,8 @@ bool SandboxDirectoryDatabase::Init(RecoveryOption recovery_option) {
leveldb::Options options;
options.max_open_files = 0; // Use minimum.
options.create_if_missing = true;
+ if (env_override_)
+ options.env = env_override_;
leveldb::DB* db;
leveldb::Status status = leveldb::DB::Open(options, path, &db);
ReportInitStatus(status);
@@ -766,6 +774,8 @@ bool SandboxDirectoryDatabase::RepairDatabase(const std::string& db_path) {
DCHECK(!db_.get());
leveldb::Options options;
options.max_open_files = 0; // Use minimum.
+ if (env_override_)
+ options.env = env_override_;
if (!leveldb::RepairDB(db_path, options).ok())
return false;
if (!Init(FAIL_ON_CORRUPTION))
diff --git a/chromium/webkit/browser/fileapi/sandbox_directory_database.h b/chromium/webkit/browser/fileapi/sandbox_directory_database.h
index 67be4328781..114af1ba9fd 100644
--- a/chromium/webkit/browser/fileapi/sandbox_directory_database.h
+++ b/chromium/webkit/browser/fileapi/sandbox_directory_database.h
@@ -8,18 +8,23 @@
#include <string>
#include <vector>
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
-#include "base/platform_file.h"
#include "base/time/time.h"
#include "webkit/browser/webkit_storage_browser_export.h"
+namespace content {
+class SandboxDirectoryDatabaseTest;
+}
+
namespace tracked_objects {
class Location;
}
namespace leveldb {
class DB;
+class Env;
class Status;
class WriteBatch;
}
@@ -56,8 +61,9 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE SandboxDirectoryDatabase {
base::Time modification_time;
};
- explicit SandboxDirectoryDatabase(
- const base::FilePath& filesystem_data_directory);
+ SandboxDirectoryDatabase(
+ const base::FilePath& filesystem_data_directory,
+ leveldb::Env* env_override);
~SandboxDirectoryDatabase();
bool GetChildWithName(
@@ -69,7 +75,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE SandboxDirectoryDatabase {
// exist.
bool ListChildren(FileId parent_id, std::vector<FileId>* children);
bool GetFileInfo(FileId file_id, FileInfo* info);
- base::PlatformFileError AddFileInfo(const FileInfo& info, FileId* file_id);
+ base::File::Error AddFileInfo(const FileInfo& info, FileId* file_id);
bool RemoveFileInfo(FileId file_id);
// This does a full update of the FileInfo, and is what you'd use for moves
// and renames. If you just want to update the modification_time, use
@@ -93,7 +99,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE SandboxDirectoryDatabase {
// Returns true if the database looks consistent with local filesystem.
bool IsFileSystemConsistent();
- static bool DestroyDatabase(const base::FilePath& path);
+ static bool DestroyDatabase(const base::FilePath& path,
+ leveldb::Env* env_override);
private:
enum RecoveryOption {
@@ -102,8 +109,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE SandboxDirectoryDatabase {
FAIL_ON_CORRUPTION,
};
+ friend class content::SandboxDirectoryDatabaseTest;
friend class ObfuscatedFileUtil;
- friend class SandboxDirectoryDatabaseTest;
bool Init(RecoveryOption recovery_option);
bool RepairDatabase(const std::string& db_path);
@@ -117,6 +124,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE SandboxDirectoryDatabase {
const leveldb::Status& status);
const base::FilePath filesystem_data_directory_;
+ leveldb::Env* env_override_;
scoped_ptr<leveldb::DB> db_;
base::Time last_reported_time_;
DISALLOW_COPY_AND_ASSIGN(SandboxDirectoryDatabase);
diff --git a/chromium/webkit/browser/fileapi/sandbox_directory_database_unittest.cc b/chromium/webkit/browser/fileapi/sandbox_directory_database_unittest.cc
deleted file mode 100644
index b43dc23ee74..00000000000
--- a/chromium/webkit/browser/fileapi/sandbox_directory_database_unittest.cc
+++ /dev/null
@@ -1,681 +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 "webkit/browser/fileapi/sandbox_directory_database.h"
-
-#include <math.h>
-#include <limits>
-
-#include "base/file_util.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/platform_file.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/string_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/leveldatabase/src/include/leveldb/db.h"
-#include "webkit/browser/fileapi/sandbox_database_test_helper.h"
-#include "webkit/common/fileapi/file_system_util.h"
-
-#define FPL(x) FILE_PATH_LITERAL(x)
-
-namespace fileapi {
-
-namespace {
-const base::FilePath::CharType kDirectoryDatabaseName[] = FPL("Paths");
-}
-
-class SandboxDirectoryDatabaseTest : public testing::Test {
- public:
- typedef SandboxDirectoryDatabase::FileId FileId;
- typedef SandboxDirectoryDatabase::FileInfo FileInfo;
-
- SandboxDirectoryDatabaseTest() {
- EXPECT_TRUE(base_.CreateUniqueTempDir());
- InitDatabase();
- }
-
- SandboxDirectoryDatabase* db() {
- return db_.get();
- }
-
- void InitDatabase() {
- // Call CloseDatabase() to avoid having multiple database instances for
- // single directory at once.
- CloseDatabase();
- db_.reset(new SandboxDirectoryDatabase(path()));
- }
-
- void CloseDatabase() {
- db_.reset();
- }
-
- base::PlatformFileError AddFileInfo(
- FileId parent_id, const base::FilePath::StringType& name) {
- FileId file_id;
- FileInfo info;
- info.parent_id = parent_id;
- info.name = name;
- return db_->AddFileInfo(info, &file_id);
- }
-
- void CreateDirectory(FileId parent_id,
- const base::FilePath::StringType& name,
- FileId* file_id_out) {
- FileInfo info;
- info.parent_id = parent_id;
- info.name = name;
- ASSERT_EQ(base::PLATFORM_FILE_OK, db_->AddFileInfo(info, file_id_out));
- }
-
- void CreateFile(FileId parent_id,
- const base::FilePath::StringType& name,
- const base::FilePath::StringType& data_path,
- FileId* file_id_out) {
- FileId file_id;
-
- FileInfo info;
- info.parent_id = parent_id;
- info.name = name;
- info.data_path = base::FilePath(data_path).NormalizePathSeparators();
- ASSERT_EQ(base::PLATFORM_FILE_OK, db_->AddFileInfo(info, &file_id));
-
- base::FilePath local_path = path().Append(data_path);
- if (!base::DirectoryExists(local_path.DirName()))
- ASSERT_TRUE(base::CreateDirectory(local_path.DirName()));
-
- bool created = false;
- base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
- base::PlatformFile file = base::CreatePlatformFile(
- local_path,
- base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_WRITE,
- &created, &error);
- ASSERT_EQ(base::PLATFORM_FILE_OK, error);
- ASSERT_TRUE(created);
- ASSERT_TRUE(base::ClosePlatformFile(file));
-
- if (file_id_out)
- *file_id_out = file_id;
- }
-
- void ClearDatabaseAndDirectory() {
- db_.reset();
- ASSERT_TRUE(base::DeleteFile(path(), true /* recursive */));
- ASSERT_TRUE(base::CreateDirectory(path()));
- db_.reset(new SandboxDirectoryDatabase(path()));
- }
-
- bool RepairDatabase() {
- return db()->RepairDatabase(
- FilePathToString(path().Append(kDirectoryDatabaseName)));
- }
-
- const base::FilePath& path() {
- return base_.path();
- }
-
- // Makes link from |parent_id| to |child_id| with |name|.
- void MakeHierarchyLink(FileId parent_id,
- FileId child_id,
- const base::FilePath::StringType& name) {
- ASSERT_TRUE(db()->db_->Put(
- leveldb::WriteOptions(),
- "CHILD_OF:" + base::Int64ToString(parent_id) + ":" +
- FilePathToString(base::FilePath(name)),
- base::Int64ToString(child_id)).ok());
- }
-
- // Deletes link from parent of |file_id| to |file_id|.
- void DeleteHierarchyLink(FileId file_id) {
- FileInfo file_info;
- ASSERT_TRUE(db()->GetFileInfo(file_id, &file_info));
- ASSERT_TRUE(db()->db_->Delete(
- leveldb::WriteOptions(),
- "CHILD_OF:" + base::Int64ToString(file_info.parent_id) + ":" +
- FilePathToString(base::FilePath(file_info.name))).ok());
- }
-
- protected:
- // Common temp base for nondestructive uses.
- base::ScopedTempDir base_;
- scoped_ptr<SandboxDirectoryDatabase> db_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(SandboxDirectoryDatabaseTest);
-};
-
-TEST_F(SandboxDirectoryDatabaseTest, TestMissingFileGetInfo) {
- FileId file_id = 888;
- FileInfo info;
- EXPECT_FALSE(db()->GetFileInfo(file_id, &info));
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestGetRootFileInfoBeforeCreate) {
- FileId file_id = 0;
- FileInfo info;
- EXPECT_TRUE(db()->GetFileInfo(file_id, &info));
- EXPECT_EQ(0, info.parent_id);
- EXPECT_TRUE(info.name.empty());
- EXPECT_TRUE(info.data_path.empty());
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestMissingParentAddFileInfo) {
- FileId parent_id = 7;
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY,
- AddFileInfo(parent_id, FILE_PATH_LITERAL("foo")));
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestAddNameClash) {
- FileInfo info;
- FileId file_id;
- info.parent_id = 0;
- info.name = FILE_PATH_LITERAL("dir 0");
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info, &file_id));
-
- // Check for name clash in the root directory.
- base::FilePath::StringType name = info.name;
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, AddFileInfo(0, name));
- name = FILE_PATH_LITERAL("dir 1");
- EXPECT_EQ(base::PLATFORM_FILE_OK, AddFileInfo(0, name));
-
- name = FILE_PATH_LITERAL("subdir 0");
- EXPECT_EQ(base::PLATFORM_FILE_OK, AddFileInfo(file_id, name));
-
- // Check for name clash in a subdirectory.
- EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, AddFileInfo(file_id, name));
- name = FILE_PATH_LITERAL("subdir 1");
- EXPECT_EQ(base::PLATFORM_FILE_OK, AddFileInfo(file_id, name));
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestRenameNoMoveNameClash) {
- FileInfo info;
- FileId file_id0;
- base::FilePath::StringType name0 = FILE_PATH_LITERAL("foo");
- base::FilePath::StringType name1 = FILE_PATH_LITERAL("bar");
- base::FilePath::StringType name2 = FILE_PATH_LITERAL("bas");
- info.parent_id = 0;
- info.name = name0;
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info, &file_id0));
- EXPECT_EQ(base::PLATFORM_FILE_OK, AddFileInfo(0, name1));
- info.name = name1;
- EXPECT_FALSE(db()->UpdateFileInfo(file_id0, info));
- info.name = name2;
- EXPECT_TRUE(db()->UpdateFileInfo(file_id0, info));
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestMoveSameNameNameClash) {
- FileInfo info;
- FileId file_id0;
- FileId file_id1;
- base::FilePath::StringType name0 = FILE_PATH_LITERAL("foo");
- base::FilePath::StringType name1 = FILE_PATH_LITERAL("bar");
- info.parent_id = 0;
- info.name = name0;
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info, &file_id0));
- info.parent_id = file_id0;
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info, &file_id1));
- info.parent_id = 0;
- EXPECT_FALSE(db()->UpdateFileInfo(file_id1, info));
- info.name = name1;
- EXPECT_TRUE(db()->UpdateFileInfo(file_id1, info));
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestMoveRenameNameClash) {
- FileInfo info;
- FileId file_id0;
- FileId file_id1;
- base::FilePath::StringType name0 = FILE_PATH_LITERAL("foo");
- base::FilePath::StringType name1 = FILE_PATH_LITERAL("bar");
- base::FilePath::StringType name2 = FILE_PATH_LITERAL("bas");
- info.parent_id = 0;
- info.name = name0;
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info, &file_id0));
- info.parent_id = file_id0;
- info.name = name1;
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info, &file_id1));
- info.parent_id = 0;
- info.name = name0;
- EXPECT_FALSE(db()->UpdateFileInfo(file_id1, info));
- info.name = name1;
- EXPECT_TRUE(db()->UpdateFileInfo(file_id1, info));
- // Also test a successful move+rename.
- info.parent_id = file_id0;
- info.name = name2;
- EXPECT_TRUE(db()->UpdateFileInfo(file_id1, info));
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestRemoveWithChildren) {
- FileInfo info;
- FileId file_id0;
- FileId file_id1;
- info.parent_id = 0;
- info.name = FILE_PATH_LITERAL("foo");
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info, &file_id0));
- info.parent_id = file_id0;
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info, &file_id1));
- EXPECT_FALSE(db()->RemoveFileInfo(file_id0));
- EXPECT_TRUE(db()->RemoveFileInfo(file_id1));
- EXPECT_TRUE(db()->RemoveFileInfo(file_id0));
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestGetChildWithName) {
- FileInfo info;
- FileId file_id0;
- FileId file_id1;
- base::FilePath::StringType name0 = FILE_PATH_LITERAL("foo");
- base::FilePath::StringType name1 = FILE_PATH_LITERAL("bar");
- info.parent_id = 0;
- info.name = name0;
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info, &file_id0));
- info.parent_id = file_id0;
- info.name = name1;
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info, &file_id1));
- EXPECT_NE(file_id0, file_id1);
-
- FileId check_file_id;
- EXPECT_FALSE(db()->GetChildWithName(0, name1, &check_file_id));
- EXPECT_TRUE(db()->GetChildWithName(0, name0, &check_file_id));
- EXPECT_EQ(file_id0, check_file_id);
- EXPECT_FALSE(db()->GetChildWithName(file_id0, name0, &check_file_id));
- EXPECT_TRUE(db()->GetChildWithName(file_id0, name1, &check_file_id));
- EXPECT_EQ(file_id1, check_file_id);
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestGetFileWithPath) {
- FileInfo info;
- FileId file_id0;
- FileId file_id1;
- FileId file_id2;
- base::FilePath::StringType name0 = FILE_PATH_LITERAL("foo");
- base::FilePath::StringType name1 = FILE_PATH_LITERAL("bar");
- base::FilePath::StringType name2 = FILE_PATH_LITERAL("dog");
-
- info.parent_id = 0;
- info.name = name0;
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info, &file_id0));
- info.parent_id = file_id0;
- info.name = name1;
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info, &file_id1));
- EXPECT_NE(file_id0, file_id1);
- info.parent_id = file_id1;
- info.name = name2;
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info, &file_id2));
- EXPECT_NE(file_id0, file_id2);
- EXPECT_NE(file_id1, file_id2);
-
- FileId check_file_id;
- base::FilePath path = base::FilePath(name0);
- EXPECT_TRUE(db()->GetFileWithPath(path, &check_file_id));
- EXPECT_EQ(file_id0, check_file_id);
-
- path = path.Append(name1);
- EXPECT_TRUE(db()->GetFileWithPath(path, &check_file_id));
- EXPECT_EQ(file_id1, check_file_id);
-
- path = path.Append(name2);
- EXPECT_TRUE(db()->GetFileWithPath(path, &check_file_id));
- EXPECT_EQ(file_id2, check_file_id);
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestListChildren) {
- // No children in the root.
- std::vector<FileId> children;
- EXPECT_TRUE(db()->ListChildren(0, &children));
- EXPECT_TRUE(children.empty());
-
- // One child in the root.
- FileId file_id0;
- FileInfo info;
- info.parent_id = 0;
- info.name = FILE_PATH_LITERAL("foo");
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info, &file_id0));
- EXPECT_TRUE(db()->ListChildren(0, &children));
- EXPECT_EQ(children.size(), 1UL);
- EXPECT_EQ(children[0], file_id0);
-
- // Two children in the root.
- FileId file_id1;
- info.name = FILE_PATH_LITERAL("bar");
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info, &file_id1));
- EXPECT_TRUE(db()->ListChildren(0, &children));
- EXPECT_EQ(2UL, children.size());
- if (children[0] == file_id0) {
- EXPECT_EQ(children[1], file_id1);
- } else {
- EXPECT_EQ(children[1], file_id0);
- EXPECT_EQ(children[0], file_id1);
- }
-
- // No children in a subdirectory.
- EXPECT_TRUE(db()->ListChildren(file_id0, &children));
- EXPECT_TRUE(children.empty());
-
- // One child in a subdirectory.
- info.parent_id = file_id0;
- info.name = FILE_PATH_LITERAL("foo");
- FileId file_id2;
- FileId file_id3;
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info, &file_id2));
- EXPECT_TRUE(db()->ListChildren(file_id0, &children));
- EXPECT_EQ(1UL, children.size());
- EXPECT_EQ(children[0], file_id2);
-
- // Two children in a subdirectory.
- info.name = FILE_PATH_LITERAL("bar");
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info, &file_id3));
- EXPECT_TRUE(db()->ListChildren(file_id0, &children));
- EXPECT_EQ(2UL, children.size());
- if (children[0] == file_id2) {
- EXPECT_EQ(children[1], file_id3);
- } else {
- EXPECT_EQ(children[1], file_id2);
- EXPECT_EQ(children[0], file_id3);
- }
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestUpdateModificationTime) {
- FileInfo info0;
- FileId file_id;
- info0.parent_id = 0;
- info0.name = FILE_PATH_LITERAL("name");
- info0.data_path = base::FilePath(FILE_PATH_LITERAL("fake path"));
- info0.modification_time = base::Time::Now();
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info0, &file_id));
- FileInfo info1;
- EXPECT_TRUE(db()->GetFileInfo(file_id, &info1));
- EXPECT_EQ(info0.name, info1.name);
- EXPECT_EQ(info0.parent_id, info1.parent_id);
- EXPECT_EQ(info0.data_path, info1.data_path);
- EXPECT_EQ(
- floor(info0.modification_time.ToDoubleT()),
- info1.modification_time.ToDoubleT());
-
- EXPECT_TRUE(db()->UpdateModificationTime(file_id, base::Time::UnixEpoch()));
- EXPECT_TRUE(db()->GetFileInfo(file_id, &info1));
- EXPECT_EQ(info0.name, info1.name);
- EXPECT_EQ(info0.parent_id, info1.parent_id);
- EXPECT_EQ(info0.data_path, info1.data_path);
- EXPECT_NE(info0.modification_time, info1.modification_time);
- EXPECT_EQ(
- info1.modification_time.ToDoubleT(),
- floor(base::Time::UnixEpoch().ToDoubleT()));
-
- EXPECT_FALSE(db()->UpdateModificationTime(999, base::Time::UnixEpoch()));
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestSimpleFileOperations) {
- FileId file_id = 888;
- FileInfo info0;
- EXPECT_FALSE(db()->GetFileInfo(file_id, &info0));
- info0.parent_id = 0;
- info0.data_path = base::FilePath(FILE_PATH_LITERAL("foo"));
- info0.name = FILE_PATH_LITERAL("file name");
- info0.modification_time = base::Time::Now();
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info0, &file_id));
- FileInfo info1;
- EXPECT_TRUE(db()->GetFileInfo(file_id, &info1));
- EXPECT_EQ(info0.parent_id, info1.parent_id);
- EXPECT_EQ(info0.data_path, info1.data_path);
- EXPECT_EQ(info0.name, info1.name);
- EXPECT_EQ(
- floor(info0.modification_time.ToDoubleT()),
- info1.modification_time.ToDoubleT());
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestOverwritingMoveFileSrcDirectory) {
- FileId directory_id;
- FileInfo info0;
- info0.parent_id = 0;
- info0.name = FILE_PATH_LITERAL("directory");
- info0.modification_time = base::Time::Now();
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info0, &directory_id));
-
- FileId file_id;
- FileInfo info1;
- info1.parent_id = 0;
- info1.data_path = base::FilePath(FILE_PATH_LITERAL("bar"));
- info1.name = FILE_PATH_LITERAL("file");
- info1.modification_time = base::Time::UnixEpoch();
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info1, &file_id));
-
- EXPECT_FALSE(db()->OverwritingMoveFile(directory_id, file_id));
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestOverwritingMoveFileDestDirectory) {
- FileId file_id;
- FileInfo info0;
- info0.parent_id = 0;
- info0.name = FILE_PATH_LITERAL("file");
- info0.data_path = base::FilePath(FILE_PATH_LITERAL("bar"));
- info0.modification_time = base::Time::Now();
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info0, &file_id));
-
- FileId directory_id;
- FileInfo info1;
- info1.parent_id = 0;
- info1.name = FILE_PATH_LITERAL("directory");
- info1.modification_time = base::Time::UnixEpoch();
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info1, &directory_id));
-
- EXPECT_FALSE(db()->OverwritingMoveFile(file_id, directory_id));
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestOverwritingMoveFileSuccess) {
- FileId file_id0;
- FileInfo info0;
- info0.parent_id = 0;
- info0.data_path = base::FilePath(FILE_PATH_LITERAL("foo"));
- info0.name = FILE_PATH_LITERAL("file name 0");
- info0.modification_time = base::Time::Now();
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info0, &file_id0));
-
- FileInfo dir_info;
- FileId dir_id;
- dir_info.parent_id = 0;
- dir_info.name = FILE_PATH_LITERAL("directory name");
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(dir_info, &dir_id));
-
- FileId file_id1;
- FileInfo info1;
- info1.parent_id = dir_id;
- info1.data_path = base::FilePath(FILE_PATH_LITERAL("bar"));
- info1.name = FILE_PATH_LITERAL("file name 1");
- info1.modification_time = base::Time::UnixEpoch();
- EXPECT_EQ(base::PLATFORM_FILE_OK, db()->AddFileInfo(info1, &file_id1));
-
- EXPECT_TRUE(db()->OverwritingMoveFile(file_id0, file_id1));
-
- FileInfo check_info;
- FileId check_id;
-
- EXPECT_FALSE(db()->GetFileWithPath(base::FilePath(info0.name), &check_id));
- EXPECT_TRUE(db()->GetFileWithPath(
- base::FilePath(dir_info.name).Append(info1.name), &check_id));
- EXPECT_TRUE(db()->GetFileInfo(check_id, &check_info));
-
- EXPECT_EQ(info0.data_path, check_info.data_path);
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestGetNextInteger) {
- int64 next = -1;
- EXPECT_TRUE(db()->GetNextInteger(&next));
- EXPECT_EQ(0, next);
- EXPECT_TRUE(db()->GetNextInteger(&next));
- EXPECT_EQ(1, next);
- InitDatabase();
- EXPECT_TRUE(db()->GetNextInteger(&next));
- EXPECT_EQ(2, next);
- EXPECT_TRUE(db()->GetNextInteger(&next));
- EXPECT_EQ(3, next);
- InitDatabase();
- EXPECT_TRUE(db()->GetNextInteger(&next));
- EXPECT_EQ(4, next);
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestConsistencyCheck_Empty) {
- EXPECT_TRUE(db()->IsFileSystemConsistent());
-
- int64 next = -1;
- EXPECT_TRUE(db()->GetNextInteger(&next));
- EXPECT_EQ(0, next);
- EXPECT_TRUE(db()->IsFileSystemConsistent());
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestConsistencyCheck_Consistent) {
- FileId dir_id;
- CreateFile(0, FPL("foo"), FPL("hoge"), NULL);
- CreateDirectory(0, FPL("bar"), &dir_id);
- CreateFile(dir_id, FPL("baz"), FPL("fuga"), NULL);
- CreateFile(dir_id, FPL("fizz"), FPL("buzz"), NULL);
-
- EXPECT_TRUE(db()->IsFileSystemConsistent());
-}
-
-TEST_F(SandboxDirectoryDatabaseTest,
- TestConsistencyCheck_BackingMultiEntry) {
- const base::FilePath::CharType kBackingFileName[] = FPL("the celeb");
- CreateFile(0, FPL("foo"), kBackingFileName, NULL);
-
- EXPECT_TRUE(db()->IsFileSystemConsistent());
- ASSERT_TRUE(base::DeleteFile(path().Append(kBackingFileName), false));
- CreateFile(0, FPL("bar"), kBackingFileName, NULL);
- EXPECT_FALSE(db()->IsFileSystemConsistent());
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestConsistencyCheck_FileLost) {
- const base::FilePath::CharType kBackingFileName[] = FPL("hoge");
- CreateFile(0, FPL("foo"), kBackingFileName, NULL);
-
- EXPECT_TRUE(db()->IsFileSystemConsistent());
- ASSERT_TRUE(base::DeleteFile(path().Append(kBackingFileName), false));
- EXPECT_TRUE(db()->IsFileSystemConsistent());
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestConsistencyCheck_OrphanFile) {
- CreateFile(0, FPL("foo"), FPL("hoge"), NULL);
-
- EXPECT_TRUE(db()->IsFileSystemConsistent());
-
- bool created = false;
- base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
- base::PlatformFile file = base::CreatePlatformFile(
- path().Append(FPL("Orphan File")),
- base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_WRITE,
- &created, &error);
- ASSERT_EQ(base::PLATFORM_FILE_OK, error);
- ASSERT_TRUE(created);
- ASSERT_TRUE(base::ClosePlatformFile(file));
-
- EXPECT_TRUE(db()->IsFileSystemConsistent());
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestConsistencyCheck_RootLoop) {
- EXPECT_TRUE(db()->IsFileSystemConsistent());
- MakeHierarchyLink(0, 0, base::FilePath::StringType());
- EXPECT_FALSE(db()->IsFileSystemConsistent());
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestConsistencyCheck_DirectoryLoop) {
- FileId dir1_id;
- FileId dir2_id;
- base::FilePath::StringType dir1_name = FPL("foo");
- CreateDirectory(0, dir1_name, &dir1_id);
- CreateDirectory(dir1_id, FPL("bar"), &dir2_id);
-
- EXPECT_TRUE(db()->IsFileSystemConsistent());
- MakeHierarchyLink(dir2_id, dir1_id, dir1_name);
- EXPECT_FALSE(db()->IsFileSystemConsistent());
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestConsistencyCheck_NameMismatch) {
- FileId dir_id;
- FileId file_id;
- CreateDirectory(0, FPL("foo"), &dir_id);
- CreateFile(dir_id, FPL("bar"), FPL("hoge/fuga/piyo"), &file_id);
-
- EXPECT_TRUE(db()->IsFileSystemConsistent());
- DeleteHierarchyLink(file_id);
- MakeHierarchyLink(dir_id, file_id, FPL("baz"));
- EXPECT_FALSE(db()->IsFileSystemConsistent());
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestConsistencyCheck_WreckedEntries) {
- FileId dir1_id;
- FileId dir2_id;
- CreateDirectory(0, FPL("foo"), &dir1_id);
- CreateDirectory(dir1_id, FPL("bar"), &dir2_id);
- CreateFile(dir2_id, FPL("baz"), FPL("fizz/buzz"), NULL);
-
- EXPECT_TRUE(db()->IsFileSystemConsistent());
- DeleteHierarchyLink(dir2_id); // Delete link from |dir1_id| to |dir2_id|.
- EXPECT_FALSE(db()->IsFileSystemConsistent());
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestRepairDatabase_Success) {
- base::FilePath::StringType kFileName = FPL("bar");
-
- FileId file_id_prev;
- CreateFile(0, FPL("foo"), FPL("hoge"), NULL);
- CreateFile(0, kFileName, FPL("fuga"), &file_id_prev);
-
- const base::FilePath kDatabaseDirectory =
- path().Append(kDirectoryDatabaseName);
- CloseDatabase();
- CorruptDatabase(kDatabaseDirectory, leveldb::kDescriptorFile,
- 0, std::numeric_limits<size_t>::max());
- InitDatabase();
- EXPECT_FALSE(db()->IsFileSystemConsistent());
-
- FileId file_id;
- EXPECT_TRUE(db()->GetChildWithName(0, kFileName, &file_id));
- EXPECT_EQ(file_id_prev, file_id);
-
- EXPECT_TRUE(db()->IsFileSystemConsistent());
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestRepairDatabase_Failure) {
- base::FilePath::StringType kFileName = FPL("bar");
-
- CreateFile(0, FPL("foo"), FPL("hoge"), NULL);
- CreateFile(0, kFileName, FPL("fuga"), NULL);
-
- const base::FilePath kDatabaseDirectory =
- path().Append(kDirectoryDatabaseName);
- CloseDatabase();
- CorruptDatabase(kDatabaseDirectory, leveldb::kDescriptorFile,
- 0, std::numeric_limits<size_t>::max());
- CorruptDatabase(kDatabaseDirectory, leveldb::kLogFile,
- -1, 1);
- InitDatabase();
- EXPECT_FALSE(db()->IsFileSystemConsistent());
-
- FileId file_id;
- EXPECT_FALSE(db()->GetChildWithName(0, kFileName, &file_id));
- EXPECT_TRUE(db()->IsFileSystemConsistent());
-}
-
-TEST_F(SandboxDirectoryDatabaseTest, TestRepairDatabase_MissingManifest) {
- base::FilePath::StringType kFileName = FPL("bar");
-
- FileId file_id_prev;
- CreateFile(0, FPL("foo"), FPL("hoge"), NULL);
- CreateFile(0, kFileName, FPL("fuga"), &file_id_prev);
-
- const base::FilePath kDatabaseDirectory =
- path().Append(kDirectoryDatabaseName);
- CloseDatabase();
-
- DeleteDatabaseFile(kDatabaseDirectory, leveldb::kDescriptorFile);
-
- InitDatabase();
- EXPECT_FALSE(db()->IsFileSystemConsistent());
-
- FileId file_id;
- EXPECT_TRUE(db()->GetChildWithName(0, kFileName, &file_id));
- EXPECT_EQ(file_id_prev, file_id);
-
- EXPECT_TRUE(db()->IsFileSystemConsistent());
-}
-
-} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/sandbox_file_stream_writer.cc b/chromium/webkit/browser/fileapi/sandbox_file_stream_writer.cc
index 24fe1c947b1..f5efaa634fa 100644
--- a/chromium/webkit/browser/fileapi/sandbox_file_stream_writer.cc
+++ b/chromium/webkit/browser/fileapi/sandbox_file_stream_writer.cc
@@ -5,7 +5,6 @@
#include "webkit/browser/fileapi/sandbox_file_stream_writer.h"
#include "base/files/file_util_proxy.h"
-#include "base/platform_file.h"
#include "base/sequenced_task_runner.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
@@ -14,7 +13,7 @@
#include "webkit/browser/fileapi/file_stream_writer.h"
#include "webkit/browser/fileapi/file_system_context.h"
#include "webkit/browser/fileapi/file_system_operation_runner.h"
-#include "webkit/browser/quota/quota_manager.h"
+#include "webkit/browser/quota/quota_manager_proxy.h"
#include "webkit/common/fileapi/file_system_util.h"
namespace fileapi {
@@ -112,16 +111,16 @@ int SandboxFileStreamWriter::WriteInternal(
void SandboxFileStreamWriter::DidCreateSnapshotFile(
const net::CompletionCallback& callback,
- base::PlatformFileError file_error,
- const base::PlatformFileInfo& file_info,
+ base::File::Error file_error,
+ const base::File::Info& file_info,
const base::FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) {
DCHECK(!file_ref.get());
if (CancelIfRequested())
return;
- if (file_error != base::PLATFORM_FILE_OK) {
- callback.Run(net::PlatformFileErrorToNetError(file_error));
+ if (file_error != base::File::FILE_OK) {
+ callback.Run(net::FileErrorToNetError(file_error));
return;
}
if (file_info.is_directory) {
@@ -138,8 +137,10 @@ void SandboxFileStreamWriter::DidCreateSnapshotFile(
}
DCHECK(!local_file_writer_.get());
local_file_writer_.reset(FileStreamWriter::CreateForLocalFile(
- file_system_context_->default_file_task_runner(), platform_path,
- initial_offset_));
+ file_system_context_->default_file_task_runner(),
+ platform_path,
+ initial_offset_,
+ FileStreamWriter::OPEN_EXISTING_FILE));
quota::QuotaManagerProxy* quota_manager_proxy =
file_system_context_->quota_manager_proxy();
diff --git a/chromium/webkit/browser/fileapi/sandbox_file_stream_writer.h b/chromium/webkit/browser/fileapi/sandbox_file_stream_writer.h
index 81123376f50..53cbb50366a 100644
--- a/chromium/webkit/browser/fileapi/sandbox_file_stream_writer.h
+++ b/chromium/webkit/browser/fileapi/sandbox_file_stream_writer.h
@@ -5,9 +5,9 @@
#ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_STREAM_WRITER_H_
#define WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_STREAM_WRITER_H_
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
-#include "base/platform_file.h"
#include "url/gurl.h"
#include "webkit/browser/fileapi/file_stream_writer.h"
#include "webkit/browser/fileapi/file_system_url.h"
@@ -52,8 +52,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE SandboxFileStreamWriter
// WriteInternal.
void DidCreateSnapshotFile(
const net::CompletionCallback& callback,
- base::PlatformFileError file_error,
- const base::PlatformFileInfo& file_info,
+ base::File::Error file_error,
+ const base::File::Info& file_info,
const base::FilePath& platform_path,
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref);
void DidGetUsageAndQuota(const net::CompletionCallback& callback,
diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_backend.cc b/chromium/webkit/browser/fileapi/sandbox_file_system_backend.cc
index cc022788aa4..cb288aaab91 100644
--- a/chromium/webkit/browser/fileapi/sandbox_file_system_backend.cc
+++ b/chromium/webkit/browser/fileapi/sandbox_file_system_backend.cc
@@ -60,24 +60,25 @@ void SandboxFileSystemBackend::Initialize(FileSystemContext* context) {
delegate_->quota_observer(), NULL);
}
-void SandboxFileSystemBackend::OpenFileSystem(
- const GURL& origin_url,
- fileapi::FileSystemType type,
+void SandboxFileSystemBackend::ResolveURL(
+ const FileSystemURL& url,
OpenFileSystemMode mode,
const OpenFileSystemCallback& callback) {
- DCHECK(CanHandleType(type));
+ DCHECK(CanHandleType(url.type()));
DCHECK(delegate_);
if (delegate_->file_system_options().is_incognito() &&
- !(type == kFileSystemTypeTemporary &&
+ !(url.type() == kFileSystemTypeTemporary &&
enable_temporary_file_system_in_incognito_)) {
// TODO(kinuko): return an isolated temporary directory.
- callback.Run(GURL(), std::string(), base::PLATFORM_FILE_ERROR_SECURITY);
+ callback.Run(GURL(), std::string(), base::File::FILE_ERROR_SECURITY);
return;
}
- delegate_->OpenFileSystem(
- origin_url, type, mode, callback,
- GetFileSystemRootURI(origin_url, type));
+ delegate_->OpenFileSystem(url.origin(),
+ url.type(),
+ mode,
+ callback,
+ GetFileSystemRootURI(url.origin(), url.type()));
}
AsyncFileUtil* SandboxFileSystemBackend::GetAsyncFileUtil(
@@ -89,16 +90,16 @@ AsyncFileUtil* SandboxFileSystemBackend::GetAsyncFileUtil(
CopyOrMoveFileValidatorFactory*
SandboxFileSystemBackend::GetCopyOrMoveFileValidatorFactory(
FileSystemType type,
- base::PlatformFileError* error_code) {
+ base::File::Error* error_code) {
DCHECK(error_code);
- *error_code = base::PLATFORM_FILE_OK;
+ *error_code = base::File::FILE_OK;
return NULL;
}
FileSystemOperation* SandboxFileSystemBackend::CreateFileSystemOperation(
const FileSystemURL& url,
FileSystemContext* context,
- base::PlatformFileError* error_code) const {
+ base::File::Error* error_code) const {
DCHECK(CanHandleType(url.type()));
DCHECK(error_code);
@@ -117,6 +118,11 @@ FileSystemOperation* SandboxFileSystemBackend::CreateFileSystemOperation(
return FileSystemOperation::Create(url, context, operation_context.Pass());
}
+bool SandboxFileSystemBackend::SupportsStreaming(
+ const fileapi::FileSystemURL& url) const {
+ return false;
+}
+
scoped_ptr<webkit_blob::FileStreamReader>
SandboxFileSystemBackend::CreateFileStreamReader(
const FileSystemURL& url,
diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_backend.h b/chromium/webkit/browser/fileapi/sandbox_file_system_backend.h
index 8531cf862bf..f82c2947396 100644
--- a/chromium/webkit/browser/fileapi/sandbox_file_system_backend.h
+++ b/chromium/webkit/browser/fileapi/sandbox_file_system_backend.h
@@ -21,7 +21,6 @@
namespace fileapi {
-// An interface to construct or crack sandboxed filesystem paths for
// TEMPORARY or PERSISTENT filesystems, which are placed under the user's
// profile directory in a sandboxed way.
// This interface also lets one enumerate and remove storage for the origins
@@ -35,19 +34,18 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend
// FileSystemBackend overrides.
virtual bool CanHandleType(FileSystemType type) const OVERRIDE;
virtual void Initialize(FileSystemContext* context) OVERRIDE;
- virtual void OpenFileSystem(
- const GURL& origin_url,
- FileSystemType type,
- OpenFileSystemMode mode,
- const OpenFileSystemCallback& callback) OVERRIDE;
+ virtual void ResolveURL(const FileSystemURL& url,
+ OpenFileSystemMode mode,
+ const OpenFileSystemCallback& callback) OVERRIDE;
virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE;
virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory(
FileSystemType type,
- base::PlatformFileError* error_code) OVERRIDE;
+ base::File::Error* error_code) OVERRIDE;
virtual FileSystemOperation* CreateFileSystemOperation(
const FileSystemURL& url,
FileSystemContext* context,
- base::PlatformFileError* error_code) const OVERRIDE;
+ base::File::Error* error_code) const OVERRIDE;
+ virtual bool SupportsStreaming(const FileSystemURL& url) const OVERRIDE;
virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader(
const FileSystemURL& url,
int64 offset,
diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.cc b/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.cc
index bb4d48e41d1..6bb2efd9499 100644
--- a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.cc
+++ b/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.cc
@@ -25,7 +25,7 @@
#include "webkit/browser/fileapi/sandbox_file_stream_writer.h"
#include "webkit/browser/fileapi/sandbox_file_system_backend.h"
#include "webkit/browser/fileapi/sandbox_quota_observer.h"
-#include "webkit/browser/quota/quota_manager.h"
+#include "webkit/browser/quota/quota_manager_proxy.h"
#include "webkit/common/fileapi/file_system_util.h"
namespace fileapi {
@@ -107,18 +107,18 @@ class ObfuscatedOriginEnumerator
scoped_ptr<ObfuscatedFileUtil::AbstractOriginEnumerator> enum_;
};
-void OpenFileSystemOnFileThread(
+void OpenFileSystemOnFileTaskRunner(
ObfuscatedFileUtil* file_util,
const GURL& origin_url,
FileSystemType type,
OpenFileSystemMode mode,
- base::PlatformFileError* error_ptr) {
+ base::File::Error* error_ptr) {
DCHECK(error_ptr);
const bool create = (mode == OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT);
file_util->GetDirectoryForOriginAndType(
origin_url, SandboxFileSystemBackendDelegate::GetTypeString(type),
create, error_ptr);
- if (*error_ptr != base::PLATFORM_FILE_OK) {
+ if (*error_ptr != base::File::FILE_OK) {
UMA_HISTOGRAM_ENUMERATION(kOpenFileSystemLabel,
kCreateDirectoryError,
kFileSystemErrorMax);
@@ -132,8 +132,8 @@ void OpenFileSystemOnFileThread(
void DidOpenFileSystem(
base::WeakPtr<SandboxFileSystemBackendDelegate> delegate,
- const base::Callback<void(base::PlatformFileError error)>& callback,
- base::PlatformFileError* error) {
+ const base::Callback<void(base::File::Error error)>& callback,
+ base::File::Error* error) {
if (delegate.get())
delegate.get()->CollectOpenFileSystemMetrics(*error);
callback.Run(*error);
@@ -180,6 +180,7 @@ SandboxFileSystemBackendDelegate::SandboxFileSystemBackendDelegate(
new ObfuscatedFileUtil(
special_storage_policy,
profile_path.Append(kFileSystemDirectory),
+ file_system_options.env_override(),
file_task_runner,
base::Bind(&GetTypeStringForURL),
GetKnownTypeStrings(),
@@ -203,7 +204,8 @@ SandboxFileSystemBackendDelegate::SandboxFileSystemBackendDelegate(
// Prepopulate database only if it can run asynchronously (i.e. the current
// thread is not file_task_runner). Usually this is the case but may not
// in test code.
- if (!file_task_runner_->RunsTasksOnCurrentThread()) {
+ if (!file_system_options.is_incognito() &&
+ !file_task_runner_->RunsTasksOnCurrentThread()) {
std::vector<std::string> types_to_prepopulate(
&kPrepopulateTypes[0],
&kPrepopulateTypes[arraysize(kPrepopulateTypes)]);
@@ -236,10 +238,10 @@ SandboxFileSystemBackendDelegate::GetBaseDirectoryForOriginAndType(
const GURL& origin_url,
FileSystemType type,
bool create) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
base::FilePath path = obfuscated_file_util()->GetDirectoryForOriginAndType(
origin_url, GetTypeString(type), create, &error);
- if (error != base::PLATFORM_FILE_OK)
+ if (error != base::File::FILE_OK)
return base::FilePath();
return path;
}
@@ -251,16 +253,16 @@ void SandboxFileSystemBackendDelegate::OpenFileSystem(
const OpenFileSystemCallback& callback,
const GURL& root_url) {
if (!IsAllowedScheme(origin_url)) {
- callback.Run(GURL(), std::string(), base::PLATFORM_FILE_ERROR_SECURITY);
+ callback.Run(GURL(), std::string(), base::File::FILE_ERROR_SECURITY);
return;
}
std::string name = GetFileSystemName(origin_url, type);
- base::PlatformFileError* error_ptr = new base::PlatformFileError;
+ base::File::Error* error_ptr = new base::File::Error;
file_task_runner_->PostTaskAndReply(
FROM_HERE,
- base::Bind(&OpenFileSystemOnFileThread,
+ base::Bind(&OpenFileSystemOnFileTaskRunner,
obfuscated_file_util(), origin_url, type, mode,
base::Unretained(error_ptr)),
base::Bind(&DidOpenFileSystem,
@@ -276,9 +278,9 @@ scoped_ptr<FileSystemOperationContext>
SandboxFileSystemBackendDelegate::CreateFileSystemOperationContext(
const FileSystemURL& url,
FileSystemContext* context,
- base::PlatformFileError* error_code) const {
+ base::File::Error* error_code) const {
if (!IsAccessValid(url)) {
- *error_code = base::PLATFORM_FILE_ERROR_SECURITY;
+ *error_code = base::File::FILE_ERROR_SECURITY;
return scoped_ptr<FileSystemOperationContext>();
}
@@ -322,13 +324,14 @@ SandboxFileSystemBackendDelegate::CreateFileStreamWriter(
new SandboxFileStreamWriter(context, url, offset, *observers));
}
-base::PlatformFileError
-SandboxFileSystemBackendDelegate::DeleteOriginDataOnFileThread(
+base::File::Error
+SandboxFileSystemBackendDelegate::DeleteOriginDataOnFileTaskRunner(
FileSystemContext* file_system_context,
quota::QuotaManagerProxy* proxy,
const GURL& origin_url,
FileSystemType type) {
- int64 usage = GetOriginUsageOnFileThread(
+ DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
+ int64 usage = GetOriginUsageOnFileTaskRunner(
file_system_context, origin_url, type);
usage_cache()->CloseCacheFiles();
bool result = obfuscated_file_util()->DeleteDirectoryForOriginAndType(
@@ -342,12 +345,13 @@ SandboxFileSystemBackendDelegate::DeleteOriginDataOnFileThread(
}
if (result)
- return base::PLATFORM_FILE_OK;
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_OK;
+ return base::File::FILE_ERROR_FAILED;
}
-void SandboxFileSystemBackendDelegate::GetOriginsForTypeOnFileThread(
+void SandboxFileSystemBackendDelegate::GetOriginsForTypeOnFileTaskRunner(
FileSystemType type, std::set<GURL>* origins) {
+ DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
DCHECK(origins);
scoped_ptr<OriginEnumerator> enumerator(CreateOriginEnumerator());
GURL origin;
@@ -367,9 +371,10 @@ void SandboxFileSystemBackendDelegate::GetOriginsForTypeOnFileThread(
}
}
-void SandboxFileSystemBackendDelegate::GetOriginsForHostOnFileThread(
+void SandboxFileSystemBackendDelegate::GetOriginsForHostOnFileTaskRunner(
FileSystemType type, const std::string& host,
std::set<GURL>* origins) {
+ DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
DCHECK(origins);
scoped_ptr<OriginEnumerator> enumerator(CreateOriginEnumerator());
GURL origin;
@@ -380,10 +385,12 @@ void SandboxFileSystemBackendDelegate::GetOriginsForHostOnFileThread(
}
}
-int64 SandboxFileSystemBackendDelegate::GetOriginUsageOnFileThread(
+int64 SandboxFileSystemBackendDelegate::GetOriginUsageOnFileTaskRunner(
FileSystemContext* file_system_context,
const GURL& origin_url,
FileSystemType type) {
+ DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
+
// Don't use usage cache and return recalculated usage for sticky invalidated
// origins.
if (ContainsKey(sticky_dirty_origins_, std::make_pair(origin_url, type)))
@@ -489,10 +496,10 @@ void SandboxFileSystemBackendDelegate::RegisterQuotaUpdateObserver(
void SandboxFileSystemBackendDelegate::InvalidateUsageCache(
const GURL& origin,
FileSystemType type) {
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
base::FilePath usage_file_path = GetUsageCachePathForOriginAndType(
obfuscated_file_util(), origin, type, &error);
- if (error != base::PLATFORM_FILE_OK)
+ if (error != base::File::FILE_OK)
return;
usage_cache()->IncrementDirty(usage_file_path);
}
@@ -563,10 +570,10 @@ base::FilePath
SandboxFileSystemBackendDelegate::GetUsageCachePathForOriginAndType(
const GURL& origin_url,
FileSystemType type) {
- base::PlatformFileError error;
+ base::File::Error error;
base::FilePath path = GetUsageCachePathForOriginAndType(
obfuscated_file_util(), origin_url, type, &error);
- if (error != base::PLATFORM_FILE_OK)
+ if (error != base::File::FILE_OK)
return base::FilePath();
return path;
}
@@ -577,12 +584,12 @@ SandboxFileSystemBackendDelegate::GetUsageCachePathForOriginAndType(
ObfuscatedFileUtil* sandbox_file_util,
const GURL& origin_url,
FileSystemType type,
- base::PlatformFileError* error_out) {
+ base::File::Error* error_out) {
DCHECK(error_out);
- *error_out = base::PLATFORM_FILE_OK;
+ *error_out = base::File::FILE_OK;
base::FilePath base_path = sandbox_file_util->GetDirectoryForOriginAndType(
origin_url, GetTypeString(type), false /* create */, error_out);
- if (*error_out != base::PLATFORM_FILE_OK)
+ if (*error_out != base::File::FILE_OK)
return base::FilePath();
return base_path.Append(FileSystemUsageCache::kUsageFileName);
}
@@ -610,7 +617,7 @@ int64 SandboxFileSystemBackendDelegate::RecalculateUsage(
}
void SandboxFileSystemBackendDelegate::CollectOpenFileSystemMetrics(
- base::PlatformFileError error_code) {
+ base::File::Error error_code) {
base::Time now = base::Time::Now();
bool throttled = now < next_release_time_for_open_filesystem_stat_;
if (!throttled) {
@@ -629,16 +636,16 @@ void SandboxFileSystemBackendDelegate::CollectOpenFileSystemMetrics(
}
switch (error_code) {
- case base::PLATFORM_FILE_OK:
+ case base::File::FILE_OK:
REPORT(kOK);
break;
- case base::PLATFORM_FILE_ERROR_INVALID_URL:
+ case base::File::FILE_ERROR_INVALID_URL:
REPORT(kInvalidSchemeError);
break;
- case base::PLATFORM_FILE_ERROR_NOT_FOUND:
+ case base::File::FILE_ERROR_NOT_FOUND:
REPORT(kNotFound);
break;
- case base::PLATFORM_FILE_ERROR_FAILED:
+ case base::File::FILE_ERROR_FAILED:
default:
REPORT(kUnknownError);
break;
@@ -655,9 +662,11 @@ ObfuscatedFileUtil* SandboxFileSystemBackendDelegate::obfuscated_file_util() {
ObfuscatedFileUtil* ObfuscatedFileUtil::CreateForTesting(
quota::SpecialStoragePolicy* special_storage_policy,
const base::FilePath& file_system_directory,
+ leveldb::Env* env_override,
base::SequencedTaskRunner* file_task_runner) {
return new ObfuscatedFileUtil(special_storage_policy,
file_system_directory,
+ env_override,
file_task_runner,
base::Bind(&GetTypeStringForURL),
GetKnownTypeStrings(),
diff --git a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.h b/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.h
index dd5e11f1837..2b67cfcc3cb 100644
--- a/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.h
+++ b/chromium/webkit/browser/fileapi/sandbox_file_system_backend_delegate.h
@@ -26,6 +26,11 @@ namespace base {
class SequencedTaskRunner;
}
+namespace content {
+class SandboxFileSystemBackendDelegateTest;
+class SandboxFileSystemTestHelper;
+}
+
namespace quota {
class QuotaManagerProxy;
class SpecialStoragePolicy;
@@ -46,7 +51,6 @@ class FileSystemUsageCache;
class ObfuscatedFileUtil;
class QuotaReservationManager;
class SandboxFileSystemBackend;
-class SandboxFileSystemTestHelper;
class SandboxQuotaObserver;
// Delegate implementation of the some methods in Sandbox/SyncFileSystemBackend.
@@ -109,7 +113,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate
scoped_ptr<FileSystemOperationContext> CreateFileSystemOperationContext(
const FileSystemURL& url,
FileSystemContext* context,
- base::PlatformFileError* error_code) const;
+ base::File::Error* error_code) const;
scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader(
const FileSystemURL& url,
int64 offset,
@@ -122,19 +126,19 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate
FileSystemType type) const;
// FileSystemQuotaUtil overrides.
- virtual base::PlatformFileError DeleteOriginDataOnFileThread(
+ virtual base::File::Error DeleteOriginDataOnFileTaskRunner(
FileSystemContext* context,
quota::QuotaManagerProxy* proxy,
const GURL& origin_url,
FileSystemType type) OVERRIDE;
- virtual void GetOriginsForTypeOnFileThread(
+ virtual void GetOriginsForTypeOnFileTaskRunner(
FileSystemType type,
std::set<GURL>* origins) OVERRIDE;
- virtual void GetOriginsForHostOnFileThread(
+ virtual void GetOriginsForHostOnFileTaskRunner(
FileSystemType type,
const std::string& host,
std::set<GURL>* origins) OVERRIDE;
- virtual int64 GetOriginUsageOnFileThread(
+ virtual int64 GetOriginUsageOnFileTaskRunner(
FileSystemContext* context,
const GURL& origin_url,
FileSystemType type) OVERRIDE;
@@ -169,7 +173,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate
void StickyInvalidateUsageCache(const GURL& origin_url,
FileSystemType type);
- void CollectOpenFileSystemMetrics(base::PlatformFileError error_code);
+ void CollectOpenFileSystemMetrics(base::File::Error error_code);
base::SequencedTaskRunner* file_task_runner() {
return file_task_runner_.get();
@@ -190,10 +194,10 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate
FileSystemFileUtil* sync_file_util();
private:
- friend class SandboxQuotaObserver;
- friend class SandboxFileSystemTestHelper;
friend class QuotaBackendImpl;
- FRIEND_TEST_ALL_PREFIXES(SandboxFileSystemBackendDelegateTest, IsAccessValid);
+ friend class SandboxQuotaObserver;
+ friend class content::SandboxFileSystemBackendDelegateTest;
+ friend class content::SandboxFileSystemTestHelper;
// Performs API-specific validity checks on the given path |url|.
// Returns true if access to |url| is valid in this filesystem.
@@ -213,7 +217,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackendDelegate
ObfuscatedFileUtil* sandbox_file_util,
const GURL& origin_url,
FileSystemType type,
- base::PlatformFileError* error_out);
+ base::File::Error* error_out);
int64 RecalculateUsage(FileSystemContext* context,
const GURL& origin,
diff --git a/chromium/webkit/browser/fileapi/sandbox_isolated_origin_database_unittest.cc b/chromium/webkit/browser/fileapi/sandbox_isolated_origin_database_unittest.cc
deleted file mode 100644
index 047a9612636..00000000000
--- a/chromium/webkit/browser/fileapi/sandbox_isolated_origin_database_unittest.cc
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2013 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 "base/basictypes.h"
-#include "base/file_util.h"
-#include "base/files/scoped_temp_dir.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/fileapi/sandbox_isolated_origin_database.h"
-#include "webkit/browser/fileapi/sandbox_origin_database.h"
-
-namespace fileapi {
-
-namespace {
-const base::FilePath::CharType kOriginDirectory[] = FILE_PATH_LITERAL("iso");
-} // namespace
-
-TEST(SandboxIsolatedOriginDatabaseTest, BasicTest) {
- base::ScopedTempDir dir;
- ASSERT_TRUE(dir.CreateUniqueTempDir());
-
- std::string kOrigin("origin");
- SandboxIsolatedOriginDatabase database(kOrigin, dir.path(),
- base::FilePath(kOriginDirectory));
-
- EXPECT_TRUE(database.HasOriginPath(kOrigin));
-
- base::FilePath path1, path2;
-
- EXPECT_FALSE(database.GetPathForOrigin(std::string(), &path1));
- EXPECT_FALSE(database.GetPathForOrigin("foo", &path1));
-
- EXPECT_TRUE(database.HasOriginPath(kOrigin));
- EXPECT_TRUE(database.GetPathForOrigin(kOrigin, &path1));
- EXPECT_TRUE(database.GetPathForOrigin(kOrigin, &path2));
- EXPECT_FALSE(path1.empty());
- EXPECT_FALSE(path2.empty());
- EXPECT_EQ(path1, path2);
-}
-
-} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/sandbox_origin_database.cc b/chromium/webkit/browser/fileapi/sandbox_origin_database.cc
index ee01d227914..3bbee520e63 100644
--- a/chromium/webkit/browser/fileapi/sandbox_origin_database.cc
+++ b/chromium/webkit/browser/fileapi/sandbox_origin_database.cc
@@ -58,8 +58,10 @@ const char* LastPathKey() {
namespace fileapi {
SandboxOriginDatabase::SandboxOriginDatabase(
- const base::FilePath& file_system_directory)
- : file_system_directory_(file_system_directory) {
+ const base::FilePath& file_system_directory,
+ leveldb::Env* env_override)
+ : file_system_directory_(file_system_directory),
+ env_override_(env_override) {
}
SandboxOriginDatabase::~SandboxOriginDatabase() {
@@ -78,6 +80,8 @@ bool SandboxOriginDatabase::Init(InitOption init_option,
leveldb::Options options;
options.max_open_files = 0; // Use minimum.
options.create_if_missing = true;
+ if (env_override_)
+ options.env = env_override_;
leveldb::DB* db;
leveldb::Status status = leveldb::DB::Open(options, path, &db);
ReportInitStatus(status);
@@ -123,6 +127,8 @@ bool SandboxOriginDatabase::RepairDatabase(const std::string& db_path) {
DCHECK(!db_.get());
leveldb::Options options;
options.max_open_files = 0; // Use minimum.
+ if (env_override_)
+ options.env = env_override_;
if (!leveldb::RepairDB(db_path, options).ok() ||
!Init(FAIL_IF_NONEXISTENT, FAIL_ON_CORRUPTION)) {
LOG(WARNING) << "Failed to repair SandboxOriginDatabase.";
diff --git a/chromium/webkit/browser/fileapi/sandbox_origin_database.h b/chromium/webkit/browser/fileapi/sandbox_origin_database.h
index dd3b32c95c3..57d2e8415ab 100644
--- a/chromium/webkit/browser/fileapi/sandbox_origin_database.h
+++ b/chromium/webkit/browser/fileapi/sandbox_origin_database.h
@@ -14,6 +14,7 @@
namespace leveldb {
class DB;
+class Env;
class Status;
}
@@ -30,7 +31,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE SandboxOriginDatabase
public:
// Only one instance of SandboxOriginDatabase should exist for a given path
// at a given time.
- explicit SandboxOriginDatabase(const base::FilePath& file_system_directory);
+ SandboxOriginDatabase(const base::FilePath& file_system_directory,
+ leveldb::Env* env_override);
virtual ~SandboxOriginDatabase();
// SandboxOriginDatabaseInterface overrides.
@@ -64,6 +66,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE SandboxOriginDatabase
bool GetLastPathNumber(int* number);
base::FilePath file_system_directory_;
+ leveldb::Env* env_override_;
scoped_ptr<leveldb::DB> db_;
base::Time last_reported_time_;
DISALLOW_COPY_AND_ASSIGN(SandboxOriginDatabase);
diff --git a/chromium/webkit/browser/fileapi/sandbox_origin_database_unittest.cc b/chromium/webkit/browser/fileapi/sandbox_origin_database_unittest.cc
deleted file mode 100644
index 340baf22409..00000000000
--- a/chromium/webkit/browser/fileapi/sandbox_origin_database_unittest.cc
+++ /dev/null
@@ -1,308 +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 <algorithm>
-#include <functional>
-#include <limits>
-#include <string>
-#include <vector>
-
-#include "base/file_util.h"
-#include "base/files/file_path.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/platform_file.h"
-#include "base/stl_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/leveldatabase/src/db/filename.h"
-#include "third_party/leveldatabase/src/include/leveldb/db.h"
-#include "webkit/browser/fileapi/sandbox_database_test_helper.h"
-#include "webkit/browser/fileapi/sandbox_origin_database.h"
-#include "webkit/common/fileapi/file_system_util.h"
-
-namespace fileapi {
-
-namespace {
-const base::FilePath::CharType kFileSystemDirName[] =
- FILE_PATH_LITERAL("File System");
-const base::FilePath::CharType kOriginDatabaseName[] =
- FILE_PATH_LITERAL("Origins");
-} // namespace
-
-TEST(SandboxOriginDatabaseTest, BasicTest) {
- base::ScopedTempDir dir;
- ASSERT_TRUE(dir.CreateUniqueTempDir());
- const base::FilePath kFSDir = dir.path().Append(kFileSystemDirName);
- EXPECT_FALSE(base::PathExists(kFSDir));
- EXPECT_TRUE(base::CreateDirectory(kFSDir));
-
- SandboxOriginDatabase database(kFSDir);
- std::string origin("origin");
-
- EXPECT_FALSE(database.HasOriginPath(origin));
- // Double-check to make sure that had no side effects.
- EXPECT_FALSE(database.HasOriginPath(origin));
-
- base::FilePath path0;
- base::FilePath path1;
-
- // Empty strings aren't valid origins.
- EXPECT_FALSE(database.GetPathForOrigin(std::string(), &path0));
-
- EXPECT_TRUE(database.GetPathForOrigin(origin, &path0));
- EXPECT_TRUE(database.HasOriginPath(origin));
- EXPECT_TRUE(database.GetPathForOrigin(origin, &path1));
- EXPECT_FALSE(path0.empty());
- EXPECT_FALSE(path1.empty());
- EXPECT_EQ(path0, path1);
-
- EXPECT_TRUE(base::PathExists(kFSDir.Append(kOriginDatabaseName)));
-}
-
-TEST(SandboxOriginDatabaseTest, TwoPathTest) {
- base::ScopedTempDir dir;
- ASSERT_TRUE(dir.CreateUniqueTempDir());
- const base::FilePath kFSDir = dir.path().Append(kFileSystemDirName);
- EXPECT_FALSE(base::PathExists(kFSDir));
- EXPECT_TRUE(base::CreateDirectory(kFSDir));
-
- SandboxOriginDatabase database(kFSDir);
- std::string origin0("origin0");
- std::string origin1("origin1");
-
- EXPECT_FALSE(database.HasOriginPath(origin0));
- EXPECT_FALSE(database.HasOriginPath(origin1));
-
- base::FilePath path0;
- base::FilePath path1;
- EXPECT_TRUE(database.GetPathForOrigin(origin0, &path0));
- EXPECT_TRUE(database.HasOriginPath(origin0));
- EXPECT_FALSE(database.HasOriginPath(origin1));
- EXPECT_TRUE(database.GetPathForOrigin(origin1, &path1));
- EXPECT_TRUE(database.HasOriginPath(origin1));
- EXPECT_FALSE(path0.empty());
- EXPECT_FALSE(path1.empty());
- EXPECT_NE(path0, path1);
-
- EXPECT_TRUE(base::PathExists(kFSDir.Append(kOriginDatabaseName)));
-}
-
-TEST(SandboxOriginDatabaseTest, DropDatabaseTest) {
- base::ScopedTempDir dir;
- ASSERT_TRUE(dir.CreateUniqueTempDir());
- const base::FilePath kFSDir = dir.path().Append(kFileSystemDirName);
- EXPECT_FALSE(base::PathExists(kFSDir));
- EXPECT_TRUE(base::CreateDirectory(kFSDir));
-
- SandboxOriginDatabase database(kFSDir);
- std::string origin("origin");
-
- EXPECT_FALSE(database.HasOriginPath(origin));
-
- base::FilePath path0;
- EXPECT_TRUE(database.GetPathForOrigin(origin, &path0));
- EXPECT_TRUE(database.HasOriginPath(origin));
- EXPECT_FALSE(path0.empty());
-
- EXPECT_TRUE(base::PathExists(kFSDir.Append(kOriginDatabaseName)));
-
- database.DropDatabase();
-
- base::FilePath path1;
- EXPECT_TRUE(database.HasOriginPath(origin));
- EXPECT_TRUE(database.GetPathForOrigin(origin, &path1));
- EXPECT_FALSE(path1.empty());
- EXPECT_EQ(path0, path1);
-}
-
-TEST(SandboxOriginDatabaseTest, DeleteOriginTest) {
- base::ScopedTempDir dir;
- ASSERT_TRUE(dir.CreateUniqueTempDir());
- const base::FilePath kFSDir = dir.path().Append(kFileSystemDirName);
- EXPECT_FALSE(base::PathExists(kFSDir));
- EXPECT_TRUE(base::CreateDirectory(kFSDir));
-
- SandboxOriginDatabase database(kFSDir);
- std::string origin("origin");
-
- EXPECT_FALSE(database.HasOriginPath(origin));
- EXPECT_TRUE(database.RemovePathForOrigin(origin));
-
- base::FilePath path0;
- EXPECT_TRUE(database.GetPathForOrigin(origin, &path0));
- EXPECT_TRUE(database.HasOriginPath(origin));
- EXPECT_FALSE(path0.empty());
-
- EXPECT_TRUE(database.RemovePathForOrigin(origin));
- EXPECT_FALSE(database.HasOriginPath(origin));
-
- base::FilePath path1;
- EXPECT_TRUE(database.GetPathForOrigin(origin, &path1));
- EXPECT_FALSE(path1.empty());
- EXPECT_NE(path0, path1);
-}
-
-TEST(SandboxOriginDatabaseTest, ListOriginsTest) {
- base::ScopedTempDir dir;
- ASSERT_TRUE(dir.CreateUniqueTempDir());
- const base::FilePath kFSDir = dir.path().Append(kFileSystemDirName);
- EXPECT_FALSE(base::PathExists(kFSDir));
- EXPECT_TRUE(base::CreateDirectory(kFSDir));
-
- std::vector<SandboxOriginDatabase::OriginRecord> origins;
-
- SandboxOriginDatabase database(kFSDir);
- EXPECT_TRUE(database.ListAllOrigins(&origins));
- EXPECT_TRUE(origins.empty());
- origins.clear();
-
- std::string origin0("origin0");
- std::string origin1("origin1");
-
- EXPECT_FALSE(database.HasOriginPath(origin0));
- EXPECT_FALSE(database.HasOriginPath(origin1));
-
- base::FilePath path0;
- base::FilePath path1;
- EXPECT_TRUE(database.GetPathForOrigin(origin0, &path0));
- EXPECT_TRUE(database.ListAllOrigins(&origins));
- EXPECT_EQ(origins.size(), 1UL);
- EXPECT_EQ(origins[0].origin, origin0);
- EXPECT_EQ(origins[0].path, path0);
- origins.clear();
- EXPECT_TRUE(database.GetPathForOrigin(origin1, &path1));
- EXPECT_TRUE(database.ListAllOrigins(&origins));
- EXPECT_EQ(origins.size(), 2UL);
- if (origins[0].origin == origin0) {
- EXPECT_EQ(origins[0].path, path0);
- EXPECT_EQ(origins[1].origin, origin1);
- EXPECT_EQ(origins[1].path, path1);
- } else {
- EXPECT_EQ(origins[0].origin, origin1);
- EXPECT_EQ(origins[0].path, path1);
- EXPECT_EQ(origins[1].origin, origin0);
- EXPECT_EQ(origins[1].path, path0);
- }
-}
-
-TEST(SandboxOriginDatabaseTest, DatabaseRecoveryTest) {
- // Checks if SandboxOriginDatabase properly handles database corruption.
- // In this test, we'll register some origins to the origin database, then
- // corrupt database and its log file.
- // After repairing, the origin database should be consistent even when some
- // entries lost.
-
- base::ScopedTempDir dir;
- ASSERT_TRUE(dir.CreateUniqueTempDir());
- const base::FilePath kFSDir = dir.path().Append(kFileSystemDirName);
- const base::FilePath kDBDir = kFSDir.Append(kOriginDatabaseName);
- EXPECT_FALSE(base::PathExists(kFSDir));
- EXPECT_TRUE(base::CreateDirectory(kFSDir));
-
- const std::string kOrigins[] = {
- "foo.example.com",
- "bar.example.com",
- "baz.example.com",
- "hoge.example.com",
- "fuga.example.com",
- };
-
- scoped_ptr<SandboxOriginDatabase> database(
- new SandboxOriginDatabase(kFSDir));
- for (size_t i = 0; i < arraysize(kOrigins); ++i) {
- base::FilePath path;
- EXPECT_FALSE(database->HasOriginPath(kOrigins[i]));
- EXPECT_TRUE(database->GetPathForOrigin(kOrigins[i], &path));
- EXPECT_FALSE(path.empty());
- EXPECT_TRUE(database->GetPathForOrigin(kOrigins[i], &path));
-
- if (i != 1)
- EXPECT_TRUE(base::CreateDirectory(kFSDir.Append(path)));
- }
- database.reset();
-
- const base::FilePath kGarbageDir = kFSDir.AppendASCII("foo");
- const base::FilePath kGarbageFile = kGarbageDir.AppendASCII("bar");
- EXPECT_TRUE(base::CreateDirectory(kGarbageDir));
- bool created = false;
- base::PlatformFileError error;
- base::PlatformFile file = base::CreatePlatformFile(
- kGarbageFile,
- base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_WRITE,
- &created, &error);
- EXPECT_EQ(base::PLATFORM_FILE_OK, error);
- EXPECT_TRUE(created);
- EXPECT_TRUE(base::ClosePlatformFile(file));
-
- // Corrupt database itself and last log entry to drop last 1 database
- // operation. The database should detect the corruption and should recover
- // its consistency after recovery.
- CorruptDatabase(kDBDir, leveldb::kDescriptorFile,
- 0, std::numeric_limits<size_t>::max());
- CorruptDatabase(kDBDir, leveldb::kLogFile, -1, 1);
-
- base::FilePath path;
- database.reset(new SandboxOriginDatabase(kFSDir));
- std::vector<SandboxOriginDatabase::OriginRecord> origins_in_db;
- EXPECT_TRUE(database->ListAllOrigins(&origins_in_db));
-
- // Expect all but last added origin will be repaired back, and kOrigins[1]
- // should be dropped due to absence of backing directory.
- EXPECT_EQ(arraysize(kOrigins) - 2, origins_in_db.size());
-
- const std::string kOrigin("piyo.example.org");
- EXPECT_FALSE(database->HasOriginPath(kOrigin));
- EXPECT_TRUE(database->GetPathForOrigin(kOrigin, &path));
- EXPECT_FALSE(path.empty());
- EXPECT_TRUE(database->HasOriginPath(kOrigin));
-
- EXPECT_FALSE(base::PathExists(kGarbageFile));
- EXPECT_FALSE(base::PathExists(kGarbageDir));
-}
-
-TEST(SandboxOriginDatabaseTest, DatabaseRecoveryForMissingDBFileTest) {
- const leveldb::FileType kLevelDBFileTypes[] = {
- leveldb::kLogFile,
- leveldb::kDBLockFile,
- leveldb::kTableFile,
- leveldb::kDescriptorFile,
- leveldb::kCurrentFile,
- leveldb::kTempFile,
- leveldb::kInfoLogFile,
- };
-
- for (size_t i = 0; i < arraysize(kLevelDBFileTypes); ++i) {
- base::ScopedTempDir dir;
- ASSERT_TRUE(dir.CreateUniqueTempDir());
- const base::FilePath kFSDir = dir.path().Append(kFileSystemDirName);
- const base::FilePath kDBDir = kFSDir.Append(kOriginDatabaseName);
- EXPECT_FALSE(base::PathExists(kFSDir));
- EXPECT_TRUE(base::CreateDirectory(kFSDir));
-
- const std::string kOrigin = "foo.example.com";
- base::FilePath path;
-
- scoped_ptr<SandboxOriginDatabase> database(
- new SandboxOriginDatabase(kFSDir));
- EXPECT_FALSE(database->HasOriginPath(kOrigin));
- EXPECT_TRUE(database->GetPathForOrigin(kOrigin, &path));
- EXPECT_FALSE(path.empty());
- EXPECT_TRUE(database->GetPathForOrigin(kOrigin, &path));
- EXPECT_TRUE(base::CreateDirectory(kFSDir.Append(path)));
- database.reset();
-
- DeleteDatabaseFile(kDBDir, kLevelDBFileTypes[i]);
-
- database.reset(new SandboxOriginDatabase(kFSDir));
- std::vector<SandboxOriginDatabase::OriginRecord> origins_in_db;
- EXPECT_TRUE(database->ListAllOrigins(&origins_in_db));
-
- const std::string kOrigin2("piyo.example.org");
- EXPECT_FALSE(database->HasOriginPath(kOrigin2));
- EXPECT_TRUE(database->GetPathForOrigin(kOrigin2, &path));
- EXPECT_FALSE(path.empty());
- EXPECT_TRUE(database->HasOriginPath(kOrigin2));
- }
-}
-
-} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/sandbox_prioritized_origin_database.cc b/chromium/webkit/browser/fileapi/sandbox_prioritized_origin_database.cc
index 06a44a07080..55ce362a9b1 100644
--- a/chromium/webkit/browser/fileapi/sandbox_prioritized_origin_database.cc
+++ b/chromium/webkit/browser/fileapi/sandbox_prioritized_origin_database.cc
@@ -5,11 +5,10 @@
#include "webkit/browser/fileapi/sandbox_prioritized_origin_database.h"
#include "base/file_util.h"
+#include "base/files/file.h"
#include "base/files/file_path.h"
-#include "base/files/scoped_platform_file_closer.h"
#include "base/logging.h"
#include "base/pickle.h"
-#include "base/platform_file.h"
#include "webkit/browser/fileapi/sandbox_isolated_origin_database.h"
#include "webkit/browser/fileapi/sandbox_origin_database.h"
@@ -24,23 +23,15 @@ const base::FilePath::CharType kPrimaryOriginFile[] =
bool WritePrimaryOriginFile(const base::FilePath& path,
const std::string& origin) {
- base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
- bool created;
- base::PlatformFile file = base::CreatePlatformFile(
- path,
- base::PLATFORM_FILE_OPEN_ALWAYS |
- base::PLATFORM_FILE_WRITE,
- &created, &error);
- base::ScopedPlatformFileCloser closer(&file);
- if (error != base::PLATFORM_FILE_OK ||
- file == base::kInvalidPlatformFileValue)
+ base::File file(path, base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_WRITE);
+ if (!file.IsValid())
return false;
- base::TruncatePlatformFile(file, 0);
+ if (!file.created())
+ file.SetLength(0);
Pickle pickle;
pickle.WriteString(origin);
- base::WritePlatformFile(file, 0, static_cast<const char*>(pickle.data()),
- pickle.size());
- base::FlushPlatformFile(file);
+ file.Write(0, static_cast<const char*>(pickle.data()), pickle.size());
+ file.Flush();
return true;
}
@@ -57,8 +48,10 @@ bool ReadPrimaryOriginFile(const base::FilePath& path,
} // namespace
SandboxPrioritizedOriginDatabase::SandboxPrioritizedOriginDatabase(
- const base::FilePath& file_system_directory)
+ const base::FilePath& file_system_directory,
+ leveldb::Env* env_override)
: file_system_directory_(file_system_directory),
+ env_override_(env_override),
primary_origin_file_(
file_system_directory_.Append(kPrimaryOriginFile)) {
}
@@ -213,7 +206,8 @@ void SandboxPrioritizedOriginDatabase::MaybeInitializeNonPrimaryDatabase(
if (origin_database_)
return;
- origin_database_.reset(new SandboxOriginDatabase(file_system_directory_));
+ origin_database_.reset(new SandboxOriginDatabase(file_system_directory_,
+ env_override_));
if (!create && !base::DirectoryExists(origin_database_->GetDatabasePath())) {
origin_database_.reset();
return;
diff --git a/chromium/webkit/browser/fileapi/sandbox_prioritized_origin_database.h b/chromium/webkit/browser/fileapi/sandbox_prioritized_origin_database.h
index 5509d0f75be..6f390dc2514 100644
--- a/chromium/webkit/browser/fileapi/sandbox_prioritized_origin_database.h
+++ b/chromium/webkit/browser/fileapi/sandbox_prioritized_origin_database.h
@@ -11,6 +11,10 @@
#include "base/memory/scoped_ptr.h"
#include "webkit/browser/fileapi/sandbox_origin_database_interface.h"
+namespace leveldb {
+class Env;
+}
+
namespace fileapi {
class ObfuscatedFileUtil;
@@ -20,8 +24,8 @@ class SandboxOriginDatabase;
class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE SandboxPrioritizedOriginDatabase
: public SandboxOriginDatabaseInterface {
public:
- explicit SandboxPrioritizedOriginDatabase(
- const base::FilePath& file_system_directory);
+ SandboxPrioritizedOriginDatabase(const base::FilePath& file_system_directory,
+ leveldb::Env* env_override);
virtual ~SandboxPrioritizedOriginDatabase();
// Sets |origin| as primary origin in this database (e.g. may
@@ -55,6 +59,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE SandboxPrioritizedOriginDatabase
SandboxOriginDatabase* GetSandboxOriginDatabase();
const base::FilePath file_system_directory_;
+ leveldb::Env* env_override_;
const base::FilePath primary_origin_file_;
scoped_ptr<SandboxOriginDatabase> origin_database_;
scoped_ptr<SandboxIsolatedOriginDatabase> primary_origin_database_;
diff --git a/chromium/webkit/browser/fileapi/sandbox_prioritized_origin_database_unittest.cc b/chromium/webkit/browser/fileapi/sandbox_prioritized_origin_database_unittest.cc
deleted file mode 100644
index fc0b9589d85..00000000000
--- a/chromium/webkit/browser/fileapi/sandbox_prioritized_origin_database_unittest.cc
+++ /dev/null
@@ -1,215 +0,0 @@
-// Copyright 2013 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 "base/basictypes.h"
-#include "base/file_util.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/platform_file.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/fileapi/sandbox_origin_database.h"
-#include "webkit/browser/fileapi/sandbox_prioritized_origin_database.h"
-
-namespace fileapi {
-
-TEST(SandboxPrioritizedOriginDatabaseTest, BasicTest) {
- base::ScopedTempDir dir;
- base::FilePath path;
- ASSERT_TRUE(dir.CreateUniqueTempDir());
-
- const std::string kOrigin1("origin1");
- const std::string kOrigin2("origin2");
-
- SandboxPrioritizedOriginDatabase database(dir.path());
-
- // Set the kOrigin1 as a parimary origin.
- EXPECT_TRUE(database.InitializePrimaryOrigin(kOrigin1));
-
- // Add two origins.
- EXPECT_TRUE(database.GetPathForOrigin(kOrigin1, &path));
- EXPECT_TRUE(database.GetPathForOrigin(kOrigin2, &path));
-
- // Verify them.
- EXPECT_TRUE(database.HasOriginPath(kOrigin1));
- EXPECT_TRUE(database.GetPathForOrigin(kOrigin1, &path));
- EXPECT_FALSE(path.empty());
- EXPECT_TRUE(database.HasOriginPath(kOrigin2));
- EXPECT_TRUE(database.GetPathForOrigin(kOrigin2, &path));
- EXPECT_FALSE(path.empty());
-
- std::vector<SandboxOriginDatabaseInterface::OriginRecord> origins;
- database.ListAllOrigins(&origins);
- ASSERT_EQ(2U, origins.size());
- EXPECT_TRUE(origins[0].origin == kOrigin1 ||
- origins[1].origin == kOrigin1);
- EXPECT_TRUE(origins[0].origin == kOrigin2 ||
- origins[1].origin == kOrigin2);
- EXPECT_NE(origins[0].path, origins[1].path);
-
- // Try remove path for kOrigin1.
- database.RemovePathForOrigin(kOrigin1);
-
- // Verify the removal.
- EXPECT_FALSE(database.HasOriginPath(kOrigin1));
- EXPECT_TRUE(database.HasOriginPath(kOrigin2));
- database.ListAllOrigins(&origins);
- ASSERT_EQ(1U, origins.size());
- EXPECT_EQ(kOrigin2, origins[0].origin);
-
- // Try remove path for kOrigin2.
- database.RemovePathForOrigin(kOrigin2);
-
- // Verify the removal.
- EXPECT_FALSE(database.HasOriginPath(kOrigin1));
- EXPECT_FALSE(database.HasOriginPath(kOrigin2));
- database.ListAllOrigins(&origins);
- EXPECT_TRUE(origins.empty());
-}
-
-TEST(SandboxPrioritizedOriginDatabaseTest, SetPrimaryLaterTest) {
- base::ScopedTempDir dir;
- base::FilePath path;
- ASSERT_TRUE(dir.CreateUniqueTempDir());
-
- const std::string kOrigin1("origin1");
- const std::string kOrigin2("origin2");
-
- SandboxPrioritizedOriginDatabase database(dir.path());
-
- EXPECT_TRUE(database.GetPrimaryOrigin().empty());
-
- EXPECT_TRUE(database.GetPathForOrigin(kOrigin1, &path));
- EXPECT_TRUE(database.GetPathForOrigin(kOrigin2, &path));
-
- // Set the kOrigin1 as a parimary origin.
- EXPECT_TRUE(database.InitializePrimaryOrigin(kOrigin1));
- EXPECT_EQ(kOrigin1, database.GetPrimaryOrigin());
-
- // Regardless of whether it is initialized as primary or not
- // they should just work.
- EXPECT_TRUE(database.HasOriginPath(kOrigin1));
- EXPECT_TRUE(database.GetPathForOrigin(kOrigin1, &path));
- EXPECT_FALSE(path.empty());
- EXPECT_TRUE(database.HasOriginPath(kOrigin2));
- EXPECT_TRUE(database.GetPathForOrigin(kOrigin2, &path));
- EXPECT_FALSE(path.empty());
-}
-
-TEST(SandboxPrioritizedOriginDatabaseTest, LostPrimaryOriginFileTest) {
- base::ScopedTempDir dir;
- base::FilePath path;
- ASSERT_TRUE(dir.CreateUniqueTempDir());
-
- const std::string kOrigin1("origin1");
- const std::string kData("foo");
-
- SandboxPrioritizedOriginDatabase database(dir.path());
-
- EXPECT_TRUE(database.GetPrimaryOrigin().empty());
-
- // Set the kOrigin1 as a parimary origin.
- EXPECT_TRUE(database.InitializePrimaryOrigin(kOrigin1));
- EXPECT_EQ(kOrigin1, database.GetPrimaryOrigin());
-
- // Make sure it works.
- EXPECT_TRUE(database.HasOriginPath(kOrigin1));
- EXPECT_TRUE(database.GetPathForOrigin(kOrigin1, &path));
-
- // Reset the database.
- database.DropDatabase();
-
- // kOrigin1 should still be marked as primary.
- EXPECT_TRUE(database.HasOriginPath(kOrigin1));
- EXPECT_TRUE(database.GetPathForOrigin(kOrigin1, &path));
-
- // Corrupt the primary origin file.
- file_util::WriteFile(
- database.primary_origin_file(), kData.data(), kData.size());
-
- // Reset the database.
- database.DropDatabase();
-
- // kOrigin1 is no longer marked as primary, and unfortunately we fail
- // to find the data for the origin.
- EXPECT_FALSE(database.HasOriginPath(kOrigin1));
-}
-
-TEST(SandboxPrioritizedOriginDatabaseTest, MigrationTest) {
- base::ScopedTempDir dir;
- ASSERT_TRUE(dir.CreateUniqueTempDir());
-
- const std::string kOrigin1("origin1");
- const std::string kOrigin2("origin2");
- const std::string kFakeDirectoryData1("0123456789");
- const std::string kFakeDirectoryData2("abcde");
- base::FilePath old_dir_db_path1, old_dir_db_path2;
- base::FilePath path1, path2;
-
- // Initialize the directory with two origins using the regular
- // SandboxOriginDatabase.
- {
- SandboxOriginDatabase database_old(dir.path());
- base::FilePath old_db_path = database_old.GetDatabasePath();
- EXPECT_FALSE(base::PathExists(old_db_path));
-
- // Initialize paths for kOrigin1 and kOrigin2.
- EXPECT_TRUE(database_old.GetPathForOrigin(kOrigin1, &path1));
- EXPECT_FALSE(path1.empty());
- EXPECT_TRUE(database_old.GetPathForOrigin(kOrigin2, &path2));
- EXPECT_FALSE(path2.empty());
-
- EXPECT_TRUE(base::DirectoryExists(old_db_path));
-
- // Populate the origin directory with some fake data.
- old_dir_db_path1 = dir.path().Append(path1);
- ASSERT_TRUE(base::CreateDirectory(old_dir_db_path1));
- EXPECT_EQ(static_cast<int>(kFakeDirectoryData1.size()),
- file_util::WriteFile(old_dir_db_path1.AppendASCII("dummy"),
- kFakeDirectoryData1.data(),
- kFakeDirectoryData1.size()));
- old_dir_db_path2 = dir.path().Append(path2);
- ASSERT_TRUE(base::CreateDirectory(old_dir_db_path2));
- EXPECT_EQ(static_cast<int>(kFakeDirectoryData2.size()),
- file_util::WriteFile(old_dir_db_path2.AppendASCII("dummy"),
- kFakeDirectoryData2.data(),
- kFakeDirectoryData2.size()));
- }
-
- // Re-open the directory using sandboxPrioritizedOriginDatabase.
- SandboxPrioritizedOriginDatabase database(dir.path());
-
- // Set the kOrigin1 as a parimary origin.
- // (Trying to initialize another origin should fail).
- EXPECT_TRUE(database.InitializePrimaryOrigin(kOrigin1));
- EXPECT_FALSE(database.InitializePrimaryOrigin(kOrigin2));
-
- EXPECT_EQ(kOrigin1, database.GetPrimaryOrigin());
-
- // Regardless of whether the origin is registered as primary or not
- // it should just work.
- EXPECT_TRUE(database.HasOriginPath(kOrigin1));
- EXPECT_TRUE(database.GetPathForOrigin(kOrigin1, &path1));
- EXPECT_TRUE(database.HasOriginPath(kOrigin2));
- EXPECT_TRUE(database.GetPathForOrigin(kOrigin2, &path2));
-
- // The directory content must be kept (or migrated if necessary) as well.
- std::string origin_db_data;
- base::FilePath dir_db_path = dir.path().Append(path1);
- EXPECT_TRUE(base::PathExists(dir_db_path.AppendASCII("dummy")));
- EXPECT_TRUE(base::ReadFileToString(
- dir_db_path.AppendASCII("dummy"), &origin_db_data));
- EXPECT_EQ(kFakeDirectoryData1, origin_db_data);
-
- origin_db_data.clear();
- dir_db_path = dir.path().Append(path2);
- EXPECT_TRUE(base::PathExists(dir_db_path.AppendASCII("dummy")));
- EXPECT_TRUE(base::ReadFileToString(
- dir_db_path.AppendASCII("dummy"), &origin_db_data));
- EXPECT_EQ(kFakeDirectoryData2, origin_db_data);
-
- // After the migration the kOrigin1 directory database path must be gone.
- EXPECT_FALSE(base::PathExists(old_dir_db_path1));
- EXPECT_TRUE(base::PathExists(old_dir_db_path2));
-}
-
-} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/sandbox_quota_observer.cc b/chromium/webkit/browser/fileapi/sandbox_quota_observer.cc
index fe5ee3796fb..42b6d08604c 100644
--- a/chromium/webkit/browser/fileapi/sandbox_quota_observer.cc
+++ b/chromium/webkit/browser/fileapi/sandbox_quota_observer.cc
@@ -10,7 +10,7 @@
#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h"
#include "webkit/browser/fileapi/timed_task_helper.h"
#include "webkit/browser/quota/quota_client.h"
-#include "webkit/browser/quota/quota_manager.h"
+#include "webkit/browser/quota/quota_manager_proxy.h"
#include "webkit/common/fileapi/file_system_util.h"
namespace fileapi {
@@ -105,11 +105,11 @@ void SandboxQuotaObserver::SetUsageCacheEnabled(
base::FilePath SandboxQuotaObserver::GetUsageCachePath(
const FileSystemURL& url) {
DCHECK(sandbox_file_util_);
- base::PlatformFileError error = base::PLATFORM_FILE_OK;
+ base::File::Error error = base::File::FILE_OK;
base::FilePath path =
SandboxFileSystemBackendDelegate::GetUsageCachePathForOriginAndType(
sandbox_file_util_, url.origin(), url.type(), &error);
- if (error != base::PLATFORM_FILE_OK) {
+ if (error != base::File::FILE_OK) {
LOG(WARNING) << "Could not get usage cache path for: "
<< url.DebugString();
return base::FilePath();
diff --git a/chromium/webkit/browser/fileapi/test_file_set.cc b/chromium/webkit/browser/fileapi/test_file_set.cc
deleted file mode 100644
index 109a0558491..00000000000
--- a/chromium/webkit/browser/fileapi/test_file_set.cc
+++ /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.
-
-#include "webkit/browser/fileapi/test_file_set.h"
-
-#include <string>
-
-#include "base/file_util.h"
-#include "base/logging.h"
-#include "base/platform_file.h"
-#include "base/rand_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace fileapi {
-
-namespace test {
-
-const TestCaseRecord kRegularTestCases[] = {
- {true, FILE_PATH_LITERAL("dir a"), 0},
- {true, FILE_PATH_LITERAL("dir a/dir A"), 0},
- {true, FILE_PATH_LITERAL("dir a/dir d"), 0},
- {true, FILE_PATH_LITERAL("dir a/dir d/dir e"), 0},
- {true, FILE_PATH_LITERAL("dir a/dir d/dir e/dir f"), 0},
- {true, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g"), 0},
- {true, FILE_PATH_LITERAL("dir a/dir d/dir e/dir h"), 0},
- {true, FILE_PATH_LITERAL("dir b"), 0},
- {true, FILE_PATH_LITERAL("dir b/dir a"), 0},
- {true, FILE_PATH_LITERAL("dir c"), 0},
- {false, FILE_PATH_LITERAL("file 0"), 38},
- {false, FILE_PATH_LITERAL("file 2"), 60},
- {false, FILE_PATH_LITERAL("file 3"), 0},
- {false, FILE_PATH_LITERAL("dir a/file 0"), 39},
- {false, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g/file 0"), 40},
- {false, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g/file 1"), 41},
- {false, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g/file 2"), 42},
- {false, FILE_PATH_LITERAL("dir a/dir d/dir e/dir g/file 3"), 50},
-};
-
-const size_t kRegularTestCaseSize = arraysize(kRegularTestCases);
-
-void SetUpOneTestCase(const base::FilePath& root_path,
- const TestCaseRecord& test_case) {
- base::FilePath path = root_path.Append(test_case.path);
- if (test_case.is_directory) {
- ASSERT_TRUE(base::CreateDirectory(path));
- return;
- }
- base::PlatformFileError error_code;
- bool created = false;
- int file_flags = base::PLATFORM_FILE_CREATE_ALWAYS |
- base::PLATFORM_FILE_WRITE;
- base::PlatformFile file_handle =
- base::CreatePlatformFile(path, file_flags, &created, &error_code);
- EXPECT_TRUE(created);
- ASSERT_EQ(base::PLATFORM_FILE_OK, error_code);
- ASSERT_NE(base::kInvalidPlatformFileValue, file_handle);
- EXPECT_TRUE(base::ClosePlatformFile(file_handle));
- if (test_case.data_file_size > 0U) {
- std::string content = base::RandBytesAsString(test_case.data_file_size);
- ASSERT_EQ(static_cast<int>(content.size()),
- file_util::WriteFile(path, content.data(), content.size()));
- }
-}
-
-
-void SetUpRegularTestCases(const base::FilePath& root_path) {
- for (size_t i = 0; i < arraysize(kRegularTestCases); ++i) {
- SCOPED_TRACE(testing::Message() << "Creating kRegularTestCases " << i);
- SetUpOneTestCase(root_path, kRegularTestCases[i]);
- }
-}
-
-} // namespace test
-
-} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/test_file_set.h b/chromium/webkit/browser/fileapi/test_file_set.h
deleted file mode 100644
index eb44521357a..00000000000
--- a/chromium/webkit/browser/fileapi/test_file_set.h
+++ /dev/null
@@ -1,42 +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 WEBKIT_BROWSER_FILEAPI_TEST_FILE_SET_H_
-#define WEBKIT_BROWSER_FILEAPI_TEST_FILE_SET_H_
-
-#include <set>
-
-#include "base/files/file_path.h"
-
-// Common test data structures and test cases.
-
-namespace fileapi {
-
-class FileSystemFileUtil;
-
-namespace test {
-
-struct TestCaseRecord {
- bool is_directory;
- const base::FilePath::CharType path[64];
- int64 data_file_size;
-};
-
-extern const TestCaseRecord kRegularTestCases[];
-extern const size_t kRegularTestCaseSize;
-
-size_t GetRegularTestCaseSize();
-
-// Creates one file or directory specified by |record|.
-void SetUpOneTestCase(const base::FilePath& root_path,
- const TestCaseRecord& record);
-
-// Creates the files and directories specified in kRegularTestCases.
-void SetUpRegularTestCases(const base::FilePath& root_path);
-
-} // namespace test
-
-} // namespace fileapi
-
-#endif // WEBKIT_BROWSER_FILEAPI_TEST_FILE_SET_H_
diff --git a/chromium/webkit/browser/fileapi/timed_task_helper_unittest.cc b/chromium/webkit/browser/fileapi/timed_task_helper_unittest.cc
deleted file mode 100644
index fa3e84d523d..00000000000
--- a/chromium/webkit/browser/fileapi/timed_task_helper_unittest.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright 2013 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 "base/basictypes.h"
-#include "base/bind.h"
-#include "base/location.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop_proxy.h"
-#include "base/run_loop.h"
-#include "base/time/time.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/fileapi/timed_task_helper.h"
-
-namespace fileapi {
-
-namespace {
-
-class Embedder {
- public:
- Embedder()
- : timer_(base::MessageLoopProxy::current().get()), timer_fired_(false) {}
-
- void OnTimerFired() {
- timer_fired_ = true;
- }
-
- TimedTaskHelper* timer() { return &timer_; }
- bool timer_fired() const { return timer_fired_; }
-
- private:
- TimedTaskHelper timer_;
- bool timer_fired_;
-};
-
-} // namespace
-
-TEST(TimedTaskHelper, FireTimerWhenAlive) {
- base::MessageLoop message_loop;
- Embedder embedder;
-
- ASSERT_FALSE(embedder.timer_fired());
- ASSERT_FALSE(embedder.timer()->IsRunning());
-
- embedder.timer()->Start(
- FROM_HERE,
- base::TimeDelta::FromSeconds(0),
- base::Bind(&Embedder::OnTimerFired, base::Unretained(&embedder)));
-
- ASSERT_TRUE(embedder.timer()->IsRunning());
- embedder.timer()->Reset();
- ASSERT_TRUE(embedder.timer()->IsRunning());
-
- base::RunLoop().RunUntilIdle();
-
- ASSERT_TRUE(embedder.timer_fired());
-}
-
-TEST(TimedTaskHelper, FireTimerWhenAlreadyDeleted) {
- base::MessageLoop message_loop;
-
- // Run message loop after embedder is already deleted to make sure callback
- // doesn't cause a crash for use after free.
- {
- Embedder embedder;
-
- ASSERT_FALSE(embedder.timer_fired());
- ASSERT_FALSE(embedder.timer()->IsRunning());
-
- embedder.timer()->Start(
- FROM_HERE,
- base::TimeDelta::FromSeconds(0),
- base::Bind(&Embedder::OnTimerFired, base::Unretained(&embedder)));
-
- ASSERT_TRUE(embedder.timer()->IsRunning());
- }
-
- // At this point the callback is still in the message queue but
- // embedder is gone.
- base::RunLoop().RunUntilIdle();
-}
-
-} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/transient_file_util.cc b/chromium/webkit/browser/fileapi/transient_file_util.cc
index 74c2dbea8c3..4cac5caad84 100644
--- a/chromium/webkit/browser/fileapi/transient_file_util.cc
+++ b/chromium/webkit/browser/fileapi/transient_file_util.cc
@@ -28,14 +28,14 @@ void RevokeFileSystem(const std::string& filesystem_id,
ScopedFile TransientFileUtil::CreateSnapshotFile(
FileSystemOperationContext* context,
const FileSystemURL& url,
- base::PlatformFileError* error,
- base::PlatformFileInfo* file_info,
+ base::File::Error* error,
+ base::File::Info* file_info,
base::FilePath* platform_path) {
DCHECK(file_info);
*error = GetFileInfo(context, url, file_info, platform_path);
- if (*error == base::PLATFORM_FILE_OK && file_info->is_directory)
- *error = base::PLATFORM_FILE_ERROR_NOT_A_FILE;
- if (*error != base::PLATFORM_FILE_OK)
+ if (*error == base::File::FILE_OK && file_info->is_directory)
+ *error = base::File::FILE_ERROR_NOT_A_FILE;
+ if (*error != base::File::FILE_OK)
return ScopedFile();
// Sets-up a transient filesystem.
diff --git a/chromium/webkit/browser/fileapi/transient_file_util.h b/chromium/webkit/browser/fileapi/transient_file_util.h
index 1e67c852027..6ffb48ca2df 100644
--- a/chromium/webkit/browser/fileapi/transient_file_util.h
+++ b/chromium/webkit/browser/fileapi/transient_file_util.h
@@ -23,8 +23,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE TransientFileUtil
virtual webkit_blob::ScopedFile CreateSnapshotFile(
FileSystemOperationContext* context,
const FileSystemURL& url,
- base::PlatformFileError* error,
- base::PlatformFileInfo* file_info,
+ base::File::Error* error,
+ base::File::Info* file_info,
base::FilePath* platform_path) OVERRIDE;
private:
diff --git a/chromium/webkit/browser/fileapi/upload_file_system_file_element_reader.cc b/chromium/webkit/browser/fileapi/upload_file_system_file_element_reader.cc
deleted file mode 100644
index 46a57f0957a..00000000000
--- a/chromium/webkit/browser/fileapi/upload_file_system_file_element_reader.cc
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright (c) 2013 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 "webkit/browser/fileapi/upload_file_system_file_element_reader.h"
-
-#include <algorithm>
-
-#include "base/bind.h"
-#include "net/base/net_errors.h"
-#include "webkit/browser/blob/file_stream_reader.h"
-#include "webkit/browser/fileapi/file_system_context.h"
-#include "webkit/browser/fileapi/file_system_url.h"
-
-namespace fileapi {
-
-UploadFileSystemFileElementReader::UploadFileSystemFileElementReader(
- FileSystemContext* file_system_context,
- const GURL& url,
- uint64 range_offset,
- uint64 range_length,
- const base::Time& expected_modification_time)
- : file_system_context_(file_system_context),
- url_(url),
- range_offset_(range_offset),
- range_length_(range_length),
- expected_modification_time_(expected_modification_time),
- stream_length_(0),
- position_(0),
- weak_ptr_factory_(this) {
-}
-
-UploadFileSystemFileElementReader::~UploadFileSystemFileElementReader() {
-}
-
-int UploadFileSystemFileElementReader::Init(
- const net::CompletionCallback& callback) {
- // Reset states.
- weak_ptr_factory_.InvalidateWeakPtrs();
- stream_length_ = 0;
- position_ = 0;
-
- // Initialize the stream reader and the length.
- stream_reader_ =
- file_system_context_->CreateFileStreamReader(
- file_system_context_->CrackURL(url_),
- range_offset_,
- expected_modification_time_);
- DCHECK(stream_reader_);
-
- const int64 result = stream_reader_->GetLength(
- base::Bind(&UploadFileSystemFileElementReader::OnGetLength,
- weak_ptr_factory_.GetWeakPtr(),
- callback));
- if (result >= 0) {
- stream_length_ = result;
- return net::OK;
- }
-
- // The error code can be casted to int.
- return static_cast<int>(result);
-}
-
-uint64 UploadFileSystemFileElementReader::GetContentLength() const {
- return std::min(stream_length_, range_length_);
-}
-
-uint64 UploadFileSystemFileElementReader::BytesRemaining() const {
- return GetContentLength() - position_;
-}
-
-int UploadFileSystemFileElementReader::Read(
- net::IOBuffer* buf,
- int buf_length,
- const net::CompletionCallback& callback) {
- DCHECK_LT(0, buf_length);
- DCHECK(stream_reader_);
-
- const uint64 num_bytes_to_read =
- std::min(BytesRemaining(), static_cast<uint64>(buf_length));
-
- if (num_bytes_to_read == 0)
- return 0;
-
- const int result = stream_reader_->Read(
- buf, num_bytes_to_read,
- base::Bind(&UploadFileSystemFileElementReader::OnRead,
- weak_ptr_factory_.GetWeakPtr(),
- callback));
- if (result >= 0)
- OnRead(net::CompletionCallback(), result);
- return result;
-}
-
-void UploadFileSystemFileElementReader::OnGetLength(
- const net::CompletionCallback& callback,
- int64 result) {
- if (result >= 0) {
- stream_length_ = result;
- callback.Run(net::OK);
- return;
- }
- callback.Run(result);
-}
-
-void UploadFileSystemFileElementReader::OnRead(
- const net::CompletionCallback& callback,
- int result) {
- if (result > 0) {
- position_ += result;
- DCHECK_LE(position_, GetContentLength());
- }
- if (!callback.is_null())
- callback.Run(result);
-}
-
-} // namespace fileapi
diff --git a/chromium/webkit/browser/fileapi/upload_file_system_file_element_reader.h b/chromium/webkit/browser/fileapi/upload_file_system_file_element_reader.h
deleted file mode 100644
index dba30868b93..00000000000
--- a/chromium/webkit/browser/fileapi/upload_file_system_file_element_reader.h
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (c) 2013 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 WEBKIT_BROWSER_FILEAPI_UPLOAD_FILE_SYSTEM_FILE_ELEMENT_READER_H_
-#define WEBKIT_BROWSER_FILEAPI_UPLOAD_FILE_SYSTEM_FILE_ELEMENT_READER_H_
-
-#include "base/memory/weak_ptr.h"
-#include "base/time/time.h"
-#include "net/base/upload_element_reader.h"
-#include "url/gurl.h"
-#include "webkit/browser/webkit_storage_browser_export.h"
-
-namespace webkit_blob {
-class FileStreamReader;
-}
-
-namespace fileapi {
-
-class FileSystemContext;
-
-// An UploadElementReader implementation for filesystem file.
-class WEBKIT_STORAGE_BROWSER_EXPORT UploadFileSystemFileElementReader
- : public net::UploadElementReader {
- public:
- UploadFileSystemFileElementReader(
- FileSystemContext* file_system_context,
- const GURL& url,
- uint64 range_offset,
- uint64 range_length,
- const base::Time& expected_modification_time);
- virtual ~UploadFileSystemFileElementReader();
-
- // UploadElementReader overrides:
- virtual int Init(const net::CompletionCallback& callback) OVERRIDE;
- virtual uint64 GetContentLength() const OVERRIDE;
- virtual uint64 BytesRemaining() const OVERRIDE;
- virtual int Read(net::IOBuffer* buf,
- int buf_length,
- const net::CompletionCallback& callback) OVERRIDE;
-
- private:
- void OnGetLength(const net::CompletionCallback& callback, int64 result);
- void OnRead(const net::CompletionCallback& callback, int result);
-
- scoped_refptr<FileSystemContext> file_system_context_;
- const GURL url_;
- const uint64 range_offset_;
- const uint64 range_length_;
- const base::Time expected_modification_time_;
-
- scoped_ptr<webkit_blob::FileStreamReader> stream_reader_;
-
- uint64 stream_length_;
- uint64 position_;
-
- base::WeakPtrFactory<UploadFileSystemFileElementReader> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(UploadFileSystemFileElementReader);
-};
-
-} // namespace fileapi
-
-#endif // WEBKIT_BROWSER_FILEAPI_UPLOAD_FILE_SYSTEM_FILE_ELEMENT_READER_H_
diff --git a/chromium/webkit/browser/quota/mock_quota_manager.cc b/chromium/webkit/browser/quota/mock_quota_manager.cc
deleted file mode 100644
index 69e3b0edb95..00000000000
--- a/chromium/webkit/browser/quota/mock_quota_manager.cc
+++ /dev/null
@@ -1,199 +0,0 @@
-// Copyright 2013 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 "webkit/browser/quota/mock_quota_manager.h"
-
-#include <set>
-#include <string>
-#include <vector>
-
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "base/single_thread_task_runner.h"
-#include "url/gurl.h"
-
-namespace quota {
-
-MockQuotaManager::OriginInfo::OriginInfo(
- const GURL& origin,
- StorageType type,
- int quota_client_mask,
- base::Time modified)
- : origin(origin),
- type(type),
- quota_client_mask(quota_client_mask),
- modified(modified) {
-}
-
-MockQuotaManager::OriginInfo::~OriginInfo() {}
-
-MockQuotaManager::StorageInfo::StorageInfo() : usage(0), quota(kint64max) {}
-MockQuotaManager::StorageInfo::~StorageInfo() {}
-
-// MockQuotaManager ----------------------------------------------------------
-
-MockQuotaManager::MockQuotaManager(
- bool is_incognito,
- const base::FilePath& profile_path,
- base::SingleThreadTaskRunner* io_thread,
- base::SequencedTaskRunner* db_thread,
- SpecialStoragePolicy* special_storage_policy)
- : QuotaManager(is_incognito, profile_path, io_thread, db_thread,
- special_storage_policy),
- weak_factory_(this) {
-}
-
-void MockQuotaManager::GetUsageAndQuota(
- const GURL& origin,
- quota::StorageType type,
- const GetUsageAndQuotaCallback& callback) {
- StorageInfo& info = usage_and_quota_map_[std::make_pair(origin, type)];
- callback.Run(quota::kQuotaStatusOk, info.usage, info.quota);
-}
-
-void MockQuotaManager::SetQuota(const GURL& origin, StorageType type,
- int64 quota) {
- usage_and_quota_map_[std::make_pair(origin, type)].quota = quota;
-}
-
-bool MockQuotaManager::AddOrigin(
- const GURL& origin,
- StorageType type,
- int quota_client_mask,
- base::Time modified) {
- origins_.push_back(OriginInfo(origin, type, quota_client_mask, modified));
- return true;
-}
-
-bool MockQuotaManager::OriginHasData(
- const GURL& origin,
- StorageType type,
- QuotaClient::ID quota_client) const {
- for (std::vector<OriginInfo>::const_iterator current = origins_.begin();
- current != origins_.end();
- ++current) {
- if (current->origin == origin &&
- current->type == type &&
- current->quota_client_mask & quota_client)
- return true;
- }
- return false;
-}
-
-void MockQuotaManager::GetOriginsModifiedSince(
- StorageType type,
- base::Time modified_since,
- const GetOriginsCallback& callback) {
- std::set<GURL>* origins_to_return = new std::set<GURL>();
- for (std::vector<OriginInfo>::const_iterator current = origins_.begin();
- current != origins_.end();
- ++current) {
- if (current->type == type && current->modified >= modified_since)
- origins_to_return->insert(current->origin);
- }
-
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&MockQuotaManager::DidGetModifiedSince,
- weak_factory_.GetWeakPtr(),
- callback,
- base::Owned(origins_to_return),
- type));
-}
-
-void MockQuotaManager::DeleteOriginData(
- const GURL& origin,
- StorageType type,
- int quota_client_mask,
- const StatusCallback& callback) {
- for (std::vector<OriginInfo>::iterator current = origins_.begin();
- current != origins_.end();
- ++current) {
- if (current->origin == origin && current->type == type) {
- // Modify the mask: if it's 0 after "deletion", remove the origin.
- current->quota_client_mask &= ~quota_client_mask;
- if (current->quota_client_mask == 0)
- origins_.erase(current);
- break;
- }
- }
-
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&MockQuotaManager::DidDeleteOriginData,
- weak_factory_.GetWeakPtr(),
- callback,
- kQuotaStatusOk));
-}
-
-MockQuotaManager::~MockQuotaManager() {}
-
-void MockQuotaManager::UpdateUsage(
- const GURL& origin, StorageType type, int64 delta) {
- usage_and_quota_map_[std::make_pair(origin, type)].usage += delta;
-}
-
-void MockQuotaManager::DidGetModifiedSince(
- const GetOriginsCallback& callback,
- std::set<GURL>* origins,
- StorageType storage_type) {
- callback.Run(*origins, storage_type);
-}
-
-void MockQuotaManager::DidDeleteOriginData(
- const StatusCallback& callback,
- QuotaStatusCode status) {
- callback.Run(status);
-}
-
-// MockQuotaManagerProxy -----------------------------------------------------
-
-MockQuotaManagerProxy::MockQuotaManagerProxy(
- MockQuotaManager* quota_manager,
- base::SingleThreadTaskRunner* task_runner)
- : QuotaManagerProxy(quota_manager, task_runner),
- storage_accessed_count_(0),
- storage_modified_count_(0),
- last_notified_type_(kStorageTypeUnknown),
- last_notified_delta_(0),
- registered_client_(NULL) {}
-
-void MockQuotaManagerProxy::RegisterClient(QuotaClient* client) {
- DCHECK(!registered_client_);
- registered_client_ = client;
-}
-
-void MockQuotaManagerProxy::SimulateQuotaManagerDestroyed() {
- if (registered_client_) {
- // We cannot call this in the destructor as the client (indirectly)
- // holds a refptr of the proxy.
- registered_client_->OnQuotaManagerDestroyed();
- registered_client_ = NULL;
- }
-}
-
-void MockQuotaManagerProxy::NotifyStorageAccessed(
- QuotaClient::ID client_id, const GURL& origin, StorageType type) {
- ++storage_accessed_count_;
- last_notified_origin_ = origin;
- last_notified_type_ = type;
-}
-
-void MockQuotaManagerProxy::NotifyStorageModified(
- QuotaClient::ID client_id, const GURL& origin,
- StorageType type, int64 delta) {
- ++storage_modified_count_;
- last_notified_origin_ = origin;
- last_notified_type_ = type;
- last_notified_delta_ = delta;
- if (mock_manager())
- mock_manager()->UpdateUsage(origin, type, delta);
-}
-
-MockQuotaManagerProxy::~MockQuotaManagerProxy() {
- DCHECK(!registered_client_);
-}
-
-} // namespace quota
diff --git a/chromium/webkit/browser/quota/mock_quota_manager.h b/chromium/webkit/browser/quota/mock_quota_manager.h
deleted file mode 100644
index 0c93c11029b..00000000000
--- a/chromium/webkit/browser/quota/mock_quota_manager.h
+++ /dev/null
@@ -1,206 +0,0 @@
-// Copyright 2013 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 WEBKIT_BROWSER_QUOTA_MOCK_QUOTA_MANAGER_H_
-#define WEBKIT_BROWSER_QUOTA_MOCK_QUOTA_MANAGER_H_
-
-#include <string>
-#include <vector>
-
-#include "base/memory/scoped_ptr.h"
-#include "url/gurl.h"
-#include "webkit/browser/quota/quota_client.h"
-#include "webkit/browser/quota/quota_manager.h"
-#include "webkit/browser/quota/quota_task.h"
-#include "webkit/common/quota/quota_types.h"
-
-namespace quota {
-
-// Mocks the pieces of QuotaManager's interface.
-//
-// For usage/quota tracking test:
-// Usage and quota information can be updated by following private helper
-// methods: SetQuota() and UpdateUsage().
-//
-// For time-based deletion test:
-// Origins can be added to the mock by calling AddOrigin, and that list of
-// origins is then searched through in GetOriginsModifiedSince.
-// Neither GetOriginsModifiedSince nor DeleteOriginData touches the actual
-// origin data stored in the profile.
-class MockQuotaManager : public QuotaManager {
- public:
- MockQuotaManager(bool is_incognito,
- const base::FilePath& profile_path,
- base::SingleThreadTaskRunner* io_thread,
- base::SequencedTaskRunner* db_thread,
- SpecialStoragePolicy* special_storage_policy);
-
- // Overrides QuotaManager's implementation. The internal usage data is
- // updated when MockQuotaManagerProxy::NotifyStorageModified() is
- // called. The internal quota value can be updated by calling
- // a helper method MockQuotaManagerProxy::SetQuota().
- virtual void GetUsageAndQuota(
- const GURL& origin,
- quota::StorageType type,
- const GetUsageAndQuotaCallback& callback) OVERRIDE;
-
- // Overrides QuotaManager's implementation with a canned implementation that
- // allows clients to set up the origin database that should be queried. This
- // method will only search through the origins added explicitly via AddOrigin.
- virtual void GetOriginsModifiedSince(
- StorageType type,
- base::Time modified_since,
- const GetOriginsCallback& callback) OVERRIDE;
-
- // Removes an origin from the canned list of origins, but doesn't touch
- // anything on disk. The caller must provide |quota_client_mask| which
- // specifies the types of QuotaClients which should be removed from this
- // origin as a bitmask built from QuotaClient::IDs. Setting the mask to
- // QuotaClient::kAllClientsMask will remove all clients from the origin,
- // regardless of type.
- virtual void DeleteOriginData(const GURL& origin,
- StorageType type,
- int quota_client_mask,
- const StatusCallback& callback) OVERRIDE;
-
- // Helper method for updating internal quota info.
- void SetQuota(const GURL& origin, StorageType type, int64 quota);
-
- // Helper methods for timed-deletion testing:
- // Adds an origin to the canned list that will be searched through via
- // GetOriginsModifiedSince. The caller must provide |quota_client_mask|
- // which specifies the types of QuotaClients this canned origin contains
- // as a bitmask built from QuotaClient::IDs.
- bool AddOrigin(const GURL& origin,
- StorageType type,
- int quota_client_mask,
- base::Time modified);
-
- // Helper methods for timed-deletion testing:
- // Checks an origin and type against the origins that have been added via
- // AddOrigin and removed via DeleteOriginData. If the origin exists in the
- // canned list with the proper StorageType and client, returns true.
- bool OriginHasData(const GURL& origin,
- StorageType type,
- QuotaClient::ID quota_client) const;
-
- protected:
- virtual ~MockQuotaManager();
-
- private:
- friend class MockQuotaManagerProxy;
-
- // Contains the essential bits of information about an origin that the
- // MockQuotaManager needs to understand for time-based deletion:
- // the origin itself, the StorageType and its modification time.
- struct OriginInfo {
- OriginInfo(const GURL& origin,
- StorageType type,
- int quota_client_mask,
- base::Time modified);
- ~OriginInfo();
-
- GURL origin;
- StorageType type;
- int quota_client_mask;
- base::Time modified;
- };
-
- // Contains the essential information for each origin for usage/quota testing.
- // (Ideally this should probably merged into the above struct, but for
- // regular usage/quota testing we hardly need modified time but only
- // want to keep usage and quota information, so this struct exists.
- struct StorageInfo {
- StorageInfo();
- ~StorageInfo();
- int64 usage;
- int64 quota;
- };
-
- typedef std::pair<GURL, StorageType> OriginAndType;
- typedef std::map<OriginAndType, StorageInfo> UsageAndQuotaMap;
-
- // This must be called via MockQuotaManagerProxy.
- void UpdateUsage(const GURL& origin, StorageType type, int64 delta);
- void DidGetModifiedSince(const GetOriginsCallback& callback,
- std::set<GURL>* origins,
- StorageType storage_type);
- void DidDeleteOriginData(const StatusCallback& callback,
- QuotaStatusCode status);
-
- // The list of stored origins that have been added via AddOrigin.
- std::vector<OriginInfo> origins_;
- UsageAndQuotaMap usage_and_quota_map_;
- base::WeakPtrFactory<MockQuotaManager> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(MockQuotaManager);
-};
-
-// MockQuotaManagerProxy.
-class MockQuotaManagerProxy : public QuotaManagerProxy {
- public:
- // It is ok to give NULL to |quota_manager|.
- MockQuotaManagerProxy(MockQuotaManager* quota_manager,
- base::SingleThreadTaskRunner* task_runner);
-
- virtual void RegisterClient(QuotaClient* client) OVERRIDE;
-
- void SimulateQuotaManagerDestroyed();
-
- // We don't mock them.
- virtual void NotifyOriginInUse(const GURL& origin) OVERRIDE {}
- virtual void NotifyOriginNoLongerInUse(const GURL& origin) OVERRIDE {}
- virtual void SetUsageCacheEnabled(QuotaClient::ID client_id,
- const GURL& origin,
- StorageType type,
- bool enabled) OVERRIDE {}
- virtual void GetUsageAndQuota(
- base::SequencedTaskRunner* original_task_runner,
- const GURL& origin,
- StorageType type,
- const QuotaManager::GetUsageAndQuotaCallback& callback) OVERRIDE {}
-
- // Validates the |client_id| and updates the internal access count
- // which can be accessed via notify_storage_accessed_count().
- // The also records the |origin| and |type| in last_notified_origin_ and
- // last_notified_type_.
- virtual void NotifyStorageAccessed(QuotaClient::ID client_id,
- const GURL& origin,
- StorageType type) OVERRIDE;
-
- // Records the |origin|, |type| and |delta| as last_notified_origin_,
- // last_notified_type_ and last_notified_delta_ respecitvely.
- // If non-null MockQuotaManager is given to the constructor this also
- // updates the manager's internal usage information.
- virtual void NotifyStorageModified(QuotaClient::ID client_id,
- const GURL& origin,
- StorageType type,
- int64 delta) OVERRIDE;
-
- int notify_storage_accessed_count() const { return storage_accessed_count_; }
- int notify_storage_modified_count() const { return storage_modified_count_; }
- GURL last_notified_origin() const { return last_notified_origin_; }
- StorageType last_notified_type() const { return last_notified_type_; }
- int64 last_notified_delta() const { return last_notified_delta_; }
-
- protected:
- virtual ~MockQuotaManagerProxy();
-
- private:
- MockQuotaManager* mock_manager() const {
- return static_cast<MockQuotaManager*>(quota_manager());
- }
-
- int storage_accessed_count_;
- int storage_modified_count_;
- GURL last_notified_origin_;
- StorageType last_notified_type_;
- int64 last_notified_delta_;
-
- QuotaClient* registered_client_;
-};
-
-} // namespace quota
-
-#endif // WEBKIT_BROWSER_QUOTA_MOCK_QUOTA_MANAGER_H_
diff --git a/chromium/webkit/browser/quota/mock_quota_manager_unittest.cc b/chromium/webkit/browser/quota/mock_quota_manager_unittest.cc
deleted file mode 100644
index bb4db22ea05..00000000000
--- a/chromium/webkit/browser/quota/mock_quota_manager_unittest.cc
+++ /dev/null
@@ -1,222 +0,0 @@
-// Copyright 2013 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 <set>
-
-#include "base/bind.h"
-#include "base/file_util.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop_proxy.h"
-#include "base/run_loop.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/quota/mock_quota_manager.h"
-#include "webkit/browser/quota/mock_special_storage_policy.h"
-#include "webkit/browser/quota/mock_storage_client.h"
-
-namespace quota {
-
-const char kTestOrigin1[] = "http://host1:1/";
-const char kTestOrigin2[] = "http://host2:1/";
-const char kTestOrigin3[] = "http://host3:1/";
-
-const GURL kOrigin1(kTestOrigin1);
-const GURL kOrigin2(kTestOrigin2);
-const GURL kOrigin3(kTestOrigin3);
-
-const StorageType kTemporary = kStorageTypeTemporary;
-const StorageType kPersistent = kStorageTypePersistent;
-
-const QuotaClient::ID kClientFile = QuotaClient::kFileSystem;
-const QuotaClient::ID kClientDB = QuotaClient::kIndexedDatabase;
-
-class MockQuotaManagerTest : public testing::Test {
- public:
- MockQuotaManagerTest()
- : deletion_callback_count_(0),
- weak_factory_(this) {
- }
-
- virtual void SetUp() {
- ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
- policy_ = new MockSpecialStoragePolicy;
- manager_ = new MockQuotaManager(false /* is_incognito */,
- data_dir_.path(),
- base::MessageLoopProxy::current().get(),
- base::MessageLoopProxy::current().get(),
- policy_.get());
- }
-
- virtual void TearDown() {
- // Make sure the quota manager cleans up correctly.
- manager_ = NULL;
- base::RunLoop().RunUntilIdle();
- }
-
- void GetModifiedOrigins(StorageType type, base::Time since) {
- manager_->GetOriginsModifiedSince(
- type, since,
- base::Bind(&MockQuotaManagerTest::GotModifiedOrigins,
- weak_factory_.GetWeakPtr()));
- }
-
- void GotModifiedOrigins(const std::set<GURL>& origins, StorageType type) {
- origins_ = origins;
- type_ = type;
- }
-
- void DeleteOriginData(const GURL& origin, StorageType type,
- int quota_client_mask) {
- manager_->DeleteOriginData(
- origin, type, quota_client_mask,
- base::Bind(&MockQuotaManagerTest::DeletedOriginData,
- weak_factory_.GetWeakPtr()));
- }
-
- void DeletedOriginData(QuotaStatusCode status) {
- ++deletion_callback_count_;
- EXPECT_EQ(quota::kQuotaStatusOk, status);
- }
-
- int deletion_callback_count() const {
- return deletion_callback_count_;
- }
-
- MockQuotaManager* manager() const {
- return manager_.get();
- }
-
- const std::set<GURL>& origins() const {
- return origins_;
- }
-
- const StorageType& type() const {
- return type_;
- }
-
- private:
- base::MessageLoop message_loop_;
- base::ScopedTempDir data_dir_;
- scoped_refptr<MockQuotaManager> manager_;
- scoped_refptr<MockSpecialStoragePolicy> policy_;
-
- int deletion_callback_count_;
-
- std::set<GURL> origins_;
- StorageType type_;
-
- base::WeakPtrFactory<MockQuotaManagerTest> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(MockQuotaManagerTest);
-};
-
-TEST_F(MockQuotaManagerTest, BasicOriginManipulation) {
- EXPECT_FALSE(manager()->OriginHasData(kOrigin1, kTemporary, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin1, kTemporary, kClientDB));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin1, kPersistent, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin1, kPersistent, kClientDB));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kTemporary, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kTemporary, kClientDB));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kPersistent, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kPersistent, kClientDB));
-
- manager()->AddOrigin(kOrigin1, kTemporary, kClientFile, base::Time::Now());
- EXPECT_TRUE(manager()->OriginHasData(kOrigin1, kTemporary, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin1, kTemporary, kClientDB));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin1, kPersistent, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin1, kPersistent, kClientDB));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kTemporary, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kTemporary, kClientDB));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kPersistent, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kPersistent, kClientDB));
-
- manager()->AddOrigin(kOrigin1, kPersistent, kClientFile, base::Time::Now());
- EXPECT_TRUE(manager()->OriginHasData(kOrigin1, kTemporary, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin1, kTemporary, kClientDB));
- EXPECT_TRUE(manager()->OriginHasData(kOrigin1, kPersistent, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin1, kPersistent, kClientDB));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kTemporary, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kTemporary, kClientDB));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kPersistent, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kPersistent, kClientDB));
-
- manager()->AddOrigin(kOrigin2, kTemporary, kClientFile | kClientDB,
- base::Time::Now());
- EXPECT_TRUE(manager()->OriginHasData(kOrigin1, kTemporary, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin1, kTemporary, kClientDB));
- EXPECT_TRUE(manager()->OriginHasData(kOrigin1, kPersistent, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin1, kPersistent, kClientDB));
- EXPECT_TRUE(manager()->OriginHasData(kOrigin2, kTemporary, kClientFile));
- EXPECT_TRUE(manager()->OriginHasData(kOrigin2, kTemporary, kClientDB));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kPersistent, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kPersistent, kClientDB));
-}
-
-TEST_F(MockQuotaManagerTest, OriginDeletion) {
- manager()->AddOrigin(kOrigin1, kTemporary, kClientFile, base::Time::Now());
- manager()->AddOrigin(kOrigin2, kTemporary, kClientFile | kClientDB,
- base::Time::Now());
- manager()->AddOrigin(kOrigin3, kTemporary, kClientFile | kClientDB,
- base::Time::Now());
-
- DeleteOriginData(kOrigin2, kTemporary, kClientFile);
- base::RunLoop().RunUntilIdle();
-
- EXPECT_EQ(1, deletion_callback_count());
- EXPECT_TRUE(manager()->OriginHasData(kOrigin1, kTemporary, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kTemporary, kClientFile));
- EXPECT_TRUE(manager()->OriginHasData(kOrigin2, kTemporary, kClientDB));
- EXPECT_TRUE(manager()->OriginHasData(kOrigin3, kTemporary, kClientFile));
- EXPECT_TRUE(manager()->OriginHasData(kOrigin3, kTemporary, kClientDB));
-
- DeleteOriginData(kOrigin3, kTemporary, kClientFile | kClientDB);
- base::RunLoop().RunUntilIdle();
-
- EXPECT_EQ(2, deletion_callback_count());
- EXPECT_TRUE(manager()->OriginHasData(kOrigin1, kTemporary, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin2, kTemporary, kClientFile));
- EXPECT_TRUE(manager()->OriginHasData(kOrigin2, kTemporary, kClientDB));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin3, kTemporary, kClientFile));
- EXPECT_FALSE(manager()->OriginHasData(kOrigin3, kTemporary, kClientDB));
-}
-
-TEST_F(MockQuotaManagerTest, ModifiedOrigins) {
- base::Time now = base::Time::Now();
- base::Time then = base::Time();
- base::TimeDelta an_hour = base::TimeDelta::FromMilliseconds(3600000);
- base::TimeDelta a_minute = base::TimeDelta::FromMilliseconds(60000);
-
- GetModifiedOrigins(kTemporary, then);
- base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(origins().empty());
-
- manager()->AddOrigin(kOrigin1, kTemporary, kClientFile, now - an_hour);
-
- GetModifiedOrigins(kTemporary, then);
- base::RunLoop().RunUntilIdle();
-
- EXPECT_EQ(kTemporary, type());
- EXPECT_EQ(1UL, origins().size());
- EXPECT_EQ(1UL, origins().count(kOrigin1));
- EXPECT_EQ(0UL, origins().count(kOrigin2));
-
- manager()->AddOrigin(kOrigin2, kTemporary, kClientFile, now);
-
- GetModifiedOrigins(kTemporary, then);
- base::RunLoop().RunUntilIdle();
-
- EXPECT_EQ(kTemporary, type());
- EXPECT_EQ(2UL, origins().size());
- EXPECT_EQ(1UL, origins().count(kOrigin1));
- EXPECT_EQ(1UL, origins().count(kOrigin2));
-
- GetModifiedOrigins(kTemporary, now - a_minute);
- base::RunLoop().RunUntilIdle();
-
- EXPECT_EQ(kTemporary, type());
- EXPECT_EQ(1UL, origins().size());
- EXPECT_EQ(0UL, origins().count(kOrigin1));
- EXPECT_EQ(1UL, origins().count(kOrigin2));
-}
-} // Namespace quota
diff --git a/chromium/webkit/browser/quota/mock_special_storage_policy.cc b/chromium/webkit/browser/quota/mock_special_storage_policy.cc
deleted file mode 100644
index 027a35d8ef3..00000000000
--- a/chromium/webkit/browser/quota/mock_special_storage_policy.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2013 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 "webkit/browser/quota/mock_special_storage_policy.h"
-
-#include "base/stl_util.h"
-
-namespace quota {
-
-MockSpecialStoragePolicy::MockSpecialStoragePolicy()
- : all_unlimited_(false) {
-}
-
-bool MockSpecialStoragePolicy::IsStorageProtected(const GURL& origin) {
- return ContainsKey(protected_, origin);
-}
-
-bool MockSpecialStoragePolicy::IsStorageUnlimited(const GURL& origin) {
- if (all_unlimited_)
- return true;
- return ContainsKey(unlimited_, origin);
-}
-
-bool MockSpecialStoragePolicy::IsStorageSessionOnly(const GURL& origin) {
- return ContainsKey(session_only_, origin);
-}
-
-bool MockSpecialStoragePolicy::CanQueryDiskSize(const GURL& origin) {
- return ContainsKey(can_query_disk_size_, origin);
-}
-
-bool MockSpecialStoragePolicy::IsFileHandler(const std::string& extension_id) {
- return ContainsKey(file_handlers_, extension_id);
-}
-
-bool MockSpecialStoragePolicy::HasIsolatedStorage(const GURL& origin) {
- return ContainsKey(isolated_, origin);
-}
-
-bool MockSpecialStoragePolicy::HasSessionOnlyOrigins() {
- return !session_only_.empty();
-}
-
-MockSpecialStoragePolicy::~MockSpecialStoragePolicy() {}
-
-} // namespace quota
diff --git a/chromium/webkit/browser/quota/mock_special_storage_policy.h b/chromium/webkit/browser/quota/mock_special_storage_policy.h
deleted file mode 100644
index 80f64bc7207..00000000000
--- a/chromium/webkit/browser/quota/mock_special_storage_policy.h
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright 2013 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 WEBKIT_BROWSER_QUOTA_MOCK_SPECIAL_STORAGE_POLICY_H_
-#define WEBKIT_BROWSER_QUOTA_MOCK_SPECIAL_STORAGE_POLICY_H_
-
-#include <set>
-#include <string>
-
-#include "url/gurl.h"
-#include "webkit/browser/quota/special_storage_policy.h"
-
-namespace quota {
-
-class MockSpecialStoragePolicy : public quota::SpecialStoragePolicy {
- public:
- MockSpecialStoragePolicy();
-
- virtual bool IsStorageProtected(const GURL& origin) OVERRIDE;
- virtual bool IsStorageUnlimited(const GURL& origin) OVERRIDE;
- virtual bool IsStorageSessionOnly(const GURL& origin) OVERRIDE;
- virtual bool CanQueryDiskSize(const GURL& origin) OVERRIDE;
- virtual bool IsFileHandler(const std::string& extension_id) OVERRIDE;
- virtual bool HasIsolatedStorage(const GURL& origin) OVERRIDE;
- virtual bool HasSessionOnlyOrigins() OVERRIDE;
-
- void AddProtected(const GURL& origin) {
- protected_.insert(origin);
- }
-
- void AddUnlimited(const GURL& origin) {
- unlimited_.insert(origin);
- }
-
- void RemoveUnlimited(const GURL& origin) {
- unlimited_.erase(origin);
- }
-
- void AddSessionOnly(const GURL& origin) {
- session_only_.insert(origin);
- }
-
- void GrantQueryDiskSize(const GURL& origin) {
- can_query_disk_size_.insert(origin);
- }
-
- void AddFileHandler(const std::string& id) {
- file_handlers_.insert(id);
- }
-
- void AddIsolated(const GURL& origin) {
- isolated_.insert(origin);
- }
-
- void RemoveIsolated(const GURL& origin) {
- isolated_.erase(origin);
- }
-
- void SetAllUnlimited(bool all_unlimited) {
- all_unlimited_ = all_unlimited;
- }
-
- void Reset() {
- protected_.clear();
- unlimited_.clear();
- session_only_.clear();
- can_query_disk_size_.clear();
- file_handlers_.clear();
- isolated_.clear();
- all_unlimited_ = false;
- }
-
- void NotifyGranted(const GURL& origin, int change_flags) {
- SpecialStoragePolicy::NotifyGranted(origin, change_flags);
- }
-
- void NotifyRevoked(const GURL& origin, int change_flags) {
- SpecialStoragePolicy::NotifyRevoked(origin, change_flags);
- }
-
- void NotifyCleared() {
- SpecialStoragePolicy::NotifyCleared();
- }
-
- protected:
- virtual ~MockSpecialStoragePolicy();
-
- private:
- std::set<GURL> protected_;
- std::set<GURL> unlimited_;
- std::set<GURL> session_only_;
- std::set<GURL> can_query_disk_size_;
- std::set<GURL> isolated_;
- std::set<std::string> file_handlers_;
-
- bool all_unlimited_;
-};
-} // namespace quota
-
-#endif // WEBKIT_BROWSER_QUOTA_MOCK_SPECIAL_STORAGE_POLICY_H_
diff --git a/chromium/webkit/browser/quota/mock_storage_client.cc b/chromium/webkit/browser/quota/mock_storage_client.cc
deleted file mode 100644
index 61fd667a85a..00000000000
--- a/chromium/webkit/browser/quota/mock_storage_client.cc
+++ /dev/null
@@ -1,186 +0,0 @@
-// Copyright 2013 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 "webkit/browser/quota/mock_storage_client.h"
-
-#include "base/basictypes.h"
-#include "base/bind.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/singleton.h"
-#include "base/message_loop/message_loop_proxy.h"
-#include "base/stl_util.h"
-#include "net/base/net_util.h"
-#include "webkit/browser/quota/quota_manager.h"
-
-namespace quota {
-
-using std::make_pair;
-
-MockStorageClient::MockStorageClient(
- QuotaManagerProxy* quota_manager_proxy,
- const MockOriginData* mock_data, QuotaClient::ID id, size_t mock_data_size)
- : quota_manager_proxy_(quota_manager_proxy),
- id_(id),
- mock_time_counter_(0),
- weak_factory_(this) {
- Populate(mock_data, mock_data_size);
-}
-
-void MockStorageClient::Populate(
- const MockOriginData* mock_data,
- size_t mock_data_size) {
- for (size_t i = 0; i < mock_data_size; ++i) {
- origin_data_[make_pair(GURL(mock_data[i].origin), mock_data[i].type)] =
- mock_data[i].usage;
- }
-}
-
-MockStorageClient::~MockStorageClient() {}
-
-void MockStorageClient::AddOriginAndNotify(
- const GURL& origin_url, StorageType type, int64 size) {
- DCHECK(origin_data_.find(make_pair(origin_url, type)) == origin_data_.end());
- DCHECK_GE(size, 0);
- origin_data_[make_pair(origin_url, type)] = size;
- quota_manager_proxy_->quota_manager()->NotifyStorageModifiedInternal(
- id(), origin_url, type, size, IncrementMockTime());
-}
-
-void MockStorageClient::ModifyOriginAndNotify(
- const GURL& origin_url, StorageType type, int64 delta) {
- OriginDataMap::iterator find = origin_data_.find(make_pair(origin_url, type));
- DCHECK(find != origin_data_.end());
- find->second += delta;
- DCHECK_GE(find->second, 0);
-
- // TODO(tzik): Check quota to prevent usage exceed
- quota_manager_proxy_->quota_manager()->NotifyStorageModifiedInternal(
- id(), origin_url, type, delta, IncrementMockTime());
-}
-
-void MockStorageClient::TouchAllOriginsAndNotify() {
- for (OriginDataMap::const_iterator itr = origin_data_.begin();
- itr != origin_data_.end();
- ++itr) {
- quota_manager_proxy_->quota_manager()->NotifyStorageModifiedInternal(
- id(), itr->first.first, itr->first.second, 0, IncrementMockTime());
- }
-}
-
-void MockStorageClient::AddOriginToErrorSet(
- const GURL& origin_url, StorageType type) {
- error_origins_.insert(make_pair(origin_url, type));
-}
-
-base::Time MockStorageClient::IncrementMockTime() {
- ++mock_time_counter_;
- return base::Time::FromDoubleT(mock_time_counter_ * 10.0);
-}
-
-QuotaClient::ID MockStorageClient::id() const {
- return id_;
-}
-
-void MockStorageClient::OnQuotaManagerDestroyed() {
- delete this;
-}
-
-void MockStorageClient::GetOriginUsage(const GURL& origin_url,
- StorageType type,
- const GetUsageCallback& callback) {
- base::MessageLoopProxy::current()->PostTask(
- FROM_HERE,
- base::Bind(&MockStorageClient::RunGetOriginUsage,
- weak_factory_.GetWeakPtr(), origin_url, type, callback));
-}
-
-void MockStorageClient::GetOriginsForType(
- StorageType type, const GetOriginsCallback& callback) {
- base::MessageLoopProxy::current()->PostTask(
- FROM_HERE,
- base::Bind(&MockStorageClient::RunGetOriginsForType,
- weak_factory_.GetWeakPtr(), type, callback));
-}
-
-void MockStorageClient::GetOriginsForHost(
- StorageType type, const std::string& host,
- const GetOriginsCallback& callback) {
- base::MessageLoopProxy::current()->PostTask(
- FROM_HERE,
- base::Bind(&MockStorageClient::RunGetOriginsForHost,
- weak_factory_.GetWeakPtr(), type, host, callback));
-}
-
-void MockStorageClient::DeleteOriginData(
- const GURL& origin, StorageType type,
- const DeletionCallback& callback) {
- base::MessageLoopProxy::current()->PostTask(
- FROM_HERE,
- base::Bind(&MockStorageClient::RunDeleteOriginData,
- weak_factory_.GetWeakPtr(), origin, type, callback));
-}
-
-bool MockStorageClient::DoesSupport(quota::StorageType type) const {
- return true;
-}
-
-void MockStorageClient::RunGetOriginUsage(
- const GURL& origin_url, StorageType type,
- const GetUsageCallback& callback) {
- OriginDataMap::iterator find = origin_data_.find(make_pair(origin_url, type));
- if (find == origin_data_.end()) {
- callback.Run(0);
- } else {
- callback.Run(find->second);
- }
-}
-
-void MockStorageClient::RunGetOriginsForType(
- StorageType type, const GetOriginsCallback& callback) {
- std::set<GURL> origins;
- for (OriginDataMap::iterator iter = origin_data_.begin();
- iter != origin_data_.end(); ++iter) {
- if (type == iter->first.second)
- origins.insert(iter->first.first);
- }
- callback.Run(origins);
-}
-
-void MockStorageClient::RunGetOriginsForHost(
- StorageType type, const std::string& host,
- const GetOriginsCallback& callback) {
- std::set<GURL> origins;
- for (OriginDataMap::iterator iter = origin_data_.begin();
- iter != origin_data_.end(); ++iter) {
- std::string host_or_spec = net::GetHostOrSpecFromURL(iter->first.first);
- if (type == iter->first.second && host == host_or_spec)
- origins.insert(iter->first.first);
- }
- callback.Run(origins);
-}
-
-void MockStorageClient::RunDeleteOriginData(
- const GURL& origin_url,
- StorageType type,
- const DeletionCallback& callback) {
- ErrorOriginSet::iterator itr_error =
- error_origins_.find(make_pair(origin_url, type));
- if (itr_error != error_origins_.end()) {
- callback.Run(kQuotaErrorInvalidModification);
- return;
- }
-
- OriginDataMap::iterator itr =
- origin_data_.find(make_pair(origin_url, type));
- if (itr != origin_data_.end()) {
- int64 delta = itr->second;
- quota_manager_proxy_->
- NotifyStorageModified(id(), origin_url, type, -delta);
- origin_data_.erase(itr);
- }
-
- callback.Run(kQuotaStatusOk);
-}
-
-} // namespace quota
diff --git a/chromium/webkit/browser/quota/mock_storage_client.h b/chromium/webkit/browser/quota/mock_storage_client.h
deleted file mode 100644
index 42c6162de49..00000000000
--- a/chromium/webkit/browser/quota/mock_storage_client.h
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright 2013 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 WEBKIT_BROWSER_QUOTA_MOCK_STORAGE_CLIENT_H_
-#define WEBKIT_BROWSER_QUOTA_MOCK_STORAGE_CLIENT_H_
-
-#include <map>
-#include <set>
-#include <string>
-#include <utility>
-
-#include "base/compiler_specific.h"
-#include "base/memory/weak_ptr.h"
-#include "base/time/time.h"
-#include "url/gurl.h"
-#include "webkit/browser/quota/quota_client.h"
-
-namespace quota {
-
-class QuotaManagerProxy;
-
-struct MockOriginData {
- const char* origin;
- StorageType type;
- int64 usage;
-};
-
-// Mock storage class for testing.
-class MockStorageClient : public QuotaClient {
- public:
- MockStorageClient(QuotaManagerProxy* quota_manager_proxy,
- const MockOriginData* mock_data,
- QuotaClient::ID id,
- size_t mock_data_size);
- virtual ~MockStorageClient();
-
- // To add or modify mock data in this client.
- void AddOriginAndNotify(
- const GURL& origin_url, StorageType type, int64 size);
- void ModifyOriginAndNotify(
- const GURL& origin_url, StorageType type, int64 delta);
- void TouchAllOriginsAndNotify();
-
- void AddOriginToErrorSet(const GURL& origin_url, StorageType type);
-
- base::Time IncrementMockTime();
-
- // QuotaClient methods.
- virtual QuotaClient::ID id() const OVERRIDE;
- virtual void OnQuotaManagerDestroyed() OVERRIDE;
- virtual void GetOriginUsage(const GURL& origin_url,
- StorageType type,
- const GetUsageCallback& callback) OVERRIDE;
- virtual void GetOriginsForType(StorageType type,
- const GetOriginsCallback& callback) OVERRIDE;
- virtual void GetOriginsForHost(StorageType type, const std::string& host,
- const GetOriginsCallback& callback) OVERRIDE;
- virtual void DeleteOriginData(const GURL& origin,
- StorageType type,
- const DeletionCallback& callback) OVERRIDE;
- virtual bool DoesSupport(quota::StorageType type) const OVERRIDE;
-
- private:
- void RunGetOriginUsage(const GURL& origin_url,
- StorageType type,
- const GetUsageCallback& callback);
- void RunGetOriginsForType(StorageType type,
- const GetOriginsCallback& callback);
- void RunGetOriginsForHost(StorageType type,
- const std::string& host,
- const GetOriginsCallback& callback);
- void RunDeleteOriginData(const GURL& origin_url,
- StorageType type,
- const DeletionCallback& callback);
-
- void Populate(const MockOriginData* mock_data, size_t mock_data_size);
-
- scoped_refptr<QuotaManagerProxy> quota_manager_proxy_;
- const ID id_;
-
- typedef std::map<std::pair<GURL, StorageType>, int64> OriginDataMap;
- OriginDataMap origin_data_;
- typedef std::set<std::pair<GURL, StorageType> > ErrorOriginSet;
- ErrorOriginSet error_origins_;
-
- int mock_time_counter_;
-
- base::WeakPtrFactory<MockStorageClient> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(MockStorageClient);
-};
-
-} // namespace quota
-
-#endif // WEBKIT_BROWSER_QUOTA_MOCK_STORAGE_CLIENT_H_
diff --git a/chromium/webkit/browser/quota/quota_database.cc b/chromium/webkit/browser/quota/quota_database.cc
index 1905f6f0c42..03bed771db0 100644
--- a/chromium/webkit/browser/quota/quota_database.cc
+++ b/chromium/webkit/browser/quota/quota_database.cc
@@ -5,6 +5,7 @@
#include "webkit/browser/quota/quota_database.h"
#include <string>
+#include <vector>
#include "base/auto_reset.h"
#include "base/bind.h"
@@ -573,9 +574,10 @@ bool QuotaDatabase::UpgradeSchema(int current_version) {
if (current_version == 2) {
QuotaTableImporter importer;
typedef std::vector<QuotaTableEntry> QuotaTableEntries;
- if (!DumpQuotaTable(new QuotaTableCallback(base::Bind(
- &QuotaTableImporter::Append, base::Unretained(&importer)))))
+ if (!DumpQuotaTable(base::Bind(&QuotaTableImporter::Append,
+ base::Unretained(&importer)))) {
return false;
+ }
ResetSchema();
for (QuotaTableEntries::const_iterator iter = importer.entries.begin();
iter != importer.entries.end(); ++iter) {
@@ -588,8 +590,7 @@ bool QuotaDatabase::UpgradeSchema(int current_version) {
return false;
}
-bool QuotaDatabase::DumpQuotaTable(QuotaTableCallback* callback) {
- scoped_ptr<QuotaTableCallback> callback_deleter(callback);
+bool QuotaDatabase::DumpQuotaTable(const QuotaTableCallback& callback) {
if (!LazyOpen(true))
return false;
@@ -602,7 +603,7 @@ bool QuotaDatabase::DumpQuotaTable(QuotaTableCallback* callback) {
static_cast<StorageType>(statement.ColumnInt(1)),
statement.ColumnInt64(2));
- if (!callback->Run(entry))
+ if (!callback.Run(entry))
return true;
}
@@ -610,8 +611,7 @@ bool QuotaDatabase::DumpQuotaTable(QuotaTableCallback* callback) {
}
bool QuotaDatabase::DumpOriginInfoTable(
- OriginInfoTableCallback* callback) {
- scoped_ptr<OriginInfoTableCallback> callback_deleter(callback);
+ const OriginInfoTableCallback& callback) {
if (!LazyOpen(true))
return false;
@@ -627,7 +627,7 @@ bool QuotaDatabase::DumpOriginInfoTable(
base::Time::FromInternalValue(statement.ColumnInt64(3)),
base::Time::FromInternalValue(statement.ColumnInt64(4)));
- if (!callback->Run(entry))
+ if (!callback.Run(entry))
return true;
}
@@ -654,4 +654,4 @@ bool operator<(const QuotaDatabase::OriginInfoTableEntry& lhs,
return lhs.last_access_time < rhs.last_access_time;
}
-} // quota namespace
+} // namespace quota
diff --git a/chromium/webkit/browser/quota/quota_database.h b/chromium/webkit/browser/quota/quota_database.h
index 92ec1591026..c64fde72577 100644
--- a/chromium/webkit/browser/quota/quota_database.h
+++ b/chromium/webkit/browser/quota/quota_database.h
@@ -19,6 +19,10 @@
#include "webkit/browser/webkit_storage_browser_export.h"
#include "webkit/common/quota/quota_types.h"
+namespace content {
+class QuotaDatabaseTest;
+}
+
namespace sql {
class Connection;
class MetaTable;
@@ -160,8 +164,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE QuotaDatabase {
const IndexSchema* indexes, size_t indexes_size);
// |callback| may return false to stop reading data.
- bool DumpQuotaTable(QuotaTableCallback* callback);
- bool DumpOriginInfoTable(OriginInfoTableCallback* callback);
+ bool DumpQuotaTable(const QuotaTableCallback& callback);
+ bool DumpOriginInfoTable(const OriginInfoTableCallback& callback);
base::FilePath db_file_path_;
@@ -172,7 +176,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE QuotaDatabase {
base::OneShotTimer<QuotaDatabase> timer_;
- friend class QuotaDatabaseTest;
+ friend class content::QuotaDatabaseTest;
friend class QuotaManager;
static const TableSchema kTables[];
diff --git a/chromium/webkit/browser/quota/quota_database_unittest.cc b/chromium/webkit/browser/quota/quota_database_unittest.cc
deleted file mode 100644
index e457da52008..00000000000
--- a/chromium/webkit/browser/quota/quota_database_unittest.cc
+++ /dev/null
@@ -1,567 +0,0 @@
-// Copyright 2013 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 <algorithm>
-#include <iterator>
-#include <set>
-
-#include "base/bind.h"
-#include "base/callback.h"
-#include "base/file_util.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/message_loop/message_loop.h"
-#include "sql/connection.h"
-#include "sql/meta_table.h"
-#include "sql/statement.h"
-#include "sql/transaction.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "url/gurl.h"
-#include "webkit/browser/quota/mock_special_storage_policy.h"
-#include "webkit/browser/quota/quota_database.h"
-
-namespace quota {
-namespace {
-
-const base::Time kZeroTime;
-
-} // namespace
-
-class QuotaDatabaseTest : public testing::Test {
- protected:
- typedef QuotaDatabase::QuotaTableEntry QuotaTableEntry;
- typedef QuotaDatabase::QuotaTableCallback QuotaTableCallback;
- typedef QuotaDatabase::OriginInfoTableCallback
- OriginInfoTableCallback;
-
- void LazyOpen(const base::FilePath& kDbFile) {
- QuotaDatabase db(kDbFile);
- EXPECT_FALSE(db.LazyOpen(false));
- ASSERT_TRUE(db.LazyOpen(true));
- EXPECT_TRUE(db.db_.get());
- EXPECT_TRUE(kDbFile.empty() || base::PathExists(kDbFile));
- }
-
- void UpgradeSchemaV2toV3(const base::FilePath& kDbFile) {
- const QuotaTableEntry entries[] = {
- QuotaTableEntry("a", kStorageTypeTemporary, 1),
- QuotaTableEntry("b", kStorageTypeTemporary, 2),
- QuotaTableEntry("c", kStorageTypePersistent, 3),
- };
-
- CreateV2Database(kDbFile, entries, ARRAYSIZE_UNSAFE(entries));
-
- QuotaDatabase db(kDbFile);
- EXPECT_TRUE(db.LazyOpen(true));
- EXPECT_TRUE(db.db_.get());
-
- typedef EntryVerifier<QuotaTableEntry> Verifier;
- Verifier verifier(entries, entries + ARRAYSIZE_UNSAFE(entries));
- EXPECT_TRUE(db.DumpQuotaTable(
- new QuotaTableCallback(
- base::Bind(&Verifier::Run,
- base::Unretained(&verifier)))));
- EXPECT_TRUE(verifier.table.empty());
- }
-
- void HostQuota(const base::FilePath& kDbFile) {
- QuotaDatabase db(kDbFile);
- ASSERT_TRUE(db.LazyOpen(true));
-
- const char* kHost = "foo.com";
- const int kQuota1 = 13579;
- const int kQuota2 = kQuota1 + 1024;
-
- int64 quota = -1;
- EXPECT_FALSE(db.GetHostQuota(kHost, kStorageTypeTemporary, &quota));
- EXPECT_FALSE(db.GetHostQuota(kHost, kStorageTypePersistent, &quota));
-
- // Insert quota for temporary.
- EXPECT_TRUE(db.SetHostQuota(kHost, kStorageTypeTemporary, kQuota1));
- EXPECT_TRUE(db.GetHostQuota(kHost, kStorageTypeTemporary, &quota));
- EXPECT_EQ(kQuota1, quota);
-
- // Update quota for temporary.
- EXPECT_TRUE(db.SetHostQuota(kHost, kStorageTypeTemporary, kQuota2));
- EXPECT_TRUE(db.GetHostQuota(kHost, kStorageTypeTemporary, &quota));
- EXPECT_EQ(kQuota2, quota);
-
- // Quota for persistent must not be updated.
- EXPECT_FALSE(db.GetHostQuota(kHost, kStorageTypePersistent, &quota));
-
- // Delete temporary storage quota.
- EXPECT_TRUE(db.DeleteHostQuota(kHost, kStorageTypeTemporary));
- EXPECT_FALSE(db.GetHostQuota(kHost, kStorageTypeTemporary, &quota));
- }
-
- void GlobalQuota(const base::FilePath& kDbFile) {
- QuotaDatabase db(kDbFile);
- ASSERT_TRUE(db.LazyOpen(true));
-
- const char* kTempQuotaKey = QuotaDatabase::kTemporaryQuotaOverrideKey;
- const char* kAvailSpaceKey = QuotaDatabase::kDesiredAvailableSpaceKey;
-
- int64 value = 0;
- const int64 kValue1 = 456;
- const int64 kValue2 = 123000;
- EXPECT_FALSE(db.GetQuotaConfigValue(kTempQuotaKey, &value));
- EXPECT_FALSE(db.GetQuotaConfigValue(kAvailSpaceKey, &value));
-
- EXPECT_TRUE(db.SetQuotaConfigValue(kTempQuotaKey, kValue1));
- EXPECT_TRUE(db.GetQuotaConfigValue(kTempQuotaKey, &value));
- EXPECT_EQ(kValue1, value);
-
- EXPECT_TRUE(db.SetQuotaConfigValue(kTempQuotaKey, kValue2));
- EXPECT_TRUE(db.GetQuotaConfigValue(kTempQuotaKey, &value));
- EXPECT_EQ(kValue2, value);
-
- EXPECT_TRUE(db.SetQuotaConfigValue(kAvailSpaceKey, kValue1));
- EXPECT_TRUE(db.GetQuotaConfigValue(kAvailSpaceKey, &value));
- EXPECT_EQ(kValue1, value);
-
- EXPECT_TRUE(db.SetQuotaConfigValue(kAvailSpaceKey, kValue2));
- EXPECT_TRUE(db.GetQuotaConfigValue(kAvailSpaceKey, &value));
- EXPECT_EQ(kValue2, value);
- }
-
- void OriginLastAccessTimeLRU(const base::FilePath& kDbFile) {
- QuotaDatabase db(kDbFile);
- ASSERT_TRUE(db.LazyOpen(true));
-
- std::set<GURL> exceptions;
- GURL origin;
- EXPECT_TRUE(db.GetLRUOrigin(kStorageTypeTemporary, exceptions,
- NULL, &origin));
- EXPECT_TRUE(origin.is_empty());
-
- const GURL kOrigin1("http://a/");
- const GURL kOrigin2("http://b/");
- const GURL kOrigin3("http://c/");
- const GURL kOrigin4("http://p/");
-
- // Adding three temporary storages, and
- EXPECT_TRUE(db.SetOriginLastAccessTime(
- kOrigin1, kStorageTypeTemporary, base::Time::FromInternalValue(10)));
- EXPECT_TRUE(db.SetOriginLastAccessTime(
- kOrigin2, kStorageTypeTemporary, base::Time::FromInternalValue(20)));
- EXPECT_TRUE(db.SetOriginLastAccessTime(
- kOrigin3, kStorageTypeTemporary, base::Time::FromInternalValue(30)));
-
- // one persistent.
- EXPECT_TRUE(db.SetOriginLastAccessTime(
- kOrigin4, kStorageTypePersistent, base::Time::FromInternalValue(40)));
-
- EXPECT_TRUE(db.GetLRUOrigin(kStorageTypeTemporary, exceptions,
- NULL, &origin));
- EXPECT_EQ(kOrigin1.spec(), origin.spec());
-
- // Test that unlimited origins are exluded from eviction, but
- // protected origins are not excluded.
- scoped_refptr<MockSpecialStoragePolicy> policy(
- new MockSpecialStoragePolicy);
- policy->AddUnlimited(kOrigin1);
- policy->AddProtected(kOrigin2);
- EXPECT_TRUE(db.GetLRUOrigin(
- kStorageTypeTemporary, exceptions, policy.get(), &origin));
- EXPECT_EQ(kOrigin2.spec(), origin.spec());
-
- exceptions.insert(kOrigin1);
- EXPECT_TRUE(db.GetLRUOrigin(kStorageTypeTemporary, exceptions,
- NULL, &origin));
- EXPECT_EQ(kOrigin2.spec(), origin.spec());
-
- exceptions.insert(kOrigin2);
- EXPECT_TRUE(db.GetLRUOrigin(kStorageTypeTemporary, exceptions,
- NULL, &origin));
- EXPECT_EQ(kOrigin3.spec(), origin.spec());
-
- exceptions.insert(kOrigin3);
- EXPECT_TRUE(db.GetLRUOrigin(kStorageTypeTemporary, exceptions,
- NULL, &origin));
- EXPECT_TRUE(origin.is_empty());
-
- EXPECT_TRUE(db.SetOriginLastAccessTime(
- kOrigin1, kStorageTypeTemporary, base::Time::Now()));
-
- // Delete origin/type last access time information.
- EXPECT_TRUE(db.DeleteOriginInfo(kOrigin3, kStorageTypeTemporary));
-
- // Querying again to see if the deletion has worked.
- exceptions.clear();
- EXPECT_TRUE(db.GetLRUOrigin(kStorageTypeTemporary, exceptions,
- NULL, &origin));
- EXPECT_EQ(kOrigin2.spec(), origin.spec());
-
- exceptions.insert(kOrigin1);
- exceptions.insert(kOrigin2);
- EXPECT_TRUE(db.GetLRUOrigin(kStorageTypeTemporary, exceptions,
- NULL, &origin));
- EXPECT_TRUE(origin.is_empty());
- }
-
- void OriginLastModifiedSince(const base::FilePath& kDbFile) {
- QuotaDatabase db(kDbFile);
- ASSERT_TRUE(db.LazyOpen(true));
-
- std::set<GURL> origins;
- EXPECT_TRUE(db.GetOriginsModifiedSince(
- kStorageTypeTemporary, &origins, base::Time()));
- EXPECT_TRUE(origins.empty());
-
- const GURL kOrigin1("http://a/");
- const GURL kOrigin2("http://b/");
- const GURL kOrigin3("http://c/");
-
- // Report last mod time for the test origins.
- EXPECT_TRUE(db.SetOriginLastModifiedTime(
- kOrigin1, kStorageTypeTemporary, base::Time::FromInternalValue(0)));
- EXPECT_TRUE(db.SetOriginLastModifiedTime(
- kOrigin2, kStorageTypeTemporary, base::Time::FromInternalValue(10)));
- EXPECT_TRUE(db.SetOriginLastModifiedTime(
- kOrigin3, kStorageTypeTemporary, base::Time::FromInternalValue(20)));
-
- EXPECT_TRUE(db.GetOriginsModifiedSince(
- kStorageTypeTemporary, &origins, base::Time()));
- EXPECT_EQ(3U, origins.size());
- EXPECT_EQ(1U, origins.count(kOrigin1));
- EXPECT_EQ(1U, origins.count(kOrigin2));
- EXPECT_EQ(1U, origins.count(kOrigin3));
-
- EXPECT_TRUE(db.GetOriginsModifiedSince(
- kStorageTypeTemporary, &origins, base::Time::FromInternalValue(5)));
- EXPECT_EQ(2U, origins.size());
- EXPECT_EQ(0U, origins.count(kOrigin1));
- EXPECT_EQ(1U, origins.count(kOrigin2));
- EXPECT_EQ(1U, origins.count(kOrigin3));
-
- EXPECT_TRUE(db.GetOriginsModifiedSince(
- kStorageTypeTemporary, &origins, base::Time::FromInternalValue(15)));
- EXPECT_EQ(1U, origins.size());
- EXPECT_EQ(0U, origins.count(kOrigin1));
- EXPECT_EQ(0U, origins.count(kOrigin2));
- EXPECT_EQ(1U, origins.count(kOrigin3));
-
- EXPECT_TRUE(db.GetOriginsModifiedSince(
- kStorageTypeTemporary, &origins, base::Time::FromInternalValue(25)));
- EXPECT_TRUE(origins.empty());
-
- // Update origin1's mod time but for persistent storage.
- EXPECT_TRUE(db.SetOriginLastModifiedTime(
- kOrigin1, kStorageTypePersistent, base::Time::FromInternalValue(30)));
-
- // Must have no effects on temporary origins info.
- EXPECT_TRUE(db.GetOriginsModifiedSince(
- kStorageTypeTemporary, &origins, base::Time::FromInternalValue(5)));
- EXPECT_EQ(2U, origins.size());
- EXPECT_EQ(0U, origins.count(kOrigin1));
- EXPECT_EQ(1U, origins.count(kOrigin2));
- EXPECT_EQ(1U, origins.count(kOrigin3));
-
- // One more update for persistent origin2.
- EXPECT_TRUE(db.SetOriginLastModifiedTime(
- kOrigin2, kStorageTypePersistent, base::Time::FromInternalValue(40)));
-
- EXPECT_TRUE(db.GetOriginsModifiedSince(
- kStorageTypePersistent, &origins, base::Time::FromInternalValue(25)));
- EXPECT_EQ(2U, origins.size());
- EXPECT_EQ(1U, origins.count(kOrigin1));
- EXPECT_EQ(1U, origins.count(kOrigin2));
- EXPECT_EQ(0U, origins.count(kOrigin3));
-
- EXPECT_TRUE(db.GetOriginsModifiedSince(
- kStorageTypePersistent, &origins, base::Time::FromInternalValue(35)));
- EXPECT_EQ(1U, origins.size());
- EXPECT_EQ(0U, origins.count(kOrigin1));
- EXPECT_EQ(1U, origins.count(kOrigin2));
- EXPECT_EQ(0U, origins.count(kOrigin3));
- }
-
- void RegisterInitialOriginInfo(const base::FilePath& kDbFile) {
- QuotaDatabase db(kDbFile);
-
- const GURL kOrigins[] = {
- GURL("http://a/"),
- GURL("http://b/"),
- GURL("http://c/") };
- std::set<GURL> origins(kOrigins, kOrigins + ARRAYSIZE_UNSAFE(kOrigins));
-
- EXPECT_TRUE(db.RegisterInitialOriginInfo(origins, kStorageTypeTemporary));
-
- int used_count = -1;
- EXPECT_TRUE(db.FindOriginUsedCount(GURL("http://a/"),
- kStorageTypeTemporary,
- &used_count));
- EXPECT_EQ(0, used_count);
-
- EXPECT_TRUE(db.SetOriginLastAccessTime(
- GURL("http://a/"), kStorageTypeTemporary,
- base::Time::FromDoubleT(1.0)));
- used_count = -1;
- EXPECT_TRUE(db.FindOriginUsedCount(GURL("http://a/"),
- kStorageTypeTemporary,
- &used_count));
- EXPECT_EQ(1, used_count);
-
- EXPECT_TRUE(db.RegisterInitialOriginInfo(origins, kStorageTypeTemporary));
-
- used_count = -1;
- EXPECT_TRUE(db.FindOriginUsedCount(GURL("http://a/"),
- kStorageTypeTemporary,
- &used_count));
- EXPECT_EQ(1, used_count);
- }
-
- template <typename EntryType>
- struct EntryVerifier {
- std::set<EntryType> table;
-
- template <typename Iterator>
- EntryVerifier(Iterator itr, Iterator end)
- : table(itr, end) {}
-
- bool Run(const EntryType& entry) {
- EXPECT_EQ(1u, table.erase(entry));
- return true;
- }
- };
-
- void DumpQuotaTable(const base::FilePath& kDbFile) {
- QuotaTableEntry kTableEntries[] = {
- QuotaTableEntry("http://go/", kStorageTypeTemporary, 1),
- QuotaTableEntry("http://oo/", kStorageTypeTemporary, 2),
- QuotaTableEntry("http://gle/", kStorageTypePersistent, 3)
- };
- QuotaTableEntry* begin = kTableEntries;
- QuotaTableEntry* end = kTableEntries + ARRAYSIZE_UNSAFE(kTableEntries);
-
- QuotaDatabase db(kDbFile);
- EXPECT_TRUE(db.LazyOpen(true));
- AssignQuotaTable(db.db_.get(), begin, end);
- db.Commit();
-
- typedef EntryVerifier<QuotaTableEntry> Verifier;
- Verifier verifier(begin, end);
- EXPECT_TRUE(db.DumpQuotaTable(
- new QuotaTableCallback(
- base::Bind(&Verifier::Run,
- base::Unretained(&verifier)))));
- EXPECT_TRUE(verifier.table.empty());
- }
-
- void DumpOriginInfoTable(const base::FilePath& kDbFile) {
- base::Time now(base::Time::Now());
- typedef QuotaDatabase::OriginInfoTableEntry Entry;
- Entry kTableEntries[] = {
- Entry(GURL("http://go/"), kStorageTypeTemporary, 2147483647, now, now),
- Entry(GURL("http://oo/"), kStorageTypeTemporary, 0, now, now),
- Entry(GURL("http://gle/"), kStorageTypeTemporary, 1, now, now),
- };
- Entry* begin = kTableEntries;
- Entry* end = kTableEntries + ARRAYSIZE_UNSAFE(kTableEntries);
-
- QuotaDatabase db(kDbFile);
- EXPECT_TRUE(db.LazyOpen(true));
- AssignOriginInfoTable(db.db_.get(), begin, end);
- db.Commit();
-
- typedef EntryVerifier<Entry> Verifier;
- Verifier verifier(begin, end);
- EXPECT_TRUE(db.DumpOriginInfoTable(
- new OriginInfoTableCallback(
- base::Bind(&Verifier::Run,
- base::Unretained(&verifier)))));
- EXPECT_TRUE(verifier.table.empty());
- }
-
- private:
- template <typename Iterator>
- void AssignQuotaTable(sql::Connection* db, Iterator itr, Iterator end) {
- ASSERT_NE(db, (sql::Connection*)NULL);
- for (; itr != end; ++itr) {
- const char* kSql =
- "INSERT INTO HostQuotaTable"
- " (host, type, quota)"
- " VALUES (?, ?, ?)";
- sql::Statement statement;
- statement.Assign(db->GetCachedStatement(SQL_FROM_HERE, kSql));
- ASSERT_TRUE(statement.is_valid());
-
- statement.BindString(0, itr->host);
- statement.BindInt(1, static_cast<int>(itr->type));
- statement.BindInt64(2, itr->quota);
- EXPECT_TRUE(statement.Run());
- }
- }
-
- template <typename Iterator>
- void AssignOriginInfoTable(sql::Connection* db, Iterator itr, Iterator end) {
- ASSERT_NE(db, (sql::Connection*)NULL);
- for (; itr != end; ++itr) {
- const char* kSql =
- "INSERT INTO OriginInfoTable"
- " (origin, type, used_count, last_access_time, last_modified_time)"
- " VALUES (?, ?, ?, ?, ?)";
- sql::Statement statement;
- statement.Assign(db->GetCachedStatement(SQL_FROM_HERE, kSql));
- ASSERT_TRUE(statement.is_valid());
-
- statement.BindString(0, itr->origin.spec());
- statement.BindInt(1, static_cast<int>(itr->type));
- statement.BindInt(2, itr->used_count);
- statement.BindInt64(3, itr->last_access_time.ToInternalValue());
- statement.BindInt64(4, itr->last_modified_time.ToInternalValue());
- EXPECT_TRUE(statement.Run());
- }
- }
-
- bool OpenDatabase(sql::Connection* db, const base::FilePath& kDbFile) {
- if (kDbFile.empty()) {
- return db->OpenInMemory();
- }
- if (!base::CreateDirectory(kDbFile.DirName()))
- return false;
- if (!db->Open(kDbFile))
- return false;
- db->Preload();
- return true;
- }
-
- // Create V2 database and populate some data.
- void CreateV2Database(
- const base::FilePath& kDbFile,
- const QuotaTableEntry* entries,
- size_t entries_size) {
- scoped_ptr<sql::Connection> db(new sql::Connection);
- scoped_ptr<sql::MetaTable> meta_table(new sql::MetaTable);
-
- // V2 schema definitions.
- static const int kCurrentVersion = 2;
- static const int kCompatibleVersion = 2;
- static const char kHostQuotaTable[] = "HostQuotaTable";
- static const char kOriginLastAccessTable[] = "OriginLastAccessTable";
- static const QuotaDatabase::TableSchema kTables[] = {
- { kHostQuotaTable,
- "(host TEXT NOT NULL,"
- " type INTEGER NOT NULL,"
- " quota INTEGER,"
- " UNIQUE(host, type))" },
- { kOriginLastAccessTable,
- "(origin TEXT NOT NULL,"
- " type INTEGER NOT NULL,"
- " used_count INTEGER,"
- " last_access_time INTEGER,"
- " UNIQUE(origin, type))" },
- };
- static const QuotaDatabase::IndexSchema kIndexes[] = {
- { "HostIndex",
- kHostQuotaTable,
- "(host)",
- false },
- { "OriginLastAccessIndex",
- kOriginLastAccessTable,
- "(origin, last_access_time)",
- false },
- };
-
- ASSERT_TRUE(OpenDatabase(db.get(), kDbFile));
- EXPECT_TRUE(QuotaDatabase::CreateSchema(
- db.get(), meta_table.get(),
- kCurrentVersion, kCompatibleVersion,
- kTables, ARRAYSIZE_UNSAFE(kTables),
- kIndexes, ARRAYSIZE_UNSAFE(kIndexes)));
-
- // V2 and V3 QuotaTable are compatible, so we can simply use
- // AssignQuotaTable to poplulate v2 database here.
- db->BeginTransaction();
- AssignQuotaTable(db.get(), entries, entries + entries_size);
- db->CommitTransaction();
- }
-
- base::MessageLoop message_loop_;
-};
-
-TEST_F(QuotaDatabaseTest, LazyOpen) {
- base::ScopedTempDir data_dir;
- ASSERT_TRUE(data_dir.CreateUniqueTempDir());
- const base::FilePath kDbFile = data_dir.path().AppendASCII("quota_manager.db");
- LazyOpen(kDbFile);
- LazyOpen(base::FilePath());
-}
-
-TEST_F(QuotaDatabaseTest, UpgradeSchema) {
- base::ScopedTempDir data_dir;
- ASSERT_TRUE(data_dir.CreateUniqueTempDir());
- const base::FilePath kDbFile = data_dir.path().AppendASCII("quota_manager.db");
- UpgradeSchemaV2toV3(kDbFile);
-}
-
-TEST_F(QuotaDatabaseTest, HostQuota) {
- base::ScopedTempDir data_dir;
- ASSERT_TRUE(data_dir.CreateUniqueTempDir());
- const base::FilePath kDbFile = data_dir.path().AppendASCII("quota_manager.db");
- HostQuota(kDbFile);
- HostQuota(base::FilePath());
-}
-
-TEST_F(QuotaDatabaseTest, GlobalQuota) {
- base::ScopedTempDir data_dir;
- ASSERT_TRUE(data_dir.CreateUniqueTempDir());
- const base::FilePath kDbFile = data_dir.path().AppendASCII("quota_manager.db");
- GlobalQuota(kDbFile);
- GlobalQuota(base::FilePath());
-}
-
-TEST_F(QuotaDatabaseTest, OriginLastAccessTimeLRU) {
- base::ScopedTempDir data_dir;
- ASSERT_TRUE(data_dir.CreateUniqueTempDir());
- const base::FilePath kDbFile = data_dir.path().AppendASCII("quota_manager.db");
- OriginLastAccessTimeLRU(kDbFile);
- OriginLastAccessTimeLRU(base::FilePath());
-}
-
-TEST_F(QuotaDatabaseTest, OriginLastModifiedSince) {
- base::ScopedTempDir data_dir;
- ASSERT_TRUE(data_dir.CreateUniqueTempDir());
- const base::FilePath kDbFile = data_dir.path().AppendASCII("quota_manager.db");
- OriginLastModifiedSince(kDbFile);
- OriginLastModifiedSince(base::FilePath());
-}
-
-TEST_F(QuotaDatabaseTest, BootstrapFlag) {
- base::ScopedTempDir data_dir;
- ASSERT_TRUE(data_dir.CreateUniqueTempDir());
-
- const base::FilePath kDbFile = data_dir.path().AppendASCII("quota_manager.db");
- QuotaDatabase db(kDbFile);
-
- EXPECT_FALSE(db.IsOriginDatabaseBootstrapped());
- EXPECT_TRUE(db.SetOriginDatabaseBootstrapped(true));
- EXPECT_TRUE(db.IsOriginDatabaseBootstrapped());
- EXPECT_TRUE(db.SetOriginDatabaseBootstrapped(false));
- EXPECT_FALSE(db.IsOriginDatabaseBootstrapped());
-}
-
-TEST_F(QuotaDatabaseTest, RegisterInitialOriginInfo) {
- base::ScopedTempDir data_dir;
- ASSERT_TRUE(data_dir.CreateUniqueTempDir());
- const base::FilePath kDbFile = data_dir.path().AppendASCII("quota_manager.db");
- RegisterInitialOriginInfo(kDbFile);
- RegisterInitialOriginInfo(base::FilePath());
-}
-
-TEST_F(QuotaDatabaseTest, DumpQuotaTable) {
- base::ScopedTempDir data_dir;
- ASSERT_TRUE(data_dir.CreateUniqueTempDir());
- const base::FilePath kDbFile = data_dir.path().AppendASCII("quota_manager.db");
- DumpQuotaTable(kDbFile);
- DumpQuotaTable(base::FilePath());
-}
-
-TEST_F(QuotaDatabaseTest, DumpOriginInfoTable) {
- base::ScopedTempDir data_dir;
- ASSERT_TRUE(data_dir.CreateUniqueTempDir());
- const base::FilePath kDbFile = data_dir.path().AppendASCII("quota_manager.db");
- DumpOriginInfoTable(kDbFile);
- DumpOriginInfoTable(base::FilePath());
-}
-} // namespace quota
diff --git a/chromium/webkit/browser/quota/quota_manager.cc b/chromium/webkit/browser/quota/quota_manager.cc
index 0663935a214..e4688220548 100644
--- a/chromium/webkit/browser/quota/quota_manager.cc
+++ b/chromium/webkit/browser/quota/quota_manager.cc
@@ -24,7 +24,9 @@
#include "base/time/time.h"
#include "net/base/net_util.h"
#include "webkit/browser/quota/quota_database.h"
+#include "webkit/browser/quota/quota_manager_proxy.h"
#include "webkit/browser/quota/quota_temporary_storage_evictor.h"
+#include "webkit/browser/quota/storage_monitor.h"
#include "webkit/browser/quota/usage_tracker.h"
#include "webkit/common/quota/quota_types.h"
@@ -43,21 +45,6 @@ const int kMinutesInMilliSeconds = 60 * 1000;
const int64 kReportHistogramInterval = 60 * 60 * 1000; // 1 hour
const double kTemporaryQuotaRatioToAvail = 1.0 / 3.0; // 33%
-void DidGetUsageAndQuota(
- base::SequencedTaskRunner* original_task_runner,
- const QuotaManagerProxy::GetUsageAndQuotaCallback& callback,
- QuotaStatusCode status, int64 usage, int64 quota) {
- if (!original_task_runner->RunsTasksOnCurrentThread()) {
- original_task_runner->PostTask(
- FROM_HERE,
- base::Bind(&DidGetUsageAndQuota,
- make_scoped_refptr(original_task_runner),
- callback, status, usage, quota));
- return;
- }
- callback.Run(status, usage, quota);
-}
-
} // namespace
// Arbitrary for now, but must be reasonably small so that
@@ -69,16 +56,22 @@ const int64 QuotaManager::kNoLimit = kint64max;
const int QuotaManager::kPerHostTemporaryPortion = 5; // 20%
+// Cap size for per-host persistent quota determined by the histogram.
+// This is a bit lax value because the histogram says nothing about per-host
+// persistent storage usage and we determined by global persistent storage
+// usage that is less than 10GB for almost all users.
+const int64 QuotaManager::kPerHostPersistentQuotaLimit = 10 * 1024 * kMBytes;
+
const char QuotaManager::kDatabaseName[] = "QuotaManager";
+const int QuotaManager::kThresholdOfErrorsToBeBlacklisted = 3;
+
// Preserve kMinimumPreserveForSystem disk space for system book-keeping
// when returning the quota to unlimited apps/extensions.
// TODO(kinuko): This should be like 10% of the actual disk space.
// For now we simply use a constant as getting the disk size needs
// platform-dependent code. (http://crbug.com/178976)
-const int64 QuotaManager::kMinimumPreserveForSystem = 1024 * kMBytes;
-
-const int QuotaManager::kThresholdOfErrorsToBeBlacklisted = 3;
+int64 QuotaManager::kMinimumPreserveForSystem = 1024 * kMBytes;
const int QuotaManager::kEvictionIntervalInMilliSeconds =
30 * kMinutesInMilliSeconds;
@@ -199,7 +192,7 @@ bool UpdateModifiedTimeOnDBThread(const GURL& origin,
int64 CallSystemGetAmountOfFreeDiskSpace(const base::FilePath& profile_path) {
// Ensure the profile path exists.
- if(!base::CreateDirectory(profile_path)) {
+ if (!base::CreateDirectory(profile_path)) {
LOG(WARNING) << "Create directory failed for path" << profile_path.value();
return 0;
}
@@ -235,8 +228,14 @@ void DispatchTemporaryGlobalQuotaCallback(
int64 CalculateQuotaWithDiskSpace(
int64 available_disk_space, int64 usage, int64 quota) {
- if (available_disk_space < QuotaManager::kMinimumPreserveForSystem ||
- quota < usage) {
+ if (available_disk_space < QuotaManager::kMinimumPreserveForSystem) {
+ LOG(WARNING)
+ << "Running out of disk space for profile."
+ << " QuotaManager starts forbidding further quota consumption.";
+ return usage;
+ }
+
+ if (quota < usage) {
// No more space; cap the quota to the current usage.
return usage;
}
@@ -325,7 +324,7 @@ class UsageAndQuotaCallbackDispatcher
: public QuotaTask,
public base::SupportsWeakPtr<UsageAndQuotaCallbackDispatcher> {
public:
- UsageAndQuotaCallbackDispatcher(QuotaManager* manager)
+ explicit UsageAndQuotaCallbackDispatcher(QuotaManager* manager)
: QuotaTask(manager),
has_usage_(false),
has_global_limited_usage_(false),
@@ -465,9 +464,6 @@ class UsageAndQuotaCallbackDispatcher
};
class QuotaManager::GetUsageInfoTask : public QuotaTask {
- private:
- typedef QuotaManager::GetUsageInfoTask self_type;
-
public:
GetUsageInfoTask(
QuotaManager* manager,
@@ -588,6 +584,7 @@ class QuotaManager::OriginDataDeleter : public QuotaTask {
DeleteSoon();
}
+ private:
void DidDeleteOriginData(QuotaStatusCode status) {
DCHECK_GT(remaining_clients_, 0);
@@ -658,6 +655,7 @@ class QuotaManager::HostDataDeleter : public QuotaTask {
DeleteSoon();
}
+ private:
void DidGetOriginsForHost(const std::set<GURL>& origins) {
DCHECK_GT(remaining_clients_, 0);
@@ -743,8 +741,7 @@ class QuotaManager::DumpQuotaTableHelper {
bool DumpQuotaTableOnDBThread(QuotaDatabase* database) {
DCHECK(database);
return database->DumpQuotaTable(
- new TableCallback(base::Bind(&DumpQuotaTableHelper::AppendEntry,
- base::Unretained(this))));
+ base::Bind(&DumpQuotaTableHelper::AppendEntry, base::Unretained(this)));
}
void DidDumpQuotaTable(const base::WeakPtr<QuotaManager>& manager,
@@ -760,8 +757,6 @@ class QuotaManager::DumpQuotaTableHelper {
}
private:
- typedef QuotaDatabase::QuotaTableCallback TableCallback;
-
bool AppendEntry(const QuotaTableEntry& entry) {
entries_.push_back(entry);
return true;
@@ -775,8 +770,8 @@ class QuotaManager::DumpOriginInfoTableHelper {
bool DumpOriginInfoTableOnDBThread(QuotaDatabase* database) {
DCHECK(database);
return database->DumpOriginInfoTable(
- new TableCallback(base::Bind(&DumpOriginInfoTableHelper::AppendEntry,
- base::Unretained(this))));
+ base::Bind(&DumpOriginInfoTableHelper::AppendEntry,
+ base::Unretained(this)));
}
void DidDumpOriginInfoTable(const base::WeakPtr<QuotaManager>& manager,
@@ -792,8 +787,6 @@ class QuotaManager::DumpOriginInfoTableHelper {
}
private:
- typedef QuotaDatabase::OriginInfoTableCallback TableCallback;
-
bool AppendEntry(const OriginInfoTableEntry& entry) {
entries_.push_back(entry);
return true;
@@ -822,6 +815,7 @@ QuotaManager::QuotaManager(bool is_incognito,
desired_available_space_(-1),
special_storage_policy_(special_storage_policy),
get_disk_space_fn_(&CallSystemGetAmountOfFreeDiskSpace),
+ storage_monitor_(new StorageMonitor(this)),
weak_factory_(this) {
}
@@ -1007,7 +1001,7 @@ void QuotaManager::SetTemporaryGlobalOverrideQuota(
}
if (db_disabled_) {
- if (callback.is_null())
+ if (!callback.is_null())
callback.Run(kQuotaErrorInvalidAccess, -1);
return;
}
@@ -1058,11 +1052,17 @@ void QuotaManager::SetPersistentHostQuota(const std::string& host,
callback.Run(kQuotaErrorNotSupported, 0);
return;
}
+
if (new_quota < 0) {
callback.Run(kQuotaErrorInvalidModification, -1);
return;
}
+ if (kPerHostPersistentQuotaLimit < new_quota) {
+ // Cap the requested size at the per-host quota limit.
+ new_quota = kPerHostPersistentQuotaLimit;
+ }
+
if (db_disabled_) {
callback.Run(kQuotaErrorInvalidAccess, -1);
return;
@@ -1167,15 +1167,18 @@ bool QuotaManager::ResetUsageTracker(StorageType type) {
switch (type) {
case kStorageTypeTemporary:
temporary_usage_tracker_.reset(new UsageTracker(
- clients_, kStorageTypeTemporary, special_storage_policy_.get()));
+ clients_, kStorageTypeTemporary, special_storage_policy_.get(),
+ storage_monitor_.get()));
return true;
case kStorageTypePersistent:
persistent_usage_tracker_.reset(new UsageTracker(
- clients_, kStorageTypePersistent, special_storage_policy_.get()));
+ clients_, kStorageTypePersistent, special_storage_policy_.get(),
+ storage_monitor_.get()));
return true;
case kStorageTypeSyncable:
syncable_usage_tracker_.reset(new UsageTracker(
- clients_, kStorageTypeSyncable, special_storage_policy_.get()));
+ clients_, kStorageTypeSyncable, special_storage_policy_.get(),
+ storage_monitor_.get()));
return true;
default:
NOTREACHED();
@@ -1183,6 +1186,23 @@ bool QuotaManager::ResetUsageTracker(StorageType type) {
return true;
}
+void QuotaManager::AddStorageObserver(
+ StorageObserver* observer, const StorageObserver::MonitorParams& params) {
+ DCHECK(observer);
+ storage_monitor_->AddObserver(observer, params);
+}
+
+void QuotaManager::RemoveStorageObserver(StorageObserver* observer) {
+ DCHECK(observer);
+ storage_monitor_->RemoveObserver(observer);
+}
+
+void QuotaManager::RemoveStorageObserverForFilter(
+ StorageObserver* observer, const StorageObserver::Filter& filter) {
+ DCHECK(observer);
+ storage_monitor_->RemoveObserverForFilter(observer, filter);
+}
+
QuotaManager::~QuotaManager() {
proxy_->manager_ = NULL;
std::for_each(clients_.begin(), clients_.end(),
@@ -1210,11 +1230,14 @@ void QuotaManager::LazyInitialize() {
profile_path_.AppendASCII(kDatabaseName)));
temporary_usage_tracker_.reset(new UsageTracker(
- clients_, kStorageTypeTemporary, special_storage_policy_.get()));
+ clients_, kStorageTypeTemporary, special_storage_policy_.get(),
+ storage_monitor_.get()));
persistent_usage_tracker_.reset(new UsageTracker(
- clients_, kStorageTypePersistent, special_storage_policy_.get()));
+ clients_, kStorageTypePersistent, special_storage_policy_.get(),
+ storage_monitor_.get()));
syncable_usage_tracker_.reset(new UsageTracker(
- clients_, kStorageTypeSyncable, special_storage_policy_.get()));
+ clients_, kStorageTypeSyncable, special_storage_policy_.get(),
+ storage_monitor_.get()));
int64* temporary_quota_override = new int64(-1);
int64* desired_available_space = new int64(-1);
@@ -1605,130 +1628,4 @@ void QuotaManager::PostTaskAndReplyWithResultForDBThread(
reply);
}
-// QuotaManagerProxy ----------------------------------------------------------
-
-void QuotaManagerProxy::RegisterClient(QuotaClient* client) {
- if (!io_thread_->BelongsToCurrentThread() &&
- io_thread_->PostTask(
- FROM_HERE,
- base::Bind(&QuotaManagerProxy::RegisterClient, this, client))) {
- return;
- }
-
- if (manager_)
- manager_->RegisterClient(client);
- else
- client->OnQuotaManagerDestroyed();
-}
-
-void QuotaManagerProxy::NotifyStorageAccessed(
- QuotaClient::ID client_id,
- const GURL& origin,
- StorageType type) {
- if (!io_thread_->BelongsToCurrentThread()) {
- io_thread_->PostTask(
- FROM_HERE,
- base::Bind(&QuotaManagerProxy::NotifyStorageAccessed, this, client_id,
- origin, type));
- return;
- }
-
- if (manager_)
- manager_->NotifyStorageAccessed(client_id, origin, type);
-}
-
-void QuotaManagerProxy::NotifyStorageModified(
- QuotaClient::ID client_id,
- const GURL& origin,
- StorageType type,
- int64 delta) {
- if (!io_thread_->BelongsToCurrentThread()) {
- io_thread_->PostTask(
- FROM_HERE,
- base::Bind(&QuotaManagerProxy::NotifyStorageModified, this, client_id,
- origin, type, delta));
- return;
- }
-
- if (manager_)
- manager_->NotifyStorageModified(client_id, origin, type, delta);
-}
-
-void QuotaManagerProxy::NotifyOriginInUse(
- const GURL& origin) {
- if (!io_thread_->BelongsToCurrentThread()) {
- io_thread_->PostTask(
- FROM_HERE,
- base::Bind(&QuotaManagerProxy::NotifyOriginInUse, this, origin));
- return;
- }
-
- if (manager_)
- manager_->NotifyOriginInUse(origin);
-}
-
-void QuotaManagerProxy::NotifyOriginNoLongerInUse(
- const GURL& origin) {
- if (!io_thread_->BelongsToCurrentThread()) {
- io_thread_->PostTask(
- FROM_HERE,
- base::Bind(&QuotaManagerProxy::NotifyOriginNoLongerInUse, this,
- origin));
- return;
- }
- if (manager_)
- manager_->NotifyOriginNoLongerInUse(origin);
-}
-
-void QuotaManagerProxy::SetUsageCacheEnabled(QuotaClient::ID client_id,
- const GURL& origin,
- StorageType type,
- bool enabled) {
- if (!io_thread_->BelongsToCurrentThread()) {
- io_thread_->PostTask(
- FROM_HERE,
- base::Bind(&QuotaManagerProxy::SetUsageCacheEnabled, this,
- client_id, origin, type, enabled));
- return;
- }
- if (manager_)
- manager_->SetUsageCacheEnabled(client_id, origin, type, enabled);
-}
-
-void QuotaManagerProxy::GetUsageAndQuota(
- base::SequencedTaskRunner* original_task_runner,
- const GURL& origin,
- StorageType type,
- const GetUsageAndQuotaCallback& callback) {
- if (!io_thread_->BelongsToCurrentThread()) {
- io_thread_->PostTask(
- FROM_HERE,
- base::Bind(&QuotaManagerProxy::GetUsageAndQuota, this,
- make_scoped_refptr(original_task_runner),
- origin, type, callback));
- return;
- }
- if (!manager_) {
- DidGetUsageAndQuota(original_task_runner, callback, kQuotaErrorAbort, 0, 0);
- return;
- }
- manager_->GetUsageAndQuota(
- origin, type,
- base::Bind(&DidGetUsageAndQuota,
- make_scoped_refptr(original_task_runner), callback));
-}
-
-QuotaManager* QuotaManagerProxy::quota_manager() const {
- DCHECK(!io_thread_.get() || io_thread_->BelongsToCurrentThread());
- return manager_;
-}
-
-QuotaManagerProxy::QuotaManagerProxy(
- QuotaManager* manager, base::SingleThreadTaskRunner* io_thread)
- : manager_(manager), io_thread_(io_thread) {
-}
-
-QuotaManagerProxy::~QuotaManagerProxy() {
-}
-
} // namespace quota
diff --git a/chromium/webkit/browser/quota/quota_manager.h b/chromium/webkit/browser/quota/quota_manager.h
index 5481b2094d7..ebb953a9ae8 100644
--- a/chromium/webkit/browser/quota/quota_manager.h
+++ b/chromium/webkit/browser/quota/quota_manager.h
@@ -25,6 +25,7 @@
#include "webkit/browser/quota/quota_database.h"
#include "webkit/browser/quota/quota_task.h"
#include "webkit/browser/quota/special_storage_policy.h"
+#include "webkit/browser/quota/storage_observer.h"
#include "webkit/browser/webkit_storage_browser_export.h"
namespace base {
@@ -37,12 +38,20 @@ namespace quota_internals {
class QuotaInternalsProxy;
}
+namespace content {
+class MockQuotaManager;
+class MockStorageClient;
+class QuotaManagerTest;
+class StorageMonitorTest;
+
+}
+
namespace quota {
-class MockQuotaManager;
class QuotaDatabase;
class QuotaManagerProxy;
class QuotaTemporaryStorageEvictor;
+class StorageMonitor;
class UsageTracker;
struct QuotaManagerDeleter;
@@ -225,21 +234,29 @@ class WEBKIT_STORAGE_BROWSER_EXPORT QuotaManager
bool ResetUsageTracker(StorageType type);
+ // Used to register/deregister observers that wish to monitor storage events.
+ void AddStorageObserver(StorageObserver* observer,
+ const StorageObserver::MonitorParams& params);
+ void RemoveStorageObserver(StorageObserver* observer);
+ void RemoveStorageObserverForFilter(StorageObserver* observer,
+ const StorageObserver::Filter& filter);
+
// Determines the portion of the temp pool that can be
// utilized by a single host (ie. 5 for 20%).
static const int kPerHostTemporaryPortion;
- static const char kDatabaseName[];
+ static const int64 kPerHostPersistentQuotaLimit;
- static const int64 kMinimumPreserveForSystem;
+ static const char kDatabaseName[];
static const int kThresholdOfErrorsToBeBlacklisted;
static const int kEvictionIntervalInMilliSeconds;
- // This is kept non-const so that test code can change the value.
+ // These are kept non-const so that test code can change the value.
// TODO(kinuko): Make this a real const value and add a proper way to set
// the quota for syncable storage. (http://crbug.com/155488)
+ static int64 kMinimumPreserveForSystem;
static int64 kSyncableStorageDefaultHostQuota;
protected:
@@ -248,11 +265,12 @@ class WEBKIT_STORAGE_BROWSER_EXPORT QuotaManager
private:
friend class base::DeleteHelper<QuotaManager>;
friend class base::RefCountedThreadSafe<QuotaManager, QuotaManagerDeleter>;
- friend class MockQuotaManager;
- friend class MockStorageClient;
+ friend class content::QuotaManagerTest;
+ friend class content::StorageMonitorTest;
+ friend class content::MockQuotaManager;
+ friend class content::MockStorageClient;
friend class quota_internals::QuotaInternalsProxy;
friend class QuotaManagerProxy;
- friend class QuotaManagerTest;
friend class QuotaTemporaryStorageEvictor;
friend struct QuotaManagerDeleter;
@@ -423,6 +441,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT QuotaManager
// value. The default value points to base::SysInfo::AmountOfFreeDiskSpace.
GetAvailableDiskSpaceFn get_disk_space_fn_;
+ scoped_ptr<StorageMonitor> storage_monitor_;
+
base::WeakPtrFactory<QuotaManager> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(QuotaManager);
@@ -434,52 +454,6 @@ struct QuotaManagerDeleter {
}
};
-// The proxy may be called and finally released on any thread.
-class WEBKIT_STORAGE_BROWSER_EXPORT QuotaManagerProxy
- : public base::RefCountedThreadSafe<QuotaManagerProxy> {
- public:
- typedef QuotaManager::GetUsageAndQuotaCallback
- GetUsageAndQuotaCallback;
-
- virtual void RegisterClient(QuotaClient* client);
- virtual void NotifyStorageAccessed(QuotaClient::ID client_id,
- const GURL& origin,
- StorageType type);
- virtual void NotifyStorageModified(QuotaClient::ID client_id,
- const GURL& origin,
- StorageType type,
- int64 delta);
- virtual void NotifyOriginInUse(const GURL& origin);
- virtual void NotifyOriginNoLongerInUse(const GURL& origin);
-
- virtual void SetUsageCacheEnabled(QuotaClient::ID client_id,
- const GURL& origin,
- StorageType type,
- bool enabled);
- virtual void GetUsageAndQuota(
- base::SequencedTaskRunner* original_task_runner,
- const GURL& origin,
- StorageType type,
- const GetUsageAndQuotaCallback& callback);
-
- // This method may only be called on the IO thread.
- // It may return NULL if the manager has already been deleted.
- QuotaManager* quota_manager() const;
-
- protected:
- friend class QuotaManager;
- friend class base::RefCountedThreadSafe<QuotaManagerProxy>;
-
- QuotaManagerProxy(QuotaManager* manager,
- base::SingleThreadTaskRunner* io_thread);
- virtual ~QuotaManagerProxy();
-
- QuotaManager* manager_; // only accessed on the io thread
- scoped_refptr<base::SingleThreadTaskRunner> io_thread_;
-
- DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy);
-};
-
} // namespace quota
#endif // WEBKIT_BROWSER_QUOTA_QUOTA_MANAGER_H_
diff --git a/chromium/webkit/browser/quota/quota_manager_proxy.cc b/chromium/webkit/browser/quota/quota_manager_proxy.cc
new file mode 100644
index 00000000000..20b42c3d3e3
--- /dev/null
+++ b/chromium/webkit/browser/quota/quota_manager_proxy.cc
@@ -0,0 +1,160 @@
+// 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 "webkit/browser/quota/quota_manager_proxy.h"
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/callback.h"
+#include "base/sequenced_task_runner.h"
+#include "base/single_thread_task_runner.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/task_runner_util.h"
+
+namespace quota {
+
+namespace {
+
+void DidGetUsageAndQuota(
+ base::SequencedTaskRunner* original_task_runner,
+ const QuotaManagerProxy::GetUsageAndQuotaCallback& callback,
+ QuotaStatusCode status, int64 usage, int64 quota) {
+ if (!original_task_runner->RunsTasksOnCurrentThread()) {
+ original_task_runner->PostTask(
+ FROM_HERE,
+ base::Bind(&DidGetUsageAndQuota,
+ make_scoped_refptr(original_task_runner),
+ callback, status, usage, quota));
+ return;
+ }
+ callback.Run(status, usage, quota);
+}
+
+} // namespace
+
+void QuotaManagerProxy::RegisterClient(QuotaClient* client) {
+ if (!io_thread_->BelongsToCurrentThread() &&
+ io_thread_->PostTask(
+ FROM_HERE,
+ base::Bind(&QuotaManagerProxy::RegisterClient, this, client))) {
+ return;
+ }
+
+ if (manager_)
+ manager_->RegisterClient(client);
+ else
+ client->OnQuotaManagerDestroyed();
+}
+
+void QuotaManagerProxy::NotifyStorageAccessed(
+ QuotaClient::ID client_id,
+ const GURL& origin,
+ StorageType type) {
+ if (!io_thread_->BelongsToCurrentThread()) {
+ io_thread_->PostTask(
+ FROM_HERE,
+ base::Bind(&QuotaManagerProxy::NotifyStorageAccessed, this, client_id,
+ origin, type));
+ return;
+ }
+
+ if (manager_)
+ manager_->NotifyStorageAccessed(client_id, origin, type);
+}
+
+void QuotaManagerProxy::NotifyStorageModified(
+ QuotaClient::ID client_id,
+ const GURL& origin,
+ StorageType type,
+ int64 delta) {
+ if (!io_thread_->BelongsToCurrentThread()) {
+ io_thread_->PostTask(
+ FROM_HERE,
+ base::Bind(&QuotaManagerProxy::NotifyStorageModified, this, client_id,
+ origin, type, delta));
+ return;
+ }
+
+ if (manager_)
+ manager_->NotifyStorageModified(client_id, origin, type, delta);
+}
+
+void QuotaManagerProxy::NotifyOriginInUse(
+ const GURL& origin) {
+ if (!io_thread_->BelongsToCurrentThread()) {
+ io_thread_->PostTask(
+ FROM_HERE,
+ base::Bind(&QuotaManagerProxy::NotifyOriginInUse, this, origin));
+ return;
+ }
+
+ if (manager_)
+ manager_->NotifyOriginInUse(origin);
+}
+
+void QuotaManagerProxy::NotifyOriginNoLongerInUse(
+ const GURL& origin) {
+ if (!io_thread_->BelongsToCurrentThread()) {
+ io_thread_->PostTask(
+ FROM_HERE,
+ base::Bind(&QuotaManagerProxy::NotifyOriginNoLongerInUse, this,
+ origin));
+ return;
+ }
+ if (manager_)
+ manager_->NotifyOriginNoLongerInUse(origin);
+}
+
+void QuotaManagerProxy::SetUsageCacheEnabled(QuotaClient::ID client_id,
+ const GURL& origin,
+ StorageType type,
+ bool enabled) {
+ if (!io_thread_->BelongsToCurrentThread()) {
+ io_thread_->PostTask(
+ FROM_HERE,
+ base::Bind(&QuotaManagerProxy::SetUsageCacheEnabled, this,
+ client_id, origin, type, enabled));
+ return;
+ }
+ if (manager_)
+ manager_->SetUsageCacheEnabled(client_id, origin, type, enabled);
+}
+
+void QuotaManagerProxy::GetUsageAndQuota(
+ base::SequencedTaskRunner* original_task_runner,
+ const GURL& origin,
+ StorageType type,
+ const GetUsageAndQuotaCallback& callback) {
+ if (!io_thread_->BelongsToCurrentThread()) {
+ io_thread_->PostTask(
+ FROM_HERE,
+ base::Bind(&QuotaManagerProxy::GetUsageAndQuota, this,
+ make_scoped_refptr(original_task_runner),
+ origin, type, callback));
+ return;
+ }
+ if (!manager_) {
+ DidGetUsageAndQuota(original_task_runner, callback, kQuotaErrorAbort, 0, 0);
+ return;
+ }
+ manager_->GetUsageAndQuota(
+ origin, type,
+ base::Bind(&DidGetUsageAndQuota,
+ make_scoped_refptr(original_task_runner), callback));
+}
+
+QuotaManager* QuotaManagerProxy::quota_manager() const {
+ DCHECK(!io_thread_.get() || io_thread_->BelongsToCurrentThread());
+ return manager_;
+}
+
+QuotaManagerProxy::QuotaManagerProxy(
+ QuotaManager* manager, base::SingleThreadTaskRunner* io_thread)
+ : manager_(manager), io_thread_(io_thread) {
+}
+
+QuotaManagerProxy::~QuotaManagerProxy() {
+}
+
+} // namespace quota
diff --git a/chromium/webkit/browser/quota/quota_manager_proxy.h b/chromium/webkit/browser/quota/quota_manager_proxy.h
new file mode 100644
index 00000000000..21c97c6cd38
--- /dev/null
+++ b/chromium/webkit/browser/quota/quota_manager_proxy.h
@@ -0,0 +1,78 @@
+// 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 WEBKIT_BROWSER_QUOTA_QUOTA_MANAGER_PROXY_H_
+#define WEBKIT_BROWSER_QUOTA_QUOTA_MANAGER_PROXY_H_
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/files/file_path.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/sequenced_task_runner_helpers.h"
+#include "webkit/browser/quota/quota_callbacks.h"
+#include "webkit/browser/quota/quota_client.h"
+#include "webkit/browser/quota/quota_database.h"
+#include "webkit/browser/quota/quota_manager.h"
+#include "webkit/browser/quota/quota_task.h"
+#include "webkit/browser/quota/special_storage_policy.h"
+#include "webkit/browser/webkit_storage_browser_export.h"
+
+namespace base {
+class SequencedTaskRunner;
+class SingleThreadTaskRunner;
+}
+
+namespace quota {
+
+// The proxy may be called and finally released on any thread.
+class WEBKIT_STORAGE_BROWSER_EXPORT QuotaManagerProxy
+ : public base::RefCountedThreadSafe<QuotaManagerProxy> {
+ public:
+ typedef QuotaManager::GetUsageAndQuotaCallback
+ GetUsageAndQuotaCallback;
+
+ virtual void RegisterClient(QuotaClient* client);
+ virtual void NotifyStorageAccessed(QuotaClient::ID client_id,
+ const GURL& origin,
+ StorageType type);
+ virtual void NotifyStorageModified(QuotaClient::ID client_id,
+ const GURL& origin,
+ StorageType type,
+ int64 delta);
+ virtual void NotifyOriginInUse(const GURL& origin);
+ virtual void NotifyOriginNoLongerInUse(const GURL& origin);
+
+ virtual void SetUsageCacheEnabled(QuotaClient::ID client_id,
+ const GURL& origin,
+ StorageType type,
+ bool enabled);
+ virtual void GetUsageAndQuota(
+ base::SequencedTaskRunner* original_task_runner,
+ const GURL& origin,
+ StorageType type,
+ const GetUsageAndQuotaCallback& callback);
+
+ // This method may only be called on the IO thread.
+ // It may return NULL if the manager has already been deleted.
+ QuotaManager* quota_manager() const;
+
+ protected:
+ friend class QuotaManager;
+ friend class base::RefCountedThreadSafe<QuotaManagerProxy>;
+
+ QuotaManagerProxy(QuotaManager* manager,
+ base::SingleThreadTaskRunner* io_thread);
+ virtual ~QuotaManagerProxy();
+
+ QuotaManager* manager_; // only accessed on the io thread
+ scoped_refptr<base::SingleThreadTaskRunner> io_thread_;
+
+ DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy);
+};
+
+} // namespace quota
+
+#endif // WEBKIT_BROWSER_QUOTA_QUOTA_MANAGER_PROXY_H_
diff --git a/chromium/webkit/browser/quota/quota_manager_unittest.cc b/chromium/webkit/browser/quota/quota_manager_unittest.cc
deleted file mode 100644
index b5a8bdce998..00000000000
--- a/chromium/webkit/browser/quota/quota_manager_unittest.cc
+++ /dev/null
@@ -1,2165 +0,0 @@
-// Copyright 2013 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 <set>
-#include <sstream>
-#include <vector>
-
-#include "base/bind.h"
-#include "base/file_util.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
-#include "base/message_loop/message_loop_proxy.h"
-#include "base/run_loop.h"
-#include "base/stl_util.h"
-#include "base/sys_info.h"
-#include "base/time/time.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "url/gurl.h"
-#include "webkit/browser/quota/mock_special_storage_policy.h"
-#include "webkit/browser/quota/mock_storage_client.h"
-#include "webkit/browser/quota/quota_database.h"
-#include "webkit/browser/quota/quota_manager.h"
-
-using base::MessageLoopProxy;
-
-namespace quota {
-
-namespace {
-
-// For shorter names.
-const StorageType kTemp = kStorageTypeTemporary;
-const StorageType kPerm = kStorageTypePersistent;
-const StorageType kSync = kStorageTypeSyncable;
-
-const int kAllClients = QuotaClient::kAllClientsMask;
-
-const int64 kAvailableSpaceForApp = 13377331U;
-
-const int64 kMinimumPreserveForSystem = QuotaManager::kMinimumPreserveForSystem;
-const int kPerHostTemporaryPortion = QuotaManager::kPerHostTemporaryPortion;
-
-// Returns a deterministic value for the amount of available disk space.
-int64 GetAvailableDiskSpaceForTest(const base::FilePath&) {
- return kAvailableSpaceForApp + kMinimumPreserveForSystem;
-}
-
-} // namespace
-
-class QuotaManagerTest : public testing::Test {
- protected:
- typedef QuotaManager::QuotaTableEntry QuotaTableEntry;
- typedef QuotaManager::QuotaTableEntries QuotaTableEntries;
- typedef QuotaManager::OriginInfoTableEntries OriginInfoTableEntries;
-
- public:
- QuotaManagerTest()
- : mock_time_counter_(0),
- weak_factory_(this) {
- }
-
- virtual void SetUp() {
- ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
- mock_special_storage_policy_ = new MockSpecialStoragePolicy;
- ResetQuotaManager(false /* is_incognito */);
- }
-
- virtual void TearDown() {
- // Make sure the quota manager cleans up correctly.
- quota_manager_ = NULL;
- base::RunLoop().RunUntilIdle();
- }
-
- protected:
- void ResetQuotaManager(bool is_incognito) {
- quota_manager_ = new QuotaManager(is_incognito,
- data_dir_.path(),
- MessageLoopProxy::current().get(),
- MessageLoopProxy::current().get(),
- mock_special_storage_policy_.get());
- // Don't (automatically) start the eviction for testing.
- quota_manager_->eviction_disabled_ = true;
- // Don't query the hard disk for remaining capacity.
- quota_manager_->get_disk_space_fn_ = &GetAvailableDiskSpaceForTest;
- additional_callback_count_ = 0;
- }
-
- MockStorageClient* CreateClient(
- const MockOriginData* mock_data,
- size_t mock_data_size,
- QuotaClient::ID id) {
- return new MockStorageClient(quota_manager_->proxy(),
- mock_data, id, mock_data_size);
- }
-
- void RegisterClient(MockStorageClient* client) {
- quota_manager_->proxy()->RegisterClient(client);
- }
-
- void GetUsageInfo() {
- usage_info_.clear();
- quota_manager_->GetUsageInfo(
- base::Bind(&QuotaManagerTest::DidGetUsageInfo,
- weak_factory_.GetWeakPtr()));
- }
-
- void GetUsageAndQuotaForWebApps(const GURL& origin,
- StorageType type) {
- quota_status_ = kQuotaStatusUnknown;
- usage_ = -1;
- quota_ = -1;
- quota_manager_->GetUsageAndQuotaForWebApps(
- origin, type, base::Bind(&QuotaManagerTest::DidGetUsageAndQuota,
- weak_factory_.GetWeakPtr()));
- }
-
- void GetUsageAndQuotaForStorageClient(const GURL& origin,
- StorageType type) {
- quota_status_ = kQuotaStatusUnknown;
- usage_ = -1;
- quota_ = -1;
- quota_manager_->GetUsageAndQuota(
- origin, type, base::Bind(&QuotaManagerTest::DidGetUsageAndQuota,
- weak_factory_.GetWeakPtr()));
- }
-
- void GetTemporaryGlobalQuota() {
- quota_status_ = kQuotaStatusUnknown;
- quota_ = -1;
- quota_manager_->GetTemporaryGlobalQuota(
- base::Bind(&QuotaManagerTest::DidGetQuota,
- weak_factory_.GetWeakPtr()));
- }
-
- void SetTemporaryGlobalQuota(int64 new_quota) {
- quota_status_ = kQuotaStatusUnknown;
- quota_ = -1;
- quota_manager_->SetTemporaryGlobalOverrideQuota(
- new_quota,
- base::Bind(&QuotaManagerTest::DidGetQuota,
- weak_factory_.GetWeakPtr()));
- }
-
- void GetPersistentHostQuota(const std::string& host) {
- quota_status_ = kQuotaStatusUnknown;
- quota_ = -1;
- quota_manager_->GetPersistentHostQuota(
- host,
- base::Bind(&QuotaManagerTest::DidGetHostQuota,
- weak_factory_.GetWeakPtr()));
- }
-
- void SetPersistentHostQuota(const std::string& host, int64 new_quota) {
- quota_status_ = kQuotaStatusUnknown;
- quota_ = -1;
- quota_manager_->SetPersistentHostQuota(
- host, new_quota,
- base::Bind(&QuotaManagerTest::DidGetHostQuota,
- weak_factory_.GetWeakPtr()));
- }
-
- void GetGlobalUsage(StorageType type) {
- usage_ = -1;
- unlimited_usage_ = -1;
- quota_manager_->GetGlobalUsage(
- type,
- base::Bind(&QuotaManagerTest::DidGetGlobalUsage,
- weak_factory_.GetWeakPtr()));
- }
-
- void GetHostUsage(const std::string& host, StorageType type) {
- usage_ = -1;
- quota_manager_->GetHostUsage(
- host, type,
- base::Bind(&QuotaManagerTest::DidGetHostUsage,
- weak_factory_.GetWeakPtr()));
- }
-
- void RunAdditionalUsageAndQuotaTask(const GURL& origin, StorageType type) {
- quota_manager_->GetUsageAndQuota(
- origin, type,
- base::Bind(&QuotaManagerTest::DidGetUsageAndQuotaAdditional,
- weak_factory_.GetWeakPtr()));
- }
-
- void DeleteClientOriginData(QuotaClient* client,
- const GURL& origin,
- StorageType type) {
- DCHECK(client);
- quota_status_ = kQuotaStatusUnknown;
- client->DeleteOriginData(
- origin, type,
- base::Bind(&QuotaManagerTest::StatusCallback,
- weak_factory_.GetWeakPtr()));
- }
-
- void EvictOriginData(const GURL& origin,
- StorageType type) {
- quota_status_ = kQuotaStatusUnknown;
- quota_manager_->EvictOriginData(
- origin, type,
- base::Bind(&QuotaManagerTest::StatusCallback,
- weak_factory_.GetWeakPtr()));
- }
-
- void DeleteOriginData(const GURL& origin,
- StorageType type,
- int quota_client_mask) {
- quota_status_ = kQuotaStatusUnknown;
- quota_manager_->DeleteOriginData(
- origin, type, quota_client_mask,
- base::Bind(&QuotaManagerTest::StatusCallback,
- weak_factory_.GetWeakPtr()));
- }
-
- void DeleteHostData(const std::string& host,
- StorageType type,
- int quota_client_mask) {
- quota_status_ = kQuotaStatusUnknown;
- quota_manager_->DeleteHostData(
- host, type, quota_client_mask,
- base::Bind(&QuotaManagerTest::StatusCallback,
- weak_factory_.GetWeakPtr()));
- }
-
- void GetAvailableSpace() {
- quota_status_ = kQuotaStatusUnknown;
- available_space_ = -1;
- quota_manager_->GetAvailableSpace(
- base::Bind(&QuotaManagerTest::DidGetAvailableSpace,
- weak_factory_.GetWeakPtr()));
- }
-
- void GetUsageAndQuotaForEviction() {
- quota_status_ = kQuotaStatusUnknown;
- usage_ = -1;
- unlimited_usage_ = -1;
- quota_ = -1;
- available_space_ = -1;
- quota_manager_->GetUsageAndQuotaForEviction(
- base::Bind(&QuotaManagerTest::DidGetUsageAndQuotaForEviction,
- weak_factory_.GetWeakPtr()));
- }
-
- void GetCachedOrigins(StorageType type, std::set<GURL>* origins) {
- ASSERT_TRUE(origins != NULL);
- origins->clear();
- quota_manager_->GetCachedOrigins(type, origins);
- }
-
- void NotifyStorageAccessed(QuotaClient* client,
- const GURL& origin,
- StorageType type) {
- DCHECK(client);
- quota_manager_->NotifyStorageAccessedInternal(
- client->id(), origin, type, IncrementMockTime());
- }
-
- void DeleteOriginFromDatabase(const GURL& origin, StorageType type) {
- quota_manager_->DeleteOriginFromDatabase(origin, type);
- }
-
- void GetLRUOrigin(StorageType type) {
- lru_origin_ = GURL();
- quota_manager_->GetLRUOrigin(
- type,
- base::Bind(&QuotaManagerTest::DidGetLRUOrigin,
- weak_factory_.GetWeakPtr()));
- }
-
- void NotifyOriginInUse(const GURL& origin) {
- quota_manager_->NotifyOriginInUse(origin);
- }
-
- void NotifyOriginNoLongerInUse(const GURL& origin) {
- quota_manager_->NotifyOriginNoLongerInUse(origin);
- }
-
- void GetOriginsModifiedSince(StorageType type, base::Time modified_since) {
- modified_origins_.clear();
- modified_origins_type_ = kStorageTypeUnknown;
- quota_manager_->GetOriginsModifiedSince(
- type, modified_since,
- base::Bind(&QuotaManagerTest::DidGetModifiedOrigins,
- weak_factory_.GetWeakPtr()));
- }
-
- void DumpQuotaTable() {
- quota_entries_.clear();
- quota_manager_->DumpQuotaTable(
- base::Bind(&QuotaManagerTest::DidDumpQuotaTable,
- weak_factory_.GetWeakPtr()));
- }
-
- void DumpOriginInfoTable() {
- origin_info_entries_.clear();
- quota_manager_->DumpOriginInfoTable(
- base::Bind(&QuotaManagerTest::DidDumpOriginInfoTable,
- weak_factory_.GetWeakPtr()));
- }
-
- void DidGetUsageInfo(const UsageInfoEntries& entries) {
- usage_info_.insert(usage_info_.begin(), entries.begin(), entries.end());
- }
-
- void DidGetUsageAndQuota(QuotaStatusCode status, int64 usage, int64 quota) {
- quota_status_ = status;
- usage_ = usage;
- quota_ = quota;
- }
-
- void DidGetQuota(QuotaStatusCode status,
- int64 quota) {
- quota_status_ = status;
- quota_ = quota;
- }
-
- void DidGetAvailableSpace(QuotaStatusCode status, int64 available_space) {
- quota_status_ = status;
- available_space_ = available_space;
- }
-
- void DidGetHostQuota(QuotaStatusCode status,
- int64 quota) {
- quota_status_ = status;
- quota_ = quota;
- }
-
- void DidGetGlobalUsage(int64 usage,
- int64 unlimited_usage) {
- usage_ = usage;
- unlimited_usage_ = unlimited_usage;
- }
-
- void DidGetHostUsage(int64 usage) {
- usage_ = usage;
- }
-
- void StatusCallback(QuotaStatusCode status) {
- ++status_callback_count_;
- quota_status_ = status;
- }
-
- void DidGetUsageAndQuotaForEviction(QuotaStatusCode status,
- const UsageAndQuota& usage_and_quota) {
- quota_status_ = status;
- limited_usage_ = usage_and_quota.global_limited_usage;
- quota_ = usage_and_quota.quota;
- available_space_ = usage_and_quota.available_disk_space;
- }
-
- void DidGetLRUOrigin(const GURL& origin) {
- lru_origin_ = origin;
- }
-
- void DidGetModifiedOrigins(const std::set<GURL>& origins, StorageType type) {
- modified_origins_ = origins;
- modified_origins_type_ = type;
- }
-
- void DidDumpQuotaTable(const QuotaTableEntries& entries) {
- quota_entries_ = entries;
- }
-
- void DidDumpOriginInfoTable(const OriginInfoTableEntries& entries) {
- origin_info_entries_ = entries;
- }
-
- void GetUsage_WithModifyTestBody(const StorageType type);
-
- void set_additional_callback_count(int c) { additional_callback_count_ = c; }
- int additional_callback_count() const { return additional_callback_count_; }
- void DidGetUsageAndQuotaAdditional(
- QuotaStatusCode status, int64 usage, int64 quota) {
- ++additional_callback_count_;
- }
-
- QuotaManager* quota_manager() const { return quota_manager_.get(); }
- void set_quota_manager(QuotaManager* quota_manager) {
- quota_manager_ = quota_manager;
- }
-
- MockSpecialStoragePolicy* mock_special_storage_policy() const {
- return mock_special_storage_policy_.get();
- }
-
- QuotaStatusCode status() const { return quota_status_; }
- const UsageInfoEntries& usage_info() const { return usage_info_; }
- int64 usage() const { return usage_; }
- int64 limited_usage() const { return limited_usage_; }
- int64 unlimited_usage() const { return unlimited_usage_; }
- int64 quota() const { return quota_; }
- int64 available_space() const { return available_space_; }
- const GURL& lru_origin() const { return lru_origin_; }
- const std::set<GURL>& modified_origins() const { return modified_origins_; }
- StorageType modified_origins_type() const { return modified_origins_type_; }
- const QuotaTableEntries& quota_entries() const { return quota_entries_; }
- const OriginInfoTableEntries& origin_info_entries() const {
- return origin_info_entries_;
- }
- base::FilePath profile_path() const { return data_dir_.path(); }
- int status_callback_count() const { return status_callback_count_; }
- void reset_status_callback_count() { status_callback_count_ = 0; }
-
- private:
- base::Time IncrementMockTime() {
- ++mock_time_counter_;
- return base::Time::FromDoubleT(mock_time_counter_ * 10.0);
- }
-
- base::MessageLoop message_loop_;
- base::ScopedTempDir data_dir_;
-
- scoped_refptr<QuotaManager> quota_manager_;
- scoped_refptr<MockSpecialStoragePolicy> mock_special_storage_policy_;
-
- QuotaStatusCode quota_status_;
- UsageInfoEntries usage_info_;
- int64 usage_;
- int64 limited_usage_;
- int64 unlimited_usage_;
- int64 quota_;
- int64 available_space_;
- GURL lru_origin_;
- std::set<GURL> modified_origins_;
- StorageType modified_origins_type_;
- QuotaTableEntries quota_entries_;
- OriginInfoTableEntries origin_info_entries_;
- int status_callback_count_;
-
- int additional_callback_count_;
-
- int mock_time_counter_;
-
- base::WeakPtrFactory<QuotaManagerTest> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(QuotaManagerTest);
-};
-
-TEST_F(QuotaManagerTest, GetUsageInfo) {
- static const MockOriginData kData1[] = {
- { "http://foo.com/", kTemp, 10 },
- { "http://foo.com:8080/", kTemp, 15 },
- { "http://bar.com/", kTemp, 20 },
- { "http://bar.com/", kPerm, 50 },
- };
- static const MockOriginData kData2[] = {
- { "https://foo.com/", kTemp, 30 },
- { "https://foo.com:8081/", kTemp, 35 },
- { "http://bar.com/", kPerm, 40 },
- { "http://example.com/", kPerm, 40 },
- };
- RegisterClient(CreateClient(kData1, ARRAYSIZE_UNSAFE(kData1),
- QuotaClient::kFileSystem));
- RegisterClient(CreateClient(kData2, ARRAYSIZE_UNSAFE(kData2),
- QuotaClient::kDatabase));
-
- GetUsageInfo();
- base::RunLoop().RunUntilIdle();
-
- EXPECT_EQ(4U, usage_info().size());
- for (size_t i = 0; i < usage_info().size(); ++i) {
- const UsageInfo& info = usage_info()[i];
- if (info.host == "foo.com" && info.type == kTemp) {
- EXPECT_EQ(10 + 15 + 30 + 35, info.usage);
- } else if (info.host == "bar.com" && info.type == kTemp) {
- EXPECT_EQ(20, info.usage);
- } else if (info.host == "bar.com" && info.type == kPerm) {
- EXPECT_EQ(50 + 40, info.usage);
- } else if (info.host == "example.com" && info.type == kPerm) {
- EXPECT_EQ(40, info.usage);
- } else {
- ADD_FAILURE()
- << "Unexpected host, type: " << info.host << ", " << info.type;
- }
- }
-}
-
-TEST_F(QuotaManagerTest, GetUsageAndQuota_Simple) {
- static const MockOriginData kData[] = {
- { "http://foo.com/", kTemp, 10 },
- { "http://foo.com/", kPerm, 80 },
- };
- RegisterClient(CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem));
-
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(80, usage());
- EXPECT_EQ(0, quota());
-
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(10, usage());
- EXPECT_LE(0, quota());
- int64 quota_returned_for_foo = quota();
-
- GetUsageAndQuotaForWebApps(GURL("http://bar.com/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(0, usage());
- EXPECT_EQ(quota_returned_for_foo, quota());
-}
-
-TEST_F(QuotaManagerTest, GetUsage_NoClient) {
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(0, usage());
-
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(0, usage());
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, usage());
-
- GetHostUsage("foo.com", kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, usage());
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, usage());
- EXPECT_EQ(0, unlimited_usage());
-
- GetGlobalUsage(kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, usage());
- EXPECT_EQ(0, unlimited_usage());
-}
-
-TEST_F(QuotaManagerTest, GetUsage_EmptyClient) {
- RegisterClient(CreateClient(NULL, 0, QuotaClient::kFileSystem));
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(0, usage());
-
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(0, usage());
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, usage());
-
- GetHostUsage("foo.com", kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, usage());
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, usage());
- EXPECT_EQ(0, unlimited_usage());
-
- GetGlobalUsage(kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, usage());
- EXPECT_EQ(0, unlimited_usage());
-}
-
-TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_MultiOrigins) {
- static const MockOriginData kData[] = {
- { "http://foo.com/", kTemp, 10 },
- { "http://foo.com:8080/", kTemp, 20 },
- { "http://bar.com/", kTemp, 5 },
- { "https://bar.com/", kTemp, 7 },
- { "http://baz.com/", kTemp, 30 },
- { "http://foo.com/", kPerm, 40 },
- };
- RegisterClient(CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem));
-
- // This time explicitly sets a temporary global quota.
- SetTemporaryGlobalQuota(100);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(100, quota());
-
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(10 + 20, usage());
-
- const int kPerHostQuota = 100 / kPerHostTemporaryPortion;
-
- // The host's quota should be its full portion of the global quota
- // since global usage is under the global quota.
- EXPECT_EQ(kPerHostQuota, quota());
-
- GetUsageAndQuotaForWebApps(GURL("http://bar.com/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(5 + 7, usage());
- EXPECT_EQ(kPerHostQuota, quota());
-}
-
-TEST_F(QuotaManagerTest, GetUsage_MultipleClients) {
- static const MockOriginData kData1[] = {
- { "http://foo.com/", kTemp, 1 },
- { "http://bar.com/", kTemp, 2 },
- { "http://bar.com/", kPerm, 4 },
- { "http://unlimited/", kPerm, 8 },
- { "http://installed/", kPerm, 16 },
- };
- static const MockOriginData kData2[] = {
- { "https://foo.com/", kTemp, 128 },
- { "http://example.com/", kPerm, 256 },
- { "http://unlimited/", kTemp, 512 },
- { "http://installed/", kTemp, 1024 },
- };
- mock_special_storage_policy()->AddUnlimited(GURL("http://unlimited/"));
- mock_special_storage_policy()->GrantQueryDiskSize(GURL("http://installed/"));
- RegisterClient(CreateClient(kData1, ARRAYSIZE_UNSAFE(kData1),
- QuotaClient::kFileSystem));
- RegisterClient(CreateClient(kData2, ARRAYSIZE_UNSAFE(kData2),
- QuotaClient::kDatabase));
-
- const int64 kTempQuotaBase =
- GetAvailableDiskSpaceForTest(base::FilePath()) / kPerHostTemporaryPortion;
-
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(1 + 128, usage());
-
- GetUsageAndQuotaForWebApps(GURL("http://bar.com/"), kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(4, usage());
-
- GetUsageAndQuotaForWebApps(GURL("http://unlimited/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(512, usage());
- EXPECT_EQ(std::min(kAvailableSpaceForApp, kTempQuotaBase) + usage(), quota());
-
- GetUsageAndQuotaForWebApps(GURL("http://unlimited/"), kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(8, usage());
- EXPECT_EQ(kAvailableSpaceForApp + usage(), quota());
-
- GetAvailableSpace();
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_LE(0, available_space());
-
- GetUsageAndQuotaForWebApps(GURL("http://installed/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(1024, usage());
- EXPECT_EQ(std::min(kAvailableSpaceForApp, kTempQuotaBase) + usage(), quota());
-
- GetUsageAndQuotaForWebApps(GURL("http://installed/"), kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(16, usage());
- EXPECT_EQ(usage(), quota()); // Over-budget case.
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(1 + 2 + 128 + 512 + 1024, usage());
- EXPECT_EQ(512, unlimited_usage());
-
- GetGlobalUsage(kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(4 + 8 + 16 + 256, usage());
- EXPECT_EQ(8, unlimited_usage());
-}
-
-void QuotaManagerTest::GetUsage_WithModifyTestBody(const StorageType type) {
- const MockOriginData data[] = {
- { "http://foo.com/", type, 10 },
- { "http://foo.com:1/", type, 20 },
- };
- MockStorageClient* client = CreateClient(data, ARRAYSIZE_UNSAFE(data),
- QuotaClient::kFileSystem);
- RegisterClient(client);
-
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), type);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(10 + 20, usage());
-
- client->ModifyOriginAndNotify(GURL("http://foo.com/"), type, 30);
- client->ModifyOriginAndNotify(GURL("http://foo.com:1/"), type, -5);
- client->AddOriginAndNotify(GURL("https://foo.com/"), type, 1);
-
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), type);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(10 + 20 + 30 - 5 + 1, usage());
- int foo_usage = usage();
-
- client->AddOriginAndNotify(GURL("http://bar.com/"), type, 40);
- GetUsageAndQuotaForWebApps(GURL("http://bar.com/"), type);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(40, usage());
-
- GetGlobalUsage(type);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(foo_usage + 40, usage());
- EXPECT_EQ(0, unlimited_usage());
-}
-
-TEST_F(QuotaManagerTest, GetTemporaryUsage_WithModify) {
- GetUsage_WithModifyTestBody(kTemp);
-}
-
-TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_WithAdditionalTasks) {
- static const MockOriginData kData[] = {
- { "http://foo.com/", kTemp, 10 },
- { "http://foo.com:8080/", kTemp, 20 },
- { "http://bar.com/", kTemp, 13 },
- { "http://foo.com/", kPerm, 40 },
- };
- RegisterClient(CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem));
- SetTemporaryGlobalQuota(100);
- base::RunLoop().RunUntilIdle();
-
- const int kPerHostQuota = 100 / QuotaManager::kPerHostTemporaryPortion;
-
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp);
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp);
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(10 + 20, usage());
- EXPECT_EQ(kPerHostQuota, quota());
-
- set_additional_callback_count(0);
- RunAdditionalUsageAndQuotaTask(GURL("http://foo.com/"),
- kTemp);
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp);
- RunAdditionalUsageAndQuotaTask(GURL("http://bar.com/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(10 + 20, usage());
- EXPECT_EQ(kPerHostQuota, quota());
- EXPECT_EQ(2, additional_callback_count());
-}
-
-TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_NukeManager) {
- static const MockOriginData kData[] = {
- { "http://foo.com/", kTemp, 10 },
- { "http://foo.com:8080/", kTemp, 20 },
- { "http://bar.com/", kTemp, 13 },
- { "http://foo.com/", kPerm, 40 },
- };
- RegisterClient(CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem));
- SetTemporaryGlobalQuota(100);
- base::RunLoop().RunUntilIdle();
-
- set_additional_callback_count(0);
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp);
- RunAdditionalUsageAndQuotaTask(GURL("http://foo.com/"),
- kTemp);
- RunAdditionalUsageAndQuotaTask(GURL("http://bar.com/"),
- kTemp);
-
- DeleteOriginData(GURL("http://foo.com/"), kTemp, kAllClients);
- DeleteOriginData(GURL("http://bar.com/"), kTemp, kAllClients);
-
- // Nuke before waiting for callbacks.
- set_quota_manager(NULL);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaErrorAbort, status());
-}
-
-TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_Overbudget) {
- static const MockOriginData kData[] = {
- { "http://usage1/", kTemp, 1 },
- { "http://usage10/", kTemp, 10 },
- { "http://usage200/", kTemp, 200 },
- };
- RegisterClient(CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem));
- SetTemporaryGlobalQuota(100);
- base::RunLoop().RunUntilIdle();
-
- const int kPerHostQuota = 100 / QuotaManager::kPerHostTemporaryPortion;
-
- GetUsageAndQuotaForWebApps(GURL("http://usage1/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(1, usage());
- EXPECT_EQ(1, quota()); // should be clamped to our current usage
-
- GetUsageAndQuotaForWebApps(GURL("http://usage10/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(10, usage());
- EXPECT_EQ(10, quota());
-
- GetUsageAndQuotaForWebApps(GURL("http://usage200/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(200, usage());
- EXPECT_EQ(kPerHostQuota, quota()); // should be clamped to the nominal quota
-}
-
-TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_Unlimited) {
- static const MockOriginData kData[] = {
- { "http://usage10/", kTemp, 10 },
- { "http://usage50/", kTemp, 50 },
- { "http://unlimited/", kTemp, 4000 },
- };
- mock_special_storage_policy()->AddUnlimited(GURL("http://unlimited/"));
- MockStorageClient* client = CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem);
- RegisterClient(client);
-
- // Test when not overbugdet.
- SetTemporaryGlobalQuota(1000);
- base::RunLoop().RunUntilIdle();
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(10 + 50 + 4000, usage());
- EXPECT_EQ(4000, unlimited_usage());
-
- const int kPerHostQuotaFor1000 =
- 1000 / QuotaManager::kPerHostTemporaryPortion;
-
- GetUsageAndQuotaForWebApps(GURL("http://usage10/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(10, usage());
- EXPECT_EQ(kPerHostQuotaFor1000, quota());
-
- GetUsageAndQuotaForWebApps(GURL("http://usage50/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(50, usage());
- EXPECT_EQ(kPerHostQuotaFor1000, quota());
-
- GetUsageAndQuotaForWebApps(GURL("http://unlimited/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(4000, usage());
- EXPECT_EQ(kAvailableSpaceForApp + usage(), quota());
-
- GetUsageAndQuotaForStorageClient(GURL("http://unlimited/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(0, usage());
- EXPECT_EQ(QuotaManager::kNoLimit, quota());
-
- // Test when overbugdet.
- SetTemporaryGlobalQuota(100);
- base::RunLoop().RunUntilIdle();
-
- const int kPerHostQuotaFor100 =
- 100 / QuotaManager::kPerHostTemporaryPortion;
-
- GetUsageAndQuotaForWebApps(GURL("http://usage10/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(10, usage());
- EXPECT_EQ(kPerHostQuotaFor100, quota());
-
- GetUsageAndQuotaForWebApps(GURL("http://usage50/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(50, usage());
- EXPECT_EQ(kPerHostQuotaFor100, quota());
-
- GetUsageAndQuotaForWebApps(GURL("http://unlimited/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(4000, usage());
- EXPECT_EQ(kAvailableSpaceForApp + usage(), quota());
-
- GetUsageAndQuotaForStorageClient(GURL("http://unlimited/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(0, usage());
- EXPECT_EQ(QuotaManager::kNoLimit, quota());
-
- // Revoke the unlimited rights and make sure the change is noticed.
- mock_special_storage_policy()->Reset();
- mock_special_storage_policy()->NotifyCleared();
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(10 + 50 + 4000, usage());
- EXPECT_EQ(0, unlimited_usage());
-
- GetUsageAndQuotaForWebApps(GURL("http://usage10/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(10, usage());
- EXPECT_EQ(10, quota()); // should be clamped to our current usage
-
- GetUsageAndQuotaForWebApps(GURL("http://usage50/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(50, usage());
- EXPECT_EQ(kPerHostQuotaFor100, quota());
-
- GetUsageAndQuotaForWebApps(GURL("http://unlimited/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(4000, usage());
- EXPECT_EQ(kPerHostQuotaFor100, quota());
-
- GetUsageAndQuotaForStorageClient(GURL("http://unlimited/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(4000, usage());
- EXPECT_EQ(kPerHostQuotaFor100, quota());
-}
-
-TEST_F(QuotaManagerTest, OriginInUse) {
- const GURL kFooOrigin("http://foo.com/");
- const GURL kBarOrigin("http://bar.com/");
-
- EXPECT_FALSE(quota_manager()->IsOriginInUse(kFooOrigin));
- quota_manager()->NotifyOriginInUse(kFooOrigin); // count of 1
- EXPECT_TRUE(quota_manager()->IsOriginInUse(kFooOrigin));
- quota_manager()->NotifyOriginInUse(kFooOrigin); // count of 2
- EXPECT_TRUE(quota_manager()->IsOriginInUse(kFooOrigin));
- quota_manager()->NotifyOriginNoLongerInUse(kFooOrigin); // count of 1
- EXPECT_TRUE(quota_manager()->IsOriginInUse(kFooOrigin));
-
- EXPECT_FALSE(quota_manager()->IsOriginInUse(kBarOrigin));
- quota_manager()->NotifyOriginInUse(kBarOrigin);
- EXPECT_TRUE(quota_manager()->IsOriginInUse(kBarOrigin));
- quota_manager()->NotifyOriginNoLongerInUse(kBarOrigin);
- EXPECT_FALSE(quota_manager()->IsOriginInUse(kBarOrigin));
-
- quota_manager()->NotifyOriginNoLongerInUse(kFooOrigin);
- EXPECT_FALSE(quota_manager()->IsOriginInUse(kFooOrigin));
-}
-
-TEST_F(QuotaManagerTest, GetAndSetPerststentHostQuota) {
- RegisterClient(CreateClient(NULL, 0, QuotaClient::kFileSystem));
-
- GetPersistentHostQuota("foo.com");
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, quota());
-
- SetPersistentHostQuota("foo.com", 100);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(100, quota());
-
- GetPersistentHostQuota("foo.com");
- SetPersistentHostQuota("foo.com", 200);
- GetPersistentHostQuota("foo.com");
- SetPersistentHostQuota("foo.com", 300000000000ll);
- GetPersistentHostQuota("foo.com");
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(300000000000ll, quota());
-}
-
-TEST_F(QuotaManagerTest, GetAndSetPersistentUsageAndQuota) {
- RegisterClient(CreateClient(NULL, 0, QuotaClient::kFileSystem));
-
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(0, usage());
- EXPECT_EQ(0, quota());
-
- SetPersistentHostQuota("foo.com", 100);
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(0, usage());
- EXPECT_EQ(100, quota());
-
- // For installed app GetUsageAndQuotaForWebApps returns the capped quota.
- mock_special_storage_policy()->GrantQueryDiskSize(GURL("http://installed/"));
- SetPersistentHostQuota("installed", kAvailableSpaceForApp + 100);
- GetUsageAndQuotaForWebApps(GURL("http://installed/"), kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kAvailableSpaceForApp, quota());
-
- // Ditto for unlimited apps.
- mock_special_storage_policy()->AddUnlimited(GURL("http://unlimited/"));
- GetUsageAndQuotaForWebApps(GURL("http://unlimited/"), kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kAvailableSpaceForApp, quota());
-
- // GetUsageAndQuotaForStorageClient should just return 0 usage and
- // kNoLimit quota.
- GetUsageAndQuotaForStorageClient(GURL("http://unlimited/"), kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(0, usage());
- EXPECT_EQ(QuotaManager::kNoLimit, quota());
-}
-
-TEST_F(QuotaManagerTest, GetSyncableQuota) {
- RegisterClient(CreateClient(NULL, 0, QuotaClient::kFileSystem));
-
- // Pre-condition check: available disk space (for testing) is less than
- // the default quota for syncable storage.
- EXPECT_LE(kAvailableSpaceForApp,
- QuotaManager::kSyncableStorageDefaultHostQuota);
-
- // For installed apps the quota manager should return
- // kAvailableSpaceForApp as syncable quota (because of the pre-condition).
- mock_special_storage_policy()->GrantQueryDiskSize(GURL("http://installed/"));
- GetUsageAndQuotaForWebApps(GURL("http://installed/"), kSync);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(0, usage());
- EXPECT_EQ(kAvailableSpaceForApp, quota());
-
- // If it's not installed (which shouldn't happen in real case) it
- // should just return the default host quota for syncable.
- GetUsageAndQuotaForWebApps(GURL("http://foo/"), kSync);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(0, usage());
- EXPECT_EQ(QuotaManager::kSyncableStorageDefaultHostQuota, quota());
-}
-
-TEST_F(QuotaManagerTest, GetPersistentUsageAndQuota_MultiOrigins) {
- static const MockOriginData kData[] = {
- { "http://foo.com/", kPerm, 10 },
- { "http://foo.com:8080/", kPerm, 20 },
- { "https://foo.com/", kPerm, 13 },
- { "https://foo.com:8081/", kPerm, 19 },
- { "http://bar.com/", kPerm, 5 },
- { "https://bar.com/", kPerm, 7 },
- { "http://baz.com/", kPerm, 30 },
- { "http://foo.com/", kTemp, 40 },
- };
- RegisterClient(CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem));
-
- SetPersistentHostQuota("foo.com", 100);
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(10 + 20 + 13 + 19, usage());
- EXPECT_EQ(100, quota());
-}
-
-TEST_F(QuotaManagerTest, GetPersistentUsage_WithModify) {
- GetUsage_WithModifyTestBody(kPerm);
-}
-
-TEST_F(QuotaManagerTest, GetPersistentUsageAndQuota_WithAdditionalTasks) {
- static const MockOriginData kData[] = {
- { "http://foo.com/", kPerm, 10 },
- { "http://foo.com:8080/", kPerm, 20 },
- { "http://bar.com/", kPerm, 13 },
- { "http://foo.com/", kTemp, 40 },
- };
- RegisterClient(CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem));
- SetPersistentHostQuota("foo.com", 100);
-
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm);
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm);
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(10 + 20, usage());
- EXPECT_EQ(100, quota());
-
- set_additional_callback_count(0);
- RunAdditionalUsageAndQuotaTask(GURL("http://foo.com/"),
- kPerm);
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm);
- RunAdditionalUsageAndQuotaTask(GURL("http://bar.com/"), kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(10 + 20, usage());
- EXPECT_EQ(2, additional_callback_count());
-}
-
-TEST_F(QuotaManagerTest, GetPersistentUsageAndQuota_NukeManager) {
- static const MockOriginData kData[] = {
- { "http://foo.com/", kPerm, 10 },
- { "http://foo.com:8080/", kPerm, 20 },
- { "http://bar.com/", kPerm, 13 },
- { "http://foo.com/", kTemp, 40 },
- };
- RegisterClient(CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem));
- SetPersistentHostQuota("foo.com", 100);
-
- set_additional_callback_count(0);
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm);
- RunAdditionalUsageAndQuotaTask(GURL("http://foo.com/"), kPerm);
- RunAdditionalUsageAndQuotaTask(GURL("http://bar.com/"), kPerm);
-
- // Nuke before waiting for callbacks.
- set_quota_manager(NULL);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaErrorAbort, status());
-}
-
-TEST_F(QuotaManagerTest, GetUsage_Simple) {
- static const MockOriginData kData[] = {
- { "http://foo.com/", kPerm, 1 },
- { "http://foo.com:1/", kPerm, 20 },
- { "http://bar.com/", kTemp, 300 },
- { "https://buz.com/", kTemp, 4000 },
- { "http://buz.com/", kTemp, 50000 },
- { "http://bar.com:1/", kPerm, 600000 },
- { "http://foo.com/", kTemp, 7000000 },
- };
- RegisterClient(CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem));
-
- GetGlobalUsage(kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(usage(), 1 + 20 + 600000);
- EXPECT_EQ(0, unlimited_usage());
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(usage(), 300 + 4000 + 50000 + 7000000);
- EXPECT_EQ(0, unlimited_usage());
-
- GetHostUsage("foo.com", kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(usage(), 1 + 20);
-
- GetHostUsage("buz.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(usage(), 4000 + 50000);
-}
-
-TEST_F(QuotaManagerTest, GetUsage_WithModification) {
- static const MockOriginData kData[] = {
- { "http://foo.com/", kPerm, 1 },
- { "http://foo.com:1/", kPerm, 20 },
- { "http://bar.com/", kTemp, 300 },
- { "https://buz.com/", kTemp, 4000 },
- { "http://buz.com/", kTemp, 50000 },
- { "http://bar.com:1/", kPerm, 600000 },
- { "http://foo.com/", kTemp, 7000000 },
- };
-
- MockStorageClient* client = CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem);
- RegisterClient(client);
-
- GetGlobalUsage(kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(usage(), 1 + 20 + 600000);
- EXPECT_EQ(0, unlimited_usage());
-
- client->ModifyOriginAndNotify(
- GURL("http://foo.com/"), kPerm, 80000000);
-
- GetGlobalUsage(kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(usage(), 1 + 20 + 600000 + 80000000);
- EXPECT_EQ(0, unlimited_usage());
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(usage(), 300 + 4000 + 50000 + 7000000);
- EXPECT_EQ(0, unlimited_usage());
-
- client->ModifyOriginAndNotify(
- GURL("http://foo.com/"), kTemp, 1);
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(usage(), 300 + 4000 + 50000 + 7000000 + 1);
- EXPECT_EQ(0, unlimited_usage());
-
- GetHostUsage("buz.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(usage(), 4000 + 50000);
-
- client->ModifyOriginAndNotify(
- GURL("http://buz.com/"), kTemp, 900000000);
-
- GetHostUsage("buz.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(usage(), 4000 + 50000 + 900000000);
-}
-
-TEST_F(QuotaManagerTest, GetUsage_WithDeleteOrigin) {
- static const MockOriginData kData[] = {
- { "http://foo.com/", kTemp, 1 },
- { "http://foo.com:1/", kTemp, 20 },
- { "http://foo.com/", kPerm, 300 },
- { "http://bar.com/", kTemp, 4000 },
- };
- MockStorageClient* client = CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem);
- RegisterClient(client);
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- int64 predelete_global_tmp = usage();
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- int64 predelete_host_tmp = usage();
-
- GetHostUsage("foo.com", kPerm);
- base::RunLoop().RunUntilIdle();
- int64 predelete_host_pers = usage();
-
- DeleteClientOriginData(client, GURL("http://foo.com/"),
- kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_global_tmp - 1, usage());
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_host_tmp - 1, usage());
-
- GetHostUsage("foo.com", kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_host_pers, usage());
-}
-
-TEST_F(QuotaManagerTest, GetAvailableSpaceTest) {
- GetAvailableSpace();
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_LE(0, available_space());
-}
-
-TEST_F(QuotaManagerTest, EvictOriginData) {
- static const MockOriginData kData1[] = {
- { "http://foo.com/", kTemp, 1 },
- { "http://foo.com:1/", kTemp, 20 },
- { "http://foo.com/", kPerm, 300 },
- { "http://bar.com/", kTemp, 4000 },
- };
- static const MockOriginData kData2[] = {
- { "http://foo.com/", kTemp, 50000 },
- { "http://foo.com:1/", kTemp, 6000 },
- { "http://foo.com/", kPerm, 700 },
- { "https://foo.com/", kTemp, 80 },
- { "http://bar.com/", kTemp, 9 },
- };
- MockStorageClient* client1 = CreateClient(kData1, ARRAYSIZE_UNSAFE(kData1),
- QuotaClient::kFileSystem);
- MockStorageClient* client2 = CreateClient(kData2, ARRAYSIZE_UNSAFE(kData2),
- QuotaClient::kDatabase);
- RegisterClient(client1);
- RegisterClient(client2);
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- int64 predelete_global_tmp = usage();
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- int64 predelete_host_tmp = usage();
-
- GetHostUsage("foo.com", kPerm);
- base::RunLoop().RunUntilIdle();
- int64 predelete_host_pers = usage();
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData1); ++i)
- quota_manager()->NotifyStorageAccessed(QuotaClient::kUnknown,
- GURL(kData1[i].origin), kData1[i].type);
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData2); ++i)
- quota_manager()->NotifyStorageAccessed(QuotaClient::kUnknown,
- GURL(kData2[i].origin), kData2[i].type);
- base::RunLoop().RunUntilIdle();
-
- EvictOriginData(GURL("http://foo.com/"), kTemp);
- base::RunLoop().RunUntilIdle();
-
- DumpOriginInfoTable();
- base::RunLoop().RunUntilIdle();
-
- typedef OriginInfoTableEntries::const_iterator iterator;
- for (iterator itr(origin_info_entries().begin()),
- end(origin_info_entries().end());
- itr != end; ++itr) {
- if (itr->type == kTemp)
- EXPECT_NE(std::string("http://foo.com/"), itr->origin.spec());
- }
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_global_tmp - (1 + 50000), usage());
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_host_tmp - (1 + 50000), usage());
-
- GetHostUsage("foo.com", kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_host_pers, usage());
-}
-
-TEST_F(QuotaManagerTest, EvictOriginDataWithDeletionError) {
- static const MockOriginData kData[] = {
- { "http://foo.com/", kTemp, 1 },
- { "http://foo.com:1/", kTemp, 20 },
- { "http://foo.com/", kPerm, 300 },
- { "http://bar.com/", kTemp, 4000 },
- };
- static const int kNumberOfTemporaryOrigins = 3;
- MockStorageClient* client = CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem);
- RegisterClient(client);
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- int64 predelete_global_tmp = usage();
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- int64 predelete_host_tmp = usage();
-
- GetHostUsage("foo.com", kPerm);
- base::RunLoop().RunUntilIdle();
- int64 predelete_host_pers = usage();
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData); ++i)
- NotifyStorageAccessed(client, GURL(kData[i].origin), kData[i].type);
- base::RunLoop().RunUntilIdle();
-
- client->AddOriginToErrorSet(GURL("http://foo.com/"), kTemp);
-
- for (int i = 0;
- i < QuotaManager::kThresholdOfErrorsToBeBlacklisted + 1;
- ++i) {
- EvictOriginData(GURL("http://foo.com/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaErrorInvalidModification, status());
- }
-
- DumpOriginInfoTable();
- base::RunLoop().RunUntilIdle();
-
- bool found_origin_in_database = false;
- typedef OriginInfoTableEntries::const_iterator iterator;
- for (iterator itr(origin_info_entries().begin()),
- end(origin_info_entries().end());
- itr != end; ++itr) {
- if (itr->type == kTemp &&
- GURL("http://foo.com/") == itr->origin) {
- found_origin_in_database = true;
- break;
- }
- }
- // The origin "http://foo.com/" should be in the database.
- EXPECT_TRUE(found_origin_in_database);
-
- for (size_t i = 0; i < kNumberOfTemporaryOrigins - 1; ++i) {
- GetLRUOrigin(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_FALSE(lru_origin().is_empty());
- // The origin "http://foo.com/" should not be in the LRU list.
- EXPECT_NE(std::string("http://foo.com/"), lru_origin().spec());
- DeleteOriginFromDatabase(lru_origin(), kTemp);
- base::RunLoop().RunUntilIdle();
- }
-
- // Now the LRU list must be empty.
- GetLRUOrigin(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(lru_origin().is_empty());
-
- // Deleting origins from the database should not affect the results of the
- // following checks.
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_global_tmp, usage());
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_host_tmp, usage());
-
- GetHostUsage("foo.com", kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_host_pers, usage());
-}
-
-TEST_F(QuotaManagerTest, GetUsageAndQuotaForEviction) {
- static const MockOriginData kData[] = {
- { "http://foo.com/", kTemp, 1 },
- { "http://foo.com:1/", kTemp, 20 },
- { "http://foo.com/", kPerm, 300 },
- { "http://unlimited/", kTemp, 4000 },
- };
-
- mock_special_storage_policy()->AddUnlimited(GURL("http://unlimited/"));
- MockStorageClient* client = CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem);
- RegisterClient(client);
-
- SetTemporaryGlobalQuota(10000000);
- base::RunLoop().RunUntilIdle();
-
- GetUsageAndQuotaForEviction();
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(21, limited_usage());
- EXPECT_EQ(10000000, quota());
- EXPECT_LE(0, available_space());
-}
-
-TEST_F(QuotaManagerTest, DeleteHostDataSimple) {
- static const MockOriginData kData[] = {
- { "http://foo.com/", kTemp, 1 },
- };
- MockStorageClient* client = CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem);
- RegisterClient(client);
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- const int64 predelete_global_tmp = usage();
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- int64 predelete_host_tmp = usage();
-
- GetHostUsage("foo.com", kPerm);
- base::RunLoop().RunUntilIdle();
- int64 predelete_host_pers = usage();
-
- DeleteHostData(std::string(), kTemp, kAllClients);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_global_tmp, usage());
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_host_tmp, usage());
-
- GetHostUsage("foo.com", kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_host_pers, usage());
-
- DeleteHostData("foo.com", kTemp, kAllClients);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_global_tmp - 1, usage());
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_host_tmp - 1, usage());
-
- GetHostUsage("foo.com", kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_host_pers, usage());
-}
-
-TEST_F(QuotaManagerTest, DeleteHostDataMultiple) {
- static const MockOriginData kData1[] = {
- { "http://foo.com/", kTemp, 1 },
- { "http://foo.com:1/", kTemp, 20 },
- { "http://foo.com/", kPerm, 300 },
- { "http://bar.com/", kTemp, 4000 },
- };
- static const MockOriginData kData2[] = {
- { "http://foo.com/", kTemp, 50000 },
- { "http://foo.com:1/", kTemp, 6000 },
- { "http://foo.com/", kPerm, 700 },
- { "https://foo.com/", kTemp, 80 },
- { "http://bar.com/", kTemp, 9 },
- };
- MockStorageClient* client1 = CreateClient(kData1, ARRAYSIZE_UNSAFE(kData1),
- QuotaClient::kFileSystem);
- MockStorageClient* client2 = CreateClient(kData2, ARRAYSIZE_UNSAFE(kData2),
- QuotaClient::kDatabase);
- RegisterClient(client1);
- RegisterClient(client2);
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- const int64 predelete_global_tmp = usage();
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- const int64 predelete_foo_tmp = usage();
-
- GetHostUsage("bar.com", kTemp);
- base::RunLoop().RunUntilIdle();
- const int64 predelete_bar_tmp = usage();
-
- GetHostUsage("foo.com", kPerm);
- base::RunLoop().RunUntilIdle();
- const int64 predelete_foo_pers = usage();
-
- GetHostUsage("bar.com", kPerm);
- base::RunLoop().RunUntilIdle();
- const int64 predelete_bar_pers = usage();
-
- reset_status_callback_count();
- DeleteHostData("foo.com", kTemp, kAllClients);
- DeleteHostData("bar.com", kTemp, kAllClients);
- DeleteHostData("foo.com", kTemp, kAllClients);
- base::RunLoop().RunUntilIdle();
-
- EXPECT_EQ(3, status_callback_count());
-
- DumpOriginInfoTable();
- base::RunLoop().RunUntilIdle();
-
- typedef OriginInfoTableEntries::const_iterator iterator;
- for (iterator itr(origin_info_entries().begin()),
- end(origin_info_entries().end());
- itr != end; ++itr) {
- if (itr->type == kTemp) {
- EXPECT_NE(std::string("http://foo.com/"), itr->origin.spec());
- EXPECT_NE(std::string("http://foo.com:1/"), itr->origin.spec());
- EXPECT_NE(std::string("https://foo.com/"), itr->origin.spec());
- EXPECT_NE(std::string("http://bar.com/"), itr->origin.spec());
- }
- }
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_global_tmp - (1 + 20 + 4000 + 50000 + 6000 + 80 + 9),
- usage());
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_foo_tmp - (1 + 20 + 50000 + 6000 + 80), usage());
-
- GetHostUsage("bar.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_bar_tmp - (4000 + 9), usage());
-
- GetHostUsage("foo.com", kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_foo_pers, usage());
-
- GetHostUsage("bar.com", kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_bar_pers, usage());
-}
-
-// Single-run DeleteOriginData cases must be well covered by
-// EvictOriginData tests.
-TEST_F(QuotaManagerTest, DeleteOriginDataMultiple) {
- static const MockOriginData kData1[] = {
- { "http://foo.com/", kTemp, 1 },
- { "http://foo.com:1/", kTemp, 20 },
- { "http://foo.com/", kPerm, 300 },
- { "http://bar.com/", kTemp, 4000 },
- };
- static const MockOriginData kData2[] = {
- { "http://foo.com/", kTemp, 50000 },
- { "http://foo.com:1/", kTemp, 6000 },
- { "http://foo.com/", kPerm, 700 },
- { "https://foo.com/", kTemp, 80 },
- { "http://bar.com/", kTemp, 9 },
- };
- MockStorageClient* client1 = CreateClient(kData1, ARRAYSIZE_UNSAFE(kData1),
- QuotaClient::kFileSystem);
- MockStorageClient* client2 = CreateClient(kData2, ARRAYSIZE_UNSAFE(kData2),
- QuotaClient::kDatabase);
- RegisterClient(client1);
- RegisterClient(client2);
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- const int64 predelete_global_tmp = usage();
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- const int64 predelete_foo_tmp = usage();
-
- GetHostUsage("bar.com", kTemp);
- base::RunLoop().RunUntilIdle();
- const int64 predelete_bar_tmp = usage();
-
- GetHostUsage("foo.com", kPerm);
- base::RunLoop().RunUntilIdle();
- const int64 predelete_foo_pers = usage();
-
- GetHostUsage("bar.com", kPerm);
- base::RunLoop().RunUntilIdle();
- const int64 predelete_bar_pers = usage();
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData1); ++i)
- quota_manager()->NotifyStorageAccessed(QuotaClient::kUnknown,
- GURL(kData1[i].origin), kData1[i].type);
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData2); ++i)
- quota_manager()->NotifyStorageAccessed(QuotaClient::kUnknown,
- GURL(kData2[i].origin), kData2[i].type);
- base::RunLoop().RunUntilIdle();
-
- reset_status_callback_count();
- DeleteOriginData(GURL("http://foo.com/"), kTemp, kAllClients);
- DeleteOriginData(GURL("http://bar.com/"), kTemp, kAllClients);
- DeleteOriginData(GURL("http://foo.com/"), kTemp, kAllClients);
- base::RunLoop().RunUntilIdle();
-
- EXPECT_EQ(3, status_callback_count());
-
- DumpOriginInfoTable();
- base::RunLoop().RunUntilIdle();
-
- typedef OriginInfoTableEntries::const_iterator iterator;
- for (iterator itr(origin_info_entries().begin()),
- end(origin_info_entries().end());
- itr != end; ++itr) {
- if (itr->type == kTemp) {
- EXPECT_NE(std::string("http://foo.com/"), itr->origin.spec());
- EXPECT_NE(std::string("http://bar.com/"), itr->origin.spec());
- }
- }
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_global_tmp - (1 + 4000 + 50000 + 9), usage());
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_foo_tmp - (1 + 50000), usage());
-
- GetHostUsage("bar.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_bar_tmp - (4000 + 9), usage());
-
- GetHostUsage("foo.com", kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_foo_pers, usage());
-
- GetHostUsage("bar.com", kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_bar_pers, usage());
-}
-
-TEST_F(QuotaManagerTest, GetCachedOrigins) {
- static const MockOriginData kData[] = {
- { "http://a.com/", kTemp, 1 },
- { "http://a.com:1/", kTemp, 20 },
- { "http://b.com/", kPerm, 300 },
- { "http://c.com/", kTemp, 4000 },
- };
- MockStorageClient* client = CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem);
- RegisterClient(client);
-
- // TODO(kinuko): Be careful when we add cache pruner.
-
- std::set<GURL> origins;
- GetCachedOrigins(kTemp, &origins);
- EXPECT_TRUE(origins.empty());
-
- // No matter how we make queries the quota manager tries to cache all
- // the origins at startup.
- GetHostUsage("a.com", kTemp);
- base::RunLoop().RunUntilIdle();
- GetCachedOrigins(kTemp, &origins);
- EXPECT_EQ(3U, origins.size());
-
- GetHostUsage("b.com", kTemp);
- base::RunLoop().RunUntilIdle();
- GetCachedOrigins(kTemp, &origins);
- EXPECT_EQ(3U, origins.size());
-
- GetCachedOrigins(kPerm, &origins);
- EXPECT_TRUE(origins.empty());
-
- GetGlobalUsage(kTemp);
- base::RunLoop().RunUntilIdle();
- GetCachedOrigins(kTemp, &origins);
- EXPECT_EQ(3U, origins.size());
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData); ++i) {
- if (kData[i].type == kTemp)
- EXPECT_TRUE(origins.find(GURL(kData[i].origin)) != origins.end());
- }
-}
-
-TEST_F(QuotaManagerTest, NotifyAndLRUOrigin) {
- static const MockOriginData kData[] = {
- { "http://a.com/", kTemp, 0 },
- { "http://a.com:1/", kTemp, 0 },
- { "https://a.com/", kTemp, 0 },
- { "http://b.com/", kPerm, 0 }, // persistent
- { "http://c.com/", kTemp, 0 },
- };
- MockStorageClient* client = CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem);
- RegisterClient(client);
-
- GURL origin;
- GetLRUOrigin(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(lru_origin().is_empty());
-
- NotifyStorageAccessed(client, GURL("http://a.com/"), kTemp);
- GetLRUOrigin(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ("http://a.com/", lru_origin().spec());
-
- NotifyStorageAccessed(client, GURL("http://b.com/"), kPerm);
- NotifyStorageAccessed(client, GURL("https://a.com/"), kTemp);
- NotifyStorageAccessed(client, GURL("http://c.com/"), kTemp);
- GetLRUOrigin(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ("http://a.com/", lru_origin().spec());
-
- DeleteOriginFromDatabase(lru_origin(), kTemp);
- GetLRUOrigin(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ("https://a.com/", lru_origin().spec());
-
- DeleteOriginFromDatabase(lru_origin(), kTemp);
- GetLRUOrigin(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ("http://c.com/", lru_origin().spec());
-}
-
-TEST_F(QuotaManagerTest, GetLRUOriginWithOriginInUse) {
- static const MockOriginData kData[] = {
- { "http://a.com/", kTemp, 0 },
- { "http://a.com:1/", kTemp, 0 },
- { "https://a.com/", kTemp, 0 },
- { "http://b.com/", kPerm, 0 }, // persistent
- { "http://c.com/", kTemp, 0 },
- };
- MockStorageClient* client = CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem);
- RegisterClient(client);
-
- GURL origin;
- GetLRUOrigin(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(lru_origin().is_empty());
-
- NotifyStorageAccessed(client, GURL("http://a.com/"), kTemp);
- NotifyStorageAccessed(client, GURL("http://b.com/"), kPerm);
- NotifyStorageAccessed(client, GURL("https://a.com/"), kTemp);
- NotifyStorageAccessed(client, GURL("http://c.com/"), kTemp);
-
- GetLRUOrigin(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ("http://a.com/", lru_origin().spec());
-
- // Notify origin http://a.com is in use.
- NotifyOriginInUse(GURL("http://a.com/"));
- GetLRUOrigin(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ("https://a.com/", lru_origin().spec());
-
- // Notify origin https://a.com is in use while GetLRUOrigin is running.
- GetLRUOrigin(kTemp);
- NotifyOriginInUse(GURL("https://a.com/"));
- base::RunLoop().RunUntilIdle();
- // Post-filtering must have excluded the returned origin, so we will
- // see empty result here.
- EXPECT_TRUE(lru_origin().is_empty());
-
- // Notify access for http://c.com while GetLRUOrigin is running.
- GetLRUOrigin(kTemp);
- NotifyStorageAccessed(client, GURL("http://c.com/"), kTemp);
- base::RunLoop().RunUntilIdle();
- // Post-filtering must have excluded the returned origin, so we will
- // see empty result here.
- EXPECT_TRUE(lru_origin().is_empty());
-
- NotifyOriginNoLongerInUse(GURL("http://a.com/"));
- NotifyOriginNoLongerInUse(GURL("https://a.com/"));
- GetLRUOrigin(kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ("http://a.com/", lru_origin().spec());
-}
-
-TEST_F(QuotaManagerTest, GetOriginsModifiedSince) {
- static const MockOriginData kData[] = {
- { "http://a.com/", kTemp, 0 },
- { "http://a.com:1/", kTemp, 0 },
- { "https://a.com/", kTemp, 0 },
- { "http://b.com/", kPerm, 0 }, // persistent
- { "http://c.com/", kTemp, 0 },
- };
- MockStorageClient* client = CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem);
- RegisterClient(client);
-
- GetOriginsModifiedSince(kTemp, base::Time());
- base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(modified_origins().empty());
- EXPECT_EQ(modified_origins_type(), kTemp);
-
- base::Time time1 = client->IncrementMockTime();
- client->ModifyOriginAndNotify(GURL("http://a.com/"), kTemp, 10);
- client->ModifyOriginAndNotify(GURL("http://a.com:1/"), kTemp, 10);
- client->ModifyOriginAndNotify(GURL("http://b.com/"), kPerm, 10);
- base::Time time2 = client->IncrementMockTime();
- client->ModifyOriginAndNotify(GURL("https://a.com/"), kTemp, 10);
- client->ModifyOriginAndNotify(GURL("http://c.com/"), kTemp, 10);
- base::Time time3 = client->IncrementMockTime();
-
- GetOriginsModifiedSince(kTemp, time1);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(4U, modified_origins().size());
- EXPECT_EQ(modified_origins_type(), kTemp);
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData); ++i) {
- if (kData[i].type == kTemp)
- EXPECT_EQ(1U, modified_origins().count(GURL(kData[i].origin)));
- }
-
- GetOriginsModifiedSince(kTemp, time2);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(2U, modified_origins().size());
-
- GetOriginsModifiedSince(kTemp, time3);
- base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(modified_origins().empty());
- EXPECT_EQ(modified_origins_type(), kTemp);
-
- client->ModifyOriginAndNotify(GURL("http://a.com/"), kTemp, 10);
-
- GetOriginsModifiedSince(kTemp, time3);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(1U, modified_origins().size());
- EXPECT_EQ(1U, modified_origins().count(GURL("http://a.com/")));
- EXPECT_EQ(modified_origins_type(), kTemp);
-}
-
-TEST_F(QuotaManagerTest, DumpQuotaTable) {
- SetPersistentHostQuota("example1.com", 1);
- SetPersistentHostQuota("example2.com", 20);
- SetPersistentHostQuota("example3.com", 300);
- base::RunLoop().RunUntilIdle();
-
- DumpQuotaTable();
- base::RunLoop().RunUntilIdle();
-
- const QuotaTableEntry kEntries[] = {
- QuotaTableEntry("example1.com", kPerm, 1),
- QuotaTableEntry("example2.com", kPerm, 20),
- QuotaTableEntry("example3.com", kPerm, 300),
- };
- std::set<QuotaTableEntry> entries
- (kEntries, kEntries + ARRAYSIZE_UNSAFE(kEntries));
-
- typedef QuotaTableEntries::const_iterator iterator;
- for (iterator itr(quota_entries().begin()), end(quota_entries().end());
- itr != end; ++itr) {
- SCOPED_TRACE(testing::Message()
- << "host = " << itr->host << ", "
- << "quota = " << itr->quota);
- EXPECT_EQ(1u, entries.erase(*itr));
- }
- EXPECT_TRUE(entries.empty());
-}
-
-TEST_F(QuotaManagerTest, DumpOriginInfoTable) {
- using std::make_pair;
-
- quota_manager()->NotifyStorageAccessed(
- QuotaClient::kUnknown,
- GURL("http://example.com/"),
- kTemp);
- quota_manager()->NotifyStorageAccessed(
- QuotaClient::kUnknown,
- GURL("http://example.com/"),
- kPerm);
- quota_manager()->NotifyStorageAccessed(
- QuotaClient::kUnknown,
- GURL("http://example.com/"),
- kPerm);
- base::RunLoop().RunUntilIdle();
-
- DumpOriginInfoTable();
- base::RunLoop().RunUntilIdle();
-
- typedef std::pair<GURL, StorageType> TypedOrigin;
- typedef std::pair<TypedOrigin, int> Entry;
- const Entry kEntries[] = {
- make_pair(make_pair(GURL("http://example.com/"), kTemp), 1),
- make_pair(make_pair(GURL("http://example.com/"), kPerm), 2),
- };
- std::set<Entry> entries
- (kEntries, kEntries + ARRAYSIZE_UNSAFE(kEntries));
-
- typedef OriginInfoTableEntries::const_iterator iterator;
- for (iterator itr(origin_info_entries().begin()),
- end(origin_info_entries().end());
- itr != end; ++itr) {
- SCOPED_TRACE(testing::Message()
- << "host = " << itr->origin << ", "
- << "type = " << itr->type << ", "
- << "used_count = " << itr->used_count);
- EXPECT_EQ(1u, entries.erase(
- make_pair(make_pair(itr->origin, itr->type),
- itr->used_count)));
- }
- EXPECT_TRUE(entries.empty());
-}
-
-TEST_F(QuotaManagerTest, QuotaForEmptyHost) {
- GetPersistentHostQuota(std::string());
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(0, quota());
-
- SetPersistentHostQuota(std::string(), 10);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaErrorNotSupported, status());
-}
-
-TEST_F(QuotaManagerTest, DeleteSpecificClientTypeSingleOrigin) {
- static const MockOriginData kData1[] = {
- { "http://foo.com/", kTemp, 1 },
- };
- static const MockOriginData kData2[] = {
- { "http://foo.com/", kTemp, 2 },
- };
- static const MockOriginData kData3[] = {
- { "http://foo.com/", kTemp, 4 },
- };
- static const MockOriginData kData4[] = {
- { "http://foo.com/", kTemp, 8 },
- };
- MockStorageClient* client1 = CreateClient(kData1, ARRAYSIZE_UNSAFE(kData1),
- QuotaClient::kFileSystem);
- MockStorageClient* client2 = CreateClient(kData2, ARRAYSIZE_UNSAFE(kData2),
- QuotaClient::kAppcache);
- MockStorageClient* client3 = CreateClient(kData3, ARRAYSIZE_UNSAFE(kData3),
- QuotaClient::kDatabase);
- MockStorageClient* client4 = CreateClient(kData4, ARRAYSIZE_UNSAFE(kData4),
- QuotaClient::kIndexedDatabase);
- RegisterClient(client1);
- RegisterClient(client2);
- RegisterClient(client3);
- RegisterClient(client4);
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- const int64 predelete_foo_tmp = usage();
-
- DeleteOriginData(GURL("http://foo.com/"), kTemp, QuotaClient::kFileSystem);
- base::RunLoop().RunUntilIdle();
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_foo_tmp - 1, usage());
-
- DeleteOriginData(GURL("http://foo.com/"), kTemp, QuotaClient::kAppcache);
- base::RunLoop().RunUntilIdle();
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_foo_tmp - 2 - 1, usage());
-
- DeleteOriginData(GURL("http://foo.com/"), kTemp, QuotaClient::kDatabase);
- base::RunLoop().RunUntilIdle();
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_foo_tmp - 4 - 2 - 1, usage());
-
- DeleteOriginData(GURL("http://foo.com/"), kTemp,
- QuotaClient::kIndexedDatabase);
- base::RunLoop().RunUntilIdle();
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_foo_tmp - 8 - 4 - 2 - 1, usage());
-}
-
-TEST_F(QuotaManagerTest, DeleteSpecificClientTypeSingleHost) {
- static const MockOriginData kData1[] = {
- { "http://foo.com:1111/", kTemp, 1 },
- };
- static const MockOriginData kData2[] = {
- { "http://foo.com:2222/", kTemp, 2 },
- };
- static const MockOriginData kData3[] = {
- { "http://foo.com:3333/", kTemp, 4 },
- };
- static const MockOriginData kData4[] = {
- { "http://foo.com:4444/", kTemp, 8 },
- };
- MockStorageClient* client1 = CreateClient(kData1, ARRAYSIZE_UNSAFE(kData1),
- QuotaClient::kFileSystem);
- MockStorageClient* client2 = CreateClient(kData2, ARRAYSIZE_UNSAFE(kData2),
- QuotaClient::kAppcache);
- MockStorageClient* client3 = CreateClient(kData3, ARRAYSIZE_UNSAFE(kData3),
- QuotaClient::kDatabase);
- MockStorageClient* client4 = CreateClient(kData4, ARRAYSIZE_UNSAFE(kData4),
- QuotaClient::kIndexedDatabase);
- RegisterClient(client1);
- RegisterClient(client2);
- RegisterClient(client3);
- RegisterClient(client4);
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- const int64 predelete_foo_tmp = usage();
-
- DeleteHostData("foo.com", kTemp, QuotaClient::kFileSystem);
- base::RunLoop().RunUntilIdle();
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_foo_tmp - 1, usage());
-
- DeleteHostData("foo.com", kTemp, QuotaClient::kAppcache);
- base::RunLoop().RunUntilIdle();
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_foo_tmp - 2 - 1, usage());
-
- DeleteHostData("foo.com", kTemp, QuotaClient::kDatabase);
- base::RunLoop().RunUntilIdle();
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_foo_tmp - 4 - 2 - 1, usage());
-
- DeleteHostData("foo.com", kTemp, QuotaClient::kIndexedDatabase);
- base::RunLoop().RunUntilIdle();
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_foo_tmp - 8 - 4 - 2 - 1, usage());
-}
-
-TEST_F(QuotaManagerTest, DeleteMultipleClientTypesSingleOrigin) {
- static const MockOriginData kData1[] = {
- { "http://foo.com/", kTemp, 1 },
- };
- static const MockOriginData kData2[] = {
- { "http://foo.com/", kTemp, 2 },
- };
- static const MockOriginData kData3[] = {
- { "http://foo.com/", kTemp, 4 },
- };
- static const MockOriginData kData4[] = {
- { "http://foo.com/", kTemp, 8 },
- };
- MockStorageClient* client1 = CreateClient(kData1, ARRAYSIZE_UNSAFE(kData1),
- QuotaClient::kFileSystem);
- MockStorageClient* client2 = CreateClient(kData2, ARRAYSIZE_UNSAFE(kData2),
- QuotaClient::kAppcache);
- MockStorageClient* client3 = CreateClient(kData3, ARRAYSIZE_UNSAFE(kData3),
- QuotaClient::kDatabase);
- MockStorageClient* client4 = CreateClient(kData4, ARRAYSIZE_UNSAFE(kData4),
- QuotaClient::kIndexedDatabase);
- RegisterClient(client1);
- RegisterClient(client2);
- RegisterClient(client3);
- RegisterClient(client4);
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- const int64 predelete_foo_tmp = usage();
-
- DeleteOriginData(GURL("http://foo.com/"), kTemp,
- QuotaClient::kFileSystem | QuotaClient::kDatabase);
- base::RunLoop().RunUntilIdle();
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_foo_tmp - 4 - 1, usage());
-
- DeleteOriginData(GURL("http://foo.com/"), kTemp,
- QuotaClient::kAppcache | QuotaClient::kIndexedDatabase);
- base::RunLoop().RunUntilIdle();
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_foo_tmp - 8 - 4 - 2 - 1, usage());
-}
-
-TEST_F(QuotaManagerTest, DeleteMultipleClientTypesSingleHost) {
- static const MockOriginData kData1[] = {
- { "http://foo.com:1111/", kTemp, 1 },
- };
- static const MockOriginData kData2[] = {
- { "http://foo.com:2222/", kTemp, 2 },
- };
- static const MockOriginData kData3[] = {
- { "http://foo.com:3333/", kTemp, 4 },
- };
- static const MockOriginData kData4[] = {
- { "http://foo.com:4444/", kTemp, 8 },
- };
- MockStorageClient* client1 = CreateClient(kData1, ARRAYSIZE_UNSAFE(kData1),
- QuotaClient::kFileSystem);
- MockStorageClient* client2 = CreateClient(kData2, ARRAYSIZE_UNSAFE(kData2),
- QuotaClient::kAppcache);
- MockStorageClient* client3 = CreateClient(kData3, ARRAYSIZE_UNSAFE(kData3),
- QuotaClient::kDatabase);
- MockStorageClient* client4 = CreateClient(kData4, ARRAYSIZE_UNSAFE(kData4),
- QuotaClient::kIndexedDatabase);
- RegisterClient(client1);
- RegisterClient(client2);
- RegisterClient(client3);
- RegisterClient(client4);
-
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- const int64 predelete_foo_tmp = usage();
-
- DeleteHostData("foo.com", kTemp,
- QuotaClient::kFileSystem | QuotaClient::kAppcache);
- base::RunLoop().RunUntilIdle();
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_foo_tmp - 2 - 1, usage());
-
- DeleteHostData("foo.com", kTemp,
- QuotaClient::kDatabase | QuotaClient::kIndexedDatabase);
- base::RunLoop().RunUntilIdle();
- GetHostUsage("foo.com", kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(predelete_foo_tmp - 8 - 4 - 2 - 1, usage());
-}
-
-TEST_F(QuotaManagerTest, GetUsageAndQuota_Incognito) {
- ResetQuotaManager(true);
-
- static const MockOriginData kData[] = {
- { "http://foo.com/", kTemp, 10 },
- { "http://foo.com/", kPerm, 80 },
- };
- RegisterClient(CreateClient(kData, ARRAYSIZE_UNSAFE(kData),
- QuotaClient::kFileSystem));
-
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(80, usage());
- EXPECT_EQ(0, quota());
-
- SetTemporaryGlobalQuota(100);
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(10, usage());
- EXPECT_LE(std::min(static_cast<int64>(100 / kPerHostTemporaryPortion),
- QuotaManager::kIncognitoDefaultQuotaLimit), quota());
-
- mock_special_storage_policy()->AddUnlimited(GURL("http://foo.com/"));
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(80, usage());
- EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota());
-
- GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp);
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(kQuotaStatusOk, status());
- EXPECT_EQ(10, usage());
- EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota());
-}
-
-} // namespace quota
diff --git a/chromium/webkit/browser/quota/quota_temporary_storage_evictor.h b/chromium/webkit/browser/quota/quota_temporary_storage_evictor.h
index 3ebcb781d29..244fa0f63c5 100644
--- a/chromium/webkit/browser/quota/quota_temporary_storage_evictor.h
+++ b/chromium/webkit/browser/quota/quota_temporary_storage_evictor.h
@@ -16,6 +16,10 @@
class GURL;
+namespace content {
+class QuotaTemporaryStorageEvictorTest;
+}
+
namespace quota {
class QuotaEvictionHandler;
@@ -84,7 +88,7 @@ class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE QuotaTemporaryStorageEvictor
}
private:
- friend class QuotaTemporaryStorageEvictorTest;
+ friend class content::QuotaTemporaryStorageEvictorTest;
void StartEvictionTimerWithDelay(int delay_ms);
void ConsiderEviction();
diff --git a/chromium/webkit/browser/quota/quota_temporary_storage_evictor_unittest.cc b/chromium/webkit/browser/quota/quota_temporary_storage_evictor_unittest.cc
deleted file mode 100644
index 941facf5267..00000000000
--- a/chromium/webkit/browser/quota/quota_temporary_storage_evictor_unittest.cc
+++ /dev/null
@@ -1,410 +0,0 @@
-// Copyright 2013 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 <list>
-#include <map>
-#include <utility>
-
-#include "base/bind.h"
-#include "base/callback.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
-#include "base/message_loop/message_loop_proxy.h"
-#include "base/run_loop.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/quota/mock_storage_client.h"
-#include "webkit/browser/quota/quota_manager.h"
-#include "webkit/browser/quota/quota_temporary_storage_evictor.h"
-
-namespace quota {
-
-class QuotaTemporaryStorageEvictorTest;
-
-namespace {
-
-class MockQuotaEvictionHandler : public quota::QuotaEvictionHandler {
- public:
- explicit MockQuotaEvictionHandler(QuotaTemporaryStorageEvictorTest *test)
- : quota_(0),
- available_space_(0),
- error_on_evict_origin_data_(false),
- error_on_get_usage_and_quota_(false) {}
-
- virtual void EvictOriginData(
- const GURL& origin,
- StorageType type,
- const EvictOriginDataCallback& callback) OVERRIDE {
- if (error_on_evict_origin_data_) {
- callback.Run(quota::kQuotaErrorInvalidModification);
- return;
- }
- int64 origin_usage = EnsureOriginRemoved(origin);
- if (origin_usage >= 0)
- available_space_ += origin_usage;
- callback.Run(quota::kQuotaStatusOk);
- }
-
- virtual void GetUsageAndQuotaForEviction(
- const UsageAndQuotaCallback& callback) OVERRIDE {
- if (error_on_get_usage_and_quota_) {
- callback.Run(quota::kQuotaErrorInvalidAccess, UsageAndQuota());
- return;
- }
- if (!task_for_get_usage_and_quota_.is_null())
- task_for_get_usage_and_quota_.Run();
- UsageAndQuota quota_and_usage(-1, GetUsage(), quota_, available_space_);
- callback.Run(quota::kQuotaStatusOk, quota_and_usage);
- }
-
- virtual void GetLRUOrigin(
- StorageType type,
- const GetLRUOriginCallback& callback) OVERRIDE {
- if (origin_order_.empty())
- callback.Run(GURL());
- else
- callback.Run(GURL(origin_order_.front()));
- }
-
- int64 GetUsage() const {
- int64 total_usage = 0;
- for (std::map<GURL, int64>::const_iterator p = origins_.begin();
- p != origins_.end();
- ++p)
- total_usage += p->second;
- return total_usage;
- }
-
- void set_quota(int64 quota) {
- quota_ = quota;
- }
- void set_available_space(int64 available_space) {
- available_space_ = available_space;
- }
- void set_task_for_get_usage_and_quota(const base::Closure& task) {
- task_for_get_usage_and_quota_= task;
- }
- void set_error_on_evict_origin_data(bool error_on_evict_origin_data) {
- error_on_evict_origin_data_ = error_on_evict_origin_data;
- }
- void set_error_on_get_usage_and_quota(bool error_on_get_usage_and_quota) {
- error_on_get_usage_and_quota_ = error_on_get_usage_and_quota;
- }
-
- // Simulates an access to |origin|. It reorders the internal LRU list.
- // It internally uses AddOrigin().
- void AccessOrigin(const GURL& origin) {
- std::map<GURL, int64>::iterator found = origins_.find(origin);
- EXPECT_TRUE(origins_.end() != found);
- AddOrigin(origin, found->second);
- }
-
- // Simulates adding or overwriting the |origin| to the internal origin set
- // with the |usage|. It also adds or moves the |origin| to the end of the
- // LRU list.
- void AddOrigin(const GURL& origin, int64 usage) {
- EnsureOriginRemoved(origin);
- origin_order_.push_back(origin);
- origins_[origin] = usage;
- }
-
- private:
- int64 EnsureOriginRemoved(const GURL& origin) {
- int64 origin_usage;
- if (origins_.find(origin) == origins_.end())
- return -1;
- else
- origin_usage = origins_[origin];
-
- origins_.erase(origin);
- origin_order_.remove(origin);
- return origin_usage;
- }
-
- int64 quota_;
- int64 available_space_;
- std::list<GURL> origin_order_;
- std::map<GURL, int64> origins_;
- bool error_on_evict_origin_data_;
- bool error_on_get_usage_and_quota_;
-
- base::Closure task_for_get_usage_and_quota_;
-};
-
-} // namespace
-
-class QuotaTemporaryStorageEvictorTest : public testing::Test {
- public:
- QuotaTemporaryStorageEvictorTest()
- : num_get_usage_and_quota_for_eviction_(0),
- weak_factory_(this) {}
-
- virtual void SetUp() {
- quota_eviction_handler_.reset(new MockQuotaEvictionHandler(this));
-
- // Run multiple evictions in a single RunUntilIdle() when interval_ms == 0
- temporary_storage_evictor_.reset(new QuotaTemporaryStorageEvictor(
- quota_eviction_handler_.get(), 0));
- }
-
- virtual void TearDown() {
- temporary_storage_evictor_.reset();
- quota_eviction_handler_.reset();
- base::RunLoop().RunUntilIdle();
- }
-
- void TaskForRepeatedEvictionTest(
- const std::pair<GURL, int64>& origin_to_be_added,
- const GURL& origin_to_be_accessed,
- int expected_usage_after_first,
- int expected_usage_after_second) {
- EXPECT_GE(4, num_get_usage_and_quota_for_eviction_);
- switch (num_get_usage_and_quota_for_eviction_) {
- case 2:
- EXPECT_EQ(expected_usage_after_first,
- quota_eviction_handler()->GetUsage());
- if (!origin_to_be_added.first.is_empty())
- quota_eviction_handler()->AddOrigin(origin_to_be_added.first,
- origin_to_be_added.second);
- if (!origin_to_be_accessed.is_empty())
- quota_eviction_handler()->AccessOrigin(origin_to_be_accessed);
- break;
- case 3:
- EXPECT_EQ(expected_usage_after_second,
- quota_eviction_handler()->GetUsage());
- temporary_storage_evictor()->set_repeated_eviction(false);
- break;
- }
- ++num_get_usage_and_quota_for_eviction_;
- }
-
- protected:
- MockQuotaEvictionHandler* quota_eviction_handler() const {
- return static_cast<MockQuotaEvictionHandler*>(
- quota_eviction_handler_.get());
- }
-
- QuotaTemporaryStorageEvictor* temporary_storage_evictor() const {
- return temporary_storage_evictor_.get();
- }
-
- const QuotaTemporaryStorageEvictor::Statistics& statistics() const {
- return temporary_storage_evictor()->statistics_;
- }
-
- void set_repeated_eviction(bool repeated_eviction) const {
- return temporary_storage_evictor_->set_repeated_eviction(repeated_eviction);
- }
-
- int num_get_usage_and_quota_for_eviction() const {
- return num_get_usage_and_quota_for_eviction_;
- }
-
- int64 default_min_available_disk_space_to_start_eviction() const {
- return 1000 * 1000 * 500;
- }
-
- void set_min_available_disk_space_to_start_eviction(int64 value) const {
- temporary_storage_evictor_->set_min_available_disk_space_to_start_eviction(
- value);
- }
-
- void reset_min_available_disk_space_to_start_eviction() const {
- temporary_storage_evictor_->
- reset_min_available_disk_space_to_start_eviction();
- }
-
- base::MessageLoop message_loop_;
- scoped_ptr<MockQuotaEvictionHandler> quota_eviction_handler_;
- scoped_ptr<QuotaTemporaryStorageEvictor> temporary_storage_evictor_;
-
- int num_get_usage_and_quota_for_eviction_;
-
- base::WeakPtrFactory<QuotaTemporaryStorageEvictorTest> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(QuotaTemporaryStorageEvictorTest);
-};
-
-TEST_F(QuotaTemporaryStorageEvictorTest, SimpleEvictionTest) {
- quota_eviction_handler()->AddOrigin(GURL("http://www.z.com"), 3000);
- quota_eviction_handler()->AddOrigin(GURL("http://www.y.com"), 200);
- quota_eviction_handler()->AddOrigin(GURL("http://www.x.com"), 500);
- quota_eviction_handler()->set_quota(4000);
- quota_eviction_handler()->set_available_space(1000000000);
- EXPECT_EQ(3000 + 200 + 500, quota_eviction_handler()->GetUsage());
- set_repeated_eviction(false);
- temporary_storage_evictor()->Start();
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(200 + 500, quota_eviction_handler()->GetUsage());
-
- EXPECT_EQ(0, statistics().num_errors_on_evicting_origin);
- EXPECT_EQ(0, statistics().num_errors_on_getting_usage_and_quota);
- EXPECT_EQ(1, statistics().num_evicted_origins);
- EXPECT_EQ(1, statistics().num_eviction_rounds);
- EXPECT_EQ(0, statistics().num_skipped_eviction_rounds);
-}
-
-TEST_F(QuotaTemporaryStorageEvictorTest, MultipleEvictionTest) {
- quota_eviction_handler()->AddOrigin(GURL("http://www.z.com"), 20);
- quota_eviction_handler()->AddOrigin(GURL("http://www.y.com"), 2900);
- quota_eviction_handler()->AddOrigin(GURL("http://www.x.com"), 450);
- quota_eviction_handler()->AddOrigin(GURL("http://www.w.com"), 400);
- quota_eviction_handler()->set_quota(4000);
- quota_eviction_handler()->set_available_space(1000000000);
- EXPECT_EQ(20 + 2900 + 450 + 400, quota_eviction_handler()->GetUsage());
- set_repeated_eviction(false);
- temporary_storage_evictor()->Start();
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(450 + 400, quota_eviction_handler()->GetUsage());
-
- EXPECT_EQ(0, statistics().num_errors_on_evicting_origin);
- EXPECT_EQ(0, statistics().num_errors_on_getting_usage_and_quota);
- EXPECT_EQ(2, statistics().num_evicted_origins);
- EXPECT_EQ(1, statistics().num_eviction_rounds);
- EXPECT_EQ(0, statistics().num_skipped_eviction_rounds);
-}
-
-TEST_F(QuotaTemporaryStorageEvictorTest, RepeatedEvictionTest) {
- const int64 a_size = 400;
- const int64 b_size = 150;
- const int64 c_size = 120;
- const int64 d_size = 292;
- const int64 initial_total_size = a_size + b_size + c_size + d_size;
- const int64 e_size = 275;
-
- quota_eviction_handler()->AddOrigin(GURL("http://www.d.com"), d_size);
- quota_eviction_handler()->AddOrigin(GURL("http://www.c.com"), c_size);
- quota_eviction_handler()->AddOrigin(GURL("http://www.b.com"), b_size);
- quota_eviction_handler()->AddOrigin(GURL("http://www.a.com"), a_size);
- quota_eviction_handler()->set_quota(1000);
- quota_eviction_handler()->set_available_space(1000000000);
- quota_eviction_handler()->set_task_for_get_usage_and_quota(
- base::Bind(&QuotaTemporaryStorageEvictorTest::TaskForRepeatedEvictionTest,
- weak_factory_.GetWeakPtr(),
- std::make_pair(GURL("http://www.e.com"), e_size), GURL(),
- initial_total_size - d_size,
- initial_total_size - d_size + e_size - c_size));
- EXPECT_EQ(initial_total_size, quota_eviction_handler()->GetUsage());
- temporary_storage_evictor()->Start();
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(initial_total_size - d_size + e_size - c_size - b_size,
- quota_eviction_handler()->GetUsage());
- EXPECT_EQ(5, num_get_usage_and_quota_for_eviction());
-
- EXPECT_EQ(0, statistics().num_errors_on_evicting_origin);
- EXPECT_EQ(0, statistics().num_errors_on_getting_usage_and_quota);
- EXPECT_EQ(3, statistics().num_evicted_origins);
- EXPECT_EQ(2, statistics().num_eviction_rounds);
- EXPECT_EQ(0, statistics().num_skipped_eviction_rounds);
-}
-
-TEST_F(QuotaTemporaryStorageEvictorTest, RepeatedEvictionSkippedTest) {
- const int64 a_size = 400;
- const int64 b_size = 150;
- const int64 c_size = 120;
- const int64 d_size = 292;
- const int64 initial_total_size = a_size + b_size + c_size + d_size;
-
- quota_eviction_handler()->AddOrigin(GURL("http://www.d.com"), d_size);
- quota_eviction_handler()->AddOrigin(GURL("http://www.c.com"), c_size);
- quota_eviction_handler()->AddOrigin(GURL("http://www.b.com"), b_size);
- quota_eviction_handler()->AddOrigin(GURL("http://www.a.com"), a_size);
- quota_eviction_handler()->set_quota(1000);
- quota_eviction_handler()->set_available_space(1000000000);
- quota_eviction_handler()->set_task_for_get_usage_and_quota(
- base::Bind(&QuotaTemporaryStorageEvictorTest::TaskForRepeatedEvictionTest,
- weak_factory_.GetWeakPtr(), std::make_pair(GURL(), 0), GURL(),
- initial_total_size - d_size, initial_total_size - d_size));
- EXPECT_EQ(initial_total_size, quota_eviction_handler()->GetUsage());
- set_repeated_eviction(true);
- temporary_storage_evictor()->Start();
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(initial_total_size - d_size, quota_eviction_handler()->GetUsage());
- EXPECT_EQ(4, num_get_usage_and_quota_for_eviction());
-
- EXPECT_EQ(0, statistics().num_errors_on_evicting_origin);
- EXPECT_EQ(0, statistics().num_errors_on_getting_usage_and_quota);
- EXPECT_EQ(1, statistics().num_evicted_origins);
- EXPECT_EQ(3, statistics().num_eviction_rounds);
- EXPECT_EQ(2, statistics().num_skipped_eviction_rounds);
-}
-
-TEST_F(QuotaTemporaryStorageEvictorTest, RepeatedEvictionWithAccessOriginTest) {
- const int64 a_size = 400;
- const int64 b_size = 150;
- const int64 c_size = 120;
- const int64 d_size = 292;
- const int64 initial_total_size = a_size + b_size + c_size + d_size;
- const int64 e_size = 275;
-
- quota_eviction_handler()->AddOrigin(GURL("http://www.d.com"), d_size);
- quota_eviction_handler()->AddOrigin(GURL("http://www.c.com"), c_size);
- quota_eviction_handler()->AddOrigin(GURL("http://www.b.com"), b_size);
- quota_eviction_handler()->AddOrigin(GURL("http://www.a.com"), a_size);
- quota_eviction_handler()->set_quota(1000);
- quota_eviction_handler()->set_available_space(1000000000);
- quota_eviction_handler()->set_task_for_get_usage_and_quota(
- base::Bind(&QuotaTemporaryStorageEvictorTest::TaskForRepeatedEvictionTest,
- weak_factory_.GetWeakPtr(),
- std::make_pair(GURL("http://www.e.com"), e_size),
- GURL("http://www.c.com"),
- initial_total_size - d_size,
- initial_total_size - d_size + e_size - b_size));
- EXPECT_EQ(initial_total_size, quota_eviction_handler()->GetUsage());
- temporary_storage_evictor()->Start();
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(initial_total_size - d_size + e_size - b_size - a_size,
- quota_eviction_handler()->GetUsage());
- EXPECT_EQ(5, num_get_usage_and_quota_for_eviction());
-
- EXPECT_EQ(0, statistics().num_errors_on_evicting_origin);
- EXPECT_EQ(0, statistics().num_errors_on_getting_usage_and_quota);
- EXPECT_EQ(3, statistics().num_evicted_origins);
- EXPECT_EQ(2, statistics().num_eviction_rounds);
- EXPECT_EQ(0, statistics().num_skipped_eviction_rounds);
-}
-
-TEST_F(QuotaTemporaryStorageEvictorTest, DiskSpaceNonEvictionTest) {
- quota_eviction_handler()->AddOrigin(GURL("http://www.z.com"), 414);
- quota_eviction_handler()->AddOrigin(GURL("http://www.x.com"), 450);
- quota_eviction_handler()->set_quota(10000);
- quota_eviction_handler()->set_available_space(
- default_min_available_disk_space_to_start_eviction() - 350);
- EXPECT_EQ(414 + 450, quota_eviction_handler()->GetUsage());
- reset_min_available_disk_space_to_start_eviction();
- set_repeated_eviction(false);
- temporary_storage_evictor()->Start();
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(414 + 450, quota_eviction_handler()->GetUsage());
-
- EXPECT_EQ(0, statistics().num_errors_on_evicting_origin);
- EXPECT_EQ(0, statistics().num_errors_on_getting_usage_and_quota);
- EXPECT_EQ(0, statistics().num_evicted_origins);
- EXPECT_EQ(1, statistics().num_eviction_rounds);
- EXPECT_EQ(1, statistics().num_skipped_eviction_rounds);
-}
-
-TEST_F(QuotaTemporaryStorageEvictorTest, DiskSpaceEvictionTest) {
- quota_eviction_handler()->AddOrigin(GURL("http://www.z.com"), 294);
- quota_eviction_handler()->AddOrigin(GURL("http://www.y.com"), 120);
- quota_eviction_handler()->AddOrigin(GURL("http://www.x.com"), 150);
- quota_eviction_handler()->AddOrigin(GURL("http://www.w.com"), 300);
- quota_eviction_handler()->set_quota(10000);
- quota_eviction_handler()->set_available_space(
- default_min_available_disk_space_to_start_eviction() - 350);
- EXPECT_EQ(294 + 120 + 150 + 300, quota_eviction_handler()->GetUsage());
- set_min_available_disk_space_to_start_eviction(
- default_min_available_disk_space_to_start_eviction());
- set_repeated_eviction(false);
- temporary_storage_evictor()->Start();
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(150 + 300, quota_eviction_handler()->GetUsage());
-
- EXPECT_EQ(0, statistics().num_errors_on_evicting_origin);
- EXPECT_EQ(0, statistics().num_errors_on_getting_usage_and_quota);
- EXPECT_EQ(2, statistics().num_evicted_origins);
- EXPECT_EQ(1, statistics().num_eviction_rounds);
- EXPECT_EQ(0, statistics().num_skipped_eviction_rounds);
-}
-
-} // namespace quota
diff --git a/chromium/webkit/browser/quota/storage_monitor.cc b/chromium/webkit/browser/quota/storage_monitor.cc
new file mode 100644
index 00000000000..bb56af3225a
--- /dev/null
+++ b/chromium/webkit/browser/quota/storage_monitor.cc
@@ -0,0 +1,379 @@
+// 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 "webkit/browser/quota/storage_monitor.h"
+
+#include <algorithm>
+
+#include "base/stl_util.h"
+#include "net/base/net_util.h"
+#include "webkit/browser/quota/quota_manager.h"
+#include "webkit/common/quota/quota_status_code.h"
+
+namespace quota {
+
+// StorageObserverList:
+
+StorageObserverList::ObserverState::ObserverState()
+ : requires_update(false) {
+}
+
+StorageObserverList::StorageObserverList() {}
+
+StorageObserverList::~StorageObserverList() {}
+
+void StorageObserverList::AddObserver(
+ StorageObserver* observer, const StorageObserver::MonitorParams& params) {
+ ObserverState& observer_state = observers_[observer];
+ observer_state.origin = params.filter.origin;
+ observer_state.rate = params.rate;
+}
+
+void StorageObserverList::RemoveObserver(StorageObserver* observer) {
+ observers_.erase(observer);
+}
+
+int StorageObserverList::ObserverCount() const {
+ return observers_.size();
+}
+
+void StorageObserverList::OnStorageChange(const StorageObserver::Event& event) {
+ for (StorageObserverStateMap::iterator it = observers_.begin();
+ it != observers_.end(); ++it) {
+ it->second.requires_update = true;
+ }
+
+ MaybeDispatchEvent(event);
+}
+
+void StorageObserverList::MaybeDispatchEvent(
+ const StorageObserver::Event& event) {
+ notification_timer_.Stop();
+ base::TimeDelta min_delay = base::TimeDelta::Max();
+ bool all_observers_notified = true;
+
+ for (StorageObserverStateMap::iterator it = observers_.begin();
+ it != observers_.end(); ++it) {
+ if (!it->second.requires_update)
+ continue;
+
+ base::TimeTicks current_time = base::TimeTicks::Now();
+ base::TimeDelta delta = current_time - it->second.last_notification_time;
+ if (it->second.last_notification_time.is_null() ||
+ delta >= it->second.rate) {
+ it->second.requires_update = false;
+ it->second.last_notification_time = current_time;
+
+ if (it->second.origin == event.filter.origin) {
+ it->first->OnStorageEvent(event);
+ } else {
+ // When the quota and usage of an origin is requested, QuotaManager
+ // returns the quota and usage of the host. Multiple origins can map to
+ // to the same host, so ensure the |origin| field in the dispatched
+ // event matches the |origin| specified by the observer when it was
+ // registered.
+ StorageObserver::Event dispatch_event(event);
+ dispatch_event.filter.origin = it->second.origin;
+ it->first->OnStorageEvent(dispatch_event);
+ }
+ } else {
+ all_observers_notified = false;
+ base::TimeDelta delay = it->second.rate - delta;
+ if (delay < min_delay)
+ min_delay = delay;
+ }
+ }
+
+ // We need to respect the notification rate specified by observers. So if it
+ // is too soon to dispatch an event to an observer, save the event and
+ // dispatch it after a delay. If we simply drop the event, another one may
+ // not arrive anytime soon and the observer will miss the most recent event.
+ if (!all_observers_notified) {
+ pending_event_ = event;
+ notification_timer_.Start(
+ FROM_HERE,
+ min_delay,
+ this,
+ &StorageObserverList::DispatchPendingEvent);
+ }
+}
+
+void StorageObserverList::ScheduleUpdateForObserver(StorageObserver* observer) {
+ DCHECK(ContainsKey(observers_, observer));
+ observers_[observer].requires_update = true;
+}
+
+void StorageObserverList::DispatchPendingEvent() {
+ MaybeDispatchEvent(pending_event_);
+}
+
+
+// HostStorageObservers:
+
+HostStorageObservers::HostStorageObservers(QuotaManager* quota_manager)
+ : quota_manager_(quota_manager),
+ initialized_(false),
+ initializing_(false),
+ event_occurred_before_init_(false),
+ usage_deltas_during_init_(0),
+ cached_usage_(0),
+ cached_quota_(0),
+ weak_factory_(this) {
+}
+
+HostStorageObservers::~HostStorageObservers() {}
+
+void HostStorageObservers::AddObserver(
+ StorageObserver* observer,
+ const StorageObserver::MonitorParams& params) {
+ observers_.AddObserver(observer, params);
+
+ if (!params.dispatch_initial_state)
+ return;
+
+ if (initialized_) {
+ StorageObserver::Event event(params.filter,
+ std::max<int64>(cached_usage_, 0),
+ std::max<int64>(cached_quota_, 0));
+ observer->OnStorageEvent(event);
+ return;
+ }
+
+ // Ensure the observer receives the initial storage state once initialization
+ // is complete.
+ observers_.ScheduleUpdateForObserver(observer);
+ StartInitialization(params.filter);
+}
+
+void HostStorageObservers::RemoveObserver(StorageObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+bool HostStorageObservers::ContainsObservers() const {
+ return observers_.ObserverCount() > 0;
+}
+
+void HostStorageObservers::NotifyUsageChange(
+ const StorageObserver::Filter& filter, int64 delta) {
+ if (initialized_) {
+ cached_usage_ += delta;
+ DispatchEvent(filter, true);
+ return;
+ }
+
+ // If a storage change occurs before initialization, ensure all observers will
+ // receive an event once initialization is complete.
+ event_occurred_before_init_ = true;
+
+ // During QuotaManager::GetUsageAndQuotaForWebApps(), cached data is read
+ // synchronously, but other data may be retrieved asynchronously. A usage
+ // change may occur between the function call and callback. These deltas need
+ // to be added to the usage received by GotHostUsageAndQuota() to ensure
+ // |cached_usage_| is correctly initialized.
+ if (initializing_) {
+ usage_deltas_during_init_ += delta;
+ return;
+ }
+
+ StartInitialization(filter);
+}
+
+void HostStorageObservers::StartInitialization(
+ const StorageObserver::Filter& filter) {
+ if (initialized_ || initializing_)
+ return;
+
+ initializing_ = true;
+ quota_manager_->GetUsageAndQuotaForWebApps(
+ filter.origin,
+ filter.storage_type,
+ base::Bind(&HostStorageObservers::GotHostUsageAndQuota,
+ weak_factory_.GetWeakPtr(),
+ filter));
+}
+
+void HostStorageObservers::GotHostUsageAndQuota(
+ const StorageObserver::Filter& filter,
+ QuotaStatusCode status,
+ int64 usage,
+ int64 quota) {
+ initializing_ = false;
+ if (status != kQuotaStatusOk)
+ return;
+
+ initialized_ = true;
+ cached_quota_ = quota;
+ cached_usage_ = usage + usage_deltas_during_init_;
+ DispatchEvent(filter, event_occurred_before_init_);
+}
+
+void HostStorageObservers::DispatchEvent(
+ const StorageObserver::Filter& filter, bool is_update) {
+ StorageObserver::Event event(filter,
+ std::max<int64>(cached_usage_, 0),
+ std::max<int64>(cached_quota_, 0));
+ if (is_update)
+ observers_.OnStorageChange(event);
+ else
+ observers_.MaybeDispatchEvent(event);
+}
+
+
+// StorageTypeObservers:
+
+StorageTypeObservers::StorageTypeObservers(QuotaManager* quota_manager)
+ : quota_manager_(quota_manager) {
+}
+
+StorageTypeObservers::~StorageTypeObservers() {
+ STLDeleteValues(&host_observers_map_);
+}
+
+void StorageTypeObservers::AddObserver(
+ StorageObserver* observer, const StorageObserver::MonitorParams& params) {
+ std::string host = net::GetHostOrSpecFromURL(params.filter.origin);
+ if (host.empty())
+ return;
+
+ HostStorageObservers* host_observers = NULL;
+ HostObserversMap::iterator it = host_observers_map_.find(host);
+ if (it == host_observers_map_.end()) {
+ host_observers = new HostStorageObservers(quota_manager_);
+ host_observers_map_[host] = host_observers;
+ } else {
+ host_observers = it->second;
+ }
+
+ host_observers->AddObserver(observer, params);
+}
+
+void StorageTypeObservers::RemoveObserver(StorageObserver* observer) {
+ for (HostObserversMap::iterator it = host_observers_map_.begin();
+ it != host_observers_map_.end(); ) {
+ it->second->RemoveObserver(observer);
+ if (!it->second->ContainsObservers()) {
+ delete it->second;
+ host_observers_map_.erase(it++);
+ } else {
+ ++it;
+ }
+ }
+}
+
+void StorageTypeObservers::RemoveObserverForFilter(
+ StorageObserver* observer, const StorageObserver::Filter& filter) {
+ std::string host = net::GetHostOrSpecFromURL(filter.origin);
+ HostObserversMap::iterator it = host_observers_map_.find(host);
+ if (it == host_observers_map_.end())
+ return;
+
+ it->second->RemoveObserver(observer);
+ if (!it->second->ContainsObservers()) {
+ delete it->second;
+ host_observers_map_.erase(it);
+ }
+}
+
+const HostStorageObservers* StorageTypeObservers::GetHostObservers(
+ const std::string& host) const {
+ HostObserversMap::const_iterator it = host_observers_map_.find(host);
+ if (it != host_observers_map_.end())
+ return it->second;
+
+ return NULL;
+}
+
+void StorageTypeObservers::NotifyUsageChange(
+ const StorageObserver::Filter& filter, int64 delta) {
+ std::string host = net::GetHostOrSpecFromURL(filter.origin);
+ HostObserversMap::iterator it = host_observers_map_.find(host);
+ if (it == host_observers_map_.end())
+ return;
+
+ it->second->NotifyUsageChange(filter, delta);
+}
+
+
+// StorageMonitor:
+
+StorageMonitor::StorageMonitor(QuotaManager* quota_manager)
+ : quota_manager_(quota_manager) {
+}
+
+StorageMonitor::~StorageMonitor() {
+ STLDeleteValues(&storage_type_observers_map_);
+}
+
+void StorageMonitor::AddObserver(
+ StorageObserver* observer, const StorageObserver::MonitorParams& params) {
+ DCHECK(observer);
+
+ // Check preconditions.
+ if (params.filter.storage_type == kStorageTypeUnknown ||
+ params.filter.storage_type == kStorageTypeQuotaNotManaged ||
+ params.filter.origin.is_empty()) {
+ NOTREACHED();
+ return;
+ }
+
+ StorageTypeObservers* type_observers = NULL;
+ StorageTypeObserversMap::iterator it =
+ storage_type_observers_map_.find(params.filter.storage_type);
+ if (it == storage_type_observers_map_.end()) {
+ type_observers = new StorageTypeObservers(quota_manager_);
+ storage_type_observers_map_[params.filter.storage_type] = type_observers;
+ } else {
+ type_observers = it->second;
+ }
+
+ type_observers->AddObserver(observer, params);
+}
+
+void StorageMonitor::RemoveObserver(StorageObserver* observer) {
+ for (StorageTypeObserversMap::iterator it =
+ storage_type_observers_map_.begin();
+ it != storage_type_observers_map_.end(); ++it) {
+ it->second->RemoveObserver(observer);
+ }
+}
+
+void StorageMonitor::RemoveObserverForFilter(
+ StorageObserver* observer, const StorageObserver::Filter& filter) {
+ StorageTypeObserversMap::iterator it =
+ storage_type_observers_map_.find(filter.storage_type);
+ if (it == storage_type_observers_map_.end())
+ return;
+
+ it->second->RemoveObserverForFilter(observer, filter);
+}
+
+const StorageTypeObservers* StorageMonitor::GetStorageTypeObservers(
+ StorageType storage_type) const {
+ StorageTypeObserversMap::const_iterator it =
+ storage_type_observers_map_.find(storage_type);
+ if (it != storage_type_observers_map_.end())
+ return it->second;
+
+ return NULL;
+}
+
+void StorageMonitor::NotifyUsageChange(
+ const StorageObserver::Filter& filter, int64 delta) {
+ // Check preconditions.
+ if (filter.storage_type == kStorageTypeUnknown ||
+ filter.storage_type == kStorageTypeQuotaNotManaged ||
+ filter.origin.is_empty()) {
+ NOTREACHED();
+ return;
+ }
+
+ StorageTypeObserversMap::iterator it =
+ storage_type_observers_map_.find(filter.storage_type);
+ if (it == storage_type_observers_map_.end())
+ return;
+
+ it->second->NotifyUsageChange(filter, delta);
+}
+
+} // namespace quota
diff --git a/chromium/webkit/browser/quota/storage_monitor.h b/chromium/webkit/browser/quota/storage_monitor.h
new file mode 100644
index 00000000000..e52fd18de55
--- /dev/null
+++ b/chromium/webkit/browser/quota/storage_monitor.h
@@ -0,0 +1,180 @@
+// 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 WEBKIT_BROWSER_QUOTA_STORAGE_MONITOR_H_
+#define WEBKIT_BROWSER_QUOTA_STORAGE_MONITOR_H_
+
+#include <map>
+
+#include "base/memory/weak_ptr.h"
+#include "base/time/time.h"
+#include "base/timer/timer.h"
+#include "webkit/browser/quota/storage_observer.h"
+
+namespace content {
+class StorageMonitorTestBase;
+}
+
+namespace quota {
+
+class QuotaManager;
+
+// This class dispatches storage events to observers of a common
+// StorageObserver::Filter.
+class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE StorageObserverList {
+ public:
+ StorageObserverList();
+ virtual ~StorageObserverList();
+
+ // Adds/removes an observer.
+ void AddObserver(StorageObserver* observer,
+ const StorageObserver::MonitorParams& params);
+ void RemoveObserver(StorageObserver* observer);
+
+ // Returns the number of observers.
+ int ObserverCount() const;
+
+ // Forwards a storage change to observers. The event may be dispatched
+ // immediately to an observer or after a delay, depending on the desired event
+ // rate of the observer.
+ void OnStorageChange(const StorageObserver::Event& event);
+
+ // Dispatch an event to observers that require it.
+ void MaybeDispatchEvent(const StorageObserver::Event& event);
+
+ // Ensure the specified observer receives the next dispatched event.
+ void ScheduleUpdateForObserver(StorageObserver* observer);
+
+ private:
+ struct WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE ObserverState {
+ GURL origin;
+ base::TimeTicks last_notification_time;
+ base::TimeDelta rate;
+ bool requires_update;
+
+ ObserverState();
+ };
+ typedef std::map<StorageObserver*, ObserverState> StorageObserverStateMap;
+
+ void DispatchPendingEvent();
+
+ StorageObserverStateMap observers_;
+ base::OneShotTimer<StorageObserverList> notification_timer_;
+ StorageObserver::Event pending_event_;
+
+ friend class content::StorageMonitorTestBase;
+
+ DISALLOW_COPY_AND_ASSIGN(StorageObserverList);
+};
+
+
+// Manages the storage observers of a common host. Caches the usage and quota of
+// the host to avoid accumulating for every change.
+class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE HostStorageObservers {
+ public:
+ explicit HostStorageObservers(QuotaManager* quota_manager);
+ virtual ~HostStorageObservers();
+
+ bool is_initialized() const { return initialized_; }
+
+ // Adds/removes an observer.
+ void AddObserver(
+ StorageObserver* observer,
+ const StorageObserver::MonitorParams& params);
+ void RemoveObserver(StorageObserver* observer);
+ bool ContainsObservers() const;
+
+ // Handles a usage change.
+ void NotifyUsageChange(const StorageObserver::Filter& filter, int64 delta);
+
+ private:
+ void StartInitialization(const StorageObserver::Filter& filter);
+ void GotHostUsageAndQuota(const StorageObserver::Filter& filter,
+ QuotaStatusCode status,
+ int64 usage,
+ int64 quota);
+ void DispatchEvent(const StorageObserver::Filter& filter, bool is_update);
+
+ QuotaManager* quota_manager_;
+ StorageObserverList observers_;
+
+ // Flags used during initialization of the cached properties.
+ bool initialized_;
+ bool initializing_;
+ bool event_occurred_before_init_;
+ int64 usage_deltas_during_init_;
+
+ // Cached accumulated usage and quota for the host.
+ int64 cached_usage_;
+ int64 cached_quota_;
+
+ base::WeakPtrFactory<HostStorageObservers> weak_factory_;
+
+ friend class content::StorageMonitorTestBase;
+
+ DISALLOW_COPY_AND_ASSIGN(HostStorageObservers);
+};
+
+
+// Manages the observers of a common storage type.
+class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE StorageTypeObservers {
+ public:
+ explicit StorageTypeObservers(QuotaManager* quota_manager);
+ virtual ~StorageTypeObservers();
+
+ // Adds and removes an observer.
+ void AddObserver(StorageObserver* observer,
+ const StorageObserver::MonitorParams& params);
+ void RemoveObserver(StorageObserver* observer);
+ void RemoveObserverForFilter(StorageObserver* observer,
+ const StorageObserver::Filter& filter);
+
+ // Returns the observers of a specific host.
+ const HostStorageObservers* GetHostObservers(const std::string& host) const;
+
+ // Handles a usage change.
+ void NotifyUsageChange(const StorageObserver::Filter& filter, int64 delta);
+
+ private:
+ typedef std::map<std::string, HostStorageObservers*> HostObserversMap;
+
+ QuotaManager* quota_manager_;
+ HostObserversMap host_observers_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(StorageTypeObservers);
+};
+
+
+// Storage monitor manages observers and dispatches storage events to them.
+class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE StorageMonitor {
+ public:
+ explicit StorageMonitor(QuotaManager* quota_manager);
+ virtual ~StorageMonitor();
+
+ // Adds and removes an observer.
+ void AddObserver(StorageObserver* observer,
+ const StorageObserver::MonitorParams& params);
+ void RemoveObserver(StorageObserver* observer);
+ void RemoveObserverForFilter(StorageObserver* observer,
+ const StorageObserver::Filter& filter);
+
+ // Returns the observers of a specific storage type.
+ const StorageTypeObservers* GetStorageTypeObservers(
+ StorageType storage_type) const;
+
+ // Handles a usage change.
+ void NotifyUsageChange(const StorageObserver::Filter& filter, int64 delta);
+
+ private:
+ typedef std::map<StorageType, StorageTypeObservers*> StorageTypeObserversMap;
+
+ QuotaManager* quota_manager_;
+ StorageTypeObserversMap storage_type_observers_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(StorageMonitor);
+};
+
+} // namespace quota
+
+#endif // WEBKIT_BROWSER_QUOTA_STORAGE_MONITOR_H_
diff --git a/chromium/webkit/browser/quota/storage_observer.cc b/chromium/webkit/browser/quota/storage_observer.cc
new file mode 100644
index 00000000000..907ed59e323
--- /dev/null
+++ b/chromium/webkit/browser/quota/storage_observer.cc
@@ -0,0 +1,65 @@
+// 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 "webkit/browser/quota/storage_observer.h"
+
+namespace quota {
+
+// StorageObserver::Filter
+
+StorageObserver::Filter::Filter()
+ : storage_type(kStorageTypeUnknown) {
+}
+
+StorageObserver::Filter::Filter(StorageType storage_type, const GURL& origin)
+ : storage_type(storage_type), origin(origin) {
+}
+
+bool StorageObserver::Filter::operator==(const Filter& other) const {
+ return storage_type == other.storage_type &&
+ origin == other.origin;
+}
+
+// StorageObserver::MonitorParams
+
+StorageObserver::MonitorParams::MonitorParams()
+ : dispatch_initial_state(false) {
+}
+
+StorageObserver::MonitorParams::MonitorParams(
+ StorageType storage_type,
+ const GURL& origin,
+ const base::TimeDelta& rate,
+ bool get_initial_state)
+ : filter(storage_type, origin),
+ rate(rate),
+ dispatch_initial_state(get_initial_state) {
+}
+
+StorageObserver::MonitorParams::MonitorParams(
+ const Filter& filter,
+ const base::TimeDelta& rate,
+ bool get_initial_state)
+ : filter(filter),
+ rate(rate),
+ dispatch_initial_state(get_initial_state) {
+}
+
+// StorageObserver::Event
+
+StorageObserver::Event::Event()
+ : usage(0), quota(0) {
+}
+
+StorageObserver::Event::Event(const Filter& filter, int64 usage, int64 quota)
+ : filter(filter), usage(usage), quota(quota) {
+}
+
+bool StorageObserver::Event::operator==(const Event& other) const {
+ return filter == other.filter &&
+ usage == other.usage &&
+ quota == other.quota;
+}
+
+} // namespace quota
diff --git a/chromium/webkit/browser/quota/storage_observer.h b/chromium/webkit/browser/quota/storage_observer.h
new file mode 100644
index 00000000000..bc6389d8b50
--- /dev/null
+++ b/chromium/webkit/browser/quota/storage_observer.h
@@ -0,0 +1,79 @@
+// 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 WEBKIT_BROWSER_QUOTA_STORAGE_OBSERVER_H_
+#define WEBKIT_BROWSER_QUOTA_STORAGE_OBSERVER_H_
+
+#include "base/basictypes.h"
+#include "base/time/time.h"
+#include "url/gurl.h"
+#include "webkit/browser/quota/quota_client.h"
+#include "webkit/common/quota/quota_types.h"
+
+namespace quota {
+
+// This interface is implemented by observers that wish to monitor storage
+// events, such as changes in quota or usage.
+class WEBKIT_STORAGE_BROWSER_EXPORT StorageObserver {
+ public:
+ struct WEBKIT_STORAGE_BROWSER_EXPORT Filter {
+ // The storage type to monitor. This must not be kStorageTypeUnknown or
+ // kStorageTypeQuotaNotManaged.
+ StorageType storage_type;
+
+ // The origin to monitor usage for. Must be specified.
+ GURL origin;
+
+ Filter();
+ Filter(StorageType storage_type, const GURL& origin);
+ bool operator==(const Filter& other) const;
+ };
+
+ struct WEBKIT_STORAGE_BROWSER_EXPORT MonitorParams {
+ // Storage type and origin to monitor.
+ Filter filter;
+
+ // The rate at which storage events will be fired. Events will be fired at
+ // approximately this rate, or when a storage status change has been
+ // detected, whichever is the least frequent.
+ base::TimeDelta rate;
+
+ // If set to true, the observer will be dispatched an event when added.
+ bool dispatch_initial_state;
+
+ MonitorParams();
+ MonitorParams(StorageType storage_type,
+ const GURL& origin,
+ const base::TimeDelta& rate,
+ bool get_initial_state);
+ MonitorParams(const Filter& filter,
+ const base::TimeDelta& rate,
+ bool get_initial_state);
+ };
+
+ struct WEBKIT_STORAGE_BROWSER_EXPORT Event {
+ // The storage type and origin monitored.
+ Filter filter;
+
+ // The current usage corresponding to the filter.
+ int64 usage;
+
+ // The quota corresponding to the filter.
+ int64 quota;
+
+ Event();
+ Event(const Filter& filter, int64 usage, int64 quota);
+ bool operator==(const Event& other) const;
+ };
+
+ // Will be called on the IO thread when a storage event occurs.
+ virtual void OnStorageEvent(const Event& event) = 0;
+
+ protected:
+ virtual ~StorageObserver() {}
+};
+
+} // namespace quota
+
+#endif // WEBKIT_BROWSER_QUOTA_STORAGE_OBSERVER_H_
diff --git a/chromium/webkit/browser/quota/usage_tracker.cc b/chromium/webkit/browser/quota/usage_tracker.cc
index 57b5e0d24ea..2e4659f0e48 100644
--- a/chromium/webkit/browser/quota/usage_tracker.cc
+++ b/chromium/webkit/browser/quota/usage_tracker.cc
@@ -14,6 +14,8 @@
#include "base/message_loop/message_loop_proxy.h"
#include "base/stl_util.h"
#include "net/base/net_util.h"
+#include "webkit/browser/quota/storage_monitor.h"
+#include "webkit/browser/quota/storage_observer.h"
namespace quota {
@@ -36,8 +38,6 @@ void DidGetHostUsage(const UsageCallback& callback,
callback.Run(limited_usage + unlimited_usage);
}
-void NoopHostUsageCallback(int64 usage) {}
-
bool EraseOriginFromOriginSet(OriginSetByHost* origins_by_host,
const std::string& host,
const GURL& origin) {
@@ -72,15 +72,18 @@ void DidGetGlobalUsageForLimitedGlobalUsage(const UsageCallback& callback,
UsageTracker::UsageTracker(const QuotaClientList& clients,
StorageType type,
- SpecialStoragePolicy* special_storage_policy)
+ SpecialStoragePolicy* special_storage_policy,
+ StorageMonitor* storage_monitor)
: type_(type),
+ storage_monitor_(storage_monitor),
weak_factory_(this) {
for (QuotaClientList::const_iterator iter = clients.begin();
iter != clients.end();
++iter) {
if ((*iter)->DoesSupport(type)) {
client_tracker_map_[(*iter)->id()] =
- new ClientUsageTracker(this, *iter, type, special_storage_policy);
+ new ClientUsageTracker(this, *iter, type, special_storage_policy,
+ storage_monitor_);
}
}
}
@@ -271,10 +274,12 @@ void UsageTracker::AccumulateClientHostUsage(AccumulateInfo* info,
ClientUsageTracker::ClientUsageTracker(
UsageTracker* tracker, QuotaClient* client, StorageType type,
- SpecialStoragePolicy* special_storage_policy)
+ SpecialStoragePolicy* special_storage_policy,
+ StorageMonitor* storage_monitor)
: tracker_(tracker),
client_(client),
type_(type),
+ storage_monitor_(storage_monitor),
global_limited_usage_(0),
global_unlimited_usage_(0),
global_usage_retrieved_(false),
@@ -364,11 +369,19 @@ void ClientUsageTracker::UpdateUsageCache(
global_limited_usage_ += delta;
DCHECK_GE(cached_usage_by_host_[host][origin], 0);
DCHECK_GE(global_limited_usage_, 0);
+
+ // Notify the usage monitor that usage has changed. The storage monitor may
+ // be NULL during tests.
+ if (storage_monitor_) {
+ StorageObserver::Filter filter(type_, origin);
+ storage_monitor_->NotifyUsageChange(filter, delta);
+ }
return;
}
// We don't know about this host yet, so populate our cache for it.
- GetHostUsage(host, base::Bind(&NoopHostUsageCallback));
+ GetHostUsage(host, base::Bind(&ClientUsageTracker::DidGetHostUsageAfterUpdate,
+ AsWeakPtr(), origin));
}
void ClientUsageTracker::GetCachedHostsUsage(
@@ -549,6 +562,15 @@ void ClientUsageTracker::AccumulateOriginUsage(AccumulateInfo* info,
host, MakeTuple(info->limited_usage, info->unlimited_usage));
}
+void ClientUsageTracker::DidGetHostUsageAfterUpdate(
+ const GURL& origin, int64 usage) {
+ if (!storage_monitor_)
+ return;
+
+ StorageObserver::Filter filter(type_, origin);
+ storage_monitor_->NotifyUsageChange(filter, 0);
+}
+
void ClientUsageTracker::AddCachedOrigin(
const GURL& origin, int64 new_usage) {
DCHECK(IsUsageCacheEnabledForOrigin(origin));
diff --git a/chromium/webkit/browser/quota/usage_tracker.h b/chromium/webkit/browser/quota/usage_tracker.h
index 6e10817c329..91bd18c5f88 100644
--- a/chromium/webkit/browser/quota/usage_tracker.h
+++ b/chromium/webkit/browser/quota/usage_tracker.h
@@ -25,6 +25,7 @@
namespace quota {
class ClientUsageTracker;
+class StorageMonitor;
// A helper class that gathers and tracks the amount of data stored in
// all quota clients.
@@ -32,7 +33,8 @@ class ClientUsageTracker;
class WEBKIT_STORAGE_BROWSER_EXPORT UsageTracker : public QuotaTaskObserver {
public:
UsageTracker(const QuotaClientList& clients, StorageType type,
- SpecialStoragePolicy* special_storage_policy);
+ SpecialStoragePolicy* special_storage_policy,
+ StorageMonitor* storage_monitor);
virtual ~UsageTracker();
StorageType type() const { return type_; }
@@ -82,6 +84,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT UsageTracker : public QuotaTaskObserver {
GlobalUsageCallbackQueue global_usage_callbacks_;
HostUsageCallbackMap host_usage_callbacks_;
+ StorageMonitor* storage_monitor_;
+
base::WeakPtrFactory<UsageTracker> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(UsageTracker);
};
@@ -101,7 +105,8 @@ class ClientUsageTracker : public SpecialStoragePolicy::Observer,
ClientUsageTracker(UsageTracker* tracker,
QuotaClient* client,
StorageType type,
- SpecialStoragePolicy* special_storage_policy);
+ SpecialStoragePolicy* special_storage_policy,
+ StorageMonitor* storage_monitor);
virtual ~ClientUsageTracker();
void GetGlobalLimitedUsage(const UsageCallback& callback);
@@ -152,6 +157,8 @@ class ClientUsageTracker : public SpecialStoragePolicy::Observer,
const GURL& origin,
int64 usage);
+ void DidGetHostUsageAfterUpdate(const GURL& origin, int64 usage);
+
// Methods used by our GatherUsage tasks, as a task makes progress
// origins and hosts are added incrementally to the cache.
void AddCachedOrigin(const GURL& origin, int64 usage);
@@ -171,6 +178,7 @@ class ClientUsageTracker : public SpecialStoragePolicy::Observer,
UsageTracker* tracker_;
QuotaClient* client_;
const StorageType type_;
+ StorageMonitor* storage_monitor_;
int64 global_limited_usage_;
int64 global_unlimited_usage_;
diff --git a/chromium/webkit/browser/quota/usage_tracker_unittest.cc b/chromium/webkit/browser/quota/usage_tracker_unittest.cc
deleted file mode 100644
index 4eaf68b1b2f..00000000000
--- a/chromium/webkit/browser/quota/usage_tracker_unittest.cc
+++ /dev/null
@@ -1,328 +0,0 @@
-// Copyright 2013 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 "base/bind.h"
-#include "base/run_loop.h"
-#include "net/base/net_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/browser/quota/mock_special_storage_policy.h"
-#include "webkit/browser/quota/usage_tracker.h"
-
-namespace quota {
-
-namespace {
-
-void DidGetGlobalUsage(bool* done,
- int64* usage_out,
- int64* unlimited_usage_out,
- int64 usage,
- int64 unlimited_usage) {
- EXPECT_FALSE(*done);
- *done = true;
- *usage_out = usage;
- *unlimited_usage_out = unlimited_usage;
-}
-
-void DidGetUsage(bool* done,
- int64* usage_out,
- int64 usage) {
- EXPECT_FALSE(*done);
- *done = true;
- *usage_out = usage;
-}
-
-} // namespace
-
-class MockQuotaClient : public QuotaClient {
- public:
- MockQuotaClient() {}
- virtual ~MockQuotaClient() {}
-
- virtual ID id() const OVERRIDE {
- return kFileSystem;
- }
-
- virtual void OnQuotaManagerDestroyed() OVERRIDE {}
-
- virtual void GetOriginUsage(const GURL& origin,
- StorageType type,
- const GetUsageCallback& callback) OVERRIDE {
- EXPECT_EQ(kStorageTypeTemporary, type);
- int64 usage = GetUsage(origin);
- base::MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(callback, usage));
- }
-
- virtual void GetOriginsForType(StorageType type,
- const GetOriginsCallback& callback) OVERRIDE {
- EXPECT_EQ(kStorageTypeTemporary, type);
- std::set<GURL> origins;
- for (UsageMap::const_iterator itr = usage_map_.begin();
- itr != usage_map_.end(); ++itr) {
- origins.insert(itr->first);
- }
- base::MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(callback, origins));
- }
-
- virtual void GetOriginsForHost(StorageType type,
- const std::string& host,
- const GetOriginsCallback& callback) OVERRIDE {
- EXPECT_EQ(kStorageTypeTemporary, type);
- std::set<GURL> origins;
- for (UsageMap::const_iterator itr = usage_map_.begin();
- itr != usage_map_.end(); ++itr) {
- if (net::GetHostOrSpecFromURL(itr->first) == host)
- origins.insert(itr->first);
- }
- base::MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(callback, origins));
- }
-
- virtual void DeleteOriginData(const GURL& origin,
- StorageType type,
- const DeletionCallback& callback) OVERRIDE {
- EXPECT_EQ(kStorageTypeTemporary, type);
- usage_map_.erase(origin);
- base::MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(callback, kQuotaStatusOk));
- }
-
- virtual bool DoesSupport(quota::StorageType type) const OVERRIDE {
- return type == quota::kStorageTypeTemporary;
- }
-
- int64 GetUsage(const GURL& origin) {
- UsageMap::const_iterator found = usage_map_.find(origin);
- if (found == usage_map_.end())
- return 0;
- return found->second;
- }
-
- void SetUsage(const GURL& origin, int64 usage) {
- usage_map_[origin] = usage;
- }
-
- int64 UpdateUsage(const GURL& origin, int64 delta) {
- return usage_map_[origin] += delta;
- }
-
- private:
- typedef std::map<GURL, int64> UsageMap;
-
- UsageMap usage_map_;
-
- DISALLOW_COPY_AND_ASSIGN(MockQuotaClient);
-};
-
-class UsageTrackerTest : public testing::Test {
- public:
- UsageTrackerTest()
- : storage_policy_(new MockSpecialStoragePolicy()),
- usage_tracker_(GetUsageTrackerList(), kStorageTypeTemporary,
- storage_policy_.get()) {
- }
-
- virtual ~UsageTrackerTest() {}
-
- UsageTracker* usage_tracker() {
- return &usage_tracker_;
- }
-
- void UpdateUsage(const GURL& origin, int64 delta) {
- quota_client_.UpdateUsage(origin, delta);
- usage_tracker_.UpdateUsageCache(quota_client_.id(), origin, delta);
- base::RunLoop().RunUntilIdle();
- }
-
- void UpdateUsageWithoutNotification(const GURL& origin, int64 delta) {
- quota_client_.UpdateUsage(origin, delta);
- }
-
- void GetGlobalLimitedUsage(int64* limited_usage) {
- bool done = false;
- usage_tracker_.GetGlobalLimitedUsage(base::Bind(
- &DidGetUsage, &done, limited_usage));
- base::RunLoop().RunUntilIdle();
-
- EXPECT_TRUE(done);
- }
-
- void GetGlobalUsage(int64* usage, int64* unlimited_usage) {
- bool done = false;
- usage_tracker_.GetGlobalUsage(base::Bind(
- &DidGetGlobalUsage,
- &done, usage, unlimited_usage));
- base::RunLoop().RunUntilIdle();
-
- EXPECT_TRUE(done);
- }
-
- void GetHostUsage(const std::string& host, int64* usage) {
- bool done = false;
- usage_tracker_.GetHostUsage(host, base::Bind(&DidGetUsage, &done, usage));
- base::RunLoop().RunUntilIdle();
-
- EXPECT_TRUE(done);
- }
-
- void GrantUnlimitedStoragePolicy(const GURL& origin) {
- if (!storage_policy_->IsStorageUnlimited(origin)) {
- storage_policy_->AddUnlimited(origin);
- storage_policy_->NotifyGranted(
- origin, SpecialStoragePolicy::STORAGE_UNLIMITED);
- }
- }
-
- void RevokeUnlimitedStoragePolicy(const GURL& origin) {
- if (storage_policy_->IsStorageUnlimited(origin)) {
- storage_policy_->RemoveUnlimited(origin);
- storage_policy_->NotifyRevoked(
- origin, SpecialStoragePolicy::STORAGE_UNLIMITED);
- }
- }
-
- void SetUsageCacheEnabled(const GURL& origin, bool enabled) {
- usage_tracker_.SetUsageCacheEnabled(
- quota_client_.id(), origin, enabled);
- }
-
- private:
- QuotaClientList GetUsageTrackerList() {
- QuotaClientList client_list;
- client_list.push_back(&quota_client_);
- return client_list;
- }
-
- base::MessageLoop message_loop_;
-
- scoped_refptr<MockSpecialStoragePolicy> storage_policy_;
- MockQuotaClient quota_client_;
- UsageTracker usage_tracker_;
-
- DISALLOW_COPY_AND_ASSIGN(UsageTrackerTest);
-};
-
-TEST_F(UsageTrackerTest, GrantAndRevokeUnlimitedStorage) {
- int64 usage = 0;
- int64 unlimited_usage = 0;
- int64 host_usage = 0;
- GetGlobalUsage(&usage, &unlimited_usage);
- EXPECT_EQ(0, usage);
- EXPECT_EQ(0, unlimited_usage);
-
- const GURL origin("http://example.com");
- const std::string host(net::GetHostOrSpecFromURL(origin));
-
- UpdateUsage(origin, 100);
- GetGlobalUsage(&usage, &unlimited_usage);
- GetHostUsage(host, &host_usage);
- EXPECT_EQ(100, usage);
- EXPECT_EQ(0, unlimited_usage);
- EXPECT_EQ(100, host_usage);
-
- GrantUnlimitedStoragePolicy(origin);
- GetGlobalUsage(&usage, &unlimited_usage);
- GetHostUsage(host, &host_usage);
- EXPECT_EQ(100, usage);
- EXPECT_EQ(100, unlimited_usage);
- EXPECT_EQ(100, host_usage);
-
- RevokeUnlimitedStoragePolicy(origin);
- GetGlobalUsage(&usage, &unlimited_usage);
- GetHostUsage(host, &host_usage);
- EXPECT_EQ(100, usage);
- EXPECT_EQ(0, unlimited_usage);
- EXPECT_EQ(100, host_usage);
-}
-
-TEST_F(UsageTrackerTest, CacheDisabledClientTest) {
- int64 usage = 0;
- int64 unlimited_usage = 0;
- int64 host_usage = 0;
-
- const GURL origin("http://example.com");
- const std::string host(net::GetHostOrSpecFromURL(origin));
-
- UpdateUsage(origin, 100);
- GetGlobalUsage(&usage, &unlimited_usage);
- GetHostUsage(host, &host_usage);
- EXPECT_EQ(100, usage);
- EXPECT_EQ(0, unlimited_usage);
- EXPECT_EQ(100, host_usage);
-
- UpdateUsageWithoutNotification(origin, 100);
- GetGlobalUsage(&usage, &unlimited_usage);
- GetHostUsage(host, &host_usage);
- EXPECT_EQ(100, usage);
- EXPECT_EQ(0, unlimited_usage);
- EXPECT_EQ(100, host_usage);
-
- GrantUnlimitedStoragePolicy(origin);
- UpdateUsageWithoutNotification(origin, 100);
- SetUsageCacheEnabled(origin, false);
- UpdateUsageWithoutNotification(origin, 100);
-
- GetGlobalUsage(&usage, &unlimited_usage);
- GetHostUsage(host, &host_usage);
- EXPECT_EQ(400, usage);
- EXPECT_EQ(400, unlimited_usage);
- EXPECT_EQ(400, host_usage);
-
- RevokeUnlimitedStoragePolicy(origin);
- GetGlobalUsage(&usage, &unlimited_usage);
- GetHostUsage(host, &host_usage);
- EXPECT_EQ(400, usage);
- EXPECT_EQ(0, unlimited_usage);
- EXPECT_EQ(400, host_usage);
-
- SetUsageCacheEnabled(origin, true);
- UpdateUsage(origin, 100);
-
- GetGlobalUsage(&usage, &unlimited_usage);
- GetHostUsage(host, &host_usage);
- EXPECT_EQ(500, usage);
- EXPECT_EQ(0, unlimited_usage);
- EXPECT_EQ(500, host_usage);
-}
-
-TEST_F(UsageTrackerTest, LimitedGlobalUsageTest) {
- const GURL kNormal("http://normal");
- const GURL kUnlimited("http://unlimited");
- const GURL kNonCached("http://non_cached");
- const GURL kNonCachedUnlimited("http://non_cached-unlimited");
-
- GrantUnlimitedStoragePolicy(kUnlimited);
- GrantUnlimitedStoragePolicy(kNonCachedUnlimited);
-
- SetUsageCacheEnabled(kNonCached, false);
- SetUsageCacheEnabled(kNonCachedUnlimited, false);
-
- UpdateUsageWithoutNotification(kNormal, 1);
- UpdateUsageWithoutNotification(kUnlimited, 2);
- UpdateUsageWithoutNotification(kNonCached, 4);
- UpdateUsageWithoutNotification(kNonCachedUnlimited, 8);
-
- int64 limited_usage = 0;
- int64 total_usage = 0;
- int64 unlimited_usage = 0;
-
- GetGlobalLimitedUsage(&limited_usage);
- GetGlobalUsage(&total_usage, &unlimited_usage);
- EXPECT_EQ(1 + 4, limited_usage);
- EXPECT_EQ(1 + 2 + 4 + 8, total_usage);
- EXPECT_EQ(2 + 8, unlimited_usage);
-
- UpdateUsageWithoutNotification(kNonCached, 16 - 4);
- UpdateUsageWithoutNotification(kNonCachedUnlimited, 32 - 8);
-
- GetGlobalLimitedUsage(&limited_usage);
- GetGlobalUsage(&total_usage, &unlimited_usage);
- EXPECT_EQ(1 + 16, limited_usage);
- EXPECT_EQ(1 + 2 + 16 + 32, total_usage);
- EXPECT_EQ(2 + 32, unlimited_usage);
-}
-
-
-} // namespace quota
diff --git a/chromium/webkit/build/webkit_version.h.in b/chromium/webkit/build/webkit_version.h.in
deleted file mode 100644
index 8d61e47d7cd..00000000000
--- a/chromium/webkit/build/webkit_version.h.in
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// webkit_version.h is generated from webkit_version.h.in. Edit the source!
-
-#define WEBKIT_VERSION_MAJOR 537
-#define WEBKIT_VERSION_MINOR 36
-#define WEBKIT_SVN_REVISION "@@LASTCHANGE@"
diff --git a/chromium/webkit/child/BUILD.gn b/chromium/webkit/child/BUILD.gn
new file mode 100644
index 00000000000..f0c36269004
--- /dev/null
+++ b/chromium/webkit/child/BUILD.gn
@@ -0,0 +1,60 @@
+# 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.
+
+component("child") {
+ output_name = "webkit_child"
+ sources = [
+ "multipart_response_delegate.cc",
+ "multipart_response_delegate.h",
+ "resource_loader_bridge.cc",
+ "resource_loader_bridge.h",
+ "webkit_child_export.h",
+ "weburlresponse_extradata_impl.cc",
+ "weburlresponse_extradata_impl.h",
+ ]
+
+ defines = [ "WEBKIT_CHILD_IMPLEMENTATION" ]
+ include_dirs = [
+ # For JNI generated header.
+ "$root_gen_dir/webkit",
+ ]
+
+ configs += [ "//build/config/compiler:wexit_time_destructors" ]
+ if (is_win) {
+ # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
+ cflags = [ "/wd4267" ]
+ }
+
+ if (is_mac) {
+ libs = [ "QuartzCore.framework" ]
+ }
+ if (is_android) {
+ #deps += [ ":overscroller_jni_headers" ] TODO(GYP)
+ }
+
+ deps = [
+ "//base",
+ "//base:i18n",
+ "//base/third_party/dynamic_annotations",
+ "//net",
+ "//skia",
+ #"//third_party/WebKit/public:blink", TODO(GYP)
+ "//ui/gfx",
+ "//ui/gfx/geometry",
+ "//ui/native_theme",
+ "//url",
+ "//v8",
+ "//webkit/common",
+ ]
+}
+
+#TODO(GYP)
+#'target_name': 'overscroller_jni_headers',
+#'type': 'none',
+#'variables': {
+# 'jni_gen_package': 'webkit',
+# 'input_java_class': 'android/widget/OverScroller.class',
+#},
+#'includes': [ '../../build/jar_file_jni_generator.gypi' ],
+
diff --git a/chromium/webkit/child/fling_animator_impl_android.cc b/chromium/webkit/child/fling_animator_impl_android.cc
deleted file mode 100644
index 668076ba235..00000000000
--- a/chromium/webkit/child/fling_animator_impl_android.cc
+++ /dev/null
@@ -1,148 +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 "webkit/child/fling_animator_impl_android.h"
-
-#include "base/android/jni_android.h"
-#include "base/android/scoped_java_ref.h"
-#include "base/logging.h"
-#include "jni/OverScroller_jni.h"
-#include "third_party/WebKit/public/platform/WebFloatSize.h"
-#include "third_party/WebKit/public/platform/WebGestureCurveTarget.h"
-#include "ui/gfx/screen.h"
-#include "ui/gfx/vector2d.h"
-
-namespace webkit_glue {
-
-namespace {
-static const float kEpsilon = 1e-4;
-}
-
-FlingAnimatorImpl::FlingAnimatorImpl()
- : is_active_(false) {
- // hold the global reference of the Java objects.
- JNIEnv* env = base::android::AttachCurrentThread();
- java_scroller_.Reset(JNI_OverScroller::Java_OverScroller_ConstructorAWOS_ACC(
- env,
- base::android::GetApplicationContext()));
-}
-
-FlingAnimatorImpl::~FlingAnimatorImpl()
-{
-}
-
-//static
-bool FlingAnimatorImpl::RegisterJni(JNIEnv* env) {
- return JNI_OverScroller::RegisterNativesImpl(env);
-}
-
-void FlingAnimatorImpl::StartFling(const gfx::PointF& velocity)
-{
- // No bounds on the fling. See http://webkit.org/b/96403
- // Instead, use the largest possible bounds for minX/maxX/minY/maxY. The
- // compositor will ignore any attempt to scroll beyond the end of the page.
-
- DCHECK(velocity.x() || velocity.y());
- if (is_active_)
- CancelFling();
-
- is_active_ = true;
- last_time_ = 0;
- last_velocity_ = velocity;
-
- JNIEnv* env = base::android::AttachCurrentThread();
-
- JNI_OverScroller::Java_OverScroller_flingV_I_I_I_I_I_I_I_I(
- env, java_scroller_.obj(), 0, 0,
- static_cast<int>(velocity.x()),
- static_cast<int>(velocity.y()),
- INT_MIN, INT_MAX, INT_MIN, INT_MAX);
-}
-
-void FlingAnimatorImpl::CancelFling()
-{
- if (!is_active_)
- return;
-
- is_active_ = false;
- JNIEnv* env = base::android::AttachCurrentThread();
- JNI_OverScroller::Java_OverScroller_abortAnimation(env, java_scroller_.obj());
-}
-
-bool FlingAnimatorImpl::UpdatePosition()
-{
- JNIEnv* env = base::android::AttachCurrentThread();
- bool result = JNI_OverScroller::Java_OverScroller_computeScrollOffset(
- env,
- java_scroller_.obj());
- return is_active_ = result;
-}
-
-gfx::Point FlingAnimatorImpl::GetCurrentPosition()
-{
- JNIEnv* env = base::android::AttachCurrentThread();
- gfx::Point position(
- JNI_OverScroller::Java_OverScroller_getCurrX(env, java_scroller_.obj()),
- JNI_OverScroller::Java_OverScroller_getCurrY(env, java_scroller_.obj()));
- return position;
-}
-
-float FlingAnimatorImpl::GetCurrentVelocity()
-{
- JNIEnv* env = base::android::AttachCurrentThread();
- // TODO(jdduke): Add Java-side hooks for getCurrVelocityX/Y, and return
- // vector velocity.
- return JNI_OverScroller::Java_OverScroller_getCurrVelocity(
- env, java_scroller_.obj());
-}
-
-bool FlingAnimatorImpl::apply(double time,
- blink::WebGestureCurveTarget* target) {
- if (!UpdatePosition())
- return false;
-
- gfx::Point current_position = GetCurrentPosition();
- gfx::Vector2d diff(current_position - last_position_);
- last_position_ = current_position;
- float dpi_scale = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay()
- .device_scale_factor();
- blink::WebFloatSize scroll_amount(diff.x() / dpi_scale,
- diff.y() / dpi_scale);
-
- float delta_time = time - last_time_;
- last_time_ = time;
-
- // Currently, the OverScroller only provides the velocity magnitude; use the
- // angle of the scroll delta to yield approximate x and y velocity components.
- // TODO(jdduke): Remove this when we can properly poll OverScroller velocity.
- gfx::PointF current_velocity = last_velocity_;
- if (delta_time > kEpsilon) {
- float diff_length = diff.Length();
- if (diff_length > kEpsilon) {
- float velocity = GetCurrentVelocity();
- float scroll_to_velocity = velocity / diff_length;
- current_velocity = gfx::PointF(diff.x() * scroll_to_velocity,
- diff.y() * scroll_to_velocity);
- }
- }
- last_velocity_ = current_velocity;
- blink::WebFloatSize fling_velocity(current_velocity.x() / dpi_scale,
- current_velocity.y() / dpi_scale);
- target->notifyCurrentFlingVelocity(fling_velocity);
-
- // scrollBy() could delete this curve if the animation is over, so don't touch
- // any member variables after making that call.
- target->scrollBy(scroll_amount);
- return true;
-}
-
-FlingAnimatorImpl* FlingAnimatorImpl::CreateAndroidGestureCurve(
- const blink::WebFloatPoint& velocity,
- const blink::WebSize&) {
- FlingAnimatorImpl* gesture_curve = new FlingAnimatorImpl();
- gesture_curve->StartFling(velocity);
- return gesture_curve;
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/child/fling_animator_impl_android.h b/chromium/webkit/child/fling_animator_impl_android.h
deleted file mode 100644
index c4703677874..00000000000
--- a/chromium/webkit/child/fling_animator_impl_android.h
+++ /dev/null
@@ -1,58 +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 WEBKIT_CHILD_FLING_ANIMATOR_IMPL_ANDROID_H_
-#define WEBKIT_CHILD_FLING_ANIMATOR_IMPL_ANDROID_H_
-
-#include "base/android/scoped_java_ref.h"
-#include "third_party/WebKit/public/platform/WebFloatPoint.h"
-#include "third_party/WebKit/public/platform/WebGestureCurve.h"
-#include "third_party/WebKit/public/platform/WebSize.h"
-#include "ui/gfx/point.h"
-#include "ui/gfx/point_f.h"
-#include "webkit/child/webkit_child_export.h"
-
-namespace blink {
-class WebGestureCurveTarget;
-}
-
-namespace webkit_glue {
-
-class WEBKIT_CHILD_EXPORT FlingAnimatorImpl : public blink::WebGestureCurve {
- public:
- FlingAnimatorImpl();
- virtual ~FlingAnimatorImpl();
-
- static FlingAnimatorImpl* CreateAndroidGestureCurve(
- const blink::WebFloatPoint& velocity,
- const blink::WebSize&);
-
- virtual bool apply(double time,
- blink::WebGestureCurveTarget* target);
-
- static bool RegisterJni(JNIEnv*);
-
- private:
- void StartFling(const gfx::PointF& velocity);
- // Returns true if the animation is not yet finished.
- bool UpdatePosition();
- gfx::Point GetCurrentPosition();
- float GetCurrentVelocity();
- virtual void CancelFling();
-
- bool is_active_;
-
- // Java OverScroller instance and methods.
- base::android::ScopedJavaGlobalRef<jobject> java_scroller_;
-
- gfx::Point last_position_;
- gfx::PointF last_velocity_;
- double last_time_;
-
- DISALLOW_COPY_AND_ASSIGN(FlingAnimatorImpl);
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_FLING_ANIMATOR_IMPL_ANDROID_H_
diff --git a/chromium/webkit/child/fling_curve_configuration.cc b/chromium/webkit/child/fling_curve_configuration.cc
deleted file mode 100644
index 070513147c5..00000000000
--- a/chromium/webkit/child/fling_curve_configuration.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) 2013 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 "webkit/child/fling_curve_configuration.h"
-
-#include "base/logging.h"
-#include "third_party/WebKit/public/platform/WebGestureCurve.h"
-#include "webkit/child/touch_fling_gesture_curve.h"
-
-namespace webkit_glue {
-
-FlingCurveConfiguration::FlingCurveConfiguration() { }
-
-FlingCurveConfiguration::~FlingCurveConfiguration() { }
-
-void FlingCurveConfiguration::SetCurveParameters(
- const std::vector<float>& new_touchpad,
- const std::vector<float>& new_touchscreen) {
- DCHECK(new_touchpad.size() >= 3);
- DCHECK(new_touchscreen.size() >= 3);
- base::AutoLock scoped_lock(lock_);
- touchpad_coefs_ = new_touchpad;
- touchscreen_coefs_ = new_touchscreen;
-}
-
-blink::WebGestureCurve* FlingCurveConfiguration::CreateCore(
- const std::vector<float>& coefs,
- const blink::WebFloatPoint& velocity,
- const blink::WebSize& cumulativeScroll) {
- float p0, p1, p2;
-
- {
- base::AutoLock scoped_lock(lock_);
- p0 = coefs[0];
- p1 = coefs[1];
- p2 = coefs[2];
- }
-
- return TouchFlingGestureCurve::Create(velocity, p0, p1, p2, cumulativeScroll);
-}
-
-blink::WebGestureCurve* FlingCurveConfiguration::CreateForTouchPad(
- const blink::WebFloatPoint& velocity,
- const blink::WebSize& cumulativeScroll) {
- return CreateCore(touchpad_coefs_, velocity, cumulativeScroll);
-}
-
-blink::WebGestureCurve* FlingCurveConfiguration::CreateForTouchScreen(
- const blink::WebFloatPoint& velocity,
- const blink::WebSize& cumulativeScroll) {
- return CreateCore(touchscreen_coefs_, velocity, cumulativeScroll);
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/child/fling_curve_configuration.h b/chromium/webkit/child/fling_curve_configuration.h
deleted file mode 100644
index a23e2c9ebc0..00000000000
--- a/chromium/webkit/child/fling_curve_configuration.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2013 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 WEBKIT_CHILD_FLING_CURVE_CONFIGURATION_H_
-#define WEBKIT_CHILD_FLING_CURVE_CONFIGURATION_H_
-
-#include <vector>
-
-#include "base/synchronization/lock.h"
-#include "third_party/WebKit/public/platform/WebFloatPoint.h"
-#include "third_party/WebKit/public/platform/WebSize.h"
-
-namespace blink {
-class WebGestureCurve;
-}
-
-namespace webkit_glue {
-
-// A class to manage dynamically adjustable parameters controlling the
-// shape of the fling deacceleration function.
-class FlingCurveConfiguration {
- public:
- FlingCurveConfiguration();
- virtual ~FlingCurveConfiguration();
-
- // Create a touchpad fling curve using the current parameters.
- blink::WebGestureCurve* CreateForTouchPad(
- const blink::WebFloatPoint& velocity,
- const blink::WebSize& cumulativeScroll);
-
- // Create a touchscreen fling curve using the current parameters.
- blink::WebGestureCurve* CreateForTouchScreen(
- const blink::WebFloatPoint& velocity,
- const blink::WebSize& cumulativeScroll);
-
- // Set the curve parameters.
- void SetCurveParameters(
- const std::vector<float>& new_touchpad,
- const std::vector<float>& new_touchscreen);
-
- private:
- blink::WebGestureCurve* CreateCore(
- const std::vector<float>& coefs,
- const blink::WebFloatPoint& velocity,
- const blink::WebSize& cumulativeScroll);
-
- // Protect access to touchpad_coefs_ and touchscreen_coefs_.
- base::Lock lock_;
- std::vector<float> touchpad_coefs_;
- std::vector<float> touchscreen_coefs_;
-
- DISALLOW_COPY_AND_ASSIGN(FlingCurveConfiguration);
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_FLING_CURVE_CONFIGURATION_H_
diff --git a/chromium/webkit/child/ftp_directory_listing_response_delegate.cc b/chromium/webkit/child/ftp_directory_listing_response_delegate.cc
deleted file mode 100644
index bad606eee6c..00000000000
--- a/chromium/webkit/child/ftp_directory_listing_response_delegate.cc
+++ /dev/null
@@ -1,123 +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 "webkit/child/ftp_directory_listing_response_delegate.h"
-
-#include <vector>
-
-#include "base/i18n/icu_encoding_detection.h"
-#include "base/i18n/icu_string_conversions.h"
-#include "base/logging.h"
-#include "base/strings/string_util.h"
-#include "base/strings/sys_string_conversions.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/time/time.h"
-#include "net/base/escape.h"
-#include "net/base/net_errors.h"
-#include "net/base/net_util.h"
-#include "net/ftp/ftp_directory_listing_parser.h"
-#include "third_party/WebKit/public/platform/WebURL.h"
-#include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
-#include "webkit/child/weburlresponse_extradata_impl.h"
-
-using net::FtpDirectoryListingEntry;
-
-using blink::WebURLLoader;
-using blink::WebURLLoaderClient;
-using blink::WebURLResponse;
-
-namespace {
-
-base::string16 ConvertPathToUTF16(const std::string& path) {
- // Per RFC 2640, FTP servers should use UTF-8 or its proper subset ASCII,
- // but many old FTP servers use legacy encodings. Try UTF-8 first.
- if (IsStringUTF8(path))
- return UTF8ToUTF16(path);
-
- // Try detecting the encoding. The sample is rather small though, so it may
- // fail.
- std::string encoding;
- if (base::DetectEncoding(path, &encoding) && !encoding.empty()) {
- base::string16 path_utf16;
- if (base::CodepageToUTF16(path, encoding.c_str(),
- base::OnStringConversionError::SUBSTITUTE,
- &path_utf16)) {
- return path_utf16;
- }
- }
-
- // Use system native encoding as the last resort.
- return WideToUTF16Hack(base::SysNativeMBToWide(path));
-}
-
-} // namespace
-
-namespace webkit_glue {
-
-FtpDirectoryListingResponseDelegate::FtpDirectoryListingResponseDelegate(
- WebURLLoaderClient* client,
- WebURLLoader* loader,
- const WebURLResponse& response)
- : client_(client),
- loader_(loader) {
- if (response.extraData()) {
- // extraData can be NULL during tests.
- WebURLResponseExtraDataImpl* extra_data =
- static_cast<WebURLResponseExtraDataImpl*>(response.extraData());
- extra_data->set_is_ftp_directory_listing(true);
- }
- Init(response.url());
-}
-
-void FtpDirectoryListingResponseDelegate::OnReceivedData(const char* data,
- int data_len) {
- buffer_.append(data, data_len);
-}
-
-void FtpDirectoryListingResponseDelegate::OnCompletedRequest() {
- std::vector<FtpDirectoryListingEntry> entries;
- int rv = net::ParseFtpDirectoryListing(buffer_, base::Time::Now(), &entries);
- if (rv != net::OK) {
- SendDataToClient("<script>onListingParsingError();</script>\n");
- return;
- }
- for (size_t i = 0; i < entries.size(); i++) {
- FtpDirectoryListingEntry entry = entries[i];
-
- // Skip the current and parent directory entries in the listing. Our header
- // always includes them.
- if (EqualsASCII(entry.name, ".") || EqualsASCII(entry.name, ".."))
- continue;
-
- bool is_directory = (entry.type == FtpDirectoryListingEntry::DIRECTORY);
- int64 size = entry.size;
- if (entry.type != FtpDirectoryListingEntry::FILE)
- size = 0;
- SendDataToClient(net::GetDirectoryListingEntry(
- entry.name, entry.raw_name, is_directory, size, entry.last_modified));
- }
-}
-
-void FtpDirectoryListingResponseDelegate::Init(const GURL& response_url) {
- net::UnescapeRule::Type unescape_rules = net::UnescapeRule::SPACES |
- net::UnescapeRule::URL_SPECIAL_CHARS;
- std::string unescaped_path = net::UnescapeURLComponent(response_url.path(),
- unescape_rules);
- SendDataToClient(net::GetDirectoryListingHeader(
- ConvertPathToUTF16(unescaped_path)));
-
- // If this isn't top level directory (i.e. the path isn't "/",)
- // add a link to the parent directory.
- if (response_url.path().length() > 1) {
- SendDataToClient(net::GetDirectoryListingEntry(
- ASCIIToUTF16(".."), std::string(), false, 0, base::Time()));
- }
-}
-
-void FtpDirectoryListingResponseDelegate::SendDataToClient(
- const std::string& data) {
- client_->didReceiveData(loader_, data.data(), data.length(), -1);
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/child/ftp_directory_listing_response_delegate.h b/chromium/webkit/child/ftp_directory_listing_response_delegate.h
deleted file mode 100644
index 539ff6741e9..00000000000
--- a/chromium/webkit/child/ftp_directory_listing_response_delegate.h
+++ /dev/null
@@ -1,53 +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.
-//
-// A delegate class of WebURLLoaderImpl that handles text/vnd.chromium.ftp-dir
-// data.
-
-#ifndef WEBKIT_CHILD_FTP_DIRECTORY_LISTING_RESPONSE_DELEGATE_H_
-#define WEBKIT_CHILD_FTP_DIRECTORY_LISTING_RESPONSE_DELEGATE_H_
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "third_party/WebKit/public/platform/WebURLResponse.h"
-
-namespace blink {
-class WebURLLoader;
-class WebURLLoaderClient;
-}
-
-class GURL;
-
-namespace webkit_glue {
-
-class FtpDirectoryListingResponseDelegate {
- public:
- FtpDirectoryListingResponseDelegate(blink::WebURLLoaderClient* client,
- blink::WebURLLoader* loader,
- const blink::WebURLResponse& response);
-
- // Passed through from ResourceHandleInternal
- void OnReceivedData(const char* data, int data_len);
- void OnCompletedRequest();
-
- private:
- void Init(const GURL& response_url);
-
- void SendDataToClient(const std::string& data);
-
- // Pointers to the client and associated loader so we can make callbacks as
- // we parse pieces of data.
- blink::WebURLLoaderClient* client_;
- blink::WebURLLoader* loader_;
-
- // Buffer for data received from the network.
- std::string buffer_;
-
- DISALLOW_COPY_AND_ASSIGN(FtpDirectoryListingResponseDelegate);
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_FTP_DIRECTORY_LISTING_RESPONSE_DELEGATE_H_
diff --git a/chromium/webkit/child/multipart_response_delegate.h b/chromium/webkit/child/multipart_response_delegate.h
index efb70e2e4f2..c1b5c89b122 100644
--- a/chromium/webkit/child/multipart_response_delegate.h
+++ b/chromium/webkit/child/multipart_response_delegate.h
@@ -60,10 +60,12 @@ class WebURLLoader;
class WebURLLoaderClient;
}
-namespace webkit_glue {
-
+namespace content {
// Used by unit tests to access private members.
class MultipartResponseDelegateTester;
+}
+
+namespace webkit_glue {
class WEBKIT_CHILD_EXPORT MultipartResponseDelegate {
public:
@@ -98,7 +100,7 @@ class WEBKIT_CHILD_EXPORT MultipartResponseDelegate {
int64* content_range_instance_size);
private:
- friend class MultipartResponseDelegateTester; // For unittests.
+ friend class content::MultipartResponseDelegateTester; // For unittests.
// Pointers to the client and associated loader so we can make callbacks as
// we parse pieces of data.
diff --git a/chromium/webkit/child/multipart_response_delegate_unittest.cc b/chromium/webkit/child/multipart_response_delegate_unittest.cc
deleted file mode 100644
index 4bfa6aba254..00000000000
--- a/chromium/webkit/child/multipart_response_delegate_unittest.cc
+++ /dev/null
@@ -1,675 +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.
-
-#include <vector>
-
-#include "base/basictypes.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/WebKit/public/platform/WebString.h"
-#include "third_party/WebKit/public/platform/WebURL.h"
-#include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
-#include "third_party/WebKit/public/platform/WebURLResponse.h"
-#include "webkit/child/multipart_response_delegate.h"
-
-using std::string;
-using blink::WebString;
-using blink::WebURL;
-using blink::WebURLError;
-using blink::WebURLLoader;
-using blink::WebURLLoaderClient;
-using blink::WebURLRequest;
-using blink::WebURLResponse;
-using webkit_glue::MultipartResponseDelegate;
-using webkit_glue::MultipartResponseDelegateTester;
-
-namespace webkit_glue {
-
-class MultipartResponseDelegateTester {
- public:
- MultipartResponseDelegateTester(MultipartResponseDelegate* delegate)
- : delegate_(delegate) {
- }
-
- int PushOverLine(const std::string& data, size_t pos) {
- return delegate_->PushOverLine(data, pos);
- }
-
- bool ParseHeaders() { return delegate_->ParseHeaders(); }
- size_t FindBoundary() { return delegate_->FindBoundary(); }
- std::string& boundary() { return delegate_->boundary_; }
- std::string& data() { return delegate_->data_; }
-
- private:
- MultipartResponseDelegate* delegate_;
-};
-
-} // namespace webkit_glue
-
-namespace {
-
-class MultipartResponseTest : public testing::Test {
-};
-
-class MockWebURLLoaderClient : public WebURLLoaderClient {
- public:
- MockWebURLLoaderClient() { Reset(); }
-
- virtual void willSendRequest(
- WebURLLoader*, WebURLRequest&, const WebURLResponse&) {}
- virtual void didSendData(
- WebURLLoader*, unsigned long long, unsigned long long) {}
-
- virtual void didReceiveResponse(WebURLLoader* loader,
- const WebURLResponse& response) {
- ++received_response_;
- response_ = response;
- data_.clear();
- }
- virtual void didReceiveData(
- blink::WebURLLoader* loader,
- const char* data,
- int data_length,
- int encoded_data_length) {
- ++received_data_;
- data_.append(data, data_length);
- total_encoded_data_length_ += encoded_data_length;
- }
- virtual void didFinishLoading(WebURLLoader*, double finishTime) {}
- virtual void didFail(WebURLLoader*, const WebURLError&) {}
-
- void Reset() {
- received_response_ = received_data_ = total_encoded_data_length_ = 0;
- data_.clear();
- response_.reset();
- }
-
- string GetResponseHeader(const char* name) const {
- return string(response_.httpHeaderField(WebString::fromUTF8(name)).utf8());
- }
-
- int received_response_, received_data_, total_encoded_data_length_;
- string data_;
- WebURLResponse response_;
-};
-
-// We can't put this in an anonymous function because it's a friend class for
-// access to private members.
-TEST(MultipartResponseTest, Functions) {
- // PushOverLine tests
-
- WebURLResponse response;
- response.initialize();
- response.setMIMEType("multipart/x-mixed-replace");
- response.setHTTPHeaderField("Foo", "Bar");
- response.setHTTPHeaderField("Content-type", "text/plain");
- MockWebURLLoaderClient client;
- MultipartResponseDelegate delegate(&client, NULL, response, "bound");
- MultipartResponseDelegateTester delegate_tester(&delegate);
-
- struct {
- const char* input;
- const int position;
- const int expected;
- } line_tests[] = {
- { "Line", 0, 0 },
- { "Line", 2, 0 },
- { "Line", 10, 0 },
- { "\r\nLine", 0, 2 },
- { "\nLine", 0, 1 },
- { "\n\nLine", 0, 2 },
- { "\rLine", 0, 1 },
- { "Line\r\nLine", 4, 2 },
- { "Line\nLine", 4, 1 },
- { "Line\n\nLine", 4, 2 },
- { "Line\rLine", 4, 1 },
- { "Line\r\rLine", 4, 1 },
- };
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(line_tests); ++i) {
- EXPECT_EQ(line_tests[i].expected,
- delegate_tester.PushOverLine(line_tests[i].input,
- line_tests[i].position));
- }
-
- // ParseHeaders tests
- struct {
- const char* data;
- const bool rv;
- const int received_response_calls;
- const char* newdata;
- } header_tests[] = {
- { "This is junk", false, 0, "This is junk" },
- { "Foo: bar\nBaz:\n\nAfter:\n", true, 1, "After:\n" },
- { "Foo: bar\nBaz:\n", false, 0, "Foo: bar\nBaz:\n" },
- { "Foo: bar\r\nBaz:\r\n\r\nAfter:\r\n", true, 1, "After:\r\n" },
- { "Foo: bar\r\nBaz:\r\n", false, 0, "Foo: bar\r\nBaz:\r\n" },
- { "Foo: bar\nBaz:\r\n\r\nAfter:\n\n", true, 1, "After:\n\n" },
- { "Foo: bar\r\nBaz:\n", false, 0, "Foo: bar\r\nBaz:\n" },
- { "\r\n", true, 1, "" },
- };
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(header_tests); ++i) {
- client.Reset();
- delegate_tester.data().assign(header_tests[i].data);
- EXPECT_EQ(header_tests[i].rv,
- delegate_tester.ParseHeaders());
- EXPECT_EQ(header_tests[i].received_response_calls,
- client.received_response_);
- EXPECT_EQ(string(header_tests[i].newdata),
- delegate_tester.data());
- }
- // Test that the resource response is filled in correctly when parsing
- // headers.
- client.Reset();
- string test_header("content-type: image/png\ncontent-length: 10\n\n");
- delegate_tester.data().assign(test_header);
- EXPECT_TRUE(delegate_tester.ParseHeaders());
- EXPECT_TRUE(delegate_tester.data().length() == 0);
- EXPECT_EQ(string("image/png"), client.GetResponseHeader("Content-Type"));
- EXPECT_EQ(string("10"), client.GetResponseHeader("content-length"));
- // This header is passed from the original request.
- EXPECT_EQ(string("Bar"), client.GetResponseHeader("foo"));
-
- // Make sure we parse the right mime-type if a charset is provided.
- client.Reset();
- string test_header2("content-type: text/html; charset=utf-8\n\n");
- delegate_tester.data().assign(test_header2);
- EXPECT_TRUE(delegate_tester.ParseHeaders());
- EXPECT_TRUE(delegate_tester.data().length() == 0);
- EXPECT_EQ(string("text/html; charset=utf-8"),
- client.GetResponseHeader("Content-Type"));
- EXPECT_EQ(string("utf-8"),
- string(client.response_.textEncodingName().utf8()));
-
- // FindBoundary tests
- struct {
- const char* boundary;
- const char* data;
- const size_t position;
- } boundary_tests[] = {
- { "bound", "bound", 0 },
- { "bound", "--bound", 0 },
- { "bound", "junkbound", 4 },
- { "bound", "junk--bound", 4 },
- { "foo", "bound", string::npos },
- { "bound", "--boundbound", 0 },
- };
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(boundary_tests); ++i) {
- delegate_tester.boundary().assign(boundary_tests[i].boundary);
- delegate_tester.data().assign(boundary_tests[i].data);
- EXPECT_EQ(boundary_tests[i].position,
- delegate_tester.FindBoundary());
- }
-}
-
-TEST(MultipartResponseTest, MissingBoundaries) {
- WebURLResponse response;
- response.initialize();
- response.setMIMEType("multipart/x-mixed-replace");
- response.setHTTPHeaderField("Foo", "Bar");
- response.setHTTPHeaderField("Content-type", "text/plain");
- MockWebURLLoaderClient client;
- MultipartResponseDelegate delegate(&client, NULL, response, "bound");
-
- // No start boundary
- string no_start_boundary(
- "Content-type: text/plain\n\n"
- "This is a sample response\n"
- "--bound--"
- "ignore junk after end token --bound\n\nTest2\n");
- delegate.OnReceivedData(no_start_boundary.c_str(),
- static_cast<int>(no_start_boundary.length()),
- static_cast<int>(no_start_boundary.length()));
- EXPECT_EQ(1, client.received_response_);
- EXPECT_EQ(1, client.received_data_);
- EXPECT_EQ(string("This is a sample response"), client.data_);
- EXPECT_EQ(static_cast<int>(no_start_boundary.length()),
- client.total_encoded_data_length_);
-
- delegate.OnCompletedRequest();
- EXPECT_EQ(1, client.received_response_);
- EXPECT_EQ(1, client.received_data_);
-
- // No end boundary
- client.Reset();
- MultipartResponseDelegate delegate2(&client, NULL, response, "bound");
- string no_end_boundary(
- "bound\nContent-type: text/plain\n\n"
- "This is a sample response\n");
- delegate2.OnReceivedData(no_end_boundary.c_str(),
- static_cast<int>(no_end_boundary.length()),
- static_cast<int>(no_end_boundary.length()));
- EXPECT_EQ(1, client.received_response_);
- EXPECT_EQ(1, client.received_data_);
- EXPECT_EQ("This is a sample response\n", client.data_);
- EXPECT_EQ(static_cast<int>(no_end_boundary.length()),
- client.total_encoded_data_length_);
-
- delegate2.OnCompletedRequest();
- EXPECT_EQ(1, client.received_response_);
- EXPECT_EQ(1, client.received_data_);
- EXPECT_EQ(string("This is a sample response\n"), client.data_);
- EXPECT_EQ(static_cast<int>(no_end_boundary.length()),
- client.total_encoded_data_length_);
-
- // Neither boundary
- client.Reset();
- MultipartResponseDelegate delegate3(&client, NULL, response, "bound");
- string no_boundaries(
- "Content-type: text/plain\n\n"
- "This is a sample response\n");
- delegate3.OnReceivedData(no_boundaries.c_str(),
- static_cast<int>(no_boundaries.length()),
- static_cast<int>(no_boundaries.length()));
- EXPECT_EQ(1, client.received_response_);
- EXPECT_EQ(1, client.received_data_);
- EXPECT_EQ("This is a sample response\n", client.data_);
- EXPECT_EQ(static_cast<int>(no_boundaries.length()),
- client.total_encoded_data_length_);
-
- delegate3.OnCompletedRequest();
- EXPECT_EQ(1, client.received_response_);
- EXPECT_EQ(1, client.received_data_);
- EXPECT_EQ(string("This is a sample response\n"), client.data_);
- EXPECT_EQ(static_cast<int>(no_boundaries.length()),
- client.total_encoded_data_length_);
-}
-
-TEST(MultipartResponseTest, MalformedBoundary) {
- // Some servers send a boundary that is prefixed by "--". See bug 5786.
-
- WebURLResponse response;
- response.initialize();
- response.setMIMEType("multipart/x-mixed-replace");
- response.setHTTPHeaderField("Foo", "Bar");
- response.setHTTPHeaderField("Content-type", "text/plain");
- MockWebURLLoaderClient client;
- MultipartResponseDelegate delegate(&client, NULL, response, "--bound");
-
- string data(
- "--bound\n"
- "Content-type: text/plain\n\n"
- "This is a sample response\n"
- "--bound--"
- "ignore junk after end token --bound\n\nTest2\n");
- delegate.OnReceivedData(data.c_str(),
- static_cast<int>(data.length()),
- static_cast<int>(data.length()));
- EXPECT_EQ(1, client.received_response_);
- EXPECT_EQ(1, client.received_data_);
- EXPECT_EQ(string("This is a sample response"), client.data_);
- EXPECT_EQ(static_cast<int>(data.length()), client.total_encoded_data_length_);
-
- delegate.OnCompletedRequest();
- EXPECT_EQ(1, client.received_response_);
- EXPECT_EQ(1, client.received_data_);
-}
-
-
-// Used in for tests that break the data in various places.
-struct TestChunk {
- const int start_pos; // offset in data
- const int end_pos; // end offset in data
- const int expected_responses;
- const int expected_received_data;
- const char* expected_data;
- const int expected_encoded_data_length;
-};
-
-void VariousChunkSizesTest(const TestChunk chunks[], int chunks_size,
- int responses, int received_data,
- const char* completed_data,
- int completed_encoded_data_length) {
- const string data(
- "--bound\n" // 0-7
- "Content-type: image/png\n\n" // 8-32
- "datadatadatadatadata" // 33-52
- "--bound\n" // 53-60
- "Content-type: image/jpg\n\n" // 61-85
- "foofoofoofoofoo" // 86-100
- "--bound--"); // 101-109
-
- WebURLResponse response;
- response.initialize();
- response.setMIMEType("multipart/x-mixed-replace");
- MockWebURLLoaderClient client;
- MultipartResponseDelegate delegate(&client, NULL, response, "bound");
-
- for (int i = 0; i < chunks_size; ++i) {
- ASSERT_TRUE(chunks[i].start_pos < chunks[i].end_pos);
- string chunk = data.substr(chunks[i].start_pos,
- chunks[i].end_pos - chunks[i].start_pos);
- delegate.OnReceivedData(
- chunk.c_str(),
- static_cast<int>(chunk.length()),
- static_cast<int>(chunk.length()));
- EXPECT_EQ(chunks[i].expected_responses, client.received_response_);
- EXPECT_EQ(chunks[i].expected_received_data, client.received_data_);
- EXPECT_EQ(string(chunks[i].expected_data), client.data_);
- EXPECT_EQ(chunks[i].expected_encoded_data_length,
- client.total_encoded_data_length_);
- }
- // Check final state
- delegate.OnCompletedRequest();
- EXPECT_EQ(responses, client.received_response_);
- EXPECT_EQ(received_data, client.received_data_);
- string completed_data_string(completed_data);
- EXPECT_EQ(completed_data_string, client.data_);
- EXPECT_EQ(completed_encoded_data_length, client.total_encoded_data_length_);
-}
-
-TEST(MultipartResponseTest, BreakInBoundary) {
- // Break in the first boundary
- const TestChunk bound1[] = {
- { 0, 4, 0, 0, "", 0 },
- { 4, 110, 2, 2, "foofoofoofoofoo", 110 },
- };
- VariousChunkSizesTest(bound1, arraysize(bound1),
- 2, 2, "foofoofoofoofoo", 110);
-
- // Break in first and second
- const TestChunk bound2[] = {
- { 0, 4, 0, 0, "", 0 },
- { 4, 55, 1, 1, "datadatadatadat", 55 },
- { 55, 65, 1, 2, "datadatadatadatadata", 65 },
- { 65, 110, 2, 3, "foofoofoofoofoo", 110 },
- };
- VariousChunkSizesTest(bound2, arraysize(bound2),
- 2, 3, "foofoofoofoofoo", 110);
-
- // Break in second only
- const TestChunk bound3[] = {
- { 0, 55, 1, 1, "datadatadatadat", 55 },
- { 55, 110, 2, 3, "foofoofoofoofoo", 110 },
- };
- VariousChunkSizesTest(bound3, arraysize(bound3),
- 2, 3, "foofoofoofoofoo", 110);
-}
-
-TEST(MultipartResponseTest, BreakInHeaders) {
- // Break in first header
- const TestChunk header1[] = {
- { 0, 10, 0, 0, "", 0 },
- { 10, 35, 1, 0, "", 0 },
- { 35, 110, 2, 2, "foofoofoofoofoo", 110 },
- };
- VariousChunkSizesTest(header1, arraysize(header1),
- 2, 2, "foofoofoofoofoo", 110);
-
- // Break in both headers
- const TestChunk header2[] = {
- { 0, 10, 0, 0, "", 0 },
- { 10, 65, 1, 1, "datadatadatadatadata", 65 },
- { 65, 110, 2, 2, "foofoofoofoofoo", 110 },
- };
- VariousChunkSizesTest(header2, arraysize(header2),
- 2, 2, "foofoofoofoofoo", 110);
-
- // Break at end of a header
- const TestChunk header3[] = {
- { 0, 33, 1, 0, "", 0 },
- { 33, 65, 1, 1, "datadatadatadatadata", 65 },
- { 65, 110, 2, 2, "foofoofoofoofoo", 110 },
- };
- VariousChunkSizesTest(header3, arraysize(header3),
- 2, 2, "foofoofoofoofoo", 110);
-}
-
-TEST(MultipartResponseTest, BreakInData) {
- // All data as one chunk
- const TestChunk data1[] = {
- { 0, 110, 2, 2, "foofoofoofoofoo", 110 },
- };
- VariousChunkSizesTest(data1, arraysize(data1),
- 2, 2, "foofoofoofoofoo", 110);
-
- // breaks in data segment
- const TestChunk data2[] = {
- { 0, 35, 1, 0, "", 0 },
- { 35, 65, 1, 1, "datadatadatadatadata", 65 },
- { 65, 90, 2, 1, "", 65 },
- { 90, 110, 2, 2, "foofoofoofoofoo", 110 },
- };
- VariousChunkSizesTest(data2, arraysize(data2),
- 2, 2, "foofoofoofoofoo", 110);
-
- // Incomplete send
- const TestChunk data3[] = {
- { 0, 35, 1, 0, "", 0 },
- { 35, 90, 2, 1, "", 90 },
- };
- VariousChunkSizesTest(data3, arraysize(data3),
- 2, 2, "foof", 90);
-}
-
-TEST(MultipartResponseTest, SmallChunk) {
- WebURLResponse response;
- response.initialize();
- response.setMIMEType("multipart/x-mixed-replace");
- response.setHTTPHeaderField("Content-type", "text/plain");
- MockWebURLLoaderClient client;
- MultipartResponseDelegate delegate(&client, NULL, response, "bound");
-
- // Test chunks of size 1, 2, and 0.
- string data(
- "--boundContent-type: text/plain\n\n"
- "\n--boundContent-type: text/plain\n\n"
- "\n\n--boundContent-type: text/plain\n\n"
- "--boundContent-type: text/plain\n\n"
- "end--bound--");
- delegate.OnReceivedData(data.c_str(),
- static_cast<int>(data.length()),
- static_cast<int>(data.length()));
- EXPECT_EQ(4, client.received_response_);
- EXPECT_EQ(2, client.received_data_);
- EXPECT_EQ(string("end"), client.data_);
- EXPECT_EQ(static_cast<int>(data.length()), client.total_encoded_data_length_);
-
- delegate.OnCompletedRequest();
- EXPECT_EQ(4, client.received_response_);
- EXPECT_EQ(2, client.received_data_);
-}
-
-TEST(MultipartResponseTest, MultipleBoundaries) {
- // Test multiple boundaries back to back
- WebURLResponse response;
- response.initialize();
- response.setMIMEType("multipart/x-mixed-replace");
- MockWebURLLoaderClient client;
- MultipartResponseDelegate delegate(&client, NULL, response, "bound");
-
- string data("--bound\r\n\r\n--bound\r\n\r\nfoofoo--bound--");
- delegate.OnReceivedData(data.c_str(),
- static_cast<int>(data.length()),
- static_cast<int>(data.length()));
- EXPECT_EQ(2, client.received_response_);
- EXPECT_EQ(1, client.received_data_);
- EXPECT_EQ(string("foofoo"), client.data_);
- EXPECT_EQ(static_cast<int>(data.length()), client.total_encoded_data_length_);
-}
-
-TEST(MultipartResponseTest, MultipartByteRangeParsingTest) {
- // Test multipart/byteranges based boundary parsing.
- WebURLResponse response1;
- response1.initialize();
- response1.setMIMEType("multipart/x-mixed-replace");
- response1.setHTTPHeaderField("Content-Length", "200");
- response1.setHTTPHeaderField("Content-type",
- "multipart/byteranges; boundary=--bound--");
-
- std::string multipart_boundary;
- bool result = MultipartResponseDelegate::ReadMultipartBoundary(
- response1, &multipart_boundary);
- EXPECT_EQ(result, true);
- EXPECT_EQ(string("--bound--"),
- multipart_boundary);
-
- WebURLResponse response2;
- response2.initialize();
- response2.setMIMEType("image/png");
-
- response2.setHTTPHeaderField("Content-Length", "300");
- response2.setHTTPHeaderField("Last-Modified",
- "Mon, 04 Apr 2005 20:36:01 GMT");
- response2.setHTTPHeaderField("Date", "Thu, 11 Sep 2008 18:21:42 GMT");
-
- multipart_boundary.clear();
- result = MultipartResponseDelegate::ReadMultipartBoundary(
- response2, &multipart_boundary);
- EXPECT_EQ(result, false);
-
- WebURLResponse response3;
- response3.initialize();
- response3.setMIMEType("multipart/byteranges");
-
- response3.setHTTPHeaderField("Content-Length", "300");
- response3.setHTTPHeaderField("Last-Modified",
- "Mon, 04 Apr 2005 20:36:01 GMT");
- response3.setHTTPHeaderField("Date", "Thu, 11 Sep 2008 18:21:42 GMT");
- response3.setHTTPHeaderField("Content-type", "multipart/byteranges");
-
- multipart_boundary.clear();
- result = MultipartResponseDelegate::ReadMultipartBoundary(
- response3, &multipart_boundary);
- EXPECT_EQ(result, false);
- EXPECT_EQ(multipart_boundary.length(), 0U);
-
- WebURLResponse response4;
- response4.initialize();
- response4.setMIMEType("multipart/byteranges");
- response4.setHTTPHeaderField("Content-Length", "200");
- response4.setHTTPHeaderField("Content-type",
- "multipart/byteranges; boundary=--bound--; charSet=utf8");
-
- multipart_boundary.clear();
-
- result = MultipartResponseDelegate::ReadMultipartBoundary(
- response4, &multipart_boundary);
- EXPECT_EQ(result, true);
- EXPECT_EQ(string("--bound--"), multipart_boundary);
-
- WebURLResponse response5;
- response5.initialize();
- response5.setMIMEType("multipart/byteranges");
- response5.setHTTPHeaderField("Content-Length", "200");
- response5.setHTTPHeaderField("Content-type",
- "multipart/byteranges; boundary=\"--bound--\"; charSet=utf8");
-
- multipart_boundary.clear();
-
- result = MultipartResponseDelegate::ReadMultipartBoundary(
- response5, &multipart_boundary);
- EXPECT_EQ(result, true);
- EXPECT_EQ(string("--bound--"), multipart_boundary);
-}
-
-TEST(MultipartResponseTest, MultipartContentRangesTest) {
- WebURLResponse response1;
- response1.initialize();
- response1.setMIMEType("application/pdf");
- response1.setHTTPHeaderField("Content-Length", "200"); // Ignored!
- // Use intentionally >32bit values to check they are handled correctly.
- response1.setHTTPHeaderField("Content-Range",
- "bytes 5000000000-5000000050/6000000000");
-
- int64 content_range_lower_bound = 0;
- int64 content_range_upper_bound = 0;
- int64 content_range_instance_size = 0;
-
- bool result = MultipartResponseDelegate::ReadContentRanges(
- response1, &content_range_lower_bound,
- &content_range_upper_bound,
- &content_range_instance_size);
-
- EXPECT_EQ(result, true);
- EXPECT_EQ(content_range_lower_bound, 5e9);
- EXPECT_EQ(content_range_upper_bound, 5e9+50);
- EXPECT_EQ(content_range_instance_size, 6e9);
-
- WebURLResponse response2;
- response2.initialize();
- response2.setMIMEType("application/pdf");
- response2.setHTTPHeaderField("Content-Length", "200");
- response2.setHTTPHeaderField("Content-Range", "bytes 1000/1050");
-
- content_range_lower_bound = 0;
- content_range_upper_bound = 0;
- content_range_instance_size = 0;
-
- result = MultipartResponseDelegate::ReadContentRanges(
- response2, &content_range_lower_bound,
- &content_range_upper_bound,
- &content_range_instance_size);
-
- EXPECT_EQ(result, false);
-
- WebURLResponse response3;
- response3.initialize();
- response3.setMIMEType("application/pdf");
- response3.setHTTPHeaderField("Content-Length", "200");
- response3.setHTTPHeaderField("Range", "bytes 1000-1050/5000");
-
- content_range_lower_bound = 0;
- content_range_upper_bound = 0;
- content_range_instance_size = 0;
-
- result = MultipartResponseDelegate::ReadContentRanges(
- response3, &content_range_lower_bound,
- &content_range_upper_bound,
- &content_range_instance_size);
-
- EXPECT_EQ(result, true);
- EXPECT_EQ(content_range_lower_bound, 1000);
- EXPECT_EQ(content_range_upper_bound, 1050);
-
- WebURLResponse response4;
- response4.initialize();
- response4.setMIMEType("application/pdf");
- response4.setHTTPHeaderField("Content-Length", "200");
-
- content_range_lower_bound = 0;
- content_range_upper_bound = 0;
- content_range_instance_size = 0;
-
- result = MultipartResponseDelegate::ReadContentRanges(
- response4, &content_range_lower_bound,
- &content_range_upper_bound,
- &content_range_instance_size);
-
- EXPECT_EQ(result, false);
-}
-
-TEST(MultipartResponseTest, MultipartPayloadSet) {
- WebURLResponse response;
- response.initialize();
- response.setMIMEType("multipart/x-mixed-replace");
- MockWebURLLoaderClient client;
- MultipartResponseDelegate delegate(&client, NULL, response, "bound");
-
- string data(
- "--bound\n"
- "Content-type: text/plain\n\n"
- "response data\n"
- "--bound\n");
- delegate.OnReceivedData(data.c_str(),
- static_cast<int>(data.length()),
- static_cast<int>(data.length()));
- EXPECT_EQ(1, client.received_response_);
- EXPECT_EQ(string("response data"), client.data_);
- EXPECT_EQ(static_cast<int>(data.length()), client.total_encoded_data_length_);
- EXPECT_FALSE(client.response_.isMultipartPayload());
-
- string data2(
- "Content-type: text/plain\n\n"
- "response data2\n"
- "--bound\n");
- delegate.OnReceivedData(data2.c_str(),
- static_cast<int>(data2.length()),
- static_cast<int>(data2.length()));
- EXPECT_EQ(2, client.received_response_);
- EXPECT_EQ(string("response data2"), client.data_);
- EXPECT_EQ(static_cast<int>(data.length()) + static_cast<int>(data2.length()),
- client.total_encoded_data_length_);
- EXPECT_TRUE(client.response_.isMultipartPayload());
-}
-
-} // namespace
diff --git a/chromium/webkit/child/resource_loader_bridge.cc b/chromium/webkit/child/resource_loader_bridge.cc
index 439a09fe3fc..3303c4d7350 100644
--- a/chromium/webkit/child/resource_loader_bridge.cc
+++ b/chromium/webkit/child/resource_loader_bridge.cc
@@ -1,35 +1,11 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// 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 "webkit/child/resource_loader_bridge.h"
-#include "net/http/http_response_headers.h"
-#include "webkit/common/appcache/appcache_interfaces.h"
-#include "webkit/common/resource_response_info.h"
-
namespace webkit_glue {
-ResourceLoaderBridge::RequestInfo::RequestInfo()
- : referrer_policy(blink::WebReferrerPolicyDefault),
- load_flags(0),
- requestor_pid(0),
- request_type(ResourceType::MAIN_FRAME),
- priority(net::LOW),
- request_context(0),
- appcache_host_id(0),
- routing_id(0),
- download_to_file(false),
- has_user_gesture(false),
- extra_data(NULL) {
-}
-
-ResourceLoaderBridge::RequestInfo::~RequestInfo() {}
-
-ResourceLoaderBridge::SyncLoadResponse::SyncLoadResponse() {}
-
-ResourceLoaderBridge::SyncLoadResponse::~SyncLoadResponse() {}
-
ResourceLoaderBridge::ResourceLoaderBridge() {}
ResourceLoaderBridge::~ResourceLoaderBridge() {}
diff --git a/chromium/webkit/child/resource_loader_bridge.h b/chromium/webkit/child/resource_loader_bridge.h
index e1cd310fd33..19077581b4f 100644
--- a/chromium/webkit/child/resource_loader_bridge.h
+++ b/chromium/webkit/child/resource_loader_bridge.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// 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.
//
@@ -10,192 +10,44 @@
// will own the pointer to the bridge, and will delete it when the request is
// no longer needed.
//
-// In turn, the bridge's owner on the WebKit end will implement the Peer
-// interface, which we will use to communicate notifications back.
+// In turn, the bridge's owner on the WebKit end will implement the
+// RequestPeer interface, which we will use to communicate notifications
+// back.
#ifndef WEBKIT_CHILD_RESOURCE_LOADER_BRIDGE_H_
#define WEBKIT_CHILD_RESOURCE_LOADER_BRIDGE_H_
-#include <utility>
-
-#include "build/build_config.h"
-#if defined(OS_POSIX)
-#include "base/file_descriptor_posix.h"
-#endif
-#include "base/memory/ref_counted.h"
-#include "base/platform_file.h"
-#include "base/values.h"
+#include "base/macros.h"
#include "net/base/request_priority.h"
-#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
-#include "third_party/WebKit/public/platform/WebURLRequest.h"
-#include "url/gurl.h"
#include "webkit/child/webkit_child_export.h"
-#include "webkit/common/resource_response_info.h"
-#include "webkit/common/resource_type.h"
-namespace webkit_glue {
+namespace blink {
+class WebThreadedDataReceiver;
+}
+
+// TODO(pilgrim) remove this once resource loader is moved to content
+// http://crbug.com/338338
+namespace content {
+class RequestPeer;
class ResourceRequestBody;
+struct SyncLoadResponse;
+}
+
+namespace webkit_glue {
class ResourceLoaderBridge {
public:
- // Structure used when calling
- // WebKitPlatformSupportImpl::CreateResourceLoader().
- struct WEBKIT_CHILD_EXPORT RequestInfo {
- RequestInfo();
- ~RequestInfo();
-
- // HTTP-style method name (e.g., "GET" or "POST").
- std::string method;
-
- // Absolute URL encoded in ASCII per the rules of RFC-2396.
- GURL url;
-
- // URL of the document in the top-level window, which may be checked by the
- // third-party cookie blocking policy.
- GURL first_party_for_cookies;
-
- // Optional parameter, a URL with similar constraints in how it must be
- // encoded as the url member.
- GURL referrer;
-
- // The referrer policy that applies to the referrer.
- blink::WebReferrerPolicy referrer_policy;
-
- // For HTTP(S) requests, the headers parameter can be a \r\n-delimited and
- // \r\n-terminated list of MIME headers. They should be ASCII-encoded using
- // the standard MIME header encoding rules. The headers parameter can also
- // be null if no extra request headers need to be set.
- std::string headers;
-
- // Composed of the values defined in url_request_load_flags.h.
- int load_flags;
-
- // Process id of the process making the request.
- int requestor_pid;
-
- // Indicates if the current request is the main frame load, a sub-frame
- // load, or a sub objects load.
- ResourceType::Type request_type;
-
- // Indicates the priority of this request, as determined by WebKit.
- net::RequestPriority priority;
-
- // Used for plugin to browser requests.
- uint32 request_context;
-
- // Identifies what appcache host this request is associated with.
- int appcache_host_id;
-
- // Used to associated the bridge with a frame's network context.
- int routing_id;
-
- // If true, then the response body will be downloaded to a file and the
- // path to that file will be provided in ResponseInfo::download_file_path.
- bool download_to_file;
-
- // True if the request was user initiated.
- bool has_user_gesture;
-
- // Extra data associated with this request. We do not own this pointer.
- blink::WebURLRequest::ExtraData* extra_data;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(RequestInfo);
- };
-
- // See the SyncLoad method declared below. (The name of this struct is not
- // suffixed with "Info" because it also contains the response data.)
- struct SyncLoadResponse : ResourceResponseInfo {
- WEBKIT_CHILD_EXPORT SyncLoadResponse();
- WEBKIT_CHILD_EXPORT ~SyncLoadResponse();
-
- // The response error code.
- int error_code;
-
- // The final URL of the response. This may differ from the request URL in
- // the case of a server redirect.
- GURL url;
-
- // The response data.
- std::string data;
- };
-
- // Generated by the bridge. This is implemented by our custom resource loader
- // within webkit. The Peer and it's bridge should have identical lifetimes
- // as they represent each end of a communication channel.
- //
- // These callbacks mirror net::URLRequest::Delegate and the order and
- // conditions in which they will be called are identical. See url_request.h
- // for more information.
- class WEBKIT_CHILD_EXPORT Peer {
- public:
- // Called as upload progress is made.
- // note: only for requests with LOAD_ENABLE_UPLOAD_PROGRESS set
- virtual void OnUploadProgress(uint64 position, uint64 size) = 0;
-
- // Called when a redirect occurs. The implementation may return false to
- // suppress the redirect. The given ResponseInfo provides complete
- // information about the redirect, and new_url is the URL that will be
- // loaded if this method returns true. If this method returns true, the
- // output parameter *has_new_first_party_for_cookies indicates whether the
- // output parameter *new_first_party_for_cookies contains the new URL that
- // should be consulted for the third-party cookie blocking policy.
- virtual bool OnReceivedRedirect(const GURL& new_url,
- const ResourceResponseInfo& info,
- bool* has_new_first_party_for_cookies,
- GURL* new_first_party_for_cookies) = 0;
-
- // Called when response headers are available (after all redirects have
- // been followed).
- virtual void OnReceivedResponse(const ResourceResponseInfo& info) = 0;
-
- // Called when a chunk of response data is downloaded. This method may be
- // called multiple times or not at all if an error occurs. This method is
- // only called if RequestInfo::download_to_file was set to true, and in
- // that case, OnReceivedData will not be called.
- // The encoded_data_length is the length of the encoded data transferred
- // over the network, which could be different from data length (e.g. for
- // gzipped content), or -1 if unknown. It is only valid while devtools are
- // attached. Otherwise it becomes -1.
- virtual void OnDownloadedData(int len, int encoded_data_length) = 0;
-
- // Called when a chunk of response data is available. This method may
- // be called multiple times or not at all if an error occurs.
- // The encoded_data_length is the length of the encoded data transferred
- // over the network, which could be different from data length (e.g. for
- // gzipped content), or -1 if unknown. It is only valid while devtools are
- // attached. Otherwise it becomes -1.
- virtual void OnReceivedData(const char* data,
- int data_length,
- int encoded_data_length) = 0;
-
- // Called when metadata generated by the renderer is retrieved from the
- // cache. This method may be called zero or one times.
- virtual void OnReceivedCachedMetadata(const char* data, int len) { }
-
- // Called when the response is complete. This method signals completion of
- // the resource load.
- virtual void OnCompletedRequest(
- int error_code,
- bool was_ignored_by_handler,
- const std::string& security_info,
- const base::TimeTicks& completion_time) = 0;
-
- protected:
- virtual ~Peer() {}
- };
-
// use WebKitPlatformSupportImpl::CreateResourceLoader() for construction, but
// anybody can delete at any time, INCLUDING during processing of callbacks.
WEBKIT_CHILD_EXPORT virtual ~ResourceLoaderBridge();
// Call this method before calling Start() to set the request body.
// May only be used with HTTP(S) POST requests.
- virtual void SetRequestBody(ResourceRequestBody* request_body) = 0;
+ virtual void SetRequestBody(content::ResourceRequestBody* request_body) = 0;
// Call this method to initiate the request. If this method succeeds, then
// the peer's methods will be called asynchronously to report various events.
- virtual bool Start(Peer* peer) = 0;
+ virtual bool Start(content::RequestPeer* peer) = 0;
// Call this method to cancel a request that is in progress. This method
// causes the request to immediately transition into the 'done' state. The
@@ -210,7 +62,13 @@ class ResourceLoaderBridge {
// Call this method when the priority of the requested resource changes after
// Start() has been called. This method may only be called after a successful
// call to the Start method.
- virtual void DidChangePriority(net::RequestPriority new_priority) = 0;
+ virtual void DidChangePriority(net::RequestPriority new_priority,
+ int intra_priority_value) = 0;
+
+ // Call this method to attach a data receiver which will receive resource data
+ // on its own thread.
+ virtual bool AttachThreadedDataReceiver(
+ blink::WebThreadedDataReceiver* threaded_data_receiver) = 0;
// Call this method to load the resource synchronously (i.e., in one shot).
// This is an alternative to the Start method. Be warned that this method
@@ -219,7 +77,7 @@ class ResourceLoaderBridge {
// use this if you really need it! There is also no way for the caller to
// interrupt this method. Errors are reported via the status field of the
// response parameter.
- virtual void SyncLoad(SyncLoadResponse* response) = 0;
+ virtual void SyncLoad(content::SyncLoadResponse* response) = 0;
protected:
// Construction must go through
diff --git a/chromium/webkit/child/touch_fling_gesture_curve.cc b/chromium/webkit/child/touch_fling_gesture_curve.cc
deleted file mode 100644
index 91033dad07e..00000000000
--- a/chromium/webkit/child/touch_fling_gesture_curve.cc
+++ /dev/null
@@ -1,163 +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 "webkit/child/touch_fling_gesture_curve.h"
-
-#include <cmath>
-
-#include "base/debug/trace_event.h"
-#include "base/logging.h"
-#include "third_party/WebKit/public/platform/WebFloatPoint.h"
-#include "third_party/WebKit/public/platform/WebFloatSize.h"
-#include "third_party/WebKit/public/platform/WebGestureCurve.h"
-#include "third_party/WebKit/public/platform/WebGestureCurveTarget.h"
-#include "third_party/WebKit/public/platform/WebSize.h"
-
-using blink::WebFloatPoint;
-using blink::WebFloatSize;
-using blink::WebGestureCurve;
-using blink::WebGestureCurveTarget;
-using blink::WebSize;
-
-namespace {
-
-const char* kCurveName = "TouchFlingGestureCurve";
-
-inline double position(double t, float* p) {
- return p[0] * exp(-p[2] * t) - p[1] * t - p[0];
-}
-
-inline double velocity(double t, float* p) {
- return -p[0] * p[2] * exp(-p[2] * t) - p[1];
-}
-
-inline double timeAtVelocity(double v, float* p) {
- DCHECK(p[0]);
- DCHECK(p[2]);
- return -log((v + p[1]) / (-p[0] * p[2])) / p[2];
-}
-
-} // namespace
-
-
-namespace webkit_glue {
-
-// This curve implementation is based on the notion of a single, absolute
-// curve, which starts at a large velocity and smoothly decreases to
-// zero. For a given input velocity, we find where on the curve this
-// velocity occurs, and start the animation at this point---denoted by
-// (time_offset_, position_offset_).
-//
-// This has the effect of automatically determining an animation duration
-// that scales with input velocity, as faster initial velocities start
-// earlier on the curve and thus take longer to reach the end. No
-// complicated time scaling is required.
-//
-// Since the starting velocity is implicitly determined by our starting
-// point, we only store the relative magnitude and direction of both
-// initial x- and y-velocities, and use this to scale the computed
-// displacement at any point in time. This guarantees that fling
-// trajectories are straight lines when viewed in x-y space. Initial
-// velocities that lie outside the max velocity are constrained to start
-// at zero (and thus are implicitly scaled).
-//
-// The curve is modelled as a 4th order polynomial, starting at t = 0,
-// and ending at t = curve_duration_. Attempts to generate
-// position/velocity estimates outside this range are undefined.
-
-WebGestureCurve* TouchFlingGestureCurve::Create(
- const WebFloatPoint& initial_velocity,
- float p0,
- float p1,
- float p2,
- const WebSize& cumulative_scroll) {
- return new TouchFlingGestureCurve(initial_velocity, p0, p1, p2,
- cumulative_scroll);
-}
-
-TouchFlingGestureCurve::TouchFlingGestureCurve(
- const WebFloatPoint& initial_velocity,
- float alpha,
- float beta,
- float gamma,
- const WebSize& cumulative_scroll)
- : cumulative_scroll_(WebFloatSize(cumulative_scroll.width,
- cumulative_scroll.height)) {
- DCHECK(initial_velocity != WebFloatPoint());
-
- coefficients_[0] = alpha;
- coefficients_[1] = beta;
- coefficients_[2] = gamma;
-
- // Curve ends when velocity reaches zero.
- curve_duration_ = timeAtVelocity(0, coefficients_);
- DCHECK(curve_duration_ > 0);
-
- float max_start_velocity = std::max(fabs(initial_velocity.x),
- fabs(initial_velocity.y));
-
- // Force max_start_velocity to lie in the range v(0) to v(curve_duration),
- // and assume that the curve parameters define a monotonically decreasing
- // velocity, or else bisection search may fail.
- if (max_start_velocity > velocity(0, coefficients_))
- max_start_velocity = velocity(0, coefficients_);
-
- if (max_start_velocity < 0)
- max_start_velocity = 0;
-
- // We keep track of relative magnitudes and directions of the
- // velocity/displacement components here.
- displacement_ratio_ = WebFloatPoint(initial_velocity.x / max_start_velocity,
- initial_velocity.y / max_start_velocity);
-
- // Compute time-offset for start velocity.
- time_offset_ = timeAtVelocity(max_start_velocity, coefficients_);
-
- // Compute curve position at offset time
- position_offset_ = position(time_offset_, coefficients_);
- TRACE_EVENT_ASYNC_BEGIN1("input", "GestureAnimation", this, "curve",
- kCurveName);
-}
-
-TouchFlingGestureCurve::~TouchFlingGestureCurve() {
- TRACE_EVENT_ASYNC_END0("input", "GestureAnimation", this);
-}
-
-bool TouchFlingGestureCurve::apply(double time, WebGestureCurveTarget* target) {
- float displacement;
- float speed;
- if (time < 0) {
- displacement = 0.f;
- speed = 0.f;
- } else if (time + time_offset_ < curve_duration_) {
- displacement =
- position(time + time_offset_, coefficients_) - position_offset_;
- speed = velocity(time + time_offset_, coefficients_);
- } else {
- displacement = position(curve_duration_, coefficients_) - position_offset_;
- speed = 0.f;
- }
-
- // Keep track of integer portion of scroll thus far, and prepare increment.
- WebFloatSize scroll(displacement * displacement_ratio_.x,
- displacement * displacement_ratio_.y);
- WebFloatSize scroll_increment(scroll.width - cumulative_scroll_.width,
- scroll.height - cumulative_scroll_.height);
- WebFloatSize scroll_velocity(speed * displacement_ratio_.x,
- speed * displacement_ratio_.y);
- cumulative_scroll_ = scroll;
-
- if (time + time_offset_ < curve_duration_ ||
- scroll_increment != WebFloatSize()) {
- target->notifyCurrentFlingVelocity(scroll_velocity);
- // scrollBy() could delete this curve if the animation is over, so don't
- // touch any member variables after making that call.
- target->scrollBy(scroll_increment);
- return true;
- }
-
- return false;
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/child/touch_fling_gesture_curve.h b/chromium/webkit/child/touch_fling_gesture_curve.h
deleted file mode 100644
index 4f8876d173b..00000000000
--- a/chromium/webkit/child/touch_fling_gesture_curve.h
+++ /dev/null
@@ -1,55 +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 WEBKIT_CHILD_TOUCH_FLING_GESTURE_CURVE_H_
-#define WEBKIT_CHILD_TOUCH_FLING_GESTURE_CURVE_H_
-
-#include "third_party/WebKit/public/platform/WebFloatPoint.h"
-#include "third_party/WebKit/public/platform/WebFloatSize.h"
-#include "third_party/WebKit/public/platform/WebGestureCurve.h"
-#include "third_party/WebKit/public/platform/WebSize.h"
-#include "webkit/child/webkit_child_export.h"
-
-namespace blink {
-class WebGestureCurveTarget;
-}
-
-namespace webkit_glue {
-
-// Implementation of WebGestureCurve suitable for touch pad/screen-based
-// fling scroll. Starts with a flat velocity profile based on 'velocity', which
-// tails off to zero. Time is scaled to that duration of the fling is
-// proportional to the initial velocity.
-class TouchFlingGestureCurve : public blink::WebGestureCurve {
- public:
-
- WEBKIT_CHILD_EXPORT static WebGestureCurve* Create(
- const blink::WebFloatPoint& initial_velocity,
- float p0, float p1, float p2,
- const blink::WebSize& cumulativeScroll);
-
- virtual bool apply(double monotonicTime,
- blink::WebGestureCurveTarget*) OVERRIDE;
-
- private:
- TouchFlingGestureCurve(const blink::WebFloatPoint& initial_velocity,
- float p0,
- float p1,
- float p2,
- const blink::WebSize& cumulativeScroll);
- virtual ~TouchFlingGestureCurve();
-
- blink::WebFloatPoint displacement_ratio_;
- blink::WebFloatSize cumulative_scroll_;
- float coefficients_[3];
- float time_offset_;
- float curve_duration_;
- float position_offset_;
-
- DISALLOW_COPY_AND_ASSIGN(TouchFlingGestureCurve);
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_TOUCH_FLING_GESTURE_CURVE_H_
diff --git a/chromium/webkit/child/touch_fling_gesture_curve_unittest.cc b/chromium/webkit/child/touch_fling_gesture_curve_unittest.cc
deleted file mode 100644
index 91b06092bbe..00000000000
--- a/chromium/webkit/child/touch_fling_gesture_curve_unittest.cc
+++ /dev/null
@@ -1,71 +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.
-
-// Tests for the TouchFlingGestureCurve.
-
-#include "webkit/child/touch_fling_gesture_curve.h"
-
-#include "base/memory/scoped_ptr.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/WebKit/public/platform/WebFloatPoint.h"
-#include "third_party/WebKit/public/platform/WebFloatSize.h"
-#include "third_party/WebKit/public/platform/WebGestureCurve.h"
-#include "third_party/WebKit/public/platform/WebGestureCurveTarget.h"
-#include "third_party/WebKit/public/platform/WebSize.h"
-
-using blink::WebFloatPoint;
-using blink::WebFloatSize;
-using blink::WebGestureCurve;
-using blink::WebGestureCurveTarget;
-using blink::WebSize;
-
-namespace {
-
-class MockGestureCurveTarget : public WebGestureCurveTarget {
- public:
- virtual void scrollBy(const WebFloatSize& delta) {
- cumulative_delta_.width += delta.width;
- cumulative_delta_.height += delta.height;
- }
-
- virtual void notifyCurrentFlingVelocity(const WebFloatSize& velocity) {
- current_velocity_ = velocity;
- }
-
- WebFloatSize cumulative_delta() const { return cumulative_delta_; }
- void resetCumulativeDelta() { cumulative_delta_ = WebFloatSize(); }
-
- WebFloatSize current_velocity() const { return current_velocity_; }
-
- private:
- WebFloatSize cumulative_delta_;
- WebFloatSize current_velocity_;
-};
-
-} // namespace anonymous
-
-TEST(TouchFlingGestureCurve, flingCurveTouch)
-{
- double initialVelocity = 5000;
- MockGestureCurveTarget target;
-
- scoped_ptr<WebGestureCurve> curve(webkit_glue::TouchFlingGestureCurve::Create(
- WebFloatPoint(initialVelocity, 0),
- -5.70762e+03f, 1.72e+02f, 3.7e+00f, WebSize()));
-
- // Note: the expectations below are dependent on the curve parameters hard
- // coded into the create call above.
- EXPECT_TRUE(curve->apply(0, &target));
- EXPECT_TRUE(curve->apply(0.25, &target));
- EXPECT_NEAR(target.current_velocity().width, 1878, 1);
- EXPECT_EQ(target.current_velocity().height, 0);
- EXPECT_TRUE(curve->apply(0.45f, &target)); // Use non-uniform tick spacing.
- EXPECT_TRUE(curve->apply(1, &target));
- EXPECT_FALSE(curve->apply(1.5, &target));
- EXPECT_NEAR(target.cumulative_delta().width, 1193, 1);
- EXPECT_EQ(target.cumulative_delta().height, 0);
- EXPECT_EQ(target.current_velocity().width, 0);
- EXPECT_EQ(target.current_velocity().height, 0);
-}
-
diff --git a/chromium/webkit/child/web_discardable_memory_impl.cc b/chromium/webkit/child/web_discardable_memory_impl.cc
deleted file mode 100644
index 285f1b0de9a..00000000000
--- a/chromium/webkit/child/web_discardable_memory_impl.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2013 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 "webkit/child/web_discardable_memory_impl.h"
-
-namespace webkit_glue {
-
-WebDiscardableMemoryImpl::~WebDiscardableMemoryImpl() {}
-
-// static
-scoped_ptr<WebDiscardableMemoryImpl>
-WebDiscardableMemoryImpl::CreateLockedMemory(size_t size) {
- scoped_ptr<base::DiscardableMemory> memory(
- base::DiscardableMemory::CreateLockedMemory(size));
- if (!memory)
- return scoped_ptr<WebDiscardableMemoryImpl>();
- return make_scoped_ptr(new WebDiscardableMemoryImpl(memory.Pass()));
-}
-
-bool WebDiscardableMemoryImpl::lock() {
- base::LockDiscardableMemoryStatus status = discardable_->Lock();
- switch (status) {
- case base::DISCARDABLE_MEMORY_SUCCESS:
- return true;
- case base::DISCARDABLE_MEMORY_PURGED:
- discardable_->Unlock();
- return false;
- default:
- discardable_.reset();
- return false;
- }
-}
-
-void WebDiscardableMemoryImpl::unlock() {
- discardable_->Unlock();
-}
-
-void* WebDiscardableMemoryImpl::data() {
- return discardable_->Memory();
-}
-
-WebDiscardableMemoryImpl::WebDiscardableMemoryImpl(
- scoped_ptr<base::DiscardableMemory> memory)
- : discardable_(memory.Pass()) {
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/child/web_discardable_memory_impl.h b/chromium/webkit/child/web_discardable_memory_impl.h
deleted file mode 100644
index 38e9b6bbf30..00000000000
--- a/chromium/webkit/child/web_discardable_memory_impl.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2013 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 WEBKIT_CHILD_WEB_DISCARDABLE_MEMORY_IMPL_H_
-#define WEBKIT_CHILD_WEB_DISCARDABLE_MEMORY_IMPL_H_
-
-#include "base/basictypes.h"
-#include "base/memory/discardable_memory.h"
-#include "base/memory/scoped_ptr.h"
-#include "third_party/WebKit/public/platform/WebDiscardableMemory.h"
-#include "webkit/child/webkit_child_export.h"
-
-namespace blink {
-class WebDiscardableMemory;
-}
-
-namespace webkit_glue {
-
-// Implementation of WebDiscardableMemory that is responsible for allocating
-// discardable memory.
-class WEBKIT_CHILD_EXPORT WebDiscardableMemoryImpl
- : NON_EXPORTED_BASE(public blink::WebDiscardableMemory) {
- public:
- virtual ~WebDiscardableMemoryImpl();
-
- static scoped_ptr<WebDiscardableMemoryImpl> CreateLockedMemory(size_t size);
-
- // blink::WebDiscardableMemory:
- virtual bool lock();
- virtual void unlock();
- virtual void* data();
-
- private:
- WebDiscardableMemoryImpl(scoped_ptr<base::DiscardableMemory> memory);
-
- scoped_ptr<base::DiscardableMemory> discardable_;
-
- DISALLOW_COPY_AND_ASSIGN(WebDiscardableMemoryImpl);
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_WEB_DISCARDABLE_MEMORY_IMPL_H_
diff --git a/chromium/webkit/child/webfallbackthemeengine_impl.cc b/chromium/webkit/child/webfallbackthemeengine_impl.cc
deleted file mode 100644
index 43787f13c1e..00000000000
--- a/chromium/webkit/child/webfallbackthemeengine_impl.cc
+++ /dev/null
@@ -1,191 +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 "webkit/child/webfallbackthemeengine_impl.h"
-
-#include "skia/ext/platform_canvas.h"
-#include "third_party/WebKit/public/platform/WebRect.h"
-#include "third_party/WebKit/public/platform/WebSize.h"
-#include "ui/native_theme/fallback_theme.h"
-
-using blink::WebCanvas;
-using blink::WebColor;
-using blink::WebRect;
-using blink::WebFallbackThemeEngine;
-
-namespace webkit_glue {
-
-static ui::NativeTheme::Part NativeThemePart(
- WebFallbackThemeEngine::Part part) {
- switch (part) {
- case WebFallbackThemeEngine::PartScrollbarDownArrow:
- return ui::NativeTheme::kScrollbarDownArrow;
- case WebFallbackThemeEngine::PartScrollbarLeftArrow:
- return ui::NativeTheme::kScrollbarLeftArrow;
- case WebFallbackThemeEngine::PartScrollbarRightArrow:
- return ui::NativeTheme::kScrollbarRightArrow;
- case WebFallbackThemeEngine::PartScrollbarUpArrow:
- return ui::NativeTheme::kScrollbarUpArrow;
- case WebFallbackThemeEngine::PartScrollbarHorizontalThumb:
- return ui::NativeTheme::kScrollbarHorizontalThumb;
- case WebFallbackThemeEngine::PartScrollbarVerticalThumb:
- return ui::NativeTheme::kScrollbarVerticalThumb;
- case WebFallbackThemeEngine::PartScrollbarHorizontalTrack:
- return ui::NativeTheme::kScrollbarHorizontalTrack;
- case WebFallbackThemeEngine::PartScrollbarVerticalTrack:
- return ui::NativeTheme::kScrollbarVerticalTrack;
- case WebFallbackThemeEngine::PartCheckbox:
- return ui::NativeTheme::kCheckbox;
- case WebFallbackThemeEngine::PartRadio:
- return ui::NativeTheme::kRadio;
- case WebFallbackThemeEngine::PartButton:
- return ui::NativeTheme::kPushButton;
- case WebFallbackThemeEngine::PartTextField:
- return ui::NativeTheme::kTextField;
- case WebFallbackThemeEngine::PartMenuList:
- return ui::NativeTheme::kMenuList;
- case WebFallbackThemeEngine::PartSliderTrack:
- return ui::NativeTheme::kSliderTrack;
- case WebFallbackThemeEngine::PartSliderThumb:
- return ui::NativeTheme::kSliderThumb;
- case WebFallbackThemeEngine::PartInnerSpinButton:
- return ui::NativeTheme::kInnerSpinButton;
- case WebFallbackThemeEngine::PartProgressBar:
- return ui::NativeTheme::kProgressBar;
- default:
- return ui::NativeTheme::kScrollbarDownArrow;
- }
-}
-
-static ui::NativeTheme::State NativeThemeState(
- WebFallbackThemeEngine::State state) {
- switch (state) {
- case WebFallbackThemeEngine::StateDisabled:
- return ui::NativeTheme::kDisabled;
- case WebFallbackThemeEngine::StateHover:
- return ui::NativeTheme::kHovered;
- case WebFallbackThemeEngine::StateNormal:
- return ui::NativeTheme::kNormal;
- case WebFallbackThemeEngine::StatePressed:
- return ui::NativeTheme::kPressed;
- default:
- return ui::NativeTheme::kDisabled;
- }
-}
-
-static void GetNativeThemeExtraParams(
- WebFallbackThemeEngine::Part part,
- WebFallbackThemeEngine::State state,
- const WebFallbackThemeEngine::ExtraParams* extra_params,
- ui::NativeTheme::ExtraParams* native_theme_extra_params) {
- switch (part) {
- case WebFallbackThemeEngine::PartScrollbarHorizontalTrack:
- case WebFallbackThemeEngine::PartScrollbarVerticalTrack:
- native_theme_extra_params->scrollbar_track.track_x =
- extra_params->scrollbarTrack.trackX;
- native_theme_extra_params->scrollbar_track.track_y =
- extra_params->scrollbarTrack.trackY;
- native_theme_extra_params->scrollbar_track.track_width =
- extra_params->scrollbarTrack.trackWidth;
- native_theme_extra_params->scrollbar_track.track_height =
- extra_params->scrollbarTrack.trackHeight;
- break;
- case WebFallbackThemeEngine::PartCheckbox:
- native_theme_extra_params->button.checked = extra_params->button.checked;
- native_theme_extra_params->button.indeterminate =
- extra_params->button.indeterminate;
- break;
- case WebFallbackThemeEngine::PartRadio:
- native_theme_extra_params->button.checked = extra_params->button.checked;
- break;
- case WebFallbackThemeEngine::PartButton:
- native_theme_extra_params->button.is_default =
- extra_params->button.isDefault;
- native_theme_extra_params->button.has_border =
- extra_params->button.hasBorder;
- // Native buttons have a different focus style.
- native_theme_extra_params->button.is_focused = false;
- native_theme_extra_params->button.background_color =
- extra_params->button.backgroundColor;
- break;
- case WebFallbackThemeEngine::PartTextField:
- native_theme_extra_params->text_field.is_text_area =
- extra_params->textField.isTextArea;
- native_theme_extra_params->text_field.is_listbox =
- extra_params->textField.isListbox;
- native_theme_extra_params->text_field.background_color =
- extra_params->textField.backgroundColor;
- break;
- case WebFallbackThemeEngine::PartMenuList:
- native_theme_extra_params->menu_list.has_border =
- extra_params->menuList.hasBorder;
- native_theme_extra_params->menu_list.has_border_radius =
- extra_params->menuList.hasBorderRadius;
- native_theme_extra_params->menu_list.arrow_x =
- extra_params->menuList.arrowX;
- native_theme_extra_params->menu_list.arrow_y =
- extra_params->menuList.arrowY;
- native_theme_extra_params->menu_list.background_color =
- extra_params->menuList.backgroundColor;
- break;
- case WebFallbackThemeEngine::PartSliderTrack:
- case WebFallbackThemeEngine::PartSliderThumb:
- native_theme_extra_params->slider.vertical =
- extra_params->slider.vertical;
- native_theme_extra_params->slider.in_drag = extra_params->slider.inDrag;
- break;
- case WebFallbackThemeEngine::PartInnerSpinButton:
- native_theme_extra_params->inner_spin.spin_up =
- extra_params->innerSpin.spinUp;
- native_theme_extra_params->inner_spin.read_only =
- extra_params->innerSpin.readOnly;
- break;
- case WebFallbackThemeEngine::PartProgressBar:
- native_theme_extra_params->progress_bar.determinate =
- extra_params->progressBar.determinate;
- native_theme_extra_params->progress_bar.value_rect_x =
- extra_params->progressBar.valueRectX;
- native_theme_extra_params->progress_bar.value_rect_y =
- extra_params->progressBar.valueRectY;
- native_theme_extra_params->progress_bar.value_rect_width =
- extra_params->progressBar.valueRectWidth;
- native_theme_extra_params->progress_bar.value_rect_height =
- extra_params->progressBar.valueRectHeight;
- break;
- default:
- break; // Parts that have no extra params get here.
- }
-}
-
-WebFallbackThemeEngineImpl::WebFallbackThemeEngineImpl()
- : theme_(new ui::FallbackTheme()) {
-}
-
-WebFallbackThemeEngineImpl::~WebFallbackThemeEngineImpl() {}
-
-blink::WebSize WebFallbackThemeEngineImpl::getSize(
- WebFallbackThemeEngine::Part part) {
- ui::NativeTheme::ExtraParams extra;
- return theme_->GetPartSize(NativeThemePart(part),
- ui::NativeTheme::kNormal,
- extra);
-}
-
-void WebFallbackThemeEngineImpl::paint(
- blink::WebCanvas* canvas,
- WebFallbackThemeEngine::Part part,
- WebFallbackThemeEngine::State state,
- const blink::WebRect& rect,
- const WebFallbackThemeEngine::ExtraParams* extra_params) {
- ui::NativeTheme::ExtraParams native_theme_extra_params;
- GetNativeThemeExtraParams(
- part, state, extra_params, &native_theme_extra_params);
- theme_->Paint(canvas,
- NativeThemePart(part),
- NativeThemeState(state),
- gfx::Rect(rect),
- native_theme_extra_params);
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/child/webfallbackthemeengine_impl.h b/chromium/webkit/child/webfallbackthemeengine_impl.h
deleted file mode 100644
index 84eac420068..00000000000
--- a/chromium/webkit/child/webfallbackthemeengine_impl.h
+++ /dev/null
@@ -1,39 +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.
-
-#ifndef WEBKIT_CHILD_WEBFALLBACKTHEMEENGINE_IMPL_H_
-#define WEBKIT_CHILD_WEBFALLBACKTHEMEENGINE_IMPL_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "third_party/WebKit/public/platform/WebFallbackThemeEngine.h"
-
-namespace ui {
-class FallbackTheme;
-}
-
-namespace webkit_glue {
-
-class WebFallbackThemeEngineImpl : public blink::WebFallbackThemeEngine {
- public:
- WebFallbackThemeEngineImpl();
- virtual ~WebFallbackThemeEngineImpl();
-
- // WebFallbackThemeEngine methods:
- virtual blink::WebSize getSize(blink::WebFallbackThemeEngine::Part);
- virtual void paint(
- blink::WebCanvas* canvas,
- blink::WebFallbackThemeEngine::Part part,
- blink::WebFallbackThemeEngine::State state,
- const blink::WebRect& rect,
- const blink::WebFallbackThemeEngine::ExtraParams* extra_params);
-
- private:
- scoped_ptr<ui::FallbackTheme> theme_;
-
- DISALLOW_COPY_AND_ASSIGN(WebFallbackThemeEngineImpl);
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_WEBFALLBACKTHEMEENGINE_IMPL_H_
diff --git a/chromium/webkit/child/webkit_child.gyp b/chromium/webkit/child/webkit_child.gyp
index 141b1ac0092..e4ac2d20a3a 100644
--- a/chromium/webkit/child/webkit_child.gyp
+++ b/chromium/webkit/child/webkit_child.gyp
@@ -40,11 +40,10 @@
'<(DEPTH)/skia/skia.gyp:skia',
'<(DEPTH)/third_party/WebKit/public/blink.gyp:blink',
'<(DEPTH)/ui/gfx/gfx.gyp:gfx',
+ '<(DEPTH)/ui/gfx/gfx.gyp:gfx_geometry',
'<(DEPTH)/ui/native_theme/native_theme.gyp:native_theme',
- '<(DEPTH)/ui/ui.gyp:ui',
'<(DEPTH)/url/url.gyp:url_lib',
'<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
- '<(DEPTH)/webkit/common/user_agent/webkit_user_agent.gyp:user_agent',
'<(DEPTH)/webkit/common/webkit_common.gyp:webkit_common',
],
'include_dirs': [
@@ -55,63 +54,17 @@
# include the header generated above.
'hard_dependency': 1,
'sources': [
- 'fling_animator_impl_android.cc',
- 'fling_animator_impl_android.h',
- 'fling_curve_configuration.cc',
- 'fling_curve_configuration.h',
- 'ftp_directory_listing_response_delegate.cc',
- 'ftp_directory_listing_response_delegate.h',
'multipart_response_delegate.cc',
'multipart_response_delegate.h',
'resource_loader_bridge.cc',
'resource_loader_bridge.h',
- 'touch_fling_gesture_curve.cc',
- 'touch_fling_gesture_curve.h',
- 'web_discardable_memory_impl.cc',
- 'web_discardable_memory_impl.h',
- 'webfallbackthemeengine_impl.cc',
- 'webfallbackthemeengine_impl.h',
'webkit_child_export.h',
- 'webkit_child_helpers.cc',
- 'webkit_child_helpers.h',
- 'webkitplatformsupport_child_impl.cc',
- 'webkitplatformsupport_child_impl.h',
- 'webkitplatformsupport_impl.cc',
- 'webkitplatformsupport_impl.h',
- 'websocketstreamhandle_bridge.h',
- 'websocketstreamhandle_delegate.h',
- 'websocketstreamhandle_impl.cc',
- 'websocketstreamhandle_impl.h',
- 'webthemeengine_impl_android.cc',
- 'webthemeengine_impl_android.h',
- 'webthemeengine_impl_default.cc',
- 'webthemeengine_impl_default.h',
- 'webthemeengine_impl_mac.cc',
- 'webthemeengine_impl_mac.h',
- 'webthemeengine_impl_win.cc',
- 'webthemeengine_impl_win.h',
- 'webthread_impl.cc',
- 'webthread_impl.h',
- 'weburlloader_impl.cc',
- 'weburlloader_impl.h',
- 'weburlrequest_extradata_impl.cc',
- 'weburlrequest_extradata_impl.h',
'weburlresponse_extradata_impl.cc',
'weburlresponse_extradata_impl.h',
- 'worker_task_runner.cc',
- 'worker_task_runner.h',
],
# TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
'msvs_disabled_warnings': [ 4267 ],
'conditions': [
- ['use_default_render_theme==0',
- {
- 'sources/': [
- ['exclude', 'webthemeengine_impl_default.cc'],
- ['exclude', 'webthemeengine_impl_default.h'],
- ],
- }
- ],
['OS=="mac"',
{
'link_settings': {
diff --git a/chromium/webkit/child/webkit_child_helpers.cc b/chromium/webkit/child/webkit_child_helpers.cc
deleted file mode 100644
index 422163f45f5..00000000000
--- a/chromium/webkit/child/webkit_child_helpers.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) 2013 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 "webkit/child/webkit_child_helpers.h"
-
-#if defined(OS_LINUX)
-#include <malloc.h>
-#endif
-
-#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/process/process_metrics.h"
-#include "v8/include/v8.h"
-
-namespace webkit_glue {
-
-#if defined(OS_LINUX) || defined(OS_ANDROID)
-size_t MemoryUsageKB() {
- struct mallinfo minfo = mallinfo();
- uint64_t mem_usage =
-#if defined(USE_TCMALLOC)
- minfo.uordblks
-#else
- (minfo.hblkhd + minfo.arena)
-#endif
- >> 10;
-
- v8::HeapStatistics stat;
- // TODO(svenpanne) The call below doesn't take web workers into account, this
- // has to be done manually by iterating over all Isolates involved.
- v8::Isolate::GetCurrent()->GetHeapStatistics(&stat);
- return mem_usage + (static_cast<uint64_t>(stat.total_heap_size()) >> 10);
-}
-#elif defined(OS_MACOSX)
-size_t MemoryUsageKB() {
- scoped_ptr<base::ProcessMetrics> process_metrics(
- // The default port provider is sufficient to get data for the current
- // process.
- base::ProcessMetrics::CreateProcessMetrics(
- base::GetCurrentProcessHandle(), NULL));
- return process_metrics->GetWorkingSetSize() >> 10;
-}
-#else
-size_t MemoryUsageKB() {
- scoped_ptr<base::ProcessMetrics> process_metrics(
- base::ProcessMetrics::CreateProcessMetrics(
- base::GetCurrentProcessHandle()));
- return process_metrics->GetPagefileUsage() >> 10;
-}
-#endif
-
-} // webkit_glue
diff --git a/chromium/webkit/child/webkit_child_helpers.h b/chromium/webkit/child/webkit_child_helpers.h
deleted file mode 100644
index 3262fa23138..00000000000
--- a/chromium/webkit/child/webkit_child_helpers.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) 2013 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 WEBKIT_CHILD_WEBKIT_CHILD_HELPERS_H_
-#define WEBKIT_CHILD_WEBKIT_CHILD_HELPERS_H_
-
-#include "base/basictypes.h"
-#include "webkit/child/webkit_child_export.h"
-
-namespace webkit_glue {
-
-// Returns an estimate of the memory usage of the renderer process. Different
-// platforms implement this function differently, and count in different
-// allocations. Results are not comparable across platforms. The estimate is
-// computed inside the sandbox and thus its not always accurate.
-WEBKIT_CHILD_EXPORT size_t MemoryUsageKB();
-
-} // webkit_glue
-
-#endif // WEBKIT_CHILD_WEBKIT_CHILD_HELPERS_H_
diff --git a/chromium/webkit/child/webkitplatformsupport_child_impl.cc b/chromium/webkit/child/webkitplatformsupport_child_impl.cc
deleted file mode 100644
index 3bb2b1954cb..00000000000
--- a/chromium/webkit/child/webkitplatformsupport_child_impl.cc
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2013 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 "webkit/child/webkitplatformsupport_child_impl.h"
-
-#include "base/memory/discardable_memory.h"
-#include "third_party/WebKit/public/web/WebInputEvent.h"
-#include "webkit/child/fling_curve_configuration.h"
-#include "webkit/child/web_discardable_memory_impl.h"
-#include "webkit/child/webthread_impl.h"
-#include "webkit/child/worker_task_runner.h"
-
-#if defined(OS_ANDROID)
-#include "webkit/child/fling_animator_impl_android.h"
-#endif
-
-using blink::WebFallbackThemeEngine;
-using blink::WebThemeEngine;
-
-namespace webkit_glue {
-
-WebKitPlatformSupportChildImpl::WebKitPlatformSupportChildImpl()
- : current_thread_slot_(&DestroyCurrentThread),
- fling_curve_configuration_(new FlingCurveConfiguration) {}
-
-WebKitPlatformSupportChildImpl::~WebKitPlatformSupportChildImpl() {}
-
-WebThemeEngine* WebKitPlatformSupportChildImpl::themeEngine() {
- return &native_theme_engine_;
-}
-
-WebFallbackThemeEngine* WebKitPlatformSupportChildImpl::fallbackThemeEngine() {
- return &fallback_theme_engine_;
-}
-
-void WebKitPlatformSupportChildImpl::SetFlingCurveParameters(
- const std::vector<float>& new_touchpad,
- const std::vector<float>& new_touchscreen) {
- fling_curve_configuration_->SetCurveParameters(new_touchpad, new_touchscreen);
-}
-
-blink::WebGestureCurve*
-WebKitPlatformSupportChildImpl::createFlingAnimationCurve(
- int device_source,
- const blink::WebFloatPoint& velocity,
- const blink::WebSize& cumulative_scroll) {
-#if defined(OS_ANDROID)
- return FlingAnimatorImpl::CreateAndroidGestureCurve(velocity,
- cumulative_scroll);
-#endif
-
- if (device_source == blink::WebGestureEvent::Touchscreen)
- return fling_curve_configuration_->CreateForTouchScreen(velocity,
- cumulative_scroll);
-
- return fling_curve_configuration_->CreateForTouchPad(velocity,
- cumulative_scroll);
-}
-
-blink::WebThread* WebKitPlatformSupportChildImpl::createThread(
- const char* name) {
- return new WebThreadImpl(name);
-}
-
-blink::WebThread* WebKitPlatformSupportChildImpl::currentThread() {
- WebThreadImplForMessageLoop* thread =
- static_cast<WebThreadImplForMessageLoop*>(current_thread_slot_.Get());
- if (thread)
- return (thread);
-
- scoped_refptr<base::MessageLoopProxy> message_loop =
- base::MessageLoopProxy::current();
- if (!message_loop.get())
- return NULL;
-
- thread = new WebThreadImplForMessageLoop(message_loop.get());
- current_thread_slot_.Set(thread);
- return thread;
-}
-
-void WebKitPlatformSupportChildImpl::didStartWorkerRunLoop(
- const blink::WebWorkerRunLoop& runLoop) {
- WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance();
- worker_task_runner->OnWorkerRunLoopStarted(runLoop);
-}
-
-void WebKitPlatformSupportChildImpl::didStopWorkerRunLoop(
- const blink::WebWorkerRunLoop& runLoop) {
- WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance();
- worker_task_runner->OnWorkerRunLoopStopped(runLoop);
-}
-
-blink::WebDiscardableMemory*
-WebKitPlatformSupportChildImpl::allocateAndLockDiscardableMemory(size_t bytes) {
- if (!base::DiscardableMemory::SupportedNatively())
- return NULL;
- return WebDiscardableMemoryImpl::CreateLockedMemory(bytes).release();
-}
-
-// static
-void WebKitPlatformSupportChildImpl::DestroyCurrentThread(void* thread) {
- WebThreadImplForMessageLoop* impl =
- static_cast<WebThreadImplForMessageLoop*>(thread);
- delete impl;
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/child/webkitplatformsupport_child_impl.h b/chromium/webkit/child/webkitplatformsupport_child_impl.h
deleted file mode 100644
index 43e447d00e1..00000000000
--- a/chromium/webkit/child/webkitplatformsupport_child_impl.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// // Copyright 2013 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 WEBKIT_CHILD_WEBKITPLATFORMSUPPORT_CHILD_IMPL_H_
-#define WEBKIT_CHILD_WEBKITPLATFORMSUPPORT_CHILD_IMPL_H_
-
-#include "base/threading/thread_local_storage.h"
-#include "webkit/child/webfallbackthemeengine_impl.h"
-#include "webkit/child/webkit_child_export.h"
-#include "webkit/child/webkitplatformsupport_impl.h"
-
-#if defined(USE_DEFAULT_RENDER_THEME)
-#include "webkit/child/webthemeengine_impl_default.h"
-#elif defined(OS_WIN)
-#include "webkit/child/webthemeengine_impl_win.h"
-#elif defined(OS_MACOSX)
-#include "webkit/child/webthemeengine_impl_mac.h"
-#elif defined(OS_ANDROID)
-#include "webkit/child/webthemeengine_impl_android.h"
-#endif
-
-namespace webkit_glue {
-
-class FlingCurveConfiguration;
-
-class WEBKIT_CHILD_EXPORT WebKitPlatformSupportChildImpl :
- public WebKitPlatformSupportImpl {
- public:
- WebKitPlatformSupportChildImpl();
- virtual ~WebKitPlatformSupportChildImpl();
-
- // Platform methods (partial implementation):
- virtual blink::WebThemeEngine* themeEngine();
- virtual blink::WebFallbackThemeEngine* fallbackThemeEngine();
-
- void SetFlingCurveParameters(
- const std::vector<float>& new_touchpad,
- const std::vector<float>& new_touchscreen);
-
- virtual blink::WebGestureCurve* createFlingAnimationCurve(
- int device_source,
- const blink::WebFloatPoint& velocity,
- const blink::WebSize& cumulative_scroll) OVERRIDE;
-
- virtual blink::WebThread* createThread(const char* name);
- virtual blink::WebThread* currentThread();
-
- virtual void didStartWorkerRunLoop(
- const blink::WebWorkerRunLoop& runLoop) OVERRIDE;
- virtual void didStopWorkerRunLoop(
- const blink::WebWorkerRunLoop& runLoop) OVERRIDE;
-
- virtual blink::WebDiscardableMemory* allocateAndLockDiscardableMemory(
- size_t bytes);
-
- private:
- static void DestroyCurrentThread(void*);
-
- WebThemeEngineImpl native_theme_engine_;
- WebFallbackThemeEngineImpl fallback_theme_engine_;
- base::ThreadLocalStorage::Slot current_thread_slot_;
- scoped_ptr<FlingCurveConfiguration> fling_curve_configuration_;
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_WEBKITPLATFORMSUPPORT_CHILD_IMPL_H_
diff --git a/chromium/webkit/child/webkitplatformsupport_impl.cc b/chromium/webkit/child/webkitplatformsupport_impl.cc
deleted file mode 100644
index 5b70672ffc1..00000000000
--- a/chromium/webkit/child/webkitplatformsupport_impl.cc
+++ /dev/null
@@ -1,947 +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 "webkit/child/webkitplatformsupport_impl.h"
-
-#include <math.h>
-
-#include <vector>
-
-#include "base/allocator/allocator_extension.h"
-#include "base/bind.h"
-#include "base/files/file_path.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/singleton.h"
-#include "base/message_loop/message_loop.h"
-#include "base/metrics/histogram.h"
-#include "base/metrics/sparse_histogram.h"
-#include "base/metrics/stats_counters.h"
-#include "base/platform_file.h"
-#include "base/process/process_metrics.h"
-#include "base/rand_util.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/synchronization/lock.h"
-#include "base/sys_info.h"
-#include "base/time/time.h"
-#include "grit/blink_resources.h"
-#include "grit/webkit_resources.h"
-#include "grit/webkit_strings.h"
-#include "net/base/data_url.h"
-#include "net/base/mime_util.h"
-#include "net/base/net_errors.h"
-#include "third_party/WebKit/public/platform/WebCookie.h"
-#include "third_party/WebKit/public/platform/WebData.h"
-#include "third_party/WebKit/public/platform/WebDiscardableMemory.h"
-#include "third_party/WebKit/public/platform/WebGestureCurve.h"
-#include "third_party/WebKit/public/platform/WebPluginListBuilder.h"
-#include "third_party/WebKit/public/platform/WebScreenInfo.h"
-#include "third_party/WebKit/public/platform/WebString.h"
-#include "third_party/WebKit/public/platform/WebURL.h"
-#include "third_party/WebKit/public/platform/WebVector.h"
-#include "third_party/WebKit/public/web/WebFrameClient.h"
-#include "third_party/WebKit/public/web/WebInputEvent.h"
-#include "ui/base/layout.h"
-#include "webkit/child/webkit_child_helpers.h"
-#include "webkit/child/websocketstreamhandle_impl.h"
-#include "webkit/child/weburlloader_impl.h"
-#include "webkit/common/user_agent/user_agent.h"
-
-#if defined(OS_ANDROID)
-#include "base/android/sys_utils.h"
-#endif
-
-#if !defined(NO_TCMALLOC) && defined(USE_TCMALLOC) && !defined(OS_WIN)
-#include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h"
-#endif
-
-using blink::WebAudioBus;
-using blink::WebCookie;
-using blink::WebData;
-using blink::WebLocalizedString;
-using blink::WebPluginListBuilder;
-using blink::WebString;
-using blink::WebSocketStreamHandle;
-using blink::WebURL;
-using blink::WebURLError;
-using blink::WebURLLoader;
-using blink::WebVector;
-
-namespace {
-
-// A simple class to cache the memory usage for a given amount of time.
-class MemoryUsageCache {
- public:
- // Retrieves the Singleton.
- static MemoryUsageCache* GetInstance() {
- return Singleton<MemoryUsageCache>::get();
- }
-
- MemoryUsageCache() : memory_value_(0) { Init(); }
- ~MemoryUsageCache() {}
-
- void Init() {
- const unsigned int kCacheSeconds = 1;
- cache_valid_time_ = base::TimeDelta::FromSeconds(kCacheSeconds);
- }
-
- // Returns true if the cached value is fresh.
- // Returns false if the cached value is stale, or if |cached_value| is NULL.
- bool IsCachedValueValid(size_t* cached_value) {
- base::AutoLock scoped_lock(lock_);
- if (!cached_value)
- return false;
- if (base::Time::Now() - last_updated_time_ > cache_valid_time_)
- return false;
- *cached_value = memory_value_;
- return true;
- };
-
- // Setter for |memory_value_|, refreshes |last_updated_time_|.
- void SetMemoryValue(const size_t value) {
- base::AutoLock scoped_lock(lock_);
- memory_value_ = value;
- last_updated_time_ = base::Time::Now();
- }
-
- private:
- // The cached memory value.
- size_t memory_value_;
-
- // How long the cached value should remain valid.
- base::TimeDelta cache_valid_time_;
-
- // The last time the cached value was updated.
- base::Time last_updated_time_;
-
- base::Lock lock_;
-};
-
-} // anonymous namespace
-
-namespace webkit_glue {
-
-static int ToMessageID(WebLocalizedString::Name name) {
- switch (name) {
- case WebLocalizedString::AXAMPMFieldText:
- return IDS_AX_AM_PM_FIELD_TEXT;
- case WebLocalizedString::AXButtonActionVerb:
- return IDS_AX_BUTTON_ACTION_VERB;
- case WebLocalizedString::AXCheckedCheckBoxActionVerb:
- return IDS_AX_CHECKED_CHECK_BOX_ACTION_VERB;
- case WebLocalizedString::AXDateTimeFieldEmptyValueText:
- return IDS_AX_DATE_TIME_FIELD_EMPTY_VALUE_TEXT;
- case WebLocalizedString::AXDayOfMonthFieldText:
- return IDS_AX_DAY_OF_MONTH_FIELD_TEXT;
- case WebLocalizedString::AXHeadingText:
- return IDS_AX_ROLE_HEADING;
- case WebLocalizedString::AXHourFieldText:
- return IDS_AX_HOUR_FIELD_TEXT;
- case WebLocalizedString::AXImageMapText:
- return IDS_AX_ROLE_IMAGE_MAP;
- case WebLocalizedString::AXLinkActionVerb:
- return IDS_AX_LINK_ACTION_VERB;
- case WebLocalizedString::AXLinkText:
- return IDS_AX_ROLE_LINK;
- case WebLocalizedString::AXListMarkerText:
- return IDS_AX_ROLE_LIST_MARKER;
- case WebLocalizedString::AXMediaDefault:
- return IDS_AX_MEDIA_DEFAULT;
- case WebLocalizedString::AXMediaAudioElement:
- return IDS_AX_MEDIA_AUDIO_ELEMENT;
- case WebLocalizedString::AXMediaVideoElement:
- return IDS_AX_MEDIA_VIDEO_ELEMENT;
- case WebLocalizedString::AXMediaMuteButton:
- return IDS_AX_MEDIA_MUTE_BUTTON;
- case WebLocalizedString::AXMediaUnMuteButton:
- return IDS_AX_MEDIA_UNMUTE_BUTTON;
- case WebLocalizedString::AXMediaPlayButton:
- return IDS_AX_MEDIA_PLAY_BUTTON;
- case WebLocalizedString::AXMediaPauseButton:
- return IDS_AX_MEDIA_PAUSE_BUTTON;
- case WebLocalizedString::AXMediaSlider:
- return IDS_AX_MEDIA_SLIDER;
- case WebLocalizedString::AXMediaSliderThumb:
- return IDS_AX_MEDIA_SLIDER_THUMB;
- case WebLocalizedString::AXMediaRewindButton:
- return IDS_AX_MEDIA_REWIND_BUTTON;
- case WebLocalizedString::AXMediaReturnToRealTime:
- return IDS_AX_MEDIA_RETURN_TO_REALTIME_BUTTON;
- case WebLocalizedString::AXMediaCurrentTimeDisplay:
- return IDS_AX_MEDIA_CURRENT_TIME_DISPLAY;
- case WebLocalizedString::AXMediaTimeRemainingDisplay:
- return IDS_AX_MEDIA_TIME_REMAINING_DISPLAY;
- case WebLocalizedString::AXMediaStatusDisplay:
- return IDS_AX_MEDIA_STATUS_DISPLAY;
- case WebLocalizedString::AXMediaEnterFullscreenButton:
- return IDS_AX_MEDIA_ENTER_FULL_SCREEN_BUTTON;
- case WebLocalizedString::AXMediaExitFullscreenButton:
- return IDS_AX_MEDIA_EXIT_FULL_SCREEN_BUTTON;
- case WebLocalizedString::AXMediaSeekForwardButton:
- return IDS_AX_MEDIA_SEEK_FORWARD_BUTTON;
- case WebLocalizedString::AXMediaSeekBackButton:
- return IDS_AX_MEDIA_SEEK_BACK_BUTTON;
- case WebLocalizedString::AXMediaShowClosedCaptionsButton:
- return IDS_AX_MEDIA_SHOW_CLOSED_CAPTIONS_BUTTON;
- case WebLocalizedString::AXMediaHideClosedCaptionsButton:
- return IDS_AX_MEDIA_HIDE_CLOSED_CAPTIONS_BUTTON;
- case WebLocalizedString::AXMediaAudioElementHelp:
- return IDS_AX_MEDIA_AUDIO_ELEMENT_HELP;
- case WebLocalizedString::AXMediaVideoElementHelp:
- return IDS_AX_MEDIA_VIDEO_ELEMENT_HELP;
- case WebLocalizedString::AXMediaMuteButtonHelp:
- return IDS_AX_MEDIA_MUTE_BUTTON_HELP;
- case WebLocalizedString::AXMediaUnMuteButtonHelp:
- return IDS_AX_MEDIA_UNMUTE_BUTTON_HELP;
- case WebLocalizedString::AXMediaPlayButtonHelp:
- return IDS_AX_MEDIA_PLAY_BUTTON_HELP;
- case WebLocalizedString::AXMediaPauseButtonHelp:
- return IDS_AX_MEDIA_PAUSE_BUTTON_HELP;
- case WebLocalizedString::AXMediaSliderHelp:
- return IDS_AX_MEDIA_SLIDER_HELP;
- case WebLocalizedString::AXMediaSliderThumbHelp:
- return IDS_AX_MEDIA_SLIDER_THUMB_HELP;
- case WebLocalizedString::AXMediaRewindButtonHelp:
- return IDS_AX_MEDIA_REWIND_BUTTON_HELP;
- case WebLocalizedString::AXMediaReturnToRealTimeHelp:
- return IDS_AX_MEDIA_RETURN_TO_REALTIME_BUTTON_HELP;
- case WebLocalizedString::AXMediaCurrentTimeDisplayHelp:
- return IDS_AX_MEDIA_CURRENT_TIME_DISPLAY_HELP;
- case WebLocalizedString::AXMediaTimeRemainingDisplayHelp:
- return IDS_AX_MEDIA_TIME_REMAINING_DISPLAY_HELP;
- case WebLocalizedString::AXMediaStatusDisplayHelp:
- return IDS_AX_MEDIA_STATUS_DISPLAY_HELP;
- case WebLocalizedString::AXMediaEnterFullscreenButtonHelp:
- return IDS_AX_MEDIA_ENTER_FULL_SCREEN_BUTTON_HELP;
- case WebLocalizedString::AXMediaExitFullscreenButtonHelp:
- return IDS_AX_MEDIA_EXIT_FULL_SCREEN_BUTTON_HELP;
- case WebLocalizedString::AXMediaSeekForwardButtonHelp:
- return IDS_AX_MEDIA_SEEK_FORWARD_BUTTON_HELP;
- case WebLocalizedString::AXMediaSeekBackButtonHelp:
- return IDS_AX_MEDIA_SEEK_BACK_BUTTON_HELP;
- case WebLocalizedString::AXMediaShowClosedCaptionsButtonHelp:
- return IDS_AX_MEDIA_SHOW_CLOSED_CAPTIONS_BUTTON_HELP;
- case WebLocalizedString::AXMediaHideClosedCaptionsButtonHelp:
- return IDS_AX_MEDIA_HIDE_CLOSED_CAPTIONS_BUTTON_HELP;
- case WebLocalizedString::AXMillisecondFieldText:
- return IDS_AX_MILLISECOND_FIELD_TEXT;
- case WebLocalizedString::AXMinuteFieldText:
- return IDS_AX_MINUTE_FIELD_TEXT;
- case WebLocalizedString::AXMonthFieldText:
- return IDS_AX_MONTH_FIELD_TEXT;
- case WebLocalizedString::AXRadioButtonActionVerb:
- return IDS_AX_RADIO_BUTTON_ACTION_VERB;
- case WebLocalizedString::AXSecondFieldText:
- return IDS_AX_SECOND_FIELD_TEXT;
- case WebLocalizedString::AXTextFieldActionVerb:
- return IDS_AX_TEXT_FIELD_ACTION_VERB;
- case WebLocalizedString::AXUncheckedCheckBoxActionVerb:
- return IDS_AX_UNCHECKED_CHECK_BOX_ACTION_VERB;
- case WebLocalizedString::AXWebAreaText:
- return IDS_AX_ROLE_WEB_AREA;
- case WebLocalizedString::AXWeekOfYearFieldText:
- return IDS_AX_WEEK_OF_YEAR_FIELD_TEXT;
- case WebLocalizedString::AXYearFieldText:
- return IDS_AX_YEAR_FIELD_TEXT;
- case WebLocalizedString::CalendarClear:
- return IDS_FORM_CALENDAR_CLEAR;
- case WebLocalizedString::CalendarToday:
- return IDS_FORM_CALENDAR_TODAY;
- case WebLocalizedString::DateFormatDayInMonthLabel:
- return IDS_FORM_DATE_FORMAT_DAY_IN_MONTH;
- case WebLocalizedString::DateFormatMonthLabel:
- return IDS_FORM_DATE_FORMAT_MONTH;
- case WebLocalizedString::DateFormatYearLabel:
- return IDS_FORM_DATE_FORMAT_YEAR;
- case WebLocalizedString::DetailsLabel:
- return IDS_DETAILS_WITHOUT_SUMMARY_LABEL;
- case WebLocalizedString::FileButtonChooseFileLabel:
- return IDS_FORM_FILE_BUTTON_LABEL;
- case WebLocalizedString::FileButtonChooseMultipleFilesLabel:
- return IDS_FORM_MULTIPLE_FILES_BUTTON_LABEL;
- case WebLocalizedString::FileButtonNoFileSelectedLabel:
- return IDS_FORM_FILE_NO_FILE_LABEL;
- case WebLocalizedString::InputElementAltText:
- return IDS_FORM_INPUT_ALT;
- case WebLocalizedString::KeygenMenuHighGradeKeySize:
- return IDS_KEYGEN_HIGH_GRADE_KEY;
- case WebLocalizedString::KeygenMenuMediumGradeKeySize:
- return IDS_KEYGEN_MED_GRADE_KEY;
- case WebLocalizedString::MissingPluginText:
- return IDS_PLUGIN_INITIALIZATION_ERROR;
- case WebLocalizedString::MultipleFileUploadText:
- return IDS_FORM_FILE_MULTIPLE_UPLOAD;
- case WebLocalizedString::OtherColorLabel:
- return IDS_FORM_OTHER_COLOR_LABEL;
- case WebLocalizedString::OtherDateLabel:
- return IDS_FORM_OTHER_DATE_LABEL;
- case WebLocalizedString::OtherMonthLabel:
- return IDS_FORM_OTHER_MONTH_LABEL;
- case WebLocalizedString::OtherTimeLabel:
- return IDS_FORM_OTHER_TIME_LABEL;
- case WebLocalizedString::OtherWeekLabel:
- return IDS_FORM_OTHER_WEEK_LABEL;
- case WebLocalizedString::PlaceholderForDayOfMonthField:
- return IDS_FORM_PLACEHOLDER_FOR_DAY_OF_MONTH_FIELD;
- case WebLocalizedString::PlaceholderForMonthField:
- return IDS_FORM_PLACEHOLDER_FOR_MONTH_FIELD;
- case WebLocalizedString::PlaceholderForYearField:
- return IDS_FORM_PLACEHOLDER_FOR_YEAR_FIELD;
- case WebLocalizedString::ResetButtonDefaultLabel:
- return IDS_FORM_RESET_LABEL;
- case WebLocalizedString::SearchableIndexIntroduction:
- return IDS_SEARCHABLE_INDEX_INTRO;
- case WebLocalizedString::SearchMenuClearRecentSearchesText:
- return IDS_RECENT_SEARCHES_CLEAR;
- case WebLocalizedString::SearchMenuNoRecentSearchesText:
- return IDS_RECENT_SEARCHES_NONE;
- case WebLocalizedString::SearchMenuRecentSearchesText:
- return IDS_RECENT_SEARCHES;
- case WebLocalizedString::SubmitButtonDefaultLabel:
- return IDS_FORM_SUBMIT_LABEL;
- case WebLocalizedString::ThisMonthButtonLabel:
- return IDS_FORM_THIS_MONTH_LABEL;
- case WebLocalizedString::ThisWeekButtonLabel:
- return IDS_FORM_THIS_WEEK_LABEL;
- case WebLocalizedString::ValidationBadInputForDateTime:
- return IDS_FORM_VALIDATION_BAD_INPUT_DATETIME;
- case WebLocalizedString::ValidationBadInputForNumber:
- return IDS_FORM_VALIDATION_BAD_INPUT_NUMBER;
- case WebLocalizedString::ValidationPatternMismatch:
- return IDS_FORM_VALIDATION_PATTERN_MISMATCH;
- case WebLocalizedString::ValidationRangeOverflow:
- return IDS_FORM_VALIDATION_RANGE_OVERFLOW;
- case WebLocalizedString::ValidationRangeOverflowDateTime:
- return IDS_FORM_VALIDATION_RANGE_OVERFLOW_DATETIME;
- case WebLocalizedString::ValidationRangeUnderflow:
- return IDS_FORM_VALIDATION_RANGE_UNDERFLOW;
- case WebLocalizedString::ValidationRangeUnderflowDateTime:
- return IDS_FORM_VALIDATION_RANGE_UNDERFLOW_DATETIME;
- case WebLocalizedString::ValidationStepMismatch:
- return IDS_FORM_VALIDATION_STEP_MISMATCH;
- case WebLocalizedString::ValidationStepMismatchCloseToLimit:
- return IDS_FORM_VALIDATION_STEP_MISMATCH_CLOSE_TO_LIMIT;
- case WebLocalizedString::ValidationTooLong:
- return IDS_FORM_VALIDATION_TOO_LONG;
- case WebLocalizedString::ValidationTypeMismatch:
- return IDS_FORM_VALIDATION_TYPE_MISMATCH;
- case WebLocalizedString::ValidationTypeMismatchForEmail:
- return IDS_FORM_VALIDATION_TYPE_MISMATCH_EMAIL;
- case WebLocalizedString::ValidationTypeMismatchForEmailEmpty:
- return IDS_FORM_VALIDATION_TYPE_MISMATCH_EMAIL_EMPTY;
- case WebLocalizedString::ValidationTypeMismatchForEmailEmptyDomain:
- return IDS_FORM_VALIDATION_TYPE_MISMATCH_EMAIL_EMPTY_DOMAIN;
- case WebLocalizedString::ValidationTypeMismatchForEmailEmptyLocal:
- return IDS_FORM_VALIDATION_TYPE_MISMATCH_EMAIL_EMPTY_LOCAL;
- case WebLocalizedString::ValidationTypeMismatchForEmailInvalidDomain:
- return IDS_FORM_VALIDATION_TYPE_MISMATCH_EMAIL_INVALID_DOMAIN;
- case WebLocalizedString::ValidationTypeMismatchForEmailInvalidDots:
- return IDS_FORM_VALIDATION_TYPE_MISMATCH_EMAIL_INVALID_DOTS;
- case WebLocalizedString::ValidationTypeMismatchForEmailInvalidLocal:
- return IDS_FORM_VALIDATION_TYPE_MISMATCH_EMAIL_INVALID_LOCAL;
- case WebLocalizedString::ValidationTypeMismatchForEmailNoAtSign:
- return IDS_FORM_VALIDATION_TYPE_MISMATCH_EMAIL_NO_AT_SIGN;
- case WebLocalizedString::ValidationTypeMismatchForMultipleEmail:
- return IDS_FORM_VALIDATION_TYPE_MISMATCH_MULTIPLE_EMAIL;
- case WebLocalizedString::ValidationTypeMismatchForURL:
- return IDS_FORM_VALIDATION_TYPE_MISMATCH_URL;
- case WebLocalizedString::ValidationValueMissing:
- return IDS_FORM_VALIDATION_VALUE_MISSING;
- case WebLocalizedString::ValidationValueMissingForCheckbox:
- return IDS_FORM_VALIDATION_VALUE_MISSING_CHECKBOX;
- case WebLocalizedString::ValidationValueMissingForFile:
- return IDS_FORM_VALIDATION_VALUE_MISSING_FILE;
- case WebLocalizedString::ValidationValueMissingForMultipleFile:
- return IDS_FORM_VALIDATION_VALUE_MISSING_MULTIPLE_FILE;
- case WebLocalizedString::ValidationValueMissingForRadio:
- return IDS_FORM_VALIDATION_VALUE_MISSING_RADIO;
- case WebLocalizedString::ValidationValueMissingForSelect:
- return IDS_FORM_VALIDATION_VALUE_MISSING_SELECT;
- case WebLocalizedString::WeekFormatTemplate:
- return IDS_FORM_INPUT_WEEK_TEMPLATE;
- case WebLocalizedString::WeekNumberLabel:
- return IDS_FORM_WEEK_NUMBER_LABEL;
- // This "default:" line exists to avoid compile warnings about enum
- // coverage when we add a new symbol to WebLocalizedString.h in WebKit.
- // After a planned WebKit patch is landed, we need to add a case statement
- // for the added symbol here.
- default:
- break;
- }
- return -1;
-}
-
-WebKitPlatformSupportImpl::WebKitPlatformSupportImpl()
- : main_loop_(base::MessageLoop::current()),
- shared_timer_func_(NULL),
- shared_timer_fire_time_(0.0),
- shared_timer_fire_time_was_set_while_suspended_(false),
- shared_timer_suspended_(0) {}
-
-WebKitPlatformSupportImpl::~WebKitPlatformSupportImpl() {
-}
-
-WebURLLoader* WebKitPlatformSupportImpl::createURLLoader() {
- return new WebURLLoaderImpl(this);
-}
-
-WebSocketStreamHandle* WebKitPlatformSupportImpl::createSocketStreamHandle() {
- return new WebSocketStreamHandleImpl(this);
-}
-
-WebString WebKitPlatformSupportImpl::userAgent(const WebURL& url) {
- return WebString::fromUTF8(webkit_glue::GetUserAgent(url));
-}
-
-WebData WebKitPlatformSupportImpl::parseDataURL(
- const WebURL& url,
- WebString& mimetype_out,
- WebString& charset_out) {
- std::string mime_type, char_set, data;
- if (net::DataURL::Parse(url, &mime_type, &char_set, &data)
- && net::IsSupportedMimeType(mime_type)) {
- mimetype_out = WebString::fromUTF8(mime_type);
- charset_out = WebString::fromUTF8(char_set);
- return data;
- }
- return WebData();
-}
-
-WebURLError WebKitPlatformSupportImpl::cancelledError(
- const WebURL& unreachableURL) const {
- return WebURLLoaderImpl::CreateError(unreachableURL, net::ERR_ABORTED);
-}
-
-void WebKitPlatformSupportImpl::decrementStatsCounter(const char* name) {
- base::StatsCounter(name).Decrement();
-}
-
-void WebKitPlatformSupportImpl::incrementStatsCounter(const char* name) {
- base::StatsCounter(name).Increment();
-}
-
-void WebKitPlatformSupportImpl::histogramCustomCounts(
- const char* name, int sample, int min, int max, int bucket_count) {
- // Copied from histogram macro, but without the static variable caching
- // the histogram because name is dynamic.
- base::HistogramBase* counter =
- base::Histogram::FactoryGet(name, min, max, bucket_count,
- base::HistogramBase::kUmaTargetedHistogramFlag);
- DCHECK_EQ(name, counter->histogram_name());
- counter->Add(sample);
-}
-
-void WebKitPlatformSupportImpl::histogramEnumeration(
- const char* name, int sample, int boundary_value) {
- // Copied from histogram macro, but without the static variable caching
- // the histogram because name is dynamic.
- base::HistogramBase* counter =
- base::LinearHistogram::FactoryGet(name, 1, boundary_value,
- boundary_value + 1, base::HistogramBase::kUmaTargetedHistogramFlag);
- DCHECK_EQ(name, counter->histogram_name());
- counter->Add(sample);
-}
-
-void WebKitPlatformSupportImpl::histogramSparse(const char* name, int sample) {
- // For sparse histograms, we can use the macro, as it does not incorporate a
- // static.
- UMA_HISTOGRAM_SPARSE_SLOWLY(name, sample);
-}
-
-const unsigned char* WebKitPlatformSupportImpl::getTraceCategoryEnabledFlag(
- const char* category_group) {
- return TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group);
-}
-
-long* WebKitPlatformSupportImpl::getTraceSamplingState(
- const unsigned thread_bucket) {
- switch (thread_bucket) {
- case 0:
- return reinterpret_cast<long*>(&TRACE_EVENT_API_THREAD_BUCKET(0));
- case 1:
- return reinterpret_cast<long*>(&TRACE_EVENT_API_THREAD_BUCKET(1));
- case 2:
- return reinterpret_cast<long*>(&TRACE_EVENT_API_THREAD_BUCKET(2));
- default:
- NOTREACHED() << "Unknown thread bucket type.";
- }
- return NULL;
-}
-
-COMPILE_ASSERT(
- sizeof(blink::Platform::TraceEventHandle) ==
- sizeof(base::debug::TraceEventHandle),
- TraceEventHandle_types_must_be_same_size);
-
-blink::Platform::TraceEventHandle WebKitPlatformSupportImpl::addTraceEvent(
- char phase,
- const unsigned char* category_group_enabled,
- const char* name,
- unsigned long long id,
- int num_args,
- const char** arg_names,
- const unsigned char* arg_types,
- const unsigned long long* arg_values,
- unsigned char flags) {
- base::debug::TraceEventHandle handle = TRACE_EVENT_API_ADD_TRACE_EVENT(
- phase, category_group_enabled, name, id,
- num_args, arg_names, arg_types, arg_values, NULL, flags);
- blink::Platform::TraceEventHandle result;
- memcpy(&result, &handle, sizeof(result));
- return result;
-}
-
-void WebKitPlatformSupportImpl::updateTraceEventDuration(
- const unsigned char* category_group_enabled,
- const char* name,
- TraceEventHandle handle) {
- base::debug::TraceEventHandle traceEventHandle;
- memcpy(&traceEventHandle, &handle, sizeof(handle));
- TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
- category_group_enabled, name, traceEventHandle);
-}
-
-namespace {
-
-WebData loadAudioSpatializationResource(WebKitPlatformSupportImpl* platform,
- const char* name) {
-#ifdef IDR_AUDIO_SPATIALIZATION_COMPOSITE
- if (!strcmp(name, "Composite")) {
- base::StringPiece resource =
- platform->GetDataResource(IDR_AUDIO_SPATIALIZATION_COMPOSITE,
- ui::SCALE_FACTOR_NONE);
- return WebData(resource.data(), resource.size());
- }
-#endif
-
-#ifdef IDR_AUDIO_SPATIALIZATION_T000_P000
- const size_t kExpectedSpatializationNameLength = 31;
- if (strlen(name) != kExpectedSpatializationNameLength) {
- return WebData();
- }
-
- // Extract the azimuth and elevation from the resource name.
- int azimuth = 0;
- int elevation = 0;
- int values_parsed =
- sscanf(name, "IRC_Composite_C_R0195_T%3d_P%3d", &azimuth, &elevation);
- if (values_parsed != 2) {
- return WebData();
- }
-
- // The resource index values go through the elevations first, then azimuths.
- const int kAngleSpacing = 15;
-
- // 0 <= elevation <= 90 (or 315 <= elevation <= 345)
- // in increments of 15 degrees.
- int elevation_index =
- elevation <= 90 ? elevation / kAngleSpacing :
- 7 + (elevation - 315) / kAngleSpacing;
- bool is_elevation_index_good = 0 <= elevation_index && elevation_index < 10;
-
- // 0 <= azimuth < 360 in increments of 15 degrees.
- int azimuth_index = azimuth / kAngleSpacing;
- bool is_azimuth_index_good = 0 <= azimuth_index && azimuth_index < 24;
-
- const int kNumberOfElevations = 10;
- const int kNumberOfAudioResources = 240;
- int resource_index = kNumberOfElevations * azimuth_index + elevation_index;
- bool is_resource_index_good = 0 <= resource_index &&
- resource_index < kNumberOfAudioResources;
-
- if (is_azimuth_index_good && is_elevation_index_good &&
- is_resource_index_good) {
- const int kFirstAudioResourceIndex = IDR_AUDIO_SPATIALIZATION_T000_P000;
- base::StringPiece resource =
- platform->GetDataResource(kFirstAudioResourceIndex + resource_index,
- ui::SCALE_FACTOR_NONE);
- return WebData(resource.data(), resource.size());
- }
-#endif // IDR_AUDIO_SPATIALIZATION_T000_P000
-
- NOTREACHED();
- return WebData();
-}
-
-struct DataResource {
- const char* name;
- int id;
- ui::ScaleFactor scale_factor;
-};
-
-const DataResource kDataResources[] = {
- { "missingImage", IDR_BROKENIMAGE, ui::SCALE_FACTOR_100P },
- { "missingImage@2x", IDR_BROKENIMAGE, ui::SCALE_FACTOR_200P },
- { "mediaplayerPause", IDR_MEDIAPLAYER_PAUSE_BUTTON, ui::SCALE_FACTOR_100P },
- { "mediaplayerPauseHover",
- IDR_MEDIAPLAYER_PAUSE_BUTTON_HOVER, ui::SCALE_FACTOR_100P },
- { "mediaplayerPauseDown",
- IDR_MEDIAPLAYER_PAUSE_BUTTON_DOWN, ui::SCALE_FACTOR_100P },
- { "mediaplayerPlay", IDR_MEDIAPLAYER_PLAY_BUTTON, ui::SCALE_FACTOR_100P },
- { "mediaplayerPlayHover",
- IDR_MEDIAPLAYER_PLAY_BUTTON_HOVER, ui::SCALE_FACTOR_100P },
- { "mediaplayerPlayDown",
- IDR_MEDIAPLAYER_PLAY_BUTTON_DOWN, ui::SCALE_FACTOR_100P },
- { "mediaplayerPlayDisabled",
- IDR_MEDIAPLAYER_PLAY_BUTTON_DISABLED, ui::SCALE_FACTOR_100P },
- { "mediaplayerSoundLevel3",
- IDR_MEDIAPLAYER_SOUND_LEVEL3_BUTTON, ui::SCALE_FACTOR_100P },
- { "mediaplayerSoundLevel3Hover",
- IDR_MEDIAPLAYER_SOUND_LEVEL3_BUTTON_HOVER, ui::SCALE_FACTOR_100P },
- { "mediaplayerSoundLevel3Down",
- IDR_MEDIAPLAYER_SOUND_LEVEL3_BUTTON_DOWN, ui::SCALE_FACTOR_100P },
- { "mediaplayerSoundLevel2",
- IDR_MEDIAPLAYER_SOUND_LEVEL2_BUTTON, ui::SCALE_FACTOR_100P },
- { "mediaplayerSoundLevel2Hover",
- IDR_MEDIAPLAYER_SOUND_LEVEL2_BUTTON_HOVER, ui::SCALE_FACTOR_100P },
- { "mediaplayerSoundLevel2Down",
- IDR_MEDIAPLAYER_SOUND_LEVEL2_BUTTON_DOWN, ui::SCALE_FACTOR_100P },
- { "mediaplayerSoundLevel1",
- IDR_MEDIAPLAYER_SOUND_LEVEL1_BUTTON, ui::SCALE_FACTOR_100P },
- { "mediaplayerSoundLevel1Hover",
- IDR_MEDIAPLAYER_SOUND_LEVEL1_BUTTON_HOVER, ui::SCALE_FACTOR_100P },
- { "mediaplayerSoundLevel1Down",
- IDR_MEDIAPLAYER_SOUND_LEVEL1_BUTTON_DOWN, ui::SCALE_FACTOR_100P },
- { "mediaplayerSoundLevel0",
- IDR_MEDIAPLAYER_SOUND_LEVEL0_BUTTON, ui::SCALE_FACTOR_100P },
- { "mediaplayerSoundLevel0Hover",
- IDR_MEDIAPLAYER_SOUND_LEVEL0_BUTTON_HOVER, ui::SCALE_FACTOR_100P },
- { "mediaplayerSoundLevel0Down",
- IDR_MEDIAPLAYER_SOUND_LEVEL0_BUTTON_DOWN, ui::SCALE_FACTOR_100P },
- { "mediaplayerSoundDisabled",
- IDR_MEDIAPLAYER_SOUND_DISABLED, ui::SCALE_FACTOR_100P },
- { "mediaplayerSliderThumb",
- IDR_MEDIAPLAYER_SLIDER_THUMB, ui::SCALE_FACTOR_100P },
- { "mediaplayerSliderThumbHover",
- IDR_MEDIAPLAYER_SLIDER_THUMB_HOVER, ui::SCALE_FACTOR_100P },
- { "mediaplayerSliderThumbDown",
- IDR_MEDIAPLAYER_SLIDER_THUMB_DOWN, ui::SCALE_FACTOR_100P },
- { "mediaplayerVolumeSliderThumb",
- IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB, ui::SCALE_FACTOR_100P },
- { "mediaplayerVolumeSliderThumbHover",
- IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB_HOVER, ui::SCALE_FACTOR_100P },
- { "mediaplayerVolumeSliderThumbDown",
- IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB_DOWN, ui::SCALE_FACTOR_100P },
- { "mediaplayerVolumeSliderThumbDisabled",
- IDR_MEDIAPLAYER_VOLUME_SLIDER_THUMB_DISABLED, ui::SCALE_FACTOR_100P },
- { "mediaplayerClosedCaption",
- IDR_MEDIAPLAYER_CLOSEDCAPTION_BUTTON, ui::SCALE_FACTOR_100P },
- { "mediaplayerClosedCaptionHover",
- IDR_MEDIAPLAYER_CLOSEDCAPTION_BUTTON_HOVER, ui::SCALE_FACTOR_100P },
- { "mediaplayerClosedCaptionDown",
- IDR_MEDIAPLAYER_CLOSEDCAPTION_BUTTON_DOWN, ui::SCALE_FACTOR_100P },
- { "mediaplayerClosedCaptionDisabled",
- IDR_MEDIAPLAYER_CLOSEDCAPTION_BUTTON_DISABLED, ui::SCALE_FACTOR_100P },
- { "mediaplayerFullscreen",
- IDR_MEDIAPLAYER_FULLSCREEN_BUTTON, ui::SCALE_FACTOR_100P },
- { "mediaplayerFullscreenHover",
- IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_HOVER, ui::SCALE_FACTOR_100P },
- { "mediaplayerFullscreenDown",
- IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_DOWN, ui::SCALE_FACTOR_100P },
- { "mediaplayerFullscreenDisabled",
- IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_DISABLED, ui::SCALE_FACTOR_100P },
-#if defined(OS_ANDROID)
- { "mediaplayerOverlayPlay",
- IDR_MEDIAPLAYER_OVERLAY_PLAY_BUTTON, ui::SCALE_FACTOR_100P },
-#endif
-#if defined(OS_MACOSX)
- { "overhangPattern", IDR_OVERHANG_PATTERN, ui::SCALE_FACTOR_100P },
- { "overhangShadow", IDR_OVERHANG_SHADOW, ui::SCALE_FACTOR_100P },
-#endif
- { "panIcon", IDR_PAN_SCROLL_ICON, ui::SCALE_FACTOR_100P },
- { "searchCancel", IDR_SEARCH_CANCEL, ui::SCALE_FACTOR_100P },
- { "searchCancelPressed", IDR_SEARCH_CANCEL_PRESSED, ui::SCALE_FACTOR_100P },
- { "searchMagnifier", IDR_SEARCH_MAGNIFIER, ui::SCALE_FACTOR_100P },
- { "searchMagnifierResults",
- IDR_SEARCH_MAGNIFIER_RESULTS, ui::SCALE_FACTOR_100P },
- { "textAreaResizeCorner", IDR_TEXTAREA_RESIZER, ui::SCALE_FACTOR_100P },
- { "textAreaResizeCorner@2x", IDR_TEXTAREA_RESIZER, ui::SCALE_FACTOR_200P },
- { "inputSpeech", IDR_INPUT_SPEECH, ui::SCALE_FACTOR_100P },
- { "inputSpeechRecording", IDR_INPUT_SPEECH_RECORDING, ui::SCALE_FACTOR_100P },
- { "inputSpeechWaiting", IDR_INPUT_SPEECH_WAITING, ui::SCALE_FACTOR_100P },
- { "americanExpressCC", IDR_AUTOFILL_CC_AMEX, ui::SCALE_FACTOR_100P },
- { "dinersCC", IDR_AUTOFILL_CC_DINERS, ui::SCALE_FACTOR_100P },
- { "discoverCC", IDR_AUTOFILL_CC_DISCOVER, ui::SCALE_FACTOR_100P },
- { "genericCC", IDR_AUTOFILL_CC_GENERIC, ui::SCALE_FACTOR_100P },
- { "jcbCC", IDR_AUTOFILL_CC_JCB, ui::SCALE_FACTOR_100P },
- { "masterCardCC", IDR_AUTOFILL_CC_MASTERCARD, ui::SCALE_FACTOR_100P },
- { "visaCC", IDR_AUTOFILL_CC_VISA, ui::SCALE_FACTOR_100P },
- { "generatePassword", IDR_PASSWORD_GENERATION_ICON, ui::SCALE_FACTOR_100P },
- { "generatePasswordHover",
- IDR_PASSWORD_GENERATION_ICON_HOVER, ui::SCALE_FACTOR_100P },
- { "syntheticTouchCursor",
- IDR_SYNTHETIC_TOUCH_CURSOR, ui::SCALE_FACTOR_100P },
-};
-
-} // namespace
-
-WebData WebKitPlatformSupportImpl::loadResource(const char* name) {
- // Some clients will call into this method with an empty |name| when they have
- // optional resources. For example, the PopupMenuChromium code can have icons
- // for some Autofill items but not for others.
- if (!strlen(name))
- return WebData();
-
- // Check the name prefix to see if it's an audio resource.
- if (StartsWithASCII(name, "IRC_Composite", true) ||
- StartsWithASCII(name, "Composite", true))
- return loadAudioSpatializationResource(this, name);
-
- // TODO(flackr): We should use a better than linear search here, a trie would
- // be ideal.
- for (size_t i = 0; i < arraysize(kDataResources); ++i) {
- if (!strcmp(name, kDataResources[i].name)) {
- base::StringPiece resource =
- GetDataResource(kDataResources[i].id,
- kDataResources[i].scale_factor);
- return WebData(resource.data(), resource.size());
- }
- }
-
- NOTREACHED() << "Unknown image resource " << name;
- return WebData();
-}
-
-WebString WebKitPlatformSupportImpl::queryLocalizedString(
- WebLocalizedString::Name name) {
- int message_id = ToMessageID(name);
- if (message_id < 0)
- return WebString();
- return GetLocalizedString(message_id);
-}
-
-WebString WebKitPlatformSupportImpl::queryLocalizedString(
- WebLocalizedString::Name name, int numeric_value) {
- return queryLocalizedString(name, base::IntToString16(numeric_value));
-}
-
-WebString WebKitPlatformSupportImpl::queryLocalizedString(
- WebLocalizedString::Name name, const WebString& value) {
- int message_id = ToMessageID(name);
- if (message_id < 0)
- return WebString();
- return ReplaceStringPlaceholders(GetLocalizedString(message_id), value, NULL);
-}
-
-WebString WebKitPlatformSupportImpl::queryLocalizedString(
- WebLocalizedString::Name name,
- const WebString& value1,
- const WebString& value2) {
- int message_id = ToMessageID(name);
- if (message_id < 0)
- return WebString();
- std::vector<base::string16> values;
- values.reserve(2);
- values.push_back(value1);
- values.push_back(value2);
- return ReplaceStringPlaceholders(
- GetLocalizedString(message_id), values, NULL);
-}
-
-double WebKitPlatformSupportImpl::currentTime() {
- return base::Time::Now().ToDoubleT();
-}
-
-double WebKitPlatformSupportImpl::monotonicallyIncreasingTime() {
- return base::TimeTicks::Now().ToInternalValue() /
- static_cast<double>(base::Time::kMicrosecondsPerSecond);
-}
-
-void WebKitPlatformSupportImpl::cryptographicallyRandomValues(
- unsigned char* buffer, size_t length) {
- base::RandBytes(buffer, length);
-}
-
-void WebKitPlatformSupportImpl::setSharedTimerFiredFunction(void (*func)()) {
- shared_timer_func_ = func;
-}
-
-void WebKitPlatformSupportImpl::setSharedTimerFireInterval(
- double interval_seconds) {
- shared_timer_fire_time_ = interval_seconds + monotonicallyIncreasingTime();
- if (shared_timer_suspended_) {
- shared_timer_fire_time_was_set_while_suspended_ = true;
- return;
- }
-
- // By converting between double and int64 representation, we run the risk
- // of losing precision due to rounding errors. Performing computations in
- // microseconds reduces this risk somewhat. But there still is the potential
- // of us computing a fire time for the timer that is shorter than what we
- // need.
- // As the event loop will check event deadlines prior to actually firing
- // them, there is a risk of needlessly rescheduling events and of
- // needlessly looping if sleep times are too short even by small amounts.
- // This results in measurable performance degradation unless we use ceil() to
- // always round up the sleep times.
- int64 interval = static_cast<int64>(
- ceil(interval_seconds * base::Time::kMillisecondsPerSecond)
- * base::Time::kMicrosecondsPerMillisecond);
-
- if (interval < 0)
- interval = 0;
-
- shared_timer_.Stop();
- shared_timer_.Start(FROM_HERE, base::TimeDelta::FromMicroseconds(interval),
- this, &WebKitPlatformSupportImpl::DoTimeout);
- OnStartSharedTimer(base::TimeDelta::FromMicroseconds(interval));
-}
-
-void WebKitPlatformSupportImpl::stopSharedTimer() {
- shared_timer_.Stop();
-}
-
-void WebKitPlatformSupportImpl::callOnMainThread(
- void (*func)(void*), void* context) {
- main_loop_->PostTask(FROM_HERE, base::Bind(func, context));
-}
-
-base::PlatformFile WebKitPlatformSupportImpl::databaseOpenFile(
- const blink::WebString& vfs_file_name, int desired_flags) {
- return base::kInvalidPlatformFileValue;
-}
-
-int WebKitPlatformSupportImpl::databaseDeleteFile(
- const blink::WebString& vfs_file_name, bool sync_dir) {
- return -1;
-}
-
-long WebKitPlatformSupportImpl::databaseGetFileAttributes(
- const blink::WebString& vfs_file_name) {
- return 0;
-}
-
-long long WebKitPlatformSupportImpl::databaseGetFileSize(
- const blink::WebString& vfs_file_name) {
- return 0;
-}
-
-long long WebKitPlatformSupportImpl::databaseGetSpaceAvailableForOrigin(
- const blink::WebString& origin_identifier) {
- return 0;
-}
-
-blink::WebString WebKitPlatformSupportImpl::signedPublicKeyAndChallengeString(
- unsigned key_size_index,
- const blink::WebString& challenge,
- const blink::WebURL& url) {
- return blink::WebString("");
-}
-
-static scoped_ptr<base::ProcessMetrics> CurrentProcessMetrics() {
- using base::ProcessMetrics;
-#if defined(OS_MACOSX)
- return scoped_ptr<ProcessMetrics>(
- // The default port provider is sufficient to get data for the current
- // process.
- ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle(),
- NULL));
-#else
- return scoped_ptr<ProcessMetrics>(
- ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle()));
-#endif
-}
-
-static size_t getMemoryUsageMB(bool bypass_cache) {
- size_t current_mem_usage = 0;
- MemoryUsageCache* mem_usage_cache_singleton = MemoryUsageCache::GetInstance();
- if (!bypass_cache &&
- mem_usage_cache_singleton->IsCachedValueValid(&current_mem_usage))
- return current_mem_usage;
-
- current_mem_usage = MemoryUsageKB() >> 10;
- mem_usage_cache_singleton->SetMemoryValue(current_mem_usage);
- return current_mem_usage;
-}
-
-size_t WebKitPlatformSupportImpl::memoryUsageMB() {
- return getMemoryUsageMB(false);
-}
-
-size_t WebKitPlatformSupportImpl::actualMemoryUsageMB() {
- return getMemoryUsageMB(true);
-}
-
-size_t WebKitPlatformSupportImpl::physicalMemoryMB() {
- return static_cast<size_t>(base::SysInfo::AmountOfPhysicalMemoryMB());
-}
-
-size_t WebKitPlatformSupportImpl::numberOfProcessors() {
- return static_cast<size_t>(base::SysInfo::NumberOfProcessors());
-}
-
-void WebKitPlatformSupportImpl::startHeapProfiling(
- const blink::WebString& prefix) {
- // FIXME(morrita): Make this built on windows.
-#if !defined(NO_TCMALLOC) && defined(USE_TCMALLOC) && !defined(OS_WIN)
- HeapProfilerStart(prefix.utf8().data());
-#endif
-}
-
-void WebKitPlatformSupportImpl::stopHeapProfiling() {
-#if !defined(NO_TCMALLOC) && defined(USE_TCMALLOC) && !defined(OS_WIN)
- HeapProfilerStop();
-#endif
-}
-
-void WebKitPlatformSupportImpl::dumpHeapProfiling(
- const blink::WebString& reason) {
-#if !defined(NO_TCMALLOC) && defined(USE_TCMALLOC) && !defined(OS_WIN)
- HeapProfilerDump(reason.utf8().data());
-#endif
-}
-
-WebString WebKitPlatformSupportImpl::getHeapProfile() {
-#if !defined(NO_TCMALLOC) && defined(USE_TCMALLOC) && !defined(OS_WIN)
- char* data = GetHeapProfile();
- WebString result = WebString::fromUTF8(std::string(data));
- free(data);
- return result;
-#else
- return WebString();
-#endif
-}
-
-bool WebKitPlatformSupportImpl::processMemorySizesInBytes(
- size_t* private_bytes,
- size_t* shared_bytes) {
- return CurrentProcessMetrics()->GetMemoryBytes(private_bytes, shared_bytes);
-}
-
-bool WebKitPlatformSupportImpl::memoryAllocatorWasteInBytes(size_t* size) {
- return base::allocator::GetAllocatorWasteSize(size);
-}
-
-size_t WebKitPlatformSupportImpl::maxDecodedImageBytes() {
-#if defined(OS_ANDROID)
- if (base::android::SysUtils::IsLowEndDevice()) {
- // Limit image decoded size to 3M pixels on low end devices.
- // 4 is maximum number of bytes per pixel.
- return 3 * 1024 * 1024 * 4;
- }
- // For other devices, limit decoded image size based on the amount of physical
- // memory. For a device with 2GB physical memory the limit is 16M pixels.
- return base::SysInfo::AmountOfPhysicalMemory() / 32;
-#else
- return noDecodedImageByteLimit;
-#endif
-}
-
-void WebKitPlatformSupportImpl::SuspendSharedTimer() {
- ++shared_timer_suspended_;
-}
-
-void WebKitPlatformSupportImpl::ResumeSharedTimer() {
- // The shared timer may have fired or been adjusted while we were suspended.
- if (--shared_timer_suspended_ == 0 &&
- (!shared_timer_.IsRunning() ||
- shared_timer_fire_time_was_set_while_suspended_)) {
- shared_timer_fire_time_was_set_while_suspended_ = false;
- setSharedTimerFireInterval(
- shared_timer_fire_time_ - monotonicallyIncreasingTime());
- }
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/child/webkitplatformsupport_impl.h b/chromium/webkit/child/webkitplatformsupport_impl.h
deleted file mode 100644
index 000708b6c50..00000000000
--- a/chromium/webkit/child/webkitplatformsupport_impl.h
+++ /dev/null
@@ -1,156 +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 WEBKIT_CHILD_WEBKITPLATFORMSUPPORT_IMPL_H_
-#define WEBKIT_CHILD_WEBKITPLATFORMSUPPORT_IMPL_H_
-
-#include "base/compiler_specific.h"
-#include "base/debug/trace_event.h"
-#include "base/platform_file.h"
-#include "base/timer/timer.h"
-#include "third_party/WebKit/public/platform/Platform.h"
-#include "third_party/WebKit/public/platform/WebURLError.h"
-#include "ui/base/layout.h"
-#include "webkit/child/resource_loader_bridge.h"
-#include "webkit/child/webkit_child_export.h"
-
-namespace base {
-class MessageLoop;
-}
-
-namespace blink {
-class WebSocketStreamHandle;
-}
-
-namespace webkit_glue {
-
-class WebSocketStreamHandleDelegate;
-class WebSocketStreamHandleBridge;
-
-class WEBKIT_CHILD_EXPORT WebKitPlatformSupportImpl :
- NON_EXPORTED_BASE(public blink::Platform) {
- public:
- WebKitPlatformSupportImpl();
- virtual ~WebKitPlatformSupportImpl();
-
- // Platform methods (partial implementation):
- virtual base::PlatformFile databaseOpenFile(
- const blink::WebString& vfs_file_name, int desired_flags);
- virtual int databaseDeleteFile(const blink::WebString& vfs_file_name,
- bool sync_dir);
- virtual long databaseGetFileAttributes(
- const blink::WebString& vfs_file_name);
- virtual long long databaseGetFileSize(const blink::WebString& vfs_file_name);
- virtual long long databaseGetSpaceAvailableForOrigin(
- const blink::WebString& origin_identifier);
- virtual blink::WebString signedPublicKeyAndChallengeString(
- unsigned key_size_index, const blink::WebString& challenge,
- const blink::WebURL& url);
- virtual size_t memoryUsageMB();
- virtual size_t actualMemoryUsageMB();
- virtual size_t physicalMemoryMB();
- virtual size_t numberOfProcessors();
-
- virtual void startHeapProfiling(const blink::WebString& prefix);
- virtual void stopHeapProfiling() OVERRIDE;
- virtual void dumpHeapProfiling(const blink::WebString& reason);
- virtual blink::WebString getHeapProfile() OVERRIDE;
-
- virtual bool processMemorySizesInBytes(size_t* private_bytes,
- size_t* shared_bytes);
- virtual bool memoryAllocatorWasteInBytes(size_t* size);
- virtual size_t maxDecodedImageBytes() OVERRIDE;
- virtual blink::WebURLLoader* createURLLoader();
- virtual blink::WebSocketStreamHandle* createSocketStreamHandle();
- virtual blink::WebString userAgent(const blink::WebURL& url);
- virtual blink::WebData parseDataURL(
- const blink::WebURL& url, blink::WebString& mimetype,
- blink::WebString& charset);
- virtual blink::WebURLError cancelledError(const blink::WebURL& url) const;
- virtual void decrementStatsCounter(const char* name);
- virtual void incrementStatsCounter(const char* name);
- virtual void histogramCustomCounts(
- const char* name, int sample, int min, int max, int bucket_count);
- virtual void histogramEnumeration(
- const char* name, int sample, int boundary_value);
- virtual void histogramSparse(const char* name, int sample);
- virtual const unsigned char* getTraceCategoryEnabledFlag(
- const char* category_name);
- virtual long* getTraceSamplingState(const unsigned thread_bucket);
- virtual TraceEventHandle addTraceEvent(
- char phase,
- const unsigned char* category_group_enabled,
- const char* name,
- unsigned long long id,
- int num_args,
- const char** arg_names,
- const unsigned char* arg_types,
- const unsigned long long* arg_values,
- unsigned char flags);
- virtual void updateTraceEventDuration(
- const unsigned char* category_group_enabled,
- const char* name,
- TraceEventHandle);
- virtual blink::WebData loadResource(const char* name);
- virtual blink::WebString queryLocalizedString(
- blink::WebLocalizedString::Name name);
- virtual blink::WebString queryLocalizedString(
- blink::WebLocalizedString::Name name, int numeric_value);
- virtual blink::WebString queryLocalizedString(
- blink::WebLocalizedString::Name name, const blink::WebString& value);
- virtual blink::WebString queryLocalizedString(
- blink::WebLocalizedString::Name name,
- const blink::WebString& value1, const blink::WebString& value2);
- virtual void suddenTerminationChanged(bool enabled) { }
- virtual double currentTime();
- virtual double monotonicallyIncreasingTime();
- virtual void cryptographicallyRandomValues(
- unsigned char* buffer, size_t length);
- virtual void setSharedTimerFiredFunction(void (*func)());
- virtual void setSharedTimerFireInterval(double interval_seconds);
- virtual void stopSharedTimer();
- virtual void callOnMainThread(void (*func)(void*), void* context);
-
-
- // Embedder functions. The following are not implemented by the glue layer and
- // need to be specialized by the embedder.
-
- // Gets a localized string given a message id. Returns an empty string if the
- // message id is not found.
- virtual base::string16 GetLocalizedString(int message_id) = 0;
-
- // Returns the raw data for a resource. This resource must have been
- // specified as BINDATA in the relevant .rc file.
- virtual base::StringPiece GetDataResource(int resource_id,
- ui::ScaleFactor scale_factor) = 0;
-
- // Creates a ResourceLoaderBridge.
- virtual ResourceLoaderBridge* CreateResourceLoader(
- const ResourceLoaderBridge::RequestInfo& request_info) = 0;
- // Creates a WebSocketStreamHandleBridge.
- virtual WebSocketStreamHandleBridge* CreateWebSocketStreamBridge(
- blink::WebSocketStreamHandle* handle,
- WebSocketStreamHandleDelegate* delegate) = 0;
-
- void SuspendSharedTimer();
- void ResumeSharedTimer();
- virtual void OnStartSharedTimer(base::TimeDelta delay) {}
-
- private:
- void DoTimeout() {
- if (shared_timer_func_ && !shared_timer_suspended_)
- shared_timer_func_();
- }
-
- base::MessageLoop* main_loop_;
- base::OneShotTimer<WebKitPlatformSupportImpl> shared_timer_;
- void (*shared_timer_func_)();
- double shared_timer_fire_time_;
- bool shared_timer_fire_time_was_set_while_suspended_;
- int shared_timer_suspended_; // counter
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_WEBKITPLATFORMSUPPORT_IMPL_H_
diff --git a/chromium/webkit/child/websocketstreamhandle_bridge.h b/chromium/webkit/child/websocketstreamhandle_bridge.h
deleted file mode 100644
index 23f5c6a1cbd..00000000000
--- a/chromium/webkit/child/websocketstreamhandle_bridge.h
+++ /dev/null
@@ -1,37 +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.
-
-#ifndef WEBKIT_CHILD_WEBSOCKETSTREAMHANDLE_BRIDGE_H_
-#define WEBKIT_CHILD_WEBSOCKETSTREAMHANDLE_BRIDGE_H_
-
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
-
-class GURL;
-
-namespace webkit_glue {
-
-class WebSocketStreamHandleBridge
- : public base::RefCountedThreadSafe<WebSocketStreamHandleBridge> {
- public:
- virtual void Connect(const GURL& url) = 0;
-
- virtual bool Send(const std::vector<char>& data) = 0;
-
- virtual void Close() = 0;
-
- protected:
- friend class base::RefCountedThreadSafe<WebSocketStreamHandleBridge>;
- WebSocketStreamHandleBridge() {}
- virtual ~WebSocketStreamHandleBridge() {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(WebSocketStreamHandleBridge);
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_WEBSOCKETSTREAMHANDLE_BRIDGE_H_
diff --git a/chromium/webkit/child/websocketstreamhandle_delegate.h b/chromium/webkit/child/websocketstreamhandle_delegate.h
deleted file mode 100644
index b7a2af3848d..00000000000
--- a/chromium/webkit/child/websocketstreamhandle_delegate.h
+++ /dev/null
@@ -1,44 +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 WEBKIT_CHILD_WEBSOCKETSTREAMHANDLE_DELEGATE_H_
-#define WEBKIT_CHILD_WEBSOCKETSTREAMHANDLE_DELEGATE_H_
-
-#include "base/strings/string16.h"
-
-class GURL;
-
-namespace blink {
-class WebSocketStreamHandle;
-}
-
-namespace webkit_glue {
-
-class WebSocketStreamHandleDelegate {
- public:
- WebSocketStreamHandleDelegate() {}
-
- virtual void WillOpenStream(blink::WebSocketStreamHandle* handle,
- const GURL& url) {}
- virtual void WillSendData(blink::WebSocketStreamHandle* handle,
- const char* data, int len) {}
-
- virtual void DidOpenStream(blink::WebSocketStreamHandle* handle,
- int max_amount_send_allowed) {}
- virtual void DidSendData(blink::WebSocketStreamHandle* handle,
- int amount_sent) {}
- virtual void DidReceiveData(blink::WebSocketStreamHandle* handle,
- const char* data, int len) {}
- virtual void DidClose(blink::WebSocketStreamHandle*) {}
- virtual void DidFail(blink::WebSocketStreamHandle* handle,
- int error_code,
- const string16& error_msg) {}
-
- protected:
- virtual ~WebSocketStreamHandleDelegate() {}
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_WEBSOCKETSTREAMHANDLE_DELEGATE_H_
diff --git a/chromium/webkit/child/websocketstreamhandle_impl.cc b/chromium/webkit/child/websocketstreamhandle_impl.cc
deleted file mode 100644
index d29859b2a1a..00000000000
--- a/chromium/webkit/child/websocketstreamhandle_impl.cc
+++ /dev/null
@@ -1,195 +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.
-
-// An implementation of WebSocketStreamHandle.
-
-#include "webkit/child/websocketstreamhandle_impl.h"
-
-#include <vector>
-
-#include "base/compiler_specific.h"
-#include "base/logging.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/strings/string16.h"
-#include "third_party/WebKit/public/platform/WebData.h"
-#include "third_party/WebKit/public/platform/WebSocketStreamError.h"
-#include "third_party/WebKit/public/platform/WebSocketStreamHandleClient.h"
-#include "third_party/WebKit/public/platform/WebURL.h"
-#include "webkit/child/webkitplatformsupport_impl.h"
-#include "webkit/child/websocketstreamhandle_bridge.h"
-#include "webkit/child/websocketstreamhandle_delegate.h"
-
-using blink::WebData;
-using blink::WebSocketStreamError;
-using blink::WebSocketStreamHandle;
-using blink::WebSocketStreamHandleClient;
-using blink::WebURL;
-
-namespace webkit_glue {
-
-// WebSocketStreamHandleImpl::Context -----------------------------------------
-
-class WebSocketStreamHandleImpl::Context
- : public base::RefCounted<Context>,
- public WebSocketStreamHandleDelegate {
- public:
- explicit Context(WebSocketStreamHandleImpl* handle);
-
- WebSocketStreamHandleClient* client() const { return client_; }
- void set_client(WebSocketStreamHandleClient* client) {
- client_ = client;
- }
-
- void Connect(const WebURL& url, WebKitPlatformSupportImpl* platform);
- bool Send(const WebData& data);
- void Close();
-
- // Must be called before |handle_| or |client_| is deleted.
- // Once detached, it never calls |client_| back.
- void Detach();
-
- // WebSocketStreamHandleDelegate methods:
- virtual void DidOpenStream(WebSocketStreamHandle*, int) OVERRIDE;
- virtual void DidSendData(WebSocketStreamHandle*, int) OVERRIDE;
- virtual void DidReceiveData(WebSocketStreamHandle*,
- const char*,
- int) OVERRIDE;
- virtual void DidClose(WebSocketStreamHandle*) OVERRIDE;
- virtual void DidFail(WebSocketStreamHandle*, int, const string16&) OVERRIDE;
-
- private:
- friend class base::RefCounted<Context>;
- virtual ~Context() {
- DCHECK(!handle_);
- DCHECK(!client_);
- DCHECK(!bridge_.get());
- }
-
- WebSocketStreamHandleImpl* handle_;
- WebSocketStreamHandleClient* client_;
- // |bridge_| is alive from Connect to DidClose, so Context must be alive
- // in the time period.
- scoped_refptr<WebSocketStreamHandleBridge> bridge_;
-
- DISALLOW_COPY_AND_ASSIGN(Context);
-};
-
-WebSocketStreamHandleImpl::Context::Context(WebSocketStreamHandleImpl* handle)
- : handle_(handle),
- client_(NULL) {
-}
-
-void WebSocketStreamHandleImpl::Context::Connect(
- const WebURL& url,
- WebKitPlatformSupportImpl* platform) {
- VLOG(1) << "Connect url=" << url;
- DCHECK(!bridge_.get());
- bridge_ = platform->CreateWebSocketStreamBridge(handle_, this);
- AddRef(); // Will be released by DidClose().
- bridge_->Connect(url);
-}
-
-bool WebSocketStreamHandleImpl::Context::Send(const WebData& data) {
- VLOG(1) << "Send data.size=" << data.size();
- DCHECK(bridge_.get());
- return bridge_->Send(
- std::vector<char>(data.data(), data.data() + data.size()));
-}
-
-void WebSocketStreamHandleImpl::Context::Close() {
- VLOG(1) << "Close";
- if (bridge_.get())
- bridge_->Close();
-}
-
-void WebSocketStreamHandleImpl::Context::Detach() {
- handle_ = NULL;
- client_ = NULL;
- // If Connect was called, |bridge_| is not NULL, so that this Context closes
- // the |bridge_| here. Then |bridge_| will call back DidClose, and will
- // be released by itself.
- // Otherwise, |bridge_| is NULL.
- if (bridge_.get())
- bridge_->Close();
-}
-
-void WebSocketStreamHandleImpl::Context::DidOpenStream(
- WebSocketStreamHandle* web_handle, int max_amount_send_allowed) {
- VLOG(1) << "DidOpen";
- if (client_)
- client_->didOpenStream(handle_, max_amount_send_allowed);
-}
-
-void WebSocketStreamHandleImpl::Context::DidSendData(
- WebSocketStreamHandle* web_handle, int amount_sent) {
- if (client_)
- client_->didSendData(handle_, amount_sent);
-}
-
-void WebSocketStreamHandleImpl::Context::DidReceiveData(
- WebSocketStreamHandle* web_handle, const char* data, int size) {
- if (client_)
- client_->didReceiveData(handle_, WebData(data, size));
-}
-
-void WebSocketStreamHandleImpl::Context::DidClose(
- WebSocketStreamHandle* web_handle) {
- VLOG(1) << "DidClose";
- bridge_ = NULL;
- WebSocketStreamHandleImpl* handle = handle_;
- handle_ = NULL;
- if (client_) {
- WebSocketStreamHandleClient* client = client_;
- client_ = NULL;
- client->didClose(handle);
- }
- Release();
-}
-
-void WebSocketStreamHandleImpl::Context::DidFail(
- WebSocketStreamHandle* web_handle,
- int error_code,
- const string16& error_msg) {
- VLOG(1) << "DidFail";
- if (client_) {
- client_->didFail(
- handle_,
- WebSocketStreamError(error_code, error_msg));
- }
-}
-
-// WebSocketStreamHandleImpl ------------------------------------------------
-
-WebSocketStreamHandleImpl::WebSocketStreamHandleImpl(
- WebKitPlatformSupportImpl* platform)
- : context_(new Context(this)),
- platform_(platform) {
-}
-
-WebSocketStreamHandleImpl::~WebSocketStreamHandleImpl() {
- // We won't receive any events from |context_|.
- // |context_| is ref counted, and will be released when it received
- // DidClose.
- context_->Detach();
-}
-
-void WebSocketStreamHandleImpl::connect(
- const WebURL& url, WebSocketStreamHandleClient* client) {
- VLOG(1) << "connect url=" << url;
- DCHECK(!context_->client());
- context_->set_client(client);
-
- context_->Connect(url, platform_);
-}
-
-bool WebSocketStreamHandleImpl::send(const WebData& data) {
- return context_->Send(data);
-}
-
-void WebSocketStreamHandleImpl::close() {
- context_->Close();
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/child/websocketstreamhandle_impl.h b/chromium/webkit/child/websocketstreamhandle_impl.h
deleted file mode 100644
index 7cd34b1c0a9..00000000000
--- a/chromium/webkit/child/websocketstreamhandle_impl.h
+++ /dev/null
@@ -1,40 +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 WEBKIT_CHILD_WEBSOCKETSTREAMHANDLE_IMPL_H_
-#define WEBKIT_CHILD_WEBSOCKETSTREAMHANDLE_IMPL_H_
-
-#include "base/memory/ref_counted.h"
-#include "base/supports_user_data.h"
-#include "third_party/WebKit/public/platform/WebSocketStreamHandle.h"
-
-namespace webkit_glue {
-
-class WebKitPlatformSupportImpl;
-
-class WebSocketStreamHandleImpl
- : public base::SupportsUserData,
- public blink::WebSocketStreamHandle {
- public:
- explicit WebSocketStreamHandleImpl(WebKitPlatformSupportImpl* platform);
- virtual ~WebSocketStreamHandleImpl();
-
- // WebSocketStreamHandle methods:
- virtual void connect(
- const blink::WebURL& url,
- blink::WebSocketStreamHandleClient* client);
- virtual bool send(const blink::WebData& data);
- virtual void close();
-
- private:
- class Context;
- scoped_refptr<Context> context_;
- WebKitPlatformSupportImpl* platform_;
-
- DISALLOW_COPY_AND_ASSIGN(WebSocketStreamHandleImpl);
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_WEBSOCKETSTREAMHANDLE_IMPL_H_
diff --git a/chromium/webkit/child/webthemeengine_impl_android.cc b/chromium/webkit/child/webthemeengine_impl_android.cc
deleted file mode 100644
index 6968064b53c..00000000000
--- a/chromium/webkit/child/webthemeengine_impl_android.cc
+++ /dev/null
@@ -1,186 +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 "webkit/child/webthemeengine_impl_android.h"
-
-#include "base/logging.h"
-#include "skia/ext/platform_canvas.h"
-#include "third_party/WebKit/public/platform/WebRect.h"
-#include "third_party/WebKit/public/platform/WebSize.h"
-#include "ui/native_theme/native_theme.h"
-
-using blink::WebCanvas;
-using blink::WebColor;
-using blink::WebRect;
-using blink::WebThemeEngine;
-
-namespace webkit_glue {
-
-static ui::NativeTheme::Part NativeThemePart(
- WebThemeEngine::Part part) {
- switch (part) {
- case WebThemeEngine::PartScrollbarDownArrow:
- return ui::NativeTheme::kScrollbarDownArrow;
- case WebThemeEngine::PartScrollbarLeftArrow:
- return ui::NativeTheme::kScrollbarLeftArrow;
- case WebThemeEngine::PartScrollbarRightArrow:
- return ui::NativeTheme::kScrollbarRightArrow;
- case WebThemeEngine::PartScrollbarUpArrow:
- return ui::NativeTheme::kScrollbarUpArrow;
- case WebThemeEngine::PartScrollbarHorizontalThumb:
- // Android doesn't draw scrollbars.
- NOTREACHED();
- return static_cast<ui::NativeTheme::Part>(0);
- case WebThemeEngine::PartScrollbarVerticalThumb:
- // Android doesn't draw scrollbars.
- NOTREACHED();
- return static_cast<ui::NativeTheme::Part>(0);
- case WebThemeEngine::PartScrollbarHorizontalTrack:
- // Android doesn't draw scrollbars.
- NOTREACHED();
- return static_cast<ui::NativeTheme::Part>(0);
- case WebThemeEngine::PartScrollbarVerticalTrack:
- // Android doesn't draw scrollbars.
- NOTREACHED();
- return static_cast<ui::NativeTheme::Part>(0);
- case WebThemeEngine::PartCheckbox:
- return ui::NativeTheme::kCheckbox;
- case WebThemeEngine::PartRadio:
- return ui::NativeTheme::kRadio;
- case WebThemeEngine::PartButton:
- return ui::NativeTheme::kPushButton;
- case WebThemeEngine::PartTextField:
- return ui::NativeTheme::kTextField;
- case WebThemeEngine::PartMenuList:
- return ui::NativeTheme::kMenuList;
- case WebThemeEngine::PartSliderTrack:
- return ui::NativeTheme::kSliderTrack;
- case WebThemeEngine::PartSliderThumb:
- return ui::NativeTheme::kSliderThumb;
- case WebThemeEngine::PartInnerSpinButton:
- return ui::NativeTheme::kInnerSpinButton;
- case WebThemeEngine::PartProgressBar:
- return ui::NativeTheme::kProgressBar;
- default:
- return ui::NativeTheme::kScrollbarDownArrow;
- }
-}
-
-static ui::NativeTheme::State NativeThemeState(
- WebThemeEngine::State state) {
- switch (state) {
- case WebThemeEngine::StateDisabled:
- return ui::NativeTheme::kDisabled;
- case WebThemeEngine::StateHover:
- return ui::NativeTheme::kHovered;
- case WebThemeEngine::StateNormal:
- return ui::NativeTheme::kNormal;
- case WebThemeEngine::StatePressed:
- return ui::NativeTheme::kPressed;
- default:
- return ui::NativeTheme::kDisabled;
- }
-}
-
-static void GetNativeThemeExtraParams(
- WebThemeEngine::Part part,
- WebThemeEngine::State state,
- const WebThemeEngine::ExtraParams* extra_params,
- ui::NativeTheme::ExtraParams* native_theme_extra_params) {
- switch (part) {
- case WebThemeEngine::PartScrollbarHorizontalTrack:
- case WebThemeEngine::PartScrollbarVerticalTrack:
- // Android doesn't draw scrollbars.
- NOTREACHED();
- break;
- case WebThemeEngine::PartCheckbox:
- native_theme_extra_params->button.checked = extra_params->button.checked;
- native_theme_extra_params->button.indeterminate =
- extra_params->button.indeterminate;
- break;
- case WebThemeEngine::PartRadio:
- native_theme_extra_params->button.checked = extra_params->button.checked;
- break;
- case WebThemeEngine::PartButton:
- native_theme_extra_params->button.is_default =
- extra_params->button.isDefault;
- native_theme_extra_params->button.has_border =
- extra_params->button.hasBorder;
- // Native buttons have a different focus style.
- native_theme_extra_params->button.is_focused = false;
- native_theme_extra_params->button.background_color =
- extra_params->button.backgroundColor;
- break;
- case WebThemeEngine::PartTextField:
- native_theme_extra_params->text_field.is_text_area =
- extra_params->textField.isTextArea;
- native_theme_extra_params->text_field.is_listbox =
- extra_params->textField.isListbox;
- native_theme_extra_params->text_field.background_color =
- extra_params->textField.backgroundColor;
- break;
- case WebThemeEngine::PartMenuList:
- native_theme_extra_params->menu_list.has_border =
- extra_params->menuList.hasBorder;
- native_theme_extra_params->menu_list.has_border_radius =
- extra_params->menuList.hasBorderRadius;
- native_theme_extra_params->menu_list.arrow_x =
- extra_params->menuList.arrowX;
- native_theme_extra_params->menu_list.arrow_y =
- extra_params->menuList.arrowY;
- native_theme_extra_params->menu_list.background_color =
- extra_params->menuList.backgroundColor;
- break;
- case WebThemeEngine::PartSliderTrack:
- case WebThemeEngine::PartSliderThumb:
- native_theme_extra_params->slider.vertical =
- extra_params->slider.vertical;
- native_theme_extra_params->slider.in_drag = extra_params->slider.inDrag;
- break;
- case WebThemeEngine::PartInnerSpinButton:
- native_theme_extra_params->inner_spin.spin_up =
- extra_params->innerSpin.spinUp;
- native_theme_extra_params->inner_spin.read_only =
- extra_params->innerSpin.readOnly;
- break;
- case WebThemeEngine::PartProgressBar:
- native_theme_extra_params->progress_bar.determinate =
- extra_params->progressBar.determinate;
- native_theme_extra_params->progress_bar.value_rect_x =
- extra_params->progressBar.valueRectX;
- native_theme_extra_params->progress_bar.value_rect_y =
- extra_params->progressBar.valueRectY;
- native_theme_extra_params->progress_bar.value_rect_width =
- extra_params->progressBar.valueRectWidth;
- native_theme_extra_params->progress_bar.value_rect_height =
- extra_params->progressBar.valueRectHeight;
- break;
- default:
- break; // Parts that have no extra params get here.
- }
-}
-
-blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) {
- ui::NativeTheme::ExtraParams extra;
- return ui::NativeTheme::instance()->GetPartSize(
- NativeThemePart(part), ui::NativeTheme::kNormal, extra);
-}
-
-void WebThemeEngineImpl::paint(
- blink::WebCanvas* canvas,
- WebThemeEngine::Part part,
- WebThemeEngine::State state,
- const blink::WebRect& rect,
- const WebThemeEngine::ExtraParams* extra_params) {
- ui::NativeTheme::ExtraParams native_theme_extra_params;
- GetNativeThemeExtraParams(
- part, state, extra_params, &native_theme_extra_params);
- ui::NativeTheme::instance()->Paint(
- canvas,
- NativeThemePart(part),
- NativeThemeState(state),
- gfx::Rect(rect),
- native_theme_extra_params);
-}
-} // namespace webkit_glue
diff --git a/chromium/webkit/child/webthemeengine_impl_android.h b/chromium/webkit/child/webthemeengine_impl_android.h
deleted file mode 100644
index 1c0a11df7d0..00000000000
--- a/chromium/webkit/child/webthemeengine_impl_android.h
+++ /dev/null
@@ -1,26 +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.
-
-#ifndef WEBKIT_CHILD_WEBTHEMEENGINE_IMPL_ANDROID_H_
-#define WEBKIT_CHILD_WEBTHEMEENGINE_IMPL_ANDROID_H_
-
-#include "third_party/WebKit/public/platform/android/WebThemeEngine.h"
-
-namespace webkit_glue {
-
-class WebThemeEngineImpl : public blink::WebThemeEngine {
- public:
- // WebThemeEngine methods:
- virtual blink::WebSize getSize(blink::WebThemeEngine::Part);
- virtual void paint(
- blink::WebCanvas* canvas,
- blink::WebThemeEngine::Part part,
- blink::WebThemeEngine::State state,
- const blink::WebRect& rect,
- const blink::WebThemeEngine::ExtraParams* extra_params);
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_WEBTHEMEENGINE_IMPL_ANDROID_H_
diff --git a/chromium/webkit/child/webthemeengine_impl_default.cc b/chromium/webkit/child/webthemeengine_impl_default.cc
deleted file mode 100644
index d1959621604..00000000000
--- a/chromium/webkit/child/webthemeengine_impl_default.cc
+++ /dev/null
@@ -1,185 +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 "webkit/child/webthemeengine_impl_default.h"
-
-#include "skia/ext/platform_canvas.h"
-#include "third_party/WebKit/public/platform/WebRect.h"
-#include "third_party/WebKit/public/platform/WebSize.h"
-#include "ui/native_theme/native_theme.h"
-
-using blink::WebCanvas;
-using blink::WebColor;
-using blink::WebRect;
-using blink::WebThemeEngine;
-
-namespace webkit_glue {
-
-static ui::NativeTheme::Part NativeThemePart(
- WebThemeEngine::Part part) {
- switch (part) {
- case WebThemeEngine::PartScrollbarDownArrow:
- return ui::NativeTheme::kScrollbarDownArrow;
- case WebThemeEngine::PartScrollbarLeftArrow:
- return ui::NativeTheme::kScrollbarLeftArrow;
- case WebThemeEngine::PartScrollbarRightArrow:
- return ui::NativeTheme::kScrollbarRightArrow;
- case WebThemeEngine::PartScrollbarUpArrow:
- return ui::NativeTheme::kScrollbarUpArrow;
- case WebThemeEngine::PartScrollbarHorizontalThumb:
- return ui::NativeTheme::kScrollbarHorizontalThumb;
- case WebThemeEngine::PartScrollbarVerticalThumb:
- return ui::NativeTheme::kScrollbarVerticalThumb;
- case WebThemeEngine::PartScrollbarHorizontalTrack:
- return ui::NativeTheme::kScrollbarHorizontalTrack;
- case WebThemeEngine::PartScrollbarVerticalTrack:
- return ui::NativeTheme::kScrollbarVerticalTrack;
- case WebThemeEngine::PartCheckbox:
- return ui::NativeTheme::kCheckbox;
- case WebThemeEngine::PartRadio:
- return ui::NativeTheme::kRadio;
- case WebThemeEngine::PartButton:
- return ui::NativeTheme::kPushButton;
- case WebThemeEngine::PartTextField:
- return ui::NativeTheme::kTextField;
- case WebThemeEngine::PartMenuList:
- return ui::NativeTheme::kMenuList;
- case WebThemeEngine::PartSliderTrack:
- return ui::NativeTheme::kSliderTrack;
- case WebThemeEngine::PartSliderThumb:
- return ui::NativeTheme::kSliderThumb;
- case WebThemeEngine::PartInnerSpinButton:
- return ui::NativeTheme::kInnerSpinButton;
- case WebThemeEngine::PartProgressBar:
- return ui::NativeTheme::kProgressBar;
- default:
- return ui::NativeTheme::kScrollbarDownArrow;
- }
-}
-
-static ui::NativeTheme::State NativeThemeState(
- WebThemeEngine::State state) {
- switch (state) {
- case WebThemeEngine::StateDisabled:
- return ui::NativeTheme::kDisabled;
- case WebThemeEngine::StateHover:
- return ui::NativeTheme::kHovered;
- case WebThemeEngine::StateNormal:
- return ui::NativeTheme::kNormal;
- case WebThemeEngine::StatePressed:
- return ui::NativeTheme::kPressed;
- default:
- return ui::NativeTheme::kDisabled;
- }
-}
-
-static void GetNativeThemeExtraParams(
- WebThemeEngine::Part part,
- WebThemeEngine::State state,
- const WebThemeEngine::ExtraParams* extra_params,
- ui::NativeTheme::ExtraParams* native_theme_extra_params) {
- switch (part) {
- case WebThemeEngine::PartScrollbarHorizontalTrack:
- case WebThemeEngine::PartScrollbarVerticalTrack:
- native_theme_extra_params->scrollbar_track.track_x =
- extra_params->scrollbarTrack.trackX;
- native_theme_extra_params->scrollbar_track.track_y =
- extra_params->scrollbarTrack.trackY;
- native_theme_extra_params->scrollbar_track.track_width =
- extra_params->scrollbarTrack.trackWidth;
- native_theme_extra_params->scrollbar_track.track_height =
- extra_params->scrollbarTrack.trackHeight;
- break;
- case WebThemeEngine::PartCheckbox:
- native_theme_extra_params->button.checked = extra_params->button.checked;
- native_theme_extra_params->button.indeterminate =
- extra_params->button.indeterminate;
- break;
- case WebThemeEngine::PartRadio:
- native_theme_extra_params->button.checked = extra_params->button.checked;
- break;
- case WebThemeEngine::PartButton:
- native_theme_extra_params->button.is_default =
- extra_params->button.isDefault;
- native_theme_extra_params->button.has_border =
- extra_params->button.hasBorder;
- // Native buttons have a different focus style.
- native_theme_extra_params->button.is_focused = false;
- native_theme_extra_params->button.background_color =
- extra_params->button.backgroundColor;
- break;
- case WebThemeEngine::PartTextField:
- native_theme_extra_params->text_field.is_text_area =
- extra_params->textField.isTextArea;
- native_theme_extra_params->text_field.is_listbox =
- extra_params->textField.isListbox;
- native_theme_extra_params->text_field.background_color =
- extra_params->textField.backgroundColor;
- break;
- case WebThemeEngine::PartMenuList:
- native_theme_extra_params->menu_list.has_border =
- extra_params->menuList.hasBorder;
- native_theme_extra_params->menu_list.has_border_radius =
- extra_params->menuList.hasBorderRadius;
- native_theme_extra_params->menu_list.arrow_x =
- extra_params->menuList.arrowX;
- native_theme_extra_params->menu_list.arrow_y =
- extra_params->menuList.arrowY;
- native_theme_extra_params->menu_list.background_color =
- extra_params->menuList.backgroundColor;
- break;
- case WebThemeEngine::PartSliderTrack:
- case WebThemeEngine::PartSliderThumb:
- native_theme_extra_params->slider.vertical =
- extra_params->slider.vertical;
- native_theme_extra_params->slider.in_drag = extra_params->slider.inDrag;
- break;
- case WebThemeEngine::PartInnerSpinButton:
- native_theme_extra_params->inner_spin.spin_up =
- extra_params->innerSpin.spinUp;
- native_theme_extra_params->inner_spin.read_only =
- extra_params->innerSpin.readOnly;
- break;
- case WebThemeEngine::PartProgressBar:
- native_theme_extra_params->progress_bar.determinate =
- extra_params->progressBar.determinate;
- native_theme_extra_params->progress_bar.value_rect_x =
- extra_params->progressBar.valueRectX;
- native_theme_extra_params->progress_bar.value_rect_y =
- extra_params->progressBar.valueRectY;
- native_theme_extra_params->progress_bar.value_rect_width =
- extra_params->progressBar.valueRectWidth;
- native_theme_extra_params->progress_bar.value_rect_height =
- extra_params->progressBar.valueRectHeight;
- break;
- default:
- break; // Parts that have no extra params get here.
- }
-}
-
-blink::WebSize WebThemeEngineImpl::getSize(WebThemeEngine::Part part) {
- ui::NativeTheme::ExtraParams extra;
- return ui::NativeTheme::instance()->GetPartSize(NativeThemePart(part),
- ui::NativeTheme::kNormal,
- extra);
-}
-
-void WebThemeEngineImpl::paint(
- blink::WebCanvas* canvas,
- WebThemeEngine::Part part,
- WebThemeEngine::State state,
- const blink::WebRect& rect,
- const WebThemeEngine::ExtraParams* extra_params) {
- ui::NativeTheme::ExtraParams native_theme_extra_params;
- GetNativeThemeExtraParams(
- part, state, extra_params, &native_theme_extra_params);
- ui::NativeTheme::instance()->Paint(
- canvas,
- NativeThemePart(part),
- NativeThemeState(state),
- gfx::Rect(rect),
- native_theme_extra_params);
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/child/webthemeengine_impl_default.h b/chromium/webkit/child/webthemeengine_impl_default.h
deleted file mode 100644
index 44cd6dd0cd1..00000000000
--- a/chromium/webkit/child/webthemeengine_impl_default.h
+++ /dev/null
@@ -1,26 +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.
-
-#ifndef WEBKIT_CHILD_WEBTHEMEENGINE_IMPL_DEFAULT_H_
-#define WEBKIT_CHILD_WEBTHEMEENGINE_IMPL_DEFAULT_H_
-
-#include "third_party/WebKit/public/platform/default/WebThemeEngine.h"
-
-namespace webkit_glue {
-
-class WebThemeEngineImpl : public blink::WebThemeEngine {
- public:
- // WebThemeEngine methods:
- virtual blink::WebSize getSize(blink::WebThemeEngine::Part);
- virtual void paint(
- blink::WebCanvas* canvas,
- blink::WebThemeEngine::Part part,
- blink::WebThemeEngine::State state,
- const blink::WebRect& rect,
- const blink::WebThemeEngine::ExtraParams* extra_params);
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_WEBTHEMEENGINE_IMPL_DEFAULT_H_
diff --git a/chromium/webkit/child/webthemeengine_impl_mac.cc b/chromium/webkit/child/webthemeengine_impl_mac.cc
deleted file mode 100644
index 2799ad7f7ec..00000000000
--- a/chromium/webkit/child/webthemeengine_impl_mac.cc
+++ /dev/null
@@ -1,61 +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 "webkit/child/webthemeengine_impl_mac.h"
-
-#include <Carbon/Carbon.h>
-
-#include "skia/ext/skia_utils_mac.h"
-#include "third_party/WebKit/public/platform/WebCanvas.h"
-#include "third_party/WebKit/public/platform/WebRect.h"
-
-using blink::WebCanvas;
-using blink::WebRect;
-using blink::WebThemeEngine;
-
-namespace webkit_glue {
-
-static ThemeTrackEnableState stateToHIEnableState(WebThemeEngine::State state) {
- switch (state) {
- case WebThemeEngine::StateDisabled:
- return kThemeTrackDisabled;
- case WebThemeEngine::StateInactive:
- return kThemeTrackInactive;
- default:
- return kThemeTrackActive;
- }
-}
-
-void WebThemeEngineImpl::paintScrollbarThumb(
- WebCanvas* canvas,
- WebThemeEngine::State state,
- WebThemeEngine::Size size,
- const WebRect& rect,
- const WebThemeEngine::ScrollbarInfo& scrollbarInfo) {
- HIThemeTrackDrawInfo trackInfo;
- trackInfo.version = 0;
- trackInfo.kind = size == WebThemeEngine::SizeRegular ?
- kThemeMediumScrollBar : kThemeSmallScrollBar;
- trackInfo.bounds = CGRectMake(rect.x, rect.y, rect.width, rect.height);
- trackInfo.min = 0;
- trackInfo.max = scrollbarInfo.maxValue;
- trackInfo.value = scrollbarInfo.currentValue;
- trackInfo.trackInfo.scrollbar.viewsize = scrollbarInfo.visibleSize;
- trackInfo.attributes = 0;
- if (scrollbarInfo.orientation ==
- WebThemeEngine::ScrollbarOrientationHorizontal) {
- trackInfo.attributes |= kThemeTrackHorizontal;
- }
-
- trackInfo.enableState = stateToHIEnableState(state);
-
- trackInfo.trackInfo.scrollbar.pressState =
- state == WebThemeEngine::StatePressed ? kThemeThumbPressed : 0;
- trackInfo.attributes |= (kThemeTrackShowThumb | kThemeTrackHideTrack);
- gfx::SkiaBitLocker bitLocker(canvas);
- CGContextRef cgContext = bitLocker.cgContext();
- HIThemeDrawTrack(&trackInfo, 0, cgContext, kHIThemeOrientationNormal);
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/child/webthemeengine_impl_mac.h b/chromium/webkit/child/webthemeengine_impl_mac.h
deleted file mode 100644
index 6754535c663..00000000000
--- a/chromium/webkit/child/webthemeengine_impl_mac.h
+++ /dev/null
@@ -1,25 +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.
-
-#ifndef WEBKIT_CHILD_WEBTHEMEENGINE_IMPL_MAC_H_
-#define WEBKIT_CHILD_WEBTHEMEENGINE_IMPL_MAC_H_
-
-#include "third_party/WebKit/public/platform/mac/WebThemeEngine.h"
-
-namespace webkit_glue {
-
-class WebThemeEngineImpl : public blink::WebThemeEngine {
- public:
- // blink::WebThemeEngine implementation.
- virtual void paintScrollbarThumb(
- blink::WebCanvas* canvas,
- blink::WebThemeEngine::State part,
- blink::WebThemeEngine::Size state,
- const blink::WebRect& rect,
- const blink::WebThemeEngine::ScrollbarInfo& extra_params);
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_WEBTHEMEENGINE_IMPL_MAC_H_
diff --git a/chromium/webkit/child/webthemeengine_impl_win.cc b/chromium/webkit/child/webthemeengine_impl_win.cc
deleted file mode 100644
index b7a0d37e5c7..00000000000
--- a/chromium/webkit/child/webthemeengine_impl_win.cc
+++ /dev/null
@@ -1,1014 +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 "webkit/child/webthemeengine_impl_win.h"
-
-#include <vsstyle.h> // To convert to ui::NativeTheme::State
-
-#include "base/logging.h"
-#include "skia/ext/platform_canvas.h"
-#include "skia/ext/skia_utils_win.h"
-#include "third_party/WebKit/public/platform/WebRect.h"
-#include "ui/gfx/win/dpi.h"
-#include "ui/native_theme/native_theme.h"
-
-using blink::WebCanvas;
-using blink::WebColor;
-using blink::WebRect;
-using blink::WebSize;
-
-namespace webkit_glue {
-
-static RECT WebRectToRECT(const WebRect& rect) {
- RECT result;
- result.left = rect.x;
- result.top = rect.y;
- result.right = rect.x + rect.width;
- result.bottom = rect.y + rect.height;
- return result;
-}
-
-static ui::NativeTheme::State WebButtonStateToGfx(
- int part, int state, ui::NativeTheme::ButtonExtraParams* extra) {
- ui::NativeTheme::State gfx_state = ui::NativeTheme::kNormal;
- // Native buttons have a different focus style.
- extra->is_focused = false;
- extra->has_border = false;
- extra->background_color = ui::NativeTheme::instance()->GetSystemColor(
- ui::NativeTheme::kColorId_ButtonBackgroundColor);
-
- if (part == BP_PUSHBUTTON) {
- switch (state) {
- case PBS_NORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case PBS_HOT:
- gfx_state = ui::NativeTheme::kHovered;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case PBS_PRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case PBS_DISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case PBS_DEFAULTED:
- gfx_state = ui::NativeTheme::kNormal;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = true;
- break;
- case PBS_DEFAULTED_ANIMATING:
- gfx_state = ui::NativeTheme::kNormal;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = true;
- break;
- default:
- NOTREACHED() << "Invalid state: " << state;
- }
- } else if (part == BP_RADIOBUTTON) {
- switch (state) {
- case RBS_UNCHECKEDNORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case RBS_UNCHECKEDHOT:
- gfx_state = ui::NativeTheme::kHovered;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case RBS_UNCHECKEDPRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case RBS_UNCHECKEDDISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case RBS_CHECKEDNORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- extra->checked = true;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case RBS_CHECKEDHOT:
- gfx_state = ui::NativeTheme::kHovered;
- extra->checked = true;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case RBS_CHECKEDPRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- extra->checked = true;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case RBS_CHECKEDDISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- extra->checked = true;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- default:
- NOTREACHED() << "Invalid state: " << state;
- break;
- }
- } else if (part == BP_CHECKBOX) {
- switch (state) {
- case CBS_UNCHECKEDNORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CBS_UNCHECKEDHOT:
- gfx_state = ui::NativeTheme::kHovered;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CBS_UNCHECKEDPRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CBS_UNCHECKEDDISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CBS_CHECKEDNORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- extra->checked = true;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CBS_CHECKEDHOT:
- gfx_state = ui::NativeTheme::kHovered;
- extra->checked = true;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CBS_CHECKEDPRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- extra->checked = true;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CBS_CHECKEDDISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- extra->checked = true;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CBS_MIXEDNORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- extra->checked = false;
- extra->indeterminate = true;
- extra->is_default = false;
- break;
- case CBS_MIXEDHOT:
- gfx_state = ui::NativeTheme::kHovered;
- extra->checked = false;
- extra->indeterminate = true;
- extra->is_default = false;
- break;
- case CBS_MIXEDPRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- extra->checked = false;
- extra->indeterminate = true;
- extra->is_default = false;
- break;
- case CBS_MIXEDDISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- extra->checked = false;
- extra->indeterminate = true;
- extra->is_default = false;
- break;
- case CBS_IMPLICITNORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CBS_IMPLICITHOT:
- gfx_state = ui::NativeTheme::kHovered;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CBS_IMPLICITPRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CBS_IMPLICITDISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CBS_EXCLUDEDNORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CBS_EXCLUDEDHOT:
- gfx_state = ui::NativeTheme::kHovered;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CBS_EXCLUDEDPRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CBS_EXCLUDEDDISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- default:
- NOTREACHED() << "Invalid state: " << state;
- break;
- }
- } else if (part == BP_GROUPBOX) {
- switch (state) {
- case GBS_NORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case GBS_DISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- default:
- NOTREACHED() << "Invalid state: " << state;
- break;
- }
- } else if (part == BP_COMMANDLINK) {
- switch (state) {
- case CMDLS_NORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CMDLS_HOT:
- gfx_state = ui::NativeTheme::kHovered;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CMDLS_PRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CMDLS_DISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CMDLS_DEFAULTED:
- gfx_state = ui::NativeTheme::kNormal;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = true;
- break;
- case CMDLS_DEFAULTED_ANIMATING:
- gfx_state = ui::NativeTheme::kNormal;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = true;
- break;
- default:
- NOTREACHED() << "Invalid state: " << state;
- break;
- }
- } else if (part == BP_COMMANDLINKGLYPH) {
- switch (state) {
- case CMDLGS_NORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CMDLGS_HOT:
- gfx_state = ui::NativeTheme::kHovered;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CMDLGS_PRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CMDLGS_DISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = false;
- break;
- case CMDLGS_DEFAULTED:
- gfx_state = ui::NativeTheme::kNormal;
- extra->checked = false;
- extra->indeterminate = false;
- extra->is_default = true;
- break;
- default:
- NOTREACHED() << "Invalid state: " << state;
- break;
- }
- }
- return gfx_state;
-}
-
-void WebThemeEngineImpl::paintButton(
- WebCanvas* canvas, int part, int state, int classic_state,
- const WebRect& rect) {
- ui::NativeTheme::Part native_part = ui::NativeTheme::kPushButton;
- switch (part) {
- case BP_PUSHBUTTON:
- native_part = ui::NativeTheme::kPushButton;
- break;
- case BP_CHECKBOX:
- native_part = ui::NativeTheme::kCheckbox;
- break;
- case BP_RADIOBUTTON:
- native_part = ui::NativeTheme::kRadio;
- break;
- default:
- NOTREACHED() << "Invalid part: " << part;
- break;
- }
- ui::NativeTheme::ExtraParams extra;
- ui::NativeTheme::State native_state = WebButtonStateToGfx(part, state,
- &extra.button);
- extra.button.classic_state = classic_state;
- gfx::Rect gfx_rect(rect.x, rect.y, rect.width, rect.height);
- ui::NativeTheme::instance()->Paint(canvas, native_part,
- native_state, gfx_rect, extra);
-}
-
-static ui::NativeTheme::State WebListMenuStateToGfx(int part, int state) {
- ui::NativeTheme::State gfx_state = ui::NativeTheme::kNormal;
-
- switch (part) {
- case CP_DROPDOWNBUTTON:
- switch (state) {
- case CBXS_NORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- break;
- case CBXS_HOT:
- gfx_state = ui::NativeTheme::kHovered;
- break;
- case CBXS_PRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- break;
- case CBXS_DISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- break;
- default:
- NOTREACHED() << "Invalid state: " << state;
- break;
- }
- break;
- default:
- NOTREACHED() << "Invalid part: " << part;
- break;
- }
- return gfx_state;
-}
-
-void WebThemeEngineImpl::paintMenuList(
- WebCanvas* canvas, int part, int state, int classic_state,
- const WebRect& rect) {
- ui::NativeTheme::Part native_part = ui::NativeTheme::kMenuList;
- switch (part) {
- case CP_DROPDOWNBUTTON:
- native_part = ui::NativeTheme::kMenuList;
- break;
- default:
- NOTREACHED() << "Invalid part: " << part;
- break;
- }
- ui::NativeTheme::State native_state = WebListMenuStateToGfx(part, state);
- gfx::Rect gfx_rect(rect.x, rect.y, rect.width, rect.height);
- ui::NativeTheme::ExtraParams extra;
- extra.menu_list.classic_state = classic_state;
- ui::NativeTheme::instance()->Paint(canvas, native_part,
- native_state, gfx_rect, extra);
-}
-
-static ui::NativeTheme::State WebScrollbarArrowStateToGfx(
- int state, ui::NativeTheme::Part* part,
- ui::NativeTheme::ScrollbarArrowExtraParams* extra) {
- ui::NativeTheme::State gfx_state = ui::NativeTheme::kNormal;
- switch (state) {
- case ABS_UPNORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- *part = ui::NativeTheme::kScrollbarUpArrow;
- extra->is_hovering = false;
- break;
- case ABS_UPHOT:
- gfx_state = ui::NativeTheme::kHovered;
- *part = ui::NativeTheme::kScrollbarUpArrow;
- extra->is_hovering = false;
- break;
- case ABS_UPPRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- *part = ui::NativeTheme::kScrollbarUpArrow;
- extra->is_hovering = false;
- break;
- case ABS_UPDISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- *part = ui::NativeTheme::kScrollbarUpArrow;
- extra->is_hovering = false;
- break;
- case ABS_DOWNNORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- *part = ui::NativeTheme::kScrollbarDownArrow;
- extra->is_hovering = false;
- break;
- case ABS_DOWNHOT:
- gfx_state = ui::NativeTheme::kHovered;
- *part = ui::NativeTheme::kScrollbarDownArrow;
- extra->is_hovering = false;
- break;
- case ABS_DOWNPRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- *part = ui::NativeTheme::kScrollbarDownArrow;
- extra->is_hovering = false;
- break;
- case ABS_DOWNDISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- *part = ui::NativeTheme::kScrollbarDownArrow;
- extra->is_hovering = false;
- break;
- case ABS_LEFTNORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- *part = ui::NativeTheme::kScrollbarLeftArrow;
- extra->is_hovering = false;
- break;
- case ABS_LEFTHOT:
- gfx_state = ui::NativeTheme::kHovered;
- *part = ui::NativeTheme::kScrollbarLeftArrow;
- extra->is_hovering = false;
- break;
- case ABS_LEFTPRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- *part = ui::NativeTheme::kScrollbarLeftArrow;
- extra->is_hovering = false;
- break;
- case ABS_LEFTDISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- *part = ui::NativeTheme::kScrollbarLeftArrow;
- extra->is_hovering = false;
- break;
- case ABS_RIGHTNORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- *part = ui::NativeTheme::kScrollbarRightArrow;
- extra->is_hovering = false;
- break;
- case ABS_RIGHTHOT:
- gfx_state = ui::NativeTheme::kHovered;
- *part = ui::NativeTheme::kScrollbarRightArrow;
- extra->is_hovering = false;
- break;
- case ABS_RIGHTPRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- *part = ui::NativeTheme::kScrollbarRightArrow;
- extra->is_hovering = false;
- break;
- case ABS_RIGHTDISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- *part = ui::NativeTheme::kScrollbarRightArrow;
- extra->is_hovering = false;
- break;
- case ABS_UPHOVER:
- gfx_state = ui::NativeTheme::kHovered;
- *part = ui::NativeTheme::kScrollbarUpArrow;
- extra->is_hovering = true;
- break;
- case ABS_DOWNHOVER:
- gfx_state = ui::NativeTheme::kHovered;
- *part = ui::NativeTheme::kScrollbarDownArrow;
- extra->is_hovering = true;
- break;
- case ABS_LEFTHOVER:
- gfx_state = ui::NativeTheme::kHovered;
- *part = ui::NativeTheme::kScrollbarLeftArrow;
- extra->is_hovering = true;
- break;
- case ABS_RIGHTHOVER:
- gfx_state = ui::NativeTheme::kHovered;
- *part = ui::NativeTheme::kScrollbarRightArrow;
- extra->is_hovering = true;
- break;
- default:
- NOTREACHED() << "Invalid state: " << state;
- break;
- }
- return gfx_state;
-}
-
-void WebThemeEngineImpl::paintScrollbarArrow(
- WebCanvas* canvas, int state, int classic_state, const WebRect& rect) {
- ui::NativeTheme::Part native_part;
- ui::NativeTheme::ExtraParams extra;
- ui::NativeTheme::State native_state = WebScrollbarArrowStateToGfx(
- state, &native_part, &extra.scrollbar_arrow);
- gfx::Rect gfx_rect(rect.x, rect.y, rect.width, rect.height);
- ui::NativeTheme::instance()->Paint(canvas, native_part,
- native_state, gfx_rect, extra);
-}
-
-static ui::NativeTheme::State WebScrollbarThumbStateToGfx(
- int state, ui::NativeTheme::ScrollbarThumbExtraParams* extra) {
- ui::NativeTheme::State gfx_state = ui::NativeTheme::kNormal;
- switch (state) {
- case SCRBS_NORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- extra->is_hovering = false;
- break;
- case SCRBS_HOVER:
- gfx_state = ui::NativeTheme::kHovered;
- extra->is_hovering = true;
- break;
- case SCRBS_HOT:
- gfx_state = ui::NativeTheme::kHovered;
- extra->is_hovering = false;
- break;
- case SCRBS_PRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- extra->is_hovering = false;
- break;
- case SCRBS_DISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- extra->is_hovering = false;
- break;
- default:
- NOTREACHED() << "Invalid state: " << state;
- break;
- }
- return gfx_state;
-}
-
-void WebThemeEngineImpl::paintScrollbarThumb(
- WebCanvas* canvas, int part, int state, int classic_state,
- const WebRect& rect) {
- ui::NativeTheme::Part native_part;
- if (part == SBP_THUMBBTNHORZ) {
- native_part = ui::NativeTheme::kScrollbarHorizontalThumb;
- } else if (part == SBP_THUMBBTNVERT) {
- native_part = ui::NativeTheme::kScrollbarVerticalThumb;
- } else if (part == SBP_GRIPPERHORZ) {
- native_part = ui::NativeTheme::kScrollbarHorizontalGripper;
- } else if (part == SBP_GRIPPERVERT) {
- native_part = ui::NativeTheme::kScrollbarVerticalGripper;
- } else {
- NOTREACHED() << "Invalid part: " << part;
- }
-
- ui::NativeTheme::ExtraParams extra;
- ui::NativeTheme::State native_state = WebScrollbarThumbStateToGfx(
- state, &extra.scrollbar_thumb);
-
- gfx::Rect gfx_rect(rect.x, rect.y, rect.width, rect.height);
- ui::NativeTheme::instance()->Paint(canvas, native_part,
- native_state, gfx_rect, extra);
-}
-
-static ui::NativeTheme::State WebScrollbarTrackStateToGfx(
- int part, int state, ui::NativeTheme::Part* gfx_part,
- ui::NativeTheme::ScrollbarTrackExtraParams* extra) {
- ui::NativeTheme::State gfx_state = ui::NativeTheme::kNormal;
- switch (part) {
- case SBP_LOWERTRACKHORZ:
- switch (state) {
- case SCRBS_NORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- *gfx_part = ui::NativeTheme::kScrollbarHorizontalTrack;
- extra->is_upper = false;
- break;
- case SCRBS_HOVER:
- case SCRBS_HOT:
- gfx_state = ui::NativeTheme::kHovered;
- *gfx_part = ui::NativeTheme::kScrollbarHorizontalTrack;
- extra->is_upper = false;
- break;
- case SCRBS_PRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- *gfx_part = ui::NativeTheme::kScrollbarHorizontalTrack;
- extra->is_upper = false;
- break;
- case SCRBS_DISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- *gfx_part = ui::NativeTheme::kScrollbarHorizontalTrack;
- extra->is_upper = false;
- break;
- default:
- NOTREACHED() << "Invalid state: " << state;
- break;
- }
- break;
- case SBP_UPPERTRACKHORZ:
- switch (state) {
- case SCRBS_NORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- *gfx_part = ui::NativeTheme::kScrollbarHorizontalTrack;
- extra->is_upper = true;
- break;
- case SCRBS_HOVER:
- case SCRBS_HOT:
- gfx_state = ui::NativeTheme::kHovered;
- *gfx_part = ui::NativeTheme::kScrollbarHorizontalTrack;
- extra->is_upper = true;
- break;
- case SCRBS_PRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- *gfx_part = ui::NativeTheme::kScrollbarHorizontalTrack;
- extra->is_upper = true;
- break;
- case SCRBS_DISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- *gfx_part = ui::NativeTheme::kScrollbarHorizontalTrack;
- extra->is_upper = true;
- break;
- default:
- NOTREACHED() << "Invalid state: " << state;
- break;
- }
- break;
- case SBP_LOWERTRACKVERT:
- switch (state) {
- case SCRBS_NORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- *gfx_part = ui::NativeTheme::kScrollbarVerticalTrack;
- extra->is_upper = false;
- break;
- case SCRBS_HOVER:
- case SCRBS_HOT:
- gfx_state = ui::NativeTheme::kHovered;
- *gfx_part = ui::NativeTheme::kScrollbarVerticalTrack;
- extra->is_upper = false;
- break;
- case SCRBS_PRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- *gfx_part = ui::NativeTheme::kScrollbarVerticalTrack;
- extra->is_upper = false;
- break;
- case SCRBS_DISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- *gfx_part = ui::NativeTheme::kScrollbarVerticalTrack;
- extra->is_upper = false;
- break;
- default:
- NOTREACHED() << "Invalid state: " << state;
- break;
- }
- break;
- case SBP_UPPERTRACKVERT:
- switch (state) {
- case SCRBS_NORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- *gfx_part = ui::NativeTheme::kScrollbarVerticalTrack;
- extra->is_upper = true;
- break;
- case SCRBS_HOVER:
- case SCRBS_HOT:
- gfx_state = ui::NativeTheme::kHovered;
- *gfx_part = ui::NativeTheme::kScrollbarVerticalTrack;
- extra->is_upper = true;
- break;
- case SCRBS_PRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- *gfx_part = ui::NativeTheme::kScrollbarVerticalTrack;
- extra->is_upper = true;
- break;
- case SCRBS_DISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- *gfx_part = ui::NativeTheme::kScrollbarVerticalTrack;
- extra->is_upper = true;
- break;
- default:
- NOTREACHED() << "Invalid state: " << state;
- break;
- }
- break;
- default:
- NOTREACHED() << "Invalid part: " << part;
- break;
- }
- return gfx_state;
-}
-
-void WebThemeEngineImpl::paintScrollbarTrack(
- WebCanvas* canvas, int part, int state, int classic_state,
- const WebRect& rect, const WebRect& align_rect) {
- ui::NativeTheme::Part native_part;
- ui::NativeTheme::ExtraParams extra;
- ui::NativeTheme::State native_state = WebScrollbarTrackStateToGfx(
- part, state, &native_part, &extra.scrollbar_track);
- extra.scrollbar_track.classic_state = classic_state;
- extra.scrollbar_track.track_x = align_rect.x;
- extra.scrollbar_track.track_y = align_rect.y;
- extra.scrollbar_track.track_width = align_rect.width;
- extra.scrollbar_track.track_height = align_rect.height;
-
- gfx::Rect gfx_rect(rect.x, rect.y, rect.width, rect.height);
- ui::NativeTheme::instance()->Paint(canvas, native_part,
- native_state, gfx_rect, extra);
-}
-
-static ui::NativeTheme::State WebSpinButtonStateToGfx(
- int part, int state, ui::NativeTheme::InnerSpinButtonExtraParams* extra) {
- ui::NativeTheme::State gfx_state = ui::NativeTheme::kNormal;
- switch (part) {
- case SPNP_UP:
- switch (state) {
- case UPS_NORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- extra->spin_up = true;
- extra->read_only = false;
- break;
- case UPS_HOT:
- gfx_state = ui::NativeTheme::kHovered;
- extra->spin_up = true;
- extra->read_only = false;
- break;
- case UPS_PRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- extra->spin_up = true;
- extra->read_only = false;
- break;
- case UPS_DISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- extra->spin_up = true;
- extra->read_only = false;
- break;
- default:
- NOTREACHED() << "Invalid state: " << state;
- break;
- }
- break;
- case SPNP_DOWN:
- switch (state) {
- case DNS_NORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- extra->spin_up = false;
- extra->read_only = false;
- break;
- case DNS_HOT:
- gfx_state = ui::NativeTheme::kHovered;
- extra->spin_up = false;
- extra->read_only = false;
- break;
- case DNS_PRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- extra->spin_up = false;
- extra->read_only = false;
- break;
- case DNS_DISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- extra->spin_up = false;
- extra->read_only = false;
- break;
- default:
- NOTREACHED() << "Invalid state: " << state;
- break;
- }
- break;
- default:
- NOTREACHED() << "Invalid part: " << part;
- break;
- }
- return gfx_state;
-}
-
-void WebThemeEngineImpl::paintSpinButton(
- WebCanvas* canvas, int part, int state, int classic_state,
- const WebRect& rect) {
- ui::NativeTheme::ExtraParams extra;
- ui::NativeTheme::State native_state = WebSpinButtonStateToGfx(
- part, state, &extra.inner_spin);
- extra.inner_spin.classic_state = classic_state;
- gfx::Rect gfx_rect(rect.x, rect.y, rect.width, rect.height);
- ui::NativeTheme::instance()->Paint(canvas,
- ui::NativeTheme::kInnerSpinButton,
- native_state,
- gfx_rect,
- extra);
-}
-
-static ui::NativeTheme::State WebTextFieldStateToGfx(
- int part, int state, ui::NativeTheme::TextFieldExtraParams* extra) {
- ui::NativeTheme::State gfx_state = ui::NativeTheme::kNormal;
- switch (part) {
- case EP_EDITTEXT:
- switch (state) {
- case ETS_NORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- extra->is_read_only = false;
- extra->is_focused = false;
- break;
- case ETS_HOT:
- gfx_state = ui::NativeTheme::kHovered;
- extra->is_read_only = false;
- extra->is_focused = false;
- break;
- case ETS_SELECTED:
- gfx_state = ui::NativeTheme::kPressed;
- extra->is_read_only = false;
- extra->is_focused = false;
- break;
- case ETS_DISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- extra->is_read_only = false;
- extra->is_focused = false;
- break;
- case ETS_FOCUSED:
- gfx_state = ui::NativeTheme::kNormal;
- extra->is_read_only = false;
- extra->is_focused = true;
- break;
- case ETS_READONLY:
- gfx_state = ui::NativeTheme::kNormal;
- extra->is_read_only = true;
- extra->is_focused = false;
- break;
- default:
- NOTREACHED() << "Invalid state: " << state;
- break;
- }
- break;
- default:
- NOTREACHED() << "Invalid part: " << part;
- break;
- }
- return gfx_state;
-}
-
-void WebThemeEngineImpl::paintTextField(
- WebCanvas* canvas, int part, int state, int classic_state,
- const WebRect& rect, WebColor color, bool fill_content_area,
- bool draw_edges) {
- ui::NativeTheme::ExtraParams extra;
- ui::NativeTheme::State native_state = WebTextFieldStateToGfx(
- part, state, &extra.text_field);
- extra.text_field.fill_content_area = fill_content_area;
- extra.text_field.draw_edges = draw_edges;
- extra.text_field.background_color = color;
- extra.text_field.classic_state = classic_state;
- gfx::Rect gfx_rect(rect.x, rect.y, rect.width, rect.height);
-
- ui::NativeTheme::instance()->Paint(canvas,
- ui::NativeTheme::kTextField, native_state, gfx_rect, extra);
-}
-
-static ui::NativeTheme::State WebTrackbarStateToGfx(
- int part,
- int state,
- ui::NativeTheme::TrackbarExtraParams* extra) {
- ui::NativeTheme::State gfx_state = ui::NativeTheme::kNormal;
- switch (state) {
- case TUS_NORMAL:
- gfx_state = ui::NativeTheme::kNormal;
- break;
- case TUS_HOT:
- gfx_state = ui::NativeTheme::kHovered;
- break;
- case TUS_PRESSED:
- gfx_state = ui::NativeTheme::kPressed;
- break;
- case TUS_DISABLED:
- gfx_state = ui::NativeTheme::kDisabled;
- break;
- default:
- NOTREACHED() << "Invalid state: " << state;
- break;
- }
-
- switch (part) {
- case TKP_TRACK:
- case TKP_THUMBBOTTOM:
- extra->vertical = false;
- break;
- case TKP_TRACKVERT:
- case TKP_THUMBVERT:
- extra->vertical = true;
- break;
- default:
- NOTREACHED() << "Invalid part: " << part;
- break;
- }
-
- return gfx_state;
-}
-
-void WebThemeEngineImpl::paintTrackbar(
- WebCanvas* canvas, int part, int state, int classic_state,
- const WebRect& rect) {
- ui::NativeTheme::Part native_part = ui::NativeTheme::kTrackbarTrack;
- switch (part) {
- case TKP_TRACK:
- case TKP_TRACKVERT:
- native_part = ui::NativeTheme::kTrackbarTrack;
- break;
- case TKP_THUMBBOTTOM:
- case TKP_THUMBVERT:
- native_part = ui::NativeTheme::kTrackbarThumb;
- break;
- default:
- NOTREACHED() << "Invalid part: " << part;
- break;
- }
-
- ui::NativeTheme::ExtraParams extra;
- ui::NativeTheme::State native_state = WebTrackbarStateToGfx(part, state,
- &extra.trackbar);
- gfx::Rect gfx_rect(rect.x, rect.y, rect.width, rect.height);
- extra.trackbar.classic_state = classic_state;
- ui::NativeTheme::instance()->Paint(canvas, native_part,
- native_state, gfx_rect, extra);
-}
-
-void WebThemeEngineImpl::paintProgressBar(
- WebCanvas* canvas, const WebRect& barRect, const WebRect& valueRect,
- bool determinate, double animatedSeconds)
-{
- gfx::Rect gfx_rect(barRect.x, barRect.y, barRect.width, barRect.height);
- ui::NativeTheme::ExtraParams extra;
- extra.progress_bar.animated_seconds = animatedSeconds;
- extra.progress_bar.determinate = determinate;
- extra.progress_bar.value_rect_x = valueRect.x;
- extra.progress_bar.value_rect_y = valueRect.y;
- extra.progress_bar.value_rect_width = valueRect.width;
- extra.progress_bar.value_rect_height = valueRect.height;
- ui::NativeTheme::instance()->Paint(canvas, ui::NativeTheme::kProgressBar,
- ui::NativeTheme::kNormal, gfx_rect,
- extra);
-}
-
-WebSize WebThemeEngineImpl::getSize(int part) {
- switch (part) {
- case SBP_ARROWBTN: {
- gfx::Size size = ui::NativeTheme::instance()->GetPartSize(
- ui::NativeTheme::kScrollbarUpArrow,
- ui::NativeTheme::kNormal,
- ui::NativeTheme::ExtraParams());
- // GetPartSize returns a size of (0, 0) when not using a themed style
- // (i.e. Windows Classic). Returning a non-zero size in this context
- // creates repaint conflicts, particularly in the window titlebar area
- // which significantly degrades performance. Fallback to using a system
- // metric if required.
- if (size.width() == 0) {
- int width = static_cast<int>(GetSystemMetrics(SM_CXVSCROLL) /
- gfx::win::GetDeviceScaleFactor());
- size = gfx::Size(width, width);
- }
- return WebSize(size.width(), size.height());
- }
- default:
- NOTREACHED() << "Unhandled part: " << part;
- }
- return WebSize();
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/child/webthemeengine_impl_win.h b/chromium/webkit/child/webthemeengine_impl_win.h
deleted file mode 100644
index 462c8ac7f86..00000000000
--- a/chromium/webkit/child/webthemeengine_impl_win.h
+++ /dev/null
@@ -1,49 +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 WEBKIT_CHILD_WEBTHEMEENGINE_IMPL_WIN_H_
-#define WEBKIT_CHILD_WEBTHEMEENGINE_IMPL_WIN_H_
-
-#include "third_party/WebKit/public/platform/win/WebThemeEngine.h"
-
-namespace webkit_glue {
-
-class WebThemeEngineImpl : public blink::WebThemeEngine {
- public:
- // WebThemeEngine methods:
- virtual void paintButton(
- blink::WebCanvas* canvas, int part, int state, int classic_state,
- const blink::WebRect& rect);
- virtual void paintMenuList(
- blink::WebCanvas* canvas, int part, int state, int classic_state,
- const blink::WebRect& rect);
- virtual void paintScrollbarArrow(
- blink::WebCanvas* canvas, int state, int classic_state,
- const blink::WebRect& rect);
- virtual void paintScrollbarThumb(
- blink::WebCanvas* canvas, int part, int state, int classic_state,
- const blink::WebRect& rect);
- virtual void paintScrollbarTrack(
- blink::WebCanvas* canvas, int part, int state, int classic_state,
- const blink::WebRect& rect, const blink::WebRect& align_rect);
- virtual void paintSpinButton(
- blink::WebCanvas* canvas, int part, int state, int classic_state,
- const blink::WebRect& rect);
- virtual void paintTextField(
- blink::WebCanvas* canvas, int part, int state, int classic_state,
- const blink::WebRect& rect, blink::WebColor color,
- bool fill_content_area, bool draw_edges);
- virtual void paintTrackbar(
- blink::WebCanvas* canvas, int part, int state, int classic_state,
- const blink::WebRect& rect);
- virtual void paintProgressBar(
- blink::WebCanvas* canvas, const blink::WebRect& barRect,
- const blink::WebRect& valueRect, bool determinate,
- double animatedSeconds);
- virtual blink::WebSize getSize(int part);
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_WEBTHEMEENGINE_IMPL_WIN_H_
diff --git a/chromium/webkit/child/webthread_impl.cc b/chromium/webkit/child/webthread_impl.cc
deleted file mode 100644
index 46466626990..00000000000
--- a/chromium/webkit/child/webthread_impl.cc
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright 2013 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.
-
-// An implementation of WebThread in terms of base::MessageLoop and
-// base::Thread
-
-#include "webkit/child/webthread_impl.h"
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/message_loop/message_loop.h"
-#include "base/pending_task.h"
-#include "base/threading/platform_thread.h"
-
-namespace webkit_glue {
-
-WebThreadBase::WebThreadBase() { }
-WebThreadBase::~WebThreadBase() { }
-
-class WebThreadBase::TaskObserverAdapter :
- public base::MessageLoop::TaskObserver {
- public:
- TaskObserverAdapter(WebThread::TaskObserver* observer)
- : observer_(observer) { }
-
- virtual void WillProcessTask(const base::PendingTask& pending_task) OVERRIDE {
- observer_->willProcessTask();
- }
-
- virtual void DidProcessTask(const base::PendingTask& pending_task) OVERRIDE {
- observer_->didProcessTask();
- }
-
-private:
- WebThread::TaskObserver* observer_;
-};
-
-void WebThreadBase::addTaskObserver(TaskObserver* observer) {
- CHECK(isCurrentThread());
- std::pair<TaskObserverMap::iterator, bool> result = task_observer_map_.insert(
- std::make_pair(observer, static_cast<TaskObserverAdapter*>(NULL)));
- if (result.second)
- result.first->second = new TaskObserverAdapter(observer);
- base::MessageLoop::current()->AddTaskObserver(result.first->second);
-}
-
-void WebThreadBase::removeTaskObserver(TaskObserver* observer) {
- CHECK(isCurrentThread());
- TaskObserverMap::iterator iter = task_observer_map_.find(observer);
- if (iter == task_observer_map_.end())
- return;
- base::MessageLoop::current()->RemoveTaskObserver(iter->second);
- delete iter->second;
- task_observer_map_.erase(iter);
-}
-
-WebThreadImpl::WebThreadImpl(const char* name)
- : thread_(new base::Thread(name)) {
- thread_->Start();
-}
-
-void WebThreadImpl::postTask(Task* task) {
- thread_->message_loop()->PostTask(
- FROM_HERE, base::Bind(&blink::WebThread::Task::run, base::Owned(task)));
-}
-
-void WebThreadImpl::postDelayedTask(
- Task* task, long long delay_ms) {
- thread_->message_loop()->PostDelayedTask(
- FROM_HERE,
- base::Bind(&blink::WebThread::Task::run, base::Owned(task)),
- base::TimeDelta::FromMilliseconds(delay_ms));
-}
-
-void WebThreadImpl::enterRunLoop() {
- CHECK(isCurrentThread());
- CHECK(!thread_->message_loop()->is_running()); // We don't support nesting.
- thread_->message_loop()->Run();
-}
-
-void WebThreadImpl::exitRunLoop() {
- CHECK(isCurrentThread());
- CHECK(thread_->message_loop()->is_running());
- thread_->message_loop()->Quit();
-}
-
-bool WebThreadImpl::isCurrentThread() const {
- return thread_->thread_id() == base::PlatformThread::CurrentId();
-}
-
-WebThreadImpl::~WebThreadImpl() {
- thread_->Stop();
-}
-
-WebThreadImplForMessageLoop::WebThreadImplForMessageLoop(
- base::MessageLoopProxy* message_loop)
- : message_loop_(message_loop) {
-}
-
-void WebThreadImplForMessageLoop::postTask(Task* task) {
- message_loop_->PostTask(
- FROM_HERE, base::Bind(&blink::WebThread::Task::run, base::Owned(task)));
-}
-
-void WebThreadImplForMessageLoop::postDelayedTask(
- Task* task, long long delay_ms) {
- message_loop_->PostDelayedTask(
- FROM_HERE,
- base::Bind(&blink::WebThread::Task::run, base::Owned(task)),
- base::TimeDelta::FromMilliseconds(delay_ms));
-}
-
-void WebThreadImplForMessageLoop::enterRunLoop() {
- CHECK(isCurrentThread());
- CHECK(!base::MessageLoop::current()
- ->is_running()); // We don't support nesting.
- base::MessageLoop::current()->Run();
-}
-
-void WebThreadImplForMessageLoop::exitRunLoop() {
- CHECK(isCurrentThread());
- CHECK(base::MessageLoop::current()->is_running());
- base::MessageLoop::current()->Quit();
-}
-
-bool WebThreadImplForMessageLoop::isCurrentThread() const {
- return message_loop_->BelongsToCurrentThread();
-}
-
-WebThreadImplForMessageLoop::~WebThreadImplForMessageLoop() {
-}
-
-}
diff --git a/chromium/webkit/child/webthread_impl.h b/chromium/webkit/child/webthread_impl.h
deleted file mode 100644
index 73f21c29dcb..00000000000
--- a/chromium/webkit/child/webthread_impl.h
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2013 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 WEBKIT_CHILD_WEBTHREAD_IMPL_H_
-#define WEBKIT_CHILD_WEBTHREAD_IMPL_H_
-
-#include <map>
-
-#include "base/memory/scoped_ptr.h"
-#include "base/threading/thread.h"
-#include "third_party/WebKit/public/platform/WebThread.h"
-#include "webkit/child/webkit_child_export.h"
-
-namespace webkit_glue {
-
-class WebThreadBase : public blink::WebThread {
- public:
- virtual ~WebThreadBase();
-
- virtual void addTaskObserver(TaskObserver* observer);
- virtual void removeTaskObserver(TaskObserver* observer);
-
- virtual bool isCurrentThread() const = 0;
-
- protected:
- WebThreadBase();
-
- private:
- class TaskObserverAdapter;
-
- typedef std::map<TaskObserver*, TaskObserverAdapter*> TaskObserverMap;
- TaskObserverMap task_observer_map_;
-};
-
-class WebThreadImpl : public WebThreadBase {
- public:
- WEBKIT_CHILD_EXPORT explicit WebThreadImpl(const char* name);
- WEBKIT_CHILD_EXPORT virtual ~WebThreadImpl();
-
- virtual void postTask(Task* task);
- virtual void postDelayedTask(Task* task, long long delay_ms);
-
- virtual void enterRunLoop();
- virtual void exitRunLoop();
-
- base::MessageLoop* message_loop() const { return thread_->message_loop(); }
-
- private:
- virtual bool isCurrentThread() const OVERRIDE;
- scoped_ptr<base::Thread> thread_;
-};
-
-class WebThreadImplForMessageLoop : public WebThreadBase {
- public:
- WEBKIT_CHILD_EXPORT explicit WebThreadImplForMessageLoop(
- base::MessageLoopProxy* message_loop);
- WEBKIT_CHILD_EXPORT virtual ~WebThreadImplForMessageLoop();
-
- virtual void postTask(Task* task);
- virtual void postDelayedTask(Task* task, long long delay_ms);
-
- virtual void enterRunLoop();
- virtual void exitRunLoop();
-
- private:
- virtual bool isCurrentThread() const OVERRIDE;
- scoped_refptr<base::MessageLoopProxy> message_loop_;
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_WEBTHREAD_IMPL_H_
diff --git a/chromium/webkit/child/weburlloader_impl.cc b/chromium/webkit/child/weburlloader_impl.cc
deleted file mode 100644
index 9ecf69a883f..00000000000
--- a/chromium/webkit/child/weburlloader_impl.cc
+++ /dev/null
@@ -1,857 +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.
-
-// An implementation of WebURLLoader in terms of ResourceLoaderBridge.
-
-#include "webkit/child/weburlloader_impl.h"
-
-#include "base/bind.h"
-#include "base/files/file_path.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "base/strings/string_util.h"
-#include "base/time/time.h"
-#include "net/base/data_url.h"
-#include "net/base/load_flags.h"
-#include "net/base/mime_util.h"
-#include "net/base/net_errors.h"
-#include "net/base/net_util.h"
-#include "net/http/http_response_headers.h"
-#include "net/http/http_util.h"
-#include "net/url_request/url_request.h"
-#include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h"
-#include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h"
-#include "third_party/WebKit/public/platform/WebURL.h"
-#include "third_party/WebKit/public/platform/WebURLError.h"
-#include "third_party/WebKit/public/platform/WebURLLoadTiming.h"
-#include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
-#include "third_party/WebKit/public/platform/WebURLRequest.h"
-#include "third_party/WebKit/public/platform/WebURLResponse.h"
-#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
-#include "webkit/child/ftp_directory_listing_response_delegate.h"
-#include "webkit/child/multipart_response_delegate.h"
-#include "webkit/child/resource_loader_bridge.h"
-#include "webkit/child/webkitplatformsupport_impl.h"
-#include "webkit/child/weburlrequest_extradata_impl.h"
-#include "webkit/child/weburlresponse_extradata_impl.h"
-#include "webkit/common/resource_request_body.h"
-
-using base::Time;
-using base::TimeTicks;
-using blink::WebData;
-using blink::WebHTTPBody;
-using blink::WebHTTPHeaderVisitor;
-using blink::WebHTTPLoadInfo;
-using blink::WebReferrerPolicy;
-using blink::WebSecurityPolicy;
-using blink::WebString;
-using blink::WebURL;
-using blink::WebURLError;
-using blink::WebURLLoadTiming;
-using blink::WebURLLoader;
-using blink::WebURLLoaderClient;
-using blink::WebURLRequest;
-using blink::WebURLResponse;
-
-namespace webkit_glue {
-
-// Utilities ------------------------------------------------------------------
-
-namespace {
-
-const char kThrottledErrorDescription[] =
- "Request throttled. Visit http://dev.chromium.org/throttling for more "
- "information.";
-
-class HeaderFlattener : public WebHTTPHeaderVisitor {
- public:
- explicit HeaderFlattener(int load_flags)
- : load_flags_(load_flags),
- has_accept_header_(false) {
- }
-
- virtual void visitHeader(const WebString& name, const WebString& value) {
- // Headers are latin1.
- const std::string& name_latin1 = name.latin1();
- const std::string& value_latin1 = value.latin1();
-
- // Skip over referrer headers found in the header map because we already
- // pulled it out as a separate parameter.
- if (LowerCaseEqualsASCII(name_latin1, "referer"))
- return;
-
- // Skip over "Cache-Control: max-age=0" header if the corresponding
- // load flag is already specified. FrameLoader sets both the flag and
- // the extra header -- the extra header is redundant since our network
- // implementation will add the necessary headers based on load flags.
- // See http://code.google.com/p/chromium/issues/detail?id=3434.
- if ((load_flags_ & net::LOAD_VALIDATE_CACHE) &&
- LowerCaseEqualsASCII(name_latin1, "cache-control") &&
- LowerCaseEqualsASCII(value_latin1, "max-age=0"))
- return;
-
- if (LowerCaseEqualsASCII(name_latin1, "accept"))
- has_accept_header_ = true;
-
- if (!buffer_.empty())
- buffer_.append("\r\n");
- buffer_.append(name_latin1 + ": " + value_latin1);
- }
-
- const std::string& GetBuffer() {
- // In some cases, WebKit doesn't add an Accept header, but not having the
- // header confuses some web servers. See bug 808613.
- if (!has_accept_header_) {
- if (!buffer_.empty())
- buffer_.append("\r\n");
- buffer_.append("Accept: */*");
- has_accept_header_ = true;
- }
- return buffer_;
- }
-
- private:
- int load_flags_;
- std::string buffer_;
- bool has_accept_header_;
-};
-
-// Extracts the information from a data: url.
-bool GetInfoFromDataURL(const GURL& url,
- ResourceResponseInfo* info,
- std::string* data,
- int* error_code) {
- std::string mime_type;
- std::string charset;
- if (net::DataURL::Parse(url, &mime_type, &charset, data)) {
- *error_code = net::OK;
- // Assure same time for all time fields of data: URLs.
- Time now = Time::Now();
- info->load_timing.request_start = TimeTicks::Now();
- info->load_timing.request_start_time = now;
- info->request_time = now;
- info->response_time = now;
- info->headers = NULL;
- info->mime_type.swap(mime_type);
- info->charset.swap(charset);
- info->security_info.clear();
- info->content_length = data->length();
- info->encoded_data_length = 0;
-
- return true;
- }
-
- *error_code = net::ERR_INVALID_URL;
- return false;
-}
-
-typedef ResourceDevToolsInfo::HeadersVector HeadersVector;
-
-// Converts timing data from |load_timing| to the format used by WebKit.
-void PopulateURLLoadTiming(const net::LoadTimingInfo& load_timing,
- WebURLLoadTiming* url_timing) {
- DCHECK(!load_timing.request_start.is_null());
-
- const TimeTicks kNullTicks;
- url_timing->initialize();
- url_timing->setRequestTime(
- (load_timing.request_start - kNullTicks).InSecondsF());
- url_timing->setProxyStart(
- (load_timing.proxy_resolve_start - kNullTicks).InSecondsF());
- url_timing->setProxyEnd(
- (load_timing.proxy_resolve_end - kNullTicks).InSecondsF());
- url_timing->setDNSStart(
- (load_timing.connect_timing.dns_start - kNullTicks).InSecondsF());
- url_timing->setDNSEnd(
- (load_timing.connect_timing.dns_end - kNullTicks).InSecondsF());
- url_timing->setConnectStart(
- (load_timing.connect_timing.connect_start - kNullTicks).InSecondsF());
- url_timing->setConnectEnd(
- (load_timing.connect_timing.connect_end - kNullTicks).InSecondsF());
- url_timing->setSSLStart(
- (load_timing.connect_timing.ssl_start - kNullTicks).InSecondsF());
- url_timing->setSSLEnd(
- (load_timing.connect_timing.ssl_end - kNullTicks).InSecondsF());
- url_timing->setSendStart(
- (load_timing.send_start - kNullTicks).InSecondsF());
- url_timing->setSendEnd(
- (load_timing.send_end - kNullTicks).InSecondsF());
- url_timing->setReceiveHeadersEnd(
- (load_timing.receive_headers_end - kNullTicks).InSecondsF());
-}
-
-net::RequestPriority ConvertWebKitPriorityToNetPriority(
- const WebURLRequest::Priority& priority) {
- switch (priority) {
- case WebURLRequest::PriorityVeryHigh:
- return net::HIGHEST;
-
- case WebURLRequest::PriorityHigh:
- return net::MEDIUM;
-
- case WebURLRequest::PriorityMedium:
- return net::LOW;
-
- case WebURLRequest::PriorityLow:
- return net::LOWEST;
-
- case WebURLRequest::PriorityVeryLow:
- return net::IDLE;
-
- case WebURLRequest::PriorityUnresolved:
- default:
- NOTREACHED();
- return net::LOW;
- }
-}
-
-} // namespace
-
-// WebURLLoaderImpl::Context --------------------------------------------------
-
-// This inner class exists since the WebURLLoader may be deleted while inside a
-// call to WebURLLoaderClient. The bridge requires its Peer to stay alive
-// until it receives OnCompletedRequest.
-class WebURLLoaderImpl::Context : public base::RefCounted<Context>,
- public ResourceLoaderBridge::Peer {
- public:
- explicit Context(WebURLLoaderImpl* loader);
-
- WebURLLoaderClient* client() const { return client_; }
- void set_client(WebURLLoaderClient* client) { client_ = client; }
-
- void Cancel();
- void SetDefersLoading(bool value);
- void DidChangePriority(WebURLRequest::Priority new_priority);
- void Start(
- const WebURLRequest& request,
- ResourceLoaderBridge::SyncLoadResponse* sync_load_response,
- WebKitPlatformSupportImpl* platform);
-
- // ResourceLoaderBridge::Peer methods:
- virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE;
- virtual bool OnReceivedRedirect(
- const GURL& new_url,
- const ResourceResponseInfo& info,
- bool* has_new_first_party_for_cookies,
- GURL* new_first_party_for_cookies) OVERRIDE;
- virtual void OnReceivedResponse(const ResourceResponseInfo& info) OVERRIDE;
- virtual void OnDownloadedData(int len, int encoded_data_length) OVERRIDE;
- virtual void OnReceivedData(const char* data,
- int data_length,
- int encoded_data_length) OVERRIDE;
- virtual void OnReceivedCachedMetadata(const char* data, int len) OVERRIDE;
- virtual void OnCompletedRequest(
- int error_code,
- bool was_ignored_by_handler,
- const std::string& security_info,
- const base::TimeTicks& completion_time) OVERRIDE;
-
- private:
- friend class base::RefCounted<Context>;
- virtual ~Context() {}
-
- // We can optimize the handling of data URLs in most cases.
- bool CanHandleDataURL(const GURL& url) const;
- void HandleDataURL();
-
- WebURLLoaderImpl* loader_;
- WebURLRequest request_;
- WebURLLoaderClient* client_;
- WebReferrerPolicy referrer_policy_;
- scoped_ptr<ResourceLoaderBridge> bridge_;
- scoped_ptr<FtpDirectoryListingResponseDelegate> ftp_listing_delegate_;
- scoped_ptr<MultipartResponseDelegate> multipart_delegate_;
- scoped_ptr<ResourceLoaderBridge> completed_bridge_;
-};
-
-WebURLLoaderImpl::Context::Context(WebURLLoaderImpl* loader)
- : loader_(loader),
- client_(NULL),
- referrer_policy_(blink::WebReferrerPolicyDefault) {
-}
-
-void WebURLLoaderImpl::Context::Cancel() {
- // The bridge will still send OnCompletedRequest, which will Release() us, so
- // we don't do that here.
- if (bridge_)
- bridge_->Cancel();
-
- // Ensure that we do not notify the multipart delegate anymore as it has
- // its own pointer to the client.
- if (multipart_delegate_)
- multipart_delegate_->Cancel();
-
- // Do not make any further calls to the client.
- client_ = NULL;
- loader_ = NULL;
-}
-
-void WebURLLoaderImpl::Context::SetDefersLoading(bool value) {
- if (bridge_)
- bridge_->SetDefersLoading(value);
-}
-
-void WebURLLoaderImpl::Context::DidChangePriority(
- WebURLRequest::Priority new_priority) {
- if (bridge_)
- bridge_->DidChangePriority(
- ConvertWebKitPriorityToNetPriority(new_priority));
-}
-
-void WebURLLoaderImpl::Context::Start(
- const WebURLRequest& request,
- ResourceLoaderBridge::SyncLoadResponse* sync_load_response,
- WebKitPlatformSupportImpl* platform) {
- DCHECK(!bridge_.get());
-
- request_ = request; // Save the request.
-
- GURL url = request.url();
- if (url.SchemeIs("data") && CanHandleDataURL(url)) {
- if (sync_load_response) {
- // This is a sync load. Do the work now.
- sync_load_response->url = url;
- std::string data;
- GetInfoFromDataURL(sync_load_response->url, sync_load_response,
- &sync_load_response->data,
- &sync_load_response->error_code);
- } else {
- AddRef(); // Balanced in OnCompletedRequest
- base::MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(&Context::HandleDataURL, this));
- }
- return;
- }
-
- GURL referrer_url(
- request.httpHeaderField(WebString::fromUTF8("Referer")).latin1());
- const std::string& method = request.httpMethod().latin1();
-
- int load_flags = net::LOAD_NORMAL;
- switch (request.cachePolicy()) {
- case WebURLRequest::ReloadIgnoringCacheData:
- // Required by LayoutTests/http/tests/misc/refresh-headers.php
- load_flags |= net::LOAD_VALIDATE_CACHE;
- break;
- case WebURLRequest::ReturnCacheDataElseLoad:
- load_flags |= net::LOAD_PREFERRING_CACHE;
- break;
- case WebURLRequest::ReturnCacheDataDontLoad:
- load_flags |= net::LOAD_ONLY_FROM_CACHE;
- break;
- case WebURLRequest::UseProtocolCachePolicy:
- break;
- }
-
- if (request.reportUploadProgress())
- load_flags |= net::LOAD_ENABLE_UPLOAD_PROGRESS;
- if (request.reportLoadTiming())
- load_flags |= net::LOAD_ENABLE_LOAD_TIMING;
- if (request.reportRawHeaders())
- load_flags |= net::LOAD_REPORT_RAW_HEADERS;
-
- if (!request.allowCookies() || !request.allowStoredCredentials()) {
- load_flags |= net::LOAD_DO_NOT_SAVE_COOKIES;
- load_flags |= net::LOAD_DO_NOT_SEND_COOKIES;
- }
-
- if (!request.allowStoredCredentials())
- load_flags |= net::LOAD_DO_NOT_SEND_AUTH_DATA;
-
- HeaderFlattener flattener(load_flags);
- request.visitHTTPHeaderFields(&flattener);
-
- // TODO(brettw) this should take parameter encoding into account when
- // creating the GURLs.
-
- ResourceLoaderBridge::RequestInfo request_info;
- request_info.method = method;
- request_info.url = url;
- request_info.first_party_for_cookies = request.firstPartyForCookies();
- request_info.referrer = referrer_url;
- request_info.headers = flattener.GetBuffer();
- request_info.load_flags = load_flags;
- // requestor_pid only needs to be non-zero if the request originates outside
- // the render process, so we can use requestorProcessID even for requests
- // from in-process plugins.
- request_info.requestor_pid = request.requestorProcessID();
- request_info.request_type =
- ResourceType::FromTargetType(request.targetType());
- request_info.priority =
- ConvertWebKitPriorityToNetPriority(request.priority());
- request_info.appcache_host_id = request.appCacheHostID();
- request_info.routing_id = request.requestorID();
- request_info.download_to_file = request.downloadToFile();
- request_info.has_user_gesture = request.hasUserGesture();
- request_info.extra_data = request.extraData();
- if (request.extraData()) {
- referrer_policy_ = static_cast<WebURLRequestExtraDataImpl*>(
- request.extraData())->referrer_policy();
- request_info.referrer_policy = referrer_policy_;
- }
- bridge_.reset(platform->CreateResourceLoader(request_info));
-
- if (!request.httpBody().isNull()) {
- // GET and HEAD requests shouldn't have http bodies.
- DCHECK(method != "GET" && method != "HEAD");
- const WebHTTPBody& httpBody = request.httpBody();
- size_t i = 0;
- WebHTTPBody::Element element;
- scoped_refptr<ResourceRequestBody> request_body = new ResourceRequestBody;
- while (httpBody.elementAt(i++, element)) {
- switch (element.type) {
- case WebHTTPBody::Element::TypeData:
- if (!element.data.isEmpty()) {
- // WebKit sometimes gives up empty data to append. These aren't
- // necessary so we just optimize those out here.
- request_body->AppendBytes(
- element.data.data(), static_cast<int>(element.data.size()));
- }
- break;
- case WebHTTPBody::Element::TypeFile:
- if (element.fileLength == -1) {
- request_body->AppendFileRange(
- base::FilePath::FromUTF16Unsafe(element.filePath),
- 0, kuint64max, base::Time());
- } else {
- request_body->AppendFileRange(
- base::FilePath::FromUTF16Unsafe(element.filePath),
- static_cast<uint64>(element.fileStart),
- static_cast<uint64>(element.fileLength),
- base::Time::FromDoubleT(element.modificationTime));
- }
- break;
- case WebHTTPBody::Element::TypeFileSystemURL: {
- GURL file_system_url = element.fileSystemURL;
- DCHECK(file_system_url.SchemeIsFileSystem());
- request_body->AppendFileSystemFileRange(
- file_system_url,
- static_cast<uint64>(element.fileStart),
- static_cast<uint64>(element.fileLength),
- base::Time::FromDoubleT(element.modificationTime));
- break;
- }
- case WebHTTPBody::Element::TypeBlob:
- request_body->AppendBlob(element.blobUUID.utf8());
- break;
- default:
- NOTREACHED();
- }
- }
- request_body->set_identifier(request.httpBody().identifier());
- bridge_->SetRequestBody(request_body.get());
- }
-
- if (sync_load_response) {
- bridge_->SyncLoad(sync_load_response);
- return;
- }
-
- if (bridge_->Start(this)) {
- AddRef(); // Balanced in OnCompletedRequest
- } else {
- bridge_.reset();
- }
-}
-
-void WebURLLoaderImpl::Context::OnUploadProgress(uint64 position, uint64 size) {
- if (client_)
- client_->didSendData(loader_, position, size);
-}
-
-bool WebURLLoaderImpl::Context::OnReceivedRedirect(
- const GURL& new_url,
- const ResourceResponseInfo& info,
- bool* has_new_first_party_for_cookies,
- GURL* new_first_party_for_cookies) {
- if (!client_)
- return false;
-
- WebURLResponse response;
- response.initialize();
- PopulateURLResponse(request_.url(), info, &response);
-
- // TODO(darin): We lack sufficient information to construct the actual
- // request that resulted from the redirect.
- WebURLRequest new_request(new_url);
- new_request.setFirstPartyForCookies(request_.firstPartyForCookies());
- new_request.setDownloadToFile(request_.downloadToFile());
-
- WebString referrer_string = WebString::fromUTF8("Referer");
- WebString referrer = WebSecurityPolicy::generateReferrerHeader(
- referrer_policy_,
- new_url,
- request_.httpHeaderField(referrer_string));
- if (!referrer.isEmpty())
- new_request.setHTTPHeaderField(referrer_string, referrer);
-
- std::string new_method = net::URLRequest::ComputeMethodForRedirect(
- request_.httpMethod().utf8(), response.httpStatusCode());
- new_request.setHTTPMethod(WebString::fromUTF8(new_method));
-
- client_->willSendRequest(loader_, new_request, response);
- request_ = new_request;
- *has_new_first_party_for_cookies = true;
- *new_first_party_for_cookies = request_.firstPartyForCookies();
-
- // Only follow the redirect if WebKit left the URL unmodified.
- if (new_url == GURL(new_request.url()))
- return true;
-
- // We assume that WebKit only changes the URL to suppress a redirect, and we
- // assume that it does so by setting it to be invalid.
- DCHECK(!new_request.url().isValid());
- return false;
-}
-
-void WebURLLoaderImpl::Context::OnReceivedResponse(
- const ResourceResponseInfo& info) {
- if (!client_)
- return;
-
- WebURLResponse response;
- response.initialize();
- PopulateURLResponse(request_.url(), info, &response);
-
- bool show_raw_listing = (GURL(request_.url()).query() == "raw");
-
- if (info.mime_type == "text/vnd.chromium.ftp-dir") {
- if (show_raw_listing) {
- // Set the MIME type to plain text to prevent any active content.
- response.setMIMEType("text/plain");
- } else {
- // We're going to produce a parsed listing in HTML.
- response.setMIMEType("text/html");
- }
- }
-
- scoped_refptr<Context> protect(this);
- client_->didReceiveResponse(loader_, response);
-
- // We may have been cancelled after didReceiveResponse, which would leave us
- // without a client and therefore without much need to do further handling.
- if (!client_)
- return;
-
- DCHECK(!ftp_listing_delegate_.get());
- DCHECK(!multipart_delegate_.get());
- if (info.headers.get() && info.mime_type == "multipart/x-mixed-replace") {
- std::string content_type;
- info.headers->EnumerateHeader(NULL, "content-type", &content_type);
-
- std::string mime_type;
- std::string charset;
- bool had_charset = false;
- std::string boundary;
- net::HttpUtil::ParseContentType(content_type, &mime_type, &charset,
- &had_charset, &boundary);
- base::TrimString(boundary, " \"", &boundary);
-
- // If there's no boundary, just handle the request normally. In the gecko
- // code, nsMultiMixedConv::OnStartRequest throws an exception.
- if (!boundary.empty()) {
- multipart_delegate_.reset(
- new MultipartResponseDelegate(client_, loader_, response, boundary));
- }
- } else if (info.mime_type == "text/vnd.chromium.ftp-dir" &&
- !show_raw_listing) {
- ftp_listing_delegate_.reset(
- new FtpDirectoryListingResponseDelegate(client_, loader_, response));
- }
-}
-
-void WebURLLoaderImpl::Context::OnDownloadedData(int len,
- int encoded_data_length) {
- if (client_)
- client_->didDownloadData(loader_, len, encoded_data_length);
-}
-
-void WebURLLoaderImpl::Context::OnReceivedData(const char* data,
- int data_length,
- int encoded_data_length) {
- if (!client_)
- return;
-
- if (ftp_listing_delegate_) {
- // The FTP listing delegate will make the appropriate calls to
- // client_->didReceiveData and client_->didReceiveResponse.
- ftp_listing_delegate_->OnReceivedData(data, data_length);
- } else if (multipart_delegate_) {
- // The multipart delegate will make the appropriate calls to
- // client_->didReceiveData and client_->didReceiveResponse.
- multipart_delegate_->OnReceivedData(data, data_length, encoded_data_length);
- } else {
- client_->didReceiveData(loader_, data, data_length, encoded_data_length);
- }
-}
-
-void WebURLLoaderImpl::Context::OnReceivedCachedMetadata(
- const char* data, int len) {
- if (client_)
- client_->didReceiveCachedMetadata(loader_, data, len);
-}
-
-void WebURLLoaderImpl::Context::OnCompletedRequest(
- int error_code,
- bool was_ignored_by_handler,
- const std::string& security_info,
- const base::TimeTicks& completion_time) {
- if (ftp_listing_delegate_) {
- ftp_listing_delegate_->OnCompletedRequest();
- ftp_listing_delegate_.reset(NULL);
- } else if (multipart_delegate_) {
- multipart_delegate_->OnCompletedRequest();
- multipart_delegate_.reset(NULL);
- }
-
- // Prevent any further IPC to the browser now that we're complete, but
- // don't delete it to keep any downloaded temp files alive.
- DCHECK(!completed_bridge_.get());
- completed_bridge_.swap(bridge_);
-
- if (client_) {
- if (error_code != net::OK) {
- client_->didFail(loader_, CreateError(request_.url(), error_code));
- } else {
- client_->didFinishLoading(
- loader_, (completion_time - TimeTicks()).InSecondsF());
- }
- }
-
- // We are done with the bridge now, and so we need to release the reference
- // to ourselves that we took on behalf of the bridge. This may cause our
- // destruction.
- Release();
-}
-
-bool WebURLLoaderImpl::Context::CanHandleDataURL(const GURL& url) const {
- DCHECK(url.SchemeIs("data"));
-
- // Optimize for the case where we can handle a data URL locally. We must
- // skip this for data URLs targetted at frames since those could trigger a
- // download.
- //
- // NOTE: We special case MIME types we can render both for performance
- // reasons as well as to support unit tests, which do not have an underlying
- // ResourceLoaderBridge implementation.
-
-#if defined(OS_ANDROID)
- // For compatibility reasons on Android we need to expose top-level data://
- // to the browser.
- if (request_.targetType() == WebURLRequest::TargetIsMainFrame)
- return false;
-#endif
-
- if (request_.targetType() != WebURLRequest::TargetIsMainFrame &&
- request_.targetType() != WebURLRequest::TargetIsSubframe)
- return true;
-
- std::string mime_type, unused_charset;
- if (net::DataURL::Parse(url, &mime_type, &unused_charset, NULL) &&
- net::IsSupportedMimeType(mime_type))
- return true;
-
- return false;
-}
-
-void WebURLLoaderImpl::Context::HandleDataURL() {
- ResourceResponseInfo info;
- int error_code;
- std::string data;
-
- if (GetInfoFromDataURL(request_.url(), &info, &data, &error_code)) {
- OnReceivedResponse(info);
- if (!data.empty())
- OnReceivedData(data.data(), data.size(), 0);
- }
-
- OnCompletedRequest(error_code, false, info.security_info,
- base::TimeTicks::Now());
-}
-
-// WebURLLoaderImpl -----------------------------------------------------------
-
-WebURLLoaderImpl::WebURLLoaderImpl(WebKitPlatformSupportImpl* platform)
- : context_(new Context(this)),
- platform_(platform) {
-}
-
-WebURLLoaderImpl::~WebURLLoaderImpl() {
- cancel();
-}
-
-WebURLError WebURLLoaderImpl::CreateError(const WebURL& unreachable_url,
- int reason) {
- WebURLError error;
- error.domain = WebString::fromUTF8(net::kErrorDomain);
- error.reason = reason;
- error.unreachableURL = unreachable_url;
- if (reason == net::ERR_ABORTED) {
- error.isCancellation = true;
- } else if (reason == net::ERR_TEMPORARILY_THROTTLED) {
- error.localizedDescription = WebString::fromUTF8(
- kThrottledErrorDescription);
- } else {
- error.localizedDescription = WebString::fromUTF8(
- net::ErrorToString(reason));
- }
- return error;
-}
-
-void WebURLLoaderImpl::PopulateURLResponse(const GURL& url,
- const ResourceResponseInfo& info,
- WebURLResponse* response) {
- response->setURL(url);
- response->setResponseTime(info.response_time.ToDoubleT());
- response->setMIMEType(WebString::fromUTF8(info.mime_type));
- response->setTextEncodingName(WebString::fromUTF8(info.charset));
- response->setExpectedContentLength(info.content_length);
- response->setSecurityInfo(info.security_info);
- response->setAppCacheID(info.appcache_id);
- response->setAppCacheManifestURL(info.appcache_manifest_url);
- response->setWasCached(!info.load_timing.request_start_time.is_null() &&
- info.response_time < info.load_timing.request_start_time);
- response->setRemoteIPAddress(
- WebString::fromUTF8(info.socket_address.host()));
- response->setRemotePort(info.socket_address.port());
- response->setConnectionID(info.load_timing.socket_log_id);
- response->setConnectionReused(info.load_timing.socket_reused);
- response->setDownloadFilePath(info.download_file_path.AsUTF16Unsafe());
- WebURLResponseExtraDataImpl* extra_data =
- new WebURLResponseExtraDataImpl(info.npn_negotiated_protocol);
- response->setExtraData(extra_data);
- extra_data->set_was_fetched_via_spdy(info.was_fetched_via_spdy);
- extra_data->set_was_npn_negotiated(info.was_npn_negotiated);
- extra_data->set_was_alternate_protocol_available(
- info.was_alternate_protocol_available);
- extra_data->set_connection_info(info.connection_info);
- extra_data->set_was_fetched_via_proxy(info.was_fetched_via_proxy);
-
- // If there's no received headers end time, don't set load timing. This is
- // the case for non-HTTP requests, requests that don't go over the wire, and
- // certain error cases.
- if (!info.load_timing.receive_headers_end.is_null()) {
- WebURLLoadTiming timing;
- PopulateURLLoadTiming(info.load_timing, &timing);
- response->setLoadTiming(timing);
- }
-
- if (info.devtools_info.get()) {
- WebHTTPLoadInfo load_info;
-
- load_info.setHTTPStatusCode(info.devtools_info->http_status_code);
- load_info.setHTTPStatusText(WebString::fromLatin1(
- info.devtools_info->http_status_text));
- load_info.setEncodedDataLength(info.encoded_data_length);
-
- load_info.setRequestHeadersText(WebString::fromLatin1(
- info.devtools_info->request_headers_text));
- load_info.setResponseHeadersText(WebString::fromLatin1(
- info.devtools_info->response_headers_text));
- const HeadersVector& request_headers = info.devtools_info->request_headers;
- for (HeadersVector::const_iterator it = request_headers.begin();
- it != request_headers.end(); ++it) {
- load_info.addRequestHeader(WebString::fromLatin1(it->first),
- WebString::fromLatin1(it->second));
- }
- const HeadersVector& response_headers =
- info.devtools_info->response_headers;
- for (HeadersVector::const_iterator it = response_headers.begin();
- it != response_headers.end(); ++it) {
- load_info.addResponseHeader(WebString::fromLatin1(it->first),
- WebString::fromLatin1(it->second));
- }
- response->setHTTPLoadInfo(load_info);
- }
-
- const net::HttpResponseHeaders* headers = info.headers.get();
- if (!headers)
- return;
-
- WebURLResponse::HTTPVersion version = WebURLResponse::Unknown;
- if (headers->GetHttpVersion() == net::HttpVersion(0, 9))
- version = WebURLResponse::HTTP_0_9;
- else if (headers->GetHttpVersion() == net::HttpVersion(1, 0))
- version = WebURLResponse::HTTP_1_0;
- else if (headers->GetHttpVersion() == net::HttpVersion(1, 1))
- version = WebURLResponse::HTTP_1_1;
- response->setHTTPVersion(version);
- response->setHTTPStatusCode(headers->response_code());
- response->setHTTPStatusText(WebString::fromLatin1(headers->GetStatusText()));
-
- // TODO(darin): We should leverage HttpResponseHeaders for this, and this
- // should be using the same code as ResourceDispatcherHost.
- // TODO(jungshik): Figure out the actual value of the referrer charset and
- // pass it to GetSuggestedFilename.
- std::string value;
- headers->EnumerateHeader(NULL, "content-disposition", &value);
- response->setSuggestedFileName(
- net::GetSuggestedFilename(url,
- value,
- std::string(), // referrer_charset
- std::string(), // suggested_name
- std::string(), // mime_type
- std::string())); // default_name
-
- Time time_val;
- if (headers->GetLastModifiedValue(&time_val))
- response->setLastModifiedDate(time_val.ToDoubleT());
-
- // Build up the header map.
- void* iter = NULL;
- std::string name;
- while (headers->EnumerateHeaderLines(&iter, &name, &value)) {
- response->addHTTPHeaderField(WebString::fromLatin1(name),
- WebString::fromLatin1(value));
- }
-}
-
-void WebURLLoaderImpl::loadSynchronously(const WebURLRequest& request,
- WebURLResponse& response,
- WebURLError& error,
- WebData& data) {
- ResourceLoaderBridge::SyncLoadResponse sync_load_response;
- context_->Start(request, &sync_load_response, platform_);
-
- const GURL& final_url = sync_load_response.url;
-
- // TODO(tc): For file loads, we may want to include a more descriptive
- // status code or status text.
- int error_code = sync_load_response.error_code;
- if (error_code != net::OK) {
- response.setURL(final_url);
- error.domain = WebString::fromUTF8(net::kErrorDomain);
- error.reason = error_code;
- error.unreachableURL = final_url;
- return;
- }
-
- PopulateURLResponse(final_url, sync_load_response, &response);
-
- data.assign(sync_load_response.data.data(),
- sync_load_response.data.size());
-}
-
-void WebURLLoaderImpl::loadAsynchronously(const WebURLRequest& request,
- WebURLLoaderClient* client) {
- DCHECK(!context_->client());
-
- context_->set_client(client);
- context_->Start(request, NULL, platform_);
-}
-
-void WebURLLoaderImpl::cancel() {
- context_->Cancel();
-}
-
-void WebURLLoaderImpl::setDefersLoading(bool value) {
- context_->SetDefersLoading(value);
-}
-
-void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) {
- context_->DidChangePriority(new_priority);
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/child/weburlloader_impl.h b/chromium/webkit/child/weburlloader_impl.h
deleted file mode 100644
index 3cd200183bb..00000000000
--- a/chromium/webkit/child/weburlloader_impl.h
+++ /dev/null
@@ -1,50 +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 WEBKIT_CHILD_WEBURLLOADER_IMPL_H_
-#define WEBKIT_CHILD_WEBURLLOADER_IMPL_H_
-
-#include "base/memory/ref_counted.h"
-#include "third_party/WebKit/public/platform/WebURLLoader.h"
-#include "webkit/child/webkit_child_export.h"
-
-namespace webkit_glue {
-
-class WebKitPlatformSupportImpl;
-struct ResourceResponseInfo;
-
-class WebURLLoaderImpl : public blink::WebURLLoader {
- public:
- explicit WebURLLoaderImpl(WebKitPlatformSupportImpl* platform);
- virtual ~WebURLLoaderImpl();
-
- static blink::WebURLError CreateError(const blink::WebURL& unreachable_url,
- int reason);
- WEBKIT_CHILD_EXPORT static void PopulateURLResponse(
- const GURL& url,
- const ResourceResponseInfo& info,
- blink::WebURLResponse* response);
-
- // WebURLLoader methods:
- virtual void loadSynchronously(
- const blink::WebURLRequest& request,
- blink::WebURLResponse& response,
- blink::WebURLError& error,
- blink::WebData& data);
- virtual void loadAsynchronously(
- const blink::WebURLRequest& request,
- blink::WebURLLoaderClient* client);
- virtual void cancel();
- virtual void setDefersLoading(bool value);
- virtual void didChangePriority(blink::WebURLRequest::Priority new_priority);
-
- private:
- class Context;
- scoped_refptr<Context> context_;
- WebKitPlatformSupportImpl* platform_;
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_WEBURLLOADER_IMPL_H_
diff --git a/chromium/webkit/child/weburlrequest_extradata_impl.cc b/chromium/webkit/child/weburlrequest_extradata_impl.cc
deleted file mode 100644
index 81b6e4ab6ba..00000000000
--- a/chromium/webkit/child/weburlrequest_extradata_impl.cc
+++ /dev/null
@@ -1,24 +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 "webkit/child/weburlrequest_extradata_impl.h"
-
-using blink::WebReferrerPolicy;
-using blink::WebString;
-
-namespace webkit_glue {
-
-WebURLRequestExtraDataImpl::WebURLRequestExtraDataImpl(
- WebReferrerPolicy referrer_policy,
- const WebString& custom_user_agent,
- bool was_after_preconnect_request)
- : referrer_policy_(referrer_policy),
- custom_user_agent_(custom_user_agent),
- was_after_preconnect_request_(was_after_preconnect_request) {
-}
-
-WebURLRequestExtraDataImpl::~WebURLRequestExtraDataImpl() {
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/child/weburlrequest_extradata_impl.h b/chromium/webkit/child/weburlrequest_extradata_impl.h
deleted file mode 100644
index 003249abb9b..00000000000
--- a/chromium/webkit/child/weburlrequest_extradata_impl.h
+++ /dev/null
@@ -1,48 +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 WEBKIT_CHILD_WEBURLREQUEST_EXTRADATA_IMPL_H_
-#define WEBKIT_CHILD_WEBURLREQUEST_EXTRADATA_IMPL_H_
-
-#include "base/compiler_specific.h"
-#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
-#include "third_party/WebKit/public/platform/WebString.h"
-#include "third_party/WebKit/public/platform/WebURLRequest.h"
-#include "webkit/child/webkit_child_export.h"
-
-namespace webkit_glue {
-
-// Base class for Chrome's implementation of the "extra data" stored in each
-// ResourceRequest.
-class WEBKIT_CHILD_EXPORT WebURLRequestExtraDataImpl :
- public NON_EXPORTED_BASE(blink::WebURLRequest::ExtraData) {
- public:
- // |custom_user_agent| is used to communicate an overriding custom user agent
- // to |RenderViewImpl::willSendRequest()|; set to a null string to indicate no
- // override and an empty string to indicate that there should be no user
- // agent. This needs to be here, instead of content's |RequestExtraData| since
- // ppb_url_request_info_impl.cc needs to be able to set it.
- explicit WebURLRequestExtraDataImpl(
- blink::WebReferrerPolicy referrer_policy,
- const blink::WebString& custom_user_agent,
- bool was_after_preconnect_request);
- virtual ~WebURLRequestExtraDataImpl();
-
- blink::WebReferrerPolicy referrer_policy() const { return referrer_policy_; }
- const blink::WebString& custom_user_agent() const {
- return custom_user_agent_;
- }
- bool was_after_preconnect_request() { return was_after_preconnect_request_; }
-
- private:
- blink::WebReferrerPolicy referrer_policy_;
- blink::WebString custom_user_agent_;
- bool was_after_preconnect_request_;
-
- DISALLOW_COPY_AND_ASSIGN(WebURLRequestExtraDataImpl);
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_WEBURLREQUEST_EXTRADATA_IMPL_H_
diff --git a/chromium/webkit/child/worker_task_runner.cc b/chromium/webkit/child/worker_task_runner.cc
deleted file mode 100644
index c0d43598f6f..00000000000
--- a/chromium/webkit/child/worker_task_runner.cc
+++ /dev/null
@@ -1,111 +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 "base/callback.h"
-#include "base/lazy_instance.h"
-#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/observer_list.h"
-#include "webkit/child/worker_task_runner.h"
-
-using blink::WebWorkerRunLoop;
-
-namespace {
-
-class RunClosureTask : public WebWorkerRunLoop::Task {
- public:
- RunClosureTask(const base::Closure& task) : task_(task) {}
- virtual ~RunClosureTask() {}
- virtual void Run() {
- task_.Run();
- }
- private:
- base::Closure task_;
-};
-
-} // unnamed namespace
-
-namespace webkit_glue {
-
-struct WorkerTaskRunner::ThreadLocalState {
- ThreadLocalState(int id, const WebWorkerRunLoop& loop)
- : id_(id), run_loop_(loop) {
- }
- int id_;
- WebWorkerRunLoop run_loop_;
- ObserverList<WorkerTaskRunner::Observer> stop_observers_;
-};
-
-WorkerTaskRunner::WorkerTaskRunner() {
- // Start worker ids at 1, 0 is reserved for the main thread.
- int id = id_sequence_.GetNext();
- DCHECK(!id);
-}
-
-bool WorkerTaskRunner::PostTask(
- int id, const base::Closure& closure) {
- DCHECK(id > 0);
- base::AutoLock locker(loop_map_lock_);
- IDToLoopMap::iterator found = loop_map_.find(id);
- if (found == loop_map_.end())
- return false;
- return found->second.postTask(new RunClosureTask(closure));
-}
-
-int WorkerTaskRunner::PostTaskToAllThreads(const base::Closure& closure) {
- base::AutoLock locker(loop_map_lock_);
- IDToLoopMap::iterator it;
- for (it = loop_map_.begin(); it != loop_map_.end(); ++it)
- it->second.postTask(new RunClosureTask(closure));
- return static_cast<int>(loop_map_.size());
-}
-
-int WorkerTaskRunner::CurrentWorkerId() {
- if (!current_tls_.Get())
- return 0;
- return current_tls_.Get()->id_;
-}
-
-WorkerTaskRunner* WorkerTaskRunner::Instance() {
- static base::LazyInstance<WorkerTaskRunner>::Leaky
- worker_task_runner = LAZY_INSTANCE_INITIALIZER;
- return worker_task_runner.Pointer();
-}
-
-void WorkerTaskRunner::AddStopObserver(Observer* obs) {
- DCHECK(CurrentWorkerId() > 0);
- current_tls_.Get()->stop_observers_.AddObserver(obs);
-}
-
-void WorkerTaskRunner::RemoveStopObserver(Observer* obs) {
- DCHECK(CurrentWorkerId() > 0);
- current_tls_.Get()->stop_observers_.RemoveObserver(obs);
-}
-
-WorkerTaskRunner::~WorkerTaskRunner() {
-}
-
-void WorkerTaskRunner::OnWorkerRunLoopStarted(const WebWorkerRunLoop& loop) {
- DCHECK(!current_tls_.Get());
- int id = id_sequence_.GetNext();
- current_tls_.Set(new ThreadLocalState(id, loop));
-
- base::AutoLock locker_(loop_map_lock_);
- loop_map_[id] = loop;
-}
-
-void WorkerTaskRunner::OnWorkerRunLoopStopped(const WebWorkerRunLoop& loop) {
- DCHECK(current_tls_.Get());
- FOR_EACH_OBSERVER(Observer, current_tls_.Get()->stop_observers_,
- OnWorkerRunLoopStopped());
- {
- base::AutoLock locker(loop_map_lock_);
- DCHECK(loop_map_[CurrentWorkerId()] == loop);
- loop_map_.erase(CurrentWorkerId());
- }
- delete current_tls_.Get();
- current_tls_.Set(NULL);
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/child/worker_task_runner.h b/chromium/webkit/child/worker_task_runner.h
deleted file mode 100644
index f756c86755a..00000000000
--- a/chromium/webkit/child/worker_task_runner.h
+++ /dev/null
@@ -1,59 +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 WEBKIT_CHILD_WORKER_TASK_RUNNER_H_
-#define WEBKIT_CHILD_WORKER_TASK_RUNNER_H_
-
-#include <map>
-
-#include "base/atomic_sequence_num.h"
-#include "base/callback_forward.h"
-#include "base/synchronization/lock.h"
-#include "base/threading/thread_local.h"
-#include "third_party/WebKit/public/platform/WebWorkerRunLoop.h"
-#include "webkit/child/webkit_child_export.h"
-
-namespace webkit_glue {
-
-class WEBKIT_CHILD_EXPORT WorkerTaskRunner {
- public:
- WorkerTaskRunner();
-
- bool PostTask(int id, const base::Closure& task);
- int PostTaskToAllThreads(const base::Closure& task);
- int CurrentWorkerId();
- static WorkerTaskRunner* Instance();
-
- class WEBKIT_CHILD_EXPORT Observer {
- public:
- virtual ~Observer() {}
- virtual void OnWorkerRunLoopStopped() = 0;
- };
- // Add/Remove an observer that will get notified when the current worker run
- // loop is stopping. This observer will not get notified when other threads
- // are stopping. It's only valid to call these on a worker thread.
- void AddStopObserver(Observer* observer);
- void RemoveStopObserver(Observer* observer);
-
- private:
- friend class WebKitPlatformSupportChildImpl;
- friend class WorkerTaskRunnerTest;
-
- typedef std::map<int, blink::WebWorkerRunLoop> IDToLoopMap;
-
- ~WorkerTaskRunner();
- void OnWorkerRunLoopStarted(const blink::WebWorkerRunLoop& loop);
- void OnWorkerRunLoopStopped(const blink::WebWorkerRunLoop& loop);
-
- struct ThreadLocalState;
- base::ThreadLocalPointer<ThreadLocalState> current_tls_;
-
- base::AtomicSequenceNumber id_sequence_;
- IDToLoopMap loop_map_;
- base::Lock loop_map_lock_;
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_CHILD_WORKER_TASK_RUNNER_H_
diff --git a/chromium/webkit/child/worker_task_runner_unittest.cc b/chromium/webkit/child/worker_task_runner_unittest.cc
deleted file mode 100644
index 9bfb0e3f6fc..00000000000
--- a/chromium/webkit/child/worker_task_runner_unittest.cc
+++ /dev/null
@@ -1,56 +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.
-
-#include "base/logging.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/child/worker_task_runner.h"
-
-namespace webkit_glue {
-
-class WorkerTaskRunnerTest : public testing::Test {
- public:
- void FakeStart() {
- task_runner_.OnWorkerRunLoopStarted(blink::WebWorkerRunLoop());
- }
- void FakeStop() {
- task_runner_.OnWorkerRunLoopStopped(blink::WebWorkerRunLoop());
- }
- WorkerTaskRunner task_runner_;
-};
-
-class MockObserver : public WorkerTaskRunner::Observer {
- public:
- MOCK_METHOD0(OnWorkerRunLoopStopped, void());
- void RemoveSelfOnNotify() {
- ON_CALL(*this, OnWorkerRunLoopStopped()).WillByDefault(
- testing::Invoke(this, &MockObserver::RemoveSelf));
- }
- void RemoveSelf() {
- runner_->RemoveStopObserver(this);
- }
- WorkerTaskRunner* runner_;
-};
-
-TEST_F(WorkerTaskRunnerTest, BasicObservingAndWorkerId) {
- ASSERT_EQ(0, task_runner_.CurrentWorkerId());
- MockObserver o;
- EXPECT_CALL(o, OnWorkerRunLoopStopped()).Times(1);
- FakeStart();
- task_runner_.AddStopObserver(&o);
- ASSERT_LT(0, task_runner_.CurrentWorkerId());
- FakeStop();
-}
-
-TEST_F(WorkerTaskRunnerTest, CanRemoveSelfDuringNotification) {
- MockObserver o;
- o.RemoveSelfOnNotify();
- o.runner_ = &task_runner_;
- EXPECT_CALL(o, OnWorkerRunLoopStopped()).Times(1);
- FakeStart();
- task_runner_.AddStopObserver(&o);
- FakeStop();
-}
-
-}
diff --git a/chromium/webkit/common/BUILD.gn b/chromium/webkit/common/BUILD.gn
new file mode 100644
index 00000000000..011a1eb42d9
--- /dev/null
+++ b/chromium/webkit/common/BUILD.gn
@@ -0,0 +1,82 @@
+# 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.
+
+# GYP version: webkit/common/webkit_common.gyp:webkit_common
+component("common") {
+ output_name = "webkit_common"
+
+ sources = [
+ "data_element.cc",
+ "data_element.h",
+ "resource_type.cc",
+ "resource_type.h",
+ "webkit_common_export.h",
+ "webpreferences.cc",
+ "webpreferences.h",
+ ]
+
+ defines = [ "WEBKIT_COMMON_IMPLEMENTATION" ]
+
+ deps = [
+ "//base",
+ "//base:i18n",
+ "//base/third_party/dynamic_annotations",
+ "//net",
+ "//skia",
+ "//third_party/icu",
+ "//third_party/WebKit/public:blink_headers",
+ "//ui/base",
+ "//ui/gfx",
+ "//ui/gfx/geometry",
+ "//ui/resources",
+ "//url",
+ "//webkit:resources",
+ ]
+ forward_dependent_configs_from = [
+ "//third_party/WebKit/public:blink_headers",
+ ]
+}
+
+component("storage") {
+ output_name = "webkit_storage_common"
+ sources = [
+ "webkit_storage_common_export.h",
+ "appcache/appcache_interfaces.cc",
+ "appcache/appcache_interfaces.h",
+ "blob/blob_data.cc",
+ "blob/blob_data.h",
+ "blob/scoped_file.cc",
+ "blob/scoped_file.h",
+ "blob/shareable_file_reference.cc",
+ "blob/shareable_file_reference.h",
+ "database/database_connections.cc",
+ "database/database_connections.h",
+ "database/database_identifier.cc",
+ "database/database_identifier.h",
+ "fileapi/directory_entry.cc",
+ "fileapi/directory_entry.h",
+ "fileapi/file_system_info.cc",
+ "fileapi/file_system_info.h",
+ "fileapi/file_system_mount_option.h",
+ "fileapi/file_system_types.h",
+ "fileapi/file_system_util.cc",
+ "fileapi/file_system_util.h",
+ "quota/quota_status_code.cc",
+ "quota/quota_status_code.h",
+ "quota/quota_types.h",
+ ]
+
+ defines = [ "WEBKIT_STORAGE_COMMON_IMPLEMENTATION" ]
+ if (is_win) {
+ cflags = [ "/wd4267" ] # TODO(jschuh): fix size_t to int truncations.
+ }
+
+ deps = [
+ ":common",
+ "//base",
+ "//base/third_party/dynamic_annotations",
+ "//net",
+ "//url",
+ ]
+}
diff --git a/chromium/webkit/common/appcache/appcache_interfaces.cc b/chromium/webkit/common/appcache/appcache_interfaces.cc
index ca43f357788..e89f5507e6e 100644
--- a/chromium/webkit/common/appcache/appcache_interfaces.cc
+++ b/chromium/webkit/common/appcache/appcache_interfaces.cc
@@ -24,9 +24,9 @@ const base::FilePath::CharType kAppCacheDatabaseName[] =
FILE_PATH_LITERAL("Index");
AppCacheInfo::AppCacheInfo()
- : cache_id(kNoCacheId),
+ : cache_id(kAppCacheNoCacheId),
group_id(0),
- status(UNCACHED),
+ status(APPCACHE_STATUS_UNCACHED),
size(0),
is_complete(false) {
}
@@ -43,20 +43,42 @@ AppCacheResourceInfo::AppCacheResourceInfo()
is_fallback(false),
is_foreign(false),
is_explicit(false),
- response_id(kNoResponseId) {
+ response_id(kAppCacheNoResponseId) {
}
AppCacheResourceInfo::~AppCacheResourceInfo() {
}
+AppCacheErrorDetails::AppCacheErrorDetails()
+ : message(),
+ reason(APPCACHE_UNKNOWN_ERROR),
+ url(),
+ status(0),
+ is_cross_origin(false) {}
+
+AppCacheErrorDetails::AppCacheErrorDetails(
+ std::string in_message,
+ AppCacheErrorReason in_reason,
+ GURL in_url,
+ int in_status,
+ bool in_is_cross_origin)
+ : message(in_message),
+ reason(in_reason),
+ url(in_url),
+ status(in_status),
+ is_cross_origin(in_is_cross_origin) {}
+
+AppCacheErrorDetails::~AppCacheErrorDetails() {}
+
Namespace::Namespace()
- : type(FALLBACK_NAMESPACE),
+ : type(APPCACHE_FALLBACK_NAMESPACE),
is_pattern(false),
is_executable(false) {
}
Namespace::Namespace(
- NamespaceType type, const GURL& url, const GURL& target, bool is_pattern)
+ AppCacheNamespaceType type, const GURL& url, const GURL& target,
+ bool is_pattern)
: type(type),
namespace_url(url),
target_url(target),
@@ -65,7 +87,7 @@ Namespace::Namespace(
}
Namespace::Namespace(
- NamespaceType type, const GURL& url, const GURL& target,
+ AppCacheNamespaceType type, const GURL& url, const GURL& target,
bool is_pattern, bool is_executable)
: type(type),
namespace_url(url),
diff --git a/chromium/webkit/common/appcache/appcache_interfaces.h b/chromium/webkit/common/appcache/appcache_interfaces.h
index 4accecf0eb0..558d6e2e4dd 100644
--- a/chromium/webkit/common/appcache/appcache_interfaces.h
+++ b/chromium/webkit/common/appcache/appcache_interfaces.h
@@ -23,43 +23,57 @@ namespace appcache {
// Defines constants, types, and abstract classes used in the main
// process and in child processes.
-static const int kNoHostId = 0;
-static const int64 kNoCacheId = 0;
-static const int64 kNoResponseId = 0;
-static const int64 kUnknownCacheId = -1;
-
-enum Status {
- UNCACHED,
- IDLE,
- CHECKING,
- DOWNLOADING,
- UPDATE_READY,
- OBSOLETE
+static const int kAppCacheNoHostId = 0;
+static const int64 kAppCacheNoCacheId = 0;
+static const int64 kAppCacheNoResponseId = 0;
+static const int64 kAppCacheUnknownCacheId = -1;
+
+enum AppCacheStatus {
+ APPCACHE_STATUS_UNCACHED,
+ APPCACHE_STATUS_IDLE,
+ APPCACHE_STATUS_CHECKING,
+ APPCACHE_STATUS_DOWNLOADING,
+ APPCACHE_STATUS_UPDATE_READY,
+ APPCACHE_STATUS_OBSOLETE,
+ APPCACHE_STATUS_LAST = APPCACHE_STATUS_OBSOLETE
};
-enum EventID {
- CHECKING_EVENT,
- ERROR_EVENT,
- NO_UPDATE_EVENT,
- DOWNLOADING_EVENT,
- PROGRESS_EVENT,
- UPDATE_READY_EVENT,
- CACHED_EVENT,
- OBSOLETE_EVENT
+enum AppCacheEventID {
+ APPCACHE_CHECKING_EVENT,
+ APPCACHE_ERROR_EVENT,
+ APPCACHE_NO_UPDATE_EVENT,
+ APPCACHE_DOWNLOADING_EVENT,
+ APPCACHE_PROGRESS_EVENT,
+ APPCACHE_UPDATE_READY_EVENT,
+ APPCACHE_CACHED_EVENT,
+ APPCACHE_OBSOLETE_EVENT,
+ APPCACHE_EVENT_ID_LAST = APPCACHE_OBSOLETE_EVENT
};
// Temporarily renumber them in wierd way, to help remove LOG_TIP from WebKit
-enum LogLevel {
- LOG_DEBUG = 4,
- LOG_INFO = 1,
- LOG_WARNING = 2,
- LOG_ERROR = 3,
+enum AppCacheLogLevel {
+ APPCACHE_LOG_DEBUG = 4,
+ APPCACHE_LOG_INFO = 1,
+ APPCACHE_LOG_WARNING = 2,
+ APPCACHE_LOG_ERROR = 3,
};
-enum NamespaceType {
- FALLBACK_NAMESPACE,
- INTERCEPT_NAMESPACE,
- NETWORK_NAMESPACE
+enum AppCacheNamespaceType {
+ APPCACHE_FALLBACK_NAMESPACE,
+ APPCACHE_INTERCEPT_NAMESPACE,
+ APPCACHE_NETWORK_NAMESPACE
+};
+
+enum AppCacheErrorReason {
+ APPCACHE_MANIFEST_ERROR,
+ APPCACHE_SIGNATURE_ERROR,
+ APPCACHE_RESOURCE_ERROR,
+ APPCACHE_CHANGED_ERROR,
+ APPCACHE_ABORT_ERROR,
+ APPCACHE_QUOTA_ERROR,
+ APPCACHE_POLICY_ERROR,
+ APPCACHE_UNKNOWN_ERROR,
+ APPCACHE_ERROR_REASON_LAST = APPCACHE_UNKNOWN_ERROR
};
struct WEBKIT_STORAGE_COMMON_EXPORT AppCacheInfo {
@@ -72,7 +86,7 @@ struct WEBKIT_STORAGE_COMMON_EXPORT AppCacheInfo {
base::Time last_access_time;
int64 cache_id;
int64 group_id;
- Status status;
+ AppCacheStatus status;
int64 size;
bool is_complete;
};
@@ -95,19 +109,35 @@ struct WEBKIT_STORAGE_COMMON_EXPORT AppCacheResourceInfo {
int64 response_id;
};
+struct WEBKIT_STORAGE_COMMON_EXPORT AppCacheErrorDetails {
+ AppCacheErrorDetails();
+ AppCacheErrorDetails(std::string message,
+ AppCacheErrorReason reason,
+ GURL url,
+ int status,
+ bool is_cross_origin);
+ ~AppCacheErrorDetails();
+
+ std::string message;
+ AppCacheErrorReason reason;
+ GURL url;
+ int status;
+ bool is_cross_origin;
+};
+
typedef std::vector<AppCacheResourceInfo> AppCacheResourceInfoVector;
struct WEBKIT_STORAGE_COMMON_EXPORT Namespace {
- Namespace(); // Type is set to FALLBACK_NAMESPACE by default.
- Namespace(NamespaceType type, const GURL& url, const GURL& target,
+ Namespace(); // Type is set to APPCACHE_FALLBACK_NAMESPACE by default.
+ Namespace(AppCacheNamespaceType type, const GURL& url, const GURL& target,
bool is_pattern);
- Namespace(NamespaceType type, const GURL& url, const GURL& target,
+ Namespace(AppCacheNamespaceType type, const GURL& url, const GURL& target,
bool is_pattern, bool is_executable);
~Namespace();
bool IsMatch(const GURL& url) const;
- NamespaceType type;
+ AppCacheNamespaceType type;
GURL namespace_url;
GURL target_url;
bool is_pattern;
@@ -122,17 +152,18 @@ class WEBKIT_STORAGE_COMMON_EXPORT AppCacheFrontend {
virtual void OnCacheSelected(
int host_id, const appcache::AppCacheInfo& info) = 0;
virtual void OnStatusChanged(const std::vector<int>& host_ids,
- Status status) = 0;
+ AppCacheStatus status) = 0;
virtual void OnEventRaised(const std::vector<int>& host_ids,
- EventID event_id) = 0;
+ AppCacheEventID event_id) = 0;
virtual void OnProgressEventRaised(const std::vector<int>& host_ids,
const GURL& url,
int num_total, int num_complete) = 0;
- virtual void OnErrorEventRaised(const std::vector<int>& host_ids,
- const std::string& message) = 0;
+ virtual void OnErrorEventRaised(
+ const std::vector<int>& host_ids,
+ const appcache::AppCacheErrorDetails& details) = 0;
virtual void OnContentBlocked(int host_id,
const GURL& manifest_url) = 0;
- virtual void OnLogMessage(int host_id, LogLevel log_level,
+ virtual void OnLogMessage(int host_id, AppCacheLogLevel log_level,
const std::string& message) = 0;
virtual ~AppCacheFrontend() {}
};
@@ -156,7 +187,7 @@ class WEBKIT_STORAGE_COMMON_EXPORT AppCacheBackend {
int64 appcache_id) = 0;
virtual void MarkAsForeignEntry(int host_id, const GURL& document_url,
int64 cache_document_was_loaded_from) = 0;
- virtual Status GetStatus(int host_id) = 0;
+ virtual AppCacheStatus GetStatus(int host_id) = 0;
virtual bool StartUpdate(int host_id) = 0;
virtual bool SwapCache(int host_id) = 0;
virtual void GetResourceList(
diff --git a/chromium/webkit/common/blob/scoped_file.cc b/chromium/webkit/common/blob/scoped_file.cc
index 45d7b6b1c32..d009108cce6 100644
--- a/chromium/webkit/common/blob/scoped_file.cc
+++ b/chromium/webkit/common/blob/scoped_file.cc
@@ -6,7 +6,7 @@
#include "base/bind.h"
#include "base/callback.h"
-#include "base/files/file_util_proxy.h"
+#include "base/file_util.h"
#include "base/location.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/task_runner.h"
@@ -63,10 +63,10 @@ void ScopedFile::Reset() {
}
if (scope_out_policy_ == DELETE_ON_SCOPE_OUT) {
- base::FileUtilProxy::DeleteFile(file_task_runner_.get(),
- path_,
- false /* recursive */,
- base::FileUtilProxy::StatusCallback());
+ file_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(base::IgnoreResult(&base::DeleteFile),
+ path_, false /* recursive */));
}
// Clear all fields.
diff --git a/chromium/webkit/common/blob/shareable_file_reference_unittest.cc b/chromium/webkit/common/blob/shareable_file_reference_unittest.cc
deleted file mode 100644
index 5d6fc41a996..00000000000
--- a/chromium/webkit/common/blob/shareable_file_reference_unittest.cc
+++ /dev/null
@@ -1,59 +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 "webkit/common/blob/shareable_file_reference.h"
-
-#include "base/file_util.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/message_loop/message_loop_proxy.h"
-#include "base/run_loop.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace webkit_blob {
-
-TEST(ShareableFileReferenceTest, TestReferences) {
- base::MessageLoop message_loop;
- scoped_refptr<base::MessageLoopProxy> loop_proxy =
- base::MessageLoopProxy::current();
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
-
- // Create a file.
- base::FilePath file;
- base::CreateTemporaryFileInDir(temp_dir.path(), &file);
- EXPECT_TRUE(base::PathExists(file));
-
- // Create a first reference to that file.
- scoped_refptr<ShareableFileReference> reference1;
- reference1 = ShareableFileReference::Get(file);
- EXPECT_FALSE(reference1.get());
- reference1 = ShareableFileReference::GetOrCreate(
- file, ShareableFileReference::DELETE_ON_FINAL_RELEASE, loop_proxy.get());
- EXPECT_TRUE(reference1.get());
- EXPECT_TRUE(file == reference1->path());
-
- // Get a second reference to that file.
- scoped_refptr<ShareableFileReference> reference2;
- reference2 = ShareableFileReference::Get(file);
- EXPECT_EQ(reference1.get(), reference2.get());
- reference2 = ShareableFileReference::GetOrCreate(
- file, ShareableFileReference::DELETE_ON_FINAL_RELEASE, loop_proxy.get());
- EXPECT_EQ(reference1.get(), reference2.get());
-
- // Drop the first reference, the file and reference should still be there.
- reference1 = NULL;
- EXPECT_TRUE(ShareableFileReference::Get(file).get());
- base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(base::PathExists(file));
-
- // Drop the second reference, the file and reference should get deleted.
- reference2 = NULL;
- EXPECT_FALSE(ShareableFileReference::Get(file).get());
- base::RunLoop().RunUntilIdle();
- EXPECT_FALSE(base::PathExists(file));
-
- // TODO(michaeln): add a test for files that aren't deletable behavior.
-}
-
-} // namespace webkit_blob
diff --git a/chromium/webkit/common/cursors/DEPS b/chromium/webkit/common/cursors/DEPS
deleted file mode 100644
index 9d59ac94407..00000000000
--- a/chromium/webkit/common/cursors/DEPS
+++ /dev/null
@@ -1,4 +0,0 @@
-include_rules = [
- "+third_party/WebKit",
- "+ui/base",
-]
diff --git a/chromium/webkit/common/cursors/webcursor.cc b/chromium/webkit/common/cursors/webcursor.cc
deleted file mode 100644
index b3036a7bad4..00000000000
--- a/chromium/webkit/common/cursors/webcursor.cc
+++ /dev/null
@@ -1,261 +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 "webkit/common/cursors/webcursor.h"
-
-#include "base/logging.h"
-#include "base/pickle.h"
-#include "third_party/WebKit/public/platform/WebImage.h"
-
-using blink::WebCursorInfo;
-
-static const int kMaxCursorDimension = 1024;
-
-WebCursor::WebCursor()
- : type_(WebCursorInfo::TypePointer),
- custom_scale_(1) {
-#if defined(OS_WIN)
- external_cursor_ = NULL;
-#endif
- InitPlatformData();
-}
-
-WebCursor::WebCursor(const CursorInfo& cursor_info)
- : type_(WebCursorInfo::TypePointer) {
-#if defined(OS_WIN)
- external_cursor_ = NULL;
-#endif
- InitPlatformData();
- InitFromCursorInfo(cursor_info);
-}
-
-WebCursor::~WebCursor() {
- Clear();
-}
-
-WebCursor::WebCursor(const WebCursor& other) {
- InitPlatformData();
- Copy(other);
-}
-
-const WebCursor& WebCursor::operator=(const WebCursor& other) {
- if (this == &other)
- return *this;
-
- Clear();
- Copy(other);
- return *this;
-}
-
-void WebCursor::InitFromCursorInfo(const CursorInfo& cursor_info) {
- Clear();
-
-#if defined(OS_WIN)
- if (cursor_info.external_handle) {
- InitFromExternalCursor(cursor_info.external_handle);
- return;
- }
-#endif
-
- type_ = cursor_info.type;
- hotspot_ = cursor_info.hotspot;
- if (IsCustom())
- SetCustomData(cursor_info.custom_image);
- custom_scale_ = cursor_info.image_scale_factor;
- CHECK(custom_scale_ > 0);
- ClampHotspot();
-}
-
-void WebCursor::GetCursorInfo(CursorInfo* cursor_info) const {
- cursor_info->type = static_cast<WebCursorInfo::Type>(type_);
- cursor_info->hotspot = hotspot_;
- ImageFromCustomData(&cursor_info->custom_image);
- cursor_info->image_scale_factor = custom_scale_;
-
-#if defined(OS_WIN)
- cursor_info->external_handle = external_cursor_;
-#endif
-}
-
-bool WebCursor::Deserialize(PickleIterator* iter) {
- int type, hotspot_x, hotspot_y, size_x, size_y, data_len;
- float scale;
- const char* data;
-
- // Leave |this| unmodified unless we are going to return success.
- if (!iter->ReadInt(&type) ||
- !iter->ReadInt(&hotspot_x) ||
- !iter->ReadInt(&hotspot_y) ||
- !iter->ReadLength(&size_x) ||
- !iter->ReadLength(&size_y) ||
- !iter->ReadFloat(&scale) ||
- !iter->ReadData(&data, &data_len))
- return false;
-
- // Ensure the size is sane, and there is enough data.
- if (size_x > kMaxCursorDimension ||
- size_y > kMaxCursorDimension)
- return false;
-
- // Ensure scale isn't ridiculous, and the scaled image size is still sane.
- if (scale < 0.01 || scale > 100 ||
- size_x / scale > kMaxCursorDimension ||
- size_y / scale > kMaxCursorDimension)
- return false;
-
- type_ = type;
-
- if (type == WebCursorInfo::TypeCustom) {
- if (size_x > 0 && size_y > 0) {
- // The * 4 is because the expected format is an array of RGBA pixel
- // values.
- if (size_x * size_y * 4 > data_len)
- return false;
-
- hotspot_.set_x(hotspot_x);
- hotspot_.set_y(hotspot_y);
- custom_size_.set_width(size_x);
- custom_size_.set_height(size_y);
- custom_scale_ = scale;
- ClampHotspot();
-
- custom_data_.clear();
- if (data_len > 0) {
- custom_data_.resize(data_len);
- memcpy(&custom_data_[0], data, data_len);
- }
- }
- }
- return DeserializePlatformData(iter);
-}
-
-bool WebCursor::Serialize(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;
-
- const char* data = NULL;
- if (!custom_data_.empty())
- data = &custom_data_[0];
- if (!pickle->WriteData(data, custom_data_.size()))
- return false;
-
- return SerializePlatformData(pickle);
-}
-
-bool WebCursor::IsCustom() const {
- return type_ == WebCursorInfo::TypeCustom;
-}
-
-bool WebCursor::IsEqual(const WebCursor& other) const {
- if (type_ != other.type_)
- return false;
-
- if (!IsPlatformDataEqual(other))
- return false;
-
- return hotspot_ == other.hotspot_ &&
- custom_size_ == other.custom_size_ &&
- custom_scale_ == other.custom_scale_ &&
- custom_data_ == other.custom_data_;
-}
-
-#if defined(OS_WIN)
-
-static WebCursorInfo::Type ToCursorType(HCURSOR cursor) {
- static struct {
- HCURSOR cursor;
- WebCursorInfo::Type type;
- } kStandardCursors[] = {
- { LoadCursor(NULL, IDC_ARROW), WebCursorInfo::TypePointer },
- { LoadCursor(NULL, IDC_CROSS), WebCursorInfo::TypeCross },
- { LoadCursor(NULL, IDC_HAND), WebCursorInfo::TypeHand },
- { LoadCursor(NULL, IDC_IBEAM), WebCursorInfo::TypeIBeam },
- { LoadCursor(NULL, IDC_WAIT), WebCursorInfo::TypeWait },
- { LoadCursor(NULL, IDC_HELP), WebCursorInfo::TypeHelp },
- { LoadCursor(NULL, IDC_SIZENESW), WebCursorInfo::TypeNorthEastResize },
- { LoadCursor(NULL, IDC_SIZENWSE), WebCursorInfo::TypeNorthWestResize },
- { LoadCursor(NULL, IDC_SIZENS), WebCursorInfo::TypeNorthSouthResize },
- { LoadCursor(NULL, IDC_SIZEWE), WebCursorInfo::TypeEastWestResize },
- { LoadCursor(NULL, IDC_SIZEALL), WebCursorInfo::TypeMove },
- { LoadCursor(NULL, IDC_APPSTARTING), WebCursorInfo::TypeProgress },
- { LoadCursor(NULL, IDC_NO), WebCursorInfo::TypeNotAllowed },
- };
- for (int i = 0; i < arraysize(kStandardCursors); ++i) {
- if (cursor == kStandardCursors[i].cursor)
- return kStandardCursors[i].type;
- }
- return WebCursorInfo::TypeCustom;
-}
-
-void WebCursor::InitFromExternalCursor(HCURSOR cursor) {
- WebCursorInfo::Type cursor_type = ToCursorType(cursor);
-
- InitFromCursorInfo(CursorInfo(cursor_type));
-
- if (cursor_type == WebCursorInfo::TypeCustom)
- external_cursor_ = cursor;
-}
-
-#endif // defined(OS_WIN)
-
-void WebCursor::Clear() {
- type_ = WebCursorInfo::TypePointer;
- hotspot_.set_x(0);
- hotspot_.set_y(0);
- custom_size_.set_width(0);
- custom_size_.set_height(0);
- custom_scale_ = 1;
- custom_data_.clear();
- CleanupPlatformData();
-}
-
-void WebCursor::Copy(const WebCursor& other) {
- type_ = other.type_;
- hotspot_ = other.hotspot_;
- custom_size_ = other.custom_size_;
- custom_scale_ = other.custom_scale_;
- custom_data_ = other.custom_data_;
- CopyPlatformData(other);
-}
-
-void WebCursor::SetCustomData(const SkBitmap& bitmap) {
- if (bitmap.empty())
- return;
-
- // Fill custom_data_ directly with the NativeImage pixels.
- SkAutoLockPixels bitmap_lock(bitmap);
- custom_data_.resize(bitmap.getSize());
- if (!custom_data_.empty())
- memcpy(&custom_data_[0], bitmap.getPixels(), bitmap.getSize());
- custom_size_.set_width(bitmap.width());
- custom_size_.set_height(bitmap.height());
-}
-
-void WebCursor::ImageFromCustomData(SkBitmap* image) const {
- if (custom_data_.empty())
- return;
-
- image->setConfig(SkBitmap::kARGB_8888_Config,
- custom_size_.width(),
- custom_size_.height());
- if (!image->allocPixels())
- return;
- memcpy(image->getPixels(), &custom_data_[0], custom_data_.size());
-}
-
-void WebCursor::ClampHotspot() {
- if (!IsCustom())
- return;
-
- // Clamp the hotspot to the custom image's dimensions.
- hotspot_.set_x(std::max(0,
- std::min(custom_size_.width() - 1, hotspot_.x())));
- hotspot_.set_y(std::max(0,
- std::min(custom_size_.height() - 1, hotspot_.y())));
-}
diff --git a/chromium/webkit/common/cursors/webcursor.h b/chromium/webkit/common/cursors/webcursor.h
deleted file mode 100644
index 7682a0a6992..00000000000
--- a/chromium/webkit/common/cursors/webcursor.h
+++ /dev/null
@@ -1,195 +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 WEBKIT_COMMON_CURSORS_WEBCURSOR_H_
-#define WEBKIT_COMMON_CURSORS_WEBCURSOR_H_
-
-#include "base/basictypes.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-#include "ui/gfx/display.h"
-#include "ui/gfx/native_widget_types.h"
-#include "ui/gfx/point.h"
-#include "ui/gfx/size.h"
-#include "webkit/common/webkit_common_export.h"
-
-#include <vector>
-
-#if defined(USE_AURA)
-#include "ui/base/cursor/cursor.h"
-#endif
-
-#if defined(OS_WIN)
-typedef struct HINSTANCE__* HINSTANCE;
-typedef struct HICON__* HICON;
-typedef HICON HCURSOR;
-#elif defined(TOOLKIT_GTK)
-typedef struct _GdkCursor GdkCursor;
-#elif defined(OS_MACOSX)
-#ifdef __OBJC__
-@class NSCursor;
-#else
-class NSCursor;
-#endif
-#endif
-
-class Pickle;
-class PickleIterator;
-
-// This class encapsulates a cross-platform description of a cursor. Platform
-// specific methods are provided to translate the cross-platform cursor into a
-// platform specific cursor. It is also possible to serialize / de-serialize a
-// WebCursor.
-class WEBKIT_COMMON_EXPORT WebCursor {
- public:
- struct CursorInfo {
- explicit CursorInfo(blink::WebCursorInfo::Type cursor_type)
- : type(cursor_type),
- image_scale_factor(1) {
-#if defined(OS_WIN)
- external_handle = NULL;
-#endif
- }
-
- CursorInfo()
- : type(blink::WebCursorInfo::TypePointer),
- image_scale_factor(1) {
-#if defined(OS_WIN)
- external_handle = NULL;
-#endif
- }
-
- blink::WebCursorInfo::Type type;
- gfx::Point hotspot;
- float image_scale_factor;
- SkBitmap custom_image;
-#if defined(OS_WIN)
- HCURSOR external_handle;
-#endif
- };
-
- WebCursor();
- explicit WebCursor(const CursorInfo& cursor_info);
- ~WebCursor();
-
- // Copy constructor/assignment operator combine.
- WebCursor(const WebCursor& other);
- const WebCursor& operator=(const WebCursor& other);
-
- // Conversion from/to CursorInfo.
- void InitFromCursorInfo(const CursorInfo& cursor_info);
- void GetCursorInfo(CursorInfo* cursor_info) const;
-
- // Serialization / De-serialization
- bool Deserialize(PickleIterator* iter);
- bool Serialize(Pickle* pickle) const;
-
- // Returns true if GetCustomCursor should be used to allocate a platform
- // specific cursor object. Otherwise GetCursor should be used.
- bool IsCustom() const;
-
- // Returns true if the current cursor object contains the same cursor as the
- // cursor object passed in. If the current cursor is a custom cursor, we also
- // compare the bitmaps to verify whether they are equal.
- bool IsEqual(const WebCursor& other) const;
-
- // Returns a native cursor representing the current WebCursor instance.
- gfx::NativeCursor GetNativeCursor();
-
-#if defined(OS_WIN)
- // Initialize this from the given Windows cursor. The caller must ensure that
- // the HCURSOR remains valid by not invoking the DestroyCursor/DestroyIcon
- // APIs on it.
- void InitFromExternalCursor(HCURSOR handle);
-#endif
-
-#if defined(USE_AURA)
- const ui::PlatformCursor GetPlatformCursor();
-
- // Updates |device_scale_factor_| and |rotation_| based on |display|.
- void SetDisplayInfo(const gfx::Display& display);
-
-#elif defined(OS_WIN)
- // Returns a HCURSOR representing the current WebCursor instance.
- // The ownership of the HCURSOR (does not apply to external cursors) remains
- // with the WebCursor instance.
- HCURSOR GetCursor(HINSTANCE module_handle);
-
-#elif defined(TOOLKIT_GTK)
- // Return the stock GdkCursorType for this cursor, or GDK_CURSOR_IS_PIXMAP
- // if it's a custom cursor. Return GDK_LAST_CURSOR to indicate that the cursor
- // should be set to the system default.
- // Returns an int so we don't need to include GDK headers in this header file.
- int GetCursorType() const;
-
- // Return a new GdkCursor* for this cursor. Only valid if GetCursorType
- // returns GDK_CURSOR_IS_PIXMAP.
- GdkCursor* GetCustomCursor();
-#elif defined(OS_MACOSX)
- // Initialize this from the given Cocoa NSCursor.
- void InitFromNSCursor(NSCursor* cursor);
-#endif
-
- private:
- // Copies the contents of the WebCursor instance passed in.
- void Copy(const WebCursor& other);
-
- // Cleans up the WebCursor instance.
- void Clear();
-
- // Platform specific initialization goes here.
- void InitPlatformData();
-
- // Platform specific Serialization / De-serialization
- bool SerializePlatformData(Pickle* pickle) const;
- bool DeserializePlatformData(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 ;
-
- // Copies platform specific data from the WebCursor instance passed in.
- void CopyPlatformData(const WebCursor& other);
-
- // Platform specific cleanup.
- void CleanupPlatformData();
-
- void SetCustomData(const SkBitmap& image);
- void ImageFromCustomData(SkBitmap* image) const;
-
- // Clamp the hotspot to the custom image's bounds, if this is a custom cursor.
- void ClampHotspot();
-
- // WebCore::PlatformCursor type.
- int type_;
-
- // Hotspot in cursor image in pixels.
- gfx::Point hotspot_;
-
- // Custom cursor data, as 32-bit RGBA.
- // Platform-inspecific because it can be serialized.
- gfx::Size custom_size_; // In pixels.
- float custom_scale_;
- std::vector<char> custom_data_;
-
-#if defined(OS_WIN)
- // An externally generated HCURSOR. We assume that it remains valid, i.e we
- // don't attempt to copy the HCURSOR.
- HCURSOR external_cursor_;
-#endif
-
-#if defined(USE_AURA) && defined(USE_X11)
- // Only used for custom cursors.
- ui::PlatformCursor platform_cursor_;
- float device_scale_factor_;
- gfx::Display::Rotation rotation_;
-#elif defined(OS_WIN)
- // A custom cursor created from custom bitmap data by Webkit.
- HCURSOR custom_cursor_;
-#elif defined(TOOLKIT_GTK)
- // A custom cursor created that should be unref'ed from the destructor.
- GdkCursor* unref_;
-#endif
-};
-
-#endif // WEBKIT_COMMON_CURSORS_WEBCURSOR_H_
diff --git a/chromium/webkit/common/cursors/webcursor_android.cc b/chromium/webkit/common/cursors/webcursor_android.cc
deleted file mode 100644
index 451ba35a5a2..00000000000
--- a/chromium/webkit/common/cursors/webcursor_android.cc
+++ /dev/null
@@ -1,29 +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 "webkit/common/cursors/webcursor.h"
-
-#include "base/logging.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-
-void WebCursor::InitPlatformData() {
-}
-
-bool WebCursor::SerializePlatformData(Pickle* pickle) const {
- return true;
-}
-
-bool WebCursor::DeserializePlatformData(PickleIterator* iter) {
- return true;
-}
-
-bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
- return true;
-}
-
-void WebCursor::CleanupPlatformData() {
-}
-
-void WebCursor::CopyPlatformData(const WebCursor& other) {
-}
diff --git a/chromium/webkit/common/cursors/webcursor_aura.cc b/chromium/webkit/common/cursors/webcursor_aura.cc
deleted file mode 100644
index a7378683a56..00000000000
--- a/chromium/webkit/common/cursors/webcursor_aura.cc
+++ /dev/null
@@ -1,110 +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 "webkit/common/cursors/webcursor.h"
-
-#include "base/logging.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-#include "ui/base/cursor/cursor.h"
-
-using blink::WebCursorInfo;
-
-gfx::NativeCursor WebCursor::GetNativeCursor() {
- switch (type_) {
- case WebCursorInfo::TypePointer:
- return ui::kCursorPointer;
- case WebCursorInfo::TypeCross:
- return ui::kCursorCross;
- case WebCursorInfo::TypeHand:
- return ui::kCursorHand;
- case WebCursorInfo::TypeIBeam:
- return ui::kCursorIBeam;
- case WebCursorInfo::TypeWait:
- return ui::kCursorWait;
- case WebCursorInfo::TypeHelp:
- return ui::kCursorHelp;
- case WebCursorInfo::TypeEastResize:
- return ui::kCursorEastResize;
- case WebCursorInfo::TypeNorthResize:
- return ui::kCursorNorthResize;
- case WebCursorInfo::TypeNorthEastResize:
- return ui::kCursorNorthEastResize;
- case WebCursorInfo::TypeNorthWestResize:
- return ui::kCursorNorthWestResize;
- case WebCursorInfo::TypeSouthResize:
- return ui::kCursorSouthResize;
- case WebCursorInfo::TypeSouthEastResize:
- return ui::kCursorSouthEastResize;
- case WebCursorInfo::TypeSouthWestResize:
- return ui::kCursorSouthWestResize;
- case WebCursorInfo::TypeWestResize:
- return ui::kCursorWestResize;
- case WebCursorInfo::TypeNorthSouthResize:
- return ui::kCursorNorthSouthResize;
- case WebCursorInfo::TypeEastWestResize:
- return ui::kCursorEastWestResize;
- case WebCursorInfo::TypeNorthEastSouthWestResize:
- return ui::kCursorNorthEastSouthWestResize;
- case WebCursorInfo::TypeNorthWestSouthEastResize:
- return ui::kCursorNorthWestSouthEastResize;
- case WebCursorInfo::TypeColumnResize:
- return ui::kCursorColumnResize;
- case WebCursorInfo::TypeRowResize:
- return ui::kCursorRowResize;
- case WebCursorInfo::TypeMiddlePanning:
- return ui::kCursorMiddlePanning;
- case WebCursorInfo::TypeEastPanning:
- return ui::kCursorEastPanning;
- case WebCursorInfo::TypeNorthPanning:
- return ui::kCursorNorthPanning;
- case WebCursorInfo::TypeNorthEastPanning:
- return ui::kCursorNorthEastPanning;
- case WebCursorInfo::TypeNorthWestPanning:
- return ui::kCursorNorthWestPanning;
- case WebCursorInfo::TypeSouthPanning:
- return ui::kCursorSouthPanning;
- case WebCursorInfo::TypeSouthEastPanning:
- return ui::kCursorSouthEastPanning;
- case WebCursorInfo::TypeSouthWestPanning:
- return ui::kCursorSouthWestPanning;
- case WebCursorInfo::TypeWestPanning:
- return ui::kCursorWestPanning;
- case WebCursorInfo::TypeMove:
- return ui::kCursorMove;
- case WebCursorInfo::TypeVerticalText:
- return ui::kCursorVerticalText;
- case WebCursorInfo::TypeCell:
- return ui::kCursorCell;
- case WebCursorInfo::TypeContextMenu:
- return ui::kCursorContextMenu;
- case WebCursorInfo::TypeAlias:
- return ui::kCursorAlias;
- case WebCursorInfo::TypeProgress:
- return ui::kCursorProgress;
- case WebCursorInfo::TypeNoDrop:
- return ui::kCursorNoDrop;
- case WebCursorInfo::TypeCopy:
- return ui::kCursorCopy;
- case WebCursorInfo::TypeNone:
- return ui::kCursorNone;
- case WebCursorInfo::TypeNotAllowed:
- return ui::kCursorNotAllowed;
- case WebCursorInfo::TypeZoomIn:
- return ui::kCursorZoomIn;
- case WebCursorInfo::TypeZoomOut:
- return ui::kCursorZoomOut;
- case WebCursorInfo::TypeGrab:
- return ui::kCursorGrab;
- case WebCursorInfo::TypeGrabbing:
- return ui::kCursorGrabbing;
- case WebCursorInfo::TypeCustom: {
- ui::Cursor cursor(ui::kCursorCustom);
- cursor.SetPlatformCursor(GetPlatformCursor());
- return cursor;
- }
- default:
- NOTREACHED();
- return gfx::kNullCursor;
- }
-}
diff --git a/chromium/webkit/common/cursors/webcursor_aurawin.cc b/chromium/webkit/common/cursors/webcursor_aurawin.cc
deleted file mode 100644
index 3fcf4c4d6df..00000000000
--- a/chromium/webkit/common/cursors/webcursor_aurawin.cc
+++ /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.
-
-#include "webkit/common/cursors/webcursor.h"
-
-#include <windows.h>
-
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-#include "ui/gfx/icon_util.h"
-
-const ui::PlatformCursor WebCursor::GetPlatformCursor() {
- if (!IsCustom())
- return LoadCursor(NULL, IDC_ARROW);
-
- if (custom_cursor_)
- return custom_cursor_;
-
- custom_cursor_ =
- IconUtil::CreateCursorFromDIB(
- custom_size_,
- hotspot_,
- !custom_data_.empty() ? &custom_data_[0] : NULL,
- custom_data_.size());
- return custom_cursor_;
-}
-
-void WebCursor::SetDisplayInfo(const gfx::Display& display) {
- // TODO(winguru): Add support for scaling the cursor.
-}
-
-void WebCursor::InitPlatformData() {
- custom_cursor_ = NULL;
-}
-
-bool WebCursor::SerializePlatformData(Pickle* pickle) const {
- return true;
-}
-
-bool WebCursor::DeserializePlatformData(PickleIterator* iter) {
- return true;
-}
-
-bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
- return true;
-}
-
-void WebCursor::CleanupPlatformData() {
- if (custom_cursor_) {
- DestroyIcon(custom_cursor_);
- custom_cursor_ = NULL;
- }
-}
-
-void WebCursor::CopyPlatformData(const WebCursor& other) {
-}
diff --git a/chromium/webkit/common/cursors/webcursor_aurax11.cc b/chromium/webkit/common/cursors/webcursor_aurax11.cc
deleted file mode 100644
index 0389f064069..00000000000
--- a/chromium/webkit/common/cursors/webcursor_aurax11.cc
+++ /dev/null
@@ -1,85 +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 "webkit/common/cursors/webcursor.h"
-
-#include <X11/Xcursor/Xcursor.h>
-#include <X11/Xlib.h>
-#include <X11/cursorfont.h>
-
-#include "base/logging.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-#include "ui/base/cursor/cursor.h"
-#include "ui/base/cursor/cursor_loader_x11.h"
-#include "ui/base/x/x11_util.h"
-
-const ui::PlatformCursor WebCursor::GetPlatformCursor() {
- if (platform_cursor_)
- return platform_cursor_;
-
- if (custom_data_.size() == 0)
- return 0;
-
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config,
- custom_size_.width(), custom_size_.height());
- bitmap.allocPixels();
- memcpy(bitmap.getAddr32(0, 0), custom_data_.data(), custom_data_.size());
- gfx::Point hotspot = hotspot_;
- ui::ScaleAndRotateCursorBitmapAndHotpoint(
- device_scale_factor_, rotation_, &bitmap, &hotspot);
-
- XcursorImage* image = ui::SkBitmapToXcursorImage(&bitmap, hotspot);
- platform_cursor_ = ui::CreateReffedCustomXCursor(image);
- return platform_cursor_;
-}
-
-void WebCursor::SetDisplayInfo(const gfx::Display& display) {
- if (rotation_ == display.rotation() &&
- device_scale_factor_ == display.device_scale_factor())
- return;
-
- device_scale_factor_ = display.device_scale_factor();
- rotation_ = display.rotation();
- if (platform_cursor_)
- ui::UnrefCustomXCursor(platform_cursor_);
- platform_cursor_ = 0;
- // It is not necessary to recreate platform_cursor_ yet, since it will be
- // recreated on demand when GetPlatformCursor is called.
-}
-
-void WebCursor::InitPlatformData() {
- platform_cursor_ = 0;
- device_scale_factor_ = 1.f;
- rotation_ = gfx::Display::ROTATE_0;
-}
-
-bool WebCursor::SerializePlatformData(Pickle* pickle) const {
- return true;
-}
-
-bool WebCursor::DeserializePlatformData(PickleIterator* iter) {
- return true;
-}
-
-bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
- return true;
-}
-
-void WebCursor::CleanupPlatformData() {
- if (platform_cursor_) {
- ui::UnrefCustomXCursor(platform_cursor_);
- platform_cursor_ = 0;
- }
-}
-
-void WebCursor::CopyPlatformData(const WebCursor& other) {
- if (platform_cursor_)
- ui::UnrefCustomXCursor(platform_cursor_);
- platform_cursor_ = other.platform_cursor_;
- if (platform_cursor_)
- ui::RefCustomXCursor(platform_cursor_);
-
- device_scale_factor_ = other.device_scale_factor_;
-}
diff --git a/chromium/webkit/common/cursors/webcursor_gtk.cc b/chromium/webkit/common/cursors/webcursor_gtk.cc
deleted file mode 100644
index eeb3aa93ea5..00000000000
--- a/chromium/webkit/common/cursors/webcursor_gtk.cc
+++ /dev/null
@@ -1,222 +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 "webkit/common/cursors/webcursor.h"
-
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-
-#include "base/logging.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-#include "ui/gfx/gtk_util.h"
-
-using blink::WebCursorInfo;
-
-namespace {
-
-// webcursor_gtk_data.h is taken directly from WebKit's CursorGtk.h.
-#include "webkit/common/cursors/webcursor_gtk_data.h"
-
-// This helper function is taken directly from WebKit's CursorGtk.cpp.
-// It attempts to create a custom cursor from the data inlined in
-// webcursor_gtk_data.h.
-GdkCursor* GetInlineCustomCursor(CustomCursorType type) {
- static GdkCursor* CustomCursorsGdk[G_N_ELEMENTS(CustomCursors)];
- GdkCursor* cursor = CustomCursorsGdk[type];
- if (cursor)
- return cursor;
- const CustomCursor& custom = CustomCursors[type];
- cursor = gdk_cursor_new_from_name(gdk_display_get_default(), custom.name);
- if (!cursor) {
- const GdkColor fg = { 0, 0, 0, 0 };
- const GdkColor bg = { 65535, 65535, 65535, 65535 };
- GdkPixmap* source = gdk_bitmap_create_from_data(
- NULL, reinterpret_cast<const gchar*>(custom.bits), 32, 32);
- GdkPixmap* mask = gdk_bitmap_create_from_data(
- NULL, reinterpret_cast<const gchar*>(custom.mask_bits), 32, 32);
- cursor = gdk_cursor_new_from_pixmap(source, mask, &fg, &bg,
- custom.hot_x, custom.hot_y);
- g_object_unref(source);
- g_object_unref(mask);
- }
- CustomCursorsGdk[type] = cursor;
- return cursor;
-}
-
-} // end anonymous namespace
-
-int WebCursor::GetCursorType() const {
- // http://library.gnome.org/devel/gdk/2.12/gdk-Cursors.html has images
- // of the default X theme, but beware that the user's cursor theme can
- // change everything.
- switch (type_) {
- case WebCursorInfo::TypePointer:
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeCross:
- return GDK_CROSS;
- case WebCursorInfo::TypeHand:
- return GDK_HAND2;
- case WebCursorInfo::TypeIBeam:
- return GDK_XTERM;
- case WebCursorInfo::TypeWait:
- return GDK_WATCH;
- case WebCursorInfo::TypeHelp:
- return GDK_QUESTION_ARROW;
- case WebCursorInfo::TypeEastResize:
- return GDK_RIGHT_SIDE;
- case WebCursorInfo::TypeNorthResize:
- return GDK_TOP_SIDE;
- case WebCursorInfo::TypeNorthEastResize:
- return GDK_TOP_RIGHT_CORNER;
- case WebCursorInfo::TypeNorthWestResize:
- return GDK_TOP_LEFT_CORNER;
- case WebCursorInfo::TypeSouthResize:
- return GDK_BOTTOM_SIDE;
- case WebCursorInfo::TypeSouthEastResize:
- return GDK_BOTTOM_RIGHT_CORNER;
- case WebCursorInfo::TypeSouthWestResize:
- return GDK_BOTTOM_LEFT_CORNER;
- case WebCursorInfo::TypeWestResize:
- return GDK_LEFT_SIDE;
- case WebCursorInfo::TypeNorthSouthResize:
- return GDK_SB_V_DOUBLE_ARROW;
- case WebCursorInfo::TypeEastWestResize:
- return GDK_SB_H_DOUBLE_ARROW;
- case WebCursorInfo::TypeNorthEastSouthWestResize:
- case WebCursorInfo::TypeNorthWestSouthEastResize:
- // There isn't really a useful cursor available for these.
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeColumnResize:
- return GDK_SB_H_DOUBLE_ARROW; // TODO(evanm): is this correct?
- case WebCursorInfo::TypeRowResize:
- return GDK_SB_V_DOUBLE_ARROW; // TODO(evanm): is this correct?
- case WebCursorInfo::TypeMiddlePanning:
- return GDK_FLEUR;
- case WebCursorInfo::TypeEastPanning:
- return GDK_SB_RIGHT_ARROW;
- case WebCursorInfo::TypeNorthPanning:
- return GDK_SB_UP_ARROW;
- case WebCursorInfo::TypeNorthEastPanning:
- return GDK_TOP_RIGHT_CORNER;
- case WebCursorInfo::TypeNorthWestPanning:
- return GDK_TOP_LEFT_CORNER;
- case WebCursorInfo::TypeSouthPanning:
- return GDK_SB_DOWN_ARROW;
- case WebCursorInfo::TypeSouthEastPanning:
- return GDK_BOTTOM_RIGHT_CORNER;
- case WebCursorInfo::TypeSouthWestPanning:
- return GDK_BOTTOM_LEFT_CORNER;
- case WebCursorInfo::TypeWestPanning:
- return GDK_SB_LEFT_ARROW;
- case WebCursorInfo::TypeMove:
- return GDK_FLEUR;
- case WebCursorInfo::TypeVerticalText:
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeCell:
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeContextMenu:
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeAlias:
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeProgress:
- return GDK_WATCH;
- case WebCursorInfo::TypeNoDrop:
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeCopy:
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeNone:
- return GDK_BLANK_CURSOR;
- case WebCursorInfo::TypeNotAllowed:
- return GDK_LAST_CURSOR;
- case WebCursorInfo::TypeZoomIn:
- case WebCursorInfo::TypeZoomOut:
- case WebCursorInfo::TypeGrab:
- case WebCursorInfo::TypeGrabbing:
- case WebCursorInfo::TypeCustom:
- return GDK_CURSOR_IS_PIXMAP;
- }
- NOTREACHED();
- return GDK_LAST_CURSOR;
-}
-
-gfx::NativeCursor WebCursor::GetNativeCursor() {
- int type = GetCursorType();
- if (type == GDK_CURSOR_IS_PIXMAP)
- return GetCustomCursor();
- return gfx::GetCursor(type);
-}
-
-GdkCursor* WebCursor::GetCustomCursor() {
- switch (type_) {
- case WebCursorInfo::TypeZoomIn:
- return GetInlineCustomCursor(CustomCursorZoomIn);
- case WebCursorInfo::TypeZoomOut:
- return GetInlineCustomCursor(CustomCursorZoomOut);
- case WebCursorInfo::TypeGrab:
- return GetInlineCustomCursor(CustomCursorGrab);
- case WebCursorInfo::TypeGrabbing:
- return GetInlineCustomCursor(CustomCursorGrabbing);
- }
-
- if (type_ != WebCursorInfo::TypeCustom) {
- NOTREACHED();
- return NULL;
- }
-
- if (custom_size_.width() == 0 || custom_size_.height() == 0) {
- // Some websites specify cursor images that are 0 sized, such as Bing Maps.
- // Don't crash on this; just use the default cursor.
- return NULL;
- }
-
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config,
- custom_size_.width(), custom_size_.height());
- bitmap.allocPixels();
- memcpy(bitmap.getAddr32(0, 0), custom_data_.data(), custom_data_.size());
-
- GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(bitmap);
- GdkCursor* cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(),
- pixbuf,
- hotspot_.x(),
- hotspot_.y());
-
- g_object_unref(pixbuf);
-
- if (unref_)
- gdk_cursor_unref(unref_);
- unref_ = cursor;
- return cursor;
-}
-
-void WebCursor::InitPlatformData() {
- unref_ = NULL;
- return;
-}
-
-bool WebCursor::SerializePlatformData(Pickle* pickle) const {
- return true;
-}
-
-bool WebCursor::DeserializePlatformData(PickleIterator* iter) {
- return true;
-}
-
-bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
- return true;
-}
-
-void WebCursor::CleanupPlatformData() {
- if (unref_) {
- gdk_cursor_unref(unref_);
- unref_ = NULL;
- }
- return;
-}
-
-void WebCursor::CopyPlatformData(const WebCursor& other) {
- if (other.unref_)
- unref_ = gdk_cursor_ref(other.unref_);
- return;
-}
diff --git a/chromium/webkit/common/cursors/webcursor_gtk_data.h b/chromium/webkit/common/cursors/webcursor_gtk_data.h
deleted file mode 100644
index c92e0266dc5..00000000000
--- a/chromium/webkit/common/cursors/webcursor_gtk_data.h
+++ /dev/null
@@ -1,311 +0,0 @@
-// This file is a cut'n'paste from WebKit/WebCore/platform/gtk/CursorGtk.h,
-// with slight modifications to fit within Chrome. Its original
-// copyright is below.
-
-// This file intentionally doesn't have a header guard, since it is just
-// data to be used within a C++ file.
-
-/*
- * Copyright (C) 2001 Tim Copperfield <timecop@network.email.ne.jp>
- * Copyright (C) 2007 Christian Dywan <christian@twotoasts.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- These cursors are copied from Mozilla code:
- http://lxr.mozilla.org/mozilla1.8/source/widget/src/gtk2/nsGtkCursors.h
-*/
-
-/* MOZ_CURSOR_VERTICAL_TEXT */
-static const uint8 moz_vertical_text_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00,
- 0x06, 0x60, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00,
- 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_vertical_text_mask_bits[] = {
- 0x07, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0x0f, 0xf0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_CONTEXT_MENU */
-static const uint8 moz_menu_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
- 0x7c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0xfd, 0x00, 0x00,
- 0xfc, 0xff, 0x00, 0x00, 0x7c, 0x84, 0x00, 0x00, 0x6c, 0xfc, 0x00, 0x00,
- 0xc4, 0x84, 0x00, 0x00, 0xc0, 0xfc, 0x00, 0x00, 0x80, 0x85, 0x00, 0x00,
- 0x80, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_menu_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
- 0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
- 0xfe, 0x00, 0x00, 0x00, 0xfe, 0xfd, 0x00, 0x00, 0xfe, 0xff, 0x01, 0x00,
- 0xfe, 0xff, 0x01, 0x00, 0xfe, 0xff, 0x01, 0x00, 0xfe, 0xfe, 0x01, 0x00,
- 0xee, 0xff, 0x01, 0x00, 0xe4, 0xff, 0x01, 0x00, 0xc0, 0xff, 0x01, 0x00,
- 0xc0, 0xff, 0x01, 0x00, 0x80, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_COPY */
-static const uint8 moz_copy_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
- 0x7c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00,
- 0xfc, 0x03, 0x00, 0x00, 0x7c, 0x30, 0x00, 0x00, 0x6c, 0x30, 0x00, 0x00,
- 0xc4, 0xfc, 0x00, 0x00, 0xc0, 0xfc, 0x00, 0x00, 0x80, 0x31, 0x00, 0x00,
- 0x80, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_copy_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
- 0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
- 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00,
- 0xfe, 0x37, 0x00, 0x00, 0xfe, 0x7b, 0x00, 0x00, 0xfe, 0xfc, 0x00, 0x00,
- 0xee, 0xff, 0x01, 0x00, 0xe4, 0xff, 0x01, 0x00, 0xc0, 0xff, 0x00, 0x00,
- 0xc0, 0x7b, 0x00, 0x00, 0x80, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_ALIAS */
-static const uint8 moz_alias_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
- 0x7c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00,
- 0xfc, 0x03, 0x00, 0x00, 0x7c, 0xf0, 0x00, 0x00, 0x6c, 0xe0, 0x00, 0x00,
- 0xc4, 0xf0, 0x00, 0x00, 0xc0, 0xb0, 0x00, 0x00, 0x80, 0x19, 0x00, 0x00,
- 0x80, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_alias_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
- 0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
- 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00,
- 0xfe, 0xf7, 0x00, 0x00, 0xfe, 0xfb, 0x01, 0x00, 0xfe, 0xf0, 0x01, 0x00,
- 0xee, 0xf9, 0x01, 0x00, 0xe4, 0xf9, 0x01, 0x00, 0xc0, 0xbf, 0x00, 0x00,
- 0xc0, 0x3f, 0x00, 0x00, 0x80, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_ZOOM_IN */
-static const uint8 moz_zoom_in_bits[] = {
- 0xf0, 0x00, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00,
- 0x62, 0x04, 0x00, 0x00, 0x61, 0x08, 0x00, 0x00, 0xf9, 0x09, 0x00, 0x00,
- 0xf9, 0x09, 0x00, 0x00, 0x61, 0x08, 0x00, 0x00, 0x62, 0x04, 0x00, 0x00,
- 0x02, 0x04, 0x00, 0x00, 0x0c, 0x0f, 0x00, 0x00, 0xf0, 0x1c, 0x00, 0x00,
- 0x00, 0x38, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_zoom_in_mask_bits[] = {
- 0xf0, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00,
- 0xfe, 0x07, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00,
- 0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00,
- 0xfe, 0x07, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xf0, 0x1c, 0x00, 0x00,
- 0x00, 0x38, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_ZOOM_OUT */
-static const uint8 moz_zoom_out_bits[] = {
- 0xf0, 0x00, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00,
- 0x02, 0x04, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0xf9, 0x09, 0x00, 0x00,
- 0xf9, 0x09, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00,
- 0x02, 0x04, 0x00, 0x00, 0x0c, 0x0f, 0x00, 0x00, 0xf0, 0x1c, 0x00, 0x00,
- 0x00, 0x38, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_zoom_out_mask_bits[] = {
- 0xf0, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00,
- 0xfe, 0x07, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00,
- 0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00,
- 0xfe, 0x07, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xf0, 0x1c, 0x00, 0x00,
- 0x00, 0x38, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_HAND_GRAB */
-static const uint8 moz_hand_grab_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
- 0x60, 0x39, 0x00, 0x00, 0x90, 0x49, 0x00, 0x00, 0x90, 0x49, 0x01, 0x00,
- 0x20, 0xc9, 0x02, 0x00, 0x20, 0x49, 0x02, 0x00, 0x58, 0x40, 0x02, 0x00,
- 0x64, 0x00, 0x02, 0x00, 0x44, 0x00, 0x01, 0x00, 0x08, 0x00, 0x01, 0x00,
- 0x10, 0x00, 0x01, 0x00, 0x10, 0x80, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00,
- 0x40, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_hand_grab_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x60, 0x3f, 0x00, 0x00,
- 0xf0, 0x7f, 0x00, 0x00, 0xf8, 0xff, 0x01, 0x00, 0xf8, 0xff, 0x03, 0x00,
- 0xf0, 0xff, 0x07, 0x00, 0xf8, 0xff, 0x07, 0x00, 0xfc, 0xff, 0x07, 0x00,
- 0xfe, 0xff, 0x07, 0x00, 0xfe, 0xff, 0x03, 0x00, 0xfc, 0xff, 0x03, 0x00,
- 0xf8, 0xff, 0x03, 0x00, 0xf8, 0xff, 0x01, 0x00, 0xf0, 0xff, 0x01, 0x00,
- 0xe0, 0xff, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_HAND_GRABBING */
-static const uint8 moz_hand_grabbing_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xc0, 0x36, 0x00, 0x00, 0x20, 0xc9, 0x00, 0x00, 0x20, 0x40, 0x01, 0x00,
- 0x40, 0x00, 0x01, 0x00, 0x60, 0x00, 0x01, 0x00, 0x10, 0x00, 0x01, 0x00,
- 0x10, 0x00, 0x01, 0x00, 0x10, 0x80, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00,
- 0x40, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_hand_grabbing_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x36, 0x00, 0x00,
- 0xe0, 0xff, 0x00, 0x00, 0xf0, 0xff, 0x01, 0x00, 0xf0, 0xff, 0x03, 0x00,
- 0xe0, 0xff, 0x03, 0x00, 0xf0, 0xff, 0x03, 0x00, 0xf8, 0xff, 0x03, 0x00,
- 0xf8, 0xff, 0x03, 0x00, 0xf8, 0xff, 0x01, 0x00, 0xf0, 0xff, 0x01, 0x00,
- 0xe0, 0xff, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-enum CustomCursorType {
- CustomCursorCopy = 0,
- CustomCursorAlias,
- CustomCursorContextMenu,
- CustomCursorZoomIn,
- CustomCursorZoomOut,
- CustomCursorVerticalText,
- CustomCursorGrab,
- CustomCursorGrabbing,
-};
-
-typedef struct {
- const char* name;
- const uint8* bits;
- const uint8* mask_bits;
- int hot_x;
- int hot_y;
-} CustomCursor;
-
-// create custom pixmap cursor from cursors in nsGTKCursorData.h
-static const CustomCursor CustomCursors[] = {
- { "copy", moz_copy_bits, moz_copy_mask_bits, 2, 2 },
- { "alias", moz_alias_bits, moz_alias_mask_bits, 2, 2 },
- { "context-menu", moz_menu_bits, moz_menu_mask_bits, 2, 2 },
- { "zoom-in", moz_zoom_in_bits, moz_zoom_in_mask_bits, 6, 6 },
- { "zoom-out", moz_zoom_out_bits, moz_zoom_out_mask_bits, 6, 6 },
- { "vertical-text", moz_vertical_text_bits, moz_vertical_text_mask_bits, 8, 4},
- { "grab", moz_hand_grab_bits, moz_hand_grab_mask_bits, 10, 10 },
- { "grabbing", moz_hand_grabbing_bits, moz_hand_grabbing_mask_bits, 10, 10 }
-};
-
-// This cursor intentionally left out of above structs. It is only used by
-// RenderWidgetHostViewGtk. For an explanation see
-// http://vektor-sigma.livejournal.com/1137.html (where it is referred
-// to as left_ptr_watch).
-
-/* MOZ_CURSOR_SPINNING */
-static const uint8 moz_spinning_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
- 0x7c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00,
- 0xfc, 0x3b, 0x00, 0x00, 0x7c, 0x38, 0x00, 0x00, 0x6c, 0x54, 0x00, 0x00,
- 0xc4, 0xdc, 0x00, 0x00, 0xc0, 0x44, 0x00, 0x00, 0x80, 0x39, 0x00, 0x00,
- 0x80, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uint8 moz_spinning_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
- 0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
- 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0xfe, 0x3b, 0x00, 0x00,
- 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00,
- 0xee, 0xff, 0x01, 0x00, 0xe4, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00,
- 0xc0, 0x7f, 0x00, 0x00, 0x80, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
diff --git a/chromium/webkit/common/cursors/webcursor_mac.mm b/chromium/webkit/common/cursors/webcursor_mac.mm
deleted file mode 100644
index 4358be086df..00000000000
--- a/chromium/webkit/common/cursors/webcursor_mac.mm
+++ /dev/null
@@ -1,395 +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 "webkit/common/cursors/webcursor.h"
-
-#import <AppKit/AppKit.h>
-
-#include "base/logging.h"
-#include "base/mac/mac_util.h"
-#include "base/mac/scoped_cftyperef.h"
-#include "grit/webkit_resources.h"
-#include "skia/ext/skia_utils_mac.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-#include "third_party/WebKit/public/platform/WebSize.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/gfx/point_conversions.h"
-#include "ui/gfx/size_conversions.h"
-
-
-using blink::WebCursorInfo;
-using blink::WebSize;
-
-// Declare symbols that are part of the 10.7 SDK.
-#if !defined(MAC_OS_X_VERSION_10_7) || \
- MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
-
-@interface NSCursor (LionSDKDeclarations)
-+ (NSCursor*)IBeamCursorForVerticalLayout;
-@end
-
-#endif // MAC_OS_X_VERSION_10_7
-
-// Private interface to CoreCursor, as of Mac OS X 10.7. This is essentially the
-// implementation of WKCursor in WebKitSystemInterface.
-
-enum {
- kArrowCursor = 0,
- kIBeamCursor = 1,
- kMakeAliasCursor = 2,
- kOperationNotAllowedCursor = 3,
- kBusyButClickableCursor = 4,
- kCopyCursor = 5,
- kClosedHandCursor = 11,
- kOpenHandCursor = 12,
- kPointingHandCursor = 13,
- kCountingUpHandCursor = 14,
- kCountingDownHandCursor = 15,
- kCountingUpAndDownHandCursor = 16,
- kResizeLeftCursor = 17,
- kResizeRightCursor = 18,
- kResizeLeftRightCursor = 19,
- kCrosshairCursor = 20,
- kResizeUpCursor = 21,
- kResizeDownCursor = 22,
- kResizeUpDownCursor = 23,
- kContextualMenuCursor = 24,
- kDisappearingItemCursor = 25,
- kVerticalIBeamCursor = 26,
- kResizeEastCursor = 27,
- kResizeEastWestCursor = 28,
- kResizeNortheastCursor = 29,
- kResizeNortheastSouthwestCursor = 30,
- kResizeNorthCursor = 31,
- kResizeNorthSouthCursor = 32,
- kResizeNorthwestCursor = 33,
- kResizeNorthwestSoutheastCursor = 34,
- kResizeSoutheastCursor = 35,
- kResizeSouthCursor = 36,
- kResizeSouthwestCursor = 37,
- kResizeWestCursor = 38,
- kMoveCursor = 39,
- kHelpCursor = 40, // Present on >= 10.7.3.
- kCellCursor = 41, // Present on >= 10.7.3.
- kZoomInCursor = 42, // Present on >= 10.7.3.
- kZoomOutCursor = 43 // Present on >= 10.7.3.
-};
-typedef long long CrCoreCursorType;
-
-@interface CrCoreCursor : NSCursor {
- @private
- CrCoreCursorType type_;
-}
-
-+ (id)cursorWithType:(CrCoreCursorType)type;
-- (id)initWithType:(CrCoreCursorType)type;
-- (CrCoreCursorType)_coreCursorType;
-
-@end
-
-@implementation CrCoreCursor
-
-+ (id)cursorWithType:(CrCoreCursorType)type {
- NSCursor* cursor = [[CrCoreCursor alloc] initWithType:type];
- if ([cursor image])
- return [cursor autorelease];
-
- [cursor release];
- return nil;
-}
-
-- (id)initWithType:(CrCoreCursorType)type {
- if ((self = [super init])) {
- type_ = type;
- }
- return self;
-}
-
-- (CrCoreCursorType)_coreCursorType {
- return type_;
-}
-
-@end
-
-namespace {
-
-NSCursor* LoadCursor(int resource_id, int hotspot_x, int hotspot_y) {
- const gfx::Image& cursor_image =
- ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
- DCHECK(!cursor_image.IsEmpty());
- return [[[NSCursor alloc] initWithImage:cursor_image.ToNSImage()
- hotSpot:NSMakePoint(hotspot_x,
- hotspot_y)] autorelease];
-}
-
-// Gets a specified cursor from CoreCursor, falling back to loading it from the
-// image cache if CoreCursor cannot provide it.
-NSCursor* GetCoreCursorWithFallback(CrCoreCursorType type,
- int resource_id,
- int hotspot_x,
- int hotspot_y) {
- if (base::mac::IsOSLionOrLater()) {
- NSCursor* cursor = [CrCoreCursor cursorWithType:type];
- if (cursor)
- return cursor;
- }
-
- return LoadCursor(resource_id, hotspot_x, hotspot_y);
-}
-
-NSCursor* CreateCustomCursor(const std::vector<char>& custom_data,
- const gfx::Size& custom_size,
- float custom_scale,
- const gfx::Point& hotspot) {
- // If the data is missing, leave the backing transparent.
- void* data = NULL;
- size_t data_size = 0;
- if (!custom_data.empty()) {
- // This is safe since we're not going to draw into the context we're
- // creating.
- data = const_cast<char*>(&custom_data[0]);
- data_size = custom_data.size();
- }
-
- // If the size is empty, use a 1x1 transparent image.
- gfx::Size size = custom_size;
- if (size.IsEmpty()) {
- size.SetSize(1, 1);
- data = NULL;
- }
-
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height());
- bitmap.allocPixels();
- if (data)
- memcpy(bitmap.getAddr32(0, 0), data, data_size);
- else
- bitmap.eraseARGB(0, 0, 0, 0);
-
- // Convert from pixels to view units.
- if (custom_scale == 0)
- custom_scale = 1;
- NSSize dip_size = NSSizeFromCGSize(gfx::ToFlooredSize(
- gfx::ScaleSize(custom_size, 1 / custom_scale)).ToCGSize());
- NSPoint dip_hotspot = NSPointFromCGPoint(gfx::ToFlooredPoint(
- gfx::ScalePoint(hotspot, 1 / custom_scale)).ToCGPoint());
-
- // Both the image and its representation need to have the same size for
- // cursors to appear in high resolution on retina displays. Note that the
- // size of a representation is not the same as pixelsWide or pixelsHigh.
- NSImage* cursor_image = gfx::SkBitmapToNSImage(bitmap);
- [cursor_image setSize:dip_size];
- [[[cursor_image representations] objectAtIndex:0] setSize:dip_size];
-
- NSCursor* cursor = [[NSCursor alloc] initWithImage:cursor_image
- hotSpot:dip_hotspot];
-
- return [cursor autorelease];
-}
-
-} // namespace
-
-// Match Safari's cursor choices; see platform/mac/CursorMac.mm .
-gfx::NativeCursor WebCursor::GetNativeCursor() {
- switch (type_) {
- case WebCursorInfo::TypePointer:
- return [NSCursor arrowCursor];
- case WebCursorInfo::TypeCross:
- return [NSCursor crosshairCursor];
- case WebCursorInfo::TypeHand:
- // If >= 10.7, the pointingHandCursor has a shadow so use it. Otherwise
- // use the custom one.
- if (base::mac::IsOSLionOrLater())
- return [NSCursor pointingHandCursor];
- else
- return LoadCursor(IDR_LINK_CURSOR, 6, 1);
- case WebCursorInfo::TypeIBeam:
- return [NSCursor IBeamCursor];
- case WebCursorInfo::TypeWait:
- return GetCoreCursorWithFallback(kBusyButClickableCursor,
- IDR_WAIT_CURSOR, 7, 7);
- case WebCursorInfo::TypeHelp:
- return GetCoreCursorWithFallback(kHelpCursor,
- IDR_HELP_CURSOR, 8, 8);
- case WebCursorInfo::TypeEastResize:
- case WebCursorInfo::TypeEastPanning:
- return GetCoreCursorWithFallback(kResizeEastCursor,
- IDR_EAST_RESIZE_CURSOR, 14, 7);
- case WebCursorInfo::TypeNorthResize:
- case WebCursorInfo::TypeNorthPanning:
- return GetCoreCursorWithFallback(kResizeNorthCursor,
- IDR_NORTH_RESIZE_CURSOR, 7, 1);
- case WebCursorInfo::TypeNorthEastResize:
- case WebCursorInfo::TypeNorthEastPanning:
- return GetCoreCursorWithFallback(kResizeNortheastCursor,
- IDR_NORTHEAST_RESIZE_CURSOR, 14, 1);
- case WebCursorInfo::TypeNorthWestResize:
- case WebCursorInfo::TypeNorthWestPanning:
- return GetCoreCursorWithFallback(kResizeNorthwestCursor,
- IDR_NORTHWEST_RESIZE_CURSOR, 0, 0);
- case WebCursorInfo::TypeSouthResize:
- case WebCursorInfo::TypeSouthPanning:
- return GetCoreCursorWithFallback(kResizeSouthCursor,
- IDR_SOUTH_RESIZE_CURSOR, 7, 14);
- case WebCursorInfo::TypeSouthEastResize:
- case WebCursorInfo::TypeSouthEastPanning:
- return GetCoreCursorWithFallback(kResizeSoutheastCursor,
- IDR_SOUTHEAST_RESIZE_CURSOR, 14, 14);
- case WebCursorInfo::TypeSouthWestResize:
- case WebCursorInfo::TypeSouthWestPanning:
- return GetCoreCursorWithFallback(kResizeSouthwestCursor,
- IDR_SOUTHWEST_RESIZE_CURSOR, 1, 14);
- case WebCursorInfo::TypeWestResize:
- case WebCursorInfo::TypeWestPanning:
- return GetCoreCursorWithFallback(kResizeWestCursor,
- IDR_WEST_RESIZE_CURSOR, 1, 7);
- case WebCursorInfo::TypeNorthSouthResize:
- return GetCoreCursorWithFallback(kResizeNorthSouthCursor,
- IDR_NORTHSOUTH_RESIZE_CURSOR, 7, 7);
- case WebCursorInfo::TypeEastWestResize:
- return GetCoreCursorWithFallback(kResizeEastWestCursor,
- IDR_EASTWEST_RESIZE_CURSOR, 7, 7);
- case WebCursorInfo::TypeNorthEastSouthWestResize:
- return GetCoreCursorWithFallback(kResizeNortheastSouthwestCursor,
- IDR_NORTHEASTSOUTHWEST_RESIZE_CURSOR,
- 7, 7);
- case WebCursorInfo::TypeNorthWestSouthEastResize:
- return GetCoreCursorWithFallback(kResizeNorthwestSoutheastCursor,
- IDR_NORTHWESTSOUTHEAST_RESIZE_CURSOR,
- 7, 7);
- case WebCursorInfo::TypeColumnResize:
- return [NSCursor resizeLeftRightCursor];
- case WebCursorInfo::TypeRowResize:
- return [NSCursor resizeUpDownCursor];
- case WebCursorInfo::TypeMiddlePanning:
- case WebCursorInfo::TypeMove:
- return GetCoreCursorWithFallback(kMoveCursor,
- IDR_MOVE_CURSOR, 7, 7);
- case WebCursorInfo::TypeVerticalText:
- // IBeamCursorForVerticalLayout is >= 10.7.
- if ([NSCursor respondsToSelector:@selector(IBeamCursorForVerticalLayout)])
- return [NSCursor IBeamCursorForVerticalLayout];
- else
- return LoadCursor(IDR_VERTICALTEXT_CURSOR, 7, 7);
- case WebCursorInfo::TypeCell:
- return GetCoreCursorWithFallback(kCellCursor,
- IDR_CELL_CURSOR, 7, 7);
- case WebCursorInfo::TypeContextMenu:
- return [NSCursor contextualMenuCursor];
- case WebCursorInfo::TypeAlias:
- return GetCoreCursorWithFallback(kMakeAliasCursor,
- IDR_ALIAS_CURSOR, 11, 3);
- case WebCursorInfo::TypeProgress:
- return GetCoreCursorWithFallback(kBusyButClickableCursor,
- IDR_PROGRESS_CURSOR, 3, 2);
- case WebCursorInfo::TypeNoDrop:
- case WebCursorInfo::TypeNotAllowed:
- return [NSCursor operationNotAllowedCursor];
- case WebCursorInfo::TypeCopy:
- return [NSCursor dragCopyCursor];
- case WebCursorInfo::TypeNone:
- return LoadCursor(IDR_NONE_CURSOR, 7, 7);
- case WebCursorInfo::TypeZoomIn:
- return GetCoreCursorWithFallback(kZoomInCursor,
- IDR_ZOOMIN_CURSOR, 7, 7);
- case WebCursorInfo::TypeZoomOut:
- return GetCoreCursorWithFallback(kZoomOutCursor,
- IDR_ZOOMOUT_CURSOR, 7, 7);
- case WebCursorInfo::TypeGrab:
- return [NSCursor openHandCursor];
- case WebCursorInfo::TypeGrabbing:
- return [NSCursor closedHandCursor];
- case WebCursorInfo::TypeCustom:
- return CreateCustomCursor(
- custom_data_, custom_size_, custom_scale_, hotspot_);
- }
- NOTREACHED();
- return nil;
-}
-
-void WebCursor::InitFromNSCursor(NSCursor* cursor) {
- CursorInfo cursor_info;
-
- if ([cursor isEqual:[NSCursor arrowCursor]]) {
- cursor_info.type = WebCursorInfo::TypePointer;
- } else if ([cursor isEqual:[NSCursor IBeamCursor]]) {
- cursor_info.type = WebCursorInfo::TypeIBeam;
- } else if ([cursor isEqual:[NSCursor crosshairCursor]]) {
- cursor_info.type = WebCursorInfo::TypeCross;
- } else if ([cursor isEqual:[NSCursor pointingHandCursor]]) {
- cursor_info.type = WebCursorInfo::TypeHand;
- } else if ([cursor isEqual:[NSCursor resizeLeftCursor]]) {
- cursor_info.type = WebCursorInfo::TypeWestResize;
- } else if ([cursor isEqual:[NSCursor resizeRightCursor]]) {
- cursor_info.type = WebCursorInfo::TypeEastResize;
- } else if ([cursor isEqual:[NSCursor resizeLeftRightCursor]]) {
- cursor_info.type = WebCursorInfo::TypeEastWestResize;
- } else if ([cursor isEqual:[NSCursor resizeUpCursor]]) {
- cursor_info.type = WebCursorInfo::TypeNorthResize;
- } else if ([cursor isEqual:[NSCursor resizeDownCursor]]) {
- cursor_info.type = WebCursorInfo::TypeSouthResize;
- } else if ([cursor isEqual:[NSCursor resizeUpDownCursor]]) {
- cursor_info.type = WebCursorInfo::TypeNorthSouthResize;
- } else if ([cursor isEqual:[NSCursor openHandCursor]]) {
- cursor_info.type = WebCursorInfo::TypeGrab;
- } else if ([cursor isEqual:[NSCursor closedHandCursor]]) {
- cursor_info.type = WebCursorInfo::TypeGrabbing;
- } else if ([cursor isEqual:[NSCursor operationNotAllowedCursor]]) {
- cursor_info.type = WebCursorInfo::TypeNotAllowed;
- } else if ([cursor isEqual:[NSCursor dragCopyCursor]]) {
- cursor_info.type = WebCursorInfo::TypeCopy;
- } else if ([cursor isEqual:[NSCursor contextualMenuCursor]]) {
- cursor_info.type = WebCursorInfo::TypeContextMenu;
- } else if (
- [NSCursor respondsToSelector:@selector(IBeamCursorForVerticalLayout)] &&
- [cursor isEqual:[NSCursor IBeamCursorForVerticalLayout]]) {
- cursor_info.type = WebCursorInfo::TypeVerticalText;
- } else {
- // Also handles the [NSCursor disappearingItemCursor] case. Quick-and-dirty
- // image conversion; TODO(avi): do better.
- CGImageRef cg_image = nil;
- NSImage* image = [cursor image];
- for (id rep in [image representations]) {
- if ([rep isKindOfClass:[NSBitmapImageRep class]]) {
- cg_image = [rep CGImage];
- break;
- }
- }
-
- if (cg_image) {
- cursor_info.type = WebCursorInfo::TypeCustom;
- NSPoint hot_spot = [cursor hotSpot];
- cursor_info.hotspot = gfx::Point(hot_spot.x, hot_spot.y);
- cursor_info.custom_image = gfx::CGImageToSkBitmap(cg_image);
- } else {
- cursor_info.type = WebCursorInfo::TypePointer;
- }
- }
-
- InitFromCursorInfo(cursor_info);
-}
-
-void WebCursor::InitPlatformData() {
- return;
-}
-
-bool WebCursor::SerializePlatformData(Pickle* pickle) const {
- return true;
-}
-
-bool WebCursor::DeserializePlatformData(PickleIterator* iter) {
- return true;
-}
-
-bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
- return true;
-}
-
-void WebCursor::CleanupPlatformData() {
- return;
-}
-
-void WebCursor::CopyPlatformData(const WebCursor& other) {
- return;
-}
diff --git a/chromium/webkit/common/cursors/webcursor_null.cc b/chromium/webkit/common/cursors/webcursor_null.cc
deleted file mode 100644
index 17fad0610d1..00000000000
--- a/chromium/webkit/common/cursors/webcursor_null.cc
+++ /dev/null
@@ -1,34 +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 "webkit/common/cursors/webcursor.h"
-
-const ui::PlatformCursor WebCursor::GetPlatformCursor() {
- return NULL;
-}
-
-void WebCursor::SetDisplayInfo(const gfx::Display& display) {
- return;
-}
-
-void WebCursor::InitPlatformData() {
-}
-
-bool WebCursor::SerializePlatformData(Pickle* pickle) const {
- return true;
-}
-
-bool WebCursor::DeserializePlatformData(PickleIterator* iter) {
- return true;
-}
-
-bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
- return true;
-}
-
-void WebCursor::CleanupPlatformData() {
-}
-
-void WebCursor::CopyPlatformData(const WebCursor& other) {
-}
diff --git a/chromium/webkit/common/cursors/webcursor_unittest.cc b/chromium/webkit/common/cursors/webcursor_unittest.cc
deleted file mode 100644
index f5f5e6b839c..00000000000
--- a/chromium/webkit/common/cursors/webcursor_unittest.cc
+++ /dev/null
@@ -1,244 +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 "base/pickle.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-#include "webkit/common/cursors/webcursor.h"
-
-using blink::WebCursorInfo;
-
-TEST(WebCursorTest, OKCursorSerialization) {
- WebCursor custom_cursor;
- // This is a valid custom cursor.
- Pickle ok_custom_pickle;
- // Type and hotspots.
- ok_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
- ok_custom_pickle.WriteInt(0);
- ok_custom_pickle.WriteInt(0);
- // X & Y
- ok_custom_pickle.WriteInt(1);
- ok_custom_pickle.WriteInt(1);
- // Scale
- ok_custom_pickle.WriteFloat(1.0);
- // Data len including enough data for a 1x1 image.
- ok_custom_pickle.WriteInt(4);
- ok_custom_pickle.WriteUInt32(0);
- // Custom Windows message.
- ok_custom_pickle.WriteUInt32(0);
- PickleIterator iter(ok_custom_pickle);
- EXPECT_TRUE(custom_cursor.Deserialize(&iter));
-
-#if defined(TOOLKIT_GTK)
- // On GTK+ using platforms, we should get a real native GdkCursor object back
- // (and the memory used should automatically be freed by the WebCursor object
- // for valgrind tests).
- EXPECT_TRUE(custom_cursor.GetCustomCursor());
-#endif
-}
-
-TEST(WebCursorTest, BrokenCursorSerialization) {
- WebCursor custom_cursor;
- // This custom cursor has not been send with enough data.
- Pickle short_custom_pickle;
- // Type and hotspots.
- short_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
- short_custom_pickle.WriteInt(0);
- short_custom_pickle.WriteInt(0);
- // X & Y
- short_custom_pickle.WriteInt(1);
- short_custom_pickle.WriteInt(1);
- // Scale
- short_custom_pickle.WriteFloat(1.0);
- // Data len not including enough data for a 1x1 image.
- short_custom_pickle.WriteInt(3);
- short_custom_pickle.WriteUInt32(0);
- PickleIterator iter(short_custom_pickle);
- EXPECT_FALSE(custom_cursor.Deserialize(&iter));
-
- // This custom cursor has enough data but is too big.
- Pickle large_custom_pickle;
- // Type and hotspots.
- large_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
- large_custom_pickle.WriteInt(0);
- large_custom_pickle.WriteInt(0);
- // X & Y
- static const int kTooBigSize = 4096 + 1;
- large_custom_pickle.WriteInt(kTooBigSize);
- large_custom_pickle.WriteInt(1);
- // Scale
- large_custom_pickle.WriteFloat(1.0);
- // Data len including enough data for a 4097x1 image.
- large_custom_pickle.WriteInt(kTooBigSize * 4);
- for (int i = 0; i < kTooBigSize; ++i)
- large_custom_pickle.WriteUInt32(0);
- iter = PickleIterator(large_custom_pickle);
- EXPECT_FALSE(custom_cursor.Deserialize(&iter));
-
- // This custom cursor uses negative lengths.
- Pickle neg_custom_pickle;
- // Type and hotspots.
- neg_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
- neg_custom_pickle.WriteInt(0);
- neg_custom_pickle.WriteInt(0);
- // X & Y
- neg_custom_pickle.WriteInt(-1);
- neg_custom_pickle.WriteInt(-1);
- // Scale
- neg_custom_pickle.WriteFloat(1.0);
- // Data len including enough data for a 1x1 image.
- neg_custom_pickle.WriteInt(4);
- neg_custom_pickle.WriteUInt32(0);
- // Custom Windows message.
- neg_custom_pickle.WriteUInt32(0);
- iter = PickleIterator(neg_custom_pickle);
- EXPECT_FALSE(custom_cursor.Deserialize(&iter));
-
- // This custom cursor uses zero scale.
- Pickle scale_zero_custom_pickle;
- // Type and hotspots.
- scale_zero_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
- scale_zero_custom_pickle.WriteInt(0);
- scale_zero_custom_pickle.WriteInt(0);
- // X & Y
- scale_zero_custom_pickle.WriteInt(1);
- scale_zero_custom_pickle.WriteInt(1);
- // Scale
- scale_zero_custom_pickle.WriteFloat(0);
- // Data len including enough data for a 1x1 image.
- scale_zero_custom_pickle.WriteInt(4);
- scale_zero_custom_pickle.WriteUInt32(0);
- // Custom Windows message.
- scale_zero_custom_pickle.WriteUInt32(0);
- iter = PickleIterator(scale_zero_custom_pickle);
- EXPECT_FALSE(custom_cursor.Deserialize(&iter));
-
- // This custom cursor uses tiny scale.
- Pickle scale_tiny_custom_pickle;
- // Type and hotspots.
- scale_tiny_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
- scale_tiny_custom_pickle.WriteInt(0);
- scale_tiny_custom_pickle.WriteInt(0);
- // X & Y
- scale_tiny_custom_pickle.WriteInt(1);
- scale_tiny_custom_pickle.WriteInt(1);
- // Scale
- scale_tiny_custom_pickle.WriteFloat(0.001f);
- // Data len including enough data for a 1x1 image.
- scale_tiny_custom_pickle.WriteInt(4);
- scale_tiny_custom_pickle.WriteUInt32(0);
- // Custom Windows message.
- scale_tiny_custom_pickle.WriteUInt32(0);
- iter = PickleIterator(scale_tiny_custom_pickle);
- EXPECT_FALSE(custom_cursor.Deserialize(&iter));
-}
-
-#if defined(OS_WIN) && !defined(USE_AURA)
-TEST(WebCursorTest, WindowsCursorConversion) {
- WebCursor custom_cursor;
- Pickle win32_custom_pickle;
- WebCursor win32_custom_cursor;
- win32_custom_cursor.InitFromExternalCursor(
- reinterpret_cast<HCURSOR>(1000));
- EXPECT_TRUE(win32_custom_cursor.Serialize(&win32_custom_pickle));
- PickleIterator iter(win32_custom_pickle);
- EXPECT_TRUE(custom_cursor.Deserialize(&iter));
- EXPECT_EQ(reinterpret_cast<HCURSOR>(1000), custom_cursor.GetCursor(NULL));
-}
-#endif // OS_WIN
-
-TEST(WebCursorTest, ClampHotspot) {
- WebCursor custom_cursor;
- // This is a valid custom cursor.
- Pickle ok_custom_pickle;
- // Type and hotspots.
- ok_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
- // Hotspot is invalid --- outside the bounds of the image.
- ok_custom_pickle.WriteInt(5);
- ok_custom_pickle.WriteInt(5);
- // X & Y
- ok_custom_pickle.WriteInt(2);
- ok_custom_pickle.WriteInt(2);
- // Scale
- ok_custom_pickle.WriteFloat(1.0);
- // Data len including enough data for a 2x2 image.
- ok_custom_pickle.WriteInt(4 * 4);
- for (size_t i = 0; i < 4; i++)
- ok_custom_pickle.WriteUInt32(0);
- // Custom Windows message.
- ok_custom_pickle.WriteUInt32(0);
- PickleIterator iter(ok_custom_pickle);
- ASSERT_TRUE(custom_cursor.Deserialize(&iter));
-
- // Convert to WebCursorInfo, make sure the hotspot got clamped.
- WebCursor::CursorInfo info;
- custom_cursor.GetCursorInfo(&info);
- EXPECT_EQ(gfx::Point(1, 1), info.hotspot);
-
- // Set hotspot to an invalid point again, pipe back through WebCursor,
- // and make sure the hotspot got clamped again.
- info.hotspot = gfx::Point(-1, -1);
- custom_cursor.InitFromCursorInfo(info);
- custom_cursor.GetCursorInfo(&info);
- EXPECT_EQ(gfx::Point(0, 0), info.hotspot);
-}
-
-TEST(WebCursorTest, EmptyImage) {
- WebCursor custom_cursor;
- Pickle broken_cursor_pickle;
- broken_cursor_pickle.WriteInt(WebCursorInfo::TypeCustom);
- // Hotspot is at origin
- broken_cursor_pickle.WriteInt(0);
- broken_cursor_pickle.WriteInt(0);
- // X & Y are empty
- broken_cursor_pickle.WriteInt(0);
- broken_cursor_pickle.WriteInt(0);
- // Scale
- broken_cursor_pickle.WriteFloat(1.0);
- // No data for the image since the size is 0.
- broken_cursor_pickle.WriteInt(0);
- // Custom Windows message.
- broken_cursor_pickle.WriteInt(0);
-
- // Make sure we can read this on all platforms; it is technicaally a valid
- // cursor.
- PickleIterator iter(broken_cursor_pickle);
- ASSERT_TRUE(custom_cursor.Deserialize(&iter));
-
-#if defined(TOOLKIT_GTK)
- // On GTK+ using platforms, we make sure that we get NULL back from this
- // method; the relevant GDK methods take NULL as a request to use the default
- // cursor.
- EXPECT_EQ(NULL, custom_cursor.GetCustomCursor());
-#endif
-}
-
-TEST(WebCursorTest, Scale2) {
- WebCursor custom_cursor;
- // This is a valid custom cursor.
- Pickle ok_custom_pickle;
- // Type and hotspots.
- ok_custom_pickle.WriteInt(WebCursorInfo::TypeCustom);
- ok_custom_pickle.WriteInt(0);
- ok_custom_pickle.WriteInt(0);
- // X & Y
- ok_custom_pickle.WriteInt(1);
- ok_custom_pickle.WriteInt(1);
- // Scale - 2 image pixels per UI pixel.
- ok_custom_pickle.WriteFloat(2.0);
- // Data len including enough data for a 1x1 image.
- ok_custom_pickle.WriteInt(4);
- ok_custom_pickle.WriteUInt32(0);
- // Custom Windows message.
- ok_custom_pickle.WriteUInt32(0);
- PickleIterator iter(ok_custom_pickle);
- EXPECT_TRUE(custom_cursor.Deserialize(&iter));
-
-#if defined(TOOLKIT_GTK)
- // On GTK+ using platforms, we should get a real native GdkCursor object back
- // (and the memory used should automatically be freed by the WebCursor object
- // for valgrind tests).
- EXPECT_TRUE(custom_cursor.GetCustomCursor());
-#endif
-}
diff --git a/chromium/webkit/common/cursors/webcursor_win.cc b/chromium/webkit/common/cursors/webcursor_win.cc
deleted file mode 100644
index e825adf244e..00000000000
--- a/chromium/webkit/common/cursors/webcursor_win.cc
+++ /dev/null
@@ -1,181 +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 "base/logging.h"
-#include "base/pickle.h"
-#include "grit/ui_unscaled_resources.h"
-#include "third_party/WebKit/public/platform/WebCursorInfo.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/gfx/icon_util.h"
-#include "webkit/common/cursors/webcursor.h"
-
-using blink::WebCursorInfo;
-
-static LPCWSTR ToCursorID(WebCursorInfo::Type type) {
- switch (type) {
- case WebCursorInfo::TypePointer:
- return IDC_ARROW;
- case WebCursorInfo::TypeCross:
- return IDC_CROSS;
- case WebCursorInfo::TypeHand:
- return IDC_HAND;
- case WebCursorInfo::TypeIBeam:
- return IDC_IBEAM;
- case WebCursorInfo::TypeWait:
- return IDC_WAIT;
- case WebCursorInfo::TypeHelp:
- return IDC_HELP;
- case WebCursorInfo::TypeEastResize:
- return IDC_SIZEWE;
- case WebCursorInfo::TypeNorthResize:
- return IDC_SIZENS;
- case WebCursorInfo::TypeNorthEastResize:
- return IDC_SIZENESW;
- case WebCursorInfo::TypeNorthWestResize:
- return IDC_SIZENWSE;
- case WebCursorInfo::TypeSouthResize:
- return IDC_SIZENS;
- case WebCursorInfo::TypeSouthEastResize:
- return IDC_SIZENWSE;
- case WebCursorInfo::TypeSouthWestResize:
- return IDC_SIZENESW;
- case WebCursorInfo::TypeWestResize:
- return IDC_SIZEWE;
- case WebCursorInfo::TypeNorthSouthResize:
- return IDC_SIZENS;
- case WebCursorInfo::TypeEastWestResize:
- return IDC_SIZEWE;
- case WebCursorInfo::TypeNorthEastSouthWestResize:
- return IDC_SIZENESW;
- case WebCursorInfo::TypeNorthWestSouthEastResize:
- return IDC_SIZENWSE;
- case WebCursorInfo::TypeColumnResize:
- return MAKEINTRESOURCE(IDC_COLRESIZE);
- case WebCursorInfo::TypeRowResize:
- return MAKEINTRESOURCE(IDC_ROWRESIZE);
- case WebCursorInfo::TypeMiddlePanning:
- return MAKEINTRESOURCE(IDC_PAN_MIDDLE);
- case WebCursorInfo::TypeEastPanning:
- return MAKEINTRESOURCE(IDC_PAN_EAST);
- case WebCursorInfo::TypeNorthPanning:
- return MAKEINTRESOURCE(IDC_PAN_NORTH);
- case WebCursorInfo::TypeNorthEastPanning:
- return MAKEINTRESOURCE(IDC_PAN_NORTH_EAST);
- case WebCursorInfo::TypeNorthWestPanning:
- return MAKEINTRESOURCE(IDC_PAN_NORTH_WEST);
- case WebCursorInfo::TypeSouthPanning:
- return MAKEINTRESOURCE(IDC_PAN_SOUTH);
- case WebCursorInfo::TypeSouthEastPanning:
- return MAKEINTRESOURCE(IDC_PAN_SOUTH_EAST);
- case WebCursorInfo::TypeSouthWestPanning:
- return MAKEINTRESOURCE(IDC_PAN_SOUTH_WEST);
- case WebCursorInfo::TypeWestPanning:
- return MAKEINTRESOURCE(IDC_PAN_WEST);
- case WebCursorInfo::TypeMove:
- return IDC_SIZEALL;
- case WebCursorInfo::TypeVerticalText:
- return MAKEINTRESOURCE(IDC_VERTICALTEXT);
- case WebCursorInfo::TypeCell:
- return MAKEINTRESOURCE(IDC_CELL);
- case WebCursorInfo::TypeContextMenu:
- return MAKEINTRESOURCE(IDC_ARROW);
- case WebCursorInfo::TypeAlias:
- return MAKEINTRESOURCE(IDC_ALIAS);
- case WebCursorInfo::TypeProgress:
- return IDC_APPSTARTING;
- case WebCursorInfo::TypeNoDrop:
- return IDC_NO;
- case WebCursorInfo::TypeCopy:
- return MAKEINTRESOURCE(IDC_COPYCUR);
- case WebCursorInfo::TypeNone:
- return MAKEINTRESOURCE(IDC_CURSOR_NONE);
- case WebCursorInfo::TypeNotAllowed:
- return IDC_NO;
- case WebCursorInfo::TypeZoomIn:
- return MAKEINTRESOURCE(IDC_ZOOMIN);
- case WebCursorInfo::TypeZoomOut:
- return MAKEINTRESOURCE(IDC_ZOOMOUT);
- case WebCursorInfo::TypeGrab:
- return MAKEINTRESOURCE(IDC_HAND_GRAB);
- case WebCursorInfo::TypeGrabbing:
- return MAKEINTRESOURCE(IDC_HAND_GRABBING);
- }
- NOTREACHED();
- return NULL;
-}
-
-static bool IsSystemCursorID(LPCWSTR cursor_id) {
- return cursor_id >= IDC_ARROW; // See WinUser.h
-}
-
-HCURSOR WebCursor::GetCursor(HINSTANCE module_handle){
- if (!IsCustom()) {
- const wchar_t* cursor_id =
- ToCursorID(static_cast<WebCursorInfo::Type>(type_));
-
- if (IsSystemCursorID(cursor_id))
- module_handle = NULL;
-
- return LoadCursor(module_handle, cursor_id);
- }
-
- if (custom_cursor_) {
- DCHECK(external_cursor_ == NULL);
- return custom_cursor_;
- }
-
- if (external_cursor_)
- return external_cursor_;
-
- custom_cursor_ =
- IconUtil::CreateCursorFromDIB(
- custom_size_,
- hotspot_,
- !custom_data_.empty() ? &custom_data_[0] : NULL,
- custom_data_.size());
- return custom_cursor_;
-}
-
-gfx::NativeCursor WebCursor::GetNativeCursor() {
- return GetCursor(NULL);
-}
-
-void WebCursor::InitPlatformData() {
- custom_cursor_ = NULL;
-}
-
-bool WebCursor::SerializePlatformData(Pickle* pickle) const {
- // There are some issues with converting certain HCURSORS to bitmaps. The
- // HCURSOR being a user object can be marshaled as is.
- // HCURSORs are always 32 bits on Windows, even on 64 bit systems.
- return pickle->WriteUInt32(reinterpret_cast<uint32>(external_cursor_));
-}
-
-bool WebCursor::DeserializePlatformData(PickleIterator* iter) {
- return iter->ReadUInt32(reinterpret_cast<uint32*>(&external_cursor_));
-}
-
-bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
- if (!IsCustom())
- return true;
-
- return (external_cursor_ == other.external_cursor_);
-}
-
-void WebCursor::CopyPlatformData(const WebCursor& other) {
- external_cursor_ = other.external_cursor_;
- // The custom_cursor_ member will be initialized to a HCURSOR the next time
- // the GetCursor member function is invoked on this WebCursor instance. The
- // cursor is created using the data in the custom_data_ vector.
- custom_cursor_ = NULL;
-}
-
-void WebCursor::CleanupPlatformData() {
- external_cursor_ = NULL;
-
- if (custom_cursor_) {
- DestroyIcon(custom_cursor_);
- custom_cursor_ = NULL;
- }
-}
diff --git a/chromium/webkit/common/database/database_connections_unittest.cc b/chromium/webkit/common/database/database_connections_unittest.cc
deleted file mode 100644
index 94b293ead0f..00000000000
--- a/chromium/webkit/common/database/database_connections_unittest.cc
+++ /dev/null
@@ -1,143 +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 "base/bind.h"
-#include "base/message_loop/message_loop.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/threading/thread.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/common/database/database_connections.h"
-
-namespace webkit_database {
-
-namespace {
-
-void RemoveConnectionTask(
- const std::string& origin_id, const base::string16& database_name,
- scoped_refptr<DatabaseConnectionsWrapper> obj,
- bool* did_task_execute) {
- *did_task_execute = true;
- obj->RemoveOpenConnection(origin_id, database_name);
-}
-
-void ScheduleRemoveConnectionTask(
- base::Thread* thread, const std::string& origin_id,
- const base::string16& database_name,
- scoped_refptr<DatabaseConnectionsWrapper> obj,
- bool* did_task_execute) {
- thread->message_loop()->PostTask(
- FROM_HERE,
- base::Bind(&RemoveConnectionTask, origin_id, database_name, obj,
- did_task_execute));
-}
-
-} // anonymous namespace
-
-TEST(DatabaseConnectionsTest, DatabaseConnectionsTest) {
- const std::string kOriginId("origin_id");
- const base::string16 kName(ASCIIToUTF16("database_name"));
- const base::string16 kName2(ASCIIToUTF16("database_name2"));
- const int64 kSize = 1000;
-
- DatabaseConnections connections;
-
- EXPECT_TRUE(connections.IsEmpty());
- EXPECT_FALSE(connections.IsDatabaseOpened(kOriginId, kName));
- EXPECT_FALSE(connections.IsOriginUsed(kOriginId));
-
- connections.AddConnection(kOriginId, kName);
- EXPECT_FALSE(connections.IsEmpty());
- EXPECT_TRUE(connections.IsDatabaseOpened(kOriginId, kName));
- EXPECT_TRUE(connections.IsOriginUsed(kOriginId));
- EXPECT_EQ(0, connections.GetOpenDatabaseSize(kOriginId, kName));
- connections.SetOpenDatabaseSize(kOriginId, kName, kSize);
- EXPECT_EQ(kSize, connections.GetOpenDatabaseSize(kOriginId, kName));
-
- connections.RemoveConnection(kOriginId, kName);
- EXPECT_TRUE(connections.IsEmpty());
- EXPECT_FALSE(connections.IsDatabaseOpened(kOriginId, kName));
- EXPECT_FALSE(connections.IsOriginUsed(kOriginId));
-
- connections.AddConnection(kOriginId, kName);
- connections.SetOpenDatabaseSize(kOriginId, kName, kSize);
- EXPECT_EQ(kSize, connections.GetOpenDatabaseSize(kOriginId, kName));
- connections.AddConnection(kOriginId, kName);
- EXPECT_EQ(kSize, connections.GetOpenDatabaseSize(kOriginId, kName));
- EXPECT_FALSE(connections.IsEmpty());
- EXPECT_TRUE(connections.IsDatabaseOpened(kOriginId, kName));
- EXPECT_TRUE(connections.IsOriginUsed(kOriginId));
- connections.AddConnection(kOriginId, kName2);
- EXPECT_TRUE(connections.IsDatabaseOpened(kOriginId, kName2));
-
- DatabaseConnections another;
- another.AddConnection(kOriginId, kName);
- another.AddConnection(kOriginId, kName2);
-
- std::vector<std::pair<std::string, base::string16> > closed_dbs;
- connections.RemoveConnections(another, &closed_dbs);
- EXPECT_EQ(1u, closed_dbs.size());
- EXPECT_EQ(kOriginId, closed_dbs[0].first);
- EXPECT_EQ(kName2, closed_dbs[0].second);
- EXPECT_FALSE(connections.IsDatabaseOpened(kOriginId, kName2));
- EXPECT_TRUE(connections.IsDatabaseOpened(kOriginId, kName));
- EXPECT_EQ(kSize, connections.GetOpenDatabaseSize(kOriginId, kName));
- another.RemoveAllConnections();
- connections.RemoveAllConnections();
- EXPECT_TRUE(connections.IsEmpty());
-
- // Ensure the return value properly indicates the initial
- // addition and final removal.
- EXPECT_TRUE(connections.AddConnection(kOriginId, kName));
- EXPECT_FALSE(connections.AddConnection(kOriginId, kName));
- EXPECT_FALSE(connections.AddConnection(kOriginId, kName));
- EXPECT_FALSE(connections.RemoveConnection(kOriginId, kName));
- EXPECT_FALSE(connections.RemoveConnection(kOriginId, kName));
- EXPECT_TRUE(connections.RemoveConnection(kOriginId, kName));
-}
-
-TEST(DatabaseConnectionsTest, DatabaseConnectionsWrapperTest) {
- const std::string kOriginId("origin_id");
- const base::string16 kName(ASCIIToUTF16("database_name"));
-
- base::MessageLoop message_loop;
- scoped_refptr<DatabaseConnectionsWrapper> obj(new DatabaseConnectionsWrapper);
- EXPECT_FALSE(obj->HasOpenConnections());
- obj->AddOpenConnection(kOriginId, kName);
- EXPECT_TRUE(obj->HasOpenConnections());
- obj->AddOpenConnection(kOriginId, kName);
- EXPECT_TRUE(obj->HasOpenConnections());
- obj->RemoveOpenConnection(kOriginId, kName);
- EXPECT_TRUE(obj->HasOpenConnections());
- obj->RemoveOpenConnection(kOriginId, kName);
- EXPECT_FALSE(obj->HasOpenConnections());
- obj->WaitForAllDatabasesToClose(); // should return immediately
-
- // Test WaitForAllDatabasesToClose with the last connection
- // being removed on the current thread.
- obj->AddOpenConnection(kOriginId, kName);
- bool did_task_execute = false;
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&RemoveConnectionTask, kOriginId, kName, obj,
- &did_task_execute));
- obj->WaitForAllDatabasesToClose(); // should return after the task executes
- EXPECT_TRUE(did_task_execute);
- EXPECT_FALSE(obj->HasOpenConnections());
-
- // Test WaitForAllDatabasesToClose with the last connection
- // being removed on another thread.
- obj->AddOpenConnection(kOriginId, kName);
- base::Thread thread("WrapperTestThread");
- thread.Start();
- did_task_execute = false;
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&ScheduleRemoveConnectionTask, &thread, kOriginId, kName, obj,
- &did_task_execute));
- obj->WaitForAllDatabasesToClose(); // should return after the task executes
- EXPECT_TRUE(did_task_execute);
- EXPECT_FALSE(obj->HasOpenConnections());
-}
-
-} // namespace webkit_database
diff --git a/chromium/webkit/common/database/database_identifier.cc b/chromium/webkit/common/database/database_identifier.cc
index 332dfb8b0cc..7bd53f77034 100644
--- a/chromium/webkit/common/database/database_identifier.cc
+++ b/chromium/webkit/common/database/database_identifier.cc
@@ -39,12 +39,12 @@ DatabaseIdentifier DatabaseIdentifier::CreateFromOrigin(const GURL& origin) {
return UniqueFileIdentifier();
int port = origin.IntPort();
- if (port == url_parse::PORT_INVALID)
+ if (port == url::PORT_INVALID)
return DatabaseIdentifier();
// We encode the default port for the specified scheme as 0. GURL
// canonicalizes this as an unspecified port.
- if (port == url_parse::PORT_UNSPECIFIED)
+ if (port == url::PORT_UNSPECIFIED)
port = 0;
return DatabaseIdentifier(origin.scheme(),
@@ -56,8 +56,15 @@ DatabaseIdentifier DatabaseIdentifier::CreateFromOrigin(const GURL& origin) {
// static
DatabaseIdentifier DatabaseIdentifier::Parse(const std::string& identifier) {
- if (!IsStringASCII(identifier))
+ if (!base::IsStringASCII(identifier))
return DatabaseIdentifier();
+ if (identifier.find("..") != std::string::npos)
+ return DatabaseIdentifier();
+ char forbidden[] = {'\\', '/', ':' ,'\0'};
+ if (identifier.find_first_of(forbidden, 0, arraysize(forbidden)) !=
+ std::string::npos) {
+ return DatabaseIdentifier();
+ }
size_t first_underscore = identifier.find_first_of('_');
if (first_underscore == std::string::npos || first_underscore == 0)
diff --git a/chromium/webkit/common/database/database_identifier_unittest.cc b/chromium/webkit/common/database/database_identifier_unittest.cc
deleted file mode 100644
index 495516373db..00000000000
--- a/chromium/webkit/common/database/database_identifier_unittest.cc
+++ /dev/null
@@ -1,245 +0,0 @@
-// Copyright 2013 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 "webkit/common/database/database_identifier.h"
-
-#include "base/basictypes.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "url/gurl.h"
-
-namespace webkit_database {
-namespace {
-
-TEST(DatabaseIdentifierTest, CreateIdentifierFromOrigin) {
- struct OriginTestCase {
- std::string origin;
- std::string expectedIdentifier;
- } cases[] = {
- {"http://google.com", "http_google.com_0"},
- {"http://google.com:80", "http_google.com_0"},
- {"https://www.google.com", "https_www.google.com_0"},
- {"https://www.google.com:443", "https_www.google.com_0"},
- {"http://foo_bar_baz.org", "http_foo_bar_baz.org_0"},
- {"http://nondefaultport.net:8001", "http_nondefaultport.net_8001"},
- {"http://invalidportnumber.org:70000", "__0"},
- {"http://invalidportnumber.org:-6", "__0"},
- {"http://%E2%98%83.unicode.com", "http_xn--n3h.unicode.com_0"},
- {"http://\xe2\x98\x83.unicode.com", "http_xn--n3h.unicode.com_0"},
- {"http://\xf0\x9f\x92\xa9.unicode.com", "http_xn--ls8h.unicode.com_0"},
- {"file:///", "file__0"},
- {"data:", "__0"},
- {"about:blank", "__0"},
- {"non-standard://foobar.com", "__0"},
- };
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
- GURL origin(cases[i].origin);
- DatabaseIdentifier identifier =
- DatabaseIdentifier::CreateFromOrigin(origin);
- EXPECT_EQ(cases[i].expectedIdentifier, identifier.ToString())
- << "test case " << cases[i].origin;
- }
-}
-
-// This tests the encoding of a hostname including every character in the range
-// [\x1f, \x80].
-TEST(DatabaseIdentifierTest, CreateIdentifierAllHostChars) {
- struct Case {
- std::string hostname;
- std::string expected;
- bool shouldRoundTrip;
- } cases[] = {
- {"x\x1Fx", "__0", false},
- {"x\x20x", "http_x%20x_0", false},
- {"x\x21x", "http_x%21x_0", false},
- {"x\x22x", "http_x%22x_0", false},
- {"x\x23x", "http_x_0", false}, // 'x#x', the # and following are ignored.
- {"x\x24x", "http_x%24x_0", false},
- {"x\x25x", "__0", false},
- {"x\x26x", "http_x%26x_0", false},
- {"x\x27x", "http_x%27x_0", false},
- {"x\x28x", "http_x%28x_0", false},
- {"x\x29x", "http_x%29x_0", false},
- {"x\x2ax", "http_x%2ax_0", false},
- {"x\x2bx", "http_x+x_0", false},
- {"x\x2cx", "http_x%2cx_0", false},
- {"x\x2dx", "http_x-x_0", true},
- {"x\x2ex", "http_x.x_0", true},
- {"x\x2fx", "http_x_0", false}, // 'x/x', the / and following are ignored.
- {"x\x30x", "http_x0x_0", true},
- {"x\x31x", "http_x1x_0", true},
- {"x\x32x", "http_x2x_0", true},
- {"x\x33x", "http_x3x_0", true},
- {"x\x34x", "http_x4x_0", true},
- {"x\x35x", "http_x5x_0", true},
- {"x\x36x", "http_x6x_0", true},
- {"x\x37x", "http_x7x_0", true},
- {"x\x38x", "http_x8x_0", true},
- {"x\x39x", "http_x9x_0", true},
- {"x\x3ax", "__0", false},
- {"x\x3bx", "__0", false},
- {"x\x3cx", "http_x%3cx_0", false},
- {"x\x3dx", "http_x%3dx_0", false},
- {"x\x3ex", "http_x%3ex_0", false},
- {"x\x3fx", "http_x_0", false}, // 'x?x', the ? and following are ignored.
- {"x\x40x", "http_x_0", false}, // 'x@x', the @ and following are ignored.
- {"x\x41x", "http_xax_0", true},
- {"x\x42x", "http_xbx_0", true},
- {"x\x43x", "http_xcx_0", true},
- {"x\x44x", "http_xdx_0", true},
- {"x\x45x", "http_xex_0", true},
- {"x\x46x", "http_xfx_0", true},
- {"x\x47x", "http_xgx_0", true},
- {"x\x48x", "http_xhx_0", true},
- {"x\x49x", "http_xix_0", true},
- {"x\x4ax", "http_xjx_0", true},
- {"x\x4bx", "http_xkx_0", true},
- {"x\x4cx", "http_xlx_0", true},
- {"x\x4dx", "http_xmx_0", true},
- {"x\x4ex", "http_xnx_0", true},
- {"x\x4fx", "http_xox_0", true},
- {"x\x50x", "http_xpx_0", true},
- {"x\x51x", "http_xqx_0", true},
- {"x\x52x", "http_xrx_0", true},
- {"x\x53x", "http_xsx_0", true},
- {"x\x54x", "http_xtx_0", true},
- {"x\x55x", "http_xux_0", true},
- {"x\x56x", "http_xvx_0", true},
- {"x\x57x", "http_xwx_0", true},
- {"x\x58x", "http_xxx_0", true},
- {"x\x59x", "http_xyx_0", true},
- {"x\x5ax", "http_xzx_0", true},
- {"x\x5bx", "__0", false},
- {"x\x5cx", "http_x_0", false}, // "x\x", the \ and following are ignored.
- {"x\x5dx", "__0", false},
- {"x\x5ex", "__0", false},
- {"x\x5fx", "http_x_x_0", true},
- {"x\x60x", "http_x%60x_0", false},
- {"x\x61x", "http_xax_0", true},
- {"x\x62x", "http_xbx_0", true},
- {"x\x63x", "http_xcx_0", true},
- {"x\x64x", "http_xdx_0", true},
- {"x\x65x", "http_xex_0", true},
- {"x\x66x", "http_xfx_0", true},
- {"x\x67x", "http_xgx_0", true},
- {"x\x68x", "http_xhx_0", true},
- {"x\x69x", "http_xix_0", true},
- {"x\x6ax", "http_xjx_0", true},
- {"x\x6bx", "http_xkx_0", true},
- {"x\x6cx", "http_xlx_0", true},
- {"x\x6dx", "http_xmx_0", true},
- {"x\x6ex", "http_xnx_0", true},
- {"x\x6fx", "http_xox_0", true},
- {"x\x70x", "http_xpx_0", true},
- {"x\x71x", "http_xqx_0", true},
- {"x\x72x", "http_xrx_0", true},
- {"x\x73x", "http_xsx_0", true},
- {"x\x74x", "http_xtx_0", true},
- {"x\x75x", "http_xux_0", true},
- {"x\x76x", "http_xvx_0", true},
- {"x\x77x", "http_xwx_0", true},
- {"x\x78x", "http_xxx_0", true},
- {"x\x79x", "http_xyx_0", true},
- {"x\x7ax", "http_xzx_0", true},
- {"x\x7bx", "http_x%7bx_0", false},
- {"x\x7cx", "http_x%7cx_0", false},
- {"x\x7dx", "http_x%7dx_0", false},
- {"x\x7ex", "__0", false},
- {"x\x7fx", "__0", false},
- {"x\x80x", "__0", false},
- };
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
- GURL origin("http://" + cases[i].hostname);
- DatabaseIdentifier identifier =
- DatabaseIdentifier::CreateFromOrigin(origin);
- EXPECT_EQ(cases[i].expected, identifier.ToString())
- << "test case " << i << " :\"" << cases[i].hostname << "\"";
- if (cases[i].shouldRoundTrip) {
- DatabaseIdentifier parsed_identifier =
- DatabaseIdentifier::Parse(identifier.ToString());
- EXPECT_EQ(identifier.ToString(), parsed_identifier.ToString())
- << "test case " << i << " :\"" << cases[i].hostname << "\"";
- }
- }
-}
-
-TEST(DatabaseIdentifierTest, ExtractOriginDataFromIdentifier) {
- struct IdentifierTestCase {
- std::string str;
- std::string expected_scheme;
- std::string expected_host;
- int expected_port;
- GURL expected_origin;
- bool expected_unique;
- };
-
- IdentifierTestCase valid_cases[] = {
- {"http_google.com_0",
- "http", "google.com", 0, GURL("http://google.com"), false},
- {"https_google.com_0",
- "https", "google.com", 0, GURL("https://google.com"), false},
- {"ftp_google.com_0",
- "ftp", "google.com", 0, GURL("ftp://google.com"), false},
- {"unknown_google.com_0",
- "unknown", "", 0, GURL("unknown://"), false},
- {"http_nondefaultport.net_8001",
- "http", "nondefaultport.net", 8001,
- GURL("http://nondefaultport.net:8001"), false},
- {"file__0",
- "", "", 0, GURL("file:///"), true},
- {"__0",
- "", "", 0, GURL(), true},
- {"http_foo_bar_baz.org_0",
- "http", "foo_bar_baz.org", 0, GURL("http://foo_bar_baz.org"), false},
- {"http_xn--n3h.unicode.com_0",
- "http", "xn--n3h.unicode.com", 0,
- GURL("http://xn--n3h.unicode.com"), false},
- {"http_dot.com_0", "http", "dot.com", 0, GURL("http://dot.com"), false},
- {"http_escaped%3Dfun.com_0", "http", "escaped%3dfun.com", 0,
- GURL("http://escaped%3dfun.com"), false},
- };
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(valid_cases); ++i) {
- DatabaseIdentifier identifier =
- DatabaseIdentifier::Parse(valid_cases[i].str);
- EXPECT_EQ(valid_cases[i].expected_scheme, identifier.scheme())
- << "test case " << valid_cases[i].str;
- EXPECT_EQ(valid_cases[i].expected_host, identifier.hostname())
- << "test case " << valid_cases[i].str;
- EXPECT_EQ(valid_cases[i].expected_port, identifier.port())
- << "test case " << valid_cases[i].str;
- EXPECT_EQ(valid_cases[i].expected_origin, identifier.ToOrigin())
- << "test case " << valid_cases[i].str;
- EXPECT_EQ(valid_cases[i].expected_unique, identifier.is_unique())
- << "test case " << valid_cases[i].str;
- }
-
- std::string bogus_components[] = {
- "", "_", "__", std::string("\x00", 1), std::string("http_\x00_0", 8),
- "ht\x7ctp_badscheme.com_0", "http_unescaped_percent_%.com_0",
- "http_port_too_big.net_75000", "http_port_too_small.net_-25",
- "http_shouldbeescaped\x7c.com_0", "http_latin1\x8a.org_8001",
- "http_\xe2\x98\x83.unicode.com_0",
- "http_dot%252ecom_0",
- "HtTp_NonCanonicalRepresenTation_0",
- "http_non_ascii.\xa1.com_0",
- "http_not_canonical_escape%3d_0",
- "http_bytes_after_port_0abcd",
- };
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(bogus_components); ++i) {
- DatabaseIdentifier identifier =
- DatabaseIdentifier::Parse(bogus_components[i]);
- EXPECT_EQ("__0", identifier.ToString())
- << "test case " << bogus_components[i];
- EXPECT_EQ(GURL("null"), identifier.ToOrigin())
- << "test case " << bogus_components[i];
- EXPECT_EQ(true, identifier.is_unique())
- << "test case " << bogus_components[i];
- }
-}
-
-} // namespace
-} // namespace webkit_database
diff --git a/chromium/webkit/common/fileapi/file_system_types.h b/chromium/webkit/common/fileapi/file_system_types.h
index 85417cca7d3..409f3dcb49d 100644
--- a/chromium/webkit/common/fileapi/file_system_types.h
+++ b/chromium/webkit/common/fileapi/file_system_types.h
@@ -116,6 +116,16 @@ enum FileSystemType {
// given identifier in each origin.
kFileSystemTypePluginPrivate,
+ // A filesystem that is mounted via the Privet storage protocol.
+ kFileSystemTypeCloudDevice,
+
+ // A filesystem that is mounted via the FileSystemProvider API.
+ kFileSystemTypeProvided,
+
+ // A media filesystem such as MTP or PTP, mounted as a file storage not
+ // limited to media files.
+ kFileSystemTypeDeviceMediaAsFileStorage,
+
// --------------------------------------------------------------------
// Marks the end of internal type enum. (This is not the actual fs type)
// New internal filesystem types must be added above this line.
diff --git a/chromium/webkit/common/fileapi/file_system_util.cc b/chromium/webkit/common/fileapi/file_system_util.cc
index 4d5c352bf37..ded3457ccf3 100644
--- a/chromium/webkit/common/fileapi/file_system_util.cc
+++ b/chromium/webkit/common/fileapi/file_system_util.cc
@@ -11,6 +11,7 @@
#include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
+#include "net/base/escape.h"
#include "net/base/net_errors.h"
#include "url/gurl.h"
#include "webkit/common/database/database_identifier.h"
@@ -146,6 +147,65 @@ bool VirtualPath::IsRootPath(const base::FilePath& path) {
components[0] == VirtualPath::kRoot));
}
+bool ParseFileSystemSchemeURL(const GURL& url,
+ GURL* origin_url,
+ FileSystemType* type,
+ base::FilePath* virtual_path) {
+ GURL origin;
+ FileSystemType file_system_type = kFileSystemTypeUnknown;
+
+ if (!url.is_valid() || !url.SchemeIsFileSystem())
+ return false;
+
+ const struct {
+ FileSystemType type;
+ const char* dir;
+ } kValidTypes[] = {
+ { kFileSystemTypePersistent, kPersistentDir },
+ { kFileSystemTypeTemporary, kTemporaryDir },
+ { kFileSystemTypeIsolated, kIsolatedDir },
+ { kFileSystemTypeExternal, kExternalDir },
+ { kFileSystemTypeTest, kTestDir },
+ };
+
+ // A path of the inner_url contains only mount type part (e.g. "/temporary").
+ DCHECK(url.inner_url());
+ std::string inner_path = url.inner_url()->path();
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kValidTypes); ++i) {
+ if (inner_path == kValidTypes[i].dir) {
+ file_system_type = kValidTypes[i].type;
+ break;
+ }
+ }
+
+ if (file_system_type == kFileSystemTypeUnknown)
+ return false;
+
+ std::string path = net::UnescapeURLComponent(url.path(),
+ net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS |
+ net::UnescapeRule::CONTROL_CHARS);
+
+ // Ensure the path is relative.
+ while (!path.empty() && path[0] == '/')
+ path.erase(0, 1);
+
+ base::FilePath converted_path = base::FilePath::FromUTF8Unsafe(path);
+
+ // All parent references should have been resolved in the renderer.
+ if (converted_path.ReferencesParent())
+ return false;
+
+ if (origin_url)
+ *origin_url = url.GetOrigin();
+ if (type)
+ *type = file_system_type;
+ if (virtual_path)
+ *virtual_path = converted_path.NormalizePathSeparators().
+ StripTrailingSeparators();
+
+ return true;
+}
+
GURL GetFileSystemRootURI(const GURL& origin_url, FileSystemType type) {
// origin_url is based on a security origin, so http://foo.com or file:///
// instead of the corresponding filesystem URL.
@@ -255,6 +315,12 @@ std::string GetFileSystemTypeString(FileSystemType type) {
return "TransientFile";
case kFileSystemTypePluginPrivate:
return "PluginPrivate";
+ case kFileSystemTypeCloudDevice:
+ return "CloudDevice";
+ case kFileSystemTypeProvided:
+ return "Provided";
+ case kFileSystemTypeDeviceMediaAsFileStorage:
+ return "DeviceMediaStorage";
case kFileSystemInternalTypeEnumStart:
case kFileSystemInternalTypeEnumEnd:
NOTREACHED();
@@ -268,7 +334,7 @@ std::string GetFileSystemTypeString(FileSystemType type) {
std::string FilePathToString(const base::FilePath& file_path) {
#if defined(OS_WIN)
- return UTF16ToUTF8(file_path.value());
+ return base::UTF16ToUTF8(file_path.value());
#elif defined(OS_POSIX)
return file_path.value();
#endif
@@ -276,35 +342,35 @@ std::string FilePathToString(const base::FilePath& file_path) {
base::FilePath StringToFilePath(const std::string& file_path_string) {
#if defined(OS_WIN)
- return base::FilePath(UTF8ToUTF16(file_path_string));
+ return base::FilePath(base::UTF8ToUTF16(file_path_string));
#elif defined(OS_POSIX)
return base::FilePath(file_path_string);
#endif
}
-blink::WebFileError PlatformFileErrorToWebFileError(
- base::PlatformFileError error_code) {
+blink::WebFileError FileErrorToWebFileError(
+ base::File::Error error_code) {
switch (error_code) {
- case base::PLATFORM_FILE_ERROR_NOT_FOUND:
+ case base::File::FILE_ERROR_NOT_FOUND:
return blink::WebFileErrorNotFound;
- case base::PLATFORM_FILE_ERROR_INVALID_OPERATION:
- case base::PLATFORM_FILE_ERROR_EXISTS:
- case base::PLATFORM_FILE_ERROR_NOT_EMPTY:
+ case base::File::FILE_ERROR_INVALID_OPERATION:
+ case base::File::FILE_ERROR_EXISTS:
+ case base::File::FILE_ERROR_NOT_EMPTY:
return blink::WebFileErrorInvalidModification;
- case base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY:
- case base::PLATFORM_FILE_ERROR_NOT_A_FILE:
+ case base::File::FILE_ERROR_NOT_A_DIRECTORY:
+ case base::File::FILE_ERROR_NOT_A_FILE:
return blink::WebFileErrorTypeMismatch;
- case base::PLATFORM_FILE_ERROR_ACCESS_DENIED:
+ case base::File::FILE_ERROR_ACCESS_DENIED:
return blink::WebFileErrorNoModificationAllowed;
- case base::PLATFORM_FILE_ERROR_FAILED:
+ case base::File::FILE_ERROR_FAILED:
return blink::WebFileErrorInvalidState;
- case base::PLATFORM_FILE_ERROR_ABORT:
+ case base::File::FILE_ERROR_ABORT:
return blink::WebFileErrorAbort;
- case base::PLATFORM_FILE_ERROR_SECURITY:
+ case base::File::FILE_ERROR_SECURITY:
return blink::WebFileErrorSecurity;
- case base::PLATFORM_FILE_ERROR_NO_SPACE:
+ case base::File::FILE_ERROR_NO_SPACE:
return blink::WebFileErrorQuotaExceeded;
- case base::PLATFORM_FILE_ERROR_INVALID_URL:
+ case base::File::FILE_ERROR_INVALID_URL:
return blink::WebFileErrorEncoding;
default:
return blink::WebFileErrorInvalidModification;
@@ -377,7 +443,7 @@ bool ValidateIsolatedFileSystemId(const std::string& filesystem_id) {
if (filesystem_id.size() != kExpectedFileSystemIdSize)
return false;
const std::string kExpectedChars("ABCDEF0123456789");
- return ContainsOnlyChars(filesystem_id, kExpectedChars);
+ return base::ContainsOnlyChars(filesystem_id, kExpectedChars);
}
std::string GetIsolatedFileSystemRootURIString(
@@ -388,12 +454,12 @@ std::string GetIsolatedFileSystemRootURIString(
kFileSystemTypeIsolated).spec();
if (base::FilePath::FromUTF8Unsafe(filesystem_id).ReferencesParent())
return std::string();
- root.append(filesystem_id);
+ root.append(net::EscapePath(filesystem_id));
root.append("/");
if (!optional_root_name.empty()) {
if (base::FilePath::FromUTF8Unsafe(optional_root_name).ReferencesParent())
return std::string();
- root.append(optional_root_name);
+ root.append(net::EscapePath(optional_root_name));
root.append("/");
}
return root;
@@ -406,50 +472,41 @@ std::string GetExternalFileSystemRootURIString(
kFileSystemTypeExternal).spec();
if (base::FilePath::FromUTF8Unsafe(mount_name).ReferencesParent())
return std::string();
- root.append(mount_name);
+ root.append(net::EscapePath(mount_name));
root.append("/");
return root;
}
-base::PlatformFileError NetErrorToPlatformFileError(int error) {
+base::File::Error NetErrorToFileError(int error) {
switch (error) {
case net::OK:
- return base::PLATFORM_FILE_OK;
+ return base::File::FILE_OK;
case net::ERR_ADDRESS_IN_USE:
- return base::PLATFORM_FILE_ERROR_IN_USE;
+ return base::File::FILE_ERROR_IN_USE;
case net::ERR_FILE_EXISTS:
- return base::PLATFORM_FILE_ERROR_EXISTS;
+ return base::File::FILE_ERROR_EXISTS;
case net::ERR_FILE_NOT_FOUND:
- return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ return base::File::FILE_ERROR_NOT_FOUND;
case net::ERR_ACCESS_DENIED:
- return base::PLATFORM_FILE_ERROR_ACCESS_DENIED;
+ return base::File::FILE_ERROR_ACCESS_DENIED;
case net::ERR_TOO_MANY_SOCKET_STREAMS:
- return base::PLATFORM_FILE_ERROR_TOO_MANY_OPENED;
+ return base::File::FILE_ERROR_TOO_MANY_OPENED;
case net::ERR_OUT_OF_MEMORY:
- return base::PLATFORM_FILE_ERROR_NO_MEMORY;
+ return base::File::FILE_ERROR_NO_MEMORY;
case net::ERR_FILE_NO_SPACE:
- return base::PLATFORM_FILE_ERROR_NO_SPACE;
+ return base::File::FILE_ERROR_NO_SPACE;
case net::ERR_INVALID_ARGUMENT:
case net::ERR_INVALID_HANDLE:
- return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
+ return base::File::FILE_ERROR_INVALID_OPERATION;
case net::ERR_ABORTED:
case net::ERR_CONNECTION_ABORTED:
- return base::PLATFORM_FILE_ERROR_ABORT;
+ return base::File::FILE_ERROR_ABORT;
case net::ERR_ADDRESS_INVALID:
case net::ERR_INVALID_URL:
- return base::PLATFORM_FILE_ERROR_INVALID_URL;
+ return base::File::FILE_ERROR_INVALID_URL;
default:
- return base::PLATFORM_FILE_ERROR_FAILED;
+ return base::File::FILE_ERROR_FAILED;
}
}
-#if defined(OS_CHROMEOS)
-FileSystemInfo GetFileSystemInfoForChromeOS(const GURL& origin_url) {
- FileSystemType mount_type = fileapi::kFileSystemTypeExternal;
- return FileSystemInfo(fileapi::GetFileSystemName(origin_url, mount_type),
- fileapi::GetFileSystemRootURI(origin_url, mount_type),
- mount_type);
-}
-#endif
-
} // namespace fileapi
diff --git a/chromium/webkit/common/fileapi/file_system_util.h b/chromium/webkit/common/fileapi/file_system_util.h
index 335d62c3d26..9bf84244f42 100644
--- a/chromium/webkit/common/fileapi/file_system_util.h
+++ b/chromium/webkit/common/fileapi/file_system_util.h
@@ -8,8 +8,8 @@
#include <string>
#include <vector>
+#include "base/files/file.h"
#include "base/files/file_path.h"
-#include "base/platform_file.h"
#include "third_party/WebKit/public/platform/WebFileError.h"
#include "third_party/WebKit/public/platform/WebFileSystemType.h"
#include "webkit/common/fileapi/file_system_info.h"
@@ -65,6 +65,16 @@ class WEBKIT_STORAGE_COMMON_EXPORT VirtualPath {
static bool IsRootPath(const base::FilePath& path);
};
+// Parses filesystem scheme |url| into uncracked file system URL components.
+// Example: For a URL 'filesystem:http://foo.com/temporary/foo/bar',
+// |origin_url| is set to 'http://foo.com', |type| is set to
+// kFileSystemTypeTemporary, and |virtual_path| is set to 'foo/bar'.
+WEBKIT_STORAGE_COMMON_EXPORT bool ParseFileSystemSchemeURL(
+ const GURL& url,
+ GURL* origin_url,
+ FileSystemType* type,
+ base::FilePath* virtual_path);
+
// Returns the root URI of the filesystem that can be specified by a pair of
// |origin_url| and |type|. The returned URI can be used as a root path
// of the filesystem (e.g. <returned_URI> + "/relative/path" will compose
@@ -129,7 +139,7 @@ WEBKIT_STORAGE_COMMON_EXPORT base::FilePath StringToFilePath(
// File error conversion
WEBKIT_STORAGE_COMMON_EXPORT blink::WebFileError
-PlatformFileErrorToWebFileError(base::PlatformFileError error_code);
+FileErrorToWebFileError(base::File::Error error_code);
// Generate a file system name for the given arguments. Should only be used by
// platform apps.
@@ -163,18 +173,9 @@ WEBKIT_STORAGE_COMMON_EXPORT std::string GetExternalFileSystemRootURIString(
const GURL& origin_url,
const std::string& mount_name);
-// Translates the net::Error to base::PlatformFileError.
-WEBKIT_STORAGE_COMMON_EXPORT base::PlatformFileError
-NetErrorToPlatformFileError(int error);
-
-#if defined(OS_CHROMEOS)
-// Returns the filesystem info that can be specified by |origin_url|.
-// TODO(nhiroki): This should be deprecated and use
-// GetExternalFileSystemRootURIString() to get separate file systems for each
-// mount type. http://crbug.com/284963.
-WEBKIT_STORAGE_COMMON_EXPORT FileSystemInfo
-GetFileSystemInfoForChromeOS(const GURL& origin_url);
-#endif
+// Translates the net::Error to base::File::Error.
+WEBKIT_STORAGE_COMMON_EXPORT base::File::Error
+NetErrorToFileError(int error);
} // namespace fileapi
diff --git a/chromium/webkit/common/fileapi/file_system_util_unittest.cc b/chromium/webkit/common/fileapi/file_system_util_unittest.cc
deleted file mode 100644
index 2cc340242eb..00000000000
--- a/chromium/webkit/common/fileapi/file_system_util_unittest.cc
+++ /dev/null
@@ -1,263 +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 "webkit/common/fileapi/file_system_util.h"
-
-#include "base/files/file_path.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "url/gurl.h"
-
-namespace fileapi {
-namespace {
-
-class FileSystemUtilTest : public testing::Test {};
-
-TEST_F(FileSystemUtilTest, GetTempFileSystemRootURI) {
- GURL origin_url("http://chromium.org");
- fileapi::FileSystemType type = fileapi::kFileSystemTypeTemporary;
- GURL uri = GURL("filesystem:http://chromium.org/temporary/");
- EXPECT_EQ(uri, GetFileSystemRootURI(origin_url, type));
-}
-
-TEST_F(FileSystemUtilTest, GetPersistentFileSystemRootURI) {
- GURL origin_url("http://chromium.org");
- fileapi::FileSystemType type = fileapi::kFileSystemTypePersistent;
- GURL uri = GURL("filesystem:http://chromium.org/persistent/");
- EXPECT_EQ(uri, GetFileSystemRootURI(origin_url, type));
-}
-
-TEST_F(FileSystemUtilTest, VirtualPathBaseName) {
- struct test_data {
- const base::FilePath::StringType path;
- const base::FilePath::StringType base_name;
- } test_cases[] = {
- { FILE_PATH_LITERAL("foo/bar"), FILE_PATH_LITERAL("bar") },
- { FILE_PATH_LITERAL("foo/b:bar"), FILE_PATH_LITERAL("b:bar") },
- { FILE_PATH_LITERAL(""), FILE_PATH_LITERAL("") },
- { FILE_PATH_LITERAL("/"), FILE_PATH_LITERAL("/") },
- { FILE_PATH_LITERAL("foo//////bar"), FILE_PATH_LITERAL("bar") },
- { FILE_PATH_LITERAL("foo/bar/"), FILE_PATH_LITERAL("bar") },
- { FILE_PATH_LITERAL("foo/bar/////"), FILE_PATH_LITERAL("bar") },
- { FILE_PATH_LITERAL("/bar/////"), FILE_PATH_LITERAL("bar") },
- { FILE_PATH_LITERAL("bar/////"), FILE_PATH_LITERAL("bar") },
- { FILE_PATH_LITERAL("bar/"), FILE_PATH_LITERAL("bar") },
- { FILE_PATH_LITERAL("/bar"), FILE_PATH_LITERAL("bar") },
- { FILE_PATH_LITERAL("////bar"), FILE_PATH_LITERAL("bar") },
- { FILE_PATH_LITERAL("bar"), FILE_PATH_LITERAL("bar") }
- };
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
- base::FilePath input = base::FilePath(test_cases[i].path);
- base::FilePath base_name = VirtualPath::BaseName(input);
- EXPECT_EQ(test_cases[i].base_name, base_name.value());
- }
-}
-
-TEST_F(FileSystemUtilTest, VirtualPathDirName) {
- struct test_data {
- const base::FilePath::StringType path;
- const base::FilePath::StringType dir_name;
- } test_cases[] = {
- { FILE_PATH_LITERAL("foo/bar"), FILE_PATH_LITERAL("foo") },
- { FILE_PATH_LITERAL("foo/b:bar"), FILE_PATH_LITERAL("foo") },
- { FILE_PATH_LITERAL(""), FILE_PATH_LITERAL(".") },
- { FILE_PATH_LITERAL("/"), FILE_PATH_LITERAL("/") },
- { FILE_PATH_LITERAL("foo//////bar"), FILE_PATH_LITERAL("foo") },
- { FILE_PATH_LITERAL("foo/bar/"), FILE_PATH_LITERAL("foo") },
- { FILE_PATH_LITERAL("foo/bar/////"), FILE_PATH_LITERAL("foo") },
- { FILE_PATH_LITERAL("/bar/////"), FILE_PATH_LITERAL("/") },
- { FILE_PATH_LITERAL("bar/////"), FILE_PATH_LITERAL(".") },
- { FILE_PATH_LITERAL("bar/"), FILE_PATH_LITERAL(".") },
- { FILE_PATH_LITERAL("/bar"), FILE_PATH_LITERAL("/") },
- { FILE_PATH_LITERAL("////bar"), FILE_PATH_LITERAL("/") },
- { FILE_PATH_LITERAL("bar"), FILE_PATH_LITERAL(".") },
- { FILE_PATH_LITERAL("c:bar"), FILE_PATH_LITERAL(".") },
-#ifdef FILE_PATH_USES_WIN_SEPARATORS
- { FILE_PATH_LITERAL("foo\\bar"), FILE_PATH_LITERAL("foo") },
- { FILE_PATH_LITERAL("foo\\b:bar"), FILE_PATH_LITERAL("foo") },
- { FILE_PATH_LITERAL("\\"), FILE_PATH_LITERAL("\\") },
- { FILE_PATH_LITERAL("foo\\\\\\\\\\\\bar"), FILE_PATH_LITERAL("foo") },
- { FILE_PATH_LITERAL("foo\\bar\\"), FILE_PATH_LITERAL("foo") },
- { FILE_PATH_LITERAL("foo\\bar\\\\\\\\\\"), FILE_PATH_LITERAL("foo") },
- { FILE_PATH_LITERAL("\\bar\\\\\\\\\\"), FILE_PATH_LITERAL("\\") },
- { FILE_PATH_LITERAL("bar\\\\\\\\\\"), FILE_PATH_LITERAL(".") },
- { FILE_PATH_LITERAL("bar\\"), FILE_PATH_LITERAL(".") },
- { FILE_PATH_LITERAL("\\bar"), FILE_PATH_LITERAL("\\") },
- { FILE_PATH_LITERAL("\\\\\\\\bar"), FILE_PATH_LITERAL("\\") },
-#endif
- };
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
- base::FilePath input = base::FilePath(test_cases[i].path);
- base::FilePath dir_name = VirtualPath::DirName(input);
- EXPECT_EQ(test_cases[i].dir_name, dir_name.value());
- }
-}
-
-TEST_F(FileSystemUtilTest, GetNormalizedFilePath) {
- struct test_data {
- const base::FilePath::StringType path;
- const base::FilePath::StringType normalized_path;
- } test_cases[] = {
- { FILE_PATH_LITERAL(""), FILE_PATH_LITERAL("/") },
- { FILE_PATH_LITERAL("/"), FILE_PATH_LITERAL("/") },
- { FILE_PATH_LITERAL("foo/bar"), FILE_PATH_LITERAL("/foo/bar") },
- { FILE_PATH_LITERAL("/foo/bar"), FILE_PATH_LITERAL("/foo/bar") },
-#if defined(FILE_PATH_USES_WIN_SEPARATORS)
- { FILE_PATH_LITERAL("\\foo"), FILE_PATH_LITERAL("/foo") },
-#endif
- };
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
- base::FilePath input = base::FilePath(test_cases[i].path);
- base::FilePath::StringType normalized_path_string =
- VirtualPath::GetNormalizedFilePath(input);
- EXPECT_EQ(test_cases[i].normalized_path, normalized_path_string);
- }
-}
-
-TEST_F(FileSystemUtilTest, IsAbsolutePath) {
- EXPECT_TRUE(VirtualPath::IsAbsolute(FILE_PATH_LITERAL("/")));
- EXPECT_TRUE(VirtualPath::IsAbsolute(FILE_PATH_LITERAL("/foo/bar")));
- EXPECT_FALSE(VirtualPath::IsAbsolute(base::FilePath::StringType()));
- EXPECT_FALSE(VirtualPath::IsAbsolute(FILE_PATH_LITERAL("foo/bar")));
-}
-
-TEST_F(FileSystemUtilTest, IsRootPath) {
- EXPECT_TRUE(VirtualPath::IsRootPath(base::FilePath(FILE_PATH_LITERAL(""))));
- EXPECT_TRUE(VirtualPath::IsRootPath(base::FilePath()));
- EXPECT_TRUE(VirtualPath::IsRootPath(base::FilePath(FILE_PATH_LITERAL("/"))));
- EXPECT_TRUE(VirtualPath::IsRootPath(base::FilePath(FILE_PATH_LITERAL("//"))));
- EXPECT_FALSE(VirtualPath::IsRootPath(
- base::FilePath(FILE_PATH_LITERAL("c:/"))));
-#if defined(FILE_PATH_USES_WIN_SEPARATORS)
- EXPECT_TRUE(VirtualPath::IsRootPath(base::FilePath(FILE_PATH_LITERAL("\\"))));
- EXPECT_FALSE(VirtualPath::IsRootPath(
- base::FilePath(FILE_PATH_LITERAL("c:\\"))));
-#endif
-}
-
-TEST_F(FileSystemUtilTest, VirtualPathGetComponents) {
- struct test_data {
- const base::FilePath::StringType path;
- size_t count;
- const base::FilePath::StringType components[3];
- } test_cases[] = {
- { FILE_PATH_LITERAL("foo/bar"),
- 2,
- { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } },
- { FILE_PATH_LITERAL("foo"),
- 1,
- { FILE_PATH_LITERAL("foo") } },
- { FILE_PATH_LITERAL("foo////bar"),
- 2,
- { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } },
- { FILE_PATH_LITERAL("foo/c:bar"),
- 2,
- { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("c:bar") } },
- { FILE_PATH_LITERAL("c:foo/bar"),
- 2,
- { FILE_PATH_LITERAL("c:foo"), FILE_PATH_LITERAL("bar") } },
- { FILE_PATH_LITERAL("foo/bar"),
- 2,
- { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } },
- { FILE_PATH_LITERAL("/foo/bar"),
- 2,
- { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } },
- { FILE_PATH_LITERAL("c:/bar"),
- 2,
- { FILE_PATH_LITERAL("c:"), FILE_PATH_LITERAL("bar") } },
-#ifdef FILE_PATH_USES_WIN_SEPARATORS
- { FILE_PATH_LITERAL("c:\\bar"),
- 2,
- { FILE_PATH_LITERAL("c:"), FILE_PATH_LITERAL("bar") } },
-#endif
- };
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
- base::FilePath input = base::FilePath(test_cases[i].path);
- std::vector<base::FilePath::StringType> components;
- VirtualPath::GetComponents(input, &components);
- EXPECT_EQ(test_cases[i].count, components.size());
- for (size_t j = 0; j < components.size(); ++j)
- EXPECT_EQ(test_cases[i].components[j], components[j]);
- }
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
- base::FilePath input = base::FilePath(test_cases[i].path);
- std::vector<std::string> components;
- VirtualPath::GetComponentsUTF8Unsafe(input, &components);
- EXPECT_EQ(test_cases[i].count, components.size());
- for (size_t j = 0; j < components.size(); ++j) {
- EXPECT_EQ(base::FilePath(test_cases[i].components[j]).AsUTF8Unsafe(),
- components[j]);
- }
- }
-}
-
-TEST_F(FileSystemUtilTest, GetIsolatedFileSystemName) {
- GURL origin_url("http://foo");
- std::string fsname1 = GetIsolatedFileSystemName(origin_url, "bar");
- EXPECT_EQ("http_foo_0:Isolated_bar", fsname1);
-}
-
-TEST_F(FileSystemUtilTest, CrackIsolatedFileSystemName) {
- std::string fsid;
- EXPECT_TRUE(CrackIsolatedFileSystemName("foo:Isolated_bar", &fsid));
- EXPECT_EQ("bar", fsid);
- EXPECT_TRUE(CrackIsolatedFileSystemName("foo:isolated_bar", &fsid));
- EXPECT_EQ("bar", fsid);
- EXPECT_TRUE(CrackIsolatedFileSystemName("foo:Isolated__bar", &fsid));
- EXPECT_EQ("_bar", fsid);
- EXPECT_TRUE(CrackIsolatedFileSystemName("foo::Isolated_bar", &fsid));
- EXPECT_EQ("bar", fsid);
-}
-
-TEST_F(FileSystemUtilTest, RejectBadIsolatedFileSystemName) {
- std::string fsid;
- EXPECT_FALSE(CrackIsolatedFileSystemName("foobar", &fsid));
- EXPECT_FALSE(CrackIsolatedFileSystemName("foo:_bar", &fsid));
- EXPECT_FALSE(CrackIsolatedFileSystemName("foo:Isolatedbar", &fsid));
- EXPECT_FALSE(CrackIsolatedFileSystemName("fooIsolatedbar", &fsid));
- EXPECT_FALSE(CrackIsolatedFileSystemName("foo:Persistent", &fsid));
- EXPECT_FALSE(CrackIsolatedFileSystemName("foo:Temporary", &fsid));
- EXPECT_FALSE(CrackIsolatedFileSystemName("foo:External", &fsid));
- EXPECT_FALSE(CrackIsolatedFileSystemName(":Isolated_bar", &fsid));
- EXPECT_FALSE(CrackIsolatedFileSystemName("foo:Isolated_", &fsid));
-}
-
-TEST_F(FileSystemUtilTest, ValidateIsolatedFileSystemId) {
- EXPECT_TRUE(ValidateIsolatedFileSystemId("ABCDEF0123456789ABCDEF0123456789"));
- EXPECT_TRUE(ValidateIsolatedFileSystemId("ABCDEFABCDEFABCDEFABCDEFABCDEFAB"));
- EXPECT_TRUE(ValidateIsolatedFileSystemId("01234567890123456789012345678901"));
-
- const size_t kExpectedFileSystemIdSize = 32;
-
- // Should not contain lowercase characters.
- const std::string kLowercaseId = "abcdef0123456789abcdef0123456789";
- EXPECT_EQ(kExpectedFileSystemIdSize, kLowercaseId.size());
- EXPECT_FALSE(ValidateIsolatedFileSystemId(kLowercaseId));
-
- // Should not be shorter/longer than expected.
- EXPECT_FALSE(ValidateIsolatedFileSystemId(std::string()));
-
- const std::string kShorterId = "ABCDEF0123456789ABCDEF";
- EXPECT_GT(kExpectedFileSystemIdSize, kShorterId.size());
- EXPECT_FALSE(ValidateIsolatedFileSystemId(kShorterId));
-
- const std::string kLongerId = "ABCDEF0123456789ABCDEF0123456789ABCDEF";
- EXPECT_LT(kExpectedFileSystemIdSize, kLongerId.size());
- EXPECT_FALSE(ValidateIsolatedFileSystemId(kLongerId));
-
- // Should not contain not alphabetical nor numerical characters.
- const std::string kSlashId = "ABCD/EFGH/IJKL/MNOP/QRST/UVWX/YZ";
- EXPECT_EQ(kExpectedFileSystemIdSize, kSlashId.size());
- EXPECT_FALSE(ValidateIsolatedFileSystemId(kSlashId));
-
- const std::string kBackslashId = "ABCD\\EFGH\\IJKL\\MNOP\\QRST\\UVWX\\YZ";
- EXPECT_EQ(kExpectedFileSystemIdSize, kBackslashId.size());
- EXPECT_FALSE(ValidateIsolatedFileSystemId(kBackslashId));
-
- const std::string kSpaceId = "ABCD EFGH IJKL MNOP QRST UVWX YZ";
- EXPECT_EQ(kExpectedFileSystemIdSize, kSpaceId.size());
- EXPECT_FALSE(ValidateIsolatedFileSystemId(kSpaceId));
-}
-
-} // namespace
-} // namespace fileapi
diff --git a/chromium/webkit/common/gpu/BUILD.gn b/chromium/webkit/common/gpu/BUILD.gn
new file mode 100644
index 00000000000..a408f9a68df
--- /dev/null
+++ b/chromium/webkit/common/gpu/BUILD.gn
@@ -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.
+
+component("gpu") {
+ sources = [
+ "context_provider_in_process.cc",
+ "context_provider_in_process.h",
+ "context_provider_web_context.h",
+ "grcontext_for_webgraphicscontext3d.cc",
+ "grcontext_for_webgraphicscontext3d.h",
+ "webgraphicscontext3d_impl.cc",
+ "webgraphicscontext3d_impl.h",
+ "webgraphicscontext3d_in_process_command_buffer_impl.cc",
+ "webgraphicscontext3d_in_process_command_buffer_impl.h",
+ ]
+
+ defines = [ "WEBKIT_GPU_IMPLEMENTATION" ]
+ configs += [ "//build/config/compiler:wexit_time_destructors" ]
+ if (is_win) {
+ # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
+ cflags = [ "/wd4267" ]
+ }
+
+ deps = [
+ "//base",
+ "//base/third_party/dynamic_annotations",
+ "//cc",
+ "//gpu/command_buffer/common",
+ "//gpu/command_buffer/service",
+ "//gpu/command_buffer/client:gles2_c_lib",
+ "//gpu/command_buffer/client:gles2_implementation",
+ "//gpu/command_buffer/client:gl_in_process_context",
+ "//gpu/skia_bindings",
+ "//skia",
+ #"//third_party/WebKit/public:blink_minimal", TODO(GYP)
+ "//third_party/angle:translator",
+ "//ui/gl",
+ "//ui/gfx",
+ "//ui/gfx/geometry",
+ ]
+}
diff --git a/chromium/webkit/common/gpu/context_provider_in_process.cc b/chromium/webkit/common/gpu/context_provider_in_process.cc
index 99359de6eff..3785d38add9 100644
--- a/chromium/webkit/common/gpu/context_provider_in_process.cc
+++ b/chromium/webkit/common/gpu/context_provider_in_process.cc
@@ -48,7 +48,8 @@ scoped_refptr<ContextProviderInProcess> ContextProviderInProcess::Create(
// static
scoped_refptr<ContextProviderInProcess>
-ContextProviderInProcess::CreateOffscreen() {
+ContextProviderInProcess::CreateOffscreen(
+ bool lose_context_when_out_of_memory) {
blink::WebGraphicsContext3D::Attributes attributes;
attributes.depth = false;
attributes.stencil = true;
@@ -58,7 +59,8 @@ ContextProviderInProcess::CreateOffscreen() {
return Create(
WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
- attributes), "Offscreen");
+ attributes, lose_context_when_out_of_memory),
+ "Offscreen");
}
ContextProviderInProcess::ContextProviderInProcess(
@@ -77,6 +79,13 @@ ContextProviderInProcess::~ContextProviderInProcess() {
context_thread_checker_.CalledOnValidThread());
}
+blink::WebGraphicsContext3D* ContextProviderInProcess::WebContext3D() {
+ DCHECK(lost_context_callback_proxy_); // Is bound to thread.
+ DCHECK(context_thread_checker_.CalledOnValidThread());
+
+ return context3d_.get();
+}
+
bool ContextProviderInProcess::BindToCurrentThread() {
DCHECK(context3d_);
@@ -100,7 +109,7 @@ bool ContextProviderInProcess::BindToCurrentThread() {
}
void ContextProviderInProcess::InitializeCapabilities() {
- capabilities_ = Capabilities(context3d_->GetImplementation()->capabilities());
+ capabilities_.gpu = context3d_->GetImplementation()->capabilities();
}
cc::ContextProvider::Capabilities
@@ -110,13 +119,6 @@ ContextProviderInProcess::ContextCapabilities() {
return capabilities_;
}
-blink::WebGraphicsContext3D* ContextProviderInProcess::Context3d() {
- DCHECK(lost_context_callback_proxy_); // Is bound to thread.
- DCHECK(context_thread_checker_.CalledOnValidThread());
-
- return context3d_.get();
-}
-
::gpu::gles2::GLES2Interface* ContextProviderInProcess::ContextGL() {
DCHECK(context3d_);
DCHECK(lost_context_callback_proxy_); // Is bound to thread.
@@ -147,14 +149,6 @@ class GrContext* ContextProviderInProcess::GrContext() {
return gr_context_->get();
}
-void ContextProviderInProcess::MakeGrContextCurrent() {
- DCHECK(lost_context_callback_proxy_); // Is bound to thread.
- DCHECK(context_thread_checker_.CalledOnValidThread());
- DCHECK(gr_context_);
-
- context3d_->makeContextCurrent();
-}
-
bool ContextProviderInProcess::IsContextLost() {
DCHECK(lost_context_callback_proxy_); // Is bound to thread.
DCHECK(context_thread_checker_.CalledOnValidThread());
@@ -170,6 +164,13 @@ void ContextProviderInProcess::VerifyContexts() {
OnLostContext();
}
+void ContextProviderInProcess::DeleteCachedResources() {
+ DCHECK(context_thread_checker_.CalledOnValidThread());
+
+ if (gr_context_)
+ gr_context_->FreeGpuResources();
+}
+
void ContextProviderInProcess::OnLostContext() {
DCHECK(context_thread_checker_.CalledOnValidThread());
{
@@ -180,6 +181,8 @@ void ContextProviderInProcess::OnLostContext() {
}
if (!lost_context_callback_.is_null())
base::ResetAndReturn(&lost_context_callback_).Run();
+ if (gr_context_)
+ gr_context_->OnLostContext();
}
bool ContextProviderInProcess::DestroyedOnMainThread() {
diff --git a/chromium/webkit/common/gpu/context_provider_in_process.h b/chromium/webkit/common/gpu/context_provider_in_process.h
index 72098b26d00..3df327b76a5 100644
--- a/chromium/webkit/common/gpu/context_provider_in_process.h
+++ b/chromium/webkit/common/gpu/context_provider_in_process.h
@@ -9,7 +9,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_checker.h"
-#include "cc/output/context_provider.h"
+#include "webkit/common/gpu/context_provider_web_context.h"
#include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
#include "webkit/common/gpu/webkit_gpu_export.h"
@@ -20,25 +20,26 @@ namespace gpu {
class GrContextForWebGraphicsContext3D;
class WEBKIT_GPU_EXPORT ContextProviderInProcess
- : NON_EXPORTED_BASE(public cc::ContextProvider) {
+ : NON_EXPORTED_BASE(public ContextProviderWebContext) {
public:
static scoped_refptr<ContextProviderInProcess> Create(
scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d,
const std::string& debug_name);
- // Calls Create() with a default factory method for creating an offscreen
- // context.
- static scoped_refptr<ContextProviderInProcess> CreateOffscreen();
+ // Uses default attributes for creating an offscreen context.
+ static scoped_refptr<ContextProviderInProcess> CreateOffscreen(
+ bool lose_context_when_out_of_memory);
+
+ virtual blink::WebGraphicsContext3D* WebContext3D() OVERRIDE;
virtual bool BindToCurrentThread() OVERRIDE;
virtual Capabilities ContextCapabilities() OVERRIDE;
- virtual blink::WebGraphicsContext3D* Context3d() OVERRIDE;
virtual ::gpu::gles2::GLES2Interface* ContextGL() OVERRIDE;
virtual ::gpu::ContextSupport* ContextSupport() OVERRIDE;
virtual class GrContext* GrContext() OVERRIDE;
- virtual void MakeGrContextCurrent() OVERRIDE;
virtual bool IsContextLost() OVERRIDE;
virtual void VerifyContexts() OVERRIDE;
+ virtual void DeleteCachedResources() OVERRIDE;
virtual bool DestroyedOnMainThread() OVERRIDE;
virtual void SetLostContextCallback(
const LostContextCallback& lost_context_callback) OVERRIDE;
diff --git a/chromium/webkit/common/gpu/context_provider_web_context.h b/chromium/webkit/common/gpu/context_provider_web_context.h
new file mode 100644
index 00000000000..9f04bf9aea3
--- /dev/null
+++ b/chromium/webkit/common/gpu/context_provider_web_context.h
@@ -0,0 +1,26 @@
+// 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 WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_WEB_CONTEXT_H_
+#define WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_WEB_CONTEXT_H_
+
+#include "cc/output/context_provider.h"
+
+namespace blink { class WebGraphicsContext3D; }
+
+namespace webkit {
+namespace gpu {
+
+class ContextProviderWebContext : public cc::ContextProvider {
+ public:
+ virtual blink::WebGraphicsContext3D* WebContext3D() = 0;
+
+ protected:
+ virtual ~ContextProviderWebContext() {}
+};
+
+} // namespace gpu
+} // namespace webkit
+
+#endif // WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_WEB_CONTEXT_H_
diff --git a/chromium/webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc b/chromium/webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc
index 61f605cef8b..5c7bc39ec3a 100644
--- a/chromium/webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc
+++ b/chromium/webkit/common/gpu/grcontext_for_webgraphicscontext3d.cc
@@ -14,10 +14,8 @@ namespace gpu {
static void BindWebGraphicsContext3DGLContextCallback(
const GrGLInterface* interface) {
-#if GR_GL_PER_GL_FUNC_CALLBACK
reinterpret_cast<blink::WebGraphicsContext3D*>(
interface->fCallbackData)->makeContextCurrent();
-#endif
}
GrContextForWebGraphicsContext3D::GrContextForWebGraphicsContext3D(
@@ -30,46 +28,39 @@ GrContextForWebGraphicsContext3D::GrContextForWebGraphicsContext3D(
if (!interface)
return;
-#if GR_GL_PER_GL_FUNC_CALLBACK
interface->fCallback = BindWebGraphicsContext3DGLContextCallback;
interface->fCallbackData =
reinterpret_cast<GrGLInterfaceCallbackData>(context3d);
-#endif
gr_context_ = skia::AdoptRef(GrContext::Create(
kOpenGL_GrBackend,
reinterpret_cast<GrBackendContext>(interface.get())));
- if (!gr_context_)
- return;
+ if (gr_context_) {
+ // The limit of the number of textures we hold in the GrContext's
+ // bitmap->texture cache.
+ static const int kMaxGaneshTextureCacheCount = 2048;
+ // The limit of the bytes allocated toward textures in the GrContext's
+ // bitmap->texture cache.
+ static const size_t kMaxGaneshTextureCacheBytes = 96 * 1024 * 1024;
- bool nonzero_allocation = true;
- SetMemoryLimit(nonzero_allocation);
+ gr_context_->setTextureCacheLimits(kMaxGaneshTextureCacheCount,
+ kMaxGaneshTextureCacheBytes);
+ }
}
GrContextForWebGraphicsContext3D::~GrContextForWebGraphicsContext3D() {
+}
+
+void GrContextForWebGraphicsContext3D::OnLostContext() {
if (gr_context_)
gr_context_->contextDestroyed();
}
-void GrContextForWebGraphicsContext3D::SetMemoryLimit(bool nonzero_allocation) {
- if (!gr_context_)
- return;
-
- if (nonzero_allocation) {
- // The limit of the number of textures we hold in the GrContext's
- // bitmap->texture cache.
- static const int kMaxGaneshTextureCacheCount = 2048;
- // The limit of the bytes allocated toward textures in the GrContext's
- // bitmap->texture cache.
- static const size_t kMaxGaneshTextureCacheBytes = 96 * 1024 * 1024;
-
- gr_context_->setTextureCacheLimits(
- kMaxGaneshTextureCacheCount, kMaxGaneshTextureCacheBytes);
- } else {
+void GrContextForWebGraphicsContext3D::FreeGpuResources() {
+ if (gr_context_) {
TRACE_EVENT_INSTANT0("gpu", "GrContext::freeGpuResources", \
TRACE_EVENT_SCOPE_THREAD);
gr_context_->freeGpuResources();
- gr_context_->setTextureCacheLimits(0, 0);
}
}
diff --git a/chromium/webkit/common/gpu/grcontext_for_webgraphicscontext3d.h b/chromium/webkit/common/gpu/grcontext_for_webgraphicscontext3d.h
index 96bb41454f8..5c983aaebce 100644
--- a/chromium/webkit/common/gpu/grcontext_for_webgraphicscontext3d.h
+++ b/chromium/webkit/common/gpu/grcontext_for_webgraphicscontext3d.h
@@ -26,7 +26,8 @@ class WEBKIT_GPU_EXPORT GrContextForWebGraphicsContext3D {
GrContext* get() { return gr_context_.get(); }
- void SetMemoryLimit(bool nonzero_allocation);
+ void OnLostContext();
+ void FreeGpuResources();
private:
skia::RefPtr<class GrContext> gr_context_;
diff --git a/chromium/webkit/common/gpu/test_context_provider_factory.cc b/chromium/webkit/common/gpu/test_context_provider_factory.cc
deleted file mode 100644
index 7e4f04f949e..00000000000
--- a/chromium/webkit/common/gpu/test_context_provider_factory.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2013 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 "webkit/common/gpu/test_context_provider_factory.h"
-
-#include "base/logging.h"
-#include "cc/output/context_provider.h"
-#include "webkit/common/gpu/context_provider_in_process.h"
-
-namespace webkit {
-namespace gpu {
-
-static TestContextProviderFactory* context_provider_instance = NULL;
-
-// static
-TestContextProviderFactory* TestContextProviderFactory::GetInstance() {
- if (!context_provider_instance)
- context_provider_instance = new TestContextProviderFactory();
- return context_provider_instance;
-}
-
-TestContextProviderFactory::TestContextProviderFactory() {}
-
-TestContextProviderFactory::~TestContextProviderFactory() {}
-
-scoped_refptr<cc::ContextProvider> TestContextProviderFactory::
- OffscreenContextProviderForMainThread() {
- if (!main_thread_.get() || main_thread_->DestroyedOnMainThread()) {
- main_thread_ = ContextProviderInProcess::CreateOffscreen();
- if (main_thread_.get() && !main_thread_->BindToCurrentThread())
- main_thread_ = NULL;
- }
- return main_thread_;
-}
-
-} // namespace gpu
-} // namespace webkit
diff --git a/chromium/webkit/common/gpu/test_context_provider_factory.h b/chromium/webkit/common/gpu/test_context_provider_factory.h
deleted file mode 100644
index 52bec774d89..00000000000
--- a/chromium/webkit/common/gpu/test_context_provider_factory.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2013 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 WEBKIT_COMMON_GPU_TEST_CONTEXT_PROVIDER_FACTORY_H_
-#define WEBKIT_COMMON_GPU_TEST_CONTEXT_PROVIDER_FACTORY_H_
-
-#include "base/memory/ref_counted.h"
-#include "webkit/common/gpu/webkit_gpu_export.h"
-
-namespace cc {
-class ContextProvider;
-}
-
-namespace webkit {
-namespace gpu {
-class ContextProviderInProcess;
-
-class WEBKIT_GPU_EXPORT TestContextProviderFactory {
- public:
- // The returned pointer is static and should not be deleted by the caller.
- static TestContextProviderFactory* GetInstance();
-
- scoped_refptr<cc::ContextProvider> OffscreenContextProviderForMainThread();
-
- private:
- TestContextProviderFactory();
- ~TestContextProviderFactory();
-
- scoped_refptr<webkit::gpu::ContextProviderInProcess> main_thread_;
-
- DISALLOW_COPY_AND_ASSIGN(TestContextProviderFactory);
-};
-
-} // namespace gpu
-} // namespace webkit
-
-#endif // WEBKIT_COMMON_GPU_TEST_CONTEXT_PROVIDER_FACTORY_H_
diff --git a/chromium/webkit/common/gpu/webgraphicscontext3d_impl.cc b/chromium/webkit/common/gpu/webgraphicscontext3d_impl.cc
new file mode 100644
index 00000000000..86df14a7973
--- /dev/null
+++ b/chromium/webkit/common/gpu/webgraphicscontext3d_impl.cc
@@ -0,0 +1,984 @@
+// 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 "webkit/common/gpu/webgraphicscontext3d_impl.h"
+
+#include "base/atomicops.h"
+#include "base/lazy_instance.h"
+#include "base/logging.h"
+#include "gpu/GLES2/gl2extchromium.h"
+#include "gpu/command_buffer/client/gles2_implementation.h"
+#include "gpu/command_buffer/client/gles2_lib.h"
+#include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h"
+
+#include "third_party/khronos/GLES2/gl2.h"
+#ifndef GL_GLEXT_PROTOTYPES
+#define GL_GLEXT_PROTOTYPES 1
+#endif
+#include "third_party/khronos/GLES2/gl2ext.h"
+
+namespace webkit {
+namespace gpu {
+
+namespace {
+
+uint32_t GenFlushID() {
+ static base::subtle::Atomic32 flush_id = 0;
+
+ base::subtle::Atomic32 my_id = base::subtle::Barrier_AtomicIncrement(
+ &flush_id, 1);
+ return static_cast<uint32_t>(my_id);
+}
+
+} // namespace anonymous
+
+class WebGraphicsContext3DErrorMessageCallback
+ : public ::gpu::gles2::GLES2ImplementationErrorMessageCallback {
+ public:
+ WebGraphicsContext3DErrorMessageCallback(
+ WebGraphicsContext3DImpl* context)
+ : graphics_context_(context) {
+ }
+
+ virtual void OnErrorMessage(const char* msg, int id) OVERRIDE;
+
+ private:
+ WebGraphicsContext3DImpl* graphics_context_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebGraphicsContext3DErrorMessageCallback);
+};
+
+void WebGraphicsContext3DErrorMessageCallback::OnErrorMessage(
+ const char* msg, int id) {
+ graphics_context_->OnErrorMessage(msg, id);
+}
+
+// Helper macros to reduce the amount of code.
+
+#define DELEGATE_TO_GL(name, glname) \
+void WebGraphicsContext3DImpl::name() { \
+ gl_->glname(); \
+}
+
+#define DELEGATE_TO_GL_R(name, glname, rt) \
+rt WebGraphicsContext3DImpl::name() { \
+ return gl_->glname(); \
+}
+
+#define DELEGATE_TO_GL_1(name, glname, t1) \
+void WebGraphicsContext3DImpl::name(t1 a1) { \
+ gl_->glname(a1); \
+}
+
+#define DELEGATE_TO_GL_1R(name, glname, t1, rt) \
+rt WebGraphicsContext3DImpl::name(t1 a1) { \
+ return gl_->glname(a1); \
+}
+
+#define DELEGATE_TO_GL_1RB(name, glname, t1, rt) \
+rt WebGraphicsContext3DImpl::name(t1 a1) { \
+ return gl_->glname(a1) ? true : false; \
+}
+
+#define DELEGATE_TO_GL_2(name, glname, t1, t2) \
+void WebGraphicsContext3DImpl::name(t1 a1, t2 a2) { \
+ gl_->glname(a1, a2); \
+}
+
+#define DELEGATE_TO_GL_2R(name, glname, t1, t2, rt) \
+rt WebGraphicsContext3DImpl::name(t1 a1, t2 a2) { \
+ return gl_->glname(a1, a2); \
+}
+
+#define DELEGATE_TO_GL_3(name, glname, t1, t2, t3) \
+void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3) { \
+ gl_->glname(a1, a2, a3); \
+}
+
+#define DELEGATE_TO_GL_3R(name, glname, t1, t2, t3, rt) \
+rt WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3) { \
+ return gl_->glname(a1, a2, a3); \
+}
+
+#define DELEGATE_TO_GL_4(name, glname, t1, t2, t3, t4) \
+void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4) { \
+ gl_->glname(a1, a2, a3, a4); \
+}
+
+#define DELEGATE_TO_GL_4R(name, glname, t1, t2, t3, t4, rt) \
+rt WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4) { \
+ return gl_->glname(a1, a2, a3, a4); \
+}
+
+#define DELEGATE_TO_GL_5(name, glname, t1, t2, t3, t4, t5) \
+void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) {\
+ \
+ gl_->glname(a1, a2, a3, a4, a5); \
+}
+
+#define DELEGATE_TO_GL_6(name, glname, t1, t2, t3, t4, t5, t6) \
+void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
+ t6 a6) { \
+ gl_->glname(a1, a2, a3, a4, a5, a6); \
+}
+
+#define DELEGATE_TO_GL_7(name, glname, t1, t2, t3, t4, t5, t6, t7) \
+void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
+ t6 a6, t7 a7) { \
+ gl_->glname(a1, a2, a3, a4, a5, a6, a7); \
+}
+
+#define DELEGATE_TO_GL_8(name, glname, t1, t2, t3, t4, t5, t6, t7, t8) \
+void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
+ t6 a6, t7 a7, t8 a8) { \
+ gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8); \
+}
+
+#define DELEGATE_TO_GL_9(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, t9) \
+void WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
+ t6 a6, t7 a7, t8 a8, t9 a9) { \
+ gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
+}
+
+#define DELEGATE_TO_GL_9R(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, \
+ t9, rt) \
+rt WebGraphicsContext3DImpl::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, \
+ t6 a6, t7 a7, t8 a8, t9 a9) { \
+ return gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
+}
+
+WebGraphicsContext3DImpl::WebGraphicsContext3DImpl()
+ : initialized_(false),
+ initialize_failed_(false),
+ context_lost_callback_(0),
+ context_lost_reason_(GL_NO_ERROR),
+ error_message_callback_(0),
+ gl_(NULL),
+ flush_id_(0) {
+}
+
+WebGraphicsContext3DImpl::~WebGraphicsContext3DImpl() {
+
+}
+
+void WebGraphicsContext3DImpl::synthesizeGLError(WGC3Denum error) {
+ if (std::find(synthetic_errors_.begin(), synthetic_errors_.end(), error) ==
+ synthetic_errors_.end()) {
+ synthetic_errors_.push_back(error);
+ }
+}
+
+uint32_t WebGraphicsContext3DImpl::lastFlushID() {
+ return flush_id_;
+}
+
+DELEGATE_TO_GL_R(insertSyncPoint, InsertSyncPointCHROMIUM, unsigned int)
+
+DELEGATE_TO_GL_3(reshapeWithScaleFactor, ResizeCHROMIUM, int, int, float)
+
+DELEGATE_TO_GL_4R(mapBufferSubDataCHROMIUM, MapBufferSubDataCHROMIUM, WGC3Denum,
+ WGC3Dintptr, WGC3Dsizeiptr, WGC3Denum, void*)
+
+DELEGATE_TO_GL_1(unmapBufferSubDataCHROMIUM, UnmapBufferSubDataCHROMIUM,
+ const void*)
+
+DELEGATE_TO_GL_9R(mapTexSubImage2DCHROMIUM, MapTexSubImage2DCHROMIUM, WGC3Denum,
+ WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei,
+ WGC3Denum, WGC3Denum, WGC3Denum, void*)
+
+DELEGATE_TO_GL_1(unmapTexSubImage2DCHROMIUM, UnmapTexSubImage2DCHROMIUM,
+ const void*)
+
+DELEGATE_TO_GL_3(discardFramebufferEXT, DiscardFramebufferEXT, WGC3Denum,
+ WGC3Dsizei, const WGC3Denum*)
+
+blink::WebString WebGraphicsContext3DImpl::
+ getRequestableExtensionsCHROMIUM() {
+ return blink::WebString::fromUTF8(
+ gl_->GetRequestableExtensionsCHROMIUM());
+}
+
+DELEGATE_TO_GL_1(requestExtensionCHROMIUM, RequestExtensionCHROMIUM,
+ const char*)
+
+void WebGraphicsContext3DImpl::blitFramebufferCHROMIUM(
+ WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1,
+ WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1,
+ WGC3Dbitfield mask, WGC3Denum filter) {
+ gl_->BlitFramebufferCHROMIUM(
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, filter);
+}
+
+DELEGATE_TO_GL_5(renderbufferStorageMultisampleCHROMIUM,
+ RenderbufferStorageMultisampleCHROMIUM, WGC3Denum, WGC3Dsizei,
+ WGC3Denum, WGC3Dsizei, WGC3Dsizei)
+
+DELEGATE_TO_GL_1(activeTexture, ActiveTexture, WGC3Denum)
+
+DELEGATE_TO_GL_2(attachShader, AttachShader, WebGLId, WebGLId)
+
+DELEGATE_TO_GL_3(bindAttribLocation, BindAttribLocation, WebGLId,
+ WGC3Duint, const WGC3Dchar*)
+
+DELEGATE_TO_GL_2(bindBuffer, BindBuffer, WGC3Denum, WebGLId)
+
+DELEGATE_TO_GL_2(bindFramebuffer, BindFramebuffer, WGC3Denum, WebGLId)
+
+DELEGATE_TO_GL_2(bindRenderbuffer, BindRenderbuffer, WGC3Denum, WebGLId)
+
+DELEGATE_TO_GL_2(bindTexture, BindTexture, WGC3Denum, WebGLId)
+
+DELEGATE_TO_GL_4(blendColor, BlendColor,
+ WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf)
+
+DELEGATE_TO_GL_1(blendEquation, BlendEquation, WGC3Denum)
+
+DELEGATE_TO_GL_2(blendEquationSeparate, BlendEquationSeparate,
+ WGC3Denum, WGC3Denum)
+
+DELEGATE_TO_GL_2(blendFunc, BlendFunc, WGC3Denum, WGC3Denum)
+
+DELEGATE_TO_GL_4(blendFuncSeparate, BlendFuncSeparate,
+ WGC3Denum, WGC3Denum, WGC3Denum, WGC3Denum)
+
+DELEGATE_TO_GL_4(bufferData, BufferData,
+ WGC3Denum, WGC3Dsizeiptr, const void*, WGC3Denum)
+
+DELEGATE_TO_GL_4(bufferSubData, BufferSubData,
+ WGC3Denum, WGC3Dintptr, WGC3Dsizeiptr, const void*)
+
+DELEGATE_TO_GL_1R(checkFramebufferStatus, CheckFramebufferStatus,
+ WGC3Denum, WGC3Denum)
+
+DELEGATE_TO_GL_1(clear, Clear, WGC3Dbitfield)
+
+DELEGATE_TO_GL_4(clearColor, ClearColor,
+ WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf)
+
+DELEGATE_TO_GL_1(clearDepth, ClearDepthf, WGC3Dclampf)
+
+DELEGATE_TO_GL_1(clearStencil, ClearStencil, WGC3Dint)
+
+DELEGATE_TO_GL_4(colorMask, ColorMask,
+ WGC3Dboolean, WGC3Dboolean, WGC3Dboolean, WGC3Dboolean)
+
+DELEGATE_TO_GL_1(compileShader, CompileShader, WebGLId)
+
+DELEGATE_TO_GL_8(compressedTexImage2D, CompressedTexImage2D,
+ WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dint, WGC3Dint,
+ WGC3Dsizei, WGC3Dsizei, const void*)
+
+DELEGATE_TO_GL_9(compressedTexSubImage2D, CompressedTexSubImage2D,
+ WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint,
+ WGC3Denum, WGC3Dsizei, const void*)
+
+DELEGATE_TO_GL_8(copyTexImage2D, CopyTexImage2D,
+ WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dint, WGC3Dint,
+ WGC3Dsizei, WGC3Dsizei, WGC3Dint)
+
+DELEGATE_TO_GL_8(copyTexSubImage2D, CopyTexSubImage2D,
+ WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint,
+ WGC3Dsizei, WGC3Dsizei)
+
+DELEGATE_TO_GL_1(cullFace, CullFace, WGC3Denum)
+
+DELEGATE_TO_GL_1(depthFunc, DepthFunc, WGC3Denum)
+
+DELEGATE_TO_GL_1(depthMask, DepthMask, WGC3Dboolean)
+
+DELEGATE_TO_GL_2(depthRange, DepthRangef, WGC3Dclampf, WGC3Dclampf)
+
+DELEGATE_TO_GL_2(detachShader, DetachShader, WebGLId, WebGLId)
+
+DELEGATE_TO_GL_1(disable, Disable, WGC3Denum)
+
+DELEGATE_TO_GL_1(disableVertexAttribArray, DisableVertexAttribArray,
+ WGC3Duint)
+
+DELEGATE_TO_GL_3(drawArrays, DrawArrays, WGC3Denum, WGC3Dint, WGC3Dsizei)
+
+void WebGraphicsContext3DImpl::drawElements(WGC3Denum mode,
+ WGC3Dsizei count,
+ WGC3Denum type,
+ WGC3Dintptr offset) {
+ gl_->DrawElements(
+ mode, count, type,
+ reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
+}
+
+DELEGATE_TO_GL_1(enable, Enable, WGC3Denum)
+
+DELEGATE_TO_GL_1(enableVertexAttribArray, EnableVertexAttribArray,
+ WGC3Duint)
+
+void WebGraphicsContext3DImpl::finish() {
+ flush_id_ = GenFlushID();
+ gl_->Finish();
+}
+
+void WebGraphicsContext3DImpl::flush() {
+ flush_id_ = GenFlushID();
+ gl_->Flush();
+}
+
+DELEGATE_TO_GL_4(framebufferRenderbuffer, FramebufferRenderbuffer,
+ WGC3Denum, WGC3Denum, WGC3Denum, WebGLId)
+
+DELEGATE_TO_GL_5(framebufferTexture2D, FramebufferTexture2D,
+ WGC3Denum, WGC3Denum, WGC3Denum, WebGLId, WGC3Dint)
+
+DELEGATE_TO_GL_1(frontFace, FrontFace, WGC3Denum)
+
+DELEGATE_TO_GL_1(generateMipmap, GenerateMipmap, WGC3Denum)
+
+bool WebGraphicsContext3DImpl::getActiveAttrib(
+ WebGLId program, WGC3Duint index, ActiveInfo& info) {
+ if (!program) {
+ synthesizeGLError(GL_INVALID_VALUE);
+ return false;
+ }
+ GLint max_name_length = -1;
+ gl_->GetProgramiv(
+ program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_name_length);
+ if (max_name_length < 0)
+ return false;
+ scoped_ptr<GLchar[]> name(new GLchar[max_name_length]);
+ if (!name) {
+ synthesizeGLError(GL_OUT_OF_MEMORY);
+ return false;
+ }
+ GLsizei length = 0;
+ GLint size = -1;
+ GLenum type = 0;
+ gl_->GetActiveAttrib(
+ program, index, max_name_length, &length, &size, &type, name.get());
+ if (size < 0) {
+ return false;
+ }
+ info.name = blink::WebString::fromUTF8(name.get(), length);
+ info.type = type;
+ info.size = size;
+ return true;
+}
+
+bool WebGraphicsContext3DImpl::getActiveUniform(
+ WebGLId program, WGC3Duint index, ActiveInfo& info) {
+ GLint max_name_length = -1;
+ gl_->GetProgramiv(
+ program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_name_length);
+ if (max_name_length < 0)
+ return false;
+ scoped_ptr<GLchar[]> name(new GLchar[max_name_length]);
+ if (!name) {
+ synthesizeGLError(GL_OUT_OF_MEMORY);
+ return false;
+ }
+ GLsizei length = 0;
+ GLint size = -1;
+ GLenum type = 0;
+ gl_->GetActiveUniform(
+ program, index, max_name_length, &length, &size, &type, name.get());
+ if (size < 0) {
+ return false;
+ }
+ info.name = blink::WebString::fromUTF8(name.get(), length);
+ info.type = type;
+ info.size = size;
+ return true;
+}
+
+DELEGATE_TO_GL_4(getAttachedShaders, GetAttachedShaders,
+ WebGLId, WGC3Dsizei, WGC3Dsizei*, WebGLId*)
+
+DELEGATE_TO_GL_2R(getAttribLocation, GetAttribLocation,
+ WebGLId, const WGC3Dchar*, WGC3Dint)
+
+DELEGATE_TO_GL_2(getBooleanv, GetBooleanv, WGC3Denum, WGC3Dboolean*)
+
+DELEGATE_TO_GL_3(getBufferParameteriv, GetBufferParameteriv,
+ WGC3Denum, WGC3Denum, WGC3Dint*)
+
+WGC3Denum WebGraphicsContext3DImpl::getError() {
+ if (!synthetic_errors_.empty()) {
+ std::vector<WGC3Denum>::iterator iter = synthetic_errors_.begin();
+ WGC3Denum err = *iter;
+ synthetic_errors_.erase(iter);
+ return err;
+ }
+
+ return gl_->GetError();
+}
+
+DELEGATE_TO_GL_2(getFloatv, GetFloatv, WGC3Denum, WGC3Dfloat*)
+
+DELEGATE_TO_GL_4(getFramebufferAttachmentParameteriv,
+ GetFramebufferAttachmentParameteriv,
+ WGC3Denum, WGC3Denum, WGC3Denum, WGC3Dint*)
+
+DELEGATE_TO_GL_2(getIntegerv, GetIntegerv, WGC3Denum, WGC3Dint*)
+
+DELEGATE_TO_GL_3(getProgramiv, GetProgramiv, WebGLId, WGC3Denum, WGC3Dint*)
+
+blink::WebString WebGraphicsContext3DImpl::getProgramInfoLog(
+ WebGLId program) {
+ GLint logLength = 0;
+ gl_->GetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength);
+ if (!logLength)
+ return blink::WebString();
+ scoped_ptr<GLchar[]> log(new GLchar[logLength]);
+ if (!log)
+ return blink::WebString();
+ GLsizei returnedLogLength = 0;
+ gl_->GetProgramInfoLog(
+ program, logLength, &returnedLogLength, log.get());
+ DCHECK_EQ(logLength, returnedLogLength + 1);
+ blink::WebString res =
+ blink::WebString::fromUTF8(log.get(), returnedLogLength);
+ return res;
+}
+
+DELEGATE_TO_GL_3(getRenderbufferParameteriv, GetRenderbufferParameteriv,
+ WGC3Denum, WGC3Denum, WGC3Dint*)
+
+DELEGATE_TO_GL_3(getShaderiv, GetShaderiv, WebGLId, WGC3Denum, WGC3Dint*)
+
+blink::WebString WebGraphicsContext3DImpl::getShaderInfoLog(
+ WebGLId shader) {
+ GLint logLength = 0;
+ gl_->GetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength);
+ if (!logLength)
+ return blink::WebString();
+ scoped_ptr<GLchar[]> log(new GLchar[logLength]);
+ if (!log)
+ return blink::WebString();
+ GLsizei returnedLogLength = 0;
+ gl_->GetShaderInfoLog(
+ shader, logLength, &returnedLogLength, log.get());
+ DCHECK_EQ(logLength, returnedLogLength + 1);
+ blink::WebString res =
+ blink::WebString::fromUTF8(log.get(), returnedLogLength);
+ return res;
+}
+
+DELEGATE_TO_GL_4(getShaderPrecisionFormat, GetShaderPrecisionFormat,
+ WGC3Denum, WGC3Denum, WGC3Dint*, WGC3Dint*)
+
+blink::WebString WebGraphicsContext3DImpl::getShaderSource(
+ WebGLId shader) {
+ GLint logLength = 0;
+ gl_->GetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &logLength);
+ if (!logLength)
+ return blink::WebString();
+ scoped_ptr<GLchar[]> log(new GLchar[logLength]);
+ if (!log)
+ return blink::WebString();
+ GLsizei returnedLogLength = 0;
+ gl_->GetShaderSource(
+ shader, logLength, &returnedLogLength, log.get());
+ if (!returnedLogLength)
+ return blink::WebString();
+ DCHECK_EQ(logLength, returnedLogLength + 1);
+ blink::WebString res =
+ blink::WebString::fromUTF8(log.get(), returnedLogLength);
+ return res;
+}
+
+blink::WebString WebGraphicsContext3DImpl::
+ getTranslatedShaderSourceANGLE(WebGLId shader) {
+ GLint logLength = 0;
+ gl_->GetShaderiv(
+ shader, GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE, &logLength);
+ if (!logLength)
+ return blink::WebString();
+ scoped_ptr<GLchar[]> log(new GLchar[logLength]);
+ if (!log)
+ return blink::WebString();
+ GLsizei returnedLogLength = 0;
+ gl_->GetTranslatedShaderSourceANGLE(
+ shader, logLength, &returnedLogLength, log.get());
+ if (!returnedLogLength)
+ return blink::WebString();
+ DCHECK_EQ(logLength, returnedLogLength + 1);
+ blink::WebString res =
+ blink::WebString::fromUTF8(log.get(), returnedLogLength);
+ return res;
+}
+
+blink::WebString WebGraphicsContext3DImpl::getString(
+ WGC3Denum name) {
+ return blink::WebString::fromUTF8(
+ reinterpret_cast<const char*>(gl_->GetString(name)));
+}
+
+DELEGATE_TO_GL_3(getTexParameterfv, GetTexParameterfv,
+ WGC3Denum, WGC3Denum, WGC3Dfloat*)
+
+DELEGATE_TO_GL_3(getTexParameteriv, GetTexParameteriv,
+ WGC3Denum, WGC3Denum, WGC3Dint*)
+
+DELEGATE_TO_GL_3(getUniformfv, GetUniformfv, WebGLId, WGC3Dint, WGC3Dfloat*)
+
+DELEGATE_TO_GL_3(getUniformiv, GetUniformiv, WebGLId, WGC3Dint, WGC3Dint*)
+
+DELEGATE_TO_GL_2R(getUniformLocation, GetUniformLocation,
+ WebGLId, const WGC3Dchar*, WGC3Dint)
+
+DELEGATE_TO_GL_3(getVertexAttribfv, GetVertexAttribfv,
+ WGC3Duint, WGC3Denum, WGC3Dfloat*)
+
+DELEGATE_TO_GL_3(getVertexAttribiv, GetVertexAttribiv,
+ WGC3Duint, WGC3Denum, WGC3Dint*)
+
+WGC3Dsizeiptr WebGraphicsContext3DImpl::getVertexAttribOffset(
+ WGC3Duint index, WGC3Denum pname) {
+ GLvoid* value = NULL;
+ // NOTE: If pname is ever a value that returns more then 1 element
+ // this will corrupt memory.
+ gl_->GetVertexAttribPointerv(index, pname, &value);
+ return static_cast<WGC3Dsizeiptr>(reinterpret_cast<intptr_t>(value));
+}
+
+DELEGATE_TO_GL_2(hint, Hint, WGC3Denum, WGC3Denum)
+
+DELEGATE_TO_GL_1RB(isBuffer, IsBuffer, WebGLId, WGC3Dboolean)
+
+DELEGATE_TO_GL_1RB(isEnabled, IsEnabled, WGC3Denum, WGC3Dboolean)
+
+DELEGATE_TO_GL_1RB(isFramebuffer, IsFramebuffer, WebGLId, WGC3Dboolean)
+
+DELEGATE_TO_GL_1RB(isProgram, IsProgram, WebGLId, WGC3Dboolean)
+
+DELEGATE_TO_GL_1RB(isRenderbuffer, IsRenderbuffer, WebGLId, WGC3Dboolean)
+
+DELEGATE_TO_GL_1RB(isShader, IsShader, WebGLId, WGC3Dboolean)
+
+DELEGATE_TO_GL_1RB(isTexture, IsTexture, WebGLId, WGC3Dboolean)
+
+DELEGATE_TO_GL_1(lineWidth, LineWidth, WGC3Dfloat)
+
+DELEGATE_TO_GL_1(linkProgram, LinkProgram, WebGLId)
+
+DELEGATE_TO_GL_2(pixelStorei, PixelStorei, WGC3Denum, WGC3Dint)
+
+DELEGATE_TO_GL_2(polygonOffset, PolygonOffset, WGC3Dfloat, WGC3Dfloat)
+
+DELEGATE_TO_GL_7(readPixels, ReadPixels,
+ WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei, WGC3Denum,
+ WGC3Denum, void*)
+
+DELEGATE_TO_GL_4(renderbufferStorage, RenderbufferStorage,
+ WGC3Denum, WGC3Denum, WGC3Dsizei, WGC3Dsizei)
+
+DELEGATE_TO_GL_2(sampleCoverage, SampleCoverage, WGC3Dfloat, WGC3Dboolean)
+
+DELEGATE_TO_GL_4(scissor, Scissor, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei)
+
+void WebGraphicsContext3DImpl::shaderSource(
+ WebGLId shader, const WGC3Dchar* string) {
+ GLint length = strlen(string);
+ gl_->ShaderSource(shader, 1, &string, &length);
+}
+
+DELEGATE_TO_GL_3(stencilFunc, StencilFunc, WGC3Denum, WGC3Dint, WGC3Duint)
+
+DELEGATE_TO_GL_4(stencilFuncSeparate, StencilFuncSeparate,
+ WGC3Denum, WGC3Denum, WGC3Dint, WGC3Duint)
+
+DELEGATE_TO_GL_1(stencilMask, StencilMask, WGC3Duint)
+
+DELEGATE_TO_GL_2(stencilMaskSeparate, StencilMaskSeparate,
+ WGC3Denum, WGC3Duint)
+
+DELEGATE_TO_GL_3(stencilOp, StencilOp,
+ WGC3Denum, WGC3Denum, WGC3Denum)
+
+DELEGATE_TO_GL_4(stencilOpSeparate, StencilOpSeparate,
+ WGC3Denum, WGC3Denum, WGC3Denum, WGC3Denum)
+
+DELEGATE_TO_GL_9(texImage2D, TexImage2D,
+ WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei,
+ WGC3Dint, WGC3Denum, WGC3Denum, const void*)
+
+DELEGATE_TO_GL_3(texParameterf, TexParameterf,
+ WGC3Denum, WGC3Denum, WGC3Dfloat);
+
+static const unsigned int kTextureWrapR = 0x8072;
+
+void WebGraphicsContext3DImpl::texParameteri(
+ WGC3Denum target, WGC3Denum pname, WGC3Dint param) {
+ // TODO(kbr): figure out whether the setting of TEXTURE_WRAP_R in
+ // GraphicsContext3D.cpp is strictly necessary to avoid seams at the
+ // edge of cube maps, and, if it is, push it into the GLES2 service
+ // side code.
+ if (pname == kTextureWrapR) {
+ return;
+ }
+ gl_->TexParameteri(target, pname, param);
+}
+
+DELEGATE_TO_GL_9(texSubImage2D, TexSubImage2D,
+ WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei,
+ WGC3Dsizei, WGC3Denum, WGC3Denum, const void*)
+
+DELEGATE_TO_GL_2(uniform1f, Uniform1f, WGC3Dint, WGC3Dfloat)
+
+DELEGATE_TO_GL_3(uniform1fv, Uniform1fv, WGC3Dint, WGC3Dsizei,
+ const WGC3Dfloat*)
+
+DELEGATE_TO_GL_2(uniform1i, Uniform1i, WGC3Dint, WGC3Dint)
+
+DELEGATE_TO_GL_3(uniform1iv, Uniform1iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
+
+DELEGATE_TO_GL_3(uniform2f, Uniform2f, WGC3Dint, WGC3Dfloat, WGC3Dfloat)
+
+DELEGATE_TO_GL_3(uniform2fv, Uniform2fv, WGC3Dint, WGC3Dsizei,
+ const WGC3Dfloat*)
+
+DELEGATE_TO_GL_3(uniform2i, Uniform2i, WGC3Dint, WGC3Dint, WGC3Dint)
+
+DELEGATE_TO_GL_3(uniform2iv, Uniform2iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
+
+DELEGATE_TO_GL_4(uniform3f, Uniform3f, WGC3Dint,
+ WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
+
+DELEGATE_TO_GL_3(uniform3fv, Uniform3fv, WGC3Dint, WGC3Dsizei,
+ const WGC3Dfloat*)
+
+DELEGATE_TO_GL_4(uniform3i, Uniform3i, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint)
+
+DELEGATE_TO_GL_3(uniform3iv, Uniform3iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
+
+DELEGATE_TO_GL_5(uniform4f, Uniform4f, WGC3Dint,
+ WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
+
+DELEGATE_TO_GL_3(uniform4fv, Uniform4fv, WGC3Dint, WGC3Dsizei,
+ const WGC3Dfloat*)
+
+DELEGATE_TO_GL_5(uniform4i, Uniform4i, WGC3Dint,
+ WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint)
+
+DELEGATE_TO_GL_3(uniform4iv, Uniform4iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
+
+DELEGATE_TO_GL_4(uniformMatrix2fv, UniformMatrix2fv,
+ WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
+
+DELEGATE_TO_GL_4(uniformMatrix3fv, UniformMatrix3fv,
+ WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
+
+DELEGATE_TO_GL_4(uniformMatrix4fv, UniformMatrix4fv,
+ WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
+
+DELEGATE_TO_GL_1(useProgram, UseProgram, WebGLId)
+
+DELEGATE_TO_GL_1(validateProgram, ValidateProgram, WebGLId)
+
+DELEGATE_TO_GL_2(vertexAttrib1f, VertexAttrib1f, WGC3Duint, WGC3Dfloat)
+
+DELEGATE_TO_GL_2(vertexAttrib1fv, VertexAttrib1fv, WGC3Duint,
+ const WGC3Dfloat*)
+
+DELEGATE_TO_GL_3(vertexAttrib2f, VertexAttrib2f, WGC3Duint,
+ WGC3Dfloat, WGC3Dfloat)
+
+DELEGATE_TO_GL_2(vertexAttrib2fv, VertexAttrib2fv, WGC3Duint,
+ const WGC3Dfloat*)
+
+DELEGATE_TO_GL_4(vertexAttrib3f, VertexAttrib3f, WGC3Duint,
+ WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
+
+DELEGATE_TO_GL_2(vertexAttrib3fv, VertexAttrib3fv, WGC3Duint,
+ const WGC3Dfloat*)
+
+DELEGATE_TO_GL_5(vertexAttrib4f, VertexAttrib4f, WGC3Duint,
+ WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
+
+DELEGATE_TO_GL_2(vertexAttrib4fv, VertexAttrib4fv, WGC3Duint,
+ const WGC3Dfloat*)
+
+void WebGraphicsContext3DImpl::vertexAttribPointer(
+ WGC3Duint index, WGC3Dint size, WGC3Denum type, WGC3Dboolean normalized,
+ WGC3Dsizei stride, WGC3Dintptr offset) {
+ gl_->VertexAttribPointer(
+ index, size, type, normalized, stride,
+ reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
+}
+
+DELEGATE_TO_GL_4(viewport, Viewport,
+ WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei)
+
+DELEGATE_TO_GL_2(genBuffers, GenBuffers, WGC3Dsizei, WebGLId*);
+
+DELEGATE_TO_GL_2(genFramebuffers, GenFramebuffers, WGC3Dsizei, WebGLId*);
+
+DELEGATE_TO_GL_2(genRenderbuffers, GenRenderbuffers, WGC3Dsizei, WebGLId*);
+
+DELEGATE_TO_GL_2(genTextures, GenTextures, WGC3Dsizei, WebGLId*);
+
+DELEGATE_TO_GL_2(deleteBuffers, DeleteBuffers, WGC3Dsizei, WebGLId*);
+
+DELEGATE_TO_GL_2(deleteFramebuffers, DeleteFramebuffers, WGC3Dsizei, WebGLId*);
+
+DELEGATE_TO_GL_2(deleteRenderbuffers, DeleteRenderbuffers, WGC3Dsizei,
+ WebGLId*);
+
+DELEGATE_TO_GL_2(deleteTextures, DeleteTextures, WGC3Dsizei, WebGLId*);
+
+WebGLId WebGraphicsContext3DImpl::createBuffer() {
+ GLuint o;
+ gl_->GenBuffers(1, &o);
+ return o;
+}
+
+WebGLId WebGraphicsContext3DImpl::createFramebuffer() {
+ GLuint o = 0;
+ gl_->GenFramebuffers(1, &o);
+ return o;
+}
+
+WebGLId WebGraphicsContext3DImpl::createRenderbuffer() {
+ GLuint o;
+ gl_->GenRenderbuffers(1, &o);
+ return o;
+}
+
+WebGLId WebGraphicsContext3DImpl::createTexture() {
+ GLuint o;
+ gl_->GenTextures(1, &o);
+ return o;
+}
+
+void WebGraphicsContext3DImpl::deleteBuffer(WebGLId buffer) {
+ gl_->DeleteBuffers(1, &buffer);
+}
+
+void WebGraphicsContext3DImpl::deleteFramebuffer(
+ WebGLId framebuffer) {
+ gl_->DeleteFramebuffers(1, &framebuffer);
+}
+
+void WebGraphicsContext3DImpl::deleteRenderbuffer(
+ WebGLId renderbuffer) {
+ gl_->DeleteRenderbuffers(1, &renderbuffer);
+}
+
+void WebGraphicsContext3DImpl::deleteTexture(WebGLId texture) {
+ gl_->DeleteTextures(1, &texture);
+}
+
+DELEGATE_TO_GL_R(createProgram, CreateProgram, WebGLId)
+
+DELEGATE_TO_GL_1R(createShader, CreateShader, WGC3Denum, WebGLId)
+
+DELEGATE_TO_GL_1(deleteProgram, DeleteProgram, WebGLId)
+
+DELEGATE_TO_GL_1(deleteShader, DeleteShader, WebGLId)
+
+void WebGraphicsContext3DImpl::setErrorMessageCallback(
+ WebGraphicsContext3D::WebGraphicsErrorMessageCallback* cb) {
+ error_message_callback_ = cb;
+}
+
+void WebGraphicsContext3DImpl::setContextLostCallback(
+ WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) {
+ context_lost_callback_ = cb;
+}
+
+DELEGATE_TO_GL_5(texImageIOSurface2DCHROMIUM, TexImageIOSurface2DCHROMIUM,
+ WGC3Denum, WGC3Dint, WGC3Dint, WGC3Duint, WGC3Duint)
+
+DELEGATE_TO_GL_5(texStorage2DEXT, TexStorage2DEXT,
+ WGC3Denum, WGC3Dint, WGC3Duint, WGC3Dint, WGC3Dint)
+
+WebGLId WebGraphicsContext3DImpl::createQueryEXT() {
+ GLuint o;
+ gl_->GenQueriesEXT(1, &o);
+ return o;
+}
+
+void WebGraphicsContext3DImpl::deleteQueryEXT(
+ WebGLId query) {
+ gl_->DeleteQueriesEXT(1, &query);
+}
+
+DELEGATE_TO_GL_1R(isQueryEXT, IsQueryEXT, WebGLId, WGC3Dboolean)
+DELEGATE_TO_GL_2(beginQueryEXT, BeginQueryEXT, WGC3Denum, WebGLId)
+DELEGATE_TO_GL_1(endQueryEXT, EndQueryEXT, WGC3Denum)
+DELEGATE_TO_GL_3(getQueryivEXT, GetQueryivEXT, WGC3Denum, WGC3Denum, WGC3Dint*)
+DELEGATE_TO_GL_3(getQueryObjectuivEXT, GetQueryObjectuivEXT,
+ WebGLId, WGC3Denum, WGC3Duint*)
+
+DELEGATE_TO_GL_6(copyTextureCHROMIUM, CopyTextureCHROMIUM, WGC3Denum,
+ WebGLId, WebGLId, WGC3Dint, WGC3Denum, WGC3Denum);
+
+DELEGATE_TO_GL_3(bindUniformLocationCHROMIUM, BindUniformLocationCHROMIUM,
+ WebGLId, WGC3Dint, const WGC3Dchar*)
+
+void WebGraphicsContext3DImpl::shallowFlushCHROMIUM() {
+ flush_id_ = GenFlushID();
+ gl_->ShallowFlushCHROMIUM();
+}
+
+void WebGraphicsContext3DImpl::shallowFinishCHROMIUM() {
+ flush_id_ = GenFlushID();
+ gl_->ShallowFinishCHROMIUM();
+}
+
+DELEGATE_TO_GL_1(waitSyncPoint, WaitSyncPointCHROMIUM, GLuint)
+
+void WebGraphicsContext3DImpl::loseContextCHROMIUM(
+ WGC3Denum current, WGC3Denum other) {
+ gl_->LoseContextCHROMIUM(current, other);
+ gl_->Flush();
+}
+
+DELEGATE_TO_GL_1(genMailboxCHROMIUM, GenMailboxCHROMIUM, WGC3Dbyte*)
+DELEGATE_TO_GL_2(produceTextureCHROMIUM, ProduceTextureCHROMIUM,
+ WGC3Denum, const WGC3Dbyte*)
+DELEGATE_TO_GL_3(produceTextureDirectCHROMIUM, ProduceTextureDirectCHROMIUM,
+ WebGLId, WGC3Denum, const WGC3Dbyte*)
+DELEGATE_TO_GL_2(consumeTextureCHROMIUM, ConsumeTextureCHROMIUM,
+ WGC3Denum, const WGC3Dbyte*)
+DELEGATE_TO_GL_2R(createAndConsumeTextureCHROMIUM,
+ CreateAndConsumeTextureCHROMIUM,
+ WGC3Denum, const WGC3Dbyte*, WebGLId)
+
+void WebGraphicsContext3DImpl::insertEventMarkerEXT(
+ const WGC3Dchar* marker) {
+ gl_->InsertEventMarkerEXT(0, marker);
+}
+
+void WebGraphicsContext3DImpl::pushGroupMarkerEXT(
+ const WGC3Dchar* marker) {
+ gl_->PushGroupMarkerEXT(0, marker);
+}
+
+DELEGATE_TO_GL(popGroupMarkerEXT, PopGroupMarkerEXT);
+
+WebGLId WebGraphicsContext3DImpl::createVertexArrayOES() {
+ GLuint array;
+ gl_->GenVertexArraysOES(1, &array);
+ return array;
+}
+
+void WebGraphicsContext3DImpl::deleteVertexArrayOES(
+ WebGLId array) {
+ gl_->DeleteVertexArraysOES(1, &array);
+}
+
+DELEGATE_TO_GL_1R(isVertexArrayOES, IsVertexArrayOES, WebGLId, WGC3Dboolean)
+DELEGATE_TO_GL_1(bindVertexArrayOES, BindVertexArrayOES, WebGLId)
+
+DELEGATE_TO_GL_2(bindTexImage2DCHROMIUM, BindTexImage2DCHROMIUM,
+ WGC3Denum, WGC3Dint)
+DELEGATE_TO_GL_2(releaseTexImage2DCHROMIUM, ReleaseTexImage2DCHROMIUM,
+ WGC3Denum, WGC3Dint)
+
+DELEGATE_TO_GL_2R(mapBufferCHROMIUM, MapBufferCHROMIUM, WGC3Denum, WGC3Denum,
+ void*)
+DELEGATE_TO_GL_1R(unmapBufferCHROMIUM, UnmapBufferCHROMIUM, WGC3Denum,
+ WGC3Dboolean)
+
+DELEGATE_TO_GL_9(asyncTexImage2DCHROMIUM, AsyncTexImage2DCHROMIUM, WGC3Denum,
+ WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei, WGC3Dint,
+ WGC3Denum, WGC3Denum, const void*)
+DELEGATE_TO_GL_9(asyncTexSubImage2DCHROMIUM, AsyncTexSubImage2DCHROMIUM,
+ WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei,
+ WGC3Dsizei, WGC3Denum, WGC3Denum, const void*)
+
+DELEGATE_TO_GL_1(waitAsyncTexImage2DCHROMIUM, WaitAsyncTexImage2DCHROMIUM,
+ WGC3Denum)
+
+DELEGATE_TO_GL_2(drawBuffersEXT, DrawBuffersEXT, WGC3Dsizei, const WGC3Denum*)
+
+DELEGATE_TO_GL_4(drawArraysInstancedANGLE, DrawArraysInstancedANGLE, WGC3Denum,
+ WGC3Dint, WGC3Dsizei, WGC3Dsizei)
+
+void WebGraphicsContext3DImpl::drawElementsInstancedANGLE(
+ WGC3Denum mode,
+ WGC3Dsizei count,
+ WGC3Denum type,
+ WGC3Dintptr offset,
+ WGC3Dsizei primcount) {
+ gl_->DrawElementsInstancedANGLE(
+ mode, count, type,
+ reinterpret_cast<void*>(static_cast<intptr_t>(offset)), primcount);
+}
+
+DELEGATE_TO_GL_2(vertexAttribDivisorANGLE, VertexAttribDivisorANGLE, WGC3Duint,
+ WGC3Duint)
+
+DELEGATE_TO_GL_4R(createImageCHROMIUM,
+ CreateImageCHROMIUM,
+ WGC3Dsizei,
+ WGC3Dsizei,
+ WGC3Denum,
+ WGC3Denum,
+ WGC3Duint);
+
+DELEGATE_TO_GL_1(destroyImageCHROMIUM, DestroyImageCHROMIUM, WGC3Duint);
+
+DELEGATE_TO_GL_3(getImageParameterivCHROMIUM, GetImageParameterivCHROMIUM,
+ WGC3Duint, WGC3Denum, GLint*);
+
+DELEGATE_TO_GL_1R(mapImageCHROMIUM, MapImageCHROMIUM, WGC3Duint, void*);
+
+DELEGATE_TO_GL_1(unmapImageCHROMIUM, UnmapImageCHROMIUM, WGC3Duint);
+
+DELEGATE_TO_GL_6(framebufferTexture2DMultisampleEXT,
+ FramebufferTexture2DMultisampleEXT,
+ WGC3Denum, WGC3Denum, WGC3Denum, WebGLId, WGC3Dint, WGC3Dsizei)
+
+DELEGATE_TO_GL_5(renderbufferStorageMultisampleEXT,
+ RenderbufferStorageMultisampleEXT, WGC3Denum, WGC3Dsizei,
+ WGC3Denum, WGC3Dsizei, WGC3Dsizei)
+
+GrGLInterface* WebGraphicsContext3DImpl::createGrGLInterface() {
+ makeContextCurrent();
+ return skia_bindings::CreateCommandBufferSkiaGLBinding();
+}
+
+::gpu::gles2::GLES2ImplementationErrorMessageCallback*
+ WebGraphicsContext3DImpl::getErrorMessageCallback() {
+ if (!client_error_message_callback_) {
+ client_error_message_callback_.reset(
+ new WebGraphicsContext3DErrorMessageCallback(this));
+ }
+ return client_error_message_callback_.get();
+}
+
+void WebGraphicsContext3DImpl::OnErrorMessage(
+ const std::string& message, int id) {
+ if (error_message_callback_) {
+ blink::WebString str = blink::WebString::fromUTF8(message.c_str());
+ error_message_callback_->onErrorMessage(str, id);
+ }
+}
+
+// TODO(bajones): Look into removing these functions from the blink interface
+void WebGraphicsContext3DImpl::prepareTexture() {
+ NOTREACHED();
+}
+
+void WebGraphicsContext3DImpl::postSubBufferCHROMIUM(
+ int x, int y, int width, int height) {
+ NOTREACHED();
+}
+
+void WebGraphicsContext3DImpl::setVisibilityCHROMIUM(
+ bool visible) {
+ NOTREACHED();
+}
+
+void WebGraphicsContext3DImpl::copyTextureToParentTextureCHROMIUM(
+ WebGLId texture, WebGLId parentTexture) {
+ NOTIMPLEMENTED();
+}
+
+void WebGraphicsContext3DImpl::releaseShaderCompiler() {
+}
+
+} // namespace gpu
+} // namespace webkit
diff --git a/chromium/webkit/common/gpu/webgraphicscontext3d_impl.h b/chromium/webkit/common/gpu/webgraphicscontext3d_impl.h
new file mode 100644
index 00000000000..83af0b4ad1a
--- /dev/null
+++ b/chromium/webkit/common/gpu/webgraphicscontext3d_impl.h
@@ -0,0 +1,598 @@
+// 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 WEBKIT_COMMON_GPU_WEBGRAPHICSCONTEXT3D_IMPL_H_
+#define WEBKIT_COMMON_GPU_WEBGRAPHICSCONTEXT3D_IMPL_H_
+
+#include <string>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/memory/scoped_ptr.h"
+#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
+#include "third_party/WebKit/public/platform/WebString.h"
+#include "webkit/common/gpu/webkit_gpu_export.h"
+
+namespace gpu {
+
+namespace gles2 {
+class GLES2Interface;
+class GLES2ImplementationErrorMessageCallback;
+}
+}
+
+using blink::WebGLId;
+
+using blink::WGC3Dbyte;
+using blink::WGC3Dchar;
+using blink::WGC3Denum;
+using blink::WGC3Dboolean;
+using blink::WGC3Dbitfield;
+using blink::WGC3Dint;
+using blink::WGC3Dsizei;
+using blink::WGC3Duint;
+using blink::WGC3Dfloat;
+using blink::WGC3Dclampf;
+using blink::WGC3Dintptr;
+using blink::WGC3Dsizeiptr;
+
+namespace webkit {
+namespace gpu {
+
+class WebGraphicsContext3DErrorMessageCallback;
+
+class WEBKIT_GPU_EXPORT WebGraphicsContext3DImpl
+ : public NON_EXPORTED_BASE(blink::WebGraphicsContext3D) {
+ public:
+ //----------------------------------------------------------------------
+ // WebGraphicsContext3D methods
+
+ virtual uint32_t lastFlushID();
+
+ virtual unsigned int insertSyncPoint();
+ virtual void waitSyncPoint(unsigned int sync_point);
+
+ virtual void loseContextCHROMIUM(WGC3Denum current, WGC3Denum other);
+
+ virtual void reshapeWithScaleFactor(
+ int width, int height, float scale_factor);
+
+ virtual void prepareTexture();
+ virtual void postSubBufferCHROMIUM(int x, int y, int width, int height);
+
+ virtual void activeTexture(WGC3Denum texture);
+ virtual void attachShader(WebGLId program, WebGLId shader);
+ virtual void bindAttribLocation(WebGLId program, WGC3Duint index,
+ const WGC3Dchar* name);
+ virtual void bindBuffer(WGC3Denum target, WebGLId buffer);
+ virtual void bindFramebuffer(WGC3Denum target, WebGLId framebuffer);
+ virtual void bindRenderbuffer(WGC3Denum target, WebGLId renderbuffer);
+ virtual void bindTexture(WGC3Denum target, WebGLId texture);
+ virtual void blendColor(WGC3Dclampf red, WGC3Dclampf green,
+ WGC3Dclampf blue, WGC3Dclampf alpha);
+ virtual void blendEquation(WGC3Denum mode);
+ virtual void blendEquationSeparate(WGC3Denum modeRGB,
+ WGC3Denum modeAlpha);
+ virtual void blendFunc(WGC3Denum sfactor, WGC3Denum dfactor);
+ virtual void blendFuncSeparate(WGC3Denum srcRGB,
+ WGC3Denum dstRGB,
+ WGC3Denum srcAlpha,
+ WGC3Denum dstAlpha);
+
+ virtual void bufferData(WGC3Denum target, WGC3Dsizeiptr size,
+ const void* data, WGC3Denum usage);
+ virtual void bufferSubData(WGC3Denum target, WGC3Dintptr offset,
+ WGC3Dsizeiptr size, const void* data);
+
+ virtual WGC3Denum checkFramebufferStatus(WGC3Denum target);
+ virtual void clear(WGC3Dbitfield mask);
+ virtual void clearColor(WGC3Dclampf red, WGC3Dclampf green,
+ WGC3Dclampf blue, WGC3Dclampf alpha);
+ virtual void clearDepth(WGC3Dclampf depth);
+ virtual void clearStencil(WGC3Dint s);
+ virtual void colorMask(WGC3Dboolean red, WGC3Dboolean green,
+ WGC3Dboolean blue, WGC3Dboolean alpha);
+ virtual void compileShader(WebGLId shader);
+
+ virtual void compressedTexImage2D(WGC3Denum target,
+ WGC3Dint level,
+ WGC3Denum internalformat,
+ WGC3Dsizei width,
+ WGC3Dsizei height,
+ WGC3Dint border,
+ WGC3Dsizei imageSize,
+ const void* data);
+ virtual void compressedTexSubImage2D(WGC3Denum target,
+ WGC3Dint level,
+ WGC3Dint xoffset,
+ WGC3Dint yoffset,
+ WGC3Dsizei width,
+ WGC3Dsizei height,
+ WGC3Denum format,
+ WGC3Dsizei imageSize,
+ const void* data);
+ virtual void copyTexImage2D(WGC3Denum target,
+ WGC3Dint level,
+ WGC3Denum internalformat,
+ WGC3Dint x,
+ WGC3Dint y,
+ WGC3Dsizei width,
+ WGC3Dsizei height,
+ WGC3Dint border);
+ virtual void copyTexSubImage2D(WGC3Denum target,
+ WGC3Dint level,
+ WGC3Dint xoffset,
+ WGC3Dint yoffset,
+ WGC3Dint x,
+ WGC3Dint y,
+ WGC3Dsizei width,
+ WGC3Dsizei height);
+ virtual void cullFace(WGC3Denum mode);
+ virtual void depthFunc(WGC3Denum func);
+ virtual void depthMask(WGC3Dboolean flag);
+ virtual void depthRange(WGC3Dclampf zNear, WGC3Dclampf zFar);
+ virtual void detachShader(WebGLId program, WebGLId shader);
+ virtual void disable(WGC3Denum cap);
+ virtual void disableVertexAttribArray(WGC3Duint index);
+ virtual void drawArrays(WGC3Denum mode, WGC3Dint first, WGC3Dsizei count);
+ virtual void drawElements(WGC3Denum mode,
+ WGC3Dsizei count,
+ WGC3Denum type,
+ WGC3Dintptr offset);
+
+ virtual void enable(WGC3Denum cap);
+ virtual void enableVertexAttribArray(WGC3Duint index);
+ virtual void finish();
+ virtual void flush();
+ virtual void framebufferRenderbuffer(WGC3Denum target,
+ WGC3Denum attachment,
+ WGC3Denum renderbuffertarget,
+ WebGLId renderbuffer);
+ virtual void framebufferTexture2D(WGC3Denum target,
+ WGC3Denum attachment,
+ WGC3Denum textarget,
+ WebGLId texture,
+ WGC3Dint level);
+ virtual void frontFace(WGC3Denum mode);
+ virtual void generateMipmap(WGC3Denum target);
+
+ virtual bool getActiveAttrib(WebGLId program,
+ WGC3Duint index,
+ ActiveInfo&);
+ virtual bool getActiveUniform(WebGLId program,
+ WGC3Duint index,
+ ActiveInfo&);
+
+ virtual void getAttachedShaders(WebGLId program,
+ WGC3Dsizei maxCount,
+ WGC3Dsizei* count,
+ WebGLId* shaders);
+
+ virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name);
+
+ virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value);
+
+ virtual void getBufferParameteriv(WGC3Denum target,
+ WGC3Denum pname,
+ WGC3Dint* value);
+
+ virtual WGC3Denum getError();
+
+ virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value);
+
+ virtual void getFramebufferAttachmentParameteriv(WGC3Denum target,
+ WGC3Denum attachment,
+ WGC3Denum pname,
+ WGC3Dint* value);
+
+ virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value);
+
+ virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value);
+
+ virtual blink::WebString getProgramInfoLog(WebGLId program);
+
+ virtual void getRenderbufferParameteriv(WGC3Denum target,
+ WGC3Denum pname,
+ WGC3Dint* value);
+
+ virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value);
+
+ virtual blink::WebString getShaderInfoLog(WebGLId shader);
+
+ virtual void getShaderPrecisionFormat(WGC3Denum shadertype,
+ WGC3Denum precisiontype,
+ WGC3Dint* range,
+ WGC3Dint* precision);
+
+ virtual blink::WebString getShaderSource(WebGLId shader);
+ virtual blink::WebString getString(WGC3Denum name);
+
+ virtual void getTexParameterfv(WGC3Denum target,
+ WGC3Denum pname,
+ WGC3Dfloat* value);
+ virtual void getTexParameteriv(WGC3Denum target,
+ WGC3Denum pname,
+ WGC3Dint* value);
+
+ virtual void getUniformfv(WebGLId program,
+ WGC3Dint location,
+ WGC3Dfloat* value);
+ virtual void getUniformiv(WebGLId program,
+ WGC3Dint location,
+ WGC3Dint* value);
+
+ virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name);
+
+ virtual void getVertexAttribfv(WGC3Duint index, WGC3Denum pname,
+ WGC3Dfloat* value);
+ virtual void getVertexAttribiv(WGC3Duint index, WGC3Denum pname,
+ WGC3Dint* value);
+
+ virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, WGC3Denum pname);
+
+ virtual void hint(WGC3Denum target, WGC3Denum mode);
+ virtual WGC3Dboolean isBuffer(WebGLId buffer);
+ virtual WGC3Dboolean isEnabled(WGC3Denum cap);
+ virtual WGC3Dboolean isFramebuffer(WebGLId framebuffer);
+ virtual WGC3Dboolean isProgram(WebGLId program);
+ virtual WGC3Dboolean isRenderbuffer(WebGLId renderbuffer);
+ virtual WGC3Dboolean isShader(WebGLId shader);
+ virtual WGC3Dboolean isTexture(WebGLId texture);
+ virtual void lineWidth(WGC3Dfloat);
+ virtual void linkProgram(WebGLId program);
+ virtual void pixelStorei(WGC3Denum pname, WGC3Dint param);
+ virtual void polygonOffset(WGC3Dfloat factor, WGC3Dfloat units);
+
+ virtual void readPixels(WGC3Dint x,
+ WGC3Dint y,
+ WGC3Dsizei width,
+ WGC3Dsizei height,
+ WGC3Denum format,
+ WGC3Denum type,
+ void* pixels);
+
+ virtual void releaseShaderCompiler();
+ virtual void renderbufferStorage(WGC3Denum target,
+ WGC3Denum internalformat,
+ WGC3Dsizei width,
+ WGC3Dsizei height);
+ virtual void sampleCoverage(WGC3Dfloat value, WGC3Dboolean invert);
+ virtual void scissor(WGC3Dint x, WGC3Dint y,
+ WGC3Dsizei width, WGC3Dsizei height);
+ virtual void shaderSource(WebGLId shader, const WGC3Dchar* string);
+ virtual void stencilFunc(WGC3Denum func, WGC3Dint ref, WGC3Duint mask);
+ virtual void stencilFuncSeparate(WGC3Denum face,
+ WGC3Denum func,
+ WGC3Dint ref,
+ WGC3Duint mask);
+ virtual void stencilMask(WGC3Duint mask);
+ virtual void stencilMaskSeparate(WGC3Denum face, WGC3Duint mask);
+ virtual void stencilOp(WGC3Denum fail,
+ WGC3Denum zfail,
+ WGC3Denum zpass);
+ virtual void stencilOpSeparate(WGC3Denum face,
+ WGC3Denum fail,
+ WGC3Denum zfail,
+ WGC3Denum zpass);
+
+ virtual void texImage2D(WGC3Denum target,
+ WGC3Dint level,
+ WGC3Denum internalformat,
+ WGC3Dsizei width,
+ WGC3Dsizei height,
+ WGC3Dint border,
+ WGC3Denum format,
+ WGC3Denum type,
+ const void* pixels);
+
+ virtual void texParameterf(WGC3Denum target,
+ WGC3Denum pname,
+ WGC3Dfloat param);
+ virtual void texParameteri(WGC3Denum target,
+ WGC3Denum pname,
+ WGC3Dint param);
+
+ virtual void texSubImage2D(WGC3Denum target,
+ WGC3Dint level,
+ WGC3Dint xoffset,
+ WGC3Dint yoffset,
+ WGC3Dsizei width,
+ WGC3Dsizei height,
+ WGC3Denum format,
+ WGC3Denum type,
+ const void* pixels);
+
+ virtual void uniform1f(WGC3Dint location, WGC3Dfloat x);
+ virtual void uniform1fv(WGC3Dint location,
+ WGC3Dsizei count, const WGC3Dfloat* v);
+ virtual void uniform1i(WGC3Dint location, WGC3Dint x);
+ virtual void uniform1iv(WGC3Dint location,
+ WGC3Dsizei count, const WGC3Dint* v);
+ virtual void uniform2f(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y);
+ virtual void uniform2fv(WGC3Dint location,
+ WGC3Dsizei count, const WGC3Dfloat* v);
+ virtual void uniform2i(WGC3Dint location, WGC3Dint x, WGC3Dint y);
+ virtual void uniform2iv(WGC3Dint location,
+ WGC3Dsizei count, const WGC3Dint* v);
+ virtual void uniform3f(WGC3Dint location,
+ WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z);
+ virtual void uniform3fv(WGC3Dint location,
+ WGC3Dsizei count, const WGC3Dfloat* v);
+ virtual void uniform3i(WGC3Dint location,
+ WGC3Dint x, WGC3Dint y, WGC3Dint z);
+ virtual void uniform3iv(WGC3Dint location,
+ WGC3Dsizei count, const WGC3Dint* v);
+ virtual void uniform4f(WGC3Dint location,
+ WGC3Dfloat x, WGC3Dfloat y,
+ WGC3Dfloat z, WGC3Dfloat w);
+ virtual void uniform4fv(WGC3Dint location,
+ WGC3Dsizei count, const WGC3Dfloat* v);
+ virtual void uniform4i(WGC3Dint location,
+ WGC3Dint x, WGC3Dint y, WGC3Dint z, WGC3Dint w);
+ virtual void uniform4iv(WGC3Dint location,
+ WGC3Dsizei count, const WGC3Dint* v);
+ virtual void uniformMatrix2fv(WGC3Dint location,
+ WGC3Dsizei count,
+ WGC3Dboolean transpose,
+ const WGC3Dfloat* value);
+ virtual void uniformMatrix3fv(WGC3Dint location,
+ WGC3Dsizei count,
+ WGC3Dboolean transpose,
+ const WGC3Dfloat* value);
+ virtual void uniformMatrix4fv(WGC3Dint location,
+ WGC3Dsizei count,
+ WGC3Dboolean transpose,
+ const WGC3Dfloat* value);
+
+ virtual void useProgram(WebGLId program);
+ virtual void validateProgram(WebGLId program);
+
+ virtual void vertexAttrib1f(WGC3Duint index, WGC3Dfloat x);
+ virtual void vertexAttrib1fv(WGC3Duint index, const WGC3Dfloat* values);
+ virtual void vertexAttrib2f(WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y);
+ virtual void vertexAttrib2fv(WGC3Duint index, const WGC3Dfloat* values);
+ virtual void vertexAttrib3f(WGC3Duint index,
+ WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z);
+ virtual void vertexAttrib3fv(WGC3Duint index, const WGC3Dfloat* values);
+ virtual void vertexAttrib4f(WGC3Duint index,
+ WGC3Dfloat x, WGC3Dfloat y,
+ WGC3Dfloat z, WGC3Dfloat w);
+ virtual void vertexAttrib4fv(WGC3Duint index, const WGC3Dfloat* values);
+ virtual void vertexAttribPointer(WGC3Duint index,
+ WGC3Dint size,
+ WGC3Denum type,
+ WGC3Dboolean normalized,
+ WGC3Dsizei stride,
+ WGC3Dintptr offset);
+
+ virtual void viewport(WGC3Dint x, WGC3Dint y,
+ WGC3Dsizei width, WGC3Dsizei height);
+
+ // Support for buffer creation and deletion
+ virtual void genBuffers(WGC3Dsizei count, WebGLId* ids);
+ virtual void genFramebuffers(WGC3Dsizei count, WebGLId* ids);
+ virtual void genRenderbuffers(WGC3Dsizei count, WebGLId* ids);
+ virtual void genTextures(WGC3Dsizei count, WebGLId* ids);
+
+ virtual void deleteBuffers(WGC3Dsizei count, WebGLId* ids);
+ virtual void deleteFramebuffers(WGC3Dsizei count, WebGLId* ids);
+ virtual void deleteRenderbuffers(WGC3Dsizei count, WebGLId* ids);
+ virtual void deleteTextures(WGC3Dsizei count, WebGLId* ids);
+
+ virtual WebGLId createBuffer();
+ virtual WebGLId createFramebuffer();
+ virtual WebGLId createRenderbuffer();
+ virtual WebGLId createTexture();
+
+ virtual void deleteBuffer(WebGLId);
+ virtual void deleteFramebuffer(WebGLId);
+ virtual void deleteRenderbuffer(WebGLId);
+ virtual void deleteTexture(WebGLId);
+
+ virtual WebGLId createProgram();
+ virtual WebGLId createShader(WGC3Denum);
+
+ virtual void deleteProgram(WebGLId);
+ virtual void deleteShader(WebGLId);
+
+ virtual void synthesizeGLError(WGC3Denum);
+
+ virtual void* mapBufferSubDataCHROMIUM(
+ WGC3Denum target, WGC3Dintptr offset,
+ WGC3Dsizeiptr size, WGC3Denum access);
+ virtual void unmapBufferSubDataCHROMIUM(const void*);
+ virtual void* mapTexSubImage2DCHROMIUM(
+ WGC3Denum target,
+ WGC3Dint level,
+ WGC3Dint xoffset,
+ WGC3Dint yoffset,
+ WGC3Dsizei width,
+ WGC3Dsizei height,
+ WGC3Denum format,
+ WGC3Denum type,
+ WGC3Denum access);
+ virtual void unmapTexSubImage2DCHROMIUM(const void*);
+
+ virtual void setVisibilityCHROMIUM(bool visible);
+
+ virtual void discardFramebufferEXT(WGC3Denum target,
+ WGC3Dsizei numAttachments,
+ const WGC3Denum* attachments);
+ virtual void copyTextureToParentTextureCHROMIUM(
+ WebGLId texture, WebGLId parentTexture);
+
+ virtual blink::WebString getRequestableExtensionsCHROMIUM();
+ virtual void requestExtensionCHROMIUM(const char*);
+
+ virtual void blitFramebufferCHROMIUM(
+ WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1,
+ WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1,
+ WGC3Dbitfield mask, WGC3Denum filter);
+ virtual void renderbufferStorageMultisampleCHROMIUM(
+ WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat,
+ WGC3Dsizei width, WGC3Dsizei height);
+
+ virtual blink::WebString getTranslatedShaderSourceANGLE(WebGLId shader);
+
+ virtual void setContextLostCallback(
+ WebGraphicsContext3D::WebGraphicsContextLostCallback* callback);
+
+ virtual void setErrorMessageCallback(
+ WebGraphicsContext3D::WebGraphicsErrorMessageCallback* callback);
+
+ virtual void texImageIOSurface2DCHROMIUM(
+ WGC3Denum target, WGC3Dint width, WGC3Dint height,
+ WGC3Duint ioSurfaceId, WGC3Duint plane);
+
+ virtual void texStorage2DEXT(
+ WGC3Denum target, WGC3Dint levels, WGC3Duint internalformat,
+ WGC3Dint width, WGC3Dint height);
+
+ virtual WebGLId createQueryEXT();
+ virtual void deleteQueryEXT(WebGLId query);
+ virtual WGC3Dboolean isQueryEXT(WGC3Duint query);
+ virtual void beginQueryEXT(WGC3Denum target, WebGLId query);
+ virtual void endQueryEXT(WGC3Denum target);
+ virtual void getQueryivEXT(
+ WGC3Denum target, WGC3Denum pname, WGC3Dint* params);
+ virtual void getQueryObjectuivEXT(
+ WebGLId query, WGC3Denum pname, WGC3Duint* params);
+
+ virtual void copyTextureCHROMIUM(WGC3Denum target, WebGLId source_id,
+ WebGLId dest_id, WGC3Dint level,
+ WGC3Denum internal_format,
+ WGC3Denum dest_type);
+
+ virtual void bindUniformLocationCHROMIUM(WebGLId program, WGC3Dint location,
+ const WGC3Dchar* uniform);
+
+ virtual void shallowFlushCHROMIUM();
+ virtual void shallowFinishCHROMIUM();
+
+ virtual void genMailboxCHROMIUM(WGC3Dbyte* mailbox);
+ virtual void produceTextureCHROMIUM(WGC3Denum target,
+ const WGC3Dbyte* mailbox);
+ virtual void produceTextureDirectCHROMIUM(WebGLId texture, WGC3Denum target,
+ const WGC3Dbyte* mailbox);
+ virtual void consumeTextureCHROMIUM(WGC3Denum target,
+ const WGC3Dbyte* mailbox);
+ virtual WebGLId createAndConsumeTextureCHROMIUM(WGC3Denum target,
+ const WGC3Dbyte* mailbox);
+
+ virtual void insertEventMarkerEXT(const WGC3Dchar* marker);
+ virtual void pushGroupMarkerEXT(const WGC3Dchar* marker);
+ virtual void popGroupMarkerEXT();
+
+ // GL_OES_vertex_array_object
+ virtual WebGLId createVertexArrayOES();
+ virtual void deleteVertexArrayOES(WebGLId array);
+ virtual WGC3Dboolean isVertexArrayOES(WebGLId array);
+ virtual void bindVertexArrayOES(WebGLId array);
+
+ virtual void bindTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint image_id);
+ virtual void releaseTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint image_id);
+
+ virtual void* mapBufferCHROMIUM(WGC3Denum target, WGC3Denum access);
+ virtual WGC3Dboolean unmapBufferCHROMIUM(WGC3Denum target);
+
+ // Async pixel transfer functions.
+ virtual void asyncTexImage2DCHROMIUM(
+ WGC3Denum target,
+ WGC3Dint level,
+ WGC3Denum internalformat,
+ WGC3Dsizei width,
+ WGC3Dsizei height,
+ WGC3Dint border,
+ WGC3Denum format,
+ WGC3Denum type,
+ const void* pixels);
+ virtual void asyncTexSubImage2DCHROMIUM(
+ WGC3Denum target,
+ WGC3Dint level,
+ WGC3Dint xoffset,
+ WGC3Dint yoffset,
+ WGC3Dsizei width,
+ WGC3Dsizei height,
+ WGC3Denum format,
+ WGC3Denum type,
+ const void* pixels);
+ virtual void waitAsyncTexImage2DCHROMIUM(WGC3Denum target);
+
+ // GL_EXT_draw_buffers
+ virtual void drawBuffersEXT(
+ WGC3Dsizei n,
+ const WGC3Denum* bufs);
+
+ // GL_ANGLE_instanced_arrays
+ virtual void drawArraysInstancedANGLE(WGC3Denum mode, WGC3Dint first,
+ WGC3Dsizei count, WGC3Dsizei primcount);
+ virtual void drawElementsInstancedANGLE(WGC3Denum mode, WGC3Dsizei count,
+ WGC3Denum type, WGC3Dintptr offset, WGC3Dsizei primcount);
+ virtual void vertexAttribDivisorANGLE(WGC3Duint index, WGC3Duint divisor);
+
+ // GL_CHROMIUM_map_image
+ virtual WGC3Duint createImageCHROMIUM(WGC3Dsizei width,
+ WGC3Dsizei height,
+ WGC3Denum internalformat,
+ WGC3Denum usage);
+ virtual void destroyImageCHROMIUM(WGC3Duint image_id);
+ virtual void getImageParameterivCHROMIUM(
+ WGC3Duint image_id, WGC3Denum pname, WGC3Dint* params);
+ virtual void* mapImageCHROMIUM(WGC3Duint image_id);
+ virtual void unmapImageCHROMIUM(WGC3Duint image_id);
+
+ // GL_EXT_multisampled_render_to_texture
+ virtual void framebufferTexture2DMultisampleEXT(WGC3Denum target,
+ WGC3Denum attachment,
+ WGC3Denum textarget,
+ WebGLId texture,
+ WGC3Dint level,
+ WGC3Dsizei samples);
+ virtual void renderbufferStorageMultisampleEXT(
+ WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat,
+ WGC3Dsizei width, WGC3Dsizei height);
+
+ virtual GrGLInterface* createGrGLInterface();
+
+ ::gpu::gles2::GLES2Interface* GetGLInterface() {
+ return gl_;
+ }
+
+ protected:
+ friend class WebGraphicsContext3DErrorMessageCallback;
+
+ WebGraphicsContext3DImpl();
+ virtual ~WebGraphicsContext3DImpl();
+
+ ::gpu::gles2::GLES2ImplementationErrorMessageCallback*
+ getErrorMessageCallback();
+ virtual void OnErrorMessage(const std::string& message, int id);
+
+ void setGLInterface(::gpu::gles2::GLES2Interface* gl) {
+ gl_ = gl;
+ }
+
+ bool initialized_;
+ bool initialize_failed_;
+
+ WebGraphicsContext3D::WebGraphicsContextLostCallback* context_lost_callback_;
+ WGC3Denum context_lost_reason_;
+
+ WebGraphicsContext3D::WebGraphicsErrorMessageCallback*
+ error_message_callback_;
+ scoped_ptr<WebGraphicsContext3DErrorMessageCallback>
+ client_error_message_callback_;
+
+ // Errors raised by synthesizeGLError().
+ std::vector<WGC3Denum> synthetic_errors_;
+
+ ::gpu::gles2::GLES2Interface* gl_;
+ bool lose_context_when_out_of_memory_;
+ uint32_t flush_id_;
+};
+
+} // namespace gpu
+} // namespace webkit
+
+#endif // WEBKIT_COMMON_GPU_WEBGRAPHICSCONTEXT3D_IMPL_H_
diff --git a/chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc b/chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
index 6d7e9f7ffa7..3ce34feaf36 100644
--- a/chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
+++ b/chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc
@@ -19,12 +19,11 @@
#include "base/callback.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
-#include "gpu/command_buffer/client/gl_in_process_context.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "gpu/command_buffer/client/gles2_lib.h"
#include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h"
#include "ui/gfx/size.h"
-#include "ui/gl/gl_surface.h"
+#include "ui/gl/gl_implementation.h"
using gpu::gles2::GLES2Implementation;
using gpu::GLInProcessContext;
@@ -41,14 +40,6 @@ const size_t kStartTransferBufferSize = 4 * 1024 * 1024;
const size_t kMinTransferBufferSize = 1 * 256 * 1024;
const size_t kMaxTransferBufferSize = 16 * 1024 * 1024;
-uint32_t GenFlushID() {
- static base::subtle::Atomic32 flush_id = 0;
-
- base::subtle::Atomic32 my_id = base::subtle::Barrier_AtomicIncrement(
- &flush_id, 1);
- return static_cast<uint32_t>(my_id);
-}
-
// Singleton used to initialize and terminate the gles2 library.
class GLES2Initializer {
public:
@@ -73,56 +64,60 @@ static base::LazyInstance<GLES2Initializer> g_gles2_initializer =
scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext(
const blink::WebGraphicsContext3D::Attributes& attributes,
+ bool lose_context_when_out_of_memory,
gfx::AcceleratedWidget window) {
- scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context;
- if (gfx::GLSurface::InitializeOneOff()) {
- context.reset(new WebGraphicsContext3DInProcessCommandBufferImpl(
- scoped_ptr< ::gpu::GLInProcessContext>(), attributes, false, window));
- }
- return context.Pass();
+ DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone);
+ bool is_offscreen = false;
+ return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl(
+ scoped_ptr< ::gpu::GLInProcessContext>(),
+ attributes,
+ lose_context_when_out_of_memory,
+ is_offscreen,
+ window));
}
// static
scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
- const blink::WebGraphicsContext3D::Attributes& attributes) {
+ const blink::WebGraphicsContext3D::Attributes& attributes,
+ bool lose_context_when_out_of_memory) {
+ bool is_offscreen = true;
return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl(
- scoped_ptr< ::gpu::GLInProcessContext>(),
- attributes,
- true,
- gfx::kNullAcceleratedWidget))
- .Pass();
+ scoped_ptr< ::gpu::GLInProcessContext>(),
+ attributes,
+ lose_context_when_out_of_memory,
+ is_offscreen,
+ gfx::kNullAcceleratedWidget));
}
scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext(
scoped_ptr< ::gpu::GLInProcessContext> context,
const blink::WebGraphicsContext3D::Attributes& attributes) {
- return make_scoped_ptr(
- new WebGraphicsContext3DInProcessCommandBufferImpl(
- context.Pass(),
- attributes,
- true /* is_offscreen. Not used. */,
- gfx::kNullAcceleratedWidget /* window. Not used. */))
- .Pass();
+ bool lose_context_when_out_of_memory = false; // Not used.
+ bool is_offscreen = true; // Not used.
+ return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl(
+ context.Pass(),
+ attributes,
+ lose_context_when_out_of_memory,
+ is_offscreen,
+ gfx::kNullAcceleratedWidget /* window. Not used. */));
}
WebGraphicsContext3DInProcessCommandBufferImpl::
WebGraphicsContext3DInProcessCommandBufferImpl(
scoped_ptr< ::gpu::GLInProcessContext> context,
const blink::WebGraphicsContext3D::Attributes& attributes,
+ bool lose_context_when_out_of_memory,
bool is_offscreen,
gfx::AcceleratedWidget window)
- : is_offscreen_(is_offscreen),
+ : share_resources_(attributes.shareResources),
+ webgl_context_(attributes.noExtensions),
+ is_offscreen_(is_offscreen),
window_(window),
- initialized_(false),
- initialize_failed_(false),
- context_(context.Pass()),
- gl_(NULL),
- context_lost_callback_(NULL),
- context_lost_reason_(GL_NO_ERROR),
- attributes_(attributes),
- flush_id_(0) {
+ context_(context.Pass()) {
+ ConvertAttributes(attributes, &attribs_);
+ attribs_.lose_context_when_out_of_memory = lose_context_when_out_of_memory;
}
WebGraphicsContext3DInProcessCommandBufferImpl::
@@ -160,15 +155,12 @@ bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() {
// discrete GPU is created, or the last one is destroyed.
gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
- ::gpu::GLInProcessContextAttribs attrib_struct;
- ConvertAttributes(attributes_, &attrib_struct),
-
context_.reset(GLInProcessContext::CreateContext(
is_offscreen_,
window_,
gfx::Size(1, 1),
- attributes_.shareResources,
- attrib_struct,
+ share_resources_,
+ attribs_,
gpu_preference));
}
@@ -182,26 +174,11 @@ bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() {
return false;
}
- gl_ = context_->GetImplementation();
-
- if (gl_ && attributes_.noExtensions)
- gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation");
+ real_gl_ = context_->GetImplementation();
+ setGLInterface(real_gl_);
- // Set attributes_ from created offscreen context.
- {
- GLint alpha_bits = 0;
- getIntegerv(GL_ALPHA_BITS, &alpha_bits);
- attributes_.alpha = alpha_bits > 0;
- GLint depth_bits = 0;
- getIntegerv(GL_DEPTH_BITS, &depth_bits);
- attributes_.depth = depth_bits > 0;
- GLint stencil_bits = 0;
- getIntegerv(GL_STENCIL_BITS, &stencil_bits);
- attributes_.stencil = stencil_bits > 0;
- GLint sample_buffers = 0;
- getIntegerv(GL_SAMPLE_BUFFERS, &sample_buffers);
- attributes_.antialias = sample_buffers > 0;
- }
+ if (real_gl_ && webgl_context_)
+ real_gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation");
initialized_ = true;
return true;
@@ -210,926 +187,22 @@ bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() {
bool WebGraphicsContext3DInProcessCommandBufferImpl::makeContextCurrent() {
if (!MaybeInitializeGL())
return false;
- ::gles2::SetGLContext(gl_);
+ ::gles2::SetGLContext(GetGLInterface());
return context_ && !isContextLost();
}
-uint32_t WebGraphicsContext3DInProcessCommandBufferImpl::lastFlushID() {
- return flush_id_;
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::ClearContext() {
- // NOTE: Comment in the line below to check for code that is not calling
- // eglMakeCurrent where appropriate. The issue is code using
- // WebGraphicsContext3D does not need to call makeContextCurrent. Code using
- // direct OpenGL bindings needs to call the appropriate form of
- // eglMakeCurrent. If it doesn't it will be issuing commands on the wrong
- // context. Uncommenting the line below clears the current context so that
- // any code not calling eglMakeCurrent in the appropriate place should crash.
- // This is not a perfect test but generally code that used the direct OpenGL
- // bindings should not be mixed with code that uses WebGraphicsContext3D.
- //
- // GLInProcessContext::MakeCurrent(NULL);
-}
-
-// Helper macros to reduce the amount of code.
-
-#define DELEGATE_TO_GL(name, glname) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name() { \
- ClearContext(); \
- gl_->glname(); \
-}
-
-#define DELEGATE_TO_GL_R(name, glname, rt) \
-rt WebGraphicsContext3DInProcessCommandBufferImpl::name() { \
- ClearContext(); \
- return gl_->glname(); \
-}
-
-#define DELEGATE_TO_GL_1(name, glname, t1) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name(t1 a1) { \
- ClearContext(); \
- gl_->glname(a1); \
-}
-
-#define DELEGATE_TO_GL_1R(name, glname, t1, rt) \
-rt WebGraphicsContext3DInProcessCommandBufferImpl::name(t1 a1) { \
- ClearContext(); \
- return gl_->glname(a1); \
-}
-
-#define DELEGATE_TO_GL_1RB(name, glname, t1, rt) \
-rt WebGraphicsContext3DInProcessCommandBufferImpl::name(t1 a1) { \
- ClearContext(); \
- return gl_->glname(a1) ? true : false; \
-}
-
-#define DELEGATE_TO_GL_2(name, glname, t1, t2) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2) { \
- ClearContext(); \
- gl_->glname(a1, a2); \
-}
-
-#define DELEGATE_TO_GL_2R(name, glname, t1, t2, rt) \
-rt WebGraphicsContext3DInProcessCommandBufferImpl::name(t1 a1, t2 a2) { \
- ClearContext(); \
- return gl_->glname(a1, a2); \
-}
-
-#define DELEGATE_TO_GL_3(name, glname, t1, t2, t3) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2, t3 a3) { \
- ClearContext(); \
- gl_->glname(a1, a2, a3); \
-}
-
-#define DELEGATE_TO_GL_3R(name, glname, t1, t2, t3, rt) \
-rt WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2, t3 a3) { \
- ClearContext(); \
- return gl_->glname(a1, a2, a3); \
-}
-
-#define DELEGATE_TO_GL_4(name, glname, t1, t2, t3, t4) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2, t3 a3, t4 a4) { \
- ClearContext(); \
- gl_->glname(a1, a2, a3, a4); \
-}
-
-#define DELEGATE_TO_GL_5(name, glname, t1, t2, t3, t4, t5) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) { \
- ClearContext(); \
- gl_->glname(a1, a2, a3, a4, a5); \
-}
-
-#define DELEGATE_TO_GL_6(name, glname, t1, t2, t3, t4, t5, t6) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) { \
- ClearContext(); \
- gl_->glname(a1, a2, a3, a4, a5, a6); \
-}
-
-#define DELEGATE_TO_GL_7(name, glname, t1, t2, t3, t4, t5, t6, t7) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7) { \
- ClearContext(); \
- gl_->glname(a1, a2, a3, a4, a5, a6, a7); \
-}
-
-#define DELEGATE_TO_GL_8(name, glname, t1, t2, t3, t4, t5, t6, t7, t8) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8) { \
- ClearContext(); \
- gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8); \
-}
-
-#define DELEGATE_TO_GL_9(name, glname, t1, t2, t3, t4, t5, t6, t7, t8, t9) \
-void WebGraphicsContext3DInProcessCommandBufferImpl::name( \
- t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8 a8, t9 a9) { \
- ClearContext(); \
- gl_->glname(a1, a2, a3, a4, a5, a6, a7, a8, a9); \
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::prepareTexture() {
- NOTREACHED();
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::postSubBufferCHROMIUM(
- int x, int y, int width, int height) {
- NOTREACHED();
-}
-
-DELEGATE_TO_GL_3(reshapeWithScaleFactor, ResizeCHROMIUM, int, int, float)
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::synthesizeGLError(
- WGC3Denum error) {
- if (std::find(synthetic_errors_.begin(), synthetic_errors_.end(), error) ==
- synthetic_errors_.end()) {
- synthetic_errors_.push_back(error);
- }
-}
-
-void* WebGraphicsContext3DInProcessCommandBufferImpl::mapBufferSubDataCHROMIUM(
- WGC3Denum target,
- WGC3Dintptr offset,
- WGC3Dsizeiptr size,
- WGC3Denum access) {
- ClearContext();
- return gl_->MapBufferSubDataCHROMIUM(target, offset, size, access);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::unmapBufferSubDataCHROMIUM(
- const void* mem) {
- ClearContext();
- return gl_->UnmapBufferSubDataCHROMIUM(mem);
-}
-
-void* WebGraphicsContext3DInProcessCommandBufferImpl::mapTexSubImage2DCHROMIUM(
- WGC3Denum target,
- WGC3Dint level,
- WGC3Dint xoffset,
- WGC3Dint yoffset,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Denum format,
- WGC3Denum type,
- WGC3Denum access) {
- ClearContext();
- return gl_->MapTexSubImage2DCHROMIUM(
- target, level, xoffset, yoffset, width, height, format, type, access);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::unmapTexSubImage2DCHROMIUM(
- const void* mem) {
- ClearContext();
- gl_->UnmapTexSubImage2DCHROMIUM(mem);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::setVisibilityCHROMIUM(
- bool visible) {
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::discardFramebufferEXT(
- WGC3Denum target, WGC3Dsizei numAttachments, const WGC3Denum* attachments) {
- gl_->DiscardFramebufferEXT(target, numAttachments, attachments);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::
- copyTextureToParentTextureCHROMIUM(WebGLId texture, WebGLId parentTexture) {
- NOTIMPLEMENTED();
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::
- rateLimitOffscreenContextCHROMIUM() {
- // TODO(gmam): See if we can comment this in.
- // ClearContext();
- gl_->RateLimitOffscreenContextCHROMIUM();
-}
-
-blink::WebString WebGraphicsContext3DInProcessCommandBufferImpl::
- getRequestableExtensionsCHROMIUM() {
- // TODO(gmam): See if we can comment this in.
- // ClearContext();
- return blink::WebString::fromUTF8(
- gl_->GetRequestableExtensionsCHROMIUM());
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::requestExtensionCHROMIUM(
- const char* extension) {
- // TODO(gmam): See if we can comment this in.
- // ClearContext();
- gl_->RequestExtensionCHROMIUM(extension);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::blitFramebufferCHROMIUM(
- WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1,
- WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1,
- WGC3Dbitfield mask, WGC3Denum filter) {
- ClearContext();
- gl_->BlitFramebufferCHROMIUM(
- srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1,
- mask, filter);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::
- renderbufferStorageMultisampleCHROMIUM(
- WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat,
- WGC3Dsizei width, WGC3Dsizei height) {
- ClearContext();
- gl_->RenderbufferStorageMultisampleCHROMIUM(
- target, samples, internalformat, width, height);
-}
-
-DELEGATE_TO_GL_1(activeTexture, ActiveTexture, WGC3Denum)
-
-DELEGATE_TO_GL_2(attachShader, AttachShader, WebGLId, WebGLId)
-
-DELEGATE_TO_GL_3(bindAttribLocation, BindAttribLocation, WebGLId,
- WGC3Duint, const WGC3Dchar*)
-
-DELEGATE_TO_GL_2(bindBuffer, BindBuffer, WGC3Denum, WebGLId)
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::bindFramebuffer(
- WGC3Denum target,
- WebGLId framebuffer) {
- ClearContext();
- gl_->BindFramebuffer(target, framebuffer);
-}
-
-DELEGATE_TO_GL_2(bindRenderbuffer, BindRenderbuffer, WGC3Denum, WebGLId)
-
-DELEGATE_TO_GL_2(bindTexture, BindTexture, WGC3Denum, WebGLId)
-
-DELEGATE_TO_GL_4(blendColor, BlendColor,
- WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf)
-
-DELEGATE_TO_GL_1(blendEquation, BlendEquation, WGC3Denum)
-
-DELEGATE_TO_GL_2(blendEquationSeparate, BlendEquationSeparate,
- WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_2(blendFunc, BlendFunc, WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_4(blendFuncSeparate, BlendFuncSeparate,
- WGC3Denum, WGC3Denum, WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_4(bufferData, BufferData,
- WGC3Denum, WGC3Dsizeiptr, const void*, WGC3Denum)
-
-DELEGATE_TO_GL_4(bufferSubData, BufferSubData,
- WGC3Denum, WGC3Dintptr, WGC3Dsizeiptr, const void*)
-
-DELEGATE_TO_GL_1R(checkFramebufferStatus, CheckFramebufferStatus,
- WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_1(clear, Clear, WGC3Dbitfield)
-
-DELEGATE_TO_GL_4(clearColor, ClearColor,
- WGC3Dclampf, WGC3Dclampf, WGC3Dclampf, WGC3Dclampf)
-
-DELEGATE_TO_GL_1(clearDepth, ClearDepthf, WGC3Dclampf)
-
-DELEGATE_TO_GL_1(clearStencil, ClearStencil, WGC3Dint)
-
-DELEGATE_TO_GL_4(colorMask, ColorMask,
- WGC3Dboolean, WGC3Dboolean, WGC3Dboolean, WGC3Dboolean)
-
-DELEGATE_TO_GL_1(compileShader, CompileShader, WebGLId)
-
-DELEGATE_TO_GL_8(compressedTexImage2D, CompressedTexImage2D,
- WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dint, WGC3Dint,
- WGC3Dsizei, WGC3Dsizei, const void*)
-
-DELEGATE_TO_GL_9(compressedTexSubImage2D, CompressedTexSubImage2D,
- WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint,
- WGC3Denum, WGC3Dsizei, const void*)
-
-DELEGATE_TO_GL_8(copyTexImage2D, CopyTexImage2D,
- WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dint, WGC3Dint,
- WGC3Dsizei, WGC3Dsizei, WGC3Dint)
-
-DELEGATE_TO_GL_8(copyTexSubImage2D, CopyTexSubImage2D,
- WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint,
- WGC3Dsizei, WGC3Dsizei)
-
-DELEGATE_TO_GL_1(cullFace, CullFace, WGC3Denum)
-
-DELEGATE_TO_GL_1(depthFunc, DepthFunc, WGC3Denum)
-
-DELEGATE_TO_GL_1(depthMask, DepthMask, WGC3Dboolean)
-
-DELEGATE_TO_GL_2(depthRange, DepthRangef, WGC3Dclampf, WGC3Dclampf)
-
-DELEGATE_TO_GL_2(detachShader, DetachShader, WebGLId, WebGLId)
-
-DELEGATE_TO_GL_1(disable, Disable, WGC3Denum)
-
-DELEGATE_TO_GL_1(disableVertexAttribArray, DisableVertexAttribArray,
- WGC3Duint)
-
-DELEGATE_TO_GL_3(drawArrays, DrawArrays, WGC3Denum, WGC3Dint, WGC3Dsizei)
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::drawElements(
- WGC3Denum mode,
- WGC3Dsizei count,
- WGC3Denum type,
- WGC3Dintptr offset) {
- ClearContext();
- gl_->DrawElements(
- mode, count, type,
- reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
-}
-
-DELEGATE_TO_GL_1(enable, Enable, WGC3Denum)
-
-DELEGATE_TO_GL_1(enableVertexAttribArray, EnableVertexAttribArray,
- WGC3Duint)
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::finish() {
- flush_id_ = GenFlushID();
- gl_->Finish();
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::flush() {
- flush_id_ = GenFlushID();
- gl_->Flush();
-}
-
-DELEGATE_TO_GL_4(framebufferRenderbuffer, FramebufferRenderbuffer,
- WGC3Denum, WGC3Denum, WGC3Denum, WebGLId)
-
-DELEGATE_TO_GL_5(framebufferTexture2D, FramebufferTexture2D,
- WGC3Denum, WGC3Denum, WGC3Denum, WebGLId, WGC3Dint)
-
-DELEGATE_TO_GL_1(frontFace, FrontFace, WGC3Denum)
-
-DELEGATE_TO_GL_1(generateMipmap, GenerateMipmap, WGC3Denum)
-
-bool WebGraphicsContext3DInProcessCommandBufferImpl::getActiveAttrib(
- WebGLId program, WGC3Duint index, ActiveInfo& info) {
- ClearContext();
- if (!program) {
- synthesizeGLError(GL_INVALID_VALUE);
- return false;
- }
- GLint max_name_length = -1;
- gl_->GetProgramiv(
- program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_name_length);
- if (max_name_length < 0)
- return false;
- scoped_ptr<GLchar[]> name(new GLchar[max_name_length]);
- if (!name) {
- synthesizeGLError(GL_OUT_OF_MEMORY);
- return false;
- }
- GLsizei length = 0;
- GLint size = -1;
- GLenum type = 0;
- gl_->GetActiveAttrib(
- program, index, max_name_length, &length, &size, &type, name.get());
- if (size < 0) {
- return false;
- }
- info.name = blink::WebString::fromUTF8(name.get(), length);
- info.type = type;
- info.size = size;
- return true;
-}
-
-bool WebGraphicsContext3DInProcessCommandBufferImpl::getActiveUniform(
- WebGLId program, WGC3Duint index, ActiveInfo& info) {
- ClearContext();
- GLint max_name_length = -1;
- gl_->GetProgramiv(
- program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max_name_length);
- if (max_name_length < 0)
- return false;
- scoped_ptr<GLchar[]> name(new GLchar[max_name_length]);
- if (!name) {
- synthesizeGLError(GL_OUT_OF_MEMORY);
- return false;
- }
- GLsizei length = 0;
- GLint size = -1;
- GLenum type = 0;
- gl_->GetActiveUniform(
- program, index, max_name_length, &length, &size, &type, name.get());
- if (size < 0) {
- return false;
- }
- info.name = blink::WebString::fromUTF8(name.get(), length);
- info.type = type;
- info.size = size;
- return true;
-}
-
-DELEGATE_TO_GL_4(getAttachedShaders, GetAttachedShaders,
- WebGLId, WGC3Dsizei, WGC3Dsizei*, WebGLId*)
-
-DELEGATE_TO_GL_2R(getAttribLocation, GetAttribLocation,
- WebGLId, const WGC3Dchar*, WGC3Dint)
-
-DELEGATE_TO_GL_2(getBooleanv, GetBooleanv, WGC3Denum, WGC3Dboolean*)
-
-DELEGATE_TO_GL_3(getBufferParameteriv, GetBufferParameteriv,
- WGC3Denum, WGC3Denum, WGC3Dint*)
-
-blink::WebGraphicsContext3D::Attributes
-WebGraphicsContext3DInProcessCommandBufferImpl::getContextAttributes() {
- return attributes_;
-}
-
-WGC3Denum WebGraphicsContext3DInProcessCommandBufferImpl::getError() {
- ClearContext();
- if (!synthetic_errors_.empty()) {
- std::vector<WGC3Denum>::iterator iter = synthetic_errors_.begin();
- WGC3Denum err = *iter;
- synthetic_errors_.erase(iter);
- return err;
- }
-
- return gl_->GetError();
-}
-
bool WebGraphicsContext3DInProcessCommandBufferImpl::isContextLost() {
return context_lost_reason_ != GL_NO_ERROR;
}
-DELEGATE_TO_GL_2(getFloatv, GetFloatv, WGC3Denum, WGC3Dfloat*)
-
-DELEGATE_TO_GL_4(getFramebufferAttachmentParameteriv,
- GetFramebufferAttachmentParameteriv,
- WGC3Denum, WGC3Denum, WGC3Denum, WGC3Dint*)
-
-DELEGATE_TO_GL_2(getIntegerv, GetIntegerv, WGC3Denum, WGC3Dint*)
-
-DELEGATE_TO_GL_3(getProgramiv, GetProgramiv, WebGLId, WGC3Denum, WGC3Dint*)
-
-blink::WebString WebGraphicsContext3DInProcessCommandBufferImpl::
- getProgramInfoLog(WebGLId program) {
- ClearContext();
- GLint logLength = 0;
- gl_->GetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength);
- if (!logLength)
- return blink::WebString();
- scoped_ptr<GLchar[]> log(new GLchar[logLength]);
- if (!log)
- return blink::WebString();
- GLsizei returnedLogLength = 0;
- gl_->GetProgramInfoLog(
- program, logLength, &returnedLogLength, log.get());
- DCHECK_EQ(logLength, returnedLogLength + 1);
- blink::WebString res =
- blink::WebString::fromUTF8(log.get(), returnedLogLength);
- return res;
-}
-
-DELEGATE_TO_GL_3(getRenderbufferParameteriv, GetRenderbufferParameteriv,
- WGC3Denum, WGC3Denum, WGC3Dint*)
-
-DELEGATE_TO_GL_3(getShaderiv, GetShaderiv, WebGLId, WGC3Denum, WGC3Dint*)
-
-blink::WebString WebGraphicsContext3DInProcessCommandBufferImpl::
- getShaderInfoLog(WebGLId shader) {
- ClearContext();
- GLint logLength = 0;
- gl_->GetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength);
- if (!logLength)
- return blink::WebString();
- scoped_ptr<GLchar[]> log(new GLchar[logLength]);
- if (!log)
- return blink::WebString();
- GLsizei returnedLogLength = 0;
- gl_->GetShaderInfoLog(
- shader, logLength, &returnedLogLength, log.get());
- DCHECK_EQ(logLength, returnedLogLength + 1);
- blink::WebString res =
- blink::WebString::fromUTF8(log.get(), returnedLogLength);
- return res;
-}
-
-DELEGATE_TO_GL_4(getShaderPrecisionFormat, GetShaderPrecisionFormat,
- WGC3Denum, WGC3Denum, WGC3Dint*, WGC3Dint*)
-
-blink::WebString WebGraphicsContext3DInProcessCommandBufferImpl::
- getShaderSource(WebGLId shader) {
- ClearContext();
- GLint logLength = 0;
- gl_->GetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &logLength);
- if (!logLength)
- return blink::WebString();
- scoped_ptr<GLchar[]> log(new GLchar[logLength]);
- if (!log)
- return blink::WebString();
- GLsizei returnedLogLength = 0;
- gl_->GetShaderSource(
- shader, logLength, &returnedLogLength, log.get());
- if (!returnedLogLength)
- return blink::WebString();
- DCHECK_EQ(logLength, returnedLogLength + 1);
- blink::WebString res =
- blink::WebString::fromUTF8(log.get(), returnedLogLength);
- return res;
-}
-
-blink::WebString WebGraphicsContext3DInProcessCommandBufferImpl::
- getTranslatedShaderSourceANGLE(WebGLId shader) {
- ClearContext();
- GLint logLength = 0;
- gl_->GetShaderiv(
- shader, GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE, &logLength);
- if (!logLength)
- return blink::WebString();
- scoped_ptr<GLchar[]> log(new GLchar[logLength]);
- if (!log)
- return blink::WebString();
- GLsizei returnedLogLength = 0;
- gl_->GetTranslatedShaderSourceANGLE(
- shader, logLength, &returnedLogLength, log.get());
- if (!returnedLogLength)
- return blink::WebString();
- DCHECK_EQ(logLength, returnedLogLength + 1);
- blink::WebString res =
- blink::WebString::fromUTF8(log.get(), returnedLogLength);
- return res;
-}
-
-blink::WebString WebGraphicsContext3DInProcessCommandBufferImpl::getString(
- WGC3Denum name) {
- ClearContext();
- return blink::WebString::fromUTF8(
- reinterpret_cast<const char*>(gl_->GetString(name)));
-}
-
-DELEGATE_TO_GL_3(getTexParameterfv, GetTexParameterfv,
- WGC3Denum, WGC3Denum, WGC3Dfloat*)
-
-DELEGATE_TO_GL_3(getTexParameteriv, GetTexParameteriv,
- WGC3Denum, WGC3Denum, WGC3Dint*)
-
-DELEGATE_TO_GL_3(getUniformfv, GetUniformfv, WebGLId, WGC3Dint, WGC3Dfloat*)
-
-DELEGATE_TO_GL_3(getUniformiv, GetUniformiv, WebGLId, WGC3Dint, WGC3Dint*)
-
-DELEGATE_TO_GL_2R(getUniformLocation, GetUniformLocation,
- WebGLId, const WGC3Dchar*, WGC3Dint)
-
-DELEGATE_TO_GL_3(getVertexAttribfv, GetVertexAttribfv,
- WGC3Duint, WGC3Denum, WGC3Dfloat*)
-
-DELEGATE_TO_GL_3(getVertexAttribiv, GetVertexAttribiv,
- WGC3Duint, WGC3Denum, WGC3Dint*)
-
-WGC3Dsizeiptr WebGraphicsContext3DInProcessCommandBufferImpl::
- getVertexAttribOffset(WGC3Duint index, WGC3Denum pname) {
- ClearContext();
- GLvoid* value = NULL;
- // NOTE: If pname is ever a value that returns more then 1 element
- // this will corrupt memory.
- gl_->GetVertexAttribPointerv(index, pname, &value);
- return static_cast<WGC3Dsizeiptr>(reinterpret_cast<intptr_t>(value));
-}
-
-DELEGATE_TO_GL_2(hint, Hint, WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_1RB(isBuffer, IsBuffer, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isEnabled, IsEnabled, WGC3Denum, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isFramebuffer, IsFramebuffer, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isProgram, IsProgram, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isRenderbuffer, IsRenderbuffer, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isShader, IsShader, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1RB(isTexture, IsTexture, WebGLId, WGC3Dboolean)
-
-DELEGATE_TO_GL_1(lineWidth, LineWidth, WGC3Dfloat)
-
-DELEGATE_TO_GL_1(linkProgram, LinkProgram, WebGLId)
-
-DELEGATE_TO_GL_2(pixelStorei, PixelStorei, WGC3Denum, WGC3Dint)
-
-DELEGATE_TO_GL_2(polygonOffset, PolygonOffset, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_7(readPixels, ReadPixels,
- WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei, WGC3Denum,
- WGC3Denum, void*)
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::releaseShaderCompiler() {
- ClearContext();
-}
-
-DELEGATE_TO_GL_4(renderbufferStorage, RenderbufferStorage,
- WGC3Denum, WGC3Denum, WGC3Dsizei, WGC3Dsizei)
-
-DELEGATE_TO_GL_2(sampleCoverage, SampleCoverage, WGC3Dfloat, WGC3Dboolean)
-
-DELEGATE_TO_GL_4(scissor, Scissor, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei)
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::shaderSource(
- WebGLId shader, const WGC3Dchar* string) {
- ClearContext();
- GLint length = strlen(string);
- gl_->ShaderSource(shader, 1, &string, &length);
-}
-
-DELEGATE_TO_GL_3(stencilFunc, StencilFunc, WGC3Denum, WGC3Dint, WGC3Duint)
-
-DELEGATE_TO_GL_4(stencilFuncSeparate, StencilFuncSeparate,
- WGC3Denum, WGC3Denum, WGC3Dint, WGC3Duint)
-
-DELEGATE_TO_GL_1(stencilMask, StencilMask, WGC3Duint)
-
-DELEGATE_TO_GL_2(stencilMaskSeparate, StencilMaskSeparate,
- WGC3Denum, WGC3Duint)
-
-DELEGATE_TO_GL_3(stencilOp, StencilOp,
- WGC3Denum, WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_4(stencilOpSeparate, StencilOpSeparate,
- WGC3Denum, WGC3Denum, WGC3Denum, WGC3Denum)
-
-DELEGATE_TO_GL_9(texImage2D, TexImage2D,
- WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei,
- WGC3Dint, WGC3Denum, WGC3Denum, const void*)
-
-DELEGATE_TO_GL_3(texParameterf, TexParameterf,
- WGC3Denum, WGC3Denum, WGC3Dfloat);
-
-static const unsigned int kTextureWrapR = 0x8072;
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::texParameteri(
- WGC3Denum target, WGC3Denum pname, WGC3Dint param) {
- ClearContext();
- // TODO(kbr): figure out whether the setting of TEXTURE_WRAP_R in
- // GraphicsContext3D.cpp is strictly necessary to avoid seams at the
- // edge of cube maps, and, if it is, push it into the GLES2 service
- // side code.
- if (pname == kTextureWrapR) {
- return;
- }
- gl_->TexParameteri(target, pname, param);
-}
-
-DELEGATE_TO_GL_9(texSubImage2D, TexSubImage2D,
- WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei,
- WGC3Dsizei, WGC3Denum, WGC3Denum, const void*)
-
-DELEGATE_TO_GL_2(uniform1f, Uniform1f, WGC3Dint, WGC3Dfloat)
-
-DELEGATE_TO_GL_3(uniform1fv, Uniform1fv, WGC3Dint, WGC3Dsizei,
- const WGC3Dfloat*)
-
-DELEGATE_TO_GL_2(uniform1i, Uniform1i, WGC3Dint, WGC3Dint)
-
-DELEGATE_TO_GL_3(uniform1iv, Uniform1iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
-
-DELEGATE_TO_GL_3(uniform2f, Uniform2f, WGC3Dint, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_3(uniform2fv, Uniform2fv, WGC3Dint, WGC3Dsizei,
- const WGC3Dfloat*)
-
-DELEGATE_TO_GL_3(uniform2i, Uniform2i, WGC3Dint, WGC3Dint, WGC3Dint)
-
-DELEGATE_TO_GL_3(uniform2iv, Uniform2iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
-
-DELEGATE_TO_GL_4(uniform3f, Uniform3f, WGC3Dint,
- WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_3(uniform3fv, Uniform3fv, WGC3Dint, WGC3Dsizei,
- const WGC3Dfloat*)
-
-DELEGATE_TO_GL_4(uniform3i, Uniform3i, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint)
-
-DELEGATE_TO_GL_3(uniform3iv, Uniform3iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
-
-DELEGATE_TO_GL_5(uniform4f, Uniform4f, WGC3Dint,
- WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_3(uniform4fv, Uniform4fv, WGC3Dint, WGC3Dsizei,
- const WGC3Dfloat*)
-
-DELEGATE_TO_GL_5(uniform4i, Uniform4i, WGC3Dint,
- WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dint)
-
-DELEGATE_TO_GL_3(uniform4iv, Uniform4iv, WGC3Dint, WGC3Dsizei, const WGC3Dint*)
-
-DELEGATE_TO_GL_4(uniformMatrix2fv, UniformMatrix2fv,
- WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
-
-DELEGATE_TO_GL_4(uniformMatrix3fv, UniformMatrix3fv,
- WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
-
-DELEGATE_TO_GL_4(uniformMatrix4fv, UniformMatrix4fv,
- WGC3Dint, WGC3Dsizei, WGC3Dboolean, const WGC3Dfloat*)
-
-DELEGATE_TO_GL_1(useProgram, UseProgram, WebGLId)
-
-DELEGATE_TO_GL_1(validateProgram, ValidateProgram, WebGLId)
-
-DELEGATE_TO_GL_2(vertexAttrib1f, VertexAttrib1f, WGC3Duint, WGC3Dfloat)
-
-DELEGATE_TO_GL_2(vertexAttrib1fv, VertexAttrib1fv, WGC3Duint,
- const WGC3Dfloat*)
-
-DELEGATE_TO_GL_3(vertexAttrib2f, VertexAttrib2f, WGC3Duint,
- WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_2(vertexAttrib2fv, VertexAttrib2fv, WGC3Duint,
- const WGC3Dfloat*)
-
-DELEGATE_TO_GL_4(vertexAttrib3f, VertexAttrib3f, WGC3Duint,
- WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_2(vertexAttrib3fv, VertexAttrib3fv, WGC3Duint,
- const WGC3Dfloat*)
-
-DELEGATE_TO_GL_5(vertexAttrib4f, VertexAttrib4f, WGC3Duint,
- WGC3Dfloat, WGC3Dfloat, WGC3Dfloat, WGC3Dfloat)
-
-DELEGATE_TO_GL_2(vertexAttrib4fv, VertexAttrib4fv, WGC3Duint,
- const WGC3Dfloat*)
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::vertexAttribPointer(
- WGC3Duint index, WGC3Dint size, WGC3Denum type, WGC3Dboolean normalized,
- WGC3Dsizei stride, WGC3Dintptr offset) {
- ClearContext();
- gl_->VertexAttribPointer(
- index, size, type, normalized, stride,
- reinterpret_cast<void*>(static_cast<intptr_t>(offset)));
-}
-
-DELEGATE_TO_GL_4(viewport, Viewport,
- WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei)
-
-DELEGATE_TO_GL_2(genBuffers, GenBuffers, WGC3Dsizei, WebGLId*);
-
-DELEGATE_TO_GL_2(genFramebuffers, GenFramebuffers, WGC3Dsizei, WebGLId*);
-
-DELEGATE_TO_GL_2(genRenderbuffers, GenRenderbuffers, WGC3Dsizei, WebGLId*);
-
-DELEGATE_TO_GL_2(genTextures, GenTextures, WGC3Dsizei, WebGLId*);
-
-DELEGATE_TO_GL_2(deleteBuffers, DeleteBuffers, WGC3Dsizei, WebGLId*);
-
-DELEGATE_TO_GL_2(deleteFramebuffers, DeleteFramebuffers, WGC3Dsizei, WebGLId*);
-
-DELEGATE_TO_GL_2(deleteRenderbuffers, DeleteRenderbuffers, WGC3Dsizei,
- WebGLId*);
-
-DELEGATE_TO_GL_2(deleteTextures, DeleteTextures, WGC3Dsizei, WebGLId*);
-
-WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createBuffer() {
- ClearContext();
- GLuint o;
- gl_->GenBuffers(1, &o);
- return o;
-}
-
-WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createFramebuffer() {
- ClearContext();
- GLuint o = 0;
- gl_->GenFramebuffers(1, &o);
- return o;
-}
-
-WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createRenderbuffer() {
- ClearContext();
- GLuint o;
- gl_->GenRenderbuffers(1, &o);
- return o;
-}
-
-WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createTexture() {
- ClearContext();
- GLuint o;
- gl_->GenTextures(1, &o);
- return o;
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::deleteBuffer(
- WebGLId buffer) {
- ClearContext();
- gl_->DeleteBuffers(1, &buffer);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::deleteFramebuffer(
- WebGLId framebuffer) {
- ClearContext();
- gl_->DeleteFramebuffers(1, &framebuffer);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::deleteRenderbuffer(
- WebGLId renderbuffer) {
- ClearContext();
- gl_->DeleteRenderbuffers(1, &renderbuffer);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::deleteTexture(
- WebGLId texture) {
- ClearContext();
- gl_->DeleteTextures(1, &texture);
-}
-
-DELEGATE_TO_GL_R(createProgram, CreateProgram, WebGLId);
-
-DELEGATE_TO_GL_1R(createShader, CreateShader, WGC3Denum, WebGLId);
-
-DELEGATE_TO_GL_1(deleteProgram, DeleteProgram, WebGLId);
-
-DELEGATE_TO_GL_1(deleteShader, DeleteShader, WebGLId);
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::setContextLostCallback(
- WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) {
- context_lost_callback_ = cb;
-}
-
WGC3Denum WebGraphicsContext3DInProcessCommandBufferImpl::
getGraphicsResetStatusARB() {
return context_lost_reason_;
}
-DELEGATE_TO_GL_5(texImageIOSurface2DCHROMIUM, TexImageIOSurface2DCHROMIUM,
- WGC3Denum, WGC3Dint, WGC3Dint, WGC3Duint, WGC3Duint)
-
-DELEGATE_TO_GL_5(texStorage2DEXT, TexStorage2DEXT,
- WGC3Denum, WGC3Dint, WGC3Duint, WGC3Dint, WGC3Dint)
-
-WebGLId WebGraphicsContext3DInProcessCommandBufferImpl::createQueryEXT() {
- GLuint o;
- gl_->GenQueriesEXT(1, &o);
- return o;
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::
- deleteQueryEXT(WebGLId query) {
- gl_->DeleteQueriesEXT(1, &query);
-}
-
-DELEGATE_TO_GL_1R(isQueryEXT, IsQueryEXT, WebGLId, WGC3Dboolean)
-DELEGATE_TO_GL_2(beginQueryEXT, BeginQueryEXT, WGC3Denum, WebGLId)
-DELEGATE_TO_GL_1(endQueryEXT, EndQueryEXT, WGC3Denum)
-DELEGATE_TO_GL_3(getQueryivEXT, GetQueryivEXT, WGC3Denum, WGC3Denum, WGC3Dint*)
-DELEGATE_TO_GL_3(getQueryObjectuivEXT, GetQueryObjectuivEXT,
- WebGLId, WGC3Denum, WGC3Duint*)
-
-DELEGATE_TO_GL_6(copyTextureCHROMIUM, CopyTextureCHROMIUM, WGC3Denum, WGC3Duint,
- WGC3Duint, WGC3Dint, WGC3Denum, WGC3Denum)
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::insertEventMarkerEXT(
- const WGC3Dchar* marker) {
- gl_->InsertEventMarkerEXT(0, marker);
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::pushGroupMarkerEXT(
- const WGC3Dchar* marker) {
- gl_->PushGroupMarkerEXT(0, marker);
-}
-
-DELEGATE_TO_GL(popGroupMarkerEXT, PopGroupMarkerEXT);
-
-DELEGATE_TO_GL_2(bindTexImage2DCHROMIUM, BindTexImage2DCHROMIUM,
- WGC3Denum, WGC3Dint)
-DELEGATE_TO_GL_2(releaseTexImage2DCHROMIUM, ReleaseTexImage2DCHROMIUM,
- WGC3Denum, WGC3Dint)
-
-DELEGATE_TO_GL_1R(createStreamTextureCHROMIUM, CreateStreamTextureCHROMIUM,
- WebGLId, WebGLId)
-DELEGATE_TO_GL_1(destroyStreamTextureCHROMIUM, DestroyStreamTextureCHROMIUM,
- WebGLId)
-
-void* WebGraphicsContext3DInProcessCommandBufferImpl::mapBufferCHROMIUM(
- WGC3Denum target, WGC3Denum access) {
- ClearContext();
- return gl_->MapBufferCHROMIUM(target, access);
-}
-
-WGC3Dboolean WebGraphicsContext3DInProcessCommandBufferImpl::
- unmapBufferCHROMIUM(WGC3Denum target) {
- ClearContext();
- return gl_->UnmapBufferCHROMIUM(target);
-}
-
-GrGLInterface* WebGraphicsContext3DInProcessCommandBufferImpl::
- createGrGLInterface() {
- return skia_bindings::CreateCommandBufferSkiaGLBinding();
-}
-
-::gpu::gles2::GLES2Interface*
-WebGraphicsContext3DInProcessCommandBufferImpl::GetGLInterface() {
- return gl_;
-}
-
::gpu::ContextSupport*
WebGraphicsContext3DInProcessCommandBufferImpl::GetContextSupport() {
- return gl_;
+ return real_gl_;
}
void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() {
@@ -1140,59 +213,5 @@ void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() {
}
}
-DELEGATE_TO_GL_3R(createImageCHROMIUM, CreateImageCHROMIUM,
- WGC3Dsizei, WGC3Dsizei, WGC3Denum, WGC3Duint);
-
-DELEGATE_TO_GL_1(destroyImageCHROMIUM, DestroyImageCHROMIUM, WGC3Duint);
-
-DELEGATE_TO_GL_3(getImageParameterivCHROMIUM, GetImageParameterivCHROMIUM,
- WGC3Duint, WGC3Denum, GLint*);
-
-DELEGATE_TO_GL_2R(mapImageCHROMIUM, MapImageCHROMIUM,
- WGC3Duint, WGC3Denum, void*);
-
-DELEGATE_TO_GL_1(unmapImageCHROMIUM, UnmapImageCHROMIUM, WGC3Duint);
-
-DELEGATE_TO_GL_3(bindUniformLocationCHROMIUM, BindUniformLocationCHROMIUM,
- WebGLId, WGC3Dint, const WGC3Dchar*)
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::shallowFlushCHROMIUM() {
- flush_id_ = GenFlushID();
- gl_->ShallowFlushCHROMIUM();
-}
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::shallowFinishCHROMIUM() {
- flush_id_ = GenFlushID();
- gl_->ShallowFinishCHROMIUM();
-}
-
-DELEGATE_TO_GL_1(genMailboxCHROMIUM, GenMailboxCHROMIUM, WGC3Dbyte*)
-DELEGATE_TO_GL_2(produceTextureCHROMIUM, ProduceTextureCHROMIUM,
- WGC3Denum, const WGC3Dbyte*)
-DELEGATE_TO_GL_2(consumeTextureCHROMIUM, ConsumeTextureCHROMIUM,
- WGC3Denum, const WGC3Dbyte*)
-
-DELEGATE_TO_GL_2(drawBuffersEXT, DrawBuffersEXT,
- WGC3Dsizei, const WGC3Denum*)
-
-DELEGATE_TO_GL_R(insertSyncPoint, InsertSyncPointCHROMIUM, unsigned)
-
-void WebGraphicsContext3DInProcessCommandBufferImpl::loseContextCHROMIUM(
- WGC3Denum current, WGC3Denum other) {
- gl_->LoseContextCHROMIUM(current, other);
- gl_->ShallowFlushCHROMIUM();
-}
-
-DELEGATE_TO_GL_9(asyncTexImage2DCHROMIUM, AsyncTexImage2DCHROMIUM,
- WGC3Denum, WGC3Dint, WGC3Denum, WGC3Dsizei, WGC3Dsizei, WGC3Dint,
- WGC3Denum, WGC3Denum, const void*)
-
-DELEGATE_TO_GL_9(asyncTexSubImage2DCHROMIUM, AsyncTexSubImage2DCHROMIUM,
- WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei,
- WGC3Denum, WGC3Denum, const void*)
-
-DELEGATE_TO_GL_1(waitAsyncTexImage2DCHROMIUM, WaitAsyncTexImage2DCHROMIUM,
- WGC3Denum)
-
} // namespace gpu
} // namespace webkit
diff --git a/chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h b/chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h
index 07dd18e7ee9..5ab1a1728d4 100644
--- a/chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h
+++ b/chromium/webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h
@@ -9,9 +9,11 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
+#include "gpu/command_buffer/client/gl_in_process_context.h"
#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "ui/gfx/native_widget_types.h"
+#include "webkit/common/gpu/webgraphicscontext3d_impl.h"
#include "webkit/common/gpu/webkit_gpu_export.h"
namespace gpu {
@@ -23,21 +25,6 @@ class GLES2Implementation;
}
}
-using blink::WebGLId;
-
-using blink::WGC3Dbyte;
-using blink::WGC3Dchar;
-using blink::WGC3Denum;
-using blink::WGC3Dboolean;
-using blink::WGC3Dbitfield;
-using blink::WGC3Dint;
-using blink::WGC3Dsizei;
-using blink::WGC3Duint;
-using blink::WGC3Dfloat;
-using blink::WGC3Dclampf;
-using blink::WGC3Dintptr;
-using blink::WGC3Dsizeiptr;
-
namespace gpu {
class GLInProcessContext;
struct GLInProcessContextAttribs;
@@ -47,16 +34,18 @@ namespace webkit {
namespace gpu {
class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl
- : public NON_EXPORTED_BASE(blink::WebGraphicsContext3D) {
+ : public WebGraphicsContext3DImpl {
public:
static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
CreateViewContext(
const blink::WebGraphicsContext3D::Attributes& attributes,
+ bool lose_context_when_out_of_memory,
gfx::AcceleratedWidget window);
static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
CreateOffscreenContext(
- const blink::WebGraphicsContext3D::Attributes& attributes);
+ const blink::WebGraphicsContext3D::Attributes& attributes,
+ bool lose_context_when_out_of_memory);
static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
WrapContext(
@@ -75,494 +64,21 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl
// WebGraphicsContext3D methods
virtual bool makeContextCurrent();
- virtual uint32_t lastFlushID();
-
- virtual void reshapeWithScaleFactor(int width, int height, float scaleFactor);
-
- virtual void prepareTexture();
- virtual void postSubBufferCHROMIUM(int x, int y, int width, int height);
-
- virtual void activeTexture(WGC3Denum texture);
- virtual void attachShader(WebGLId program, WebGLId shader);
- virtual void bindAttribLocation(WebGLId program, WGC3Duint index,
- const WGC3Dchar* name);
- virtual void bindBuffer(WGC3Denum target, WebGLId buffer);
- virtual void bindFramebuffer(WGC3Denum target, WebGLId framebuffer);
- virtual void bindRenderbuffer(WGC3Denum target, WebGLId renderbuffer);
- virtual void bindTexture(WGC3Denum target, WebGLId texture);
- virtual void blendColor(WGC3Dclampf red, WGC3Dclampf green,
- WGC3Dclampf blue, WGC3Dclampf alpha);
- virtual void blendEquation(WGC3Denum mode);
- virtual void blendEquationSeparate(WGC3Denum modeRGB,
- WGC3Denum modeAlpha);
- virtual void blendFunc(WGC3Denum sfactor, WGC3Denum dfactor);
- virtual void blendFuncSeparate(WGC3Denum srcRGB,
- WGC3Denum dstRGB,
- WGC3Denum srcAlpha,
- WGC3Denum dstAlpha);
-
- virtual void bufferData(WGC3Denum target, WGC3Dsizeiptr size,
- const void* data, WGC3Denum usage);
- virtual void bufferSubData(WGC3Denum target, WGC3Dintptr offset,
- WGC3Dsizeiptr size, const void* data);
-
- virtual WGC3Denum checkFramebufferStatus(WGC3Denum target);
- virtual void clear(WGC3Dbitfield mask);
- virtual void clearColor(WGC3Dclampf red, WGC3Dclampf green,
- WGC3Dclampf blue, WGC3Dclampf alpha);
- virtual void clearDepth(WGC3Dclampf depth);
- virtual void clearStencil(WGC3Dint s);
- virtual void colorMask(WGC3Dboolean red, WGC3Dboolean green,
- WGC3Dboolean blue, WGC3Dboolean alpha);
- virtual void compileShader(WebGLId shader);
-
- virtual void compressedTexImage2D(WGC3Denum target,
- WGC3Dint level,
- WGC3Denum internalformat,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Dint border,
- WGC3Dsizei imageSize,
- const void* data);
- virtual void compressedTexSubImage2D(WGC3Denum target,
- WGC3Dint level,
- WGC3Dint xoffset,
- WGC3Dint yoffset,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Denum format,
- WGC3Dsizei imageSize,
- const void* data);
- virtual void copyTexImage2D(WGC3Denum target,
- WGC3Dint level,
- WGC3Denum internalformat,
- WGC3Dint x,
- WGC3Dint y,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Dint border);
- virtual void copyTexSubImage2D(WGC3Denum target,
- WGC3Dint level,
- WGC3Dint xoffset,
- WGC3Dint yoffset,
- WGC3Dint x,
- WGC3Dint y,
- WGC3Dsizei width,
- WGC3Dsizei height);
- virtual void cullFace(WGC3Denum mode);
- virtual void depthFunc(WGC3Denum func);
- virtual void depthMask(WGC3Dboolean flag);
- virtual void depthRange(WGC3Dclampf zNear, WGC3Dclampf zFar);
- virtual void detachShader(WebGLId program, WebGLId shader);
- virtual void disable(WGC3Denum cap);
- virtual void disableVertexAttribArray(WGC3Duint index);
- virtual void drawArrays(WGC3Denum mode, WGC3Dint first, WGC3Dsizei count);
- virtual void drawElements(WGC3Denum mode,
- WGC3Dsizei count,
- WGC3Denum type,
- WGC3Dintptr offset);
-
- virtual void enable(WGC3Denum cap);
- virtual void enableVertexAttribArray(WGC3Duint index);
- virtual void finish();
- virtual void flush();
- virtual void framebufferRenderbuffer(WGC3Denum target,
- WGC3Denum attachment,
- WGC3Denum renderbuffertarget,
- WebGLId renderbuffer);
- virtual void framebufferTexture2D(WGC3Denum target,
- WGC3Denum attachment,
- WGC3Denum textarget,
- WebGLId texture,
- WGC3Dint level);
- virtual void frontFace(WGC3Denum mode);
- virtual void generateMipmap(WGC3Denum target);
-
- virtual bool getActiveAttrib(WebGLId program,
- WGC3Duint index,
- ActiveInfo&);
- virtual bool getActiveUniform(WebGLId program,
- WGC3Duint index,
- ActiveInfo&);
-
- virtual void getAttachedShaders(WebGLId program,
- WGC3Dsizei maxCount,
- WGC3Dsizei* count,
- WebGLId* shaders);
-
- virtual WGC3Dint getAttribLocation(WebGLId program, const WGC3Dchar* name);
-
- virtual void getBooleanv(WGC3Denum pname, WGC3Dboolean* value);
-
- virtual void getBufferParameteriv(WGC3Denum target,
- WGC3Denum pname,
- WGC3Dint* value);
-
- virtual Attributes getContextAttributes();
-
- virtual WGC3Denum getError();
-
virtual bool isContextLost();
- virtual void getFloatv(WGC3Denum pname, WGC3Dfloat* value);
-
- virtual void getFramebufferAttachmentParameteriv(WGC3Denum target,
- WGC3Denum attachment,
- WGC3Denum pname,
- WGC3Dint* value);
-
- virtual void getIntegerv(WGC3Denum pname, WGC3Dint* value);
-
- virtual void getProgramiv(WebGLId program, WGC3Denum pname, WGC3Dint* value);
-
- virtual blink::WebString getProgramInfoLog(WebGLId program);
-
- virtual void getRenderbufferParameteriv(WGC3Denum target,
- WGC3Denum pname,
- WGC3Dint* value);
-
- virtual void getShaderiv(WebGLId shader, WGC3Denum pname, WGC3Dint* value);
-
- virtual blink::WebString getShaderInfoLog(WebGLId shader);
-
- virtual void getShaderPrecisionFormat(WGC3Denum shadertype,
- WGC3Denum precisiontype,
- WGC3Dint* range,
- WGC3Dint* precision);
-
- virtual blink::WebString getShaderSource(WebGLId shader);
- virtual blink::WebString getString(WGC3Denum name);
-
- virtual void getTexParameterfv(WGC3Denum target,
- WGC3Denum pname,
- WGC3Dfloat* value);
- virtual void getTexParameteriv(WGC3Denum target,
- WGC3Denum pname,
- WGC3Dint* value);
-
- virtual void getUniformfv(WebGLId program,
- WGC3Dint location,
- WGC3Dfloat* value);
- virtual void getUniformiv(WebGLId program,
- WGC3Dint location,
- WGC3Dint* value);
-
- virtual WGC3Dint getUniformLocation(WebGLId program, const WGC3Dchar* name);
-
- virtual void getVertexAttribfv(WGC3Duint index, WGC3Denum pname,
- WGC3Dfloat* value);
- virtual void getVertexAttribiv(WGC3Duint index, WGC3Denum pname,
- WGC3Dint* value);
-
- virtual WGC3Dsizeiptr getVertexAttribOffset(WGC3Duint index, WGC3Denum pname);
-
- virtual void hint(WGC3Denum target, WGC3Denum mode);
- virtual WGC3Dboolean isBuffer(WebGLId buffer);
- virtual WGC3Dboolean isEnabled(WGC3Denum cap);
- virtual WGC3Dboolean isFramebuffer(WebGLId framebuffer);
- virtual WGC3Dboolean isProgram(WebGLId program);
- virtual WGC3Dboolean isRenderbuffer(WebGLId renderbuffer);
- virtual WGC3Dboolean isShader(WebGLId shader);
- virtual WGC3Dboolean isTexture(WebGLId texture);
- virtual void lineWidth(WGC3Dfloat);
- virtual void linkProgram(WebGLId program);
- virtual void pixelStorei(WGC3Denum pname, WGC3Dint param);
- virtual void polygonOffset(WGC3Dfloat factor, WGC3Dfloat units);
-
- virtual void readPixels(WGC3Dint x,
- WGC3Dint y,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Denum format,
- WGC3Denum type,
- void* pixels);
-
- virtual void releaseShaderCompiler();
- virtual void renderbufferStorage(WGC3Denum target,
- WGC3Denum internalformat,
- WGC3Dsizei width,
- WGC3Dsizei height);
- virtual void sampleCoverage(WGC3Dfloat value, WGC3Dboolean invert);
- virtual void scissor(WGC3Dint x, WGC3Dint y,
- WGC3Dsizei width, WGC3Dsizei height);
- virtual void shaderSource(WebGLId shader, const WGC3Dchar* string);
- virtual void stencilFunc(WGC3Denum func, WGC3Dint ref, WGC3Duint mask);
- virtual void stencilFuncSeparate(WGC3Denum face,
- WGC3Denum func,
- WGC3Dint ref,
- WGC3Duint mask);
- virtual void stencilMask(WGC3Duint mask);
- virtual void stencilMaskSeparate(WGC3Denum face, WGC3Duint mask);
- virtual void stencilOp(WGC3Denum fail,
- WGC3Denum zfail,
- WGC3Denum zpass);
- virtual void stencilOpSeparate(WGC3Denum face,
- WGC3Denum fail,
- WGC3Denum zfail,
- WGC3Denum zpass);
-
- virtual void texImage2D(WGC3Denum target,
- WGC3Dint level,
- WGC3Denum internalformat,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Dint border,
- WGC3Denum format,
- WGC3Denum type,
- const void* pixels);
-
- virtual void texParameterf(WGC3Denum target,
- WGC3Denum pname,
- WGC3Dfloat param);
- virtual void texParameteri(WGC3Denum target,
- WGC3Denum pname,
- WGC3Dint param);
-
- virtual void texSubImage2D(WGC3Denum target,
- WGC3Dint level,
- WGC3Dint xoffset,
- WGC3Dint yoffset,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Denum format,
- WGC3Denum type,
- const void* pixels);
-
- virtual void uniform1f(WGC3Dint location, WGC3Dfloat x);
- virtual void uniform1fv(WGC3Dint location,
- WGC3Dsizei count, const WGC3Dfloat* v);
- virtual void uniform1i(WGC3Dint location, WGC3Dint x);
- virtual void uniform1iv(WGC3Dint location,
- WGC3Dsizei count, const WGC3Dint* v);
- virtual void uniform2f(WGC3Dint location, WGC3Dfloat x, WGC3Dfloat y);
- virtual void uniform2fv(WGC3Dint location,
- WGC3Dsizei count, const WGC3Dfloat* v);
- virtual void uniform2i(WGC3Dint location, WGC3Dint x, WGC3Dint y);
- virtual void uniform2iv(WGC3Dint location,
- WGC3Dsizei count, const WGC3Dint* v);
- virtual void uniform3f(WGC3Dint location,
- WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z);
- virtual void uniform3fv(WGC3Dint location,
- WGC3Dsizei count, const WGC3Dfloat* v);
- virtual void uniform3i(WGC3Dint location,
- WGC3Dint x, WGC3Dint y, WGC3Dint z);
- virtual void uniform3iv(WGC3Dint location,
- WGC3Dsizei count, const WGC3Dint* v);
- virtual void uniform4f(WGC3Dint location,
- WGC3Dfloat x, WGC3Dfloat y,
- WGC3Dfloat z, WGC3Dfloat w);
- virtual void uniform4fv(WGC3Dint location,
- WGC3Dsizei count, const WGC3Dfloat* v);
- virtual void uniform4i(WGC3Dint location,
- WGC3Dint x, WGC3Dint y, WGC3Dint z, WGC3Dint w);
- virtual void uniform4iv(WGC3Dint location,
- WGC3Dsizei count, const WGC3Dint* v);
- virtual void uniformMatrix2fv(WGC3Dint location,
- WGC3Dsizei count,
- WGC3Dboolean transpose,
- const WGC3Dfloat* value);
- virtual void uniformMatrix3fv(WGC3Dint location,
- WGC3Dsizei count,
- WGC3Dboolean transpose,
- const WGC3Dfloat* value);
- virtual void uniformMatrix4fv(WGC3Dint location,
- WGC3Dsizei count,
- WGC3Dboolean transpose,
- const WGC3Dfloat* value);
-
- virtual void useProgram(WebGLId program);
- virtual void validateProgram(WebGLId program);
-
- virtual void vertexAttrib1f(WGC3Duint index, WGC3Dfloat x);
- virtual void vertexAttrib1fv(WGC3Duint index, const WGC3Dfloat* values);
- virtual void vertexAttrib2f(WGC3Duint index, WGC3Dfloat x, WGC3Dfloat y);
- virtual void vertexAttrib2fv(WGC3Duint index, const WGC3Dfloat* values);
- virtual void vertexAttrib3f(WGC3Duint index,
- WGC3Dfloat x, WGC3Dfloat y, WGC3Dfloat z);
- virtual void vertexAttrib3fv(WGC3Duint index, const WGC3Dfloat* values);
- virtual void vertexAttrib4f(WGC3Duint index,
- WGC3Dfloat x, WGC3Dfloat y,
- WGC3Dfloat z, WGC3Dfloat w);
- virtual void vertexAttrib4fv(WGC3Duint index, const WGC3Dfloat* values);
- virtual void vertexAttribPointer(WGC3Duint index,
- WGC3Dint size,
- WGC3Denum type,
- WGC3Dboolean normalized,
- WGC3Dsizei stride,
- WGC3Dintptr offset);
-
- virtual void viewport(WGC3Dint x, WGC3Dint y,
- WGC3Dsizei width, WGC3Dsizei height);
-
- // Support for buffer creation and deletion
- virtual void genBuffers(WGC3Dsizei count, WebGLId* ids);
- virtual void genFramebuffers(WGC3Dsizei count, WebGLId* ids);
- virtual void genRenderbuffers(WGC3Dsizei count, WebGLId* ids);
- virtual void genTextures(WGC3Dsizei count, WebGLId* ids);
-
- virtual void deleteBuffers(WGC3Dsizei count, WebGLId* ids);
- virtual void deleteFramebuffers(WGC3Dsizei count, WebGLId* ids);
- virtual void deleteRenderbuffers(WGC3Dsizei count, WebGLId* ids);
- virtual void deleteTextures(WGC3Dsizei count, WebGLId* ids);
-
- virtual WebGLId createBuffer();
- virtual WebGLId createFramebuffer();
- virtual WebGLId createRenderbuffer();
- virtual WebGLId createTexture();
-
- virtual void deleteBuffer(WebGLId);
- virtual void deleteFramebuffer(WebGLId);
- virtual void deleteRenderbuffer(WebGLId);
- virtual void deleteTexture(WebGLId);
-
- virtual WebGLId createProgram();
- virtual WebGLId createShader(WGC3Denum);
-
- virtual void deleteProgram(WebGLId);
- virtual void deleteShader(WebGLId);
-
- virtual void synthesizeGLError(WGC3Denum);
-
- virtual void* mapBufferSubDataCHROMIUM(
- WGC3Denum target, WGC3Dintptr offset,
- WGC3Dsizeiptr size, WGC3Denum access);
- virtual void unmapBufferSubDataCHROMIUM(const void*);
- virtual void* mapTexSubImage2DCHROMIUM(
- WGC3Denum target,
- WGC3Dint level,
- WGC3Dint xoffset,
- WGC3Dint yoffset,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Denum format,
- WGC3Denum type,
- WGC3Denum access);
- virtual void unmapTexSubImage2DCHROMIUM(const void*);
-
- virtual void setVisibilityCHROMIUM(bool visible);
-
- virtual void discardFramebufferEXT(WGC3Denum target,
- WGC3Dsizei numAttachments,
- const WGC3Denum* attachments);
-
- virtual void copyTextureToParentTextureCHROMIUM(
- WebGLId texture, WebGLId parentTexture);
-
- virtual void rateLimitOffscreenContextCHROMIUM();
-
- virtual blink::WebString getRequestableExtensionsCHROMIUM();
- virtual void requestExtensionCHROMIUM(const char*);
-
- virtual void blitFramebufferCHROMIUM(
- WGC3Dint srcX0, WGC3Dint srcY0, WGC3Dint srcX1, WGC3Dint srcY1,
- WGC3Dint dstX0, WGC3Dint dstY0, WGC3Dint dstX1, WGC3Dint dstY1,
- WGC3Dbitfield mask, WGC3Denum filter);
- virtual void renderbufferStorageMultisampleCHROMIUM(
- WGC3Denum target, WGC3Dsizei samples, WGC3Denum internalformat,
- WGC3Dsizei width, WGC3Dsizei height);
-
- virtual blink::WebString getTranslatedShaderSourceANGLE(WebGLId shader);
-
- virtual void setContextLostCallback(
- WebGraphicsContext3D::WebGraphicsContextLostCallback* callback);
virtual WGC3Denum getGraphicsResetStatusARB();
- virtual void texImageIOSurface2DCHROMIUM(
- WGC3Denum target, WGC3Dint width, WGC3Dint height,
- WGC3Duint ioSurfaceId, WGC3Duint plane);
-
- virtual void bindTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint imageId);
- virtual void releaseTexImage2DCHROMIUM(WGC3Denum target, WGC3Dint imageId);
-
- virtual WebGLId createStreamTextureCHROMIUM(WebGLId texture);
- virtual void destroyStreamTextureCHROMIUM(WebGLId texture);
-
- virtual void texStorage2DEXT(
- WGC3Denum target, WGC3Dint levels, WGC3Duint internalformat,
- WGC3Dint width, WGC3Dint height);
- virtual WGC3Duint createImageCHROMIUM(
- WGC3Dsizei width, WGC3Dsizei height, WGC3Denum internalformat);
- virtual void destroyImageCHROMIUM(WGC3Duint image_id);
- virtual void getImageParameterivCHROMIUM(
- WGC3Duint image_id, WGC3Denum pname, WGC3Dint* params);
- virtual void* mapImageCHROMIUM(WGC3Duint image_id, WGC3Denum access);
- virtual void unmapImageCHROMIUM(WGC3Duint image_id);
- virtual WebGLId createQueryEXT();
- virtual void deleteQueryEXT(WebGLId query);
- virtual WGC3Dboolean isQueryEXT(WebGLId query);
- virtual void beginQueryEXT(WGC3Denum target, WebGLId query);
- virtual void endQueryEXT(WGC3Denum target);
- virtual void getQueryivEXT(
- WGC3Denum target, WGC3Denum pname, WGC3Dint* params);
- virtual void getQueryObjectuivEXT(
- WebGLId query, WGC3Denum pname, WGC3Duint* params);
-
- virtual void copyTextureCHROMIUM(WGC3Denum target, WGC3Duint source_id,
- WGC3Duint dest_id, WGC3Dint level,
- WGC3Denum internal_format,
- WGC3Denum dest_type);
-
- virtual void bindUniformLocationCHROMIUM(WebGLId program, WGC3Dint location,
- const WGC3Dchar* uniform);
-
- virtual void shallowFlushCHROMIUM();
- virtual void shallowFinishCHROMIUM();
-
- virtual void genMailboxCHROMIUM(WGC3Dbyte* mailbox);
- virtual void produceTextureCHROMIUM(WGC3Denum target,
- const WGC3Dbyte* mailbox);
- virtual void consumeTextureCHROMIUM(WGC3Denum target,
- const WGC3Dbyte* mailbox);
-
- virtual void insertEventMarkerEXT(const WGC3Dchar* marker);
- virtual void pushGroupMarkerEXT(const WGC3Dchar* marker);
- virtual void popGroupMarkerEXT();
-
- virtual void* mapBufferCHROMIUM(WGC3Denum target, WGC3Denum access);
- virtual WGC3Dboolean unmapBufferCHROMIUM(WGC3Denum target);
-
- // Async pixel transfer functions.
- virtual void asyncTexImage2DCHROMIUM(
- WGC3Denum target,
- WGC3Dint level,
- WGC3Denum internalformat,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Dint border,
- WGC3Denum format,
- WGC3Denum type,
- const void* pixels);
- virtual void asyncTexSubImage2DCHROMIUM(
- WGC3Denum target,
- WGC3Dint level,
- WGC3Dint xoffset,
- WGC3Dint yoffset,
- WGC3Dsizei width,
- WGC3Dsizei height,
- WGC3Denum format,
- WGC3Denum type,
- const void* pixels);
- virtual void waitAsyncTexImage2DCHROMIUM(WGC3Denum target);
-
- virtual void drawBuffersEXT(WGC3Dsizei n, const WGC3Denum* bufs);
-
- virtual unsigned insertSyncPoint();
-
- virtual void loseContextCHROMIUM(WGC3Denum current, WGC3Denum other);
-
- virtual GrGLInterface* createGrGLInterface();
-
- ::gpu::gles2::GLES2Interface* GetGLInterface();
::gpu::ContextSupport* GetContextSupport();
::gpu::gles2::GLES2Implementation* GetImplementation() {
- return gl_;
+ return real_gl_;
}
private:
WebGraphicsContext3DInProcessCommandBufferImpl(
scoped_ptr< ::gpu::GLInProcessContext> context,
const blink::WebGraphicsContext3D::Attributes& attributes,
+ bool lose_context_when_out_of_memory,
bool is_offscreen,
gfx::AcceleratedWidget window);
@@ -574,27 +90,18 @@ class WEBKIT_GPU_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl
// instead of going through WebGraphicsContext3D.
void ClearContext();
+ ::gpu::GLInProcessContextAttribs attribs_;
+ bool share_resources_;
+ bool webgl_context_;
+
bool is_offscreen_;
// Only used when not offscreen.
gfx::AcceleratedWidget window_;
- bool initialized_;
- bool initialize_failed_;
-
// The context we use for OpenGL rendering.
scoped_ptr< ::gpu::GLInProcessContext> context_;
// The GLES2Implementation we use for OpenGL rendering.
- ::gpu::gles2::GLES2Implementation* gl_;
-
- WebGraphicsContext3D::WebGraphicsContextLostCallback* context_lost_callback_;
- WGC3Denum context_lost_reason_;
-
- blink::WebGraphicsContext3D::Attributes attributes_;
-
- // Errors raised by synthesizeGLError().
- std::vector<WGC3Denum> synthetic_errors_;
-
- uint32_t flush_id_;
+ ::gpu::gles2::GLES2Implementation* real_gl_;
};
} // namespace gpu
diff --git a/chromium/webkit/common/gpu/webgraphicscontext3d_provider_impl.cc b/chromium/webkit/common/gpu/webgraphicscontext3d_provider_impl.cc
deleted file mode 100644
index 56291316780..00000000000
--- a/chromium/webkit/common/gpu/webgraphicscontext3d_provider_impl.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2013 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 "webkit/common/gpu/webgraphicscontext3d_provider_impl.h"
-
-#include "cc/output/context_provider.h"
-
-namespace webkit {
-namespace gpu {
-
-WebGraphicsContext3DProviderImpl::WebGraphicsContext3DProviderImpl(
- scoped_refptr<cc::ContextProvider> provider)
- : provider_(provider) {}
-
-WebGraphicsContext3DProviderImpl::~WebGraphicsContext3DProviderImpl() {}
-
-blink::WebGraphicsContext3D* WebGraphicsContext3DProviderImpl::context3d() {
- return provider_->Context3d();
-}
-
-GrContext* WebGraphicsContext3DProviderImpl::grContext() {
- return provider_->GrContext();
-}
-
-} // namespace gpu
-} // namespace webkit
diff --git a/chromium/webkit/common/gpu/webgraphicscontext3d_provider_impl.h b/chromium/webkit/common/gpu/webgraphicscontext3d_provider_impl.h
deleted file mode 100644
index 794df1363ef..00000000000
--- a/chromium/webkit/common/gpu/webgraphicscontext3d_provider_impl.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2013 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 WEBKIT_COMMON_GPU_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_
-#define WEBKIT_COMMON_GPU_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_
-
-#include "base/compiler_specific.h"
-#include "base/memory/ref_counted.h"
-#include "third_party/WebKit/public/platform/WebGraphicsContext3DProvider.h"
-#include "webkit/common/gpu/webkit_gpu_export.h"
-
-namespace cc { class ContextProvider; }
-
-namespace webkit {
-namespace gpu {
-
-class WEBKIT_GPU_EXPORT WebGraphicsContext3DProviderImpl
- : public NON_EXPORTED_BASE(blink::WebGraphicsContext3DProvider) {
- public:
- explicit WebGraphicsContext3DProviderImpl(
- scoped_refptr<cc::ContextProvider> provider);
- virtual ~WebGraphicsContext3DProviderImpl();
-
- // WebGraphicsContext3DProvider implementation.
- virtual blink::WebGraphicsContext3D* context3d() OVERRIDE;
- virtual GrContext* grContext() OVERRIDE;
-
- private:
- scoped_refptr<cc::ContextProvider> provider_;
-};
-
-} // namespace gpu
-} // namespace webkit
-
-#endif // WEBKIT_COMMON_GPU_WEBGRAPHICSCONTEXT3D_PROVIDER_IMPL_H_
diff --git a/chromium/webkit/common/gpu/webkit_gpu.gyp b/chromium/webkit/common/gpu/webkit_gpu.gyp
index a28e4e851a4..23b36e530f1 100644
--- a/chromium/webkit/common/gpu/webkit_gpu.gyp
+++ b/chromium/webkit/common/gpu/webkit_gpu.gyp
@@ -21,25 +21,26 @@
'<(DEPTH)/gpu/gpu.gyp:command_buffer_service',
'<(DEPTH)/gpu/gpu.gyp:gles2_c_lib',
'<(DEPTH)/gpu/gpu.gyp:gles2_implementation',
+ '<(DEPTH)/gpu/gpu.gyp:gl_in_process_context',
'<(DEPTH)/gpu/skia_bindings/skia_bindings.gyp:gpu_skia_bindings',
'<(DEPTH)/skia/skia.gyp:skia',
'<(DEPTH)/third_party/WebKit/public/blink.gyp:blink_minimal',
'<(angle_path)/src/build_angle.gyp:translator',
'<(DEPTH)/ui/gl/gl.gyp:gl',
'<(DEPTH)/ui/gfx/gfx.gyp:gfx',
+ '<(DEPTH)/ui/gfx/gfx.gyp:gfx_geometry',
],
'sources': [
# This list contains all .h and .cc in gpu except for test code.
'context_provider_in_process.cc',
'context_provider_in_process.h',
+ 'context_provider_web_context.h',
'grcontext_for_webgraphicscontext3d.cc',
'grcontext_for_webgraphicscontext3d.h',
- 'test_context_provider_factory.cc',
- 'test_context_provider_factory.h',
+ 'webgraphicscontext3d_impl.cc',
+ 'webgraphicscontext3d_impl.h',
'webgraphicscontext3d_in_process_command_buffer_impl.cc',
'webgraphicscontext3d_in_process_command_buffer_impl.h',
- 'webgraphicscontext3d_provider_impl.cc',
- 'webgraphicscontext3d_provider_impl.h',
],
'defines': [
'WEBKIT_GPU_IMPLEMENTATION',
diff --git a/chromium/webkit/common/quota/quota_types.h b/chromium/webkit/common/quota/quota_types.h
index 6cb45c9d7f8..bc8cd00bc50 100644
--- a/chromium/webkit/common/quota/quota_types.h
+++ b/chromium/webkit/common/quota/quota_types.h
@@ -15,6 +15,7 @@ enum StorageType {
kStorageTypeSyncable,
kStorageTypeQuotaNotManaged,
kStorageTypeUnknown,
+ kStorageTypeLast = kStorageTypeUnknown
};
enum QuotaLimitType {
diff --git a/chromium/webkit/common/resource_devtools_info.cc b/chromium/webkit/common/resource_devtools_info.cc
deleted file mode 100644
index 0cd07d842bf..00000000000
--- a/chromium/webkit/common/resource_devtools_info.cc
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2013 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 "webkit/common/resource_devtools_info.h"
-
-namespace webkit_glue {
-
-ResourceDevToolsInfo::ResourceDevToolsInfo()
- : http_status_code(0) {
-}
-
-ResourceDevToolsInfo::~ResourceDevToolsInfo() {
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/common/resource_devtools_info.h b/chromium/webkit/common/resource_devtools_info.h
deleted file mode 100644
index 96c163c8a08..00000000000
--- a/chromium/webkit/common/resource_devtools_info.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2013 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 WEBKIT_COMMON_RESOURCE_DEVTOOLS_INFO_H_
-#define WEBKIT_COMMON_RESOURCE_DEVTOOLS_INFO_H_
-
-#include <string>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
-#include "webkit/common/webkit_common_export.h"
-
-namespace webkit_glue {
-
-struct ResourceDevToolsInfo : base::RefCounted<ResourceDevToolsInfo> {
- typedef std::vector<std::pair<std::string, std::string> >
- HeadersVector;
-
- WEBKIT_COMMON_EXPORT ResourceDevToolsInfo();
-
- int32 http_status_code;
- std::string http_status_text;
- HeadersVector request_headers;
- HeadersVector response_headers;
- std::string request_headers_text;
- std::string response_headers_text;
-
- private:
- friend class base::RefCounted<ResourceDevToolsInfo>;
- WEBKIT_COMMON_EXPORT ~ResourceDevToolsInfo();
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_COMMON_RESOURCE_DEVTOOLS_INFO_H_
diff --git a/chromium/webkit/common/resource_request_body.cc b/chromium/webkit/common/resource_request_body.cc
deleted file mode 100644
index 42b798fefe1..00000000000
--- a/chromium/webkit/common/resource_request_body.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2013 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 "webkit/common/resource_request_body.h"
-
-namespace webkit_glue {
-
-ResourceRequestBody::ResourceRequestBody()
- : identifier_(0) {
-}
-
-void ResourceRequestBody::AppendBytes(const char* bytes, int bytes_len) {
- if (bytes_len > 0) {
- elements_.push_back(Element());
- elements_.back().SetToBytes(bytes, bytes_len);
- }
-}
-
-void ResourceRequestBody::AppendFileRange(
- const base::FilePath& file_path,
- uint64 offset, uint64 length,
- const base::Time& expected_modification_time) {
- elements_.push_back(Element());
- elements_.back().SetToFilePathRange(file_path, offset, length,
- expected_modification_time);
-}
-
-void ResourceRequestBody::AppendBlob(const std::string& uuid) {
- elements_.push_back(Element());
- elements_.back().SetToBlob(uuid);
-}
-
-void ResourceRequestBody::AppendFileSystemFileRange(
- const GURL& url, uint64 offset, uint64 length,
- const base::Time& expected_modification_time) {
- elements_.push_back(Element());
- elements_.back().SetToFileSystemUrlRange(url, offset, length,
- expected_modification_time);
-}
-
-ResourceRequestBody::~ResourceRequestBody() {
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/common/resource_request_body.h b/chromium/webkit/common/resource_request_body.h
deleted file mode 100644
index ccfc1f3e58d..00000000000
--- a/chromium/webkit/common/resource_request_body.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2013 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 WEBKIT_COMMON_RESOURCE_REQUEST_BODY_H_
-#define WEBKIT_COMMON_RESOURCE_REQUEST_BODY_H_
-
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
-#include "base/supports_user_data.h"
-#include "url/gurl.h"
-#include "webkit/common/data_element.h"
-#include "webkit/common/webkit_common_export.h"
-
-namespace base {
-class FilePath;
-}
-
-namespace webkit_glue {
-
-// A struct used to represent upload data. The data field is populated by
-// WebURLLoader from the data given as WebHTTPBody.
-class WEBKIT_COMMON_EXPORT ResourceRequestBody
- : public base::RefCounted<ResourceRequestBody>,
- public base::SupportsUserData {
- public:
- typedef webkit_common::DataElement Element;
-
- ResourceRequestBody();
-
- void AppendBytes(const char* bytes, int bytes_len);
- void AppendFileRange(const base::FilePath& file_path,
- uint64 offset, uint64 length,
- const base::Time& expected_modification_time);
- void AppendBlob(const std::string& uuid);
- void AppendFileSystemFileRange(const GURL& url, uint64 offset, uint64 length,
- const base::Time& expected_modification_time);
-
- const std::vector<Element>* elements() const { return &elements_; }
- std::vector<Element>* elements_mutable() { return &elements_; }
- void swap_elements(std::vector<Element>* elements) {
- elements_.swap(*elements);
- }
-
- // Identifies a particular upload instance, which is used by the cache to
- // formulate a cache key. This value should be unique across browser
- // sessions. A value of 0 is used to indicate an unspecified identifier.
- void set_identifier(int64 id) { identifier_ = id; }
- int64 identifier() const { return identifier_; }
-
- private:
- friend class base::RefCounted<ResourceRequestBody>;
- virtual ~ResourceRequestBody();
-
- std::vector<Element> elements_;
- int64 identifier_;
-
- DISALLOW_COPY_AND_ASSIGN(ResourceRequestBody);
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_COMMON_RESOURCE_REQUEST_BODY_H_
diff --git a/chromium/webkit/common/resource_response_info.cc b/chromium/webkit/common/resource_response_info.cc
deleted file mode 100644
index 66e612f7dc3..00000000000
--- a/chromium/webkit/common/resource_response_info.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2013 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 "webkit/common/resource_response_info.h"
-
-#include "net/http/http_response_headers.h"
-#include "webkit/common/appcache/appcache_interfaces.h"
-
-namespace webkit_glue {
-
-ResourceResponseInfo::ResourceResponseInfo()
- : content_length(-1),
- encoded_data_length(-1),
- appcache_id(appcache::kNoCacheId),
- was_fetched_via_spdy(false),
- was_npn_negotiated(false),
- was_alternate_protocol_available(false),
- connection_info(net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN),
- was_fetched_via_proxy(false) {
-}
-
-ResourceResponseInfo::~ResourceResponseInfo() {}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/common/resource_response_info.h b/chromium/webkit/common/resource_response_info.h
deleted file mode 100644
index 5f8b88bdfc8..00000000000
--- a/chromium/webkit/common/resource_response_info.h
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright 2013 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 WEBKIT_COMMON_RESOURCE_RESPONSE_INFO_H_
-#define WEBKIT_COMMON_RESOURCE_RESPONSE_INFO_H_
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/files/file_path.h"
-#include "base/memory/ref_counted.h"
-#include "base/time/time.h"
-#include "net/base/host_port_pair.h"
-#include "net/base/load_timing_info.h"
-#include "net/http/http_response_info.h"
-#include "url/gurl.h"
-#include "webkit/common/resource_devtools_info.h"
-
-namespace webkit_glue {
-
-struct ResourceResponseInfo {
- WEBKIT_COMMON_EXPORT ResourceResponseInfo();
- WEBKIT_COMMON_EXPORT ~ResourceResponseInfo();
-
- // The time at which the request was made that resulted in this response.
- // For cached responses, this time could be "far" in the past.
- base::Time request_time;
-
- // The time at which the response headers were received. For cached
- // responses, this time could be "far" in the past.
- base::Time response_time;
-
- // The response headers or NULL if the URL type does not support headers.
- scoped_refptr<net::HttpResponseHeaders> headers;
-
- // The mime type of the response. This may be a derived value.
- std::string mime_type;
-
- // The character encoding of the response or none if not applicable to the
- // response's mime type. This may be a derived value.
- std::string charset;
-
- // An opaque string carrying security information pertaining to this
- // response. This may include information about the SSL connection used.
- std::string security_info;
-
- // Content length if available. -1 if not available
- int64 content_length;
-
- // Length of the encoded data transferred over the network. In case there is
- // no data, contains -1.
- int64 encoded_data_length;
-
- // The appcache this response was loaded from, or kNoCacheId.
- int64 appcache_id;
-
- // The manifest url of the appcache this response was loaded from.
- // Note: this value is only populated for main resource requests.
- GURL appcache_manifest_url;
-
- // Detailed timing information used by the WebTiming, HAR and Developer
- // Tools. Includes socket ID and socket reuse information.
- net::LoadTimingInfo load_timing;
-
- // Actual request and response headers, as obtained from the network stack.
- // Only present if request had LOAD_REPORT_RAW_HEADERS in load_flags, and
- // requesting renderer had CanReadRowCookies permission.
- scoped_refptr<ResourceDevToolsInfo> devtools_info;
-
- // The path to a file that will contain the response body. It may only
- // contain a portion of the response body at the time that the ResponseInfo
- // becomes available.
- base::FilePath download_file_path;
-
- // True if the response was delivered using SPDY.
- bool was_fetched_via_spdy;
-
- // True if the response was delivered after NPN is negotiated.
- bool was_npn_negotiated;
-
- // True if response could use alternate protocol. However, browser will
- // ignore the alternate protocol when spdy is not enabled on browser side.
- bool was_alternate_protocol_available;
-
- // Information about the type of connection used to fetch this response.
- net::HttpResponseInfo::ConnectionInfo connection_info;
-
- // True if the response was fetched via an explicit proxy (as opposed to a
- // transparent proxy). The proxy could be any type of proxy, HTTP or SOCKS.
- // Note: we cannot tell if a transparent proxy may have been involved.
- bool was_fetched_via_proxy;
-
- // NPN protocol negotiated with the server.
- std::string npn_negotiated_protocol;
-
- // Remote address of the socket which fetched this resource.
- net::HostPortPair socket_address;
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_COMMON_RESOURCE_RESPONSE_INFO_H_
diff --git a/chromium/webkit/common/resource_type.cc b/chromium/webkit/common/resource_type.cc
index fccaf7ea082..7e938db162a 100644
--- a/chromium/webkit/common/resource_type.cc
+++ b/chromium/webkit/common/resource_type.cc
@@ -42,6 +42,8 @@ ResourceType::Type ResourceType::FromTargetType(
return ResourceType::XHR;
case WebURLRequest::TargetIsPing:
return ResourceType::PING;
+ case WebURLRequest::TargetIsServiceWorker:
+ return ResourceType::SERVICE_WORKER;
default:
NOTREACHED();
return ResourceType::SUB_RESOURCE;
diff --git a/chromium/webkit/common/resource_type.h b/chromium/webkit/common/resource_type.h
index 014a7224a26..4cfd0f6ee59 100644
--- a/chromium/webkit/common/resource_type.h
+++ b/chromium/webkit/common/resource_type.h
@@ -30,6 +30,7 @@ class ResourceType {
FAVICON, // a favicon
XHR, // a XMLHttpRequest
PING, // a ping request for <a ping>
+ SERVICE_WORKER, // the main resource of a service worker.
LAST_TYPE // Place holder so we don't need to change ValidType
// everytime.
};
@@ -53,6 +54,10 @@ class ResourceType {
return type == SHARED_WORKER;
}
+ static bool IsServiceWorker(ResourceType::Type type) {
+ return type == SERVICE_WORKER;
+ }
+
static bool IsSubresource(ResourceType::Type type) {
return type == STYLESHEET ||
type == SCRIPT ||
diff --git a/chromium/webkit/common/user_agent/user_agent.cc b/chromium/webkit/common/user_agent/user_agent.cc
deleted file mode 100644
index 9a1fdb0047e..00000000000
--- a/chromium/webkit/common/user_agent/user_agent.cc
+++ /dev/null
@@ -1,133 +0,0 @@
-// Copyright 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 "webkit/common/user_agent/user_agent.h"
-
-#include "base/lazy_instance.h"
-#include "base/logging.h"
-#include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
-#include "base/synchronization/lock.h"
-#include "webkit/common/user_agent/user_agent_util.h"
-
-namespace webkit_glue {
-
-namespace {
-
-class UserAgentState {
- public:
- UserAgentState();
- ~UserAgentState();
-
- void Set(const std::string& user_agent, bool overriding);
- const std::string& Get(const GURL& url) const;
-
- private:
- mutable std::string user_agent_;
- // The UA string when we're pretending to be Mac Safari or Win Firefox.
- mutable std::string user_agent_for_spoofing_hack_;
-
- mutable bool user_agent_requested_;
- bool user_agent_is_overridden_;
-
- // This object can be accessed from multiple threads, so use a lock around
- // accesses to the data members.
- mutable base::Lock lock_;
-};
-
-UserAgentState::UserAgentState()
- : user_agent_requested_(false),
- user_agent_is_overridden_(false) {
-}
-
-UserAgentState::~UserAgentState() {
-}
-
-void UserAgentState::Set(const std::string& user_agent, bool overriding) {
- base::AutoLock auto_lock(lock_);
- if (user_agent == user_agent_) {
- // We allow the user agent to be set multiple times as long as it
- // is set to the same value, in order to simplify unit testing
- // given g_user_agent is a global.
- return;
- }
- DCHECK(!user_agent.empty());
- DCHECK(!user_agent_requested_) << "Setting the user agent after someone has "
- "already requested it can result in unexpected behavior.";
- user_agent_is_overridden_ = overriding;
- user_agent_ = user_agent;
-}
-
-bool IsMicrosoftSiteThatNeedsSpoofingForSilverlight(const GURL& url) {
-#if defined(OS_MACOSX) && !defined(OS_IOS)
- // The landing page for updating Silverlight gives a confusing experience
- // in browsers that Silverlight doesn't officially support; spoof as
- // Safari to reduce the chance that users won't complete updates.
- // Should be removed if the sniffing is removed: http://crbug.com/88211
- if (url.host() == "www.microsoft.com" &&
- StartsWithASCII(url.path(), "/getsilverlight", false)) {
- return true;
- }
-#endif
- return false;
-}
-
-bool IsYahooSiteThatNeedsSpoofingForSilverlight(const GURL& url) {
-#if defined(OS_MACOSX) && !defined(OS_IOS)
- if ((url.host() == "downloads.yahoo.co.jp" &&
- StartsWithASCII(url.path(), "/docs/silverlight/", true)) ||
- url.host() == "gyao.yahoo.co.jp") {
- return true;
- }
-#elif defined(OS_WIN)
- if (url.host() == "promotion.shopping.yahoo.co.jp") {
- return true;
- }
-#endif
- return false;
-}
-
-const std::string& UserAgentState::Get(const GURL& url) const {
- base::AutoLock auto_lock(lock_);
- user_agent_requested_ = true;
-
- DCHECK(!user_agent_.empty());
-
- // Workarounds for sites that use misguided UA sniffing.
- if (!user_agent_is_overridden_) {
- if (IsMicrosoftSiteThatNeedsSpoofingForSilverlight(url) ||
- IsYahooSiteThatNeedsSpoofingForSilverlight(url)) {
- if (user_agent_for_spoofing_hack_.empty()) {
-#if defined(OS_MACOSX) && !defined(OS_IOS)
- user_agent_for_spoofing_hack_ =
- BuildUserAgentFromProduct("Version/5.1.1 Safari/534.51.22");
-#elif defined(OS_WIN)
- // Pretend to be Firefox. Silverlight doesn't support Win Safari.
- base::StringAppendF(
- &user_agent_for_spoofing_hack_,
- "Mozilla/5.0 (%s) Gecko/20100101 Firefox/8.0",
- webkit_glue::BuildOSCpuInfo().c_str());
-#endif
- }
- DCHECK(!user_agent_for_spoofing_hack_.empty());
- return user_agent_for_spoofing_hack_;
- }
- }
-
- return user_agent_;
-}
-
-base::LazyInstance<UserAgentState> g_user_agent = LAZY_INSTANCE_INITIALIZER;
-
-} // namespace
-
-void SetUserAgent(const std::string& user_agent, bool overriding) {
- g_user_agent.Get().Set(user_agent, overriding);
-}
-
-const std::string& GetUserAgent(const GURL& url) {
- return g_user_agent.Get().Get(url);
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/common/user_agent/user_agent.h b/chromium/webkit/common/user_agent/user_agent.h
deleted file mode 100644
index 849f5c35ef9..00000000000
--- a/chromium/webkit/common/user_agent/user_agent.h
+++ /dev/null
@@ -1,29 +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 WEBKIT_COMMON_USER_AGENT_USER_AGENT_H_
-#define WEBKIT_COMMON_USER_AGENT_USER_AGENT_H_
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "url/gurl.h"
-#include "webkit/common/user_agent/webkit_user_agent_export.h"
-
-namespace webkit_glue {
-
-// Sets the user agent. Pass true for overriding if this is a custom
-// user agent instead of the default one (in order to turn off any browser
-// sniffing workarounds). This must be called before GetUserAgent() can
-// be called.
-WEBKIT_USER_AGENT_EXPORT void SetUserAgent(const std::string& user_agent,
- bool overriding);
-
-// Returns the user agent to use for the given URL. SetUserAgent() must
-// be called prior to calling this function.
-WEBKIT_USER_AGENT_EXPORT const std::string& GetUserAgent(const GURL& url);
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_COMMON_USER_AGENT_USER_AGENT_H_
diff --git a/chromium/webkit/common/user_agent/user_agent_unittest.cc b/chromium/webkit/common/user_agent/user_agent_unittest.cc
deleted file mode 100644
index bed7652dc69..00000000000
--- a/chromium/webkit/common/user_agent/user_agent_unittest.cc
+++ /dev/null
@@ -1,55 +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 "webkit/common/user_agent/user_agent.h"
-
-#include <string>
-
-#include "testing/gtest/include/gtest/gtest.h"
-#include "url/gurl.h"
-
-namespace {
-
-typedef testing::Test WebkitGlueUserAgentTest;
-
-bool IsSpoofedUserAgent(const std::string& user_agent) {
- return user_agent.find("TestContentClient") == std::string::npos;
-}
-
-TEST_F(WebkitGlueUserAgentTest, UserAgentSpoofingHack) {
- enum Platform {
- NONE = 0,
- MACOSX = 1,
- WIN = 2,
- OTHER = 4,
- };
-
- struct Expected {
- const char* url;
- int os_mask;
- };
-
- Expected expected[] = {
- { "http://wwww.google.com", NONE },
- { "http://www.microsoft.com/getsilverlight", MACOSX },
- { "http://downloads.yahoo.co.jp/docs/silverlight/", MACOSX },
- { "http://gyao.yahoo.co.jp/", MACOSX },
- { "http://promotion.shopping.yahoo.co.jp/", WIN },
- };
-#if defined(OS_MACOSX)
- int os_bit = MACOSX;
-#elif defined(OS_WIN)
- int os_bit = WIN;
-#else
- int os_bit = OTHER;
-#endif
-
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(expected); ++i) {
- EXPECT_EQ((expected[i].os_mask & os_bit) != 0,
- IsSpoofedUserAgent(
- webkit_glue::GetUserAgent(GURL(expected[i].url))));
- }
-}
-
-} // namespace
diff --git a/chromium/webkit/common/user_agent/user_agent_util.cc b/chromium/webkit/common/user_agent/user_agent_util.cc
deleted file mode 100644
index 7655d6963d4..00000000000
--- a/chromium/webkit/common/user_agent/user_agent_util.cc
+++ /dev/null
@@ -1,196 +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 "webkit/common/user_agent/user_agent_util.h"
-
-#if defined(OS_POSIX) && !defined(OS_MACOSX)
-#include <sys/utsname.h>
-#endif
-
-#include "base/lazy_instance.h"
-#include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
-#include "base/sys_info.h"
-
-#if defined(OS_WIN)
-#include "base/win/windows_version.h"
-#endif
-
-// Generated
-#include "webkit_version.h" // NOLINT
-
-namespace webkit_glue {
-
-std::string GetWebKitVersion() {
- return base::StringPrintf("%d.%d (%s)",
- WEBKIT_VERSION_MAJOR,
- WEBKIT_VERSION_MINOR,
- WEBKIT_SVN_REVISION);
-}
-
-std::string GetWebKitRevision() {
- return WEBKIT_SVN_REVISION;
-}
-
-#if defined(OS_ANDROID)
-std::string GetAndroidDeviceName() {
- std::string android_device_name = base::SysInfo::GetDeviceName();
-#if defined(GOOGLE_TV)
- android_device_name += " TV";
-#endif
- return android_device_name;
-}
-#endif
-
-std::string BuildOSCpuInfo() {
- std::string os_cpu;
-
-#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) ||\
- defined(OS_ANDROID)
- int32 os_major_version = 0;
- int32 os_minor_version = 0;
- int32 os_bugfix_version = 0;
- base::SysInfo::OperatingSystemVersionNumbers(&os_major_version,
- &os_minor_version,
- &os_bugfix_version);
-#endif
-
-#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
- // Should work on any Posix system.
- struct utsname unixinfo;
- uname(&unixinfo);
-
- std::string cputype;
- // special case for biarch systems
- if (strcmp(unixinfo.machine, "x86_64") == 0 &&
- sizeof(void*) == sizeof(int32)) { // NOLINT
- cputype.assign("i686 (x86_64)");
- } else {
- cputype.assign(unixinfo.machine);
- }
-#endif
-
-#if defined(OS_WIN)
- std::string architecture_token;
- base::win::OSInfo* os_info = base::win::OSInfo::GetInstance();
- if (os_info->wow64_status() == base::win::OSInfo::WOW64_ENABLED) {
- architecture_token = "; WOW64";
- } else {
- base::win::OSInfo::WindowsArchitecture windows_architecture =
- os_info->architecture();
- if (windows_architecture == base::win::OSInfo::X64_ARCHITECTURE)
- architecture_token = "; Win64; x64";
- else if (windows_architecture == base::win::OSInfo::IA64_ARCHITECTURE)
- architecture_token = "; Win64; IA64";
- }
-#endif
-
-#if defined(OS_ANDROID)
- std::string android_version_str;
- base::StringAppendF(
- &android_version_str, "%d.%d", os_major_version, os_minor_version);
- if (os_bugfix_version != 0)
- base::StringAppendF(&android_version_str, ".%d", os_bugfix_version);
-
- std::string android_info_str;
-
- // Send information about the device.
- bool semicolon_inserted = false;
- std::string android_build_codename = base::SysInfo::GetAndroidBuildCodename();
- std::string android_device_name = GetAndroidDeviceName();
- if ("REL" == android_build_codename && android_device_name.size() > 0) {
- android_info_str += "; " + android_device_name;
- semicolon_inserted = true;
- }
-
- // Append the build ID.
- std::string android_build_id = base::SysInfo::GetAndroidBuildID();
- if (android_build_id.size() > 0) {
- if (!semicolon_inserted) {
- android_info_str += ";";
- }
- android_info_str += " Build/" + android_build_id;
- }
-#endif
-
- base::StringAppendF(
- &os_cpu,
-#if defined(OS_WIN)
- "Windows NT %d.%d%s",
- os_major_version,
- os_minor_version,
- architecture_token.c_str()
-#elif defined(OS_MACOSX)
- "Intel Mac OS X %d_%d_%d",
- os_major_version,
- os_minor_version,
- os_bugfix_version
-#elif defined(OS_CHROMEOS)
- "CrOS "
- "%s %d.%d.%d",
- cputype.c_str(), // e.g. i686
- os_major_version,
- os_minor_version,
- os_bugfix_version
-#elif defined(OS_ANDROID)
- "Android %s%s",
- android_version_str.c_str(),
- android_info_str.c_str()
-#else
- "%s %s",
- unixinfo.sysname, // e.g. Linux
- cputype.c_str() // e.g. i686
-#endif
- ); // NOLINT
-
- return os_cpu;
-}
-
-int GetWebKitMajorVersion() {
- return WEBKIT_VERSION_MAJOR;
-}
-
-int GetWebKitMinorVersion() {
- return WEBKIT_VERSION_MINOR;
-}
-
-std::string BuildUserAgentFromProduct(const std::string& product) {
- const char kUserAgentPlatform[] =
-#if defined(OS_WIN)
- "";
-#elif defined(OS_MACOSX)
- "Macintosh; ";
-#elif defined(USE_X11)
- "X11; "; // strange, but that's what Firefox uses
-#elif defined(OS_ANDROID)
- "Linux; ";
-#else
- "Unknown; ";
-#endif
-
- std::string os_info;
- base::StringAppendF(&os_info, "%s%s", kUserAgentPlatform,
- webkit_glue::BuildOSCpuInfo().c_str());
- return BuildUserAgentFromOSAndProduct(os_info, product);
-}
-
-std::string BuildUserAgentFromOSAndProduct(const std::string& os_info,
- const std::string& product) {
- // Derived from Safari's UA string.
- // This is done to expose our product name in a manner that is maximally
- // compatible with Safari, we hope!!
- std::string user_agent;
- base::StringAppendF(
- &user_agent,
- "Mozilla/5.0 (%s) AppleWebKit/%d.%d (KHTML, like Gecko) %s Safari/%d.%d",
- os_info.c_str(),
- WEBKIT_VERSION_MAJOR,
- WEBKIT_VERSION_MINOR,
- product.c_str(),
- WEBKIT_VERSION_MAJOR,
- WEBKIT_VERSION_MINOR);
- return user_agent;
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/common/user_agent/user_agent_util.h b/chromium/webkit/common/user_agent/user_agent_util.h
deleted file mode 100644
index e23b809a505..00000000000
--- a/chromium/webkit/common/user_agent/user_agent_util.h
+++ /dev/null
@@ -1,40 +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 WEBKIT_COMMON_USER_AGENT_USER_AGENT_UTIL_H_
-#define WEBKIT_COMMON_USER_AGENT_USER_AGENT_UTIL_H_
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "webkit/common/user_agent/webkit_user_agent_export.h"
-
-namespace webkit_glue {
-
-// Builds a User-agent compatible string that describes the OS and CPU type.
-WEBKIT_USER_AGENT_EXPORT std::string BuildOSCpuInfo();
-
-// Returns the WebKit version, in the form "major.minor (branch@revision)".
-WEBKIT_USER_AGENT_EXPORT std::string GetWebKitVersion();
-
-// The following 2 functions return the major and minor webkit versions.
-WEBKIT_USER_AGENT_EXPORT int GetWebKitMajorVersion();
-WEBKIT_USER_AGENT_EXPORT int GetWebKitMinorVersion();
-
-WEBKIT_USER_AGENT_EXPORT std::string GetWebKitRevision();
-
-// Helper function to generate a full user agent string from a short
-// product name.
-WEBKIT_USER_AGENT_EXPORT std::string BuildUserAgentFromProduct(
- const std::string& product);
-
-// Builds a full user agent string given a string describing the OS and a
-// product name.
-WEBKIT_USER_AGENT_EXPORT std::string BuildUserAgentFromOSAndProduct(
- const std::string& os_info,
- const std::string& product);
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_COMMON_USER_AGENT_USER_AGENT_UTIL_H_
diff --git a/chromium/webkit/common/user_agent/user_agent_util_ios.mm b/chromium/webkit/common/user_agent/user_agent_util_ios.mm
deleted file mode 100644
index 6a42c5133a0..00000000000
--- a/chromium/webkit/common/user_agent/user_agent_util_ios.mm
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright 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 "webkit/common/user_agent/user_agent_util.h"
-
-#import <UIKit/UIKit.h>
-
-#include <sys/sysctl.h>
-#include <string>
-
-#include "base/mac/scoped_nsobject.h"
-#include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
-#include "base/strings/sys_string_conversions.h"
-#include "base/sys_info.h"
-
-namespace {
-
-struct UAVersions {
- const char* safari_version_string;
- const char* webkit_version_string;
-};
-
-struct OSVersionMap {
- int32 major_os_version;
- int32 minor_os_version;
- UAVersions ua_versions;
-};
-
-const UAVersions& GetUAVersionsForCurrentOS() {
- // The WebKit version can be extracted dynamically from UIWebView, but the
- // Safari version can't be, so a lookup table is used instead (for both, since
- // the reported versions should stay in sync).
- static const OSVersionMap version_map[] = {
- { 7, 0, { "9537.53", "537.51.1" } },
- // 6.1 has the same values as 6.0.
- { 6, 0, { "8536.25", "536.26" } },
- };
-
- int32 os_major_version = 0;
- int32 os_minor_version = 0;
- int32 os_bugfix_version = 0;
- base::SysInfo::OperatingSystemVersionNumbers(&os_major_version,
- &os_minor_version,
- &os_bugfix_version);
-
- // Return the versions corresponding to the first (and thus highest) OS
- // version less than or equal to the given OS version.
- for (unsigned int i = 0; i < arraysize(version_map); ++i) {
- if (os_major_version > version_map[i].major_os_version ||
- (os_major_version == version_map[i].major_os_version &&
- os_minor_version >= version_map[i].minor_os_version))
- return version_map[i].ua_versions;
- }
- NOTREACHED();
- return version_map[arraysize(version_map) - 1].ua_versions;
-}
-
-} // namespace
-
-namespace webkit_glue {
-
-std::string BuildOSCpuInfo() {
- int32 os_major_version = 0;
- int32 os_minor_version = 0;
- int32 os_bugfix_version = 0;
- base::SysInfo::OperatingSystemVersionNumbers(&os_major_version,
- &os_minor_version,
- &os_bugfix_version);
- std::string os_version;
- if (os_bugfix_version == 0) {
- base::StringAppendF(&os_version,
- "%d_%d",
- os_major_version,
- os_minor_version);
- } else {
- base::StringAppendF(&os_version,
- "%d_%d_%d",
- os_major_version,
- os_minor_version,
- os_bugfix_version);
- }
-
- // Remove the end of the platform name. For example "iPod touch" becomes
- // "iPod".
- std::string platform = base::SysNSStringToUTF8(
- [[UIDevice currentDevice] model]);
- size_t position = platform.find_first_of(" ");
- if (position != std::string::npos)
- platform = platform.substr(0, position);
-
- std::string os_cpu;
- base::StringAppendF(
- &os_cpu,
- "%s; CPU %s %s like Mac OS X",
- platform.c_str(),
- (platform == "iPad") ? "OS" : "iPhone OS",
- os_version.c_str());
-
- return os_cpu;
-}
-
-std::string BuildUserAgentFromProduct(const std::string& product) {
- // Retrieve the kernel build number.
- int mib[2] = {CTL_KERN, KERN_OSVERSION};
- unsigned int namelen = sizeof(mib) / sizeof(mib[0]);
- size_t bufferSize = 0;
- sysctl(mib, namelen, NULL, &bufferSize, NULL, 0);
- char kernel_version[bufferSize];
- int result = sysctl(mib, namelen, kernel_version, &bufferSize, NULL, 0);
- DCHECK(result == 0);
-
- UAVersions ua_versions = GetUAVersionsForCurrentOS();
-
- std::string user_agent;
- base::StringAppendF(
- &user_agent,
- "Mozilla/5.0 (%s) AppleWebKit/%s"
- " (KHTML, like Gecko) %s Mobile/%s Safari/%s",
- webkit_glue::BuildOSCpuInfo().c_str(),
- ua_versions.webkit_version_string,
- product.c_str(),
- kernel_version,
- ua_versions.safari_version_string);
-
- return user_agent;
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/common/user_agent/webkit_user_agent.gyp b/chromium/webkit/common/user_agent/webkit_user_agent.gyp
deleted file mode 100644
index be4a042ac5e..00000000000
--- a/chromium/webkit/common/user_agent/webkit_user_agent.gyp
+++ /dev/null
@@ -1,88 +0,0 @@
-# Copyright 2013 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.
-
-{
- 'targets': [
- {
- 'target_name': 'user_agent',
- 'type': '<(component)',
- 'defines': [
- 'WEBKIT_USER_AGENT_IMPLEMENTATION',
- ],
- 'variables': {
- 'chromium_code': 1,
- },
- 'dependencies': [
- '<(DEPTH)/base/base.gyp:base',
- '<(DEPTH)/base/base.gyp:base_i18n',
- '<(DEPTH)/url/url.gyp:url_lib',
- ],
- 'sources': [
- 'user_agent.cc',
- 'user_agent.h',
- 'user_agent_util.cc',
- 'user_agent_util_ios.mm',
- 'user_agent_util.h',
- 'webkit_user_agent_export.h',
- ],
- 'conditions': [
- ['OS == "ios"', {
- # iOS has different user-agent construction utilities, since the
- # version strings is not derived from webkit_version, and follows
- # a different format.
- 'sources!': [
- 'user_agent_util.cc',
- ],
- }, { # OS != "ios"
- 'dependencies': [
- 'webkit_version',
- '<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
- ],
- }],
- ],
- },
- ],
- 'conditions': [
- ['OS != "ios"', {
- 'targets': [
- {
- 'target_name': 'webkit_version',
- 'type': 'none',
- 'actions': [
- {
- 'action_name': 'webkit_version',
- 'inputs': [
- '<(script)',
- '<(lastchange)',
- '<(template)',
- ],
- 'outputs': [
- '<(SHARED_INTERMEDIATE_DIR)/webkit_version.h',
- ],
- 'action': ['python',
- '<(script)',
- '-f', '<(lastchange)',
- '<(template)',
- '<@(_outputs)',
- ],
- 'variables': {
- 'script': '<(DEPTH)/chrome/tools/build/version.py',
- 'lastchange': '<(DEPTH)/build/util/LASTCHANGE.blink',
- 'template': '<(DEPTH)/webkit/build/webkit_version.h.in',
- },
- },
- ],
- 'direct_dependent_settings': {
- 'include_dirs': [
- '<(SHARED_INTERMEDIATE_DIR)',
- ],
- },
- # Dependents may rely on files generated by this target or one of its
- # own hard dependencies.
- 'hard_dependency': 1,
- },
- ],
- }],
- ],
-}
diff --git a/chromium/webkit/common/user_agent/webkit_user_agent_export.h b/chromium/webkit/common/user_agent/webkit_user_agent_export.h
deleted file mode 100644
index 5f9598ff2bc..00000000000
--- a/chromium/webkit/common/user_agent/webkit_user_agent_export.h
+++ /dev/null
@@ -1,29 +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 WEBKIT_COMMON_USER_AGENT_WEBKIT_USER_AGENT_EXPORT_H_
-#define WEBKIT_COMMON_USER_AGENT_WEBKIT_USER_AGENT_EXPORT_H_
-
-#if defined(COMPONENT_BUILD)
-#if defined(WIN32)
-
-#if defined(WEBKIT_USER_AGENT_IMPLEMENTATION)
-#define WEBKIT_USER_AGENT_EXPORT __declspec(dllexport)
-#else
-#define WEBKIT_USER_AGENT_EXPORT __declspec(dllimport)
-#endif // defined(WEBKIT_USER_AGENT_IMPLEMENTATION)
-
-#else // defined(WIN32)
-#if defined(WEBKIT_USER_AGENT_IMPLEMENTATION)
-#define WEBKIT_USER_AGENT_EXPORT __attribute__((visibility("default")))
-#else
-#define WEBKIT_USER_AGENT_EXPORT
-#endif
-#endif
-
-#else // defined(COMPONENT_BUILD)
-#define WEBKIT_USER_AGENT_EXPORT
-#endif
-
-#endif // WEBKIT_COMMON_USER_AGENT_WEBKIT_USER_AGENT_EXPORT_H_
diff --git a/chromium/webkit/common/webkit_common.gyp b/chromium/webkit/common/webkit_common.gyp
index 0a162bcea0d..5e3e8b8e100 100644
--- a/chromium/webkit/common/webkit_common.gyp
+++ b/chromium/webkit/common/webkit_common.gyp
@@ -9,6 +9,7 @@
},
'targets': [
{
+ # GN version: //webkit/common:common",
'target_name': 'webkit_common',
'type': '<(component)',
'defines': [
@@ -20,11 +21,16 @@
'<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
'<(DEPTH)/net/net.gyp:net',
'<(DEPTH)/skia/skia.gyp:skia',
+ '<(DEPTH)/ui/base/ui_base.gyp:ui_base',
'<(DEPTH)/ui/gfx/gfx.gyp:gfx',
+ '<(DEPTH)/ui/gfx/gfx.gyp:gfx_geometry',
'<(DEPTH)/ui/resources/ui_resources.gyp:ui_resources',
- '<(DEPTH)/ui/ui.gyp:ui',
'<(DEPTH)/url/url.gyp:url_lib',
'<(DEPTH)/webkit/webkit_resources.gyp:webkit_resources',
+ '<(DEPTH)/third_party/WebKit/public/blink_headers.gyp:blink_headers',
+ ],
+ 'export_dependent_settings': [
+ '<(DEPTH)/third_party/WebKit/public/blink_headers.gyp:blink_headers',
],
'include_dirs': [
@@ -34,25 +40,8 @@
],
'sources': [
- 'cursors/webcursor.cc',
- 'cursors/webcursor.h',
- 'cursors/webcursor_android.cc',
- 'cursors/webcursor_aura.cc',
- 'cursors/webcursor_aurawin.cc',
- 'cursors/webcursor_aurax11.cc',
- 'cursors/webcursor_gtk.cc',
- 'cursors/webcursor_gtk_data.h',
- 'cursors/webcursor_mac.mm',
- 'cursors/webcursor_null.cc',
- 'cursors/webcursor_win.cc',
'data_element.cc',
'data_element.h',
- 'resource_devtools_info.cc',
- 'resource_devtools_info.h',
- 'resource_request_body.cc',
- 'resource_request_body.h',
- 'resource_response_info.cc',
- 'resource_response_info.h',
'resource_type.cc',
'resource_type.h',
'webkit_common_export.h',
@@ -61,43 +50,21 @@
],
'conditions': [
- ['toolkit_uses_gtk == 1', {
- 'dependencies': [
- '<(DEPTH)/build/linux/system.gyp:gtk',
- ],
- 'sources/': [['exclude', '_x11\\.cc$']],
- }],
- ['use_aura==1', {
- 'sources!': [
- 'cursors/webcursor_mac.mm',
- 'cursors/webcursor_win.cc',
- ],
- }],
['use_aura==1 and use_x11==1', {
- 'link_settings': {
- 'libraries': [ '-lXcursor', ],
- },
- }],
- ['use_ozone==0', {
- 'sources!': [
- 'cursors/webcursor_null.cc',
+ 'dependencies': [
+ '<(DEPTH)/build/linux/system.gyp:xcursor',
],
}],
- ['OS!="mac"', {
- 'sources/': [['exclude', '_mac\\.(cc|mm)$']],
- }, { # else: OS=="mac"
+ ['OS=="mac"', {
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/QuartzCore.framework',
],
},
}],
- ['OS!="win"', {
- 'sources/': [['exclude', '_win\\.cc$']],
- }, { # else: OS=="win"
+ ['OS=="win"', {
# TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
'msvs_disabled_warnings': [ 4800, 4267 ],
- 'sources/': [['exclude', '_posix\\.cc$']],
}],
],
},
diff --git a/chromium/webkit/common/webpreferences.cc b/chromium/webkit/common/webpreferences.cc
index 409693260e5..a953f4a99aa 100644
--- a/chromium/webkit/common/webpreferences.cc
+++ b/chromium/webkit/common/webpreferences.cc
@@ -10,6 +10,7 @@
#include "third_party/WebKit/public/web/WebSettings.h"
#include "third_party/icu/source/common/unicode/uchar.h"
+using base::ASCIIToWide;
using blink::WebSettings;
WebPreferences::WebPreferences()
@@ -43,55 +44,43 @@ WebPreferences::WebPreferences()
caret_browsing_enabled(false),
hyperlink_auditing_enabled(true),
is_online(true),
+ connection_type(net::NetworkChangeNotifier::CONNECTION_NONE),
allow_universal_access_from_file_urls(false),
allow_file_access_from_file_urls(false),
webaudio_enabled(false),
experimental_webgl_enabled(false),
+ pepper_3d_enabled(false),
flash_3d_enabled(true),
flash_stage3d_enabled(false),
flash_stage3d_baseline_enabled(false),
gl_multisampling_enabled(true),
privileged_webgl_extensions_enabled(false),
webgl_errors_to_console_enabled(true),
- accelerated_compositing_for_overflow_scroll_enabled(false),
- universal_accelerated_compositing_for_overflow_scroll_enabled(false),
- accelerated_compositing_for_scrollable_frames_enabled(false),
- composited_scrolling_for_frames_enabled(false),
mock_scrollbars_enabled(false),
- layer_squashing_enabled(false),
- threaded_html_parser(true),
- show_paint_rects(false),
+ layer_squashing_enabled(true),
asynchronous_spell_checking_enabled(true),
unified_textchecker_enabled(false),
- accelerated_compositing_enabled(false),
- force_compositing_mode(false),
- accelerated_compositing_for_3d_transforms_enabled(false),
- accelerated_compositing_for_animation_enabled(false),
- accelerated_compositing_for_video_enabled(false),
+ accelerated_compositing_for_video_enabled(true),
accelerated_2d_canvas_enabled(false),
minimum_accelerated_2d_canvas_size(257 * 256),
antialiased_2d_canvas_disabled(false),
accelerated_2d_canvas_msaa_sample_count(0),
accelerated_filters_enabled(false),
+ deferred_filters_enabled(false),
+ container_culling_enabled(false),
gesture_tap_highlight_enabled(false),
- accelerated_compositing_for_plugins_enabled(false),
- memory_info_enabled(false),
- fullscreen_enabled(false),
allow_displaying_insecure_content(true),
allow_running_insecure_content(false),
password_echo_enabled(false),
should_print_backgrounds(false),
should_clear_document_background(true),
enable_scroll_animator(false),
- visual_word_movement_enabled(false),
- lazy_layout_enabled(false),
region_based_columns_enabled(false),
touch_enabled(false),
device_supports_touch(false),
device_supports_mouse(true),
touch_adjustment_enabled(true),
pointer_events_max_touch_points(0),
- fixed_position_creates_stacking_context(false),
sync_xhr_in_documents_enabled(true),
deferred_image_decoding_enabled(false),
should_respect_image_orientation(false),
@@ -118,12 +107,13 @@ WebPreferences::WebPreferences()
smart_insert_delete_enabled(false),
#endif
spatial_navigation_enabled(false),
- experimental_websocket_enabled(false),
pinch_virtual_viewport_enabled(false),
pinch_overlay_scrollbar_thickness(0),
use_solid_color_scrollbars(false),
compositor_touch_hit_testing(true),
- cookie_enabled(true)
+ navigate_on_drag_drop(true),
+ cookie_enabled(true),
+ pepper_accelerated_video_decode_enabled(false)
#if defined(OS_ANDROID)
,
text_autosizing_enabled(true),
@@ -132,7 +122,6 @@ WebPreferences::WebPreferences()
force_enable_zoom(false),
double_tap_to_zoom_enabled(true),
user_gesture_required_for_media_playback(true),
- user_gesture_required_for_media_fullscreen(true),
support_deprecated_target_density_dpi(false),
use_legacy_background_size_shorthand_behavior(false),
wide_viewport_quirk(false),
@@ -147,19 +136,19 @@ WebPreferences::WebPreferences()
#endif
{
standard_font_family_map[webkit_glue::kCommonScript] =
- ASCIIToUTF16("Times New Roman");
+ base::ASCIIToUTF16("Times New Roman");
fixed_font_family_map[webkit_glue::kCommonScript] =
- ASCIIToUTF16("Courier New");
+ base::ASCIIToUTF16("Courier New");
serif_font_family_map[webkit_glue::kCommonScript] =
- ASCIIToUTF16("Times New Roman");
+ base::ASCIIToUTF16("Times New Roman");
sans_serif_font_family_map[webkit_glue::kCommonScript] =
- ASCIIToUTF16("Arial");
+ base::ASCIIToUTF16("Arial");
cursive_font_family_map[webkit_glue::kCommonScript] =
- ASCIIToUTF16("Script");
+ base::ASCIIToUTF16("Script");
fantasy_font_family_map[webkit_glue::kCommonScript] =
- ASCIIToUTF16("Impact");
+ base::ASCIIToUTF16("Impact");
pictograph_font_family_map[webkit_glue::kCommonScript] =
- ASCIIToUTF16("Times New Roman");
+ base::ASCIIToUTF16("Times New Roman");
}
WebPreferences::~WebPreferences() {
diff --git a/chromium/webkit/common/webpreferences.h b/chromium/webkit/common/webpreferences.h
index 6e689d1a730..241fde36a26 100644
--- a/chromium/webkit/common/webpreferences.h
+++ b/chromium/webkit/common/webpreferences.h
@@ -16,6 +16,7 @@
#include <vector>
#include "base/strings/string16.h"
+#include "net/base/network_change_notifier.h"
#include "url/gurl.h"
#include "webkit/common/webkit_common_export.h"
@@ -38,7 +39,8 @@ enum EditingBehavior {
EDITING_BEHAVIOR_MAC,
EDITING_BEHAVIOR_WIN,
EDITING_BEHAVIOR_UNIX,
- EDITING_BEHAVIOR_ANDROID
+ EDITING_BEHAVIOR_ANDROID,
+ EDITING_BEHAVIOR_LAST = EDITING_BEHAVIOR_ANDROID
};
@@ -91,56 +93,44 @@ struct WEBKIT_COMMON_EXPORT WebPreferences {
bool caret_browsing_enabled;
bool hyperlink_auditing_enabled;
bool is_online;
+ net::NetworkChangeNotifier::ConnectionType connection_type;
bool allow_universal_access_from_file_urls;
bool allow_file_access_from_file_urls;
bool webaudio_enabled;
bool experimental_webgl_enabled;
+ bool pepper_3d_enabled;
bool flash_3d_enabled;
bool flash_stage3d_enabled;
bool flash_stage3d_baseline_enabled;
bool gl_multisampling_enabled;
bool privileged_webgl_extensions_enabled;
bool webgl_errors_to_console_enabled;
- bool accelerated_compositing_for_overflow_scroll_enabled;
- bool universal_accelerated_compositing_for_overflow_scroll_enabled;
- bool accelerated_compositing_for_scrollable_frames_enabled;
- bool composited_scrolling_for_frames_enabled;
bool mock_scrollbars_enabled;
bool layer_squashing_enabled;
- bool threaded_html_parser;
- bool show_paint_rects;
bool asynchronous_spell_checking_enabled;
bool unified_textchecker_enabled;
- bool accelerated_compositing_enabled;
- bool force_compositing_mode;
- bool accelerated_compositing_for_3d_transforms_enabled;
- bool accelerated_compositing_for_animation_enabled;
bool accelerated_compositing_for_video_enabled;
bool accelerated_2d_canvas_enabled;
int minimum_accelerated_2d_canvas_size;
bool antialiased_2d_canvas_disabled;
int accelerated_2d_canvas_msaa_sample_count;
bool accelerated_filters_enabled;
+ bool deferred_filters_enabled;
+ bool container_culling_enabled;
bool gesture_tap_highlight_enabled;
- bool accelerated_compositing_for_plugins_enabled;
- bool memory_info_enabled;
- bool fullscreen_enabled;
bool allow_displaying_insecure_content;
bool allow_running_insecure_content;
bool password_echo_enabled;
bool should_print_backgrounds;
bool should_clear_document_background;
bool enable_scroll_animator;
- bool visual_word_movement_enabled;
bool css_variables_enabled;
- bool lazy_layout_enabled;
bool region_based_columns_enabled;
bool touch_enabled;
bool device_supports_touch;
bool device_supports_mouse;
bool touch_adjustment_enabled;
int pointer_events_max_touch_points;
- bool fixed_position_creates_stacking_context;
bool sync_xhr_in_documents_enabled;
bool deferred_image_decoding_enabled;
bool should_respect_image_orientation;
@@ -153,11 +143,11 @@ struct WEBKIT_COMMON_EXPORT WebPreferences {
bool initialize_at_minimum_page_scale;
bool smart_insert_delete_enabled;
bool spatial_navigation_enabled;
- bool experimental_websocket_enabled;
bool pinch_virtual_viewport_enabled;
int pinch_overlay_scrollbar_thickness;
bool use_solid_color_scrollbars;
bool compositor_touch_hit_testing;
+ bool navigate_on_drag_drop;
// This flags corresponds to a Page's Settings' setCookieEnabled state. It
// only controls whether or not the "document.cookie" field is properly
@@ -166,6 +156,10 @@ struct WEBKIT_COMMON_EXPORT WebPreferences {
// without raising a DOM security exception.
bool cookie_enabled;
+ // This flag indicates whether H/W accelerated video decode is enabled for
+ // pepper plugins. Defaults to false.
+ bool pepper_accelerated_video_decode_enabled;
+
#if defined(OS_ANDROID)
bool text_autosizing_enabled;
float font_scale_factor;
@@ -173,7 +167,6 @@ struct WEBKIT_COMMON_EXPORT WebPreferences {
bool force_enable_zoom;
bool double_tap_to_zoom_enabled;
bool user_gesture_required_for_media_playback;
- bool user_gesture_required_for_media_fullscreen;
GURL default_video_poster_url;
bool support_deprecated_target_density_dpi;
bool use_legacy_background_size_shorthand_behavior;
diff --git a/chromium/webkit/glue/inspector_strings.grd b/chromium/webkit/glue/inspector_strings.grd
index 78c558406cb..59642e45cd8 100644
--- a/chromium/webkit/glue/inspector_strings.grd
+++ b/chromium/webkit/glue/inspector_strings.grd
@@ -43,34 +43,34 @@ so we include the original license below:
<outputs>
<output filename="inspectorStrings_am.js" type="js_map_format" lang="am" />
<output filename="inspectorStrings_ar.js" type="js_map_format" lang="ar" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="inspectorStrings_ast.js" type="js_map_format" lang="ast" />
</if>
<output filename="inspectorStrings_bg.js" type="js_map_format" lang="bg" />
<output filename="inspectorStrings_bn.js" type="js_map_format" lang="bn" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="inspectorStrings_bs.js" type="js_map_format" lang="bs" />
</if>
<output filename="inspectorStrings_ca.js" type="js_map_format" lang="ca" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="inspectorStrings_ca@valencia.js" type="js_map_format" lang="ca@valencia" />
</if>
<output filename="inspectorStrings_cs.js" type="js_map_format" lang="cs" />
<output filename="inspectorStrings_da.js" type="js_map_format" lang="da" />
<output filename="inspectorStrings_de.js" type="js_map_format" lang="de" />
<output filename="inspectorStrings_el.js" type="js_map_format" lang="el" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="inspectorStrings_en-AU.js" type="js_map_format" lang="en-AU" />
</if>
<output filename="inspectorStrings_en-GB.js" type="js_map_format" lang="en-GB" />
<output filename="inspectorStrings_en-US.js" type="js_map_format" lang="en" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="inspectorStrings_eo.js" type="js_map_format" lang="eo" />
</if>
<output filename="inspectorStrings_es.js" type="js_map_format" lang="es" />
<output filename="inspectorStrings_es-419.js" type="js_map_format" lang="es-419" />
<output filename="inspectorStrings_et.js" type="js_map_format" lang="et" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="inspectorStrings_eu.js" type="js_map_format" lang="eu" />
</if>
<output filename="inspectorStrings_fa.js" type="js_map_format" lang="fa" />
@@ -78,7 +78,7 @@ so we include the original license below:
<output filename="inspectorStrings_fi.js" type="js_map_format" lang="fi" />
<output filename="inspectorStrings_fil.js" type="js_map_format" lang="fil" />
<output filename="inspectorStrings_fr.js" type="js_map_format" lang="fr" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="inspectorStrings_gl.js" type="js_map_format" lang="gl" />
</if>
<output filename="inspectorStrings_gu.js" type="js_map_format" lang="gu" />
@@ -86,19 +86,19 @@ so we include the original license below:
<output filename="inspectorStrings_hi.js" type="js_map_format" lang="hi" />
<output filename="inspectorStrings_hr.js" type="js_map_format" lang="hr" />
<output filename="inspectorStrings_hu.js" type="js_map_format" lang="hu" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="inspectorStrings_hy.js" type="js_map_format" lang="hy" />
<output filename="inspectorStrings_ia.js" type="js_map_format" lang="ia" />
</if>
<output filename="inspectorStrings_id.js" type="js_map_format" lang="id" />
<output filename="inspectorStrings_it.js" type="js_map_format" lang="it" />
<output filename="inspectorStrings_ja.js" type="js_map_format" lang="ja" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="inspectorStrings_ka.js" type="js_map_format" lang="ka" />
</if>
<output filename="inspectorStrings_kn.js" type="js_map_format" lang="kn" />
<output filename="inspectorStrings_ko.js" type="js_map_format" lang="ko" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="inspectorStrings_ku.js" type="js_map_format" lang="ku" />
<output filename="inspectorStrings_kw.js" type="js_map_format" lang="kw" />
</if>
@@ -106,7 +106,7 @@ so we include the original license below:
<output filename="inspectorStrings_lv.js" type="js_map_format" lang="lv" />
<output filename="inspectorStrings_ml.js" type="js_map_format" lang="ml" />
<output filename="inspectorStrings_mr.js" type="js_map_format" lang="mr" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="inspectorStrings_ms.js" type="js_map_format" lang="ms" />
</if>
<output filename="inspectorStrings_nl.js" type="js_map_format" lang="nl" />
@@ -127,7 +127,7 @@ so we include the original license below:
<output filename="inspectorStrings_te.js" type="js_map_format" lang="te" />
<output filename="inspectorStrings_th.js" type="js_map_format" lang="th" />
<output filename="inspectorStrings_tr.js" type="js_map_format" lang="tr" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="inspectorStrings_ug.js" type="js_map_format" lang="ug" />
</if>
<output filename="inspectorStrings_uk.js" type="js_map_format" lang="uk" />
@@ -136,7 +136,7 @@ so we include the original license below:
<output filename="inspectorStrings_zh-TW.js" type="js_map_format" lang="zh-TW" />
</outputs>
<translations>
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<file path="../../third_party/launchpad_translations/inspector_strings_ast.xtb" lang="ast" />
<file path="../../third_party/launchpad_translations/inspector_strings_bn.xtb" lang="bn" />
<file path="../../third_party/launchpad_translations/inspector_strings_bs.xtb" lang="bs" />
diff --git a/chromium/webkit/glue/resources/default_100_percent/amex.png b/chromium/webkit/glue/resources/default_100_percent/amex.png
deleted file mode 100644
index cb20e05817c..00000000000
--- a/chromium/webkit/glue/resources/default_100_percent/amex.png
+++ /dev/null
Binary files differ
diff --git a/chromium/webkit/glue/resources/default_100_percent/cc-generic.png b/chromium/webkit/glue/resources/default_100_percent/cc-generic.png
deleted file mode 100644
index 195ad9769a7..00000000000
--- a/chromium/webkit/glue/resources/default_100_percent/cc-generic.png
+++ /dev/null
Binary files differ
diff --git a/chromium/webkit/glue/resources/default_100_percent/diners.png b/chromium/webkit/glue/resources/default_100_percent/diners.png
deleted file mode 100644
index f3e82663443..00000000000
--- a/chromium/webkit/glue/resources/default_100_percent/diners.png
+++ /dev/null
Binary files differ
diff --git a/chromium/webkit/glue/resources/default_100_percent/discover.png b/chromium/webkit/glue/resources/default_100_percent/discover.png
deleted file mode 100644
index d6a27178b7f..00000000000
--- a/chromium/webkit/glue/resources/default_100_percent/discover.png
+++ /dev/null
Binary files differ
diff --git a/chromium/webkit/glue/resources/default_100_percent/input_speech.png b/chromium/webkit/glue/resources/default_100_percent/input_speech.png
deleted file mode 100644
index 16a73a1b7dc..00000000000
--- a/chromium/webkit/glue/resources/default_100_percent/input_speech.png
+++ /dev/null
Binary files differ
diff --git a/chromium/webkit/glue/resources/default_100_percent/input_speech_recording.png b/chromium/webkit/glue/resources/default_100_percent/input_speech_recording.png
deleted file mode 100644
index 7d3931ddca8..00000000000
--- a/chromium/webkit/glue/resources/default_100_percent/input_speech_recording.png
+++ /dev/null
Binary files differ
diff --git a/chromium/webkit/glue/resources/default_100_percent/input_speech_waiting.png b/chromium/webkit/glue/resources/default_100_percent/input_speech_waiting.png
deleted file mode 100644
index 5665f468b47..00000000000
--- a/chromium/webkit/glue/resources/default_100_percent/input_speech_waiting.png
+++ /dev/null
Binary files differ
diff --git a/chromium/webkit/glue/resources/default_100_percent/jcb.png b/chromium/webkit/glue/resources/default_100_percent/jcb.png
deleted file mode 100644
index af76eec65c4..00000000000
--- a/chromium/webkit/glue/resources/default_100_percent/jcb.png
+++ /dev/null
Binary files differ
diff --git a/chromium/webkit/glue/resources/default_100_percent/mastercard.png b/chromium/webkit/glue/resources/default_100_percent/mastercard.png
deleted file mode 100644
index 85fc46bfd6e..00000000000
--- a/chromium/webkit/glue/resources/default_100_percent/mastercard.png
+++ /dev/null
Binary files differ
diff --git a/chromium/webkit/glue/resources/default_100_percent/north_east_south_west_resize_cursor.png b/chromium/webkit/glue/resources/default_100_percent/north_east_south_west_resize_cursor.png
index aec2b407b06..5db337a1d51 100644
--- a/chromium/webkit/glue/resources/default_100_percent/north_east_south_west_resize_cursor.png
+++ b/chromium/webkit/glue/resources/default_100_percent/north_east_south_west_resize_cursor.png
Binary files differ
diff --git a/chromium/webkit/glue/resources/default_100_percent/north_resize_cursor.png b/chromium/webkit/glue/resources/default_100_percent/north_resize_cursor.png
index a0ea30ff8b6..bdd01b9fc40 100644
--- a/chromium/webkit/glue/resources/default_100_percent/north_resize_cursor.png
+++ b/chromium/webkit/glue/resources/default_100_percent/north_resize_cursor.png
Binary files differ
diff --git a/chromium/webkit/glue/resources/default_100_percent/synthetic_touch_cursor.png b/chromium/webkit/glue/resources/default_100_percent/synthetic_touch_cursor.png
deleted file mode 100644
index 883e6905059..00000000000
--- a/chromium/webkit/glue/resources/default_100_percent/synthetic_touch_cursor.png
+++ /dev/null
Binary files differ
diff --git a/chromium/webkit/glue/resources/default_100_percent/visa.png b/chromium/webkit/glue/resources/default_100_percent/visa.png
deleted file mode 100644
index 5f223226bec..00000000000
--- a/chromium/webkit/glue/resources/default_100_percent/visa.png
+++ /dev/null
Binary files differ
diff --git a/chromium/webkit/glue/resources/default_200_percent/amex.png b/chromium/webkit/glue/resources/default_200_percent/amex.png
deleted file mode 100644
index dc25fda58df..00000000000
--- a/chromium/webkit/glue/resources/default_200_percent/amex.png
+++ /dev/null
Binary files differ
diff --git a/chromium/webkit/glue/resources/default_200_percent/discover.png b/chromium/webkit/glue/resources/default_200_percent/discover.png
deleted file mode 100644
index e8935be955b..00000000000
--- a/chromium/webkit/glue/resources/default_200_percent/discover.png
+++ /dev/null
Binary files differ
diff --git a/chromium/webkit/glue/resources/default_200_percent/mastercard.png b/chromium/webkit/glue/resources/default_200_percent/mastercard.png
deleted file mode 100644
index bd570e3e640..00000000000
--- a/chromium/webkit/glue/resources/default_200_percent/mastercard.png
+++ /dev/null
Binary files differ
diff --git a/chromium/webkit/glue/resources/default_200_percent/visa.png b/chromium/webkit/glue/resources/default_200_percent/visa.png
deleted file mode 100644
index e92cd71bf52..00000000000
--- a/chromium/webkit/glue/resources/default_200_percent/visa.png
+++ /dev/null
Binary files differ
diff --git a/chromium/webkit/glue/resources/webkit_resources.grd b/chromium/webkit/glue/resources/webkit_resources.grd
index 1cfaa94d1a5..42654c5e953 100644
--- a/chromium/webkit/glue/resources/webkit_resources.grd
+++ b/chromium/webkit/glue/resources/webkit_resources.grd
@@ -6,17 +6,10 @@
</output>
<output filename="webkit_resources_100_percent.pak" type="data_package" context="default_100_percent" />
<output filename="webkit_resources_200_percent.pak" type="data_package" context="default_200_percent" />
- <!-- This is used by third_party/WebKit/Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp
- TOOD(oshima): Fix the above gype and remove this.
- -->
- <output filename="webkit_resources.rc" type="rc_all" context="default_100_percent" />
</outputs>
<release seq="1">
<structures fallback_to_low_resolution="true">
<structure type="chrome_scaled_image" name="IDR_BROKENIMAGE" file="broken_image.png" />
- <structure type="chrome_scaled_image" name="IDR_INPUT_SPEECH" file="input_speech.png" />
- <structure type="chrome_scaled_image" name="IDR_INPUT_SPEECH_RECORDING" file="input_speech_recording.png" />
- <structure type="chrome_scaled_image" name="IDR_INPUT_SPEECH_WAITING" file="input_speech_waiting.png" />
<structure type="chrome_scaled_image" name="IDR_MEDIAPLAYER_PAUSE_BUTTON" file="mediaplayer_pause.png" />
<structure type="chrome_scaled_image" name="IDR_MEDIAPLAYER_PAUSE_BUTTON_HOVER" file="mediaplayer_pause_hover.png" />
<structure type="chrome_scaled_image" name="IDR_MEDIAPLAYER_PAUSE_BUTTON_DOWN" file="mediaplayer_pause_down.png" />
@@ -52,9 +45,7 @@
<structure type="chrome_scaled_image" name="IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_HOVER" file="mediaplayer_fullscreen_hover.png" />
<structure type="chrome_scaled_image" name="IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_DOWN" file="mediaplayer_fullscreen_down.png" />
<structure type="chrome_scaled_image" name="IDR_MEDIAPLAYER_FULLSCREEN_BUTTON_DISABLED" file="mediaplayer_fullscreen_disabled.png" />
- <if expr="is_android">
- <structure type="chrome_scaled_image" name="IDR_MEDIAPLAYER_OVERLAY_PLAY_BUTTON" file="mediaplayer_overlay_play.png" />
- </if>
+ <structure type="chrome_scaled_image" name="IDR_MEDIAPLAYER_OVERLAY_PLAY_BUTTON" file="mediaplayer_overlay_play.png" />
<if expr="is_macosx">
<structure type="chrome_scaled_image" name="IDR_OVERHANG_PATTERN" file="overhang_pattern.png" />
<structure type="chrome_scaled_image" name="IDR_OVERHANG_SHADOW" file="overhang_shadow.png" />
@@ -88,61 +79,55 @@
<structure type="chrome_scaled_image" name="IDR_SEARCH_MAGNIFIER" file="search_magnifier.png" />
<structure type="chrome_scaled_image" name="IDR_SEARCH_MAGNIFIER_RESULTS" file="search_magnifier_results.png" />
<structure type="chrome_scaled_image" name="IDR_TEXTAREA_RESIZER" file="textarea_resize_corner.png" />
- <structure type="chrome_scaled_image" name="IDR_AUTOFILL_CC_AMEX" file="amex.png" />
- <structure type="chrome_scaled_image" name="IDR_AUTOFILL_CC_DINERS" file="diners.png" />
- <structure type="chrome_scaled_image" name="IDR_AUTOFILL_CC_DISCOVER" file="discover.png" />
- <structure type="chrome_scaled_image" name="IDR_AUTOFILL_CC_GENERIC" file="cc-generic.png" />
- <structure type="chrome_scaled_image" name="IDR_AUTOFILL_CC_JCB" file="jcb.png" />
- <structure type="chrome_scaled_image" name="IDR_AUTOFILL_CC_MASTERCARD" file="mastercard.png" />
- <structure type="chrome_scaled_image" name="IDR_AUTOFILL_CC_VISA" file="visa.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_FTP" file="pdf_button_ftp.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_FTP_HOVER" file="pdf_button_ftp_hover.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_FTP_PRESSED" file="pdf_button_ftp_pressed.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_FTW" file="pdf_button_ftw.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_FTW_HOVER" file="pdf_button_ftw_hover.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_FTW_PRESSED" file="pdf_button_ftw_pressed.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMIN_END" file="pdf_button_zoomin_end.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMIN_END_HOVER" file="pdf_button_zoomin_end_hover.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMIN_END_PRESSED" file="pdf_button_zoomin_end_pressed.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMIN" file="pdf_button_zoomin.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMIN_HOVER" file="pdf_button_zoomin_hover.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMIN_PRESSED" file="pdf_button_zoomin_pressed.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMOUT" file="pdf_button_zoomout.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMOUT_HOVER" file="pdf_button_zoomout_hover.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMOUT_PRESSED" file="pdf_button_zoomout_pressed.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_SAVE" file="pdf_button_save.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_SAVE_HOVER" file="pdf_button_save_hover.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_SAVE_PRESSED" file="pdf_button_save_pressed.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_PRINT" file="pdf_button_print.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_PRINT_HOVER" file="pdf_button_print_hover.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_PRINT_PRESSED" file="pdf_button_print_pressed.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_PRINT_DISABLED" file="pdf_button_print_disabled.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_0" file="pdf_thumbnail_0.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_1" file="pdf_thumbnail_1.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_2" file="pdf_thumbnail_2.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_3" file="pdf_thumbnail_3.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_4" file="pdf_thumbnail_4.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_5" file="pdf_thumbnail_5.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_6" file="pdf_thumbnail_6.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_7" file="pdf_thumbnail_7.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_8" file="pdf_thumbnail_8.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_9" file="pdf_thumbnail_9.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_NUM_BACKGROUND" file="pdf_thumbnail_num_background.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_0" file="pdf_progress_0.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_1" file="pdf_progress_1.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_2" file="pdf_progress_2.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_3" file="pdf_progress_3.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_4" file="pdf_progress_4.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_5" file="pdf_progress_5.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_6" file="pdf_progress_6.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_7" file="pdf_progress_7.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_8" file="pdf_progress_8.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_BACKGROUND" file="pdf_progress_background.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_PAGE_INDICATOR_BACKGROUND" file="pdf_page_indicator_background.png" />
- <structure type="chrome_scaled_image" name="IDR_PDF_PAGE_DROPSHADOW" file="pdf_dropshadow.png" />
+ <if expr="enable_plugins">
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_FTP" file="pdf_button_ftp.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_FTP_HOVER" file="pdf_button_ftp_hover.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_FTP_PRESSED" file="pdf_button_ftp_pressed.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_FTW" file="pdf_button_ftw.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_FTW_HOVER" file="pdf_button_ftw_hover.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_FTW_PRESSED" file="pdf_button_ftw_pressed.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMIN_END" file="pdf_button_zoomin_end.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMIN_END_HOVER" file="pdf_button_zoomin_end_hover.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMIN_END_PRESSED" file="pdf_button_zoomin_end_pressed.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMIN" file="pdf_button_zoomin.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMIN_HOVER" file="pdf_button_zoomin_hover.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMIN_PRESSED" file="pdf_button_zoomin_pressed.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMOUT" file="pdf_button_zoomout.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMOUT_HOVER" file="pdf_button_zoomout_hover.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_ZOOMOUT_PRESSED" file="pdf_button_zoomout_pressed.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_SAVE" file="pdf_button_save.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_SAVE_HOVER" file="pdf_button_save_hover.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_SAVE_PRESSED" file="pdf_button_save_pressed.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_PRINT" file="pdf_button_print.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_PRINT_HOVER" file="pdf_button_print_hover.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_PRINT_PRESSED" file="pdf_button_print_pressed.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_BUTTON_PRINT_DISABLED" file="pdf_button_print_disabled.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_0" file="pdf_thumbnail_0.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_1" file="pdf_thumbnail_1.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_2" file="pdf_thumbnail_2.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_3" file="pdf_thumbnail_3.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_4" file="pdf_thumbnail_4.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_5" file="pdf_thumbnail_5.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_6" file="pdf_thumbnail_6.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_7" file="pdf_thumbnail_7.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_8" file="pdf_thumbnail_8.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_9" file="pdf_thumbnail_9.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_THUMBNAIL_NUM_BACKGROUND" file="pdf_thumbnail_num_background.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_0" file="pdf_progress_0.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_1" file="pdf_progress_1.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_2" file="pdf_progress_2.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_3" file="pdf_progress_3.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_4" file="pdf_progress_4.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_5" file="pdf_progress_5.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_6" file="pdf_progress_6.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_7" file="pdf_progress_7.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_8" file="pdf_progress_8.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_PROGRESS_BAR_BACKGROUND" file="pdf_progress_background.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_PAGE_INDICATOR_BACKGROUND" file="pdf_page_indicator_background.png" />
+ <structure type="chrome_scaled_image" name="IDR_PDF_PAGE_DROPSHADOW" file="pdf_dropshadow.png" />
+ </if>
<structure type="chrome_scaled_image" name="IDR_PASSWORD_GENERATION_ICON" file="password_generation.png" />
<structure type="chrome_scaled_image" name="IDR_PASSWORD_GENERATION_ICON_HOVER" file="password_generation_hover.png" />
- <structure type="chrome_scaled_image" name="IDR_SYNTHETIC_TOUCH_CURSOR" file="synthetic_touch_cursor.png" />
</structures>
</release>
</grit>
diff --git a/chromium/webkit/glue/resources/webkit_strings_am.xtb b/chromium/webkit/glue/resources/webkit_strings_am.xtb
index 94150f03e0b..8fa754a49e0 100644
--- a/chromium/webkit/glue/resources/webkit_strings_am.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_am.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="am">
<translation id="4763480195061959176">ቪዲዮ</translation>
<translation id="5843503607508392247">ሌላ...</translation>
-<translation id="2426432199384958866">በዥረት የሚለቀቀውን ፊልም ወደ ትክክለኛው ጊዜ መልስ</translation>
<translation id="248395913932153421">ቀን</translation>
<translation id="1729654308190250600">እባክዎ ባዶ ያልሆነ የኢሜይል አድራሻ ያስገቡ።</translation>
<translation id="6015796118275082299">ዓመት</translation>
-<translation id="9186171386827445984">ሰነዱን በመጫን ላይ፦ <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> ገጾች...</translation>
-<translation id="1235745349614807883">የቅርብ ጊዜ ፍለጋዎችን አስወግድ</translation>
+<translation id="1235745349614807883">የቅርብ ጊዜ ፍለጋዎችን አጽዳ</translation>
<translation id="7223624360433298498">ያለፈው ጊዜ</translation>
<translation id="1171774979989969504">እባክዎ የኢሜይል አድራሻ ያስገቡ።</translation>
<translation id="709897737746224366">እባክዎ የተጠየቀውን ቅርጸት ያዛምዱ።</translation>
<translation id="5048533449481078685">ዝርዝር አመልካች</translation>
<translation id="4202807286478387388">ዝለል</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">እባክዎ አንድ ክፍል ያስገቡና «<ph name="ATSIGN"/>»ን ያስከትሉ። «<ph name="INVALIDADDRESS"/>» ያልተሟላ ነው።</translation>
<translation id="2746543609216772311">ዋጋ <ph name="MINIMUM_DATE_OR_TIME"/> ወይም ከዚያ በኋላ መሆን አለበት።</translation>
<translation id="2572483411312390101">አጫውት</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">የፊልም ሰዓት</translation>
<translation id="8199524924445686405">ዓዓዓዓ</translation>
<translation id="795667975304826397">ምንም ፋይል አልተመረጠም</translation>
-<translation id="1320012872283894746">በፍጥነት ወደ ኋላ ተመልሰው ይፈልጉ</translation>
<translation id="7789962463072032349">ላፍታ አቁም</translation>
<translation id="6853785296079745596">የተዘጉ የስዕል መግለጫዎችን ይደብቁ</translation>
<translation id="4360991593054037559">እባክዎ የሚሰራ ዋጋ ያስገቡ። ሁለቱ የሚቀርቡ ዋጋዎች <ph name="VALID_VALUE_LOW"/> እና <ph name="VALID_VALUE_HIGHER"/> ናቸው።</translation>
@@ -35,8 +31,7 @@
<translation id="2723001399770238859">ድምጽ</translation>
<translation id="6845533974506654842">ተጫን</translation>
<translation id="8244226242650769279">የምስል ካርታ</translation>
-<translation id="310520048233152454">እባክዎ አንድ ዩ አር ኤል ያስገቡ።</translation>
-<translation id="9039488204461337220">በፍጥነት ወደፊት ሄደህ ፈልግ</translation>
+<translation id="310520048233152454">እባክዎ አንድ ዩአርኤል ያስገቡ።</translation>
<translation id="4812940957355064477">እባክዎ ቁጥር ያስገቡ።</translation>
<translation id="2548326553472216322">የቅርብ ጊዜ ፍለጋዎች የሉም</translation>
<translation id="1938124657309484470">ዋጋ <ph name="MAXIMUM_DATE_OR_TIME"/> ወይም ከዚያ በፊት መሆን አለበት።</translation>
@@ -49,11 +44,10 @@
<translation id="3075154866155599887">እባክዎ የሚሰራ ዋጋ ያስገቡ። መስኩ ያልተጠናቀቀ ነው ወይም ልክ ያልሆነ ቀን አለው።</translation>
<translation id="3040011195152428237">አገናኝ</translation>
<translation id="1014825444426747588">ባዶ</translation>
-<translation id="3356679314312413792">30 ሰከንዶች ወደ ኋላ ሄደህ ፈልግ</translation>
<translation id="9050748414552849310">የተዘጉ የስዕል መግለጫዎችን አሳይ</translation>
<translation id="4522570452068850558">ዝርዝሮች</translation>
<translation id="8451268428117625855">እባክዎ ፋይል ይምረጡ።</translation>
-<translation id="8117451130807776954">በዚህ ሣምንት</translation>
+<translation id="8117451130807776954">በዚህ ሳምንት</translation>
<translation id="5966707198760109579">ሳምንት</translation>
<translation id="2901282870647571346">የአሁኑ የፊልም ሁኔታ</translation>
<translation id="2060505056492490888">«<ph name="DOT"/>» በ«<ph name="INVALIDDOMAIN"/>» ውስጥ በተሳሳተ ቦታ ላይ ነው የገባው።</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">ለመቀጠል ከፈለጉ እባክዎ ይህ ሳጥን ላይ ምልክት ያድርጉ።</translation>
<translation id="8534579021159131403">ደቂቃዎች</translation>
<translation id="819205353528511139">ፊልሙን በሙሉ ማያ ገጽ ሁነታ አጫውት</translation>
-<translation id="8964020114565522021">ፋይል ወደዚህ ጎትት</translation>
<translation id="4103419683916926126">ሚሊሰኮንዶች</translation>
<translation id="838869780401515933">አመልክት</translation>
<translation id="2846343701378493991">1024(መካከለኛ ደረጃ)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">ይህ ሰነድ በይለፍ ቃል የተጠበቀ ነው። እባክዎ የይለፍ ቃል ያስገቡ።</translation>
<translation id="5466621249238537318">እባክዎ አንድ ወይም ተጨማሪ ፋይሎችን ይምረጡ።</translation>
<translation id="9132465097189459683">ሌላ...</translation>
+<translation id="10623998915015855">የማቀያየሪያ አዝራር</translation>
<translation id="8750798805984357768">እባክዎ ከእነዚህ አማራጮች ውስጥ አንዱን ይምረጡ።</translation>
<translation id="7740050170769002709">የኤች ቲ ኤም ኤል ይዘት</translation>
<translation id="6692633176391053278">አስኪያጅ</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> ተመርጠዋል</translation>
<translation id="8541249477527128034">የማህደረ መረጃ ቁጥጥር</translation>
<translation id="2226276347425096477">እባክዎ ይህ ጽሑፍ ወደ <ph name="MAX_CHARACTERS"/> ወይም ከዚያ በታች ቁምፊዎች ያሳጥሩት (በአሁኑ ጊዜ <ph name="CURRENT_LENGTH"/> ቁምፊዎችን እየተጠቀሙ ነዎት)።</translation>
<translation id="6101327004457443354">የድምጹ ትራክ ድምጸ-ከል አንሳ</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">ሰዓቶች</translation>
<translation id="4664250907885839816">ከ«<ph name="ATSIGN"/>» በኋላ የሚመጣ ክፍል የ«<ph name="INVALIDCHARACTER"/>» ምልክት መያዝ የለበትም።</translation>
<translation id="3450233048674729344">ዋጋ ከ<ph name="MAXIMUM"/> የሚያንስ ወይም ከእሱ እኩል መሆን አለበት።</translation>
-<translation id="3471999216963526757">30 ሰከንዶች ወደ ኋላ </translation>
<translation id="668171684555832681">ሌላ…</translation>
<translation id="6270583010843788609">የፊልም ሰዓት መስመር አውራ ጣት</translation>
<translation id="5641012560118721995">መልሶ ማጫወትን ለአፍታ አቁም</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> ፋይሎች</translation>
<translation id="6643016212128521049">አጽዳ</translation>
<translation id="7888071071722539607">እባክዎ በኢሜይል አድራሻው ውስጥ «<ph name="ATSIGN"/>» ያካትቱ። «<ph name="INVALIDADDRESS"/>» ውስጥ «<ph name="ATSIGN"/>» ይጎድላል።</translation>
-<translation id="4851297395436456855">በፍጥነት ወደፊት</translation>
<translation id="1088086359088493902">ሰኮንዶች</translation>
<translation id="3934680773876859118">የፒ ዲ ኤፍ ሰነድ መጫን አልተሳካም</translation>
<translation id="3632707345189162177">የፊልሙ ቀሪ ሰከንዶች</translation>
<translation id="6359256949422175976">የፊልም ሰዓት አንፏቃቂ አውራ ጣት</translation>
<translation id="8597182159515967513">ርዕስ</translation>
<translation id="6843725295806269523">ድምጸ-ከል ያድርጉ</translation>
-<translation id="2615751259741237794">ወደ ትክክለኛ ጊዜ ተመለስ</translation>
<translation id="2653659639078652383">አስገባ</translation>
<translation id="3732799496749320381">ሚሜ</translation>
-<translation id="4484359737905287537">በፍጥነት ወደኋላ</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_ar.xtb b/chromium/webkit/glue/resources/webkit_strings_ar.xtb
index 3d5c9549b2b..0e5cb7c89c3 100644
--- a/chromium/webkit/glue/resources/webkit_strings_ar.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_ar.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="ar">
<translation id="4763480195061959176">فيديو</translation>
<translation id="5843503607508392247">آخر...</translation>
-<translation id="2426432199384958866">إرجاع الفيلم الذي يتم بثه إلى الوقت الفعلي</translation>
<translation id="248395913932153421">يوم</translation>
<translation id="1729654308190250600">يُرجى إدخال عنوان البريد الإلكتروني وعدم ترك الحق فارغًا.</translation>
<translation id="6015796118275082299">عام</translation>
-<translation id="9186171386827445984">جارٍ تحميل المستند: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> من الصفحات...</translation>
<translation id="1235745349614807883">محو آخر عمليات البحث</translation>
<translation id="7223624360433298498">المدة المنقضية</translation>
<translation id="1171774979989969504">الرجاء إدخال عنوان البريد الإلكتروني.</translation>
<translation id="709897737746224366">الرجاء مطابقة التنسيق المطلوب.</translation>
<translation id="5048533449481078685">محدّد القائمة</translation>
<translation id="4202807286478387388">الدخول</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">يُرجى إدخال جزء متبوع بعلامة &quot;<ph name="ATSIGN"/>&quot;، حيث إن &quot;<ph name="INVALIDADDRESS"/>&quot; غير مكتمل.</translation>
<translation id="2746543609216772311">يجب أن تكون القيمة <ph name="MINIMUM_DATE_OR_TIME"/> أو بعد ذلك.</translation>
<translation id="2572483411312390101">تشغيل</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">وقت الفيلم</translation>
<translation id="8199524924445686405">سنة</translation>
<translation id="795667975304826397">ّلم يتمّ اختيار أيّ ملفّ</translation>
-<translation id="1320012872283894746">محاولة الرجوع للوراء بسرعة</translation>
<translation id="7789962463072032349">إيقاف مؤقت</translation>
<translation id="6853785296079745596">إخفاء التسميات التوضيحية المغلقة</translation>
<translation id="4360991593054037559">يُرجى إدخال قيمة صالحة. علمًا بأن القيم الصالحة تتراوح بين <ph name="VALID_VALUE_LOW"/> و<ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">اضغط</translation>
<translation id="8244226242650769279">مخطّط صورة</translation>
<translation id="310520048233152454">‏الرجاء إدخال عنوان URL.</translation>
-<translation id="9039488204461337220">محاولة الانتقال للأمام بسرعة</translation>
<translation id="4812940957355064477">الرجاء إدخال عدد.</translation>
<translation id="2548326553472216322">لا عمليات بحث حديثة</translation>
<translation id="1938124657309484470">يجب أن تكون القيمة <ph name="MAXIMUM_DATE_OR_TIME"/> أو قبل ذلك.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">يرجى إدخال قيمة صالحة. الحقل غير مكتمل أو أن التاريخ غير صالح.</translation>
<translation id="3040011195152428237">رابط</translation>
<translation id="1014825444426747588">فارغ</translation>
-<translation id="3356679314312413792">محاولة إرجاع الفيلم للوراء بمقدار 30 ثانية</translation>
<translation id="9050748414552849310">عرض التسميات التوضيحية المغلقة</translation>
<translation id="4522570452068850558">التفاصيل</translation>
<translation id="8451268428117625855">الرجاء تحديد ملف.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">الرجاء تحديد هذا المربع إذا أردت المتابعة.</translation>
<translation id="8534579021159131403">دقائق</translation>
<translation id="819205353528511139">تشغيل الفيلم في وضع ملء الشاشة</translation>
-<translation id="8964020114565522021">سحب الملفّ إلى هنا</translation>
<translation id="4103419683916926126">مللي ثانية</translation>
<translation id="838869780401515933">الاختيار</translation>
<translation id="2846343701378493991">1024 (درجة متوسطة)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">هذا المستند محمي بكلمة المرور. الرجاء إدخال كلمة مرور.</translation>
<translation id="5466621249238537318">الرجاء تحديد ملف واحد أو أكثر.</translation>
<translation id="9132465097189459683">آخر...</translation>
+<translation id="10623998915015855">زر التبديل</translation>
<translation id="8750798805984357768">الرجاء اختيار أحد هذه الخيارات.</translation>
<translation id="7740050170769002709">‏محتوى HTML</translation>
<translation id="6692633176391053278">تخطي</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> محددة</translation>
<translation id="8541249477527128034">التحكم في الوسائط</translation>
<translation id="2226276347425096477">الرجاء اختصار هذا النص حتى يصل إلى <ph name="MAX_CHARACTERS"/> من الحروف أو أقل (أنت الآن تستخدم <ph name="CURRENT_LENGTH"/> من الحروف).</translation>
<translation id="6101327004457443354">إعادة صوت المقطع الصوتي</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">ساعات</translation>
<translation id="4664250907885839816">يجب ألا يشتمل الجزء الذي يلي العلامة &quot;<ph name="ATSIGN"/>&quot; على الرمز &quot;<ph name="INVALIDCHARACTER"/>&quot;.</translation>
<translation id="3450233048674729344">يجب أن تكون القيمة أقل من أو تساوي <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">الرجوع للوراء بمقدار 30 ثانية</translation>
<translation id="668171684555832681">ملف تعريف آخر...</translation>
<translation id="6270583010843788609">صورة مصغرة للتسلسل الزمني للفيلم</translation>
<translation id="5641012560118721995">إيقاف التشغيل مؤقتًا</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423">عدد الملفات: <ph name="NUMBER_OF_FILES"/></translation>
<translation id="6643016212128521049">محو</translation>
<translation id="7888071071722539607">يُرجى تضمين العلامة &quot;<ph name="ATSIGN"/>&quot; في عنوان البريد الإلكتروني، حيث يفتقر &quot;<ph name="INVALIDADDRESS"/>&quot; إلى العلامة &quot;<ph name="ATSIGN"/>&quot;.</translation>
-<translation id="4851297395436456855">تقديم سريع</translation>
<translation id="1088086359088493902">ثوانٍ‬‬</translation>
<translation id="3934680773876859118">‏إخفاق تحميل مستند PDF</translation>
<translation id="3632707345189162177">عدد الثواني المتبقية من الفيلم</translation>
<translation id="6359256949422175976">صورة مصغرة لشريط تمرير وقت الفيلم</translation>
<translation id="8597182159515967513">العنوان</translation>
<translation id="6843725295806269523">كتم الصوت</translation>
-<translation id="2615751259741237794">الرجوع إلى الوقت الفعلي</translation>
<translation id="2653659639078652383">إرسال</translation>
<translation id="3732799496749320381">شهر</translation>
-<translation id="4484359737905287537">الإرجاع السريع</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_bg.xtb b/chromium/webkit/glue/resources/webkit_strings_bg.xtb
index c8e734cfb07..1f309af56e5 100644
--- a/chromium/webkit/glue/resources/webkit_strings_bg.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_bg.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="bg">
<translation id="4763480195061959176">видео</translation>
<translation id="5843503607508392247">Други...</translation>
-<translation id="2426432199384958866">връщане на поточно предавания филм към реално време</translation>
<translation id="248395913932153421">Ден</translation>
<translation id="1729654308190250600">Моля, въведете имейл адрес.</translation>
<translation id="6015796118275082299">Година</translation>
-<translation id="9186171386827445984">Документът се зарежда: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> страници...</translation>
<translation id="1235745349614807883">Изчистване на скорошните търсения</translation>
<translation id="7223624360433298498">изминало време</translation>
<translation id="1171774979989969504">Моля, въведете имейл адрес.</translation>
<translation id="709897737746224366">Моля, спазвайте изисквания формат.</translation>
<translation id="5048533449481078685">списъчен показалец</translation>
<translation id="4202807286478387388">преминаване</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Моля, въведете текст преди „<ph name="ATSIGN"/>“. „<ph name="INVALIDADDRESS"/>“ е непълно.</translation>
<translation id="2746543609216772311">Стойността трябва да е <ph name="MINIMUM_DATE_OR_TIME"/> или по-късно.</translation>
<translation id="2572483411312390101">пускане</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">време от филма</translation>
<translation id="8199524924445686405">гггг</translation>
<translation id="795667975304826397">Няма избран файл</translation>
-<translation id="1320012872283894746">бързо придвижване назад</translation>
<translation id="7789962463072032349">поставяне на пауза</translation>
<translation id="6853785296079745596">скриване на надписите</translation>
<translation id="4360991593054037559">Моля, въведете валидна стойност. Двете най-близки такива са <ph name="VALID_VALUE_LOW"/> и <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">натискане</translation>
<translation id="8244226242650769279">карта с изображения</translation>
<translation id="310520048233152454">Моля, въведете URL адрес.</translation>
-<translation id="9039488204461337220">бързо придвижване напред</translation>
<translation id="4812940957355064477">Моля, въведете номер.</translation>
<translation id="2548326553472216322">Няма скорошни търсения</translation>
<translation id="1938124657309484470">Стойността трябва да е <ph name="MAXIMUM_DATE_OR_TIME"/> или по-рано.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Моля, въведете валидна стойност. Данните в полето са непълни или датата е невалидна.</translation>
<translation id="3040011195152428237">връзка</translation>
<translation id="1014825444426747588">празно</translation>
-<translation id="3356679314312413792">придвижване с 30 секунди назад във филма</translation>
<translation id="9050748414552849310">показване на надписите</translation>
<translation id="4522570452068850558">Подробности</translation>
<translation id="8451268428117625855">Моля, изберете файл.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Моля, поставете отметка в това квадратче, ако искате да продължите.</translation>
<translation id="8534579021159131403">Минути</translation>
<translation id="819205353528511139">пускане на филма в режим на цял екран</translation>
-<translation id="8964020114565522021">Плъзнете файла тук</translation>
<translation id="4103419683916926126">Милисекунди</translation>
<translation id="838869780401515933">отмятане</translation>
<translation id="2846343701378493991">1024 (средна степен на сложност)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Този документ е защитен с парола. Моля, въведете я.</translation>
<translation id="5466621249238537318">Моля, изберете един или повече файлове.</translation>
<translation id="9132465097189459683">Други...</translation>
+<translation id="10623998915015855">бутон за превключване</translation>
<translation id="8750798805984357768">Моля, изберете една от тези опции.</translation>
<translation id="7740050170769002709">HTML съдържание</translation>
<translation id="6692633176391053278">stepper</translation>
+<translation id="4975562563186953947">Избрани: <ph name="SELECTED_COUNT"/></translation>
<translation id="8541249477527128034">медийна контрола</translation>
<translation id="2226276347425096477">Моля, съкратете този текст до <ph name="MAX_CHARACTERS"/> знака или по-малко (понастоящем използвате <ph name="CURRENT_LENGTH"/> знака).</translation>
<translation id="6101327004457443354">пускане на аудиозаписа</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Часове</translation>
<translation id="4664250907885839816">Текстът след „<ph name="ATSIGN"/>“ не бива да съдържа символа „<ph name="INVALIDCHARACTER"/>“.</translation>
<translation id="3450233048674729344">Стойността трябва да е по-малка или равна на <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">назад с 30 секунди</translation>
<translation id="668171684555832681">Друг...</translation>
<translation id="6270583010843788609">миниизображение за времевата контрола за филма</translation>
<translation id="5641012560118721995">поставяне на възпроизвеждането на пауза</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> файла</translation>
<translation id="6643016212128521049">Изчистване</translation>
<translation id="7888071071722539607">Моля, включете „<ph name="ATSIGN"/>“ в имейл адреса. В/ъв „<ph name="INVALIDADDRESS"/>“ липсва „<ph name="ATSIGN"/>“.</translation>
-<translation id="4851297395436456855">превъртане напред</translation>
<translation id="1088086359088493902">Секунди</translation>
<translation id="3934680773876859118">PDF документът не успя да се зареди</translation>
<translation id="3632707345189162177">брой оставащи секунди от филма</translation>
<translation id="6359256949422175976">миниизображение за времевия плъзгач за филма</translation>
<translation id="8597182159515967513">заглавие</translation>
<translation id="6843725295806269523">заглушаване</translation>
-<translation id="2615751259741237794">връщане към реално време</translation>
<translation id="2653659639078652383">Изпращане</translation>
<translation id="3732799496749320381">мм</translation>
-<translation id="4484359737905287537">превъртане назад</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_bn.xtb b/chromium/webkit/glue/resources/webkit_strings_bn.xtb
index 0cb46b8663f..51d9ded66ae 100644
--- a/chromium/webkit/glue/resources/webkit_strings_bn.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_bn.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="bn">
<translation id="4763480195061959176">ভিডিও</translation>
<translation id="5843503607508392247">অন্যান্য...</translation>
-<translation id="2426432199384958866">স্ট্রীমিং চলচ্চিত্রটিকে রিয়েল টাইমে ফেরান</translation>
<translation id="248395913932153421">দিন</translation>
<translation id="1729654308190250600">দয়া করে একটি খালি না থাকা ইমেল ঠিকানা লিখুন৷</translation>
<translation id="6015796118275082299">বছর</translation>
-<translation id="9186171386827445984">নথি লোড হচ্ছে: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> পৃষ্ঠা...</translation>
<translation id="1235745349614807883">সাম্প্রতিক অনুসন্ধানগুলি সাফ করুন</translation>
<translation id="7223624360433298498">অতিবাহিত সময়</translation>
<translation id="1171774979989969504">দয়া করে কোন ইমেল ঠিকানা প্রবেশ করান:</translation>
<translation id="709897737746224366">দয়া করে অনুরোধ হওয়া বিন্যাসটি মেলান৷</translation>
<translation id="5048533449481078685">তালিকা নির্দেশক</translation>
<translation id="4202807286478387388">লাফ দিন</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">'<ph name="ATSIGN"/>' অনুসরণ করে একটি অংশ লিখুন৷ '<ph name="INVALIDADDRESS"/>' অসম্পূর্ণ৷</translation>
<translation id="2746543609216772311">মানকে অবশ্যই <ph name="MINIMUM_DATE_OR_TIME"/> বা পরবর্তী হতে হবে৷</translation>
<translation id="2572483411312390101">চালনা করুন</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">চলচ্চিত্রের সময়</translation>
<translation id="8199524924445686405">yyyy</translation>
<translation id="795667975304826397">কোনও ফাইল চয়ন করা হয় নি</translation>
-<translation id="1320012872283894746">দ্রুত পেছনে যাওয়া পছন্দ করুন</translation>
<translation id="7789962463072032349">বিরাম</translation>
<translation id="6853785296079745596">বন্ধ করা পরিচয়লিপিগুলি লুকান</translation>
<translation id="4360991593054037559">দয়া করে একটি বৈধ মান লিখুন৷ দুটি কাছাকাছির বৈধ মান হল <ph name="VALID_VALUE_LOW"/> এবং <ph name="VALID_VALUE_HIGHER"/>৷</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">টিপুন</translation>
<translation id="8244226242650769279">ছবি মানচিত্র</translation>
<translation id="310520048233152454">দয়া করে একটি বৈধ URL প্রবেশ করুন৷</translation>
-<translation id="9039488204461337220">দ্রুত এগিয়ে যাওয়া পচ্ছন্দ করুন</translation>
<translation id="4812940957355064477">দয়া করে একটি সংখ্যা লিখুন৷</translation>
<translation id="2548326553472216322">কোন সাম্প্রতিক অনুসন্ধান নেই</translation>
<translation id="1938124657309484470">মানকে অবশ্যই <ph name="MAXIMUM_DATE_OR_TIME"/> বা আগের হতে হবে৷</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">দয়া করে একটি বৈধ মান লিখুন৷ ক্ষেত্রটি অসম্পূর্ণ অথবা একটি অবৈধ তারিখ আছে৷</translation>
<translation id="3040011195152428237">লিঙ্ক</translation>
<translation id="1014825444426747588">খালি</translation>
-<translation id="3356679314312413792">চলচ্চিত্র ৩০ সেকেন্ড পিছিয়ে নিয়ে যাওয়া পচ্ছন্দ করুন</translation>
<translation id="9050748414552849310">বন্ধ করা পরিচয়লিপিগুলি দেখান</translation>
<translation id="4522570452068850558">বিশদ বিবরণ</translation>
<translation id="8451268428117625855">দয়া করে একটি ফাইল নির্বাচন করুন৷</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">আপনি যদি এগিয়ে যেতে চান তবে দয়া করে এই বাক্সটি পরীক্ষা করুন৷</translation>
<translation id="8534579021159131403">মিনিট</translation>
<translation id="819205353528511139">পূর্ণ স্ক্রীন মোডে চলচ্চিত্র চালান</translation>
-<translation id="8964020114565522021">ফাইল এখানে টেনে আনুন</translation>
<translation id="4103419683916926126">মিলিসেকেন্ড</translation>
<translation id="838869780401515933">চেক করুন</translation>
<translation id="2846343701378493991">1024 (মধ্যম গ্রেড)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">এই দস্তাবেজটি পাসওয়ার্ড সুরক্ষিত৷ দয়া করে একটি পাসওয়ার্ড লিখুন৷</translation>
<translation id="5466621249238537318">দয়া করে এক বা একাধিক ফাইল নির্বাচন করুন৷</translation>
<translation id="9132465097189459683">অন্যান্য...</translation>
+<translation id="10623998915015855">টগল বোতাম</translation>
<translation id="8750798805984357768">দয়া করে বিকল্পগুলির একটি নির্বাচন করুন৷</translation>
<translation id="7740050170769002709">HTML সামগ্রী</translation>
<translation id="6692633176391053278">পদক্ষেপকারী</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/>টি নির্বাচিত</translation>
<translation id="8541249477527128034">মিডিয়া নিয়ন্ত্রণ</translation>
<translation id="2226276347425096477">দয়া করে এই পাঠ্যটি <ph name="MAX_CHARACTERS"/>টি অক্ষর বা তার কমে (আপনি বর্তমানে <ph name="CURRENT_LENGTH"/>টি অক্ষর ব্যবহার করছেন) সংক্ষিপ্ত করুন৷</translation>
<translation id="6101327004457443354">অডিও ট্র্যাক সশব্দ করুন</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">ঘন্টা</translation>
<translation id="4664250907885839816">'<ph name="ATSIGN"/>' অনুসরণ করে এমন একটি অংশে '<ph name="INVALIDCHARACTER"/>' চিহ্ন থাকা উচিত নয়৷</translation>
<translation id="3450233048674729344">মানটি অবশ্যই <ph name="MAXIMUM"/>এর চেয়ে কম বা সমান হবে৷</translation>
-<translation id="3471999216963526757">৩০ সেকেন্ড পেছনে যান</translation>
<translation id="668171684555832681">অন্যান্য...</translation>
<translation id="6270583010843788609">চলচ্চিত্র টাইমলাইন থাম্ব</translation>
<translation id="5641012560118721995">প্লেব্যাক বিরতি</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> টি ফাইল</translation>
<translation id="6643016212128521049">সাফ করুন</translation>
<translation id="7888071071722539607">ইমেল ঠিনাকাটিতে দয়া করে একটি '<ph name="ATSIGN"/>' অন্তর্ভুক্ত করুন৷ '<ph name="INVALIDADDRESS"/>' এ একটি '<ph name="ATSIGN"/>' অনুপস্থিত৷</translation>
-<translation id="4851297395436456855">দ্রুত এগিয়ে যান</translation>
<translation id="1088086359088493902">সেকেন্ড</translation>
<translation id="3934680773876859118">PDF দস্তাবেজ লোড হতে ব্যর্থ</translation>
<translation id="3632707345189162177">চলচ্চিত্রের অবশিষ্ট সেকেন্ড</translation>
<translation id="6359256949422175976">চলচ্চিত্রের সময় স্ক্রাবার থাম্ব</translation>
<translation id="8597182159515967513">শিরোনামা</translation>
<translation id="6843725295806269523">নিঃশব্দ</translation>
-<translation id="2615751259741237794">রিয়েল টাইমে ফেরান</translation>
<translation id="2653659639078652383">জমা</translation>
<translation id="3732799496749320381">মিমি</translation>
-<translation id="4484359737905287537">দ্রুত পিছিয়ে যান</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_ca.xtb b/chromium/webkit/glue/resources/webkit_strings_ca.xtb
index f1e66c0e43c..6de75457c3c 100644
--- a/chromium/webkit/glue/resources/webkit_strings_ca.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_ca.xtb
@@ -3,26 +3,22 @@
<translationbundle lang="ca">
<translation id="4763480195061959176">vídeo</translation>
<translation id="5843503607508392247">Altres...</translation>
-<translation id="2426432199384958866">restableix la reproducció de la pel·lícula a temps real</translation>
<translation id="248395913932153421">Dia</translation>
<translation id="1729654308190250600">Introduïu una adreça electrònica.</translation>
<translation id="6015796118275082299">Any</translation>
-<translation id="9186171386827445984">S'està carregant el document: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> pàgines...</translation>
<translation id="1235745349614807883">Esborra les cerques recents</translation>
<translation id="7223624360433298498">temps transcorregut</translation>
<translation id="1171774979989969504">Introduïu una adreça electrònica.</translation>
<translation id="709897737746224366">Feu servir el format sol·licitat.</translation>
<translation id="5048533449481078685">marcador de llistes</translation>
<translation id="4202807286478387388">salta</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Introduïu un nom d'usuari seguit de &quot;<ph name="ATSIGN"/>&quot;. &quot;<ph name="INVALIDADDRESS"/>&quot; no és una adreça completa.</translation>
<translation id="2746543609216772311">El valor ha de ser <ph name="MINIMUM_DATE_OR_TIME"/> o posterior.</translation>
<translation id="2572483411312390101">reprodueix</translation>
<translation id="8785498733064193001">inicia la reproducció</translation>
<translation id="7057186640035488495">moment de la pel·lícula</translation>
<translation id="8199524924445686405">aaaa</translation>
-<translation id="795667975304826397">Cap fitxer seleccionat.</translation>
-<translation id="1320012872283894746">torna enrere ràpidament</translation>
+<translation id="795667975304826397">No s'ha triat cap fitxer</translation>
<translation id="7789962463072032349">pausa</translation>
<translation id="6853785296079745596">amaga els subtítols ocults</translation>
<translation id="4360991593054037559">Introduïu un valor vàlid. Els valors vàlids més propers són <ph name="VALID_VALUE_LOW"/> i <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">prem</translation>
<translation id="8244226242650769279">mapa d'imatges</translation>
<translation id="310520048233152454">Introduïu un URL.</translation>
-<translation id="9039488204461337220">permet avançar ràpidament</translation>
<translation id="4812940957355064477">Introduïu un número.</translation>
<translation id="2548326553472216322">No hi ha cerques recents</translation>
<translation id="1938124657309484470">El valor ha de ser <ph name="MAXIMUM_DATE_OR_TIME"/> o anterior.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Introduïu un valor vàlid. El camp està incomplet o conté una data no vàlida.</translation>
<translation id="3040011195152428237">enllaç</translation>
<translation id="1014825444426747588">buit</translation>
-<translation id="3356679314312413792">torna 30 segons enrere en la pel·lícula</translation>
<translation id="9050748414552849310">mostra els subtítols ocults</translation>
<translation id="4522570452068850558">Detalls</translation>
<translation id="8451268428117625855">Seleccioneu un fitxer.</translation>
@@ -60,11 +54,10 @@
<translation id="2674318244760992338">peu</translation>
<translation id="8987927404178983737">Mes</translation>
<translation id="8115662671911883373">comença a mostrar subtítols ocults</translation>
-<translation id="7364796246159120393">Selecciona el fitxer</translation>
+<translation id="7364796246159120393">Tria un fitxer</translation>
<translation id="2761667185364618470">Marqueu aquesta casella si voleu continuar.</translation>
<translation id="8534579021159131403">Minuts</translation>
<translation id="819205353528511139">reprodueix la pel·lícula en mode de pantalla completa</translation>
-<translation id="8964020114565522021">Arrossegueu el fitxer aquí.</translation>
<translation id="4103419683916926126">Mil·lisegons</translation>
<translation id="838869780401515933">marca</translation>
<translation id="2846343701378493991">1024 (Mitjà)</translation>
@@ -84,16 +77,18 @@
<translation id="2597378329261239068">Aquest document està protegit mitjançant contrasenya. Introduïu una contrasenya.</translation>
<translation id="5466621249238537318">Seleccioneu un o diversos fitxers.</translation>
<translation id="9132465097189459683">Altres...</translation>
+<translation id="10623998915015855">botó de commutació</translation>
<translation id="8750798805984357768">Seleccioneu una d'aquestes opcions.</translation>
<translation id="7740050170769002709">Contingut HTML</translation>
<translation id="6692633176391053278">desplaçador</translation>
+<translation id="4975562563186953947">Elements seleccionats: <ph name="SELECTED_COUNT"/></translation>
<translation id="8541249477527128034">control de mitjans</translation>
<translation id="2226276347425096477">Escurceu aquest text a un màxim de <ph name="MAX_CHARACTERS"/> caràcters (ara n'esteu utilitzant <ph name="CURRENT_LENGTH"/>).</translation>
<translation id="6101327004457443354">activa el so de la pista d'àudio</translation>
<translation id="1822429046913737220">a. m./p. m.</translation>
<translation id="1639239467298939599">S'està carregant</translation>
<translation id="2908441821576996758">Introduïu una llista d'adreces electròniques separades per comes.</translation>
-<translation id="5939518447894949180">Restablir</translation>
+<translation id="5939518447894949180">Restableix</translation>
<translation id="1921819250265091946">dd</translation>
<translation id="2613802280814924224">Introduïu un valor vàlid. El valor vàlid més proper és <ph name="VALID_VALUE"/>.</translation>
<translation id="835897206747267392">Valor no vàlid.</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Hores</translation>
<translation id="4664250907885839816">Un domini precedit per &quot;<ph name="ATSIGN"/>&quot; no pot contenir el símbol &quot;<ph name="INVALIDCHARACTER"/>&quot;.</translation>
<translation id="3450233048674729344">El valor ha de ser més petit o igual que <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">retrocedeix 30 segons</translation>
<translation id="668171684555832681">Altres...</translation>
<translation id="6270583010843788609">miniatura de cronologia de pel·lícula</translation>
<translation id="5641012560118721995">pausa la reproducció</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> fitxers</translation>
<translation id="6643016212128521049">Esborra</translation>
<translation id="7888071071722539607">Incloeu el símbol &quot;<ph name="ATSIGN"/>&quot; a l'adreça electrònica. Al camp &quot;<ph name="INVALIDADDRESS"/>&quot; falta el símbol &quot;<ph name="ATSIGN"/>&quot;.</translation>
-<translation id="4851297395436456855">avança ràpidament</translation>
<translation id="1088086359088493902">Segons</translation>
<translation id="3934680773876859118">No es pot carregar el document en format PDF</translation>
<translation id="3632707345189162177">nombre de segons restants de la pel·lícula</translation>
<translation id="6359256949422175976">miniatura de la barra de moment de la pel·lícula</translation>
<translation id="8597182159515967513">Encapçalament</translation>
<translation id="6843725295806269523">silencia</translation>
-<translation id="2615751259741237794">restableix a temps real</translation>
<translation id="2653659639078652383">Envia</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">retrocés ràpid</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_cs.xtb b/chromium/webkit/glue/resources/webkit_strings_cs.xtb
index 615a93e064f..276a0639ed7 100644
--- a/chromium/webkit/glue/resources/webkit_strings_cs.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_cs.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="cs">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Jiné…</translation>
-<translation id="2426432199384958866">vrátit se k přehrávání v reálném čase</translation>
<translation id="248395913932153421">Den</translation>
<translation id="1729654308190250600">Vyplňte e-mailovou adresu.</translation>
<translation id="6015796118275082299">Rok</translation>
-<translation id="9186171386827445984">Načítání dokumentu: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> stran...</translation>
<translation id="1235745349614807883">Smazat nedávná vyhledávání</translation>
<translation id="7223624360433298498">přehraný čas</translation>
<translation id="1171774979989969504">Zadejte prosím e-mailovou adresu.</translation>
<translation id="709897737746224366">Zadejte hodnotu, která odpovídá požadovanému formátu.</translation>
<translation id="5048533449481078685">značka seznamu</translation>
<translation id="4202807286478387388">přejít</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Zadejte část před znakem <ph name="ATSIGN"/>. Adresa <ph name="INVALIDADDRESS"/> není úplná.</translation>
<translation id="2746543609216772311">Datum musí být <ph name="MINIMUM_DATE_OR_TIME"/> nebo později.</translation>
<translation id="2572483411312390101">přehrát</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">čas filmu</translation>
<translation id="8199524924445686405">rrrr</translation>
<translation id="795667975304826397">Soubor nevybrán</translation>
-<translation id="1320012872283894746">rychlé přetáčení zpět</translation>
<translation id="7789962463072032349">pozastavit</translation>
<translation id="6853785296079745596">skrýt titulky</translation>
<translation id="4360991593054037559">Zadejte platnou hodnotu. Dvě nejbližší hodnoty jsou <ph name="VALID_VALUE_LOW"/> a <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">zmáčknout</translation>
<translation id="8244226242650769279">obrázková mapa</translation>
<translation id="310520048233152454">Zadejte prosím adresu URL.</translation>
-<translation id="9039488204461337220">rychlé přetáčení vpřed</translation>
<translation id="4812940957355064477">Zadejte prosím číslo.</translation>
<translation id="2548326553472216322">Žádná nedávná vyhledávání</translation>
<translation id="1938124657309484470">Datum musí být <ph name="MAXIMUM_DATE_OR_TIME"/> nebo dříve.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Zadejte prosím platnou hodnotu. Pole obsahuje neúplnou hodnotu nebo neplatné datum.</translation>
<translation id="3040011195152428237">odkaz</translation>
<translation id="1014825444426747588">prázdné</translation>
-<translation id="3356679314312413792">přetočit film zpět o 30 sekund</translation>
<translation id="9050748414552849310">zobrazit titulky</translation>
<translation id="4522570452068850558">Podrobnosti</translation>
<translation id="8451268428117625855">Vyberte prosím soubor.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Chcete-li pokračovat, zaškrtněte toto políčko.</translation>
<translation id="8534579021159131403">Minuty</translation>
<translation id="819205353528511139">přehrát film v režimu celé obrazovky</translation>
-<translation id="8964020114565522021">Přetáhnout soubor sem</translation>
<translation id="4103419683916926126">Milisekundy</translation>
<translation id="838869780401515933">zaškrtnout</translation>
<translation id="2846343701378493991">1024 (Střední kvalita)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Tento dokument je chráněn heslem. Zadejte prosím heslo.</translation>
<translation id="5466621249238537318">Vyberte prosím jeden nebo více souborů.</translation>
<translation id="9132465097189459683">Jiné…</translation>
+<translation id="10623998915015855">přepínací tlačítko</translation>
<translation id="8750798805984357768">Vyberte jednu z těchto možností.</translation>
<translation id="7740050170769002709">Obsah ve formátu HTML</translation>
<translation id="6692633176391053278">stepper</translation>
+<translation id="4975562563186953947">Vybráno: <ph name="SELECTED_COUNT"/></translation>
<translation id="8541249477527128034">ovládání médií</translation>
<translation id="2226276347425096477">Zkraťte prosím tento text na <ph name="MAX_CHARACTERS"/> znaků nebo méně. (Aktuálně má <ph name="CURRENT_LENGTH"/> znaků.)</translation>
<translation id="6101327004457443354">zapnout zvukovou stopu</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Hodiny</translation>
<translation id="4664250907885839816">Část za znakem <ph name="ATSIGN"/> nesmí obsahovat znak <ph name="INVALIDCHARACTER"/>.</translation>
<translation id="3450233048674729344">Hodnota musí být menší nebo rovna <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">zpět o 30 sekund</translation>
<translation id="668171684555832681">Další...</translation>
<translation id="6270583010843788609">náhled na časové ose filmu</translation>
<translation id="5641012560118721995">pozastavit přehrávání</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423">Počet souborů: <ph name="NUMBER_OF_FILES"/></translation>
<translation id="6643016212128521049">Vymazat</translation>
<translation id="7888071071722539607">Do e-mailové adresy zahrňte znak <ph name="ATSIGN"/>. V adrese <ph name="INVALIDADDRESS"/> chybí znak <ph name="ATSIGN"/>.</translation>
-<translation id="4851297395436456855">přetočit vpřed</translation>
<translation id="1088086359088493902">Sekundy</translation>
<translation id="3934680773876859118">Načítání dokumentu PDF se nezdařilo.</translation>
<translation id="3632707345189162177">zbývající čas filmu v sekundách</translation>
<translation id="6359256949422175976">náhled na posuvníku filmu</translation>
<translation id="8597182159515967513">záhlaví</translation>
<translation id="6843725295806269523">ztlumit</translation>
-<translation id="2615751259741237794">zpět do reálného času</translation>
<translation id="2653659639078652383">Odeslat</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">přetočit zpět</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_da.xtb b/chromium/webkit/glue/resources/webkit_strings_da.xtb
index f461c7389aa..6a297603f7f 100644
--- a/chromium/webkit/glue/resources/webkit_strings_da.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_da.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="da">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Andet...</translation>
-<translation id="2426432199384958866">sæt filmstreaming tilbage til realtid</translation>
<translation id="248395913932153421">Dag</translation>
<translation id="1729654308190250600">Angiv en e-mailadresse, der ikke er tom.</translation>
<translation id="6015796118275082299">År</translation>
-<translation id="9186171386827445984">Indlæser dokument: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> sider...</translation>
<translation id="1235745349614807883">Slet nylige søgninger</translation>
<translation id="7223624360433298498">forløbet tid</translation>
<translation id="1171774979989969504">Angiv en e-mailadresse.</translation>
<translation id="709897737746224366">Find et match til det anmodede format.</translation>
<translation id="5048533449481078685">listemarkering</translation>
<translation id="4202807286478387388">hop</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Angiv den del, der kommer før &quot;<ph name="ATSIGN"/>&quot;. &quot;<ph name="INVALIDADDRESS"/>&quot; er ufuldstændig.</translation>
<translation id="2746543609216772311">Værdien må ikke være tidligere end <ph name="MINIMUM_DATE_OR_TIME"/>.</translation>
<translation id="2572483411312390101">afspil</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">filmtid</translation>
<translation id="8199524924445686405">åååå</translation>
<translation id="795667975304826397">Der er ikke valgt nogen fil</translation>
-<translation id="1320012872283894746">spol hurtigt tilbage</translation>
<translation id="7789962463072032349">pause</translation>
<translation id="6853785296079745596">skjul undertekster</translation>
<translation id="4360991593054037559">Angiv en gyldig værdi. De to nærmeste gyldige værdier er <ph name="VALID_VALUE_LOW"/> og <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">tryk</translation>
<translation id="8244226242650769279">billedekort</translation>
<translation id="310520048233152454">Angiv en webadresse.</translation>
-<translation id="9039488204461337220">spol hurtigt frem</translation>
<translation id="4812940957355064477">Angiv et nummer.</translation>
<translation id="2548326553472216322">Ingen nylige søgninger</translation>
<translation id="1938124657309484470">Værdien må ikke være senere end <ph name="MAXIMUM_DATE_OR_TIME"/>.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Angiv en gyldig værdi. Feltet er ufuldstændigt eller har en ugyldig dato.</translation>
<translation id="3040011195152428237">link</translation>
<translation id="1014825444426747588">tom</translation>
-<translation id="3356679314312413792">spol 30 sekunder tilbage i filmen</translation>
<translation id="9050748414552849310">vis undertekster</translation>
<translation id="4522570452068850558">Detaljer</translation>
<translation id="8451268428117625855">Vælg en fil.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Markér dette felt, hvis du vil fortsætte.</translation>
<translation id="8534579021159131403">Minutter</translation>
<translation id="819205353528511139">afspil film i fuld skærm</translation>
-<translation id="8964020114565522021">Træk filer hertil</translation>
<translation id="4103419683916926126">Millisekunder</translation>
<translation id="838869780401515933">markér</translation>
<translation id="2846343701378493991">1024 (Mellemklasse)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Dette dokument er adgangskodebeskyttet. Indtast en adgangskode.</translation>
<translation id="5466621249238537318">Vælg en eller flere filer.</translation>
<translation id="9132465097189459683">Andet...</translation>
+<translation id="10623998915015855">til/fra-knap</translation>
<translation id="8750798805984357768">Vælg en af disse muligheder.</translation>
<translation id="7740050170769002709">HTML-indhold</translation>
<translation id="6692633176391053278">stepper</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> er valgt</translation>
<translation id="8541249477527128034">mediekontrol</translation>
<translation id="2226276347425096477">Forkort denne tekst til <ph name="MAX_CHARACTERS"/> tegn eller færre (du bruger i øjeblikket <ph name="CURRENT_LENGTH"/> tegn).</translation>
<translation id="6101327004457443354">slå lydspor til</translation>
@@ -101,8 +96,7 @@
<translation id="7673697353781729403">Timer</translation>
<translation id="4664250907885839816">Den del, der kommer efter &quot;<ph name="ATSIGN"/>&quot;, må ikke indeholde symbolet &quot;<ph name="INVALIDCHARACTER"/>&quot;.</translation>
<translation id="3450233048674729344">Værdien skal være mindre end eller lig med <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">gå 30 sekunder tilbage</translation>
-<translation id="668171684555832681">Andre ...</translation>
+<translation id="668171684555832681">Andre...</translation>
<translation id="6270583010843788609">miniature for tidslinje</translation>
<translation id="5641012560118721995">pause</translation>
<translation id="1591562245178063882">Denne måned</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> filer</translation>
<translation id="6643016212128521049">Ryd</translation>
<translation id="7888071071722539607">E-mailadressen skal indeholde et &quot;<ph name="ATSIGN"/>&quot;. &quot;<ph name="INVALIDADDRESS"/>&quot; mangler et &quot;<ph name="ATSIGN"/>&quot;.</translation>
-<translation id="4851297395436456855">spol frem</translation>
<translation id="1088086359088493902">Sekunder</translation>
<translation id="3934680773876859118">PDF-dokumentet kunne ikke indlæses</translation>
<translation id="3632707345189162177">antal sekunder tilbage af filmen</translation>
<translation id="6359256949422175976">miniature for filmtidsskyder</translation>
<translation id="8597182159515967513">overskrift</translation>
<translation id="6843725295806269523">slå lyden fra</translation>
-<translation id="2615751259741237794">tilbage til realtid</translation>
<translation id="2653659639078652383">Indsend</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">spol tilbage</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_de.xtb b/chromium/webkit/glue/resources/webkit_strings_de.xtb
index bd7b34e279a..a6c1c904fef 100644
--- a/chromium/webkit/glue/resources/webkit_strings_de.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_de.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="de">
<translation id="4763480195061959176">Video</translation>
<translation id="5843503607508392247">Andere...</translation>
-<translation id="2426432199384958866">Vom Streaming zu Echtzeit zurückkehren</translation>
<translation id="248395913932153421">Tag</translation>
<translation id="1729654308190250600">Geben Sie eine E-Mail-Adresse ein.</translation>
<translation id="6015796118275082299">Jahr</translation>
-<translation id="9186171386827445984">Dokument wird geladen <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> Seiten...</translation>
<translation id="1235745349614807883">Vor Kurzem durchgeführte Suchanfragen löschen</translation>
<translation id="7223624360433298498">Vergangene Zeit</translation>
<translation id="1171774979989969504">Geben Sie eine E-Mail-Adresse ein.</translation>
<translation id="709897737746224366">Ihre Eingabe muss mit dem geforderten Format übereinstimmen.</translation>
<translation id="5048533449481078685">Listenmarkierung</translation>
<translation id="4202807286478387388">springen</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Geben Sie etwas vor dem <ph name="ATSIGN"/>-Zeichen ein. Die Angabe &quot;<ph name="INVALIDADDRESS"/>&quot; ist unvollständig.</translation>
<translation id="2746543609216772311">Verwenden Sie <ph name="MINIMUM_DATE_OR_TIME"/> oder einen späteren Wert.</translation>
<translation id="2572483411312390101">Wiedergeben</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">Filmdauer</translation>
<translation id="8199524924445686405">jjjj</translation>
<translation id="795667975304826397">Keine ausgewählt</translation>
-<translation id="1320012872283894746">Schneller Rücklauf</translation>
<translation id="7789962463072032349">Pausieren</translation>
<translation id="6853785296079745596">Untertitel ausblenden</translation>
<translation id="4360991593054037559">Geben Sie einen gültigen Wert ein. Die zwei nächstliegenden gültigen Werte sind <ph name="VALID_VALUE_LOW"/> und <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">klicken</translation>
<translation id="8244226242650769279">Imagemap</translation>
<translation id="310520048233152454">Geben Sie eine URL ein.</translation>
-<translation id="9039488204461337220">Schneller Vorlauf</translation>
<translation id="4812940957355064477">Geben Sie eine Nummer ein.</translation>
<translation id="2548326553472216322">Keine vor Kurzem durchgeführte Suchanfragen</translation>
<translation id="1938124657309484470">Verwenden Sie <ph name="MAXIMUM_DATE_OR_TIME"/> oder einen früheren Wert.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Geben Sie einen gültigen Wert ein. Das Feld ist nicht vollständig oder enthält ein ungültiges Datum.</translation>
<translation id="3040011195152428237">Link</translation>
<translation id="1014825444426747588">leer</translation>
-<translation id="3356679314312413792">Film 30 Sekunden zurückspulen</translation>
<translation id="9050748414552849310">Untertitel anzeigen</translation>
<translation id="4522570452068850558">Details</translation>
<translation id="8451268428117625855">Wählen Sie eine Datei aus.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Aktivieren Sie dieses Kontrollkästchen, wenn Sie fortfahren möchten.</translation>
<translation id="8534579021159131403">Minuten</translation>
<translation id="819205353528511139">Film im Vollbildmodus ansehen</translation>
-<translation id="8964020114565522021">Datei hier ablegen</translation>
<translation id="4103419683916926126">Millisekunden</translation>
<translation id="838869780401515933">auswählen</translation>
<translation id="2846343701378493991">1024 (mittlere Stufe)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Dieses Dokument ist passwortgeschützt. Geben Sie ein Passwort ein.</translation>
<translation id="5466621249238537318">Wählen Sie eine oder mehrere Dateien aus.</translation>
<translation id="9132465097189459683">Andere...</translation>
+<translation id="10623998915015855">Schaltfläche zum Umschalten</translation>
<translation id="8750798805984357768">Wählen Sie eine dieser Optionen aus.</translation>
<translation id="7740050170769002709">HTML-Inhalte</translation>
<translation id="6692633176391053278">Stepper</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> ausgewählt</translation>
<translation id="8541249477527128034">Mediensteuerung</translation>
<translation id="2226276347425096477">Kürzen Sie diesen Text auf max. <ph name="MAX_CHARACTERS"/> Zeichen. Zurzeit verwenden Sie <ph name="CURRENT_LENGTH"/> Zeichen.</translation>
<translation id="6101327004457443354">Ton anschalten</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Stunden</translation>
<translation id="4664250907885839816">Nach dem <ph name="ATSIGN"/>-Zeichen darf das Zeichen &quot;<ph name="INVALIDCHARACTER"/>&quot; nicht verwendet werden.</translation>
<translation id="3450233048674729344">Wert muss kleiner als oder gleich <ph name="MAXIMUM"/> sein.</translation>
-<translation id="3471999216963526757">30 Sekunden zurück</translation>
<translation id="668171684555832681">Andere...</translation>
<translation id="6270583010843788609">Zeitachsen-Ziehpunkt</translation>
<translation id="5641012560118721995">Wiedergabe anhalten</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> Dateien</translation>
<translation id="6643016212128521049">Löschen</translation>
<translation id="7888071071722539607">Die E-Mail-Adresse muss ein <ph name="ATSIGN"/>-Zeichen enthalten. In der Angabe &quot;<ph name="INVALIDADDRESS"/>&quot; fehlt ein <ph name="ATSIGN"/>-Zeichen.</translation>
-<translation id="4851297395436456855">Vorspulen</translation>
<translation id="1088086359088493902">Sekunden</translation>
<translation id="3934680773876859118">Fehler beim Laden des PDF-Dokuments</translation>
<translation id="3632707345189162177">Verbleibende Dauer in Sekunden</translation>
<translation id="6359256949422175976">Ziehpunkt für Video-Zeitachse</translation>
<translation id="8597182159515967513">Kopfzeile</translation>
<translation id="6843725295806269523">Stumm</translation>
-<translation id="2615751259741237794">Zu Echtzeit zurückkehren</translation>
<translation id="2653659639078652383">Senden</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">Zurückspulen</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_el.xtb b/chromium/webkit/glue/resources/webkit_strings_el.xtb
index a9111fafd5d..294e1cf682e 100644
--- a/chromium/webkit/glue/resources/webkit_strings_el.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_el.xtb
@@ -3,26 +3,22 @@
<translationbundle lang="el">
<translation id="4763480195061959176">βίντεο</translation>
<translation id="5843503607508392247">Άλλες…</translation>
-<translation id="2426432199384958866">επιστροφή ροής ταινίας σε πραγματικό χρόνο</translation>
<translation id="248395913932153421">Ημέρα</translation>
<translation id="1729654308190250600">Καταχωρίστε μια διεύθυνση ηλεκτρονικού ταχυδρομείου.</translation>
<translation id="6015796118275082299">Έτος</translation>
-<translation id="9186171386827445984">Φόρτωση εγγράφου: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> σελίδες...</translation>
-<translation id="1235745349614807883">Εκκαθάριση πρόσφατων αναζητήσεων</translation>
+<translation id="1235745349614807883">Διαγραφή πρόσφατων αναζητήσεων</translation>
<translation id="7223624360433298498">χρόνος που παρήλθε</translation>
<translation id="1171774979989969504">Εισαγάγετε μια διεύθυνση ηλεκτρονικού ταχυδρομείου.</translation>
<translation id="709897737746224366">Αντιστοιχίστε τη ζητούμενη μορφή.</translation>
<translation id="5048533449481078685">δείκτης λίστας</translation>
<translation id="4202807286478387388">μεταπήδηση</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Καταχωρίστε το τμήμα της διεύθυνσης πριν το σύμβολο &quot;<ph name="ATSIGN"/>&quot;. Η διεύθυνση &quot;<ph name="INVALIDADDRESS"/>&quot; δεν είναι πλήρης.</translation>
<translation id="2746543609216772311">Η τιμή πρέπει να είναι <ph name="MINIMUM_DATE_OR_TIME"/> ή μεταγενέστερη.</translation>
<translation id="2572483411312390101">αναπαραγωγή</translation>
<translation id="8785498733064193001">έναρξη αναπαραγωγής</translation>
<translation id="7057186640035488495">χρόνος ταινίας</translation>
<translation id="8199524924445686405">εεεε</translation>
-<translation id="795667975304826397">Δεν έχει επιλεγεί κανένα αρχείο</translation>
-<translation id="1320012872283894746">γρήγορη αναζήτηση προς τα πίσω</translation>
+<translation id="795667975304826397">Δεν επιλέχθηκε κανένα αρχείο.</translation>
<translation id="7789962463072032349">παύση</translation>
<translation id="6853785296079745596">απόκρυψη υπότιτλων</translation>
<translation id="4360991593054037559">Καταχωρίστε μια έγκυρη τιμή. Οι δύο πιο κοντινές έγκυρες τιμές είναι <ph name="VALID_VALUE_LOW"/> και <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">πατήστε</translation>
<translation id="8244226242650769279">χάρτης εικόνας</translation>
<translation id="310520048233152454">Εισαγάγετε μια διεύθυνση URL.</translation>
-<translation id="9039488204461337220">γρήγορη αναζήτηση προς τα εμπρός</translation>
<translation id="4812940957355064477">Εισαγάγετε έναν αριθμό.</translation>
<translation id="2548326553472216322">Δεν υπάρχουν πρόσφατες αναζητήσεις</translation>
<translation id="1938124657309484470">Η τιμή πρέπει να είναι <ph name="MAXIMUM_DATE_OR_TIME"/> ή προγενέστερη.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Καταχωρίστε μια έγκυρη τιμή. Το πεδίο είναι ελλιπές ή περιέχει μη έγκυρη ημερομηνία.</translation>
<translation id="3040011195152428237">σύνδεσμος</translation>
<translation id="1014825444426747588">κενό</translation>
-<translation id="3356679314312413792">αναζήτηση προς τα πίσω στην ταινία για 30 δευτερόλεπτα</translation>
<translation id="9050748414552849310">εμφάνιση υπότιτλων</translation>
<translation id="4522570452068850558">Λεπτομέρειες</translation>
<translation id="8451268428117625855">Επιλέξτε ένα αρχείο.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Αν θέλετε να συνεχίσετε, επιλέξτε αυτό το πλαίσιο.</translation>
<translation id="8534579021159131403">Λεπτά</translation>
<translation id="819205353528511139">αναπαραγωγή ταινίας σε λειτουργία πλήρους οθόνης</translation>
-<translation id="8964020114565522021">Σύρετε το αρχείο εδώ</translation>
<translation id="4103419683916926126">Χιλιοστά του δευτερολέπτου</translation>
<translation id="838869780401515933">ενεργοποίηση</translation>
<translation id="2846343701378493991">1024 (Μέτριος βαθμός)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Αυτό το έγγραφο προστατεύεται με κωδικό πρόσβασης. Πληκτρολογήστε έναν κωδικό πρόσβασης.</translation>
<translation id="5466621249238537318">Επιλέξτε ένα ή περισσότερα αρχεία.</translation>
<translation id="9132465097189459683">Άλλες…</translation>
+<translation id="10623998915015855">κουμπί εναλλαγής</translation>
<translation id="8750798805984357768">Ορίστε μία από αυτές τις επιλογές.</translation>
<translation id="7740050170769002709">Περιεχόμενο HTML</translation>
<translation id="6692633176391053278">stepper</translation>
+<translation id="4975562563186953947">Επιλέχτηκαν <ph name="SELECTED_COUNT"/></translation>
<translation id="8541249477527128034">έλεγχος μέσων</translation>
<translation id="2226276347425096477">Κάντε πιο σύντομο αυτό το κείμενο ώστε να έχει το πολύ <ph name="MAX_CHARACTERS"/> χαρακτήρες (αυτήν τη στιγμή χρησιμοποιείτε <ph name="CURRENT_LENGTH"/> χαρακτήρες).</translation>
<translation id="6101327004457443354">κατάργηση σίγασης ήχου</translation>
@@ -101,24 +96,20 @@
<translation id="7673697353781729403">Ώρες</translation>
<translation id="4664250907885839816">Το τμήμα της διεύθυνσης μετά το σύμβολο &quot;<ph name="ATSIGN"/>&quot; δεν πρέπει να περιέχει το σύμβολο &quot;<ph name="INVALIDCHARACTER"/>&quot;.</translation>
<translation id="3450233048674729344">Η τιμή πρέπει να είναι μικρότερη ή ίση του <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">πίσω για 30 δευτερόλεπτα</translation>
<translation id="668171684555832681">Άλλο...</translation>
<translation id="6270583010843788609">δείκτης κύλισης χρονικού πλαισίου ταινίας</translation>
<translation id="5641012560118721995">παύση αναπαραγωγής</translation>
<translation id="1591562245178063882">Αυτόν το μήνα</translation>
<translation id="6119846243427417423">ενεργοποίηση</translation>
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> αρχεία</translation>
-<translation id="6643016212128521049">Εκκαθάριση</translation>
+<translation id="6643016212128521049">Διαγραφή</translation>
<translation id="7888071071722539607">Συμπεριλάβετε το σύμβολο &quot;<ph name="ATSIGN"/>&quot; στη διεύθυνση ηλεκτρονικού ταχυδρομείου. Από τη διεύθυνση &quot;<ph name="INVALIDADDRESS"/>&quot; λείπει το σύμβολο &quot;<ph name="ATSIGN"/>&quot;.</translation>
-<translation id="4851297395436456855">γρήγορη προώθηση</translation>
<translation id="1088086359088493902">Δευτερόλεπτα</translation>
<translation id="3934680773876859118">Δεν ήταν δυνατή η φόρτωση του εγγράφου PDF</translation>
<translation id="3632707345189162177">αριθμός δευτερολέπτων της ταινίας που απομένουν</translation>
<translation id="6359256949422175976">δείκτης κύλισης χρόνου ταινίας</translation>
<translation id="8597182159515967513">επικεφαλίδα</translation>
<translation id="6843725295806269523">σίγαση</translation>
-<translation id="2615751259741237794">επιστροφή σε πραγματικό χρόνο</translation>
<translation id="2653659639078652383">Υποβολή</translation>
<translation id="3732799496749320381">μμ</translation>
-<translation id="4484359737905287537">γρήγορη επαναφορά</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_en-GB.xtb b/chromium/webkit/glue/resources/webkit_strings_en-GB.xtb
index 6acd634e88f..ede2337381f 100644
--- a/chromium/webkit/glue/resources/webkit_strings_en-GB.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_en-GB.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="en-GB">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Other...</translation>
-<translation id="2426432199384958866">return streaming film to real time</translation>
<translation id="248395913932153421">Day</translation>
<translation id="1729654308190250600">Please enter a non-empty email address.</translation>
<translation id="6015796118275082299">Year</translation>
-<translation id="9186171386827445984">Loading document: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> pages...</translation>
<translation id="1235745349614807883">Clear Recent Searches</translation>
<translation id="7223624360433298498">elapsed time</translation>
<translation id="1171774979989969504">Please enter an email address.</translation>
<translation id="709897737746224366">Please match the format requested.</translation>
<translation id="5048533449481078685">list marker</translation>
<translation id="4202807286478387388">jump</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Please enter a part followed by '<ph name="ATSIGN"/>'. '<ph name="INVALIDADDRESS"/>' is incomplete.</translation>
<translation id="2746543609216772311">Value must be <ph name="MINIMUM_DATE_OR_TIME"/> or later.</translation>
<translation id="2572483411312390101">play</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">film time</translation>
<translation id="8199524924445686405">yyyy</translation>
<translation id="795667975304826397">No file chosen</translation>
-<translation id="1320012872283894746">seek quickly back</translation>
<translation id="7789962463072032349">pause</translation>
<translation id="6853785296079745596">hide closed captions</translation>
<translation id="4360991593054037559">Please enter a valid value. The two nearest valid values are <ph name="VALID_VALUE_LOW"/> and <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">press</translation>
<translation id="8244226242650769279">image map</translation>
<translation id="310520048233152454">Please enter a URL.</translation>
-<translation id="9039488204461337220">seek quickly forward</translation>
<translation id="4812940957355064477">Please enter a number.</translation>
<translation id="2548326553472216322">No recent searches</translation>
<translation id="1938124657309484470">Value must be <ph name="MAXIMUM_DATE_OR_TIME"/> or earlier.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Please enter a valid value. The field is incomplete or has an invalid date.</translation>
<translation id="3040011195152428237">link</translation>
<translation id="1014825444426747588">blank</translation>
-<translation id="3356679314312413792">seek film back 30 seconds</translation>
<translation id="9050748414552849310">show closed captions</translation>
<translation id="4522570452068850558">Details</translation>
<translation id="8451268428117625855">Please select a file.</translation>
@@ -60,11 +54,10 @@
<translation id="2674318244760992338">footer</translation>
<translation id="8987927404178983737">Month</translation>
<translation id="8115662671911883373">start displaying closed captions</translation>
-<translation id="7364796246159120393">Choose File</translation>
+<translation id="7364796246159120393">Choose file</translation>
<translation id="2761667185364618470">Please tick this box if you want to proceed.</translation>
<translation id="8534579021159131403">Minutes</translation>
<translation id="819205353528511139">play film in full screen mode</translation>
-<translation id="8964020114565522021">Drag file here</translation>
<translation id="4103419683916926126">Milliseconds</translation>
<translation id="838869780401515933">tick</translation>
<translation id="2846343701378493991">1024 (Medium Grade)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">This document is password-protected. Please enter a password.</translation>
<translation id="5466621249238537318">Please select one or more files.</translation>
<translation id="9132465097189459683">Other...</translation>
+<translation id="10623998915015855">toggle button</translation>
<translation id="8750798805984357768">Please select one of these options.</translation>
<translation id="7740050170769002709">HTML content</translation>
<translation id="6692633176391053278">stepper</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> selected</translation>
<translation id="8541249477527128034">media control</translation>
<translation id="2226276347425096477">Please shorten this text to <ph name="MAX_CHARACTERS"/> characters or less (you are currently using <ph name="CURRENT_LENGTH"/> characters).</translation>
<translation id="6101327004457443354">un-mute audio track</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Hours</translation>
<translation id="4664250907885839816">A part following '<ph name="ATSIGN"/>' should not contain the symbol '<ph name="INVALIDCHARACTER"/>'.</translation>
<translation id="3450233048674729344">Value must be less than or equal to <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">back 30 seconds</translation>
<translation id="668171684555832681">Other...</translation>
<translation id="6270583010843788609">film timeline thumb</translation>
<translation id="5641012560118721995">pause playback</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> files</translation>
<translation id="6643016212128521049">Clear</translation>
<translation id="7888071071722539607">Please include an '<ph name="ATSIGN"/>' in the email address. '<ph name="INVALIDADDRESS"/>' is missing an '<ph name="ATSIGN"/>'.</translation>
-<translation id="4851297395436456855">fast forward</translation>
<translation id="1088086359088493902">Seconds</translation>
<translation id="3934680773876859118">Failed to load PDF document</translation>
<translation id="3632707345189162177">number of seconds of film remaining</translation>
<translation id="6359256949422175976">film time scrubber thumb</translation>
<translation id="8597182159515967513">heading</translation>
<translation id="6843725295806269523">mute</translation>
-<translation id="2615751259741237794">return to real time</translation>
<translation id="2653659639078652383">Submit</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">fast reverse</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_es-419.xtb b/chromium/webkit/glue/resources/webkit_strings_es-419.xtb
index 7008094a196..00880020247 100644
--- a/chromium/webkit/glue/resources/webkit_strings_es-419.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_es-419.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="es-419">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Otra...</translation>
-<translation id="2426432199384958866">volver a la transmisión de películas en tiempo real</translation>
<translation id="248395913932153421">Día</translation>
<translation id="1729654308190250600">Ingresa una dirección de correo electrónico que no esté vacía.</translation>
<translation id="6015796118275082299">Año</translation>
-<translation id="9186171386827445984">Cargando documento: páginas <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/>...</translation>
<translation id="1235745349614807883">Eliminar búsquedas recientes</translation>
<translation id="7223624360433298498">tiempo transcurrido</translation>
<translation id="1171774979989969504">Ingresa una dirección de correo electrónico.</translation>
<translation id="709897737746224366">Haz coincidir el formato solicitado.</translation>
<translation id="5048533449481078685">marcador de listas</translation>
<translation id="4202807286478387388">saltar</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Ingresa texto antes del signo &quot;<ph name="ATSIGN"/>&quot;. La dirección &quot;<ph name="INVALIDADDRESS"/>&quot; está incompleta.</translation>
<translation id="2746543609216772311">El valor debe ser igual o posterior a <ph name="MINIMUM_DATE_OR_TIME"/>.</translation>
<translation id="2572483411312390101">reproducir</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">horario de película</translation>
<translation id="8199524924445686405">aaaa</translation>
<translation id="795667975304826397">No se eligió archivo</translation>
-<translation id="1320012872283894746">buscar rápidamente hacia atrás</translation>
<translation id="7789962463072032349">pausa</translation>
<translation id="6853785296079745596">ocultar los subtítulos</translation>
<translation id="4360991593054037559">Ingresa un valor válido. Los dos valores válidos más aproximados son <ph name="VALID_VALUE_LOW"/> y <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">hacer clic</translation>
<translation id="8244226242650769279">mapa de imágenes</translation>
<translation id="310520048233152454">Ingresa una URL.</translation>
-<translation id="9039488204461337220">avanzar rápidamente</translation>
<translation id="4812940957355064477">Debes ingresar un número.</translation>
<translation id="2548326553472216322">No hay búsquedas recientes</translation>
<translation id="1938124657309484470">El valor debe ser igual o anterior a <ph name="MAXIMUM_DATE_OR_TIME"/>.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Debes ingresar un valor válido. El campo está incompleto o contiene una fecha no válida.</translation>
<translation id="3040011195152428237">enlace</translation>
<translation id="1014825444426747588">espacio en blanco</translation>
-<translation id="3356679314312413792">rebobinar la película 30 segundos</translation>
<translation id="9050748414552849310">mostrar subtítulos</translation>
<translation id="4522570452068850558">Detalles</translation>
<translation id="8451268428117625855">Selecciona un archivo.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Controla esta casilla si deseas continuar.</translation>
<translation id="8534579021159131403">Minutos</translation>
<translation id="819205353528511139">reproducir la película en modo de pantalla completa</translation>
-<translation id="8964020114565522021">Arrastre el archivo hasta aquí</translation>
<translation id="4103419683916926126">Milisegundos</translation>
<translation id="838869780401515933">marcar</translation>
<translation id="2846343701378493991">1024 (Mediano)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Este documento está protegido por contraseña. Ingresa una contraseña.</translation>
<translation id="5466621249238537318">Selecciona uno o más archivos.</translation>
<translation id="9132465097189459683">Otra...</translation>
+<translation id="10623998915015855">botón de activación</translation>
<translation id="8750798805984357768">Selecciona una de estas opciones.</translation>
<translation id="7740050170769002709">Contenido HTML</translation>
<translation id="6692633176391053278">secuenciador</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> elementos seleccionados</translation>
<translation id="8541249477527128034">control de medios</translation>
<translation id="2226276347425096477">Acorta este texto a <ph name="MAX_CHARACTERS"/> caracteres o menos (actualmente estás usando <ph name="CURRENT_LENGTH"/> caracteres).</translation>
<translation id="6101327004457443354">desactivar silencio de la pista de audio</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Horas</translation>
<translation id="4664250907885839816">El texto después del signo &quot;<ph name="ATSIGN"/>&quot; no debe incluir el símbolo &quot;<ph name="INVALIDCHARACTER"/>&quot;.</translation>
<translation id="3450233048674729344">El valor debe ser menor de o igual a <ph name="MAXIMUM"/></translation>
-<translation id="3471999216963526757">rebobinar 30 segundos</translation>
<translation id="668171684555832681">Otro...</translation>
<translation id="6270583010843788609">miniatura de línea de tiempo de la película</translation>
<translation id="5641012560118721995">pausar reproducción</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> archivos</translation>
<translation id="6643016212128521049">Borrar</translation>
<translation id="7888071071722539607">Incluye un signo &quot;<ph name="ATSIGN"/>&quot; en la dirección de correo electrónico. La dirección &quot;<ph name="INVALIDADDRESS"/>&quot; no incluye el signo &quot;<ph name="ATSIGN"/>&quot;.</translation>
-<translation id="4851297395436456855">avance rápido</translation>
<translation id="1088086359088493902">Segundos</translation>
<translation id="3934680773876859118">No se pudo cargar el documento PDF</translation>
<translation id="3632707345189162177">cantidad de segundos restantes de la película</translation>
<translation id="6359256949422175976">miniatura del control deslizante de duración de la película</translation>
<translation id="8597182159515967513">cabecera</translation>
<translation id="6843725295806269523">silencio</translation>
-<translation id="2615751259741237794">volver a tiempo real</translation>
<translation id="2653659639078652383">Enviar</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">retroceso rápido</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_es.xtb b/chromium/webkit/glue/resources/webkit_strings_es.xtb
index 23644cd1fe2..b34e66a0af1 100644
--- a/chromium/webkit/glue/resources/webkit_strings_es.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_es.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="es">
<translation id="4763480195061959176">vídeo</translation>
<translation id="5843503607508392247">Otra...</translation>
-<translation id="2426432199384958866">volver a la emisión de películas en tiempo real</translation>
<translation id="248395913932153421">Día</translation>
<translation id="1729654308190250600">Introduce una dirección de correo electrónico que no esté vacía.</translation>
<translation id="6015796118275082299">Año</translation>
-<translation id="9186171386827445984">Cargando documento: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> páginas...</translation>
<translation id="1235745349614807883">Eliminar búsquedas recientes</translation>
<translation id="7223624360433298498">tiempo transcurrido</translation>
<translation id="1171774979989969504">Introduce una dirección de correo electrónico</translation>
<translation id="709897737746224366">Utiliza un formato que coincida con el solicitado</translation>
<translation id="5048533449481078685">marcador de listas</translation>
<translation id="4202807286478387388">saltar</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Introduce texto seguido del signo &quot;<ph name="ATSIGN"/>&quot;. La dirección &quot;<ph name="INVALIDADDRESS"/>&quot; está incompleta.</translation>
<translation id="2746543609216772311">El valor debe ser igual o posterior a <ph name="MINIMUM_DATE_OR_TIME"/>.</translation>
<translation id="2572483411312390101">reproducir</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">cronología de la película</translation>
<translation id="8199524924445686405">aaaa</translation>
<translation id="795667975304826397">Ningún archivo seleccionado</translation>
-<translation id="1320012872283894746">rebobinar rápidamente</translation>
<translation id="7789962463072032349">pausar</translation>
<translation id="6853785296079745596">ocultar subtítulos cerrados</translation>
<translation id="4360991593054037559">Introduce un valor válido. Los dos valores válidos más aproximados son <ph name="VALID_VALUE_LOW"/> y <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">pulsar</translation>
<translation id="8244226242650769279">mapa de imágenes</translation>
<translation id="310520048233152454">Introduce una URL</translation>
-<translation id="9039488204461337220">avanzar rápidamente</translation>
<translation id="4812940957355064477">Debes introducir un número.</translation>
<translation id="2548326553472216322">No hay búsquedas recientes</translation>
<translation id="1938124657309484470">El valor debe ser igual o anterior a <ph name="MAXIMUM_DATE_OR_TIME"/>.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Debes introducir un valor válido. El campo está incompleto o incluye una fecha no válida.</translation>
<translation id="3040011195152428237">enlace</translation>
<translation id="1014825444426747588">vacío</translation>
-<translation id="3356679314312413792">rebobinar la película 30 segundos</translation>
<translation id="9050748414552849310">mostrar subtítulos cerrados</translation>
<translation id="4522570452068850558">Detalles</translation>
<translation id="8451268428117625855">Selecciona un archivo</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Selecciona esta casilla de verificación si quieres continuar</translation>
<translation id="8534579021159131403">Minutos</translation>
<translation id="819205353528511139">reproducir la película en modo de pantalla completa</translation>
-<translation id="8964020114565522021">Arrastrar archivo hasta aquí</translation>
<translation id="4103419683916926126">Millisegundos</translation>
<translation id="838869780401515933">marcar</translation>
<translation id="2846343701378493991">1024 (Mediano)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Este documento está protegido por contraseña. Introduce una contraseña.</translation>
<translation id="5466621249238537318">Selecciona uno o varios archivos</translation>
<translation id="9132465097189459683">Otra...</translation>
+<translation id="10623998915015855">botón de activación</translation>
<translation id="8750798805984357768">Selecciona una de estas opciones</translation>
<translation id="7740050170769002709">Contenido HTML</translation>
<translation id="6692633176391053278">secuenciador</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> seleccionados</translation>
<translation id="8541249477527128034">control de medios</translation>
<translation id="2226276347425096477">Reduce la longitud de este texto a <ph name="MAX_CHARACTERS"/> caracteres o menos (actualmente, el texto tiene <ph name="CURRENT_LENGTH"/> caracteres)</translation>
<translation id="6101327004457443354">activar sonido de la pista de audio</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Horas</translation>
<translation id="4664250907885839816">El texto detrás del signo &quot;<ph name="ATSIGN"/>&quot; no debe incluir el símbolo &quot;<ph name="INVALIDCHARACTER"/>&quot;.</translation>
<translation id="3450233048674729344">El valor debe inferior o igual a <ph name="MAXIMUM"/></translation>
-<translation id="3471999216963526757">rebobinar 30 segundos</translation>
<translation id="668171684555832681">Otros...</translation>
<translation id="6270583010843788609">miniatura de línea de tiempo de la película</translation>
<translation id="5641012560118721995">pausar reproducción</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> archivos</translation>
<translation id="6643016212128521049">Eliminar</translation>
<translation id="7888071071722539607">Incluye un signo &quot;<ph name="ATSIGN"/>&quot; en la dirección de correo electrónico. La dirección &quot;<ph name="INVALIDADDRESS"/>&quot; no incluye el signo &quot;<ph name="ATSIGN"/>&quot;.</translation>
-<translation id="4851297395436456855">avance rápido</translation>
<translation id="1088086359088493902">Segundos</translation>
<translation id="3934680773876859118">Se ha producido un error al cargar el documento PDF.</translation>
<translation id="3632707345189162177">número de segundos restantes de la película</translation>
<translation id="6359256949422175976">miniatura del control deslizante de duración de la película</translation>
<translation id="8597182159515967513">cabecera</translation>
<translation id="6843725295806269523">silenciar</translation>
-<translation id="2615751259741237794">volver a tiempo real</translation>
<translation id="2653659639078652383">Enviar</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">retroceso rápido</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_et.xtb b/chromium/webkit/glue/resources/webkit_strings_et.xtb
index 14ba666ef7c..04d60ae91fa 100644
--- a/chromium/webkit/glue/resources/webkit_strings_et.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_et.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="et">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Muu ...</translation>
-<translation id="2426432199384958866">video voogesituse lülitamine tagasi reaalajale</translation>
<translation id="248395913932153421">päev</translation>
<translation id="1729654308190250600">Sisestage mittetühi e-posti aadress.</translation>
<translation id="6015796118275082299">Aasta</translation>
-<translation id="9186171386827445984">Dokumendi laadimine: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> lehte ...</translation>
<translation id="1235745349614807883">Kustuta viimased otsingud</translation>
<translation id="7223624360433298498">möödunud aeg</translation>
<translation id="1171774979989969504">Sisestage meiliaadress.</translation>
<translation id="709897737746224366">Vastendage nõutav vorming.</translation>
<translation id="5048533449481078685">loendilooja</translation>
<translation id="4202807286478387388">liigu</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Sisestage märgile „<ph name="ATSIGN"/>” eelnev osa. Aadress „<ph name="INVALIDADDRESS"/>” pole täielik.</translation>
<translation id="2746543609216772311">Väärtus peab olema <ph name="MINIMUM_DATE_OR_TIME"/> või hilisem.</translation>
<translation id="2572483411312390101">esitus</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">video aeg</translation>
<translation id="8199524924445686405">aaaa</translation>
<translation id="795667975304826397">Pole valitud</translation>
-<translation id="1320012872283894746">kiiresti tagasikerimine</translation>
<translation id="7789962463072032349">peata</translation>
<translation id="6853785296079745596">subtiitrite peitmine</translation>
<translation id="4360991593054037559">Sisestage kehtiv väärtus. Kaks lähimat kehtivat väärtust on <ph name="VALID_VALUE_LOW"/> ja <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">vajuta</translation>
<translation id="8244226242650769279">hüperpilt</translation>
<translation id="310520048233152454">Sisestage URL.</translation>
-<translation id="9039488204461337220">kiiresti edasikerimine</translation>
<translation id="4812940957355064477">Sisestage arv.</translation>
<translation id="2548326553472216322">Pole viimaseid otsingud</translation>
<translation id="1938124657309484470">Väärtus peab olema <ph name="MAXIMUM_DATE_OR_TIME"/> või varasem.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Sisestage kehtiv väärtus. Väli on täitmata või sisaldab sobimatut kuupäeva.</translation>
<translation id="3040011195152428237">link</translation>
<translation id="1014825444426747588">tühi</translation>
-<translation id="3356679314312413792">video kerimine tagasi 30 sekundit</translation>
<translation id="9050748414552849310">subtiitrite kuvamine</translation>
<translation id="4522570452068850558">Üksikasjad</translation>
<translation id="8451268428117625855">Valige üks fail.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Märkige see ruut, kui soovite jätkata.</translation>
<translation id="8534579021159131403">Minutid</translation>
<translation id="819205353528511139">video esitus täisekraani režiimis</translation>
-<translation id="8964020114565522021">Lohistage fail siia</translation>
<translation id="4103419683916926126">Millisekundid</translation>
<translation id="838869780401515933">mrgista</translation>
<translation id="2846343701378493991">1024 (keskmine)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Dokument on parooliga kaitstud. Sisestage parool.</translation>
<translation id="5466621249238537318">Valige üks või mitu faili.</translation>
<translation id="9132465097189459683">Muu ...</translation>
+<translation id="10623998915015855">ümberlülitusnupp</translation>
<translation id="8750798805984357768">Tehke üks nendest valikutest.</translation>
<translation id="7740050170769002709">HTML-sisu</translation>
<translation id="6692633176391053278">stepper</translation>
+<translation id="4975562563186953947">Valitud on <ph name="SELECTED_COUNT"/> üksust</translation>
<translation id="8541249477527128034">meedia juhtimine</translation>
<translation id="2226276347425096477">Lühendage seda teksti <ph name="MAX_CHARACTERS"/> tähemärgini või rohkem (praegu kasutate <ph name="CURRENT_LENGTH"/> tähemärki).</translation>
<translation id="6101327004457443354">heliraja vaigistamise tühistamine</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Tunnid</translation>
<translation id="4664250907885839816">Märgile „<ph name="ATSIGN"/>” järgnev osa ei tohi sisaldada sümbolit „<ph name="INVALIDCHARACTER"/>”.</translation>
<translation id="3450233048674729344">Väärtus peab olema väiksem või võrdne <ph name="MAXIMUM"/>-ga.</translation>
-<translation id="3471999216963526757">tagasi 30 sekundit</translation>
<translation id="668171684555832681">Muu...</translation>
<translation id="6270583010843788609">video ajajoone pisipilt</translation>
<translation id="5641012560118721995">taasesituse peatamine</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> faili</translation>
<translation id="6643016212128521049">Tühjenda</translation>
<translation id="7888071071722539607">Lisage e-posti aadressile märk „<ph name="ATSIGN"/>”. Aadressist „<ph name="INVALIDADDRESS"/>” puudub märk „<ph name="ATSIGN"/>”.</translation>
-<translation id="4851297395436456855">edasikerimine</translation>
<translation id="1088086359088493902">Sekundid</translation>
<translation id="3934680773876859118">PDF-dokumendi laadimine nurjus</translation>
<translation id="3632707345189162177">video järelejäänud aeg sekundites</translation>
<translation id="6359256949422175976">video ajakursori pisipilt</translation>
<translation id="8597182159515967513">pealkiri</translation>
<translation id="6843725295806269523">vaigista</translation>
-<translation id="2615751259741237794">reaalajale naasmine</translation>
<translation id="2653659639078652383">Esita</translation>
<translation id="3732799496749320381">kk</translation>
-<translation id="4484359737905287537">tagasikerimine</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_fa.xtb b/chromium/webkit/glue/resources/webkit_strings_fa.xtb
index 260e9408e3f..f7c1c261577 100644
--- a/chromium/webkit/glue/resources/webkit_strings_fa.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_fa.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="fa">
<translation id="4763480195061959176">ویدیو</translation>
<translation id="5843503607508392247">موارد دیگر...</translation>
-<translation id="2426432199384958866">بازگرداندن فیلم پخش جریانی به پخش بیدرنگ</translation>
<translation id="248395913932153421">روز</translation>
<translation id="1729654308190250600">لطفاً یک آدرس ایمیل غیرخالی وارد کنید.</translation>
<translation id="6015796118275082299">سال</translation>
-<translation id="9186171386827445984">در حال بارگیری سند: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> صفحات...</translation>
<translation id="1235745349614807883">پاک کردن جستجوهای اخیر</translation>
<translation id="7223624360433298498">مدت سپری شده</translation>
<translation id="1171774979989969504">لطفاً یک آدرس ایمیل وارد کنید.</translation>
<translation id="709897737746224366">لطفاً با قالب درخواستی مطابقت دهید.</translation>
<translation id="5048533449481078685">علامت گذار لیست</translation>
<translation id="4202807286478387388">پرش</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">لطفاً قسمت قبل از «<ph name="ATSIGN"/>» را وارد کنید. «<ph name="INVALIDADDRESS"/>» ناقص است.</translation>
<translation id="2746543609216772311">مقدار باید <ph name="MINIMUM_DATE_OR_TIME"/> یا بعد از آن باشد.</translation>
<translation id="2572483411312390101">پخش</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">زمان فیلم</translation>
<translation id="8199524924445686405">yyyy</translation>
<translation id="795667975304826397">فایلی انتخاب نشده است</translation>
-<translation id="1320012872283894746">جستجوی سریع به عقب</translation>
<translation id="7789962463072032349">توقف موقت</translation>
<translation id="6853785296079745596">پنهان کردن توصیف‌های بسته</translation>
<translation id="4360991593054037559">لطفاً یک مقدار معتبر وارد کنید. نزدیک‌ترین مقادیر معتبر <ph name="VALID_VALUE_LOW"/> و <ph name="VALID_VALUE_HIGHER"/> هستند.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">فشار دادن</translation>
<translation id="8244226242650769279">نقشه تصویر</translation>
<translation id="310520048233152454">‏لطفاً یک URL وارد کنید.</translation>
-<translation id="9039488204461337220">جستجو به جلو</translation>
<translation id="4812940957355064477">لطفاً شماره‌ای را وارد کنید.</translation>
<translation id="2548326553472216322">جستجوی جدیدی وجود ندارد</translation>
<translation id="1938124657309484470">مقدار باید <ph name="MAXIMUM_DATE_OR_TIME"/> یا قبل از آن باشد.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">لطفاً یک مقدار معتبر وارد کنید. این قسمت کامل نیست و یا تاریخ نامعتبر است.</translation>
<translation id="3040011195152428237">پیوند</translation>
<translation id="1014825444426747588">خالی</translation>
-<translation id="3356679314312413792">جستجو در ۳۰ ثانیه گذشته فیلم</translation>
<translation id="9050748414552849310">نمایش توصیف‌های بسته</translation>
<translation id="4522570452068850558">جزئیات</translation>
<translation id="8451268428117625855">لطفاً یک فایل انتخاب کنید.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">در صورتی که می‌خواهید ادامه دهید، این کادر را انتخاب کنید.</translation>
<translation id="8534579021159131403">دقیقه</translation>
<translation id="819205353528511139">پخش فیلم در حالت تمام صفحه</translation>
-<translation id="8964020114565522021">فایل را اینجا بکشید</translation>
<translation id="4103419683916926126">میلی‌ ثانیه</translation>
<translation id="838869780401515933">علامت‌گذاری</translation>
<translation id="2846343701378493991">1024 (درجه متوسط)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">این سند توسط رمز ورود محافظت می‌شود. لطفاً یک رمز ورود وارد کنید.</translation>
<translation id="5466621249238537318">لطفاً یک یا چند فایل را انتخاب کنید.</translation>
<translation id="9132465097189459683">موارد دیگر...</translation>
+<translation id="10623998915015855">دکمه تغییر حالت</translation>
<translation id="8750798805984357768">لطفاً یکی از این گزینه‌ها را انتخاب کنید.</translation>
<translation id="7740050170769002709">‏محتوای HTML</translation>
<translation id="6692633176391053278">گام به گام</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> انتخاب شد</translation>
<translation id="8541249477527128034">کنترل رسانه</translation>
<translation id="2226276347425096477">لطفاً این متن را به اندازه <ph name="MAX_CHARACTERS"/> نویسه یا کمتر کوتاه کنید (شما در حال حاضر از <ph name="CURRENT_LENGTH"/> نویسه استفاده می‌کنید).</translation>
<translation id="6101327004457443354">صدادارکردن تراک صوتی</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">ساعت</translation>
<translation id="4664250907885839816">قسمت بعد از «<ph name="ATSIGN"/>» نباید حاوی نماد «<ph name="INVALIDCHARACTER"/>» باشد.</translation>
<translation id="3450233048674729344">مقدار باید کمتر یا برابر با <ph name="MAXIMUM"/> باشد.</translation>
-<translation id="3471999216963526757">بازگشت به ۳۰ ثانیه قبل</translation>
<translation id="668171684555832681">دیگر...</translation>
<translation id="6270583010843788609">نشانگر خط زمان فیلم</translation>
<translation id="5641012560118721995">توقف موقت پخش</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> فایل</translation>
<translation id="6643016212128521049">پاک کردن</translation>
<translation id="7888071071722539607">لطفاً نماد «<ph name="ATSIGN"/>» را به آدرس ایمیل اضافه کنید. «<ph name="INVALIDADDRESS"/>» در «<ph name="ATSIGN"/>» موجود نیست.</translation>
-<translation id="4851297395436456855">سریع به جلو</translation>
<translation id="1088086359088493902">ثانیه</translation>
<translation id="3934680773876859118">‏بارگیری سند PDF انجام نشد</translation>
<translation id="3632707345189162177">مقدار ثانیه‌های باقیمانده فیلم</translation>
<translation id="6359256949422175976">نشانگر حذف‌کننده زمان فیلم</translation>
<translation id="8597182159515967513">عنوان</translation>
<translation id="6843725295806269523">بیصداکردن</translation>
-<translation id="2615751259741237794">بازگشت به پخش بیدرنگ</translation>
<translation id="2653659639078652383">ارائه</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">سریع به عقب</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_fi.xtb b/chromium/webkit/glue/resources/webkit_strings_fi.xtb
index cf024adae18..1ea919fe564 100644
--- a/chromium/webkit/glue/resources/webkit_strings_fi.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_fi.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="fi">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Muu...</translation>
-<translation id="2426432199384958866">palauta suoratoistettava elokuva reaaliaikaiseksi</translation>
<translation id="248395913932153421">Päivä</translation>
<translation id="1729654308190250600">Kirjoita ei-tyhjä sähköpostiosoite.</translation>
<translation id="6015796118275082299">Vuosi</translation>
-<translation id="9186171386827445984">Ladataan asiakirjaa: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> sivua...</translation>
<translation id="1235745349614807883">Poista viimeisimmät haut</translation>
<translation id="7223624360433298498">kulunut aika</translation>
<translation id="1171774979989969504">Anna sähköpostiosoite.</translation>
<translation id="709897737746224366">Käytä pyydettyä muotoilua.</translation>
<translation id="5048533449481078685">luettelon merkitsijä</translation>
<translation id="4202807286478387388">siirry</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Lisää <ph name="ATSIGN"/>-osaa ennen tuleva osa. <ph name="INVALIDADDRESS"/> on puutteellinen.</translation>
<translation id="2746543609216772311">Arvon on oltava <ph name="MINIMUM_DATE_OR_TIME"/> tai myöhempi.</translation>
<translation id="2572483411312390101">toista</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">elokuvan aikajana</translation>
<translation id="8199524924445686405">vvvv</translation>
<translation id="795667975304826397">Ei valittua tiedostoa</translation>
-<translation id="1320012872283894746">kuvakelaus taaksepäin</translation>
<translation id="7789962463072032349">tauko</translation>
<translation id="6853785296079745596">piilota tekstitykset</translation>
<translation id="4360991593054037559">Syötä kelvollinen arvo. Kaksi lähintä kelvollista arvoa ovat <ph name="VALID_VALUE_LOW"/> ja <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">paina</translation>
<translation id="8244226242650769279">kuvakartta</translation>
<translation id="310520048233152454">Anna URL-osoite.</translation>
-<translation id="9039488204461337220">kuvakelaus eteenpäin</translation>
<translation id="4812940957355064477">Anna numero.</translation>
<translation id="2548326553472216322">Ei viimeisimpiä hakuja</translation>
<translation id="1938124657309484470">Arvon on oltava <ph name="MAXIMUM_DATE_OR_TIME"/> tai aiempi.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Anna kelvollinen arvo. Kentän arvo on puutteellinen tai annettu päivä on virheellinen.</translation>
<translation id="3040011195152428237">linkki</translation>
<translation id="1014825444426747588">tyhjä</translation>
-<translation id="3356679314312413792">kelaa elokuvaa 30 sekuntia taaksepäin</translation>
<translation id="9050748414552849310">näytä tekstitykset</translation>
<translation id="4522570452068850558">Tiedot</translation>
<translation id="8451268428117625855">Valitse tiedosto.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Valitse tämä ruutu jatkaaksesi.</translation>
<translation id="8534579021159131403">Minuuttia</translation>
<translation id="819205353528511139">toista elokuva koko näytön tilassa</translation>
-<translation id="8964020114565522021">Vedä tiedosto tähän</translation>
<translation id="4103419683916926126">Millisekuntia</translation>
<translation id="838869780401515933">valitse</translation>
<translation id="2846343701378493991">1024 (keskitaso)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Tämä asiakirja on suojattu salasanalla. Anna salasana.</translation>
<translation id="5466621249238537318">Valitse vähintään yksi tiedosto.</translation>
<translation id="9132465097189459683">Muu...</translation>
+<translation id="10623998915015855">vaihtopainike</translation>
<translation id="8750798805984357768">Valitse yksi vaihtoehdoista.</translation>
<translation id="7740050170769002709">HTML-sisältö</translation>
<translation id="6692633176391053278">askellin</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> valittu</translation>
<translation id="8541249477527128034">median hallinta</translation>
<translation id="2226276347425096477">Lyhennä tämä teksti alle <ph name="MAX_CHARACTERS"/> merkkiin (tällä hetkellä käytössä <ph name="CURRENT_LENGTH"/> merkkiä).</translation>
<translation id="6101327004457443354">peruuta ääniraidan mykistys</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Tuntia</translation>
<translation id="4664250907885839816"><ph name="ATSIGN"/>-osan jälkeen tulevassa osassa ei pitäisi olla merkkiä <ph name="INVALIDCHARACTER"/>.</translation>
<translation id="3450233048674729344">Arvon tulee olla pienempi tai yhtä suuri kuin <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">30 sekuntia taaksepäin</translation>
<translation id="668171684555832681">Joku muu profiili...</translation>
<translation id="6270583010843788609">elokuvan aikajanan pikkukuva</translation>
<translation id="5641012560118721995">keskeytä toisto</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> tiedostoa</translation>
<translation id="6643016212128521049">Tyhjennä</translation>
<translation id="7888071071722539607">Sähköpostiosoitteeseen kuuluu <ph name="ATSIGN"/>-osa. Osoitteesta <ph name="INVALIDADDRESS"/> puuttuu <ph name="ATSIGN"/>.</translation>
-<translation id="4851297395436456855">kelaus eteenpäin</translation>
<translation id="1088086359088493902">Sekuntia</translation>
<translation id="3934680773876859118">PDF-asiakirjan lataaminen epäonnistui</translation>
<translation id="3632707345189162177">elokuvan jäljellä oleva aika sekunteina</translation>
<translation id="6359256949422175976">elokuvan ajan säätimen pikkukuva</translation>
<translation id="8597182159515967513">otsikko</translation>
<translation id="6843725295806269523">äänetön</translation>
-<translation id="2615751259741237794">palauta reaaliaikaiseksi</translation>
<translation id="2653659639078652383">Lähetä</translation>
<translation id="3732799496749320381">kk</translation>
-<translation id="4484359737905287537">pikakelaus taaksepäin</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_fil.xtb b/chromium/webkit/glue/resources/webkit_strings_fil.xtb
index ddbb0e9f1f8..24780470d2a 100644
--- a/chromium/webkit/glue/resources/webkit_strings_fil.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_fil.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="fil">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Iba pa...</translation>
-<translation id="2426432199384958866">ibalik sa real time ang streaming ng pelikula</translation>
<translation id="248395913932153421">Araw</translation>
<translation id="1729654308190250600">Mangyaring maglagay ng isang non-empty na email address.</translation>
<translation id="6015796118275082299">Taon</translation>
-<translation id="9186171386827445984">Nilo-load ang dokumento: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> (na) pahina...</translation>
<translation id="1235745349614807883">Lisiman ang Kasalukuyang Mga Paghahanap</translation>
<translation id="7223624360433298498">lumipas na oras</translation>
<translation id="1171774979989969504">Mangyaring magpasok ng email address.</translation>
<translation id="709897737746224366">Pakitugma ang hiniling na format.</translation>
<translation id="5048533449481078685">Ilista ang marker</translation>
<translation id="4202807286478387388">tumalon</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Mangyaring maglagay ng isang bahagi na sinusundan ng '<ph name="ATSIGN"/>.' Hindi kumpleto ang '<ph name="INVALIDADDRESS"/>.'</translation>
<translation id="2746543609216772311">Dapat <ph name="MINIMUM_DATE_OR_TIME"/> o mas bago ang value.</translation>
<translation id="2572483411312390101">i-play</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">oras ng pelikula</translation>
<translation id="8199524924445686405">yyyy</translation>
<translation id="795667975304826397">Walang napiling file</translation>
-<translation id="1320012872283894746">mabilisang maghanap nang pabalik</translation>
<translation id="7789962463072032349">i-pause</translation>
<translation id="6853785296079745596">itago ang mga nakasarang caption</translation>
<translation id="4360991593054037559">Mangyaring maglagay ng isang wastong value. Ang dalawang pinakamalapit na wastong value ay <ph name="VALID_VALUE_LOW"/> at <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">pindutin</translation>
<translation id="8244226242650769279">mapa ng imahe</translation>
<translation id="310520048233152454">Mangyaring magpasok ng URL.</translation>
-<translation id="9039488204461337220">mabilisang maghanap nang pasulong</translation>
<translation id="4812940957355064477">Mangyaring maglagay ng numero.</translation>
<translation id="2548326553472216322">Walang kamakailang mga paghahanap</translation>
<translation id="1938124657309484470">Dapat <ph name="MAXIMUM_DATE_OR_TIME"/> o mas nauna ang value.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Mangyaring maglagay ng wastong halaga. Hindi kumpleto ang field o may isang di-wastong petsa.</translation>
<translation id="3040011195152428237">link</translation>
<translation id="1014825444426747588">blangko</translation>
-<translation id="3356679314312413792">ibalik ang pelikula nang 30 segundo</translation>
<translation id="9050748414552849310">ipakita ang mga nakasarang caption</translation>
<translation id="4522570452068850558">Mga Detalye</translation>
<translation id="8451268428117625855">Mangyaring pumili ng file.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Pakitingnan ang kahon na ito kung gusto mong magpatuloy.</translation>
<translation id="8534579021159131403">Minuto</translation>
<translation id="819205353528511139">i-play ang pelikula sa full screen mode</translation>
-<translation id="8964020114565522021">Kaldkarin dito ang file</translation>
<translation id="4103419683916926126">Milliseconds</translation>
<translation id="838869780401515933">I-tsek</translation>
<translation id="2846343701378493991">1024 (Katamtamang Grado)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Protektado ng password ang dokumentong ito. Mangyaring magpasok ng password.</translation>
<translation id="5466621249238537318">Mangyaring pumili ng isa o higit pang mga file.</translation>
<translation id="9132465097189459683">Iba pa...</translation>
+<translation id="10623998915015855">button sa pag-toggle</translation>
<translation id="8750798805984357768">Mangyaring pumili ng isa sa mga opsyong ito.</translation>
<translation id="7740050170769002709">HTML na nilalaman</translation>
<translation id="6692633176391053278">stepper</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> ang napili</translation>
<translation id="8541249477527128034">kontrol sa media</translation>
<translation id="2226276347425096477">Mangyaring paikliin ang tekstong ito ng <ph name="MAX_CHARACTERS"/> (na) character o mas mababa (kasalukuyan kang gumagamit ng <ph name="CURRENT_LENGTH"/> (na) character).</translation>
<translation id="6101327004457443354">i-unmute ang audio track</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Oras</translation>
<translation id="4664250907885839816">Hindi dapat naglalaman ng simbolong '<ph name="INVALIDCHARACTER"/>' ang bahagi pagkatapos ng '<ph name="ATSIGN"/>.'</translation>
<translation id="3450233048674729344">Dapat mas mababa kaysa sa o katumbas ng <ph name="MAXIMUM"/> ang halaga.</translation>
-<translation id="3471999216963526757">bumalik nang 30 segundo</translation>
<translation id="668171684555832681">Iba pa...</translation>
<translation id="6270583010843788609">thumb ng timeline ng pelikula</translation>
<translation id="5641012560118721995">i-pause ang pag-playback</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> mga file</translation>
<translation id="6643016212128521049">I-clear</translation>
<translation id="7888071071722539607">Mangyaring magsama ng '<ph name="ATSIGN"/>' sa email address. Kulang ng '<ph name="ATSIGN"/>' ang '<ph name="INVALIDADDRESS"/>.'</translation>
-<translation id="4851297395436456855">i-fast forward</translation>
<translation id="1088086359088493902">Segundo</translation>
<translation id="3934680773876859118">Nabigong i-load ang dokumentong PDF</translation>
<translation id="3632707345189162177">bilang ng segundong natitira sa pelikula</translation>
<translation id="6359256949422175976">thumb ng scrubber ng oras ng pelikula</translation>
<translation id="8597182159515967513">heading</translation>
<translation id="6843725295806269523">i-mute</translation>
-<translation id="2615751259741237794">bumalik sa real time</translation>
<translation id="2653659639078652383">Isumite</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">mabilis na bumalik</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_fr.xtb b/chromium/webkit/glue/resources/webkit_strings_fr.xtb
index 7fb087ef230..191e82984ad 100644
--- a/chromium/webkit/glue/resources/webkit_strings_fr.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_fr.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="fr">
<translation id="4763480195061959176">vidéo</translation>
<translation id="5843503607508392247">Autre…</translation>
-<translation id="2426432199384958866">revenir à une lecture en streaming des films en temps réel</translation>
<translation id="248395913932153421">Jour</translation>
<translation id="1729654308190250600">Veuillez saisir une adresse e-mail dans le champ correspondant.</translation>
<translation id="6015796118275082299">Année</translation>
-<translation id="9186171386827445984">Chargement du document : <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> pages...</translation>
<translation id="1235745349614807883">Effacer les recherches récentes</translation>
<translation id="7223624360433298498">temps écoulé</translation>
<translation id="1171774979989969504">Veuillez saisir une adresse e-mail.</translation>
<translation id="709897737746224366">Veuillez respecter le format requis.</translation>
<translation id="5048533449481078685">marqueur de liste</translation>
<translation id="4202807286478387388">accéder</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/> × <ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Veuillez saisir la partie manquante avant le caractère &quot;<ph name="ATSIGN"/>&quot;. L'adresse &quot;<ph name="INVALIDADDRESS"/>&quot; est incomplète.</translation>
<translation id="2746543609216772311">La date ou l'heure doit être égale ou postérieure à &quot;<ph name="MINIMUM_DATE_OR_TIME"/>&quot;.</translation>
<translation id="2572483411312390101">lire</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">durée du film</translation>
<translation id="8199524924445686405">aaaa</translation>
<translation id="795667975304826397">Aucun fichier choisi</translation>
-<translation id="1320012872283894746">recherche arrière rapide</translation>
<translation id="7789962463072032349">pause</translation>
<translation id="6853785296079745596">masquer les sous-titres</translation>
<translation id="4360991593054037559">Veuillez saisir une valeur valide. Les deux valeurs valides les plus proches sont &quot;<ph name="VALID_VALUE_LOW"/>&quot; et &quot;<ph name="VALID_VALUE_HIGHER"/>&quot;.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">appuyer</translation>
<translation id="8244226242650769279">image map</translation>
<translation id="310520048233152454">Veuillez saisir une URL.</translation>
-<translation id="9039488204461337220">recherche avant rapide</translation>
<translation id="4812940957355064477">Veuillez saisir un nombre.</translation>
<translation id="2548326553472216322">Aucune recherche récente</translation>
<translation id="1938124657309484470">La date ou l'heure doit être égale ou antérieure à &quot;<ph name="MAXIMUM_DATE_OR_TIME"/>&quot;.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Veuillez saisir une valeur valide. Le champ n'est pas complet ou contient une date non valide.</translation>
<translation id="3040011195152428237">Lien</translation>
<translation id="1014825444426747588">vide</translation>
-<translation id="3356679314312413792">recherche arrière de 30 secondes</translation>
<translation id="9050748414552849310">afficher les sous-titres</translation>
<translation id="4522570452068850558">Détails</translation>
<translation id="8451268428117625855">Veuillez sélectionner un fichier.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Veuillez cocher cette case si vous souhaitez continuer.</translation>
<translation id="8534579021159131403">Minutes</translation>
<translation id="819205353528511139">lire le film en mode plein écran</translation>
-<translation id="8964020114565522021">Placer le fichier ici</translation>
<translation id="4103419683916926126">Millisecondes</translation>
<translation id="838869780401515933">cocher</translation>
<translation id="2846343701378493991">1024 (sécurité moyenne)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Ce document est protégé par mot de passe. Veuillez saisir ce dernier.</translation>
<translation id="5466621249238537318">Veuillez sélectionner un ou plusieurs fichiers.</translation>
<translation id="9132465097189459683">Autre…</translation>
+<translation id="10623998915015855">bouton d'activation/de désactivation</translation>
<translation id="8750798805984357768">Veuillez sélectionner l'une de ces options.</translation>
<translation id="7740050170769002709">Contenu HTML</translation>
<translation id="6692633176391053278">curseur</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> élément(s) sélectionné(s)</translation>
<translation id="8541249477527128034">commande multimédia</translation>
<translation id="2226276347425096477">Veuillez réduire ce texte à <ph name="MAX_CHARACTERS"/> caractères maximum (il compte actuellement <ph name="CURRENT_LENGTH"/> caractères).</translation>
<translation id="6101327004457443354">réactiver le son de la piste audio</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Heures</translation>
<translation id="4664250907885839816">La partie précédée du symbole &quot;<ph name="ATSIGN"/>&quot; ne doit pas contenir le caractère &quot;<ph name="INVALIDCHARACTER"/>&quot;.</translation>
<translation id="3450233048674729344">Cette valeur doit être inférieure ou égale à <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">revenir en arrière de 30 secondes</translation>
<translation id="668171684555832681">Autre...</translation>
<translation id="6270583010843788609">vignette de la chronologie du film</translation>
<translation id="5641012560118721995">interrompre la lecture</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> fichiers</translation>
<translation id="6643016212128521049">Effacer</translation>
<translation id="7888071071722539607">Veuillez inclure &quot;<ph name="ATSIGN"/>&quot; dans l'adresse e-mail. Il manque un symbole &quot;<ph name="ATSIGN"/>&quot; dans &quot;<ph name="INVALIDADDRESS"/>&quot;.</translation>
-<translation id="4851297395436456855">avance rapide</translation>
<translation id="1088086359088493902">Secondes</translation>
<translation id="3934680773876859118">Échec du chargement du document PDF</translation>
<translation id="3632707345189162177">nombre de secondes du film restantes</translation>
<translation id="6359256949422175976">vignette de la barre de défilement de la durée du film</translation>
<translation id="8597182159515967513">en-tête</translation>
<translation id="6843725295806269523">muet</translation>
-<translation id="2615751259741237794">revenir en temps réel</translation>
<translation id="2653659639078652383">Valider</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">retour rapide</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_gu.xtb b/chromium/webkit/glue/resources/webkit_strings_gu.xtb
index c9aa700cec5..0d3d9d1d8de 100644
--- a/chromium/webkit/glue/resources/webkit_strings_gu.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_gu.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="gu">
<translation id="4763480195061959176">વિડિઓ</translation>
<translation id="5843503607508392247">અન્ય...</translation>
-<translation id="2426432199384958866">રિયલ ટાઇમ પર ધારાવાહિક ફિલ્મ પાછી કરો</translation>
<translation id="248395913932153421">દિવસ</translation>
<translation id="1729654308190250600">કૃપા કરીને એક બિન-ખાલી ઇમેઇલ સરનામું દાખલ કરો.</translation>
<translation id="6015796118275082299">વર્ષ</translation>
-<translation id="9186171386827445984">દસ્તાવેજ લોડ કરી રહ્યું છે: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> પૃષ્ઠ...</translation>
<translation id="1235745349614807883">હાલની શોધને સાફ કરો</translation>
<translation id="7223624360433298498">વીતેલો સમય</translation>
<translation id="1171774979989969504">કૃપા કરી કોઈ ઇમેઇલ સરનામું દાખલ કરો.</translation>
<translation id="709897737746224366">કૃપા કરીને વિનંતી કરેલા ફોર્મેટ સાથે મેળ કરો.</translation>
<translation id="5048533449481078685">સૂચિ માર્કર</translation>
<translation id="4202807286478387388">જંપ કરો</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">કૃપા કરીને '<ph name="ATSIGN"/>' ની આગળનો ભાગ દાખલ કરો. '<ph name="INVALIDADDRESS"/>' અપૂર્ણ છે.</translation>
<translation id="2746543609216772311">મૂલ્ય <ph name="MINIMUM_DATE_OR_TIME"/> અથવા પછીનું હોવું આવશ્યક છે.</translation>
<translation id="2572483411312390101">ચલાવો</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">મૂવીનો સમય</translation>
<translation id="8199524924445686405">yyyy</translation>
<translation id="795667975304826397">કોઈ ફાઇલ પસંદ કરેલી નથી</translation>
-<translation id="1320012872283894746">ઝડપથી પાછા લો</translation>
<translation id="7789962463072032349">થોભો</translation>
<translation id="6853785296079745596">વિગતવાર ઉપશીર્ષક છુપાવો</translation>
<translation id="4360991593054037559">કૃપા કરીને એક માન્ય મૂલ્ય દાખલ કરો. બે નિકટતમ માન્ય મૂલ્યો <ph name="VALID_VALUE_LOW"/> અને <ph name="VALID_VALUE_HIGHER"/> છે.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">દબાવો</translation>
<translation id="8244226242650769279">છબી નકશો</translation>
<translation id="310520048233152454">કૃપા કરી કોઈ URL દાખલ કરો.</translation>
-<translation id="9039488204461337220">ઝડપથી આગળ લો</translation>
<translation id="4812940957355064477">કૃપા કરીને એક નંબર દાખલ કરો.</translation>
<translation id="2548326553472216322">હાલની શોધો નથી</translation>
<translation id="1938124657309484470">મૂલ્ય <ph name="MAXIMUM_DATE_OR_TIME"/> અથવા પહેલાંનું હોવું આવશ્યક છે.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">કૃપા કરીને માન્ય કિંમત દાખલ કરો. ફીલ્ડ અપૂર્ણ છે અથવા અમાન્ય તારીખ ધરાવે છે.</translation>
<translation id="3040011195152428237">લિંક</translation>
<translation id="1014825444426747588">ખાલી</translation>
-<translation id="3356679314312413792">30 સેકન્ડ પાછળ ફિલ્મ લેવી</translation>
<translation id="9050748414552849310">વિગતવાર ઉપશીર્ષક બતાવો</translation>
<translation id="4522570452068850558">વિગતો</translation>
<translation id="8451268428117625855">કૃપા કરીને કોઈ ફાઇલ પસંદ કરો.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">જો તમે આગળ વધવા માંગતા હો તો કૃપા કરીને આ બૉક્સને ચેક કરો.</translation>
<translation id="8534579021159131403">મિનિટ</translation>
<translation id="819205353528511139">પૂર્ણ સ્ક્રીન મોડમાં મૂવી ચલાવો</translation>
-<translation id="8964020114565522021">ફાઇલને અહીં ખેંચો</translation>
<translation id="4103419683916926126">મીલીસેકન્ડ</translation>
<translation id="838869780401515933">તપાસો</translation>
<translation id="2846343701378493991">1024 (મધ્યમ ગ્રેડ)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">આ દસ્તાવેજ પાસવર્ડ સુરક્ષિત છે. કૃપા કરીને પાસવર્ડ દાખલ કરો.</translation>
<translation id="5466621249238537318">કૃપા કરીને એક અથવા વધુ ફાઇલ પસંદ કરો. </translation>
<translation id="9132465097189459683">અન્ય...</translation>
+<translation id="10623998915015855">ટોગલ બટન</translation>
<translation id="8750798805984357768">કૃપા કરીને આ વિકલ્પોમાંથી કોઈ એક પસંદ કરો.</translation>
<translation id="7740050170769002709">HTML સામગ્રી</translation>
<translation id="6692633176391053278">સ્ટેપર</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> પસંદ કર્યા</translation>
<translation id="8541249477527128034">મીડિયાનું નિયંત્રણ</translation>
<translation id="2226276347425096477">કૃપા કરીને આ ટેક્સ્ટને <ph name="MAX_CHARACTERS"/> અક્ષર અથવા તેથી ઓછા સુધી નાનો કરો (તમે હાલમાં <ph name="CURRENT_LENGTH"/> અક્ષરોનો ઉપયોગ કરી રહ્યા છો).</translation>
<translation id="6101327004457443354">ઑડિઓ ટ્રેક અનમ્યૂટ કરો</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">કલાક</translation>
<translation id="4664250907885839816">'<ph name="ATSIGN"/>' ને અનુસરી રહેલા ભાગમાં '<ph name="INVALIDCHARACTER"/>' પ્રતીક શામેલ હોવું જોઈએ નહીં.</translation>
<translation id="3450233048674729344">મૂલ્ય <ph name="MAXIMUM"/> જેટલું અથવા આનાથી ઓછું હોવું આવશ્યક છે.</translation>
-<translation id="3471999216963526757">30 સેકન્ડ પાછા જાઓ</translation>
<translation id="668171684555832681">અન્ય...</translation>
<translation id="6270583010843788609">મૂવી સમયરેખા થમ્બ</translation>
<translation id="5641012560118721995">પ્લેબેક થોભાવો</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> ફાઇલો</translation>
<translation id="6643016212128521049">સાફ કરો</translation>
<translation id="7888071071722539607">કૃપા કરીને ઇમેઇલ સરનામાંમાં '<ph name="ATSIGN"/>' શામેલ કરો. '<ph name="INVALIDADDRESS"/>' માં '<ph name="ATSIGN"/>' ખૂટી રહ્યું છે.</translation>
-<translation id="4851297395436456855">ઝડપથી આગળ વધો</translation>
<translation id="1088086359088493902">સેકંડ</translation>
<translation id="3934680773876859118">PDF દસ્તાવેજ લોડ કરવામાં નિષ્ફળ રહ્યા</translation>
<translation id="3632707345189162177">ofmovie ની બાકી સેકન્ડ્સની સંખ્યા</translation>
<translation id="6359256949422175976">મૂવી સમય સ્ક્રબર થમ્બ</translation>
<translation id="8597182159515967513">મથાળું</translation>
<translation id="6843725295806269523">બંધ કરો</translation>
-<translation id="2615751259741237794">રીઅલ ટાઇમ પર પાછા કરો</translation>
<translation id="2653659639078652383">સબમિટ કરો</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">ઝડપી રિવર્સ</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_hi.xtb b/chromium/webkit/glue/resources/webkit_strings_hi.xtb
index 0f00848c1dc..4aeaf0b89ae 100644
--- a/chromium/webkit/glue/resources/webkit_strings_hi.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_hi.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="hi">
<translation id="4763480195061959176">वीडियो</translation>
<translation id="5843503607508392247">अन्य...</translation>
-<translation id="2426432199384958866">स्ट्रीम हो रही फ़िल्म को रीयल टाइम में वापस लाएं</translation>
<translation id="248395913932153421">दिन</translation>
<translation id="1729654308190250600">कृपया गैर-रिक्त ईमेल पता डालें.</translation>
<translation id="6015796118275082299">वर्ष</translation>
-<translation id="9186171386827445984">दस्तावेज़ लोड कर रहा है: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> पृष्ठ...</translation>
<translation id="1235745349614807883">हाल ही की खोजें साफ़ करें</translation>
<translation id="7223624360433298498">बीता हुआ समय</translation>
<translation id="1171774979989969504">कृपया ई-मेल पता दर्ज करें.</translation>
<translation id="709897737746224366">कृपया अनुरोधित प्रारूप का मिलान करें.</translation>
<translation id="5048533449481078685">सूची चिन्हक</translation>
<translation id="4202807286478387388">जाएं</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">कृपया '<ph name="ATSIGN"/>' के पहले वाला भाग डालें. '<ph name="INVALIDADDRESS"/>' अधूरा है.</translation>
<translation id="2746543609216772311">मान <ph name="MINIMUM_DATE_OR_TIME"/> या बाद का होना चाहिए.</translation>
<translation id="2572483411312390101">चलाएं</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">फि़ल्म का समय</translation>
<translation id="8199524924445686405">yyyy</translation>
<translation id="795667975304826397">कोई फाइल नहीं चुनी गई</translation>
-<translation id="1320012872283894746">तेज़ी से पीछे करें</translation>
<translation id="7789962463072032349">पॉज़ करें</translation>
<translation id="6853785296079745596">बंद कैप्शन छिपाएं</translation>
<translation id="4360991593054037559">कृपया कोई मान्य मान डालें. दो निकटतम मान्य मान <ph name="VALID_VALUE_LOW"/> और <ph name="VALID_VALUE_HIGHER"/> हैं.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">दबाएं</translation>
<translation id="8244226242650769279">चित्र नक्शे</translation>
<translation id="310520048233152454">कृपया URL लिखें.</translation>
-<translation id="9039488204461337220">तेज़ी से आगे करें</translation>
<translation id="4812940957355064477">कृपया कोई संख्या डालें.</translation>
<translation id="2548326553472216322">हाल ही कोई खोज नहीं</translation>
<translation id="1938124657309484470">मान <ph name="MAXIMUM_DATE_OR_TIME"/> या पहले का होना चाहिए.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">कृपया मान्य मान डालें. फ़ील्ड अधूरी है या उसमें एक अमान्य दिनांक है.</translation>
<translation id="3040011195152428237">संपर्क</translation>
<translation id="1014825444426747588">रिक्त</translation>
-<translation id="3356679314312413792">फ़िल्म को 30 सेकंड पीछे करें</translation>
<translation id="9050748414552849310">बंद कैप्शन दिखाएं</translation>
<translation id="4522570452068850558">विवरण</translation>
<translation id="8451268428117625855">कृपया किसी फ़ाइल को चुनें.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">यदि आप आगे बढ़ना चाहते हैं तो इस बॉक्‍स को चेक करें.</translation>
<translation id="8534579021159131403">मिनट</translation>
<translation id="819205353528511139">फ़िल्म को पूर्ण स्क्रीन मोड में चलाएं</translation>
-<translation id="8964020114565522021">यहां फाइल खींचकर लाएं</translation>
<translation id="4103419683916926126">मिलीसेकंड</translation>
<translation id="838869780401515933">चेक करें</translation>
<translation id="2846343701378493991">1024 (मध्यम ग्रेड)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">यह दस्तावेज़ पासवर्ड सुरक्षित है. कृपया पासवर्ड डालें.</translation>
<translation id="5466621249238537318">कृपया एक या अधिक फ़ाइल को चुनें.</translation>
<translation id="9132465097189459683">अन्य...</translation>
+<translation id="10623998915015855">टॉगल बटन</translation>
<translation id="8750798805984357768">कृपया इनमें से कोई विकल्प चुनें.</translation>
<translation id="7740050170769002709">HTML सामग्री</translation>
<translation id="6692633176391053278">स्टेपर</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> चुने गए</translation>
<translation id="8541249477527128034">मीडिया नियंत्रण</translation>
<translation id="2226276347425096477">कृपया इस टेक्स्ट को <ph name="MAX_CHARACTERS"/> वर्णों या कम तक छोटा करें (वर्तमान में आप <ph name="CURRENT_LENGTH"/> वर्णों का उपयोग कर रहे हैं).</translation>
<translation id="6101327004457443354">ऑडियो ट्रैक अनम्यूट करें</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">घंटे</translation>
<translation id="4664250907885839816">'<ph name="ATSIGN"/>' के बाद आने वाले भाग में '<ph name="INVALIDCHARACTER"/>' प्रतीक शामिल नहीं होना चाहिए.</translation>
<translation id="3450233048674729344">मान <ph name="MAXIMUM"/> से कम या इसके बराबर होना चाहिए.</translation>
-<translation id="3471999216963526757">30 सेकंड पीछे करें</translation>
<translation id="668171684555832681">अन्य...</translation>
<translation id="6270583010843788609">फ़िल्म टाइमलाइन झलक</translation>
<translation id="5641012560118721995">प्लेबैक रोकें</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> फ़ाइल</translation>
<translation id="6643016212128521049">साफ़ करें</translation>
<translation id="7888071071722539607">कृपया ईमेल पते में '<ph name="ATSIGN"/>' शामिल करें. '<ph name="INVALIDADDRESS"/>' में '<ph name="ATSIGN"/>' नहीं है.</translation>
-<translation id="4851297395436456855">फ़ास्ट फ़ॉरवर्ड</translation>
<translation id="1088086359088493902">सेकंड</translation>
<translation id="3934680773876859118">PDF दस्तावेज़ लोड करने में विफल</translation>
<translation id="3632707345189162177">फ़िल्म के शेष सेकंड</translation>
<translation id="6359256949422175976">फ़िल्म समय स्क्रबर झलक</translation>
<translation id="8597182159515967513">हेडिंग</translation>
<translation id="6843725295806269523">म्यूट करें</translation>
-<translation id="2615751259741237794">रीयल टाइम में वापस जाएं</translation>
<translation id="2653659639078652383">सबमिट करें</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">फ़ास्ट रिवर्स</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_hr.xtb b/chromium/webkit/glue/resources/webkit_strings_hr.xtb
index 69d24eaad2b..ae8026a7835 100644
--- a/chromium/webkit/glue/resources/webkit_strings_hr.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_hr.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="hr">
<translation id="4763480195061959176">videozapis</translation>
<translation id="5843503607508392247">Drugo...</translation>
-<translation id="2426432199384958866">vraćanje strujanja filma u stvarno vrijeme</translation>
<translation id="248395913932153421">Dan</translation>
<translation id="1729654308190250600">Unesite e-adresu koja nije prazna vrijednost.</translation>
<translation id="6015796118275082299">Godina</translation>
-<translation id="9186171386827445984">Učitavanje dokumenta: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> stranica...</translation>
<translation id="1235745349614807883">Obriši najnovija pretraživanja</translation>
<translation id="7223624360433298498">proteklo vrijeme</translation>
<translation id="1171774979989969504">Unesite adresu e-pošte.</translation>
<translation id="709897737746224366">Udovoljite zadanom formatu.</translation>
<translation id="5048533449481078685">oznaka popisa</translation>
<translation id="4202807286478387388">skoči</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Unesite dio adrese ispred znaka &quot;<ph name="ATSIGN"/>&quot;. &quot;<ph name="INVALIDADDRESS"/>&quot; nije potpuna e-adresa.</translation>
<translation id="2746543609216772311">Vrijednost mora biti <ph name="MINIMUM_DATE_OR_TIME"/> ili nakon toga.</translation>
<translation id="2572483411312390101">reprodukcija</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">vrijeme filma</translation>
<translation id="8199524924445686405">gggg</translation>
<translation id="795667975304826397">Nije odabrana niti jedna datoteka.</translation>
-<translation id="1320012872283894746">brzo traženje unatrag</translation>
<translation id="7789962463072032349">pauziraj</translation>
<translation id="6853785296079745596">sakrivanje titlova</translation>
<translation id="4360991593054037559">Unesite važeću vrijednost. Dvije su najbliže važeće vrijednosti <ph name="VALID_VALUE_LOW"/> i <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">pritisni</translation>
<translation id="8244226242650769279">karta slika</translation>
<translation id="310520048233152454">Unesite URL.</translation>
-<translation id="9039488204461337220">brzo traženje unaprijed</translation>
<translation id="4812940957355064477">Unesite broj.</translation>
<translation id="2548326553472216322">Nema najnovijih pretraživanja</translation>
<translation id="1938124657309484470">Vrijednost mora biti <ph name="MAXIMUM_DATE_OR_TIME"/> ili prije toga.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Unesite važeću vrijednost. Ovo je polje nepotpuno ili sadrži nevažeći datum.</translation>
<translation id="3040011195152428237">veza</translation>
<translation id="1014825444426747588">prazno</translation>
-<translation id="3356679314312413792">traženje u filmu 30 sekundi unatrag</translation>
<translation id="9050748414552849310">prikazivanje titlova</translation>
<translation id="4522570452068850558">Detalji</translation>
<translation id="8451268428117625855">Odaberite datoteku.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Označite taj okvir ako želite ići dalje.</translation>
<translation id="8534579021159131403">Minute</translation>
<translation id="819205353528511139">reprodukcija filma na cijelom zaslonu</translation>
-<translation id="8964020114565522021">Povucite datoteku ovamo</translation>
<translation id="4103419683916926126">Milisekunde</translation>
<translation id="838869780401515933">označi</translation>
<translation id="2846343701378493991">1024 (srednji)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Ovaj je dokument zaštićen zaporkom. Unesite zaporku.</translation>
<translation id="5466621249238537318">Izaberite jednu ili više datoteka.</translation>
<translation id="9132465097189459683">Drugo...</translation>
+<translation id="10623998915015855">preklopni gumb</translation>
<translation id="8750798805984357768">Izaberite jednu od tih opcija.</translation>
<translation id="7740050170769002709">HTML sadržaj</translation>
<translation id="6692633176391053278">povećanje/smanjenje strelicama gore/dolje (stepper)</translation>
+<translation id="4975562563186953947">Odabrano: <ph name="SELECTED_COUNT"/></translation>
<translation id="8541249477527128034">kontrola medija</translation>
<translation id="2226276347425096477">Skratite taj tekst na <ph name="MAX_CHARACTERS"/> znakova ili manje (trenutačno upotrebljavate <ph name="CURRENT_LENGTH"/> znakova).</translation>
<translation id="6101327004457443354">uključivanje zvučnog zapisa</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Sati</translation>
<translation id="4664250907885839816">Dio adrese iza znaka &quot;<ph name="ATSIGN"/>&quot; ne smije sadržavati simbol &quot;<ph name="INVALIDCHARACTER"/>&quot;.</translation>
<translation id="3450233048674729344">Vrijednost mora biti <ph name="MAXIMUM"/> ili manja.</translation>
-<translation id="3471999216963526757">30 sekundi unatrag</translation>
<translation id="668171684555832681">Ostalo...</translation>
<translation id="6270583010843788609">gumb na vremenskom klizaču filma</translation>
<translation id="5641012560118721995">pauziranje reprodukcije</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423">Broj datoteka: <ph name="NUMBER_OF_FILES"/></translation>
<translation id="6643016212128521049">Izbriši</translation>
<translation id="7888071071722539607">Uključite znak &quot;<ph name="ATSIGN"/>&quot; u e-adresu. U adresi &quot;<ph name="INVALIDADDRESS"/>&quot; nedostaje znak &quot;<ph name="ATSIGN"/>&quot;.</translation>
-<translation id="4851297395436456855">brzo unaprijed</translation>
<translation id="1088086359088493902">Sekunde</translation>
<translation id="3934680773876859118">Učitavanje dokumenta PDF nije uspjelo</translation>
<translation id="3632707345189162177">preostali broj sekundi filma</translation>
<translation id="6359256949422175976">gumb vremenskog klizača filma</translation>
<translation id="8597182159515967513">naslov</translation>
<translation id="6843725295806269523">isključi ton</translation>
-<translation id="2615751259741237794">vraćanje u stvarno vrijeme</translation>
<translation id="2653659639078652383">Pošalji</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">brzo unatrag</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_hu.xtb b/chromium/webkit/glue/resources/webkit_strings_hu.xtb
index deeaf2e9871..a8ab563d594 100644
--- a/chromium/webkit/glue/resources/webkit_strings_hu.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_hu.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="hu">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Más...</translation>
-<translation id="2426432199384958866">közvetített videó visszaállítása valós időre</translation>
<translation id="248395913932153421">nap</translation>
<translation id="1729654308190250600">Kérjük, ne hagyja üresen az e-mail cím mezőjét.</translation>
<translation id="6015796118275082299">Év</translation>
-<translation id="9186171386827445984">Dokumentum betöltése: <ph name="NUMBER_OF_PAGES"/>/<ph name="PAGE_NUMBER"/>. oldal...</translation>
<translation id="1235745349614807883">Friss keresések törlése</translation>
<translation id="7223624360433298498">eltelt idő</translation>
<translation id="1171774979989969504">Kérjük, adjon meg egy e-mail címet.</translation>
<translation id="709897737746224366">Kérjük, tartsa magát a kívánt formátumhoz.</translation>
<translation id="5048533449481078685">listajelölő</translation>
<translation id="4202807286478387388">Mehet</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Kérjük, adja meg a „<ph name="ATSIGN"/>” előtti részt is. A „<ph name="INVALIDADDRESS"/>” cím nem teljes.</translation>
<translation id="2746543609216772311">Az érték <ph name="MINIMUM_DATE_OR_TIME"/> vagy azt követő kell, hogy legyen.</translation>
<translation id="2572483411312390101">lejátszás</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">film ideje</translation>
<translation id="8199524924445686405">éééé</translation>
<translation id="795667975304826397">Nincs fájl kiválasztva</translation>
-<translation id="1320012872283894746">gyors visszakeresés</translation>
<translation id="7789962463072032349">szüneteltetés</translation>
<translation id="6853785296079745596">feliratok elrejtése</translation>
<translation id="4360991593054037559">Kérjük, érvényes értéket adjon meg. A két legközelebbi érvényes érték <ph name="VALID_VALUE_LOW"/> és <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">Gomb lenyomása</translation>
<translation id="8244226242650769279">interaktív kép</translation>
<translation id="310520048233152454">Adjon meg egy URL-t.</translation>
-<translation id="9039488204461337220">gyors keresés előre</translation>
<translation id="4812940957355064477">Kérjük, adjon meg egy számot.</translation>
<translation id="2548326553472216322">Nincsenek friss keresések</translation>
<translation id="1938124657309484470">Az érték <ph name="MAXIMUM_DATE_OR_TIME"/> vagy azt megelőző kell, hogy legyen.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Kérjük, adjon meg érvényes értéket. A mező hiányos, vagy érvénytelen dátum van megadva.</translation>
<translation id="3040011195152428237">link</translation>
<translation id="1014825444426747588">üres</translation>
-<translation id="3356679314312413792">film visszatekerése 30 másodperccel</translation>
<translation id="9050748414552849310">feliratok megjelenítése</translation>
<translation id="4522570452068850558">Részletek</translation>
<translation id="8451268428117625855">Válasszon egy fájlt.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Kérjük, jelölje be ezt a jelölőnégyzetet, ha tovább kíván haladni.</translation>
<translation id="8534579021159131403">Perc</translation>
<translation id="819205353528511139">film lejátszása teljes képernyős nézetben</translation>
-<translation id="8964020114565522021">Húzza át ide a fájlt</translation>
<translation id="4103419683916926126">Ezredmásodperc</translation>
<translation id="838869780401515933">Megjelölés</translation>
<translation id="2846343701378493991">1024 (Közepes)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Ez a dokumentum jelszóval védett. Kérjük, adja meg a jelszót.</translation>
<translation id="5466621249238537318">Kérjük, válasszon ki egy vagy több fájlt.</translation>
<translation id="9132465097189459683">Más...</translation>
+<translation id="10623998915015855">átkapcsológomb</translation>
<translation id="8750798805984357768">Kérjük, válassza ki az egyik opciót.</translation>
<translation id="7740050170769002709">HTML-tartalom</translation>
<translation id="6692633176391053278">léptető</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> kiválasztva</translation>
<translation id="8541249477527128034">médiavezérlő</translation>
<translation id="2226276347425096477">Kérjük, rövidítse le a szöveget legfeljebb <ph name="MAX_CHARACTERS"/> karakterre (jelenleg <ph name="CURRENT_LENGTH"/> karaktert használ).</translation>
<translation id="6101327004457443354">hangsáv némításának feloldása</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Óra</translation>
<translation id="4664250907885839816">A „<ph name="ATSIGN"/>” utáni rész nem tartalmazhat „<ph name="INVALIDCHARACTER"/>” karaktert.</translation>
<translation id="3450233048674729344">Az érték legyen kisebb vagy egyenlő, mint <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">vissza 30 másodperccel</translation>
<translation id="668171684555832681">Egyéb...</translation>
<translation id="6270583010843788609">film idővonalának indexképe</translation>
<translation id="5641012560118721995">lejátszás szüneteltetése</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> fájl</translation>
<translation id="6643016212128521049">Törlés</translation>
<translation id="7888071071722539607">Kérjük, írjon egy „<ph name="ATSIGN"/>” karaktert az e-mail címbe. A(z) „<ph name="INVALIDADDRESS"/>” címből hiányzik a „<ph name="ATSIGN"/>” jel.</translation>
-<translation id="4851297395436456855">gyors előretekerés</translation>
<translation id="1088086359088493902">Másodperc</translation>
<translation id="3934680773876859118">PDF dokumentum betöltése sikertelen</translation>
<translation id="3632707345189162177">a filmből hátralévő másodpercek</translation>
<translation id="6359256949422175976">a filmidővezérlő indexképe</translation>
<translation id="8597182159515967513">fejléc</translation>
<translation id="6843725295806269523">némítás</translation>
-<translation id="2615751259741237794">visszatérés a valós időhöz</translation>
<translation id="2653659639078652383">Elküldés</translation>
<translation id="3732799496749320381">hh</translation>
-<translation id="4484359737905287537">gyors visszatekerés</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_id.xtb b/chromium/webkit/glue/resources/webkit_strings_id.xtb
index da5adb5a3a2..f6e837de76f 100644
--- a/chromium/webkit/glue/resources/webkit_strings_id.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_id.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="id">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Lainnya...</translation>
-<translation id="2426432199384958866">kembalikan streaming film ke waktu nyata</translation>
<translation id="248395913932153421">Hari</translation>
<translation id="1729654308190250600">Jangan mengosongkan bidang alamat email.</translation>
<translation id="6015796118275082299">Tahun</translation>
-<translation id="9186171386827445984">Memuat dokumen: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> halaman...</translation>
<translation id="1235745349614807883">Hapus Penelusuran Barusan</translation>
<translation id="7223624360433298498">waktu berlalu</translation>
<translation id="1171774979989969504">Masukkan alamat email.</translation>
<translation id="709897737746224366">Sesuaikan dengan format yang diminta.</translation>
<translation id="5048533449481078685">penanda daftar</translation>
<translation id="4202807286478387388">lompati</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/> - <ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Masukkan bagian yang diikuti dengan '<ph name="ATSIGN"/>'. '<ph name="INVALIDADDRESS"/>' tidak lengkap.</translation>
<translation id="2746543609216772311">Tanggal harus <ph name="MINIMUM_DATE_OR_TIME"/> atau setelahnya.</translation>
<translation id="2572483411312390101">main</translation>
@@ -22,9 +19,8 @@
<translation id="7057186640035488495">waktu film</translation>
<translation id="8199524924445686405">tttt</translation>
<translation id="795667975304826397">Tidak ada file yang dipilih</translation>
-<translation id="1320012872283894746">mencari mundur dengan cepat</translation>
<translation id="7789962463072032349">jeda</translation>
-<translation id="6853785296079745596">sembunyikan teks tertutup</translation>
+<translation id="6853785296079745596">sembunyikan teks</translation>
<translation id="4360991593054037559">Masukkan nilai yang valid. Dua nilai valid terdekat adalah <ph name="VALID_VALUE_LOW"/> dan <ph name="VALID_VALUE_HIGHER"/>.</translation>
<translation id="1758486001363313524">Lainnya...</translation>
<translation id="8141602879876242471">Terdapat indeks yang dapat dicari. Masukkan kata kunci penelusuran:</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">tekan</translation>
<translation id="8244226242650769279">gambar peta</translation>
<translation id="310520048233152454">Masukkan URL.</translation>
-<translation id="9039488204461337220">mencari maju dengan cepat</translation>
<translation id="4812940957355064477">Masukkan nomor.</translation>
<translation id="2548326553472216322">Tidak ada penelusuran terkini</translation>
<translation id="1938124657309484470">Tanggal harus <ph name="MAXIMUM_DATE_OR_TIME"/> atau lebih awal.</translation>
@@ -44,13 +39,12 @@
<translation id="901493112792887934">waktu saat ini dalam detik</translation>
<translation id="5164977714490026579">Nilai harus lebih besar daripada atau sama dengan <ph name="MINIMUM"/>.</translation>
<translation id="2247351761944213033">Minggu <ph name="WEEKNUMBER"/>, <ph name="YEAR"/></translation>
-<translation id="7740016676195725605">berhenti menampilkan teks tertutup</translation>
+<translation id="7740016676195725605">berhenti menampilkan teks</translation>
<translation id="5944544982112848342">2048 (Tingkat Tinggi)</translation>
<translation id="3075154866155599887">Masukkan nilai yang valid. Bidang tersebut tidak lengkap atau memiliki tanggal yang tidak valid.</translation>
<translation id="3040011195152428237">tautan</translation>
<translation id="1014825444426747588">kosong</translation>
-<translation id="3356679314312413792">cari film mundur 30 detik</translation>
-<translation id="9050748414552849310">tampilkan teks tertutup</translation>
+<translation id="9050748414552849310">tampilkan teks</translation>
<translation id="4522570452068850558">Detail</translation>
<translation id="8451268428117625855">Pilih file.</translation>
<translation id="8117451130807776954">Minggu ini</translation>
@@ -59,12 +53,11 @@
<translation id="2060505056492490888">'<ph name="DOT"/>' digunakan pada posisi yang salah di '<ph name="INVALIDDOMAIN"/>'.</translation>
<translation id="2674318244760992338">footer</translation>
<translation id="8987927404178983737">Bulan</translation>
-<translation id="8115662671911883373">mulai menampilkan teks tertutup</translation>
+<translation id="8115662671911883373">mulai menampilkan teks</translation>
<translation id="7364796246159120393">Pilih File</translation>
<translation id="2761667185364618470">Centang kotak ini jika Anda ingin melanjutkan.</translation>
<translation id="8534579021159131403">Menit</translation>
<translation id="819205353528511139">putar film dalam mode layar penuh</translation>
-<translation id="8964020114565522021">Tarik file ke sini</translation>
<translation id="4103419683916926126">Milidetik</translation>
<translation id="838869780401515933">centangi</translation>
<translation id="2846343701378493991">1024 (Tingkat Menengah)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Dokumen ini dilindungi sandi. Masukkan sandi.</translation>
<translation id="5466621249238537318">Pilih salah satu atau beberapa file.</translation>
<translation id="9132465097189459683">Lainnya...</translation>
+<translation id="10623998915015855">tombol beralih</translation>
<translation id="8750798805984357768">Pilih salah satu opsi berikut.</translation>
<translation id="7740050170769002709">Konten HTML</translation>
<translation id="6692633176391053278">stepper</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> dipilih</translation>
<translation id="8541249477527128034">kontrol media</translation>
<translation id="2226276347425096477">Pendekkan teks ini menjadi <ph name="MAX_CHARACTERS"/> karakter atau kurang (saat ini Anda menggunakan <ph name="CURRENT_LENGTH"/> karakter).</translation>
<translation id="6101327004457443354">suarakan trek audio</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Jam</translation>
<translation id="4664250907885839816">Bagian setelah '<ph name="ATSIGN"/>' tidak boleh berisi simbol '<ph name="INVALIDCHARACTER"/>'.</translation>
<translation id="3450233048674729344">Nilai harus lebih kecil atau sama dengan <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">mundur 30 detik</translation>
<translation id="668171684555832681">Lainnya...</translation>
<translation id="6270583010843788609">jempol garis waktu film</translation>
<translation id="5641012560118721995">jeda pemutaran</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> file</translation>
<translation id="6643016212128521049">Hapus</translation>
<translation id="7888071071722539607">Sertakan '<ph name="ATSIGN"/>' pada alamat email. '<ph name="INVALIDADDRESS"/>' tidak memiliki '<ph name="ATSIGN"/>'.</translation>
-<translation id="4851297395436456855">maju cepat</translation>
<translation id="1088086359088493902">Detik</translation>
<translation id="3934680773876859118">Gagal memuat dokumen PDF</translation>
<translation id="3632707345189162177">sisa waktu film dalam detik</translation>
<translation id="6359256949422175976">jempol scrubber waktu film</translation>
<translation id="8597182159515967513">kepala</translation>
<translation id="6843725295806269523">bisukan</translation>
-<translation id="2615751259741237794">kembalikan ke waktu nyata</translation>
<translation id="2653659639078652383">Kirim</translation>
<translation id="3732799496749320381">bb</translation>
-<translation id="4484359737905287537">balik cepat</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_it.xtb b/chromium/webkit/glue/resources/webkit_strings_it.xtb
index 369cd1fd4c9..ef6be1affa9 100644
--- a/chromium/webkit/glue/resources/webkit_strings_it.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_it.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="it">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Altro...</translation>
-<translation id="2426432199384958866">ritorna a tempo reale per filmato in streaming</translation>
<translation id="248395913932153421">Giorno</translation>
<translation id="1729654308190250600">Inserisci un indirizzo email valido.</translation>
<translation id="6015796118275082299">Anno</translation>
-<translation id="9186171386827445984">Caricamento del documento in corso: pagine <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/>...</translation>
<translation id="1235745349614807883">Cancella ricerche recenti</translation>
<translation id="7223624360433298498">tempo trascorso</translation>
<translation id="1171774979989969504">Inserisci un indirizzo email.</translation>
<translation id="709897737746224366">Rispetta il formato richiesto.</translation>
<translation id="5048533449481078685">indicatore elenco</translation>
<translation id="4202807286478387388">vai</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Inserisci una parte seguita da &quot;<ph name="ATSIGN"/>&quot;. Il valore &quot;<ph name="INVALIDADDRESS"/>&quot; è incompleto.</translation>
<translation id="2746543609216772311">Il valore deve essere <ph name="MINIMUM_DATE_OR_TIME"/> o successivo.</translation>
<translation id="2572483411312390101">riproduci</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">tempo filmato</translation>
<translation id="8199524924445686405">aaaa</translation>
<translation id="795667975304826397">Nessun file selezionato</translation>
-<translation id="1320012872283894746">cerca velocemente indietro</translation>
<translation id="7789962463072032349">pausa</translation>
<translation id="6853785296079745596">nascondi sottotitoli</translation>
<translation id="4360991593054037559">Inserisci un valore valido. I due valori validi più vicini sono <ph name="VALID_VALUE_LOW"/> e <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">premi</translation>
<translation id="8244226242650769279">image map</translation>
<translation id="310520048233152454">Inserisci un URL.</translation>
-<translation id="9039488204461337220">cerca velocemente in avanti</translation>
<translation id="4812940957355064477">Inserisci un numero.</translation>
<translation id="2548326553472216322">Nessuna ricerca recente</translation>
<translation id="1938124657309484470">Il valore deve essere <ph name="MAXIMUM_DATE_OR_TIME"/> o precedente.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Inserisci un valore valido. Il campo è incompleto o presenta una data non valida.</translation>
<translation id="3040011195152428237">link</translation>
<translation id="1014825444426747588">vuoto</translation>
-<translation id="3356679314312413792">posiziona filmato indietro di 30 secondi</translation>
<translation id="9050748414552849310">mostra sottotitoli</translation>
<translation id="4522570452068850558">Dettagli</translation>
<translation id="8451268428117625855">Seleziona un file.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Seleziona questa casella se intendi procedere.</translation>
<translation id="8534579021159131403">Minuti</translation>
<translation id="819205353528511139">riproduci filmato in modalità a schermo intero</translation>
-<translation id="8964020114565522021">Trascina il file qui</translation>
<translation id="4103419683916926126">Millisecondi</translation>
<translation id="838869780401515933">seleziona</translation>
<translation id="2846343701378493991">1024 (Medium Grade)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Questo documento è protetto da password. Inserisci una password.</translation>
<translation id="5466621249238537318">Seleziona uno o più file.</translation>
<translation id="9132465097189459683">Altro...</translation>
+<translation id="10623998915015855">pulsante di attivazione/disattivazione</translation>
<translation id="8750798805984357768">Seleziona una di queste opzioni.</translation>
<translation id="7740050170769002709">Contenuti HTML</translation>
<translation id="6692633176391053278">stepper</translation>
+<translation id="4975562563186953947">Elementi selezionati: <ph name="SELECTED_COUNT"/></translation>
<translation id="8541249477527128034">controllo contenuti multimediali</translation>
<translation id="2226276347425096477">Riduci questo testo a <ph name="MAX_CHARACTERS"/> caratteri o meno (attualmente stai utilizzando <ph name="CURRENT_LENGTH"/> caratteri).</translation>
<translation id="6101327004457443354">riattiva traccia audio</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Orario</translation>
<translation id="4664250907885839816">Una parte che segue &quot;<ph name="ATSIGN"/>&quot; non deve contenere il simbolo &quot;<ph name="INVALIDCHARACTER"/>&quot;.</translation>
<translation id="3450233048674729344">Il valore deve essere inferiore o uguale a <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">indietro di 30 secondi</translation>
<translation id="668171684555832681">Altro...</translation>
<translation id="6270583010843788609">cursore sequenza temporale filmato</translation>
<translation id="5641012560118721995">sospendi riproduzione</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> file</translation>
<translation id="6643016212128521049">Cancella</translation>
<translation id="7888071071722539607">Aggiungi un simbolo &quot;<ph name="ATSIGN"/>&quot; nell'indirizzo email. In &quot;<ph name="INVALIDADDRESS"/>&quot; manca un simbolo &quot;<ph name="ATSIGN"/>&quot;.</translation>
-<translation id="4851297395436456855">avanzamento rapido</translation>
<translation id="1088086359088493902">Secondi</translation>
<translation id="3934680773876859118">Caricamento del documento PDF non riuscito</translation>
<translation id="3632707345189162177">numero di secondi di filmato rimanenti</translation>
<translation id="6359256949422175976">cursore dispositivo di scorrimento tempo filmato</translation>
<translation id="8597182159515967513">intestazione</translation>
<translation id="6843725295806269523">disattiva audio</translation>
-<translation id="2615751259741237794">torna a tempo reale</translation>
<translation id="2653659639078652383">Invia</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">riavvolgimento rapido</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_iw.xtb b/chromium/webkit/glue/resources/webkit_strings_iw.xtb
index 9546a05c41b..8327556220b 100644
--- a/chromium/webkit/glue/resources/webkit_strings_iw.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_iw.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="iw">
<translation id="4763480195061959176">סרטוני וידאו</translation>
<translation id="5843503607508392247">אחר...</translation>
-<translation id="2426432199384958866">החזר סרט בהזרמה לזמן אמת</translation>
<translation id="248395913932153421">יום</translation>
<translation id="1729654308190250600">הזן ערך נדרש בשדה של כתובת הדוא&quot;ל.</translation>
<translation id="6015796118275082299">שנה</translation>
-<translation id="9186171386827445984">טוען מסמך: דפים <ph name="NUMBER_OF_PAGES"/>/<ph name="PAGE_NUMBER"/>...</translation>
<translation id="1235745349614807883">הסר חיפושים אחרונים</translation>
<translation id="7223624360433298498">זמן שחלף</translation>
<translation id="1171774979989969504">הזן כתובת דוא&quot;ל.</translation>
<translation id="709897737746224366">התאם את הפורמט המבוקש.</translation>
<translation id="5048533449481078685">סמן רשימה</translation>
<translation id="4202807286478387388">קפוץ</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">הזן חלק ולאחריו '<ph name="ATSIGN"/>'‏. השדה '<ph name="INVALIDADDRESS"/>' אינו מלא.</translation>
<translation id="2746543609216772311">על הערך להיות <ph name="MINIMUM_DATE_OR_TIME"/> ומעלה.</translation>
<translation id="2572483411312390101">הפעל</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">משך הסרט</translation>
<translation id="8199524924445686405">yyyy</translation>
<translation id="795667975304826397">לא נבחר קובץ</translation>
-<translation id="1320012872283894746">הרץ במהירות אחורה</translation>
<translation id="7789962463072032349">השהה</translation>
<translation id="6853785296079745596">הסתר כתוביות סגורות</translation>
<translation id="4360991593054037559">הזן ערך חוקי. שני הערכים החוקיים הקרובים ביותר הם <ph name="VALID_VALUE_LOW"/> ו-<ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">לחץ</translation>
<translation id="8244226242650769279">מפת תמונות</translation>
<translation id="310520048233152454">הזן כתובת אתר.</translation>
-<translation id="9039488204461337220">הרץ קדימה במהירות</translation>
<translation id="4812940957355064477">הזן מספר.</translation>
<translation id="2548326553472216322">אין חיפושים אחרונים</translation>
<translation id="1938124657309484470">על הערך להיות <ph name="MAXIMUM_DATE_OR_TIME"/> או מוקדם יותר.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">הזן ערך חוקי. השדה ריק או שהוא מכיל תאריך לא חוקי.</translation>
<translation id="3040011195152428237">קישור</translation>
<translation id="1014825444426747588">ריק</translation>
-<translation id="3356679314312413792">הרץ את הסרט אחורה 30 שניות</translation>
<translation id="9050748414552849310">הצג כתוביות סגורות</translation>
<translation id="4522570452068850558">פרטים</translation>
<translation id="8451268428117625855">בחר קובץ.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">סמן תיבה זו אם אתה רוצה להמשיך.</translation>
<translation id="8534579021159131403">דקות</translation>
<translation id="819205353528511139">הפעל את הסרט במצב מסך מלא</translation>
-<translation id="8964020114565522021">גרור את הקובץ לכאן</translation>
<translation id="4103419683916926126">אלפיות שנייה</translation>
<translation id="838869780401515933">סמן</translation>
<translation id="2846343701378493991">1024 (Medium Grade)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">מסמך זה מוגן באמצעות סיסמה. הזן סיסמה.</translation>
<translation id="5466621249238537318">בחר קובץ אחד או יותר.</translation>
<translation id="9132465097189459683">אחר...</translation>
+<translation id="10623998915015855">לחצן החלפה</translation>
<translation id="8750798805984357768">בחר אחת מהאפשרויות הבאות.</translation>
<translation id="7740050170769002709">‏תוכן HTML</translation>
<translation id="6692633176391053278">פקד חצים</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> נבחרו</translation>
<translation id="8541249477527128034">שליטה במדיה</translation>
<translation id="2226276347425096477">קצר טקסט זה ל-<ph name="MAX_CHARACTERS"/> תווים או פחות (אתה משתמש כעת ב-<ph name="CURRENT_LENGTH"/> תווים).</translation>
<translation id="6101327004457443354">בטל השתקה של רצועת אודיו</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">שעות</translation>
<translation id="4664250907885839816">חלק ולאחריו '<ph name="ATSIGN"/>' לא אמור לכלול את הסמל '<ph name="INVALIDCHARACTER"/>'.</translation>
<translation id="3450233048674729344">הערך חייב להיות קטן מ-<ph name="MAXIMUM"/> או שווה לו.</translation>
-<translation id="3471999216963526757">חזור אחורה 30 שניות</translation>
<translation id="668171684555832681">אחר...</translation>
<translation id="6270583010843788609">תמונה ממוזערת של משך סרט</translation>
<translation id="5641012560118721995">השהה הפעלה</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> קבצים</translation>
<translation id="6643016212128521049">נקה</translation>
<translation id="7888071071722539607">כלול '<ph name="ATSIGN"/>' בכתובת הדוא&quot;ל. ב-'<ph name="INVALIDADDRESS"/>' חסר '<ph name="ATSIGN"/>'.</translation>
-<translation id="4851297395436456855">הרץ קדימה</translation>
<translation id="1088086359088493902">שניות</translation>
<translation id="3934680773876859118">‏הטעינה של מסמך PDF נכשלה</translation>
<translation id="3632707345189162177">מספר שניות שנותרו עד לסיום הסרט</translation>
<translation id="6359256949422175976">תמונה ממוזערת של מסתיר זמן סרט</translation>
<translation id="8597182159515967513">כותרת</translation>
<translation id="6843725295806269523">השתק</translation>
-<translation id="2615751259741237794">חזור לזמן אמת</translation>
<translation id="2653659639078652383">שלח</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">הרץ אחורה</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_ja.xtb b/chromium/webkit/glue/resources/webkit_strings_ja.xtb
index 00be052ed42..50a52fc5004 100644
--- a/chromium/webkit/glue/resources/webkit_strings_ja.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_ja.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="ja">
<translation id="4763480195061959176">動画</translation>
<translation id="5843503607508392247">その他...</translation>
-<translation id="2426432199384958866">ストリーミング映画をリアル タイムに戻す</translation>
<translation id="248395913932153421">日</translation>
<translation id="1729654308190250600">メール アドレスを入力してください。</translation>
<translation id="6015796118275082299">年</translation>
-<translation id="9186171386827445984">ドキュメントの読み込み中: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> ページ...</translation>
<translation id="1235745349614807883">最近の検索履歴を消去</translation>
<translation id="7223624360433298498">経過時間</translation>
<translation id="1171774979989969504">メール アドレスを入力してください。</translation>
<translation id="709897737746224366">指定されている形式で入力してください。</translation>
<translation id="5048533449481078685">リスト マーカー</translation>
<translation id="4202807286478387388">ジャンプ</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">「<ph name="ATSIGN"/>」の前の文字列を入力してください。「<ph name="INVALIDADDRESS"/>」は完全なメール アドレスではありません。</translation>
<translation id="2746543609216772311"><ph name="MINIMUM_DATE_OR_TIME"/> 以降の値を指定する必要があります。</translation>
<translation id="2572483411312390101">再生</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">上映時間</translation>
<translation id="8199524924445686405"> 年 </translation>
<translation id="795667975304826397">選択されていません</translation>
-<translation id="1320012872283894746">シークで巻き戻し</translation>
<translation id="7789962463072032349">一時停止</translation>
<translation id="6853785296079745596">クローズド キャプションを非表示</translation>
<translation id="4360991593054037559">有効な値を入力してください。有効な値として最も近いのは <ph name="VALID_VALUE_LOW"/> と <ph name="VALID_VALUE_HIGHER"/> です。</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">押す</translation>
<translation id="8244226242650769279">イメージ マップ</translation>
<translation id="310520048233152454">URL を入力してください。</translation>
-<translation id="9039488204461337220">シークで早送り</translation>
<translation id="4812940957355064477">数字を入力してください。</translation>
<translation id="2548326553472216322">最近の検索はありません</translation>
<translation id="1938124657309484470"><ph name="MAXIMUM_DATE_OR_TIME"/> 以前の値を指定する必要があります。</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">有効な値を入力してください。フィールドの入力が不完全か、日付が無効です。</translation>
<translation id="3040011195152428237">リンク</translation>
<translation id="1014825444426747588">空白</translation>
-<translation id="3356679314312413792">30 秒前までシーク</translation>
<translation id="9050748414552849310">クローズド キャプションを表示</translation>
<translation id="4522570452068850558">詳細</translation>
<translation id="8451268428117625855">ファイルを選択してください。</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">次に進むにはこのチェックボックスをオンにしてください。</translation>
<translation id="8534579021159131403">分</translation>
<translation id="819205353528511139">全画面表示モードで再生</translation>
-<translation id="8964020114565522021">ファイルをここにドラッグ</translation>
<translation id="4103419683916926126">ミリ秒</translation>
<translation id="838869780401515933">チェックを付ける</translation>
<translation id="2846343701378493991">1024 (中)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">このドキュメントはパスワードで保護されています。パスワードを入力してください。</translation>
<translation id="5466621249238537318">1 つ以上のファイルを選択してください。</translation>
<translation id="9132465097189459683">その他...</translation>
+<translation id="10623998915015855">切り替えボタン</translation>
<translation id="8750798805984357768">これらのオプションから 1 つ選択してください。</translation>
<translation id="7740050170769002709">HTML コンテンツ</translation>
<translation id="6692633176391053278">ステッパー</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> 件選択</translation>
<translation id="8541249477527128034">メディア管理</translation>
<translation id="2226276347425096477">このテキストを半角 <ph name="MAX_CHARACTERS"/> 文字以下にしてください(現時点で半角 <ph name="CURRENT_LENGTH"/> 文字です)。</translation>
<translation id="6101327004457443354">音声トラックのミュートを解除</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">時間</translation>
<translation id="4664250907885839816">「<ph name="ATSIGN"/>」に続く文字列に記号「<ph name="INVALIDCHARACTER"/>」を使用しないでください。</translation>
<translation id="3450233048674729344">値は <ph name="MAXIMUM"/> 以下にする必要があります。</translation>
-<translation id="3471999216963526757">30 秒戻る</translation>
<translation id="668171684555832681">その他...</translation>
<translation id="6270583010843788609">タイムラインのサムネイル</translation>
<translation id="5641012560118721995">再生を一時停止</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> ファイル</translation>
<translation id="6643016212128521049">クリア</translation>
<translation id="7888071071722539607">メール アドレスに「<ph name="ATSIGN"/>」を挿入してください。「<ph name="INVALIDADDRESS"/>」内に「<ph name="ATSIGN"/>」がありません。</translation>
-<translation id="4851297395436456855">早送り</translation>
<translation id="1088086359088493902">秒</translation>
<translation id="3934680773876859118">PDF ドキュメントを読み込むことができませんでした</translation>
<translation id="3632707345189162177">残り時間(秒)</translation>
<translation id="6359256949422175976">シークバーのサムネイル</translation>
<translation id="8597182159515967513">見出し</translation>
<translation id="6843725295806269523">ミュート</translation>
-<translation id="2615751259741237794">リアル タイムに戻る</translation>
<translation id="2653659639078652383">送信</translation>
<translation id="3732799496749320381">月</translation>
-<translation id="4484359737905287537">巻き戻し</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_kn.xtb b/chromium/webkit/glue/resources/webkit_strings_kn.xtb
index 87d1b6112dd..ec44917a5c2 100644
--- a/chromium/webkit/glue/resources/webkit_strings_kn.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_kn.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="kn">
<translation id="4763480195061959176">ವೀಡಿಯೊ</translation>
<translation id="5843503607508392247">ಇತರೆ...</translation>
-<translation id="2426432199384958866">ಸ್ಟ್ರೀಮಿಂಗ್ ಚಲನಚಿತ್ರವನ್ನು ನೈಜ ಸಮಯಕ್ಕೆ ಹಿಂತಿರುಗಿಸಿ</translation>
<translation id="248395913932153421">ದಿನ</translation>
<translation id="1729654308190250600">ಖಾಲಿ-ಅಲ್ಲದ ಇಮೇಲ್ ವಿಳಾಸವನ್ನು ನಮೂದಿಸಿ.</translation>
<translation id="6015796118275082299">ವರ್ಷ</translation>
-<translation id="9186171386827445984">ಲೋಡಿಂಗ್ ಡಾಕ್ಯುಮೆಂಟ್: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> ಪುಟಗಳು...</translation>
<translation id="1235745349614807883">ಇತ್ತೀಚಿನ ಹುಡುಕಾಟವನ್ನು ತೆರವುಗೊಳಿಸಿ</translation>
<translation id="7223624360433298498">ಕಳೆದುಹೋದ ಸಮಯ</translation>
<translation id="1171774979989969504">ದಯವಿಟ್ಟು ಇಮೇಲ್ ವಿಳಾಸವನ್ನು ನಮೂದಿಸಿ.</translation>
<translation id="709897737746224366">ದಯವಿಟ್ಟು ವಿನಂತಿಸಿದ ಸ್ವರೂಪವನ್ನು ಹೊಂದಿಸಿ.</translation>
<translation id="5048533449481078685">ಪಟ್ಟಿ ಗುರುತು</translation>
<translation id="4202807286478387388">ಹಾರು</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">'<ph name="ATSIGN"/>' ನಂತರದ ಭಾಗವನ್ನು ನಮೂದಿಸಿ. '<ph name="INVALIDADDRESS"/>' ಅಪೂರ್ಣವಾಗಿದೆ.</translation>
<translation id="2746543609216772311">ಮೌಲ್ಯವು <ph name="MINIMUM_DATE_OR_TIME"/> ಅಥವಾ ನಂತರದ್ದಾಗಿರಬೇಕು.</translation>
<translation id="2572483411312390101">ಪ್ಲೇ ಮಾಡಿ</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">ಚಲನಚಿತ್ರ ಸಮಯ</translation>
<translation id="8199524924445686405">ವವವವ</translation>
<translation id="795667975304826397">ಯಾವುದೇ ಫೈಲ್ ಆಯ್ಕೆ ಮಾಡಿಲ್ಲ</translation>
-<translation id="1320012872283894746">ತ್ವರಿತವಾಗಿ ಹಿಂದಕ್ಕೆ ಪಡೆಯಿರಿ</translation>
<translation id="7789962463072032349">ವಿರಾಮ</translation>
<translation id="6853785296079745596">ಮುಚ್ಚಿರುವ ಶೀರ್ಷಿಕೆಗಳನ್ನು ಮರೆಮಾಡಿ</translation>
<translation id="4360991593054037559">ಮಾನ್ಯವಾದ ಮೌಲ್ಯವನ್ನು ನಮೂದಿಸಿ. <ph name="VALID_VALUE_LOW"/> ಮತ್ತು <ph name="VALID_VALUE_HIGHER"/> ಎರಡು ಹತ್ತಿರದ ಮಾನ್ಯ ಮೌಲ್ಯಗಳಾಗಿವೆ.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">ಒತ್ತಿ</translation>
<translation id="8244226242650769279">ಇಮೇಜ್ ನಕ್ಷೆ</translation>
<translation id="310520048233152454">ದಯವಿಟ್ಟು URL ಅನ್ನು ನಮೂದಿಸಿ.</translation>
-<translation id="9039488204461337220">ತ್ವರಿತವಾಗಿ ಮುಂದೆ ಪಡೆಯಿರಿ</translation>
<translation id="4812940957355064477">ದಯವಿಟ್ಟು ಸಂಖ್ಯೆಯನ್ನು ನಮೂದಿಸಿ.</translation>
<translation id="2548326553472216322">ಇತ್ತೀಚಿನ ಹುಡುಕಾಟಗಳು ಇಲ್ಲ</translation>
<translation id="1938124657309484470">ಮೌಲ್ಯವು <ph name="MAXIMUM_DATE_OR_TIME"/> ಅಥವಾ ಹಿಂದಿನದ್ದಾಗಿರಬೇಕು.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">ದಯವಿಟ್ಟು ಮಾನ್ಯ ಮೌಲ್ಯವನ್ನು ನಮೂದಿಸಿ. ಕ್ಷೇತ್ರವು ಅಪೂರ್ಣವಾಗಿದೆ ಅಥವಾ ಅಮಾನ್ಯ ದಿನಾಂಕವನ್ನು ಹೊಂದಿದೆ.</translation>
<translation id="3040011195152428237">ಲಿಂಕ್</translation>
<translation id="1014825444426747588">ಖಾಲಿ</translation>
-<translation id="3356679314312413792">ಚಲನಚಿತ್ರವನ್ನು 30 ಸೆಕೆಂಡ್‌ಗಳು ಹಿಂದಕ್ಕೆ ಪಡೆಯಿರಿ</translation>
<translation id="9050748414552849310">ಮುಚ್ಚಿರುವ ಶೀರ್ಷಿಕೆಗಳನ್ನು ತೋರಿಸಿ</translation>
<translation id="4522570452068850558">ವಿವರಗಳು</translation>
<translation id="8451268428117625855">ದಯವಿಟ್ಟು ಫೈಲ್ ಆಯ್ಕೆಮಾಡಿ.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">ನೀವು ಮುಂದುವರೆಯಬೇಕಾದರೆ ದಯವಿಟ್ಟು ಈ ಬಾಕ್ಸ್ ಅನ್ನು ಪರೀಕ್ಷಿಸಿ.</translation>
<translation id="8534579021159131403">ನಿಮಿಷಗಳು</translation>
<translation id="819205353528511139">ಪೂರ್ಣ ಪರದೆಯ ಮೋಡ್‌‌ನಲ್ಲಿ ಚಲನಚಿತ್ರವನ್ನು ಪ್ಲೇ ಮಾಡಿ</translation>
-<translation id="8964020114565522021">ಇಲ್ಲಿ ಫೈಲ್ ಅನ್ನು ಎಳೆಯಿರಿ</translation>
<translation id="4103419683916926126">ಮಿಲಿಸೆಕೆಂಡುಗಳು</translation>
<translation id="838869780401515933">ಪರಿಶೀಲಿಸು</translation>
<translation id="2846343701378493991">1024 (ಮದ್ಯಮ ಶ್ರೇಣಿ)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">ಈ ಡಾಕ್ಯುಮೆಂಟ್‌ ಅನ್ನು ಪಾಸ್‌ವರ್ಡ್‌ನಿಂದ ರಕ್ಷಿಸಲಾಗಿದೆ. ದಯವಿಟ್ಟು ಪಾಸ್‌ವರ್ಡ್ ಅನ್ನು ನಮೂದಿಸಿ.</translation>
<translation id="5466621249238537318">ದಯವಿಟ್ಟು ಒಂದು ಅಥವಾ ಹೆಚ್ಚು ಫೈಲ್‌ಗಳನ್ನು ಆಯ್ಕೆಮಾಡಿ.</translation>
<translation id="9132465097189459683">ಇತರೆ...</translation>
+<translation id="10623998915015855">ಟಾಗಲ್ ಬಟನ್</translation>
<translation id="8750798805984357768">ದಯವಿಟ್ಟು ಈ ಕೆಳಗಿನ ಆಯ್ಕೆಗಳಲ್ಲಿ ಒಂದನ್ನು ಆರಿಸಿ.</translation>
<translation id="7740050170769002709">HTML ವಿಷಯ</translation>
<translation id="6692633176391053278">ಸ್ಟೀಪರ್</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> ಆಯ್ಕೆ ಮಾಡಲಾಗಿದೆ</translation>
<translation id="8541249477527128034">ಮಾಧ್ಯಮ ನಿಯಂತ್ರಣ</translation>
<translation id="2226276347425096477">ದಯವಿಟ್ಟು ಈ ಪಠ್ಯವನ್ನು <ph name="MAX_CHARACTERS"/> ಅಕ್ಷರಗಳಿಗೆ ಅಥವಾ ಅದಕ್ಕಿಂತಲೂ ಕಡಿಮೆಗೆ ಸೀಮಿತಗೊಳಿಸಿ (ನೀವು ಪ್ರಸ್ತುತವಾಗಿ <ph name="CURRENT_LENGTH"/> ಅಕ್ಷರಗಳನ್ನು ಬಳಸುತ್ತಿರುವಿರಿ).</translation>
<translation id="6101327004457443354">ಆಡಿಯೋ ಟ್ರ್ಯಾಕ್ ಅನ್‌ಮ್ಯೂಟ್ ಮಾಡು</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">ಗಂಟೆಗಳು</translation>
<translation id="4664250907885839816">'<ph name="ATSIGN"/>' ನಂತರದ ಭಾಗವು '<ph name="INVALIDCHARACTER"/>' ಚಿಹ್ನೆಯನ್ನು ಒಳಗೊಂಡಿರಬಾರದು.</translation>
<translation id="3450233048674729344">ಮೌಲ್ಯವು <ph name="MAXIMUM"/> ಕ್ಕೆ ಸಮನಾಗಿರಬಹುದು ಅಥವಾ ಅದಕ್ಕಿಂತಲೂ ಕಡಿಮೆ ಆಗಿರಬಹುದು.</translation>
-<translation id="3471999216963526757">30 ಸೆಕೆಂಡ್‌ಗಳಲ್ಲಿ ಮರಳಿ</translation>
<translation id="668171684555832681">ಇತರೆ...</translation>
<translation id="6270583010843788609">ಚಲನಚಿತ್ರ ಸಮಯಮಿತಿಯ ಥಂಬ್‌</translation>
<translation id="5641012560118721995">ಪ್ಲೇಬ್ಯಾಕ್ ವಿರಾಮಗೊಳಿಸು</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> ಫೈಲ್‌ಗಳು</translation>
<translation id="6643016212128521049">ತೆರವುಗೊಳಿಸಿ</translation>
<translation id="7888071071722539607">ಇಮೇಲ್ ವಿಳಾಸದಲ್ಲಿ ಒಂದು '<ph name="ATSIGN"/>' ಅನ್ನು ಸೇರಿಸಿ. '<ph name="ATSIGN"/>' ನಲ್ಲಿ '<ph name="INVALIDADDRESS"/>' ಕಾಣೆಯಾಗಿದೆ.</translation>
-<translation id="4851297395436456855">ವೇಗವಾಗಿ ಮುಂದಕ್ಕೆ</translation>
<translation id="1088086359088493902">ಸೆಕೆಂಡುಗಳು</translation>
<translation id="3934680773876859118">PDF ಡಾಕ್ಯುಮೆಂಟ್ ಅನ್ನು ಲೋಡ್ ಮಾಡಲು ವಿಫಲವಾಗಿದೆ</translation>
<translation id="3632707345189162177">ಚಲನಚಿತ್ರ ಬಾಕಿ ಉಳಿದಿರುವ ಸೆಕುಂಡುಗಳ ಸಂಖ್ಯೆ</translation>
<translation id="6359256949422175976">ಚಲನಚಿತ್ರ ಸಮಯ ಸ್ಕ್ರಬ್ಬರ್ ಥಂಬ್</translation>
<translation id="8597182159515967513">ಶೀರ್ಷಿಕೆ</translation>
<translation id="6843725295806269523">ಮ್ಯೂಟ್</translation>
-<translation id="2615751259741237794">ನೈಜ ಸಮಯಕ್ಕೆ ಹಿಂತಿರುಗು</translation>
<translation id="2653659639078652383">ಸಲ್ಲಿಸು</translation>
<translation id="3732799496749320381">ಮಿಮೀ</translation>
-<translation id="4484359737905287537">ವೇಗವಾಗಿ ಹಿಂದಕ್ಕೆ</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_ko.xtb b/chromium/webkit/glue/resources/webkit_strings_ko.xtb
index c5b4bdc7694..2d22e6b703b 100644
--- a/chromium/webkit/glue/resources/webkit_strings_ko.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_ko.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="ko">
<translation id="4763480195061959176">동영상</translation>
<translation id="5843503607508392247">다른 시간...</translation>
-<translation id="2426432199384958866">스트리밍 영화를 실시간 방송으로 되돌리기</translation>
<translation id="248395913932153421">일</translation>
<translation id="1729654308190250600">비어 있지 않은 이메일 주소를 입력해 주세요.</translation>
<translation id="6015796118275082299">연도</translation>
-<translation id="9186171386827445984">문서 로드 중: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/>페이지</translation>
<translation id="1235745349614807883">최근 검색 삭제</translation>
<translation id="7223624360433298498">경과 시간</translation>
<translation id="1171774979989969504">이메일 주소를 입력하세요.</translation>
<translation id="709897737746224366">요청한 형식과 일치시키세요.</translation>
<translation id="5048533449481078685">목록 표시기</translation>
<translation id="4202807286478387388">건너뛰기</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">'<ph name="ATSIGN"/>' 앞 부분을 입력해 주세요. '<ph name="INVALIDADDRESS"/>'(이)가 완전하지 않습니다.</translation>
<translation id="2746543609216772311">값은 <ph name="MINIMUM_DATE_OR_TIME"/> 이후여야 합니다.</translation>
<translation id="2572483411312390101">재생</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">영화 시간</translation>
<translation id="8199524924445686405">연도</translation>
<translation id="795667975304826397">선택된 파일 없음</translation>
-<translation id="1320012872283894746">뒤로 빠르게 탐색</translation>
<translation id="7789962463072032349">일시중지</translation>
<translation id="6853785296079745596">캡션 숨기기</translation>
<translation id="4360991593054037559">유효한 값을 입력해 주세요. 가장 근접한 유효 값 2개는 <ph name="VALID_VALUE_LOW"/> 및 <ph name="VALID_VALUE_HIGHER"/>입니다.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">누르기</translation>
<translation id="8244226242650769279">이미지 지도</translation>
<translation id="310520048233152454">URL을 입력하세요.</translation>
-<translation id="9039488204461337220">앞으로 빠르게 탐색</translation>
<translation id="4812940957355064477">숫자를 입력하세요.</translation>
<translation id="2548326553472216322">최근 수행된 검색 없음</translation>
<translation id="1938124657309484470">값은 <ph name="MAXIMUM_DATE_OR_TIME"/> 이전이어야 합니다.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">유효한 값을 입력하세요. 입력을 완료하지 않았거나 날짜가 잘못되었습니다.</translation>
<translation id="3040011195152428237">링크</translation>
<translation id="1014825444426747588">비어 있음</translation>
-<translation id="3356679314312413792">30초 뒤로 영화 탐색</translation>
<translation id="9050748414552849310">캡션 표시</translation>
<translation id="4522570452068850558">세부정보</translation>
<translation id="8451268428117625855">파일을 선택하세요.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">계속하려면 이 확인란을 선택하세요.</translation>
<translation id="8534579021159131403">분</translation>
<translation id="819205353528511139">전체화면 모드로 영화 재생</translation>
-<translation id="8964020114565522021">여기로 파일 드래그</translation>
<translation id="4103419683916926126">밀리초</translation>
<translation id="838869780401515933">선택</translation>
<translation id="2846343701378493991">1024(중간 등급)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">문서가 비밀번호로 보호되고 있습니다. 비밀번호를 입력하세요.</translation>
<translation id="5466621249238537318">파일을 한 개 이상 선택하세요.</translation>
<translation id="9132465097189459683">다른 달...</translation>
+<translation id="10623998915015855">전환 버튼</translation>
<translation id="8750798805984357768">다음 옵션 중 하나를 선택하세요.</translation>
<translation id="7740050170769002709">HTML 콘텐츠</translation>
<translation id="6692633176391053278">증감자</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/>개 선택됨</translation>
<translation id="8541249477527128034">미디어 컨트롤</translation>
<translation id="2226276347425096477">이 텍스트를 <ph name="MAX_CHARACTERS"/>자 이하로 줄이세요(현재 <ph name="CURRENT_LENGTH"/>자 사용 중).</translation>
<translation id="6101327004457443354">오디오 트랙 음소거 해제</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">시간</translation>
<translation id="4664250907885839816">'<ph name="ATSIGN"/>' 다음 부분에 '<ph name="INVALIDCHARACTER"/>' 기호가 포함되면 안됩니다.</translation>
<translation id="3450233048674729344">값은 <ph name="MAXIMUM"/> 이하여야 합니다.</translation>
-<translation id="3471999216963526757">30초 뒤로</translation>
<translation id="668171684555832681">기타...</translation>
<translation id="6270583010843788609">영화 타임라인 썸</translation>
<translation id="5641012560118721995">재생 일시중지</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423">파일 <ph name="NUMBER_OF_FILES"/>개</translation>
<translation id="6643016212128521049">삭제</translation>
<translation id="7888071071722539607">이메일 주소에 '<ph name="ATSIGN"/>'를 포함해 주세요. '<ph name="INVALIDADDRESS"/>'에 '<ph name="ATSIGN"/>'가 없습니다.</translation>
-<translation id="4851297395436456855">빨리 감기</translation>
<translation id="1088086359088493902">초</translation>
<translation id="3934680773876859118">PDF 문서를 로드하지 못했습니다.</translation>
<translation id="3632707345189162177">영화 남은 시간(초)</translation>
<translation id="6359256949422175976">영화 시간 스크러버 썸</translation>
<translation id="8597182159515967513">항목</translation>
<translation id="6843725295806269523">음소거</translation>
-<translation id="2615751259741237794">실시간 방송으로 돌아가기</translation>
<translation id="2653659639078652383">제출</translation>
<translation id="3732799496749320381">월</translation>
-<translation id="4484359737905287537">역방향으로 빨리 감기</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_lt.xtb b/chromium/webkit/glue/resources/webkit_strings_lt.xtb
index 7f067950160..56505b97a2a 100644
--- a/chromium/webkit/glue/resources/webkit_strings_lt.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_lt.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="lt">
<translation id="4763480195061959176">vaizdo įrašas</translation>
<translation id="5843503607508392247">Kita...</translation>
-<translation id="2426432199384958866">transliuojamą vaizdo įrašą grąžinti į realųjį laiką</translation>
<translation id="248395913932153421">Diena</translation>
<translation id="1729654308190250600">Įveskite el. pašto adresą (nepalikite lauko tuščio).</translation>
<translation id="6015796118275082299">Metai</translation>
-<translation id="9186171386827445984">Įkeliamas dokumentas: <ph name="PAGE_NUMBER"/> / <ph name="NUMBER_OF_PAGES"/> psl...</translation>
<translation id="1235745349614807883">Išvalyti pastarąsias paieškas</translation>
<translation id="7223624360433298498">praėjęs laikas</translation>
<translation id="1171774979989969504">Įveskite el. pašto adresą.</translation>
<translation id="709897737746224366">Priderinkite reikalaujamą formatą.</translation>
<translation id="5048533449481078685">sąrašo žymeklis</translation>
<translation id="4202807286478387388">peršokti</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Įveskite el. pašto adreso dalį iki „<ph name="ATSIGN"/>“. „<ph name="INVALIDADDRESS"/>“ nėra visas el. pašto adresas.</translation>
<translation id="2746543609216772311">Vertė turi būti <ph name="MINIMUM_DATE_OR_TIME"/> ar vėlesnė data.</translation>
<translation id="2572483411312390101">paleisti</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">filmo laikas</translation>
<translation id="8199524924445686405">mmmm</translation>
<translation id="795667975304826397">Nepasirinktas joks failas</translation>
-<translation id="1320012872283894746">greitai eiti atgal</translation>
<translation id="7789962463072032349">pristabdyti</translation>
<translation id="6853785296079745596">slėpti uždaras antraštes</translation>
<translation id="4360991593054037559">Įveskite galiojančią vertę. Dvi artimiausios vertės yra <ph name="VALID_VALUE_LOW"/> ir <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">paspausti</translation>
<translation id="8244226242650769279">paveikslėlio žemėlapis</translation>
<translation id="310520048233152454">Įveskite URL.</translation>
-<translation id="9039488204461337220">greitai eiti pirmyn</translation>
<translation id="4812940957355064477">Įveskite skaičių.</translation>
<translation id="2548326553472216322">Pastaruoju metu paieškų nevykdyta</translation>
<translation id="1938124657309484470">Vertė turi būti <ph name="MAXIMUM_DATE_OR_TIME"/> ar ankstesnė data.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Įveskite tinkamą vertę. Laukas užpildytas nevisiškai arba įvesta netinkama data.</translation>
<translation id="3040011195152428237">nuoroda</translation>
<translation id="1014825444426747588">tuščia</translation>
-<translation id="3356679314312413792">atsukti filmą atgal 30 sek.</translation>
<translation id="9050748414552849310">rodyti uždaras antraštes</translation>
<translation id="4522570452068850558">Išsami informacija</translation>
<translation id="8451268428117625855">Pasirinkite failą.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Jei norite tęsti, pažymėkite šį laukelį.</translation>
<translation id="8534579021159131403">Minutės</translation>
<translation id="819205353528511139">paleisti filmą viso ekrano režimu</translation>
-<translation id="8964020114565522021">Vilkite failą čia</translation>
<translation id="4103419683916926126">Milisekundės</translation>
<translation id="838869780401515933">tikrinti</translation>
<translation id="2846343701378493991">1024 (vidutinio lygio)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Šis dokumentas apsaugotas slaptažodžiu. Įveskite slaptažodį.</translation>
<translation id="5466621249238537318">Pasirinkite bent vieną failą.</translation>
<translation id="9132465097189459683">Kita...</translation>
+<translation id="10623998915015855">perjungimo mygtukas</translation>
<translation id="8750798805984357768">Pasirinkite vieną iš šių parinkčių.</translation>
<translation id="7740050170769002709">HTML turinys</translation>
<translation id="6692633176391053278">ėjimo aukštyn / žemyn valdiklis</translation>
+<translation id="4975562563186953947">Pasirinkta: <ph name="SELECTED_COUNT"/></translation>
<translation id="8541249477527128034">medijos valdiklis</translation>
<translation id="2226276347425096477">Sutrumpinkite šį tekstą iki <ph name="MAX_CHARACTERS"/> simb. ar mažiau (šiuo metu naudojate <ph name="CURRENT_LENGTH"/> simb.).</translation>
<translation id="6101327004457443354">įjungti garso įrašo takelio garsą</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Valandos</translation>
<translation id="4664250907885839816">Po „<ph name="ATSIGN"/>“ esančioje dalyje neturėtų būti simbolio „<ph name="INVALIDCHARACTER"/>“.</translation>
<translation id="3450233048674729344">Vertė turi būti <ph name="MAXIMUM"/> arba mažesnė.</translation>
-<translation id="3471999216963526757">atgal 30 sek.</translation>
<translation id="668171684555832681">Kita...</translation>
<translation id="6270583010843788609">filmo laiko juostos miniatiūra</translation>
<translation id="5641012560118721995">pristabdyti atkūrimą</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> failai (-ų)</translation>
<translation id="6643016212128521049">Išvalyti</translation>
<translation id="7888071071722539607">Į el. pašto adresą įtraukite „<ph name="ATSIGN"/>“. „<ph name="INVALIDADDRESS"/>“ trūksta „<ph name="ATSIGN"/>“.</translation>
-<translation id="4851297395436456855">sukti pirmyn</translation>
<translation id="1088086359088493902">Sekundės</translation>
<translation id="3934680773876859118">Nepavyko įkelti PDF dokumento</translation>
<translation id="3632707345189162177">likusių filmo sekundžių skaičius</translation>
<translation id="6359256949422175976">filmo laiko valdiklio miniatiūra</translation>
<translation id="8597182159515967513">antraštė</translation>
<translation id="6843725295806269523">nutildyti</translation>
-<translation id="2615751259741237794">grįžti į realųjį laiką</translation>
<translation id="2653659639078652383">Pateikti</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">sukti atgal</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_lv.xtb b/chromium/webkit/glue/resources/webkit_strings_lv.xtb
index 5a1357a3476..479305be3a9 100644
--- a/chromium/webkit/glue/resources/webkit_strings_lv.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_lv.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="lv">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Cits...</translation>
-<translation id="2426432199384958866">atsākt filmas straumēšanu reāllaikā</translation>
<translation id="248395913932153421">Diena</translation>
<translation id="1729654308190250600">Lūdzu, ievadiet e-pasta adresi.</translation>
<translation id="6015796118275082299">Gads</translation>
-<translation id="9186171386827445984">Notiek dokumenta ielāde: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> lappuses...</translation>
<translation id="1235745349614807883">Dzēst nesenos meklējumus</translation>
<translation id="7223624360433298498">pagājušais laiks</translation>
<translation id="1171774979989969504">Ievadiet e-pasta adresi.</translation>
<translation id="709897737746224366">Pieskaņojiet vērtību prasītajam formātam.</translation>
<translation id="5048533449481078685">sarakstu marķieris</translation>
<translation id="4202807286478387388">lekt</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Lūdzu, ievadiet daļu, kas atrodas pirms zīmes <ph name="ATSIGN"/>. “<ph name="INVALIDADDRESS"/>” ir nepilna adrese.</translation>
<translation id="2746543609216772311">Vērtībai ir jābūt “<ph name="MINIMUM_DATE_OR_TIME"/>” vai vēlākam datumam vai laikam.</translation>
<translation id="2572483411312390101">atskaņot</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">filmas laiks</translation>
<translation id="8199524924445686405">gggg</translation>
<translation id="795667975304826397">Nav izvēlēts neviens fails</translation>
-<translation id="1320012872283894746">ātri pārtīt atpakaļ</translation>
<translation id="7789962463072032349">pauzēt</translation>
<translation id="6853785296079745596">slēpt slēgtos parakstus</translation>
<translation id="4360991593054037559">Lūdzu, ievadiet derīgu vērtību. Divas tuvākās derīgās vērtības ir <ph name="VALID_VALUE_LOW"/> un <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">nospiest</translation>
<translation id="8244226242650769279">attēlu karte</translation>
<translation id="310520048233152454">Ievadiet URL.</translation>
-<translation id="9039488204461337220">ātri pārtīt uz priekšu</translation>
<translation id="4812940957355064477">Lūdzu, ievadiet skaitli.</translation>
<translation id="2548326553472216322">Nav nesenu meklējumu</translation>
<translation id="1938124657309484470">Vērtībai ir jābūt “<ph name="MAXIMUM_DATE_OR_TIME"/>” vai agrākam datumam vai laikam.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Lūdzu, ievadiet derīgu vērtību. Šis lauks nav pabeigts, vai tajā ir norādīts nederīgs datums.</translation>
<translation id="3040011195152428237">saite</translation>
<translation id="1014825444426747588">tukšs</translation>
-<translation id="3356679314312413792">pārtīt filmu atpakaļ par 30 sekundēm</translation>
<translation id="9050748414552849310">rādīt slēgtos parakstus</translation>
<translation id="4522570452068850558">Informācija</translation>
<translation id="8451268428117625855">Lūdzu, atlasiet failu.</translation>
@@ -60,11 +54,10 @@
<translation id="2674318244760992338">kājene</translation>
<translation id="8987927404178983737">Mēnesis</translation>
<translation id="8115662671911883373">sākt slēgto parakstu rādīšanu</translation>
-<translation id="7364796246159120393">Izvēlieties failu</translation>
+<translation id="7364796246159120393">Izvēlēties failu</translation>
<translation id="2761667185364618470">Lai turpinātu, atzīmējiet šo izvēles rūtiņu.</translation>
<translation id="8534579021159131403">Minūtes</translation>
<translation id="819205353528511139">atskaņot filmu pilnekrāna režīmā</translation>
-<translation id="8964020114565522021">Ievelciet failu šeit</translation>
<translation id="4103419683916926126">Milisekundes</translation>
<translation id="838869780401515933">prbaudt</translation>
<translation id="2846343701378493991">1024 (Vidēja Atzīme)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Šis dokuments ir aizsargāts ar paroli. Lūdzu, ievadiet paroli.</translation>
<translation id="5466621249238537318">Lūdzu, atlasiet vienu vai vairākus failus.</translation>
<translation id="9132465097189459683">Cits...</translation>
+<translation id="10623998915015855">pārslēgšanas poga</translation>
<translation id="8750798805984357768">Lūdzu, atlasiet vienu no šīm opcijām.</translation>
<translation id="7740050170769002709">HTML saturs</translation>
<translation id="6692633176391053278">pārslēdzējs</translation>
+<translation id="4975562563186953947">Atlasīti <ph name="SELECTED_COUNT"/></translation>
<translation id="8541249477527128034">multivides vadība</translation>
<translation id="2226276347425096477">Lūdzu, saīsiniet šo tekstu līdz <ph name="MAX_CHARACTERS"/> vai mazāk zīmēm (pašreiz tas ietver <ph name="CURRENT_LENGTH"/> rakstzīmes).</translation>
<translation id="6101327004457443354">ieslēgt audio ieraksta skaņu</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Stundas</translation>
<translation id="4664250907885839816">Daļā, kas atrodas aiz zīmes <ph name="ATSIGN"/>, nedrīkst būt ietverts simbols <ph name="INVALIDCHARACTER"/>.</translation>
<translation id="3450233048674729344">Vērtībai ir jābūt mazākai vai vienādai ar <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">atpakaļ par 30 sekundēm</translation>
<translation id="668171684555832681">Cits</translation>
<translation id="6270583010843788609">filmas laika skalas sīktēls</translation>
<translation id="5641012560118721995">pauzēt atskaņošanu</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> faili</translation>
<translation id="6643016212128521049">Notīrīt</translation>
<translation id="7888071071722539607">E-pasta adresē ietveriet zīmi <ph name="ATSIGN"/>. Adresē “<ph name="INVALIDADDRESS"/>” trūkst zīmes <ph name="ATSIGN"/>.</translation>
-<translation id="4851297395436456855">pārtīt uz priekšu</translation>
<translation id="1088086359088493902">Sekundes</translation>
<translation id="3934680773876859118">Neizdevās ielādēt PDF dokumentu</translation>
<translation id="3632707345189162177">atlikušais filmas laiks sekundēs</translation>
<translation id="6359256949422175976">filmas laika skalas slīdņa sīktēls</translation>
<translation id="8597182159515967513">Virsraksts</translation>
<translation id="6843725295806269523">izslēgt skaņu</translation>
-<translation id="2615751259741237794">atsākt reāllaikā</translation>
<translation id="2653659639078652383">Iesniegt</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">pārtīt atpakaļ</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_ml.xtb b/chromium/webkit/glue/resources/webkit_strings_ml.xtb
index 839bbe8c8de..cd73807a298 100644
--- a/chromium/webkit/glue/resources/webkit_strings_ml.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_ml.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="ml">
<translation id="4763480195061959176">വീഡിയോ</translation>
<translation id="5843503607508392247">മറ്റുള്ളവ...</translation>
-<translation id="2426432199384958866">സ്‌ട്രീമിംഗ് മൂവിയെ തൽസമയത്തിലേക്ക് മാറ്റുക</translation>
<translation id="248395913932153421">ദിവസം</translation>
<translation id="1729654308190250600">ശൂന്യമായിടാതെ, ഇമെയിൽ വിലാസം നൽകുക.</translation>
<translation id="6015796118275082299">വര്‍ഷം</translation>
-<translation id="9186171386827445984">പ്രമാണങ്ങള്‍ ലോഡുചെയ്യുന്നു: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> പേജുകള്‍...</translation>
<translation id="1235745349614807883">അടുത്തിടെയുള്ള തിരയലുകള്‍ മായ്ക്കുക</translation>
<translation id="7223624360433298498">കഴിഞ്ഞ സമയം</translation>
<translation id="1171774979989969504">ദയവായി ഒരു ഇമെയില്‍ വിലാസം നല്‍കുക.</translation>
<translation id="709897737746224366">അഭ്യര്‍ത്ഥി ച്ചഫോര്‍മാറ്റ് ദയവായി പൊരുത്തപ്പെടുത്തുക.</translation>
<translation id="5048533449481078685">പട്ടിക മാര്‍ക്കര്‍</translation>
<translation id="4202807286478387388">jump</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">'<ph name="ATSIGN"/>' എന്നതിനുശേഷം ഒരു ഭാഗം നൽകുക.'<ph name="INVALIDADDRESS"/>' അപൂർണ്ണമാണ്.</translation>
<translation id="2746543609216772311">മൂല്യം <ph name="MINIMUM_DATE_OR_TIME"/> എന്നതോ അതിനുശേഷമുള്ള തീയതിയോ ആയിരിക്കണം.</translation>
<translation id="2572483411312390101">പ്ലേ ചെയ്യുക</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">മൂവി ടൈം</translation>
<translation id="8199524924445686405">വർഷം</translation>
<translation id="795667975304826397">ഒരു ഫയലും തിരഞ്ഞെടുത്തിട്ടില്ല</translation>
-<translation id="1320012872283894746">പെട്ടെന്ന് പിന്നോട്ട് പോകുക</translation>
<translation id="7789962463072032349">താല്‍‌ക്കാലികമായി നിര്‍‌ത്തുക</translation>
<translation id="6853785296079745596">അടച്ച അടിക്കുറിപ്പുകൾ മറയ്‌ക്കുക</translation>
<translation id="4360991593054037559">സാധുവായ മൂല്യം നൽകുക. സാധുവായ ഏറ്റവുമടുത്ത രണ്ട് മൂല്യങ്ങൾ <ph name="VALID_VALUE_LOW"/>, <ph name="VALID_VALUE_HIGHER"/> എന്നിവയാണ്.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">അമര്‍ത്തുക</translation>
<translation id="8244226242650769279">ഇമേജ് മാപ്പ്</translation>
<translation id="310520048233152454">ദയവായി ഒരു URL നല്‍കുക.</translation>
-<translation id="9039488204461337220">പെട്ടെന്ന് മുന്നോട്ട് പോകുക</translation>
<translation id="4812940957355064477">ഒരു നമ്പർ നൽകുക.</translation>
<translation id="2548326553472216322">സമീപകാല തിരയലുകള്‍ ഇല്ല</translation>
<translation id="1938124657309484470">മൂല്യം <ph name="MAXIMUM_DATE_OR_TIME"/> എന്നതോ അതിനുമുമ്പുള്ള തീയതിയോ ആയിരിക്കണം.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">ഒരു സാധുതയുള്ള മൂല്യം നൽകുക. ഫീൽഡ് പൂർണ്ണമല്ല അല്ലെങ്കിൽ അസാധുവായ തീയതിയിലുള്ളതാണ്.</translation>
<translation id="3040011195152428237">ലിങ്ക്</translation>
<translation id="1014825444426747588">ശൂന്യം</translation>
-<translation id="3356679314312413792">മൂവി 30 നിമിഷം പിന്നോട്ട് പോകുക</translation>
<translation id="9050748414552849310">അടച്ച അടിക്കുറിപ്പുകൾ കാണിക്കുക</translation>
<translation id="4522570452068850558">വിശദാംശങ്ങള്‍‌</translation>
<translation id="8451268428117625855">ദയവായി ഒരു ഫയല്‍ തരം തിരഞ്ഞെടുക്കുക.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">നിങ്ങള്‍ തുടരാന്‍ താല്‍പ്പര്യപ്പെടുന്നെങ്കില്‍ ഈ ബോക്സ് ദയവായി പരിശോധിക്കുക.</translation>
<translation id="8534579021159131403">മിനിറ്റ്</translation>
<translation id="819205353528511139">പൂർണ്ണ സ്‌ക്രീൻ മോഡിൽ മൂവി പ്ലേ ചെയ്യുക</translation>
-<translation id="8964020114565522021">ഇവിടെ ഫയല്‍ ഇഴയ്ക്കുക</translation>
<translation id="4103419683916926126">മില്ലിസെക്കൻഡ്</translation>
<translation id="838869780401515933">പരിശോധിക്കൂ</translation>
<translation id="2846343701378493991">1024 (മീഡിയം ഗ്രേഡ്)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">ഈ പ്രമാണം പാസ്‌വേഡ് പരിരക്ഷിതമാണ്. ദയവായി ഒരു പാസ്‌വേഡ് നല്‍‌കുക.</translation>
<translation id="5466621249238537318">ഒന്നോ അതില്‍ക്കൂടുതലോ ഫയലുകള്‍ ദയവായി തിരഞ്ഞെടുക്കുക.</translation>
<translation id="9132465097189459683">മറ്റുള്ളവ...</translation>
+<translation id="10623998915015855">ടോഗിൾ ബട്ടൺ</translation>
<translation id="8750798805984357768">ഈ ഓപ്ഷനുകളിലൊന്ന് ദയവായി തിരഞ്ഞെടുക്കുക.</translation>
<translation id="7740050170769002709">HTML ഉള്ളടക്കം</translation>
<translation id="6692633176391053278">സ്റ്റെപ്പർ</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> തിരഞ്ഞെടുത്തു</translation>
<translation id="8541249477527128034">മീഡിയ നിയന്ത്രണം</translation>
<translation id="2226276347425096477">ഈ വാചകത്തെ <ph name="MAX_CHARACTERS"/> അല്ലെങ്കില്‍ അതില്‍‌ക്കുറവ് പ്രതീകങ്ങളായി ദയവായി കുറയ്ക്കുക (നിങ്ങള്‍ നിലവില്‍ <ph name="CURRENT_LENGTH"/> പ്രതീകങ്ങള്‍ ഉപയോഗിക്കുകയാണ്).</translation>
<translation id="6101327004457443354">ഓഡിയോ ട്രാക്ക് ശബ്‌ദമുള്ളതാക്കുക</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">മണിക്കൂര്‍‌</translation>
<translation id="4664250907885839816">'<ph name="ATSIGN"/>' എന്നതിനുശേഷം വരുന്ന ഭാഗത്തിൽ '<ph name="INVALIDCHARACTER"/>' ചിഹ്നം ഉണ്ടാകരുത്.</translation>
<translation id="3450233048674729344">മൂല്യം <ph name="MAXIMUM"/> എന്നതില്‍ കുറവോ സമമോ ആയിരിക്കണം.</translation>
-<translation id="3471999216963526757">30 നിമിഷം പിന്നോട്ട്</translation>
<translation id="668171684555832681">മറ്റുള്ളവ...</translation>
<translation id="6270583010843788609">മൂവി ടൈംലൈൻ തമ്പ്</translation>
<translation id="5641012560118721995">പ്ലേബാക്ക് താൽക്കാലികമായി നിർത്തുക</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> ഫയലുകള്‍</translation>
<translation id="6643016212128521049">മായ്‌ക്കുക</translation>
<translation id="7888071071722539607">ഇമെയിൽ വിലാസത്തിൽ '<ph name="ATSIGN"/>' ഉൾപ്പെടുത്തുക. '<ph name="INVALIDADDRESS"/>' എന്നതിൽ ഒരു '<ph name="ATSIGN"/>' കാണുന്നില്ല.</translation>
-<translation id="4851297395436456855">വേഗത്തിൽ മുന്നോട്ട് പോകുക</translation>
<translation id="1088086359088493902">സെക്കൻഡ്</translation>
<translation id="3934680773876859118">PDF പ്രമാണം ലോഡുചെയ്യുന്നത് പരാജയപ്പെട്ടു</translation>
<translation id="3632707345189162177">മൂവിയുടെ അവശേഷിക്കുന്ന നിമിഷങ്ങളുടെ എണ്ണം</translation>
<translation id="6359256949422175976">മൂവി ടൈം സ്‌ക്രബ്ബർ തമ്പ്</translation>
<translation id="8597182159515967513">തലക്കെട്ട്</translation>
<translation id="6843725295806269523">നിശബ്‌ദമാക്കുക</translation>
-<translation id="2615751259741237794">തൽസമയത്തിലേക്ക് മടങ്ങുക</translation>
<translation id="2653659639078652383">സമര്‍പ്പിക്കൂ</translation>
<translation id="3732799496749320381">മാസം</translation>
-<translation id="4484359737905287537">വേഗത്തിൽ പിന്നോട്ട് പോകുക</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_mr.xtb b/chromium/webkit/glue/resources/webkit_strings_mr.xtb
index bc6aae29e07..a8504925737 100644
--- a/chromium/webkit/glue/resources/webkit_strings_mr.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_mr.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="mr">
<translation id="4763480195061959176">व्हिडिओ</translation>
<translation id="5843503607508392247">अन्य...</translation>
-<translation id="2426432199384958866">रिअल टाइमकडे प्रवाह चित्रपट परत करा</translation>
<translation id="248395913932153421">दिवस</translation>
<translation id="1729654308190250600">कृपया एक रिक्त-नसलेला ईमेल पत्ता प्रविष्ट करा.</translation>
<translation id="6015796118275082299">वर्ष</translation>
-<translation id="9186171386827445984">दस्तऐवज लोड करत आहे: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> पृष्ठे...</translation>
<translation id="1235745349614807883">अलीकडील शोध साफ करा</translation>
<translation id="7223624360433298498">लोटलेला अवधी</translation>
<translation id="1171774979989969504">कृपया एक ईमेल पत्ता प्रविष्ट करा.</translation>
<translation id="709897737746224366">कृपया विनंती केलेले स्वरूपन जुळवा.</translation>
<translation id="5048533449481078685">सूची चिन्हक</translation>
<translation id="4202807286478387388">जंप करा</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">कृपया '<ph name="ATSIGN"/>' मागुन येणारा भाग प्रविष्ट करा. '<ph name="INVALIDADDRESS"/>' अपूर्ण आहे.</translation>
<translation id="2746543609216772311">मूल्य <ph name="MINIMUM_DATE_OR_TIME"/> किंवा नंतरचे असणे आवश्यक आहे.</translation>
<translation id="2572483411312390101">प्ले करा</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">चित्रपटाची वेळ</translation>
<translation id="8199524924445686405">yyyy</translation>
<translation id="795667975304826397">कोणतीही फाइल निवडलेली नाही</translation>
-<translation id="1320012872283894746">द्रुतपणे परत शोधून काढा</translation>
<translation id="7789962463072032349">विराम द्या</translation>
<translation id="6853785296079745596">बंद मथळा लपवा</translation>
<translation id="4360991593054037559">कृपया एक वैध मूल्य प्रविष्ट करा. दोन जवळील वैध मूल्ये <ph name="VALID_VALUE_LOW"/> आणि <ph name="VALID_VALUE_HIGHER"/> आहेत.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">दाबा</translation>
<translation id="8244226242650769279">प्रतिमा नकाशा</translation>
<translation id="310520048233152454">कृपया एखादी URL प्रविष्ट करा.</translation>
-<translation id="9039488204461337220">द्रुतपणे अग्रेषण शोधून काढा</translation>
<translation id="4812940957355064477">कृपया एक नंबर प्रविष्ट करा.</translation>
<translation id="2548326553472216322">अलीकडील शोध नाहीत</translation>
<translation id="1938124657309484470">मूल्य <ph name="MAXIMUM_DATE_OR_TIME"/> किंवा आधीचे असणे आवश्यक आहे.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">कृपया एक वैध मूल्य प्रविष्ट करा. फील्ड अपूर्ण आहे किंवा अवैध तारीख आहे.</translation>
<translation id="3040011195152428237">दुवा</translation>
<translation id="1014825444426747588">रिक्त</translation>
-<translation id="3356679314312413792">30 सेकंदांमध्ये चित्रपट परत शोधून काढा</translation>
<translation id="9050748414552849310">बंद मथळा दर्शवा</translation>
<translation id="4522570452068850558">तपशील</translation>
<translation id="8451268428117625855">कृपया एखादी फाइल निवडा.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">कृपया आपण पुढे चालू ठेवू इच्छित असल्यास हा बॉक्स पहा.</translation>
<translation id="8534579021159131403">मिनिटे</translation>
<translation id="819205353528511139">पूर्ण स्क्रीन मोडमध्ये चित्रपट प्ले करा</translation>
-<translation id="8964020114565522021">फाइल येथे ड्रॅग करा</translation>
<translation id="4103419683916926126">मिलिसेकंद</translation>
<translation id="838869780401515933">तपासा</translation>
<translation id="2846343701378493991">1024 (मध्यम प्रत)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">हा दस्तऐवज संकेतशब्द संरक्षित आहे. कृपया संकेतशब्द प्रविष्ट करा.</translation>
<translation id="5466621249238537318">कृपया एक किंवा अधिक फायली निवडा.</translation>
<translation id="9132465097189459683">अन्य...</translation>
+<translation id="10623998915015855">टॉगल बटण</translation>
<translation id="8750798805984357768">कृपया या पर्यायांपैकी एक निवडा.</translation>
<translation id="7740050170769002709">HTML सामुग्री</translation>
<translation id="6692633176391053278">stepper</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> निवडले</translation>
<translation id="8541249477527128034">माध्यम नियंत्रण</translation>
<translation id="2226276347425096477">कृपया हा मजकूर <ph name="MAX_CHARACTERS"/> वर्ण लहान किंवा कमी करा (आपण सध्या <ph name="CURRENT_LENGTH"/> वर्ण वापरत आहात).</translation>
<translation id="6101327004457443354">ऑडिओ ट्रॅक सशब्द करा</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">तास</translation>
<translation id="4664250907885839816">'<ph name="ATSIGN"/>' चे अनुसरण करणार्‍या भागामध्ये '<ph name="INVALIDCHARACTER"/>' चिन्ह नसावे.</translation>
<translation id="3450233048674729344">मूल्य <ph name="MAXIMUM"/> पेक्षा कमी किंवा समान असावे.</translation>
-<translation id="3471999216963526757">परत 30 सेकंद</translation>
<translation id="668171684555832681">अन्य...</translation>
<translation id="6270583010843788609">चित्रपट टाइमलाइन थंब</translation>
<translation id="5641012560118721995">प्लेबॅकला विराम द्या</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> फायली</translation>
<translation id="6643016212128521049">साफ करा</translation>
<translation id="7888071071722539607">कृपया ईमेल पत्त्यामध्ये '<ph name="ATSIGN"/>' समाविष्ट करा. '<ph name="INVALIDADDRESS"/>' '<ph name="ATSIGN"/>' गमावत आहे.</translation>
-<translation id="4851297395436456855">जलद अग्रेषण</translation>
<translation id="1088086359088493902">सेकंद</translation>
<translation id="3934680773876859118">PDF दस्तऐवज लोड करणे अयशस्वी</translation>
<translation id="3632707345189162177">चित्रपटाचे शिल्लक सेकंद</translation>
<translation id="6359256949422175976">चित्रपट वेळ स्क्रबर थंब</translation>
<translation id="8597182159515967513">शीर्षलेख</translation>
<translation id="6843725295806269523">नि:शब्द करा</translation>
-<translation id="2615751259741237794">रिअल टाइमकडे परत</translation>
<translation id="2653659639078652383">सबमिट करा</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">जलद मागे</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_ms.xtb b/chromium/webkit/glue/resources/webkit_strings_ms.xtb
index c94d5b0ea3e..def0378cbaf 100644
--- a/chromium/webkit/glue/resources/webkit_strings_ms.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_ms.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="ms">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Lain-lain...</translation>
-<translation id="2426432199384958866">kembalikan penstriman filem pada masa nyata</translation>
<translation id="248395913932153421">Hari</translation>
<translation id="1729654308190250600">Sila masukkan alamat e-mel bukan kosong.</translation>
<translation id="6015796118275082299">Tahun</translation>
-<translation id="9186171386827445984">Memuatkan dokumen: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> halaman...</translation>
<translation id="1235745349614807883">Kosongkan Carian Baru-baru Ini</translation>
<translation id="7223624360433298498">masa berlalu</translation>
<translation id="1171774979989969504">Sila masukkan alamat e-mel.</translation>
<translation id="709897737746224366">Sila padankan dengan format yang diminta.</translation>
<translation id="5048533449481078685">penanda senarai</translation>
<translation id="4202807286478387388">lompat</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Sila masukkan bahagian diikuti oleh '<ph name="ATSIGN"/>'. '<ph name="INVALIDADDRESS"/>' tidak lengkap.</translation>
<translation id="2746543609216772311">Nilai mestilah <ph name="MINIMUM_DATE_OR_TIME"/> atau kemudian.</translation>
<translation id="2572483411312390101">main</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">masa filem</translation>
<translation id="8199524924445686405">yyyy</translation>
<translation id="795667975304826397">Tiada fail dipilih</translation>
-<translation id="1320012872283894746">cari ke belakang dengan cepat</translation>
<translation id="7789962463072032349">jeda</translation>
<translation id="6853785296079745596">sembunyikan kapsyen tertutup</translation>
<translation id="4360991593054037559">Sila masukkan nilai yang sah. Dua nilai sah yang terdekat ialah <ph name="VALID_VALUE_LOW"/> dan <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">tekan</translation>
<translation id="8244226242650769279">peta imej</translation>
<translation id="310520048233152454">Sila masukkan URL.</translation>
-<translation id="9039488204461337220">cari ke hadapan dengan cepat</translation>
<translation id="4812940957355064477">Sila masukkan nombor.</translation>
<translation id="2548326553472216322">Tiada carian baru-baru ini</translation>
<translation id="1938124657309484470">Nilai mestilah <ph name="MAXIMUM_DATE_OR_TIME"/> atau lebih awal.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Sila masukkan nilai yang sah. Medan tidak lengkap atau mengandungi tarikh yang tidak sah.</translation>
<translation id="3040011195152428237">pautan</translation>
<translation id="1014825444426747588">kosong</translation>
-<translation id="3356679314312413792">cari filem 30 saat ke belakang</translation>
<translation id="9050748414552849310">paparkan kapsyen tertutup</translation>
<translation id="4522570452068850558">Butiran</translation>
<translation id="8451268428117625855">Sila pilih fail.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Sila tandakan kotak ini jika anda mahu teruskan.</translation>
<translation id="8534579021159131403">Minit</translation>
<translation id="819205353528511139">mainkan filem dalam mod skrin penuh</translation>
-<translation id="8964020114565522021">Seret fail ke sini</translation>
<translation id="4103419683916926126">Milisaat</translation>
<translation id="838869780401515933">periksa</translation>
<translation id="2846343701378493991">1024 (Gred Sederhana)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Dokumen ini dilindungi kata laluan. Sila masukkan kata laluan.</translation>
<translation id="5466621249238537318">Sila pilih satu fail atau lebih.</translation>
<translation id="9132465097189459683">Lain-lain...</translation>
+<translation id="10623998915015855">butang togol</translation>
<translation id="8750798805984357768">Sila pilih salah satu pilihan ini.</translation>
<translation id="7740050170769002709">Kandungan HTML</translation>
<translation id="6692633176391053278">pelangkah</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> dipilih</translation>
<translation id="8541249477527128034">kawalan media</translation>
<translation id="2226276347425096477">Sila pendekkan teks ini menjadi <ph name="MAX_CHARACTERS"/> aksara atau kurang (anda kini menggunakan <ph name="CURRENT_LENGTH"/> aksara).</translation>
<translation id="6101327004457443354">nyahredam runut audio</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Jam</translation>
<translation id="4664250907885839816">Bahagian selepas '<ph name="ATSIGN"/>' tidak boleh mengandungi simbol '<ph name="INVALIDCHARACTER"/>'.</translation>
<translation id="3450233048674729344">Nilai mestilah kurang daripada atau sama dengan <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">30 saat ke belakang</translation>
<translation id="668171684555832681">Lain-lain...</translation>
<translation id="6270583010843788609">ibu jari garis masa filem</translation>
<translation id="5641012560118721995">jeda main balik</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> fail</translation>
<translation id="6643016212128521049">Kosongkan</translation>
<translation id="7888071071722539607">Sila masukkan '<ph name="ATSIGN"/>' dalam alamat e-mel. '<ph name="INVALIDADDRESS"/>' tiada '<ph name="ATSIGN"/>'.</translation>
-<translation id="4851297395436456855">mara laju</translation>
<translation id="1088086359088493902">Saat</translation>
<translation id="3934680773876859118">Gagal untuk memuatkan dokumen PDF</translation>
<translation id="3632707345189162177">bilangan saat filem yang tinggal</translation>
<translation id="6359256949422175976">ibu jari pembersih masa filem</translation>
<translation id="8597182159515967513">tajuk</translation>
<translation id="6843725295806269523">redam</translation>
-<translation id="2615751259741237794">kembali ke masa nyata</translation>
<translation id="2653659639078652383">Serah</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">undur laju</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_nl.xtb b/chromium/webkit/glue/resources/webkit_strings_nl.xtb
index 9b1cdd85f30..6b0cd97cd62 100644
--- a/chromium/webkit/glue/resources/webkit_strings_nl.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_nl.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="nl">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Anders...</translation>
-<translation id="2426432199384958866">terug naar streamen van film in realtime</translation>
<translation id="248395913932153421">Dag</translation>
<translation id="1729654308190250600">Geef een e-mailadres op.</translation>
<translation id="6015796118275082299">Jaar</translation>
-<translation id="9186171386827445984">Document wordt geladen: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> pagina's...</translation>
<translation id="1235745349614807883">Recente zoekopdrachten wissen</translation>
<translation id="7223624360433298498">verstreken tijd</translation>
<translation id="1171774979989969504">Geef een e-mailadres op.</translation>
<translation id="709897737746224366">Zorg dat de indeling voldoet aan de gevraagde indeling.</translation>
<translation id="5048533449481078685">lijstmarkering</translation>
<translation id="4202807286478387388">Gaan naar</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Geef een naamgedeelte op, gevolgd door '<ph name="ATSIGN"/>'. '<ph name="INVALIDADDRESS"/>' is onvolledig.</translation>
<translation id="2746543609216772311">Waarde moet <ph name="MINIMUM_DATE_OR_TIME"/> of later zijn.</translation>
<translation id="2572483411312390101">afspelen</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">tijd van de film</translation>
<translation id="8199524924445686405">jjjj</translation>
<translation id="795667975304826397">Geen bestand gekozen</translation>
-<translation id="1320012872283894746">snel achteruit zoeken</translation>
<translation id="7789962463072032349">onderbreken</translation>
<translation id="6853785296079745596">ondertiteling verbergen</translation>
<translation id="4360991593054037559">Geef een geldige waarde op. De twee dichtstbijzijnde geldige waarden zijn <ph name="VALID_VALUE_LOW"/> en <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">Indrukken</translation>
<translation id="8244226242650769279">image map</translation>
<translation id="310520048233152454">Geef een URL op.</translation>
-<translation id="9039488204461337220">snel vooruit zoeken</translation>
<translation id="4812940957355064477">Voer een getal in.</translation>
<translation id="2548326553472216322">Geen recente zoekopdrachten</translation>
<translation id="1938124657309484470">Waarde moet <ph name="MAXIMUM_DATE_OR_TIME"/> of eerder zijn.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Voer een geldige waarde in. Het veld is onvolledig of bevat een ongeldige datum.</translation>
<translation id="3040011195152428237">link</translation>
<translation id="1014825444426747588">leeg</translation>
-<translation id="3356679314312413792">30 seconden terugspoelen in de film</translation>
<translation id="9050748414552849310">ondertiteling weergeven</translation>
<translation id="4522570452068850558">Details</translation>
<translation id="8451268428117625855">Selecteer een bestand.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Vink dit selectievakje aan als je wilt doorgaan.</translation>
<translation id="8534579021159131403">Minuten</translation>
<translation id="819205353528511139">film afspelen op volledig scherm</translation>
-<translation id="8964020114565522021">Sleep bestand hier naartoe</translation>
<translation id="4103419683916926126">Milliseconden</translation>
<translation id="838869780401515933">Selecteren</translation>
<translation id="2846343701378493991">1024 (gemiddeld niveau)</translation>
@@ -84,16 +77,18 @@
<translation id="2597378329261239068">Dit document is beveiligd met een wachtwoord. Geef een wachtwoord op.</translation>
<translation id="5466621249238537318">Selecteer een of meer bestanden.</translation>
<translation id="9132465097189459683">Anders...</translation>
+<translation id="10623998915015855">schakelknop</translation>
<translation id="8750798805984357768">Selecteer een van deze opties.</translation>
<translation id="7740050170769002709">HTML-inhoud</translation>
<translation id="6692633176391053278">stappenregelaar</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> geselecteerd</translation>
<translation id="8541249477527128034">mediacontrole</translation>
<translation id="2226276347425096477">Kort deze tekst in tot <ph name="MAX_CHARACTERS"/> tekens of minder (je gebruikt momenteel <ph name="CURRENT_LENGTH"/> tekens).</translation>
<translation id="6101327004457443354">dempen van audiotrack opheffen</translation>
<translation id="1822429046913737220">a.m./p.m.</translation>
<translation id="1639239467298939599">Laden</translation>
<translation id="2908441821576996758">Voer een door komma's gescheiden lijst met e-mailadressen in.</translation>
-<translation id="5939518447894949180">Herstellen</translation>
+<translation id="5939518447894949180">Terugzetten</translation>
<translation id="1921819250265091946">dd</translation>
<translation id="2613802280814924224">Geef een geldige waarde op. De dichtstbijzijnde geldige waarde is <ph name="VALID_VALUE"/>.</translation>
<translation id="835897206747267392">Ongeldige waarde.</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Uur</translation>
<translation id="4664250907885839816">Het adresgedeelte na '<ph name="ATSIGN"/>' mag niet het teken '<ph name="INVALIDCHARACTER"/>' bevatten.</translation>
<translation id="3450233048674729344">Waarde moet kleiner dan of gelijk zijn aan <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">30 seconden terug</translation>
<translation id="668171684555832681">Anders...</translation>
<translation id="6270583010843788609">miniatuur van tijdlijn van film</translation>
<translation id="5641012560118721995">afspelen onderbreken</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> bestanden</translation>
<translation id="6643016212128521049">Wissen</translation>
<translation id="7888071071722539607">Gebruik een '<ph name="ATSIGN"/>' in thet e-mailadres. In '<ph name="INVALIDADDRESS"/>' ontbreekt een '<ph name="ATSIGN"/>'.</translation>
-<translation id="4851297395436456855">snel vooruitspoelen</translation>
<translation id="1088086359088493902">Seconden</translation>
<translation id="3934680773876859118">PDF-document kan niet worden geladen</translation>
<translation id="3632707345189162177">aantal seconden van resterende film</translation>
<translation id="6359256949422175976">miniatuur van schuifbalk met tijd van de film</translation>
<translation id="8597182159515967513">kop</translation>
<translation id="6843725295806269523">dempen</translation>
-<translation id="2615751259741237794">terug naar realtime</translation>
<translation id="2653659639078652383">Verzenden</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">snel terugspoelen</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_no.xtb b/chromium/webkit/glue/resources/webkit_strings_no.xtb
index 62bd07ee42d..394354d3eeb 100644
--- a/chromium/webkit/glue/resources/webkit_strings_no.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_no.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="no">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Andre</translation>
-<translation id="2426432199384958866">gå tilbake til direkteavspilling av filmen i sanntid</translation>
<translation id="248395913932153421">Dag</translation>
<translation id="1729654308190250600">Skriv inn en ikke-tom e-postadresse.</translation>
<translation id="6015796118275082299">År</translation>
-<translation id="9186171386827445984">Laster inn dokument: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> sider</translation>
<translation id="1235745349614807883">Fjern nylige søk</translation>
<translation id="7223624360433298498">brukt tid</translation>
<translation id="1171774979989969504">Skriv inn en e-postadresse.</translation>
<translation id="709897737746224366">Sørg for samsvar med det forespurte formatet.</translation>
<translation id="5048533449481078685">listemarkør</translation>
<translation id="4202807286478387388">hopp</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Skriv inn en del etterfulgt av «<ph name="ATSIGN"/>». «<ph name="INVALIDADDRESS"/>» er ufullstendig.</translation>
<translation id="2746543609216772311">Verdien må være <ph name="MINIMUM_DATE_OR_TIME"/> eller senere.</translation>
<translation id="2572483411312390101">spill av</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">gå til et annet tidspunkt</translation>
<translation id="8199524924445686405">åååå</translation>
<translation id="795667975304826397">Ingen fil valgt</translation>
-<translation id="1320012872283894746">spol raskt bakover</translation>
<translation id="7789962463072032349">stans midlertidig</translation>
<translation id="6853785296079745596">skjul teksting</translation>
<translation id="4360991593054037559">Skriv inn en gyldig verdi. De to nærmeste, gyldige verdiene er <ph name="VALID_VALUE_LOW"/> og <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">trykk</translation>
<translation id="8244226242650769279">bildekart</translation>
<translation id="310520048233152454">Skriv inn en nettadresse.</translation>
-<translation id="9039488204461337220">spol raskt fremover</translation>
<translation id="4812940957355064477">Skriv inn et tall.</translation>
<translation id="2548326553472216322">Ingen nylige søk</translation>
<translation id="1938124657309484470">Verdien må være <ph name="MAXIMUM_DATE_OR_TIME"/> eller før.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Skriv inn en gyldig verdi. Feltet er ufullstendig, eller har en ugyldig dato.</translation>
<translation id="3040011195152428237">link</translation>
<translation id="1014825444426747588">tom</translation>
-<translation id="3356679314312413792">spol 30 sekunder tilbake</translation>
<translation id="9050748414552849310">vis teksting</translation>
<translation id="4522570452068850558">Detaljer</translation>
<translation id="8451268428117625855">Velg en fil.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Kryss av denne boksen hvis du vil fortsette.</translation>
<translation id="8534579021159131403">Minutter</translation>
<translation id="819205353528511139">spill av filmen i fullskjermmodus</translation>
-<translation id="8964020114565522021">Dra filen hit</translation>
<translation id="4103419683916926126">Millisekunder</translation>
<translation id="838869780401515933">merk av</translation>
<translation id="2846343701378493991">1024 (middels)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Dette dokumentet er passordbeskyttet. Skriv inn et passord.</translation>
<translation id="5466621249238537318">Velg én eller flere filer.</translation>
<translation id="9132465097189459683">Andre</translation>
+<translation id="10623998915015855">av/på-knapp</translation>
<translation id="8750798805984357768">Velg ett av følgende alternativer.</translation>
<translation id="7740050170769002709">HTML-innhold</translation>
<translation id="6692633176391053278">stepper</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> er valgt</translation>
<translation id="8541249477527128034">mediekontroll</translation>
<translation id="2226276347425096477">Forkort denne teksten til <ph name="MAX_CHARACTERS"/> tegn eller færre (for øyeblikket bruker du <ph name="CURRENT_LENGTH"/> tegn).</translation>
<translation id="6101327004457443354">slå på lydsporet</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Timer</translation>
<translation id="4664250907885839816">En del etterfulgt av «<ph name="ATSIGN"/>» kan ikke inneholde symbolet «<ph name="INVALIDCHARACTER"/>».</translation>
<translation id="3450233048674729344">Verdien må være mindre enn eller lik <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">30 sekunder bakover</translation>
<translation id="668171684555832681">Annen</translation>
<translation id="6270583010843788609">filmtidslinjemarkøren</translation>
<translation id="5641012560118721995">stopp avspillingen midlertidig</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> filer</translation>
<translation id="6643016212128521049">Tøm</translation>
<translation id="7888071071722539607">Inkluder en «<ph name="ATSIGN"/>» i e-postadressen. «<ph name="INVALIDADDRESS"/>» mangler en «<ph name="ATSIGN"/>».</translation>
-<translation id="4851297395436456855">spol fremover</translation>
<translation id="1088086359088493902">Sekunder</translation>
<translation id="3934680773876859118">Kan ikke laste inn PDF-dokument</translation>
<translation id="3632707345189162177">antall sekunder som gjenstår av filmen</translation>
<translation id="6359256949422175976">markøren for filmtidslinjen</translation>
<translation id="8597182159515967513">overskrift</translation>
<translation id="6843725295806269523">kutt lyd</translation>
-<translation id="2615751259741237794">tilbake til sanntid</translation>
<translation id="2653659639078652383">Send</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">spol bakover</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_pl.xtb b/chromium/webkit/glue/resources/webkit_strings_pl.xtb
index 7bdd27fb16c..c34757f0599 100644
--- a/chromium/webkit/glue/resources/webkit_strings_pl.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_pl.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="pl">
<translation id="4763480195061959176">film</translation>
<translation id="5843503607508392247">Inny...</translation>
-<translation id="2426432199384958866">powróć do czasu rzeczywistego strumieniowo przesyłanego filmu</translation>
<translation id="248395913932153421">Dzień</translation>
<translation id="1729654308190250600">Podaj adres e-mail.</translation>
<translation id="6015796118275082299">Rok</translation>
-<translation id="9186171386827445984">Wczytywanie dokumentu: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> stron...</translation>
<translation id="1235745349614807883">Wyczyść ostatnie wyszukiwania</translation>
<translation id="7223624360433298498">upłynęło czasu</translation>
<translation id="1171774979989969504">Wprowadź adres e-mail.</translation>
<translation id="709897737746224366">Podaj wartość w wymaganym formacie.</translation>
<translation id="5048533449481078685">znacznik listy</translation>
<translation id="4202807286478387388">przejdź</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Podaj część przed znakiem „<ph name="ATSIGN"/>”. Adres „<ph name="INVALIDADDRESS"/>” jest niepełny.</translation>
<translation id="2746543609216772311">Musisz podać wartość <ph name="MINIMUM_DATE_OR_TIME"/> lub późniejszą.</translation>
<translation id="2572483411312390101">odtwórz</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">czas filmu</translation>
<translation id="8199524924445686405">rrrr</translation>
<translation id="795667975304826397">Nie wybrano pliku</translation>
-<translation id="1320012872283894746">szybko przewiń do tyłu</translation>
<translation id="7789962463072032349">wstrzymaj</translation>
<translation id="6853785296079745596">ukryj napisy</translation>
<translation id="4360991593054037559">Podaj prawidłową wartość. Dwie najbliższe prawidłowe wartości to <ph name="VALID_VALUE_LOW"/> i <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">naciśnij</translation>
<translation id="8244226242650769279">mapa grafiki</translation>
<translation id="310520048233152454">Wprowadź adres URL.</translation>
-<translation id="9039488204461337220">szybko przewiń do przodu</translation>
<translation id="4812940957355064477">Wpisz liczbę.</translation>
<translation id="2548326553472216322">Brak ostatnich wyszukiwań</translation>
<translation id="1938124657309484470">Musisz podać wartość <ph name="MAXIMUM_DATE_OR_TIME"/> lub wcześniejszą.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Wpisz prawidłową wartość. Pole jest niekompletne lub zawiera nieprawidłową datę.</translation>
<translation id="3040011195152428237">link</translation>
<translation id="1014825444426747588">puste</translation>
-<translation id="3356679314312413792">przewiń film 30 sekund do tyłu</translation>
<translation id="9050748414552849310">pokaż napisy</translation>
<translation id="4522570452068850558">Szczegóły</translation>
<translation id="8451268428117625855">Wybierz plik.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Zaznacz to pole, jeśli chcesz kontynuować.</translation>
<translation id="8534579021159131403">Minuty</translation>
<translation id="819205353528511139">odtwórz film w trybie pełnoekranowym</translation>
-<translation id="8964020114565522021">Przeciągnij plik tutaj</translation>
<translation id="4103419683916926126">Milisekundy</translation>
<translation id="838869780401515933">zaznacz</translation>
<translation id="2846343701378493991">1024 (średni poziom)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Ten dokument jest chroniony hasłem. Wprowadź hasło.</translation>
<translation id="5466621249238537318">Wybierz jeden lub kilka plików.</translation>
<translation id="9132465097189459683">Inny...</translation>
+<translation id="10623998915015855">przycisk przełączania</translation>
<translation id="8750798805984357768">Wybierz jedną z opcji.</translation>
<translation id="7740050170769002709">Treść HTML</translation>
<translation id="6692633176391053278">element kroczący</translation>
+<translation id="4975562563186953947">Wybrano: <ph name="SELECTED_COUNT"/></translation>
<translation id="8541249477527128034">sterowanie multimediami</translation>
<translation id="2226276347425096477">Skróć ten tekst do maksymalnie <ph name="MAX_CHARACTERS"/> znaków (w tej chwili korzystasz z <ph name="CURRENT_LENGTH"/> znaków).</translation>
<translation id="6101327004457443354">wyłącz wyciszenie ścieżki dźwiękowej</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Godziny</translation>
<translation id="4664250907885839816">Część po znaku „<ph name="ATSIGN"/>” nie może zawierać symbolu „<ph name="INVALIDCHARACTER"/>”.</translation>
<translation id="3450233048674729344">Wartość nie może być większa niż <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">30 sekund do tyłu</translation>
<translation id="668171684555832681">Inny...</translation>
<translation id="6270583010843788609">miniatura osi czasu filmu</translation>
<translation id="5641012560118721995">wstrzymaj odtwarzanie</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423">Liczba plików: <ph name="NUMBER_OF_FILES"/></translation>
<translation id="6643016212128521049">Wyczyść</translation>
<translation id="7888071071722539607">Uwzględnij znak „<ph name="ATSIGN"/>” w adresie e-mail. W adresie „<ph name="INVALIDADDRESS"/>” brakuje znaku „<ph name="ATSIGN"/>”.</translation>
-<translation id="4851297395436456855">przewiń do przodu</translation>
<translation id="1088086359088493902">Sekundy</translation>
<translation id="3934680773876859118">Nie można wczytać dokumentu PDF</translation>
<translation id="3632707345189162177">pozostały czas filmu w sekundach</translation>
<translation id="6359256949422175976">miniatura paska czasu odtwarzania filmu</translation>
<translation id="8597182159515967513">nagłówek</translation>
<translation id="6843725295806269523">wyciszenie</translation>
-<translation id="2615751259741237794">powróć do czasu rzeczywistego</translation>
<translation id="2653659639078652383">Prześlij</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">szybko przewiń do tyłu</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_pt-BR.xtb b/chromium/webkit/glue/resources/webkit_strings_pt-BR.xtb
index adfbf684fda..6b9da080762 100644
--- a/chromium/webkit/glue/resources/webkit_strings_pt-BR.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_pt-BR.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="pt-BR">
<translation id="4763480195061959176">vídeo</translation>
<translation id="5843503607508392247">Outras...</translation>
-<translation id="2426432199384958866">retornar filme em fluxo contínuo para tempo real</translation>
<translation id="248395913932153421">Dia</translation>
<translation id="1729654308190250600">Insira um endereço de e-mail que não esteja vazio.</translation>
<translation id="6015796118275082299">Ano</translation>
-<translation id="9186171386827445984">Carregando documento: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> páginas...</translation>
<translation id="1235745349614807883">Limpar pesquisas recentes</translation>
<translation id="7223624360433298498">tempo decorrido</translation>
<translation id="1171774979989969504">Insira um endereço de e-mail.</translation>
<translation id="709897737746224366">É preciso que o formato corresponda ao exigido.</translation>
<translation id="5048533449481078685">marcador de lista</translation>
<translation id="4202807286478387388">pular</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Insira uma parte seguida por &quot;<ph name="ATSIGN"/>&quot;. &quot;<ph name="INVALIDADDRESS"/>&quot; está incompleto.</translation>
<translation id="2746543609216772311">O valor deve ser <ph name="MINIMUM_DATE_OR_TIME"/> ou posterior.</translation>
<translation id="2572483411312390101">reproduzir</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">tempo de filme</translation>
<translation id="8199524924445686405">aaaa</translation>
<translation id="795667975304826397">Nenhum arquivo selecionado</translation>
-<translation id="1320012872283894746">retroceder rapidamente</translation>
<translation id="7789962463072032349">pausar</translation>
<translation id="6853785296079745596">ocultar legendas ocultas</translation>
<translation id="4360991593054037559">Insira um valor válido. Os dois valores válidos mais próximos são <ph name="VALID_VALUE_LOW"/> e <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">pressione</translation>
<translation id="8244226242650769279">mapa de imagens</translation>
<translation id="310520048233152454">Insira um URL.</translation>
-<translation id="9039488204461337220">avançar rapidamente</translation>
<translation id="4812940957355064477">Insira um número.</translation>
<translation id="2548326553472216322">Nenhuma pesquisa recente</translation>
<translation id="1938124657309484470">O valor deve ser <ph name="MAXIMUM_DATE_OR_TIME"/> ou anterior.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Insira um valor válido. O campo está incompleto ou tem uma data inválida.</translation>
<translation id="3040011195152428237">link</translation>
<translation id="1014825444426747588">em branco</translation>
-<translation id="3356679314312413792">voltar 30 segundos no filme</translation>
<translation id="9050748414552849310">mostrar legendas ocultas</translation>
<translation id="4522570452068850558">Detalhes</translation>
<translation id="8451268428117625855">Selecione um arquivo.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Marque esta caixa se deseja continuar.</translation>
<translation id="8534579021159131403">Minutos</translation>
<translation id="819205353528511139">reproduzir filme em tela cheia</translation>
-<translation id="8964020114565522021">Arraste o arquivo até aquil</translation>
<translation id="4103419683916926126">Milésimos de segundo</translation>
<translation id="838869780401515933">marcar</translation>
<translation id="2846343701378493991">1024 (Nível médio)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Este documento está protegido por senha. Digite a senha.</translation>
<translation id="5466621249238537318">Selecione um ou mais arquivos.</translation>
<translation id="9132465097189459683">Outras...</translation>
+<translation id="10623998915015855">botão &quot;alternar&quot;</translation>
<translation id="8750798805984357768">Selecione uma das opções.</translation>
<translation id="7740050170769002709">Conteúdo HTML</translation>
<translation id="6692633176391053278">stepper</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> selecionados</translation>
<translation id="8541249477527128034">controle de mídia</translation>
<translation id="2226276347425096477">Reduza este texto para <ph name="MAX_CHARACTERS"/> caracteres ou menos (você está usando <ph name="CURRENT_LENGTH"/> caracteres).</translation>
<translation id="6101327004457443354">ativar som da faixa de áudio</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Horas</translation>
<translation id="4664250907885839816">A parte depois de &quot;<ph name="ATSIGN"/>&quot; não deve conter o símbolo &quot;<ph name="INVALIDCHARACTER"/>&quot;.</translation>
<translation id="3450233048674729344">O valor deve ser menor ou igual a <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">voltar 30 segundos</translation>
<translation id="668171684555832681">Outro...</translation>
<translation id="6270583010843788609">miniatura da barra de progressão do filme</translation>
<translation id="5641012560118721995">pausar reprodução</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> arquivos</translation>
<translation id="6643016212128521049">Limpar</translation>
<translation id="7888071071722539607">Inclua um &quot;<ph name="ATSIGN"/>&quot; no endereço de e-mail. &quot;<ph name="INVALIDADDRESS"/>&quot; está com um &quot;<ph name="ATSIGN"/>&quot; faltando.</translation>
-<translation id="4851297395436456855">avanço rápido</translation>
<translation id="1088086359088493902">Segundos</translation>
<translation id="3934680773876859118">Falha ao carregar o documento PDF</translation>
<translation id="3632707345189162177">segundos restantes do filme</translation>
<translation id="6359256949422175976">miniatura da barra de progressão do filme</translation>
<translation id="8597182159515967513">cabeçalho</translation>
<translation id="6843725295806269523">sem som</translation>
-<translation id="2615751259741237794">retornar para tempo real</translation>
<translation id="2653659639078652383">Enviar</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">retrocesso rápido</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_pt-PT.xtb b/chromium/webkit/glue/resources/webkit_strings_pt-PT.xtb
index 33c711b9aa8..e5d7fac772c 100644
--- a/chromium/webkit/glue/resources/webkit_strings_pt-PT.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_pt-PT.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="pt-PT">
<translation id="4763480195061959176">vídeo</translation>
<translation id="5843503607508392247">Outra...</translation>
-<translation id="2426432199384958866">fazer regressar a transmissão do filme para tempo real</translation>
<translation id="248395913932153421">Dia</translation>
<translation id="1729654308190250600">Introduza um endereço de email que não esteja vazio.</translation>
<translation id="6015796118275082299">Ano</translation>
-<translation id="9186171386827445984">A carregar o documento: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> páginas...</translation>
<translation id="1235745349614807883">Limpar pesquisas recentes</translation>
<translation id="7223624360433298498">tempo decorrido</translation>
-<translation id="1171774979989969504">Introduza um endereço de e-mail.</translation>
+<translation id="1171774979989969504">Introduza um endereço de email.</translation>
<translation id="709897737746224366">Faça corresponder o formato pedido.</translation>
<translation id="5048533449481078685">marcador de lista</translation>
<translation id="4202807286478387388">ir para</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Introduza uma parte seguida de &quot;<ph name="ATSIGN"/>&quot;. &quot;<ph name="INVALIDADDRESS"/>&quot; está incompleto.</translation>
<translation id="2746543609216772311">O valor tem de ser <ph name="MINIMUM_DATE_OR_TIME"/> ou posterior.</translation>
<translation id="2572483411312390101">reproduzir</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">tempo do filme</translation>
<translation id="8199524924445686405">aaaa</translation>
<translation id="795667975304826397">Nenhum ficheiro selecionado</translation>
-<translation id="1320012872283894746">recuar rapidamente</translation>
<translation id="7789962463072032349">pausa</translation>
<translation id="6853785296079745596">esconder legendas ocultas</translation>
<translation id="4360991593054037559">Introduza um valor válido. Os dois valores válidos mais próximos são <ph name="VALID_VALUE_LOW"/> e <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">premir</translation>
<translation id="8244226242650769279">mapa de imagem</translation>
<translation id="310520048233152454">Introduza um URL.</translation>
-<translation id="9039488204461337220">avançar rapidamente</translation>
<translation id="4812940957355064477">Introduza um número.</translation>
<translation id="2548326553472216322">Nenhuma pesquisa recente</translation>
<translation id="1938124657309484470">O valor tem de ser <ph name="MAXIMUM_DATE_OR_TIME"/> ou anterior.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Introduza um valor válido. O campo está incompleto ou tem uma data inválida.</translation>
<translation id="3040011195152428237">link</translation>
<translation id="1014825444426747588">em branco</translation>
-<translation id="3356679314312413792">recuar 30 segundos no filme</translation>
<translation id="9050748414552849310">apresentar legendas ocultas</translation>
<translation id="4522570452068850558">Detalhes</translation>
<translation id="8451268428117625855">Seleccione um ficheiro.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Seleccione esta caixa se pretender continuar.</translation>
<translation id="8534579021159131403">Minutos</translation>
<translation id="819205353528511139">reproduzir o filme no modo de ecrã inteiro</translation>
-<translation id="8964020114565522021">Arraste o ficheiro para aqui</translation>
<translation id="4103419683916926126">Milissegundos</translation>
<translation id="838869780401515933">verificar</translation>
<translation id="2846343701378493991">1024 (Tamanho médio)</translation>
@@ -84,15 +77,17 @@
<translation id="2597378329261239068">Este documento está protegido por palavra-passe. Introduza uma palavra-passe.</translation>
<translation id="5466621249238537318">Seleccione um ou mais ficheiros.</translation>
<translation id="9132465097189459683">Outra...</translation>
+<translation id="10623998915015855">botão alternar</translation>
<translation id="8750798805984357768">Seleccione uma destas opções.</translation>
<translation id="7740050170769002709">Conteúdo HTML</translation>
<translation id="6692633176391053278">stepper</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> selecionados</translation>
<translation id="8541249477527128034">controlo multimédia</translation>
-<translation id="2226276347425096477">Encurte este texto para <ph name="MAX_CHARACTERS"/> caracteres ou menos (está actualmente a utilizar <ph name="CURRENT_LENGTH"/> caracteres).</translation>
+<translation id="2226276347425096477">Encurte este texto para <ph name="MAX_CHARACTERS"/> caracteres ou menos (está atualmente a utilizar <ph name="CURRENT_LENGTH"/> caracteres).</translation>
<translation id="6101327004457443354">reativar a faixa de áudio</translation>
<translation id="1822429046913737220">AM/PM</translation>
<translation id="1639239467298939599">A carregar</translation>
-<translation id="2908441821576996758">Introduza uma lista de endereços de e-mail separados por vírgula.</translation>
+<translation id="2908441821576996758">Introduza uma lista de endereços de email separados por vírgula.</translation>
<translation id="5939518447894949180">Repor</translation>
<translation id="1921819250265091946">dd</translation>
<translation id="2613802280814924224">Introduza um valor válido. O valor válido mais próximo é <ph name="VALID_VALUE"/>.</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Horas</translation>
<translation id="4664250907885839816">Uma parte a seguir a &quot;<ph name="ATSIGN"/>&quot; não deve conter o símbolo &quot;<ph name="INVALIDCHARACTER"/>&quot;.</translation>
<translation id="3450233048674729344">O valor tem de ser inferior ou igual a <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">recuar 30 segundos</translation>
<translation id="668171684555832681">Outros...</translation>
<translation id="6270583010843788609">botão da cronologia do filme</translation>
<translation id="5641012560118721995">interromper a reprodução</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> ficheiros</translation>
<translation id="6643016212128521049">Limpar</translation>
<translation id="7888071071722539607">Inclua um &quot;<ph name="ATSIGN"/>&quot; no endereço de email. Falta um &quot;<ph name="ATSIGN"/>&quot; em &quot;<ph name="INVALIDADDRESS"/>&quot;.</translation>
-<translation id="4851297395436456855">avanço rápido</translation>
<translation id="1088086359088493902">Segundos</translation>
<translation id="3934680773876859118">Falha ao carregar o documento em PDF</translation>
<translation id="3632707345189162177">segundos que restam ao filme</translation>
<translation id="6359256949422175976">botão do scrubber do tempo do filme</translation>
<translation id="8597182159515967513">cabeçalho</translation>
<translation id="6843725295806269523">desativar som</translation>
-<translation id="2615751259741237794">regressar ao tempo real</translation>
<translation id="2653659639078652383">Submeter</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">retrocesso rápido</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_ro.xtb b/chromium/webkit/glue/resources/webkit_strings_ro.xtb
index 32fda27e1ee..99db9732af4 100644
--- a/chromium/webkit/glue/resources/webkit_strings_ro.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_ro.xtb
@@ -3,27 +3,23 @@
<translationbundle lang="ro">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Altele...</translation>
-<translation id="2426432199384958866">reveniți la redarea în timp real a filmului transmis în flux</translation>
<translation id="248395913932153421">Zi</translation>
<translation id="1729654308190250600">Introduceți o adresă de e-mail concretă.</translation>
<translation id="6015796118275082299">An</translation>
-<translation id="9186171386827445984">Se încarcă documentul: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> (de) pagini...</translation>
<translation id="1235745349614807883">Ștergeți căutările recente</translation>
<translation id="7223624360433298498">timp scurs</translation>
<translation id="1171774979989969504">Introduceți o adresă de e-mail.</translation>
<translation id="709897737746224366">Potriviți cu formatul solicitat.</translation>
<translation id="5048533449481078685">marcator listă</translation>
-<translation id="4202807286478387388">Salt</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
+<translation id="4202807286478387388">accesați</translation>
<translation id="5307600278924710095">Introduceți o valoare urmată de semnul „<ph name="ATSIGN"/>”. Adresa „<ph name="INVALIDADDRESS"/>” nu este completă.</translation>
<translation id="2746543609216772311">Valoarea pentru dată/oră trebuie să fie <ph name="MINIMUM_DATE_OR_TIME"/> sau una ulterioară.</translation>
<translation id="2572483411312390101">redați</translation>
<translation id="8785498733064193001">începeți redarea</translation>
<translation id="7057186640035488495">durată film</translation>
<translation id="8199524924445686405">aaaa</translation>
-<translation id="795667975304826397">Nu s-au ales fișiere</translation>
-<translation id="1320012872283894746">derulați rapid înapoi</translation>
-<translation id="7789962463072032349">pauză</translation>
+<translation id="795667975304826397">Nu ați ales niciun fișier</translation>
+<translation id="7789962463072032349">întrerupeți</translation>
<translation id="6853785296079745596">ascundeți subtitrările</translation>
<translation id="4360991593054037559">Introduceți o valoare validă. Cele mai apropiate valori valide sunt <ph name="VALID_VALUE_LOW"/> și <ph name="VALID_VALUE_HIGHER"/>.</translation>
<translation id="1758486001363313524">Altele...</translation>
@@ -31,12 +27,11 @@
<translation id="1930711995431081526">stare</translation>
<translation id="658823671542763450">deschideți în ecran complet</translation>
<translation id="7720026100085573005">timp rămas</translation>
-<translation id="370665806235115550">Se încarcă...</translation>
+<translation id="370665806235115550">Se încarcă…</translation>
<translation id="2723001399770238859">audio</translation>
-<translation id="6845533974506654842">Apăsați</translation>
-<translation id="8244226242650769279">hartă cu imagini</translation>
+<translation id="6845533974506654842">apăsați</translation>
+<translation id="8244226242650769279">hartă imagine</translation>
<translation id="310520048233152454">Introduceți o adresă URL.</translation>
-<translation id="9039488204461337220">derulați rapid înainte</translation>
<translation id="4812940957355064477">Introduceți un număr.</translation>
<translation id="2548326553472216322">Nicio căutare recentă</translation>
<translation id="1938124657309484470">Valoarea pentru dată/oră trebuie să fie <ph name="MAXIMUM_DATE_OR_TIME"/> sau una anterioară.</translation>
@@ -45,11 +40,10 @@
<translation id="5164977714490026579">Valoarea trebuie să fie mai mare sau egală cu <ph name="MINIMUM"/>.</translation>
<translation id="2247351761944213033">Săptămâna <ph name="WEEKNUMBER"/>, <ph name="YEAR"/></translation>
<translation id="7740016676195725605">nu mai afișați subtitrările</translation>
-<translation id="5944544982112848342">2048 (Grad înalt)</translation>
+<translation id="5944544982112848342">2048 (nivel ridicat)</translation>
<translation id="3075154866155599887">Introduceți o valoare validă. Câmpul este incomplet sau conține o dată nevalidă.</translation>
<translation id="3040011195152428237">link</translation>
<translation id="1014825444426747588">necompletat</translation>
-<translation id="3356679314312413792">derulați filmul înapoi cu 30 de secunde</translation>
<translation id="9050748414552849310">afișați subtitrările</translation>
<translation id="4522570452068850558">Detalii</translation>
<translation id="8451268428117625855">Selectați un fișier.</translation>
@@ -64,13 +58,12 @@
<translation id="2761667185364618470">Bifați caseta dacă doriți să continuați.</translation>
<translation id="8534579021159131403">Minute</translation>
<translation id="819205353528511139">redați filmul în modul ecran complet</translation>
-<translation id="8964020114565522021">Trageți fișierul aici</translation>
<translation id="4103419683916926126">Milisecunde</translation>
-<translation id="838869780401515933">Bifați</translation>
-<translation id="2846343701378493991">1024 (Grad mediu)</translation>
+<translation id="838869780401515933">bifați</translation>
+<translation id="2846343701378493991">1024 (nivel mediu)</translation>
<translation id="1637811476055996098">Alegeți fișierele</translation>
<translation id="49969490063480558">Introduceți o valoare după semnul „<ph name="ATSIGN"/>”. Adresa „<ph name="INVALIDADDRESS"/>” nu este completă.</translation>
-<translation id="5476505524087279545">Debifați</translation>
+<translation id="5476505524087279545">debifați</translation>
<translation id="2148716181193084225">Astăzi</translation>
<translation id="2507943997699731163">Completați acest câmp.</translation>
<translation id="3785482301506746191">glisor redare film</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Acest document este protejat cu parolă. Introduceți o parolă.</translation>
<translation id="5466621249238537318">Selectați unul sau mai multe fișiere.</translation>
<translation id="9132465097189459683">Altele...</translation>
+<translation id="10623998915015855">buton de comutare</translation>
<translation id="8750798805984357768">Selectați una dintre aceste opțiuni.</translation>
<translation id="7740050170769002709">Conținut HTML</translation>
<translation id="6692633176391053278">control numeric cu incrementare/decrementare</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> selectate</translation>
<translation id="8541249477527128034">comandă media</translation>
<translation id="2226276347425096477">Micșorați acest text la cel mult <ph name="MAX_CHARACTERS"/> (de) caractere (în prezent utilizați <ph name="CURRENT_LENGTH"/> (de) caractere).</translation>
<translation id="6101327004457443354">activați sunetul înregistrării audio</translation>
@@ -97,28 +92,24 @@
<translation id="1921819250265091946">zz</translation>
<translation id="2613802280814924224">Introduceți o valoare validă. Cea mai apropiată valoare validă este <ph name="VALID_VALUE"/>.</translation>
<translation id="835897206747267392">Valoare nevalidă.</translation>
-<translation id="1842960171412779397">Selectați</translation>
+<translation id="1842960171412779397">selectați</translation>
<translation id="7673697353781729403">Ore</translation>
<translation id="4664250907885839816">Valoarea care urmează după semnul „<ph name="ATSIGN"/>” nu trebuie să conțină simbolul „<ph name="INVALIDCHARACTER"/>”.</translation>
<translation id="3450233048674729344">Valoarea trebuie să fie mai mică sau egală cu <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">înapoi cu 30 de secunde</translation>
-<translation id="668171684555832681">Altul...</translation>
+<translation id="668171684555832681">Altele...</translation>
<translation id="6270583010843788609">miniatură cronologie film</translation>
<translation id="5641012560118721995">întrerupeți redarea</translation>
<translation id="1591562245178063882">Luna aceasta</translation>
-<translation id="6119846243427417423">Activați</translation>
-<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> fișiere</translation>
+<translation id="6119846243427417423">activați</translation>
+<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> (de) fișiere</translation>
<translation id="6643016212128521049">Ștergeți</translation>
<translation id="7888071071722539607">Includeți semnul „<ph name="ATSIGN"/>” în adresa de e-mail. Din adresa „<ph name="INVALIDADDRESS"/>” lipsește semnul „<ph name="ATSIGN"/>”.</translation>
-<translation id="4851297395436456855">rapid înainte</translation>
<translation id="1088086359088493902">Secunde</translation>
-<translation id="3934680773876859118">Încărcarea documentului PDF nu a reușit</translation>
+<translation id="3934680773876859118">Documentul PDF nu a fost încărcat</translation>
<translation id="3632707345189162177">numărul secundelor rămase din film</translation>
<translation id="6359256949422175976">miniatură glisor redare film</translation>
-<translation id="8597182159515967513">titlu</translation>
+<translation id="8597182159515967513">antet</translation>
<translation id="6843725295806269523">dezactivați sunetul</translation>
-<translation id="2615751259741237794">reveniți la redarea în timp real</translation>
<translation id="2653659639078652383">Trimiteți</translation>
<translation id="3732799496749320381">ll</translation>
-<translation id="4484359737905287537">rapid înapoi</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_ru.xtb b/chromium/webkit/glue/resources/webkit_strings_ru.xtb
index 8b2e4e7dd4a..d16bed1fc24 100644
--- a/chromium/webkit/glue/resources/webkit_strings_ru.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_ru.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="ru">
<translation id="4763480195061959176">видео</translation>
<translation id="5843503607508392247">Другое…</translation>
-<translation id="2426432199384958866">передача потокового видео в реальном времени</translation>
<translation id="248395913932153421">День</translation>
<translation id="1729654308190250600">Введите адрес электронной почты.</translation>
<translation id="6015796118275082299">Год</translation>
-<translation id="9186171386827445984">Загрузка документа: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> стр.</translation>
<translation id="1235745349614807883">Очистить недавние поиски</translation>
<translation id="7223624360433298498">прошедшее время</translation>
<translation id="1171774979989969504">Введите адрес электронной почты.</translation>
<translation id="709897737746224366">Введите данные в указанном формате.</translation>
<translation id="5048533449481078685">маркер списка</translation>
<translation id="4202807286478387388">перейти</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Введите часть адреса до символа &quot;<ph name="ATSIGN"/>&quot;. Адрес &quot;<ph name="INVALIDADDRESS"/>&quot; неполный.</translation>
<translation id="2746543609216772311">Минимальное значение должно быть <ph name="MINIMUM_DATE_OR_TIME"/>.</translation>
<translation id="2572483411312390101">воспроизведение</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">продолжительность ролика</translation>
<translation id="8199524924445686405">гггг</translation>
<translation id="795667975304826397">Файл не выбран</translation>
-<translation id="1320012872283894746">перемотка назад</translation>
<translation id="7789962463072032349">Пауза</translation>
<translation id="6853785296079745596">скрыть субтитры</translation>
<translation id="4360991593054037559">Введите допустимое значение. Ближайшие допустимые значения: <ph name="VALID_VALUE_LOW"/> и <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">нажать</translation>
<translation id="8244226242650769279">графическая карта</translation>
<translation id="310520048233152454">Введите URL.</translation>
-<translation id="9039488204461337220">перемотка вперед</translation>
<translation id="4812940957355064477">Введите число.</translation>
<translation id="2548326553472216322">Нет недавних поисков</translation>
<translation id="1938124657309484470">Максимальное значение должно быть <ph name="MAXIMUM_DATE_OR_TIME"/>.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Введите верное значение. Поле не заполнено или введена недействительная дата.</translation>
<translation id="3040011195152428237">ссылка</translation>
<translation id="1014825444426747588">нет данных</translation>
-<translation id="3356679314312413792">перемотка на 30 секунд назад</translation>
<translation id="9050748414552849310">показать субтитры</translation>
<translation id="4522570452068850558">Подробнее</translation>
<translation id="8451268428117625855">Выберите файл.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Чтобы продолжить, установите этот флажок.</translation>
<translation id="8534579021159131403">Минуты</translation>
<translation id="819205353528511139">воспроизведение в полноэкранном режиме</translation>
-<translation id="8964020114565522021">Перетащите файл сюда</translation>
<translation id="4103419683916926126">Миллисекунды</translation>
<translation id="838869780401515933">поставить галочку</translation>
<translation id="2846343701378493991">1024 (Средний размер)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Документ защищен паролем. Введите пароль.</translation>
<translation id="5466621249238537318">Выберите один или несколько файлов.</translation>
<translation id="9132465097189459683">Другое…</translation>
+<translation id="10623998915015855">кнопка-переключатель</translation>
<translation id="8750798805984357768">Выберите один из вариантов.</translation>
<translation id="7740050170769002709">HTML-содержание</translation>
<translation id="6692633176391053278">счетчик</translation>
+<translation id="4975562563186953947">Выбрано: <ph name="SELECTED_COUNT"/></translation>
<translation id="8541249477527128034">управление мультимедиа</translation>
<translation id="2226276347425096477">Длина текста не должна превышать <ph name="MAX_CHARACTERS"/> симв. (сейчас <ph name="CURRENT_LENGTH"/> симв.).</translation>
<translation id="6101327004457443354">включение звуковой дорожки</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Часы</translation>
<translation id="4664250907885839816">Часть адреса после символа &quot;<ph name="ATSIGN"/>&quot; не должна содержать символ &quot;<ph name="INVALIDCHARACTER"/>&quot;.</translation>
<translation id="3450233048674729344">Значение должно быть меньше или равно <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">назад на 30 секунд</translation>
<translation id="668171684555832681">Другой...</translation>
<translation id="6270583010843788609">бегунок временной шкалы</translation>
<translation id="5641012560118721995">пауза</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423">Число файлов: <ph name="NUMBER_OF_FILES"/></translation>
<translation id="6643016212128521049">Очистить</translation>
<translation id="7888071071722539607">Адрес электронной почты должен содержать символ &quot;<ph name="ATSIGN"/>&quot;. В адресе &quot;<ph name="INVALIDADDRESS"/>&quot; отсутствует символ &quot;<ph name="ATSIGN"/>&quot;.</translation>
-<translation id="4851297395436456855">перемотка вперед</translation>
<translation id="1088086359088493902">Секунды</translation>
<translation id="3934680773876859118">Не удалось загрузить документ PDF</translation>
<translation id="3632707345189162177">оставшееся время в секундах</translation>
<translation id="6359256949422175976">бегунок полосы прокрутки</translation>
<translation id="8597182159515967513">заголовок</translation>
<translation id="6843725295806269523">отключить звук</translation>
-<translation id="2615751259741237794">вернуться в режим реального времени</translation>
<translation id="2653659639078652383">Отправить</translation>
<translation id="3732799496749320381">мм</translation>
-<translation id="4484359737905287537">перемотка назад</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_sk.xtb b/chromium/webkit/glue/resources/webkit_strings_sk.xtb
index 27a2ad132b0..96f7e3ac9e4 100644
--- a/chromium/webkit/glue/resources/webkit_strings_sk.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_sk.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="sk">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Iné...</translation>
-<translation id="2426432199384958866">vrátiť sa k prehrávaniu v reálnom čase</translation>
<translation id="248395913932153421">Deň</translation>
<translation id="1729654308190250600">Zadajte e-mailovú adresu, ktorá nie je prázdna hodnota.</translation>
<translation id="6015796118275082299">Rok</translation>
-<translation id="9186171386827445984">Prebieha načítavanie dokumentu: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> stránok...</translation>
<translation id="1235745349614807883">Vyčistiť posledné vyhľadávania</translation>
<translation id="7223624360433298498">uplynutý čas</translation>
<translation id="1171774979989969504">Zadajte e-mailovú adresu.</translation>
<translation id="709897737746224366">Zadajte hodnotu zodpovedajúcu požadovanému formátu.</translation>
<translation id="5048533449481078685">ukazovateľ v zozname</translation>
<translation id="4202807286478387388">skok</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/> <ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Zadajte časť pred znakom <ph name="ATSIGN"/>. Adresa <ph name="INVALIDADDRESS"/> je neúplná.</translation>
<translation id="2746543609216772311">Hodnota musí byť <ph name="MINIMUM_DATE_OR_TIME"/> alebo neskôr.</translation>
<translation id="2572483411312390101">prehrať</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">čas filmu</translation>
<translation id="8199524924445686405">rrrr</translation>
<translation id="795667975304826397">Nie je vybratý žiadny súbor</translation>
-<translation id="1320012872283894746">rýchlo pretáčať dozadu</translation>
<translation id="7789962463072032349">pozastaviť</translation>
<translation id="6853785296079745596">skryť skryté titulky</translation>
<translation id="4360991593054037559">Zadajte platnú hodnotu. Najbližšie platné hodnoty sú <ph name="VALID_VALUE_LOW"/> a <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -35,8 +31,7 @@
<translation id="2723001399770238859">zvuk</translation>
<translation id="6845533974506654842">stlačiť</translation>
<translation id="8244226242650769279">mapa obrázka</translation>
-<translation id="310520048233152454">Zadajte adresu URL.</translation>
-<translation id="9039488204461337220">rýchlo pretáčať dopredu</translation>
+<translation id="310520048233152454">Zadajte webovú adresu.</translation>
<translation id="4812940957355064477">Zadajte číslo.</translation>
<translation id="2548326553472216322">Žiadne posledné vyhľadávania</translation>
<translation id="1938124657309484470">Hodnota musí byť <ph name="MAXIMUM_DATE_OR_TIME"/> alebo skôr.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Zadajte platnú hodnotu. Pole obsahuje neúplnú hodnotu alebo neplatný dátum.</translation>
<translation id="3040011195152428237">odkaz</translation>
<translation id="1014825444426747588">prázdne</translation>
-<translation id="3356679314312413792">pretočiť film dozadu o 30 sekúnd</translation>
<translation id="9050748414552849310">zobraziť skryté titulky</translation>
<translation id="4522570452068850558">Podrobnosti</translation>
<translation id="8451268428117625855">Vyberte súbor.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Ak chcete pokračovať, začiarknite toto políčko.</translation>
<translation id="8534579021159131403">Minúty</translation>
<translation id="819205353528511139">prehrať film v režime celej obrazovky</translation>
-<translation id="8964020114565522021">Súbor presunúť sem</translation>
<translation id="4103419683916926126">Milisekundy</translation>
<translation id="838869780401515933">označiť</translation>
<translation id="2846343701378493991">1024 (stredný stupeň)</translation>
@@ -84,16 +77,18 @@
<translation id="2597378329261239068">Tento dokument je chránený heslom. Zadajte heslo.</translation>
<translation id="5466621249238537318">Vyberte jeden alebo viac súborov.</translation>
<translation id="9132465097189459683">Iné...</translation>
+<translation id="10623998915015855">tlačidlo prepínania</translation>
<translation id="8750798805984357768">Vyberte jednu z týchto možností.</translation>
<translation id="7740050170769002709">Obsah HTML</translation>
<translation id="6692633176391053278">stepper</translation>
+<translation id="4975562563186953947">Počet vybraných položiek: <ph name="SELECTED_COUNT"/></translation>
<translation id="8541249477527128034">ovládanie médií</translation>
<translation id="2226276347425096477">Tento text musíte skrátiť na <ph name="MAX_CHARACTERS"/> znakov alebo menej (súčasný počet znakov: <ph name="CURRENT_LENGTH"/>).</translation>
<translation id="6101327004457443354">obnoviť zvukovú stopu</translation>
<translation id="1822429046913737220">dop. / odp.</translation>
<translation id="1639239467298939599">Prebieha načítavanie</translation>
<translation id="2908441821576996758">Zadajte zoznam e-mailových adries oddelených čiarkou.</translation>
-<translation id="5939518447894949180">Vynulovať</translation>
+<translation id="5939518447894949180">Obnoviť</translation>
<translation id="1921819250265091946">dd</translation>
<translation id="2613802280814924224">Zadajte platnú hodnotu. Najbližšia platná hodnota je <ph name="VALID_VALUE"/>.</translation>
<translation id="835897206747267392">Neplatná hodnota.</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Hodiny</translation>
<translation id="4664250907885839816">Časť za znakom <ph name="ATSIGN"/> by nemala obsahovať symbol <ph name="INVALIDCHARACTER"/>.</translation>
<translation id="3450233048674729344">Hodnota musí byť menšia alebo rovná hodnote <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">pretočiť dozadu o 30 sekúnd</translation>
<translation id="668171684555832681">Iný...</translation>
<translation id="6270583010843788609">časová os filmu</translation>
<translation id="5641012560118721995">pozastaviť prehrávanie</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423">Počet súborov: <ph name="NUMBER_OF_FILES"/></translation>
<translation id="6643016212128521049">Vymazať</translation>
<translation id="7888071071722539607">Uveďte v e-mailovej adrese znak <ph name="ATSIGN"/>. V adrese <ph name="INVALIDADDRESS"/> znak <ph name="ATSIGN"/> chýba.</translation>
-<translation id="4851297395436456855">pretočiť dopredu</translation>
<translation id="1088086359088493902">Sekundy</translation>
<translation id="3934680773876859118">Načítanie dokumentu PDF zlyhalo</translation>
<translation id="3632707345189162177">zostávajúci čas do konca filmu v sekundách</translation>
<translation id="6359256949422175976">posúvač času filmu</translation>
<translation id="8597182159515967513">nadpis</translation>
<translation id="6843725295806269523">stlmiť</translation>
-<translation id="2615751259741237794">návrat do reálneho času</translation>
<translation id="2653659639078652383">Odoslať</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">pretočiť dozadu</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_sl.xtb b/chromium/webkit/glue/resources/webkit_strings_sl.xtb
index c803967cc0a..2fc88e755d3 100644
--- a/chromium/webkit/glue/resources/webkit_strings_sl.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_sl.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="sl">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Drugo ...</translation>
-<translation id="2426432199384958866">vrnitev predvajanja filma iz pretakanja nazaj na dejanski čas</translation>
<translation id="248395913932153421">Dan</translation>
<translation id="1729654308190250600">Vnesite e-poštni naslov (polje ne sme biti prazno).</translation>
<translation id="6015796118275082299">Leto</translation>
-<translation id="9186171386827445984">Nalaganje dokumenta: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> strani ...</translation>
<translation id="1235745349614807883">Počisti zadnja iskanja</translation>
<translation id="7223624360433298498">pretečeni čas</translation>
<translation id="1171774979989969504">Vnesite e-poštni naslov</translation>
<translation id="709897737746224366">Poskrbite za ujemanje z zahtevano obliko.</translation>
<translation id="5048533449481078685">označevalnik seznama</translation>
<translation id="4202807286478387388">skoči</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Vnesite nekaj in nato <ph name="ATSIGN"/>. Naslov »<ph name="INVALIDADDRESS"/>« je nepopoln.</translation>
<translation id="2746543609216772311">Vrednost mora biti <ph name="MINIMUM_DATE_OR_TIME"/> ali pozneje.</translation>
<translation id="2572483411312390101">predvajanje</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">čas filma</translation>
<translation id="8199524924445686405">llll</translation>
<translation id="795667975304826397">Nobena datoteka ni izbrana</translation>
-<translation id="1320012872283894746">hitro iskanje nazaj</translation>
<translation id="7789962463072032349">premor</translation>
<translation id="6853785296079745596">skrivanje podnapisov</translation>
<translation id="4360991593054037559">Vnesite veljavno vrednost. Najbližji veljavni vrednosti sta <ph name="VALID_VALUE_LOW"/> in <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">pritisni</translation>
<translation id="8244226242650769279">slikovni zemljevid</translation>
<translation id="310520048233152454">Vnesite URL.</translation>
-<translation id="9039488204461337220">hitro iskanje naprej</translation>
<translation id="4812940957355064477">Vnesite številko.</translation>
<translation id="2548326553472216322">Ni zadnjih iskanj</translation>
<translation id="1938124657309484470">Vrednost mora biti <ph name="MAXIMUM_DATE_OR_TIME"/> ali prej.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Vnesite veljavno vrednost. Vnos v polje je nepopoln ali vsebuje neveljaven datum.</translation>
<translation id="3040011195152428237">povezava</translation>
<translation id="1014825444426747588">prazno</translation>
-<translation id="3356679314312413792">previjanje filma nazaj za 30 sekund</translation>
<translation id="9050748414552849310">prikaz podnapisov</translation>
<translation id="4522570452068850558">Podrobnosti</translation>
<translation id="8451268428117625855">Izberite datoteko.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Potrdite to polje, če želite nadaljevati.</translation>
<translation id="8534579021159131403">Minute</translation>
<translation id="819205353528511139">predvajanje filma v celozaslonskem načinu</translation>
-<translation id="8964020114565522021">Datoteko povleci sem</translation>
<translation id="4103419683916926126">Milisekunde</translation>
<translation id="838869780401515933">potrdi</translation>
<translation id="2846343701378493991">1024 (srednja stopnja)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Dokument je zaščiten z geslom. Vnesite geslo.</translation>
<translation id="5466621249238537318">Izberite eno ali več datotek.</translation>
<translation id="9132465097189459683">Drugo ...</translation>
+<translation id="10623998915015855">preklopni gumb</translation>
<translation id="8750798805984357768">Izberite eno od teh možnosti.</translation>
<translation id="7740050170769002709">Vsebina HTML</translation>
<translation id="6692633176391053278">kontrolnik</translation>
+<translation id="4975562563186953947">Št. izbranih: <ph name="SELECTED_COUNT"/></translation>
<translation id="8541249477527128034">nadziranje predstavnosti</translation>
<translation id="2226276347425096477">Skrajšajte to besedilo na <ph name="MAX_CHARACTERS"/> znakov ali manj (trenutno uporabljate <ph name="CURRENT_LENGTH"/> znakov).</translation>
<translation id="6101327004457443354">vklop zvoka za zvočni posnetek</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Ure</translation>
<translation id="4664250907885839816">Del po »<ph name="ATSIGN"/>« ne sme vsebovati znaka »<ph name="INVALIDCHARACTER"/>«.</translation>
<translation id="3450233048674729344">Vrednost mora biti manjša od <ph name="MAXIMUM"/> ali enaka.</translation>
-<translation id="3471999216963526757">30 sekund nazaj</translation>
<translation id="668171684555832681">Drugo ...</translation>
<translation id="6270583010843788609">sličica časovne premice filma</translation>
<translation id="5641012560118721995">začasna ustavitev predvajanja</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423">Število datotek: <ph name="NUMBER_OF_FILES"/></translation>
<translation id="6643016212128521049">Počisti</translation>
<translation id="7888071071722539607">V e-poštnem naslovu mora biti znak »<ph name="ATSIGN"/>«. V naslovu »<ph name="INVALIDADDRESS"/>« manjka »<ph name="ATSIGN"/>«.</translation>
-<translation id="4851297395436456855">previjanje naprej</translation>
<translation id="1088086359088493902">Sekunde</translation>
<translation id="3934680773876859118">Dokumenta PDF ni bilo mogoče naložiti</translation>
<translation id="3632707345189162177">preostale sekunde filma</translation>
<translation id="6359256949422175976">sličica časovnega krmilnika za predvajanje filma</translation>
<translation id="8597182159515967513">naslov</translation>
<translation id="6843725295806269523">nemo</translation>
-<translation id="2615751259741237794">nazaj na dejanski čas</translation>
<translation id="2653659639078652383">Pošlji</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">previjanje nazaj</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_sr.xtb b/chromium/webkit/glue/resources/webkit_strings_sr.xtb
index 0e21d2fd96e..0938474b026 100644
--- a/chromium/webkit/glue/resources/webkit_strings_sr.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_sr.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="sr">
<translation id="4763480195061959176">видео</translation>
<translation id="5843503607508392247">Друго...</translation>
-<translation id="2426432199384958866">вратите филм који се стримује у реално време</translation>
<translation id="248395913932153421">Дан</translation>
-<translation id="1729654308190250600">Унесите адресу е-поште која није празна.</translation>
+<translation id="1729654308190250600">Унесите имејл адресу која није празна.</translation>
<translation id="6015796118275082299">Година</translation>
-<translation id="9186171386827445984">Учитавање документа: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> странице(а)...</translation>
<translation id="1235745349614807883">Обриши недавне претраге</translation>
<translation id="7223624360433298498">протекло време</translation>
-<translation id="1171774979989969504">Унесите адресу е-поште.</translation>
+<translation id="1171774979989969504">Унесите имејл адресу.</translation>
<translation id="709897737746224366">Изаберите захтевани формат.</translation>
<translation id="5048533449481078685">означивач листе</translation>
<translation id="4202807286478387388">прескочи</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Унесите неки део пре „<ph name="ATSIGN"/>“. Адреса „<ph name="INVALIDADDRESS"/>“ је непотпуна.</translation>
<translation id="2746543609216772311">Вредност мора да буде <ph name="MINIMUM_DATE_OR_TIME"/> или новија.</translation>
<translation id="2572483411312390101">пустите</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">трајање филма</translation>
<translation id="8199524924445686405">гггг</translation>
<translation id="795667975304826397">Није одабрано</translation>
-<translation id="1320012872283894746">брзо премотајте уназад</translation>
<translation id="7789962463072032349">паузирај</translation>
<translation id="6853785296079745596">сакријте опционални титл</translation>
<translation id="4360991593054037559">Унесите важећу вредност. Две најближе важеће вредности су <ph name="VALID_VALUE_LOW"/> и <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">притисни</translation>
<translation id="8244226242650769279">мапа слике</translation>
<translation id="310520048233152454">Унесите URL адресу.</translation>
-<translation id="9039488204461337220">брзо премотајте унапред</translation>
<translation id="4812940957355064477">Унесите број.</translation>
<translation id="2548326553472216322">Нема недавних претрага</translation>
<translation id="1938124657309484470">Вредност мора да буде <ph name="MAXIMUM_DATE_OR_TIME"/> или старија.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Унесите важећу вредност. Поље није попуњено или садржи неважећи датум.</translation>
<translation id="3040011195152428237">веза</translation>
<translation id="1014825444426747588">празно</translation>
-<translation id="3356679314312413792">премотајте филм уназад 30 секунди</translation>
<translation id="9050748414552849310">приказивање опционалног титла</translation>
<translation id="4522570452068850558">Детаљи</translation>
<translation id="8451268428117625855">Изаберите датотеку.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Потврдите избор у овом пољу за потврду уколико желите да наставите.</translation>
<translation id="8534579021159131403">Минути</translation>
<translation id="819205353528511139">пустите филм у режиму целог екрана</translation>
-<translation id="8964020114565522021">Превуците датотеку овде</translation>
<translation id="4103419683916926126">Милисекунде</translation>
<translation id="838869780401515933">изабери</translation>
<translation id="2846343701378493991">1024 (средњи степен)</translation>
@@ -84,15 +77,17 @@
<translation id="2597378329261239068">Овај документ је заштићен лозинком. Унесите лозинку.</translation>
<translation id="5466621249238537318">Изаберите једну или више датотека.</translation>
<translation id="9132465097189459683">Друго...</translation>
+<translation id="10623998915015855">дугме за укључивање/искључивање</translation>
<translation id="8750798805984357768">Изаберите неку од ових опција.</translation>
<translation id="7740050170769002709">HTML садржај</translation>
<translation id="6692633176391053278">контрола за промене у корацима</translation>
+<translation id="4975562563186953947">Изабрано: <ph name="SELECTED_COUNT"/></translation>
<translation id="8541249477527128034">контрола за медије</translation>
<translation id="2226276347425096477">Скратите овај текст на <ph name="MAX_CHARACTERS"/> знак(ов)а или мање (тренутно користите <ph name="CURRENT_LENGTH"/> знак(ов)а).</translation>
<translation id="6101327004457443354">укључите звук аудио снимка</translation>
<translation id="1822429046913737220">пре подне/по подне</translation>
<translation id="1639239467298939599">Учитавање</translation>
-<translation id="2908441821576996758">Унесите листу адреса е-поште раздвојених зарезима.</translation>
+<translation id="2908441821576996758">Унесите листу имејл адреса раздвојених зарезима.</translation>
<translation id="5939518447894949180">Ресетуј</translation>
<translation id="1921819250265091946">дд</translation>
<translation id="2613802280814924224">Унесите важећу вредност. Најближа важећа вредност је <ph name="VALID_VALUE"/>.</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Сати</translation>
<translation id="4664250907885839816">Део после „<ph name="ATSIGN"/>“ не треба да садржи симбол „<ph name="INVALIDCHARACTER"/>“.</translation>
<translation id="3450233048674729344">Вредност сме да буде највише <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">уназад 30 секунди</translation>
<translation id="668171684555832681">Друго...</translation>
<translation id="6270583010843788609">клизач на временској траци филма</translation>
<translation id="5641012560118721995">паузирајте репродукцију</translation>
@@ -109,16 +103,13 @@
<translation id="6119846243427417423">активирај</translation>
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> датотеке(а)</translation>
<translation id="6643016212128521049">Обриши</translation>
-<translation id="7888071071722539607">Уврстите „<ph name="ATSIGN"/>“ у адресу е-поште. У адреси е-поште „<ph name="INVALIDADDRESS"/>“ недостаје „<ph name="ATSIGN"/>“.</translation>
-<translation id="4851297395436456855">премотајте унапред</translation>
+<translation id="7888071071722539607">Уврстите „<ph name="ATSIGN"/>“ у имејл адресу. У адреси е-поште „<ph name="INVALIDADDRESS"/>“ недостаје „<ph name="ATSIGN"/>“.</translation>
<translation id="1088086359088493902">Секунде</translation>
<translation id="3934680773876859118">Учитавање PDF документа није успело</translation>
<translation id="3632707345189162177">број преосталих секунди филма</translation>
<translation id="6359256949422175976">клизач за трајање филма</translation>
<translation id="8597182159515967513">наслов</translation>
<translation id="6843725295806269523">искључи звук</translation>
-<translation id="2615751259741237794">вратите у реално време</translation>
<translation id="2653659639078652383">Пошаљи</translation>
<translation id="3732799496749320381">мм</translation>
-<translation id="4484359737905287537">премотајте уназад</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_sv.xtb b/chromium/webkit/glue/resources/webkit_strings_sv.xtb
index 2255450e152..1b2461a5a93 100644
--- a/chromium/webkit/glue/resources/webkit_strings_sv.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_sv.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="sv">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Annat ...</translation>
-<translation id="2426432199384958866">återställ direktuppspelad film till realtid</translation>
<translation id="248395913932153421">Dag</translation>
<translation id="1729654308190250600">Ange en e-postadress som inte är tom.</translation>
<translation id="6015796118275082299">År</translation>
-<translation id="9186171386827445984">Läser in dokument: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> sidor...</translation>
<translation id="1235745349614807883">Rensa senaste sökningar</translation>
<translation id="7223624360433298498">förfluten tid</translation>
<translation id="1171774979989969504">Ange en e-postadress.</translation>
<translation id="709897737746224366">Matcha det format som anges.</translation>
<translation id="5048533449481078685">listmarkör</translation>
<translation id="4202807286478387388">fortsätta</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Ange en del följt av <ph name="ATSIGN"/>. <ph name="INVALIDADDRESS"/> är ofullständig.</translation>
<translation id="2746543609216772311">Värdet måste vara <ph name="MINIMUM_DATE_OR_TIME"/> eller senare.</translation>
<translation id="2572483411312390101">spela upp</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">filmtid</translation>
<translation id="8199524924445686405">åååå</translation>
<translation id="795667975304826397">Ingen fil har valts</translation>
-<translation id="1320012872283894746">söka snabbt bakåt</translation>
<translation id="7789962463072032349">paus</translation>
<translation id="6853785296079745596">dölj textning</translation>
<translation id="4360991593054037559">Ange ett giltigt värde. De två närmaste giltiga värdena är <ph name="VALID_VALUE_LOW"/> och <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">tryck</translation>
<translation id="8244226242650769279">bildkarta</translation>
<translation id="310520048233152454">Ange en webbadress.</translation>
-<translation id="9039488204461337220">söka snabbt framåt</translation>
<translation id="4812940957355064477">Ange ett nummer.</translation>
<translation id="2548326553472216322">Inga nya sökningar</translation>
<translation id="1938124657309484470">Värdet måste vara <ph name="MAXIMUM_DATE_OR_TIME"/> eller tidigare.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Ange ett giltigt värde. Fältet är ofullständigt eller innehåller ett ogiltigt datum.</translation>
<translation id="3040011195152428237">länk</translation>
<translation id="1014825444426747588">tomt</translation>
-<translation id="3356679314312413792">sök 30 sekunder bakåt i filmen</translation>
<translation id="9050748414552849310">visa textning</translation>
<translation id="4522570452068850558">Info</translation>
<translation id="8451268428117625855">Välj en fil.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Markera den här kryssrutan om du vill fortsätta.</translation>
<translation id="8534579021159131403">Minuter</translation>
<translation id="819205353528511139">spela upp filmen i helskärmsläge</translation>
-<translation id="8964020114565522021">Dra filen hit</translation>
<translation id="4103419683916926126">Millisekunder</translation>
<translation id="838869780401515933">kryssa för</translation>
<translation id="2846343701378493991">1024 (medel)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Dokumentet är lösenordsskyddat. Ange ett lösenord.</translation>
<translation id="5466621249238537318">Välj en eller flera filer.</translation>
<translation id="9132465097189459683">Annat ...</translation>
+<translation id="10623998915015855">växlingsknapp</translation>
<translation id="8750798805984357768">Välj ett av följande alternativ.</translation>
<translation id="7740050170769002709">HTML-innehåll</translation>
<translation id="6692633176391053278">knappreglage</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> valda</translation>
<translation id="8541249477527128034">mediekontroll</translation>
<translation id="2226276347425096477">Förkorta texten till <ph name="MAX_CHARACTERS"/> tecken eller mindre (nu är texten <ph name="CURRENT_LENGTH"/> tecken).</translation>
<translation id="6101327004457443354">spela upp ljudspåret</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Timmar</translation>
<translation id="4664250907885839816">En del efter <ph name="ATSIGN"/> får inte innehålla symbolen <ph name="INVALIDCHARACTER"/>.</translation>
<translation id="3450233048674729344">Värdet måste vara mindre än eller lika med <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">30 sekunder bakåt</translation>
<translation id="668171684555832681">Annan...</translation>
<translation id="6270583010843788609">miniatyr för filmtidslinje</translation>
<translation id="5641012560118721995">pausa uppspelning</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> filer</translation>
<translation id="6643016212128521049">Rensa</translation>
<translation id="7888071071722539607">Inkludera ett <ph name="ATSIGN"/> i e-postadressen. <ph name="INVALIDADDRESS"/> saknar ett <ph name="ATSIGN"/>.</translation>
-<translation id="4851297395436456855">snabbspola framåt</translation>
<translation id="1088086359088493902">Sekunder</translation>
<translation id="3934680773876859118">Det gick inte att läsa in PDF-dokumentet</translation>
<translation id="3632707345189162177">antal sekunder kvar av filmen</translation>
<translation id="6359256949422175976">miniatyr för filmtidsreglage</translation>
<translation id="8597182159515967513">rubrik</translation>
<translation id="6843725295806269523">ljud av</translation>
-<translation id="2615751259741237794">återgå till realtid</translation>
<translation id="2653659639078652383">Skicka</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">snabbspola bakåt</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_sw.xtb b/chromium/webkit/glue/resources/webkit_strings_sw.xtb
index 42edf85bbcb..4e3c640a374 100644
--- a/chromium/webkit/glue/resources/webkit_strings_sw.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_sw.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="sw">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Nyingine...</translation>
-<translation id="2426432199384958866">rejesha utiririshaji wa filamu inavyofanyika</translation>
<translation id="248395913932153421">Siku</translation>
-<translation id="1729654308190250600">Tafadhali ingiza anwani ya barua pepe ambayo sio tupu.</translation>
+<translation id="1729654308190250600">Tafadhali jaza sehemu ya anwani ya barua pepe.</translation>
<translation id="6015796118275082299">Mwaka</translation>
-<translation id="9186171386827445984">Inapakia hati: Kurasa <ph name="PAGE_NUMBER"/> / <ph name="NUMBER_OF_PAGES"/>...</translation>
<translation id="1235745349614807883">Futa Utafutaji wa Hivi Karibuni</translation>
<translation id="7223624360433298498">muda uliokwisha</translation>
-<translation id="1171774979989969504">Tafadhali ingiza anwani ya barua pepe.</translation>
+<translation id="1171774979989969504">Tafadhali weka anwani ya barua pepe.</translation>
<translation id="709897737746224366">Tafadhali linganisha umbizo lililoombwa.</translation>
<translation id="5048533449481078685">kialamishi orodha</translation>
<translation id="4202807286478387388">ruka</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Tafadhali ingiza sehemu ikifuatiwa na '<ph name="ATSIGN"/>'. '<ph name="INVALIDADDRESS"/>' haijakamilika.</translation>
<translation id="2746543609216772311">Thamani lazima iwe <ph name="MINIMUM_DATE_OR_TIME"/> au baadaye.</translation>
<translation id="2572483411312390101">cheza</translation>
@@ -22,8 +19,7 @@
<translation id="7057186640035488495">muda wa filamu</translation>
<translation id="8199524924445686405">yyyy</translation>
<translation id="795667975304826397">Hakuna faili iliyochaguliwa</translation>
-<translation id="1320012872283894746">omba kurejea haraka</translation>
-<translation id="7789962463072032349">pumzisha</translation>
+<translation id="7789962463072032349">Sitisha</translation>
<translation id="6853785296079745596">ficha manukuu yanayoweza kuonyeshwa</translation>
<translation id="4360991593054037559">Tafadhali ingiza thamani halali. Thamani mbili halali za karibu ni <ph name="VALID_VALUE_LOW"/> na <ph name="VALID_VALUE_HIGHER"/>.</translation>
<translation id="1758486001363313524">Nyingine...</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">bofya</translation>
<translation id="8244226242650769279">ramani ya picha</translation>
<translation id="310520048233152454">Tafadhali ingiza URL.</translation>
-<translation id="9039488204461337220">omba upelekaji mbele wa haraka</translation>
<translation id="4812940957355064477">Tafadhali ingiza nambari.</translation>
<translation id="2548326553472216322">Hakuna utafutaji wa hivi karibuni</translation>
<translation id="1938124657309484470">Thamani lazima iwe <ph name="MAXIMUM_DATE_OR_TIME"/> au mapema.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Tafadhali ingiza thamani halali. Uga umekamilika au una tarehe batili.</translation>
<translation id="3040011195152428237">kiungo</translation>
<translation id="1014825444426747588">tupu</translation>
-<translation id="3356679314312413792">omba kurejea kwa filamu kwa sekunde 30</translation>
<translation id="9050748414552849310">onyesha manakuu yaliyofichwa</translation>
<translation id="4522570452068850558">Maelezo</translation>
<translation id="8451268428117625855">Tafadhali chagua faili.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Tafadhali angalia kikasha hiki iwapo unataka kuendelea.</translation>
<translation id="8534579021159131403">Dakika</translation>
<translation id="819205353528511139">cheza filamu katika hali ya skrini kamili</translation>
-<translation id="8964020114565522021">Vuta faili hapa</translation>
<translation id="4103419683916926126">nukta</translation>
<translation id="838869780401515933">chunguza</translation>
<translation id="2846343701378493991">1024 (Gredi Wastani)</translation>
@@ -84,15 +77,17 @@
<translation id="2597378329261239068">Hati hii imelindwa kwa nenosiri. Tafadhali ingiza nenosiri.</translation>
<translation id="5466621249238537318">Tafadhali chagua faili moja au zaidi.</translation>
<translation id="9132465097189459683">Nyingine...</translation>
+<translation id="10623998915015855">kitufe cha kugeuza</translation>
<translation id="8750798805984357768">Tafadhali chagua moja wapo ya chaguo hizi.</translation>
<translation id="7740050170769002709">Maudhui ya HTML</translation>
<translation id="6692633176391053278">stepper</translation>
+<translation id="4975562563186953947">Vipengee <ph name="SELECTED_COUNT"/> vimechaguliwa</translation>
<translation id="8541249477527128034">udhibiti wa vyombo vya habari</translation>
<translation id="2226276347425096477">Tafadhali fupisha maandishi haya hadi vibambo <ph name="MAX_CHARACTERS"/> au chini (kwa sasa unatumia vibambo <ph name="CURRENT_LENGTH"/> ).</translation>
<translation id="6101327004457443354">rejesha sauti ya wimbo</translation>
<translation id="1822429046913737220">AM / PM</translation>
<translation id="1639239467298939599">Inapakia</translation>
-<translation id="2908441821576996758">Tafadhali ingiza orodha iliyotenganishwa kwa koma ya anwani za barua pepe.</translation>
+<translation id="2908441821576996758">Tafadhali weka orodha ya anwani za barua pepe zilizotenganishwa kwa vikomo.</translation>
<translation id="5939518447894949180">Weka upya</translation>
<translation id="1921819250265091946">dd</translation>
<translation id="2613802280814924224">Tafadhali ingiza thamani halali.Thamani halali ya karibu ni <ph name="VALID_VALUE"/>.</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Saa</translation>
<translation id="4664250907885839816">Sehemu inayofuata '<ph name="ATSIGN"/>' haipaswi kuwa na alama ya '<ph name="INVALIDCHARACTER"/>'.</translation>
<translation id="3450233048674729344">Lazima thamani iwe chache kuliko au sawa na <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">rejea baada ya sekunde 30</translation>
<translation id="668171684555832681">Mengine...</translation>
<translation id="6270583010843788609">kijipicha cha muda wa filamu</translation>
<translation id="5641012560118721995">sitisha kucheza</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423">faili <ph name="NUMBER_OF_FILES"/></translation>
<translation id="6643016212128521049">Futa</translation>
<translation id="7888071071722539607">Tafadhali jumuisha '<ph name="ATSIGN"/>' katika anwani ya barua pepe. '<ph name="INVALIDADDRESS"/>' inakosa '<ph name="ATSIGN"/>'.</translation>
-<translation id="4851297395436456855">peleka mbele haraka</translation>
<translation id="1088086359088493902">Sekunde</translation>
<translation id="3934680773876859118">Imeshindwa kupakia hati ya PDF</translation>
<translation id="3632707345189162177">idadi ya sekunde zinazosalia za filamu</translation>
<translation id="6359256949422175976">kijipicha cha kitelezi cha muda wa filamu</translation>
<translation id="8597182159515967513">kichwa</translation>
<translation id="6843725295806269523">nyamazisha</translation>
-<translation id="2615751259741237794">rejea kwenye muda halisi</translation>
<translation id="2653659639078652383">Wasilisha</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">peleka nyuma haraka</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_ta.xtb b/chromium/webkit/glue/resources/webkit_strings_ta.xtb
index 234b6f7cfe8..ed7e5dbba54 100644
--- a/chromium/webkit/glue/resources/webkit_strings_ta.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_ta.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="ta">
<translation id="4763480195061959176">வீடியோ</translation>
<translation id="5843503607508392247">மற்றவை…</translation>
-<translation id="2426432199384958866">ஸ்ட்ரீமிங் மூவியை நிகழ்நேரத்திற்கு மீட்டமை</translation>
<translation id="248395913932153421">நாள்</translation>
<translation id="1729654308190250600">காலி அல்லாத மின்னஞ்சல் முகவரியை உள்ளிடவும்.</translation>
<translation id="6015796118275082299">ஆண்டு</translation>
-<translation id="9186171386827445984">ஆவணத்தை ஏற்றுகிறது: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> பக்கங்கள்...</translation>
<translation id="1235745349614807883">சமீபத்திய தேடல்களை சுத்தமாக்கு</translation>
<translation id="7223624360433298498">முடிவடைந்த நேரம்</translation>
<translation id="1171774979989969504">ஒரு மின்னஞ்சல் முகவரியை உள்ளிடவும்.</translation>
<translation id="709897737746224366">கோரிய வடிவமைப்பில் தருக.</translation>
<translation id="5048533449481078685">பட்டியல் குறிப்பான்</translation>
<translation id="4202807286478387388">தாவு</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">'<ph name="ATSIGN"/>' ஐத் தொடர்ந்து ஒரு பகுதியை உள்ளிடவும். '<ph name="INVALIDADDRESS"/>' முழுமைப் பெறாமல் உள்ளது.</translation>
<translation id="2746543609216772311">மதிப்பானது <ph name="MINIMUM_DATE_OR_TIME"/> அல்லது அதற்குப் பின்பு இருக்க வேண்டும்.</translation>
<translation id="2572483411312390101">இயக்கு</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">மூவி நேரம்</translation>
<translation id="8199524924445686405">yyyy</translation>
<translation id="795667975304826397">எந்த கோப்பும் தேர்ந்தெடுக்கப்படவில்லை</translation>
-<translation id="1320012872283894746">விரைவாகப் பின்செல்</translation>
<translation id="7789962463072032349">இடைநிறுத்து</translation>
<translation id="6853785296079745596">மூடப்பட்ட தலைப்புகளை மறை</translation>
<translation id="4360991593054037559">சரியான மதிப்பை உள்ளிடவும். <ph name="VALID_VALUE_LOW"/> மற்றும் <ph name="VALID_VALUE_HIGHER"/> ஆகியவை மிக நெருக்கமான சரியான இரண்டு மதிப்புகளாகும்.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">அழுத்துக</translation>
<translation id="8244226242650769279">பட மேப்</translation>
<translation id="310520048233152454">URL ஐ உள்ளிடுக.</translation>
-<translation id="9039488204461337220">விரைவாக முன்செல்</translation>
<translation id="4812940957355064477">எண்ணை உள்ளிடுக.</translation>
<translation id="2548326553472216322">சமீபத்திய தேடல்கள் எதுவுமில்லை</translation>
<translation id="1938124657309484470">மதிப்பு <ph name="MAXIMUM_DATE_OR_TIME"/> அல்லது அதற்கு முன்பு இருக்க வேண்டும்.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">சரியான மதிப்பை உள்ளிடவும். இந்தப் புலம் முழுமையற்றதாக உள்ளது அல்லது தவறான தேதியைக் கொண்டுள்ளது.</translation>
<translation id="3040011195152428237">இணைப்பு</translation>
<translation id="1014825444426747588">வெற்று</translation>
-<translation id="3356679314312413792">மூவியில் 30 வினாடிகள் பின்செல்</translation>
<translation id="9050748414552849310">மூடப்பட்ட தலைப்புகளைக் காட்டு</translation>
<translation id="4522570452068850558">விவரங்கள்</translation>
<translation id="8451268428117625855">ஒரு கோப்பை தேர்ந்தெடுக்கவும்.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">தொடர விரும்பினால், இந்தப் பெட்டியைத் தேர்ந்தெடுங்கள்.</translation>
<translation id="8534579021159131403">நிமிடங்கள்</translation>
<translation id="819205353528511139">மூவியை முழுத்திரைப் பயன்முறையில் இயக்கு</translation>
-<translation id="8964020114565522021">கோப்பை இங்கே இழுத்து வருக</translation>
<translation id="4103419683916926126">மில்லிவினாடிகள்</translation>
<translation id="838869780401515933">சரிபார்</translation>
<translation id="2846343701378493991">1024 (இடைநிலைத் தரம்)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">இந்த ஆவணம் கடவுச்சொல் பாதுகாக்கப்பட்ட ஒன்று. தயவுசெய்து ஒரு கடவுச்சொல்லை உள்ளிடுக.</translation>
<translation id="5466621249238537318">ஒன்று அல்லது அதற்குமேற்பட்ட கோப்புகளைத் தேர்ந்தெடுங்கள்.</translation>
<translation id="9132465097189459683">மற்றவை…</translation>
+<translation id="10623998915015855">நிலைமாற்றுதல் பொத்தான்</translation>
<translation id="8750798805984357768">தயவுசெய்து இந்த விருப்பங்களில் ஒன்றைத் தேர்ந்தெடுங்கள்.</translation>
<translation id="7740050170769002709">HTML உள்ளடக்கம்</translation>
<translation id="6692633176391053278">ஸ்டெப்பர்</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> தேர்ந்தெடுக்கப்பட்டன</translation>
<translation id="8541249477527128034">மீடியா கட்டுப்பாடு</translation>
<translation id="2226276347425096477">இந்த உரையை <ph name="MAX_CHARACTERS"/> எழுத்துக்குறிகள் அல்லது அதற்கும் குறைவாக சுருக்கிடுங்கள் (நீங்கள் தற்போது <ph name="CURRENT_LENGTH"/> எழுத்துக்குறிகளைப் பயன்படுத்துகிறீர்கள்).</translation>
<translation id="6101327004457443354">ஆடியோ டிராக்கை இயக்கு</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">மணிநேரம்</translation>
<translation id="4664250907885839816">'<ph name="ATSIGN"/>' ஐத் தொடரும் பகுதியில், '<ph name="INVALIDCHARACTER"/>' சின்னம் இருக்கக்கூடாது.</translation>
<translation id="3450233048674729344">மதிப்பானது கண்டிப்பாக <ph name="MAXIMUM"/> ஐ விடக்குறைவாக அல்லது அதற்குச் சமமாக இருக்க வேண்டும்.</translation>
-<translation id="3471999216963526757">30 வினாடிகள் பின்செல்</translation>
<translation id="668171684555832681">மற்றவை…</translation>
<translation id="6270583010843788609">மூவி டைம்லைன் சிறுபடம்</translation>
<translation id="5641012560118721995">மறுஇயக்கத்தை இடைநிறுத்து</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> கோப்புகள்</translation>
<translation id="6643016212128521049">அழி</translation>
<translation id="7888071071722539607">மின்னஞ்சல் முகவரியில் '<ph name="ATSIGN"/>' ஐச் சேர்க்கவும். '<ph name="ATSIGN"/>' இல் '<ph name="INVALIDADDRESS"/>' இல்லை.</translation>
-<translation id="4851297395436456855">வேகமாக முன்செல்</translation>
<translation id="1088086359088493902">வினாடிகள்</translation>
<translation id="3934680773876859118">PDF ஆவணத்தை ஏற்றுவது தோல்வியடைந்தது</translation>
<translation id="3632707345189162177">மீதமுள்ள மூவியின் வினாடிகள்</translation>
<translation id="6359256949422175976">மூவி நேர ஸ்க்ரப்பர் சிறுபடம்</translation>
<translation id="8597182159515967513">தலைப்பு</translation>
<translation id="6843725295806269523">ஒலியடக்கு</translation>
-<translation id="2615751259741237794">நிகழ்நேரத்திற்கு மீட்டமை</translation>
<translation id="2653659639078652383">சமர்ப்பி</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">வேகமாகப் பின்செல்</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_te.xtb b/chromium/webkit/glue/resources/webkit_strings_te.xtb
index c0471dd17ef..fe9a8bf3e9e 100644
--- a/chromium/webkit/glue/resources/webkit_strings_te.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_te.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="te">
<translation id="4763480195061959176">వీడియో</translation>
<translation id="5843503607508392247">ఇతర...</translation>
-<translation id="2426432199384958866">చలనచిత్రాన్ని నిజ సమయంలో ప్రసారం చేయడానికి తిరిగి వెళ్లు</translation>
<translation id="248395913932153421">రోజు</translation>
<translation id="1729654308190250600">దయచేసి ఖాళీ-కాని ఇమెయిల్ చిరునామాని నమోదు చేయండి.</translation>
<translation id="6015796118275082299">సంవత్సరం</translation>
-<translation id="9186171386827445984">పత్రాన్ని లోడ్ చేస్తోంది: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> పేజీలు...</translation>
<translation id="1235745349614807883">ఇటీవల శోధనలను క్లియర్ చెయ్యి</translation>
<translation id="7223624360433298498">గడిచిన సమయం</translation>
<translation id="1171774979989969504">దయచేసి ఇమెయిల్ చిరునామాను ఎంటర్ చెయ్యండి.</translation>
<translation id="709897737746224366">దయచేసి అభ్యర్థించిన ఆకృతీకరణను సరిపోల్చండి.</translation>
<translation id="5048533449481078685">జాబితా మార్కర్</translation>
<translation id="4202807286478387388">వెళ్ళు</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">దయచేసి '<ph name="ATSIGN"/>'కి ముందు ఉన్న భాగాన్ని నమోదు చేయండి. '<ph name="INVALIDADDRESS"/>' అసంపూర్ణంగా ఉంది.</translation>
<translation id="2746543609216772311">విలువ తప్పనిసరిగా <ph name="MINIMUM_DATE_OR_TIME"/> లేదా అంతకంటే తదుపరిది అయి ఉండాలి.</translation>
<translation id="2572483411312390101">ప్లే చేయి</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">చలనచిత్ర నిడివి</translation>
<translation id="8199524924445686405">yyyy</translation>
<translation id="795667975304826397">ఫైల్ ఏదీ ఎంచుకోలేదు</translation>
-<translation id="1320012872283894746">త్వరగా వెనుకకు వెళ్లు</translation>
<translation id="7789962463072032349">నిలిపివేయి</translation>
<translation id="6853785296079745596">సంవృత శీర్షికలను దాచు</translation>
<translation id="4360991593054037559">దయచేసి చెల్లుబాటు అయ్యే విలువను నమోదు చేయండి. <ph name="VALID_VALUE_LOW"/> మరియు <ph name="VALID_VALUE_HIGHER"/> అనేవి రెండు సమీప చెల్లుబాటు విలువలు.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">నొక్కండి</translation>
<translation id="8244226242650769279">చిత్రం మ్యాప్‌</translation>
<translation id="310520048233152454">దయచేసి ఒక URLని ఎంటర్ చెయ్యండి.</translation>
-<translation id="9039488204461337220">త్వరగా ముందుకు వెళ్లు</translation>
<translation id="4812940957355064477">దయచేసి సంఖ్యను నమోదు చేయండి.</translation>
<translation id="2548326553472216322">ఇటీవల శోధనలు లేవు</translation>
<translation id="1938124657309484470">విలువ తప్పనిసరిగా <ph name="MAXIMUM_DATE_OR_TIME"/> లేదా అంతకంటే మునుపటిది అయి ఉండాలి.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">దయచేసి చెల్లుబాటు అయ్యే విలువను నమోదు చేయండి. ఫీల్డ్ అసంపూర్ణంగా ఉంది లేదా చెల్లని తేదీని కలిగి ఉంది.</translation>
<translation id="3040011195152428237">లింక్</translation>
<translation id="1014825444426747588">ఖాళీ</translation>
-<translation id="3356679314312413792">చలనచిత్రంలో 30 సెకన్లు వెనుకకు వెళ్లు</translation>
<translation id="9050748414552849310">సంవృత శీర్షికలను చూపు</translation>
<translation id="4522570452068850558">వివరాలు</translation>
<translation id="8451268428117625855">దయచేసి ఒక ఫైల్‌ని ఎంచుకోండి.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">దయచేసి మీరు కొనసాగాలనుకుంటే ఈ బాక్స్‌కి టిక్కు పెట్టండి.</translation>
<translation id="8534579021159131403">నిమిషాలు</translation>
<translation id="819205353528511139">చలనచిత్రాన్ని పూర్తి స్క్రీన్ మోడ్‌లో ప్లే చేయి</translation>
-<translation id="8964020114565522021">ఫైల్‌ను ఇక్కడకు లాగండి</translation>
<translation id="4103419683916926126">మిల్లీసెకన్లు</translation>
<translation id="838869780401515933">తనిఖీ చెయ్యి</translation>
<translation id="2846343701378493991">1024 (మధ్యస్థ గ్రేడ్)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">ఈ పత్రం అనుమతి పదంచే రక్షించబడింది. దయచేసి అనుమతి పదాన్ని నమోదు చేయండి.</translation>
<translation id="5466621249238537318">దయచేసి ఒకటి లేదా మరిన్ని ఫైళ్ళను ఎంచుకోండి.</translation>
<translation id="9132465097189459683">ఇతర...</translation>
+<translation id="10623998915015855">టోగుల్ బటన్</translation>
<translation id="8750798805984357768">దయచేసి ఈ ఎంపికలలో ఒకదాన్ని ఎంచుకోండి.</translation>
<translation id="7740050170769002709">HTML కంటెంట్</translation>
<translation id="6692633176391053278">స్టెప్పర్</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> ఎంచుకోబడ్డాయి</translation>
<translation id="8541249477527128034">మీడియా నియంత్రణ</translation>
<translation id="2226276347425096477">దయచేసి ఈ వచనాన్ని <ph name="MAX_CHARACTERS"/> అక్షరాలకు లేదా అంతకంటే తక్కువ (మీరు ప్రస్తుతం <ph name="CURRENT_LENGTH"/> అక్షరాలను ఉపయోగిస్తున్నారు)కు తగ్గించండి.</translation>
<translation id="6101327004457443354">ఆడియో ట్రాక్‌ను అన్‌మ్యూట్ చేయి</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">గంటలు</translation>
<translation id="4664250907885839816">'<ph name="ATSIGN"/>'కి తర్వాత ఉన్న భాగంలో '<ph name="INVALIDCHARACTER"/>' చిహ్నం ఉండకూడదు.</translation>
<translation id="3450233048674729344">విలువ ఖచ్చితంగా <ph name="MAXIMUM"/> కంటే తగ్గువగా లేదా సమానంగా ఉండాలి.</translation>
-<translation id="3471999216963526757">30 సెకన్లు వెనుకకు</translation>
<translation id="668171684555832681">ఇతర...</translation>
<translation id="6270583010843788609">చలనచిత్ర టైమ్‌లైన్ సూక్ష్మచిత్రం</translation>
<translation id="5641012560118721995">ప్లేబ్యాక్‌ను పాజ్ చేయి</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> ఫైళ్ళు</translation>
<translation id="6643016212128521049">క్లియర్ చేయి</translation>
<translation id="7888071071722539607">దయచేసి ఇమెయిల్ చిరునామాలో '<ph name="ATSIGN"/>'ని చేర్చండి. '<ph name="INVALIDADDRESS"/>'లో '<ph name="ATSIGN"/>' లేదు.</translation>
-<translation id="4851297395436456855">వేగంగా ముందుకు వెళ్లు</translation>
<translation id="1088086359088493902">సెకన్లు</translation>
<translation id="3934680773876859118">PDF పత్రాన్ని లోడ్ చెయ్యడానికి విఫలమైంది</translation>
<translation id="3632707345189162177">చలనచిత్రంలో మిగిలి ఉన్న సెకన్లు</translation>
<translation id="6359256949422175976">చలనచిత్ర సమయ స్క్రబ్బర్ సూక్ష్మచిత్రం</translation>
<translation id="8597182159515967513">శీర్షిక</translation>
<translation id="6843725295806269523">మ్యూట్ చేయి</translation>
-<translation id="2615751259741237794">నిజ సమయానికి తిరిగి వెళ్లు</translation>
<translation id="2653659639078652383">సమర్పించు</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">త్వరగా వెనుకకు వెళ్లు</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_th.xtb b/chromium/webkit/glue/resources/webkit_strings_th.xtb
index 2b6651fdab1..02ee0ded1a6 100644
--- a/chromium/webkit/glue/resources/webkit_strings_th.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_th.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="th">
<translation id="4763480195061959176">วิดีโอ</translation>
<translation id="5843503607508392247">อื่นๆ...</translation>
-<translation id="2426432199384958866">เปลี่ยนภาพยนตร์แบบสตรีมมิงกลับไปเป็นแบบเรียลไทม์</translation>
<translation id="248395913932153421">วัน</translation>
<translation id="1729654308190250600">โปรดป้อนที่อยู่อีเมลที่ไม่ว่างเปล่า</translation>
<translation id="6015796118275082299">ปี</translation>
-<translation id="9186171386827445984">กำลังโหลดเอกสาร: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> หน้า...</translation>
<translation id="1235745349614807883">ลบการค้นหาล่าสุด</translation>
<translation id="7223624360433298498">เวลาที่ผ่านไป</translation>
<translation id="1171774979989969504">โปรดป้อนที่อยู่อีเมล</translation>
<translation id="709897737746224366">โปรดจับคู่รูปแบบที่ร้องขอ</translation>
<translation id="5048533449481078685">ผู้สร้างรายการ</translation>
<translation id="4202807286478387388">ข้าม</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">โปรดป้อนส่วนหนึ่งโดยตามด้วย &quot;<ph name="ATSIGN"/>&quot; &quot;<ph name="INVALIDADDRESS"/>&quot; นั้นไม่สมบูรณ์</translation>
<translation id="2746543609216772311">ค่าต้องเป็น <ph name="MINIMUM_DATE_OR_TIME"/> หรือหลังจากนั้น</translation>
<translation id="2572483411312390101">เล่น</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">เวลาของภาพยนตร์</translation>
<translation id="8199524924445686405">ปปปป</translation>
<translation id="795667975304826397">ไม่ได้เลือกไฟล์ใด</translation>
-<translation id="1320012872283894746">ย้อนกลับอย่างรวดเร็ว</translation>
<translation id="7789962463072032349">หยุดชั่วคราว</translation>
<translation id="6853785296079745596">ซ่อนคำอธิบายภาพ</translation>
<translation id="4360991593054037559">โปรดป้อนค่าที่ถูกต้อง ค่าใกล้เคียงที่สุดที่ถูกต้องสองรายการคือ <ph name="VALID_VALUE_LOW"/> และ <ph name="VALID_VALUE_HIGHER"/></translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">กด</translation>
<translation id="8244226242650769279">แผนที่รูปภาพ</translation>
<translation id="310520048233152454">โปรดป้อน URL</translation>
-<translation id="9039488204461337220">ไปข้างหน้าอย่างรวดเร็ว</translation>
<translation id="4812940957355064477">โปรดป้อนตัวเลข</translation>
<translation id="2548326553472216322">ไม่พบการค้นหาล่าสุด</translation>
<translation id="1938124657309484470">ค่าต้องเป็น <ph name="MAXIMUM_DATE_OR_TIME"/> หรือก่อนหน้านั้น</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">โปรดป้อนค่าที่ถูกต้อง ฟิลด์นี้ไม่สมบูรณ์หรือมีวันที่ที่ไม่ถูกต้อง</translation>
<translation id="3040011195152428237">ลิงก์</translation>
<translation id="1014825444426747588">ว่าง</translation>
-<translation id="3356679314312413792">ย้อนภาพยนตร์กลับ 30 วินาที</translation>
<translation id="9050748414552849310">แสดงคำอธิบายภาพ</translation>
<translation id="4522570452068850558">รายละเอียด</translation>
<translation id="8451268428117625855">โปรดเลือกไฟล์</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">โปรดเลือกช่องนี้หากคุณต้องการดำเนินการต่อ</translation>
<translation id="8534579021159131403">นาที</translation>
<translation id="819205353528511139">เล่นภาพยนตร์ในโหมดเต็มหน้าจอ</translation>
-<translation id="8964020114565522021">ลากไฟล์มาที่นี่</translation>
<translation id="4103419683916926126">มิลลิวินาที</translation>
<translation id="838869780401515933">ทำเครื่องหมาย</translation>
<translation id="2846343701378493991">1024 (เกรดปานกลาง)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">เอกสารนี้ได้รับการป้องกันด้วยรหัสผ่าน โปรดป้อนรหัสผ่าน</translation>
<translation id="5466621249238537318">โปรดเลือกอย่างน้อยหนึ่งไฟล์</translation>
<translation id="9132465097189459683">อื่นๆ...</translation>
+<translation id="10623998915015855">ปุ่มสลับ</translation>
<translation id="8750798805984357768">โปรดเลือกตัวเลือกอย่างหนึ่งอย่างใดเหล่านี้</translation>
<translation id="7740050170769002709">เนื้อหา HTML</translation>
<translation id="6692633176391053278">ตัวเพิ่ม/ลดระดับเสียง</translation>
+<translation id="4975562563186953947">เลือกไว้ <ph name="SELECTED_COUNT"/> รายการ</translation>
<translation id="8541249477527128034">การควบคุมสื่อ</translation>
<translation id="2226276347425096477">โปรดย่อข้อความนี้ให้เหลือไม่เกิน <ph name="MAX_CHARACTERS"/> อักขระ (ขณะนี้ข้อความของคุณมี <ph name="CURRENT_LENGTH"/> อักขระ)</translation>
<translation id="6101327004457443354">เปิดไฟล์เสียง</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">ชั่วโมง</translation>
<translation id="4664250907885839816">ส่วนที่ต่อท้าย &quot;<ph name="ATSIGN"/>&quot; ต้องไม่มีสัญลักษณ์ &quot;<ph name="INVALIDCHARACTER"/>&quot;</translation>
<translation id="3450233048674729344">ค่าต้องน้อยกว่าหรือเท่ากับ <ph name="MAXIMUM"/></translation>
-<translation id="3471999216963526757">ย้อนกลับ 30 วินาที</translation>
<translation id="668171684555832681">อื่นๆ...</translation>
<translation id="6270583010843788609">เส้นเวลาขนาดย่อของภาพยนตร์</translation>
<translation id="5641012560118721995">หยุดเล่นชั่วคราว</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> ไฟล์</translation>
<translation id="6643016212128521049">ล้าง</translation>
<translation id="7888071071722539607">โปรดใส่ &quot;<ph name="ATSIGN"/>&quot; ในที่อยู่อีเมล &quot;<ph name="INVALIDADDRESS"/>&quot; ขาด &quot;<ph name="ATSIGN"/>&quot;</translation>
-<translation id="4851297395436456855">ไปข้างหน้าอย่างรวดเร็ว</translation>
<translation id="1088086359088493902">วินาที</translation>
<translation id="3934680773876859118">โหลดเอกสาร PDF ล้มเหลว</translation>
<translation id="3632707345189162177">จำนวนวินาทีที่เหลือของภาพยนตร์</translation>
<translation id="6359256949422175976">ตัวควบคุมเวลาขนาดย่อของภาพยนตร์</translation>
<translation id="8597182159515967513">ส่วนหัว</translation>
<translation id="6843725295806269523">ปิดเสียง</translation>
-<translation id="2615751259741237794">กลับไปเป็นแบบเรียลไทม์</translation>
<translation id="2653659639078652383">ส่ง</translation>
<translation id="3732799496749320381">ดด</translation>
-<translation id="4484359737905287537">ย้อนกลับอย่างรวดเร็ว</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_tr.xtb b/chromium/webkit/glue/resources/webkit_strings_tr.xtb
index 9a9e44f96fd..88e86311cc3 100644
--- a/chromium/webkit/glue/resources/webkit_strings_tr.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_tr.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="tr">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Diğer...</translation>
-<translation id="2426432199384958866">akışı yapılan filmi gerçek zamanlı hale döndür</translation>
<translation id="248395913932153421">Gün</translation>
<translation id="1729654308190250600">Lütfen e-posta adresini boş bırakmayın.</translation>
<translation id="6015796118275082299">Yıl</translation>
-<translation id="9186171386827445984">Belge yükleniyor: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> sayfa...</translation>
<translation id="1235745349614807883">Son Aramaları Temizle</translation>
<translation id="7223624360433298498">geçen süre</translation>
<translation id="1171774979989969504">Lütfen e-posta adresi girin.</translation>
<translation id="709897737746224366">Lütfen istenen biçimi eşleştirin.</translation>
<translation id="5048533449481078685">liste işaretçisi</translation>
<translation id="4202807286478387388">git</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Lütfen başına &quot;<ph name="ATSIGN"/>&quot; ekleyin. &quot;<ph name="INVALIDADDRESS"/>&quot; adresi eksik.</translation>
<translation id="2746543609216772311">Değer <ph name="MINIMUM_DATE_OR_TIME"/> veya daha ileri olmalıdır.</translation>
<translation id="2572483411312390101">oynat</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">filmin süresi</translation>
<translation id="8199524924445686405">yyyy</translation>
<translation id="795667975304826397">Dosya seçilmedi</translation>
-<translation id="1320012872283894746">hızlı şekilde geriye doğru git</translation>
<translation id="7789962463072032349">duraklat</translation>
<translation id="6853785296079745596">alt yazıları gizle</translation>
<translation id="4360991593054037559">Lütfen geçerli bir değer girin. En yakın iki geçerli değer şunlardır: <ph name="VALID_VALUE_LOW"/> ve <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">bas</translation>
<translation id="8244226242650769279">resim haritası</translation>
<translation id="310520048233152454">Lütfen bir URL girin.</translation>
-<translation id="9039488204461337220">hızlı şekilde ileriye doğru git</translation>
<translation id="4812940957355064477">Lütfen bir sayı girin.</translation>
<translation id="2548326553472216322">Yeni arama yok</translation>
<translation id="1938124657309484470">Değer <ph name="MAXIMUM_DATE_OR_TIME"/> veya daha geri olmalıdır.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Lütfen geçerli bir tarih girin. Alan tam doldurulmamış veya geçersiz bir tarih var.</translation>
<translation id="3040011195152428237">bağlantı</translation>
<translation id="1014825444426747588">boş</translation>
-<translation id="3356679314312413792">filmde 30 saniye geriye git</translation>
<translation id="9050748414552849310">alt yazıları göster</translation>
<translation id="4522570452068850558">Ayrıntılar</translation>
<translation id="8451268428117625855">Lütfen bir dosya seçin.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">İlerlemek istiyorsanız lütfen bu kutuyu işaretleyin.</translation>
<translation id="8534579021159131403">Dakika</translation>
<translation id="819205353528511139">filmi tam ekran modunda oynat</translation>
-<translation id="8964020114565522021">Dosyayı buraya sürükleyin</translation>
<translation id="4103419683916926126">Milisaniye</translation>
<translation id="838869780401515933">işaretle</translation>
<translation id="2846343701378493991">1024 (Orta Düzey)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Doküman şifre korumalı. Lütfen şifreyi girin.</translation>
<translation id="5466621249238537318">Lütfen bir veya daha fazla dosya seçin.</translation>
<translation id="9132465097189459683">Diğer...</translation>
+<translation id="10623998915015855">geçiş düğmesi</translation>
<translation id="8750798805984357768">Lütfen bu seçeneklerden birini belirleyin.</translation>
<translation id="7740050170769002709">HTML içeriği</translation>
<translation id="6692633176391053278">stepper (adımlayıcı)</translation>
+<translation id="4975562563186953947"><ph name="SELECTED_COUNT"/> tane seçildi</translation>
<translation id="8541249477527128034">medya kontrolü</translation>
<translation id="2226276347425096477">Lütfen bu metni <ph name="MAX_CHARACTERS"/> veya daha az karakter olacak şekilde kısaltın (şu anda <ph name="CURRENT_LENGTH"/> karakter kullanıyorsunuz).</translation>
<translation id="6101327004457443354">ses kanalını aç</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Saat</translation>
<translation id="4664250907885839816">Başında &quot;<ph name="ATSIGN"/>&quot; bulunan kısımda &quot;<ph name="INVALIDCHARACTER"/>&quot; simgesi bulunmamalıdır.</translation>
<translation id="3450233048674729344">Değer <ph name="MAXIMUM"/> veya daha küçük olmalıdır.</translation>
-<translation id="3471999216963526757">30 saniye geri git</translation>
<translation id="668171684555832681">Diğer...</translation>
<translation id="6270583010843788609">film zaman çizelgesi küçük resmi</translation>
<translation id="5641012560118721995">oynatmayı duraklat</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> dosya</translation>
<translation id="6643016212128521049">Temizle</translation>
<translation id="7888071071722539607">Lütfen e-posta adresine bir &quot;<ph name="ATSIGN"/>&quot; işareti ekleyin. &quot;<ph name="INVALIDADDRESS"/>&quot; adresinde &quot;<ph name="ATSIGN"/>&quot; eksik.</translation>
-<translation id="4851297395436456855">ileri sar</translation>
<translation id="1088086359088493902">Saniye</translation>
<translation id="3934680773876859118">PDF dokümanı yüklenemedi</translation>
<translation id="3632707345189162177">saniye olarak filmin kalan süresi</translation>
<translation id="6359256949422175976">film süresi göstergesinin küçük resmi</translation>
<translation id="8597182159515967513">başlık</translation>
<translation id="6843725295806269523">sesi kapat</translation>
-<translation id="2615751259741237794">gerçek zamanlı moda dön</translation>
<translation id="2653659639078652383">Gönder</translation>
<translation id="3732799496749320381">aa</translation>
-<translation id="4484359737905287537">geri sar</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_uk.xtb b/chromium/webkit/glue/resources/webkit_strings_uk.xtb
index 84a819a9df9..dc914e323d4 100644
--- a/chromium/webkit/glue/resources/webkit_strings_uk.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_uk.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="uk">
<translation id="4763480195061959176">відео</translation>
<translation id="5843503607508392247">Інші...</translation>
-<translation id="2426432199384958866">повернути трансляцію фільму в режим реального часу</translation>
<translation id="248395913932153421">День</translation>
<translation id="1729654308190250600">Введіть електронну адресу.</translation>
<translation id="6015796118275082299">Рік</translation>
-<translation id="9186171386827445984">Завантаження документа – сторінки: <ph name="PAGE_NUMBER"/> із <ph name="NUMBER_OF_PAGES"/>...</translation>
<translation id="1235745349614807883">Очистити останні пошуки</translation>
<translation id="7223624360433298498">минуло часу</translation>
<translation id="1171774979989969504">Введіть електронну адресу.</translation>
<translation id="709897737746224366">Виберіть потрібний формат.</translation>
<translation id="5048533449481078685">маркер списку</translation>
<translation id="4202807286478387388">перейти</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Введіть частину електронної адреси до знака &quot;<ph name="ATSIGN"/>&quot;. Електронна адреса &quot;<ph name="INVALIDADDRESS"/>&quot; неповна.</translation>
<translation id="2746543609216772311">Має бути <ph name="MINIMUM_DATE_OR_TIME"/> або пізніша дата.</translation>
<translation id="2572483411312390101">відтворити</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">тривалість фільму</translation>
<translation id="8199524924445686405">рррр</translation>
<translation id="795667975304826397">Файл не вибрано</translation>
-<translation id="1320012872283894746">швидко перемотати назад</translation>
<translation id="7789962463072032349">призупинити</translation>
<translation id="6853785296079745596">сховати приховані субтирти</translation>
<translation id="4360991593054037559">Введіть дійсне значення. Два найближчі дійсні значення: <ph name="VALID_VALUE_LOW"/> і <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">натиснути</translation>
<translation id="8244226242650769279">мапа зображення</translation>
<translation id="310520048233152454">Введіть URL-адресу.</translation>
-<translation id="9039488204461337220">швидко перемотати вперед</translation>
<translation id="4812940957355064477">Введіть число.</translation>
<translation id="2548326553472216322">Немає останніх пошуків</translation>
<translation id="1938124657309484470">Має бути <ph name="MAXIMUM_DATE_OR_TIME"/> або раніша дата.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Введіть дійсне значення. Поле не заповнено або введено недійсну дату.</translation>
<translation id="3040011195152428237">посилання</translation>
<translation id="1014825444426747588">порожнє</translation>
-<translation id="3356679314312413792">перемотати фільм назад на 30 секунд</translation>
<translation id="9050748414552849310">показати приховані субтитри</translation>
<translation id="4522570452068850558">Деталі</translation>
<translation id="8451268428117625855">Виберіть файл.</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">Поставте тут прапорець, якщо хочете продовжити.</translation>
<translation id="8534579021159131403">Хвилини</translation>
<translation id="819205353528511139">відтворити фільм у повноекранному режимі</translation>
-<translation id="8964020114565522021">Перетягніть файл сюди</translation>
<translation id="4103419683916926126">Мілісекунди</translation>
<translation id="838869780401515933">установити прапорець</translation>
<translation id="2846343701378493991">1024 (Середній рівень)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">Цей документ захищено паролем. Введіть пароль.</translation>
<translation id="5466621249238537318">Виберіть один або декілька файлів.</translation>
<translation id="9132465097189459683">Інші...</translation>
+<translation id="10623998915015855">перемикач</translation>
<translation id="8750798805984357768">Виберіть один із запропонованих варіантів.</translation>
<translation id="7740050170769002709">Вміст HTML</translation>
<translation id="6692633176391053278">повторювач stepper</translation>
+<translation id="4975562563186953947">Вибрано <ph name="SELECTED_COUNT"/></translation>
<translation id="8541249477527128034">елемент керування мультимедіа</translation>
<translation id="2226276347425096477">Скоротіть текст до такої кількості символів або менше: <ph name="MAX_CHARACTERS"/> (наразі використано символів: <ph name="CURRENT_LENGTH"/>).</translation>
<translation id="6101327004457443354">увімкнути звукову доріжку</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Години</translation>
<translation id="4664250907885839816">Частина після знака &quot;<ph name="ATSIGN"/>&quot; не може містити символ &quot;<ph name="INVALIDCHARACTER"/>&quot;.</translation>
<translation id="3450233048674729344">Значення має бути меншим або дорівнювати <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">назад на 30 секунд</translation>
<translation id="668171684555832681">Інший...</translation>
<translation id="6270583010843788609">ескіз на часовій шкалі фільму</translation>
<translation id="5641012560118721995">призупинити відтворення</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423">файлів: <ph name="NUMBER_OF_FILES"/></translation>
<translation id="6643016212128521049">Очистити</translation>
<translation id="7888071071722539607">Електронна адреса має містити знак &quot;<ph name="ATSIGN"/>&quot;. В електронній адресі &quot;<ph name="INVALIDADDRESS"/>&quot; знака &quot;<ph name="ATSIGN"/>&quot; немає.</translation>
-<translation id="4851297395436456855">перемотати вперед</translation>
<translation id="1088086359088493902">Секунди</translation>
<translation id="3934680773876859118">Не вдалося завантажити документ PDF</translation>
<translation id="3632707345189162177">кількість секунд до кінця фільму</translation>
<translation id="6359256949422175976">ескіз на повзунку перебігу фільму</translation>
<translation id="8597182159515967513">заголовок</translation>
<translation id="6843725295806269523">вимкнути звук</translation>
-<translation id="2615751259741237794">повернутися в режим реального часу</translation>
<translation id="2653659639078652383">Надіслати</translation>
<translation id="3732799496749320381">мм</translation>
-<translation id="4484359737905287537">перемотати назад</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_vi.xtb b/chromium/webkit/glue/resources/webkit_strings_vi.xtb
index 2f0c01ffe2e..d0906e24637 100644
--- a/chromium/webkit/glue/resources/webkit_strings_vi.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_vi.xtb
@@ -3,18 +3,15 @@
<translationbundle lang="vi">
<translation id="4763480195061959176">video</translation>
<translation id="5843503607508392247">Khác...</translation>
-<translation id="2426432199384958866">đưa phim phát trực tuyến trở về thời gian thực</translation>
<translation id="248395913932153421">Ngày</translation>
<translation id="1729654308190250600">Vui lòng nhập địa chỉ email không trống.</translation>
<translation id="6015796118275082299">Năm</translation>
-<translation id="9186171386827445984">Đang tải tài liệu: <ph name="PAGE_NUMBER"/>/<ph name="NUMBER_OF_PAGES"/> trang...</translation>
<translation id="1235745349614807883">Xóa Tìm kiếm Gần đây</translation>
<translation id="7223624360433298498">thời gian trôi qua</translation>
<translation id="1171774979989969504">Vui lòng nhập địa chỉ email.</translation>
<translation id="709897737746224366">Vui lòng khớp với định dạng được yêu cầu.</translation>
<translation id="5048533449481078685">đánh dấu danh sách</translation>
<translation id="4202807286478387388">chuyển</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">Vui lòng nhập phần đứng trước '<ph name="ATSIGN"/>'. '<ph name="INVALIDADDRESS"/>' không hoàn chỉnh.</translation>
<translation id="2746543609216772311">Giá trị phải là <ph name="MINIMUM_DATE_OR_TIME"/> hoặc muộn hơn.</translation>
<translation id="2572483411312390101">phát</translation>
@@ -22,7 +19,6 @@
<translation id="7057186640035488495">thời gian phim</translation>
<translation id="8199524924445686405">yyyy</translation>
<translation id="795667975304826397">Không có tệp nào được chọn</translation>
-<translation id="1320012872283894746">tìm kiếm tua về nhanh</translation>
<translation id="7789962463072032349">tạm dừng</translation>
<translation id="6853785296079745596">ẩn phụ đề chi tiết</translation>
<translation id="4360991593054037559">Vui lòng nhập giá trị hợp lệ. Hai giá trị hợp lệ gần nhất là <ph name="VALID_VALUE_LOW"/> và <ph name="VALID_VALUE_HIGHER"/>.</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">nhấn</translation>
<translation id="8244226242650769279">bản đồ hình ảnh</translation>
<translation id="310520048233152454">Vui lòng nhập URL.</translation>
-<translation id="9039488204461337220">tìm kiếm tua đi nhanh</translation>
<translation id="4812940957355064477">Vui lòng nhập một số.</translation>
<translation id="2548326553472216322">Không có tìm kiếm nào gần đây</translation>
<translation id="1938124657309484470">Giá trị phải là <ph name="MAXIMUM_DATE_OR_TIME"/> hoặc sớm hơn.</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">Vui lòng nhập một giá trị hợp lệ. Trường không hoàn chỉnh hoặc có giá trị không hợp lệ.</translation>
<translation id="3040011195152428237">liên kết</translation>
<translation id="1014825444426747588">trống</translation>
-<translation id="3356679314312413792">tìm kiếm phim quay lại 30 giây</translation>
<translation id="9050748414552849310">hiển thị phụ đề chi tiết</translation>
<translation id="4522570452068850558">Chi tiết</translation>
<translation id="8451268428117625855">Vui lòng chọn một tệp.</translation>
@@ -60,11 +54,10 @@
<translation id="2674318244760992338">chân trang</translation>
<translation id="8987927404178983737">Tháng</translation>
<translation id="8115662671911883373">bắt đầu hiển thị phụ đề chi tiết</translation>
-<translation id="7364796246159120393">Chọn Tệp tin</translation>
+<translation id="7364796246159120393">Chọn tệp</translation>
<translation id="2761667185364618470">Vui lòng chọn hộp kiểm này nếu bạn muốn tiếp tục.</translation>
<translation id="8534579021159131403">Phút</translation>
<translation id="819205353528511139">phát phim ở chế độ toàn màn hình</translation>
-<translation id="8964020114565522021">Kéo tệp tại đây</translation>
<translation id="4103419683916926126">Mili giây</translation>
<translation id="838869780401515933">chọn</translation>
<translation id="2846343701378493991">1024 (Loại Trung bình)</translation>
@@ -77,16 +70,18 @@
<translation id="739024184232394898">Khác...</translation>
<translation id="383465348367842624">Phần đứng trước '<ph name="ATSIGN"/>' không được chứa biểu tượng '<ph name="INVALIDCHARACTER"/>'.</translation>
<translation id="5468998798572797635">thoát khỏi chế độ toàn màn hình</translation>
-<translation id="5919473608089529604">Không thể tải trình cắm.</translation>
+<translation id="5919473608089529604">Không thể tải plugin.</translation>
<translation id="5546461542133609677">bật tiếng</translation>
<translation id="6663448176199120256">Tìm kiếm Gần đây</translation>
<translation id="1020833440720551630">tắt tiếng bản âm thanh</translation>
<translation id="2597378329261239068">Tài liệu này được bảo vệ bằng mật khẩu. Vui lòng nhập mật khẩu.</translation>
<translation id="5466621249238537318">Vui lòng chọn một hoặc nhiều tệp.</translation>
<translation id="9132465097189459683">Khác...</translation>
+<translation id="10623998915015855">nút chuyển đổi</translation>
<translation id="8750798805984357768">Vui lòng chọn một trong các tùy chọn sau.</translation>
<translation id="7740050170769002709">Nội dung HTML</translation>
<translation id="6692633176391053278">điều khiển tăng/giảm</translation>
+<translation id="4975562563186953947">Đã chọn <ph name="SELECTED_COUNT"/></translation>
<translation id="8541249477527128034">kiểm soát phương tiện</translation>
<translation id="2226276347425096477">Hãy cắt ngắn văn bản này thành <ph name="MAX_CHARACTERS"/> ký tự hoặc ít hơn (bạn hiện đang sử dụng <ph name="CURRENT_LENGTH"/> ký tự).</translation>
<translation id="6101327004457443354">bật tiếng bản âm thanh</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">Giờ</translation>
<translation id="4664250907885839816">Phần đứng sau '<ph name="ATSIGN"/>' không được chứa biểu tượng '<ph name="INVALIDCHARACTER"/>'.</translation>
<translation id="3450233048674729344">Giá trị phải nhỏ hơn hoặc bằng <ph name="MAXIMUM"/>.</translation>
-<translation id="3471999216963526757">quay lại 30 giây</translation>
<translation id="668171684555832681">Khác...</translation>
<translation id="6270583010843788609">núm dòng thời gian phim</translation>
<translation id="5641012560118721995">tạm dừng phát lại</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> tệp</translation>
<translation id="6643016212128521049">Xóa</translation>
<translation id="7888071071722539607">Vui lòng bao gồm '<ph name="ATSIGN"/>' trong địa chỉ email. '<ph name="INVALIDADDRESS"/>' bị thiếu '<ph name="ATSIGN"/>'.</translation>
-<translation id="4851297395436456855">tua đi nhanh</translation>
<translation id="1088086359088493902">Giây</translation>
<translation id="3934680773876859118">Không thể tải tài liệu PDF</translation>
<translation id="3632707345189162177">số giây còn lại của phim</translation>
<translation id="6359256949422175976">núm trình kiểm soát thời gian phim</translation>
<translation id="8597182159515967513">đầu đề</translation>
<translation id="6843725295806269523">tắt tiếng</translation>
-<translation id="2615751259741237794">trở về thời gian thực</translation>
<translation id="2653659639078652383">Gửi</translation>
<translation id="3732799496749320381">mm</translation>
-<translation id="4484359737905287537">tua về nhanh</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_zh-CN.xtb b/chromium/webkit/glue/resources/webkit_strings_zh-CN.xtb
index b971e7bf108..8cf54d04ab0 100644
--- a/chromium/webkit/glue/resources/webkit_strings_zh-CN.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_zh-CN.xtb
@@ -3,26 +3,22 @@
<translationbundle lang="zh-CN">
<translation id="4763480195061959176">视频</translation>
<translation id="5843503607508392247">其他...</translation>
-<translation id="2426432199384958866">将流式传输电影恢复为实时</translation>
<translation id="248395913932153421">日</translation>
<translation id="1729654308190250600">请输入有效的电子邮件地址。</translation>
<translation id="6015796118275082299">年</translation>
-<translation id="9186171386827445984">正在加载文档:已加载 <ph name="PAGE_NUMBER"/> 页,共 <ph name="NUMBER_OF_PAGES"/> 页...</translation>
<translation id="1235745349614807883">清除最近的搜索</translation>
<translation id="7223624360433298498">已播放时间</translation>
<translation id="1171774979989969504">请输入电子邮件地址。</translation>
<translation id="709897737746224366">请与所请求的格式保持一致。</translation>
<translation id="5048533449481078685">列表标记</translation>
<translation id="4202807286478387388">略过</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">请在“<ph name="ATSIGN"/>”前面输入内容。“<ph name="INVALIDADDRESS"/>”不完整。</translation>
<translation id="2746543609216772311">指定的值不得早于<ph name="MINIMUM_DATE_OR_TIME"/>。</translation>
<translation id="2572483411312390101">播放</translation>
<translation id="8785498733064193001">开始播放</translation>
<translation id="7057186640035488495">电影时间</translation>
<translation id="8199524924445686405"> 年 </translation>
-<translation id="795667975304826397">未选择文件</translation>
-<translation id="1320012872283894746">快速回退</translation>
+<translation id="795667975304826397">未选择任何文件</translation>
<translation id="7789962463072032349">暂停</translation>
<translation id="6853785296079745596">隐藏可选字幕</translation>
<translation id="4360991593054037559">请输入有效值。两个最接近的有效值分别为<ph name="VALID_VALUE_LOW"/>和<ph name="VALID_VALUE_HIGHER"/>。</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">按</translation>
<translation id="8244226242650769279">图片映射</translation>
<translation id="310520048233152454">请输入网址。</translation>
-<translation id="9039488204461337220">快速前进</translation>
<translation id="4812940957355064477">请输入一个数字。</translation>
<translation id="2548326553472216322">最近未执行搜索</translation>
<translation id="1938124657309484470">指定的值不得晚于<ph name="MAXIMUM_DATE_OR_TIME"/>。</translation>
@@ -49,7 +44,6 @@
<translation id="3075154866155599887">请输入一个有效值。该字段不完整或存在无效日期。</translation>
<translation id="3040011195152428237">链接</translation>
<translation id="1014825444426747588">空白</translation>
-<translation id="3356679314312413792">将电影后退 30 秒</translation>
<translation id="9050748414552849310">显示可选字幕</translation>
<translation id="4522570452068850558">详细信息</translation>
<translation id="8451268428117625855">请选择一个文件。</translation>
@@ -64,7 +58,6 @@
<translation id="2761667185364618470">如果要继续,请选中此框。</translation>
<translation id="8534579021159131403">分钟</translation>
<translation id="819205353528511139">在全屏模式下播放电影</translation>
-<translation id="8964020114565522021">将文件拖到此处</translation>
<translation id="4103419683916926126">毫秒</translation>
<translation id="838869780401515933">选中</translation>
<translation id="2846343701378493991">1024(中等强度)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">本文档设置了密码保护,请输入密码。</translation>
<translation id="5466621249238537318">请选择一个或多个文件。</translation>
<translation id="9132465097189459683">其他...</translation>
+<translation id="10623998915015855">切换按钮</translation>
<translation id="8750798805984357768">请从这些选项中选择一个。</translation>
<translation id="7740050170769002709">HTML 内容</translation>
<translation id="6692633176391053278">步进器</translation>
+<translation id="4975562563186953947">选择了<ph name="SELECTED_COUNT"/>项</translation>
<translation id="8541249477527128034">媒体控件</translation>
<translation id="2226276347425096477">请将该文本减少为 <ph name="MAX_CHARACTERS"/> 个字符或更少(您当前使用了 <ph name="CURRENT_LENGTH"/> 个字符)。</translation>
<translation id="6101327004457443354">取消对音轨静音</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">小时</translation>
<translation id="4664250907885839816">“<ph name="ATSIGN"/>”后面的内容不应包含符号“<ph name="INVALIDCHARACTER"/>”。</translation>
<translation id="3450233048674729344">值必须小于或等于 <ph name="MAXIMUM"/>。</translation>
-<translation id="3471999216963526757">后退 30 秒</translation>
<translation id="668171684555832681">其他...</translation>
<translation id="6270583010843788609">电影时间轴缩略图</translation>
<translation id="5641012560118721995">暂停播放</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> 个文件</translation>
<translation id="6643016212128521049">清除</translation>
<translation id="7888071071722539607">请在电子邮件地址中包括“<ph name="ATSIGN"/>”。“<ph name="INVALIDADDRESS"/>”中缺少“<ph name="ATSIGN"/>”。</translation>
-<translation id="4851297395436456855">快进</translation>
<translation id="1088086359088493902">秒</translation>
<translation id="3934680773876859118">无法加载 PDF 文档</translation>
<translation id="3632707345189162177">电影剩余时间(以秒为单位)</translation>
<translation id="6359256949422175976">电影时间进度条缩略图</translation>
<translation id="8597182159515967513">标题</translation>
<translation id="6843725295806269523">静音</translation>
-<translation id="2615751259741237794">恢复为实时</translation>
<translation id="2653659639078652383">提交</translation>
<translation id="3732799496749320381">月</translation>
-<translation id="4484359737905287537">快退</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/resources/webkit_strings_zh-TW.xtb b/chromium/webkit/glue/resources/webkit_strings_zh-TW.xtb
index ab37fe041cd..24395f3e936 100644
--- a/chromium/webkit/glue/resources/webkit_strings_zh-TW.xtb
+++ b/chromium/webkit/glue/resources/webkit_strings_zh-TW.xtb
@@ -3,28 +3,24 @@
<translationbundle lang="zh-TW">
<translation id="4763480195061959176">影片</translation>
<translation id="5843503607508392247">其他...</translation>
-<translation id="2426432199384958866">將串流影片恢復為即時播放</translation>
<translation id="248395913932153421">日</translation>
<translation id="1729654308190250600">請輸入電子郵件地址。</translation>
<translation id="6015796118275082299">年</translation>
-<translation id="9186171386827445984">正在載入文件:第 <ph name="PAGE_NUMBER"/> 頁,共 <ph name="NUMBER_OF_PAGES"/> 頁...</translation>
<translation id="1235745349614807883">清除最近的搜尋紀錄</translation>
<translation id="7223624360433298498">已播放時間</translation>
<translation id="1171774979989969504">請輸入電子郵件地址。</translation>
<translation id="709897737746224366">請符合要求的格式。</translation>
<translation id="5048533449481078685">清單標記</translation>
<translation id="4202807286478387388">跳至另一頁</translation>
-<translation id="4611115858363067980"><ph name="FILENAME"/><ph name="WIDTH"/>×<ph name="HEIGHT"/></translation>
<translation id="5307600278924710095">請輸入「<ph name="ATSIGN"/>」後面的部分。「<ph name="INVALIDADDRESS"/>」不是完整值。</translation>
<translation id="2746543609216772311">必須輸入 <ph name="MINIMUM_DATE_OR_TIME"/> 或之後的值。</translation>
<translation id="2572483411312390101">播放</translation>
<translation id="8785498733064193001">開始播放</translation>
<translation id="7057186640035488495">電影時間</translation>
<translation id="8199524924445686405"> 年 </translation>
-<translation id="795667975304826397">未選擇檔案</translation>
-<translation id="1320012872283894746">影片倒轉</translation>
+<translation id="795667975304826397">未選擇任何檔案</translation>
<translation id="7789962463072032349">暫停</translation>
-<translation id="6853785296079745596">不顯示隱藏式輔助字幕</translation>
+<translation id="6853785296079745596">不顯示字幕</translation>
<translation id="4360991593054037559">請輸入有效值。最接近的兩個有效值分別是 <ph name="VALID_VALUE_LOW"/> 和 <ph name="VALID_VALUE_HIGHER"/>。</translation>
<translation id="1758486001363313524">其他...</translation>
<translation id="8141602879876242471">這是可搜尋的索引,輸入搜尋關鍵字:</translation>
@@ -36,7 +32,6 @@
<translation id="6845533974506654842">按下</translation>
<translation id="8244226242650769279">圖片點擊區</translation>
<translation id="310520048233152454">請輸入網址。</translation>
-<translation id="9039488204461337220">影片快轉</translation>
<translation id="4812940957355064477">請輸入一個數字。</translation>
<translation id="2548326553472216322">沒有近期的搜尋</translation>
<translation id="1938124657309484470">必須輸入 <ph name="MAXIMUM_DATE_OR_TIME"/> 或之前的值。</translation>
@@ -44,13 +39,12 @@
<translation id="901493112792887934">目前時間 (以秒為單位)</translation>
<translation id="5164977714490026579">值必須大於或等於 <ph name="MINIMUM"/>。</translation>
<translation id="2247351761944213033"><ph name="YEAR"/> 年,第 <ph name="WEEKNUMBER"/> 週</translation>
-<translation id="7740016676195725605">停止顯示隱藏式輔助字幕</translation>
+<translation id="7740016676195725605">停止顯示字幕</translation>
<translation id="5944544982112848342">2048 (高級)</translation>
<translation id="3075154866155599887">欄位內容不完整或日期無效,請輸入有效的值。</translation>
<translation id="3040011195152428237">連結</translation>
<translation id="1014825444426747588">空白</translation>
-<translation id="3356679314312413792">影片倒轉 (30 秒)</translation>
-<translation id="9050748414552849310">顯示隱藏式輔助字幕</translation>
+<translation id="9050748414552849310">顯示字幕</translation>
<translation id="4522570452068850558">詳細資訊</translation>
<translation id="8451268428117625855">請選取檔案。</translation>
<translation id="8117451130807776954">本週</translation>
@@ -59,12 +53,11 @@
<translation id="2060505056492490888">「<ph name="DOT"/>」未放在「<ph name="INVALIDDOMAIN"/>」的正確位置。</translation>
<translation id="2674318244760992338">頁尾</translation>
<translation id="8987927404178983737">月</translation>
-<translation id="8115662671911883373">開始顯示隱藏式輔助字幕</translation>
+<translation id="8115662671911883373">開始顯示字幕</translation>
<translation id="7364796246159120393">選擇檔案</translation>
<translation id="2761667185364618470">如果您要繼續執行,請勾選這個核取方塊。</translation>
<translation id="8534579021159131403">分鐘</translation>
<translation id="819205353528511139">使用全螢幕模式播放電影</translation>
-<translation id="8964020114565522021">拖曳檔案至此</translation>
<translation id="4103419683916926126">毫秒</translation>
<translation id="838869780401515933">選取</translation>
<translation id="2846343701378493991">1024 (中等)</translation>
@@ -84,9 +77,11 @@
<translation id="2597378329261239068">此文件受到密碼保護,請輸入密碼。</translation>
<translation id="5466621249238537318">請選取一或多個檔案。</translation>
<translation id="9132465097189459683">其他...</translation>
+<translation id="10623998915015855">切換按鈕</translation>
<translation id="8750798805984357768">請選取其中一個選項。</translation>
<translation id="7740050170769002709">HTML 內容</translation>
<translation id="6692633176391053278">步進器</translation>
+<translation id="4975562563186953947">已選取 <ph name="SELECTED_COUNT"/> 個項目</translation>
<translation id="8541249477527128034">媒體控制</translation>
<translation id="2226276347425096477">請將這段文字刪減至 <ph name="MAX_CHARACTERS"/> 個字元以下 (目前的字元數為 <ph name="CURRENT_LENGTH"/> 個)。</translation>
<translation id="6101327004457443354">取消音軌靜音</translation>
@@ -101,7 +96,6 @@
<translation id="7673697353781729403">小時</translation>
<translation id="4664250907885839816">「<ph name="ATSIGN"/>」後面的部分不應包含「<ph name="INVALIDCHARACTER"/>」符號。</translation>
<translation id="3450233048674729344">值必須小於或等於 <ph name="MAXIMUM"/>。</translation>
-<translation id="3471999216963526757">倒轉 30 秒</translation>
<translation id="668171684555832681">其他...</translation>
<translation id="6270583010843788609">電影時間軸捲動方塊</translation>
<translation id="5641012560118721995">暫停播放</translation>
@@ -110,15 +104,12 @@
<translation id="8444882422881193423"><ph name="NUMBER_OF_FILES"/> 個檔案</translation>
<translation id="6643016212128521049">清除</translation>
<translation id="7888071071722539607">請在電子郵件地址中包含「<ph name="ATSIGN"/>」。「<ph name="INVALIDADDRESS"/>」未包含「<ph name="ATSIGN"/>」。</translation>
-<translation id="4851297395436456855">向前快轉</translation>
<translation id="1088086359088493902">秒</translation>
<translation id="3934680773876859118">無法載入 PDF 文件</translation>
<translation id="3632707345189162177">電影剩餘秒數</translation>
<translation id="6359256949422175976">影片時間拖曳工具捲動方塊</translation>
<translation id="8597182159515967513">標題</translation>
<translation id="6843725295806269523">忽略的項目</translation>
-<translation id="2615751259741237794">返回即時播放模式</translation>
<translation id="2653659639078652383">提交</translation>
<translation id="3732799496749320381">月</translation>
-<translation id="4484359737905287537">向後快轉</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/webkit/glue/simple_webmimeregistry_impl.cc b/chromium/webkit/glue/simple_webmimeregistry_impl.cc
deleted file mode 100644
index b6bdadc68cc..00000000000
--- a/chromium/webkit/glue/simple_webmimeregistry_impl.cc
+++ /dev/null
@@ -1,91 +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 "webkit/glue/simple_webmimeregistry_impl.h"
-
-#include "base/files/file_path.h"
-#include "base/strings/string_util.h"
-#include "base/strings/sys_string_conversions.h"
-#include "base/strings/utf_string_conversions.h"
-#include "net/base/mime_util.h"
-#include "third_party/WebKit/public/platform/WebString.h"
-
-using blink::WebString;
-using blink::WebMimeRegistry;
-
-namespace webkit_glue {
-
-//static
-std::string SimpleWebMimeRegistryImpl::ToASCIIOrEmpty(const WebString& string) {
- return IsStringASCII(string) ? UTF16ToASCII(string) : std::string();
-}
-
-WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMIMEType(
- const WebString& mime_type) {
- return net::IsSupportedMimeType(ToASCIIOrEmpty(mime_type)) ?
- WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
-}
-
-WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsImageMIMEType(
- const WebString& mime_type) {
- return net::IsSupportedImageMimeType(ToASCIIOrEmpty(mime_type)) ?
- WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
-}
-
-WebMimeRegistry::SupportsType
- SimpleWebMimeRegistryImpl::supportsJavaScriptMIMEType(
- const WebString& mime_type) {
- return net::IsSupportedJavascriptMimeType(ToASCIIOrEmpty(mime_type)) ?
- WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
-}
-
-// When debugging layout tests failures in the test shell,
-// see TestShellWebMimeRegistryImpl.
-WebMimeRegistry::SupportsType SimpleWebMimeRegistryImpl::supportsMediaMIMEType(
- const WebString& mime_type,
- const WebString& codecs,
- const WebString& key_system) {
- // Media features are only supported at the content/ layer.
- return IsNotSupported;
-}
-
-bool SimpleWebMimeRegistryImpl::supportsMediaSourceMIMEType(
- const WebString& mime_type,
- const WebString& codecs) {
- // Media features are only supported at the content/ layer.
- return IsNotSupported;
-}
-
-WebMimeRegistry::SupportsType
- SimpleWebMimeRegistryImpl::supportsNonImageMIMEType(
- const WebString& mime_type) {
- return net::IsSupportedNonImageMimeType(ToASCIIOrEmpty(mime_type)) ?
- WebMimeRegistry::IsSupported : WebMimeRegistry::IsNotSupported;
-}
-
-WebString SimpleWebMimeRegistryImpl::mimeTypeForExtension(
- const WebString& file_extension) {
- std::string mime_type;
- net::GetMimeTypeFromExtension(
- base::FilePath::FromUTF16Unsafe(file_extension).value(), &mime_type);
- return WebString::fromUTF8(mime_type);
-}
-
-WebString SimpleWebMimeRegistryImpl::wellKnownMimeTypeForExtension(
- const WebString& file_extension) {
- std::string mime_type;
- net::GetWellKnownMimeTypeFromExtension(
- base::FilePath::FromUTF16Unsafe(file_extension).value(), &mime_type);
- return WebString::fromUTF8(mime_type);
-}
-
-WebString SimpleWebMimeRegistryImpl::mimeTypeFromFile(
- const WebString& file_path) {
- std::string mime_type;
- net::GetMimeTypeFromFile(base::FilePath::FromUTF16Unsafe(file_path),
- &mime_type);
- return WebString::fromUTF8(mime_type);
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/glue/simple_webmimeregistry_impl.h b/chromium/webkit/glue/simple_webmimeregistry_impl.h
deleted file mode 100644
index 9d765505b31..00000000000
--- a/chromium/webkit/glue/simple_webmimeregistry_impl.h
+++ /dev/null
@@ -1,49 +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 WEBKIT_GLUE_SIMPLE_WEBMIMEREGISTRY_IMPL_H_
-#define WEBKIT_GLUE_SIMPLE_WEBMIMEREGISTRY_IMPL_H_
-
-#include <string>
-
-#include "base/compiler_specific.h"
-#include "third_party/WebKit/public/platform/WebMimeRegistry.h"
-#include "webkit/glue/webkit_glue_export.h"
-
-namespace webkit_glue {
-
-class WEBKIT_GLUE_EXPORT SimpleWebMimeRegistryImpl :
- NON_EXPORTED_BASE(public blink::WebMimeRegistry) {
- public:
- SimpleWebMimeRegistryImpl() {}
- virtual ~SimpleWebMimeRegistryImpl() {}
-
- // Convert a WebString to ASCII, falling back on an empty string in the case
- // of a non-ASCII string.
- static std::string ToASCIIOrEmpty(const blink::WebString& string);
-
- // WebMimeRegistry methods:
- virtual blink::WebMimeRegistry::SupportsType supportsMIMEType(
- const blink::WebString&);
- virtual blink::WebMimeRegistry::SupportsType supportsImageMIMEType(
- const blink::WebString&);
- virtual blink::WebMimeRegistry::SupportsType supportsJavaScriptMIMEType(
- const blink::WebString&);
- virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType(
- const blink::WebString&,
- const blink::WebString&,
- const blink::WebString&);
- virtual bool supportsMediaSourceMIMEType(const blink::WebString&,
- const blink::WebString&);
- virtual blink::WebMimeRegistry::SupportsType supportsNonImageMIMEType(
- const blink::WebString&);
- virtual blink::WebString mimeTypeForExtension(const blink::WebString&);
- virtual blink::WebString wellKnownMimeTypeForExtension(
- const blink::WebString&);
- virtual blink::WebString mimeTypeFromFile(const blink::WebString&);
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_GLUE_SIMPLE_WEBMIMEREGISTRY_IMPL_H_
diff --git a/chromium/webkit/glue/webfileutilities_impl.cc b/chromium/webkit/glue/webfileutilities_impl.cc
deleted file mode 100644
index c7f4c7c40bb..00000000000
--- a/chromium/webkit/glue/webfileutilities_impl.cc
+++ /dev/null
@@ -1,85 +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 "webkit/glue/webfileutilities_impl.h"
-
-#include "base/file_util.h"
-#include "base/files/file_path.h"
-#include "base/logging.h"
-#include "net/base/file_stream.h"
-#include "net/base/net_util.h"
-#include "third_party/WebKit/public/platform/WebFileInfo.h"
-#include "third_party/WebKit/public/platform/WebString.h"
-#include "third_party/WebKit/public/platform/WebURL.h"
-#include "webkit/glue/webkit_glue.h"
-
-using blink::WebString;
-
-namespace webkit_glue {
-
-WebFileUtilitiesImpl::WebFileUtilitiesImpl()
- : sandbox_enabled_(true) {
-}
-
-WebFileUtilitiesImpl::~WebFileUtilitiesImpl() {
-}
-
-bool WebFileUtilitiesImpl::getFileInfo(const WebString& path,
- blink::WebFileInfo& web_file_info) {
- if (sandbox_enabled_) {
- NOTREACHED();
- return false;
- }
- base::PlatformFileInfo file_info;
- if (!base::GetFileInfo(base::FilePath::FromUTF16Unsafe(path), &file_info))
- return false;
-
- webkit_glue::PlatformFileInfoToWebFileInfo(file_info, &web_file_info);
- web_file_info.platformPath = path;
- return true;
-}
-
-WebString WebFileUtilitiesImpl::directoryName(const WebString& path) {
- return base::FilePath::FromUTF16Unsafe(path).DirName().AsUTF16Unsafe();
-}
-
-WebString WebFileUtilitiesImpl::baseName(const WebString& path) {
- return base::FilePath::FromUTF16Unsafe(path).BaseName().AsUTF16Unsafe();
-}
-
-blink::WebURL WebFileUtilitiesImpl::filePathToURL(const WebString& path) {
- return net::FilePathToFileURL(base::FilePath::FromUTF16Unsafe(path));
-}
-
-base::PlatformFile WebFileUtilitiesImpl::openFile(const WebString& path,
- int mode) {
- if (sandbox_enabled_) {
- NOTREACHED();
- return base::kInvalidPlatformFileValue;
- }
- // mode==0 (read-only) is the only supported mode.
- // TODO(kinuko): Remove this parameter.
- DCHECK_EQ(0, mode);
- return base::CreatePlatformFile(
- base::FilePath::FromUTF16Unsafe(path),
- base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ,
- NULL, NULL);
-}
-
-void WebFileUtilitiesImpl::closeFile(base::PlatformFile& handle) {
- if (handle == base::kInvalidPlatformFileValue)
- return;
- if (base::ClosePlatformFile(handle))
- handle = base::kInvalidPlatformFileValue;
-}
-
-int WebFileUtilitiesImpl::readFromFile(base::PlatformFile handle,
- char* data,
- int length) {
- if (handle == base::kInvalidPlatformFileValue || !data || length <= 0)
- return -1;
- return base::ReadPlatformFileCurPosNoBestEffort(handle, data, length);
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/glue/webfileutilities_impl.h b/chromium/webkit/glue/webfileutilities_impl.h
deleted file mode 100644
index c4e0aacae1b..00000000000
--- a/chromium/webkit/glue/webfileutilities_impl.h
+++ /dev/null
@@ -1,42 +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 WEBFILEUTILITIES_IMPL_H_
-#define WEBFILEUTILITIES_IMPL_H_
-
-#include "base/platform_file.h"
-#include "third_party/WebKit/public/platform/WebFileInfo.h"
-#include "third_party/WebKit/public/platform/WebFileUtilities.h"
-#include "webkit/glue/webkit_glue_export.h"
-
-namespace webkit_glue {
-
-class WEBKIT_GLUE_EXPORT WebFileUtilitiesImpl :
- NON_EXPORTED_BASE(public blink::WebFileUtilities) {
- public:
- WebFileUtilitiesImpl();
- virtual ~WebFileUtilitiesImpl();
-
- // WebFileUtilities methods:
- virtual bool getFileInfo(
- const blink::WebString& path,
- blink::WebFileInfo& result);
- virtual blink::WebString directoryName(const blink::WebString& path);
- virtual blink::WebString baseName(const blink::WebString& path);
- virtual blink::WebURL filePathToURL(const blink::WebString& path);
- virtual base::PlatformFile openFile(const blink::WebString& path, int mode);
- virtual void closeFile(base::PlatformFile& handle);
- virtual int readFromFile(base::PlatformFile handle, char* data, int length);
-
- void set_sandbox_enabled(bool sandbox_enabled) {
- sandbox_enabled_ = sandbox_enabled;
- }
-
- protected:
- bool sandbox_enabled_;
-};
-
-} // namespace webkit_glue
-
-#endif // WEBFILEUTILITIES_IMPL_H_
diff --git a/chromium/webkit/glue/webkit_glue.cc b/chromium/webkit/glue/webkit_glue.cc
deleted file mode 100644
index b051e433337..00000000000
--- a/chromium/webkit/glue/webkit_glue.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2013 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 "webkit/glue/webkit_glue.h"
-
-#include "base/logging.h"
-#include "third_party/WebKit/public/platform/WebFileInfo.h"
-#include "v8/include/v8.h"
-
-namespace webkit_glue {
-
-void SetJavaScriptFlags(const std::string& str) {
- v8::V8::SetFlagsFromString(str.data(), static_cast<int>(str.size()));
-}
-
-void PlatformFileInfoToWebFileInfo(
- const base::PlatformFileInfo& file_info,
- blink::WebFileInfo* web_file_info) {
- DCHECK(web_file_info);
- // WebKit now expects NaN as uninitialized/null Date.
- if (file_info.last_modified.is_null())
- web_file_info->modificationTime = std::numeric_limits<double>::quiet_NaN();
- else
- web_file_info->modificationTime = file_info.last_modified.ToDoubleT();
- web_file_info->length = file_info.size;
- if (file_info.is_directory)
- web_file_info->type = blink::WebFileInfo::TypeDirectory;
- else
- web_file_info->type = blink::WebFileInfo::TypeFile;
-}
-
-COMPILE_ASSERT(std::numeric_limits<double>::has_quiet_NaN, has_quiet_NaN);
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/glue/webkit_glue.gyp b/chromium/webkit/glue/webkit_glue.gyp
deleted file mode 100644
index 2b5c9158677..00000000000
--- a/chromium/webkit/glue/webkit_glue.gyp
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2013 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.
-
-{
- 'conditions': [
- # TODO(stuartmorgan): All dependencies from code built on iOS to
- # webkit/ should be removed, at which point this condition can be
- # removed.
- ['OS != "ios"', {
- 'includes': [
- '../../build/win_precompile.gypi',
- '../glue/webkit_glue.gypi',
- ],
- }],
- ],
-}
diff --git a/chromium/webkit/glue/webkit_glue.gypi b/chromium/webkit/glue/webkit_glue.gypi
deleted file mode 100644
index 868d22f5280..00000000000
--- a/chromium/webkit/glue/webkit_glue.gypi
+++ /dev/null
@@ -1,132 +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.
-
-{
- 'target_defaults': {
- # Disable narrowing-conversion-in-initialization-list warnings in that we
- # do not want to fix it in data file "webcursor_gtk_data.h".
- 'cflags+': ['-Wno-narrowing'],
- 'cflags_cc+': ['-Wno-narrowing'],
- },
- 'variables': {
- 'chromium_code': 1,
- },
- 'targets': [
- {
- 'target_name': 'glue',
- 'type': '<(component)',
- 'variables': { 'enable_wexit_time_destructors': 1, },
- 'defines': [
- 'WEBKIT_EXTENSIONS_IMPLEMENTATION',
- 'WEBKIT_GLUE_IMPLEMENTATION',
- ],
- 'dependencies': [
- '<(DEPTH)/base/base.gyp:base',
- '<(DEPTH)/base/base.gyp:base_i18n',
- '<(DEPTH)/base/base.gyp:base_static',
- '<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
- '<(DEPTH)/gpu/gpu.gyp:gles2_c_lib',
- '<(DEPTH)/gpu/gpu.gyp:gles2_implementation',
- '<(DEPTH)/net/net.gyp:net',
- '<(DEPTH)/skia/skia.gyp:skia',
- '<(DEPTH)/third_party/icu/icu.gyp:icui18n',
- '<(DEPTH)/third_party/icu/icu.gyp:icuuc',
- '<(DEPTH)/third_party/npapi/npapi.gyp:npapi',
- '<(DEPTH)/ui/gfx/gfx.gyp:gfx',
- '<(DEPTH)/ui/gl/gl.gyp:gl',
- '<(DEPTH)/url/url.gyp:url_lib',
- '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
- '<(DEPTH)/webkit/common/user_agent/webkit_user_agent.gyp:user_agent',
- '<(DEPTH)/webkit/common/webkit_common.gyp:webkit_common',
- '<(DEPTH)/webkit/renderer/compositor_bindings/compositor_bindings.gyp:webkit_compositor_support',
- '<(DEPTH)/webkit/storage_browser.gyp:webkit_storage_browser',
- '<(DEPTH)/webkit/storage_common.gyp:webkit_storage_common',
- '<(DEPTH)/webkit/webkit_resources.gyp:webkit_resources',
- '<(DEPTH)/webkit/webkit_resources.gyp:webkit_strings',
- ],
- 'include_dirs': [
- '<(INTERMEDIATE_DIR)',
- '<(SHARED_INTERMEDIATE_DIR)/webkit',
- '<(SHARED_INTERMEDIATE_DIR)/ui',
- ],
- 'sources': [
- 'simple_webmimeregistry_impl.cc',
- 'simple_webmimeregistry_impl.h',
- 'webfileutilities_impl.cc',
- 'webfileutilities_impl.h',
- 'webkit_glue.cc',
- 'webkit_glue.h',
- 'webkit_glue_export.h',
- ],
- # When glue is a dependency, it needs to be a hard dependency.
- # Dependents may rely on files generated by this target or one of its
- # own hard dependencies.
- 'hard_dependency': 1,
- 'conditions': [
- ['toolkit_uses_gtk == 1', {
- 'dependencies': [
- '<(DEPTH)/build/linux/system.gyp:gtk',
- ],
- 'sources/': [['exclude', '_x11\\.cc$']],
- }],
- ['use_aura==1 and use_x11==1', {
- 'link_settings': {
- 'libraries': [ '-lXcursor', ],
- },
- }],
- ['OS=="win"', {
- 'include_dirs': [
- '<(DEPTH)/third_party/wtl/include',
- ],
- # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
- 'msvs_disabled_warnings': [ 4800, 4267 ],
- 'conditions': [
- ['component=="shared_library"', {
- 'dependencies': [
- '<(DEPTH)/third_party/WebKit/public/blink.gyp:blink',
- ],
- 'export_dependent_settings': [
- '<(DEPTH)/third_party/WebKit/public/blink.gyp:blink',
- '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
- ],
- }],
- ],
- }],
- ['chrome_multiple_dll!=1', {
- 'dependencies': [
- '<(DEPTH)/third_party/WebKit/public/blink.gyp:blink',
- ],
- }],
- ['enable_printing!=0', {
- 'dependencies': [
- '<(DEPTH)/printing/printing.gyp:printing',
- ],
- }],
- ],
- },
- ],
- 'conditions': [
- ['use_third_party_translations==1', {
- 'targets': [
- {
- 'target_name': 'inspector_strings',
- 'type': 'none',
- 'variables': {
- 'grit_out_dir': '<(PRODUCT_DIR)/resources/inspector/l10n',
- },
- 'actions': [
- {
- 'action_name': 'inspector_strings',
- 'variables': {
- 'grit_grd_file': 'inspector_strings.grd',
- },
- 'includes': [ '../../build/grit_action.gypi' ],
- },
- ],
- 'includes': [ '../../build/grit_target.gypi' ],
- },
- ],
- }],
- ],
-}
diff --git a/chromium/webkit/glue/webkit_glue.h b/chromium/webkit/glue/webkit_glue.h
deleted file mode 100644
index 8f3a62baf56..00000000000
--- a/chromium/webkit/glue/webkit_glue.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2013 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 WEBKIT_GLUE_WEBKIT_GLUE_H_
-#define WEBKIT_GLUE_WEBKIT_GLUE_H_
-
-#include <string>
-
-#include "base/platform_file.h"
-#include "webkit/glue/webkit_glue_export.h"
-
-namespace blink {
-struct WebFileInfo;
-}
-
-namespace webkit_glue {
-
-WEBKIT_GLUE_EXPORT void SetJavaScriptFlags(const std::string& flags);
-
-// File info conversion
-WEBKIT_GLUE_EXPORT void PlatformFileInfoToWebFileInfo(
- const base::PlatformFileInfo& file_info,
- blink::WebFileInfo* web_file_info);
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_GLUE_WEBKIT_GLUE_H_
diff --git a/chromium/webkit/glue/webkit_glue_export.h b/chromium/webkit/glue/webkit_glue_export.h
deleted file mode 100644
index 0cbd3650a6c..00000000000
--- a/chromium/webkit/glue/webkit_glue_export.h
+++ /dev/null
@@ -1,29 +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 WEBKIT_GLUE_WEBKIT_GLUE_EXPORT_H_
-#define WEBKIT_GLUE_WEBKIT_GLUE_EXPORT_H_
-
-#if defined(COMPONENT_BUILD)
-#if defined(WIN32)
-
-#if defined(WEBKIT_GLUE_IMPLEMENTATION)
-#define WEBKIT_GLUE_EXPORT __declspec(dllexport)
-#else
-#define WEBKIT_GLUE_EXPORT __declspec(dllimport)
-#endif // defined(WEBKIT_GLUE_IMPLEMENTATION)
-
-#else // defined(WIN32)
-#if defined(WEBKIT_GLUE_IMPLEMENTATION)
-#define WEBKIT_GLUE_EXPORT __attribute__((visibility("default")))
-#else
-#define WEBKIT_GLUE_EXPORT
-#endif
-#endif
-
-#else // defined(COMPONENT_BUILD)
-#define WEBKIT_GLUE_EXPORT
-#endif
-
-#endif // WEBKIT_GLUE_WEBKIT_GLUE_EXPORT_H_
diff --git a/chromium/webkit/glue/webkit_glue_unittest.cc b/chromium/webkit/glue/webkit_glue_unittest.cc
deleted file mode 100644
index dd8deee873e..00000000000
--- a/chromium/webkit/glue/webkit_glue_unittest.cc
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright 2013 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 <string>
-
-#include "base/run_loop.h"
-#include "base/time/time.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/child/webkitplatformsupport_impl.h"
-
-namespace {
-
-// Derives WebKitPlatformSupportImpl for testing shared timers.
-class TestWebKitPlatformSupport
- : public webkit_glue::WebKitPlatformSupportImpl {
- public:
- TestWebKitPlatformSupport() : mock_monotonically_increasing_time_(0) {
- }
-
- // WebKitPlatformSupportImpl implementation
- virtual base::string16 GetLocalizedString(int) OVERRIDE {
- return base::string16();
- }
-
- virtual base::StringPiece GetDataResource(int, ui::ScaleFactor) OVERRIDE {
- return base::StringPiece();
- }
-
- virtual webkit_glue::ResourceLoaderBridge* CreateResourceLoader(
- const webkit_glue::ResourceLoaderBridge::RequestInfo&) OVERRIDE {
- return NULL;
- }
-
- virtual webkit_glue::WebSocketStreamHandleBridge* CreateWebSocketStreamBridge(
- blink::WebSocketStreamHandle*,
- webkit_glue::WebSocketStreamHandleDelegate*) OVERRIDE {
- return NULL;
- }
-
- // Returns mock time when enabled.
- virtual double monotonicallyIncreasingTime() OVERRIDE {
- if (mock_monotonically_increasing_time_ > 0.0)
- return mock_monotonically_increasing_time_;
- return webkit_glue::WebKitPlatformSupportImpl::
- monotonicallyIncreasingTime();
- }
-
- virtual void OnStartSharedTimer(base::TimeDelta delay) OVERRIDE {
- shared_timer_delay_ = delay;
- }
-
- base::TimeDelta shared_timer_delay() {
- return shared_timer_delay_;
- }
-
- void set_mock_monotonically_increasing_time(double mock_time) {
- mock_monotonically_increasing_time_ = mock_time;
- }
-
- private:
- base::TimeDelta shared_timer_delay_;
- double mock_monotonically_increasing_time_;
-};
-
-TEST(WebkitGlueTest, SuspendResumeSharedTimer) {
- base::MessageLoop message_loop;
-
- TestWebKitPlatformSupport platform_support;
-
- // Set a timer to fire as soon as possible.
- platform_support.setSharedTimerFireInterval(0);
- // Suspend timers immediately so the above timer wouldn't be fired.
- platform_support.SuspendSharedTimer();
- // The above timer would have posted a task which can be processed out of the
- // message loop.
- base::RunLoop().RunUntilIdle();
- // Set a mock time after 1 second to simulate timers suspended for 1 second.
- double new_time = base::Time::Now().ToDoubleT() + 1;
- platform_support.set_mock_monotonically_increasing_time(new_time);
- // Resume timers so that the timer set above will be set again to fire
- // immediately.
- platform_support.ResumeSharedTimer();
- EXPECT_TRUE(base::TimeDelta() == platform_support.shared_timer_delay());
-}
-
-} // namespace
diff --git a/chromium/webkit/glue/webkit_strings.grd b/chromium/webkit/glue/webkit_strings.grd
index 6f6d14cc9a9..f62606f1c79 100644
--- a/chromium/webkit/glue/webkit_strings.grd
+++ b/chromium/webkit/glue/webkit_strings.grd
@@ -30,7 +30,7 @@ below:
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-->
@@ -50,34 +50,34 @@ below:
<output filename="webkit_strings_am.pak" type="data_package" lang="am" />
<output filename="webkit_strings_ar.pak" type="data_package" lang="ar" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="webkit_strings_ast.pak" type="data_package" lang="ast" />
</if>
<output filename="webkit_strings_bg.pak" type="data_package" lang="bg" />
<output filename="webkit_strings_bn.pak" type="data_package" lang="bn" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="webkit_strings_bs.pak" type="data_package" lang="bs" />
</if>
<output filename="webkit_strings_ca.pak" type="data_package" lang="ca" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="webkit_strings_ca@valencia.pak" type="data_package" lang="ca@valencia" />
</if>
<output filename="webkit_strings_cs.pak" type="data_package" lang="cs" />
<output filename="webkit_strings_da.pak" type="data_package" lang="da" />
<output filename="webkit_strings_de.pak" type="data_package" lang="de" />
<output filename="webkit_strings_el.pak" type="data_package" lang="el" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="webkit_strings_en-AU.pak" type="data_package" lang="en-AU" />
</if>
<output filename="webkit_strings_en-GB.pak" type="data_package" lang="en-GB" />
<output filename="webkit_strings_en-US.pak" type="data_package" lang="en" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="webkit_strings_eo.pak" type="data_package" lang="eo" />
</if>
<output filename="webkit_strings_es.pak" type="data_package" lang="es" />
<output filename="webkit_strings_es-419.pak" type="data_package" lang="es-419" />
<output filename="webkit_strings_et.pak" type="data_package" lang="et" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="webkit_strings_eu.pak" type="data_package" lang="eu" />
</if>
<output filename="webkit_strings_fa.pak" type="data_package" lang="fa" />
@@ -85,7 +85,7 @@ below:
<output filename="webkit_strings_fi.pak" type="data_package" lang="fi" />
<output filename="webkit_strings_fil.pak" type="data_package" lang="fil" />
<output filename="webkit_strings_fr.pak" type="data_package" lang="fr" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="webkit_strings_gl.pak" type="data_package" lang="gl" />
</if>
<output filename="webkit_strings_gu.pak" type="data_package" lang="gu" />
@@ -93,19 +93,19 @@ below:
<output filename="webkit_strings_hi.pak" type="data_package" lang="hi" />
<output filename="webkit_strings_hr.pak" type="data_package" lang="hr" />
<output filename="webkit_strings_hu.pak" type="data_package" lang="hu" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="webkit_strings_hy.pak" type="data_package" lang="hy" />
<output filename="webkit_strings_ia.pak" type="data_package" lang="ia" />
</if>
<output filename="webkit_strings_id.pak" type="data_package" lang="id" />
<output filename="webkit_strings_it.pak" type="data_package" lang="it" />
<output filename="webkit_strings_ja.pak" type="data_package" lang="ja" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="webkit_strings_ka.pak" type="data_package" lang="ka" />
</if>
<output filename="webkit_strings_kn.pak" type="data_package" lang="kn" />
<output filename="webkit_strings_ko.pak" type="data_package" lang="ko" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="webkit_strings_ku.pak" type="data_package" lang="ku" />
<output filename="webkit_strings_kw.pak" type="data_package" lang="kw" />
</if>
@@ -132,7 +132,7 @@ below:
<output filename="webkit_strings_te.pak" type="data_package" lang="te" />
<output filename="webkit_strings_th.pak" type="data_package" lang="th" />
<output filename="webkit_strings_tr.pak" type="data_package" lang="tr" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<output filename="webkit_strings_ug.pak" type="data_package" lang="ug" />
</if>
<output filename="webkit_strings_uk.pak" type="data_package" lang="uk" />
@@ -143,44 +143,44 @@ below:
<translations>
<file path="resources/webkit_strings_am.xtb" lang="am" />
<file path="resources/webkit_strings_ar.xtb" lang="ar" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<file path="../../third_party/launchpad_translations/webkit_strings_ast.xtb" lang="ast" />
</if>
<file path="resources/webkit_strings_bg.xtb" lang="bg" />
<file path="resources/webkit_strings_bn.xtb" lang="bn" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<file path="../../third_party/launchpad_translations/webkit_strings_bs.xtb" lang="bs" />
</if>
<file path="resources/webkit_strings_ca.xtb" lang="ca" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<file path="../../third_party/launchpad_translations/webkit_strings_ca-valencia.xtb" lang="ca@valencia" />
</if>
<file path="resources/webkit_strings_cs.xtb" lang="cs" />
<file path="resources/webkit_strings_da.xtb" lang="da" />
<file path="resources/webkit_strings_de.xtb" lang="de" />
<file path="resources/webkit_strings_el.xtb" lang="el" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<file path="../../third_party/launchpad_translations/webkit_strings_en-AU.xtb" lang="en-AU" />
</if>
<file path="resources/webkit_strings_en-GB.xtb" lang="en-GB" />
<file path="resources/webkit_strings_es.xtb" lang="es" />
<file path="resources/webkit_strings_es-419.xtb" lang="es-419" />
<file path="resources/webkit_strings_et.xtb" lang="et" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<file path="../../third_party/launchpad_translations/webkit_strings_eu.xtb" lang="eu" />
</if>
<file path="resources/webkit_strings_fa.xtb" lang="fa" />
<file path="resources/webkit_strings_fi.xtb" lang="fi" />
<file path="resources/webkit_strings_fil.xtb" lang="fil" />
<file path="resources/webkit_strings_fr.xtb" lang="fr" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<file path="../../third_party/launchpad_translations/webkit_strings_gl.xtb" lang="gl" />
</if>
<file path="resources/webkit_strings_gu.xtb" lang="gu" />
<file path="resources/webkit_strings_hi.xtb" lang="hi" />
<file path="resources/webkit_strings_hr.xtb" lang="hr" />
<file path="resources/webkit_strings_hu.xtb" lang="hu" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<file path="../../third_party/launchpad_translations/webkit_strings_hy.xtb" lang="hy" />
</if>
<file path="resources/webkit_strings_id.xtb" lang="id" />
@@ -188,12 +188,12 @@ below:
<!-- The translation console uses 'iw' for Hebrew, but we use 'he'. -->
<file path="resources/webkit_strings_iw.xtb" lang="he" />
<file path="resources/webkit_strings_ja.xtb" lang="ja" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<file path="../../third_party/launchpad_translations/webkit_strings_ka.xtb" lang="ka" />
</if>
<file path="resources/webkit_strings_kn.xtb" lang="kn" />
<file path="resources/webkit_strings_ko.xtb" lang="ko" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<file path="../../third_party/launchpad_translations/webkit_strings_ku.xtb" lang="ku" />
<file path="../../third_party/launchpad_translations/webkit_strings_kw.xtb" lang="kw" />
</if>
@@ -218,7 +218,7 @@ below:
<file path="resources/webkit_strings_te.xtb" lang="te" />
<file path="resources/webkit_strings_th.xtb" lang="th" />
<file path="resources/webkit_strings_tr.xtb" lang="tr" />
- <if expr="pp_ifdef('use_third_party_translations')">
+ <if expr="use_third_party_translations">
<file path="../../third_party/launchpad_translations/webkit_strings_ug.xtb" lang="ug" />
</if>
<file path="resources/webkit_strings_uk.xtb" lang="uk" />
@@ -272,9 +272,6 @@ below:
<message name="IDS_FORM_FILE_NO_FILE_LABEL" desc="text to display in file button used in HTML forms when no file is selected">
No file chosen
</message>
- <message name="IDS_FORM_FILE_NO_FILE_DRAG_LABEL" desc="text to display in file button used in HTML forms when no file is selected to indicate that files can be dragged onto the file button">
- Drag file here
- </message>
<message name="IDS_FORM_FILE_MULTIPLE_UPLOAD" desc="text to display next to file buttons in HTML forms when 2 or more files are selected for uploading. This is not used for a case that just 1 file is selected.">
<ph name="NUMBER_OF_FILES">$1<ex>3</ex></ph> files
</message>
@@ -302,6 +299,9 @@ below:
<message name="IDS_FORM_PLACEHOLDER_FOR_YEAR_FIELD" desc="Text for denoting day of month field position in date format. Short text is prefered. See http://crbug.com/152632 for samples.">
yyyy
</message>
+ <message name="IDS_FORM_SELECT_MENU_LIST_TEXT" desc="Text for the menu list rendering of a select element.">
+ <ph name="SELECTED_COUNT">$1<ex>3</ex></ph> selected
+ </message>
<message name="IDS_FORM_THIS_MONTH_LABEL" desc="Label for button in month picker to select this month.">
This month
</message>
@@ -322,10 +322,6 @@ below:
Clear Recent Searches
</message>
- <message name="IDS_IMAGE_TITLE_FOR_FILENAME" desc="window title for a standalone image (uses mutiplication symbol, not x)">
- <ph name="FILENAME">%s<ex>My Cool Image.gif</ex></ph><ph name="WIDTH">%d<ex>400</ex></ph>×<ph name="HEIGHT">%d<ex>600</ex></ph>
- </message>
-
<message name="IDS_AX_ROLE_WEB_AREA" desc="accessibility role description for web area">
HTML content
</message>
@@ -341,12 +337,17 @@ below:
<message name="IDS_AX_ROLE_HEADING" desc="accessibility role description for headings">
heading
</message>
- <message name="IDS_AX_ROLE_FOOTER" desc="accessibility role description for footers">
- footer
- </message>
- <message name="IDS_AX_ROLE_STEPPER" desc="accessibility role description for a stepper - a control where you can use up/down arrows to increment or decrement it. The name 'stepper' is how this user interface element is described by VoiceOver on Mac OS X; the translation should be consistent with VoiceOver.">
- stepper
- </message>
+ <if expr="is_macosx">
+ <message name="IDS_AX_ROLE_FOOTER" desc="accessibility role description for footers">
+ footer
+ </message>
+ <message name="IDS_AX_ROLE_STEPPER" desc="accessibility role description for a stepper - a control where you can use up/down arrows to increment or decrement it. The name 'stepper' is how this user interface element is described by VoiceOver on Mac OS X; the translation should be consistent with VoiceOver.">
+ stepper
+ </message>
+ <message name="IDS_AX_ROLE_TOGGLE_BUTTON" desc="accessibility role description for a toggle button">
+ toggle button
+ </message>
+ </if>
<message name="IDS_AX_BUTTON_ACTION_VERB" desc="Verb stating the action that will occur when a button is pressed, as used by accessibility.">
press
@@ -419,14 +420,6 @@ below:
movie timeline thumb
</message>
- <message name="IDS_AX_MEDIA_REWIND_BUTTON" desc="accessibility role description for seek back 30 seconds button">
- back 30 seconds
- </message>
-
- <message name="IDS_AX_MEDIA_RETURN_TO_REALTIME_BUTTON" desc="accessibility role description for return to real time button">
- return to real time
- </message>
-
<message name="IDS_AX_MEDIA_CURRENT_TIME_DISPLAY" desc="accessibility role description for elapsed time display">
elapsed time
</message>
@@ -447,14 +440,6 @@ below:
exit full screen
</message>
- <message name="IDS_AX_MEDIA_SEEK_FORWARD_BUTTON" desc="accessibility role description for fast forward button">
- fast forward
- </message>
-
- <message name="IDS_AX_MEDIA_SEEK_BACK_BUTTON" desc="accessibility role description for fast reverse button">
- fast reverse
- </message>
-
<message name="IDS_AX_MEDIA_SHOW_CLOSED_CAPTIONS_BUTTON" desc="accessibility role description for show closed captions button">
show closed captions
</message>
@@ -495,14 +480,6 @@ below:
movie time scrubber thumb
</message>
- <message name="IDS_AX_MEDIA_REWIND_BUTTON_HELP" desc="accessibility help description for seek back 30 seconds button">
- seek movie back 30 seconds
- </message>
-
- <message name="IDS_AX_MEDIA_RETURN_TO_REALTIME_BUTTON_HELP" desc="accessibility help description for return to real time button">
- return streaming movie to real time
- </message>
-
<message name="IDS_AX_MEDIA_CURRENT_TIME_DISPLAY_HELP" desc="accessibility help description for elapsed time display">
current time in seconds
</message>
@@ -523,14 +500,6 @@ below:
exit full screen
</message>
- <message name="IDS_AX_MEDIA_SEEK_FORWARD_BUTTON_HELP" desc="accessibility help description for fast forward button">
- seek quickly forward
- </message>
-
- <message name="IDS_AX_MEDIA_SEEK_BACK_BUTTON_HELP" desc="accessibility help description for fast reverse button">
- seek quickly back
- </message>
-
<message name="IDS_AX_MEDIA_SHOW_CLOSED_CAPTIONS_BUTTON_HELP" desc="accessibility help description for show closed captions button">
start displaying closed captions
</message>
@@ -616,10 +585,10 @@ below:
Value must be <ph name="MAXIMUM_DATE_OR_TIME">$1<ex>12/31/2013</ex></ph> or earlier.
</message>
<message name="IDS_FORM_VALIDATION_BAD_INPUT_DATETIME" desc="Heading or short sentence shown when a user specified an incomplete value or an invalid date (such as 02/31/2012) to a date/time form control in a webpage.">
- Please enter a valid value. The field is incomplete or has an invalid date.
+ Please enter a valid value. The field is incomplete or has an invalid date.
</message>
<message name="IDS_FORM_VALIDATION_BAD_INPUT_NUMBER" desc="Heading or short sentence shown when a user entered a non-number string to a number field in a webpage.">
- Please enter a number.
+ Please enter a number.
</message>
<!-- The following IDS_FORM_VALIDATION_* messages were taken from Mozilla's dom.properties file.
@@ -704,10 +673,6 @@ below:
Loading...
</message>
- <message name="IDS_PDF_LOADING_PROGRESS" desc="A message displayed on the PDF control to indicate loading progress.">
- Loading document: <ph name="PAGE_NUMBER">%d<ex>3</ex></ph>/<ph name="NUMBER_OF_PAGES">%d<ex>15</ex></ph> pages...
- </message>
-
<message name="IDS_PDF_PAGE_LOAD_FAILED" desc="A message displayed on the PDF control to indicate that the PDF document failed to load.">
Failed to load PDF document
</message>
diff --git a/chromium/webkit/renderer/compositor_bindings/DEPS b/chromium/webkit/renderer/compositor_bindings/DEPS
deleted file mode 100644
index c3a5b96fc44..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/DEPS
+++ /dev/null
@@ -1,3 +0,0 @@
-include_rules = [
- "+media",
-]
diff --git a/chromium/webkit/renderer/compositor_bindings/OWNERS b/chromium/webkit/renderer/compositor_bindings/OWNERS
deleted file mode 100644
index d42bb39ccd8..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-enne@chromium.org
-nduca@chromium.org
diff --git a/chromium/webkit/renderer/compositor_bindings/PRESUBMIT.py b/chromium/webkit/renderer/compositor_bindings/PRESUBMIT.py
deleted file mode 100644
index 4c2c1f98741..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/PRESUBMIT.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright (c) 2013 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.
-
-"""
-See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
-details on the presubmit API built into gcl.
-"""
-
-SOURCE_FILES = (r'^.*\.(cc|h)$')
-
-def CheckChangeLintsClean(input_api, output_api):
- input_api.cpplint._cpplint_state.ResetErrorCounts() # reset global state
- source_filter = lambda x: input_api.FilterSourceFile(
- x, white_list=SOURCE_FILES, black_list=None)
- files = [f.AbsoluteLocalPath() for f in
- input_api.AffectedSourceFiles(source_filter)]
- level = 1 # strict, but just warn
-
- for file_name in files:
- input_api.cpplint.ProcessFile(file_name, level)
-
- if not input_api.cpplint._cpplint_state.error_count:
- return []
-
- return [output_api.PresubmitPromptWarning(
- 'Changelist failed cpplint.py check.')]
-
-
-def CheckChangeOnUpload(input_api, output_api):
- results = []
- results += CheckChangeLintsClean(input_api, output_api)
- return results
diff --git a/chromium/webkit/renderer/compositor_bindings/compositor_bindings.gyp b/chromium/webkit/renderer/compositor_bindings/compositor_bindings.gyp
deleted file mode 100644
index abaf7252c70..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/compositor_bindings.gyp
+++ /dev/null
@@ -1,84 +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.
-
-{
- 'variables': {
- 'chromium_code': 1,
- },
- 'targets': [
- {
- 'target_name': 'webkit_compositor_support',
- 'type': 'static_library',
- 'dependencies': [
- '<(DEPTH)/skia/skia.gyp:skia',
- '<(DEPTH)/cc/cc.gyp:cc',
- 'webkit_compositor_bindings',
- ],
- 'sources': [
- 'web_compositor_support_impl.cc',
- 'web_compositor_support_impl.h',
- ],
- 'include_dirs': [
- '../..',
- '<(SHARED_INTERMEDIATE_DIR)/webkit',
- ],
- },
- {
- 'target_name': 'webkit_compositor_bindings',
- 'type': '<(component)',
- 'dependencies': [
- '<(DEPTH)/base/base.gyp:base',
- '<(DEPTH)/cc/cc.gyp:cc',
- '<(DEPTH)/gpu/gpu.gyp:gpu',
- '<(DEPTH)/media/media.gyp:media',
- '<(DEPTH)/skia/skia.gyp:skia',
- '<(DEPTH)/third_party/WebKit/public/blink.gyp:blink',
- '<(DEPTH)/ui/gfx/gfx.gyp:gfx',
- '<(DEPTH)/webkit/common/gpu/webkit_gpu.gyp:webkit_gpu',
- ],
- 'defines': [
- 'WEBKIT_COMPOSITOR_BINDINGS_IMPLEMENTATION=1'
- ],
- 'sources': [
- 'scrollbar_impl.cc',
- 'scrollbar_impl.h',
- 'web_animation_curve_common.cc',
- 'web_animation_curve_common.h',
- 'web_animation_impl.cc',
- 'web_animation_impl.h',
- 'web_compositing_reasons.cc',
- 'web_content_layer_impl.cc',
- 'web_content_layer_impl.h',
- 'web_external_bitmap_impl.cc',
- 'web_external_bitmap_impl.h',
- 'web_external_texture_layer_impl.cc',
- 'web_external_texture_layer_impl.h',
- 'web_filter_animation_curve_impl.cc',
- 'web_filter_animation_curve_impl.h',
- 'web_filter_operations_impl.cc',
- 'web_filter_operations_impl.h',
- 'web_float_animation_curve_impl.cc',
- 'web_float_animation_curve_impl.h',
- 'web_image_layer_impl.cc',
- 'web_image_layer_impl.h',
- 'web_layer_impl.cc',
- 'web_layer_impl.h',
- 'web_layer_impl_fixed_bounds.cc',
- 'web_layer_impl_fixed_bounds.h',
- 'web_nine_patch_layer_impl.cc',
- 'web_nine_patch_layer_impl.h',
- 'web_scrollbar_layer_impl.cc',
- 'web_scrollbar_layer_impl.h',
- 'web_solid_color_layer_impl.cc',
- 'web_solid_color_layer_impl.h',
- 'web_to_cc_animation_delegate_adapter.cc',
- 'web_to_cc_animation_delegate_adapter.h',
- 'web_transform_animation_curve_impl.cc',
- 'web_transform_animation_curve_impl.h',
- 'web_transform_operations_impl.cc',
- 'web_transform_operations_impl.h',
- ],
- },
- ],
-}
diff --git a/chromium/webkit/renderer/compositor_bindings/compositor_bindings_dummy_unittest.cc b/chromium/webkit/renderer/compositor_bindings/compositor_bindings_dummy_unittest.cc
new file mode 100644
index 00000000000..7a3ecfec2fc
--- /dev/null
+++ b/chromium/webkit/renderer/compositor_bindings/compositor_bindings_dummy_unittest.cc
@@ -0,0 +1,11 @@
+// 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 "testing/gtest/include/gtest/gtest.h"
+
+namespace webkit {
+ TEST(CompositorBindingsDummyTest, DummyTest) {
+ EXPECT_EQ(0, 0);
+ }
+}
diff --git a/chromium/webkit/renderer/compositor_bindings/compositor_bindings_tests.gyp b/chromium/webkit/renderer/compositor_bindings/compositor_bindings_tests.gyp
index 9c5018eba3b..6164935a4da 100644
--- a/chromium/webkit/renderer/compositor_bindings/compositor_bindings_tests.gyp
+++ b/chromium/webkit/renderer/compositor_bindings/compositor_bindings_tests.gyp
@@ -2,44 +2,34 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+# This is a dummy target so as to not to break the build while moving tests from
+# webkit_compositor_bindings_unittests to content_unittests.
{
'variables': {
'chromium_code': 1,
- 'webkit_compositor_bindings_tests_sources': [
- 'web_animation_unittest.cc',
- 'web_float_animation_curve_unittest.cc',
- 'web_layer_impl_fixed_bounds_unittest.cc',
- ],
},
'targets': [
{
'target_name': 'webkit_compositor_bindings_unittests',
'type' : '<(gtest_target_type)',
'dependencies': [
- '<(DEPTH)/base/base.gyp:test_support_base',
- '<(DEPTH)/cc/cc.gyp:cc',
- '<(DEPTH)/cc/cc_tests.gyp:cc_test_support',
- '<(DEPTH)/skia/skia.gyp:skia',
'<(DEPTH)/testing/gmock.gyp:gmock',
'<(DEPTH)/testing/gtest.gyp:gtest',
- 'compositor_bindings.gyp:webkit_compositor_bindings',
+ '<(DEPTH)/base/base.gyp:test_support_base',
],
'sources': [
- '<@(webkit_compositor_bindings_tests_sources)',
+ 'compositor_bindings_dummy_unittest.cc',
'test/run_all_unittests.cc',
],
- 'include_dirs': [
- '<(DEPTH)'
- ],
'conditions': [
- ['OS == "android" and gtest_target_type == "shared_library"', {
+ ['OS == "android"', {
'dependencies': [
'<(DEPTH)/testing/android/native_test.gyp:native_test_native_code',
],
}],
[ 'os_posix == 1 and OS != "mac" and OS != "android" and OS != "ios"', {
'conditions': [
- [ 'linux_use_tcmalloc==1', {
+ [ 'use_allocator!="none"', {
'dependencies': [
'<(DEPTH)/base/allocator/allocator.gyp:allocator',
],
@@ -50,9 +40,7 @@
},
],
'conditions': [
- # Special target to wrap a gtest_target_type==shared_library
- # package webkit_compositor_bindings_unittests into an android apk for execution.
- ['OS == "android" and gtest_target_type == "shared_library"', {
+ ['OS == "android"', {
'targets': [
{
'target_name': 'webkit_compositor_bindings_unittests_apk',
@@ -62,11 +50,10 @@
],
'variables': {
'test_suite_name': 'webkit_compositor_bindings_unittests',
- 'input_shlib_path': '<(SHARED_LIB_DIR)/<(SHARED_LIB_PREFIX)webkit_compositor_bindings_unittests<(SHARED_LIB_SUFFIX)',
},
'includes': [ '../../../build/apk_test.gypi' ],
},
],
}],
],
-}
+} \ No newline at end of file
diff --git a/chromium/webkit/renderer/compositor_bindings/scrollbar_impl.cc b/chromium/webkit/renderer/compositor_bindings/scrollbar_impl.cc
deleted file mode 100644
index fb60cd89a5e..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/scrollbar_impl.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 2013 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 "webkit/renderer/compositor_bindings/scrollbar_impl.h"
-
-#include "base/logging.h"
-#include "third_party/WebKit/public/platform/WebScrollbar.h"
-#include "third_party/WebKit/public/platform/WebScrollbarThemeGeometry.h"
-
-using blink::WebScrollbar;
-
-namespace webkit {
-
-ScrollbarImpl::ScrollbarImpl(
- scoped_ptr<WebScrollbar> scrollbar,
- blink::WebScrollbarThemePainter painter,
- scoped_ptr<blink::WebScrollbarThemeGeometry> geometry)
- : scrollbar_(scrollbar.Pass()),
- painter_(painter),
- geometry_(geometry.Pass()) {}
-
-ScrollbarImpl::~ScrollbarImpl() {}
-
-cc::ScrollbarOrientation ScrollbarImpl::Orientation() const {
- if (scrollbar_->orientation() == WebScrollbar::Horizontal)
- return cc::HORIZONTAL;
- return cc::VERTICAL;
-}
-
-bool ScrollbarImpl::IsLeftSideVerticalScrollbar() const {
- return scrollbar_->isLeftSideVerticalScrollbar();
-}
-
-bool ScrollbarImpl::HasThumb() const {
- return geometry_->hasThumb(scrollbar_.get());
-}
-
-bool ScrollbarImpl::IsOverlay() const {
- return scrollbar_->isOverlay();
-}
-
-gfx::Point ScrollbarImpl::Location() const {
- return scrollbar_->location();
-}
-
-int ScrollbarImpl::ThumbThickness() const {
- gfx::Rect thumb_rect = geometry_->thumbRect(scrollbar_.get());
- if (scrollbar_->orientation() == WebScrollbar::Horizontal)
- return thumb_rect.height();
- return thumb_rect.width();
-}
-
-int ScrollbarImpl::ThumbLength() const {
- gfx::Rect thumb_rect = geometry_->thumbRect(scrollbar_.get());
- if (scrollbar_->orientation() == WebScrollbar::Horizontal)
- return thumb_rect.width();
- return thumb_rect.height();
-}
-
-gfx::Rect ScrollbarImpl::TrackRect() const {
- return geometry_->trackRect(scrollbar_.get());
-}
-
-void ScrollbarImpl::PaintPart(
- SkCanvas* canvas, cc::ScrollbarPart part, gfx::Rect content_rect) {
- if (part == cc::THUMB) {
- painter_.paintThumb(canvas, content_rect);
- return;
- }
-
- // The following is a simplification of ScrollbarThemeComposite::paint.
- painter_.paintScrollbarBackground(canvas, content_rect);
-
- if (geometry_->hasButtons(scrollbar_.get())) {
- gfx::Rect back_button_start_paint_rect =
- geometry_->backButtonStartRect(scrollbar_.get());
- painter_.paintBackButtonStart(canvas, back_button_start_paint_rect);
-
- gfx::Rect back_button_end_paint_rect =
- geometry_->backButtonEndRect(scrollbar_.get());
- painter_.paintBackButtonEnd(canvas, back_button_end_paint_rect);
-
- gfx::Rect forward_button_start_paint_rect =
- geometry_->forwardButtonStartRect(scrollbar_.get());
- painter_.paintForwardButtonStart(canvas,
- forward_button_start_paint_rect);
-
- gfx::Rect forward_button_end_paint_rect =
- geometry_->forwardButtonEndRect(scrollbar_.get());
- painter_.paintForwardButtonEnd(canvas, forward_button_end_paint_rect);
- }
-
- gfx::Rect track_paint_rect = geometry_->trackRect(scrollbar_.get());
- painter_.paintTrackBackground(canvas, track_paint_rect);
-
- bool thumb_present = geometry_->hasThumb(scrollbar_.get());
- if (thumb_present) {
- painter_.paintForwardTrackPart(canvas, track_paint_rect);
- painter_.paintBackTrackPart(canvas, track_paint_rect);
- }
-
- painter_.paintTickmarks(canvas, track_paint_rect);
-}
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/scrollbar_impl.h b/chromium/webkit/renderer/compositor_bindings/scrollbar_impl.h
deleted file mode 100644
index c77ad79c760..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/scrollbar_impl.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2013 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_SCROLLBAR_IMPL_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_SCROLLBAR_IMPL_H_
-
-#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-#include "cc/input/scrollbar.h"
-#include "third_party/WebKit/public/platform/WebScrollbarThemePainter.h"
-
-namespace blink {
-class WebScrollbar;
-class WebScrollbarThemeGeometry;
-}
-
-namespace webkit {
-
-class ScrollbarImpl : public cc::Scrollbar {
- public:
- ScrollbarImpl(scoped_ptr<blink::WebScrollbar> scrollbar,
- blink::WebScrollbarThemePainter painter,
- scoped_ptr<blink::WebScrollbarThemeGeometry> geometry);
- virtual ~ScrollbarImpl();
-
- // cc::Scrollbar implementation.
- virtual cc::ScrollbarOrientation Orientation() const OVERRIDE;
- virtual bool IsLeftSideVerticalScrollbar() const OVERRIDE;
- virtual bool HasThumb() const OVERRIDE;
- virtual bool IsOverlay() const OVERRIDE;
- virtual gfx::Point Location() const OVERRIDE;
- virtual int ThumbThickness() const OVERRIDE;
- virtual int ThumbLength() const OVERRIDE;
- virtual gfx::Rect TrackRect() const OVERRIDE;
- virtual void PaintPart(SkCanvas* canvas,
- cc::ScrollbarPart part,
- gfx::Rect content_rect) OVERRIDE;
-
- private:
- scoped_ptr<blink::WebScrollbar> scrollbar_;
- blink::WebScrollbarThemePainter painter_;
- scoped_ptr<blink::WebScrollbarThemeGeometry> geometry_;
-
- DISALLOW_COPY_AND_ASSIGN(ScrollbarImpl);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_SCROLLBAR_IMPL_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_animation_curve_common.cc b/chromium/webkit/renderer/compositor_bindings/web_animation_curve_common.cc
deleted file mode 100644
index 0104ea346a0..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_animation_curve_common.cc
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 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 "webkit/renderer/compositor_bindings/web_animation_curve_common.h"
-
-#include "cc/animation/timing_function.h"
-
-namespace webkit {
-
-scoped_ptr<cc::TimingFunction> CreateTimingFunction(
- blink::WebAnimationCurve::TimingFunctionType type) {
- switch (type) {
- case blink::WebAnimationCurve::TimingFunctionTypeEase:
- return cc::EaseTimingFunction::Create();
- case blink::WebAnimationCurve::TimingFunctionTypeEaseIn:
- return cc::EaseInTimingFunction::Create();
- case blink::WebAnimationCurve::TimingFunctionTypeEaseOut:
- return cc::EaseOutTimingFunction::Create();
- case blink::WebAnimationCurve::TimingFunctionTypeEaseInOut:
- return cc::EaseInOutTimingFunction::Create();
- case blink::WebAnimationCurve::TimingFunctionTypeLinear:
- return scoped_ptr<cc::TimingFunction>();
- }
- return scoped_ptr<cc::TimingFunction>();
-}
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_animation_curve_common.h b/chromium/webkit/renderer/compositor_bindings/web_animation_curve_common.h
deleted file mode 100644
index b24fabacc37..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_animation_curve_common.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_ANIMATION_CURVE_COMMON_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_ANIMATION_CURVE_COMMON_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "third_party/WebKit/public/platform/WebAnimationCurve.h"
-
-namespace cc { class TimingFunction; }
-
-namespace webkit {
-scoped_ptr<cc::TimingFunction> CreateTimingFunction(
- blink::WebAnimationCurve::TimingFunctionType);
-}
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_ANIMATION_CURVE_COMMON_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_animation_impl.cc b/chromium/webkit/renderer/compositor_bindings/web_animation_impl.cc
deleted file mode 100644
index dbcc184b268..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_animation_impl.cc
+++ /dev/null
@@ -1,113 +0,0 @@
-// Copyright 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 "webkit/renderer/compositor_bindings/web_animation_impl.h"
-
-#include "cc/animation/animation.h"
-#include "cc/animation/animation_curve.h"
-#include "cc/animation/animation_id_provider.h"
-#include "third_party/WebKit/public/platform/WebAnimation.h"
-#include "third_party/WebKit/public/platform/WebAnimationCurve.h"
-#include "webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.h"
-#include "webkit/renderer/compositor_bindings/web_float_animation_curve_impl.h"
-#include "webkit/renderer/compositor_bindings/web_transform_animation_curve_impl.h"
-
-using cc::Animation;
-using cc::AnimationIdProvider;
-
-using blink::WebAnimation;
-using blink::WebAnimationCurve;
-
-namespace webkit {
-
-WebAnimationImpl::WebAnimationImpl(const WebAnimationCurve& web_curve,
- TargetProperty target_property,
- int animation_id,
- int group_id) {
- if (!animation_id)
- animation_id = AnimationIdProvider::NextAnimationId();
- if (!group_id)
- group_id = AnimationIdProvider::NextGroupId();
-
- WebAnimationCurve::AnimationCurveType curve_type = web_curve.type();
- scoped_ptr<cc::AnimationCurve> curve;
- switch (curve_type) {
- case WebAnimationCurve::AnimationCurveTypeFloat: {
- const WebFloatAnimationCurveImpl* float_curve_impl =
- static_cast<const WebFloatAnimationCurveImpl*>(&web_curve);
- curve = float_curve_impl->CloneToAnimationCurve();
- break;
- }
- case WebAnimationCurve::AnimationCurveTypeTransform: {
- const WebTransformAnimationCurveImpl* transform_curve_impl =
- static_cast<const WebTransformAnimationCurveImpl*>(&web_curve);
- curve = transform_curve_impl->CloneToAnimationCurve();
- break;
- }
- case WebAnimationCurve::AnimationCurveTypeFilter: {
- const WebFilterAnimationCurveImpl* filter_curve_impl =
- static_cast<const WebFilterAnimationCurveImpl*>(&web_curve);
- curve = filter_curve_impl->CloneToAnimationCurve();
- break;
- }
- }
- animation_ = Animation::Create(
- curve.Pass(),
- animation_id,
- group_id,
- static_cast<cc::Animation::TargetProperty>(target_property));
-}
-
-WebAnimationImpl::~WebAnimationImpl() {}
-
-int WebAnimationImpl::id() { return animation_->id(); }
-
-blink::WebAnimation::TargetProperty WebAnimationImpl::targetProperty() const {
- return static_cast<WebAnimationImpl::TargetProperty>(
- animation_->target_property());
-}
-
-int WebAnimationImpl::iterations() const { return animation_->iterations(); }
-
-void WebAnimationImpl::setIterations(int n) { animation_->set_iterations(n); }
-
-double WebAnimationImpl::startTime() const { return animation_->start_time(); }
-
-void WebAnimationImpl::setStartTime(double monotonic_time) {
- animation_->set_start_time(monotonic_time);
-}
-
-double WebAnimationImpl::timeOffset() const {
- return animation_->time_offset();
-}
-
-void WebAnimationImpl::setTimeOffset(double monotonic_time) {
- animation_->set_time_offset(monotonic_time);
-}
-
-bool WebAnimationImpl::alternatesDirection() const {
- return animation_->alternates_direction();
-}
-
-void WebAnimationImpl::setAlternatesDirection(bool alternates) {
- animation_->set_alternates_direction(alternates);
-}
-
-scoped_ptr<cc::Animation> WebAnimationImpl::PassAnimation() {
- animation_->set_needs_synchronized_start_time(true);
- return animation_.Pass();
-}
-
-#define COMPILE_ASSERT_MATCHING_ENUMS(webkit_name, cc_name) \
- COMPILE_ASSERT(static_cast<int>(webkit_name) == static_cast<int>(cc_name), \
- mismatching_enums)
-
-COMPILE_ASSERT_MATCHING_ENUMS(
- WebAnimation::TargetPropertyTransform, Animation::Transform);
-COMPILE_ASSERT_MATCHING_ENUMS(
- WebAnimation::TargetPropertyOpacity, Animation::Opacity);
-COMPILE_ASSERT_MATCHING_ENUMS(
- WebAnimation::TargetPropertyFilter, Animation::Filter);
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_animation_impl.h b/chromium/webkit/renderer/compositor_bindings/web_animation_impl.h
deleted file mode 100644
index 0c248fcfce1..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_animation_impl.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_ANIMATION_IMPL_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_ANIMATION_IMPL_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "third_party/WebKit/public/platform/WebAnimation.h"
-#include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
-
-namespace cc { class Animation; }
-
-namespace blink { class WebAnimationCurve; }
-
-namespace webkit {
-
-class WebAnimationImpl : public blink::WebAnimation {
- public:
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebAnimationImpl(
- const blink::WebAnimationCurve& curve,
- TargetProperty target,
- int animation_id,
- int group_id);
- virtual ~WebAnimationImpl();
-
- // blink::WebAnimation implementation
- virtual int id();
- virtual TargetProperty targetProperty() const;
- virtual int iterations() const;
- virtual void setIterations(int iterations);
- virtual double startTime() const;
- virtual void setStartTime(double monotonic_time);
- virtual double timeOffset() const;
- virtual void setTimeOffset(double monotonic_time);
- virtual bool alternatesDirection() const;
- virtual void setAlternatesDirection(bool alternates);
-
- scoped_ptr<cc::Animation> PassAnimation();
-
- private:
- scoped_ptr<cc::Animation> animation_;
-
- DISALLOW_COPY_AND_ASSIGN(WebAnimationImpl);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_ANIMATION_IMPL_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_animation_unittest.cc b/chromium/webkit/renderer/compositor_bindings/web_animation_unittest.cc
deleted file mode 100644
index e5be25a8860..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_animation_unittest.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 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 "base/memory/scoped_ptr.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/renderer/compositor_bindings/web_animation_impl.h"
-#include "webkit/renderer/compositor_bindings/web_float_animation_curve_impl.h"
-
-using blink::WebAnimation;
-using blink::WebAnimationCurve;
-using blink::WebFloatAnimationCurve;
-
-namespace webkit {
-namespace {
-
-TEST(WebAnimationTest, DefaultSettings) {
- scoped_ptr<WebAnimationCurve> curve(new WebFloatAnimationCurveImpl());
- scoped_ptr<WebAnimation> animation(
- new WebAnimationImpl(*curve, WebAnimation::TargetPropertyOpacity, 1, 0));
-
- // Ensure that the defaults are correct.
- EXPECT_EQ(1, animation->iterations());
- EXPECT_EQ(0, animation->startTime());
- EXPECT_EQ(0, animation->timeOffset());
- EXPECT_FALSE(animation->alternatesDirection());
-}
-
-TEST(WebAnimationTest, ModifiedSettings) {
- scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl());
- scoped_ptr<WebAnimation> animation(
- new WebAnimationImpl(*curve, WebAnimation::TargetPropertyOpacity, 1, 0));
- animation->setIterations(2);
- animation->setStartTime(2);
- animation->setTimeOffset(2);
- animation->setAlternatesDirection(true);
-
- EXPECT_EQ(2, animation->iterations());
- EXPECT_EQ(2, animation->startTime());
- EXPECT_EQ(2, animation->timeOffset());
- EXPECT_TRUE(animation->alternatesDirection());
-}
-
-} // namespace
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_blend_mode.h b/chromium/webkit/renderer/compositor_bindings/web_blend_mode.h
deleted file mode 100644
index 24236ffe622..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_blend_mode.h
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 2013 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_BLEND_MODE_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_BLEND_MODE_H_
-
-#include "third_party/WebKit/public/platform/WebBlendMode.h"
-
-namespace webkit {
-
-inline SkXfermode::Mode BlendModeToSkia(blink::WebBlendMode blend_mode) {
- switch (blend_mode) {
- case blink::WebBlendModeNormal:
- return SkXfermode::kSrcOver_Mode;
- case blink::WebBlendModeMultiply:
- return SkXfermode::kMultiply_Mode;
- case blink::WebBlendModeScreen:
- return SkXfermode::kScreen_Mode;
- case blink::WebBlendModeOverlay:
- return SkXfermode::kOverlay_Mode;
- case blink::WebBlendModeDarken:
- return SkXfermode::kDarken_Mode;
- case blink::WebBlendModeLighten:
- return SkXfermode::kLighten_Mode;
- case blink::WebBlendModeColorDodge:
- return SkXfermode::kColorDodge_Mode;
- case blink::WebBlendModeColorBurn:
- return SkXfermode::kColorBurn_Mode;
- case blink::WebBlendModeHardLight:
- return SkXfermode::kHardLight_Mode;
- case blink::WebBlendModeSoftLight:
- return SkXfermode::kSoftLight_Mode;
- case blink::WebBlendModeDifference:
- return SkXfermode::kDifference_Mode;
- case blink::WebBlendModeExclusion:
- return SkXfermode::kExclusion_Mode;
- case blink::WebBlendModeHue:
- return SkXfermode::kHue_Mode;
- case blink::WebBlendModeSaturation:
- return SkXfermode::kSaturation_Mode;
- case blink::WebBlendModeColor:
- return SkXfermode::kColor_Mode;
- case blink::WebBlendModeLuminosity:
- return SkXfermode::kLuminosity_Mode;
- }
- return SkXfermode::kSrcOver_Mode;
-}
-
-inline blink::WebBlendMode BlendModeFromSkia(SkXfermode::Mode blend_mode) {
- switch (blend_mode) {
- case SkXfermode::kSrcOver_Mode:
- return blink::WebBlendModeNormal;
- case SkXfermode::kMultiply_Mode:
- return blink::WebBlendModeMultiply;
- case SkXfermode::kScreen_Mode:
- return blink::WebBlendModeScreen;
- case SkXfermode::kOverlay_Mode:
- return blink::WebBlendModeOverlay;
- case SkXfermode::kDarken_Mode:
- return blink::WebBlendModeDarken;
- case SkXfermode::kLighten_Mode:
- return blink::WebBlendModeLighten;
- case SkXfermode::kColorDodge_Mode:
- return blink::WebBlendModeColorDodge;
- case SkXfermode::kColorBurn_Mode:
- return blink::WebBlendModeColorBurn;
- case SkXfermode::kHardLight_Mode:
- return blink::WebBlendModeHardLight;
- case SkXfermode::kSoftLight_Mode:
- return blink::WebBlendModeSoftLight;
- case SkXfermode::kDifference_Mode:
- return blink::WebBlendModeDifference;
- case SkXfermode::kExclusion_Mode:
- return blink::WebBlendModeExclusion;
- case SkXfermode::kHue_Mode:
- return blink::WebBlendModeHue;
- case SkXfermode::kSaturation_Mode:
- return blink::WebBlendModeSaturation;
- case SkXfermode::kColor_Mode:
- return blink::WebBlendModeColor;
- case SkXfermode::kLuminosity_Mode:
- return blink::WebBlendModeLuminosity;
-
- // these value are SkXfermodes, but no blend modes.
- case SkXfermode::kClear_Mode:
- case SkXfermode::kSrc_Mode:
- case SkXfermode::kDst_Mode:
- case SkXfermode::kDstOver_Mode:
- case SkXfermode::kSrcIn_Mode:
- case SkXfermode::kDstIn_Mode:
- case SkXfermode::kSrcOut_Mode:
- case SkXfermode::kDstOut_Mode:
- case SkXfermode::kSrcATop_Mode:
- case SkXfermode::kDstATop_Mode:
- case SkXfermode::kXor_Mode:
- case SkXfermode::kPlus_Mode:
- case SkXfermode::kModulate_Mode:
- NOTREACHED();
- }
- return blink::WebBlendModeNormal;
-}
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_BLEND_MODE_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_compositing_reasons.cc b/chromium/webkit/renderer/compositor_bindings/web_compositing_reasons.cc
deleted file mode 100644
index ace216b173f..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_compositing_reasons.cc
+++ /dev/null
@@ -1,151 +0,0 @@
-// Copyright 2013 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 "base/basictypes.h"
-#include "base/port.h"
-#include "cc/layers/compositing_reasons.h"
-#include "third_party/WebKit/public/platform/WebCompositingReasons.h"
-
-#define COMPILE_ASSERT_MATCHING_UINT64(cc_name, webkit_name) \
- COMPILE_ASSERT(cc_name == webkit_name, mismatching_uint64)
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonUnknown,
- blink::CompositingReasonUnknown);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReason3DTransform,
- blink::CompositingReason3DTransform);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonVideo,
- blink::CompositingReasonVideo);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonCanvas,
- blink::CompositingReasonCanvas);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonPlugin,
- blink::CompositingReasonPlugin);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonIFrame,
- blink::CompositingReasonIFrame);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonBackfaceVisibilityHidden,
- blink::CompositingReasonBackfaceVisibilityHidden);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonAnimation,
- blink::CompositingReasonAnimation);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonFilters,
- blink::CompositingReasonFilters);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonPositionFixed,
- blink::CompositingReasonPositionFixed);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonPositionSticky,
- blink::CompositingReasonPositionSticky);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonOverflowScrollingTouch,
- blink::CompositingReasonOverflowScrollingTouch);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonAssumedOverlap,
- blink::CompositingReasonAssumedOverlap);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonOverlap,
- blink::CompositingReasonOverlap);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonNegativeZIndexChildren,
- blink::CompositingReasonNegativeZIndexChildren);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonTransformWithCompositedDescendants,
- blink::CompositingReasonTransformWithCompositedDescendants);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonOpacityWithCompositedDescendants,
- blink::CompositingReasonOpacityWithCompositedDescendants);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonMaskWithCompositedDescendants,
- blink::CompositingReasonMaskWithCompositedDescendants);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonReflectionWithCompositedDescendants,
- blink::CompositingReasonReflectionWithCompositedDescendants);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonFilterWithCompositedDescendants,
- blink::CompositingReasonFilterWithCompositedDescendants);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonBlendingWithCompositedDescendants,
- blink::CompositingReasonBlendingWithCompositedDescendants);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonClipsCompositingDescendants,
- blink::CompositingReasonClipsCompositingDescendants);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonPerspective,
- blink::CompositingReasonPerspective);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonPreserve3D,
- blink::CompositingReasonPreserve3D);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonReflectionOfCompositedParent,
- blink::CompositingReasonReflectionOfCompositedParent);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonRoot,
- blink::CompositingReasonRoot);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonLayerForClip,
- blink::CompositingReasonLayerForClip);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonLayerForScrollbar,
- blink::CompositingReasonLayerForScrollbar);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonLayerForScrollingContainer,
- blink::CompositingReasonLayerForScrollingContainer);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonLayerForForeground,
- blink::CompositingReasonLayerForForeground);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonLayerForBackground,
- blink::CompositingReasonLayerForBackground);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonLayerForMask,
- blink::CompositingReasonLayerForMask);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonOverflowScrollingParent,
- blink::CompositingReasonOverflowScrollingParent);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonOutOfFlowClipping,
- blink::CompositingReasonOutOfFlowClipping);
-
-COMPILE_ASSERT_MATCHING_UINT64(
- cc::kCompositingReasonIsolateCompositedDescendants,
- blink::CompositingReasonIsolateCompositedDescendants);
diff --git a/chromium/webkit/renderer/compositor_bindings/web_compositor_support_impl.cc b/chromium/webkit/renderer/compositor_bindings/web_compositor_support_impl.cc
deleted file mode 100644
index a49de0990e5..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_compositor_support_impl.cc
+++ /dev/null
@@ -1,122 +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 "webkit/renderer/compositor_bindings/web_compositor_support_impl.h"
-
-#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop_proxy.h"
-#include "cc/animation/transform_operations.h"
-#include "cc/output/output_surface.h"
-#include "cc/output/software_output_device.h"
-#include "webkit/child/webthread_impl.h"
-#include "webkit/renderer/compositor_bindings/web_animation_impl.h"
-#include "webkit/renderer/compositor_bindings/web_content_layer_impl.h"
-#include "webkit/renderer/compositor_bindings/web_external_texture_layer_impl.h"
-#include "webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.h"
-#include "webkit/renderer/compositor_bindings/web_filter_operations_impl.h"
-#include "webkit/renderer/compositor_bindings/web_float_animation_curve_impl.h"
-#include "webkit/renderer/compositor_bindings/web_image_layer_impl.h"
-#include "webkit/renderer/compositor_bindings/web_layer_impl.h"
-#include "webkit/renderer/compositor_bindings/web_nine_patch_layer_impl.h"
-#include "webkit/renderer/compositor_bindings/web_scrollbar_layer_impl.h"
-#include "webkit/renderer/compositor_bindings/web_solid_color_layer_impl.h"
-#include "webkit/renderer/compositor_bindings/web_transform_animation_curve_impl.h"
-#include "webkit/renderer/compositor_bindings/web_transform_operations_impl.h"
-
-using blink::WebAnimation;
-using blink::WebAnimationCurve;
-using blink::WebContentLayer;
-using blink::WebContentLayerClient;
-using blink::WebExternalTextureLayer;
-using blink::WebExternalTextureLayerClient;
-using blink::WebFilterAnimationCurve;
-using blink::WebFilterOperations;
-using blink::WebFloatAnimationCurve;
-using blink::WebImageLayer;
-using blink::WebNinePatchLayer;
-using blink::WebLayer;
-using blink::WebScrollbar;
-using blink::WebScrollbarLayer;
-using blink::WebScrollbarThemeGeometry;
-using blink::WebScrollbarThemePainter;
-using blink::WebSolidColorLayer;
-using blink::WebTransformAnimationCurve;
-using blink::WebTransformOperations;
-
-namespace webkit {
-
-WebCompositorSupportImpl::WebCompositorSupportImpl() {}
-
-WebCompositorSupportImpl::~WebCompositorSupportImpl() {}
-
-WebLayer* WebCompositorSupportImpl::createLayer() {
- return new WebLayerImpl();
-}
-
-WebContentLayer* WebCompositorSupportImpl::createContentLayer(
- WebContentLayerClient* client) {
- return new WebContentLayerImpl(client);
-}
-
-WebExternalTextureLayer* WebCompositorSupportImpl::createExternalTextureLayer(
- WebExternalTextureLayerClient* client) {
- return new WebExternalTextureLayerImpl(client);
-}
-
-blink::WebImageLayer* WebCompositorSupportImpl::createImageLayer() {
- return new WebImageLayerImpl();
-}
-
-blink::WebNinePatchLayer* WebCompositorSupportImpl::createNinePatchLayer() {
- return new WebNinePatchLayerImpl();
-}
-
-WebSolidColorLayer* WebCompositorSupportImpl::createSolidColorLayer() {
- return new WebSolidColorLayerImpl();
-}
-
-WebScrollbarLayer* WebCompositorSupportImpl::createScrollbarLayer(
- WebScrollbar* scrollbar,
- WebScrollbarThemePainter painter,
- WebScrollbarThemeGeometry* geometry) {
- return new WebScrollbarLayerImpl(scrollbar, painter, geometry);
-}
-
-WebScrollbarLayer* WebCompositorSupportImpl::createSolidColorScrollbarLayer(
- WebScrollbar::Orientation orientation, int thumb_thickness,
- bool is_left_side_vertical_scrollbar) {
- return new WebScrollbarLayerImpl(orientation, thumb_thickness,
- is_left_side_vertical_scrollbar);
-}
-
-WebAnimation* WebCompositorSupportImpl::createAnimation(
- const blink::WebAnimationCurve& curve,
- blink::WebAnimation::TargetProperty target,
- int animation_id) {
- return new WebAnimationImpl(curve, target, animation_id, 0);
-}
-
-WebFilterAnimationCurve*
-WebCompositorSupportImpl::createFilterAnimationCurve() {
- return new WebFilterAnimationCurveImpl();
-}
-
-WebFloatAnimationCurve* WebCompositorSupportImpl::createFloatAnimationCurve() {
- return new WebFloatAnimationCurveImpl();
-}
-
-WebTransformAnimationCurve*
-WebCompositorSupportImpl::createTransformAnimationCurve() {
- return new WebTransformAnimationCurveImpl();
-}
-
-WebTransformOperations* WebCompositorSupportImpl::createTransformOperations() {
- return new WebTransformOperationsImpl();
-}
-
-WebFilterOperations* WebCompositorSupportImpl::createFilterOperations() {
- return new WebFilterOperationsImpl();
-}
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_compositor_support_impl.h b/chromium/webkit/renderer/compositor_bindings/web_compositor_support_impl.h
deleted file mode 100644
index 276a59069d0..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_compositor_support_impl.h
+++ /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.
-
-#ifndef WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_COMPOSITOR_SUPPORT_IMPL_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_COMPOSITOR_SUPPORT_IMPL_H_
-
-#include "base/memory/ref_counted.h"
-#include "base/message_loop/message_loop_proxy.h"
-#include "third_party/WebKit/public/platform/WebCompositorSupport.h"
-#include "third_party/WebKit/public/platform/WebLayer.h"
-#include "third_party/WebKit/public/platform/WebTransformOperations.h"
-
-namespace blink {
-class WebGraphicsContext3D;
-}
-
-namespace webkit {
-
-class WebCompositorSupportImpl : public blink::WebCompositorSupport {
- public:
- WebCompositorSupportImpl();
- virtual ~WebCompositorSupportImpl();
-
- virtual blink::WebLayer* createLayer();
- virtual blink::WebContentLayer* createContentLayer(
- blink::WebContentLayerClient* client);
- virtual blink::WebExternalTextureLayer* createExternalTextureLayer(
- blink::WebExternalTextureLayerClient* client);
- virtual blink::WebImageLayer* createImageLayer();
- virtual blink::WebNinePatchLayer* createNinePatchLayer();
- virtual blink::WebSolidColorLayer* createSolidColorLayer();
- virtual blink::WebScrollbarLayer* createScrollbarLayer(
- blink::WebScrollbar* scrollbar,
- blink::WebScrollbarThemePainter painter,
- blink::WebScrollbarThemeGeometry*);
- virtual blink::WebScrollbarLayer* createSolidColorScrollbarLayer(
- blink::WebScrollbar::Orientation orientation, int thumb_thickness,
- bool is_left_side_vertical_scrollbar);
- virtual blink::WebAnimation* createAnimation(
- const blink::WebAnimationCurve& curve,
- blink::WebAnimation::TargetProperty target,
- int animation_id);
- virtual blink::WebFilterAnimationCurve* createFilterAnimationCurve();
- virtual blink::WebFloatAnimationCurve* createFloatAnimationCurve();
- virtual blink::WebTransformAnimationCurve* createTransformAnimationCurve();
- virtual blink::WebTransformOperations* createTransformOperations();
- virtual blink::WebFilterOperations* createFilterOperations();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(WebCompositorSupportImpl);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_COMPOSITOR_SUPPORT_IMPL_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_content_layer_impl.cc b/chromium/webkit/renderer/compositor_bindings/web_content_layer_impl.cc
deleted file mode 100644
index 381501a4a1b..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_content_layer_impl.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 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.
-
-#include "webkit/renderer/compositor_bindings/web_content_layer_impl.h"
-
-#include "base/command_line.h"
-#include "cc/base/switches.h"
-#include "cc/layers/content_layer.h"
-#include "cc/layers/picture_layer.h"
-#include "third_party/WebKit/public/platform/WebContentLayerClient.h"
-#include "third_party/WebKit/public/platform/WebFloatPoint.h"
-#include "third_party/WebKit/public/platform/WebFloatRect.h"
-#include "third_party/WebKit/public/platform/WebRect.h"
-#include "third_party/WebKit/public/platform/WebSize.h"
-#include "third_party/skia/include/utils/SkMatrix44.h"
-
-using cc::ContentLayer;
-using cc::PictureLayer;
-
-namespace webkit {
-
-static bool usingPictureLayer() {
- return cc::switches::IsImplSidePaintingEnabled();
-}
-
-WebContentLayerImpl::WebContentLayerImpl(blink::WebContentLayerClient* client)
- : client_(client),
- ignore_lcd_text_change_(false) {
- if (usingPictureLayer())
- layer_ = make_scoped_ptr(new WebLayerImpl(PictureLayer::Create(this)));
- else
- layer_ = make_scoped_ptr(new WebLayerImpl(ContentLayer::Create(this)));
- layer_->layer()->SetIsDrawable(true);
- can_use_lcd_text_ = layer_->layer()->can_use_lcd_text();
-}
-
-WebContentLayerImpl::~WebContentLayerImpl() {
- if (usingPictureLayer())
- static_cast<PictureLayer*>(layer_->layer())->ClearClient();
- else
- static_cast<ContentLayer*>(layer_->layer())->ClearClient();
-}
-
-blink::WebLayer* WebContentLayerImpl::layer() { return layer_.get(); }
-
-void WebContentLayerImpl::setDoubleSided(bool double_sided) {
- layer_->layer()->SetDoubleSided(double_sided);
-}
-
-void WebContentLayerImpl::setDrawCheckerboardForMissingTiles(bool enable) {
- layer_->layer()->SetDrawCheckerboardForMissingTiles(enable);
-}
-
-void WebContentLayerImpl::PaintContents(SkCanvas* canvas,
- gfx::Rect clip,
- gfx::RectF* opaque) {
- if (!client_)
- return;
-
- blink::WebFloatRect web_opaque;
- // For picture layers, always record with LCD text. PictureLayerImpl
- // will turn this off later during rasterization.
- bool use_lcd_text = usingPictureLayer() || can_use_lcd_text_;
- client_->paintContents(canvas, clip, use_lcd_text, web_opaque);
- *opaque = web_opaque;
-}
-
-void WebContentLayerImpl::DidChangeLayerCanUseLCDText() {
- // It is important to make this comparison because the LCD text status
- // here can get out of sync with that in the layer.
- if (can_use_lcd_text_ == layer_->layer()->can_use_lcd_text())
- return;
-
- // LCD text cannot be enabled once disabled.
- if (layer_->layer()->can_use_lcd_text() && ignore_lcd_text_change_)
- return;
-
- can_use_lcd_text_ = layer_->layer()->can_use_lcd_text();
- ignore_lcd_text_change_ = true;
- layer_->invalidate();
-}
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_content_layer_impl.h b/chromium/webkit/renderer/compositor_bindings/web_content_layer_impl.h
deleted file mode 100644
index 382b580e2a2..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_content_layer_impl.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 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.
-
-#ifndef WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_CONTENT_LAYER_IMPL_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_CONTENT_LAYER_IMPL_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "cc/layers/content_layer_client.h"
-#include "third_party/WebKit/public/platform/WebContentLayer.h"
-#include "webkit/renderer/compositor_bindings/web_layer_impl.h"
-#include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
-
-namespace cc {
-class IntRect;
-class FloatRect;
-}
-
-namespace blink { class WebContentLayerClient; }
-
-namespace webkit {
-
-class WebContentLayerImpl : public blink::WebContentLayer,
- public cc::ContentLayerClient {
- public:
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT explicit WebContentLayerImpl(
- blink::WebContentLayerClient*);
-
- // WebContentLayer implementation.
- virtual blink::WebLayer* layer();
- virtual void setDoubleSided(bool double_sided);
- virtual void setDrawCheckerboardForMissingTiles(bool checkerboard);
-
- protected:
- virtual ~WebContentLayerImpl();
-
- // ContentLayerClient implementation.
- virtual void PaintContents(SkCanvas* canvas,
- gfx::Rect clip,
- gfx::RectF* opaque) OVERRIDE;
- virtual void DidChangeLayerCanUseLCDText() OVERRIDE;
-
- scoped_ptr<WebLayerImpl> layer_;
- blink::WebContentLayerClient* client_;
- bool draws_content_;
-
- private:
- bool can_use_lcd_text_;
- bool ignore_lcd_text_change_;
-
- DISALLOW_COPY_AND_ASSIGN(WebContentLayerImpl);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_CONTENT_LAYER_IMPL_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_external_bitmap_impl.cc b/chromium/webkit/renderer/compositor_bindings/web_external_bitmap_impl.cc
deleted file mode 100644
index 5e97b579806..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_external_bitmap_impl.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2013 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 "webkit/renderer/compositor_bindings/web_external_bitmap_impl.h"
-
-#include "base/memory/shared_memory.h"
-
-namespace webkit {
-
-namespace {
-
-SharedMemoryAllocationFunction g_memory_allocator;
-
-} // namespace
-
-void SetSharedMemoryAllocationFunction(
- SharedMemoryAllocationFunction allocator) {
- g_memory_allocator = allocator;
-}
-
-WebExternalBitmapImpl::WebExternalBitmapImpl() {}
-
-WebExternalBitmapImpl::~WebExternalBitmapImpl() {}
-
-void WebExternalBitmapImpl::setSize(blink::WebSize size) {
- if (size != size_) {
- size_t byte_size = size.width * size.height * 4;
- shared_memory_ = g_memory_allocator(byte_size);
- if (shared_memory_)
- shared_memory_->Map(byte_size);
- size_ = size;
- }
-}
-
-blink::WebSize WebExternalBitmapImpl::size() {
- return size_;
-}
-
-uint8* WebExternalBitmapImpl::pixels() {
- return static_cast<uint8*>(shared_memory_->memory());
-}
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_external_bitmap_impl.h b/chromium/webkit/renderer/compositor_bindings/web_external_bitmap_impl.h
deleted file mode 100644
index b113d6453d6..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_external_bitmap_impl.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2013 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_EXTERNAL_BITMAP_IMPL_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_EXTERNAL_BITMAP_IMPL_H_
-
-#include "base/bind.h"
-#include "base/memory/scoped_ptr.h"
-#include "third_party/WebKit/public/platform/WebExternalBitmap.h"
-#include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
-
-namespace base {
-class SharedMemory;
-}
-
-namespace webkit {
-
-typedef scoped_ptr<base::SharedMemory> (*SharedMemoryAllocationFunction)(
- size_t);
-
-// Sets the function that this will use to allocate shared memory.
-WEBKIT_COMPOSITOR_BINDINGS_EXPORT void SetSharedMemoryAllocationFunction(
- SharedMemoryAllocationFunction);
-
-class WebExternalBitmapImpl : public blink::WebExternalBitmap {
- public:
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT explicit WebExternalBitmapImpl();
- virtual ~WebExternalBitmapImpl();
-
- // blink::WebExternalBitmap implementation.
- virtual blink::WebSize size() OVERRIDE;
- virtual void setSize(blink::WebSize size) OVERRIDE;
- virtual uint8* pixels() OVERRIDE;
-
- base::SharedMemory* shared_memory() { return shared_memory_.get(); }
-
- private:
- scoped_ptr<base::SharedMemory> shared_memory_;
- blink::WebSize size_;
-
- DISALLOW_COPY_AND_ASSIGN(WebExternalBitmapImpl);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_EXTERNAL_BITMAP_IMPL_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.cc b/chromium/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.cc
deleted file mode 100644
index e5a33d5f22a..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.cc
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright 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.
-
-#include "webkit/renderer/compositor_bindings/web_external_texture_layer_impl.h"
-
-#include "cc/layers/texture_layer.h"
-#include "cc/resources/resource_update_queue.h"
-#include "cc/resources/single_release_callback.h"
-#include "cc/resources/texture_mailbox.h"
-#include "third_party/WebKit/public/platform/WebExternalTextureLayerClient.h"
-#include "third_party/WebKit/public/platform/WebExternalTextureMailbox.h"
-#include "third_party/WebKit/public/platform/WebFloatRect.h"
-#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
-#include "third_party/WebKit/public/platform/WebSize.h"
-#include "webkit/renderer/compositor_bindings/web_external_bitmap_impl.h"
-#include "webkit/renderer/compositor_bindings/web_layer_impl.h"
-
-using cc::TextureLayer;
-using cc::ResourceUpdateQueue;
-
-namespace webkit {
-
-WebExternalTextureLayerImpl::WebExternalTextureLayerImpl(
- blink::WebExternalTextureLayerClient* client)
- : client_(client) {
- cc::TextureLayerClient* cc_client = client_ ? this : NULL;
- scoped_refptr<TextureLayer> layer = TextureLayer::CreateForMailbox(cc_client);
- layer->SetIsDrawable(true);
- layer_.reset(new WebLayerImpl(layer));
-}
-
-WebExternalTextureLayerImpl::~WebExternalTextureLayerImpl() {
- static_cast<TextureLayer*>(layer_->layer())->ClearClient();
-}
-
-blink::WebLayer* WebExternalTextureLayerImpl::layer() { return layer_.get(); }
-
-void WebExternalTextureLayerImpl::clearTexture() {
- TextureLayer *layer = static_cast<TextureLayer*>(layer_->layer());
- layer->WillModifyTexture();
- layer->SetTextureMailbox(cc::TextureMailbox(),
- scoped_ptr<cc::SingleReleaseCallback>());
-}
-
-void WebExternalTextureLayerImpl::setOpaque(bool opaque) {
- static_cast<TextureLayer*>(layer_->layer())->SetContentsOpaque(opaque);
-}
-
-void WebExternalTextureLayerImpl::setPremultipliedAlpha(
- bool premultiplied_alpha) {
- static_cast<TextureLayer*>(layer_->layer())->SetPremultipliedAlpha(
- premultiplied_alpha);
-}
-
-void WebExternalTextureLayerImpl::setBlendBackgroundColor(bool blend) {
- static_cast<TextureLayer*>(layer_->layer())->SetBlendBackgroundColor(blend);
-}
-
-void WebExternalTextureLayerImpl::setRateLimitContext(bool rate_limit) {
- static_cast<TextureLayer*>(layer_->layer())->SetRateLimitContext(rate_limit);
-}
-
-unsigned WebExternalTextureLayerImpl::PrepareTexture() {
- NOTREACHED();
- return 0;
-}
-
-bool WebExternalTextureLayerImpl::PrepareTextureMailbox(
- cc::TextureMailbox* mailbox,
- scoped_ptr<cc::SingleReleaseCallback>* release_callback,
- bool use_shared_memory) {
- blink::WebExternalTextureMailbox client_mailbox;
- WebExternalBitmapImpl* bitmap = NULL;
-
- if (use_shared_memory)
- bitmap = AllocateBitmap();
- if (!client_->prepareMailbox(&client_mailbox, bitmap)) {
- if (bitmap)
- free_bitmaps_.push_back(bitmap);
- return false;
- }
- gpu::Mailbox name;
- name.SetName(client_mailbox.name);
- if (bitmap)
- *mailbox = cc::TextureMailbox(bitmap->shared_memory(), bitmap->size());
- else
- *mailbox = cc::TextureMailbox(name, client_mailbox.syncPoint);
-
- if (mailbox->IsValid()) {
- *release_callback = cc::SingleReleaseCallback::Create(base::Bind(
- &WebExternalTextureLayerImpl::DidReleaseMailbox,
- this->AsWeakPtr(),
- client_mailbox,
- bitmap));
- }
-
- return true;
-}
-
-WebExternalBitmapImpl* WebExternalTextureLayerImpl::AllocateBitmap() {
- if (!free_bitmaps_.empty()) {
- WebExternalBitmapImpl* result = free_bitmaps_.back();
- free_bitmaps_.weak_erase(free_bitmaps_.end() - 1);
- return result;
- }
- return new WebExternalBitmapImpl;
-}
-
-// static
-void WebExternalTextureLayerImpl::DidReleaseMailbox(
- base::WeakPtr<WebExternalTextureLayerImpl> layer,
- const blink::WebExternalTextureMailbox& mailbox,
- WebExternalBitmapImpl* bitmap,
- unsigned sync_point,
- bool lost_resource) {
- if (lost_resource || !layer) {
- delete bitmap;
- return;
- }
-
- blink::WebExternalTextureMailbox available_mailbox;
- memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name));
- available_mailbox.syncPoint = sync_point;
- if (bitmap)
- layer->free_bitmaps_.push_back(bitmap);
- layer->client_->mailboxReleased(available_mailbox);
-}
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.h b/chromium/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.h
deleted file mode 100644
index 56745b9b943..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_external_texture_layer_impl.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 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.
-
-#ifndef WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_EXTERNAL_TEXTURE_LAYER_IMPL_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_EXTERNAL_TEXTURE_LAYER_IMPL_H_
-
-#include "base/bind.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/scoped_vector.h"
-#include "cc/layers/texture_layer_client.h"
-#include "third_party/WebKit/public/platform/WebExternalTextureLayer.h"
-#include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
-
-namespace cc {
-class SingleReleaseCallback;
-class TextureMailbox;
-}
-
-namespace blink {
-struct WebFloatRect;
-struct WebExternalTextureMailbox;
-}
-
-namespace webkit {
-
-class WebLayerImpl;
-class WebExternalBitmapImpl;
-
-class WebExternalTextureLayerImpl
- : public blink::WebExternalTextureLayer,
- public cc::TextureLayerClient,
- public base::SupportsWeakPtr<WebExternalTextureLayerImpl> {
- public:
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT explicit WebExternalTextureLayerImpl(
- blink::WebExternalTextureLayerClient*);
- virtual ~WebExternalTextureLayerImpl();
-
- // blink::WebExternalTextureLayer implementation.
- virtual blink::WebLayer* layer();
- virtual void clearTexture();
- virtual void setOpaque(bool opaque);
- virtual void setPremultipliedAlpha(bool premultiplied);
- virtual void setBlendBackgroundColor(bool blend);
- virtual void setRateLimitContext(bool rate_limit);
-
- // TextureLayerClient implementation.
- virtual unsigned PrepareTexture() OVERRIDE;
- virtual bool PrepareTextureMailbox(
- cc::TextureMailbox* mailbox,
- scoped_ptr<cc::SingleReleaseCallback>* release_callback,
- bool use_shared_memory) OVERRIDE;
-
- private:
- static void DidReleaseMailbox(
- base::WeakPtr<WebExternalTextureLayerImpl> layer,
- const blink::WebExternalTextureMailbox& mailbox,
- WebExternalBitmapImpl* bitmap,
- unsigned sync_point,
- bool lost_resource);
-
- WebExternalBitmapImpl* AllocateBitmap();
-
- blink::WebExternalTextureLayerClient* client_;
- scoped_ptr<WebLayerImpl> layer_;
- ScopedVector<WebExternalBitmapImpl> free_bitmaps_;
-
- DISALLOW_COPY_AND_ASSIGN(WebExternalTextureLayerImpl);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_EXTERNAL_TEXTURE_LAYER_IMPL_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.cc b/chromium/webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.cc
deleted file mode 100644
index 6663267011a..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.cc
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2013 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 "webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.h"
-
-#include "cc/animation/keyframed_animation_curve.h"
-#include "cc/animation/timing_function.h"
-#include "cc/output/filter_operations.h"
-#include "webkit/renderer/compositor_bindings/web_animation_curve_common.h"
-#include "webkit/renderer/compositor_bindings/web_filter_operations_impl.h"
-
-using blink::WebFilterKeyframe;
-
-namespace webkit {
-
-WebFilterAnimationCurveImpl::WebFilterAnimationCurveImpl()
- : curve_(cc::KeyframedFilterAnimationCurve::Create()) {}
-
-WebFilterAnimationCurveImpl::~WebFilterAnimationCurveImpl() {}
-
-blink::WebAnimationCurve::AnimationCurveType
-WebFilterAnimationCurveImpl::type() const {
- return WebAnimationCurve::AnimationCurveTypeFilter;
-}
-
-void WebFilterAnimationCurveImpl::add(const WebFilterKeyframe& keyframe,
- TimingFunctionType type) {
- const cc::FilterOperations& filter_operations =
- static_cast<const webkit::WebFilterOperationsImpl&>(keyframe.value())
- .AsFilterOperations();
- curve_->AddKeyframe(cc::FilterKeyframe::Create(
- keyframe.time(), filter_operations, CreateTimingFunction(type)));
-}
-
-void WebFilterAnimationCurveImpl::add(const WebFilterKeyframe& keyframe,
- double x1,
- double y1,
- double x2,
- double y2) {
- const cc::FilterOperations& filter_operations =
- static_cast<const webkit::WebFilterOperationsImpl&>(keyframe.value())
- .AsFilterOperations();
- curve_->AddKeyframe(cc::FilterKeyframe::Create(
- keyframe.time(),
- filter_operations,
- cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2)
- .PassAs<cc::TimingFunction>()));
-}
-
-scoped_ptr<cc::AnimationCurve>
-WebFilterAnimationCurveImpl::CloneToAnimationCurve() const {
- return curve_->Clone();
-}
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.h b/chromium/webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.h
deleted file mode 100644
index 64f8f11800b..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_filter_animation_curve_impl.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2013 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_FILTER_ANIMATION_CURVE_IMPL_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_FILTER_ANIMATION_CURVE_IMPL_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "third_party/WebKit/public/platform/WebFilterAnimationCurve.h"
-#include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
-
-namespace cc {
-class AnimationCurve;
-class KeyframedFilterAnimationCurve;
-}
-
-namespace blink { class WebFilterKeyframe; }
-
-namespace webkit {
-
-class WebFilterAnimationCurveImpl
- : public blink::WebFilterAnimationCurve {
- public:
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebFilterAnimationCurveImpl();
- virtual ~WebFilterAnimationCurveImpl();
-
- // blink::WebAnimationCurve implementation.
- virtual AnimationCurveType type() const;
-
- // blink::WebFilterAnimationCurve implementation.
- virtual void add(const blink::WebFilterKeyframe& keyframe,
- TimingFunctionType type);
- virtual void add(const blink::WebFilterKeyframe& keyframe,
- double x1,
- double y1,
- double x2,
- double y2);
-
- scoped_ptr<cc::AnimationCurve> CloneToAnimationCurve() const;
-
- private:
- scoped_ptr<cc::KeyframedFilterAnimationCurve> curve_;
-
- DISALLOW_COPY_AND_ASSIGN(WebFilterAnimationCurveImpl);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_FILTER_ANIMATION_CURVE_IMPL_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_filter_operations_impl.cc b/chromium/webkit/renderer/compositor_bindings/web_filter_operations_impl.cc
deleted file mode 100644
index 6fb35e656ca..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_filter_operations_impl.cc
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2013 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 "webkit/renderer/compositor_bindings/web_filter_operations_impl.h"
-
-#include "base/basictypes.h"
-#include "skia/ext/refptr.h"
-#include "third_party/WebKit/public/platform/WebColor.h"
-#include "third_party/WebKit/public/platform/WebPoint.h"
-#include "third_party/skia/include/core/SkScalar.h"
-
-namespace webkit {
-
-WebFilterOperationsImpl::WebFilterOperationsImpl() {}
-
-WebFilterOperationsImpl::~WebFilterOperationsImpl() {}
-
-const cc::FilterOperations& WebFilterOperationsImpl::AsFilterOperations()
- const {
- return filter_operations_;
-}
-
-void WebFilterOperationsImpl::appendGrayscaleFilter(float amount) {
- filter_operations_.Append(cc::FilterOperation::CreateGrayscaleFilter(amount));
-}
-
-void WebFilterOperationsImpl::appendSepiaFilter(float amount) {
- filter_operations_.Append(cc::FilterOperation::CreateSepiaFilter(amount));
-}
-
-void WebFilterOperationsImpl::appendSaturateFilter(float amount) {
- filter_operations_.Append(cc::FilterOperation::CreateSaturateFilter(amount));
-}
-
-void WebFilterOperationsImpl::appendHueRotateFilter(float amount) {
- filter_operations_.Append(cc::FilterOperation::CreateHueRotateFilter(amount));
-}
-
-void WebFilterOperationsImpl::appendInvertFilter(float amount) {
- filter_operations_.Append(cc::FilterOperation::CreateInvertFilter(amount));
-}
-
-void WebFilterOperationsImpl::appendBrightnessFilter(float amount) {
- filter_operations_.Append(
- cc::FilterOperation::CreateBrightnessFilter(amount));
-}
-
-void WebFilterOperationsImpl::appendContrastFilter(float amount) {
- filter_operations_.Append(cc::FilterOperation::CreateContrastFilter(amount));
-}
-
-void WebFilterOperationsImpl::appendOpacityFilter(float amount) {
- filter_operations_.Append(cc::FilterOperation::CreateOpacityFilter(amount));
-}
-
-void WebFilterOperationsImpl::appendBlurFilter(float amount) {
- filter_operations_.Append(cc::FilterOperation::CreateBlurFilter(amount));
-}
-
-void WebFilterOperationsImpl::appendDropShadowFilter(blink::WebPoint offset,
- float std_deviation,
- blink::WebColor color) {
- filter_operations_.Append(cc::FilterOperation::CreateDropShadowFilter(
- offset, std_deviation, color));
-}
-
-void WebFilterOperationsImpl::appendColorMatrixFilter(SkScalar matrix[20]) {
- filter_operations_.Append(
- cc::FilterOperation::CreateColorMatrixFilter(matrix));
-}
-
-void WebFilterOperationsImpl::appendZoomFilter(float amount, int inset) {
- filter_operations_.Append(
- cc::FilterOperation::CreateZoomFilter(amount, inset));
-}
-
-void WebFilterOperationsImpl::appendSaturatingBrightnessFilter(float amount) {
- filter_operations_.Append(
- cc::FilterOperation::CreateSaturatingBrightnessFilter(amount));
-}
-
-void WebFilterOperationsImpl::appendReferenceFilter(
- SkImageFilter* image_filter) {
- filter_operations_.Append(
- cc::FilterOperation::CreateReferenceFilter(skia::SharePtr(image_filter)));
-}
-
-void WebFilterOperationsImpl::clear() {
- filter_operations_.Clear();
-}
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_filter_operations_impl.h b/chromium/webkit/renderer/compositor_bindings/web_filter_operations_impl.h
deleted file mode 100644
index a60366c22ab..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_filter_operations_impl.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2013 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_FILTER_OPERATIONS_IMPL_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_FILTER_OPERATIONS_IMPL_H_
-
-#include "cc/output/filter_operations.h"
-#include "third_party/WebKit/public/platform/WebFilterOperations.h"
-#include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
-
-namespace webkit {
-
-class WebFilterOperationsImpl : public blink::WebFilterOperations {
- public:
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebFilterOperationsImpl();
- virtual ~WebFilterOperationsImpl();
-
- const cc::FilterOperations& AsFilterOperations() const;
-
- // Implementation of blink::WebFilterOperations methods
- virtual void appendGrayscaleFilter(float amount);
- virtual void appendSepiaFilter(float amount);
- virtual void appendSaturateFilter(float amount);
- virtual void appendHueRotateFilter(float amount);
- virtual void appendInvertFilter(float amount);
- virtual void appendBrightnessFilter(float amount);
- virtual void appendContrastFilter(float amount);
- virtual void appendOpacityFilter(float amount);
- virtual void appendBlurFilter(float amount);
- virtual void appendDropShadowFilter(blink::WebPoint offset,
- float std_deviation,
- blink::WebColor color);
- virtual void appendColorMatrixFilter(SkScalar matrix[20]);
- virtual void appendZoomFilter(float amount, int inset);
- virtual void appendSaturatingBrightnessFilter(float amount);
- virtual void appendReferenceFilter(SkImageFilter* image_filter);
-
- virtual void clear();
-
- private:
- cc::FilterOperations filter_operations_;
-
- DISALLOW_COPY_AND_ASSIGN(WebFilterOperationsImpl);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_FILTER_OPERATIONS_IMPL_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_float_animation_curve_impl.cc b/chromium/webkit/renderer/compositor_bindings/web_float_animation_curve_impl.cc
deleted file mode 100644
index fe2ae81d440..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_float_animation_curve_impl.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 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 "webkit/renderer/compositor_bindings/web_float_animation_curve_impl.h"
-
-#include "cc/animation/animation_curve.h"
-#include "cc/animation/keyframed_animation_curve.h"
-#include "cc/animation/timing_function.h"
-#include "webkit/renderer/compositor_bindings/web_animation_curve_common.h"
-
-using blink::WebFloatKeyframe;
-
-namespace webkit {
-
-WebFloatAnimationCurveImpl::WebFloatAnimationCurveImpl()
- : curve_(cc::KeyframedFloatAnimationCurve::Create()) {}
-
-WebFloatAnimationCurveImpl::~WebFloatAnimationCurveImpl() {}
-
-blink::WebAnimationCurve::AnimationCurveType
-WebFloatAnimationCurveImpl::type() const {
- return blink::WebAnimationCurve::AnimationCurveTypeFloat;
-}
-
-void WebFloatAnimationCurveImpl::add(const WebFloatKeyframe& keyframe) {
- add(keyframe, TimingFunctionTypeEase);
-}
-
-void WebFloatAnimationCurveImpl::add(const WebFloatKeyframe& keyframe,
- TimingFunctionType type) {
- curve_->AddKeyframe(cc::FloatKeyframe::Create(
- keyframe.time, keyframe.value, CreateTimingFunction(type)));
-}
-
-void WebFloatAnimationCurveImpl::add(const WebFloatKeyframe& keyframe,
- double x1,
- double y1,
- double x2,
- double y2) {
- curve_->AddKeyframe(cc::FloatKeyframe::Create(
- keyframe.time,
- keyframe.value,
- cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2)
- .PassAs<cc::TimingFunction>()));
-}
-
-float WebFloatAnimationCurveImpl::getValue(double time) const {
- return curve_->GetValue(time);
-}
-
-scoped_ptr<cc::AnimationCurve>
-WebFloatAnimationCurveImpl::CloneToAnimationCurve() const {
- return curve_->Clone();
-}
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_float_animation_curve_impl.h b/chromium/webkit/renderer/compositor_bindings/web_float_animation_curve_impl.h
deleted file mode 100644
index 99e186ddfce..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_float_animation_curve_impl.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_FLOAT_ANIMATION_CURVE_IMPL_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_FLOAT_ANIMATION_CURVE_IMPL_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "third_party/WebKit/public/platform/WebFloatAnimationCurve.h"
-#include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
-
-namespace cc {
-class AnimationCurve;
-class KeyframedFloatAnimationCurve;
-}
-
-namespace blink { struct WebFloatKeyframe; }
-
-namespace webkit {
-
-class WebFloatAnimationCurveImpl : public blink::WebFloatAnimationCurve {
- public:
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebFloatAnimationCurveImpl();
- virtual ~WebFloatAnimationCurveImpl();
-
- // WebAnimationCurve implementation.
- virtual AnimationCurveType type() const;
-
- // WebFloatAnimationCurve implementation.
- virtual void add(const blink::WebFloatKeyframe& keyframe);
- virtual void add(const blink::WebFloatKeyframe& keyframe,
- TimingFunctionType type);
- virtual void add(const blink::WebFloatKeyframe& keyframe,
- double x1,
- double y1,
- double x2,
- double y2);
-
- virtual float getValue(double time) const;
-
- scoped_ptr<cc::AnimationCurve> CloneToAnimationCurve() const;
-
- private:
- scoped_ptr<cc::KeyframedFloatAnimationCurve> curve_;
-
- DISALLOW_COPY_AND_ASSIGN(WebFloatAnimationCurveImpl);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_FLOAT_ANIMATION_CURVE_IMPL_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_float_animation_curve_unittest.cc b/chromium/webkit/renderer/compositor_bindings/web_float_animation_curve_unittest.cc
deleted file mode 100644
index 04605fbd80e..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_float_animation_curve_unittest.cc
+++ /dev/null
@@ -1,233 +0,0 @@
-// Copyright 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 "base/memory/scoped_ptr.h"
-#include "cc/animation/timing_function.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/renderer/compositor_bindings/web_float_animation_curve_impl.h"
-
-using blink::WebAnimationCurve;
-using blink::WebFloatAnimationCurve;
-using blink::WebFloatKeyframe;
-
-namespace webkit {
-namespace {
-
-// Tests that a float animation with one keyframe works as expected.
-TEST(WebFloatAnimationCurveTest, OneFloatKeyframe) {
- scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl);
- curve->add(WebFloatKeyframe(0, 2),
- WebAnimationCurve::TimingFunctionTypeLinear);
- EXPECT_FLOAT_EQ(2, curve->getValue(-1));
- EXPECT_FLOAT_EQ(2, curve->getValue(0));
- EXPECT_FLOAT_EQ(2, curve->getValue(0.5));
- EXPECT_FLOAT_EQ(2, curve->getValue(1));
- EXPECT_FLOAT_EQ(2, curve->getValue(2));
-}
-
-// Tests that a float animation with two keyframes works as expected.
-TEST(WebFloatAnimationCurveTest, TwoFloatKeyframe) {
- scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl);
- curve->add(WebFloatKeyframe(0, 2),
- WebAnimationCurve::TimingFunctionTypeLinear);
- curve->add(WebFloatKeyframe(1, 4),
- WebAnimationCurve::TimingFunctionTypeLinear);
- EXPECT_FLOAT_EQ(2, curve->getValue(-1));
- EXPECT_FLOAT_EQ(2, curve->getValue(0));
- EXPECT_FLOAT_EQ(3, curve->getValue(0.5));
- EXPECT_FLOAT_EQ(4, curve->getValue(1));
- EXPECT_FLOAT_EQ(4, curve->getValue(2));
-}
-
-// Tests that a float animation with three keyframes works as expected.
-TEST(WebFloatAnimationCurveTest, ThreeFloatKeyframe) {
- scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl);
- curve->add(WebFloatKeyframe(0, 2),
- WebAnimationCurve::TimingFunctionTypeLinear);
- curve->add(WebFloatKeyframe(1, 4),
- WebAnimationCurve::TimingFunctionTypeLinear);
- curve->add(WebFloatKeyframe(2, 8),
- WebAnimationCurve::TimingFunctionTypeLinear);
- EXPECT_FLOAT_EQ(2, curve->getValue(-1));
- EXPECT_FLOAT_EQ(2, curve->getValue(0));
- EXPECT_FLOAT_EQ(3, curve->getValue(0.5));
- EXPECT_FLOAT_EQ(4, curve->getValue(1));
- EXPECT_FLOAT_EQ(6, curve->getValue(1.5));
- EXPECT_FLOAT_EQ(8, curve->getValue(2));
- EXPECT_FLOAT_EQ(8, curve->getValue(3));
-}
-
-// Tests that a float animation with multiple keys at a given time works sanely.
-TEST(WebFloatAnimationCurveTest, RepeatedFloatKeyTimes) {
- scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl);
- curve->add(WebFloatKeyframe(0, 4),
- WebAnimationCurve::TimingFunctionTypeLinear);
- curve->add(WebFloatKeyframe(1, 4),
- WebAnimationCurve::TimingFunctionTypeLinear);
- curve->add(WebFloatKeyframe(1, 6),
- WebAnimationCurve::TimingFunctionTypeLinear);
- curve->add(WebFloatKeyframe(2, 6),
- WebAnimationCurve::TimingFunctionTypeLinear);
-
- EXPECT_FLOAT_EQ(4, curve->getValue(-1));
- EXPECT_FLOAT_EQ(4, curve->getValue(0));
- EXPECT_FLOAT_EQ(4, curve->getValue(0.5));
-
- // There is a discontinuity at 1. Any value between 4 and 6 is valid.
- float value = curve->getValue(1);
- EXPECT_TRUE(value >= 4 && value <= 6);
-
- EXPECT_FLOAT_EQ(6, curve->getValue(1.5));
- EXPECT_FLOAT_EQ(6, curve->getValue(2));
- EXPECT_FLOAT_EQ(6, curve->getValue(3));
-}
-
-// Tests that the keyframes may be added out of order.
-TEST(WebFloatAnimationCurveTest, UnsortedKeyframes) {
- scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl);
- curve->add(WebFloatKeyframe(2, 8),
- WebAnimationCurve::TimingFunctionTypeLinear);
- curve->add(WebFloatKeyframe(0, 2),
- WebAnimationCurve::TimingFunctionTypeLinear);
- curve->add(WebFloatKeyframe(1, 4),
- WebAnimationCurve::TimingFunctionTypeLinear);
-
- EXPECT_FLOAT_EQ(2, curve->getValue(-1));
- EXPECT_FLOAT_EQ(2, curve->getValue(0));
- EXPECT_FLOAT_EQ(3, curve->getValue(0.5));
- EXPECT_FLOAT_EQ(4, curve->getValue(1));
- EXPECT_FLOAT_EQ(6, curve->getValue(1.5));
- EXPECT_FLOAT_EQ(8, curve->getValue(2));
- EXPECT_FLOAT_EQ(8, curve->getValue(3));
-}
-
-// Tests that a cubic bezier timing function works as expected.
-TEST(WebFloatAnimationCurveTest, CubicBezierTimingFunction) {
- scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl);
- curve->add(WebFloatKeyframe(0, 0), 0.25, 0, 0.75, 1);
- curve->add(WebFloatKeyframe(1, 1),
- WebAnimationCurve::TimingFunctionTypeLinear);
-
- EXPECT_FLOAT_EQ(0, curve->getValue(0));
- EXPECT_LT(0, curve->getValue(0.25));
- EXPECT_GT(0.25, curve->getValue(0.25));
- EXPECT_NEAR(curve->getValue(0.5), 0.5, 0.00015);
- EXPECT_LT(0.75, curve->getValue(0.75));
- EXPECT_GT(1, curve->getValue(0.75));
- EXPECT_FLOAT_EQ(1, curve->getValue(1));
-}
-
-// Tests that an ease timing function works as expected.
-TEST(WebFloatAnimationCurveTest, EaseTimingFunction) {
- scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl);
- curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase);
- curve->add(WebFloatKeyframe(1, 1),
- WebAnimationCurve::TimingFunctionTypeLinear);
-
- scoped_ptr<cc::TimingFunction> timing_function(
- cc::EaseTimingFunction::Create());
- for (int i = 0; i <= 4; ++i) {
- const double time = i * 0.25;
- EXPECT_FLOAT_EQ(timing_function->GetValue(time), curve->getValue(time));
- }
-}
-
-// Tests using a linear timing function.
-TEST(WebFloatAnimationCurveTest, LinearTimingFunction) {
- scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl);
- curve->add(WebFloatKeyframe(0, 0),
- WebAnimationCurve::TimingFunctionTypeLinear);
- curve->add(WebFloatKeyframe(1, 1),
- WebAnimationCurve::TimingFunctionTypeLinear);
-
- for (int i = 0; i <= 4; ++i) {
- const double time = i * 0.25;
- EXPECT_FLOAT_EQ(time, curve->getValue(time));
- }
-}
-
-// Tests that an ease in timing function works as expected.
-TEST(WebFloatAnimationCurveTest, EaseInTimingFunction) {
- scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl);
- curve->add(WebFloatKeyframe(0, 0),
- WebAnimationCurve::TimingFunctionTypeEaseIn);
- curve->add(WebFloatKeyframe(1, 1),
- WebAnimationCurve::TimingFunctionTypeLinear);
-
- scoped_ptr<cc::TimingFunction> timing_function(
- cc::EaseInTimingFunction::Create());
- for (int i = 0; i <= 4; ++i) {
- const double time = i * 0.25;
- EXPECT_FLOAT_EQ(timing_function->GetValue(time), curve->getValue(time));
- }
-}
-
-// Tests that an ease in timing function works as expected.
-TEST(WebFloatAnimationCurveTest, EaseOutTimingFunction) {
- scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl);
- curve->add(WebFloatKeyframe(0, 0),
- WebAnimationCurve::TimingFunctionTypeEaseOut);
- curve->add(WebFloatKeyframe(1, 1),
- WebAnimationCurve::TimingFunctionTypeLinear);
-
- scoped_ptr<cc::TimingFunction> timing_function(
- cc::EaseOutTimingFunction::Create());
- for (int i = 0; i <= 4; ++i) {
- const double time = i * 0.25;
- EXPECT_FLOAT_EQ(timing_function->GetValue(time), curve->getValue(time));
- }
-}
-
-// Tests that an ease in timing function works as expected.
-TEST(WebFloatAnimationCurveTest, EaseInOutTimingFunction) {
- scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl);
- curve->add(WebFloatKeyframe(0, 0),
- WebAnimationCurve::TimingFunctionTypeEaseInOut);
- curve->add(WebFloatKeyframe(1, 1),
- WebAnimationCurve::TimingFunctionTypeLinear);
-
- scoped_ptr<cc::TimingFunction> timing_function(
- cc::EaseInOutTimingFunction::Create());
- for (int i = 0; i <= 4; ++i) {
- const double time = i * 0.25;
- EXPECT_FLOAT_EQ(timing_function->GetValue(time), curve->getValue(time));
- }
-}
-
-// Tests that an ease in timing function works as expected.
-TEST(WebFloatAnimationCurveTest, CustomBezierTimingFunction) {
- scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl);
- double x1 = 0.3;
- double y1 = 0.2;
- double x2 = 0.8;
- double y2 = 0.7;
- curve->add(WebFloatKeyframe(0, 0), x1, y1, x2, y2);
- curve->add(WebFloatKeyframe(1, 1),
- WebAnimationCurve::TimingFunctionTypeLinear);
-
- scoped_ptr<cc::TimingFunction> timing_function(
- cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2));
- for (int i = 0; i <= 4; ++i) {
- const double time = i * 0.25;
- EXPECT_FLOAT_EQ(timing_function->GetValue(time), curve->getValue(time));
- }
-}
-
-// Tests that the default timing function is indeed ease.
-TEST(WebFloatAnimationCurveTest, DefaultTimingFunction) {
- scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl);
- curve->add(WebFloatKeyframe(0, 0));
- curve->add(WebFloatKeyframe(1, 1),
- WebAnimationCurve::TimingFunctionTypeLinear);
-
- scoped_ptr<cc::TimingFunction> timing_function(
- cc::EaseTimingFunction::Create());
- for (int i = 0; i <= 4; ++i) {
- const double time = i * 0.25;
- EXPECT_FLOAT_EQ(timing_function->GetValue(time), curve->getValue(time));
- }
-}
-
-} // namespace
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_image_layer_impl.cc b/chromium/webkit/renderer/compositor_bindings/web_image_layer_impl.cc
deleted file mode 100644
index 2074d05dbd0..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_image_layer_impl.cc
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 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 "webkit/renderer/compositor_bindings/web_image_layer_impl.h"
-
-#include "base/command_line.h"
-#include "cc/base/switches.h"
-#include "cc/layers/image_layer.h"
-#include "cc/layers/picture_image_layer.h"
-#include "webkit/renderer/compositor_bindings/web_layer_impl.h"
-#include "webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.h"
-
-static bool usingPictureLayer() {
- return cc::switches::IsImplSidePaintingEnabled();
-}
-
-namespace webkit {
-
-WebImageLayerImpl::WebImageLayerImpl() {
- if (usingPictureLayer())
- layer_.reset(new WebLayerImplFixedBounds(cc::PictureImageLayer::Create()));
- else
- layer_.reset(new WebLayerImpl(cc::ImageLayer::Create()));
-}
-
-WebImageLayerImpl::~WebImageLayerImpl() {}
-
-blink::WebLayer* WebImageLayerImpl::layer() { return layer_.get(); }
-
-void WebImageLayerImpl::setBitmap(SkBitmap bitmap) {
- if (usingPictureLayer()) {
- static_cast<cc::PictureImageLayer*>(layer_->layer())->SetBitmap(bitmap);
- static_cast<WebLayerImplFixedBounds*>(layer_.get())->SetFixedBounds(
- gfx::Size(bitmap.width(), bitmap.height()));
- } else {
- static_cast<cc::ImageLayer*>(layer_->layer())->SetBitmap(bitmap);
- }
-}
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_image_layer_impl.h b/chromium/webkit/renderer/compositor_bindings/web_image_layer_impl.h
deleted file mode 100644
index 73ad4b096f5..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_image_layer_impl.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_IMAGE_LAYER_IMPL_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_IMAGE_LAYER_IMPL_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "third_party/WebKit/public/platform/WebImageLayer.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
-
-namespace webkit {
-
-class WebLayerImpl;
-
-class WebImageLayerImpl : public blink::WebImageLayer {
- public:
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebImageLayerImpl();
- virtual ~WebImageLayerImpl();
-
- // blink::WebImageLayer implementation.
- virtual blink::WebLayer* layer();
- virtual void setBitmap(SkBitmap);
-
- private:
- scoped_ptr<WebLayerImpl> layer_;
-
- DISALLOW_COPY_AND_ASSIGN(WebImageLayerImpl);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_IMAGE_LAYER_IMPL_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_layer_impl.cc b/chromium/webkit/renderer/compositor_bindings/web_layer_impl.cc
deleted file mode 100644
index 22a5485a3cf..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_layer_impl.cc
+++ /dev/null
@@ -1,451 +0,0 @@
-// Copyright 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.
-
-#include "webkit/renderer/compositor_bindings/web_layer_impl.h"
-
-#include "base/bind.h"
-#include "base/debug/trace_event_impl.h"
-#include "base/strings/string_util.h"
-#include "base/threading/thread_checker.h"
-#include "cc/animation/animation.h"
-#include "cc/base/region.h"
-#include "cc/layers/layer.h"
-#include "cc/layers/layer_position_constraint.h"
-#include "third_party/WebKit/public/platform/WebCompositingReasons.h"
-#include "third_party/WebKit/public/platform/WebFloatPoint.h"
-#include "third_party/WebKit/public/platform/WebFloatRect.h"
-#include "third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h"
-#include "third_party/WebKit/public/platform/WebLayerClient.h"
-#include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h"
-#include "third_party/WebKit/public/platform/WebLayerScrollClient.h"
-#include "third_party/WebKit/public/platform/WebSize.h"
-#include "third_party/skia/include/utils/SkMatrix44.h"
-#include "webkit/renderer/compositor_bindings/web_animation_impl.h"
-#include "webkit/renderer/compositor_bindings/web_blend_mode.h"
-#include "webkit/renderer/compositor_bindings/web_filter_operations_impl.h"
-#include "webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.h"
-
-using cc::Animation;
-using cc::Layer;
-using blink::WebLayer;
-using blink::WebFloatPoint;
-using blink::WebVector;
-using blink::WebRect;
-using blink::WebSize;
-using blink::WebColor;
-using blink::WebFilterOperations;
-
-namespace webkit {
-
-WebLayerImpl::WebLayerImpl() : layer_(Layer::Create()) {
- web_layer_client_ = NULL;
- layer_->SetLayerClient(this);
-}
-
-WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) : layer_(layer) {
- web_layer_client_ = NULL;
- layer_->SetLayerClient(this);
-}
-
-WebLayerImpl::~WebLayerImpl() {
- layer_->ClearRenderSurface();
- layer_->set_layer_animation_delegate(NULL);
- web_layer_client_ = NULL;
-}
-
-int WebLayerImpl::id() const { return layer_->id(); }
-
-void WebLayerImpl::invalidateRect(const blink::WebFloatRect& rect) {
- layer_->SetNeedsDisplayRect(rect);
-}
-
-void WebLayerImpl::invalidate() { layer_->SetNeedsDisplay(); }
-
-void WebLayerImpl::addChild(WebLayer* child) {
- layer_->AddChild(static_cast<WebLayerImpl*>(child)->layer());
-}
-
-void WebLayerImpl::insertChild(WebLayer* child, size_t index) {
- layer_->InsertChild(static_cast<WebLayerImpl*>(child)->layer(), index);
-}
-
-void WebLayerImpl::replaceChild(WebLayer* reference, WebLayer* new_layer) {
- layer_->ReplaceChild(static_cast<WebLayerImpl*>(reference)->layer(),
- static_cast<WebLayerImpl*>(new_layer)->layer());
-}
-
-void WebLayerImpl::removeFromParent() { layer_->RemoveFromParent(); }
-
-void WebLayerImpl::removeAllChildren() { layer_->RemoveAllChildren(); }
-
-void WebLayerImpl::setAnchorPoint(const WebFloatPoint& anchor_point) {
- layer_->SetAnchorPoint(anchor_point);
-}
-
-WebFloatPoint WebLayerImpl::anchorPoint() const {
- return layer_->anchor_point();
-}
-
-void WebLayerImpl::setAnchorPointZ(float anchor_point_z) {
- layer_->SetAnchorPointZ(anchor_point_z);
-}
-
-float WebLayerImpl::anchorPointZ() const { return layer_->anchor_point_z(); }
-
-void WebLayerImpl::setBounds(const WebSize& size) { layer_->SetBounds(size); }
-
-WebSize WebLayerImpl::bounds() const { return layer_->bounds(); }
-
-void WebLayerImpl::setMasksToBounds(bool masks_to_bounds) {
- layer_->SetMasksToBounds(masks_to_bounds);
-}
-
-bool WebLayerImpl::masksToBounds() const { return layer_->masks_to_bounds(); }
-
-void WebLayerImpl::setMaskLayer(WebLayer* maskLayer) {
- layer_->SetMaskLayer(
- maskLayer ? static_cast<WebLayerImpl*>(maskLayer)->layer() : 0);
-}
-
-void WebLayerImpl::setReplicaLayer(WebLayer* replica_layer) {
- layer_->SetReplicaLayer(
- replica_layer ? static_cast<WebLayerImpl*>(replica_layer)->layer() : 0);
-}
-
-void WebLayerImpl::setOpacity(float opacity) { layer_->SetOpacity(opacity); }
-
-float WebLayerImpl::opacity() const { return layer_->opacity(); }
-
-void WebLayerImpl::setBlendMode(blink::WebBlendMode blend_mode) {
- layer_->SetBlendMode(BlendModeToSkia(blend_mode));
-}
-
-blink::WebBlendMode WebLayerImpl::blendMode() const {
- return BlendModeFromSkia(layer_->blend_mode());
-}
-
-void WebLayerImpl::setIsRootForIsolatedGroup(bool isolate) {
- layer_->SetIsRootForIsolatedGroup(isolate);
-}
-
-bool WebLayerImpl::isRootForIsolatedGroup() {
- return layer_->is_root_for_isolated_group();
-}
-
-void WebLayerImpl::setOpaque(bool opaque) { layer_->SetContentsOpaque(opaque); }
-
-bool WebLayerImpl::opaque() const { return layer_->contents_opaque(); }
-
-void WebLayerImpl::setPosition(const WebFloatPoint& position) {
- layer_->SetPosition(position);
-}
-
-WebFloatPoint WebLayerImpl::position() const { return layer_->position(); }
-
-void WebLayerImpl::setSublayerTransform(const SkMatrix44& matrix) {
- gfx::Transform sub_layer_transform;
- sub_layer_transform.matrix() = matrix;
- layer_->SetSublayerTransform(sub_layer_transform);
-}
-
-SkMatrix44 WebLayerImpl::sublayerTransform() const {
- return layer_->sublayer_transform().matrix();
-}
-
-void WebLayerImpl::setTransform(const SkMatrix44& matrix) {
- gfx::Transform transform;
- transform.matrix() = matrix;
- layer_->SetTransform(transform);
-}
-
-SkMatrix44 WebLayerImpl::transform() const {
- return layer_->transform().matrix();
-}
-
-void WebLayerImpl::setDrawsContent(bool draws_content) {
- layer_->SetIsDrawable(draws_content);
-}
-
-bool WebLayerImpl::drawsContent() const { return layer_->DrawsContent(); }
-
-void WebLayerImpl::setPreserves3D(bool preserve3D) {
- layer_->SetPreserves3d(preserve3D);
-}
-
-void WebLayerImpl::setUseParentBackfaceVisibility(
- bool use_parent_backface_visibility) {
- layer_->set_use_parent_backface_visibility(use_parent_backface_visibility);
-}
-
-void WebLayerImpl::setBackgroundColor(WebColor color) {
- layer_->SetBackgroundColor(color);
-}
-
-WebColor WebLayerImpl::backgroundColor() const {
- return layer_->background_color();
-}
-
-void WebLayerImpl::setFilters(const WebFilterOperations& filters) {
- const WebFilterOperationsImpl& filters_impl =
- static_cast<const WebFilterOperationsImpl&>(filters);
- layer_->SetFilters(filters_impl.AsFilterOperations());
-}
-
-void WebLayerImpl::setBackgroundFilters(const WebFilterOperations& filters) {
- const WebFilterOperationsImpl& filters_impl =
- static_cast<const WebFilterOperationsImpl&>(filters);
- layer_->SetBackgroundFilters(filters_impl.AsFilterOperations());
-}
-
-void WebLayerImpl::setCompositingReasons(
- blink::WebCompositingReasons reasons) {
- layer_->SetCompositingReasons(reasons);
-}
-
-void WebLayerImpl::setAnimationDelegate(
- blink::WebAnimationDelegate* delegate) {
- animation_delegate_adapter_.reset(
- new WebToCCAnimationDelegateAdapter(delegate));
- layer_->set_layer_animation_delegate(animation_delegate_adapter_.get());
-}
-
-bool WebLayerImpl::addAnimation(blink::WebAnimation* animation) {
- bool result = layer_->AddAnimation(
- static_cast<WebAnimationImpl*>(animation)->PassAnimation());
- delete animation;
- return result;
-}
-
-void WebLayerImpl::removeAnimation(int animation_id) {
- layer_->RemoveAnimation(animation_id);
-}
-
-void WebLayerImpl::removeAnimation(
- int animation_id,
- blink::WebAnimation::TargetProperty target_property) {
- layer_->layer_animation_controller()->RemoveAnimation(
- animation_id,
- static_cast<Animation::TargetProperty>(target_property));
-}
-
-void WebLayerImpl::pauseAnimation(int animation_id, double time_offset) {
- layer_->PauseAnimation(animation_id, time_offset);
-}
-
-bool WebLayerImpl::hasActiveAnimation() { return layer_->HasActiveAnimation(); }
-
-void WebLayerImpl::setForceRenderSurface(bool force_render_surface) {
- layer_->SetForceRenderSurface(force_render_surface);
-}
-
-void WebLayerImpl::setScrollPosition(blink::WebPoint position) {
- layer_->SetScrollOffset(gfx::Point(position).OffsetFromOrigin());
-}
-
-blink::WebPoint WebLayerImpl::scrollPosition() const {
- return gfx::PointAtOffsetFromOrigin(layer_->scroll_offset());
-}
-
-void WebLayerImpl::setMaxScrollPosition(WebSize max_scroll_position) {
- layer_->SetMaxScrollOffset(max_scroll_position);
-}
-
-WebSize WebLayerImpl::maxScrollPosition() const {
- return layer_->max_scroll_offset();
-}
-
-void WebLayerImpl::setScrollable(bool scrollable) {
- layer_->SetScrollable(scrollable);
-}
-
-bool WebLayerImpl::scrollable() const { return layer_->scrollable(); }
-
-void WebLayerImpl::setUserScrollable(bool horizontal, bool vertical) {
- layer_->SetUserScrollable(horizontal, vertical);
-}
-
-bool WebLayerImpl::userScrollableHorizontal() const {
- return layer_->user_scrollable_horizontal();
-}
-
-bool WebLayerImpl::userScrollableVertical() const {
- return layer_->user_scrollable_vertical();
-}
-
-void WebLayerImpl::setHaveWheelEventHandlers(bool have_wheel_event_handlers) {
- layer_->SetHaveWheelEventHandlers(have_wheel_event_handlers);
-}
-
-bool WebLayerImpl::haveWheelEventHandlers() const {
- return layer_->have_wheel_event_handlers();
-}
-
-void WebLayerImpl::setShouldScrollOnMainThread(
- bool should_scroll_on_main_thread) {
- layer_->SetShouldScrollOnMainThread(should_scroll_on_main_thread);
-}
-
-bool WebLayerImpl::shouldScrollOnMainThread() const {
- return layer_->should_scroll_on_main_thread();
-}
-
-void WebLayerImpl::setNonFastScrollableRegion(const WebVector<WebRect>& rects) {
- cc::Region region;
- for (size_t i = 0; i < rects.size(); ++i)
- region.Union(rects[i]);
- layer_->SetNonFastScrollableRegion(region);
-}
-
-WebVector<WebRect> WebLayerImpl::nonFastScrollableRegion() const {
- size_t num_rects = 0;
- for (cc::Region::Iterator region_rects(layer_->non_fast_scrollable_region());
- region_rects.has_rect();
- region_rects.next())
- ++num_rects;
-
- WebVector<WebRect> result(num_rects);
- size_t i = 0;
- for (cc::Region::Iterator region_rects(layer_->non_fast_scrollable_region());
- region_rects.has_rect();
- region_rects.next()) {
- result[i] = region_rects.rect();
- ++i;
- }
- return result;
-}
-
-void WebLayerImpl::setTouchEventHandlerRegion(const WebVector<WebRect>& rects) {
- cc::Region region;
- for (size_t i = 0; i < rects.size(); ++i)
- region.Union(rects[i]);
- layer_->SetTouchEventHandlerRegion(region);
-}
-
-WebVector<WebRect> WebLayerImpl::touchEventHandlerRegion() const {
- size_t num_rects = 0;
- for (cc::Region::Iterator region_rects(layer_->touch_event_handler_region());
- region_rects.has_rect();
- region_rects.next())
- ++num_rects;
-
- WebVector<WebRect> result(num_rects);
- size_t i = 0;
- for (cc::Region::Iterator region_rects(layer_->touch_event_handler_region());
- region_rects.has_rect();
- region_rects.next()) {
- result[i] = region_rects.rect();
- ++i;
- }
- return result;
-}
-
-void WebLayerImpl::setIsContainerForFixedPositionLayers(bool enable) {
- layer_->SetIsContainerForFixedPositionLayers(enable);
-}
-
-bool WebLayerImpl::isContainerForFixedPositionLayers() const {
- return layer_->IsContainerForFixedPositionLayers();
-}
-
-static blink::WebLayerPositionConstraint ToWebLayerPositionConstraint(
- const cc::LayerPositionConstraint& constraint) {
- blink::WebLayerPositionConstraint web_constraint;
- web_constraint.isFixedPosition = constraint.is_fixed_position();
- web_constraint.isFixedToRightEdge = constraint.is_fixed_to_right_edge();
- web_constraint.isFixedToBottomEdge = constraint.is_fixed_to_bottom_edge();
- return web_constraint;
-}
-
-static cc::LayerPositionConstraint ToLayerPositionConstraint(
- const blink::WebLayerPositionConstraint& web_constraint) {
- cc::LayerPositionConstraint constraint;
- constraint.set_is_fixed_position(web_constraint.isFixedPosition);
- constraint.set_is_fixed_to_right_edge(web_constraint.isFixedToRightEdge);
- constraint.set_is_fixed_to_bottom_edge(web_constraint.isFixedToBottomEdge);
- return constraint;
-}
-
-void WebLayerImpl::setPositionConstraint(
- const blink::WebLayerPositionConstraint& constraint) {
- layer_->SetPositionConstraint(ToLayerPositionConstraint(constraint));
-}
-
-blink::WebLayerPositionConstraint WebLayerImpl::positionConstraint() const {
- return ToWebLayerPositionConstraint(layer_->position_constraint());
-}
-
-void WebLayerImpl::setScrollClient(
- blink::WebLayerScrollClient* scroll_client) {
- if (scroll_client) {
- layer_->set_did_scroll_callback(
- base::Bind(&blink::WebLayerScrollClient::didScroll,
- base::Unretained(scroll_client)));
- } else {
- layer_->set_did_scroll_callback(base::Closure());
- }
-}
-
-bool WebLayerImpl::isOrphan() const { return !layer_->layer_tree_host(); }
-
-void WebLayerImpl::setWebLayerClient(blink::WebLayerClient* client) {
- web_layer_client_ = client;
-}
-
-// TODO(chrishtr): move DebugName into this class.
-class TracedDebugInfo : public base::debug::ConvertableToTraceFormat {
- public:
- // This object takes ownership of the debug_info object.
- explicit TracedDebugInfo(blink::WebGraphicsLayerDebugInfo* debug_info) :
- debug_info_(debug_info) {}
- virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE {
- DCHECK(thread_checker_.CalledOnValidThread());
- blink::WebString web_string;
- debug_info_->appendAsTraceFormat(&web_string);
- out->append(web_string.utf8());
- }
- private:
- virtual ~TracedDebugInfo() {}
- scoped_ptr<blink::WebGraphicsLayerDebugInfo> debug_info_;
- base::ThreadChecker thread_checker_;
-};
-
-scoped_refptr<base::debug::ConvertableToTraceFormat>
- WebLayerImpl::TakeDebugInfo() {
- if (!web_layer_client_)
- return NULL;
- blink::WebGraphicsLayerDebugInfo* debug_info =
- web_layer_client_->takeDebugInfo();
-
- if (debug_info)
- return new TracedDebugInfo(debug_info);
- else
- return NULL;
-}
-
-std::string WebLayerImpl::DebugName() {
- if (!web_layer_client_)
- return std::string();
-
- std::string name = web_layer_client_->debugName(this).utf8();
- DCHECK(IsStringASCII(name));
- return name;
-}
-
-void WebLayerImpl::setScrollParent(blink::WebLayer* parent) {
- cc::Layer* scroll_parent = NULL;
- if (parent)
- scroll_parent = static_cast<WebLayerImpl*>(parent)->layer();
- layer_->SetScrollParent(scroll_parent);
-}
-
-void WebLayerImpl::setClipParent(blink::WebLayer* parent) {
- cc::Layer* clip_parent = NULL;
- if (parent)
- clip_parent = static_cast<WebLayerImpl*>(parent)->layer();
- layer_->SetClipParent(clip_parent);
-}
-
-Layer* WebLayerImpl::layer() const { return layer_.get(); }
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_layer_impl.h b/chromium/webkit/renderer/compositor_bindings/web_layer_impl.h
deleted file mode 100644
index 011ec49a8fd..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_layer_impl.h
+++ /dev/null
@@ -1,156 +0,0 @@
-// Copyright 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.
-
-#ifndef WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_LAYER_IMPL_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_LAYER_IMPL_H_
-
-#include <string>
-
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "cc/layers/layer_client.h"
-#include "third_party/WebKit/public/platform/WebAnimation.h"
-#include "third_party/WebKit/public/platform/WebCString.h"
-#include "third_party/WebKit/public/platform/WebColor.h"
-#include "third_party/WebKit/public/platform/WebCompositingReasons.h"
-#include "third_party/WebKit/public/platform/WebFloatPoint.h"
-#include "third_party/WebKit/public/platform/WebLayer.h"
-#include "third_party/WebKit/public/platform/WebPoint.h"
-#include "third_party/WebKit/public/platform/WebRect.h"
-#include "third_party/WebKit/public/platform/WebSize.h"
-#include "third_party/WebKit/public/platform/WebString.h"
-#include "third_party/WebKit/public/platform/WebVector.h"
-#include "third_party/skia/include/utils/SkMatrix44.h"
-#include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
-
-namespace cc { class Layer; }
-
-// TODO(senorblanco): Remove this once WebKit changes have landed.
-class SkImageFilter;
-
-namespace blink {
-class WebFilterOperations;
-class WebLayerClient;
-struct WebFloatRect;
-}
-
-namespace base {
-namespace debug {
-class ConvertableToTraceFormat;
-}
-}
-
-namespace webkit {
-
-class WebToCCAnimationDelegateAdapter;
-
-class WebLayerImpl : public blink::WebLayer, public cc::LayerClient {
- public:
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebLayerImpl();
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT explicit WebLayerImpl(
- scoped_refptr<cc::Layer>);
- virtual ~WebLayerImpl();
-
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT cc::Layer* layer() const;
-
- // WebLayer implementation.
- virtual int id() const;
- virtual void invalidateRect(const blink::WebFloatRect&);
- virtual void invalidate();
- virtual void addChild(blink::WebLayer* child);
- virtual void insertChild(blink::WebLayer* child, size_t index);
- virtual void replaceChild(blink::WebLayer* reference,
- blink::WebLayer* new_layer);
- virtual void removeFromParent();
- virtual void removeAllChildren();
- virtual void setAnchorPoint(const blink::WebFloatPoint&);
- virtual blink::WebFloatPoint anchorPoint() const;
- virtual void setAnchorPointZ(float anchor_point_z);
- virtual float anchorPointZ() const;
- virtual void setBounds(const blink::WebSize& bounds);
- virtual blink::WebSize bounds() const;
- virtual void setMasksToBounds(bool masks_to_bounds);
- virtual bool masksToBounds() const;
- virtual void setMaskLayer(blink::WebLayer* mask);
- virtual void setReplicaLayer(blink::WebLayer* replica);
- virtual void setOpacity(float opacity);
- virtual float opacity() const;
- virtual void setBlendMode(blink::WebBlendMode blend_mode);
- virtual blink::WebBlendMode blendMode() const;
- virtual void setIsRootForIsolatedGroup(bool root);
- virtual bool isRootForIsolatedGroup();
- virtual void setOpaque(bool opaque);
- virtual bool opaque() const;
- virtual void setPosition(const blink::WebFloatPoint& position);
- virtual blink::WebFloatPoint position() const;
- virtual void setSublayerTransform(const SkMatrix44&);
- virtual SkMatrix44 sublayerTransform() const;
- virtual void setTransform(const SkMatrix44& transform);
- virtual SkMatrix44 transform() const;
- virtual void setDrawsContent(bool draws_content);
- virtual bool drawsContent() const;
- virtual void setPreserves3D(bool preserves_3d);
- virtual void setUseParentBackfaceVisibility(bool visible);
- virtual void setBackgroundColor(blink::WebColor color);
- virtual blink::WebColor backgroundColor() const;
- virtual void setFilters(const blink::WebFilterOperations& filters);
- virtual void setBackgroundFilters(const blink::WebFilterOperations& filters);
- virtual void setCompositingReasons(blink::WebCompositingReasons);
- virtual void setAnimationDelegate(blink::WebAnimationDelegate* delegate);
- virtual bool addAnimation(blink::WebAnimation* animation);
- virtual void removeAnimation(int animation_id);
- virtual void removeAnimation(int animation_id,
- blink::WebAnimation::TargetProperty);
- virtual void pauseAnimation(int animation_id, double time_offset);
- virtual bool hasActiveAnimation();
- virtual void setForceRenderSurface(bool force);
- virtual void setScrollPosition(blink::WebPoint position);
- virtual blink::WebPoint scrollPosition() const;
- virtual void setMaxScrollPosition(blink::WebSize max_position);
- virtual blink::WebSize maxScrollPosition() const;
- virtual void setScrollable(bool scrollable);
- virtual bool scrollable() const;
- virtual void setUserScrollable(bool horizontal, bool vertical);
- virtual bool userScrollableHorizontal() const;
- virtual bool userScrollableVertical() const;
- virtual void setHaveWheelEventHandlers(bool have_wheel_event_handlers);
- virtual bool haveWheelEventHandlers() const;
- virtual void setShouldScrollOnMainThread(bool scroll_on_main);
- virtual bool shouldScrollOnMainThread() const;
- virtual void setNonFastScrollableRegion(
- const blink::WebVector<blink::WebRect>& region);
- virtual blink::WebVector<blink::WebRect> nonFastScrollableRegion() const;
- virtual void setTouchEventHandlerRegion(
- const blink::WebVector<blink::WebRect>& region);
- virtual blink::WebVector<blink::WebRect> touchEventHandlerRegion() const;
- virtual void setIsContainerForFixedPositionLayers(bool is_container);
- virtual bool isContainerForFixedPositionLayers() const;
- virtual void setPositionConstraint(
- const blink::WebLayerPositionConstraint& constraint);
- virtual blink::WebLayerPositionConstraint positionConstraint() const;
- virtual void setScrollClient(blink::WebLayerScrollClient* client);
- virtual bool isOrphan() const;
- virtual void setWebLayerClient(blink::WebLayerClient* client);
-
- // LayerClient implementation.
- virtual std::string DebugName() OVERRIDE;
- virtual scoped_refptr<base::debug::ConvertableToTraceFormat>
- TakeDebugInfo() OVERRIDE;
-
- virtual void setScrollParent(blink::WebLayer* parent);
- virtual void setClipParent(blink::WebLayer* parent);
-
- protected:
- scoped_refptr<cc::Layer> layer_;
- blink::WebLayerClient* web_layer_client_;
-
- private:
- scoped_ptr<WebToCCAnimationDelegateAdapter> animation_delegate_adapter_;
-
- DISALLOW_COPY_AND_ASSIGN(WebLayerImpl);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_LAYER_IMPL_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.cc b/chromium/webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.cc
deleted file mode 100644
index a62fcee4a37..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.cc
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright 2013 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 "webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.h"
-
-#include "cc/layers/layer.h"
-#include "third_party/WebKit/public/platform/WebFloatPoint.h"
-#include "third_party/WebKit/public/platform/WebSize.h"
-#include "third_party/skia/include/utils/SkMatrix44.h"
-
-using cc::Layer;
-
-namespace webkit {
-
-WebLayerImplFixedBounds::WebLayerImplFixedBounds() {
-}
-
-WebLayerImplFixedBounds::WebLayerImplFixedBounds(scoped_refptr<Layer> layer)
- : WebLayerImpl(layer) {
-}
-
-
-WebLayerImplFixedBounds::~WebLayerImplFixedBounds() {
-}
-
-void WebLayerImplFixedBounds::invalidateRect(const blink::WebFloatRect& rect) {
- // Partial invalidations seldom occur for such layers.
- // Simply invalidate the whole layer to avoid transformation of coordinates.
- invalidate();
-}
-
-void WebLayerImplFixedBounds::setAnchorPoint(
- const blink::WebFloatPoint& anchor_point) {
- if (anchor_point != this->anchorPoint()) {
- layer_->SetAnchorPoint(anchor_point);
- UpdateLayerBoundsAndTransform();
- }
-}
-
-void WebLayerImplFixedBounds::setBounds(const blink::WebSize& bounds) {
- if (original_bounds_ != gfx::Size(bounds)) {
- original_bounds_ = bounds;
- UpdateLayerBoundsAndTransform();
- }
-}
-
-blink::WebSize WebLayerImplFixedBounds::bounds() const {
- return original_bounds_;
-}
-
-void WebLayerImplFixedBounds::setSublayerTransform(const SkMatrix44& matrix) {
- gfx::Transform transform;
- transform.matrix() = matrix;
- SetSublayerTransformInternal(transform);
-}
-
-SkMatrix44 WebLayerImplFixedBounds::sublayerTransform() const {
- return original_sublayer_transform_.matrix();
-}
-
-void WebLayerImplFixedBounds::setTransform(const SkMatrix44& matrix) {
- gfx::Transform transform;
- transform.matrix() = matrix;
- SetTransformInternal(transform);
-}
-
-SkMatrix44 WebLayerImplFixedBounds::transform() const {
- return original_transform_.matrix();
-}
-
-void WebLayerImplFixedBounds::SetFixedBounds(gfx::Size fixed_bounds) {
- if (fixed_bounds_ != fixed_bounds) {
- fixed_bounds_ = fixed_bounds;
- UpdateLayerBoundsAndTransform();
- }
-}
-
-void WebLayerImplFixedBounds::SetSublayerTransformInternal(
- const gfx::Transform& transform) {
- if (original_sublayer_transform_ != transform) {
- original_sublayer_transform_ = transform;
- UpdateLayerBoundsAndTransform();
- }
-}
-
-void WebLayerImplFixedBounds::SetTransformInternal(
- const gfx::Transform& transform) {
- if (original_transform_ != transform) {
- original_transform_ = transform;
- UpdateLayerBoundsAndTransform();
- }
-}
-
-void WebLayerImplFixedBounds::UpdateLayerBoundsAndTransform() {
- if (fixed_bounds_.IsEmpty() || original_bounds_.IsEmpty() ||
- fixed_bounds_ == original_bounds_ ||
- // For now fall back to non-fixed bounds for non-zero anchor point.
- // TODO(wangxianzhu): Support non-zero anchor point for fixed bounds.
- anchorPoint().x || anchorPoint().y) {
- layer_->SetBounds(original_bounds_);
- layer_->SetTransform(original_transform_);
- layer_->SetSublayerTransform(original_sublayer_transform_);
- return;
- }
-
- layer_->SetBounds(fixed_bounds_);
-
- // Apply bounds scale (bounds/fixed_bounds) over original transform.
- gfx::Transform transform_with_bounds_scale(original_transform_);
- float bounds_scale_x =
- static_cast<float>(original_bounds_.width()) / fixed_bounds_.width();
- float bounds_scale_y =
- static_cast<float>(original_bounds_.height()) / fixed_bounds_.height();
- transform_with_bounds_scale.Scale(bounds_scale_x, bounds_scale_y);
- layer_->SetTransform(transform_with_bounds_scale);
-
- // As we apply extra scale transform on this layer which will propagate to the
- // sublayers, here undo the scale on sublayers.
- gfx::Transform sublayer_transform_with_inverse_bounds_scale;
- sublayer_transform_with_inverse_bounds_scale.Scale(1.f / bounds_scale_x,
- 1.f / bounds_scale_y);
- sublayer_transform_with_inverse_bounds_scale.PreconcatTransform(
- original_sublayer_transform_);
- layer_->SetSublayerTransform(sublayer_transform_with_inverse_bounds_scale);
-}
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.h b/chromium/webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.h
deleted file mode 100644
index bd8a6ff7a24..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2013 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_LAYER_IMPL_FIXED_BOUNDS_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_LAYER_IMPL_FIXED_BOUNDS_H_
-
-#include "ui/gfx/size.h"
-#include "ui/gfx/transform.h"
-#include "webkit/renderer/compositor_bindings/web_layer_impl.h"
-
-namespace webkit {
-
-// A special implementation of WebLayerImpl for layers that its contents
-// need to be automatically scaled when the bounds changes. The compositor
-// can efficiently handle the bounds change of such layers if the bounds
-// is fixed to a given value and the change of bounds are converted to
-// transformation scales.
-class WebLayerImplFixedBounds : public WebLayerImpl {
- public:
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebLayerImplFixedBounds();
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT explicit WebLayerImplFixedBounds(
- scoped_refptr<cc::Layer>);
- virtual ~WebLayerImplFixedBounds();
-
- // WebLayerImpl overrides.
- virtual void invalidateRect(const blink::WebFloatRect& rect);
- virtual void setAnchorPoint(const blink::WebFloatPoint& anchor_point);
- virtual void setBounds(const blink::WebSize& bounds);
- virtual blink::WebSize bounds() const;
- virtual void setSublayerTransform(const SkMatrix44& transform);
- virtual SkMatrix44 sublayerTransform() const;
- virtual void setTransform(const SkMatrix44& transform);
- virtual SkMatrix44 transform() const;
-
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT void SetFixedBounds(gfx::Size bounds);
-
- protected:
- void SetTransformInternal(const gfx::Transform& transform);
- void SetSublayerTransformInternal(const gfx::Transform& transform);
- void UpdateLayerBoundsAndTransform();
-
- gfx::Transform original_sublayer_transform_;
- gfx::Transform original_transform_;
- gfx::Size original_bounds_;
- gfx::Size fixed_bounds_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(WebLayerImplFixedBounds);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_LAYER_IMPL_FIXED_BOUNDS_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds_unittest.cc b/chromium/webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds_unittest.cc
deleted file mode 100644
index b1710271e6e..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds_unittest.cc
+++ /dev/null
@@ -1,203 +0,0 @@
-// Copyright 2013 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 <vector>
-#include "cc/layers/picture_image_layer.h"
-#include "cc/test/fake_layer_tree_host.h"
-#include "cc/test/geometry_test_utils.h"
-#include "cc/trees/layer_tree_host_common.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/WebKit/public/platform/WebFloatPoint.h"
-#include "third_party/WebKit/public/platform/WebSize.h"
-#include "third_party/skia/include/utils/SkMatrix44.h"
-#include "ui/gfx/point3_f.h"
-#include "webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.h"
-
-using blink::WebFloatPoint;
-using blink::WebSize;
-
-namespace webkit {
-namespace {
-
-TEST(WebLayerImplFixedBoundsTest, IdentityBounds) {
- scoped_ptr<WebLayerImplFixedBounds> layer(new WebLayerImplFixedBounds());
- layer->setAnchorPoint(WebFloatPoint(0, 0));
- layer->SetFixedBounds(gfx::Size(100, 100));
- layer->setBounds(WebSize(100, 100));
- EXPECT_EQ(WebSize(100, 100), layer->bounds());
- EXPECT_EQ(gfx::Size(100, 100), layer->layer()->bounds());
- EXPECT_EQ(gfx::Transform(), layer->layer()->transform());
-}
-
-gfx::Point3F TransformPoint(const gfx::Transform& transform,
- const gfx::Point3F& point) {
- gfx::Point3F result = point;
- transform.TransformPoint(&result);
- return result;
-}
-
-void CheckBoundsScaleSimple(WebLayerImplFixedBounds* layer,
- const WebSize& bounds,
- const gfx::Size& fixed_bounds) {
- layer->setBounds(bounds);
- layer->SetFixedBounds(fixed_bounds);
-
- EXPECT_EQ(bounds, layer->bounds());
- EXPECT_EQ(fixed_bounds, layer->layer()->bounds());
- EXPECT_TRUE(layer->transform().isIdentity());
- EXPECT_TRUE(layer->sublayerTransform().isIdentity());
-
- // An arbitrary point to check the scale and transforms.
- gfx::Point3F original_point(10, 20, 1);
- gfx::Point3F scaled_point(
- original_point.x() * bounds.width / fixed_bounds.width(),
- original_point.y() * bounds.height / fixed_bounds.height(),
- original_point.z());
- // Test if the bounds scale is correctly applied in transform and
- // sublayerTransform.
- EXPECT_POINT3F_EQ(scaled_point,
- TransformPoint(layer->layer()->transform(),
- original_point));
- EXPECT_POINT3F_EQ(original_point,
- TransformPoint(layer->layer()->sublayer_transform(),
- scaled_point));
-}
-
-TEST(WebLayerImplFixedBoundsTest, BoundsScaleSimple) {
- scoped_ptr<WebLayerImplFixedBounds> layer(new WebLayerImplFixedBounds());
- layer->setAnchorPoint(WebFloatPoint(0, 0));
- CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(150, 250));
- // Change fixed_bounds.
- CheckBoundsScaleSimple(layer.get(), WebSize(100, 200), gfx::Size(75, 100));
- // Change bounds.
- CheckBoundsScaleSimple(layer.get(), WebSize(300, 100), gfx::Size(75, 100));
-}
-
-void ExpectEqualLayerRectsInTarget(cc::Layer* layer1, cc::Layer* layer2) {
- gfx::RectF layer1_rect_in_target(layer1->content_bounds());
- layer1->draw_transform().TransformRect(&layer1_rect_in_target);
-
- gfx::RectF layer2_rect_in_target(layer2->content_bounds());
- layer2->draw_transform().TransformRect(&layer2_rect_in_target);
-
- EXPECT_FLOAT_RECT_EQ(layer1_rect_in_target, layer2_rect_in_target);
-}
-
-void CompareFixedBoundsLayerAndNormalLayer(
- const WebFloatPoint& anchor_point,
- const gfx::Transform& transform,
- const gfx::Transform& sublayer_transform) {
- const gfx::Size kDeviceViewportSize(800, 600);
- const float kDeviceScaleFactor = 2.f;
- const float kPageScaleFactor = 1.5f;
-
- WebSize bounds(150, 200);
- WebFloatPoint position(20, 30);
- WebSize sublayer_bounds(88, 99);
- WebFloatPoint sublayer_position(50, 60);
- gfx::Size fixed_bounds(160, 70);
-
- scoped_ptr<WebLayerImplFixedBounds> root_layer(new WebLayerImplFixedBounds());
-
- WebLayerImplFixedBounds* fixed_bounds_layer =
- new WebLayerImplFixedBounds(cc::PictureImageLayer::Create());
- WebLayerImpl* sublayer_under_fixed_bounds_layer = new WebLayerImpl();
- sublayer_under_fixed_bounds_layer->setBounds(sublayer_bounds);
- sublayer_under_fixed_bounds_layer->setPosition(sublayer_position);
- fixed_bounds_layer->addChild(sublayer_under_fixed_bounds_layer);
- fixed_bounds_layer->setBounds(bounds);
- fixed_bounds_layer->SetFixedBounds(fixed_bounds);
- fixed_bounds_layer->setAnchorPoint(anchor_point);
- fixed_bounds_layer->setTransform(transform.matrix());
- fixed_bounds_layer->setSublayerTransform(sublayer_transform.matrix());
- fixed_bounds_layer->setPosition(position);
- root_layer->addChild(fixed_bounds_layer);
-
- WebLayerImpl* normal_layer(new WebLayerImpl(cc::PictureImageLayer::Create()));
- WebLayerImpl* sublayer_under_normal_layer = new WebLayerImpl();
- sublayer_under_normal_layer->setBounds(sublayer_bounds);
- sublayer_under_normal_layer->setPosition(sublayer_position);
-
- normal_layer->addChild(sublayer_under_normal_layer);
- normal_layer->setBounds(bounds);
- normal_layer->setAnchorPoint(anchor_point);
- normal_layer->setTransform(transform.matrix());
- normal_layer->setSublayerTransform(sublayer_transform.matrix());
- normal_layer->setPosition(position);
- root_layer->addChild(normal_layer);
-
- scoped_ptr<cc::FakeLayerTreeHost> host = cc::FakeLayerTreeHost::Create();
- host->SetRootLayer(root_layer->layer());
-
- {
- cc::RenderSurfaceLayerList render_surface_layer_list;
- cc::LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- root_layer->layer(), kDeviceViewportSize, &render_surface_layer_list);
- inputs.device_scale_factor = kDeviceScaleFactor;
- inputs.page_scale_factor = kPageScaleFactor;
- inputs.page_scale_application_layer = root_layer->layer(),
- cc::LayerTreeHostCommon::CalculateDrawProperties(&inputs);
-
- ExpectEqualLayerRectsInTarget(normal_layer->layer(),
- fixed_bounds_layer->layer());
- ExpectEqualLayerRectsInTarget(sublayer_under_normal_layer->layer(),
- sublayer_under_fixed_bounds_layer->layer());
- }
-
- // Change of fixed bounds should not affect the target geometries.
- fixed_bounds_layer->SetFixedBounds(gfx::Size(fixed_bounds.width() / 2,
- fixed_bounds.height() * 2));
-
- {
- cc::RenderSurfaceLayerList render_surface_layer_list;
- cc::LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs(
- root_layer->layer(), kDeviceViewportSize, &render_surface_layer_list);
- inputs.device_scale_factor = kDeviceScaleFactor;
- inputs.page_scale_factor = kPageScaleFactor;
- inputs.page_scale_application_layer = root_layer->layer(),
- cc::LayerTreeHostCommon::CalculateDrawProperties(&inputs);
-
- ExpectEqualLayerRectsInTarget(normal_layer->layer(),
- fixed_bounds_layer->layer());
- ExpectEqualLayerRectsInTarget(sublayer_under_normal_layer->layer(),
- sublayer_under_fixed_bounds_layer->layer());
- }
-}
-
-// A black box test that ensures WebLayerImplFixedBounds won't change target
-// geometries. Simple case: identity transforms and zero anchor point.
-TEST(WebLayerImplFixedBoundsTest, CompareToWebLayerImplSimple) {
- CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0, 0),
- gfx::Transform(),
- gfx::Transform());
-}
-
-// A black box test that ensures WebLayerImplFixedBounds won't change target
-// geometries. Complex case: complex transforms and non-zero anchor point.
-TEST(WebLayerImplFixedBoundsTest, CompareToWebLayerImplComplex) {
- gfx::Transform transform;
- // These are arbitrary values that should not affect the results.
- transform.Translate3d(50, 60, 70);
- transform.Scale3d(2, 3, 4);
- transform.RotateAbout(gfx::Vector3dF(33, 44, 55), 99);
-
- gfx::Transform sublayer_transform;
- // These are arbitrary values that should not affect the results.
- sublayer_transform.Scale3d(1.1f, 2.2f, 3.3f);
- sublayer_transform.Translate3d(11, 22, 33);
- sublayer_transform.RotateAbout(gfx::Vector3dF(10, 30, 20), 88);
-
- CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0, 0),
- transform,
- sublayer_transform);
-
- // With non-zero anchor point, WebLayerImplFixedBounds will fall back to
- // WebLayerImpl.
- CompareFixedBoundsLayerAndNormalLayer(WebFloatPoint(0.4f, 0.6f),
- transform,
- sublayer_transform);
-}
-
-} // namespace
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_nine_patch_layer_impl.cc b/chromium/webkit/renderer/compositor_bindings/web_nine_patch_layer_impl.cc
deleted file mode 100644
index 6d8f7207393..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_nine_patch_layer_impl.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2013 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 "webkit/renderer/compositor_bindings/web_nine_patch_layer_impl.h"
-
-#include "base/command_line.h"
-#include "cc/base/switches.h"
-#include "cc/layers/nine_patch_layer.h"
-#include "cc/layers/picture_image_layer.h"
-#include "webkit/renderer/compositor_bindings/web_layer_impl.h"
-#include "webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.h"
-
-namespace webkit {
-
-WebNinePatchLayerImpl::WebNinePatchLayerImpl() {
- layer_.reset(new WebLayerImpl(cc::NinePatchLayer::Create()));
-}
-
-WebNinePatchLayerImpl::~WebNinePatchLayerImpl() {}
-
-blink::WebLayer* WebNinePatchLayerImpl::layer() { return layer_.get(); }
-
-void WebNinePatchLayerImpl::setBitmap(SkBitmap bitmap,
- const blink::WebRect& aperture) {
- setBitmap(bitmap);
- setAperture(aperture);
- setBorder(blink::WebRect(aperture.x, aperture.y,
- bitmap.width() - aperture.width,
- bitmap.height() - aperture.height));
-}
-
-void WebNinePatchLayerImpl::setBitmap(SkBitmap bitmap) {
- cc::NinePatchLayer* nine_patch =
- static_cast<cc::NinePatchLayer*>(layer_->layer());
- nine_patch->SetBitmap(bitmap);
-}
-
-void WebNinePatchLayerImpl::setAperture(const blink::WebRect& aperture) {
- cc::NinePatchLayer* nine_patch =
- static_cast<cc::NinePatchLayer*>(layer_->layer());
- nine_patch->SetAperture(gfx::Rect(aperture));
-}
-
-void WebNinePatchLayerImpl::setBorder(const blink::WebRect& border) {
- cc::NinePatchLayer* nine_patch =
- static_cast<cc::NinePatchLayer*>(layer_->layer());
- nine_patch->SetBorder(gfx::Rect(border));
-}
-
-void WebNinePatchLayerImpl::setFillCenter(bool fill_center) {
- cc::NinePatchLayer* nine_patch =
- static_cast<cc::NinePatchLayer*>(layer_->layer());
- nine_patch->SetFillCenter(fill_center);
-}
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_nine_patch_layer_impl.h b/chromium/webkit/renderer/compositor_bindings/web_nine_patch_layer_impl.h
deleted file mode 100644
index 5cca0389fc8..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_nine_patch_layer_impl.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2013 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_NINE_PATCH_LAYER_IMPL_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_NINE_PATCH_LAYER_IMPL_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "third_party/WebKit/public/platform/WebNinePatchLayer.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
-
-namespace webkit {
-
-class WebLayerImpl;
-
-class WebNinePatchLayerImpl : public blink::WebNinePatchLayer {
- public:
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebNinePatchLayerImpl();
- virtual ~WebNinePatchLayerImpl();
-
- // blink::WebNinePatchLayer implementation.
- virtual blink::WebLayer* layer();
-
- // TODO(ccameron): Remove setBitmap(SkBitmap, blink::WebRect) in favor of
- // setBitmap(), setAperture(), and setBorder();
- virtual void setBitmap(SkBitmap bitmap, const blink::WebRect& aperture);
- virtual void setBitmap(SkBitmap bitmap);
- virtual void setAperture(const blink::WebRect& aperture);
- virtual void setBorder(const blink::WebRect& border);
- virtual void setFillCenter(bool fill_center);
-
- private:
- scoped_ptr<WebLayerImpl> layer_;
-
- DISALLOW_COPY_AND_ASSIGN(WebNinePatchLayerImpl);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_NINE_PATCH_LAYER_IMPL_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_rendering_stats_impl.h b/chromium/webkit/renderer/compositor_bindings/web_rendering_stats_impl.h
deleted file mode 100644
index 2b347af9f89..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_rendering_stats_impl.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_RENDERING_STATS_IMPL_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_RENDERING_STATS_IMPL_H_
-
-#include "cc/debug/rendering_stats.h"
-#include "third_party/WebKit/public/platform/WebRenderingStats.h"
-
-namespace blink {
-
-struct WebRenderingStatsImpl : public WebRenderingStats {
- WebRenderingStatsImpl() {}
-
- cc::RenderingStats rendering_stats;
-};
-
-} // namespace blink
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_RENDERING_STATS_IMPL_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_scrollbar_layer_impl.cc b/chromium/webkit/renderer/compositor_bindings/web_scrollbar_layer_impl.cc
deleted file mode 100644
index 265a97db41c..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_scrollbar_layer_impl.cc
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 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 "webkit/renderer/compositor_bindings/web_scrollbar_layer_impl.h"
-
-#include "cc/layers/painted_scrollbar_layer.h"
-#include "cc/layers/scrollbar_layer_interface.h"
-#include "cc/layers/solid_color_scrollbar_layer.h"
-#include "webkit/renderer/compositor_bindings/scrollbar_impl.h"
-#include "webkit/renderer/compositor_bindings/web_layer_impl.h"
-
-using cc::PaintedScrollbarLayer;
-using cc::SolidColorScrollbarLayer;
-
-namespace {
-
-cc::ScrollbarOrientation ConvertOrientation(
- blink::WebScrollbar::Orientation orientation) {
- return orientation == blink::WebScrollbar::Horizontal ? cc::HORIZONTAL
- : cc::VERTICAL;
-}
-
-} // namespace
-
-namespace webkit {
-
-WebScrollbarLayerImpl::WebScrollbarLayerImpl(
- blink::WebScrollbar* scrollbar,
- blink::WebScrollbarThemePainter painter,
- blink::WebScrollbarThemeGeometry* geometry)
- : layer_(new WebLayerImpl(PaintedScrollbarLayer::Create(
- scoped_ptr<cc::Scrollbar>(new ScrollbarImpl(
- make_scoped_ptr(scrollbar),
- painter,
- make_scoped_ptr(geometry))).Pass(), 0))) {}
-
-WebScrollbarLayerImpl::WebScrollbarLayerImpl(
- blink::WebScrollbar::Orientation orientation,
- int thumb_thickness,
- bool is_left_side_vertical_scrollbar)
- : layer_(new WebLayerImpl(
- SolidColorScrollbarLayer::Create(
- ConvertOrientation(orientation),
- thumb_thickness,
- is_left_side_vertical_scrollbar,
- 0))) {}
-
-WebScrollbarLayerImpl::~WebScrollbarLayerImpl() {}
-
-blink::WebLayer* WebScrollbarLayerImpl::layer() { return layer_.get(); }
-
-void WebScrollbarLayerImpl::setScrollLayer(blink::WebLayer* layer) {
- int id = layer ? static_cast<WebLayerImpl*>(layer)->layer()->id() : 0;
- static_cast<PaintedScrollbarLayer*>(layer_->layer())->SetScrollLayerId(id);
-}
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_scrollbar_layer_impl.h b/chromium/webkit/renderer/compositor_bindings/web_scrollbar_layer_impl.h
deleted file mode 100644
index 85d9794e34a..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_scrollbar_layer_impl.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_SCROLLBAR_LAYER_IMPL_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_SCROLLBAR_LAYER_IMPL_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "third_party/WebKit/public/platform/WebScrollbar.h"
-#include "third_party/WebKit/public/platform/WebScrollbarLayer.h"
-#include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
-
-namespace blink {
-class WebScrollbarThemeGeometry;
-class WebScrollbarThemePainter;
-}
-
-namespace webkit {
-
-class WebLayerImpl;
-
-class WebScrollbarLayerImpl : public blink::WebScrollbarLayer {
- public:
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebScrollbarLayerImpl(
- blink::WebScrollbar* scrollbar,
- blink::WebScrollbarThemePainter painter,
- blink::WebScrollbarThemeGeometry* geometry);
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebScrollbarLayerImpl(
- blink::WebScrollbar::Orientation orientation,
- int thumb_thickness,
- bool is_left_side_vertical_scrollbar);
- virtual ~WebScrollbarLayerImpl();
-
- // blink::WebScrollbarLayer implementation.
- virtual blink::WebLayer* layer();
- virtual void setScrollLayer(blink::WebLayer* layer);
-
- private:
- scoped_ptr<WebLayerImpl> layer_;
-
- DISALLOW_COPY_AND_ASSIGN(WebScrollbarLayerImpl);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_SCROLLBAR_LAYER_IMPL_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_solid_color_layer_impl.cc b/chromium/webkit/renderer/compositor_bindings/web_solid_color_layer_impl.cc
deleted file mode 100644
index 5dd6aa383c4..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_solid_color_layer_impl.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 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 "webkit/renderer/compositor_bindings/web_solid_color_layer_impl.h"
-
-#include "cc/layers/solid_color_layer.h"
-#include "webkit/renderer/compositor_bindings/web_layer_impl.h"
-
-using cc::SolidColorLayer;
-
-namespace webkit {
-
-WebSolidColorLayerImpl::WebSolidColorLayerImpl()
- : layer_(new WebLayerImpl(SolidColorLayer::Create())) {
- layer_->layer()->SetIsDrawable(true);
-}
-
-WebSolidColorLayerImpl::~WebSolidColorLayerImpl() {}
-
-blink::WebLayer* WebSolidColorLayerImpl::layer() { return layer_.get(); }
-
-void WebSolidColorLayerImpl::setBackgroundColor(blink::WebColor color) {
- layer_->setBackgroundColor(color);
-}
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_solid_color_layer_impl.h b/chromium/webkit/renderer/compositor_bindings/web_solid_color_layer_impl.h
deleted file mode 100644
index 0a2ec2641ce..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_solid_color_layer_impl.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_SOLID_COLOR_LAYER_IMPL_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_SOLID_COLOR_LAYER_IMPL_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "third_party/WebKit/public/platform/WebColor.h"
-#include "third_party/WebKit/public/platform/WebSolidColorLayer.h"
-#include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
-
-namespace webkit {
-class WebLayerImpl;
-
-class WebSolidColorLayerImpl : public blink::WebSolidColorLayer {
- public:
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebSolidColorLayerImpl();
- virtual ~WebSolidColorLayerImpl();
-
- // blink::WebSolidColorLayer implementation.
- virtual blink::WebLayer* layer();
- virtual void setBackgroundColor(blink::WebColor);
-
- private:
- scoped_ptr<WebLayerImpl> layer_;
-
- DISALLOW_COPY_AND_ASSIGN(WebSolidColorLayerImpl);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_SOLID_COLOR_LAYER_IMPL_H_
-
diff --git a/chromium/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.cc b/chromium/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.cc
deleted file mode 100644
index c042bb66d64..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2013 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 "webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.h"
-
-#include "third_party/WebKit/public/platform/WebAnimationDelegate.h"
-
-namespace webkit {
-
-WebToCCAnimationDelegateAdapter::WebToCCAnimationDelegateAdapter(
- blink::WebAnimationDelegate* delegate)
- : delegate_(delegate) {}
-
-void WebToCCAnimationDelegateAdapter::NotifyAnimationStarted(
- double wall_clock_time,
- base::TimeTicks monotonic_time,
- cc::Animation::TargetProperty target_property) {
- delegate_->notifyAnimationStarted(
- wall_clock_time,
- (monotonic_time - base::TimeTicks()).InSecondsF(),
- static_cast<blink::WebAnimation::TargetProperty>(target_property));
-}
-
-void WebToCCAnimationDelegateAdapter::NotifyAnimationFinished(
- double wall_clock_time,
- base::TimeTicks monotonic_time,
- cc::Animation::TargetProperty target_property) {
- delegate_->notifyAnimationFinished(
- wall_clock_time,
- (monotonic_time - base::TimeTicks()).InSecondsF(),
- static_cast<blink::WebAnimation::TargetProperty>(target_property));
-}
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.h b/chromium/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.h
deleted file mode 100644
index 7338322e99d..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_to_cc_animation_delegate_adapter.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2013 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_TO_CC_ANIMATION_DELEGATE_ADAPTER_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_TO_CC_ANIMATION_DELEGATE_ADAPTER_H_
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "cc/animation/animation_delegate.h"
-
-namespace blink { class WebAnimationDelegate; }
-
-namespace webkit {
-
-class WebToCCAnimationDelegateAdapter : public cc::AnimationDelegate {
- public:
- explicit WebToCCAnimationDelegateAdapter(
- blink::WebAnimationDelegate* delegate);
-
- private:
- virtual void NotifyAnimationStarted(
- double wall_clock_time,
- base::TimeTicks monotonic_time,
- cc::Animation::TargetProperty target_property) OVERRIDE;
- virtual void NotifyAnimationFinished(
- double wall_clock_time,
- base::TimeTicks monotonic_time,
- cc::Animation::TargetProperty target_property) OVERRIDE;
-
- blink::WebAnimationDelegate* delegate_;
-
- DISALLOW_COPY_AND_ASSIGN(WebToCCAnimationDelegateAdapter);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_TO_CC_ANIMATION_DELEGATE_ADAPTER_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_transform_animation_curve_impl.cc b/chromium/webkit/renderer/compositor_bindings/web_transform_animation_curve_impl.cc
deleted file mode 100644
index 1b0d073b21e..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_transform_animation_curve_impl.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright 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 "webkit/renderer/compositor_bindings/web_transform_animation_curve_impl.h"
-
-#include "cc/animation/keyframed_animation_curve.h"
-#include "cc/animation/timing_function.h"
-#include "cc/animation/transform_operations.h"
-#include "webkit/renderer/compositor_bindings/web_animation_curve_common.h"
-#include "webkit/renderer/compositor_bindings/web_transform_operations_impl.h"
-
-using blink::WebTransformKeyframe;
-
-namespace webkit {
-
-WebTransformAnimationCurveImpl::WebTransformAnimationCurveImpl()
- : curve_(cc::KeyframedTransformAnimationCurve::Create()) {}
-
-WebTransformAnimationCurveImpl::~WebTransformAnimationCurveImpl() {}
-
-blink::WebAnimationCurve::AnimationCurveType
-WebTransformAnimationCurveImpl::type() const {
- return WebAnimationCurve::AnimationCurveTypeTransform;
-}
-
-void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe) {
- add(keyframe, TimingFunctionTypeEase);
-}
-
-void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe,
- TimingFunctionType type) {
- const cc::TransformOperations& transform_operations =
- static_cast<const webkit::WebTransformOperationsImpl&>(keyframe.value())
- .AsTransformOperations();
- curve_->AddKeyframe(cc::TransformKeyframe::Create(
- keyframe.time(), transform_operations, CreateTimingFunction(type)));
-}
-
-void WebTransformAnimationCurveImpl::add(const WebTransformKeyframe& keyframe,
- double x1,
- double y1,
- double x2,
- double y2) {
- const cc::TransformOperations& transform_operations =
- static_cast<const webkit::WebTransformOperationsImpl&>(keyframe.value())
- .AsTransformOperations();
- curve_->AddKeyframe(cc::TransformKeyframe::Create(
- keyframe.time(),
- transform_operations,
- cc::CubicBezierTimingFunction::Create(x1, y1, x2, y2)
- .PassAs<cc::TimingFunction>()));
-}
-
-scoped_ptr<cc::AnimationCurve>
-WebTransformAnimationCurveImpl::CloneToAnimationCurve() const {
- return curve_->Clone();
-}
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_transform_animation_curve_impl.h b/chromium/webkit/renderer/compositor_bindings/web_transform_animation_curve_impl.h
deleted file mode 100644
index 56eb637287c..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_transform_animation_curve_impl.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_TRANSFORM_ANIMATION_CURVE_IMPL_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_TRANSFORM_ANIMATION_CURVE_IMPL_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "third_party/WebKit/public/platform/WebTransformAnimationCurve.h"
-#include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
-
-namespace cc {
-class AnimationCurve;
-class KeyframedTransformAnimationCurve;
-}
-
-namespace blink { class WebTransformKeyframe; }
-
-namespace webkit {
-
-class WebTransformAnimationCurveImpl
- : public blink::WebTransformAnimationCurve {
- public:
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebTransformAnimationCurveImpl();
- virtual ~WebTransformAnimationCurveImpl();
-
- // blink::WebAnimationCurve implementation.
- virtual AnimationCurveType type() const;
-
- // blink::WebTransformAnimationCurve implementation.
- virtual void add(const blink::WebTransformKeyframe& keyframe);
- virtual void add(const blink::WebTransformKeyframe& keyframe,
- TimingFunctionType type);
- virtual void add(const blink::WebTransformKeyframe& keyframe,
- double x1,
- double y1,
- double x2,
- double y2);
-
- scoped_ptr<cc::AnimationCurve> CloneToAnimationCurve() const;
-
- private:
- scoped_ptr<cc::KeyframedTransformAnimationCurve> curve_;
-
- DISALLOW_COPY_AND_ASSIGN(WebTransformAnimationCurveImpl);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_TRANSFORM_ANIMATION_CURVE_IMPL_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/web_transform_operations_impl.cc b/chromium/webkit/renderer/compositor_bindings/web_transform_operations_impl.cc
deleted file mode 100644
index 8201f5ae16e..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_transform_operations_impl.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2013 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 "webkit/renderer/compositor_bindings/web_transform_operations_impl.h"
-
-#include <algorithm>
-
-#include "ui/gfx/transform.h"
-
-namespace webkit {
-
-WebTransformOperationsImpl::WebTransformOperationsImpl() {}
-
-const cc::TransformOperations&
-WebTransformOperationsImpl::AsTransformOperations() const {
- return transform_operations_;
-}
-
-bool WebTransformOperationsImpl::canBlendWith(
- const blink::WebTransformOperations& other) const {
- const WebTransformOperationsImpl& other_impl =
- static_cast<const WebTransformOperationsImpl&>(other);
- return transform_operations_.CanBlendWith(other_impl.transform_operations_);
-}
-
-void WebTransformOperationsImpl::appendTranslate(double x, double y, double z) {
- transform_operations_.AppendTranslate(x, y, z);
-}
-
-void WebTransformOperationsImpl::appendRotate(double x,
- double y,
- double z,
- double degrees) {
- transform_operations_.AppendRotate(x, y, z, degrees);
-}
-
-void WebTransformOperationsImpl::appendScale(double x, double y, double z) {
- transform_operations_.AppendScale(x, y, z);
-}
-
-void WebTransformOperationsImpl::appendSkew(double x, double y) {
- transform_operations_.AppendSkew(x, y);
-}
-
-void WebTransformOperationsImpl::appendPerspective(double depth) {
- transform_operations_.AppendPerspective(depth);
-}
-
-void WebTransformOperationsImpl::appendMatrix(const SkMatrix44& matrix) {
- gfx::Transform transform(gfx::Transform::kSkipInitialization);
- transform.matrix() = matrix;
- transform_operations_.AppendMatrix(transform);
-}
-
-void WebTransformOperationsImpl::appendIdentity() {
- transform_operations_.AppendIdentity();
-}
-
-bool WebTransformOperationsImpl::isIdentity() const {
- return transform_operations_.IsIdentity();
-}
-
-WebTransformOperationsImpl::~WebTransformOperationsImpl() {}
-
-} // namespace webkit
diff --git a/chromium/webkit/renderer/compositor_bindings/web_transform_operations_impl.h b/chromium/webkit/renderer/compositor_bindings/web_transform_operations_impl.h
deleted file mode 100644
index 374cdb7111b..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/web_transform_operations_impl.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2013 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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_TRANSFORM_OPERATIONS_IMPL_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_TRANSFORM_OPERATIONS_IMPL_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "cc/animation/transform_operations.h"
-#include "third_party/WebKit/public/platform/WebTransformOperations.h"
-#include "webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h"
-
-namespace webkit {
-
-class WebTransformOperationsImpl : public blink::WebTransformOperations {
- public:
- WEBKIT_COMPOSITOR_BINDINGS_EXPORT WebTransformOperationsImpl();
- virtual ~WebTransformOperationsImpl();
-
- const cc::TransformOperations& AsTransformOperations() const;
-
- // Implementation of blink::WebTransformOperations methods
- virtual bool canBlendWith(const blink::WebTransformOperations& other) const;
- virtual void appendTranslate(double x, double y, double z);
- virtual void appendRotate(double x, double y, double z, double degrees);
- virtual void appendScale(double x, double y, double z);
- virtual void appendSkew(double x, double y);
- virtual void appendPerspective(double depth);
- virtual void appendMatrix(const SkMatrix44&);
- virtual void appendIdentity();
- virtual bool isIdentity() const;
-
- private:
- cc::TransformOperations transform_operations_;
-
- DISALLOW_COPY_AND_ASSIGN(WebTransformOperationsImpl);
-};
-
-} // namespace webkit
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEB_TRANSFORM_OPERATIONS_IMPL_H_
diff --git a/chromium/webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h b/chromium/webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h
deleted file mode 100644
index 77a698f0380..00000000000
--- a/chromium/webkit/renderer/compositor_bindings/webkit_compositor_bindings_export.h
+++ /dev/null
@@ -1,30 +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 WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEBKIT_COMPOSITOR_BINDINGS_EXPORT_H_
-#define WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEBKIT_COMPOSITOR_BINDINGS_EXPORT_H_
-
-#if defined(COMPONENT_BUILD)
-#if defined(WIN32)
-
-#if defined(WEBKIT_COMPOSITOR_BINDINGS_IMPLEMENTATION)
-#define WEBKIT_COMPOSITOR_BINDINGS_EXPORT __declspec(dllexport)
-#else
-#define WEBKIT_COMPOSITOR_BINDINGS_EXPORT __declspec(dllimport)
-#endif // defined(WEBKIT_COMPOSITOR_BINDINGS_IMPLEMENTATION)
-
-#else // defined(WIN32)
-#if defined(WEBKIT_COMPOSITOR_BINDINGS_IMPLEMENTATION)
-#define WEBKIT_COMPOSITOR_BINDINGS_EXPORT \
- __attribute__((visibility("default")))
-#else
-#define WEBKIT_COMPOSITOR_BINDINGS_EXPORT
-#endif
-#endif
-
-#else // defined(COMPONENT_BUILD)
-#define WEBKIT_COMPOSITOR_BINDINGS_EXPORT
-#endif
-
-#endif // WEBKIT_RENDERER_COMPOSITOR_BINDINGS_WEBKIT_COMPOSITOR_BINDINGS_EXPORT_H_
diff --git a/chromium/webkit/renderer/cpp_bound_class.cc b/chromium/webkit/renderer/cpp_bound_class.cc
deleted file mode 100644
index 6a652f48505..00000000000
--- a/chromium/webkit/renderer/cpp_bound_class.cc
+++ /dev/null
@@ -1,329 +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 file contains definitions for CppBoundClass
-
-// Here's the control flow of a JS method getting forwarded to a class.
-// - Something calls our NPObject with a function like "Invoke".
-// - CppNPObject's static invoke() function forwards it to its attached
-// CppBoundClass's Invoke() method.
-// - CppBoundClass has then overridden Invoke() to look up the function
-// name in its internal map of methods, and then calls the appropriate
-// method.
-
-#include "webkit/renderer/cpp_bound_class.h"
-
-#include "base/compiler_specific.h"
-#include "base/logging.h"
-#include "base/stl_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "third_party/WebKit/public/web/WebBindings.h"
-#include "third_party/WebKit/public/web/WebFrame.h"
-#include "third_party/WebKit/public/platform/WebString.h"
-
-using blink::WebBindings;
-using blink::WebFrame;
-
-namespace webkit_glue {
-
-namespace {
-
-class CppVariantPropertyCallback : public CppBoundClass::PropertyCallback {
- public:
- CppVariantPropertyCallback(CppVariant* value) : value_(value) { }
-
- virtual bool GetValue(CppVariant* value) OVERRIDE {
- value->Set(*value_);
- return true;
- }
- virtual bool SetValue(const CppVariant& value) OVERRIDE {
- value_->Set(value);
- return true;
- }
-
- private:
- CppVariant* value_;
-};
-
-class GetterPropertyCallback : public CppBoundClass::PropertyCallback {
-public:
- GetterPropertyCallback(const CppBoundClass::GetterCallback& callback)
- : callback_(callback) { }
-
- virtual bool GetValue(CppVariant* value) OVERRIDE {
- callback_.Run(value);
- return true;
- }
-
- virtual bool SetValue(const CppVariant& value) OVERRIDE {
- return false;
- }
-
-private:
- CppBoundClass::GetterCallback callback_;
-};
-
-}
-
-// Our special NPObject type. We extend an NPObject with a pointer to a
-// CppBoundClass, which is just a C++ interface that we forward all NPObject
-// callbacks to.
-struct CppNPObject {
- NPObject parent; // This must be the first field in the struct.
- CppBoundClass* bound_class;
-
- //
- // All following objects and functions are static, and just used to interface
- // with NPObject/NPClass.
- //
-
- // An NPClass associates static functions of CppNPObject with the
- // function pointers used by the JS runtime.
- static NPClass np_class_;
-
- // Allocate a new NPObject with the specified class.
- static NPObject* allocate(NPP npp, NPClass* aClass);
-
- // Free an object.
- static void deallocate(NPObject* obj);
-
- // Returns true if the C++ class associated with this NPObject exposes the
- // given property. Called by the JS runtime.
- static bool hasProperty(NPObject *obj, NPIdentifier ident);
-
- // Returns true if the C++ class associated with this NPObject exposes the
- // given method. Called by the JS runtime.
- static bool hasMethod(NPObject *obj, NPIdentifier ident);
-
- // If the given method is exposed by the C++ class associated with this
- // NPObject, invokes it with the given args and returns a result. Otherwise,
- // returns "undefined" (in the JavaScript sense). Called by the JS runtime.
- static bool invoke(NPObject *obj, NPIdentifier ident,
- const NPVariant *args, uint32_t arg_count,
- NPVariant *result);
-
- // If the given property is exposed by the C++ class associated with this
- // NPObject, returns its value. Otherwise, returns "undefined" (in the
- // JavaScript sense). Called by the JS runtime.
- static bool getProperty(NPObject *obj, NPIdentifier ident,
- NPVariant *result);
-
- // If the given property is exposed by the C++ class associated with this
- // NPObject, sets its value. Otherwise, does nothing. Called by the JS
- // runtime.
- static bool setProperty(NPObject *obj, NPIdentifier ident,
- const NPVariant *value);
-};
-
-// Build CppNPObject's static function pointers into an NPClass, for use
-// in constructing NPObjects for the C++ classes.
-NPClass CppNPObject::np_class_ = {
- NP_CLASS_STRUCT_VERSION,
- CppNPObject::allocate,
- CppNPObject::deallocate,
- /* NPInvalidateFunctionPtr */ NULL,
- CppNPObject::hasMethod,
- CppNPObject::invoke,
- /* NPInvokeDefaultFunctionPtr */ NULL,
- CppNPObject::hasProperty,
- CppNPObject::getProperty,
- CppNPObject::setProperty,
- /* NPRemovePropertyFunctionPtr */ NULL
-};
-
-/* static */ NPObject* CppNPObject::allocate(NPP npp, NPClass* aClass) {
- CppNPObject* obj = new CppNPObject;
- // obj->parent will be initialized by the NPObject code calling this.
- obj->bound_class = NULL;
- return &obj->parent;
-}
-
-/* static */ void CppNPObject::deallocate(NPObject* np_obj) {
- CppNPObject* obj = reinterpret_cast<CppNPObject*>(np_obj);
- delete obj;
-}
-
-/* static */ bool CppNPObject::hasMethod(NPObject* np_obj,
- NPIdentifier ident) {
- CppNPObject* obj = reinterpret_cast<CppNPObject*>(np_obj);
- return obj->bound_class->HasMethod(ident);
-}
-
-/* static */ bool CppNPObject::hasProperty(NPObject* np_obj,
- NPIdentifier ident) {
- CppNPObject* obj = reinterpret_cast<CppNPObject*>(np_obj);
- return obj->bound_class->HasProperty(ident);
-}
-
-/* static */ bool CppNPObject::invoke(NPObject* np_obj, NPIdentifier ident,
- const NPVariant* args, uint32_t arg_count,
- NPVariant* result) {
- CppNPObject* obj = reinterpret_cast<CppNPObject*>(np_obj);
- return obj->bound_class->Invoke(ident, args, arg_count, result);
-}
-
-/* static */ bool CppNPObject::getProperty(NPObject* np_obj,
- NPIdentifier ident,
- NPVariant* result) {
- CppNPObject* obj = reinterpret_cast<CppNPObject*>(np_obj);
- return obj->bound_class->GetProperty(ident, result);
-}
-
-/* static */ bool CppNPObject::setProperty(NPObject* np_obj,
- NPIdentifier ident,
- const NPVariant* value) {
- CppNPObject* obj = reinterpret_cast<CppNPObject*>(np_obj);
- return obj->bound_class->SetProperty(ident, value);
-}
-
-CppBoundClass::CppBoundClass() : bound_to_frame_(false), npp_(new NPP_t) {
- WebBindings::registerObjectOwner(npp_.get());
-}
-
-CppBoundClass::~CppBoundClass() {
- STLDeleteValues(&properties_);
-
- // TODO(wez): Remove once crrev.com/14019005 lands.
- if (bound_to_frame_)
- WebBindings::unregisterObject(NPVARIANT_TO_OBJECT(self_variant_));
-
- WebBindings::unregisterObjectOwner(npp_.get());
-}
-
-bool CppBoundClass::HasMethod(NPIdentifier ident) const {
- return (methods_.find(ident) != methods_.end());
-}
-
-bool CppBoundClass::HasProperty(NPIdentifier ident) const {
- return (properties_.find(ident) != properties_.end());
-}
-
-bool CppBoundClass::Invoke(NPIdentifier ident,
- const NPVariant* args,
- size_t arg_count,
- NPVariant* result) {
- MethodList::const_iterator method = methods_.find(ident);
- Callback callback;
- if (method == methods_.end()) {
- if (!fallback_callback_.is_null()) {
- callback = fallback_callback_;
- } else {
- VOID_TO_NPVARIANT(*result);
- return false;
- }
- } else {
- callback = method->second;
- }
-
- // Build a CppArgumentList argument vector from the NPVariants coming in.
- CppArgumentList cpp_args(arg_count);
- for (size_t i = 0; i < arg_count; i++)
- cpp_args[i].Set(args[i]);
-
- CppVariant cpp_result;
- callback.Run(cpp_args, &cpp_result);
-
- cpp_result.CopyToNPVariant(result);
- return true;
-}
-
-bool CppBoundClass::GetProperty(NPIdentifier ident, NPVariant* result) const {
- PropertyList::const_iterator callback = properties_.find(ident);
- if (callback == properties_.end()) {
- VOID_TO_NPVARIANT(*result);
- return false;
- }
-
- CppVariant cpp_value;
- if (!callback->second->GetValue(&cpp_value))
- return false;
- cpp_value.CopyToNPVariant(result);
- return true;
-}
-
-bool CppBoundClass::SetProperty(NPIdentifier ident,
- const NPVariant* value) {
- PropertyList::iterator callback = properties_.find(ident);
- if (callback == properties_.end())
- return false;
-
- CppVariant cpp_value;
- cpp_value.Set(*value);
- return (*callback).second->SetValue(cpp_value);
-}
-
-void CppBoundClass::BindCallback(const std::string& name,
- const Callback& callback) {
- NPIdentifier ident = WebBindings::getStringIdentifier(name.c_str());
- if (callback.is_null()) {
- methods_.erase(ident);
- return;
- }
-
- methods_[ident] = callback;
-}
-
-void CppBoundClass::BindGetterCallback(const std::string& name,
- const GetterCallback& callback) {
- PropertyCallback* property_callback = callback.is_null() ?
- NULL : new GetterPropertyCallback(callback);
-
- BindProperty(name, property_callback);
-}
-
-void CppBoundClass::BindProperty(const std::string& name, CppVariant* prop) {
- PropertyCallback* property_callback = prop == NULL ?
- NULL : new CppVariantPropertyCallback(prop);
-
- BindProperty(name, property_callback);
-}
-
-void CppBoundClass::BindProperty(const std::string& name,
- PropertyCallback* callback) {
- NPIdentifier ident = WebBindings::getStringIdentifier(name.c_str());
- PropertyList::iterator old_callback = properties_.find(ident);
- if (old_callback != properties_.end()) {
- delete old_callback->second;
- if (callback == NULL) {
- properties_.erase(old_callback);
- return;
- }
- }
-
- properties_[ident] = callback;
-}
-
-bool CppBoundClass::IsMethodRegistered(const std::string& name) const {
- NPIdentifier ident = WebBindings::getStringIdentifier(name.c_str());
- MethodList::const_iterator callback = methods_.find(ident);
- return (callback != methods_.end());
-}
-
-CppVariant* CppBoundClass::GetAsCppVariant() {
- if (!self_variant_.isObject()) {
- // Create an NPObject using our static NPClass. The first argument has type
- // NPP, but is only used to track object ownership, so passing this is fine.
- NPObject* np_obj = WebBindings::createObject(
- npp_.get(), &CppNPObject::np_class_);
- CppNPObject* obj = reinterpret_cast<CppNPObject*>(np_obj);
- obj->bound_class = this;
- self_variant_.Set(np_obj);
- WebBindings::releaseObject(np_obj); // CppVariant takes the reference.
- }
- DCHECK(self_variant_.isObject());
- return &self_variant_;
-}
-
-void CppBoundClass::BindToJavascript(WebFrame* frame,
- const std::string& classname) {
- // BindToWindowObject will take its own reference to the NPObject, and clean
- // up after itself. It will also (indirectly) register the object with V8,
- // against an owner pointer we supply, so we must register that as an owner,
- // and unregister when we teardown.
- frame->bindToWindowObject(ASCIIToUTF16(classname),
- NPVARIANT_TO_OBJECT(*GetAsCppVariant()));
- bound_to_frame_ = true;
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/renderer/cpp_bound_class.h b/chromium/webkit/renderer/cpp_bound_class.h
deleted file mode 100644
index 537a4c13879..00000000000
--- a/chromium/webkit/renderer/cpp_bound_class.h
+++ /dev/null
@@ -1,147 +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.
-
-/*
- CppBoundClass class:
- This base class serves as a parent for C++ classes designed to be bound to
- JavaScript objects.
-
- Subclasses should define the constructor to build the property and method
- lists needed to bind this class to a JS object. They should also declare
- and define member variables and methods to be exposed to JS through
- that object.
-
- See cpp_binding_example.{h|cc} for an example.
-*/
-
-#ifndef WEBKIT_RENDERER_CPP_BOUND_CLASS_H_
-#define WEBKIT_RENDERER_CPP_BOUND_CLASS_H_
-
-#include <map>
-#include <vector>
-
-#include "base/callback.h"
-#include "webkit/renderer/cpp_variant.h"
-#include "webkit/renderer/webkit_renderer_export.h"
-
-namespace blink {
-class WebFrame;
-}
-
-namespace webkit_glue {
-
-typedef std::vector<CppVariant> CppArgumentList;
-
-// CppBoundClass lets you map Javascript method calls and property accesses
-// directly to C++ method calls and CppVariant* variable access.
-class WEBKIT_RENDERER_EXPORT CppBoundClass {
- public:
- class PropertyCallback {
- public:
- virtual ~PropertyCallback() { }
-
- // Sets |value| to the value of the property. Returns false in case of
- // failure. |value| is always non-NULL.
- virtual bool GetValue(CppVariant* value) = 0;
-
- // sets the property value to |value|. Returns false in case of failure.
- virtual bool SetValue(const CppVariant& value) = 0;
- };
-
- // The constructor should call BindCallback, BindProperty, and
- // BindFallbackCallback as needed to set up the methods, properties, and
- // fallback method.
- CppBoundClass();
- virtual ~CppBoundClass();
-
- // Return a CppVariant representing this class, for use with BindProperty().
- // The variant type is guaranteed to be NPVariantType_Object.
- CppVariant* GetAsCppVariant();
-
- // Given a WebFrame, BindToJavascript builds the NPObject that will represent
- // this CppBoundClass object and binds it to the frame's window under the
- // given name. This should generally be called from the WebView delegate's
- // WindowObjectCleared(). This CppBoundClass object will be accessible to
- // JavaScript as window.<classname>. The owner of this CppBoundClass object is
- // responsible for keeping it around while the frame is alive, and for
- // destroying it afterwards.
- void BindToJavascript(blink::WebFrame* frame, const std::string& classname);
-
- // The type of callbacks.
- typedef base::Callback<void(const CppArgumentList&, CppVariant*)> Callback;
- typedef base::Callback<void(CppVariant*)> GetterCallback;
-
- // Used by a test. Returns true if a method with name |name| exists,
- // regardless of whether a fallback is registered.
- bool IsMethodRegistered(const std::string& name) const;
-
- protected:
- // Bind the Javascript method called |name| to the C++ callback |callback|.
- void BindCallback(const std::string& name, const Callback& callback);
-
- // Bind Javascript property |name| to the C++ getter callback |callback|.
- // This can be used to create read-only properties.
- void BindGetterCallback(const std::string& name,
- const GetterCallback& callback);
-
- // Bind the Javascript property called |name| to a CppVariant |prop|.
- void BindProperty(const std::string& name, CppVariant* prop);
-
- // Bind Javascript property called |name| to a PropertyCallback |callback|.
- // CppBoundClass assumes control over the life time of the |callback|.
- void BindProperty(const std::string& name, PropertyCallback* callback);
-
- // Set the fallback callback, which is called when when a callback is
- // invoked that isn't bound.
- // If it is NULL (its default value), a JavaScript exception is thrown in
- // that case (as normally expected). If non NULL, the fallback method is
- // invoked and the script continues its execution.
- // Passing NULL for |callback| clears out any existing binding.
- // It is used for tests and should probably only be used in such cases
- // as it may cause unexpected behaviors (a JavaScript object with a
- // fallback always returns true when checked for a method's
- // existence).
- void BindFallbackCallback(const Callback& fallback_callback) {
- fallback_callback_ = fallback_callback;
- }
-
- // Some fields are protected because some tests depend on accessing them,
- // but otherwise they should be considered private.
-
- typedef std::map<NPIdentifier, PropertyCallback*> PropertyList;
- typedef std::map<NPIdentifier, Callback> MethodList;
- // These maps associate names with property and method pointers to be
- // exposed to JavaScript.
- PropertyList properties_;
- MethodList methods_;
-
- // The callback gets invoked when a call is made to an nonexistent method.
- Callback fallback_callback_;
-
- private:
- // NPObject callbacks.
- friend struct CppNPObject;
- bool HasMethod(NPIdentifier ident) const;
- bool Invoke(NPIdentifier ident, const NPVariant* args, size_t arg_count,
- NPVariant* result);
- bool HasProperty(NPIdentifier ident) const;
- bool GetProperty(NPIdentifier ident, NPVariant* result) const;
- bool SetProperty(NPIdentifier ident, const NPVariant* value);
-
- // A lazily-initialized CppVariant representing this class. We retain 1
- // reference to this object, and it is released on deletion.
- CppVariant self_variant_;
-
- // TODO(wez): Remove once crrev.com/14019005 lands.
- bool bound_to_frame_;
-
- // Dummy NPP to use to register as owner for NPObjects.
- scoped_ptr<NPP_t> npp_;
-
- DISALLOW_COPY_AND_ASSIGN(CppBoundClass);
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_RENDERER_CPP_BOUND_CLASS_H_
diff --git a/chromium/webkit/renderer/cpp_variant.cc b/chromium/webkit/renderer/cpp_variant.cc
deleted file mode 100644
index 1438c388fee..00000000000
--- a/chromium/webkit/renderer/cpp_variant.cc
+++ /dev/null
@@ -1,268 +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 file contains definitions for CppVariant.
-
-#include <limits>
-#include "base/logging.h"
-#include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
-#include "base/strings/utf_string_conversions.h"
-#include "third_party/WebKit/public/web/WebBindings.h"
-#include "webkit/renderer/cpp_variant.h"
-
-using blink::WebBindings;
-
-namespace webkit_glue {
-
-CppVariant::CppVariant() {
- type = NPVariantType_Null;
-}
-
-// Note that Set() performs a deep copy, which is necessary to safely
-// call FreeData() on the value in the destructor.
-CppVariant::CppVariant(const CppVariant& original) {
- type = NPVariantType_Null;
- Set(original);
-}
-
-// See comment for copy constructor, above.
-CppVariant& CppVariant::operator=(const CppVariant& original) {
- if (&original != this)
- Set(original);
- return *this;
-}
-
-CppVariant::~CppVariant() {
- FreeData();
-}
-
-void CppVariant::FreeData() {
- WebBindings::releaseVariantValue(this);
-}
-
-bool CppVariant::isEqual(const CppVariant& other) const {
- if (type != other.type)
- return false;
-
- switch (type) {
- case NPVariantType_Bool: {
- return (value.boolValue == other.value.boolValue);
- }
- case NPVariantType_Int32: {
- return (value.intValue == other.value.intValue);
- }
- case NPVariantType_Double: {
- return (value.doubleValue == other.value.doubleValue);
- }
- case NPVariantType_String: {
- const NPString *this_value = &value.stringValue;
- const NPString *other_value = &other.value.stringValue;
- uint32_t len = this_value->UTF8Length;
- return (len == other_value->UTF8Length &&
- !strncmp(this_value->UTF8Characters, other_value->UTF8Characters,
- len));
- }
- case NPVariantType_Null:
- case NPVariantType_Void: {
- return true;
- }
- case NPVariantType_Object: {
- NPObject *this_value = value.objectValue;
- NPObject *other_value = other.value.objectValue;
- return (this_value->_class == other_value->_class &&
- this_value->referenceCount == other_value->referenceCount);
- }
- }
- return false;
-}
-
-void CppVariant::CopyToNPVariant(NPVariant* result) const {
- result->type = type;
- switch (type) {
- case NPVariantType_Bool:
- result->value.boolValue = value.boolValue;
- break;
- case NPVariantType_Int32:
- result->value.intValue = value.intValue;
- break;
- case NPVariantType_Double:
- result->value.doubleValue = value.doubleValue;
- break;
- case NPVariantType_String:
- WebBindings::initializeVariantWithStringCopy(result, &value.stringValue);
- break;
- case NPVariantType_Null:
- case NPVariantType_Void:
- // Nothing to set.
- break;
- case NPVariantType_Object:
- result->type = NPVariantType_Object;
- result->value.objectValue = WebBindings::retainObject(value.objectValue);
- break;
- }
-}
-
-void CppVariant::Set(const NPVariant& new_value) {
- FreeData();
- switch (new_value.type) {
- case NPVariantType_Bool:
- Set(new_value.value.boolValue);
- break;
- case NPVariantType_Int32:
- Set(new_value.value.intValue);
- break;
- case NPVariantType_Double:
- Set(new_value.value.doubleValue);
- break;
- case NPVariantType_String:
- Set(new_value.value.stringValue);
- break;
- case NPVariantType_Null:
- case NPVariantType_Void:
- type = new_value.type;
- break;
- case NPVariantType_Object:
- Set(new_value.value.objectValue);
- break;
- }
-}
-
-void CppVariant::SetNull() {
- FreeData();
- type = NPVariantType_Null;
-}
-
-void CppVariant::Set(bool new_value) {
- FreeData();
- type = NPVariantType_Bool;
- value.boolValue = new_value;
-}
-
-void CppVariant::Set(int32_t new_value) {
- FreeData();
- type = NPVariantType_Int32;
- value.intValue = new_value;
-}
-
-void CppVariant::Set(double new_value) {
- FreeData();
- type = NPVariantType_Double;
- value.doubleValue = new_value;
-}
-
-// The new_value must be a null-terminated string.
-void CppVariant::Set(const char* new_value) {
- FreeData();
- type = NPVariantType_String;
- NPString new_string = {new_value,
- static_cast<uint32_t>(strlen(new_value))};
- WebBindings::initializeVariantWithStringCopy(this, &new_string);
-}
-
-void CppVariant::Set(const std::string& new_value) {
- FreeData();
- type = NPVariantType_String;
- NPString new_string = {new_value.data(),
- static_cast<uint32_t>(new_value.size())};
- WebBindings::initializeVariantWithStringCopy(this, &new_string);
-}
-void CppVariant::Set(const NPString& new_value) {
- FreeData();
- type = NPVariantType_String;
- WebBindings::initializeVariantWithStringCopy(this, &new_value);
-}
-
-void CppVariant::Set(NPObject* new_value) {
- FreeData();
- type = NPVariantType_Object;
- value.objectValue = WebBindings::retainObject(new_value);
-}
-
-std::string CppVariant::ToString() const {
- DCHECK(isString());
- return std::string(value.stringValue.UTF8Characters,
- value.stringValue.UTF8Length);
-}
-
-int32_t CppVariant::ToInt32() const {
- if (isInt32()) {
- return value.intValue;
- } else if (isDouble()) {
- return static_cast<int32_t>(value.doubleValue);
- } else {
- NOTREACHED();
- return 0;
- }
-}
-
-double CppVariant::ToDouble() const {
- if (isInt32()) {
- return static_cast<double>(value.intValue);
- } else if (isDouble()) {
- return value.doubleValue;
- } else {
- NOTREACHED();
- return 0.0;
- }
-}
-
-bool CppVariant::ToBoolean() const {
- DCHECK(isBool());
- return value.boolValue;
-}
-
-std::vector<CppVariant> CppVariant::ToVector() const {
- DCHECK(isObject());
- std::vector<CppVariant> vector;
- NPObject* np_value = value.objectValue;
- NPIdentifier length_id = WebBindings::getStringIdentifier("length");
-
- if (WebBindings::hasProperty(NULL, np_value, length_id)) {
- CppVariant length_value;
- if (WebBindings::getProperty(NULL, np_value, length_id, &length_value)) {
- int length = 0;
- // The length is a double in some cases.
- if (NPVARIANT_IS_DOUBLE(length_value))
- length = static_cast<int>(NPVARIANT_TO_DOUBLE(length_value));
- else if (NPVARIANT_IS_INT32(length_value))
- length = NPVARIANT_TO_INT32(length_value);
- else
- NOTREACHED();
-
- // For sanity, only allow 60000 items.
- length = std::min(60000, length);
- for (int i = 0; i < length; ++i) {
- // Get each of the items.
- NPIdentifier index = WebBindings::getIntIdentifier(i);
- if (WebBindings::hasProperty(NULL, np_value, index)) {
- CppVariant index_value;
- if (WebBindings::getProperty(NULL, np_value, index, &index_value))
- vector.push_back(index_value);
- }
- }
- }
- } else {
- NOTREACHED();
- }
- return vector;
-}
-
-bool CppVariant::Invoke(const std::string& method, const CppVariant* args,
- uint32 arg_count, CppVariant& result) const {
- DCHECK(isObject());
- NPIdentifier method_name = WebBindings::getStringIdentifier(method.c_str());
- NPObject* np_object = value.objectValue;
- if (WebBindings::hasMethod(NULL, np_object, method_name)) {
- NPVariant r;
- bool status =
- WebBindings::invoke(NULL, np_object, method_name, args, arg_count, &r);
- result.Set(r);
- return status;
- } else {
- return false;
- }
-}
-
-} // namespace webkit_glue
diff --git a/chromium/webkit/renderer/cpp_variant.h b/chromium/webkit/renderer/cpp_variant.h
deleted file mode 100644
index b390402b00c..00000000000
--- a/chromium/webkit/renderer/cpp_variant.h
+++ /dev/null
@@ -1,116 +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 file contains the declaration for CppVariant, a type used by C++ classes
- that are to be bound to JavaScript objects.
-
- CppVariant exists primarily as an interface between C++ callers and the
- corresponding NPVariant type. CppVariant also provides a number of
- convenience constructors and accessors, so that the NPVariantType values
- don't need to be exposed, and a destructor to free any memory allocated for
- string values.
-
- For a usage example, see cpp_binding_example.{h|cc}.
-*/
-
-#ifndef WEBKIT_RENDERER_CPP_VARIANT_H__
-#define WEBKIT_RENDERER_CPP_VARIANT_H__
-
-#include <string>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "third_party/npapi/bindings/npruntime.h"
-#include "webkit/renderer/webkit_renderer_export.h"
-
-namespace webkit_glue {
-
-class WEBKIT_RENDERER_EXPORT CppVariant : public NPVariant {
- public:
- CppVariant();
- ~CppVariant();
- void SetNull();
- void Set(bool value);
- void Set(int32_t value);
- void Set(double value);
-
- // Note that setting a CppVariant to a string value involves copying the
- // string data, which must be freed with a call to FreeData() when the
- // CppVariant is set to a different value or is no longer needed. Normally
- // this is handled by the other Set() methods and by the destructor.
- void Set(const char* value); // Must be a null-terminated string.
- void Set(const std::string& value);
- void Set(const NPString& new_value);
- void Set(const NPVariant& new_value);
-
- // Note that setting a CppVariant to an NPObject involves ref-counting
- // the actual object. FreeData() should only be called if the CppVariant
- // is no longer needed. The other Set() methods handle this internally.
- // Also, the object's NPClass is expected to be a static object: neither
- // the NP runtime nor CPPVariant will ever free it.
- void Set(NPObject* new_value);
-
- // These three methods all perform deep copies of any string data. This
- // allows local CppVariants to be released by the destructor without
- // corrupting their sources. In performance-critical code, or when strings
- // are very long, avoid creating new CppVariants.
- // In case of NPObject as the data, the copying involves ref-counting
- // as opposed to deep-copying. The ref-counting ensures that sources don't
- // get corrupted when the copies get destroyed.
- void CopyToNPVariant(NPVariant* result) const;
- CppVariant& operator=(const CppVariant& original);
- CppVariant(const CppVariant& original);
-
- // Calls NPN_ReleaseVariantValue, which frees any string data
- // held by the object and sets its type to null.
- // In case of NPObject, the NPN_ReleaseVariantValue decrements
- // the ref-count (releases when ref-count becomes 0)
- void FreeData();
-
- // Compares this CppVariant's type and value to another's. They must be
- // identical in both type and value to be considered equal. For string and
- // object types, a deep comparison is performed; that is, the contents of the
- // strings, or the classes and refcounts of the objects, must be the same,
- // but they need not be the same pointers.
- bool isEqual(const CppVariant& other) const;
-
- // The value of a CppVariant may be read directly from its NPVariant (but
- // should only be set using one of the Set() methods above). Although the
- // type of a CppVariant is likewise public, it can be accessed through these
- // functions rather than directly if a caller wishes to avoid dependence on
- // the NPVariantType values.
- bool isBool() const { return (type == NPVariantType_Bool); }
- bool isInt32() const { return (type == NPVariantType_Int32); }
- bool isDouble() const { return (type == NPVariantType_Double); }
- bool isNumber() const { return (isInt32() || isDouble()); }
- bool isString() const { return (type == NPVariantType_String); }
- bool isVoid() const { return (type == NPVariantType_Void); }
- bool isNull() const { return (type == NPVariantType_Null); }
- bool isEmpty() const { return (isVoid() || isNull()); }
- bool isObject() const { return (type == NPVariantType_Object); }
-
- // Converters. The CppVariant must be of a type convertible to these values.
- // For example, ToInt32() works only if isNumber() is true.
- std::string ToString() const;
- int32_t ToInt32() const;
- double ToDouble() const;
- bool ToBoolean() const;
- // Returns a vector of CppVariant for the specified variant. This should only
- // be called on an Object. If the object has no "length" property an empty
- // vector is returned.
- std::vector<CppVariant> ToVector() const;
-
- // Invoke method of the given name on an object with the supplied arguments.
- // The first argument should be the object on which the method is to be
- // invoked. Returns whether the method was successfully invoked. If the
- // method was invoked successfully, any return value is stored in the
- // CppVariant specified by result.
- bool Invoke(const std::string& method, const CppVariant* args,
- uint32 arg_count, CppVariant& result) const;
-};
-
-} // namespace webkit_glue
-
-#endif // WEBKIT_RENDERER_CPP_VARIANT_H__
diff --git a/chromium/webkit/renderer/cpp_variant_unittest.cc b/chromium/webkit/renderer/cpp_variant_unittest.cc
deleted file mode 100644
index dc7d908c3c8..00000000000
--- a/chromium/webkit/renderer/cpp_variant_unittest.cc
+++ /dev/null
@@ -1,514 +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 <vector>
-
-#include "base/compiler_specific.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/strings/string_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/WebKit/public/web/WebBindings.h"
-#include "webkit/renderer/cpp_variant.h"
-
-using blink::WebBindings;
-using webkit_glue::CppVariant;
-
-// Creates a std::string from an NPVariant of string type. If the NPVariant
-// is not a string, empties the std::string.
-void MakeStdString(const NPVariant& np, std::string* std_string) {
- if (np.type == NPVariantType_String) {
- const char* chars =
- reinterpret_cast<const char*>(np.value.stringValue.UTF8Characters);
- (*std_string).assign(chars, np.value.stringValue.UTF8Length);
- } else {
- (*std_string).clear();
- }
-}
-
-// Verifies that the actual NPVariant is a string and that its value matches
-// the expected_str.
-void CheckString(const std::string& expected_str, const NPVariant& actual) {
- EXPECT_EQ(NPVariantType_String, actual.type);
- std::string actual_str;
- MakeStdString(actual, &actual_str);
- EXPECT_EQ(expected_str, actual_str);
-}
-
-// Verifies that both the actual and the expected NPVariants are strings and
-// that their values match.
-void CheckString(const NPVariant& expected, const NPVariant& actual) {
- EXPECT_EQ(NPVariantType_String, expected.type);
- std::string expected_str;
- MakeStdString(expected, &expected_str);
- CheckString(expected_str, actual);
-}
-
-int g_allocate_call_count = 0;
-int g_deallocate_call_count = 0;
-
-void CheckObject(const NPVariant& actual) {
- EXPECT_EQ(NPVariantType_Object, actual.type);
- EXPECT_TRUE(actual.value.objectValue);
- EXPECT_EQ(1U, actual.value.objectValue->referenceCount);
- EXPECT_EQ(1, g_allocate_call_count);
- EXPECT_EQ(0, g_deallocate_call_count);
-}
-
-NPObject* MockNPAllocate(NPP npp, NPClass* aClass) {
- // This is a mock allocate method that mimics the behavior
- // of WebBindings::createObject when allocate() is NULL
-
- ++g_allocate_call_count;
- // Ignore npp and NPClass
- return reinterpret_cast<NPObject*>(malloc(sizeof(NPObject)));
-}
-
-void MockNPDeallocate(NPObject* npobj) {
- // This is a mock deallocate method that mimics the behavior
- // of NPN_DeallocateObject when deallocate() is NULL
-
- ++g_deallocate_call_count;
- free(npobj);
-}
-
-static NPClass void_class = { NP_CLASS_STRUCT_VERSION,
- MockNPAllocate,
- MockNPDeallocate,
- 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
-class CppVariantTest : public testing::Test {
-public:
- CppVariantTest() : npp_(new struct _NPP) {}
- virtual ~CppVariantTest() {}
-
- virtual void SetUp() OVERRIDE {
- WebBindings::registerObjectOwner(npp_.get());
- }
-
- virtual void TearDown() OVERRIDE {
- WebBindings::unregisterObjectOwner(npp_.get());
- }
-
- struct _NPP* npp() { return npp_.get(); }
-
- NPObject* MakeVoidObject() {
- g_allocate_call_count = 0;
- g_deallocate_call_count = 0;
- return WebBindings::createObject(npp_.get(), &void_class);
- }
-
-private:
- scoped_ptr<struct _NPP> npp_;
-};
-
-TEST_F(CppVariantTest, NewVariantHasNullType) {
- CppVariant value;
- EXPECT_EQ(NPVariantType_Null, value.type);
-}
-
-TEST_F(CppVariantTest, SetNullSetsType) {
- CppVariant value;
- value.Set(17);
- value.SetNull();
- EXPECT_EQ(NPVariantType_Null, value.type);
-}
-
-TEST_F(CppVariantTest, CopyConstructorDoesDeepCopy) {
- CppVariant source;
- source.Set("test string");
- CppVariant dest = source;
- EXPECT_EQ(NPVariantType_String, dest.type);
- EXPECT_EQ(NPVariantType_String, source.type);
-
- // Ensure that the string was copied, not just the pointer.
- EXPECT_NE(source.value.stringValue.UTF8Characters,
- dest.value.stringValue.UTF8Characters);
-
- CheckString(source, dest);
-}
-
-TEST_F(CppVariantTest, CopyConstructorIncrementsRefCount) {
- CppVariant source;
- NPObject *object = MakeVoidObject();
- source.Set(object);
- // 2 references so far.
- EXPECT_EQ(2U, source.value.objectValue->referenceCount);
-
- CppVariant dest = source;
- EXPECT_EQ(3U, dest.value.objectValue->referenceCount);
- EXPECT_EQ(1, g_allocate_call_count);
- WebBindings::releaseObject(object);
- source.SetNull();
- CheckObject(dest);
-}
-
-TEST_F(CppVariantTest, AssignmentDoesDeepCopy) {
- CppVariant source;
- source.Set("test string");
- CppVariant dest;
- dest = source;
- EXPECT_EQ(NPVariantType_String, dest.type);
- EXPECT_EQ(NPVariantType_String, source.type);
-
- // Ensure that the string was copied, not just the pointer.
- EXPECT_NE(source.value.stringValue.UTF8Characters,
- dest.value.stringValue.UTF8Characters);
-
- CheckString(source, dest);
-}
-
-TEST_F(CppVariantTest, AssignmentIncrementsRefCount) {
- CppVariant source;
- NPObject *object = MakeVoidObject();
- source.Set(object);
- // 2 references so far.
- EXPECT_EQ(2U, source.value.objectValue->referenceCount);
-
- CppVariant dest;
- dest = source;
- EXPECT_EQ(3U, dest.value.objectValue->referenceCount);
- EXPECT_EQ(1, g_allocate_call_count);
-
- WebBindings::releaseObject(object);
- source.SetNull();
- CheckObject(dest);
-}
-
-TEST_F(CppVariantTest, DestroyingCopyDoesNotCorruptSource) {
- CppVariant source;
- source.Set("test string");
- std::string before;
- MakeStdString(source, &before);
- {
- CppVariant dest = source;
- }
- CheckString(before, source);
-
- NPObject *object = MakeVoidObject();
- source.Set(object);
- {
- CppVariant dest2 = source;
- }
- WebBindings::releaseObject(object);
- CheckObject(source);
-}
-
-TEST_F(CppVariantTest, CopiesTypeAndValueToNPVariant) {
- NPVariant np;
- CppVariant cpp;
-
- cpp.Set(true);
- cpp.CopyToNPVariant(&np);
- EXPECT_EQ(cpp.type, np.type);
- EXPECT_EQ(cpp.value.boolValue, np.value.boolValue);
- WebBindings::releaseVariantValue(&np);
-
- cpp.Set(17);
- cpp.CopyToNPVariant(&np);
- EXPECT_EQ(cpp.type, np.type);
- EXPECT_EQ(cpp.value.intValue, np.value.intValue);
- WebBindings::releaseVariantValue(&np);
-
- cpp.Set(3.1415);
- cpp.CopyToNPVariant(&np);
- EXPECT_EQ(cpp.type, np.type);
- EXPECT_EQ(cpp.value.doubleValue, np.value.doubleValue);
- WebBindings::releaseVariantValue(&np);
-
- cpp.Set("test value");
- cpp.CopyToNPVariant(&np);
- CheckString("test value", np);
- WebBindings::releaseVariantValue(&np);
-
- cpp.SetNull();
- cpp.CopyToNPVariant(&np);
- EXPECT_EQ(cpp.type, np.type);
- WebBindings::releaseVariantValue(&np);
-
- NPObject *object = MakeVoidObject();
- cpp.Set(object);
- cpp.CopyToNPVariant(&np);
- WebBindings::releaseObject(object);
- cpp.SetNull();
- CheckObject(np);
- WebBindings::releaseVariantValue(&np);
-}
-
-TEST_F(CppVariantTest, SetsTypeAndValueFromNPVariant) {
- NPVariant np;
- CppVariant cpp;
-
- VOID_TO_NPVARIANT(np);
- cpp.Set(np);
- EXPECT_EQ(np.type, cpp.type);
- WebBindings::releaseVariantValue(&np);
-
- NULL_TO_NPVARIANT(np);
- cpp.Set(np);
- EXPECT_EQ(np.type, cpp.type);
- WebBindings::releaseVariantValue(&np);
-
- BOOLEAN_TO_NPVARIANT(true, np);
- cpp.Set(np);
- EXPECT_EQ(np.type, cpp.type);
- EXPECT_EQ(np.value.boolValue, cpp.value.boolValue);
- WebBindings::releaseVariantValue(&np);
-
- INT32_TO_NPVARIANT(15, np);
- cpp.Set(np);
- EXPECT_EQ(np.type, cpp.type);
- EXPECT_EQ(np.value.intValue, cpp.value.intValue);
- WebBindings::releaseVariantValue(&np);
-
- DOUBLE_TO_NPVARIANT(2.71828, np);
- cpp.Set(np);
- EXPECT_EQ(np.type, cpp.type);
- EXPECT_EQ(np.value.doubleValue, cpp.value.doubleValue);
- WebBindings::releaseVariantValue(&np);
-
- NPString np_ascii_str = { "1st test value",
- static_cast<uint32_t>(strlen("1st test value")) };
- WebBindings::initializeVariantWithStringCopy(&np, &np_ascii_str);
- cpp.Set(np);
- CheckString("1st test value", cpp);
- WebBindings::releaseVariantValue(&np);
-
- // Test characters represented in 2/3/4 bytes in UTF-8
- // Greek alpha, Chinese number 1 (horizontal bar),
- // Deseret letter (similar to 'O')
- NPString np_intl_str = { "\xce\xb1\xe4\xb8\x80\xf0\x90\x90\x84",
- static_cast<uint32_t>(strlen(
- "\xce\xb1\xe4\xb8\x80\xf0\x90\x90\x84")) };
- WebBindings::initializeVariantWithStringCopy(&np, &np_intl_str);
- cpp.Set(np);
- CheckString("\xce\xb1\xe4\xb8\x80\xf0\x90\x90\x84", cpp);
- WebBindings::releaseVariantValue(&np);
-
- NPObject *obj = MakeVoidObject();
- OBJECT_TO_NPVARIANT(obj, np); // Doesn't make a copy.
- cpp.Set(np);
- // Use this or WebBindings::releaseObject but NOT both.
- WebBindings::releaseVariantValue(&np);
- CheckObject(cpp);
-}
-
-TEST_F(CppVariantTest, SetsSimpleTypesAndValues) {
- CppVariant cpp;
- cpp.Set(true);
- EXPECT_EQ(NPVariantType_Bool, cpp.type);
- EXPECT_TRUE(cpp.value.boolValue);
-
- cpp.Set(5);
- EXPECT_EQ(NPVariantType_Int32, cpp.type);
- EXPECT_EQ(5, cpp.value.intValue);
-
- cpp.Set(1.234);
- EXPECT_EQ(NPVariantType_Double, cpp.type);
- EXPECT_EQ(1.234, cpp.value.doubleValue);
-
- // C string
- cpp.Set("1st test string");
- CheckString("1st test string", cpp);
-
- // std::string
- std::string source("std test string");
- cpp.Set(source);
- CheckString("std test string", cpp);
-
- // NPString
- NPString np_ascii_str = { "test NPString",
- static_cast<uint32_t>(strlen("test NPString")) };
- cpp.Set(np_ascii_str);
- std::string expected("test NPString");
- CheckString(expected, cpp);
-
- // Test characters represented in 2/3/4 bytes in UTF-8
- // Greek alpha, Chinese number 1 (horizontal bar),
- // Deseret letter (similar to 'O')
- NPString np_intl_str = { "\xce\xb1\xe4\xb8\x80\xf0\x90\x90\x84",
- static_cast<uint32_t>(strlen(
- "\xce\xb1\xe4\xb8\x80\xf0\x90\x90\x84")) };
- cpp.Set(np_intl_str);
- expected = std::string("\xce\xb1\xe4\xb8\x80\xf0\x90\x90\x84");
- CheckString(expected, cpp);
-
- NPObject* obj = MakeVoidObject();
- cpp.Set(obj);
- WebBindings::releaseObject(obj);
- CheckObject(cpp);
-}
-
-TEST_F(CppVariantTest, FreeDataSetsToVoid) {
- CppVariant cpp;
- EXPECT_EQ(NPVariantType_Null, cpp.type);
- cpp.Set(12);
- EXPECT_EQ(NPVariantType_Int32, cpp.type);
- cpp.FreeData();
- EXPECT_EQ(NPVariantType_Void, cpp.type);
-}
-
-TEST_F(CppVariantTest, FreeDataReleasesObject) {
- CppVariant cpp;
- NPObject* object = MakeVoidObject();
- cpp.Set(object);
- EXPECT_EQ(2U, object->referenceCount);
- cpp.FreeData();
- EXPECT_EQ(1U, object->referenceCount);
- EXPECT_EQ(0, g_deallocate_call_count);
-
- cpp.Set(object);
- WebBindings::releaseObject(object);
- EXPECT_EQ(0, g_deallocate_call_count);
- cpp.FreeData();
- EXPECT_EQ(1, g_deallocate_call_count);
-}
-
-TEST_F(CppVariantTest, IsTypeFunctionsWork) {
- CppVariant cpp;
- // These should not happen in practice, since voids are not supported
- // This test must be first since it just clobbers internal data without
- // releasing.
- VOID_TO_NPVARIANT(cpp);
- EXPECT_FALSE(cpp.isBool());
- EXPECT_FALSE(cpp.isInt32());
- EXPECT_FALSE(cpp.isDouble());
- EXPECT_FALSE(cpp.isNumber());
- EXPECT_FALSE(cpp.isString());
- EXPECT_TRUE(cpp.isVoid());
- EXPECT_FALSE(cpp.isNull());
- EXPECT_TRUE(cpp.isEmpty());
-
- cpp.Set(true);
- EXPECT_TRUE(cpp.isBool());
- EXPECT_FALSE(cpp.isInt32());
- EXPECT_FALSE(cpp.isDouble());
- EXPECT_FALSE(cpp.isNumber());
- EXPECT_FALSE(cpp.isString());
- EXPECT_FALSE(cpp.isVoid());
- EXPECT_FALSE(cpp.isNull());
- EXPECT_FALSE(cpp.isEmpty());
- EXPECT_FALSE(cpp.isObject());
-
- cpp.Set(12);
- EXPECT_FALSE(cpp.isBool());
- EXPECT_TRUE(cpp.isInt32());
- EXPECT_FALSE(cpp.isDouble());
- EXPECT_TRUE(cpp.isNumber());
- EXPECT_FALSE(cpp.isString());
- EXPECT_FALSE(cpp.isVoid());
- EXPECT_FALSE(cpp.isNull());
- EXPECT_FALSE(cpp.isEmpty());
- EXPECT_FALSE(cpp.isObject());
-
- cpp.Set(3.1415);
- EXPECT_FALSE(cpp.isBool());
- EXPECT_FALSE(cpp.isInt32());
- EXPECT_TRUE(cpp.isDouble());
- EXPECT_TRUE(cpp.isNumber());
- EXPECT_FALSE(cpp.isString());
- EXPECT_FALSE(cpp.isVoid());
- EXPECT_FALSE(cpp.isNull());
- EXPECT_FALSE(cpp.isEmpty());
- EXPECT_FALSE(cpp.isObject());
-
- cpp.Set("a string");
- EXPECT_FALSE(cpp.isBool());
- EXPECT_FALSE(cpp.isInt32());
- EXPECT_FALSE(cpp.isDouble());
- EXPECT_FALSE(cpp.isNumber());
- EXPECT_TRUE(cpp.isString());
- EXPECT_FALSE(cpp.isVoid());
- EXPECT_FALSE(cpp.isNull());
- EXPECT_FALSE(cpp.isEmpty());
- EXPECT_FALSE(cpp.isObject());
-
- cpp.SetNull();
- EXPECT_FALSE(cpp.isBool());
- EXPECT_FALSE(cpp.isInt32());
- EXPECT_FALSE(cpp.isDouble());
- EXPECT_FALSE(cpp.isNumber());
- EXPECT_FALSE(cpp.isString());
- EXPECT_FALSE(cpp.isVoid());
- EXPECT_TRUE(cpp.isNull());
- EXPECT_TRUE(cpp.isEmpty());
- EXPECT_FALSE(cpp.isObject());
-
- NPObject *obj = MakeVoidObject();
- cpp.Set(obj);
- EXPECT_FALSE(cpp.isBool());
- EXPECT_FALSE(cpp.isInt32());
- EXPECT_FALSE(cpp.isDouble());
- EXPECT_FALSE(cpp.isNumber());
- EXPECT_FALSE(cpp.isString());
- EXPECT_FALSE(cpp.isVoid());
- EXPECT_FALSE(cpp.isNull());
- EXPECT_FALSE(cpp.isEmpty());
- EXPECT_TRUE(cpp.isObject());
- WebBindings::releaseObject(obj);
- CheckObject(cpp);
-}
-
-bool MockNPHasPropertyFunction(NPObject *npobj, NPIdentifier name) {
- return true;
-}
-
-bool MockNPGetPropertyFunction(NPObject *npobj, NPIdentifier name,
- NPVariant *result) {
- if (WebBindings::getStringIdentifier("length") == name) {
- DOUBLE_TO_NPVARIANT(4, *result);
- } else if (WebBindings::getIntIdentifier(0) == name) {
- DOUBLE_TO_NPVARIANT(0, *result);
- } else if (WebBindings::getIntIdentifier(1) == name) {
- BOOLEAN_TO_NPVARIANT(true, *result);
- } else if (WebBindings::getIntIdentifier(2) == name) {
- NULL_TO_NPVARIANT(*result);
- } else if (WebBindings::getIntIdentifier(3) == name) {
- const char* s = "string";
- size_t length = strlen(s);
- char* mem = static_cast<char*>(malloc(length + 1));
- base::strlcpy(mem, s, length + 1);
- STRINGZ_TO_NPVARIANT(mem, *result);
- }
-
- return true;
-}
-
-TEST_F(CppVariantTest, ToVector) {
- NPClass array_like_class = {
- NP_CLASS_STRUCT_VERSION,
- 0, // NPAllocateFunctionPtr allocate;
- 0, // NPDeallocateFunctionPtr deallocate;
- 0, // NPInvalidateFunctionPtr invalidate;
- 0, // NPHasMethodFunctionPtr hasMethod;
- 0, // NPInvokeFunctionPtr invoke;
- 0, // NPInvokeDefaultFunctionPtr invokeDefault;
- MockNPHasPropertyFunction, // NPHasPropertyFunctionPtr hasProperty;
- MockNPGetPropertyFunction, // NPGetPropertyFunctionPtr getProperty;
- 0, // NPSetPropertyFunctionPtr setProperty;
- 0, // NPRemovePropertyFunctionPtr removeProperty;
- 0, // NPEnumerationFunctionPtr enumerate;
- 0 // NPConstructFunctionPtr construct;
- };
-
- NPObject* obj = WebBindings::createObject(npp(), &array_like_class);
-
- CppVariant cpp;
- cpp.Set(obj);
-
- std::vector<CppVariant> cpp_vector = cpp.ToVector();
- EXPECT_EQ(4u, cpp_vector.size());
-
- EXPECT_TRUE(cpp_vector[0].isDouble());
- EXPECT_EQ(0, cpp_vector[0].ToDouble());
-
- EXPECT_TRUE(cpp_vector[1].isBool());
- EXPECT_EQ(true, cpp_vector[1].ToBoolean());
-
- EXPECT_TRUE(cpp_vector[2].isNull());
-
- EXPECT_TRUE(cpp_vector[3].isString());
- CheckString("string", cpp_vector[3]);
-
- WebBindings::releaseObject(obj);
-}
diff --git a/chromium/webkit/renderer/webkit_renderer.gyp b/chromium/webkit/renderer/webkit_renderer.gyp
deleted file mode 100644
index b120a0a14da..00000000000
--- a/chromium/webkit/renderer/webkit_renderer.gyp
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2013 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.
-
-{
- 'targets': [
- {
- 'target_name': 'webkit_renderer',
- 'type': '<(component)',
- 'variables': { 'enable_wexit_time_destructors': 1, },
- 'defines': [
- 'WEBKIT_RENDERER_IMPLEMENTATION',
- ],
- 'dependencies': [
- '<(DEPTH)/base/base.gyp:base',
- '<(DEPTH)/base/base.gyp:base_i18n',
- '<(DEPTH)/net/net.gyp:net',
- '<(DEPTH)/skia/skia.gyp:skia',
- '<(DEPTH)/third_party/WebKit/public/blink.gyp:blink',
- '<(DEPTH)/third_party/icu/icu.gyp:icuuc',
- '<(DEPTH)/ui/gfx/gfx.gyp:gfx',
- '<(DEPTH)/url/url.gyp:url_lib',
- '<(DEPTH)/webkit/common/webkit_common.gyp:webkit_common',
- ],
- 'sources': [
- 'cpp_bound_class.cc',
- 'cpp_bound_class.h',
- 'cpp_variant.cc',
- 'cpp_variant.h',
- 'webkit_renderer_export.h',
- ],
- },
- ],
-}
diff --git a/chromium/webkit/renderer/webkit_renderer_export.h b/chromium/webkit/renderer/webkit_renderer_export.h
deleted file mode 100644
index 376ac429753..00000000000
--- a/chromium/webkit/renderer/webkit_renderer_export.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2013 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 WEBKIT_RENDERER_WEBKIT_RENDERER_EXPORT_H_
-#define WEBKIT_RENDERER_WEBKIT_RENDERER_EXPORT_H_
-
-#if defined(COMPONENT_BUILD)
-#if defined(WIN32)
-
-#if defined(WEBKIT_RENDERER_IMPLEMENTATION)
-#define WEBKIT_RENDERER_EXPORT __declspec(dllexport)
-#else
-#define WEBKIT_RENDERER_EXPORT __declspec(dllimport)
-#endif // defined(WEBKIT_RENDERER_IMPLEMENTATION)
-
-#else // defined(WIN32)
-#if defined(WEBKIT_RENDERER_IMPLEMENTATION)
-#define WEBKIT_RENDERER_EXPORT __attribute__((visibility("default")))
-#else
-#define WEBKIT_RENDERER_EXPORT
-#endif
-#endif
-
-#else // defined(COMPONENT_BUILD)
-#define WEBKIT_RENDERER_EXPORT
-#endif
-
-#endif // WEBKIT_RENDERER_WEBKIT_RENDERER_EXPORT_H_
diff --git a/chromium/webkit/storage_browser.gyp b/chromium/webkit/storage_browser.gyp
index c474c5605be..6f510d9bb2b 100644
--- a/chromium/webkit/storage_browser.gyp
+++ b/chromium/webkit/storage_browser.gyp
@@ -8,6 +8,7 @@
},
'targets': [
{
+ # GN version: //webkit/browser:storage
'target_name': 'webkit_storage_browser',
'type': '<(component)',
'variables': { 'enable_wexit_time_destructors': 1, },
@@ -42,8 +43,6 @@
'browser/appcache/appcache_histograms.h',
'browser/appcache/appcache_host.cc',
'browser/appcache/appcache_host.h',
- 'browser/appcache/appcache_interceptor.cc',
- 'browser/appcache/appcache_interceptor.h',
'browser/appcache/appcache_policy.h',
'browser/appcache/appcache_quota_client.cc',
'browser/appcache/appcache_quota_client.h',
@@ -51,8 +50,9 @@
'browser/appcache/appcache_request_handler.h',
'browser/appcache/appcache_response.cc',
'browser/appcache/appcache_response.h',
- 'browser/appcache/appcache_service.cc',
'browser/appcache/appcache_service.h',
+ 'browser/appcache/appcache_service_impl.cc',
+ 'browser/appcache/appcache_service_impl.h',
'browser/appcache/appcache_storage.cc',
'browser/appcache/appcache_storage.h',
'browser/appcache/appcache_storage_impl.cc',
@@ -65,18 +65,16 @@
'browser/appcache/appcache_url_request_job.h',
'browser/appcache/manifest_parser.cc',
'browser/appcache/manifest_parser.h',
- 'browser/appcache/view_appcache_internals_job.h',
- 'browser/appcache/view_appcache_internals_job.cc',
'browser/blob/blob_data_handle.cc',
'browser/blob/blob_data_handle.h',
'browser/blob/blob_storage_context.cc',
'browser/blob/blob_storage_context.h',
- 'browser/blob/blob_storage_host.cc',
- 'browser/blob/blob_storage_host.h',
'browser/blob/blob_url_request_job.cc',
'browser/blob/blob_url_request_job.h',
'browser/blob/blob_url_request_job_factory.cc',
'browser/blob/blob_url_request_job_factory.h',
+ 'browser/blob/file_stream_reader.cc',
+ 'browser/blob/file_stream_reader.h',
'browser/blob/local_file_stream_reader.cc',
'browser/blob/local_file_stream_reader.h',
'browser/blob/view_blob_internals_job.cc',
@@ -191,20 +189,24 @@
'browser/fileapi/timed_task_helper.h',
'browser/fileapi/transient_file_util.cc',
'browser/fileapi/transient_file_util.h',
- 'browser/fileapi/upload_file_system_file_element_reader.cc',
- 'browser/fileapi/upload_file_system_file_element_reader.h',
'browser/quota/quota_callbacks.h',
'browser/quota/quota_client.h',
'browser/quota/quota_database.cc',
'browser/quota/quota_database.h',
'browser/quota/quota_manager.cc',
'browser/quota/quota_manager.h',
+ 'browser/quota/quota_manager_proxy.cc',
+ 'browser/quota/quota_manager_proxy.h',
'browser/quota/quota_task.cc',
'browser/quota/quota_task.h',
'browser/quota/quota_temporary_storage_evictor.cc',
'browser/quota/quota_temporary_storage_evictor.h',
'browser/quota/special_storage_policy.cc',
'browser/quota/special_storage_policy.h',
+ 'browser/quota/storage_monitor.cc',
+ 'browser/quota/storage_monitor.h',
+ 'browser/quota/storage_observer.cc',
+ 'browser/quota/storage_observer.h',
'browser/quota/usage_tracker.cc',
'browser/quota/usage_tracker.h',
],
@@ -226,6 +228,7 @@
],
},
{
+ # GN version: //webkit/browser:dump_file_system
'target_name': 'dump_file_system',
'type': 'executable',
'sources': [
diff --git a/chromium/webkit/storage_common.gyp b/chromium/webkit/storage_common.gyp
index 64178c2e1b3..f52af1e2a4c 100644
--- a/chromium/webkit/storage_common.gyp
+++ b/chromium/webkit/storage_common.gyp
@@ -8,6 +8,7 @@
},
'targets': [
{
+ # GN version: //webkit/common:storage
'target_name': 'webkit_storage_common',
'type': '<(component)',
'variables': { 'enable_wexit_time_destructors': 1, },
@@ -32,7 +33,7 @@
'common/database/database_connections.cc',
'common/database/database_connections.h',
'common/database/database_identifier.cc',
- 'common/database/database_identifier.cc',
+ 'common/database/database_identifier.h',
'common/fileapi/directory_entry.cc',
'common/fileapi/directory_entry.h',
'common/fileapi/file_system_info.cc',
diff --git a/chromium/webkit/tools/layout_tests/test_expectations.txt b/chromium/webkit/tools/layout_tests/test_expectations.txt
index e855b3d483f..4229c65b1e0 100644
--- a/chromium/webkit/tools/layout_tests/test_expectations.txt
+++ b/chromium/webkit/tools/layout_tests/test_expectations.txt
@@ -30,5 +30,3 @@
# src/third_party/WebKit/LayoutTests/TestExpectations . Right?)
#
# EVERYTHING BELOW THIS LINE WILL BE DELETED AT EVERY WEBKIT DEPS ROLL
-
-Bug(dcarney) http/tests/security/naked-global-object.html [ NeedsManualRebaseline ]
diff --git a/chromium/webkit/tools/layout_tests/test_expectations_asan.txt b/chromium/webkit/tools/layout_tests/test_expectations_asan.txt
deleted file mode 100644
index 434b07a39a6..00000000000
--- a/chromium/webkit/tools/layout_tests/test_expectations_asan.txt
+++ /dev/null
@@ -1,71 +0,0 @@
-# This file is used for tests that only need to be suppressed on
-# the Chromium WebKit ASAN bots. We keep these here because the memory
-# sheriffs are not usually WebKit committers; we can create an upstream
-# file if this turns out to not be true.
-
-# NULL deref in libflashplayer.so, http://crbug.com/145940
-# ==12527== ERROR: AddressSanitizer: SEGV on unknown address 0x7f628058b38b
-# AddressSanitizer can not provide additional info.
-# #0 0x7f62d3d34cf0 in ?? ??:0
-# #1 0x1fec5c261c15ff
-crbug.com/145940 [ Linux ] fast/images/embed-does-not-propagate-dimensions-to-object-ancestor.html [ Skip ]
-crbug.com/145940 [ Linux ] fast/loader/loadInProgress.html [ Skip ]
-crbug.com/145940 [ Linux ] fast/replaced/border-radius-clip.html [ Skip ]
-crbug.com/145940 [ Linux ] plugins/crash-restoring-plugin-page-from-page-cache.html [ Skip ]
-crbug.com/145940 [ Linux ] plugins/iframe-shims.html [ Skip ]
-
-
-# Use-after-free in NPP_SetWindow, http://crbug.com/144118
-# ==15959== ERROR: AddressSanitizer: heap-use-after-free on address 0x7f6c187f8481
-# READ of size 1 at 0x7f6c187f8481 thread T0
-# #0 0x7f6c1aec6c7a in NPP_SetWindow
-crbug.com/144118 [ Linux ] plugins/destroy-on-setwindow.html [ Skip ]
-
-
-# Use-after-free in NPP_DestroyStream, http://crbug.com/166932
-# ==17332== ERROR: AddressSanitizer: heap-use-after-free on address 0x7f48e8a05a58
-# WRITE of size 1 at 0x7f48e8a05a58 thread T0
-# #0 0x7f48eb06f7c5 in DocumentOpenInDestroyStream::NPP_DestroyStream
-crbug.com/166932 [ Linux ] plugins/embed-attributes-setting.html [ Skip ]
-crbug.com/166932 [ Linux ] plugins/embed-attributes-style.html [ Skip ]
-crbug.com/166932 [ Linux ] plugins/embed-inside-object.html [ Skip ]
-crbug.com/166932 [ Linux ] plugins/embed-prefers-plugins-for-images.html [ Skip ]
-crbug.com/166932 [ Linux ] plugins/form-value.html [ Skip ]
-crbug.com/166932 [ Linux ] plugins/fullscreen-plugins-dont-reload.html [ Skip ]
-crbug.com/166932 [ Linux ] plugins/get-empty-url.html [ Skip ]
-crbug.com/166932 [ Linux ] plugins/get-file-url.html [ Skip ]
-
-
-# NULL deref in HandleURLRequestInternal, http://crbug.com/142301
-# ==17931== ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000
-# AddressSanitizer can not provide additional info.
-# #0 0x2a054b2 in webkit::npapi::WebPluginImpl::HandleURLRequestInternal
-crbug.com/142301 [ Linux ] plugins/get-url-notify-with-url-that-fails-to-load.html [ Skip ]
-
-# Crash in fast/js/string-replacement-outofmemory.html, http://crbug.com/173366
-# ==5971== ERROR: AddressSanitizer: SEGV on unknown address 0x0000bbadbeef
-# AddressSanitizer can not provide additional info.
-# #0 0x8c2ee4 in WebCore::reportFatalErrorInMainThread
-crbug.com/173366 [ Linux ] fast/js/string-replacement-outofmemory.html [ Skip ]
-
-# Crash in fast/speechsynthesis/speech-synthesis-cancel.html:
-# ==10454==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000008 (pc 0x00000558b918 sp 0x7fff3153dcf0 bp 0x7fff3153dcf0 T0)
-# AddressSanitizer can not provide additional info.
-# #0 0x558b917 in WebCore::PlatformSpeechSynthesisUtterance::client() const /mnt/data/b/build/slave/WebKit_Linux_ASAN/build/src/out/Release/../../third_party/WebKit/Source/core/platform/PlatformSpeechSynthesisUtterance.h:71:0
-crbug.com/250520 [ Linux ] fast/speechsynthesis/speech-synthesis-cancel.html [ Crash ]
-
-# These tests consistently fail on slow bots.
-crbug.com/231357 [ Linux ] virtual/softwarecompositing/video-page-visibility.html [ ImageOnlyFailure ]
-crbug.com/231357 [ Linux ] compositing/video-page-visibility.html [ ImageOnlyFailure ]
-crbug.com/14885 [ Linux ] fast/js/JSON-stringify.html [ Failure ]
-
-# These tests flakily timeout on the ASAN bot
-crbug.com/247466 [ Linux ] inspector/debugger/live-edit-breakpoints.html [ Pass Timeout ]
-crbug.com/247466 [ Linux ] inspector/debugger/reveal-not-skipped.html [ Pass Timeout ]
-crbug.com/247466 [ Linux ] inspector/debugger/script-formatter-breakpoints.html [ Pass Timeout ]
-crbug.com/247466 [ Linux ] inspector/editor/text-editor-word-jumps.html [ Pass Timeout ]
-crbug.com/247466 [ Linux ] inspector/profiler/heap-snapshot-summary-sorting-fields.html [ Pass Timeout ]
-
-# These have been failing since at least chrome r203901, blink r151723 (no memory errors, just text failure):
-crbug.com/231357 [ Linux ] editing/execCommand/switch-list-type-with-orphaned-li.html [ Failure ]
-crbug.com/231357 [ Linux ] perf/mouse-event.html [ Crash ]
diff --git a/chromium/webkit/tools/layout_tests/test_expectations_w3c.txt b/chromium/webkit/tools/layout_tests/test_expectations_w3c.txt
new file mode 100644
index 00000000000..36a81e9ef88
--- /dev/null
+++ b/chromium/webkit/tools/layout_tests/test_expectations_w3c.txt
@@ -0,0 +1,14 @@
+# This file is reserved for temporary suppressions needed while importing
+# tests from the W3C until they can be moved to
+# src/third_party/WebKit/LayoutTests/TestExpectations and dealt with.
+#
+
+#
+# Expectations to delete on the next W3C roll.
+#
+
+
+#
+# Expectations to upstream into blink after the next W3C roll has rolled into Blink.
+#
+
diff --git a/chromium/webkit/webkit_resources.gyp b/chromium/webkit/webkit_resources.gyp
index 8ce53a72b8b..f86317a8890 100644
--- a/chromium/webkit/webkit_resources.gyp
+++ b/chromium/webkit/webkit_resources.gyp
@@ -5,6 +5,7 @@
{
'targets': [
{
+ # GN version: //webkit:resources
'target_name': 'webkit_resources',
'type': 'none',
'variables': {
@@ -32,6 +33,7 @@
},
},
{
+ # GN version: //webkit:strings
'target_name': 'webkit_strings',
'type': 'none',
'variables': {