diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-24 16:33:36 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-24 16:33:36 +0000 |
commit | 4348625078fcbdcfa75396e30bea9ddca70d8b05 (patch) | |
tree | fb9b66875acd9517e701d991543ffa5bbd5dbb4b | |
parent | 1dfddfd36b884014ebc31cc1101ba022ebaccd76 (diff) | |
download | chromium_src-4348625078fcbdcfa75396e30bea9ddca70d8b05.zip chromium_src-4348625078fcbdcfa75396e30bea9ddca70d8b05.tar.gz chromium_src-4348625078fcbdcfa75396e30bea9ddca70d8b05.tar.bz2 |
Move ImportantFileWriter to base/. It now has two consumers, base/prefs and chrome/.
TBR=ben@chromium.org
BUG=155525
Review URL: https://chromiumcodereview.appspot.com/11227026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163840 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | .gitmodules | 476 | ||||
-rw-r--r-- | base/base.gyp | 1 | ||||
-rw-r--r-- | base/base.gypi | 2 | ||||
-rw-r--r-- | base/files/important_file_writer.cc (renamed from chrome/common/important_file_writer.cc) | 30 | ||||
-rw-r--r-- | base/files/important_file_writer.h (renamed from chrome/common/important_file_writer.h) | 25 | ||||
-rw-r--r-- | base/files/important_file_writer_unittest.cc (renamed from chrome/common/important_file_writer_unittest.cc) | 24 | ||||
-rw-r--r-- | base/prefs/DEPS | 5 | ||||
-rw-r--r-- | base/prefs/json_pref_store.h | 7 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_storage.h | 6 | ||||
-rw-r--r-- | chrome/browser/net/transport_security_persister.h | 6 | ||||
-rw-r--r-- | chrome/chrome_common.gypi | 2 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 1 |
12 files changed, 533 insertions, 52 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..f0b44be --- /dev/null +++ b/.gitmodules @@ -0,0 +1,476 @@ +[submodule "breakpad/src"] + path = breakpad/src + url = https://chromium.googlesource.com/external/google-breakpad/src.git + os = all +[submodule "build/util/support"] + path = build/util/support + url = + os = ios +[submodule "chrome/installer/mac/third_party/xz/xz"] + path = chrome/installer/mac/third_party/xz/xz + url = https://chromium.googlesource.com/chromium/deps/xz.git + os = mac +[submodule "chrome/test/data/extensions/api_test/permissions/nacl_enabled/bin"] + path = chrome/test/data/extensions/api_test/permissions/nacl_enabled/bin + url = https://chromium.googlesource.com/native_client/src/native_client/tests/prebuilt.git + os = all +[submodule "chrome/test/data/perf/canvas_bench"] + path = chrome/test/data/perf/canvas_bench + url = https://chromium.googlesource.com/chromium/canvas_bench.git + os = all +[submodule "chrome/test/data/perf/frame_rate/content"] + path = chrome/test/data/perf/frame_rate/content + url = https://chromium.googlesource.com/chromium/frame_rate/content.git + os = all +[submodule "chrome/tools/test/reference_build/chrome_linux"] + path = chrome/tools/test/reference_build/chrome_linux + url = https://chromium.googlesource.com/chromium/reference_builds/chrome_linux.git + os = unix +[submodule "chrome/tools/test/reference_build/chrome_mac"] + path = chrome/tools/test/reference_build/chrome_mac + url = https://chromium.googlesource.com/chromium/reference_builds/chrome_mac.git + os = mac +[submodule "chrome/tools/test/reference_build/chrome_win"] + path = chrome/tools/test/reference_build/chrome_win + url = https://chromium.googlesource.com/chromium/reference_builds/chrome_win.git + os = win +[submodule "chrome_frame/tools/test/reference_build/chrome_win"] + path = chrome_frame/tools/test/reference_build/chrome_win + url = https://chromium.googlesource.com/chromium/reference_builds/chrome_win.git + os = win +[submodule "content/test/data/layout_tests/LayoutTests/fast/events"] + path = content/test/data/layout_tests/LayoutTests/fast/events + url = + os = ios +[submodule "content/test/data/layout_tests/LayoutTests/fast/filesystem/resources"] + path = content/test/data/layout_tests/LayoutTests/fast/filesystem/resources + url = + os = ios +[submodule "content/test/data/layout_tests/LayoutTests/fast/js/resources"] + path = content/test/data/layout_tests/LayoutTests/fast/js/resources + url = + os = ios +[submodule "content/test/data/layout_tests/LayoutTests/fast/workers"] + path = content/test/data/layout_tests/LayoutTests/fast/workers + url = + os = ios +[submodule "content/test/data/layout_tests/LayoutTests/http/tests/appcache"] + path = content/test/data/layout_tests/LayoutTests/http/tests/appcache + url = + os = ios +[submodule "content/test/data/layout_tests/LayoutTests/http/tests/resources"] + path = content/test/data/layout_tests/LayoutTests/http/tests/resources + url = + os = ios +[submodule "content/test/data/layout_tests/LayoutTests/http/tests/websocket/tests"] + path = content/test/data/layout_tests/LayoutTests/http/tests/websocket/tests + url = + os = ios +[submodule "content/test/data/layout_tests/LayoutTests/http/tests/workers"] + path = content/test/data/layout_tests/LayoutTests/http/tests/workers + url = + os = ios +[submodule "content/test/data/layout_tests/LayoutTests/http/tests/xmlhttprequest"] + path = content/test/data/layout_tests/LayoutTests/http/tests/xmlhttprequest + url = + os = ios +[submodule "content/test/data/layout_tests/LayoutTests/media"] + path = content/test/data/layout_tests/LayoutTests/media + url = + os = ios +[submodule "content/test/data/layout_tests/LayoutTests/platform/chromium-win/fast/events"] + path = content/test/data/layout_tests/LayoutTests/platform/chromium-win/fast/events + url = + os = ios +[submodule "content/test/data/layout_tests/LayoutTests/platform/chromium-win/fast/workers"] + path = content/test/data/layout_tests/LayoutTests/platform/chromium-win/fast/workers + url = + os = ios +[submodule "content/test/data/layout_tests/LayoutTests/platform/chromium-win/http/tests/workers"] + path = content/test/data/layout_tests/LayoutTests/platform/chromium-win/http/tests/workers + url = + os = ios +[submodule "content/test/data/layout_tests/LayoutTests/platform/chromium-win/storage/domstorage"] + path = content/test/data/layout_tests/LayoutTests/platform/chromium-win/storage/domstorage + url = + os = ios +[submodule "content/test/data/layout_tests/LayoutTests/platform/chromium/fast/events"] + path = content/test/data/layout_tests/LayoutTests/platform/chromium/fast/events + url = + os = ios +[submodule "content/test/data/layout_tests/LayoutTests/platform/chromium/fast/workers"] + path = content/test/data/layout_tests/LayoutTests/platform/chromium/fast/workers + url = + os = ios +[submodule "content/test/data/layout_tests/LayoutTests/storage/domstorage"] + path = content/test/data/layout_tests/LayoutTests/storage/domstorage + url = + os = ios +[submodule "content/test/data/layout_tests/LayoutTests/storage/indexeddb"] + path = content/test/data/layout_tests/LayoutTests/storage/indexeddb + url = + os = ios +[submodule "googleurl"] + path = googleurl + url = https://chromium.googlesource.com/external/google-url.git + os = all +[submodule "native_client"] + path = native_client + url = https://chromium.googlesource.com/native_client/src/native_client.git + os = all +[submodule "sandbox/linux/seccomp-legacy"] + path = sandbox/linux/seccomp-legacy + url = https://chromium.googlesource.com/external/seccompsandbox.git + os = all +[submodule "sdch/open-vcdiff"] + path = sdch/open-vcdiff + url = https://chromium.googlesource.com/external/open-vcdiff.git + os = all +[submodule "testing/gmock"] + path = testing/gmock + url = https://chromium.googlesource.com/external/googlemock.git + os = all +[submodule "testing/gtest"] + path = testing/gtest + url = https://chromium.googlesource.com/external/googletest.git + os = all +[submodule "testing/iossim/third_party/class-dump"] + path = testing/iossim/third_party/class-dump + url = https://chromium.googlesource.com/chromium/deps/class-dump.git + os = ios +[submodule "third_party/GTM"] + path = third_party/GTM + url = https://chromium.googlesource.com/external/google-toolbox-for-mac.git + os = ios,mac +[submodule "third_party/WebKit"] + path = third_party/WebKit + url = https://chromium.googlesource.com/external/WebKit_trimmed.git + os = all +[submodule "third_party/android_tools"] + path = third_party/android_tools + url = https://chromium.googlesource.com/android_tools.git + os = android +[submodule "third_party/angle"] + path = third_party/angle + url = https://chromium.googlesource.com/external/angleproject.git + os = all +[submodule "third_party/aosp"] + path = third_party/aosp + url = https://chromium.googlesource.com/chromium/deps/aosp.git + os = android +[submodule "third_party/bidichecker"] + path = third_party/bidichecker + url = https://chromium.googlesource.com/external/bidichecker/lib.git + os = all +[submodule "third_party/bison"] + path = third_party/bison + url = https://chromium.googlesource.com/chromium/deps/bison.git + os = win +[submodule "third_party/cacheinvalidation/src"] + path = third_party/cacheinvalidation/src + url = https://chromium.googlesource.com/external/google-cache-invalidation-api/src.git + os = all +[submodule "third_party/cros_dbus_cplusplus/source"] + path = third_party/cros_dbus_cplusplus/source + url = https://chromium.googlesource.com/chromiumos/third_party/dbus-cplusplus.git + os = unix +[submodule "third_party/cros_system_api"] + path = third_party/cros_system_api + url = https://chromium.googlesource.com/chromiumos/platform/system_api.git + os = unix +[submodule "third_party/cygwin"] + path = third_party/cygwin + url = https://chromium.googlesource.com/chromium/deps/cygwin.git + os = win +[submodule "third_party/ffmpeg"] + path = third_party/ffmpeg + url = https://chromium.googlesource.com/chromium/third_party/ffmpeg.git + os = all +[submodule "third_party/flac"] + path = third_party/flac + url = https://chromium.googlesource.com/chromium/deps/flac.git + os = all +[submodule "third_party/freetype"] + path = third_party/freetype + url = https://chromium.googlesource.com/chromium/src/third_party/freetype.git + os = android +[submodule "third_party/gnu_binutils"] + path = third_party/gnu_binutils + url = https://chromium.googlesource.com/native_client/deps/third_party/gnu_binutils.git + os = win +[submodule "third_party/gold"] + path = third_party/gold + url = https://chromium.googlesource.com/chromium/deps/gold.git + os = unix +[submodule "third_party/gperf"] + path = third_party/gperf + url = https://chromium.googlesource.com/chromium/deps/gperf.git + os = win +[submodule "third_party/hunspell"] + path = third_party/hunspell + url = https://chromium.googlesource.com/chromium/deps/hunspell.git + os = all +[submodule "third_party/hunspell_dictionaries"] + path = third_party/hunspell_dictionaries + url = https://chromium.googlesource.com/chromium/deps/hunspell_dictionaries.git + os = all +[submodule "third_party/icu"] + path = third_party/icu + url = https://chromium.googlesource.com/chromium/deps/icu46.git + os = all +[submodule "third_party/jsoncpp/source/include"] + path = third_party/jsoncpp/source/include + url = https://chromium.googlesource.com/external/jsoncpp/jsoncpp/include.git + os = all +[submodule "third_party/jsoncpp/source/src/lib_json"] + path = third_party/jsoncpp/source/src/lib_json + url = https://chromium.googlesource.com/external/jsoncpp/jsoncpp/src/lib_json.git + os = all +[submodule "third_party/leveldatabase/src"] + path = third_party/leveldatabase/src + url = https://chromium.googlesource.com/external/leveldb.git + os = all +[submodule "third_party/libexif/sources"] + path = third_party/libexif/sources + url = https://chromium.googlesource.com/chromium/deps/libexif/sources.git + os = all +[submodule "third_party/libjingle/source"] + path = third_party/libjingle/source + url = https://chromium.googlesource.com/external/libjingle.git + os = all +[submodule "third_party/libjpeg_turbo"] + path = third_party/libjpeg_turbo + url = https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git + os = all +[submodule "third_party/libmtp"] + path = third_party/libmtp + url = https://chromium.googlesource.com/chromium/deps/libmtp.git + os = unix +[submodule "third_party/libphonenumber/src/phonenumbers"] + path = third_party/libphonenumber/src/phonenumbers + url = https://chromium.googlesource.com/external/libphonenumber/cpp/src/phonenumbers.git + os = all +[submodule "third_party/libphonenumber/src/resources"] + path = third_party/libphonenumber/src/resources + url = https://chromium.googlesource.com/external/libphonenumber/resources.git + os = all +[submodule "third_party/libphonenumber/src/test"] + path = third_party/libphonenumber/src/test + url = https://chromium.googlesource.com/external/libphonenumber/cpp/test.git + os = all +[submodule "third_party/libsrtp"] + path = third_party/libsrtp + url = https://chromium.googlesource.com/chromium/deps/libsrtp.git + os = all +[submodule "third_party/libvpx"] + path = third_party/libvpx + url = https://chromium.googlesource.com/chromium/deps/libvpx.git + os = all +[submodule "third_party/libyuv"] + path = third_party/libyuv + url = https://chromium.googlesource.com/external/libyuv.git + os = all +[submodule "third_party/lighttpd"] + path = third_party/lighttpd + url = https://chromium.googlesource.com/chromium/deps/lighttpd.git + os = win,mac +[submodule "third_party/lss"] + path = third_party/lss + url = https://chromium.googlesource.com/external/linux-syscall-support/lss.git + os = unix +[submodule "third_party/mingw-w64/mingw/bin"] + path = third_party/mingw-w64/mingw/bin + url = https://chromium.googlesource.com/native_client/deps/third_party/mingw-w64/mingw/bin.git + os = win +[submodule "third_party/mozc/chrome/chromeos/renderer"] + path = third_party/mozc/chrome/chromeos/renderer + url = https://chromium.googlesource.com/external/mozc/src/chrome/chromeos/renderer.git + os = all +[submodule "third_party/mozc/session"] + path = third_party/mozc/session + url = https://chromium.googlesource.com/external/mozc/src/session.git + os = all +[submodule "third_party/mtpd/source"] + path = third_party/mtpd/source + url = https://chromium.googlesource.com/chromiumos/platform/mtpd.git + os = unix +[submodule "third_party/nacl_sdk_binaries"] + path = third_party/nacl_sdk_binaries + url = https://chromium.googlesource.com/chromium/deps/nacl_sdk_binaries.git + os = win +[submodule "third_party/nss"] + path = third_party/nss + url = https://chromium.googlesource.com/chromium/deps/nss.git + os = win,ios,mac +[submodule "third_party/openssl"] + path = third_party/openssl + url = https://chromium.googlesource.com/chromium/deps/openssl.git + os = unix +[submodule "third_party/opus/src"] + path = third_party/opus/src + url = https://chromium.googlesource.com/chromium/deps/opus.git + os = all +[submodule "third_party/ots"] + path = third_party/ots + url = https://chromium.googlesource.com/external/ots.git + os = all +[submodule "third_party/pdfsqueeze"] + path = third_party/pdfsqueeze + url = https://chromium.googlesource.com/external/pdfsqueeze.git + os = mac +[submodule "third_party/pefile"] + path = third_party/pefile + url = https://chromium.googlesource.com/external/pefile.git + os = win +[submodule "third_party/perl"] + path = third_party/perl + url = https://chromium.googlesource.com/chromium/deps/perl.git + os = win +[submodule "third_party/psyco_win32"] + path = third_party/psyco_win32 + url = https://chromium.googlesource.com/chromium/deps/psyco_win32.git + os = win +[submodule "third_party/pyftpdlib/src"] + path = third_party/pyftpdlib/src + url = https://chromium.googlesource.com/external/pyftpdlib.git + os = all +[submodule "third_party/pylib"] + path = third_party/pylib + url = + os = ios +[submodule "third_party/pymox/src"] + path = third_party/pymox/src + url = https://chromium.googlesource.com/external/pymox.git + os = all +[submodule "third_party/python_26"] + path = third_party/python_26 + url = https://chromium.googlesource.com/chromium/deps/python_26.git + os = win +[submodule "third_party/pywebsocket/src"] + path = third_party/pywebsocket/src + url = https://chromium.googlesource.com/external/pywebsocket/src.git + os = all +[submodule "third_party/safe_browsing/testing"] + path = third_party/safe_browsing/testing + url = https://chromium.googlesource.com/external/google-safe-browsing/testing.git + os = all +[submodule "third_party/scons-2.0.1"] + path = third_party/scons-2.0.1 + url = https://chromium.googlesource.com/native_client/src/third_party/scons-2.0.1.git + os = all +[submodule "third_party/sfntly/cpp/src"] + path = third_party/sfntly/cpp/src + url = https://chromium.googlesource.com/external/sfntly/cpp/src.git + os = all +[submodule "third_party/skia/gyp"] + path = third_party/skia/gyp + url = https://chromium.googlesource.com/external/skia/gyp.git + os = all +[submodule "third_party/skia/include"] + path = third_party/skia/include + url = https://chromium.googlesource.com/external/skia/include.git + os = all +[submodule "third_party/skia/src"] + path = third_party/skia/src + url = https://chromium.googlesource.com/external/skia/src.git + os = all +[submodule "third_party/smhasher/src"] + path = third_party/smhasher/src + url = https://chromium.googlesource.com/external/smhasher.git + os = all +[submodule "third_party/snappy/src"] + path = third_party/snappy/src + url = https://chromium.googlesource.com/external/snappy.git + os = all +[submodule "third_party/speex"] + path = third_party/speex + url = https://chromium.googlesource.com/chromium/deps/speex.git + os = all +[submodule "third_party/swig/Lib"] + path = third_party/swig/Lib + url = https://chromium.googlesource.com/chromium/deps/swig/Lib.git + os = all +[submodule "third_party/swig/linux"] + path = third_party/swig/linux + url = https://chromium.googlesource.com/chromium/deps/swig/linux.git + os = unix +[submodule "third_party/swig/mac"] + path = third_party/swig/mac + url = https://chromium.googlesource.com/chromium/deps/swig/mac.git + os = mac +[submodule "third_party/swig/win"] + path = third_party/swig/win + url = https://chromium.googlesource.com/chromium/deps/swig/win.git + os = win +[submodule "third_party/syzygy/binaries"] + path = third_party/syzygy/binaries + url = https://chromium.googlesource.com/external/sawbuck/syzygy/binaries.git + os = win +[submodule "third_party/trace-viewer"] + path = third_party/trace-viewer + url = https://chromium.googlesource.com/external/trace-viewer.git + os = all +[submodule "third_party/undoview"] + path = third_party/undoview + url = https://chromium.googlesource.com/chromium/deps/undoview.git + os = all +[submodule "third_party/v8-i18n"] + path = third_party/v8-i18n + url = https://chromium.googlesource.com/external/v8-i18n.git + os = all +[submodule "third_party/webdriver/pylib"] + path = third_party/webdriver/pylib + url = https://chromium.googlesource.com/external/selenium/py.git + os = all +[submodule "third_party/webgl_conformance"] + path = third_party/webgl_conformance + url = https://chromium.googlesource.com/chromium/deps/webgl/sdk/tests.git + os = all +[submodule "third_party/webpagereplay"] + path = third_party/webpagereplay + url = https://chromium.googlesource.com/external/web-page-replay.git + os = all +[submodule "third_party/webrtc"] + path = third_party/webrtc + url = https://chromium.googlesource.com/external/webrtc/stable/src.git + os = all +[submodule "third_party/xdg-utils"] + path = third_party/xdg-utils + url = https://chromium.googlesource.com/chromium/deps/xdg-utils.git + os = unix +[submodule "third_party/xulrunner-sdk"] + path = third_party/xulrunner-sdk + url = https://chromium.googlesource.com/chromium/deps/xulrunner-sdk.git + os = win +[submodule "third_party/yasm/binaries"] + path = third_party/yasm/binaries + url = https://chromium.googlesource.com/chromium/deps/yasm/binaries.git + os = win +[submodule "third_party/yasm/source/patched-yasm"] + path = third_party/yasm/source/patched-yasm + url = https://chromium.googlesource.com/chromium/deps/yasm/patched-yasm.git + os = all +[submodule "tools/deps2git"] + path = tools/deps2git + url = https://chromium.googlesource.com/chromium/tools/deps2git.git + os = all +[submodule "tools/grit"] + path = tools/grit + url = https://chromium.googlesource.com/external/grit-i18n.git + os = all +[submodule "tools/gyp"] + path = tools/gyp + url = https://chromium.googlesource.com/external/gyp.git + os = all +[submodule "tools/page_cycler/acid3"] + path = tools/page_cycler/acid3 + url = https://chromium.googlesource.com/chromium/deps/acid3.git + os = all +[submodule "tools/swarm_client"] + path = tools/swarm_client + url = https://chromium.googlesource.com/chromium/tools/swarm_client.git + os = all +[submodule "v8"] + path = v8 + url = https://chromium.googlesource.com/external/v8.git + os = all diff --git a/base/base.gyp b/base/base.gyp index c7cd608..1d87505 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -396,6 +396,7 @@ 'file_util_unittest.cc', 'file_version_info_unittest.cc', 'files/dir_reader_posix_unittest.cc', + 'files/important_file_writer_unittest.cc', 'gmock_unittest.cc', 'guid_unittest.cc', 'hi_res_timer_manager_unittest.cc', diff --git a/base/base.gypi b/base/base.gypi index 0d5be70..337f722 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -146,6 +146,8 @@ 'files/file_path_watcher_linux.cc', 'files/file_path_watcher_stub.cc', 'files/file_path_watcher_win.cc', + 'files/important_file_writer.h', + 'files/important_file_writer.cc', 'float_util.h', 'format_macros.h', 'global_descriptors_posix.cc', diff --git a/chrome/common/important_file_writer.cc b/base/files/important_file_writer.cc index 6a76dfb..6e447a4 100644 --- a/chrome/common/important_file_writer.cc +++ b/base/files/important_file_writer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/common/important_file_writer.h" +#include "base/files/important_file_writer.h" #include <stdio.h> @@ -18,7 +18,7 @@ #include "base/threading/thread.h" #include "base/time.h" -using base::TimeDelta; +namespace base { namespace { @@ -37,7 +37,7 @@ void LogFailure(const FilePath& path, TempFileFailure failure_code, const std::string& message) { UMA_HISTOGRAM_ENUMERATION("ImportantFile.TempFileFailures", failure_code, TEMP_FILE_FAILURE_MAX); - DPLOG(WARNING) << "temp file failure: " << path.value() + DPLOG(WARNING) << "temp file failure: " << path.value().c_str() << " : " << message; } @@ -52,21 +52,21 @@ void WriteToDiskTask(const FilePath& path, const std::string& data) { return; } - int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE; - base::PlatformFile tmp_file = - base::CreatePlatformFile(tmp_file_path, flags, NULL, NULL); - if (tmp_file == base::kInvalidPlatformFileValue) { + int flags = PLATFORM_FILE_OPEN | PLATFORM_FILE_WRITE; + PlatformFile tmp_file = + CreatePlatformFile(tmp_file_path, flags, NULL, NULL); + if (tmp_file == kInvalidPlatformFileValue) { LogFailure(path, FAILED_OPENING, "could not open temporary file"); return; } // If this happens in the wild something really bad is going on. CHECK_LE(data.length(), static_cast<size_t>(kint32max)); - int bytes_written = base::WritePlatformFile( + int bytes_written = WritePlatformFile( tmp_file, 0, data.data(), static_cast<int>(data.length())); - base::FlushPlatformFile(tmp_file); // Ignore return value. + FlushPlatformFile(tmp_file); // Ignore return value. - if (!base::ClosePlatformFile(tmp_file)) { + if (!ClosePlatformFile(tmp_file)) { LogFailure(path, FAILED_CLOSING, "failed to close temporary file"); file_util::Delete(tmp_file_path, false); return; @@ -74,7 +74,7 @@ void WriteToDiskTask(const FilePath& path, const std::string& data) { if (bytes_written < static_cast<int>(data.length())) { LogFailure(path, FAILED_WRITING, "error writing, bytes_written=" + - base::IntToString(bytes_written)); + IntToString(bytes_written)); file_util::Delete(tmp_file_path, false); return; } @@ -89,7 +89,7 @@ void WriteToDiskTask(const FilePath& path, const std::string& data) { } // namespace ImportantFileWriter::ImportantFileWriter( - const FilePath& path, base::MessageLoopProxy* file_message_loop_proxy) + const FilePath& path, MessageLoopProxy* file_message_loop_proxy) : path_(path), file_message_loop_proxy_(file_message_loop_proxy), serializer_(NULL), @@ -122,7 +122,7 @@ void ImportantFileWriter::WriteNow(const std::string& data) { timer_.Stop(); if (!file_message_loop_proxy_->PostTask( - FROM_HERE, base::Bind(&WriteToDiskTask, path_, data))) { + FROM_HERE, Bind(&WriteToDiskTask, path_, data))) { // Posting the task to background message loop is not expected // to fail, but if it does, avoid losing data and just hit the disk // on the current thread. @@ -151,7 +151,9 @@ void ImportantFileWriter::DoScheduledWrite() { WriteNow(data); } else { DLOG(WARNING) << "failed to serialize data to be saved in " - << path_.value(); + << path_.value().c_str(); } serializer_ = NULL; } + +} // namespace base diff --git a/chrome/common/important_file_writer.h b/base/files/important_file_writer.h index 5bd5def..4a6794c 100644 --- a/chrome/common/important_file_writer.h +++ b/base/files/important_file_writer.h @@ -2,11 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_COMMON_IMPORTANT_FILE_WRITER_H_ -#define CHROME_COMMON_IMPORTANT_FILE_WRITER_H_ +#ifndef BASE_FILES_IMPORTANT_FILE_WRITER_H_ +#define BASE_FILES_IMPORTANT_FILE_WRITER_H_ #include <string> +#include "base/base_export.h" #include "base/basictypes.h" #include "base/file_path.h" #include "base/memory/ref_counted.h" @@ -15,9 +16,9 @@ #include "base/timer.h" namespace base { + class MessageLoopProxy; class Thread; -} // Helper to ensure that a file won't be corrupted by the write (for example on // application crash). Consider a naive way to save an important file F: @@ -35,7 +36,7 @@ class Thread; // // If you want to know more about this approach and ext3/ext4 fsync issues, see // http://valhenson.livejournal.com/37921.html -class ImportantFileWriter : public base::NonThreadSafe { +class BASE_EXPORT ImportantFileWriter : public NonThreadSafe { public: // Used by ScheduleSave to lazily provide the data to be saved. Allows us // to also batch data serializations. @@ -56,7 +57,7 @@ class ImportantFileWriter : public base::NonThreadSafe { // file I/O can be done. // All non-const methods, ctor and dtor must be called on the same thread. ImportantFileWriter(const FilePath& path, - base::MessageLoopProxy* file_message_loop_proxy); + MessageLoopProxy* file_message_loop_proxy); // You have to ensure that there are no pending writes at the moment // of destruction. @@ -83,11 +84,11 @@ class ImportantFileWriter : public base::NonThreadSafe { // Serialize data pending to be saved and execute write on backend thread. void DoScheduledWrite(); - base::TimeDelta commit_interval() const { + TimeDelta commit_interval() const { return commit_interval_; } - void set_commit_interval(const base::TimeDelta& interval) { + void set_commit_interval(const TimeDelta& interval) { commit_interval_ = interval; } @@ -96,18 +97,20 @@ class ImportantFileWriter : public base::NonThreadSafe { const FilePath path_; // MessageLoopProxy for the thread on which file I/O can be done. - scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy_; + scoped_refptr<MessageLoopProxy> file_message_loop_proxy_; // Timer used to schedule commit after ScheduleWrite. - base::OneShotTimer<ImportantFileWriter> timer_; + OneShotTimer<ImportantFileWriter> timer_; // Serializer which will provide the data to be saved. DataSerializer* serializer_; // Time delta after which scheduled data will be written to disk. - base::TimeDelta commit_interval_; + TimeDelta commit_interval_; DISALLOW_COPY_AND_ASSIGN(ImportantFileWriter); }; -#endif // CHROME_COMMON_IMPORTANT_FILE_WRITER_H_ +} // namespace base + +#endif // BASE_FILES_IMPORTANT_FILE_WRITER_H_ diff --git a/chrome/common/important_file_writer_unittest.cc b/base/files/important_file_writer_unittest.cc index 35b2b44..b4e8f0f 100644 --- a/chrome/common/important_file_writer_unittest.cc +++ b/base/files/important_file_writer_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/common/important_file_writer.h" +#include "base/files/important_file_writer.h" #include "base/compiler_specific.h" #include "base/file_path.h" @@ -14,6 +14,8 @@ #include "base/time.h" #include "testing/gtest/include/gtest/gtest.h" +namespace base { + namespace { std::string GetFileContent(const FilePath& path) { @@ -58,7 +60,7 @@ class ImportantFileWriterTest : public testing::Test { TEST_F(ImportantFileWriterTest, Basic) { ImportantFileWriter writer(file_, - base::MessageLoopProxy::current()); + MessageLoopProxy::current()); EXPECT_FALSE(file_util::PathExists(writer.path())); writer.WriteNow("foo"); loop_.RunAllPending(); @@ -69,8 +71,8 @@ TEST_F(ImportantFileWriterTest, Basic) { TEST_F(ImportantFileWriterTest, ScheduleWrite) { ImportantFileWriter writer(file_, - base::MessageLoopProxy::current()); - writer.set_commit_interval(base::TimeDelta::FromMilliseconds(25)); + MessageLoopProxy::current()); + writer.set_commit_interval(TimeDelta::FromMilliseconds(25)); EXPECT_FALSE(writer.HasPendingWrite()); DataSerializer serializer("foo"); writer.ScheduleWrite(&serializer); @@ -78,7 +80,7 @@ TEST_F(ImportantFileWriterTest, ScheduleWrite) { MessageLoop::current()->PostDelayedTask( FROM_HERE, MessageLoop::QuitClosure(), - base::TimeDelta::FromMilliseconds(100)); + TimeDelta::FromMilliseconds(100)); MessageLoop::current()->Run(); EXPECT_FALSE(writer.HasPendingWrite()); ASSERT_TRUE(file_util::PathExists(writer.path())); @@ -87,7 +89,7 @@ TEST_F(ImportantFileWriterTest, ScheduleWrite) { TEST_F(ImportantFileWriterTest, DoScheduledWrite) { ImportantFileWriter writer(file_, - base::MessageLoopProxy::current()); + MessageLoopProxy::current()); EXPECT_FALSE(writer.HasPendingWrite()); DataSerializer serializer("foo"); writer.ScheduleWrite(&serializer); @@ -96,7 +98,7 @@ TEST_F(ImportantFileWriterTest, DoScheduledWrite) { MessageLoop::current()->PostDelayedTask( FROM_HERE, MessageLoop::QuitClosure(), - base::TimeDelta::FromMilliseconds(100)); + TimeDelta::FromMilliseconds(100)); MessageLoop::current()->Run(); EXPECT_FALSE(writer.HasPendingWrite()); ASSERT_TRUE(file_util::PathExists(writer.path())); @@ -106,8 +108,8 @@ TEST_F(ImportantFileWriterTest, DoScheduledWrite) { // Flaky - http://crbug.com/109292 TEST_F(ImportantFileWriterTest, DISABLED_BatchingWrites) { ImportantFileWriter writer(file_, - base::MessageLoopProxy::current()); - writer.set_commit_interval(base::TimeDelta::FromMilliseconds(25)); + MessageLoopProxy::current()); + writer.set_commit_interval(TimeDelta::FromMilliseconds(25)); DataSerializer foo("foo"), bar("bar"), baz("baz"); writer.ScheduleWrite(&foo); writer.ScheduleWrite(&bar); @@ -115,8 +117,10 @@ TEST_F(ImportantFileWriterTest, DISABLED_BatchingWrites) { MessageLoop::current()->PostDelayedTask( FROM_HERE, MessageLoop::QuitClosure(), - base::TimeDelta::FromMilliseconds(100)); + TimeDelta::FromMilliseconds(100)); MessageLoop::current()->Run(); ASSERT_TRUE(file_util::PathExists(writer.path())); EXPECT_EQ("baz", GetFileContent(writer.path())); } + +} // namespace base diff --git a/base/prefs/DEPS b/base/prefs/DEPS index ab1b336..233fb42 100644 --- a/base/prefs/DEPS +++ b/base/prefs/DEPS @@ -1,8 +1,3 @@ -include_rules = [ - # Will move to base/ - "+chrome/common/important_file_writer.h", -] - specific_include_rules = { '.*_[a-z]+test\.cc': [ "!chrome/common/chrome_notification_types.h", diff --git a/base/prefs/json_pref_store.h b/base/prefs/json_pref_store.h index 3ed1ffb1..f5f083a 100644 --- a/base/prefs/json_pref_store.h +++ b/base/prefs/json_pref_store.h @@ -11,10 +11,11 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/file_path.h" +#include "base/files/important_file_writer.h" #include "base/memory/scoped_ptr.h" +#include "base/message_loop_proxy.h" #include "base/observer_list.h" #include "base/prefs/persistent_pref_store.h" -#include "chrome/common/important_file_writer.h" namespace base { class DictionaryValue; @@ -26,7 +27,7 @@ class FilePath; // A writable PrefStore implementation that is used for user preferences. class JsonPrefStore : public PersistentPrefStore, - public ImportantFileWriter::DataSerializer { + public base::ImportantFileWriter::DataSerializer { public: // |file_message_loop_proxy| is the MessageLoopProxy for a thread on which // file I/O can be done. @@ -76,7 +77,7 @@ class JsonPrefStore : public PersistentPrefStore, bool read_only_; // Helper for safely writing pref data. - ImportantFileWriter writer_; + base::ImportantFileWriter writer_; ObserverList<PrefStore::Observer, true> observers_; diff --git a/chrome/browser/bookmarks/bookmark_storage.h b/chrome/browser/bookmarks/bookmark_storage.h index ec93d0f..b4f0d9d 100644 --- a/chrome/browser/bookmarks/bookmark_storage.h +++ b/chrome/browser/bookmarks/bookmark_storage.h @@ -5,10 +5,10 @@ #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ +#include "base/files/important_file_writer.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "chrome/browser/bookmarks/bookmark_index.h" -#include "chrome/common/important_file_writer.h" class BookmarkModel; class BookmarkPermanentNode; @@ -92,7 +92,7 @@ class BookmarkLoadDetails { // as notifying the BookmarkStorage every time the model changes. // // Internally BookmarkStorage uses BookmarkCodec to do the actual read/write. -class BookmarkStorage : public ImportantFileWriter::DataSerializer, +class BookmarkStorage : public base::ImportantFileWriter::DataSerializer, public base::RefCountedThreadSafe<BookmarkStorage> { public: // Creates a BookmarkStorage for the specified model @@ -128,7 +128,7 @@ class BookmarkStorage : public ImportantFileWriter::DataSerializer, BookmarkModel* model_; // Helper to write bookmark data safely. - ImportantFileWriter writer_; + base::ImportantFileWriter writer_; // See class description of BookmarkLoadDetails for details on this. scoped_ptr<BookmarkLoadDetails> details_; diff --git a/chrome/browser/net/transport_security_persister.h b/chrome/browser/net/transport_security_persister.h index 8896933..8458453 100644 --- a/chrome/browser/net/transport_security_persister.h +++ b/chrome/browser/net/transport_security_persister.h @@ -36,15 +36,15 @@ #include <string> #include "base/file_path.h" +#include "base/files/important_file_writer.h" #include "base/memory/weak_ptr.h" -#include "chrome/common/important_file_writer.h" #include "net/base/transport_security_state.h" // Reads and updates on-disk TransportSecurity state. // Must be created, used and destroyed only on the IO thread. class TransportSecurityPersister : public net::TransportSecurityState::Delegate, - public ImportantFileWriter::DataSerializer { + public base::ImportantFileWriter::DataSerializer { public: TransportSecurityPersister(net::TransportSecurityState* state, const FilePath& profile_path, @@ -117,7 +117,7 @@ class TransportSecurityPersister net::TransportSecurityState* transport_security_state_; // Helper for safely writing the data. - ImportantFileWriter writer_; + base::ImportantFileWriter writer_; // Whether or not we're in read-only mode. const bool readonly_; diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index c154ef8..8fba850 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -216,8 +216,6 @@ 'common/form_field_data_predictions.cc', 'common/form_field_data_predictions.h', 'common/icon_messages.h', - 'common/important_file_writer.cc', - 'common/important_file_writer.h', 'common/instant_types.cc', 'common/instant_types.h', 'common/json_schema_constants.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index b6314e9..e3378e1 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2116,7 +2116,6 @@ 'common/extensions/user_script_unittest.cc', 'common/extensions/value_counter_unittest.cc', 'common/extensions/api/extension_api_unittest.cc', - 'common/important_file_writer_unittest.cc', 'common/json_schema_validator_unittest.cc', 'common/json_schema_validator_unittest_base.cc', 'common/json_schema_validator_unittest_base.h', |