diff options
author | nhiroki <nhiroki@chromium.org> | 2015-05-08 08:29:01 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-08 15:30:18 +0000 |
commit | 77d218aa592546b8845cf75b4506999826444ee3 (patch) | |
tree | 620751d9c0333f9505d9cfff2e1937b0c982274b | |
parent | 0ec19711ba3ed3223abd0c3e8062bb35002658ae (diff) | |
download | chromium_src-77d218aa592546b8845cf75b4506999826444ee3.zip chromium_src-77d218aa592546b8845cf75b4506999826444ee3.tar.gz chromium_src-77d218aa592546b8845cf75b4506999826444ee3.tar.bz2 |
CacheStorage: Merge CacheStorage::CacheStorageError and CacheStorageCache::ErrorType
Both error codes have similar values and it's not necessary to separate them.
BUG=425505
TEST=content_unittests --gtest_filter=CacheStorage*
TEST=run-webkit-tests http/tests/cachestorage/
Review URL: https://codereview.chromium.org/1132683003
Cr-Commit-Position: refs/heads/master@{#328959}
9 files changed, 155 insertions, 192 deletions
diff --git a/content/browser/cache_storage/cache_storage.cc b/content/browser/cache_storage/cache_storage.cc index bca88cd..c49daa1 100644 --- a/content/browser/cache_storage/cache_storage.cc +++ b/content/browser/cache_storage/cache_storage.cc @@ -560,7 +560,7 @@ void CacheStorage::OpenCacheImpl(const std::string& cache_name, const CacheAndErrorCallback& callback) { scoped_refptr<CacheStorageCache> cache = GetLoadedCache(cache_name); if (cache.get()) { - callback.Run(cache, CACHE_STORAGE_ERROR_NO_ERROR); + callback.Run(cache, CACHE_STORAGE_OK); return; } @@ -577,7 +577,7 @@ void CacheStorage::CreateCacheDidCreateCache( if (!cache.get()) { callback.Run(scoped_refptr<CacheStorageCache>(), - CACHE_STORAGE_ERROR_CLOSING); + CACHE_STORAGE_ERROR_STORAGE); return; } @@ -602,14 +602,14 @@ void CacheStorage::CreateCacheDidWriteIndex( // TODO(jkarlin): Handle !success. - callback.Run(cache, CACHE_STORAGE_ERROR_NO_ERROR); + callback.Run(cache, CACHE_STORAGE_OK); } void CacheStorage::HasCacheImpl(const std::string& cache_name, const BoolAndErrorCallback& callback) { bool has_cache = cache_map_.find(cache_name) != cache_map_.end(); - callback.Run(has_cache, CACHE_STORAGE_ERROR_NO_ERROR); + callback.Run(has_cache, CACHE_STORAGE_OK); } void CacheStorage::DeleteCacheImpl(const std::string& cache_name, @@ -668,12 +668,12 @@ void CacheStorage::DeleteCacheDidCleanUp(const BoolAndErrorCallback& callback, bool success) { DCHECK_CURRENTLY_ON(BrowserThread::IO); - callback.Run(true, CACHE_STORAGE_ERROR_NO_ERROR); + callback.Run(true, CACHE_STORAGE_OK); } void CacheStorage::EnumerateCachesImpl( const StringsAndErrorCallback& callback) { - callback.Run(ordered_cache_names_, CACHE_STORAGE_ERROR_NO_ERROR); + callback.Run(ordered_cache_names_, CACHE_STORAGE_OK); } void CacheStorage::MatchCacheImpl( @@ -683,7 +683,7 @@ void CacheStorage::MatchCacheImpl( scoped_refptr<CacheStorageCache> cache = GetLoadedCache(cache_name); if (!cache.get()) { - callback.Run(CacheStorageCache::ERROR_TYPE_NOT_FOUND, + callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND, scoped_ptr<ServiceWorkerResponse>(), scoped_ptr<storage::BlobDataHandle>()); return; @@ -699,7 +699,7 @@ void CacheStorage::MatchCacheImpl( void CacheStorage::MatchCacheDidMatch( const scoped_refptr<CacheStorageCache>& cache, const CacheStorageCache::ResponseCallback& callback, - CacheStorageCache::ErrorType error, + CacheStorageError error, scoped_ptr<ServiceWorkerResponse> response, scoped_ptr<storage::BlobDataHandle> handle) { callback.Run(error, response.Pass(), handle.Pass()); @@ -733,10 +733,10 @@ void CacheStorage::MatchAllCachesDidMatch( scoped_refptr<CacheStorageCache> cache, const base::Closure& barrier_closure, CacheStorageCache::ResponseCallback* callback, - CacheStorageCache::ErrorType error, + CacheStorageError error, scoped_ptr<ServiceWorkerResponse> response, scoped_ptr<storage::BlobDataHandle> handle) { - if (callback->is_null() || error == CacheStorageCache::ERROR_TYPE_NOT_FOUND) { + if (callback->is_null() || error == CACHE_STORAGE_ERROR_NOT_FOUND) { barrier_closure.Run(); return; } @@ -749,7 +749,7 @@ void CacheStorage::MatchAllCachesDidMatch( void CacheStorage::MatchAllCachesDidMatchAll( scoped_ptr<CacheStorageCache::ResponseCallback> callback) { if (!callback->is_null()) { - callback->Run(CacheStorageCache::ERROR_TYPE_NOT_FOUND, + callback->Run(CACHE_STORAGE_ERROR_NOT_FOUND, scoped_ptr<ServiceWorkerResponse>(), scoped_ptr<storage::BlobDataHandle>()); } @@ -847,7 +847,7 @@ void CacheStorage::PendingStringsAndErrorCallback( void CacheStorage::PendingResponseCallback( const CacheStorageCache::ResponseCallback& callback, - CacheStorageCache::ErrorType error, + CacheStorageError error, scoped_ptr<ServiceWorkerResponse> response, scoped_ptr<storage::BlobDataHandle> blob_data_handle) { base::WeakPtr<CacheStorage> cache_storage = weak_factory_.GetWeakPtr(); diff --git a/content/browser/cache_storage/cache_storage.h b/content/browser/cache_storage/cache_storage.h index 3313b87..261eebd 100644 --- a/content/browser/cache_storage/cache_storage.h +++ b/content/browser/cache_storage/cache_storage.h @@ -35,14 +35,6 @@ class CacheStorageScheduler; // on the IO thread. The asynchronous methods are executed serially. class CONTENT_EXPORT CacheStorage { public: - enum CacheStorageError { - CACHE_STORAGE_ERROR_NO_ERROR, - CACHE_STORAGE_ERROR_NOT_IMPLEMENTED, - CACHE_STORAGE_ERROR_NOT_FOUND, - CACHE_STORAGE_ERROR_EXISTS, - CACHE_STORAGE_ERROR_STORAGE, - CACHE_STORAGE_ERROR_CLOSING - }; typedef std::vector<std::string> StringVector; typedef base::Callback<void(bool, CacheStorageError)> BoolAndErrorCallback; typedef base::Callback<void(const scoped_refptr<CacheStorageCache>&, @@ -91,7 +83,7 @@ class CONTENT_EXPORT CacheStorage { // first response found. Note that if multiple caches have the same // request/response then it is not defined which cache's response will be // returned. If no response is found then |callback| is called with - // CacheStorageCache::ErrorTypeNotFound. + // CACHE_STORAGE_ERROR_NOT_FOUND. void MatchAllCaches(scoped_ptr<ServiceWorkerFetchRequest> request, const CacheStorageCache::ResponseCallback& callback); @@ -163,7 +155,7 @@ class CONTENT_EXPORT CacheStorage { const CacheStorageCache::ResponseCallback& callback); void MatchCacheDidMatch(const scoped_refptr<CacheStorageCache>& cache, const CacheStorageCache::ResponseCallback& callback, - CacheStorageCache::ErrorType error, + CacheStorageError error, scoped_ptr<ServiceWorkerResponse> response, scoped_ptr<storage::BlobDataHandle> handle); @@ -173,7 +165,7 @@ class CONTENT_EXPORT CacheStorage { void MatchAllCachesDidMatch(scoped_refptr<CacheStorageCache> cache, const base::Closure& barrier_closure, CacheStorageCache::ResponseCallback* callback, - CacheStorageCache::ErrorType error, + CacheStorageError error, scoped_ptr<ServiceWorkerResponse> response, scoped_ptr<storage::BlobDataHandle> handle); void MatchAllCachesDidMatchAll( @@ -195,7 +187,7 @@ class CONTENT_EXPORT CacheStorage { CacheStorageError error); void PendingResponseCallback( const CacheStorageCache::ResponseCallback& callback, - CacheStorageCache::ErrorType error, + CacheStorageError error, scoped_ptr<ServiceWorkerResponse> response, scoped_ptr<storage::BlobDataHandle> blob_data_handle); diff --git a/content/browser/cache_storage/cache_storage_cache.cc b/content/browser/cache_storage/cache_storage_cache.cc index 5443552..522897b 100644 --- a/content/browser/cache_storage/cache_storage_cache.cc +++ b/content/browser/cache_storage/cache_storage_cache.cc @@ -408,13 +408,13 @@ void CacheStorageCache::Put(scoped_ptr<ServiceWorkerFetchRequest> request, if (!response->blob_uuid.empty()) { if (!blob_storage_context_) { - callback.Run(ERROR_TYPE_STORAGE); + callback.Run(CACHE_STORAGE_ERROR_STORAGE); return; } blob_data_handle = blob_storage_context_->GetBlobDataFromUUID(response->blob_uuid); if (!blob_data_handle) { - callback.Run(ERROR_TYPE_STORAGE); + callback.Run(CACHE_STORAGE_ERROR_STORAGE); return; } } @@ -442,7 +442,8 @@ void CacheStorageCache::Match(scoped_ptr<ServiceWorkerFetchRequest> request, InitBackend(); break; case BACKEND_CLOSED: - callback.Run(ERROR_TYPE_STORAGE, scoped_ptr<ServiceWorkerResponse>(), + callback.Run(CACHE_STORAGE_ERROR_STORAGE, + scoped_ptr<ServiceWorkerResponse>(), scoped_ptr<storage::BlobDataHandle>()); return; case BACKEND_OPEN: @@ -465,7 +466,7 @@ void CacheStorageCache::Delete(scoped_ptr<ServiceWorkerFetchRequest> request, InitBackend(); break; case BACKEND_CLOSED: - callback.Run(ERROR_TYPE_STORAGE); + callback.Run(CACHE_STORAGE_ERROR_STORAGE); return; case BACKEND_OPEN: DCHECK(backend_); @@ -485,7 +486,7 @@ void CacheStorageCache::Keys(const RequestsCallback& callback) { InitBackend(); break; case BACKEND_CLOSED: - callback.Run(ERROR_TYPE_STORAGE, scoped_ptr<Requests>()); + callback.Run(CACHE_STORAGE_ERROR_STORAGE, scoped_ptr<Requests>()); return; case BACKEND_OPEN: DCHECK(backend_); @@ -563,7 +564,8 @@ void CacheStorageCache::MatchImpl(scoped_ptr<ServiceWorkerFetchRequest> request, const ResponseCallback& callback) { DCHECK(backend_state_ != BACKEND_UNINITIALIZED); if (backend_state_ != BACKEND_OPEN) { - callback.Run(ERROR_TYPE_STORAGE, scoped_ptr<ServiceWorkerResponse>(), + callback.Run(CACHE_STORAGE_ERROR_STORAGE, + scoped_ptr<ServiceWorkerResponse>(), scoped_ptr<storage::BlobDataHandle>()); return; } @@ -588,10 +590,9 @@ void CacheStorageCache::MatchDidOpenEntry( scoped_ptr<MatchContext> match_context, int rv) { if (rv != net::OK) { - match_context->original_callback.Run( - CacheStorageCache::ERROR_TYPE_NOT_FOUND, - scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + match_context->original_callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND, + scoped_ptr<ServiceWorkerResponse>(), + scoped_ptr<storage::BlobDataHandle>()); return; } @@ -610,7 +611,7 @@ void CacheStorageCache::MatchDidReadMetadata( scoped_ptr<MatchContext> match_context, scoped_ptr<CacheMetadata> metadata) { if (!metadata) { - match_context->original_callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE, + match_context->original_callback.Run(CACHE_STORAGE_ERROR_STORAGE, scoped_ptr<ServiceWorkerResponse>(), scoped_ptr<storage::BlobDataHandle>()); return; @@ -644,15 +645,14 @@ void CacheStorageCache::MatchDidReadMetadata( if (!VaryMatches(match_context->request->headers, cached_request_headers, response->headers)) { - match_context->original_callback.Run( - CacheStorageCache::ERROR_TYPE_NOT_FOUND, - scoped_ptr<ServiceWorkerResponse>(), - scoped_ptr<storage::BlobDataHandle>()); + match_context->original_callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND, + scoped_ptr<ServiceWorkerResponse>(), + scoped_ptr<storage::BlobDataHandle>()); return; } if (match_context->entry->GetDataSize(INDEX_RESPONSE_BODY) == 0) { - match_context->original_callback.Run(CacheStorageCache::ERROR_TYPE_OK, + match_context->original_callback.Run(CACHE_STORAGE_OK, match_context->response.Pass(), scoped_ptr<storage::BlobDataHandle>()); return; @@ -660,7 +660,7 @@ void CacheStorageCache::MatchDidReadMetadata( // Stream the response body into a blob. if (!match_context->blob_storage_context) { - match_context->original_callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE, + match_context->original_callback.Run(CACHE_STORAGE_ERROR_STORAGE, scoped_ptr<ServiceWorkerResponse>(), scoped_ptr<storage::BlobDataHandle>()); return; @@ -692,7 +692,7 @@ void CacheStorageCache::MatchDidReadResponseBodyData( scoped_ptr<MatchContext> match_context, int rv) { if (rv < 0) { - match_context->original_callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE, + match_context->original_callback.Run(CACHE_STORAGE_ERROR_STORAGE, scoped_ptr<ServiceWorkerResponse>(), scoped_ptr<storage::BlobDataHandle>()); return; @@ -731,7 +731,7 @@ void CacheStorageCache::MatchDidReadResponseBodyData( void CacheStorageCache::MatchDoneWithBody( scoped_ptr<MatchContext> match_context) { if (!match_context->blob_storage_context) { - match_context->original_callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE, + match_context->original_callback.Run(CACHE_STORAGE_ERROR_STORAGE, scoped_ptr<ServiceWorkerResponse>(), scoped_ptr<storage::BlobDataHandle>()); return; @@ -741,7 +741,7 @@ void CacheStorageCache::MatchDoneWithBody( match_context->blob_storage_context->AddFinishedBlob( match_context->blob_data.get())); - match_context->original_callback.Run(CacheStorageCache::ERROR_TYPE_OK, + match_context->original_callback.Run(CACHE_STORAGE_OK, match_context->response.Pass(), blob_data_handle.Pass()); } @@ -749,7 +749,7 @@ void CacheStorageCache::MatchDoneWithBody( void CacheStorageCache::PutImpl(scoped_ptr<PutContext> put_context) { DCHECK(backend_state_ != BACKEND_UNINITIALIZED); if (backend_state_ != BACKEND_OPEN) { - put_context->callback.Run(ERROR_TYPE_STORAGE); + put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE); return; } @@ -762,9 +762,9 @@ void CacheStorageCache::PutImpl(scoped_ptr<PutContext> put_context) { } void CacheStorageCache::PutDidDelete(scoped_ptr<PutContext> put_context, - ErrorType delete_error) { + CacheStorageError delete_error) { if (backend_state_ != BACKEND_OPEN) { - put_context->callback.Run(ERROR_TYPE_STORAGE); + put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE); return; } @@ -786,7 +786,7 @@ void CacheStorageCache::PutDidDelete(scoped_ptr<PutContext> put_context, void CacheStorageCache::PutDidCreateEntry(scoped_ptr<PutContext> put_context, int rv) { if (rv != net::OK) { - put_context->callback.Run(CacheStorageCache::ERROR_TYPE_EXISTS); + put_context->callback.Run(CACHE_STORAGE_ERROR_EXISTS); return; } @@ -823,7 +823,7 @@ void CacheStorageCache::PutDidCreateEntry(scoped_ptr<PutContext> put_context, scoped_ptr<std::string> serialized(new std::string()); if (!metadata.SerializeToString(serialized.get())) { - put_context->callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE); + put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE); return; } @@ -850,7 +850,7 @@ void CacheStorageCache::PutDidWriteHeaders(scoped_ptr<PutContext> put_context, int rv) { if (rv != expected_bytes) { put_context->cache_entry->Doom(); - put_context->callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE); + put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE); return; } @@ -865,7 +865,7 @@ void CacheStorageCache::PutDidWriteHeaders(scoped_ptr<PutContext> put_context, put_context->cache_entry->GetDataSize(INDEX_HEADERS)); } - put_context->callback.Run(CacheStorageCache::ERROR_TYPE_OK); + put_context->callback.Run(CACHE_STORAGE_OK); return; } @@ -899,7 +899,7 @@ void CacheStorageCache::PutDidWriteBlobToCache( if (!success) { put_context->cache_entry->Doom(); - put_context->callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE); + put_context->callback.Run(CACHE_STORAGE_ERROR_STORAGE); return; } @@ -911,7 +911,7 @@ void CacheStorageCache::PutDidWriteBlobToCache( put_context->cache_entry->GetDataSize(INDEX_RESPONSE_BODY)); } - put_context->callback.Run(CacheStorageCache::ERROR_TYPE_OK); + put_context->callback.Run(CACHE_STORAGE_OK); } void CacheStorageCache::DeleteImpl( @@ -919,7 +919,7 @@ void CacheStorageCache::DeleteImpl( const ErrorCallback& callback) { DCHECK(backend_state_ != BACKEND_UNINITIALIZED); if (backend_state_ != BACKEND_OPEN) { - callback.Run(ERROR_TYPE_STORAGE); + callback.Run(CACHE_STORAGE_ERROR_STORAGE); return; } scoped_ptr<disk_cache::Entry*> entry(new disk_cache::Entry*); @@ -947,7 +947,7 @@ void CacheStorageCache::DeleteDidOpenEntry( const scoped_refptr<storage::QuotaManagerProxy>& quota_manager_proxy, int rv) { if (rv != net::OK) { - callback.Run(CacheStorageCache::ERROR_TYPE_NOT_FOUND); + callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND); return; } @@ -963,13 +963,13 @@ void CacheStorageCache::DeleteDidOpenEntry( } entry->Doom(); - callback.Run(CacheStorageCache::ERROR_TYPE_OK); + callback.Run(CACHE_STORAGE_OK); } void CacheStorageCache::KeysImpl(const RequestsCallback& callback) { DCHECK(backend_state_ != BACKEND_UNINITIALIZED); if (backend_state_ != BACKEND_OPEN) { - callback.Run(ERROR_TYPE_STORAGE, scoped_ptr<Requests>()); + callback.Run(CACHE_STORAGE_ERROR_STORAGE, scoped_ptr<Requests>()); return; } @@ -1011,13 +1011,13 @@ void CacheStorageCache::KeysDidOpenNextEntry( } if (rv < 0) { - keys_context->original_callback.Run(ERROR_TYPE_STORAGE, + keys_context->original_callback.Run(CACHE_STORAGE_ERROR_STORAGE, scoped_ptr<Requests>()); return; } if (backend_state_ != BACKEND_OPEN) { - keys_context->original_callback.Run(ERROR_TYPE_NOT_FOUND, + keys_context->original_callback.Run(CACHE_STORAGE_ERROR_NOT_FOUND, scoped_ptr<Requests>()); return; } @@ -1044,7 +1044,7 @@ void CacheStorageCache::KeysProcessNextEntry( const Entries::iterator& iter) { if (iter == keys_context->entries.end()) { // All done. Return all of the keys. - keys_context->original_callback.Run(ERROR_TYPE_OK, + keys_context->original_callback.Run(CACHE_STORAGE_OK, keys_context->out_keys.Pass()); return; } @@ -1121,12 +1121,12 @@ void CacheStorageCache::CreateBackendDidCreate( scoped_ptr<ScopedBackendPtr> backend_ptr, int rv) { if (rv != net::OK) { - callback.Run(CacheStorageCache::ERROR_TYPE_STORAGE); + callback.Run(CACHE_STORAGE_ERROR_STORAGE); return; } backend_ = backend_ptr->Pass(); - callback.Run(CacheStorageCache::ERROR_TYPE_OK); + callback.Run(CACHE_STORAGE_OK); } void CacheStorageCache::InitBackend() { @@ -1144,15 +1144,15 @@ void CacheStorageCache::InitBackend() { weak_ptr_factory_.GetWeakPtr()))); } -void CacheStorageCache::InitDone(ErrorType error) { +void CacheStorageCache::InitDone(CacheStorageError error) { initializing_ = false; - backend_state_ = (error == ERROR_TYPE_OK && backend_ && + backend_state_ = (error == CACHE_STORAGE_OK && backend_ && backend_state_ == BACKEND_UNINITIALIZED) ? BACKEND_OPEN : BACKEND_CLOSED; UMA_HISTOGRAM_ENUMERATION("ServiceWorkerCache.InitBackendResult", error, - ErrorType::ERROR_TYPE_LAST + 1); + CACHE_STORAGE_ERROR_LAST + 1); scheduler_->CompleteOperationAndRunNext(); } @@ -1166,7 +1166,7 @@ void CacheStorageCache::PendingClosure(const base::Closure& callback) { } void CacheStorageCache::PendingErrorCallback(const ErrorCallback& callback, - ErrorType error) { + CacheStorageError error) { base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr(); callback.Run(error); @@ -1176,7 +1176,7 @@ void CacheStorageCache::PendingErrorCallback(const ErrorCallback& callback, void CacheStorageCache::PendingResponseCallback( const ResponseCallback& callback, - ErrorType error, + CacheStorageError error, scoped_ptr<ServiceWorkerResponse> response, scoped_ptr<storage::BlobDataHandle> blob_data_handle) { base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr(); @@ -1188,7 +1188,7 @@ void CacheStorageCache::PendingResponseCallback( void CacheStorageCache::PendingRequestsCallback( const RequestsCallback& callback, - ErrorType error, + CacheStorageError error, scoped_ptr<Requests> requests) { base::WeakPtr<CacheStorageCache> cache = weak_ptr_factory_.GetWeakPtr(); diff --git a/content/browser/cache_storage/cache_storage_cache.h b/content/browser/cache_storage/cache_storage_cache.h index c558e2e..447196d 100644 --- a/content/browser/cache_storage/cache_storage_cache.h +++ b/content/browser/cache_storage/cache_storage_cache.h @@ -39,24 +39,14 @@ class TestCacheStorageCache; class CONTENT_EXPORT CacheStorageCache : public base::RefCounted<CacheStorageCache> { public: - // This enum is used in histograms, so do not change the ordering and always - // append new types to the end. - enum ErrorType { - ERROR_TYPE_OK = 0, - ERROR_TYPE_EXISTS, - ERROR_TYPE_STORAGE, - ERROR_TYPE_NOT_FOUND, - ERROR_TYPE_LAST = ERROR_TYPE_NOT_FOUND - }; - - typedef base::Callback<void(ErrorType)> ErrorCallback; - typedef base::Callback<void(ErrorType, - scoped_ptr<ServiceWorkerResponse>, - scoped_ptr<storage::BlobDataHandle>)> - ResponseCallback; - typedef std::vector<ServiceWorkerFetchRequest> Requests; - typedef base::Callback<void(ErrorType, scoped_ptr<Requests>)> - RequestsCallback; + using ErrorCallback = base::Callback<void(CacheStorageError)>; + using ResponseCallback = + base::Callback<void(CacheStorageError, + scoped_ptr<ServiceWorkerResponse>, + scoped_ptr<storage::BlobDataHandle>)>; + using Requests = std::vector<ServiceWorkerFetchRequest>; + using RequestsCallback = + base::Callback<void(CacheStorageError, scoped_ptr<Requests>)>; static scoped_refptr<CacheStorageCache> CreateMemoryCache( const GURL& origin, @@ -87,7 +77,7 @@ class CONTENT_EXPORT CacheStorageCache const ErrorCallback& callback); // TODO(jkarlin): Have keys take an optional ServiceWorkerFetchRequest. - // Returns ErrorTypeOK and a vector of requests if there are no errors. + // Returns CACHE_STORAGE_OK and a vector of requests if there are no errors. void Keys(const RequestsCallback& callback); // Closes the backend. Future operations that require the backend @@ -117,8 +107,8 @@ class CONTENT_EXPORT CacheStorageCache BACKEND_CLOSED // Backend cannot be used. All ops should fail. }; - typedef std::vector<disk_cache::Entry*> Entries; - typedef scoped_ptr<disk_cache::Backend> ScopedBackendPtr; + using Entries = std::vector<disk_cache::Entry*>; + using ScopedBackendPtr = scoped_ptr<disk_cache::Backend>; CacheStorageCache( const GURL& origin, @@ -142,7 +132,8 @@ class CONTENT_EXPORT CacheStorageCache // Put callbacks. void PutImpl(scoped_ptr<PutContext> put_context); - void PutDidDelete(scoped_ptr<PutContext> put_context, ErrorType delete_error); + void PutDidDelete(scoped_ptr<PutContext> put_context, + CacheStorageError delete_error); void PutDidCreateEntry(scoped_ptr<PutContext> put_context, int rv); void PutDidWriteHeaders(scoped_ptr<PutContext> put_context, int expected_bytes, @@ -182,17 +173,18 @@ class CONTENT_EXPORT CacheStorageCache int rv); void InitBackend(); - void InitDone(ErrorType error); + void InitDone(CacheStorageError error); void PendingClosure(const base::Closure& callback); - void PendingErrorCallback(const ErrorCallback& callback, ErrorType error); + void PendingErrorCallback(const ErrorCallback& callback, + CacheStorageError error); void PendingResponseCallback( const ResponseCallback& callback, - ErrorType error, + CacheStorageError error, scoped_ptr<ServiceWorkerResponse> response, scoped_ptr<storage::BlobDataHandle> blob_data_handle); void PendingRequestsCallback(const RequestsCallback& callback, - ErrorType error, + CacheStorageError error, scoped_ptr<Requests> requests); // Be sure to check |backend_state_| before use. diff --git a/content/browser/cache_storage/cache_storage_cache_unittest.cc b/content/browser/cache_storage/cache_storage_cache_unittest.cc index 3da11ec..c1d8224 100644 --- a/content/browser/cache_storage/cache_storage_cache_unittest.cc +++ b/content/browser/cache_storage/cache_storage_cache_unittest.cc @@ -175,7 +175,7 @@ class CacheStorageCacheTest : public testing::Test { public: CacheStorageCacheTest() : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP), - callback_error_(CacheStorageCache::ERROR_TYPE_OK), + callback_error_(CACHE_STORAGE_OK), callback_closed_(false) {} void SetUp() override { @@ -274,7 +274,7 @@ class CacheStorageCacheTest : public testing::Test { // thread. loop->Run(); - return callback_error_ == CacheStorageCache::ERROR_TYPE_OK; + return callback_error_ == CACHE_STORAGE_OK; } bool Match(const ServiceWorkerFetchRequest& request) { @@ -286,7 +286,7 @@ class CacheStorageCacheTest : public testing::Test { base::Unretained(this), base::Unretained(loop.get()))); loop->Run(); - return callback_error_ == CacheStorageCache::ERROR_TYPE_OK; + return callback_error_ == CACHE_STORAGE_OK; } bool Delete(const ServiceWorkerFetchRequest& request) { @@ -298,7 +298,7 @@ class CacheStorageCacheTest : public testing::Test { base::Unretained(this), base::Unretained(loop.get()))); loop->Run(); - return callback_error_ == CacheStorageCache::ERROR_TYPE_OK; + return callback_error_ == CACHE_STORAGE_OK; } bool Keys() { @@ -309,7 +309,7 @@ class CacheStorageCacheTest : public testing::Test { base::Unretained(loop.get()))); loop->Run(); - return callback_error_ == CacheStorageCache::ERROR_TYPE_OK; + return callback_error_ == CACHE_STORAGE_OK; } bool Close() { @@ -323,7 +323,7 @@ class CacheStorageCacheTest : public testing::Test { } void RequestsCallback(base::RunLoop* run_loop, - CacheStorageCache::ErrorType error, + CacheStorageError error, scoped_ptr<CacheStorageCache::Requests> requests) { callback_error_ = error; callback_strings_.clear(); @@ -335,8 +335,7 @@ class CacheStorageCacheTest : public testing::Test { run_loop->Quit(); } - void ErrorTypeCallback(base::RunLoop* run_loop, - CacheStorageCache::ErrorType error) { + void ErrorTypeCallback(base::RunLoop* run_loop, CacheStorageError error) { callback_error_ = error; if (run_loop) run_loop->Quit(); @@ -345,7 +344,7 @@ class CacheStorageCacheTest : public testing::Test { void SequenceCallback(int sequence, int* sequence_out, base::RunLoop* run_loop, - CacheStorageCache::ErrorType error) { + CacheStorageError error) { *sequence_out = sequence; callback_error_ = error; if (run_loop) @@ -354,16 +353,14 @@ class CacheStorageCacheTest : public testing::Test { void ResponseAndErrorCallback( base::RunLoop* run_loop, - CacheStorageCache::ErrorType error, + CacheStorageError error, scoped_ptr<ServiceWorkerResponse> response, scoped_ptr<storage::BlobDataHandle> body_handle) { callback_error_ = error; callback_response_ = response.Pass(); callback_response_data_.reset(); - if (error == CacheStorageCache::ERROR_TYPE_OK && - !callback_response_->blob_uuid.empty()) { + if (error == CACHE_STORAGE_OK && !callback_response_->blob_uuid.empty()) callback_response_data_ = body_handle.Pass(); - } if (run_loop) run_loop->Quit(); @@ -433,7 +430,7 @@ class CacheStorageCacheTest : public testing::Test { scoped_ptr<storage::BlobDataHandle> blob_handle_; std::string expected_blob_data_; - CacheStorageCache::ErrorType callback_error_; + CacheStorageError callback_error_; scoped_ptr<ServiceWorkerResponse> callback_response_; scoped_ptr<storage::BlobDataHandle> callback_response_data_; std::vector<std::string> callback_strings_; @@ -488,7 +485,7 @@ TEST_F(CacheStorageCacheTest, PutBodyDropBlobRef) { blob_handle_.reset(); loop->Run(); - EXPECT_EQ(CacheStorageCache::ERROR_TYPE_OK, callback_error_); + EXPECT_EQ(CACHE_STORAGE_OK, callback_error_); } TEST_P(CacheStorageCacheTestP, PutReplace) { diff --git a/content/browser/cache_storage/cache_storage_dispatcher_host.cc b/content/browser/cache_storage/cache_storage_dispatcher_host.cc index 4d245f7..025a130 100644 --- a/content/browser/cache_storage/cache_storage_dispatcher_host.cc +++ b/content/browser/cache_storage/cache_storage_dispatcher_host.cc @@ -24,45 +24,18 @@ namespace { const uint32 kFilteredMessageClasses[] = {CacheStorageMsgStart}; blink::WebServiceWorkerCacheError ToWebServiceWorkerCacheError( - CacheStorage::CacheStorageError err) { + CacheStorageError err) { switch (err) { - case CacheStorage::CACHE_STORAGE_ERROR_NO_ERROR: + case CACHE_STORAGE_OK: NOTREACHED(); return blink::WebServiceWorkerCacheErrorNotImplemented; - case CacheStorage::CACHE_STORAGE_ERROR_NOT_IMPLEMENTED: - return blink::WebServiceWorkerCacheErrorNotImplemented; - case CacheStorage::CACHE_STORAGE_ERROR_NOT_FOUND: - return blink::WebServiceWorkerCacheErrorNotFound; - case CacheStorage::CACHE_STORAGE_ERROR_EXISTS: + case CACHE_STORAGE_ERROR_EXISTS: return blink::WebServiceWorkerCacheErrorExists; - case CacheStorage::CACHE_STORAGE_ERROR_STORAGE: - // TODO(jkarlin): Change this to CACHE_STORAGE_ERROR_STORAGE once that's - // added. + case CACHE_STORAGE_ERROR_STORAGE: + // TODO(nhiroki): Add WebServiceWorkerCacheError equivalent to + // CACHE_STORAGE_ERROR_STORAGE. return blink::WebServiceWorkerCacheErrorNotFound; - case CacheStorage::CACHE_STORAGE_ERROR_CLOSING: - // TODO(jkarlin): Update this to CACHE_STORAGE_ERROR_CLOSING once that's - // added. - return blink::WebServiceWorkerCacheErrorNotFound; - } - NOTREACHED(); - return blink::WebServiceWorkerCacheErrorNotImplemented; -} - -// TODO(jkarlin): CacheStorageCache and CacheStorage should share -// an error enum type. -blink::WebServiceWorkerCacheError CacheErrorToWebServiceWorkerCacheError( - CacheStorageCache::ErrorType err) { - switch (err) { - case CacheStorageCache::ERROR_TYPE_OK: - NOTREACHED(); - return blink::WebServiceWorkerCacheErrorNotImplemented; - case CacheStorageCache::ERROR_TYPE_EXISTS: - return blink::WebServiceWorkerCacheErrorExists; - case CacheStorageCache::ERROR_TYPE_STORAGE: - // TODO(jkarlin): Change this to CACHE_STORAGE_ERROR_STORAGE once that's - // added. - return blink::WebServiceWorkerCacheErrorNotFound; - case CacheStorageCache::ERROR_TYPE_NOT_FOUND: + case CACHE_STORAGE_ERROR_NOT_FOUND: return blink::WebServiceWorkerCacheErrorNotFound; } NOTREACHED(); @@ -319,8 +292,8 @@ void CacheStorageDispatcherHost::OnCacheStorageHasCallback( int thread_id, int request_id, bool has_cache, - CacheStorage::CacheStorageError error) { - if (error != CacheStorage::CACHE_STORAGE_ERROR_NO_ERROR) { + CacheStorageError error) { + if (error != CACHE_STORAGE_OK) { Send(new CacheStorageMsg_CacheStorageHasError( thread_id, request_id, ToWebServiceWorkerCacheError(error))); return; @@ -337,8 +310,8 @@ void CacheStorageDispatcherHost::OnCacheStorageOpenCallback( int thread_id, int request_id, const scoped_refptr<CacheStorageCache>& cache, - CacheStorage::CacheStorageError error) { - if (error != CacheStorage::CACHE_STORAGE_ERROR_NO_ERROR) { + CacheStorageError error) { + if (error != CACHE_STORAGE_OK) { Send(new CacheStorageMsg_CacheStorageOpenError( thread_id, request_id, ToWebServiceWorkerCacheError(error))); return; @@ -352,8 +325,8 @@ void CacheStorageDispatcherHost::OnCacheStorageDeleteCallback( int thread_id, int request_id, bool deleted, - CacheStorage::CacheStorageError error) { - if (!deleted || error != CacheStorage::CACHE_STORAGE_ERROR_NO_ERROR) { + CacheStorageError error) { + if (!deleted || error != CACHE_STORAGE_OK) { Send(new CacheStorageMsg_CacheStorageDeleteError( thread_id, request_id, ToWebServiceWorkerCacheError(error))); return; @@ -365,8 +338,8 @@ void CacheStorageDispatcherHost::OnCacheStorageKeysCallback( int thread_id, int request_id, const std::vector<std::string>& strings, - CacheStorage::CacheStorageError error) { - if (error != CacheStorage::CACHE_STORAGE_ERROR_NO_ERROR) { + CacheStorageError error) { + if (error != CACHE_STORAGE_OK) { Send(new CacheStorageMsg_CacheStorageKeysError( thread_id, request_id, ToWebServiceWorkerCacheError(error))); return; @@ -383,12 +356,12 @@ void CacheStorageDispatcherHost::OnCacheStorageKeysCallback( void CacheStorageDispatcherHost::OnCacheStorageMatchCallback( int thread_id, int request_id, - CacheStorageCache::ErrorType error, + CacheStorageError error, scoped_ptr<ServiceWorkerResponse> response, scoped_ptr<storage::BlobDataHandle> blob_data_handle) { - if (error != CacheStorageCache::ERROR_TYPE_OK) { + if (error != CACHE_STORAGE_OK) { Send(new CacheStorageMsg_CacheStorageMatchError( - thread_id, request_id, CacheErrorToWebServiceWorkerCacheError(error))); + thread_id, request_id, ToWebServiceWorkerCacheError(error))); return; } @@ -403,12 +376,12 @@ void CacheStorageDispatcherHost::OnCacheMatchCallback( int thread_id, int request_id, const scoped_refptr<CacheStorageCache>& cache, - CacheStorageCache::ErrorType error, + CacheStorageError error, scoped_ptr<ServiceWorkerResponse> response, scoped_ptr<storage::BlobDataHandle> blob_data_handle) { - if (error != CacheStorageCache::ERROR_TYPE_OK) { + if (error != CACHE_STORAGE_OK) { Send(new CacheStorageMsg_CacheMatchError( - thread_id, request_id, CacheErrorToWebServiceWorkerCacheError(error))); + thread_id, request_id, ToWebServiceWorkerCacheError(error))); return; } @@ -422,11 +395,11 @@ void CacheStorageDispatcherHost::OnCacheKeysCallback( int thread_id, int request_id, const scoped_refptr<CacheStorageCache>& cache, - CacheStorageCache::ErrorType error, + CacheStorageError error, scoped_ptr<CacheStorageCache::Requests> requests) { - if (error != CacheStorageCache::ERROR_TYPE_OK) { + if (error != CACHE_STORAGE_OK) { Send(new CacheStorageMsg_CacheKeysError( - thread_id, request_id, CacheErrorToWebServiceWorkerCacheError(error))); + thread_id, request_id, ToWebServiceWorkerCacheError(error))); return; } @@ -446,10 +419,10 @@ void CacheStorageDispatcherHost::OnCacheBatchCallback( int thread_id, int request_id, const scoped_refptr<CacheStorageCache>& cache, - CacheStorageCache::ErrorType error) { - if (error != CacheStorageCache::ERROR_TYPE_OK) { + CacheStorageError error) { + if (error != CACHE_STORAGE_OK) { Send(new CacheStorageMsg_CacheBatchError( - thread_id, request_id, CacheErrorToWebServiceWorkerCacheError(error))); + thread_id, request_id, ToWebServiceWorkerCacheError(error))); return; } diff --git a/content/browser/cache_storage/cache_storage_dispatcher_host.h b/content/browser/cache_storage/cache_storage_dispatcher_host.h index 258d38f..8691a9c 100644 --- a/content/browser/cache_storage/cache_storage_dispatcher_host.h +++ b/content/browser/cache_storage/cache_storage_dispatcher_host.h @@ -85,23 +85,23 @@ class CONTENT_EXPORT CacheStorageDispatcherHost : public BrowserMessageFilter { void OnCacheStorageHasCallback(int thread_id, int request_id, bool has_cache, - CacheStorage::CacheStorageError error); + CacheStorageError error); void OnCacheStorageOpenCallback(int thread_id, int request_id, const scoped_refptr<CacheStorageCache>& cache, - CacheStorage::CacheStorageError error); + CacheStorageError error); void OnCacheStorageDeleteCallback(int thread_id, int request_id, bool deleted, - CacheStorage::CacheStorageError error); + CacheStorageError error); void OnCacheStorageKeysCallback(int thread_id, int request_id, const std::vector<std::string>& strings, - CacheStorage::CacheStorageError error); + CacheStorageError error); void OnCacheStorageMatchCallback( int thread_id, int request_id, - CacheStorageCache::ErrorType error, + CacheStorageError error, scoped_ptr<ServiceWorkerResponse> response, scoped_ptr<storage::BlobDataHandle> blob_data_handle); @@ -110,7 +110,7 @@ class CONTENT_EXPORT CacheStorageDispatcherHost : public BrowserMessageFilter { int thread_id, int request_id, const scoped_refptr<CacheStorageCache>& cache, - CacheStorageCache::ErrorType error, + CacheStorageError error, scoped_ptr<ServiceWorkerResponse> response, scoped_ptr<storage::BlobDataHandle> blob_data_handle); void OnCacheMatchAll(int thread_id, @@ -121,12 +121,12 @@ class CONTENT_EXPORT CacheStorageDispatcherHost : public BrowserMessageFilter { void OnCacheKeysCallback(int thread_id, int request_id, const scoped_refptr<CacheStorageCache>& cache, - CacheStorageCache::ErrorType error, + CacheStorageError error, scoped_ptr<CacheStorageCache::Requests> requests); void OnCacheBatchCallback(int thread_id, int request_id, const scoped_refptr<CacheStorageCache>& cache, - CacheStorageCache::ErrorType error); + CacheStorageError error); // Hangs onto a scoped_refptr for the cache if it isn't already doing so. // Returns a unique cache_id. Call DropCacheReference when the client is done diff --git a/content/browser/cache_storage/cache_storage_manager_unittest.cc b/content/browser/cache_storage/cache_storage_manager_unittest.cc index 5c40251..f0dfe4a 100644 --- a/content/browser/cache_storage/cache_storage_manager_unittest.cc +++ b/content/browser/cache_storage/cache_storage_manager_unittest.cc @@ -28,8 +28,8 @@ class CacheStorageManagerTest : public testing::Test { CacheStorageManagerTest() : browser_thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP), callback_bool_(false), - callback_error_(CacheStorage::CACHE_STORAGE_ERROR_NO_ERROR), - callback_cache_error_(CacheStorageCache::ERROR_TYPE_OK), + callback_error_(CACHE_STORAGE_OK), + callback_cache_error_(CACHE_STORAGE_OK), origin1_("http://example1.com"), origin2_("http://example2.com") {} @@ -68,7 +68,7 @@ class CacheStorageManagerTest : public testing::Test { void BoolAndErrorCallback(base::RunLoop* run_loop, bool value, - CacheStorage::CacheStorageError error) { + CacheStorageError error) { callback_bool_ = value; callback_error_ = error; run_loop->Quit(); @@ -76,7 +76,7 @@ class CacheStorageManagerTest : public testing::Test { void CacheAndErrorCallback(base::RunLoop* run_loop, const scoped_refptr<CacheStorageCache>& cache, - CacheStorage::CacheStorageError error) { + CacheStorageError error) { callback_cache_ = cache; callback_error_ = error; run_loop->Quit(); @@ -84,21 +84,20 @@ class CacheStorageManagerTest : public testing::Test { void StringsAndErrorCallback(base::RunLoop* run_loop, const std::vector<std::string>& strings, - CacheStorage::CacheStorageError error) { + CacheStorageError error) { callback_strings_ = strings; callback_error_ = error; run_loop->Quit(); } - void CachePutCallback(base::RunLoop* run_loop, - CacheStorageCache::ErrorType error) { + void CachePutCallback(base::RunLoop* run_loop, CacheStorageError error) { callback_cache_error_ = error; run_loop->Quit(); } void CacheMatchCallback( base::RunLoop* run_loop, - CacheStorageCache::ErrorType error, + CacheStorageError error, scoped_ptr<ServiceWorkerResponse> response, scoped_ptr<storage::BlobDataHandle> blob_data_handle) { callback_cache_error_ = error; @@ -115,7 +114,7 @@ class CacheStorageManagerTest : public testing::Test { base::Unretained(this), base::Unretained(loop.get()))); loop->Run(); - bool error = callback_error_ != CacheStorage::CACHE_STORAGE_ERROR_NO_ERROR; + bool error = callback_error_ != CACHE_STORAGE_OK; if (error) EXPECT_TRUE(!callback_cache_.get()); else @@ -153,7 +152,7 @@ class CacheStorageManagerTest : public testing::Test { base::Unretained(this), base::Unretained(loop.get()))); loop->Run(); - bool error = callback_error_ != CacheStorage::CACHE_STORAGE_ERROR_NO_ERROR; + bool error = callback_error_ != CACHE_STORAGE_OK; return !error; } @@ -170,7 +169,7 @@ class CacheStorageManagerTest : public testing::Test { base::Unretained(this), base::Unretained(loop.get()))); loop->Run(); - bool error = callback_cache_error_ != CacheStorageCache::ERROR_TYPE_OK; + bool error = callback_cache_error_ != CACHE_STORAGE_OK; return !error; } @@ -185,7 +184,7 @@ class CacheStorageManagerTest : public testing::Test { base::Unretained(this), base::Unretained(loop.get()))); loop->Run(); - bool error = callback_cache_error_ != CacheStorageCache::ERROR_TYPE_OK; + bool error = callback_cache_error_ != CACHE_STORAGE_OK; return !error; } @@ -203,7 +202,7 @@ class CacheStorageManagerTest : public testing::Test { base::Unretained(this), base::Unretained(loop.get()))); loop->Run(); - bool error = callback_cache_error_ != CacheStorageCache::ERROR_TYPE_OK; + bool error = callback_cache_error_ != CACHE_STORAGE_OK; return !error; } @@ -219,7 +218,7 @@ class CacheStorageManagerTest : public testing::Test { base::Unretained(this), base::Unretained(loop.get()))); loop->Run(); - bool error = callback_cache_error_ != CacheStorageCache::ERROR_TYPE_OK; + bool error = callback_cache_error_ != CACHE_STORAGE_OK; return !error; } @@ -237,8 +236,8 @@ class CacheStorageManagerTest : public testing::Test { scoped_refptr<CacheStorageCache> callback_cache_; int callback_bool_; - CacheStorage::CacheStorageError callback_error_; - CacheStorageCache::ErrorType callback_cache_error_; + CacheStorageError callback_error_; + CacheStorageError callback_cache_error_; scoped_ptr<ServiceWorkerResponse> callback_cache_response_; std::vector<std::string> callback_strings_; @@ -312,7 +311,7 @@ TEST_P(CacheStorageManagerTestP, DeleteTwice) { EXPECT_TRUE(Open(origin1_, "foo")); EXPECT_TRUE(Delete(origin1_, "foo")); EXPECT_FALSE(Delete(origin1_, "foo")); - EXPECT_EQ(CacheStorage::CACHE_STORAGE_ERROR_NOT_FOUND, callback_error_); + EXPECT_EQ(CACHE_STORAGE_ERROR_NOT_FOUND, callback_error_); } TEST_P(CacheStorageManagerTestP, EmptyKeys) { @@ -355,14 +354,14 @@ TEST_P(CacheStorageManagerTestP, StorageMatchNoEntry) { EXPECT_TRUE(Open(origin1_, "foo")); EXPECT_TRUE(CachePut(callback_cache_, GURL("http://example.com/foo"))); EXPECT_FALSE(StorageMatch(origin1_, "foo", GURL("http://example.com/bar"))); - EXPECT_EQ(CacheStorageCache::ERROR_TYPE_NOT_FOUND, callback_cache_error_); + EXPECT_EQ(CACHE_STORAGE_ERROR_NOT_FOUND, callback_cache_error_); } TEST_P(CacheStorageManagerTestP, StorageMatchNoCache) { EXPECT_TRUE(Open(origin1_, "foo")); EXPECT_TRUE(CachePut(callback_cache_, GURL("http://example.com/foo"))); EXPECT_FALSE(StorageMatch(origin1_, "bar", GURL("http://example.com/foo"))); - EXPECT_EQ(CacheStorageCache::ERROR_TYPE_NOT_FOUND, callback_cache_error_); + EXPECT_EQ(CACHE_STORAGE_ERROR_NOT_FOUND, callback_cache_error_); } TEST_P(CacheStorageManagerTestP, StorageMatchAllEntryExists) { @@ -375,12 +374,12 @@ TEST_P(CacheStorageManagerTestP, StorageMatchAllNoEntry) { EXPECT_TRUE(Open(origin1_, "foo")); EXPECT_TRUE(CachePut(callback_cache_, GURL("http://example.com/foo"))); EXPECT_FALSE(StorageMatchAll(origin1_, GURL("http://example.com/bar"))); - EXPECT_EQ(CacheStorageCache::ERROR_TYPE_NOT_FOUND, callback_cache_error_); + EXPECT_EQ(CACHE_STORAGE_ERROR_NOT_FOUND, callback_cache_error_); } TEST_P(CacheStorageManagerTestP, StorageMatchAllNoCaches) { EXPECT_FALSE(StorageMatchAll(origin1_, GURL("http://example.com/foo"))); - EXPECT_EQ(CacheStorageCache::ERROR_TYPE_NOT_FOUND, callback_cache_error_); + EXPECT_EQ(CACHE_STORAGE_ERROR_NOT_FOUND, callback_cache_error_); } TEST_P(CacheStorageManagerTestP, StorageMatchAllEntryExistsTwice) { diff --git a/content/common/cache_storage/cache_storage_types.h b/content/common/cache_storage/cache_storage_types.h index 26ac5e0..b52d517 100644 --- a/content/common/cache_storage/cache_storage_types.h +++ b/content/common/cache_storage/cache_storage_types.h @@ -47,6 +47,16 @@ struct CONTENT_EXPORT CacheStorageBatchOperation { CacheStorageCacheQueryParams match_params; }; +// This enum is used in histograms, so do not change the ordering and always +// append new types to the end. +enum CacheStorageError { + CACHE_STORAGE_OK = 0, + CACHE_STORAGE_ERROR_EXISTS, + CACHE_STORAGE_ERROR_STORAGE, + CACHE_STORAGE_ERROR_NOT_FOUND, + CACHE_STORAGE_ERROR_LAST = CACHE_STORAGE_ERROR_NOT_FOUND +}; + } // namespace content #endif // CONTENT_COMMON_CACHE_STORAGE_CACHE_STORAGE_TYPES_H_ |