From 3367fc1dd134eeaf9ab6e62397f05ad3964319fe Mon Sep 17 00:00:00 2001 From: "michaeln@google.com" Date: Mon, 9 Nov 2009 00:09:21 +0000 Subject: AppCache changes to the networking model. Added new classes AppCacheRequestHandler and AppCacheURLRequestJob. TEST=appcache_url_request_job_unittest.cc, appcache_request_handler_unittest.cc BUG=none Review URL: http://codereview.chromium.org/338034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31411 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/appcache/appcache_response_unittest.cc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'webkit/appcache/appcache_response_unittest.cc') diff --git a/webkit/appcache/appcache_response_unittest.cc b/webkit/appcache/appcache_response_unittest.cc index 939086e..1077b9b 100644 --- a/webkit/appcache/appcache_response_unittest.cc +++ b/webkit/appcache/appcache_response_unittest.cc @@ -12,6 +12,7 @@ #include "webkit/appcache/mock_appcache_service.h" using net::IOBuffer; +using net::WrappedIOBuffer; namespace appcache { @@ -164,16 +165,21 @@ class AppCacheResponseTest : public testing::Test { // Wrappers to call AppCacheResponseReader/Writer Read and Write methods void WriteBasicResponse() { - static const char* kRawHttpHeaders = - "HTTP/1.0 200 OK\r\nContent-Length: 5\r\n\r\n"; - static const char* kRawHttpBody = "Hello"; - WriteResponse(MakeHttpResponseInfo(kRawHttpHeaders), kRawHttpBody); - } - - void WriteResponse(net::HttpResponseInfo* head, const char* body) { + static const char kHttpHeaders[] = + "HTTP/1.0 200 OK\0Content-Length: 5\0\0"; + static const char* kHttpBody = "Hello"; + scoped_refptr body = new WrappedIOBuffer(kHttpBody); + std::string raw_headers(kHttpHeaders, arraysize(kHttpHeaders)); + WriteResponse(MakeHttpResponseInfo(raw_headers), body, strlen(kHttpBody)); + } + + void WriteResponse(net::HttpResponseInfo* head, + IOBuffer* body, int body_len) { + DCHECK(body); + scoped_refptr body_ref(body); PushNextTask(method_factory_.NewRunnableMethod( &AppCacheResponseTest::WriteResponseBody, - new net::WrappedIOBuffer(body), strlen(body))); + body_ref, body_len)); WriteResponseHead(head); } @@ -238,7 +244,7 @@ class AppCacheResponseTest : public testing::Test { // Helpers to work with HttpResponseInfo objects - net::HttpResponseInfo* MakeHttpResponseInfo(const char* raw_headers) { + net::HttpResponseInfo* MakeHttpResponseInfo(const std::string& raw_headers) { net::HttpResponseInfo* info = new net::HttpResponseInfo; info->request_time = base::Time::Now(); info->response_time = base::Time::Now(); -- cgit v1.1