diff options
author | gregsimon@chromium.org <gregsimon@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-20 21:38:53 +0000 |
---|---|---|
committer | gregsimon@chromium.org <gregsimon@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-20 21:38:53 +0000 |
commit | 7184ea172212bfc0b6379dc3c730b90dfba7b046 (patch) | |
tree | 89a37e75a74502c397cd99da822d6ce63d3d7404 /webkit | |
parent | 186e4151cab660c370282b3ff77cb97b1c515cf6 (diff) | |
download | chromium_src-7184ea172212bfc0b6379dc3c730b90dfba7b046.zip chromium_src-7184ea172212bfc0b6379dc3c730b90dfba7b046.tar.gz chromium_src-7184ea172212bfc0b6379dc3c730b90dfba7b046.tar.bz2 |
Exporting ScopedTempDir so it can be used by webkit layout tests.
Testing the LevelDB backend from the webkit unit tests requires it
create a temporary file system. In order to clean this up
(and on all platforms) we are going to make the scoped_temp_dir
functionallity available to LayoutTestController.
TEST=This is a thin wrapper on ScopedTempDir which is already covered by unit testing. This will be connected to LayoutTestController (a future patch in WebKit).
Review URL: http://codereview.chromium.org/7034047
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86148 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/support/webkit_support.cc | 21 | ||||
-rw-r--r-- | webkit/support/webkit_support.h | 10 |
2 files changed, 31 insertions, 0 deletions
diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc index ae6f08a..6b40477 100644 --- a/webkit/support/webkit_support.cc +++ b/webkit/support/webkit_support.cc @@ -17,6 +17,7 @@ #include "base/message_loop.h" #include "base/path_service.h" #include "base/process_util.h" +#include "base/scoped_temp_dir.h" #include "base/string_piece.h" #include "base/string_util.h" #include "base/stringprintf.h" @@ -486,6 +487,26 @@ WebURL LocalFileToDataURL(const WebURL& fileUrl) { return WebURL(GURL(kDataUrlPrefix + contents_base64)); } +// A wrapper object for exporting ScopedTempDir to be used +// by webkit layout tests. +class ScopedTempDirectoryInternal : public ScopedTempDirectory { + public: + virtual bool CreateUniqueTempDir() { + return tempDirectory_.CreateUniqueTempDir(); + } + + virtual std::string path() const { + return tempDirectory_.path().MaybeAsASCII(); + } + + private: + ScopedTempDir tempDirectory_; +}; + +ScopedTempDirectory* CreateScopedTempDirectory() { + return new ScopedTempDirectoryInternal(); +} + int64 GetCurrentTimeInMillisecond() { return base::TimeTicks::Now().ToInternalValue() / base::Time::kMicrosecondsPerMillisecond; diff --git a/webkit/support/webkit_support.h b/webkit/support/webkit_support.h index 2482c87..d11f09b 100644 --- a/webkit/support/webkit_support.h +++ b/webkit/support/webkit_support.h @@ -154,6 +154,16 @@ bool SetCurrentDirectoryForFileURL(const WebKit::WebURL& fileUrl); // Convert a file:/// URL to a base64 encoded data: URL. WebKit::WebURL LocalFileToDataURL(const WebKit::WebURL& fileUrl); +// Scoped temporary directories for use by webkit layout tests. +class ScopedTempDirectory { + public: + virtual ~ScopedTempDirectory() {} + virtual bool CreateUniqueTempDir() = 0; + virtual std::string path() const = 0; +}; + +ScopedTempDirectory* CreateScopedTempDirectory(); + // -------- Time int64 GetCurrentTimeInMillisecond(); |