From f55d19fce5e8521d5e269739e2e0e553dcb61bf2 Mon Sep 17 00:00:00 2001 From: pilgrim Date: Wed, 3 Sep 2014 17:05:24 -0700 Subject: Move fileapi-related files from webkit/common/ to storage/common/ and set up redirect headers BUG=338338 TBR=darin@chromium.org Review URL: https://codereview.chromium.org/524983002 Cr-Commit-Position: refs/heads/master@{#293228} --- android_webview/native/webview_native.gyp | 2 +- build/whitespace_file.txt | 2 + chrome/browser/BUILD.gn | 3 +- chrome/browser/extensions/BUILD.gn | 2 +- chrome/browser/ui/BUILD.gn | 3 +- chrome/chrome_browser.gypi | 2 +- chrome/chrome_browser_chromeos.gypi | 2 +- chrome/chrome_browser_extensions.gypi | 2 +- chrome/chrome_browser_ui.gypi | 2 +- chrome/renderer/BUILD.gn | 2 +- content/browser/BUILD.gn | 3 +- content/child/BUILD.gn | 2 +- content/common/BUILD.gn | 3 +- content/content_browser.gypi | 3 +- content/content_child.gypi | 2 +- content/content_common.gypi | 3 +- content/content_renderer.gypi | 2 +- content/content_tests.gypi | 6 +- content/renderer/BUILD.gn | 3 +- content/test/BUILD.gn | 4 +- storage/DEPS | 5 + storage/OWNERS | 6 + storage/common/BUILD.gn | 46 ++ storage/common/blob/blob_data.cc | 63 +++ storage/common/blob/blob_data.h | 98 +++++ storage/common/blob/scoped_file.cc | 85 ++++ storage/common/blob/scoped_file.h | 94 ++++ storage/common/blob/shareable_file_reference.cc | 121 +++++ storage/common/blob/shareable_file_reference.h | 74 ++++ storage/common/data_element.cc | 49 +++ storage/common/data_element.h | 127 ++++++ storage/common/database/database_connections.cc | 175 ++++++++ storage/common/database/database_connections.h | 99 +++++ storage/common/database/database_identifier.cc | 145 ++++++ storage/common/database/database_identifier.h | 54 +++ storage/common/fileapi/OWNERS | 2 + storage/common/fileapi/directory_entry.cc | 21 + storage/common/fileapi/directory_entry.h | 38 ++ storage/common/fileapi/file_system_info.cc | 22 + storage/common/fileapi/file_system_info.h | 33 ++ storage/common/fileapi/file_system_mount_option.h | 37 ++ storage/common/fileapi/file_system_types.h | 137 ++++++ storage/common/fileapi/file_system_util.cc | 511 ++++++++++++++++++++++ storage/common/fileapi/file_system_util.h | 182 ++++++++ storage/common/quota/quota_status_code.cc | 29 ++ storage/common/quota/quota_status_code.h | 28 ++ storage/common/quota/quota_types.h | 29 ++ storage/common/storage_common_export.h | 29 ++ storage/storage_common.gyp | 52 +++ webkit/DEPS | 1 + webkit/browser/BUILD.gn | 6 +- webkit/common/BUILD.gn | 62 --- webkit/common/blob/blob_data.cc | 63 --- webkit/common/blob/blob_data.h | 97 +--- webkit/common/blob/scoped_file.cc | 85 ---- webkit/common/blob/scoped_file.h | 93 +--- webkit/common/blob/shareable_file_reference.cc | 119 ----- webkit/common/blob/shareable_file_reference.h | 73 +--- webkit/common/data_element.cc | 49 --- webkit/common/data_element.h | 126 +----- webkit/common/database/database_connections.cc | 175 -------- webkit/common/database/database_connections.h | 98 +---- webkit/common/database/database_identifier.cc | 145 ------ webkit/common/database/database_identifier.h | 53 +-- webkit/common/fileapi/OWNERS | 2 - webkit/common/fileapi/directory_entry.cc | 21 - webkit/common/fileapi/directory_entry.h | 37 +- webkit/common/fileapi/file_system_info.cc | 22 - webkit/common/fileapi/file_system_info.h | 32 +- webkit/common/fileapi/file_system_mount_option.h | 36 +- webkit/common/fileapi/file_system_types.h | 136 +----- webkit/common/fileapi/file_system_util.cc | 511 ---------------------- webkit/common/fileapi/file_system_util.h | 181 +------- webkit/common/quota/quota_status_code.cc | 29 -- webkit/common/quota/quota_status_code.h | 27 +- webkit/common/quota/quota_types.h | 28 +- webkit/common/storage_common_export.h | 29 -- webkit/common/webkit_common.gyp | 29 -- webkit/storage_browser.gyp | 5 +- webkit/storage_common.gyp | 51 --- 80 files changed, 2447 insertions(+), 2418 deletions(-) create mode 100644 storage/DEPS create mode 100644 storage/OWNERS create mode 100644 storage/common/BUILD.gn create mode 100644 storage/common/blob/blob_data.cc create mode 100644 storage/common/blob/blob_data.h create mode 100644 storage/common/blob/scoped_file.cc create mode 100644 storage/common/blob/scoped_file.h create mode 100644 storage/common/blob/shareable_file_reference.cc create mode 100644 storage/common/blob/shareable_file_reference.h create mode 100644 storage/common/data_element.cc create mode 100644 storage/common/data_element.h create mode 100644 storage/common/database/database_connections.cc create mode 100644 storage/common/database/database_connections.h create mode 100644 storage/common/database/database_identifier.cc create mode 100644 storage/common/database/database_identifier.h create mode 100644 storage/common/fileapi/OWNERS create mode 100644 storage/common/fileapi/directory_entry.cc create mode 100644 storage/common/fileapi/directory_entry.h create mode 100644 storage/common/fileapi/file_system_info.cc create mode 100644 storage/common/fileapi/file_system_info.h create mode 100644 storage/common/fileapi/file_system_mount_option.h create mode 100644 storage/common/fileapi/file_system_types.h create mode 100644 storage/common/fileapi/file_system_util.cc create mode 100644 storage/common/fileapi/file_system_util.h create mode 100644 storage/common/quota/quota_status_code.cc create mode 100644 storage/common/quota/quota_status_code.h create mode 100644 storage/common/quota/quota_types.h create mode 100644 storage/common/storage_common_export.h create mode 100644 storage/storage_common.gyp delete mode 100644 webkit/common/BUILD.gn delete mode 100644 webkit/common/blob/blob_data.cc delete mode 100644 webkit/common/blob/scoped_file.cc delete mode 100644 webkit/common/blob/shareable_file_reference.cc delete mode 100644 webkit/common/data_element.cc delete mode 100644 webkit/common/database/database_connections.cc delete mode 100644 webkit/common/database/database_identifier.cc delete mode 100644 webkit/common/fileapi/OWNERS delete mode 100644 webkit/common/fileapi/directory_entry.cc delete mode 100644 webkit/common/fileapi/file_system_info.cc delete mode 100644 webkit/common/fileapi/file_system_util.cc delete mode 100644 webkit/common/quota/quota_status_code.cc delete mode 100644 webkit/common/storage_common_export.h delete mode 100644 webkit/common/webkit_common.gyp delete mode 100644 webkit/storage_common.gyp diff --git a/android_webview/native/webview_native.gyp b/android_webview/native/webview_native.gyp index 60e09ad..790d40e 100644 --- a/android_webview/native/webview_native.gyp +++ b/android_webview/native/webview_native.gyp @@ -19,11 +19,11 @@ '../../media/media.gyp:player_android', '../../net/net.gyp:net', '../../skia/skia.gyp:skia', + '../../storage/storage_common.gyp:storage_common', '../../ui/base/ui_base.gyp:ui_base', '../../ui/gfx/gfx.gyp:gfx', '../../ui/gfx/gfx.gyp:gfx_geometry', '../../webkit/storage_browser.gyp:storage', - '../../webkit/storage_common.gyp:storage_common', '../../third_party/boringssl/boringssl.gyp:boringssl', 'android_webview_native_jni', ], diff --git a/build/whitespace_file.txt b/build/whitespace_file.txt index b4ab204..6155a3f 100644 --- a/build/whitespace_file.txt +++ b/build/whitespace_file.txt @@ -135,3 +135,5 @@ Suddenly Domo-Kun found itself in a room filled with dazzling mirrors. A herd of wild gits appears! Time for CQ :D And one more for sizes.py... + +Sigh. diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 443c700..325ed73 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn @@ -166,6 +166,7 @@ static_library("browser") { "//mojo/system", "//net:extras", "//net:net_with_v8", + "//storage/common", "//third_party/WebKit/public:resources", "//third_party/expat", "//third_party/leveldatabase", @@ -180,8 +181,6 @@ static_library("browser") { "//ui/web_dialogs", "//v8", "//webkit/browser:storage", - "//webkit/common", - "//webkit/common:storage_common", ## TODO(tonyg): Remove this dependency (crbug.com/280157). #"../testing/perf/perf_test.gyp:*", TODO(GYP) ] diff --git a/chrome/browser/extensions/BUILD.gn b/chrome/browser/extensions/BUILD.gn index 58f750e..8beed8a 100644 --- a/chrome/browser/extensions/BUILD.gn +++ b/chrome/browser/extensions/BUILD.gn @@ -57,6 +57,7 @@ static_library("extensions") { "//extensions/strings", "//net", "//skia", + "//storage/common", "//sync", "//third_party/WebKit/public:resources", "//third_party/cacheinvalidation", @@ -72,7 +73,6 @@ static_library("extensions") { "//ui/strings", "//url", "//webkit/browser:storage", - "//webkit/common:storage_common", ] forward_dependent_configs_from = [ diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index 02d0744..077de8c 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn @@ -108,8 +108,7 @@ static_library("ui") { "//ui/web_dialogs", "//v8", "//webkit/browser:storage", - "//webkit/common", - "//webkit/common:storage_common", + "//storage/common", ] # TODO(GYP) #'defines': [ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index d12924b..c23766e 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2926,6 +2926,7 @@ '../mojo/mojo_base.gyp:mojo_system_impl', '../net/net.gyp:net_extras', '../net/net.gyp:net_with_v8', + '../storage/storage_common.gyp:storage_common', # TODO(tonyg): Remove this dependency (crbug.com/280157). '../testing/perf/perf_test.gyp:*', '../third_party/expat/expat.gyp:expat', @@ -2940,7 +2941,6 @@ '../ui/web_dialogs/web_dialogs.gyp:web_dialogs', '../v8/tools/gyp/v8.gyp:v8', '../webkit/storage_browser.gyp:storage', - '../webkit/storage_common.gyp:storage_common', ], 'sources': [ '<@(chrome_browser_non_ios_sources)', diff --git a/chrome/chrome_browser_chromeos.gypi b/chrome/chrome_browser_chromeos.gypi index b7e75cf..dea5a27 100644 --- a/chrome/chrome_browser_chromeos.gypi +++ b/chrome/chrome_browser_chromeos.gypi @@ -73,6 +73,7 @@ '../net/net.gyp:net', '../ppapi/ppapi_internal.gyp:ppapi_ipc', # For PpapiMsg_LoadPlugin '../skia/skia.gyp:skia', + '../storage/storage_common.gyp:storage_common', '../sync/sync.gyp:sync', '../third_party/adobe/flash/flash_player.gyp:flapper_version_h', '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation', @@ -106,7 +107,6 @@ '../url/url.gyp:url_lib', '../v8/tools/gyp/v8.gyp:v8', '../webkit/storage_browser.gyp:storage', - '../webkit/storage_common.gyp:storage_common', 'chrome_resources.gyp:chrome_strings', ], 'defines': [ diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi index 5c9b97e..fd82487 100644 --- a/chrome/chrome_browser_extensions.gypi +++ b/chrome/chrome_browser_extensions.gypi @@ -965,6 +965,7 @@ '../extensions/extensions_strings.gyp:extensions_strings', '../net/net.gyp:net', '../skia/skia.gyp:skia', + '../storage/storage_common.gyp:storage_common', '../sync/sync.gyp:sync', '../third_party/cacheinvalidation/cacheinvalidation.gyp:cacheinvalidation', '../third_party/icu/icu.gyp:icui18n', @@ -980,7 +981,6 @@ '../ui/strings/ui_strings.gyp:ui_strings', '../url/url.gyp:url_lib', '../webkit/storage_browser.gyp:storage', - '../webkit/storage_common.gyp:storage_common', ], 'include_dirs': [ '..', diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index 0d0723a..4a5d16c 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -2627,6 +2627,7 @@ '../media/media.gyp:media', '../mojo/mojo_base.gyp:mojo_system_impl', '../net/net.gyp:net_with_v8', + '../storage/storage_common.gyp:storage_common', '../third_party/expat/expat.gyp:expat', '../third_party/leveldatabase/leveldatabase.gyp:leveldatabase', '../third_party/libjingle/libjingle.gyp:libjingle', @@ -2637,7 +2638,6 @@ '../ui/web_dialogs/web_dialogs.gyp:web_dialogs', '../v8/tools/gyp/v8.gyp:v8', '../webkit/storage_browser.gyp:storage', - '../webkit/storage_common.gyp:storage_common', ], 'defines': [ '<@(nacl_defines)', diff --git a/chrome/renderer/BUILD.gn b/chrome/renderer/BUILD.gn index dbee281..8aec953 100644 --- a/chrome/renderer/BUILD.gn +++ b/chrome/renderer/BUILD.gn @@ -65,7 +65,7 @@ static_library("renderer") { "//ui/surface", "//v8:v8", "//webkit/child", - "//webkit/common", + "//storage/common", ] if (enable_nacl) { diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn index 85798bf..26e1f05 100644 --- a/content/browser/BUILD.gn +++ b/content/browser/BUILD.gn @@ -98,6 +98,7 @@ source_set("browser") { "//mojo/public/interfaces/application", "//mojo/public/js/bindings", "//net:http_server", + "//storage/common", "//third_party/WebKit/public:resources", "//third_party/angle:commit_id", "//third_party/icu", @@ -106,8 +107,6 @@ source_set("browser") { "//ui/resources", "//ui/surface", "//webkit/browser:storage", - "//webkit/common", - "//webkit/common:storage_common", ] } diff --git a/content/child/BUILD.gn b/content/child/BUILD.gn index d9b9a5b..e078d3a 100644 --- a/content/child/BUILD.gn +++ b/content/child/BUILD.gn @@ -94,7 +94,7 @@ source_set("child") { "//third_party/WebKit/public:resources", "//third_party/npapi", "//webkit/child", - "//webkit/common", + "//storage/common", ] } diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn index 40639a7..e41d84c 100644 --- a/content/common/BUILD.gn +++ b/content/common/BUILD.gn @@ -64,8 +64,7 @@ source_set("common") { "//third_party/WebKit/public:blink", "//ui/gl", "//webkit/browser:storage", - "//webkit/common", - "//webkit/common:storage_common", + "//storage/common", "//webkit/common/gpu", ] } diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 7006e40..85a65e9 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -1597,12 +1597,11 @@ '../mojo/mojo_base.gyp:mojo_cpp_bindings', '../mojo/mojo_base.gyp:mojo_js_bindings', '../net/net.gyp:http_server', + '../storage/storage_common.gyp:storage_common', '../third_party/angle/src/build_angle.gyp:commit_id', '../third_party/leveldatabase/leveldatabase.gyp:leveldatabase', '../ui/surface/surface.gyp:surface', - '../webkit/common/webkit_common.gyp:webkit_common', '../webkit/storage_browser.gyp:storage', - '../webkit/storage_common.gyp:storage_common', ], }], ['enable_printing!=0', { diff --git a/content/content_child.gypi b/content/content_child.gypi index c61d6ff..5da4bc3 100644 --- a/content/content_child.gypi +++ b/content/content_child.gypi @@ -324,11 +324,11 @@ 'dependencies': [ 'app/resources/content_resources.gyp:content_resources', 'app/strings/content_strings.gyp:content_strings', + '../storage/storage_common.gyp:storage_common', '../third_party/WebKit/public/blink.gyp:blink', '../third_party/WebKit/public/blink_resources.gyp:blink_resources', '../third_party/npapi/npapi.gyp:npapi', '../webkit/child/webkit_child.gyp:webkit_child', - '../webkit/common/webkit_common.gyp:webkit_common', ], }], ['use_aura==1', { diff --git a/content/content_common.gypi b/content/content_common.gypi index 889d754..cfd4abe 100644 --- a/content/content_common.gypi +++ b/content/content_common.gypi @@ -564,12 +564,11 @@ '../mojo/mojo_base.gyp:mojo_cpp_bindings', '../mojo/mojo_base.gyp:mojo_environment_chromium', '../mojo/mojo_base.gyp:mojo_system_impl', + '../storage/storage_common.gyp:storage_common', '../third_party/WebKit/public/blink.gyp:blink', '../ui/gl/gl.gyp:gl', '../webkit/common/gpu/webkit_gpu.gyp:webkit_gpu', - '../webkit/common/webkit_common.gyp:webkit_common', '../webkit/storage_browser.gyp:storage', - '../webkit/storage_common.gyp:storage_common', ], 'actions': [ { diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi index ce6e115..2b74476 100644 --- a/content/content_renderer.gypi +++ b/content/content_renderer.gypi @@ -18,6 +18,7 @@ '../mojo/mojo_base.gyp:mojo_js_bindings_lib', '../net/net.gyp:net', '../skia/skia.gyp:skia', + '../storage/storage_common.gyp:storage_common', '../third_party/WebKit/public/blink.gyp:blink', '../third_party/icu/icu.gyp:icui18n', '../third_party/icu/icu.gyp:icuuc', @@ -32,7 +33,6 @@ '../ui/surface/surface.gyp:surface', '../v8/tools/gyp/v8.gyp:v8', '../webkit/common/gpu/webkit_gpu.gyp:webkit_gpu', - '../webkit/storage_common.gyp:storage_common', ], 'include_dirs': [ '..', diff --git a/content/content_tests.gypi b/content/content_tests.gypi index 69675f4..2b928e8 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -198,6 +198,7 @@ 'dependencies': [ '../net/net.gyp:net_test_support', '../skia/skia.gyp:skia', + '../storage/storage_common.gyp:storage_common', '../testing/gmock.gyp:gmock', '../testing/gtest.gyp:gtest', '../ui/accessibility/accessibility.gyp:ax_gen', @@ -210,7 +211,6 @@ '../ui/gfx/gfx.gyp:gfx_test_support', '../ui/resources/ui_resources.gyp:ui_resources', '../url/url.gyp:url_lib', - '../webkit/common/webkit_common.gyp:webkit_common', 'browser/speech/proto/speech_proto.gyp:speech_proto', 'content.gyp:content_app_both', 'content.gyp:content_browser', @@ -277,13 +277,13 @@ '../ppapi/ppapi_internal.gyp:ppapi_proxy', '../ppapi/ppapi_internal.gyp:ppapi_shared', '../ppapi/ppapi_internal.gyp:ppapi_unittest_shared', + '../storage/storage_common.gyp:storage_common', '../third_party/WebKit/public/blink.gyp:blink', '../ui/compositor/compositor.gyp:compositor_test_support', '../ui/surface/surface.gyp:surface', '../v8/tools/gyp/v8.gyp:v8', '../webkit/common/gpu/webkit_gpu.gyp:webkit_gpu', '../webkit/storage_browser.gyp:storage', - '../webkit/storage_common.gyp:storage_common', ], 'export_dependent_settings': [ '../third_party/WebKit/public/blink.gyp:blink', @@ -759,6 +759,7 @@ '../ipc/ipc.gyp:test_support_ipc', '../media/media.gyp:media_test_support', '../media/media.gyp:shared_memory_support', + '../storage/storage_common.gyp:storage_common', '../third_party/WebKit/public/blink.gyp:blink', '../third_party/icu/icu.gyp:icui18n', '../third_party/icu/icu.gyp:icuuc', @@ -766,7 +767,6 @@ '../third_party/libjingle/libjingle.gyp:libjingle', '../ui/gl/gl.gyp:gl', '../webkit/storage_browser.gyp:storage', - '../webkit/storage_common.gyp:storage_common', ], }], ['enable_plugins==0', { diff --git a/content/renderer/BUILD.gn b/content/renderer/BUILD.gn index f84e57a..c74c5ba 100644 --- a/content/renderer/BUILD.gn +++ b/content/renderer/BUILD.gn @@ -35,6 +35,7 @@ source_set("renderer") { "//mojo/public/interfaces/application", "//net", "//skia", + "//storage/common", "//third_party/icu", "//third_party/libjingle", "//third_party/npapi", @@ -46,8 +47,6 @@ source_set("renderer") { "//ui/surface", "//v8", "//webkit/child", - "//webkit/common", - "//webkit/common:storage_common", "//webkit/common/gpu", ] diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn index 8218f3e..ba398b7 100644 --- a/content/test/BUILD.gn +++ b/content/test/BUILD.gn @@ -32,7 +32,7 @@ static_library("test_support") { "//ui/gfx:test_support", "//ui/resources", "//url", - "//webkit/common", + "//storage/common", ] if (!is_ios) { @@ -53,13 +53,13 @@ static_library("test_support") { "//ppapi:ppapi_proxy", "//ppapi:ppapi_shared", "//ppapi:ppapi_unittest_shared", + "//storage/common", "//third_party/WebKit/public:blink", "//ui/surface", "//v8", "//webkit/child", "//webkit/common/gpu", "//webkit/browser:storage", - "//webkit/common:storage_common", ] forward_dependent_configs_from = [ diff --git a/storage/DEPS b/storage/DEPS new file mode 100644 index 0000000..8e3d4fd --- /dev/null +++ b/storage/DEPS @@ -0,0 +1,5 @@ +include_rules = [ + "+net", + "+sql", + "+third_party/WebKit/public/platform", +] diff --git a/storage/OWNERS b/storage/OWNERS new file mode 100644 index 0000000..a1327dd --- /dev/null +++ b/storage/OWNERS @@ -0,0 +1,6 @@ +darin@chromium.org +jamesr@chromium.org +kinuko@chromium.org +michaeln@chromium.org +piman@chromium.org +danakj@chromium.org diff --git a/storage/common/BUILD.gn b/storage/common/BUILD.gn new file mode 100644 index 0000000..5212a92 --- /dev/null +++ b/storage/common/BUILD.gn @@ -0,0 +1,46 @@ +# 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: storage/storage_common.gyp:storage_common +component("common") { + output_name = "storage_common" + sources = [ + "data_element.cc", + "data_element.h", + "storage_common_export.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 = [ "STORAGE_COMMON_IMPLEMENTATION" ] + if (is_win) { + cflags = [ "/wd4267" ] # TODO(jschuh): fix size_t to int truncations. + } + + deps = [ + "//base", + "//base/third_party/dynamic_annotations", + "//net", + "//url", + ] +} diff --git a/storage/common/blob/blob_data.cc b/storage/common/blob/blob_data.cc new file mode 100644 index 0000000..23f73e3 --- /dev/null +++ b/storage/common/blob/blob_data.cc @@ -0,0 +1,63 @@ +// 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 "storage/common/blob/blob_data.h" + +#include "base/logging.h" +#include "base/strings/sys_string_conversions.h" +#include "base/strings/utf_string_conversions.h" +#include "base/time/time.h" + +namespace storage { + +BlobData::BlobData() {} +BlobData::BlobData(const std::string& uuid) + : uuid_(uuid) { +} + +BlobData::~BlobData() {} + +void BlobData::AppendData(const char* data, size_t length) { + DCHECK(length > 0); + items_.push_back(Item()); + items_.back().SetToBytes(data, length); +} + +void BlobData::AppendFile(const base::FilePath& file_path, + uint64 offset, uint64 length, + const base::Time& expected_modification_time) { + DCHECK(length > 0); + items_.push_back(Item()); + items_.back().SetToFilePathRange(file_path, offset, length, + expected_modification_time); +} + +void BlobData::AppendBlob(const std::string& uuid, + uint64 offset, uint64 length) { + DCHECK_GT(length, 0ul); + items_.push_back(Item()); + items_.back().SetToBlobRange(uuid, offset, length); +} + +void BlobData::AppendFileSystemFile( + const GURL& url, uint64 offset, + uint64 length, + const base::Time& expected_modification_time) { + DCHECK(length > 0); + items_.push_back(Item()); + items_.back().SetToFileSystemUrlRange(url, offset, length, + expected_modification_time); +} + +int64 BlobData::GetMemoryUsage() const { + int64 memory = 0; + for (std::vector::const_iterator iter = items_.begin(); + iter != items_.end(); ++iter) { + if (iter->type() == Item::TYPE_BYTES) + memory += iter->length(); + } + return memory; +} + +} // namespace storage diff --git a/storage/common/blob/blob_data.h b/storage/common/blob/blob_data.h new file mode 100644 index 0000000..2f48546 --- /dev/null +++ b/storage/common/blob/blob_data.h @@ -0,0 +1,98 @@ +// 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 STORAGE_COMMON_BLOB_BLOB_DATA_H_ +#define STORAGE_COMMON_BLOB_BLOB_DATA_H_ + +#include +#include + +#include "base/basictypes.h" +#include "base/files/file_path.h" +#include "base/memory/ref_counted.h" +#include "base/time/time.h" +#include "storage/common/blob/shareable_file_reference.h" +#include "storage/common/data_element.h" +#include "storage/common/storage_common_export.h" +#include "url/gurl.h" + +namespace storage { + +class STORAGE_COMMON_EXPORT BlobData + : public base::RefCounted { + public: + typedef storage::DataElement Item; + + // TODO(michaeln): remove the empty ctor when we fully transition to uuids. + BlobData(); + explicit BlobData(const std::string& uuid); + + void AppendData(const std::string& data) { + AppendData(data.c_str(), data.size()); + } + + void AppendData(const char* data, size_t length); + + void AppendFile(const base::FilePath& file_path, uint64 offset, uint64 length, + const base::Time& expected_modification_time); + void AppendBlob(const std::string& uuid, uint64 offset, uint64 length); + void AppendFileSystemFile(const GURL& url, uint64 offset, uint64 length, + const base::Time& expected_modification_time); + + void AttachShareableFileReference(ShareableFileReference* reference) { + shareable_files_.push_back(reference); + } + + const std::string& uuid() const { return uuid_; } + const std::vector& items() const { return items_; } + const std::string& content_type() const { return content_type_; } + void set_content_type(const std::string& content_type) { + content_type_ = content_type; + } + + const std::string& content_disposition() const { + return content_disposition_; + } + void set_content_disposition(const std::string& content_disposition) { + content_disposition_ = content_disposition; + } + + int64 GetMemoryUsage() const; + + private: + friend class base::RefCounted; + virtual ~BlobData(); + + std::string uuid_; + std::string content_type_; + std::string content_disposition_; + std::vector items_; + std::vector > shareable_files_; + + DISALLOW_COPY_AND_ASSIGN(BlobData); +}; + +#if defined(UNIT_TEST) +inline bool operator==(const BlobData& a, const BlobData& b) { + if (a.content_type() != b.content_type()) + return false; + if (a.content_disposition() != b.content_disposition()) + return false; + if (a.items().size() != b.items().size()) + return false; + for (size_t i = 0; i < a.items().size(); ++i) { + if (a.items()[i] != b.items()[i]) + return false; + } + return true; +} + +inline bool operator!=(const BlobData& a, const BlobData& b) { + return !(a == b); +} +#endif // defined(UNIT_TEST) + +} // namespace storage + +#endif // STORAGE_COMMON_BLOB_BLOB_DATA_H_ diff --git a/storage/common/blob/scoped_file.cc b/storage/common/blob/scoped_file.cc new file mode 100644 index 0000000..9cfb1a8 --- /dev/null +++ b/storage/common/blob/scoped_file.cc @@ -0,0 +1,85 @@ +// 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 "storage/common/blob/scoped_file.h" + +#include "base/bind.h" +#include "base/callback.h" +#include "base/file_util.h" +#include "base/location.h" +#include "base/message_loop/message_loop_proxy.h" +#include "base/task_runner.h" + +namespace storage { + +ScopedFile::ScopedFile() + : scope_out_policy_(DONT_DELETE_ON_SCOPE_OUT) { +} + +ScopedFile::ScopedFile(const base::FilePath& path, + ScopeOutPolicy policy, + const scoped_refptr& file_task_runner) + : path_(path), + scope_out_policy_(policy), + file_task_runner_(file_task_runner) { + DCHECK(path.empty() || policy != DELETE_ON_SCOPE_OUT || + file_task_runner.get()) + << "path:" << path.value() << " policy:" << policy + << " runner:" << file_task_runner; +} + +ScopedFile::ScopedFile(RValue other) { + MoveFrom(*other.object); +} + +ScopedFile::~ScopedFile() { + Reset(); +} + +void ScopedFile::AddScopeOutCallback( + const ScopeOutCallback& callback, + base::TaskRunner* callback_runner) { + if (!callback_runner) + callback_runner = base::MessageLoopProxy::current().get(); + scope_out_callbacks_.push_back(std::make_pair(callback, callback_runner)); +} + +base::FilePath ScopedFile::Release() { + base::FilePath path = path_; + path_.clear(); + scope_out_callbacks_.clear(); + scope_out_policy_ = DONT_DELETE_ON_SCOPE_OUT; + return path; +} + +void ScopedFile::Reset() { + if (path_.empty()) + return; + + for (ScopeOutCallbackList::iterator iter = scope_out_callbacks_.begin(); + iter != scope_out_callbacks_.end(); ++iter) { + iter->second->PostTask(FROM_HERE, base::Bind(iter->first, path_)); + } + + if (scope_out_policy_ == DELETE_ON_SCOPE_OUT) { + file_task_runner_->PostTask( + FROM_HERE, + base::Bind(base::IgnoreResult(&base::DeleteFile), + path_, false /* recursive */)); + } + + // Clear all fields. + Release(); +} + +void ScopedFile::MoveFrom(ScopedFile& other) { + Reset(); + + scope_out_policy_ = other.scope_out_policy_; + scope_out_callbacks_.swap(other.scope_out_callbacks_); + file_task_runner_ = other.file_task_runner_; + path_ = other.Release(); +} + +} // namespace storage diff --git a/storage/common/blob/scoped_file.h b/storage/common/blob/scoped_file.h new file mode 100644 index 0000000..4a51a46 --- /dev/null +++ b/storage/common/blob/scoped_file.h @@ -0,0 +1,94 @@ +// 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 STORAGE_COMMON_BLOB_SCOPED_FILE_H_ +#define STORAGE_COMMON_BLOB_SCOPED_FILE_H_ + +#include + +#include "base/callback_forward.h" +#include "base/files/file_path.h" +#include "base/memory/ref_counted.h" +#include "base/move.h" +#include "storage/common/storage_common_export.h" + +namespace base { +class TaskRunner; +} + +namespace storage { + +// A scoped reference for a FilePath that can optionally schedule the file +// to be deleted and/or to notify a consumer when it is going to be scoped out. +// This class supports move semantics, i.e. consumers can call Pass() to +// pass the ownership of ScopedFile. +// +// TODO(kinuko): Probably this can be moved under base or somewhere more +// common place. +class STORAGE_COMMON_EXPORT ScopedFile { + // To support destructive assignment from an l-value assignment. + // This provides Pass() method which creates an r-value for the current + // instance. (See base/move.h for details) + MOVE_ONLY_TYPE_FOR_CPP_03(ScopedFile, RValue) + + public: + typedef base::Callback ScopeOutCallback; + typedef std::pair > + ScopeOutCallbackPair; + typedef std::vector ScopeOutCallbackList; + + enum ScopeOutPolicy { + DELETE_ON_SCOPE_OUT, + DONT_DELETE_ON_SCOPE_OUT, + }; + + ScopedFile(); + + // |file_task_runner| is used to schedule a file deletion if |policy| + // is DELETE_ON_SCOPE_OUT. + ScopedFile(const base::FilePath& path, + ScopeOutPolicy policy, + const scoped_refptr& file_task_runner); + + // Move constructor and operator. The data of r-value will be transfered + // in a destructive way. (See base/move.h) + ScopedFile(RValue other); + ScopedFile& operator=(RValue rhs) { + MoveFrom(*rhs.object); + return *this; + } + + ~ScopedFile(); + + // The |callback| is fired on |callback_runner| when the final reference + // of this instance is released. + // If release policy is DELETE_ON_SCOPE_OUT the + // callback task(s) is/are posted before the deletion is scheduled. + void AddScopeOutCallback(const ScopeOutCallback& callback, + base::TaskRunner* callback_runner); + + // The full file path. + const base::FilePath& path() const { return path_; } + + // Releases the file. After calling this, this instance will hold + // an empty file path and scoping out won't make any file deletion + // or callback dispatch. (If an owned pointer is attached to any of + // callbacks the pointer will be deleted.) + base::FilePath Release(); + + void Reset(); + + private: + // Performs destructive move from |other| to this. + void MoveFrom(ScopedFile& other); + + base::FilePath path_; + ScopeOutPolicy scope_out_policy_; + scoped_refptr file_task_runner_; + ScopeOutCallbackList scope_out_callbacks_; +}; + +} // namespace storage + +#endif // STORAGE_COMMON_BLOB_SCOPED_FILE_H_ diff --git a/storage/common/blob/shareable_file_reference.cc b/storage/common/blob/shareable_file_reference.cc new file mode 100644 index 0000000..c2ec839 --- /dev/null +++ b/storage/common/blob/shareable_file_reference.cc @@ -0,0 +1,121 @@ +// 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 "storage/common/blob/shareable_file_reference.h" + +#include + +#include "base/lazy_instance.h" +#include "base/message_loop/message_loop_proxy.h" +#include "base/task_runner.h" +#include "base/threading/non_thread_safe.h" + +namespace storage { + +namespace { + +// A shareable file map with enforcement of thread checker. +class ShareableFileMap : public base::NonThreadSafe { + public: + typedef std::map FileMap; + typedef FileMap::iterator iterator; + typedef FileMap::key_type key_type; + typedef FileMap::value_type value_type; + + ShareableFileMap() {} + + ~ShareableFileMap() { + DetachFromThread(); + } + + iterator Find(key_type key) { + DCHECK(CalledOnValidThread()); + return file_map_.find(key); + } + + iterator End() { + DCHECK(CalledOnValidThread()); + return file_map_.end(); + } + + std::pair Insert(value_type value) { + DCHECK(CalledOnValidThread()); + return file_map_.insert(value); + } + + void Erase(key_type key) { + DCHECK(CalledOnValidThread()); + file_map_.erase(key); + } + + private: + FileMap file_map_; + DISALLOW_COPY_AND_ASSIGN(ShareableFileMap); +}; + +base::LazyInstance g_file_map = LAZY_INSTANCE_INITIALIZER; + +} // namespace + +// static +scoped_refptr ShareableFileReference::Get( + const base::FilePath& path) { + ShareableFileMap::iterator found = g_file_map.Get().Find(path); + ShareableFileReference* reference = + (found == g_file_map.Get().End()) ? NULL : found->second; + return scoped_refptr(reference); +} + +// static +scoped_refptr ShareableFileReference::GetOrCreate( + const base::FilePath& path, + FinalReleasePolicy policy, + base::TaskRunner* file_task_runner) { + return GetOrCreate( + ScopedFile(path, static_cast(policy), + file_task_runner)); +} + +// static +scoped_refptr ShareableFileReference::GetOrCreate( + ScopedFile scoped_file) { + if (scoped_file.path().empty()) + return scoped_refptr(); + + typedef std::pair InsertResult; + // Required for VS2010: + // http://connect.microsoft.com/VisualStudio/feedback/ + // details/520043/error-converting-from-null-to-a-pointer-type-in-std-pair + storage::ShareableFileReference* null_reference = NULL; + InsertResult result = g_file_map.Get().Insert( + ShareableFileMap::value_type(scoped_file.path(), null_reference)); + if (result.second == false) { + scoped_file.Release(); + return scoped_refptr(result.first->second); + } + + // Wasn't in the map, create a new reference and store the pointer. + scoped_refptr reference( + new ShareableFileReference(scoped_file.Pass())); + result.first->second = reference.get(); + return reference; +} + +void ShareableFileReference::AddFinalReleaseCallback( + const FinalReleaseCallback& callback) { + DCHECK(g_file_map.Get().CalledOnValidThread()); + scoped_file_.AddScopeOutCallback(callback, NULL); +} + +ShareableFileReference::ShareableFileReference(ScopedFile scoped_file) + : scoped_file_(scoped_file.Pass()) { + DCHECK(g_file_map.Get().Find(path())->second == NULL); +} + +ShareableFileReference::~ShareableFileReference() { + DCHECK(g_file_map.Get().Find(path())->second == this); + g_file_map.Get().Erase(path()); +} + +} // namespace storage diff --git a/storage/common/blob/shareable_file_reference.h b/storage/common/blob/shareable_file_reference.h new file mode 100644 index 0000000..bd9d050 --- /dev/null +++ b/storage/common/blob/shareable_file_reference.h @@ -0,0 +1,74 @@ +// 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 STORAGE_COMMON_BLOB_SHAREABLE_FILE_REFERENCE_H_ +#define STORAGE_COMMON_BLOB_SHAREABLE_FILE_REFERENCE_H_ + +#include + +#include "storage/common/blob/scoped_file.h" + +namespace storage { + +// ShareableFileReference allows consumers to share FileReference for the +// same path if it already exists in its internal map. +// This class is non-thread-safe and all methods must be called on a single +// thread. +class STORAGE_COMMON_EXPORT ShareableFileReference + : public base::RefCounted { + public: + typedef ScopedFile::ScopeOutCallback FinalReleaseCallback; + + enum FinalReleasePolicy { + DELETE_ON_FINAL_RELEASE = ScopedFile::DELETE_ON_SCOPE_OUT, + DONT_DELETE_ON_FINAL_RELEASE = ScopedFile::DONT_DELETE_ON_SCOPE_OUT, + }; + + // Returns a ShareableFileReference for the given path, if no reference + // for this path exists returns NULL. + static scoped_refptr Get(const base::FilePath& path); + + // Returns a ShareableFileReference for the given path, creating a new + // reference if none yet exists. If there's a pre-existing reference for + // the path, the policy parameter of this method is ignored. + static scoped_refptr GetOrCreate( + const base::FilePath& path, + FinalReleasePolicy policy, + base::TaskRunner* file_task_runner); + + // Returns a ShareableFileReference for the given path of the |scoped_file|, + // creating a new reference if none yet exists. The ownership of |scoped_file| + // is passed to this reference. + // If there's a pre-existing reference for the path, the scope out policy + // and scope-out-callbacks of the given |scoped_file| is ignored. + // If the given scoped_file has an empty path (e.g. maybe already + // released) this returns NULL reference. + // + // TODO(kinuko): Make sure if this behavior is ok, we could alternatively + // merge callbacks to the existing one. + static scoped_refptr GetOrCreate( + ScopedFile scoped_file); + + // The full file path. + const base::FilePath& path() const { return scoped_file_.path(); } + + // The |callback| is fired when the final reference of this instance + // is released. If release policy is DELETE_ON_FINAL_RELEASE the + // callback task(s) is/are posted before the deletion is scheduled. + void AddFinalReleaseCallback(const FinalReleaseCallback& callback); + + private: + friend class base::RefCounted; + + ShareableFileReference(ScopedFile scoped_file); + ~ShareableFileReference(); + + ScopedFile scoped_file_; + + DISALLOW_COPY_AND_ASSIGN(ShareableFileReference); +}; + +} // namespace storage + +#endif // STORAGE_COMMON_BLOB_SHAREABLE_FILE_REFERENCE_H_ diff --git a/storage/common/data_element.cc b/storage/common/data_element.cc new file mode 100644 index 0000000..c6d52f4 --- /dev/null +++ b/storage/common/data_element.cc @@ -0,0 +1,49 @@ +// 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 "storage/common/data_element.h" + +namespace storage { + +DataElement::DataElement() + : type_(TYPE_UNKNOWN), + bytes_(NULL), + offset_(0), + length_(kuint64max) { +} + +DataElement::~DataElement() {} + +void DataElement::SetToFilePathRange( + const base::FilePath& path, + uint64 offset, uint64 length, + const base::Time& expected_modification_time) { + type_ = TYPE_FILE; + path_ = path; + offset_ = offset; + length_ = length; + expected_modification_time_ = expected_modification_time; +} + +void DataElement::SetToBlobRange( + const std::string& blob_uuid, + uint64 offset, uint64 length) { + type_ = TYPE_BLOB; + blob_uuid_ = blob_uuid; + offset_ = offset; + length_ = length; +} + +void DataElement::SetToFileSystemUrlRange( + const GURL& filesystem_url, + uint64 offset, uint64 length, + const base::Time& expected_modification_time) { + type_ = TYPE_FILE_FILESYSTEM; + filesystem_url_ = filesystem_url; + offset_ = offset; + length_ = length; + expected_modification_time_ = expected_modification_time; +} + +} // namespace storage diff --git a/storage/common/data_element.h b/storage/common/data_element.h new file mode 100644 index 0000000..bdc8812 --- /dev/null +++ b/storage/common/data_element.h @@ -0,0 +1,127 @@ +// 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 STORAGE_COMMON_DATA_ELEMENT_H_ +#define STORAGE_COMMON_DATA_ELEMENT_H_ + +#include +#include + +#include "base/basictypes.h" +#include "base/files/file_path.h" +#include "base/logging.h" +#include "base/time/time.h" +#include "storage/common/storage_common_export.h" +#include "url/gurl.h" + +namespace storage { + +// Represents a base Web data element. This could be either one of +// bytes, file or blob data. +class STORAGE_COMMON_EXPORT DataElement { + public: + enum Type { + TYPE_UNKNOWN = -1, + TYPE_BYTES, + TYPE_FILE, + TYPE_BLOB, + TYPE_FILE_FILESYSTEM, + }; + + DataElement(); + ~DataElement(); + + Type type() const { return type_; } + const char* bytes() const { return bytes_ ? bytes_ : &buf_[0]; } + const base::FilePath& path() const { return path_; } + const GURL& filesystem_url() const { return filesystem_url_; } + const std::string& blob_uuid() const { return blob_uuid_; } + uint64 offset() const { return offset_; } + uint64 length() const { return length_; } + const base::Time& expected_modification_time() const { + return expected_modification_time_; + } + + // Sets TYPE_BYTES data. This copies the given data into the element. + void SetToBytes(const char* bytes, int bytes_len) { + type_ = TYPE_BYTES; + buf_.assign(bytes, bytes + bytes_len); + length_ = buf_.size(); + } + + // Sets TYPE_BYTES data. This does NOT copy the given data and the caller + // should make sure the data is alive when this element is accessed. + void SetToSharedBytes(const char* bytes, int bytes_len) { + type_ = TYPE_BYTES; + bytes_ = bytes; + length_ = bytes_len; + } + + // Sets TYPE_FILE data. + void SetToFilePath(const base::FilePath& path) { + SetToFilePathRange(path, 0, kuint64max, base::Time()); + } + + // Sets TYPE_BLOB data. + void SetToBlob(const std::string& uuid) { + SetToBlobRange(uuid, 0, kuint64max); + } + + // Sets TYPE_FILE data with range. + void SetToFilePathRange(const base::FilePath& path, + uint64 offset, uint64 length, + const base::Time& expected_modification_time); + + // Sets TYPE_BLOB data with range. + void SetToBlobRange(const std::string& blob_uuid, + uint64 offset, uint64 length); + + // Sets TYPE_FILE_FILESYSTEM with range. + void SetToFileSystemUrlRange(const GURL& filesystem_url, + uint64 offset, uint64 length, + const base::Time& expected_modification_time); + + private: + Type type_; + std::vector buf_; // For TYPE_BYTES. + const char* bytes_; // For TYPE_BYTES. + base::FilePath path_; // For TYPE_FILE. + GURL filesystem_url_; // For TYPE_FILE_FILESYSTEM. + std::string blob_uuid_; + uint64 offset_; + uint64 length_; + base::Time expected_modification_time_; +}; + +#if defined(UNIT_TEST) +inline bool operator==(const DataElement& a, const DataElement& b) { + if (a.type() != b.type() || + a.offset() != b.offset() || + a.length() != b.length()) + return false; + switch (a.type()) { + case DataElement::TYPE_BYTES: + return memcmp(a.bytes(), b.bytes(), b.length()) == 0; + case DataElement::TYPE_FILE: + return a.path() == b.path() && + a.expected_modification_time() == b.expected_modification_time(); + case DataElement::TYPE_BLOB: + return a.blob_uuid() == b.blob_uuid(); + case DataElement::TYPE_FILE_FILESYSTEM: + return a.filesystem_url() == b.filesystem_url(); + case DataElement::TYPE_UNKNOWN: + NOTREACHED(); + return false; + } + return false; +} + +inline bool operator!=(const DataElement& a, const DataElement& b) { + return !(a == b); +} +#endif // defined(UNIT_TEST) + +} // namespace storage + +#endif // STORAGE_COMMON_DATA_ELEMENT_H_ diff --git a/storage/common/database/database_connections.cc b/storage/common/database/database_connections.cc new file mode 100644 index 0000000..adfcde1 --- /dev/null +++ b/storage/common/database/database_connections.cc @@ -0,0 +1,175 @@ +// 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 "storage/common/database/database_connections.h" + +#include "base/auto_reset.h" +#include "base/bind.h" +#include "base/logging.h" +#include "base/message_loop/message_loop.h" +#include "base/message_loop/message_loop_proxy.h" + +namespace storage { + +DatabaseConnections::DatabaseConnections() { +} + +DatabaseConnections::~DatabaseConnections() { + DCHECK(connections_.empty()); +} + +bool DatabaseConnections::IsEmpty() const { + return connections_.empty(); +} + +bool DatabaseConnections::IsDatabaseOpened( + const std::string& origin_identifier, + const base::string16& database_name) const { + OriginConnections::const_iterator origin_it = + connections_.find(origin_identifier); + if (origin_it == connections_.end()) + return false; + const DBConnections& origin_connections = origin_it->second; + return (origin_connections.find(database_name) != origin_connections.end()); +} + +bool DatabaseConnections::IsOriginUsed( + const std::string& origin_identifier) const { + return (connections_.find(origin_identifier) != connections_.end()); +} + +bool DatabaseConnections::AddConnection( + const std::string& origin_identifier, + const base::string16& database_name) { + int& count = connections_[origin_identifier][database_name].first; + return ++count == 1; +} + +bool DatabaseConnections::RemoveConnection( + const std::string& origin_identifier, + const base::string16& database_name) { + return RemoveConnectionsHelper(origin_identifier, database_name, 1); +} + +void DatabaseConnections::RemoveAllConnections() { + connections_.clear(); +} + +void DatabaseConnections::RemoveConnections( + const DatabaseConnections& connections, + std::vector >* closed_dbs) { + for (OriginConnections::const_iterator origin_it = + connections.connections_.begin(); + origin_it != connections.connections_.end(); + origin_it++) { + const DBConnections& db_connections = origin_it->second; + for (DBConnections::const_iterator db_it = db_connections.begin(); + db_it != db_connections.end(); db_it++) { + if (RemoveConnectionsHelper(origin_it->first, db_it->first, + db_it->second.first)) + closed_dbs->push_back(std::make_pair(origin_it->first, db_it->first)); + } + } +} + +int64 DatabaseConnections::GetOpenDatabaseSize( + const std::string& origin_identifier, + const base::string16& database_name) const { + DCHECK(IsDatabaseOpened(origin_identifier, database_name)); + return connections_[origin_identifier][database_name].second; +} + +void DatabaseConnections::SetOpenDatabaseSize( + const std::string& origin_identifier, + const base::string16& database_name, + int64 size) { + DCHECK(IsDatabaseOpened(origin_identifier, database_name)); + connections_[origin_identifier][database_name].second = size; +} + +void DatabaseConnections::ListConnections( + std::vector > *list) const { + for (OriginConnections::const_iterator origin_it = + connections_.begin(); + origin_it != connections_.end(); + origin_it++) { + const DBConnections& db_connections = origin_it->second; + for (DBConnections::const_iterator db_it = db_connections.begin(); + db_it != db_connections.end(); db_it++) { + list->push_back(std::make_pair(origin_it->first, db_it->first)); + } + } +} + +bool DatabaseConnections::RemoveConnectionsHelper( + const std::string& origin_identifier, + const base::string16& database_name, + int num_connections) { + OriginConnections::iterator origin_iterator = + connections_.find(origin_identifier); + DCHECK(origin_iterator != connections_.end()); + DBConnections& db_connections = origin_iterator->second; + int& count = db_connections[database_name].first; + DCHECK(count >= num_connections); + count -= num_connections; + if (count) + return false; + db_connections.erase(database_name); + if (db_connections.empty()) + connections_.erase(origin_iterator); + return true; +} + +DatabaseConnectionsWrapper::DatabaseConnectionsWrapper() + : waiting_for_dbs_to_close_(false), + main_thread_(base::MessageLoopProxy::current()) { +} + +DatabaseConnectionsWrapper::~DatabaseConnectionsWrapper() { +} + +void DatabaseConnectionsWrapper::WaitForAllDatabasesToClose() { + // We assume that new databases won't be open while we're waiting. + DCHECK(main_thread_->BelongsToCurrentThread()); + if (HasOpenConnections()) { + base::AutoReset auto_reset(&waiting_for_dbs_to_close_, true); + base::MessageLoop::ScopedNestableTaskAllower allow( + base::MessageLoop::current()); + base::MessageLoop::current()->Run(); + } +} + +bool DatabaseConnectionsWrapper::HasOpenConnections() { + DCHECK(main_thread_->BelongsToCurrentThread()); + base::AutoLock auto_lock(open_connections_lock_); + return !open_connections_.IsEmpty(); +} + +void DatabaseConnectionsWrapper::AddOpenConnection( + const std::string& origin_identifier, + const base::string16& database_name) { + // We add to the collection immediately on any thread. + base::AutoLock auto_lock(open_connections_lock_); + open_connections_.AddConnection(origin_identifier, database_name); +} + +void DatabaseConnectionsWrapper::RemoveOpenConnection( + const std::string& origin_identifier, + const base::string16& database_name) { + // But only remove from the collection on the main thread + // so we can handle the waiting_for_dbs_to_close_ case. + if (!main_thread_->BelongsToCurrentThread()) { + main_thread_->PostTask( + FROM_HERE, + base::Bind(&DatabaseConnectionsWrapper::RemoveOpenConnection, this, + origin_identifier, database_name)); + return; + } + base::AutoLock auto_lock(open_connections_lock_); + open_connections_.RemoveConnection(origin_identifier, database_name); + if (waiting_for_dbs_to_close_ && open_connections_.IsEmpty()) + base::MessageLoop::current()->Quit(); +} + +} // namespace storage diff --git a/storage/common/database/database_connections.h b/storage/common/database/database_connections.h new file mode 100644 index 0000000..ab4812e --- /dev/null +++ b/storage/common/database/database_connections.h @@ -0,0 +1,99 @@ +// 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 STORAGE_COMMON_DATABASE_DATABASE_CONNECTIONS_H_ +#define STORAGE_COMMON_DATABASE_DATABASE_CONNECTIONS_H_ + +#include +#include +#include + +#include "base/memory/ref_counted.h" +#include "base/strings/string16.h" +#include "base/synchronization/lock.h" +#include "storage/common/storage_common_export.h" + +namespace base { +class MessageLoopProxy; +} + +namespace storage { + +class STORAGE_COMMON_EXPORT DatabaseConnections { + public: + DatabaseConnections(); + ~DatabaseConnections(); + + bool IsEmpty() const; + bool IsDatabaseOpened(const std::string& origin_identifier, + const base::string16& database_name) const; + bool IsOriginUsed(const std::string& origin_identifier) const; + + // Returns true if this is the first connection. + bool AddConnection(const std::string& origin_identifier, + const base::string16& database_name); + + // Returns true if the last connection was removed. + bool RemoveConnection(const std::string& origin_identifier, + const base::string16& database_name); + + void RemoveAllConnections(); + void RemoveConnections( + const DatabaseConnections& connections, + std::vector >* closed_dbs); + + // Database sizes can be kept only if IsDatabaseOpened returns true. + int64 GetOpenDatabaseSize(const std::string& origin_identifier, + const base::string16& database_name) const; + void SetOpenDatabaseSize(const std::string& origin_identifier, + const base::string16& database_name, + int64 size); + + // Returns a list of the connections, . + void ListConnections( + std::vector > *list) const; + + private: + // Mapping from name to + typedef std::map > DBConnections; + typedef std::map OriginConnections; + mutable OriginConnections connections_; // mutable for GetOpenDatabaseSize + + // Returns true if the last connection was removed. + bool RemoveConnectionsHelper(const std::string& origin_identifier, + const base::string16& database_name, + int num_connections); +}; + +// A wrapper class that provides thread-safety and the +// ability to wait until all connections have closed. +// Intended for use in renderer processes. +class STORAGE_COMMON_EXPORT DatabaseConnectionsWrapper + : public base::RefCountedThreadSafe { + public: + DatabaseConnectionsWrapper(); + + // The Wait and Has methods should only be called on the + // main thread (the thread on which the wrapper is constructed). + void WaitForAllDatabasesToClose(); + bool HasOpenConnections(); + + // Add and Remove may be called on any thread. + void AddOpenConnection(const std::string& origin_identifier, + const base::string16& database_name); + void RemoveOpenConnection(const std::string& origin_identifier, + const base::string16& database_name); + private: + ~DatabaseConnectionsWrapper(); + friend class base::RefCountedThreadSafe; + + bool waiting_for_dbs_to_close_; + base::Lock open_connections_lock_; + DatabaseConnections open_connections_; + scoped_refptr main_thread_; +}; + +} // namespace storage + +#endif // STORAGE_COMMON_DATABASE_DATABASE_CONNECTIONS_H_ diff --git a/storage/common/database/database_identifier.cc b/storage/common/database/database_identifier.cc new file mode 100644 index 0000000..e642a1a --- /dev/null +++ b/storage/common/database/database_identifier.cc @@ -0,0 +1,145 @@ +// 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 "storage/common/database/database_identifier.h" + +#include "base/strings/string_number_conversions.h" +#include "base/strings/string_util.h" +#include "url/url_canon.h" + +namespace storage { + +// static +std::string GetIdentifierFromOrigin(const GURL& origin) { + return DatabaseIdentifier::CreateFromOrigin(origin).ToString(); +} + +// static +GURL GetOriginFromIdentifier(const std::string& identifier) { + return DatabaseIdentifier::Parse(identifier).ToOrigin(); +} + +static bool SchemeIsUnique(const std::string& scheme) { + return scheme == "about" || scheme == "data" || scheme == "javascript"; +} + +// static +const DatabaseIdentifier DatabaseIdentifier::UniqueFileIdentifier() { + return DatabaseIdentifier("", "", 0, true, true); +} + +// static +DatabaseIdentifier DatabaseIdentifier::CreateFromOrigin(const GURL& origin) { + if (!origin.is_valid() || origin.is_empty() || + !origin.IsStandard() || SchemeIsUnique(origin.scheme())) + return DatabaseIdentifier(); + + if (origin.SchemeIsFile()) + return UniqueFileIdentifier(); + + int port = origin.IntPort(); + 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::PORT_UNSPECIFIED) + port = 0; + + return DatabaseIdentifier(origin.scheme(), + origin.host(), + port, + false /* unique */, + false /* file */); +} + +// static +DatabaseIdentifier DatabaseIdentifier::Parse(const std::string& 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) + return DatabaseIdentifier(); + + size_t last_underscore = identifier.find_last_of('_'); + if (last_underscore == std::string::npos || + last_underscore == first_underscore || + last_underscore == identifier.length() - 1) + return DatabaseIdentifier(); + + std::string scheme(identifier.data(), first_underscore); + if (scheme == "file") + return UniqueFileIdentifier(); + + // This magical set of schemes is always treated as unique. + if (SchemeIsUnique(scheme)) + return DatabaseIdentifier(); + + base::StringPiece port_str(identifier.begin() + last_underscore + 1, + identifier.end()); + int port = 0; + if (!base::StringToInt(port_str, &port) || port < 0 || port >= 1 << 16) + return DatabaseIdentifier(); + + std::string hostname(identifier.data() + first_underscore + 1, + last_underscore - first_underscore - 1); + GURL url(scheme + "://" + hostname + "/"); + + if (!url.IsStandard()) + hostname = ""; + + // If a url doesn't parse cleanly or doesn't round trip, reject it. + if (!url.is_valid() || url.scheme() != scheme || url.host() != hostname) + return DatabaseIdentifier(); + + return DatabaseIdentifier(scheme, hostname, port, false /* unique */, false); +} + +DatabaseIdentifier::DatabaseIdentifier() + : port_(0), + is_unique_(true), + is_file_(false) { +} + +DatabaseIdentifier::DatabaseIdentifier(const std::string& scheme, + const std::string& hostname, + int port, + bool is_unique, + bool is_file) + : scheme_(scheme), + hostname_(base::StringToLowerASCII(hostname)), + port_(port), + is_unique_(is_unique), + is_file_(is_file) { +} + +DatabaseIdentifier::~DatabaseIdentifier() {} + +std::string DatabaseIdentifier::ToString() const { + if (is_file_) + return "file__0"; + if (is_unique_) + return "__0"; + return scheme_ + "_" + hostname_ + "_" + base::IntToString(port_); +} + +GURL DatabaseIdentifier::ToOrigin() const { + if (is_file_) + return GURL("file:///"); + if (is_unique_) + return GURL(); + if (port_ == 0) + return GURL(scheme_ + "://" + hostname_); + return GURL(scheme_ + "://" + hostname_ + ":" + base::IntToString(port_)); +} + +} // namespace storage diff --git a/storage/common/database/database_identifier.h b/storage/common/database/database_identifier.h new file mode 100644 index 0000000..a658ade --- /dev/null +++ b/storage/common/database/database_identifier.h @@ -0,0 +1,54 @@ +// 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 STORAGE_COMMON_DATABASE_DATABASE_IDENTIFIER_H_ +#define STORAGE_COMMON_DATABASE_DATABASE_IDENTIFIER_H_ + +#include + +#include "base/basictypes.h" +#include "base/strings/string_piece.h" +#include "storage/common/storage_common_export.h" +#include "url/gurl.h" + +namespace storage { + +STORAGE_COMMON_EXPORT std::string GetIdentifierFromOrigin( + const GURL& origin); +STORAGE_COMMON_EXPORT GURL GetOriginFromIdentifier( + const std::string& identifier); + +class STORAGE_COMMON_EXPORT DatabaseIdentifier { + public: + static const DatabaseIdentifier UniqueFileIdentifier(); + static DatabaseIdentifier CreateFromOrigin(const GURL& origin); + static DatabaseIdentifier Parse(const std::string& identifier); + ~DatabaseIdentifier(); + + std::string ToString() const; + GURL ToOrigin() const; + + std::string scheme() const { return scheme_; } + std::string hostname() const { return hostname_; } + int port() const { return port_; } + bool is_unique() const { return is_unique_; } + + private: + DatabaseIdentifier(); + DatabaseIdentifier(const std::string& scheme, + const std::string& hostname, + int port, + bool is_unique, + bool is_file); + + std::string scheme_; + std::string hostname_; + int port_; + bool is_unique_; + bool is_file_; +}; + +} // namespace storage + +#endif // STORAGE_COMMON_DATABASE_DATABASE_IDENTIFIER_H_ diff --git a/storage/common/fileapi/OWNERS b/storage/common/fileapi/OWNERS new file mode 100644 index 0000000..232db84 --- /dev/null +++ b/storage/common/fileapi/OWNERS @@ -0,0 +1,2 @@ +tzik@chromium.org +nhiroki@chromium.org diff --git a/storage/common/fileapi/directory_entry.cc b/storage/common/fileapi/directory_entry.cc new file mode 100644 index 0000000..477ede8 --- /dev/null +++ b/storage/common/fileapi/directory_entry.cc @@ -0,0 +1,21 @@ +// 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 "storage/common/fileapi/directory_entry.h" + +namespace storage { + +DirectoryEntry::DirectoryEntry() : is_directory(false), size(0) {} + +DirectoryEntry::DirectoryEntry(const std::string& name, + DirectoryEntryType type, + int64 size, + const base::Time& last_modified_time) + : name(base::FilePath::FromUTF8Unsafe(name).value()), + is_directory(type == DIRECTORY), + size(size), + last_modified_time(last_modified_time) { +} + +} // namespace storage diff --git a/storage/common/fileapi/directory_entry.h b/storage/common/fileapi/directory_entry.h new file mode 100644 index 0000000..1b06828 --- /dev/null +++ b/storage/common/fileapi/directory_entry.h @@ -0,0 +1,38 @@ +// 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 STORAGE_COMMON_FILEAPI_DIRECTORY_ENTRY_H_ +#define STORAGE_COMMON_FILEAPI_DIRECTORY_ENTRY_H_ + +#include + +#include "base/basictypes.h" +#include "base/files/file_path.h" +#include "base/time/time.h" +#include "storage/common/storage_common_export.h" + +namespace storage { + +// Holds metadata for file or directory entry. +struct STORAGE_COMMON_EXPORT DirectoryEntry { + enum DirectoryEntryType { + FILE, + DIRECTORY, + }; + + DirectoryEntry(); + DirectoryEntry(const std::string& name, + DirectoryEntryType type, + int64 size, + const base::Time& last_modified_time); + + base::FilePath::StringType name; + bool is_directory; + int64 size; + base::Time last_modified_time; +}; + +} // namespace storage + +#endif // STORAGE_COMMON_FILEAPI_DIRECTORY_ENTRY_H_ diff --git a/storage/common/fileapi/file_system_info.cc b/storage/common/fileapi/file_system_info.cc new file mode 100644 index 0000000..1a6a9cc --- /dev/null +++ b/storage/common/fileapi/file_system_info.cc @@ -0,0 +1,22 @@ +// 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 "storage/common/fileapi/file_system_info.h" + +namespace storage { + +FileSystemInfo::FileSystemInfo() + : mount_type(storage::kFileSystemTypeTemporary) { +} + +FileSystemInfo::FileSystemInfo(const std::string& name, + const GURL& root_url, + storage::FileSystemType mount_type) + : name(name), root_url(root_url), mount_type(mount_type) { +} + +FileSystemInfo::~FileSystemInfo() { +} + +} // namespace storage diff --git a/storage/common/fileapi/file_system_info.h b/storage/common/fileapi/file_system_info.h new file mode 100644 index 0000000..bb2fea9 --- /dev/null +++ b/storage/common/fileapi/file_system_info.h @@ -0,0 +1,33 @@ +// 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 STORAGE_COMMON_FILEAPI_FILE_SYSTEM_INFO_H_ +#define STORAGE_COMMON_FILEAPI_FILE_SYSTEM_INFO_H_ + +#include + +#include "storage/common/fileapi/file_system_types.h" +#include "storage/common/storage_common_export.h" +#include "url/gurl.h" + +namespace storage { + +// This struct is used to send the necessary information for Blink to create a +// DOMFileSystem. Since Blink side only uses mount_type (rather than +// detailed/cracked filesystem type) this only contains mount_type but not type. +struct STORAGE_COMMON_EXPORT FileSystemInfo { + FileSystemInfo(); + FileSystemInfo(const std::string& filesystem_name, + const GURL& root_url, + storage::FileSystemType mount_type); + ~FileSystemInfo(); + + std::string name; + GURL root_url; + storage::FileSystemType mount_type; +}; + +} // namespace storage + +#endif // STORAGE_COMMON_FILEAPI_FILE_SYSTEM_INFO_H_ diff --git a/storage/common/fileapi/file_system_mount_option.h b/storage/common/fileapi/file_system_mount_option.h new file mode 100644 index 0000000..dc5cdc4 --- /dev/null +++ b/storage/common/fileapi/file_system_mount_option.h @@ -0,0 +1,37 @@ +// 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 STORAGE_COMMON_FILEAPI_FILE_SYSTEM_MOUNT_OPTION_H_ +#define STORAGE_COMMON_FILEAPI_FILE_SYSTEM_MOUNT_OPTION_H_ + +namespace storage { + +// Option for specifying if disk sync operation is wanted after copying. +enum CopySyncOption { + COPY_SYNC_OPTION_NO_SYNC, + COPY_SYNC_OPTION_SYNC, +}; + +// Conveys options for a mounted file systems. +class FileSystemMountOption { + public: + // Constructs with the default options. + FileSystemMountOption() + : copy_sync_option_(COPY_SYNC_OPTION_NO_SYNC) {} + + // Constructs with the specified component. + explicit FileSystemMountOption(CopySyncOption copy_sync_option) + : copy_sync_option_(copy_sync_option) {} + + CopySyncOption copy_sync_option() const { + return copy_sync_option_; + } + + private: + CopySyncOption copy_sync_option_; +}; + +} // namespace storage + +#endif // STORAGE_COMMON_FILEAPI_FILE_SYSTEM_MOUNT_OPTION_H_ diff --git a/storage/common/fileapi/file_system_types.h b/storage/common/fileapi/file_system_types.h new file mode 100644 index 0000000..645b759 --- /dev/null +++ b/storage/common/fileapi/file_system_types.h @@ -0,0 +1,137 @@ +// 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 STORAGE_COMMON_FILEAPI_FILE_SYSTEM_TYPES_H_ +#define STORAGE_COMMON_FILEAPI_FILE_SYSTEM_TYPES_H_ + +#include "third_party/WebKit/public/platform/WebFileSystemType.h" + +namespace storage { + +enum FileSystemType { + // Indicates uninitialized or invalid filesystem type. + kFileSystemTypeUnknown = -1, + + // ------------------------------------------------------------------------ + // Public FileSystem types, that are embedded in filesystem: URL and exposed + // to WebKit/renderer. Both Chrome and WebKit know how to handle these types. + + // Following two types are for TEMPORARY or PERSISTENT filesystems that + // can be used by webapps via standard app-facing API + // as defined in File API: Directories and System. + // http://www.w3.org/TR/file-system-api/#temporary-vs.-persistent-storage + // They are sandboxed filesystems; all the files in the filesystems are + // placed under the profile directory with path obfuscation and quota + // enforcement. + kFileSystemTypeTemporary = blink::WebFileSystemTypeTemporary, + kFileSystemTypePersistent = blink::WebFileSystemTypePersistent, + + // Indicates non-sandboxed isolated filesystem. + kFileSystemTypeIsolated = blink::WebFileSystemTypeIsolated, + + // Indicates filesystems that are mounted externally via + // ExternalMountPoints with a well-known mount name. The mounted + // filesystems can be sandboxed or non-sandboxed. (E.g. Chrome OS mounts + // non-sandboxed removable media folder with a name 'removable', while + // chrome.syncFileSystem mounts a sandboxed filesystem with a name + // 'syncfs'.) + kFileSystemTypeExternal = blink::WebFileSystemTypeExternal, + + // ------------------------------------------------------------------------ + // Marks the beginning of internal type enum. (This is not the actual fs type) + kFileSystemInternalTypeEnumStart = 99, + + // Private FileSystem types, that should not appear in filesystem: URL as + // WebKit has no idea how to handle those types. + // + // One can register (mount) a new file system with a private file system type + // using IsolatedContext. Files in such file systems can be accessed via + // either Isolated or External public file system types (depending on + // how the file system is registered). + // See the comments for IsolatedContext and/or FileSystemURL for more details. + + // Should be used only for testing. + kFileSystemTypeTest, + + // Indicates a local filesystem where we can access files using native + // local path. + kFileSystemTypeNativeLocal, + + // Indicates a local filesystem where we can access files using native + // local path, but with restricted access. + // Restricted native local file system is in read-only mode. + kFileSystemTypeRestrictedNativeLocal, + + // Indicates a transient, isolated file system for dragged files (which could + // contain multiple dragged paths in the virtual root). + kFileSystemTypeDragged, + + // Indicates media filesystem which we can access with same manner to + // regular filesystem. + kFileSystemTypeNativeMedia, + + // Indicates media filesystem to which we need special protocol to access, + // such as MTP or PTP. + kFileSystemTypeDeviceMedia, + + // Indicates a Picasa virtual filesystem provided by Media Galleries API. + kFileSystemTypePicasa, + + // Indicates a synthetic iTunes filesystem. + kFileSystemTypeItunes, + + // Indicates a synthetic iPhoto filesystem. + kFileSystemTypeIphoto, + + // Indicates a Drive filesystem which provides access to Google Drive. + kFileSystemTypeDrive, + + // Indicates a Syncable sandboxed filesystem which can be backed by a + // cloud storage service. + kFileSystemTypeSyncable, + + // Indicates a special filesystem type for internal file sync operation + // for Syncable sandboxed filesystems. The file system is overlayed, i.e. + // points to the same sandboxed filesystem as that of kFileSystemTypeSyncable, + // but the changes made with this filesystem type are not recorded for + // further sync. + kFileSystemTypeSyncableForInternalSync, + + // Indicates an external filesystem accessible by file paths from platform + // Apps. As of writing, on non Chrome OS platform, this is merely a + // kFileSystemTypeNativeLocal. On Chrome OS, the path is parsed by + // the handlers of kFileSystemTypeExternal. + kFileSystemTypeNativeForPlatformApp, + + // Indicates an isolated filesystem which is supposed to contain one + // temporary which is supposed to go away when the last reference of + // its snapshot is dropped. + // This type is useful for creating a blob reference for a temporary + // file which must go away when the blob's last reference is dropped. + kFileSystemTypeForTransientFile, + + // Sandboxed private filesystem. This filesystem cannot be opened + // via regular OpenFileSystem, and provides private filesystem space for + // 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. + kFileSystemInternalTypeEnumEnd, +}; + +} // namespace storage + +#endif // STORAGE_COMMON_FILEAPI_FILE_SYSTEM_TYPES_H_ diff --git a/storage/common/fileapi/file_system_util.cc b/storage/common/fileapi/file_system_util.cc new file mode 100644 index 0000000..0e81843 --- /dev/null +++ b/storage/common/fileapi/file_system_util.cc @@ -0,0 +1,511 @@ +// 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 "storage/common/fileapi/file_system_util.h" + +#include + +#include "base/files/file_path.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 "net/base/escape.h" +#include "net/base/net_errors.h" +#include "storage/common/database/database_identifier.h" +#include "url/gurl.h" + +namespace storage { + +const char kPersistentDir[] = "/persistent"; +const char kTemporaryDir[] = "/temporary"; +const char kIsolatedDir[] = "/isolated"; +const char kExternalDir[] = "/external"; +const char kTestDir[] = "/test"; + +const base::FilePath::CharType VirtualPath::kRoot[] = FILE_PATH_LITERAL("/"); +const base::FilePath::CharType VirtualPath::kSeparator = FILE_PATH_LITERAL('/'); + +// TODO(ericu): Consider removing support for '\', even on Windows, if possible. +// There's a lot of test code that will need reworking, and we may have trouble +// with base::FilePath elsewhere [e.g. DirName and other methods may also need +// replacement]. +base::FilePath VirtualPath::BaseName(const base::FilePath& virtual_path) { + base::FilePath::StringType path = virtual_path.value(); + + // Keep everything after the final separator, but if the pathname is only + // one character and it's a separator, leave it alone. + while (path.size() > 1 && base::FilePath::IsSeparator(path[path.size() - 1])) + path.resize(path.size() - 1); + base::FilePath::StringType::size_type last_separator = + path.find_last_of(base::FilePath::kSeparators); + if (last_separator != base::FilePath::StringType::npos && + last_separator < path.size() - 1) + path.erase(0, last_separator + 1); + + return base::FilePath(path); +} + +base::FilePath VirtualPath::DirName(const base::FilePath& virtual_path) { + typedef base::FilePath::StringType StringType; + StringType path = virtual_path.value(); + + // The logic below is taken from that of base::FilePath::DirName, except + // that this version never cares about '//' or drive-letters even on win32. + + // Strip trailing separators. + while (path.size() > 1 && base::FilePath::IsSeparator(path[path.size() - 1])) + path.resize(path.size() - 1); + + StringType::size_type last_separator = + path.find_last_of(base::FilePath::kSeparators); + if (last_separator == StringType::npos) { + // path_ is in the current directory. + return base::FilePath(base::FilePath::kCurrentDirectory); + } + if (last_separator == 0) { + // path_ is in the root directory. + return base::FilePath(path.substr(0, 1)); + } + // path_ is somewhere else, trim the basename. + path.resize(last_separator); + + // Strip trailing separators. + while (path.size() > 1 && base::FilePath::IsSeparator(path[path.size() - 1])) + path.resize(path.size() - 1); + + if (path.empty()) + return base::FilePath(base::FilePath::kCurrentDirectory); + + return base::FilePath(path); +} + +void VirtualPath::GetComponents( + const base::FilePath& path, + std::vector* components) { + typedef base::FilePath::StringType StringType; + + DCHECK(components); + if (!components) + return; + components->clear(); + if (path.value().empty()) + return; + + StringType::size_type begin = 0, end = 0; + while (begin < path.value().length() && end != StringType::npos) { + end = path.value().find_first_of(base::FilePath::kSeparators, begin); + StringType component = path.value().substr( + begin, end == StringType::npos ? StringType::npos : end - begin); + if (!component.empty() && component != base::FilePath::kCurrentDirectory) + components->push_back(component); + begin = end + 1; + } +} + +void VirtualPath::GetComponentsUTF8Unsafe( + const base::FilePath& path, + std::vector* components) { + DCHECK(components); + if (!components) + return; + components->clear(); + + std::vector stringtype_components; + VirtualPath::GetComponents(path, &stringtype_components); + std::vector::const_iterator it; + for (it = stringtype_components.begin(); it != stringtype_components.end(); + ++it) { + components->push_back(base::FilePath(*it).AsUTF8Unsafe()); + } +} + +base::FilePath::StringType VirtualPath::GetNormalizedFilePath( + const base::FilePath& path) { + base::FilePath::StringType normalized_path = path.value(); + const size_t num_separators = base::FilePath::StringType( + base::FilePath::kSeparators).length(); + for (size_t i = 0; i < num_separators; ++i) { + std::replace(normalized_path.begin(), normalized_path.end(), + base::FilePath::kSeparators[i], kSeparator); + } + + return (IsAbsolute(normalized_path)) ? + normalized_path : base::FilePath::StringType(kRoot) + normalized_path; +} + +bool VirtualPath::IsAbsolute(const base::FilePath::StringType& path) { + return path.find(kRoot) == 0; +} + +bool VirtualPath::IsRootPath(const base::FilePath& path) { + std::vector components; + VirtualPath::GetComponents(path, &components); + return (path.empty() || components.empty() || + (components.size() == 1 && + 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. + DCHECK(!origin_url.SchemeIsFileSystem()); + + std::string url = "filesystem:" + origin_url.GetWithEmptyPath().spec(); + switch (type) { + case kFileSystemTypeTemporary: + url += (kTemporaryDir + 1); // We don't want the leading slash. + return GURL(url + "/"); + case kFileSystemTypePersistent: + url += (kPersistentDir + 1); // We don't want the leading slash. + return GURL(url + "/"); + case kFileSystemTypeExternal: + url += (kExternalDir + 1); // We don't want the leading slash. + return GURL(url + "/"); + case kFileSystemTypeIsolated: + url += (kIsolatedDir + 1); // We don't want the leading slash. + return GURL(url + "/"); + case kFileSystemTypeTest: + url += (kTestDir + 1); // We don't want the leading slash. + return GURL(url + "/"); + // Internal types are always pointed via isolated or external URLs. + default: + NOTREACHED(); + } + NOTREACHED(); + return GURL(); +} + +std::string GetFileSystemName(const GURL& origin_url, FileSystemType type) { + std::string origin_identifier = storage::GetIdentifierFromOrigin(origin_url); + std::string type_string = GetFileSystemTypeString(type); + DCHECK(!type_string.empty()); + return origin_identifier + ":" + type_string; +} + +FileSystemType QuotaStorageTypeToFileSystemType( + storage::StorageType storage_type) { + switch (storage_type) { + case storage::kStorageTypeTemporary: + return kFileSystemTypeTemporary; + case storage::kStorageTypePersistent: + return kFileSystemTypePersistent; + case storage::kStorageTypeSyncable: + return kFileSystemTypeSyncable; + case storage::kStorageTypeQuotaNotManaged: + case storage::kStorageTypeUnknown: + return kFileSystemTypeUnknown; + } + return kFileSystemTypeUnknown; +} + +storage::StorageType FileSystemTypeToQuotaStorageType(FileSystemType type) { + switch (type) { + case kFileSystemTypeTemporary: + return storage::kStorageTypeTemporary; + case kFileSystemTypePersistent: + return storage::kStorageTypePersistent; + case kFileSystemTypeSyncable: + case kFileSystemTypeSyncableForInternalSync: + return storage::kStorageTypeSyncable; + case kFileSystemTypePluginPrivate: + return storage::kStorageTypeQuotaNotManaged; + default: + return storage::kStorageTypeUnknown; + } +} + +std::string GetFileSystemTypeString(FileSystemType type) { + switch (type) { + case kFileSystemTypeTemporary: + return "Temporary"; + case kFileSystemTypePersistent: + return "Persistent"; + case kFileSystemTypeIsolated: + return "Isolated"; + case kFileSystemTypeExternal: + return "External"; + case kFileSystemTypeTest: + return "Test"; + case kFileSystemTypeNativeLocal: + return "NativeLocal"; + case kFileSystemTypeRestrictedNativeLocal: + return "RestrictedNativeLocal"; + case kFileSystemTypeDragged: + return "Dragged"; + case kFileSystemTypeNativeMedia: + return "NativeMedia"; + case kFileSystemTypeDeviceMedia: + return "DeviceMedia"; + case kFileSystemTypePicasa: + return "Picasa"; + case kFileSystemTypeItunes: + return "Itunes"; + case kFileSystemTypeIphoto: + return "Iphoto"; + case kFileSystemTypeDrive: + return "Drive"; + case kFileSystemTypeSyncable: + case kFileSystemTypeSyncableForInternalSync: + return "Syncable"; + case kFileSystemTypeNativeForPlatformApp: + return "NativeForPlatformApp"; + case kFileSystemTypeForTransientFile: + return "TransientFile"; + case kFileSystemTypePluginPrivate: + return "PluginPrivate"; + case kFileSystemTypeCloudDevice: + return "CloudDevice"; + case kFileSystemTypeProvided: + return "Provided"; + case kFileSystemTypeDeviceMediaAsFileStorage: + return "DeviceMediaStorage"; + case kFileSystemInternalTypeEnumStart: + case kFileSystemInternalTypeEnumEnd: + NOTREACHED(); + // Fall through. + case kFileSystemTypeUnknown: + return "Unknown"; + } + NOTREACHED(); + return std::string(); +} + +std::string FilePathToString(const base::FilePath& file_path) { +#if defined(OS_WIN) + return base::UTF16ToUTF8(file_path.value()); +#elif defined(OS_POSIX) + return file_path.value(); +#endif +} + +base::FilePath StringToFilePath(const std::string& file_path_string) { +#if defined(OS_WIN) + return base::FilePath(base::UTF8ToUTF16(file_path_string)); +#elif defined(OS_POSIX) + return base::FilePath(file_path_string); +#endif +} + +blink::WebFileError FileErrorToWebFileError( + base::File::Error error_code) { + switch (error_code) { + case base::File::FILE_ERROR_NOT_FOUND: + return blink::WebFileErrorNotFound; + 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::File::FILE_ERROR_NOT_A_DIRECTORY: + case base::File::FILE_ERROR_NOT_A_FILE: + return blink::WebFileErrorTypeMismatch; + case base::File::FILE_ERROR_ACCESS_DENIED: + return blink::WebFileErrorNoModificationAllowed; + case base::File::FILE_ERROR_FAILED: + return blink::WebFileErrorInvalidState; + case base::File::FILE_ERROR_ABORT: + return blink::WebFileErrorAbort; + case base::File::FILE_ERROR_SECURITY: + return blink::WebFileErrorSecurity; + case base::File::FILE_ERROR_NO_SPACE: + return blink::WebFileErrorQuotaExceeded; + case base::File::FILE_ERROR_INVALID_URL: + return blink::WebFileErrorEncoding; + default: + return blink::WebFileErrorInvalidModification; + } +} + +bool GetFileSystemPublicType( + const std::string type_string, + blink::WebFileSystemType* type) { + DCHECK(type); + if (type_string == "Temporary") { + *type = blink::WebFileSystemTypeTemporary; + return true; + } + if (type_string == "Persistent") { + *type = blink::WebFileSystemTypePersistent; + return true; + } + if (type_string == "Isolated") { + *type = blink::WebFileSystemTypeIsolated; + return true; + } + if (type_string == "External") { + *type = blink::WebFileSystemTypeExternal; + return true; + } + NOTREACHED(); + return false; +} + +std::string GetIsolatedFileSystemName(const GURL& origin_url, + const std::string& filesystem_id) { + std::string name( + storage::GetFileSystemName(origin_url, storage::kFileSystemTypeIsolated)); + name.append("_"); + name.append(filesystem_id); + return name; +} + +bool CrackIsolatedFileSystemName(const std::string& filesystem_name, + std::string* filesystem_id) { + DCHECK(filesystem_id); + + // |filesystem_name| is of the form {origin}:isolated_{filesystem_id}. + std::string start_token(":"); + start_token = start_token.append( + GetFileSystemTypeString(kFileSystemTypeIsolated)).append("_"); + // WebKit uses different case in its constant for isolated file system + // names, so we do a case insensitive compare by converting both strings + // to uppercase. + // TODO(benwells): Remove this when WebKit uses the same constant. + start_token = StringToUpperASCII(start_token); + std::string filesystem_name_upper = StringToUpperASCII(filesystem_name); + size_t pos = filesystem_name_upper.find(start_token); + if (pos == std::string::npos) + return false; + if (pos == 0) + return false; + + *filesystem_id = filesystem_name.substr(pos + start_token.length(), + std::string::npos); + if (filesystem_id->empty()) + return false; + + return true; +} + +bool ValidateIsolatedFileSystemId(const std::string& filesystem_id) { + const size_t kExpectedFileSystemIdSize = 32; + if (filesystem_id.size() != kExpectedFileSystemIdSize) + return false; + const std::string kExpectedChars("ABCDEF0123456789"); + return base::ContainsOnlyChars(filesystem_id, kExpectedChars); +} + +std::string GetIsolatedFileSystemRootURIString( + const GURL& origin_url, + const std::string& filesystem_id, + const std::string& optional_root_name) { + std::string root = GetFileSystemRootURI(origin_url, + kFileSystemTypeIsolated).spec(); + if (base::FilePath::FromUTF8Unsafe(filesystem_id).ReferencesParent()) + return std::string(); + 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(net::EscapePath(optional_root_name)); + root.append("/"); + } + return root; +} + +std::string GetExternalFileSystemRootURIString( + const GURL& origin_url, + const std::string& mount_name) { + std::string root = GetFileSystemRootURI(origin_url, + kFileSystemTypeExternal).spec(); + if (base::FilePath::FromUTF8Unsafe(mount_name).ReferencesParent()) + return std::string(); + root.append(net::EscapePath(mount_name)); + root.append("/"); + return root; +} + +base::File::Error NetErrorToFileError(int error) { + switch (error) { + case net::OK: + return base::File::FILE_OK; + case net::ERR_ADDRESS_IN_USE: + return base::File::FILE_ERROR_IN_USE; + case net::ERR_FILE_EXISTS: + return base::File::FILE_ERROR_EXISTS; + case net::ERR_FILE_NOT_FOUND: + return base::File::FILE_ERROR_NOT_FOUND; + case net::ERR_ACCESS_DENIED: + return base::File::FILE_ERROR_ACCESS_DENIED; + case net::ERR_TOO_MANY_SOCKET_STREAMS: + return base::File::FILE_ERROR_TOO_MANY_OPENED; + case net::ERR_OUT_OF_MEMORY: + return base::File::FILE_ERROR_NO_MEMORY; + case net::ERR_FILE_NO_SPACE: + return base::File::FILE_ERROR_NO_SPACE; + case net::ERR_INVALID_ARGUMENT: + case net::ERR_INVALID_HANDLE: + return base::File::FILE_ERROR_INVALID_OPERATION; + case net::ERR_ABORTED: + case net::ERR_CONNECTION_ABORTED: + return base::File::FILE_ERROR_ABORT; + case net::ERR_ADDRESS_INVALID: + case net::ERR_INVALID_URL: + return base::File::FILE_ERROR_INVALID_URL; + default: + return base::File::FILE_ERROR_FAILED; + } +} + +} // namespace storage diff --git a/storage/common/fileapi/file_system_util.h b/storage/common/fileapi/file_system_util.h new file mode 100644 index 0000000..55684b6 --- /dev/null +++ b/storage/common/fileapi/file_system_util.h @@ -0,0 +1,182 @@ +// 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 STORAGE_COMMON_FILEAPI_FILE_SYSTEM_UTIL_H_ +#define STORAGE_COMMON_FILEAPI_FILE_SYSTEM_UTIL_H_ + +#include +#include + +#include "base/files/file.h" +#include "base/files/file_path.h" +#include "storage/common/fileapi/file_system_info.h" +#include "storage/common/fileapi/file_system_types.h" +#include "storage/common/quota/quota_types.h" +#include "storage/common/storage_common_export.h" +#include "third_party/WebKit/public/platform/WebFileError.h" +#include "third_party/WebKit/public/platform/WebFileSystemType.h" + +class GURL; + +namespace storage { + +STORAGE_COMMON_EXPORT extern const char kPersistentDir[]; +STORAGE_COMMON_EXPORT extern const char kTemporaryDir[]; +STORAGE_COMMON_EXPORT extern const char kExternalDir[]; +STORAGE_COMMON_EXPORT extern const char kIsolatedDir[]; +STORAGE_COMMON_EXPORT extern const char kTestDir[]; + +class STORAGE_COMMON_EXPORT VirtualPath { + public: + static const base::FilePath::CharType kRoot[]; + static const base::FilePath::CharType kSeparator; + + // Use this instead of base::FilePath::BaseName when operating on virtual + // paths. FilePath::BaseName will get confused by ':' on Windows when it + // looks like a drive letter separator; this will treat it as just another + // character. + static base::FilePath BaseName(const base::FilePath& virtual_path); + + // Use this instead of base::FilePath::DirName when operating on virtual + // paths. + static base::FilePath DirName(const base::FilePath& virtual_path); + + // Likewise, use this instead of base::FilePath::GetComponents when + // operating on virtual paths. + // Note that this assumes very clean input, with no leading slash, and + // it will not evaluate '..' components. + static void GetComponents( + const base::FilePath& path, + std::vector* components); + + static void GetComponentsUTF8Unsafe( + const base::FilePath& path, std::vector* components); + + // Returns a path name ensuring that it begins with kRoot and all path + // separators are forward slashes /. + static base::FilePath::StringType GetNormalizedFilePath( + const base::FilePath& path); + + // Returns true if the given path begins with kRoot. + static bool IsAbsolute(const base::FilePath::StringType& path); + + // Returns true if the given path points to the root. + 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'. +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. + "/relative/path" will compose +// a path pointing to the entry "/relative/path" in the filesystem). +// +// For Isolated filesystem this returns the 'common' root part, e.g. +// returns URL without the filesystem ID. +// +// |type| needs to be public type as the returned URI is given to the renderer. +STORAGE_COMMON_EXPORT GURL GetFileSystemRootURI(const GURL& origin_url, + FileSystemType type); + +// Returns the name for the filesystem that is specified by a pair of +// |origin_url| and |type|. +// (The name itself is neither really significant nor a formal identifier +// but can be read as the .name field of the returned FileSystem object +// as a user-friendly name in the javascript layer). +// +// |type| needs to be public type as the returned name is given to the renderer. +// +// Example: +// The name for a TEMPORARY filesystem of "http://www.example.com:80/" +// should look like: "http_www.example.host_80:temporary" +STORAGE_COMMON_EXPORT std::string +GetFileSystemName(const GURL& origin_url, FileSystemType type); + +// Converts FileSystemType |type| to/from the StorageType |storage_type| that +// is used for the unified quota system. +// (Basically this naively maps TEMPORARY storage type to TEMPORARY filesystem +// type, PERSISTENT storage type to PERSISTENT filesystem type and vice versa.) +STORAGE_COMMON_EXPORT FileSystemType + QuotaStorageTypeToFileSystemType(storage::StorageType storage_type); + +STORAGE_COMMON_EXPORT storage::StorageType + FileSystemTypeToQuotaStorageType(FileSystemType type); + +// Returns the string representation of the given filesystem |type|. +// Returns an empty string if the |type| is invalid. +STORAGE_COMMON_EXPORT std::string +GetFileSystemTypeString(FileSystemType type); + +// Sets type to FileSystemType enum that corresponds to the string name. +// Returns false if the |type_string| is invalid. +STORAGE_COMMON_EXPORT bool GetFileSystemPublicType( + std::string type_string, + blink::WebFileSystemType* type); + +// Encodes |file_path| to a string. +// Following conditions should be held: +// - StringToFilePath(FilePathToString(path)) == path +// - StringToFilePath(FilePathToString(path) + "/" + "SubDirectory") == +// path.AppendASCII("SubDirectory"); +// +// TODO(tzik): Replace CreateFilePath and FilePathToString in +// third_party/leveldatabase/env_chromium.cc with them. +STORAGE_COMMON_EXPORT std::string FilePathToString( + const base::FilePath& file_path); + +// Decode a file path from |file_path_string|. +STORAGE_COMMON_EXPORT base::FilePath StringToFilePath( + const std::string& file_path_string); + +// File error conversion +STORAGE_COMMON_EXPORT blink::WebFileError +FileErrorToWebFileError(base::File::Error error_code); + +// Generate a file system name for the given arguments. Should only be used by +// platform apps. +STORAGE_COMMON_EXPORT std::string GetIsolatedFileSystemName( + const GURL& origin_url, + const std::string& filesystem_id); + +// Find the file system id from |filesystem_name|. Should only be used by +// platform apps. This function will return false if the file system name is +// not of the form {origin}:Isolated_{id}, and will also check that there is an +// origin and id present. It will not check that the origin or id are valid. +STORAGE_COMMON_EXPORT bool CrackIsolatedFileSystemName( + const std::string& filesystem_name, + std::string* filesystem_id); + +// Validates the given isolated file system id. +STORAGE_COMMON_EXPORT bool ValidateIsolatedFileSystemId( + const std::string& filesystem_id); + +// Returns the root URI for an isolated filesystem for origin |origin_url| +// and |filesystem_id|. If the |optional_root_name| is given the resulting +// root URI will point to the subfolder within the isolated filesystem. +STORAGE_COMMON_EXPORT std::string GetIsolatedFileSystemRootURIString( + const GURL& origin_url, + const std::string& filesystem_id, + const std::string& optional_root_name); + +// Returns the root URI for an external filesystem for origin |origin_url| +// and |mount_name|. +STORAGE_COMMON_EXPORT std::string GetExternalFileSystemRootURIString( + const GURL& origin_url, + const std::string& mount_name); + +// Translates the net::Error to base::File::Error. +STORAGE_COMMON_EXPORT base::File::Error +NetErrorToFileError(int error); + +} // namespace storage + +#endif // STORAGE_COMMON_FILEAPI_FILE_SYSTEM_UTIL_H_ diff --git a/storage/common/quota/quota_status_code.cc b/storage/common/quota/quota_status_code.cc new file mode 100644 index 0000000..b3976e5 --- /dev/null +++ b/storage/common/quota/quota_status_code.cc @@ -0,0 +1,29 @@ +// 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/logging.h" +#include "storage/common/quota/quota_status_code.h" + +namespace storage { + +const char* QuotaStatusCodeToString(QuotaStatusCode status) { + switch (status) { + case kQuotaStatusOk: + return "OK."; + case kQuotaErrorNotSupported: + return "Operation not supported."; + case kQuotaErrorInvalidModification: + return "Invalid modification."; + case kQuotaErrorInvalidAccess: + return "Invalid access."; + case kQuotaErrorAbort: + return "Quota operation aborted."; + case kQuotaStatusUnknown: + return "Unknown error."; + } + NOTREACHED(); + return "Unknown error."; +} + +} // namespace storage diff --git a/storage/common/quota/quota_status_code.h b/storage/common/quota/quota_status_code.h new file mode 100644 index 0000000..00da235 --- /dev/null +++ b/storage/common/quota/quota_status_code.h @@ -0,0 +1,28 @@ +// 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 STORAGE_COMMON_QUOTA_QUOTA_STATUS_CODE_H_ +#define STORAGE_COMMON_QUOTA_QUOTA_STATUS_CODE_H_ + +#include "storage/common/storage_common_export.h" +#include "third_party/WebKit/public/platform/WebStorageQuotaError.h" + +namespace storage { + +enum QuotaStatusCode { + kQuotaStatusOk = 0, + kQuotaErrorNotSupported = blink::WebStorageQuotaErrorNotSupported, + kQuotaErrorInvalidModification = + blink::WebStorageQuotaErrorInvalidModification, + kQuotaErrorInvalidAccess = blink::WebStorageQuotaErrorInvalidAccess, + kQuotaErrorAbort = blink::WebStorageQuotaErrorAbort, + kQuotaStatusUnknown = -1, +}; + +STORAGE_COMMON_EXPORT const char* QuotaStatusCodeToString( + QuotaStatusCode status); + +} // namespace storage + +#endif // STORAGE_COMMON_QUOTA_QUOTA_STATUS_CODE_H_ diff --git a/storage/common/quota/quota_types.h b/storage/common/quota/quota_types.h new file mode 100644 index 0000000..c8087e6 --- /dev/null +++ b/storage/common/quota/quota_types.h @@ -0,0 +1,29 @@ +// 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 STORAGE_COMMON_QUOTA_QUOTA_TYPES_H_ +#define STORAGE_COMMON_QUOTA_QUOTA_TYPES_H_ + +#include "storage/common/quota/quota_status_code.h" + +namespace storage { + +enum StorageType { + kStorageTypeTemporary, + kStorageTypePersistent, + kStorageTypeSyncable, + kStorageTypeQuotaNotManaged, + kStorageTypeUnknown, + kStorageTypeLast = kStorageTypeUnknown +}; + +enum QuotaLimitType { + kQuotaLimitTypeUnknown, + kQuotaLimitTypeLimited, + kQuotaLimitTypeUnlimited, +}; + +} // namespace storage + +#endif // STORAGE_COMMON_QUOTA_QUOTA_TYPES_H_ diff --git a/storage/common/storage_common_export.h b/storage/common/storage_common_export.h new file mode 100644 index 0000000..3c97109 --- /dev/null +++ b/storage/common/storage_common_export.h @@ -0,0 +1,29 @@ +// 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 STORAGE_COMMON_STORAGE_COMMON_EXPORT_H_ +#define STORAGE_COMMON_STORAGE_COMMON_EXPORT_H_ + +#if defined(COMPONENT_BUILD) +#if defined(WIN32) + +#if defined(STORAGE_COMMON_IMPLEMENTATION) +#define STORAGE_COMMON_EXPORT __declspec(dllexport) +#else +#define STORAGE_COMMON_EXPORT __declspec(dllimport) +#endif // defined(STORAGE_COMMON_IMPLEMENTATION) + +#else // defined(WIN32) +#if defined(STORAGE_COMMON_IMPLEMENTATION) +#define STORAGE_COMMON_EXPORT __attribute__((visibility("default"))) +#else +#define STORAGE_COMMON_EXPORT +#endif +#endif + +#else // defined(COMPONENT_BUILD) +#define STORAGE_COMMON_EXPORT +#endif + +#endif // STORAGE_COMMON_STORAGE_COMMON_EXPORT_H_ diff --git a/storage/storage_common.gyp b/storage/storage_common.gyp new file mode 100644 index 0000000..87d34b9 --- /dev/null +++ b/storage/storage_common.gyp @@ -0,0 +1,52 @@ +# 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. + +{ + 'variables': { + 'chromium_code': 1, + }, + 'targets': [ + { + # GN version: //storage/common + 'target_name': 'storage_common', + 'type': '<(component)', + 'variables': { 'enable_wexit_time_destructors': 1, }, + 'dependencies': [ + '<(DEPTH)/base/base.gyp:base', + '<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', + '<(DEPTH)/net/net.gyp:net', + '<(DEPTH)/url/url.gyp:url_lib', + ], + 'defines': ['STORAGE_COMMON_IMPLEMENTATION'], + 'sources': [ + 'common/data_element.cc', + 'common/data_element.h', + 'common/blob/blob_data.cc', + 'common/blob/blob_data.h', + 'common/blob/scoped_file.cc', + 'common/blob/scoped_file.h', + 'common/blob/shareable_file_reference.cc', + 'common/blob/shareable_file_reference.h', + 'common/database/database_connections.cc', + 'common/database/database_connections.h', + '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', + 'common/fileapi/file_system_info.h', + 'common/fileapi/file_system_mount_option.h', + 'common/fileapi/file_system_types.h', + 'common/fileapi/file_system_util.cc', + 'common/fileapi/file_system_util.h', + 'common/quota/quota_status_code.cc', + 'common/quota/quota_status_code.h', + 'common/quota/quota_types.h', + 'common/storage_common_export.h', + ], + # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. + 'msvs_disabled_warnings': [ 4267, ], + }, + ], +} diff --git a/webkit/DEPS b/webkit/DEPS index 6e69dfd..2d45bbb 100644 --- a/webkit/DEPS +++ b/webkit/DEPS @@ -24,6 +24,7 @@ include_rules = [ # For databases/ "+sql", + "+storage", # For gpu/ "+ui/gfx", diff --git a/webkit/browser/BUILD.gn b/webkit/browser/BUILD.gn index ab47b35..0a74f5e 100644 --- a/webkit/browser/BUILD.gn +++ b/webkit/browser/BUILD.gn @@ -2,6 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +# GYP version: webkit/storage_browser.gyp:storage component("storage") { output_name = "storage" sources = [ @@ -164,11 +165,10 @@ component("storage") { "//base/third_party/dynamic_annotations", "//net", "//sql", + "//storage/common", "//third_party/leveldatabase", "//third_party/sqlite", "//url", - "//webkit/common", - "//webkit/common:storage_common", ] # TODO(GYP) support chrome_multiple_dll @@ -187,6 +187,6 @@ executable("dump_file_system") { deps = [ ":storage", "//base", - "//webkit/common:storage_common", + "//storage/common", ] } diff --git a/webkit/common/BUILD.gn b/webkit/common/BUILD.gn deleted file mode 100644 index 591f299..0000000 --- a/webkit/common/BUILD.gn +++ /dev/null @@ -1,62 +0,0 @@ -# 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", - "webkit_common_export.h", - ] - - defines = [ "WEBKIT_COMMON_IMPLEMENTATION" ] - - deps = [ - "//base", - "//url", - ] -} - -component("storage_common") { - output_name = "storage" - sources = [ - "storage_common_export.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 = [ "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/webkit/common/blob/blob_data.cc b/webkit/common/blob/blob_data.cc deleted file mode 100644 index 4718c74..0000000 --- a/webkit/common/blob/blob_data.cc +++ /dev/null @@ -1,63 +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/blob_data.h" - -#include "base/logging.h" -#include "base/strings/sys_string_conversions.h" -#include "base/strings/utf_string_conversions.h" -#include "base/time/time.h" - -namespace storage { - -BlobData::BlobData() {} -BlobData::BlobData(const std::string& uuid) - : uuid_(uuid) { -} - -BlobData::~BlobData() {} - -void BlobData::AppendData(const char* data, size_t length) { - DCHECK(length > 0); - items_.push_back(Item()); - items_.back().SetToBytes(data, length); -} - -void BlobData::AppendFile(const base::FilePath& file_path, - uint64 offset, uint64 length, - const base::Time& expected_modification_time) { - DCHECK(length > 0); - items_.push_back(Item()); - items_.back().SetToFilePathRange(file_path, offset, length, - expected_modification_time); -} - -void BlobData::AppendBlob(const std::string& uuid, - uint64 offset, uint64 length) { - DCHECK_GT(length, 0ul); - items_.push_back(Item()); - items_.back().SetToBlobRange(uuid, offset, length); -} - -void BlobData::AppendFileSystemFile( - const GURL& url, uint64 offset, - uint64 length, - const base::Time& expected_modification_time) { - DCHECK(length > 0); - items_.push_back(Item()); - items_.back().SetToFileSystemUrlRange(url, offset, length, - expected_modification_time); -} - -int64 BlobData::GetMemoryUsage() const { - int64 memory = 0; - for (std::vector::const_iterator iter = items_.begin(); - iter != items_.end(); ++iter) { - if (iter->type() == Item::TYPE_BYTES) - memory += iter->length(); - } - return memory; -} - -} // namespace storage diff --git a/webkit/common/blob/blob_data.h b/webkit/common/blob/blob_data.h index 6918679..25d1fa2 100644 --- a/webkit/common/blob/blob_data.h +++ b/webkit/common/blob/blob_data.h @@ -1,98 +1,5 @@ -// 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. -#ifndef WEBKIT_COMMON_BLOB_BLOB_DATA_H_ -#define WEBKIT_COMMON_BLOB_BLOB_DATA_H_ - -#include -#include - -#include "base/basictypes.h" -#include "base/files/file_path.h" -#include "base/memory/ref_counted.h" -#include "base/time/time.h" -#include "url/gurl.h" -#include "webkit/common/blob/shareable_file_reference.h" -#include "webkit/common/data_element.h" -#include "webkit/common/storage_common_export.h" - -namespace storage { - -class STORAGE_COMMON_EXPORT BlobData - : public base::RefCounted { - public: - typedef storage::DataElement Item; - - // TODO(michaeln): remove the empty ctor when we fully transition to uuids. - BlobData(); - explicit BlobData(const std::string& uuid); - - void AppendData(const std::string& data) { - AppendData(data.c_str(), data.size()); - } - - void AppendData(const char* data, size_t length); - - void AppendFile(const base::FilePath& file_path, uint64 offset, uint64 length, - const base::Time& expected_modification_time); - void AppendBlob(const std::string& uuid, uint64 offset, uint64 length); - void AppendFileSystemFile(const GURL& url, uint64 offset, uint64 length, - const base::Time& expected_modification_time); - - void AttachShareableFileReference(ShareableFileReference* reference) { - shareable_files_.push_back(reference); - } - - const std::string& uuid() const { return uuid_; } - const std::vector& items() const { return items_; } - const std::string& content_type() const { return content_type_; } - void set_content_type(const std::string& content_type) { - content_type_ = content_type; - } - - const std::string& content_disposition() const { - return content_disposition_; - } - void set_content_disposition(const std::string& content_disposition) { - content_disposition_ = content_disposition; - } - - int64 GetMemoryUsage() const; - - private: - friend class base::RefCounted; - virtual ~BlobData(); - - std::string uuid_; - std::string content_type_; - std::string content_disposition_; - std::vector items_; - std::vector > shareable_files_; - - DISALLOW_COPY_AND_ASSIGN(BlobData); -}; - -#if defined(UNIT_TEST) -inline bool operator==(const BlobData& a, const BlobData& b) { - if (a.content_type() != b.content_type()) - return false; - if (a.content_disposition() != b.content_disposition()) - return false; - if (a.items().size() != b.items().size()) - return false; - for (size_t i = 0; i < a.items().size(); ++i) { - if (a.items()[i] != b.items()[i]) - return false; - } - return true; -} - -inline bool operator!=(const BlobData& a, const BlobData& b) { - return !(a == b); -} -#endif // defined(UNIT_TEST) - -} // namespace storage - -#endif // WEBKIT_COMMON_BLOB_BLOB_DATA_H_ +#include "storage/common/blob/blob_data.h" diff --git a/webkit/common/blob/scoped_file.cc b/webkit/common/blob/scoped_file.cc deleted file mode 100644 index 19e68e1..0000000 --- a/webkit/common/blob/scoped_file.cc +++ /dev/null @@ -1,85 +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/blob/scoped_file.h" - -#include "base/bind.h" -#include "base/callback.h" -#include "base/file_util.h" -#include "base/location.h" -#include "base/message_loop/message_loop_proxy.h" -#include "base/task_runner.h" - -namespace storage { - -ScopedFile::ScopedFile() - : scope_out_policy_(DONT_DELETE_ON_SCOPE_OUT) { -} - -ScopedFile::ScopedFile(const base::FilePath& path, - ScopeOutPolicy policy, - const scoped_refptr& file_task_runner) - : path_(path), - scope_out_policy_(policy), - file_task_runner_(file_task_runner) { - DCHECK(path.empty() || policy != DELETE_ON_SCOPE_OUT || - file_task_runner.get()) - << "path:" << path.value() << " policy:" << policy - << " runner:" << file_task_runner; -} - -ScopedFile::ScopedFile(RValue other) { - MoveFrom(*other.object); -} - -ScopedFile::~ScopedFile() { - Reset(); -} - -void ScopedFile::AddScopeOutCallback( - const ScopeOutCallback& callback, - base::TaskRunner* callback_runner) { - if (!callback_runner) - callback_runner = base::MessageLoopProxy::current().get(); - scope_out_callbacks_.push_back(std::make_pair(callback, callback_runner)); -} - -base::FilePath ScopedFile::Release() { - base::FilePath path = path_; - path_.clear(); - scope_out_callbacks_.clear(); - scope_out_policy_ = DONT_DELETE_ON_SCOPE_OUT; - return path; -} - -void ScopedFile::Reset() { - if (path_.empty()) - return; - - for (ScopeOutCallbackList::iterator iter = scope_out_callbacks_.begin(); - iter != scope_out_callbacks_.end(); ++iter) { - iter->second->PostTask(FROM_HERE, base::Bind(iter->first, path_)); - } - - if (scope_out_policy_ == DELETE_ON_SCOPE_OUT) { - file_task_runner_->PostTask( - FROM_HERE, - base::Bind(base::IgnoreResult(&base::DeleteFile), - path_, false /* recursive */)); - } - - // Clear all fields. - Release(); -} - -void ScopedFile::MoveFrom(ScopedFile& other) { - Reset(); - - scope_out_policy_ = other.scope_out_policy_; - scope_out_callbacks_.swap(other.scope_out_callbacks_); - file_task_runner_ = other.file_task_runner_; - path_ = other.Release(); -} - -} // namespace storage diff --git a/webkit/common/blob/scoped_file.h b/webkit/common/blob/scoped_file.h index 78e592e..027ab3b 100644 --- a/webkit/common/blob/scoped_file.h +++ b/webkit/common/blob/scoped_file.h @@ -1,94 +1,5 @@ -// Copyright (c) 2013 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. -#ifndef WEBKIT_COMMON_BLOB_SCOPED_FILE_H_ -#define WEBKIT_COMMON_BLOB_SCOPED_FILE_H_ - -#include - -#include "base/callback_forward.h" -#include "base/files/file_path.h" -#include "base/memory/ref_counted.h" -#include "base/move.h" -#include "webkit/common/storage_common_export.h" - -namespace base { -class TaskRunner; -} - -namespace storage { - -// A scoped reference for a FilePath that can optionally schedule the file -// to be deleted and/or to notify a consumer when it is going to be scoped out. -// This class supports move semantics, i.e. consumers can call Pass() to -// pass the ownership of ScopedFile. -// -// TODO(kinuko): Probably this can be moved under base or somewhere more -// common place. -class STORAGE_COMMON_EXPORT ScopedFile { - // To support destructive assignment from an l-value assignment. - // This provides Pass() method which creates an r-value for the current - // instance. (See base/move.h for details) - MOVE_ONLY_TYPE_FOR_CPP_03(ScopedFile, RValue) - - public: - typedef base::Callback ScopeOutCallback; - typedef std::pair > - ScopeOutCallbackPair; - typedef std::vector ScopeOutCallbackList; - - enum ScopeOutPolicy { - DELETE_ON_SCOPE_OUT, - DONT_DELETE_ON_SCOPE_OUT, - }; - - ScopedFile(); - - // |file_task_runner| is used to schedule a file deletion if |policy| - // is DELETE_ON_SCOPE_OUT. - ScopedFile(const base::FilePath& path, - ScopeOutPolicy policy, - const scoped_refptr& file_task_runner); - - // Move constructor and operator. The data of r-value will be transfered - // in a destructive way. (See base/move.h) - ScopedFile(RValue other); - ScopedFile& operator=(RValue rhs) { - MoveFrom(*rhs.object); - return *this; - } - - ~ScopedFile(); - - // The |callback| is fired on |callback_runner| when the final reference - // of this instance is released. - // If release policy is DELETE_ON_SCOPE_OUT the - // callback task(s) is/are posted before the deletion is scheduled. - void AddScopeOutCallback(const ScopeOutCallback& callback, - base::TaskRunner* callback_runner); - - // The full file path. - const base::FilePath& path() const { return path_; } - - // Releases the file. After calling this, this instance will hold - // an empty file path and scoping out won't make any file deletion - // or callback dispatch. (If an owned pointer is attached to any of - // callbacks the pointer will be deleted.) - base::FilePath Release(); - - void Reset(); - - private: - // Performs destructive move from |other| to this. - void MoveFrom(ScopedFile& other); - - base::FilePath path_; - ScopeOutPolicy scope_out_policy_; - scoped_refptr file_task_runner_; - ScopeOutCallbackList scope_out_callbacks_; -}; - -} // namespace storage - -#endif // WEBKIT_COMMON_BLOB_SCOPED_FILE_H_ +#include "storage/common/blob/scoped_file.h" diff --git a/webkit/common/blob/shareable_file_reference.cc b/webkit/common/blob/shareable_file_reference.cc deleted file mode 100644 index 93d0631e..0000000 --- a/webkit/common/blob/shareable_file_reference.cc +++ /dev/null @@ -1,119 +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 - -#include "base/lazy_instance.h" -#include "base/message_loop/message_loop_proxy.h" -#include "base/task_runner.h" -#include "base/threading/non_thread_safe.h" - -namespace storage { - -namespace { - -// A shareable file map with enforcement of thread checker. -class ShareableFileMap : public base::NonThreadSafe { - public: - typedef std::map FileMap; - typedef FileMap::iterator iterator; - typedef FileMap::key_type key_type; - typedef FileMap::value_type value_type; - - ShareableFileMap() {} - - ~ShareableFileMap() { - DetachFromThread(); - } - - iterator Find(key_type key) { - DCHECK(CalledOnValidThread()); - return file_map_.find(key); - } - - iterator End() { - DCHECK(CalledOnValidThread()); - return file_map_.end(); - } - - std::pair Insert(value_type value) { - DCHECK(CalledOnValidThread()); - return file_map_.insert(value); - } - - void Erase(key_type key) { - DCHECK(CalledOnValidThread()); - file_map_.erase(key); - } - - private: - FileMap file_map_; - DISALLOW_COPY_AND_ASSIGN(ShareableFileMap); -}; - -base::LazyInstance g_file_map = LAZY_INSTANCE_INITIALIZER; - -} // namespace - -// static -scoped_refptr ShareableFileReference::Get( - const base::FilePath& path) { - ShareableFileMap::iterator found = g_file_map.Get().Find(path); - ShareableFileReference* reference = - (found == g_file_map.Get().End()) ? NULL : found->second; - return scoped_refptr(reference); -} - -// static -scoped_refptr ShareableFileReference::GetOrCreate( - const base::FilePath& path, - FinalReleasePolicy policy, - base::TaskRunner* file_task_runner) { - return GetOrCreate( - ScopedFile(path, static_cast(policy), - file_task_runner)); -} - -// static -scoped_refptr ShareableFileReference::GetOrCreate( - ScopedFile scoped_file) { - if (scoped_file.path().empty()) - return scoped_refptr(); - - typedef std::pair InsertResult; - // Required for VS2010: http://connect.microsoft.com/VisualStudio/feedback/details/520043/error-converting-from-null-to-a-pointer-type-in-std-pair - storage::ShareableFileReference* null_reference = NULL; - InsertResult result = g_file_map.Get().Insert( - ShareableFileMap::value_type(scoped_file.path(), null_reference)); - if (result.second == false) { - scoped_file.Release(); - return scoped_refptr(result.first->second); - } - - // Wasn't in the map, create a new reference and store the pointer. - scoped_refptr reference( - new ShareableFileReference(scoped_file.Pass())); - result.first->second = reference.get(); - return reference; -} - -void ShareableFileReference::AddFinalReleaseCallback( - const FinalReleaseCallback& callback) { - DCHECK(g_file_map.Get().CalledOnValidThread()); - scoped_file_.AddScopeOutCallback(callback, NULL); -} - -ShareableFileReference::ShareableFileReference(ScopedFile scoped_file) - : scoped_file_(scoped_file.Pass()) { - DCHECK(g_file_map.Get().Find(path())->second == NULL); -} - -ShareableFileReference::~ShareableFileReference() { - DCHECK(g_file_map.Get().Find(path())->second == this); - g_file_map.Get().Erase(path()); -} - -} // namespace storage diff --git a/webkit/common/blob/shareable_file_reference.h b/webkit/common/blob/shareable_file_reference.h index 2e011f4..5702067 100644 --- a/webkit/common/blob/shareable_file_reference.h +++ b/webkit/common/blob/shareable_file_reference.h @@ -1,74 +1,5 @@ -// 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. -#ifndef WEBKIT_COMMON_BLOB_SHAREABLE_FILE_REFERENCE_H_ -#define WEBKIT_COMMON_BLOB_SHAREABLE_FILE_REFERENCE_H_ - -#include - -#include "webkit/common/blob/scoped_file.h" - -namespace storage { - -// ShareableFileReference allows consumers to share FileReference for the -// same path if it already exists in its internal map. -// This class is non-thread-safe and all methods must be called on a single -// thread. -class STORAGE_COMMON_EXPORT ShareableFileReference - : public base::RefCounted { - public: - typedef ScopedFile::ScopeOutCallback FinalReleaseCallback; - - enum FinalReleasePolicy { - DELETE_ON_FINAL_RELEASE = ScopedFile::DELETE_ON_SCOPE_OUT, - DONT_DELETE_ON_FINAL_RELEASE = ScopedFile::DONT_DELETE_ON_SCOPE_OUT, - }; - - // Returns a ShareableFileReference for the given path, if no reference - // for this path exists returns NULL. - static scoped_refptr Get(const base::FilePath& path); - - // Returns a ShareableFileReference for the given path, creating a new - // reference if none yet exists. If there's a pre-existing reference for - // the path, the policy parameter of this method is ignored. - static scoped_refptr GetOrCreate( - const base::FilePath& path, - FinalReleasePolicy policy, - base::TaskRunner* file_task_runner); - - // Returns a ShareableFileReference for the given path of the |scoped_file|, - // creating a new reference if none yet exists. The ownership of |scoped_file| - // is passed to this reference. - // If there's a pre-existing reference for the path, the scope out policy - // and scope-out-callbacks of the given |scoped_file| is ignored. - // If the given scoped_file has an empty path (e.g. maybe already - // released) this returns NULL reference. - // - // TODO(kinuko): Make sure if this behavior is ok, we could alternatively - // merge callbacks to the existing one. - static scoped_refptr GetOrCreate( - ScopedFile scoped_file); - - // The full file path. - const base::FilePath& path() const { return scoped_file_.path(); } - - // The |callback| is fired when the final reference of this instance - // is released. If release policy is DELETE_ON_FINAL_RELEASE the - // callback task(s) is/are posted before the deletion is scheduled. - void AddFinalReleaseCallback(const FinalReleaseCallback& callback); - - private: - friend class base::RefCounted; - - ShareableFileReference(ScopedFile scoped_file); - ~ShareableFileReference(); - - ScopedFile scoped_file_; - - DISALLOW_COPY_AND_ASSIGN(ShareableFileReference); -}; - -} // namespace storage - -#endif // WEBKIT_COMMON_BLOB_SHAREABLE_FILE_REFERENCE_H_ +#include "storage/common/blob/shareable_file_reference.h" diff --git a/webkit/common/data_element.cc b/webkit/common/data_element.cc deleted file mode 100644 index 024abe4..0000000 --- a/webkit/common/data_element.cc +++ /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. - -#include "webkit/common/data_element.h" - -namespace storage { - -DataElement::DataElement() - : type_(TYPE_UNKNOWN), - bytes_(NULL), - offset_(0), - length_(kuint64max) { -} - -DataElement::~DataElement() {} - -void DataElement::SetToFilePathRange( - const base::FilePath& path, - uint64 offset, uint64 length, - const base::Time& expected_modification_time) { - type_ = TYPE_FILE; - path_ = path; - offset_ = offset; - length_ = length; - expected_modification_time_ = expected_modification_time; -} - -void DataElement::SetToBlobRange( - const std::string& blob_uuid, - uint64 offset, uint64 length) { - type_ = TYPE_BLOB; - blob_uuid_ = blob_uuid; - offset_ = offset; - length_ = length; -} - -void DataElement::SetToFileSystemUrlRange( - const GURL& filesystem_url, - uint64 offset, uint64 length, - const base::Time& expected_modification_time) { - type_ = TYPE_FILE_FILESYSTEM; - filesystem_url_ = filesystem_url; - offset_ = offset; - length_ = length; - expected_modification_time_ = expected_modification_time; -} - -} // webkit_common diff --git a/webkit/common/data_element.h b/webkit/common/data_element.h index 33c5c1b..88e0e75 100644 --- a/webkit/common/data_element.h +++ b/webkit/common/data_element.h @@ -1,127 +1,5 @@ -// Copyright 2013 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. -#ifndef WEBKIT_COMMON_DATA_ELEMENT_H_ -#define WEBKIT_COMMON_DATA_ELEMENT_H_ - -#include -#include - -#include "base/basictypes.h" -#include "base/files/file_path.h" -#include "base/logging.h" -#include "base/time/time.h" -#include "url/gurl.h" -#include "webkit/common/webkit_common_export.h" - -namespace storage { - -// Represents a base Web data element. This could be either one of -// bytes, file or blob data. -class WEBKIT_COMMON_EXPORT DataElement { - public: - enum Type { - TYPE_UNKNOWN = -1, - TYPE_BYTES, - TYPE_FILE, - TYPE_BLOB, - TYPE_FILE_FILESYSTEM, - }; - - DataElement(); - ~DataElement(); - - Type type() const { return type_; } - const char* bytes() const { return bytes_ ? bytes_ : &buf_[0]; } - const base::FilePath& path() const { return path_; } - const GURL& filesystem_url() const { return filesystem_url_; } - const std::string& blob_uuid() const { return blob_uuid_; } - uint64 offset() const { return offset_; } - uint64 length() const { return length_; } - const base::Time& expected_modification_time() const { - return expected_modification_time_; - } - - // Sets TYPE_BYTES data. This copies the given data into the element. - void SetToBytes(const char* bytes, int bytes_len) { - type_ = TYPE_BYTES; - buf_.assign(bytes, bytes + bytes_len); - length_ = buf_.size(); - } - - // Sets TYPE_BYTES data. This does NOT copy the given data and the caller - // should make sure the data is alive when this element is accessed. - void SetToSharedBytes(const char* bytes, int bytes_len) { - type_ = TYPE_BYTES; - bytes_ = bytes; - length_ = bytes_len; - } - - // Sets TYPE_FILE data. - void SetToFilePath(const base::FilePath& path) { - SetToFilePathRange(path, 0, kuint64max, base::Time()); - } - - // Sets TYPE_BLOB data. - void SetToBlob(const std::string& uuid) { - SetToBlobRange(uuid, 0, kuint64max); - } - - // Sets TYPE_FILE data with range. - void SetToFilePathRange(const base::FilePath& path, - uint64 offset, uint64 length, - const base::Time& expected_modification_time); - - // Sets TYPE_BLOB data with range. - void SetToBlobRange(const std::string& blob_uuid, - uint64 offset, uint64 length); - - // Sets TYPE_FILE_FILESYSTEM with range. - void SetToFileSystemUrlRange(const GURL& filesystem_url, - uint64 offset, uint64 length, - const base::Time& expected_modification_time); - - private: - Type type_; - std::vector buf_; // For TYPE_BYTES. - const char* bytes_; // For TYPE_BYTES. - base::FilePath path_; // For TYPE_FILE. - GURL filesystem_url_; // For TYPE_FILE_FILESYSTEM. - std::string blob_uuid_; - uint64 offset_; - uint64 length_; - base::Time expected_modification_time_; -}; - -#if defined(UNIT_TEST) -inline bool operator==(const DataElement& a, const DataElement& b) { - if (a.type() != b.type() || - a.offset() != b.offset() || - a.length() != b.length()) - return false; - switch (a.type()) { - case DataElement::TYPE_BYTES: - return memcmp(a.bytes(), b.bytes(), b.length()) == 0; - case DataElement::TYPE_FILE: - return a.path() == b.path() && - a.expected_modification_time() == b.expected_modification_time(); - case DataElement::TYPE_BLOB: - return a.blob_uuid() == b.blob_uuid(); - case DataElement::TYPE_FILE_FILESYSTEM: - return a.filesystem_url() == b.filesystem_url(); - case DataElement::TYPE_UNKNOWN: - NOTREACHED(); - return false; - } - return false; -} - -inline bool operator!=(const DataElement& a, const DataElement& b) { - return !(a == b); -} -#endif // defined(UNIT_TEST) - -} // namespace storage - -#endif // WEBKIT_COMMON_DATA_ELEMENT_H_ +#include "storage/common/data_element.h" diff --git a/webkit/common/database/database_connections.cc b/webkit/common/database/database_connections.cc deleted file mode 100644 index bb2eaee..0000000 --- a/webkit/common/database/database_connections.cc +++ /dev/null @@ -1,175 +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/database/database_connections.h" - -#include "base/auto_reset.h" -#include "base/bind.h" -#include "base/logging.h" -#include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" - -namespace storage { - -DatabaseConnections::DatabaseConnections() { -} - -DatabaseConnections::~DatabaseConnections() { - DCHECK(connections_.empty()); -} - -bool DatabaseConnections::IsEmpty() const { - return connections_.empty(); -} - -bool DatabaseConnections::IsDatabaseOpened( - const std::string& origin_identifier, - const base::string16& database_name) const { - OriginConnections::const_iterator origin_it = - connections_.find(origin_identifier); - if (origin_it == connections_.end()) - return false; - const DBConnections& origin_connections = origin_it->second; - return (origin_connections.find(database_name) != origin_connections.end()); -} - -bool DatabaseConnections::IsOriginUsed( - const std::string& origin_identifier) const { - return (connections_.find(origin_identifier) != connections_.end()); -} - -bool DatabaseConnections::AddConnection( - const std::string& origin_identifier, - const base::string16& database_name) { - int& count = connections_[origin_identifier][database_name].first; - return ++count == 1; -} - -bool DatabaseConnections::RemoveConnection( - const std::string& origin_identifier, - const base::string16& database_name) { - return RemoveConnectionsHelper(origin_identifier, database_name, 1); -} - -void DatabaseConnections::RemoveAllConnections() { - connections_.clear(); -} - -void DatabaseConnections::RemoveConnections( - const DatabaseConnections& connections, - std::vector >* closed_dbs) { - for (OriginConnections::const_iterator origin_it = - connections.connections_.begin(); - origin_it != connections.connections_.end(); - origin_it++) { - const DBConnections& db_connections = origin_it->second; - for (DBConnections::const_iterator db_it = db_connections.begin(); - db_it != db_connections.end(); db_it++) { - if (RemoveConnectionsHelper(origin_it->first, db_it->first, - db_it->second.first)) - closed_dbs->push_back(std::make_pair(origin_it->first, db_it->first)); - } - } -} - -int64 DatabaseConnections::GetOpenDatabaseSize( - const std::string& origin_identifier, - const base::string16& database_name) const { - DCHECK(IsDatabaseOpened(origin_identifier, database_name)); - return connections_[origin_identifier][database_name].second; -} - -void DatabaseConnections::SetOpenDatabaseSize( - const std::string& origin_identifier, - const base::string16& database_name, - int64 size) { - DCHECK(IsDatabaseOpened(origin_identifier, database_name)); - connections_[origin_identifier][database_name].second = size; -} - -void DatabaseConnections::ListConnections( - std::vector > *list) const { - for (OriginConnections::const_iterator origin_it = - connections_.begin(); - origin_it != connections_.end(); - origin_it++) { - const DBConnections& db_connections = origin_it->second; - for (DBConnections::const_iterator db_it = db_connections.begin(); - db_it != db_connections.end(); db_it++) { - list->push_back(std::make_pair(origin_it->first, db_it->first)); - } - } -} - -bool DatabaseConnections::RemoveConnectionsHelper( - const std::string& origin_identifier, - const base::string16& database_name, - int num_connections) { - OriginConnections::iterator origin_iterator = - connections_.find(origin_identifier); - DCHECK(origin_iterator != connections_.end()); - DBConnections& db_connections = origin_iterator->second; - int& count = db_connections[database_name].first; - DCHECK(count >= num_connections); - count -= num_connections; - if (count) - return false; - db_connections.erase(database_name); - if (db_connections.empty()) - connections_.erase(origin_iterator); - return true; -} - -DatabaseConnectionsWrapper::DatabaseConnectionsWrapper() - : waiting_for_dbs_to_close_(false), - main_thread_(base::MessageLoopProxy::current()) { -} - -DatabaseConnectionsWrapper::~DatabaseConnectionsWrapper() { -} - -void DatabaseConnectionsWrapper::WaitForAllDatabasesToClose() { - // We assume that new databases won't be open while we're waiting. - DCHECK(main_thread_->BelongsToCurrentThread()); - if (HasOpenConnections()) { - base::AutoReset auto_reset(&waiting_for_dbs_to_close_, true); - base::MessageLoop::ScopedNestableTaskAllower allow( - base::MessageLoop::current()); - base::MessageLoop::current()->Run(); - } -} - -bool DatabaseConnectionsWrapper::HasOpenConnections() { - DCHECK(main_thread_->BelongsToCurrentThread()); - base::AutoLock auto_lock(open_connections_lock_); - return !open_connections_.IsEmpty(); -} - -void DatabaseConnectionsWrapper::AddOpenConnection( - const std::string& origin_identifier, - const base::string16& database_name) { - // We add to the collection immediately on any thread. - base::AutoLock auto_lock(open_connections_lock_); - open_connections_.AddConnection(origin_identifier, database_name); -} - -void DatabaseConnectionsWrapper::RemoveOpenConnection( - const std::string& origin_identifier, - const base::string16& database_name) { - // But only remove from the collection on the main thread - // so we can handle the waiting_for_dbs_to_close_ case. - if (!main_thread_->BelongsToCurrentThread()) { - main_thread_->PostTask( - FROM_HERE, - base::Bind(&DatabaseConnectionsWrapper::RemoveOpenConnection, this, - origin_identifier, database_name)); - return; - } - base::AutoLock auto_lock(open_connections_lock_); - open_connections_.RemoveConnection(origin_identifier, database_name); - if (waiting_for_dbs_to_close_ && open_connections_.IsEmpty()) - base::MessageLoop::current()->Quit(); -} - -} // namespace storage diff --git a/webkit/common/database/database_connections.h b/webkit/common/database/database_connections.h index 88421cb..b847909 100644 --- a/webkit/common/database/database_connections.h +++ b/webkit/common/database/database_connections.h @@ -1,99 +1,5 @@ -// Copyright (c) 2011 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. -#ifndef WEBKIT_COMMON_DATABASE_DATABASE_CONNECTIONS_H_ -#define WEBKIT_COMMON_DATABASE_DATABASE_CONNECTIONS_H_ - -#include -#include -#include - -#include "base/memory/ref_counted.h" -#include "base/strings/string16.h" -#include "base/synchronization/lock.h" -#include "webkit/common/storage_common_export.h" - -namespace base { -class MessageLoopProxy; -} - -namespace storage { - -class STORAGE_COMMON_EXPORT DatabaseConnections { - public: - DatabaseConnections(); - ~DatabaseConnections(); - - bool IsEmpty() const; - bool IsDatabaseOpened(const std::string& origin_identifier, - const base::string16& database_name) const; - bool IsOriginUsed(const std::string& origin_identifier) const; - - // Returns true if this is the first connection. - bool AddConnection(const std::string& origin_identifier, - const base::string16& database_name); - - // Returns true if the last connection was removed. - bool RemoveConnection(const std::string& origin_identifier, - const base::string16& database_name); - - void RemoveAllConnections(); - void RemoveConnections( - const DatabaseConnections& connections, - std::vector >* closed_dbs); - - // Database sizes can be kept only if IsDatabaseOpened returns true. - int64 GetOpenDatabaseSize(const std::string& origin_identifier, - const base::string16& database_name) const; - void SetOpenDatabaseSize(const std::string& origin_identifier, - const base::string16& database_name, - int64 size); - - // Returns a list of the connections, . - void ListConnections( - std::vector > *list) const; - - private: - // Mapping from name to - typedef std::map > DBConnections; - typedef std::map OriginConnections; - mutable OriginConnections connections_; // mutable for GetOpenDatabaseSize - - // Returns true if the last connection was removed. - bool RemoveConnectionsHelper(const std::string& origin_identifier, - const base::string16& database_name, - int num_connections); -}; - -// A wrapper class that provides thread-safety and the -// ability to wait until all connections have closed. -// Intended for use in renderer processes. -class STORAGE_COMMON_EXPORT DatabaseConnectionsWrapper - : public base::RefCountedThreadSafe { - public: - DatabaseConnectionsWrapper(); - - // The Wait and Has methods should only be called on the - // main thread (the thread on which the wrapper is constructed). - void WaitForAllDatabasesToClose(); - bool HasOpenConnections(); - - // Add and Remove may be called on any thread. - void AddOpenConnection(const std::string& origin_identifier, - const base::string16& database_name); - void RemoveOpenConnection(const std::string& origin_identifier, - const base::string16& database_name); - private: - ~DatabaseConnectionsWrapper(); - friend class base::RefCountedThreadSafe; - - bool waiting_for_dbs_to_close_; - base::Lock open_connections_lock_; - DatabaseConnections open_connections_; - scoped_refptr main_thread_; -}; - -} // namespace storage - -#endif // WEBKIT_COMMON_DATABASE_DATABASE_CONNECTIONS_H_ +#include "storage/common/database/database_connections.h" diff --git a/webkit/common/database/database_identifier.cc b/webkit/common/database/database_identifier.cc deleted file mode 100644 index b793ff7..0000000 --- a/webkit/common/database/database_identifier.cc +++ /dev/null @@ -1,145 +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/strings/string_number_conversions.h" -#include "base/strings/string_util.h" -#include "url/url_canon.h" - -namespace storage { - -// static -std::string GetIdentifierFromOrigin(const GURL& origin) { - return DatabaseIdentifier::CreateFromOrigin(origin).ToString(); -} - -// static -GURL GetOriginFromIdentifier(const std::string& identifier) { - return DatabaseIdentifier::Parse(identifier).ToOrigin(); -} - -static bool SchemeIsUnique(const std::string& scheme) { - return scheme == "about" || scheme == "data" || scheme == "javascript"; -} - -// static -const DatabaseIdentifier DatabaseIdentifier::UniqueFileIdentifier() { - return DatabaseIdentifier("", "", 0, true, true); -} - -// static -DatabaseIdentifier DatabaseIdentifier::CreateFromOrigin(const GURL& origin) { - if (!origin.is_valid() || origin.is_empty() || - !origin.IsStandard() || SchemeIsUnique(origin.scheme())) - return DatabaseIdentifier(); - - if (origin.SchemeIsFile()) - return UniqueFileIdentifier(); - - int port = origin.IntPort(); - 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::PORT_UNSPECIFIED) - port = 0; - - return DatabaseIdentifier(origin.scheme(), - origin.host(), - port, - false /* unique */, - false /* file */); -} - -// static -DatabaseIdentifier DatabaseIdentifier::Parse(const std::string& 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) - return DatabaseIdentifier(); - - size_t last_underscore = identifier.find_last_of('_'); - if (last_underscore == std::string::npos || - last_underscore == first_underscore || - last_underscore == identifier.length() - 1) - return DatabaseIdentifier(); - - std::string scheme(identifier.data(), first_underscore); - if (scheme == "file") - return UniqueFileIdentifier(); - - // This magical set of schemes is always treated as unique. - if (SchemeIsUnique(scheme)) - return DatabaseIdentifier(); - - base::StringPiece port_str(identifier.begin() + last_underscore + 1, - identifier.end()); - int port = 0; - if (!base::StringToInt(port_str, &port) || port < 0 || port >= 1 << 16) - return DatabaseIdentifier(); - - std::string hostname(identifier.data() + first_underscore + 1, - last_underscore - first_underscore - 1); - GURL url(scheme + "://" + hostname + "/"); - - if (!url.IsStandard()) - hostname = ""; - - // If a url doesn't parse cleanly or doesn't round trip, reject it. - if (!url.is_valid() || url.scheme() != scheme || url.host() != hostname) - return DatabaseIdentifier(); - - return DatabaseIdentifier(scheme, hostname, port, false /* unique */, false); -} - -DatabaseIdentifier::DatabaseIdentifier() - : port_(0), - is_unique_(true), - is_file_(false) { -} - -DatabaseIdentifier::DatabaseIdentifier(const std::string& scheme, - const std::string& hostname, - int port, - bool is_unique, - bool is_file) - : scheme_(scheme), - hostname_(base::StringToLowerASCII(hostname)), - port_(port), - is_unique_(is_unique), - is_file_(is_file) { -} - -DatabaseIdentifier::~DatabaseIdentifier() {} - -std::string DatabaseIdentifier::ToString() const { - if (is_file_) - return "file__0"; - if (is_unique_) - return "__0"; - return scheme_ + "_" + hostname_ + "_" + base::IntToString(port_); -} - -GURL DatabaseIdentifier::ToOrigin() const { - if (is_file_) - return GURL("file:///"); - if (is_unique_) - return GURL(); - if (port_ == 0) - return GURL(scheme_ + "://" + hostname_); - return GURL(scheme_ + "://" + hostname_ + ":" + base::IntToString(port_)); -} - -} // namespace storage diff --git a/webkit/common/database/database_identifier.h b/webkit/common/database/database_identifier.h index b72c02b..38e2777 100644 --- a/webkit/common/database/database_identifier.h +++ b/webkit/common/database/database_identifier.h @@ -1,54 +1,5 @@ -// Copyright 2013 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. -#ifndef WEBKIT_COMMON_DATABASE_DATABASE_IDENTIFIER_H_ -#define WEBKIT_COMMON_DATABASE_DATABASE_IDENTIFIER_H_ - -#include - -#include "base/basictypes.h" -#include "base/strings/string_piece.h" -#include "url/gurl.h" -#include "webkit/common/storage_common_export.h" - -namespace storage { - -STORAGE_COMMON_EXPORT std::string GetIdentifierFromOrigin( - const GURL& origin); -STORAGE_COMMON_EXPORT GURL GetOriginFromIdentifier( - const std::string& identifier); - -class STORAGE_COMMON_EXPORT DatabaseIdentifier { - public: - static const DatabaseIdentifier UniqueFileIdentifier(); - static DatabaseIdentifier CreateFromOrigin(const GURL& origin); - static DatabaseIdentifier Parse(const std::string& identifier); - ~DatabaseIdentifier(); - - std::string ToString() const; - GURL ToOrigin() const; - - std::string scheme() const { return scheme_; } - std::string hostname() const { return hostname_; } - int port() const { return port_; } - bool is_unique() const { return is_unique_; } - - private: - DatabaseIdentifier(); - DatabaseIdentifier(const std::string& scheme, - const std::string& hostname, - int port, - bool is_unique, - bool is_file); - - std::string scheme_; - std::string hostname_; - int port_; - bool is_unique_; - bool is_file_; -}; - -} // namespace storage - -#endif // WEBKIT_COMMON_DATABASE_DATABASE_IDENTIFIER_H_ +#include "storage/common/database/database_identifier.h" diff --git a/webkit/common/fileapi/OWNERS b/webkit/common/fileapi/OWNERS deleted file mode 100644 index 232db84..0000000 --- a/webkit/common/fileapi/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -tzik@chromium.org -nhiroki@chromium.org diff --git a/webkit/common/fileapi/directory_entry.cc b/webkit/common/fileapi/directory_entry.cc deleted file mode 100644 index ea062b4..0000000 --- a/webkit/common/fileapi/directory_entry.cc +++ /dev/null @@ -1,21 +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/fileapi/directory_entry.h" - -namespace storage { - -DirectoryEntry::DirectoryEntry() : is_directory(false), size(0) {} - -DirectoryEntry::DirectoryEntry(const std::string& name, - DirectoryEntryType type, - int64 size, - const base::Time& last_modified_time) - : name(base::FilePath::FromUTF8Unsafe(name).value()), - is_directory(type == DIRECTORY), - size(size), - last_modified_time(last_modified_time) { -} - -} // namespace storage diff --git a/webkit/common/fileapi/directory_entry.h b/webkit/common/fileapi/directory_entry.h index 359fce4..536fe6f 100644 --- a/webkit/common/fileapi/directory_entry.h +++ b/webkit/common/fileapi/directory_entry.h @@ -1,38 +1,5 @@ -// Copyright 2013 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. -#ifndef WEBKIT_COMMON_FILEAPI_DIRECTORY_ENTRY_H_ -#define WEBKIT_COMMON_FILEAPI_DIRECTORY_ENTRY_H_ - -#include - -#include "base/basictypes.h" -#include "base/files/file_path.h" -#include "base/time/time.h" -#include "webkit/common/storage_common_export.h" - -namespace storage { - -// Holds metadata for file or directory entry. -struct STORAGE_COMMON_EXPORT DirectoryEntry { - enum DirectoryEntryType { - FILE, - DIRECTORY, - }; - - DirectoryEntry(); - DirectoryEntry(const std::string& name, - DirectoryEntryType type, - int64 size, - const base::Time& last_modified_time); - - base::FilePath::StringType name; - bool is_directory; - int64 size; - base::Time last_modified_time; -}; - -} // namespace storage - -#endif // WEBKIT_COMMON_FILEAPI_DIRECTORY_ENTRY_H_ +#include "storage/common/fileapi/directory_entry.h" diff --git a/webkit/common/fileapi/file_system_info.cc b/webkit/common/fileapi/file_system_info.cc deleted file mode 100644 index 40b868d..0000000 --- a/webkit/common/fileapi/file_system_info.cc +++ /dev/null @@ -1,22 +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/fileapi/file_system_info.h" - -namespace storage { - -FileSystemInfo::FileSystemInfo() - : mount_type(storage::kFileSystemTypeTemporary) { -} - -FileSystemInfo::FileSystemInfo(const std::string& name, - const GURL& root_url, - storage::FileSystemType mount_type) - : name(name), root_url(root_url), mount_type(mount_type) { -} - -FileSystemInfo::~FileSystemInfo() { -} - -} // namespace storage diff --git a/webkit/common/fileapi/file_system_info.h b/webkit/common/fileapi/file_system_info.h index eefe55e..5e20860 100644 --- a/webkit/common/fileapi/file_system_info.h +++ b/webkit/common/fileapi/file_system_info.h @@ -1,33 +1,5 @@ -// Copyright 2013 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. -#ifndef WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_INFO_H_ -#define WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_INFO_H_ - -#include - -#include "url/gurl.h" -#include "webkit/common/fileapi/file_system_types.h" -#include "webkit/common/storage_common_export.h" - -namespace storage { - -// This struct is used to send the necessary information for Blink to create a -// DOMFileSystem. Since Blink side only uses mount_type (rather than -// detailed/cracked filesystem type) this only contains mount_type but not type. -struct STORAGE_COMMON_EXPORT FileSystemInfo { - FileSystemInfo(); - FileSystemInfo(const std::string& filesystem_name, - const GURL& root_url, - storage::FileSystemType mount_type); - ~FileSystemInfo(); - - std::string name; - GURL root_url; - storage::FileSystemType mount_type; -}; - -} // namespace storage - -#endif // WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_INFO_H_ +#include "storage/common/fileapi/file_system_info.h" diff --git a/webkit/common/fileapi/file_system_mount_option.h b/webkit/common/fileapi/file_system_mount_option.h index a2ab732..fc7b325 100644 --- a/webkit/common/fileapi/file_system_mount_option.h +++ b/webkit/common/fileapi/file_system_mount_option.h @@ -1,37 +1,5 @@ -// Copyright 2013 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. -#ifndef WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_MOUNT_OPTION_H_ -#define WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_MOUNT_OPTION_H_ - -namespace storage { - -// Option for specifying if disk sync operation is wanted after copying. -enum CopySyncOption { - COPY_SYNC_OPTION_NO_SYNC, - COPY_SYNC_OPTION_SYNC, -}; - -// Conveys options for a mounted file systems. -class FileSystemMountOption { - public: - // Constructs with the default options. - FileSystemMountOption() - : copy_sync_option_(COPY_SYNC_OPTION_NO_SYNC) {} - - // Constructs with the specified component. - explicit FileSystemMountOption(CopySyncOption copy_sync_option) - : copy_sync_option_(copy_sync_option) {} - - CopySyncOption copy_sync_option() const { - return copy_sync_option_; - } - - private: - CopySyncOption copy_sync_option_; -}; - -} // namespace storage - -#endif // WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_MOUNT_OPTION_H_ +#include "storage/common/fileapi/file_system_mount_option.h" diff --git a/webkit/common/fileapi/file_system_types.h b/webkit/common/fileapi/file_system_types.h index 8a56a8b..ff8e0fd 100644 --- a/webkit/common/fileapi/file_system_types.h +++ b/webkit/common/fileapi/file_system_types.h @@ -1,137 +1,5 @@ -// 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. -#ifndef WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_TYPES_H_ -#define WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_TYPES_H_ - -#include "third_party/WebKit/public/platform/WebFileSystemType.h" - -namespace storage { - -enum FileSystemType { - // Indicates uninitialized or invalid filesystem type. - kFileSystemTypeUnknown = -1, - - // ------------------------------------------------------------------------ - // Public FileSystem types, that are embedded in filesystem: URL and exposed - // to WebKit/renderer. Both Chrome and WebKit know how to handle these types. - - // Following two types are for TEMPORARY or PERSISTENT filesystems that - // can be used by webapps via standard app-facing API - // as defined in File API: Directories and System. - // http://www.w3.org/TR/file-system-api/#temporary-vs.-persistent-storage - // They are sandboxed filesystems; all the files in the filesystems are - // placed under the profile directory with path obfuscation and quota - // enforcement. - kFileSystemTypeTemporary = blink::WebFileSystemTypeTemporary, - kFileSystemTypePersistent = blink::WebFileSystemTypePersistent, - - // Indicates non-sandboxed isolated filesystem. - kFileSystemTypeIsolated = blink::WebFileSystemTypeIsolated, - - // Indicates filesystems that are mounted externally via - // ExternalMountPoints with a well-known mount name. The mounted - // filesystems can be sandboxed or non-sandboxed. (E.g. Chrome OS mounts - // non-sandboxed removable media folder with a name 'removable', while - // chrome.syncFileSystem mounts a sandboxed filesystem with a name - // 'syncfs'.) - kFileSystemTypeExternal = blink::WebFileSystemTypeExternal, - - // ------------------------------------------------------------------------ - // Marks the beginning of internal type enum. (This is not the actual fs type) - kFileSystemInternalTypeEnumStart = 99, - - // Private FileSystem types, that should not appear in filesystem: URL as - // WebKit has no idea how to handle those types. - // - // One can register (mount) a new file system with a private file system type - // using IsolatedContext. Files in such file systems can be accessed via - // either Isolated or External public file system types (depending on - // how the file system is registered). - // See the comments for IsolatedContext and/or FileSystemURL for more details. - - // Should be used only for testing. - kFileSystemTypeTest, - - // Indicates a local filesystem where we can access files using native - // local path. - kFileSystemTypeNativeLocal, - - // Indicates a local filesystem where we can access files using native - // local path, but with restricted access. - // Restricted native local file system is in read-only mode. - kFileSystemTypeRestrictedNativeLocal, - - // Indicates a transient, isolated file system for dragged files (which could - // contain multiple dragged paths in the virtual root). - kFileSystemTypeDragged, - - // Indicates media filesystem which we can access with same manner to - // regular filesystem. - kFileSystemTypeNativeMedia, - - // Indicates media filesystem to which we need special protocol to access, - // such as MTP or PTP. - kFileSystemTypeDeviceMedia, - - // Indicates a Picasa virtual filesystem provided by Media Galleries API. - kFileSystemTypePicasa, - - // Indicates a synthetic iTunes filesystem. - kFileSystemTypeItunes, - - // Indicates a synthetic iPhoto filesystem. - kFileSystemTypeIphoto, - - // Indicates a Drive filesystem which provides access to Google Drive. - kFileSystemTypeDrive, - - // Indicates a Syncable sandboxed filesystem which can be backed by a - // cloud storage service. - kFileSystemTypeSyncable, - - // Indicates a special filesystem type for internal file sync operation - // for Syncable sandboxed filesystems. The file system is overlayed, i.e. - // points to the same sandboxed filesystem as that of kFileSystemTypeSyncable, - // but the changes made with this filesystem type are not recorded for - // further sync. - kFileSystemTypeSyncableForInternalSync, - - // Indicates an external filesystem accessible by file paths from platform - // Apps. As of writing, on non Chrome OS platform, this is merely a - // kFileSystemTypeNativeLocal. On Chrome OS, the path is parsed by - // the handlers of kFileSystemTypeExternal. - kFileSystemTypeNativeForPlatformApp, - - // Indicates an isolated filesystem which is supposed to contain one - // temporary which is supposed to go away when the last reference of - // its snapshot is dropped. - // This type is useful for creating a blob reference for a temporary - // file which must go away when the blob's last reference is dropped. - kFileSystemTypeForTransientFile, - - // Sandboxed private filesystem. This filesystem cannot be opened - // via regular OpenFileSystem, and provides private filesystem space for - // 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. - kFileSystemInternalTypeEnumEnd, -}; - -} // namespace storage - -#endif // WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_TYPES_H_ +#include "storage/common/fileapi/file_system_types.h" diff --git a/webkit/common/fileapi/file_system_util.cc b/webkit/common/fileapi/file_system_util.cc deleted file mode 100644 index f5e3531..0000000 --- a/webkit/common/fileapi/file_system_util.cc +++ /dev/null @@ -1,511 +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 - -#include "base/files/file_path.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 "net/base/escape.h" -#include "net/base/net_errors.h" -#include "url/gurl.h" -#include "webkit/common/database/database_identifier.h" - -namespace storage { - -const char kPersistentDir[] = "/persistent"; -const char kTemporaryDir[] = "/temporary"; -const char kIsolatedDir[] = "/isolated"; -const char kExternalDir[] = "/external"; -const char kTestDir[] = "/test"; - -const base::FilePath::CharType VirtualPath::kRoot[] = FILE_PATH_LITERAL("/"); -const base::FilePath::CharType VirtualPath::kSeparator = FILE_PATH_LITERAL('/'); - -// TODO(ericu): Consider removing support for '\', even on Windows, if possible. -// There's a lot of test code that will need reworking, and we may have trouble -// with base::FilePath elsewhere [e.g. DirName and other methods may also need -// replacement]. -base::FilePath VirtualPath::BaseName(const base::FilePath& virtual_path) { - base::FilePath::StringType path = virtual_path.value(); - - // Keep everything after the final separator, but if the pathname is only - // one character and it's a separator, leave it alone. - while (path.size() > 1 && base::FilePath::IsSeparator(path[path.size() - 1])) - path.resize(path.size() - 1); - base::FilePath::StringType::size_type last_separator = - path.find_last_of(base::FilePath::kSeparators); - if (last_separator != base::FilePath::StringType::npos && - last_separator < path.size() - 1) - path.erase(0, last_separator + 1); - - return base::FilePath(path); -} - -base::FilePath VirtualPath::DirName(const base::FilePath& virtual_path) { - typedef base::FilePath::StringType StringType; - StringType path = virtual_path.value(); - - // The logic below is taken from that of base::FilePath::DirName, except - // that this version never cares about '//' or drive-letters even on win32. - - // Strip trailing separators. - while (path.size() > 1 && base::FilePath::IsSeparator(path[path.size() - 1])) - path.resize(path.size() - 1); - - StringType::size_type last_separator = - path.find_last_of(base::FilePath::kSeparators); - if (last_separator == StringType::npos) { - // path_ is in the current directory. - return base::FilePath(base::FilePath::kCurrentDirectory); - } - if (last_separator == 0) { - // path_ is in the root directory. - return base::FilePath(path.substr(0, 1)); - } - // path_ is somewhere else, trim the basename. - path.resize(last_separator); - - // Strip trailing separators. - while (path.size() > 1 && base::FilePath::IsSeparator(path[path.size() - 1])) - path.resize(path.size() - 1); - - if (path.empty()) - return base::FilePath(base::FilePath::kCurrentDirectory); - - return base::FilePath(path); -} - -void VirtualPath::GetComponents( - const base::FilePath& path, - std::vector* components) { - typedef base::FilePath::StringType StringType; - - DCHECK(components); - if (!components) - return; - components->clear(); - if (path.value().empty()) - return; - - StringType::size_type begin = 0, end = 0; - while (begin < path.value().length() && end != StringType::npos) { - end = path.value().find_first_of(base::FilePath::kSeparators, begin); - StringType component = path.value().substr( - begin, end == StringType::npos ? StringType::npos : end - begin); - if (!component.empty() && component != base::FilePath::kCurrentDirectory) - components->push_back(component); - begin = end + 1; - } -} - -void VirtualPath::GetComponentsUTF8Unsafe( - const base::FilePath& path, - std::vector* components) { - DCHECK(components); - if (!components) - return; - components->clear(); - - std::vector stringtype_components; - VirtualPath::GetComponents(path, &stringtype_components); - std::vector::const_iterator it; - for (it = stringtype_components.begin(); it != stringtype_components.end(); - ++it) { - components->push_back(base::FilePath(*it).AsUTF8Unsafe()); - } -} - -base::FilePath::StringType VirtualPath::GetNormalizedFilePath( - const base::FilePath& path) { - base::FilePath::StringType normalized_path = path.value(); - const size_t num_separators = base::FilePath::StringType( - base::FilePath::kSeparators).length(); - for (size_t i = 0; i < num_separators; ++i) { - std::replace(normalized_path.begin(), normalized_path.end(), - base::FilePath::kSeparators[i], kSeparator); - } - - return (IsAbsolute(normalized_path)) ? - normalized_path : base::FilePath::StringType(kRoot) + normalized_path; -} - -bool VirtualPath::IsAbsolute(const base::FilePath::StringType& path) { - return path.find(kRoot) == 0; -} - -bool VirtualPath::IsRootPath(const base::FilePath& path) { - std::vector components; - VirtualPath::GetComponents(path, &components); - return (path.empty() || components.empty() || - (components.size() == 1 && - 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. - DCHECK(!origin_url.SchemeIsFileSystem()); - - std::string url = "filesystem:" + origin_url.GetWithEmptyPath().spec(); - switch (type) { - case kFileSystemTypeTemporary: - url += (kTemporaryDir + 1); // We don't want the leading slash. - return GURL(url + "/"); - case kFileSystemTypePersistent: - url += (kPersistentDir + 1); // We don't want the leading slash. - return GURL(url + "/"); - case kFileSystemTypeExternal: - url += (kExternalDir + 1); // We don't want the leading slash. - return GURL(url + "/"); - case kFileSystemTypeIsolated: - url += (kIsolatedDir + 1); // We don't want the leading slash. - return GURL(url + "/"); - case kFileSystemTypeTest: - url += (kTestDir + 1); // We don't want the leading slash. - return GURL(url + "/"); - // Internal types are always pointed via isolated or external URLs. - default: - NOTREACHED(); - } - NOTREACHED(); - return GURL(); -} - -std::string GetFileSystemName(const GURL& origin_url, FileSystemType type) { - std::string origin_identifier = storage::GetIdentifierFromOrigin(origin_url); - std::string type_string = GetFileSystemTypeString(type); - DCHECK(!type_string.empty()); - return origin_identifier + ":" + type_string; -} - -FileSystemType QuotaStorageTypeToFileSystemType( - storage::StorageType storage_type) { - switch (storage_type) { - case storage::kStorageTypeTemporary: - return kFileSystemTypeTemporary; - case storage::kStorageTypePersistent: - return kFileSystemTypePersistent; - case storage::kStorageTypeSyncable: - return kFileSystemTypeSyncable; - case storage::kStorageTypeQuotaNotManaged: - case storage::kStorageTypeUnknown: - return kFileSystemTypeUnknown; - } - return kFileSystemTypeUnknown; -} - -storage::StorageType FileSystemTypeToQuotaStorageType(FileSystemType type) { - switch (type) { - case kFileSystemTypeTemporary: - return storage::kStorageTypeTemporary; - case kFileSystemTypePersistent: - return storage::kStorageTypePersistent; - case kFileSystemTypeSyncable: - case kFileSystemTypeSyncableForInternalSync: - return storage::kStorageTypeSyncable; - case kFileSystemTypePluginPrivate: - return storage::kStorageTypeQuotaNotManaged; - default: - return storage::kStorageTypeUnknown; - } -} - -std::string GetFileSystemTypeString(FileSystemType type) { - switch (type) { - case kFileSystemTypeTemporary: - return "Temporary"; - case kFileSystemTypePersistent: - return "Persistent"; - case kFileSystemTypeIsolated: - return "Isolated"; - case kFileSystemTypeExternal: - return "External"; - case kFileSystemTypeTest: - return "Test"; - case kFileSystemTypeNativeLocal: - return "NativeLocal"; - case kFileSystemTypeRestrictedNativeLocal: - return "RestrictedNativeLocal"; - case kFileSystemTypeDragged: - return "Dragged"; - case kFileSystemTypeNativeMedia: - return "NativeMedia"; - case kFileSystemTypeDeviceMedia: - return "DeviceMedia"; - case kFileSystemTypePicasa: - return "Picasa"; - case kFileSystemTypeItunes: - return "Itunes"; - case kFileSystemTypeIphoto: - return "Iphoto"; - case kFileSystemTypeDrive: - return "Drive"; - case kFileSystemTypeSyncable: - case kFileSystemTypeSyncableForInternalSync: - return "Syncable"; - case kFileSystemTypeNativeForPlatformApp: - return "NativeForPlatformApp"; - case kFileSystemTypeForTransientFile: - return "TransientFile"; - case kFileSystemTypePluginPrivate: - return "PluginPrivate"; - case kFileSystemTypeCloudDevice: - return "CloudDevice"; - case kFileSystemTypeProvided: - return "Provided"; - case kFileSystemTypeDeviceMediaAsFileStorage: - return "DeviceMediaStorage"; - case kFileSystemInternalTypeEnumStart: - case kFileSystemInternalTypeEnumEnd: - NOTREACHED(); - // Fall through. - case kFileSystemTypeUnknown: - return "Unknown"; - } - NOTREACHED(); - return std::string(); -} - -std::string FilePathToString(const base::FilePath& file_path) { -#if defined(OS_WIN) - return base::UTF16ToUTF8(file_path.value()); -#elif defined(OS_POSIX) - return file_path.value(); -#endif -} - -base::FilePath StringToFilePath(const std::string& file_path_string) { -#if defined(OS_WIN) - return base::FilePath(base::UTF8ToUTF16(file_path_string)); -#elif defined(OS_POSIX) - return base::FilePath(file_path_string); -#endif -} - -blink::WebFileError FileErrorToWebFileError( - base::File::Error error_code) { - switch (error_code) { - case base::File::FILE_ERROR_NOT_FOUND: - return blink::WebFileErrorNotFound; - 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::File::FILE_ERROR_NOT_A_DIRECTORY: - case base::File::FILE_ERROR_NOT_A_FILE: - return blink::WebFileErrorTypeMismatch; - case base::File::FILE_ERROR_ACCESS_DENIED: - return blink::WebFileErrorNoModificationAllowed; - case base::File::FILE_ERROR_FAILED: - return blink::WebFileErrorInvalidState; - case base::File::FILE_ERROR_ABORT: - return blink::WebFileErrorAbort; - case base::File::FILE_ERROR_SECURITY: - return blink::WebFileErrorSecurity; - case base::File::FILE_ERROR_NO_SPACE: - return blink::WebFileErrorQuotaExceeded; - case base::File::FILE_ERROR_INVALID_URL: - return blink::WebFileErrorEncoding; - default: - return blink::WebFileErrorInvalidModification; - } -} - -bool GetFileSystemPublicType( - const std::string type_string, - blink::WebFileSystemType* type) { - DCHECK(type); - if (type_string == "Temporary") { - *type = blink::WebFileSystemTypeTemporary; - return true; - } - if (type_string == "Persistent") { - *type = blink::WebFileSystemTypePersistent; - return true; - } - if (type_string == "Isolated") { - *type = blink::WebFileSystemTypeIsolated; - return true; - } - if (type_string == "External") { - *type = blink::WebFileSystemTypeExternal; - return true; - } - NOTREACHED(); - return false; -} - -std::string GetIsolatedFileSystemName(const GURL& origin_url, - const std::string& filesystem_id) { - std::string name( - storage::GetFileSystemName(origin_url, storage::kFileSystemTypeIsolated)); - name.append("_"); - name.append(filesystem_id); - return name; -} - -bool CrackIsolatedFileSystemName(const std::string& filesystem_name, - std::string* filesystem_id) { - DCHECK(filesystem_id); - - // |filesystem_name| is of the form {origin}:isolated_{filesystem_id}. - std::string start_token(":"); - start_token = start_token.append( - GetFileSystemTypeString(kFileSystemTypeIsolated)).append("_"); - // WebKit uses different case in its constant for isolated file system - // names, so we do a case insensitive compare by converting both strings - // to uppercase. - // TODO(benwells): Remove this when WebKit uses the same constant. - start_token = StringToUpperASCII(start_token); - std::string filesystem_name_upper = StringToUpperASCII(filesystem_name); - size_t pos = filesystem_name_upper.find(start_token); - if (pos == std::string::npos) - return false; - if (pos == 0) - return false; - - *filesystem_id = filesystem_name.substr(pos + start_token.length(), - std::string::npos); - if (filesystem_id->empty()) - return false; - - return true; -} - -bool ValidateIsolatedFileSystemId(const std::string& filesystem_id) { - const size_t kExpectedFileSystemIdSize = 32; - if (filesystem_id.size() != kExpectedFileSystemIdSize) - return false; - const std::string kExpectedChars("ABCDEF0123456789"); - return base::ContainsOnlyChars(filesystem_id, kExpectedChars); -} - -std::string GetIsolatedFileSystemRootURIString( - const GURL& origin_url, - const std::string& filesystem_id, - const std::string& optional_root_name) { - std::string root = GetFileSystemRootURI(origin_url, - kFileSystemTypeIsolated).spec(); - if (base::FilePath::FromUTF8Unsafe(filesystem_id).ReferencesParent()) - return std::string(); - 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(net::EscapePath(optional_root_name)); - root.append("/"); - } - return root; -} - -std::string GetExternalFileSystemRootURIString( - const GURL& origin_url, - const std::string& mount_name) { - std::string root = GetFileSystemRootURI(origin_url, - kFileSystemTypeExternal).spec(); - if (base::FilePath::FromUTF8Unsafe(mount_name).ReferencesParent()) - return std::string(); - root.append(net::EscapePath(mount_name)); - root.append("/"); - return root; -} - -base::File::Error NetErrorToFileError(int error) { - switch (error) { - case net::OK: - return base::File::FILE_OK; - case net::ERR_ADDRESS_IN_USE: - return base::File::FILE_ERROR_IN_USE; - case net::ERR_FILE_EXISTS: - return base::File::FILE_ERROR_EXISTS; - case net::ERR_FILE_NOT_FOUND: - return base::File::FILE_ERROR_NOT_FOUND; - case net::ERR_ACCESS_DENIED: - return base::File::FILE_ERROR_ACCESS_DENIED; - case net::ERR_TOO_MANY_SOCKET_STREAMS: - return base::File::FILE_ERROR_TOO_MANY_OPENED; - case net::ERR_OUT_OF_MEMORY: - return base::File::FILE_ERROR_NO_MEMORY; - case net::ERR_FILE_NO_SPACE: - return base::File::FILE_ERROR_NO_SPACE; - case net::ERR_INVALID_ARGUMENT: - case net::ERR_INVALID_HANDLE: - return base::File::FILE_ERROR_INVALID_OPERATION; - case net::ERR_ABORTED: - case net::ERR_CONNECTION_ABORTED: - return base::File::FILE_ERROR_ABORT; - case net::ERR_ADDRESS_INVALID: - case net::ERR_INVALID_URL: - return base::File::FILE_ERROR_INVALID_URL; - default: - return base::File::FILE_ERROR_FAILED; - } -} - -} // namespace storage diff --git a/webkit/common/fileapi/file_system_util.h b/webkit/common/fileapi/file_system_util.h index 4da856d..c5c0efa 100644 --- a/webkit/common/fileapi/file_system_util.h +++ b/webkit/common/fileapi/file_system_util.h @@ -1,182 +1,5 @@ -// 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. -#ifndef WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_UTIL_H_ -#define WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_UTIL_H_ - -#include -#include - -#include "base/files/file.h" -#include "base/files/file_path.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" -#include "webkit/common/fileapi/file_system_types.h" -#include "webkit/common/quota/quota_types.h" -#include "webkit/common/storage_common_export.h" - -class GURL; - -namespace storage { - -STORAGE_COMMON_EXPORT extern const char kPersistentDir[]; -STORAGE_COMMON_EXPORT extern const char kTemporaryDir[]; -STORAGE_COMMON_EXPORT extern const char kExternalDir[]; -STORAGE_COMMON_EXPORT extern const char kIsolatedDir[]; -STORAGE_COMMON_EXPORT extern const char kTestDir[]; - -class STORAGE_COMMON_EXPORT VirtualPath { - public: - static const base::FilePath::CharType kRoot[]; - static const base::FilePath::CharType kSeparator; - - // Use this instead of base::FilePath::BaseName when operating on virtual - // paths. FilePath::BaseName will get confused by ':' on Windows when it - // looks like a drive letter separator; this will treat it as just another - // character. - static base::FilePath BaseName(const base::FilePath& virtual_path); - - // Use this instead of base::FilePath::DirName when operating on virtual - // paths. - static base::FilePath DirName(const base::FilePath& virtual_path); - - // Likewise, use this instead of base::FilePath::GetComponents when - // operating on virtual paths. - // Note that this assumes very clean input, with no leading slash, and - // it will not evaluate '..' components. - static void GetComponents( - const base::FilePath& path, - std::vector* components); - - static void GetComponentsUTF8Unsafe( - const base::FilePath& path, std::vector* components); - - // Returns a path name ensuring that it begins with kRoot and all path - // separators are forward slashes /. - static base::FilePath::StringType GetNormalizedFilePath( - const base::FilePath& path); - - // Returns true if the given path begins with kRoot. - static bool IsAbsolute(const base::FilePath::StringType& path); - - // Returns true if the given path points to the root. - 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'. -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. + "/relative/path" will compose -// a path pointing to the entry "/relative/path" in the filesystem). -// -// For Isolated filesystem this returns the 'common' root part, e.g. -// returns URL without the filesystem ID. -// -// |type| needs to be public type as the returned URI is given to the renderer. -STORAGE_COMMON_EXPORT GURL GetFileSystemRootURI(const GURL& origin_url, - FileSystemType type); - -// Returns the name for the filesystem that is specified by a pair of -// |origin_url| and |type|. -// (The name itself is neither really significant nor a formal identifier -// but can be read as the .name field of the returned FileSystem object -// as a user-friendly name in the javascript layer). -// -// |type| needs to be public type as the returned name is given to the renderer. -// -// Example: -// The name for a TEMPORARY filesystem of "http://www.example.com:80/" -// should look like: "http_www.example.host_80:temporary" -STORAGE_COMMON_EXPORT std::string -GetFileSystemName(const GURL& origin_url, FileSystemType type); - -// Converts FileSystemType |type| to/from the StorageType |storage_type| that -// is used for the unified quota system. -// (Basically this naively maps TEMPORARY storage type to TEMPORARY filesystem -// type, PERSISTENT storage type to PERSISTENT filesystem type and vice versa.) -STORAGE_COMMON_EXPORT FileSystemType - QuotaStorageTypeToFileSystemType(storage::StorageType storage_type); - -STORAGE_COMMON_EXPORT storage::StorageType - FileSystemTypeToQuotaStorageType(FileSystemType type); - -// Returns the string representation of the given filesystem |type|. -// Returns an empty string if the |type| is invalid. -STORAGE_COMMON_EXPORT std::string -GetFileSystemTypeString(FileSystemType type); - -// Sets type to FileSystemType enum that corresponds to the string name. -// Returns false if the |type_string| is invalid. -STORAGE_COMMON_EXPORT bool GetFileSystemPublicType( - std::string type_string, - blink::WebFileSystemType* type); - -// Encodes |file_path| to a string. -// Following conditions should be held: -// - StringToFilePath(FilePathToString(path)) == path -// - StringToFilePath(FilePathToString(path) + "/" + "SubDirectory") == -// path.AppendASCII("SubDirectory"); -// -// TODO(tzik): Replace CreateFilePath and FilePathToString in -// third_party/leveldatabase/env_chromium.cc with them. -STORAGE_COMMON_EXPORT std::string FilePathToString( - const base::FilePath& file_path); - -// Decode a file path from |file_path_string|. -STORAGE_COMMON_EXPORT base::FilePath StringToFilePath( - const std::string& file_path_string); - -// File error conversion -STORAGE_COMMON_EXPORT blink::WebFileError -FileErrorToWebFileError(base::File::Error error_code); - -// Generate a file system name for the given arguments. Should only be used by -// platform apps. -STORAGE_COMMON_EXPORT std::string GetIsolatedFileSystemName( - const GURL& origin_url, - const std::string& filesystem_id); - -// Find the file system id from |filesystem_name|. Should only be used by -// platform apps. This function will return false if the file system name is -// not of the form {origin}:Isolated_{id}, and will also check that there is an -// origin and id present. It will not check that the origin or id are valid. -STORAGE_COMMON_EXPORT bool CrackIsolatedFileSystemName( - const std::string& filesystem_name, - std::string* filesystem_id); - -// Validates the given isolated file system id. -STORAGE_COMMON_EXPORT bool ValidateIsolatedFileSystemId( - const std::string& filesystem_id); - -// Returns the root URI for an isolated filesystem for origin |origin_url| -// and |filesystem_id|. If the |optional_root_name| is given the resulting -// root URI will point to the subfolder within the isolated filesystem. -STORAGE_COMMON_EXPORT std::string GetIsolatedFileSystemRootURIString( - const GURL& origin_url, - const std::string& filesystem_id, - const std::string& optional_root_name); - -// Returns the root URI for an external filesystem for origin |origin_url| -// and |mount_name|. -STORAGE_COMMON_EXPORT std::string GetExternalFileSystemRootURIString( - const GURL& origin_url, - const std::string& mount_name); - -// Translates the net::Error to base::File::Error. -STORAGE_COMMON_EXPORT base::File::Error -NetErrorToFileError(int error); - -} // namespace storage - -#endif // WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_UTIL_H_ +#include "storage/common/fileapi/file_system_util.h" diff --git a/webkit/common/quota/quota_status_code.cc b/webkit/common/quota/quota_status_code.cc deleted file mode 100644 index 1139589..0000000 --- a/webkit/common/quota/quota_status_code.cc +++ /dev/null @@ -1,29 +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/logging.h" -#include "webkit/common/quota/quota_status_code.h" - -namespace storage { - -const char* QuotaStatusCodeToString(QuotaStatusCode status) { - switch (status) { - case kQuotaStatusOk: - return "OK."; - case kQuotaErrorNotSupported: - return "Operation not supported."; - case kQuotaErrorInvalidModification: - return "Invalid modification."; - case kQuotaErrorInvalidAccess: - return "Invalid access."; - case kQuotaErrorAbort: - return "Quota operation aborted."; - case kQuotaStatusUnknown: - return "Unknown error."; - } - NOTREACHED(); - return "Unknown error."; -} - -} // namespace storage diff --git a/webkit/common/quota/quota_status_code.h b/webkit/common/quota/quota_status_code.h index bfd6ece..b9e239d 100644 --- a/webkit/common/quota/quota_status_code.h +++ b/webkit/common/quota/quota_status_code.h @@ -1,28 +1,5 @@ -// Copyright 2013 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. -#ifndef WEBKIT_COMMON_QUOTA_QUOTA_STATUS_CODE_H_ -#define WEBKIT_COMMON_QUOTA_QUOTA_STATUS_CODE_H_ - -#include "third_party/WebKit/public/platform/WebStorageQuotaError.h" -#include "webkit/common/storage_common_export.h" - -namespace storage { - -enum QuotaStatusCode { - kQuotaStatusOk = 0, - kQuotaErrorNotSupported = blink::WebStorageQuotaErrorNotSupported, - kQuotaErrorInvalidModification = - blink::WebStorageQuotaErrorInvalidModification, - kQuotaErrorInvalidAccess = blink::WebStorageQuotaErrorInvalidAccess, - kQuotaErrorAbort = blink::WebStorageQuotaErrorAbort, - kQuotaStatusUnknown = -1, -}; - -STORAGE_COMMON_EXPORT const char* QuotaStatusCodeToString( - QuotaStatusCode status); - -} // namespace storage - -#endif // WEBKIT_COMMON_QUOTA_QUOTA_STATUS_CODE_H_ +#include "storage/common/quota/quota_status_code.h" diff --git a/webkit/common/quota/quota_types.h b/webkit/common/quota/quota_types.h index fa69b29..36c9ba4 100644 --- a/webkit/common/quota/quota_types.h +++ b/webkit/common/quota/quota_types.h @@ -1,29 +1,5 @@ -// Copyright 2013 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. -#ifndef WEBKIT_COMMON_QUOTA_QUOTA_TYPES_H_ -#define WEBKIT_COMMON_QUOTA_QUOTA_TYPES_H_ - -#include "webkit/common/quota/quota_status_code.h" - -namespace storage { - -enum StorageType { - kStorageTypeTemporary, - kStorageTypePersistent, - kStorageTypeSyncable, - kStorageTypeQuotaNotManaged, - kStorageTypeUnknown, - kStorageTypeLast = kStorageTypeUnknown -}; - -enum QuotaLimitType { - kQuotaLimitTypeUnknown, - kQuotaLimitTypeLimited, - kQuotaLimitTypeUnlimited, -}; - -} // namespace storage - -#endif // WEBKIT_COMMON_QUOTA_QUOTA_TYPES_H_ +#include "storage/common/quota/quota_types.h" diff --git a/webkit/common/storage_common_export.h b/webkit/common/storage_common_export.h deleted file mode 100644 index 5f2baf4..0000000 --- a/webkit/common/storage_common_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_COMMON_STORAGE_COMMON_EXPORT_H_ -#define WEBKIT_COMMON_STORAGE_COMMON_EXPORT_H_ - -#if defined(COMPONENT_BUILD) -#if defined(WIN32) - -#if defined(STORAGE_COMMON_IMPLEMENTATION) -#define STORAGE_COMMON_EXPORT __declspec(dllexport) -#else -#define STORAGE_COMMON_EXPORT __declspec(dllimport) -#endif // defined(STORAGE_COMMON_IMPLEMENTATION) - -#else // defined(WIN32) -#if defined(STORAGE_COMMON_IMPLEMENTATION) -#define STORAGE_COMMON_EXPORT __attribute__((visibility("default"))) -#else -#define STORAGE_COMMON_EXPORT -#endif -#endif - -#else // defined(COMPONENT_BUILD) -#define STORAGE_COMMON_EXPORT -#endif - -#endif // WEBKIT_COMMON_STORAGE_COMMON_EXPORT_H_ diff --git a/webkit/common/webkit_common.gyp b/webkit/common/webkit_common.gyp deleted file mode 100644 index 89a5a34..0000000 --- a/webkit/common/webkit_common.gyp +++ /dev/null @@ -1,29 +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. - -{ - 'variables': { - 'enable_wexit_time_destructors': 1, - 'chromium_code': 1 - }, - 'targets': [ - { - # GN version: //webkit/common:common", - 'target_name': 'webkit_common', - 'type': '<(component)', - 'defines': [ - 'WEBKIT_COMMON_IMPLEMENTATION', - ], - 'dependencies': [ - '../../base/base.gyp:base', - '../../url/url.gyp:url_lib', - ], - 'sources': [ - 'data_element.cc', - 'data_element.h', - 'webkit_common_export.h', - ], - }, - ], -} diff --git a/webkit/storage_browser.gyp b/webkit/storage_browser.gyp index 71ebcd9..ed08918 100644 --- a/webkit/storage_browser.gyp +++ b/webkit/storage_browser.gyp @@ -18,11 +18,10 @@ '<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', '<(DEPTH)/net/net.gyp:net', '<(DEPTH)/sql/sql.gyp:sql', + '<(DEPTH)/storage/storage_common.gyp:storage_common', '<(DEPTH)/third_party/leveldatabase/leveldatabase.gyp:leveldatabase', '<(DEPTH)/third_party/sqlite/sqlite.gyp:sqlite', '<(DEPTH)/url/url.gyp:url_lib', - '<(DEPTH)/webkit/common/webkit_common.gyp:webkit_common', - '<(DEPTH)/webkit/storage_common.gyp:storage_common', ], 'defines': ['STORAGE_BROWSER_IMPLEMENTATION'], 'sources': [ @@ -192,7 +191,7 @@ ], 'dependencies': [ '<(DEPTH)/base/base.gyp:base', - '<(DEPTH)/webkit/storage_common.gyp:storage_common', + '<(DEPTH)/storage/storage_common.gyp:storage_common', 'storage', ], }, diff --git a/webkit/storage_common.gyp b/webkit/storage_common.gyp deleted file mode 100644 index cc95ef0..0000000 --- a/webkit/storage_common.gyp +++ /dev/null @@ -1,51 +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. - -{ - 'variables': { - 'chromium_code': 1, - }, - 'targets': [ - { - # GN version: //webkit/common:storage_common - 'target_name': 'storage_common', - 'type': '<(component)', - 'variables': { 'enable_wexit_time_destructors': 1, }, - 'dependencies': [ - '<(DEPTH)/base/base.gyp:base', - '<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', - '<(DEPTH)/net/net.gyp:net', - '<(DEPTH)/url/url.gyp:url_lib', - '<(DEPTH)/webkit/common/webkit_common.gyp:webkit_common', - ], - 'defines': ['STORAGE_COMMON_IMPLEMENTATION'], - 'sources': [ - 'common/blob/blob_data.cc', - 'common/blob/blob_data.h', - 'common/blob/scoped_file.cc', - 'common/blob/scoped_file.h', - 'common/blob/shareable_file_reference.cc', - 'common/blob/shareable_file_reference.h', - 'common/database/database_connections.cc', - 'common/database/database_connections.h', - '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', - 'common/fileapi/file_system_info.h', - 'common/fileapi/file_system_mount_option.h', - 'common/fileapi/file_system_types.h', - 'common/fileapi/file_system_util.cc', - 'common/fileapi/file_system_util.h', - 'common/quota/quota_status_code.cc', - 'common/quota/quota_status_code.h', - 'common/quota/quota_types.h', - 'common/storage_common_export.h', - ], - # TODO(jschuh): crbug.com/167187 fix size_t to int truncations. - 'msvs_disabled_warnings': [ 4267, ], - }, - ], -} -- cgit v1.1