diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-21 19:18:36 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-21 19:18:36 +0000 |
commit | 4252f6098889f2c5a8649d1688b269e53a51d42d (patch) | |
tree | bbb1040a665b91ac297685ee6b7add579822a911 /webkit/appcache | |
parent | 29a6c9738ebb608d40567189452fd9c19f55569c (diff) | |
download | chromium_src-4252f6098889f2c5a8649d1688b269e53a51d42d.zip chromium_src-4252f6098889f2c5a8649d1688b269e53a51d42d.tar.gz chromium_src-4252f6098889f2c5a8649d1688b269e53a51d42d.tar.bz2 |
More groundwork for filestream based response storage.
This CL touches many files, but it amounts to mindless plumbing of a group_id value.
This doesn't involve any new database or fileio or task scheduling.
In order to read or write a response, callers now need to provide the group_id of
the corresponding manifest, so the AppCacheStorage CreateRepsonseReader() and
CreateResponseWriter() methods now take this additional parameter.
The current disk_cache based impl doesn't use this param for anything, but the
filestream based impl will use it to keep responses for a group in a particular
subdirectory.
When looking up the main resource for a page load via FindResponseForMainRequest,
the group_id needs to be returned so the response may later be read, the
AppCacheStorage::Delegate OnMainResponseFound() method has a param for that.
A bunch of callsites, tests, and mocks are updated accordingly.
BUG=78359
Review URL: http://codereview.chromium.org/8343018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106755 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache')
25 files changed, 227 insertions, 143 deletions
diff --git a/webkit/appcache/appcache_host.cc b/webkit/appcache/appcache_host.cc index dd9f9fb..d2cc50f 100644 --- a/webkit/appcache/appcache_host.cc +++ b/webkit/appcache/appcache_host.cc @@ -24,7 +24,9 @@ void FillCacheInfo( info->status = status; info->is_complete = cache->is_complete(); if (info->is_complete) { + DCHECK(cache->owning_group()); info->manifest_url = cache->owning_group()->manifest_url(); + info->group_id = cache->owning_group()->group_id(); info->last_update_time = cache->update_time(); info->creation_time = cache->owning_group()->creation_time(); info->size = cache->cache_size(); diff --git a/webkit/appcache/appcache_interfaces.cc b/webkit/appcache/appcache_interfaces.cc index 3f9fa19..eaa91ca6 100644 --- a/webkit/appcache/appcache_interfaces.cc +++ b/webkit/appcache/appcache_interfaces.cc @@ -25,6 +25,7 @@ const FilePath::CharType kAppCacheDatabaseName[] = FILE_PATH_LITERAL("Index"); AppCacheInfo::AppCacheInfo() : cache_id(kNoCacheId), + group_id(0), status(UNCACHED), size(0), is_complete(false) { diff --git a/webkit/appcache/appcache_interfaces.h b/webkit/appcache/appcache_interfaces.h index 70baf3a..449b004 100644 --- a/webkit/appcache/appcache_interfaces.h +++ b/webkit/appcache/appcache_interfaces.h @@ -64,6 +64,7 @@ struct APPCACHE_EXPORT AppCacheInfo { base::Time last_update_time; base::Time last_access_time; int64 cache_id; + int64 group_id; Status status; int64 size; bool is_complete; diff --git a/webkit/appcache/appcache_request_handler.cc b/webkit/appcache/appcache_request_handler.cc index f4d74b1..dc55088 100644 --- a/webkit/appcache/appcache_request_handler.cc +++ b/webkit/appcache/appcache_request_handler.cc @@ -12,11 +12,12 @@ namespace appcache { -AppCacheRequestHandler::AppCacheRequestHandler(AppCacheHost* host, - ResourceType::Type resource_type) +AppCacheRequestHandler::AppCacheRequestHandler( + AppCacheHost* host, ResourceType::Type resource_type) : host_(host), resource_type_(resource_type), - is_waiting_for_cache_selection_(false), found_cache_id_(0), - found_network_namespace_(false), cache_entry_not_found_(false) { + is_waiting_for_cache_selection_(false), found_group_id_(0), + found_cache_id_(0), found_network_namespace_(false), + cache_entry_not_found_(false) { DCHECK(host_); host_->AddObserver(this); } @@ -103,8 +104,8 @@ AppCacheURLRequestJob* AppCacheRequestHandler::MaybeLoadFallbackForRedirect( // get the resource of the fallback entry. job_ = new AppCacheURLRequestJob(request, storage()); DeliverAppCachedResponse( - found_fallback_entry_, found_cache_id_, found_manifest_url_, - true, found_fallback_url_); + found_fallback_entry_, found_cache_id_, found_group_id_, + found_manifest_url_, true, found_fallback_url_); } else if (!found_network_namespace_) { // 6.9.6, step 6: Fail the resource load. job_ = new AppCacheURLRequestJob(request, storage()); @@ -155,8 +156,8 @@ AppCacheURLRequestJob* AppCacheRequestHandler::MaybeLoadFallbackForResponse( // or there were network errors, get the resource of the fallback entry. job_ = new AppCacheURLRequestJob(request, storage()); DeliverAppCachedResponse( - found_fallback_entry_, found_cache_id_, found_manifest_url_, - true, found_fallback_url_); + found_fallback_entry_, found_cache_id_, found_group_id_, + found_manifest_url_, true, found_fallback_url_); return job_; } @@ -173,8 +174,8 @@ void AppCacheRequestHandler::OnDestructionImminent(AppCacheHost* host) { } void AppCacheRequestHandler::DeliverAppCachedResponse( - const AppCacheEntry& entry, int64 cache_id, const GURL& manifest_url, - bool is_fallback, const GURL& fallback_url) { + const AppCacheEntry& entry, int64 cache_id, int64 group_id, + const GURL& manifest_url, bool is_fallback, const GURL& fallback_url) { DCHECK(host_ && job_ && job_->is_waiting()); DCHECK(entry.has_response_id()); @@ -183,7 +184,8 @@ void AppCacheRequestHandler::DeliverAppCachedResponse( host_->NotifyMainResourceFallback(fallback_url); } - job_->DeliverAppCachedResponse(manifest_url, cache_id, entry, is_fallback); + job_->DeliverAppCachedResponse(manifest_url, group_id, cache_id, + entry, is_fallback); } void AppCacheRequestHandler::DeliverErrorResponse() { @@ -218,7 +220,7 @@ void AppCacheRequestHandler::MaybeLoadMainResource(net::URLRequest* request) { void AppCacheRequestHandler::OnMainResponseFound( const GURL& url, const AppCacheEntry& entry, const GURL& fallback_url, const AppCacheEntry& fallback_entry, - int64 cache_id, const GURL& manifest_url) { + int64 cache_id, int64 group_id, const GURL& manifest_url) { DCHECK(job_); DCHECK(host_); DCHECK(is_main_resource()); @@ -259,12 +261,13 @@ void AppCacheRequestHandler::OnMainResponseFound( found_fallback_url_ = fallback_url; found_fallback_entry_ = fallback_entry; found_cache_id_ = cache_id; + found_group_id_ = group_id; found_manifest_url_ = manifest_url; found_network_namespace_ = false; // not applicable to main requests if (found_entry_.has_response_id()) { DeliverAppCachedResponse( - found_entry_, found_cache_id_, found_manifest_url_, + found_entry_, found_cache_id_, found_group_id_, found_manifest_url_, false, GURL()); } else { DeliverNetworkResponse(); @@ -313,9 +316,10 @@ void AppCacheRequestHandler::ContinueMaybeLoadSubResource() { DCHECK(!found_network_namespace_ && !found_fallback_entry_.has_response_id()); found_cache_id_ = cache->cache_id(); + found_group_id_ = cache->owning_group()->group_id(); found_manifest_url_ = cache->owning_group()->manifest_url(); DeliverAppCachedResponse( - found_entry_, found_cache_id_, found_manifest_url_, + found_entry_, found_cache_id_, found_group_id_, found_manifest_url_, false, GURL()); return; } diff --git a/webkit/appcache/appcache_request_handler.h b/webkit/appcache/appcache_request_handler.h index e2f5b94..b4a387d 100644 --- a/webkit/appcache/appcache_request_handler.h +++ b/webkit/appcache/appcache_request_handler.h @@ -53,13 +53,13 @@ class APPCACHE_EXPORT AppCacheRequestHandler AppCacheRequestHandler(AppCacheHost* host, ResourceType::Type resource_type); // AppCacheHost::Observer override - virtual void OnDestructionImminent(AppCacheHost* host); + virtual void OnDestructionImminent(AppCacheHost* host) OVERRIDE; // Helpers to instruct a waiting job with what response to // deliver for the request we're handling. void DeliverAppCachedResponse(const AppCacheEntry& entry, int64 cache_id, - const GURL& manifest_url, bool is_fallback, - const GURL& fallback_url); + int64 group_id, const GURL& manifest_url, + bool is_fallback, const GURL& fallback_url); void DeliverNetworkResponse(); void DeliverErrorResponse(); @@ -79,7 +79,7 @@ class APPCACHE_EXPORT AppCacheRequestHandler virtual void OnMainResponseFound( const GURL& url, const AppCacheEntry& entry, const GURL& fallback_url, const AppCacheEntry& fallback_entry, - int64 cache_id, const GURL& mainfest_url); + int64 cache_id, int64 group_id, const GURL& mainfest_url) OVERRIDE; // Sub-resource loading ------------------------------------- // Dedicated worker and all manner of sub-resources are handled here. @@ -88,7 +88,7 @@ class APPCACHE_EXPORT AppCacheRequestHandler void ContinueMaybeLoadSubResource(); // AppCacheHost::Observer override - virtual void OnCacheSelectionComplete(AppCacheHost* host); + virtual void OnCacheSelectionComplete(AppCacheHost* host) OVERRIDE; // Data members ----------------------------------------------- @@ -103,6 +103,7 @@ class APPCACHE_EXPORT AppCacheRequestHandler // Info about the type of response we found for delivery. // These are relevant for both main and subresource requests. + int64 found_group_id_; int64 found_cache_id_; AppCacheEntry found_entry_; AppCacheEntry found_fallback_entry_; diff --git a/webkit/appcache/appcache_request_handler_unittest.cc b/webkit/appcache/appcache_request_handler_unittest.cc index 60324fb0..0d706d2 100644 --- a/webkit/appcache/appcache_request_handler_unittest.cc +++ b/webkit/appcache/appcache_request_handler_unittest.cc @@ -255,6 +255,7 @@ class AppCacheRequestHandlerTest : public testing::Test { handler_->GetExtraResponseInfo(&cache_id, &manifest_url); EXPECT_EQ(kNoCacheId, cache_id); EXPECT_EQ(GURL(), manifest_url); + EXPECT_EQ(0, handler_->found_group_id_); AppCacheURLRequestJob* fallback_job; fallback_job = handler_->MaybeLoadFallbackForRedirect( @@ -282,7 +283,7 @@ class AppCacheRequestHandlerTest : public testing::Test { mock_storage()->SimulateFindMainResource( AppCacheEntry(AppCacheEntry::EXPLICIT, 1), GURL(), AppCacheEntry(), - 1, GURL("http://blah/manifest/")); + 1, 2, GURL("http://blah/manifest/")); job_ = handler_->MaybeLoadResource(request_.get()); EXPECT_TRUE(job_.get()); @@ -301,6 +302,7 @@ class AppCacheRequestHandlerTest : public testing::Test { handler_->GetExtraResponseInfo(&cache_id, &manifest_url); EXPECT_EQ(1, cache_id); EXPECT_EQ(GURL("http://blah/manifest/"), manifest_url); + EXPECT_EQ(2, handler_->found_group_id_); AppCacheURLRequestJob* fallback_job; fallback_job = handler_->MaybeLoadFallbackForResponse(request_.get()); @@ -327,7 +329,7 @@ class AppCacheRequestHandlerTest : public testing::Test { AppCacheEntry(), GURL("http://blah/fallbackurl"), AppCacheEntry(AppCacheEntry::EXPLICIT, 1), - 1, GURL("http://blah/manifest/")); + 1, 2, GURL("http://blah/manifest/")); job_ = handler_->MaybeLoadResource(request_.get()); EXPECT_TRUE(job_.get()); @@ -384,7 +386,7 @@ class AppCacheRequestHandlerTest : public testing::Test { AppCacheEntry(), GURL("http://blah/fallbackurl"), AppCacheEntry(AppCacheEntry::EXPLICIT, 1), - 1, GURL("http://blah/manifest/")); + 1, 2, GURL("http://blah/manifest/")); job_ = handler_->MaybeLoadResource(request_.get()); EXPECT_TRUE(job_.get()); @@ -755,7 +757,7 @@ class AppCacheRequestHandlerTest : public testing::Test { mock_storage()->SimulateFindMainResource( AppCacheEntry(AppCacheEntry::EXPLICIT, 1), GURL(), AppCacheEntry(), - 1, GURL("http://blah/manifest/")); + 1, 2, GURL("http://blah/manifest/")); job_ = handler_->MaybeLoadResource(request_.get()); EXPECT_TRUE(job_.get()); @@ -770,6 +772,7 @@ class AppCacheRequestHandlerTest : public testing::Test { EXPECT_FALSE(job_->is_delivering_appcache_response()); EXPECT_EQ(0, handler_->found_cache_id_); + EXPECT_EQ(0, handler_->found_group_id_); EXPECT_TRUE(handler_->found_manifest_url_.is_empty()); EXPECT_TRUE(host_->preferred_manifest_url().is_empty()); EXPECT_TRUE(host_->main_resource_blocked_); diff --git a/webkit/appcache/appcache_response.cc b/webkit/appcache/appcache_response.cc index 3845ce3..28e035b 100644 --- a/webkit/appcache/appcache_response.cc +++ b/webkit/appcache/appcache_response.cc @@ -72,8 +72,8 @@ HttpResponseInfoIOBuffer::~HttpResponseInfoIOBuffer() {} // AppCacheResponseIO ---------------------------------------------- AppCacheResponseIO::AppCacheResponseIO( - int64 response_id, AppCacheDiskCacheInterface* disk_cache) - : response_id_(response_id), disk_cache_(disk_cache), + int64 response_id, int64 group_id, AppCacheDiskCacheInterface* disk_cache) + : response_id_(response_id), group_id_(group_id), disk_cache_(disk_cache), entry_(NULL), buffer_len_(0), user_callback_(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(raw_callback_( @@ -135,8 +135,8 @@ void AppCacheResponseIO::OnRawIOComplete(int result) { // AppCacheResponseReader ---------------------------------------------- AppCacheResponseReader::AppCacheResponseReader( - int64 response_id, AppCacheDiskCacheInterface* disk_cache) - : AppCacheResponseIO(response_id, disk_cache), + int64 response_id, int64 group_id, AppCacheDiskCacheInterface* disk_cache) + : AppCacheResponseIO(response_id, group_id, disk_cache), range_offset_(0), range_length_(kint32max), read_position_(0) { } @@ -269,8 +269,8 @@ void AppCacheResponseReader::OnOpenEntryComplete(int rv) { // AppCacheResponseWriter ---------------------------------------------- AppCacheResponseWriter::AppCacheResponseWriter( - int64 response_id, AppCacheDiskCacheInterface* disk_cache) - : AppCacheResponseIO(response_id, disk_cache), + int64 response_id, int64 group_id, AppCacheDiskCacheInterface* disk_cache) + : AppCacheResponseIO(response_id, group_id, disk_cache), info_size_(0), write_position_(0), write_amount_(0), creation_phase_(INITIAL_ATTEMPT) { } diff --git a/webkit/appcache/appcache_response.h b/webkit/appcache/appcache_response.h index ca24c37..1f19ba6 100644 --- a/webkit/appcache/appcache_response.h +++ b/webkit/appcache/appcache_response.h @@ -118,6 +118,7 @@ class APPCACHE_EXPORT AppCacheResponseIO { }; AppCacheResponseIO(int64 response_id, + int64 group_id, AppCacheDiskCacheInterface* disk_cache); virtual void OnIOComplete(int result) = 0; @@ -129,6 +130,7 @@ class APPCACHE_EXPORT AppCacheResponseIO { void WriteRaw(int index, int offset, net::IOBuffer* buf, int buf_len); const int64 response_id_; + const int64 group_id_; AppCacheDiskCacheInterface* disk_cache_; AppCacheDiskCacheInterface::Entry* entry_; scoped_refptr<HttpResponseInfoIOBuffer> info_buffer_; @@ -190,6 +192,7 @@ class APPCACHE_EXPORT AppCacheResponseReader : public AppCacheResponseIO { // Should only be constructed by the storage class. AppCacheResponseReader(int64 response_id, + int64 group_id, AppCacheDiskCacheInterface* disk_cache); virtual void OnIOComplete(int result); @@ -252,6 +255,7 @@ class APPCACHE_EXPORT AppCacheResponseWriter : public AppCacheResponseIO { // Should only be constructed by the storage class. AppCacheResponseWriter(int64 response_id, + int64 group_id, AppCacheDiskCacheInterface* disk_cache); virtual void OnIOComplete(int result); diff --git a/webkit/appcache/appcache_response_unittest.cc b/webkit/appcache/appcache_response_unittest.cc index 2a36b5e..ae75a4b 100644 --- a/webkit/appcache/appcache_response_unittest.cc +++ b/webkit/appcache/appcache_response_unittest.cc @@ -306,7 +306,7 @@ class AppCacheResponseTest : public testing::Test { // 2. Attempt to ReadData reader_.reset(service_->storage()->CreateResponseReader( - GURL(), kNoSuchResponseId)); + GURL(), 0, kNoSuchResponseId)); // Push tasks in reverse order PushNextTask(NewRunnableMethod( @@ -336,7 +336,7 @@ class AppCacheResponseTest : public testing::Test { void LoadResponseInfo_Miss() { PushNextTask(NewRunnableMethod( this, &AppCacheResponseTest::LoadResponseInfo_Miss_Verify)); - service_->storage()->LoadResponseInfo(GURL(), kNoSuchResponseId, + service_->storage()->LoadResponseInfo(GURL(), 0, kNoSuchResponseId, storage_delegate_.get()); } @@ -355,7 +355,7 @@ class AppCacheResponseTest : public testing::Test { // 2. Use LoadResponseInfo to read the response headers back out PushNextTask(NewRunnableMethod( this, &AppCacheResponseTest::LoadResponseInfo_Hit_Step2)); - writer_.reset(service_->storage()->CreateResponseWriter(GURL())); + writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); written_response_id_ = writer_->response_id(); WriteBasicResponse(); } @@ -364,7 +364,7 @@ class AppCacheResponseTest : public testing::Test { writer_.reset(); PushNextTask(NewRunnableMethod( this, &AppCacheResponseTest::LoadResponseInfo_Hit_Verify)); - service_->storage()->LoadResponseInfo(GURL(), written_response_id_, + service_->storage()->LoadResponseInfo(GURL(), 0, written_response_id_, storage_delegate_.get()); } @@ -400,7 +400,7 @@ class AppCacheResponseTest : public testing::Test { PushNextTask(NewRunnableMethod( this, &AppCacheResponseTest::WriteResponseHead, head)); - writer_.reset(service_->storage()->CreateResponseWriter(GURL())); + writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); written_response_id_ = writer_->response_id(); ScheduleNextTask(); } @@ -446,7 +446,7 @@ class AppCacheResponseTest : public testing::Test { } void WriteOutBlocks() { - writer_.reset(service_->storage()->CreateResponseWriter(GURL())); + writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); written_response_id_ = writer_->response_id(); for (int i = 0; i < kNumBlocks; ++i) { PushNextTask(NewRunnableMethod( @@ -465,7 +465,7 @@ class AppCacheResponseTest : public testing::Test { void ReadInBlocks() { writer_.reset(); reader_.reset(service_->storage()->CreateResponseReader( - GURL(), written_response_id_)); + GURL(), 0, written_response_id_)); for (int i = 0; i < kNumBlocks; ++i) { PushNextTask(NewRunnableMethod( this, &AppCacheResponseTest::ReadOneBlock, kNumBlocks - i)); @@ -488,7 +488,7 @@ class AppCacheResponseTest : public testing::Test { PushNextTask(NewRunnableMethod( this, &AppCacheResponseTest::VerifyAllAtOnce)); reader_.reset(service_->storage()->CreateResponseReader( - GURL(), written_response_id_)); + GURL(), 0, written_response_id_)); int big_size = kNumBlocks * kBlockSize; ReadResponseBody(new IOBuffer(big_size), big_size); } @@ -512,7 +512,7 @@ class AppCacheResponseTest : public testing::Test { PushNextTask(NewRunnableMethod( this, &AppCacheResponseTest::VerifyRange)); reader_.reset(service_->storage()->CreateResponseReader( - GURL(), written_response_id_)); + GURL(), 0, written_response_id_)); reader_->SetReadRange(kBlockSize, kBlockSize); ReadResponseBody(new IOBuffer(kBlockSize), kBlockSize); } @@ -526,7 +526,7 @@ class AppCacheResponseTest : public testing::Test { PushNextTask(NewRunnableMethod( this, &AppCacheResponseTest::VerifyRangeBeyondEOF)); reader_.reset(service_->storage()->CreateResponseReader( - GURL(), written_response_id_)); + GURL(), 0, written_response_id_)); reader_->SetReadRange(kBlockSize, kNumBlocks * kBlockSize); ReadResponseBody(new IOBuffer(kNumBlocks * kBlockSize), kNumBlocks * kBlockSize); @@ -540,7 +540,7 @@ class AppCacheResponseTest : public testing::Test { void ReadRangeFullyBeyondEOF() { reader_.reset(service_->storage()->CreateResponseReader( - GURL(), written_response_id_)); + GURL(), 0, written_response_id_)); reader_->SetReadRange((kNumBlocks * kBlockSize) + 1, kBlockSize); ReadResponseBody(new IOBuffer(kBlockSize), kBlockSize); expected_read_result_ = 0; @@ -563,7 +563,7 @@ class AppCacheResponseTest : public testing::Test { } void WriteOutBlocksImmediately() { - writer_.reset(service_->storage()->CreateResponseWriter(GURL())); + writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); written_response_id_ = writer_->response_id(); for (int i = 0; i < kNumBlocks; ++i) { PushNextTaskAsImmediate(NewRunnableMethod( @@ -575,7 +575,7 @@ class AppCacheResponseTest : public testing::Test { void ReadInBlocksImmediately() { writer_.reset(); reader_.reset(service_->storage()->CreateResponseReader( - GURL(), written_response_id_)); + GURL(), 0, written_response_id_)); for (int i = 0; i < kNumBlocks; ++i) { PushNextTaskAsImmediate(NewRunnableMethod( this, &AppCacheResponseTest::ReadOneBlockImmediately, @@ -634,7 +634,7 @@ class AppCacheResponseTest : public testing::Test { void ReadThenDelete() { read_callback_was_called_ = false; reader_.reset(service_->storage()->CreateResponseReader( - GURL(), written_response_id_)); + GURL(), 0, written_response_id_)); ReadResponseBody(new IOBuffer(kBlockSize), kBlockSize); EXPECT_TRUE(reader_->IsReadPending()); reader_.reset(); diff --git a/webkit/appcache/appcache_service.cc b/webkit/appcache/appcache_service.cc index a16a9dc..e1fac1b 100644 --- a/webkit/appcache/appcache_service.cc +++ b/webkit/appcache/appcache_service.cc @@ -97,7 +97,7 @@ class AppCacheService::CanHandleOfflineHelper : AsyncHelper { virtual void OnMainResponseFound( const GURL& url, const AppCacheEntry& entry, const GURL& fallback_url, const AppCacheEntry& fallback_entry, - int64 cache_id, const GURL& mainfest_url); + int64 cache_id, int64 group_id, const GURL& mainfest_url) OVERRIDE; GURL url_; GURL first_party_; @@ -107,7 +107,7 @@ class AppCacheService::CanHandleOfflineHelper : AsyncHelper { void AppCacheService::CanHandleOfflineHelper::OnMainResponseFound( const GURL& url, const AppCacheEntry& entry, const GURL& fallback_url, const AppCacheEntry& fallback_entry, - int64 cache_id, const GURL& manifest_url) { + int64 cache_id, int64 group_id, const GURL& manifest_url) { bool can = (entry.has_response_id() || fallback_entry.has_response_id()); CallCallback(can ? net::OK : net::ERR_FAILED); delete this; @@ -361,7 +361,7 @@ void AppCacheService::CheckResponseHelper::OnGroupLoaded( // Verify that we can read the response info and data. expected_total_size_ = entry->response_size(); response_reader_.reset(service_->storage()->CreateResponseReader( - manifest_url_, response_id_)); + manifest_url_, group->group_id(), response_id_)); info_buffer_ = new HttpResponseInfoIOBuffer(); response_reader_->ReadInfo(info_buffer_, &read_info_callback_); } diff --git a/webkit/appcache/appcache_service_unittest.cc b/webkit/appcache/appcache_service_unittest.cc index 8002177..dd37d47 100644 --- a/webkit/appcache/appcache_service_unittest.cc +++ b/webkit/appcache/appcache_service_unittest.cc @@ -33,7 +33,7 @@ class MockResponseReader : public AppCacheResponseReader { MockResponseReader(int64 response_id, net::HttpResponseInfo* info, int info_size, const char* data, int data_size) - : AppCacheResponseReader(response_id, NULL), + : AppCacheResponseReader(response_id, 0, NULL), info_(info), info_size_(info_size), data_(data), data_size_(data_size) { } diff --git a/webkit/appcache/appcache_storage.cc b/webkit/appcache/appcache_storage.cc index 47e64db..7247c40 100644 --- a/webkit/appcache/appcache_storage.cc +++ b/webkit/appcache/appcache_storage.cc @@ -39,10 +39,12 @@ AppCacheStorage::DelegateReference::~DelegateReference() { AppCacheStorage::ResponseInfoLoadTask::ResponseInfoLoadTask( const GURL& manifest_url, + int64 group_id, int64 response_id, AppCacheStorage* storage) : storage_(storage), manifest_url_(manifest_url), + group_id_(group_id), response_id_(response_id), info_buffer_(new HttpResponseInfoIOBuffer), ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_( @@ -58,7 +60,7 @@ void AppCacheStorage::ResponseInfoLoadTask::StartIfNeeded() { if (reader_.get()) return; reader_.reset( - storage_->CreateResponseReader(manifest_url_, response_id_)); + storage_->CreateResponseReader(manifest_url_, group_id_, response_id_)); reader_->ReadInfo(info_buffer_, &read_callback_); } @@ -76,15 +78,16 @@ void AppCacheStorage::ResponseInfoLoadTask::OnReadComplete(int result) { } void AppCacheStorage::LoadResponseInfo( - const GURL& manifest_url, int64 id, Delegate* delegate) { + const GURL& manifest_url, int64 group_id, int64 id, Delegate* delegate) { AppCacheResponseInfo* info = working_set_.GetResponseInfo(id); if (info) { delegate->OnResponseInfoLoaded(info, id); return; } ResponseInfoLoadTask* info_load = - GetOrCreateResponseInfoLoadTask(manifest_url, id); + GetOrCreateResponseInfoLoadTask(manifest_url, group_id, id); DCHECK(manifest_url == info_load->manifest_url()); + DCHECK(group_id == info_load->group_id()); DCHECK(id == info_load->response_id()); info_load->AddDelegate(GetOrCreateDelegateReference(delegate)); info_load->StartIfNeeded(); diff --git a/webkit/appcache/appcache_storage.h b/webkit/appcache/appcache_storage.h index 7df1580..7aab17f 100644 --- a/webkit/appcache/appcache_storage.h +++ b/webkit/appcache/appcache_storage.h @@ -66,7 +66,7 @@ class APPCACHE_EXPORT AppCacheStorage { virtual void OnMainResponseFound( const GURL& url, const AppCacheEntry& entry, const GURL& fallback_url, const AppCacheEntry& fallback_entry, - int64 cache_id, const GURL& mainfest_url) {} + int64 cache_id, int64 group_id, const GURL& mainfest_url) {} }; explicit AppCacheStorage(AppCacheService* service); @@ -98,7 +98,8 @@ class APPCACHE_EXPORT AppCacheStorage { // immediately without returning to the message loop. If the load fails, // the delegate will be called back with a NULL pointer. virtual void LoadResponseInfo( - const GURL& manifest_url, int64 response_id, Delegate* delegate); + const GURL& manifest_url, int64 group_id, int64 response_id, + Delegate* delegate); // Schedules a group and its newest complete cache to be initially stored or // incrementally updated with new changes. Upon completion the delegate @@ -150,12 +151,12 @@ class APPCACHE_EXPORT AppCacheStorage { // Creates a reader to read a response from storage. virtual AppCacheResponseReader* CreateResponseReader( - const GURL& manifest_url, int64 response_id) = 0; + const GURL& manifest_url, int64 group_id, int64 response_id) = 0; // Creates a writer to write a new response to storage. This call // establishes a new response id. virtual AppCacheResponseWriter* CreateResponseWriter( - const GURL& manifest_url) = 0; + const GURL& manifest_url, int64 group_id) = 0; // Schedules the lazy deletion of responses and saves the ids // persistently such that the responses will be deleted upon restart @@ -229,12 +230,13 @@ class APPCACHE_EXPORT AppCacheStorage { // multiple callers. class ResponseInfoLoadTask { public: - ResponseInfoLoadTask(const GURL& manifest_url, int64 response_id, - AppCacheStorage* storage); + ResponseInfoLoadTask(const GURL& manifest_url, int64 group_id, + int64 response_id, AppCacheStorage* storage); ~ResponseInfoLoadTask(); int64 response_id() const { return response_id_; } const GURL& manifest_url() const { return manifest_url_; } + int64 group_id() const { return group_id_; } void AddDelegate(DelegateReference* delegate_reference) { delegates_.push_back(delegate_reference); @@ -247,6 +249,7 @@ class APPCACHE_EXPORT AppCacheStorage { AppCacheStorage* storage_; GURL manifest_url_; + int64 group_id_; int64 response_id_; scoped_ptr<AppCacheResponseReader> reader_; DelegateReferenceVector delegates_; @@ -272,12 +275,12 @@ class APPCACHE_EXPORT AppCacheStorage { } ResponseInfoLoadTask* GetOrCreateResponseInfoLoadTask( - const GURL& manifest_url, int64 response_id) { + const GURL& manifest_url, int64 group_id, int64 response_id) { PendingResponseInfoLoads::iterator iter = pending_info_loads_.find(response_id); if (iter != pending_info_loads_.end()) return iter->second; - return new ResponseInfoLoadTask(manifest_url, response_id, this); + return new ResponseInfoLoadTask(manifest_url, group_id, response_id, this); } // Should only be called when creating a new response writer. diff --git a/webkit/appcache/appcache_storage_impl.cc b/webkit/appcache/appcache_storage_impl.cc index ca112df..69911b7 100644 --- a/webkit/appcache/appcache_storage_impl.cc +++ b/webkit/appcache/appcache_storage_impl.cc @@ -330,6 +330,7 @@ void AppCacheStorageImpl::GetAllInfoTask::Run() { info.last_access_time = group->last_access_time; info.last_update_time = cache_record.update_time; info.cache_id = cache_record.cache_id; + info.group_id = group->group_id; info.is_complete = true; infos.push_back(info); } @@ -627,6 +628,7 @@ void AppCacheStorageImpl::StoreGroupAndCacheTask::Run() { database_->DeleteFallbackNameSpacesForCache(cache.cache_id) && database_->DeleteOnlineWhiteListForCache(cache.cache_id) && database_->InsertDeletableResponseIds(newly_deletable_response_ids_); + // TODO(michaeln): store group_id too with deletable ids } else { NOTREACHED() << "A existing group without a cache is unexpected"; } @@ -713,7 +715,7 @@ class AppCacheStorageImpl::FindMainResponseTask : public DatabaseTask { const AppCacheWorkingSet::GroupMap* groups_in_use) : DatabaseTask(storage), url_(url), preferred_manifest_url_(preferred_manifest_url), - cache_id_(kNoCacheId) { + cache_id_(kNoCacheId), group_id_(0) { if (groups_in_use) { for (AppCacheWorkingSet::GroupMap::const_iterator it = groups_in_use->begin(); @@ -744,6 +746,7 @@ class AppCacheStorageImpl::FindMainResponseTask : public DatabaseTask { AppCacheEntry fallback_entry_; GURL fallback_url_; int64 cache_id_; + int64 group_id_; GURL manifest_url_; }; @@ -819,19 +822,6 @@ class NetworkNamespaceHelper { AppCacheDatabase* database_; }; -bool FindManifestForEntry( - const AppCacheDatabase::EntryRecord& entry_record, - AppCacheDatabase* database, - GURL* manifest_url_out) { - AppCacheDatabase::GroupRecord group_record; - if (!database->FindGroupForCache(entry_record.cache_id, &group_record)) { - NOTREACHED() << "A cache without a group is not expected."; - return false; - } - *manifest_url_out = group_record.manifest_url; - return true; -} - } // namespace void AppCacheStorageImpl::FindMainResponseTask::Run() { @@ -862,12 +852,14 @@ void AppCacheStorageImpl::FindMainResponseTask::Run() { if (FindExactMatch(preferred_cache_id) || FindFallback(preferred_cache_id)) { // We found something. - DCHECK(cache_id_ != kNoCacheId && !manifest_url_.is_empty()); + DCHECK(cache_id_ != kNoCacheId && !manifest_url_.is_empty() && + group_id_ != 0); return; } // We didn't find anything. - DCHECK(cache_id_ == kNoCacheId && manifest_url_.is_empty()); + DCHECK(cache_id_ == kNoCacheId && manifest_url_.is_empty() && + group_id_ == 0); } bool AppCacheStorageImpl:: @@ -882,10 +874,13 @@ FindMainResponseTask::FindExactMatch(int64 preferred_cache_id) { // Take the first with a valid, non-foreign entry. std::vector<AppCacheDatabase::EntryRecord>::iterator iter; for (iter = entries.begin(); iter < entries.end(); ++iter) { + AppCacheDatabase::GroupRecord group_record; if ((iter->flags & AppCacheEntry::FOREIGN) || - !FindManifestForEntry(*iter, database_, &manifest_url_)) { + !database_->FindGroupForCache(iter->cache_id, &group_record)) { continue; } + manifest_url_ = group_record.manifest_url; + group_id_ = group_record.group_id; entry_ = AppCacheEntry(iter->flags, iter->response_id); cache_id_ = iter->cache_id; return true; // We found an exact match. @@ -950,10 +945,13 @@ FindMainResponseTask::FindFirstValidFallback( AppCacheDatabase::EntryRecord entry_record; if (database_->FindEntry((*iter)->cache_id, (*iter)->fallback_entry_url, &entry_record)) { + AppCacheDatabase::GroupRecord group_record; if ((entry_record.flags & AppCacheEntry::FOREIGN) || - !FindManifestForEntry(entry_record, database_, &manifest_url_)) { + !database_->FindGroupForCache(entry_record.cache_id, &group_record)) { continue; } + manifest_url_ = group_record.manifest_url; + group_id_ = group_record.group_id; cache_id_ = (*iter)->cache_id; fallback_url_ = (*iter)->fallback_entry_url; fallback_entry_ = AppCacheEntry( @@ -967,7 +965,7 @@ FindMainResponseTask::FindFirstValidFallback( void AppCacheStorageImpl::FindMainResponseTask::RunCompleted() { storage_->CallOnMainResponseFound( &delegates_, url_, entry_, fallback_url_, fallback_entry_, - cache_id_, manifest_url_); + cache_id_, group_id_, manifest_url_); } // MarkEntryAsForeignTask ------- @@ -1088,6 +1086,7 @@ class AppCacheStorageImpl::GetDeletableResponseIdsTask : public DatabaseTask { void AppCacheStorageImpl::GetDeletableResponseIdsTask::Run() { const int kSqlLimit = 1000; database_->GetDeletableResponseIds(&response_ids_, max_rowid_, kSqlLimit); + // TODO(michaeln): retrieve group_ids too } void AppCacheStorageImpl::GetDeletableResponseIdsTask::RunCompleted() { @@ -1108,6 +1107,7 @@ class AppCacheStorageImpl::InsertDeletableResponseIdsTask void AppCacheStorageImpl::InsertDeletableResponseIdsTask::Run() { database_->InsertDeletableResponseIds(response_ids_); + // TODO(michaeln): store group_ids too } // DeleteDeletableResponseIdsTask ------- @@ -1393,6 +1393,7 @@ void AppCacheStorageImpl::DeliverShortCircuitedFindMainResponse( &delegates, url, found_entry, GURL(), AppCacheEntry(), cache.get() ? cache->cache_id() : kNoCacheId, + group.get() ? group->group_id() : kNoCacheId, group.get() ? group->manifest_url() : GURL()); } } @@ -1401,12 +1402,12 @@ void AppCacheStorageImpl::CallOnMainResponseFound( DelegateReferenceVector* delegates, const GURL& url, const AppCacheEntry& entry, const GURL& fallback_url, const AppCacheEntry& fallback_entry, - int64 cache_id, const GURL& manifest_url) { + int64 cache_id, int64 group_id, const GURL& manifest_url) { FOR_EACH_DELEGATE( (*delegates), OnMainResponseFound(url, entry, fallback_url, fallback_entry, - cache_id, manifest_url)); + cache_id, group_id, manifest_url)); } void AppCacheStorageImpl::FindResponseForSubRequest( @@ -1456,13 +1457,13 @@ void AppCacheStorageImpl::MakeGroupObsolete( } AppCacheResponseReader* AppCacheStorageImpl::CreateResponseReader( - const GURL& manifest_url, int64 response_id) { - return new AppCacheResponseReader(response_id, disk_cache()); + const GURL& manifest_url, int64 group_id, int64 response_id) { + return new AppCacheResponseReader(response_id, group_id, disk_cache()); } AppCacheResponseWriter* AppCacheStorageImpl::CreateResponseWriter( - const GURL& manifest_url) { - return new AppCacheResponseWriter(NewResponseId(), disk_cache()); + const GURL& manifest_url, int64 group_id) { + return new AppCacheResponseWriter(NewResponseId(), group_id, disk_cache()); } void AppCacheStorageImpl::DoomResponses( @@ -1539,6 +1540,7 @@ void AppCacheStorageImpl::DeleteOneResponse() { return; } + // TODO(michaeln): add group_id to DoomEntry args int64 id = deletable_response_ids_.front(); int rv = disk_cache_->DoomEntry(id, &doom_callback_); if (rv != net::ERR_IO_PENDING) diff --git a/webkit/appcache/appcache_storage_impl.h b/webkit/appcache/appcache_storage_impl.h index 37a4370..3c12b6d 100644 --- a/webkit/appcache/appcache_storage_impl.h +++ b/webkit/appcache/appcache_storage_impl.h @@ -49,9 +49,9 @@ class AppCacheStorageImpl : public AppCacheStorage { virtual void MarkEntryAsForeign(const GURL& entry_url, int64 cache_id); virtual void MakeGroupObsolete(AppCacheGroup* group, Delegate* delegate); virtual AppCacheResponseReader* CreateResponseReader( - const GURL& manifest_url, int64 response_id); + const GURL& manifest_url, int64 group_id, int64 response_id); virtual AppCacheResponseWriter* CreateResponseWriter( - const GURL& manifest_url); + const GURL& manifest_url, int64 group_id); virtual void DoomResponses( const GURL& manifest_url, const std::vector<int64>& response_ids); virtual void DeleteResponses( @@ -121,7 +121,7 @@ class AppCacheStorageImpl : public AppCacheStorage { DelegateReferenceVector* delegates, const GURL& url, const AppCacheEntry& entry, const GURL& fallback_url, const AppCacheEntry& fallback_entry, - int64 cache_id, const GURL& manifest_url); + int64 cache_id, int64 group_id, const GURL& manifest_url); APPCACHE_EXPORT AppCacheDiskCache* disk_cache(); @@ -160,7 +160,6 @@ class AppCacheStorageImpl : public AppCacheStorage { // disk cache and cannot continue. bool is_disabled_; - // TODO(michaeln): use a disk_cache per group (manifest or group_id). scoped_ptr<AppCacheDiskCache> disk_cache_; // Used to short-circuit certain operations without having to schedule diff --git a/webkit/appcache/appcache_storage_impl_unittest.cc b/webkit/appcache/appcache_storage_impl_unittest.cc index cc3a5ba..18de4a0 100644 --- a/webkit/appcache/appcache_storage_impl_unittest.cc +++ b/webkit/appcache/appcache_storage_impl_unittest.cc @@ -91,12 +91,14 @@ class AppCacheStorageImplTest : public testing::Test { void OnMainResponseFound(const GURL& url, const AppCacheEntry& entry, const GURL& fallback_url, const AppCacheEntry& fallback_entry, - int64 cache_id, const GURL& manifest_url) { + int64 cache_id, int64 group_id, + const GURL& manifest_url) { found_url_ = url; found_entry_ = entry; found_fallback_url_ = fallback_url; found_fallback_entry_ = fallback_entry; found_cache_id_ = cache_id; + found_group_id_ = group_id; found_manifest_url_ = manifest_url; test_->ScheduleNextTask(); } @@ -116,6 +118,7 @@ class AppCacheStorageImplTest : public testing::Test { GURL found_fallback_url_; AppCacheEntry found_fallback_entry_; int64 found_cache_id_; + int64 found_group_id_; GURL found_manifest_url_; AppCacheStorageImplTest* test_; }; @@ -827,7 +830,7 @@ class AppCacheStorageImplTest : public testing::Test { // Setup some preconditions. Create a complete cache with an entry // in storage. - MakeCacheAndGroup(kManifestUrl, 1, 1, true); + MakeCacheAndGroup(kManifestUrl, 2, 1, true); cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, 1)); AppCacheDatabase::EntryRecord entry_record; entry_record.cache_id = 1; @@ -853,6 +856,7 @@ class AppCacheStorageImplTest : public testing::Test { EXPECT_EQ(kEntryUrl, delegate()->found_url_); EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_); EXPECT_EQ(1, delegate()->found_cache_id_); + EXPECT_EQ(2, delegate()->found_group_id_); EXPECT_EQ(1, delegate()->found_entry_.response_id()); EXPECT_TRUE(delegate()->found_entry_.IsExplicit()); EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id()); @@ -875,7 +879,7 @@ class AppCacheStorageImplTest : public testing::Test { // Setup some preconditions. Create a complete cache with a // fallback namespace and entry. - MakeCacheAndGroup(kManifestUrl, 1, 1, true); + MakeCacheAndGroup(kManifestUrl, 2, 1, true); cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::FALLBACK, 1)); cache_->AddEntry(kEntryUrl2, AppCacheEntry(AppCacheEntry::FALLBACK, 2)); cache_->fallback_namespaces_.push_back( @@ -917,6 +921,7 @@ class AppCacheStorageImplTest : public testing::Test { EXPECT_EQ(kFallbackTestUrl, delegate()->found_url_); EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_); EXPECT_EQ(1, delegate()->found_cache_id_); + EXPECT_EQ(2, delegate()->found_group_id_); EXPECT_FALSE(delegate()->found_entry_.has_response_id()); EXPECT_EQ(2, delegate()->found_fallback_entry_.response_id()); EXPECT_EQ(kEntryUrl2, delegate()->found_fallback_url_); @@ -991,6 +996,7 @@ class AppCacheStorageImplTest : public testing::Test { EXPECT_EQ(kEntryUrl, delegate()->found_url_); EXPECT_EQ(kManifestUrl3, delegate()->found_manifest_url_); EXPECT_EQ(3, delegate()->found_cache_id_); + EXPECT_EQ(3, delegate()->found_group_id_); EXPECT_EQ(3, delegate()->found_entry_.response_id()); EXPECT_TRUE(delegate()->found_entry_.IsExplicit()); EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id()); @@ -1007,6 +1013,7 @@ class AppCacheStorageImplTest : public testing::Test { EXPECT_EQ(kEntryUrl, delegate()->found_url_); EXPECT_EQ(kManifestUrl, delegate()->found_manifest_url_); EXPECT_EQ(1, delegate()->found_cache_id_); + EXPECT_EQ(1, delegate()->found_group_id_); EXPECT_EQ(1, delegate()->found_entry_.response_id()); EXPECT_TRUE(delegate()->found_entry_.IsExplicit()); EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id()); @@ -1023,6 +1030,7 @@ class AppCacheStorageImplTest : public testing::Test { EXPECT_EQ(kEntryUrl, delegate()->found_url_); EXPECT_EQ(kManifestUrl2, delegate()->found_manifest_url_); EXPECT_EQ(2, delegate()->found_cache_id_); + EXPECT_EQ(2, delegate()->found_group_id_); EXPECT_EQ(2, delegate()->found_entry_.response_id()); EXPECT_TRUE(delegate()->found_entry_.IsExplicit()); EXPECT_FALSE(delegate()->found_fallback_entry_.has_response_id()); @@ -1040,6 +1048,7 @@ class AppCacheStorageImplTest : public testing::Test { EXPECT_EQ(kFallbackTestUrl, delegate()->found_url_); EXPECT_EQ(kManifestUrl3, delegate()->found_manifest_url_); EXPECT_EQ(3, delegate()->found_cache_id_); + EXPECT_EQ(3, delegate()->found_group_id_); EXPECT_FALSE(delegate()->found_entry_.has_response_id()); EXPECT_EQ(3 + kFallbackEntryIdOffset, delegate()->found_fallback_entry_.response_id()); @@ -1059,6 +1068,7 @@ class AppCacheStorageImplTest : public testing::Test { EXPECT_EQ(kFallbackTestUrl, delegate()->found_url_); EXPECT_EQ(kManifestUrl2, delegate()->found_manifest_url_); EXPECT_EQ(2, delegate()->found_cache_id_); + EXPECT_EQ(2, delegate()->found_group_id_); EXPECT_FALSE(delegate()->found_entry_.has_response_id()); EXPECT_EQ(2 + kFallbackEntryIdOffset, delegate()->found_fallback_entry_.response_id()); @@ -1129,6 +1139,7 @@ class AppCacheStorageImplTest : public testing::Test { EXPECT_EQ(expected_url, delegate()->found_url_); EXPECT_TRUE(delegate()->found_manifest_url_.is_empty()); EXPECT_EQ(kNoCacheId, delegate()->found_cache_id_); + EXPECT_EQ(0, delegate()->found_group_id_); EXPECT_EQ(kNoResponseId, delegate()->found_entry_.response_id()); EXPECT_EQ(kNoResponseId, delegate()->found_fallback_entry_.response_id()); EXPECT_TRUE(delegate()->found_fallback_url_.is_empty()); diff --git a/webkit/appcache/appcache_update_job.cc b/webkit/appcache/appcache_update_job.cc index e6bdf55..dd77329 100644 --- a/webkit/appcache/appcache_update_job.cc +++ b/webkit/appcache/appcache_update_job.cc @@ -382,7 +382,8 @@ void AppCacheUpdateJob::StartUpdate(AppCacheHost* host, AppCacheResponseWriter* AppCacheUpdateJob::CreateResponseWriter() { AppCacheResponseWriter* writer = - service_->storage()->CreateResponseWriter(manifest_url_); + service_->storage()->CreateResponseWriter(manifest_url_, + group_->group_id()); stored_response_ids_.push_back(writer->response_id()); return writer; } @@ -414,7 +415,7 @@ void AppCacheUpdateJob::FetchManifest(bool is_first_fetch) { group_->newest_complete_cache()->GetEntry(manifest_url_) : NULL; if (entry) { // Asynchronously load response info for manifest from newest cache. - service_->storage()->LoadResponseInfo(manifest_url_, + service_->storage()->LoadResponseInfo(manifest_url_, group_->group_id(), entry->response_id(), this); } else { manifest_fetcher_->Start(); @@ -561,6 +562,11 @@ void AppCacheUpdateJob::HandleUrlFetchCompleted(URLFetcher* fetcher) { if (!inprogress_cache_->AddOrModifyEntry(url, entry)) duplicate_response_ids_.push_back(entry.response_id()); + // TODO(michaeln): Check for <html manifest=xxx> + // See http://code.google.com/p/chromium/issues/detail?id=97930 + // if (entry.IsMaster() && !entry.IsExplicit()) + // if (!manifestAttribute) skip it + // Foreign entries will be detected during cache selection. // Note: 6.9.4, step 17.9 possible optimization: if resource is HTML or XML // file whose root element is an html element with a manifest attribute @@ -848,6 +854,7 @@ void AppCacheUpdateJob::CheckIfManifestChanged() { // Load manifest data from storage to compare against fetched manifest. manifest_response_reader_.reset( service_->storage()->CreateResponseReader(manifest_url_, + group_->group_id(), entry->response_id())); read_manifest_buffer_ = new net::IOBuffer(kBufferSize); manifest_response_reader_->ReadData(read_manifest_buffer_, kBufferSize, @@ -1111,7 +1118,8 @@ bool AppCacheUpdateJob::MaybeLoadFromNewestCache(const GURL& url, // Load HTTP headers for entry from newest cache. loading_responses_.insert( LoadingResponses::value_type(copy_me->response_id(), url)); - service_->storage()->LoadResponseInfo(manifest_url_, copy_me->response_id(), + service_->storage()->LoadResponseInfo(manifest_url_, group_->group_id(), + copy_me->response_id(), this); // Async: wait for OnResponseInfoLoaded to complete. return true; diff --git a/webkit/appcache/appcache_update_job_unittest.cc b/webkit/appcache/appcache_update_job_unittest.cc index 9283e0f..7fade2e 100644 --- a/webkit/appcache/appcache_update_job_unittest.cc +++ b/webkit/appcache/appcache_update_job_unittest.cc @@ -925,7 +925,8 @@ class AppCacheUpdateJobTest : public testing::Test, // Create response writer to get a response id. response_writer_.reset( - service_->storage()->CreateResponseWriter(group_->manifest_url())); + service_->storage()->CreateResponseWriter(group_->manifest_url(), + group_->group_id())); AppCache* cache = MakeCacheForGroup(1, response_writer_->response_id()); MockFrontend* frontend1 = MakeMockFrontend(); @@ -1011,7 +1012,8 @@ class AppCacheUpdateJobTest : public testing::Test, // Create a response writer to get a response id. response_writer_.reset( - service_->storage()->CreateResponseWriter(group_->manifest_url())); + service_->storage()->CreateResponseWriter(group_->manifest_url(), + group_->group_id())); AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), response_writer_->response_id()); @@ -1075,7 +1077,8 @@ class AppCacheUpdateJobTest : public testing::Test, // Give the newest cache an entry that is in storage. response_writer_.reset( - service_->storage()->CreateResponseWriter(group_->manifest_url())); + service_->storage()->CreateResponseWriter(group_->manifest_url(), + group_->group_id())); cache->AddEntry(MockHttpServer::GetMockUrl("files/explicit1"), AppCacheEntry(AppCacheEntry::EXPLICIT, response_writer_->response_id())); @@ -1136,7 +1139,8 @@ class AppCacheUpdateJobTest : public testing::Test, // Give the newest cache an entry that is in storage. response_writer_.reset( - service_->storage()->CreateResponseWriter(group_->manifest_url())); + service_->storage()->CreateResponseWriter(group_->manifest_url(), + group_->group_id())); cache->AddEntry(MockHttpServer::GetMockUrl("files/explicit1"), AppCacheEntry(AppCacheEntry::EXPLICIT, response_writer_->response_id())); @@ -1194,7 +1198,8 @@ class AppCacheUpdateJobTest : public testing::Test, // Give the newest cache an entry that is in storage. response_writer_.reset( - service_->storage()->CreateResponseWriter(group_->manifest_url())); + service_->storage()->CreateResponseWriter(group_->manifest_url(), + group_->group_id())); cache->AddEntry(MockHttpServer::GetMockUrl("files/explicit1"), AppCacheEntry(AppCacheEntry::EXPLICIT, response_writer_->response_id())); @@ -2573,7 +2578,8 @@ class AppCacheUpdateJobTest : public testing::Test, // Give the newest cache a manifest enry that is in storage. response_writer_.reset( - service_->storage()->CreateResponseWriter(group_->manifest_url())); + service_->storage()->CreateResponseWriter(group_->manifest_url(), + group_->group_id())); AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), response_writer_->response_id()); @@ -2631,7 +2637,8 @@ class AppCacheUpdateJobTest : public testing::Test, // Give the newest cache a manifest enry that is in storage. response_writer_.reset( - service_->storage()->CreateResponseWriter(group_->manifest_url())); + service_->storage()->CreateResponseWriter(group_->manifest_url(), + group_->group_id())); AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), response_writer_->response_id()); diff --git a/webkit/appcache/appcache_url_request_job.cc b/webkit/appcache/appcache_url_request_job.cc index 441b5b6..d1c9d18 100644 --- a/webkit/appcache/appcache_url_request_job.cc +++ b/webkit/appcache/appcache_url_request_job.cc @@ -26,7 +26,7 @@ AppCacheURLRequestJob::AppCacheURLRequestJob( : net::URLRequestJob(request), storage_(storage), has_been_started_(false), has_been_killed_(false), delivery_type_(AWAITING_DELIVERY_ORDERS), - cache_id_(kNoCacheId), is_fallback_(false), + group_id_(0), cache_id_(kNoCacheId), is_fallback_(false), cache_entry_not_found_(false), ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_( this, &AppCacheURLRequestJob::OnReadComplete)), @@ -40,12 +40,13 @@ AppCacheURLRequestJob::~AppCacheURLRequestJob() { } void AppCacheURLRequestJob::DeliverAppCachedResponse( - const GURL& manifest_url, int64 cache_id, const AppCacheEntry& entry, - bool is_fallback) { + const GURL& manifest_url, int64 group_id, int64 cache_id, + const AppCacheEntry& entry, bool is_fallback) { DCHECK(!has_delivery_orders()); DCHECK(entry.has_response_id()); delivery_type_ = APPCACHED_DELIVERY; manifest_url_ = manifest_url; + group_id_ = group_id; cache_id_ = cache_id; entry_ = entry; is_fallback_ = is_fallback; @@ -105,7 +106,8 @@ void AppCacheURLRequestJob::BeginDelivery() { net::NetLog::TYPE_APPCACHE_DELIVERING_FALLBACK_RESPONSE : net::NetLog::TYPE_APPCACHE_DELIVERING_CACHED_RESPONSE, NULL); - storage_->LoadResponseInfo(manifest_url_, entry_.response_id(), this); + storage_->LoadResponseInfo( + manifest_url_, group_id_, entry_.response_id(), this); break; default: @@ -120,8 +122,8 @@ void AppCacheURLRequestJob::OnResponseInfoLoaded( scoped_refptr<AppCacheURLRequestJob> protect(this); if (response_info) { info_ = response_info; - reader_.reset( - storage_->CreateResponseReader(manifest_url_, entry_.response_id())); + reader_.reset(storage_->CreateResponseReader( + manifest_url_, group_id_, entry_.response_id())); if (is_range_request()) SetupRangeResponse(); diff --git a/webkit/appcache/appcache_url_request_job.h b/webkit/appcache/appcache_url_request_job.h index fed5722..dfd67d9 100644 --- a/webkit/appcache/appcache_url_request_job.h +++ b/webkit/appcache/appcache_url_request_job.h @@ -28,8 +28,9 @@ class APPCACHE_EXPORT AppCacheURLRequestJob : public net::URLRequestJob, // Informs the job of what response it should deliver. Only one of these // methods should be called, and only once per job. A job will sit idle and // wait indefinitely until one of the deliver methods is called. - void DeliverAppCachedResponse(const GURL& manifest_url, int64 cache_id, - const AppCacheEntry& entry, bool is_fallback); + void DeliverAppCachedResponse(const GURL& manifest_url, int64 group_id, + int64 cache_id, const AppCacheEntry& entry, + bool is_fallback); void DeliverNetworkResponse(); void DeliverErrorResponse(); @@ -52,9 +53,10 @@ class APPCACHE_EXPORT AppCacheURLRequestJob : public net::URLRequestJob, // Accessors for the info about the appcached response, if any, // that this job has been instructed to deliver. These are only // valid to call if is_delivering_appcache_response. - const GURL& manifest_url() { return manifest_url_; } - int64 cache_id() { return cache_id_; } - const AppCacheEntry& entry() { return entry_; } + const GURL& manifest_url() const { return manifest_url_; } + int64 group_id() const { return group_id_; } + int64 cache_id() const { return cache_id_; } + const AppCacheEntry& entry() const { return entry_; } // net::URLRequestJob's Kill method is made public so the users of this // class in the appcache namespace can call it. @@ -125,6 +127,7 @@ class APPCACHE_EXPORT AppCacheURLRequestJob : public net::URLRequestJob, bool has_been_killed_; DeliveryType delivery_type_; GURL manifest_url_; + int64 group_id_; int64 cache_id_; AppCacheEntry entry_; bool is_fallback_; diff --git a/webkit/appcache/appcache_url_request_job_unittest.cc b/webkit/appcache/appcache_url_request_job_unittest.cc index 9f406ca..eadac53 100644 --- a/webkit/appcache/appcache_url_request_job_unittest.cc +++ b/webkit/appcache/appcache_url_request_job_unittest.cc @@ -436,13 +436,16 @@ class AppCacheURLRequestJobTest : public testing::Test { job = new AppCacheURLRequestJob(&request, storage); const GURL kManifestUrl("http://blah/"); const int64 kCacheId(1); + const int64 kGroupId(1); const AppCacheEntry kEntry(AppCacheEntry::EXPLICIT, 1); - job->DeliverAppCachedResponse(kManifestUrl, kCacheId, kEntry, false); + job->DeliverAppCachedResponse(kManifestUrl, kCacheId, kGroupId, + kEntry, false); EXPECT_FALSE(job->is_waiting()); EXPECT_TRUE(job->is_delivering_appcache_response()); EXPECT_FALSE(job->has_been_started()); EXPECT_EQ(kManifestUrl, job->manifest_url()); EXPECT_EQ(kCacheId, job->cache_id()); + EXPECT_EQ(kGroupId, job->group_id()); EXPECT_EQ(kEntry.types(), job->entry().types()); EXPECT_EQ(kEntry.response_id(), job->entry().response_id()); @@ -527,7 +530,7 @@ class AppCacheURLRequestJobTest : public testing::Test { PushNextTask(NewRunnableMethod( this, &AppCacheURLRequestJobTest::RequestAppCachedResource, false)); - writer_.reset(service_->storage()->CreateResponseWriter(GURL())); + writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); written_response_id_ = writer_->response_id(); WriteBasicResponse(); // Continues async @@ -545,7 +548,7 @@ class AppCacheURLRequestJobTest : public testing::Test { if (start_after_delivery_orders) { job->DeliverAppCachedResponse( - GURL(), 111, + GURL(), 0, 111, AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_), false); EXPECT_TRUE(job->is_delivering_appcache_response()); @@ -560,7 +563,7 @@ class AppCacheURLRequestJobTest : public testing::Test { if (!start_after_delivery_orders) { job->DeliverAppCachedResponse( - GURL(), 111, + GURL(), 0, 111, AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_), false); EXPECT_TRUE(job->is_delivering_appcache_response()); @@ -595,7 +598,7 @@ class AppCacheURLRequestJobTest : public testing::Test { PushNextTask(NewRunnableMethod( this, &AppCacheURLRequestJobTest::RequestAppCachedResource, true)); - writer_.reset(service_->storage()->CreateResponseWriter(GURL())); + writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); written_response_id_ = writer_->response_id(); WriteLargeResponse(); // Continues async @@ -636,7 +639,7 @@ class AppCacheURLRequestJobTest : public testing::Test { this, &AppCacheURLRequestJobTest::VerifyDeliverPartialResponse)); PushNextTask(NewRunnableMethod( this, &AppCacheURLRequestJobTest::MakeRangeRequest)); - writer_.reset(service_->storage()->CreateResponseWriter(GURL())); + writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); written_response_id_ = writer_->response_id(); WriteBasicResponse(); // Continues async @@ -656,7 +659,7 @@ class AppCacheURLRequestJobTest : public testing::Test { scoped_refptr<AppCacheURLRequestJob> job( new AppCacheURLRequestJob(request_.get(), storage)); job->DeliverAppCachedResponse( - GURL(), 111, + GURL(), 0, 111, AppCacheEntry(AppCacheEntry::EXPLICIT, written_response_id_), false); EXPECT_TRUE(job->is_delivering_appcache_response()); @@ -702,7 +705,7 @@ class AppCacheURLRequestJobTest : public testing::Test { PushNextTask(NewRunnableMethod( this, &AppCacheURLRequestJobTest::RequestAppCachedResource, true)); - writer_.reset(service_->storage()->CreateResponseWriter(GURL())); + writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); written_response_id_ = writer_->response_id(); WriteLargeResponse(); @@ -730,7 +733,7 @@ class AppCacheURLRequestJobTest : public testing::Test { PushNextTask(NewRunnableMethod( this, &AppCacheURLRequestJobTest::RequestAppCachedResource, true)); - writer_.reset(service_->storage()->CreateResponseWriter(GURL())); + writer_.reset(service_->storage()->CreateResponseWriter(GURL(), 0)); written_response_id_ = writer_->response_id(); WriteLargeResponse(); diff --git a/webkit/appcache/mock_appcache_storage.cc b/webkit/appcache/mock_appcache_storage.cc index 20ecf8d..8560074 100644 --- a/webkit/appcache/mock_appcache_storage.cc +++ b/webkit/appcache/mock_appcache_storage.cc @@ -34,6 +34,7 @@ MockAppCacheStorage::MockAppCacheStorage(AppCacheService* service) simulate_find_main_resource_(false), simulate_find_sub_resource_(false), simulated_found_cache_id_(kNoCacheId), + simulated_found_group_id_(0), simulated_found_network_namespace_(false) { last_cache_id_ = 0; last_group_id_ = 0; @@ -146,15 +147,15 @@ void MockAppCacheStorage::MakeGroupObsolete( } AppCacheResponseReader* MockAppCacheStorage::CreateResponseReader( - const GURL& manifest_url, int64 response_id) { + const GURL& manifest_url, int64 group_id, int64 response_id) { if (simulated_reader_.get()) return simulated_reader_.release(); - return new AppCacheResponseReader(response_id, disk_cache()); + return new AppCacheResponseReader(response_id, group_id, disk_cache()); } AppCacheResponseWriter* MockAppCacheStorage::CreateResponseWriter( - const GURL& manifest_url) { - return new AppCacheResponseWriter(NewResponseId(), disk_cache()); + const GURL& manifest_url, int64 group_id) { + return new AppCacheResponseWriter(NewResponseId(), group_id, disk_cache()); } void MockAppCacheStorage::DoomResponses( @@ -232,10 +233,12 @@ struct FoundCandidate { GURL url; AppCacheEntry entry; int64 cache_id; + int64 group_id; GURL manifest_url; bool is_cache_in_use; - FoundCandidate() : cache_id(kNoCacheId), is_cache_in_use(false) {} + FoundCandidate() + : cache_id(kNoCacheId), group_id(0), is_cache_in_use(false) {} }; } // namespace @@ -248,7 +251,8 @@ void MockAppCacheStorage::ProcessFindResponseForMainRequest( delegate_ref->delegate->OnMainResponseFound( url, simulated_found_entry_, simulated_found_fallback_url_, simulated_found_fallback_entry_, - simulated_found_cache_id_, simulated_found_manifest_url_); + simulated_found_cache_id_, simulated_found_group_id_, + simulated_found_manifest_url_); } return; } @@ -305,6 +309,7 @@ void MockAppCacheStorage::ProcessFindResponseForMainRequest( found_candidate.url = url; found_candidate.entry = found_entry; found_candidate.cache_id = cache->cache_id(); + found_candidate.group_id = group->group_id(); found_candidate.manifest_url = group->manifest_url(); found_candidate.is_cache_in_use = is_in_use; if (is_in_use) @@ -337,6 +342,7 @@ void MockAppCacheStorage::ProcessFindResponseForMainRequest( cache->GetFallbackEntryUrl(found_fallback_namespace); found_fallback_candidate.entry = found_fallback_entry; found_fallback_candidate.cache_id = cache->cache_id(); + found_fallback_candidate.group_id = group->group_id(); found_fallback_candidate.manifest_url = group->manifest_url(); found_fallback_candidate.is_cache_in_use = is_in_use; found_fallback_candidate_namespace = found_fallback_namespace; @@ -348,7 +354,8 @@ void MockAppCacheStorage::ProcessFindResponseForMainRequest( if (found_candidate.entry.has_response_id()) { delegate_ref->delegate->OnMainResponseFound( url, found_candidate.entry, GURL(), AppCacheEntry(), - found_candidate.cache_id, found_candidate.manifest_url); + found_candidate.cache_id, found_candidate.group_id, + found_candidate.manifest_url); return; } @@ -359,13 +366,14 @@ void MockAppCacheStorage::ProcessFindResponseForMainRequest( found_fallback_candidate.url, found_fallback_candidate.entry, found_fallback_candidate.cache_id, + found_fallback_candidate.group_id, found_fallback_candidate.manifest_url); return; } // Didn't find anything. delegate_ref->delegate->OnMainResponseFound( - url, AppCacheEntry(), GURL(), AppCacheEntry(), kNoCacheId, GURL()); + url, AppCacheEntry(), GURL(), AppCacheEntry(), kNoCacheId, 0, GURL()); } void MockAppCacheStorage::ProcessMakeGroupObsolete( diff --git a/webkit/appcache/mock_appcache_storage.h b/webkit/appcache/mock_appcache_storage.h index 54c6ea0..c6a49fac 100644 --- a/webkit/appcache/mock_appcache_storage.h +++ b/webkit/appcache/mock_appcache_storage.h @@ -44,8 +44,9 @@ class MockAppCacheStorage : public AppCacheStorage { virtual void MarkEntryAsForeign(const GURL& entry_url, int64 cache_id); virtual void MakeGroupObsolete(AppCacheGroup* group, Delegate* delegate); virtual AppCacheResponseReader* CreateResponseReader( - const GURL& manifest_url, int64 response_id); - virtual AppCacheResponseWriter* CreateResponseWriter(const GURL& origin); + const GURL& manifest_url, int64 group_id, int64 response_id); + virtual AppCacheResponseWriter* CreateResponseWriter( + const GURL& manifest_url, int64 group_id); virtual void DoomResponses( const GURL& manifest_url, const std::vector<int64>& response_ids); virtual void DeleteResponses( @@ -128,13 +129,16 @@ class MockAppCacheStorage : public AppCacheStorage { const AppCacheEntry& entry, const GURL& fallback_url, const AppCacheEntry& fallback_entry, - int64 cache_id, const GURL& manifest_url) { + int64 cache_id, + int64 group_id, + const GURL& manifest_url) { simulate_find_main_resource_ = true; simulate_find_sub_resource_ = false; simulated_found_entry_ = entry; simulated_found_fallback_url_ = fallback_url; simulated_found_fallback_entry_ = fallback_entry; simulated_found_cache_id_ = cache_id; + simulated_found_group_id_ = group_id; simulated_found_manifest_url_ = manifest_url, simulated_found_network_namespace_ = false; // N/A to main resource loads } @@ -148,6 +152,7 @@ class MockAppCacheStorage : public AppCacheStorage { simulated_found_fallback_entry_ = fallback_entry; simulated_found_cache_id_ = kNoCacheId; // N/A to sub resource loads simulated_found_manifest_url_ = GURL(); // N/A to sub resource loads + simulated_found_group_id_ = 0; // N/A to sub resource loads simulated_found_network_namespace_ = network_namespace; } @@ -174,6 +179,7 @@ class MockAppCacheStorage : public AppCacheStorage { AppCacheEntry simulated_found_entry_; AppCacheEntry simulated_found_fallback_entry_; int64 simulated_found_cache_id_; + int64 simulated_found_group_id_; GURL simulated_found_fallback_url_; GURL simulated_found_manifest_url_; bool simulated_found_network_namespace_; diff --git a/webkit/appcache/mock_appcache_storage_unittest.cc b/webkit/appcache/mock_appcache_storage_unittest.cc index ac03356..2731ba8 100644 --- a/webkit/appcache/mock_appcache_storage_unittest.cc +++ b/webkit/appcache/mock_appcache_storage_unittest.cc @@ -46,7 +46,8 @@ class MockAppCacheStorageTest : public testing::Test { void OnMainResponseFound(const GURL& url, const AppCacheEntry& entry, const GURL& fallback_url, const AppCacheEntry& fallback_entry, - int64 cache_id, const GURL& manifest_url) { + int64 cache_id, int64 group_id, + const GURL& manifest_url) { found_url_ = url; found_entry_ = entry; found_fallback_url_ = fallback_url; diff --git a/webkit/appcache/view_appcache_internals_job.cc b/webkit/appcache/view_appcache_internals_job.cc index 8a36ad7..6d1f824 100644 --- a/webkit/appcache/view_appcache_internals_job.cc +++ b/webkit/appcache/view_appcache_internals_job.cc @@ -185,13 +185,16 @@ std::string FormFlagsString(const AppCacheResourceInfo& info) { std::string FormViewEntryAnchor(const GURL& base_url, const GURL& manifest_url, const GURL& entry_url, - int64 response_id) { + int64 response_id, + int64 group_id) { std::string manifest_url_base64; std::string entry_url_base64; std::string response_id_string; + std::string group_id_string; base::Base64Encode(manifest_url.spec(), &manifest_url_base64); base::Base64Encode(entry_url.spec(), &entry_url_base64); response_id_string = base::Int64ToString(response_id); + group_id_string = base::Int64ToString(group_id); std::string query(kViewEntryCommand); query.push_back('='); @@ -200,6 +203,8 @@ std::string FormViewEntryAnchor(const GURL& base_url, query.append(entry_url_base64); query.push_back('|'); query.append(response_id_string); + query.push_back('|'); + query.append(group_id_string); GURL::Replacements replacements; replacements.SetQuery(query.data(), @@ -215,6 +220,7 @@ void EmitAppCacheResourceInfoVector( const GURL& base_url, const GURL& manifest_url, const AppCacheResourceInfoVector& resource_infos, + int64 group_id, std::string* out) { out->append("<table border='0'>\n"); out->append("<tr>"); @@ -228,7 +234,8 @@ void EmitAppCacheResourceInfoVector( out->append("<tr>"); EmitTableData(FormFlagsString(*iter), false, false, out); EmitTableData(FormViewEntryAnchor(base_url, manifest_url, - iter->url, iter->response_id), + iter->url, iter->response_id, + group_id), false, false, out); EmitTableData(UTF16ToUTF8(FormatBytesUnlocalized(iter->size)), true, false, out); @@ -455,7 +462,9 @@ class ViewAppCacheJob : public BaseInternalsJob, EmitAppCacheInfo(base_url, appcache_service_, &appcache_info_, out); EmitAppCacheResourceInfoVector(base_url, manifest_url_, - resource_infos_, out); + resource_infos_, + appcache_info_.group_id, + out); } EmitPageEnd(out); return true; @@ -472,6 +481,7 @@ class ViewAppCacheJob : public BaseInternalsJob, DCHECK_EQ(manifest_url_, manifest_url); if (group && group->newest_complete_cache()) { appcache_info_.manifest_url = manifest_url; + appcache_info_.group_id = group->group_id(); appcache_info_.size = group->newest_complete_cache()->cache_size(); appcache_info_.creation_time = group->creation_time(); appcache_info_.last_update_time = @@ -497,17 +507,17 @@ class ViewEntryJob : public BaseInternalsJob, ViewEntryJob( net::URLRequest* request, AppCacheService* service, const GURL& manifest_url, const GURL& entry_url, - int64 response_id) + int64 response_id, int64 group_id) : BaseInternalsJob(request, service), manifest_url_(manifest_url), entry_url_(entry_url), - response_id_(response_id), amount_read_(0), + response_id_(response_id), group_id_(group_id), amount_read_(0), ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_( this, &ViewEntryJob::OnReadComplete)) {} virtual void Start() { DCHECK(request_); appcache_service_->storage()->LoadResponseInfo( - manifest_url_, response_id_, this); + manifest_url_, group_id_, response_id_, this); } // Produces a page containing the response headers and data. @@ -559,7 +569,7 @@ class ViewEntryJob : public BaseInternalsJob, response_data_ = new net::IOBuffer(amount_to_read); reader_.reset(appcache_service_->storage()->CreateResponseReader( - manifest_url_, response_id_)); + manifest_url_, group_id_, response_id_)); reader_->ReadData( response_data_, amount_to_read, &read_callback_); } @@ -575,6 +585,7 @@ class ViewEntryJob : public BaseInternalsJob, GURL manifest_url_; GURL entry_url_; int64 response_id_; + int64 group_id_; scoped_refptr<AppCacheResponseInfo> response_info_; scoped_refptr<net::IOBuffer> response_data_; int amount_read_; @@ -603,13 +614,14 @@ net::URLRequestJob* ViewAppCacheInternalsJobFactory::CreateJobForRequest( std::vector<std::string> tokens; int64 response_id; - if (command == kViewEntryCommand && - Tokenize(param, "|", &tokens) == 3u && - base::StringToInt64(tokens[2], &response_id)) { + int64 group_id; + if (command == kViewEntryCommand && Tokenize(param, "|", &tokens) == 4u && + base::StringToInt64(tokens[2], &response_id) && + base::StringToInt64(tokens[3], &group_id)) { return new ViewEntryJob(request, service, DecodeBase64URL(tokens[0]), // manifest url DecodeBase64URL(tokens[1]), // entry url - response_id); + response_id, group_id); } return new RedirectToMainPageJob(request, service); |