diff options
author | tkent@chromium.org <tkent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-03 00:54:05 +0000 |
---|---|---|
committer | tkent@chromium.org <tkent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-03 00:54:05 +0000 |
commit | 783a516a3fa720df98d4df5bb4296971cdd9d80b (patch) | |
tree | cd80ceb3317bb5c9a0d62094d46b5fef7255306e /webkit | |
parent | d8f33a693a3b49024bd0ceaca04a7ada2f15f997 (diff) | |
download | chromium_src-783a516a3fa720df98d4df5bb4296971cdd9d80b.zip chromium_src-783a516a3fa720df98d4df5bb4296971cdd9d80b.tar.gz chromium_src-783a516a3fa720df98d4df5bb4296971cdd9d80b.tar.bz2 |
webkit_support: Prepareation to remove dependencies to base/time.h,
net/base/escape.h, and net/base/net_errors.h from DRT.
Make wrapper functions of features used by DRT.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/2873088
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54646 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/support/webkit_support.cc | 50 | ||||
-rw-r--r-- | webkit/support/webkit_support.h | 13 |
2 files changed, 63 insertions, 0 deletions
diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc index e354d49..87f140e 100644 --- a/webkit/support/webkit_support.cc +++ b/webkit/support/webkit_support.cc @@ -15,14 +15,19 @@ #include "base/path_service.h" #include "base/process_util.h" #include "base/string_piece.h" +#include "base/string_util.h" #include "base/sys_string_conversions.h" +#include "base/time.h" #include "base/utf_string_conversions.h" #include "base/weak_ptr.h" #include "grit/webkit_chromium_resources.h" +#include "net/base/escape.h" +#include "net/base/net_errors.h" #include "net/base/net_util.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" #include "third_party/WebKit/WebKit/chromium/public/WebPluginParams.h" +#include "third_party/WebKit/WebKit/chromium/public/WebURLError.h" #include "webkit/appcache/web_application_cache_host_impl.h" #include "webkit/glue/media/buffered_data_source.h" #include "webkit/glue/media/media_resource_loader_bridge_factory.h" @@ -389,6 +394,51 @@ bool SetCurrentDirectoryForFileURL(const WebKit::WebURL& fileUrl) { && file_util::SetCurrentDirectory(localPath.DirName()); } +int64 GetCurrentTimeInMillisecond() { + return base::TimeTicks::Now().ToInternalValue() + / base::Time::kMicrosecondsPerMillisecond; +} + +std::string EscapePath(const std::string& path) { + return ::EscapePath(path); +} + +std::string MakeURLErrorDescription(const WebKit::WebURLError& error) { + std::string domain = error.domain.utf8(); + int code = error.reason; + + if (domain == net::kErrorDomain) { + domain = "NSURLErrorDomain"; + switch (error.reason) { + case net::ERR_ABORTED: + code = -999; + break; + case net::ERR_UNSAFE_PORT: + // Our unsafe port checking happens at the network stack level, but we + // make this translation here to match the behavior of stock WebKit. + domain = "WebKitErrorDomain"; + code = 103; + break; + case net::ERR_ADDRESS_INVALID: + case net::ERR_ADDRESS_UNREACHABLE: + code = -1004; + break; + } + } else + DLOG(WARNING) << "Unknown error domain"; + + return StringPrintf("<NSError domain %s, code %d, failing URL \"%s\">", + domain.c_str(), code, error.unreachableURL.spec().data()); +} + +WebKit::WebURLError CreateCancelledError(const WebKit::WebURLRequest& request) { + WebKit::WebURLError error; + error.domain = WebKit::WebString::fromUTF8(net::kErrorDomain); + error.reason = net::ERR_ABORTED; + error.unreachableURL = request.url(); + return error; +} + // Bridge for SimpleDatabaseSystem void SetDatabaseQuota(int quota) { diff --git a/webkit/support/webkit_support.h b/webkit/support/webkit_support.h index d577c09..a762669 100644 --- a/webkit/support/webkit_support.h +++ b/webkit/support/webkit_support.h @@ -23,8 +23,10 @@ class WebPlugin; class WebString; class WebThemeEngine; class WebURL; +class WebURLRequest; class WebURLResponse; struct WebPluginParams; +struct WebURLError; } // This package provides functions used by DumpRenderTree/chromium. @@ -118,6 +120,17 @@ WebKit::WebURL RewriteLayoutTestsURL(const std::string& utf8_url); // Set the directory of specified file: URL as the current working directory. bool SetCurrentDirectoryForFileURL(const WebKit::WebURL& fileUrl); +// -------- Time +int64 GetCurrentTimeInMillisecond(); + +// -------- Net +// A wrapper of net::EscapePath(). +std::string EscapePath(const std::string& path); +// Make an error description for layout tests. +std::string MakeURLErrorDescription(const WebKit::WebURLError& error); +// Creates WebURLError for an aborted request. +WebKit::WebURLError CreateCancelledError(const WebKit::WebURLRequest& request); + // - Database void SetDatabaseQuota(int quota); void ClearAllDatabases(); |