Commit 4650dfdf authored by jkarlin's avatar jkarlin Committed by Commit bot

[ServiceWorkerCacheStorage] Delete unused get/create functions.

The spec added 'open' and removed 'get/create'.  Delete get and create.

CLs in this three-legged-patch:

1. Add open to browser - https://codereview.chromium.org/664433003/
2. Add open (remove get/create) to Blink - https://codereview.chromium.org/638023003
*3. Remove get/create from browser - https://codereview.chromium.org/663503002/

BUG=423942

Review URL: https://codereview.chromium.org/663503002

Cr-Commit-Position: refs/heads/master@{#300266}
parent 62117928
......@@ -87,12 +87,8 @@ bool ServiceWorkerCacheListener::OnMessageReceived(
const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ServiceWorkerCacheListener, message)
IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_CacheStorageGet,
OnCacheStorageGet)
IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_CacheStorageHas,
OnCacheStorageHas)
IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_CacheStorageCreate,
OnCacheStorageCreate)
IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_CacheStorageOpen,
OnCacheStorageOpen)
IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_CacheStorageDelete,
......@@ -116,19 +112,6 @@ bool ServiceWorkerCacheListener::OnMessageReceived(
return handled;
}
void ServiceWorkerCacheListener::OnCacheStorageGet(
int request_id,
const base::string16& cache_name) {
TRACE_EVENT0("ServiceWorker",
"ServiceWorkerCacheListener::OnCacheStorageGet");
context_->cache_manager()->GetCache(
version_->scope().GetOrigin(),
base::UTF16ToUTF8(cache_name),
base::Bind(&ServiceWorkerCacheListener::OnCacheStorageGetCallback,
weak_factory_.GetWeakPtr(),
request_id));
}
void ServiceWorkerCacheListener::OnCacheStorageHas(
int request_id,
const base::string16& cache_name) {
......@@ -142,19 +125,6 @@ void ServiceWorkerCacheListener::OnCacheStorageHas(
request_id));
}
void ServiceWorkerCacheListener::OnCacheStorageCreate(
int request_id,
const base::string16& cache_name) {
TRACE_EVENT0("ServiceWorker",
"ServiceWorkerCacheListener::OnCacheStorageCreate");
context_->cache_manager()->CreateCache(
version_->scope().GetOrigin(),
base::UTF16ToUTF8(cache_name),
base::Bind(&ServiceWorkerCacheListener::OnCacheStorageCreateCallback,
weak_factory_.GetWeakPtr(),
request_id));
}
void ServiceWorkerCacheListener::OnCacheStorageOpen(
int request_id,
const base::string16& cache_name) {
......@@ -314,20 +284,6 @@ void ServiceWorkerCacheListener::Send(const IPC::Message& message) {
version_->embedded_worker()->SendMessage(message);
}
void ServiceWorkerCacheListener::OnCacheStorageGetCallback(
int request_id,
const scoped_refptr<ServiceWorkerCache>& cache,
ServiceWorkerCacheStorage::CacheStorageError error) {
if (error != ServiceWorkerCacheStorage::CACHE_STORAGE_ERROR_NO_ERROR) {
Send(ServiceWorkerMsg_CacheStorageGetError(
request_id, ToWebServiceWorkerCacheError(error)));
return;
}
CacheID cache_id = StoreCacheReference(cache);
Send(ServiceWorkerMsg_CacheStorageGetSuccess(request_id, cache_id));
}
void ServiceWorkerCacheListener::OnCacheStorageHasCallback(
int request_id,
bool has_cache,
......@@ -346,19 +302,6 @@ void ServiceWorkerCacheListener::OnCacheStorageHasCallback(
Send(ServiceWorkerMsg_CacheStorageHasSuccess(request_id));
}
void ServiceWorkerCacheListener::OnCacheStorageCreateCallback(
int request_id,
const scoped_refptr<ServiceWorkerCache>& cache,
ServiceWorkerCacheStorage::CacheStorageError error) {
if (error != ServiceWorkerCacheStorage::CACHE_STORAGE_ERROR_NO_ERROR) {
Send(ServiceWorkerMsg_CacheStorageCreateError(
request_id, ToWebServiceWorkerCacheError(error)));
return;
}
CacheID cache_id = StoreCacheReference(cache);
Send(ServiceWorkerMsg_CacheStorageCreateSuccess(request_id, cache_id));
}
void ServiceWorkerCacheListener::OnCacheStorageOpenCallback(
int request_id,
const scoped_refptr<ServiceWorkerCache>& cache,
......
......@@ -351,31 +351,6 @@ ServiceWorkerCacheStorage::ServiceWorkerCacheStorage(
ServiceWorkerCacheStorage::~ServiceWorkerCacheStorage() {
}
void ServiceWorkerCacheStorage::CreateCache(
const std::string& cache_name,
const CacheAndErrorCallback& callback) {
if (!initialized_) {
LazyInit(base::Bind(&ServiceWorkerCacheStorage::CreateCache,
weak_factory_.GetWeakPtr(),
cache_name,
callback));
return;
}
if (cache_map_.find(cache_name) != cache_map_.end()) {
callback.Run(scoped_refptr<ServiceWorkerCache>(),
CACHE_STORAGE_ERROR_EXISTS);
return;
}
cache_loader_->CreateCache(
cache_name,
base::Bind(&ServiceWorkerCacheStorage::CreateCacheDidCreateCache,
weak_factory_.GetWeakPtr(),
cache_name,
callback));
}
void ServiceWorkerCacheStorage::OpenCache(
const std::string& cache_name,
const CacheAndErrorCallback& callback) {
......@@ -403,29 +378,6 @@ void ServiceWorkerCacheStorage::OpenCache(
callback));
}
void ServiceWorkerCacheStorage::GetCache(
const std::string& cache_name,
const CacheAndErrorCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!initialized_) {
LazyInit(base::Bind(&ServiceWorkerCacheStorage::GetCache,
weak_factory_.GetWeakPtr(),
cache_name,
callback));
return;
}
scoped_refptr<ServiceWorkerCache> cache = GetLoadedCache(cache_name);
if (!cache.get()) {
callback.Run(scoped_refptr<ServiceWorkerCache>(),
CACHE_STORAGE_ERROR_NOT_FOUND);
return;
}
callback.Run(cache, CACHE_STORAGE_ERROR_NO_ERROR);
}
void ServiceWorkerCacheStorage::HasCache(const std::string& cache_name,
const BoolAndErrorCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
......
......@@ -58,17 +58,6 @@ class CONTENT_EXPORT ServiceWorkerCacheStorage {
virtual ~ServiceWorkerCacheStorage();
// Create a ServiceWorkerCache if it doesn't already exist and call the
// callback with the cache. If it already
// exists the callback is called with CACHE_STORAGE_ERROR_EXISTS.
void CreateCache(const std::string& cache_name,
const CacheAndErrorCallback& callback);
// Get the cache for the given key. If not found returns
// CACHE_STORAGE_ERROR_NOT_FOUND.
void GetCache(const std::string& cache_name,
const CacheAndErrorCallback& callback);
// Get the cache for the given key. If the cache is not found it is
// created.
void OpenCache(const std::string& cache_name,
......
......@@ -68,30 +68,6 @@ ServiceWorkerCacheStorageManager::~ServiceWorkerCacheStorageManager() {
}
}
void ServiceWorkerCacheStorageManager::CreateCache(
const GURL& origin,
const std::string& cache_name,
const ServiceWorkerCacheStorage::CacheAndErrorCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
ServiceWorkerCacheStorage* cache_storage =
FindOrCreateServiceWorkerCacheManager(origin);
cache_storage->CreateCache(cache_name, callback);
}
void ServiceWorkerCacheStorageManager::GetCache(
const GURL& origin,
const std::string& cache_name,
const ServiceWorkerCacheStorage::CacheAndErrorCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
ServiceWorkerCacheStorage* cache_storage =
FindOrCreateServiceWorkerCacheManager(origin);
cache_storage->GetCache(cache_name, callback);
}
void ServiceWorkerCacheStorageManager::OpenCache(
const GURL& origin,
const std::string& cache_name,
......
......@@ -45,14 +45,6 @@ class CONTENT_EXPORT ServiceWorkerCacheStorageManager {
// Methods to support the CacheStorage spec. These methods call the
// corresponding ServiceWorkerCacheStorage method on the appropriate thread.
void CreateCache(
const GURL& origin,
const std::string& cache_name,
const ServiceWorkerCacheStorage::CacheAndErrorCallback& callback);
void GetCache(
const GURL& origin,
const std::string& cache_name,
const ServiceWorkerCacheStorage::CacheAndErrorCallback& callback);
void OpenCache(
const GURL& origin,
const std::string& cache_name,
......
......@@ -189,18 +189,10 @@ IPC_MESSAGE_ROUTED3(ServiceWorkerHostMsg_PostMessageToDocument,
std::vector<int> /* sent_message_port_ids */)
// CacheStorage operations in the browser.
IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_CacheStorageGet,
int /* request_id */,
base::string16 /* fetch_store_name */)
IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_CacheStorageHas,
int /* request_id */,
base::string16 /* fetch_store_name */)
IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_CacheStorageCreate,
int /* request_id */,
base::string16 /* fetch_store_name */)
IPC_MESSAGE_ROUTED2(ServiceWorkerHostMsg_CacheStorageOpen,
int /* request_id */,
base::string16 /* fetch_store_name */)
......@@ -365,14 +357,8 @@ IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_DidGetClientDocuments,
std::vector<int> /* client_ids */)
// Sent via EmbeddedWorker at successful completion of CacheStorage operations.
IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageGetSuccess,
int /* request_id */,
int /* fetch_store_id */)
IPC_MESSAGE_CONTROL1(ServiceWorkerMsg_CacheStorageHasSuccess,
int /* request_id */)
IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageCreateSuccess,
int /* request_id */,
int /* fetch_store_id */)
IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageOpenSuccess,
int /* request_id */,
int /* fetch_store_id */)
......@@ -383,15 +369,9 @@ IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageKeysSuccess,
std::vector<base::string16> /* keys */)
// Sent via EmbeddedWorker at erroneous completion of CacheStorage operations.
IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageGetError,
int /* request_id */,
blink::WebServiceWorkerCacheError /* reason */)
IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageHasError,
int /* request_id */,
blink::WebServiceWorkerCacheError /* reason */)
IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageCreateError,
int /* request_id */,
blink::WebServiceWorkerCacheError /* reason */)
IPC_MESSAGE_CONTROL2(ServiceWorkerMsg_CacheStorageOpenError,
int /* request_id */,
blink::WebServiceWorkerCacheError /* reason */)
......
......@@ -204,9 +204,7 @@ ServiceWorkerCacheStorageDispatcher::ServiceWorkerCacheStorageDispatcher(
weak_factory_(this) {}
ServiceWorkerCacheStorageDispatcher::~ServiceWorkerCacheStorageDispatcher() {
ClearCallbacksMapWithErrors(&get_callbacks_);
ClearCallbacksMapWithErrors(&has_callbacks_);
ClearCallbacksMapWithErrors(&create_callbacks_);
ClearCallbacksMapWithErrors(&open_callbacks_);
ClearCallbacksMapWithErrors(&delete_callbacks_);
ClearCallbacksMapWithErrors(&keys_callbacks_);
......@@ -221,24 +219,16 @@ bool ServiceWorkerCacheStorageDispatcher::OnMessageReceived(
const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ServiceWorkerCacheStorageDispatcher, message)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CacheStorageGetSuccess,
OnCacheStorageGetSuccess)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CacheStorageHasSuccess,
OnCacheStorageHasSuccess)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CacheStorageCreateSuccess,
OnCacheStorageCreateSuccess)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CacheStorageOpenSuccess,
OnCacheStorageOpenSuccess)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CacheStorageDeleteSuccess,
OnCacheStorageDeleteSuccess)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CacheStorageKeysSuccess,
OnCacheStorageKeysSuccess)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CacheStorageGetError,
OnCacheStorageGetError)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CacheStorageHasError,
OnCacheStorageHasError)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CacheStorageCreateError,
OnCacheStorageCreateError)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CacheStorageOpenError,
OnCacheStorageOpenError)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_CacheStorageDeleteError,
......@@ -267,16 +257,6 @@ bool ServiceWorkerCacheStorageDispatcher::OnMessageReceived(
return handled;
}
void ServiceWorkerCacheStorageDispatcher::OnCacheStorageGetSuccess(
int request_id,
int cache_id) {
WebCache* web_cache = new WebCache(weak_factory_.GetWeakPtr(), cache_id);
web_caches_.AddWithID(web_cache, cache_id);
CacheStorageWithCacheCallbacks* callbacks = get_callbacks_.Lookup(request_id);
callbacks->onSuccess(web_cache);
get_callbacks_.Remove(request_id);
}
void ServiceWorkerCacheStorageDispatcher::OnCacheStorageHasSuccess(
int request_id) {
CacheStorageCallbacks* callbacks = has_callbacks_.Lookup(request_id);
......@@ -284,17 +264,6 @@ void ServiceWorkerCacheStorageDispatcher::OnCacheStorageHasSuccess(
has_callbacks_.Remove(request_id);
}
void ServiceWorkerCacheStorageDispatcher::OnCacheStorageCreateSuccess(
int request_id,
int cache_id) {
WebCache* web_cache = new WebCache(weak_factory_.GetWeakPtr(), cache_id);
web_caches_.AddWithID(web_cache, cache_id);
CacheStorageWithCacheCallbacks* callbacks =
create_callbacks_.Lookup(request_id);
callbacks->onSuccess(web_cache);
create_callbacks_.Remove(request_id);
}
void ServiceWorkerCacheStorageDispatcher::OnCacheStorageOpenSuccess(
int request_id,
int cache_id) {
......@@ -325,15 +294,6 @@ void ServiceWorkerCacheStorageDispatcher::OnCacheStorageKeysSuccess(
keys_callbacks_.Remove(request_id);
}
void ServiceWorkerCacheStorageDispatcher::OnCacheStorageGetError(
int request_id,
blink::WebServiceWorkerCacheError reason) {
CacheStorageWithCacheCallbacks* callbacks =
get_callbacks_.Lookup(request_id);
callbacks->onError(&reason);
get_callbacks_.Remove(request_id);
}
void ServiceWorkerCacheStorageDispatcher::OnCacheStorageHasError(
int request_id,
blink::WebServiceWorkerCacheError reason) {
......@@ -342,15 +302,6 @@ void ServiceWorkerCacheStorageDispatcher::OnCacheStorageHasError(
has_callbacks_.Remove(request_id);
}
void ServiceWorkerCacheStorageDispatcher::OnCacheStorageCreateError(
int request_id,
blink::WebServiceWorkerCacheError reason) {
CacheStorageWithCacheCallbacks* callbacks =
create_callbacks_.Lookup(request_id);
callbacks->onError(&reason);
create_callbacks_.Remove(request_id);
}
void ServiceWorkerCacheStorageDispatcher::OnCacheStorageOpenError(
int request_id,
blink::WebServiceWorkerCacheError reason) {
......@@ -461,14 +412,6 @@ void ServiceWorkerCacheStorageDispatcher::OnCacheBatchError(
cache_batch_callbacks_.Remove(request_id);
}
void ServiceWorkerCacheStorageDispatcher::dispatchGet(
CacheStorageWithCacheCallbacks* callbacks,
const blink::WebString& cacheName) {
int request_id = get_callbacks_.Add(callbacks);
script_context_->Send(new ServiceWorkerHostMsg_CacheStorageGet(
script_context_->GetRoutingID(), request_id, cacheName));
}
void ServiceWorkerCacheStorageDispatcher::dispatchHas(
CacheStorageCallbacks* callbacks,
const blink::WebString& cacheName) {
......@@ -477,14 +420,6 @@ void ServiceWorkerCacheStorageDispatcher::dispatchHas(
script_context_->GetRoutingID(), request_id, cacheName));
}
void ServiceWorkerCacheStorageDispatcher::dispatchCreate(
CacheStorageWithCacheCallbacks* callbacks,
const blink::WebString& cacheName) {
int request_id = create_callbacks_.Add(callbacks);
script_context_->Send(new ServiceWorkerHostMsg_CacheStorageCreate(
script_context_->GetRoutingID(), request_id, cacheName));
}
void ServiceWorkerCacheStorageDispatcher::dispatchOpen(
CacheStorageWithCacheCallbacks* callbacks,
const blink::WebString& cacheName) {
......
......@@ -38,20 +38,14 @@ class ServiceWorkerCacheStorageDispatcher
bool OnMessageReceived(const IPC::Message& message);
// Message handlers for CacheStorage messages from the browser process.
void OnCacheStorageGetSuccess(int request_id, int cache_id);
void OnCacheStorageHasSuccess(int request_id);
void OnCacheStorageCreateSuccess(int request_id, int cache_id);
void OnCacheStorageOpenSuccess(int request_id, int cache_id);
void OnCacheStorageDeleteSuccess(int request_id);
void OnCacheStorageKeysSuccess(int request_id,
const std::vector<base::string16>& keys);
void OnCacheStorageGetError(int request_id,
blink::WebServiceWorkerCacheError reason);
void OnCacheStorageHasError(int request_id,
blink::WebServiceWorkerCacheError reason);
void OnCacheStorageCreateError(int request_id,
blink::WebServiceWorkerCacheError reason);
void OnCacheStorageOpenError(int request_id,
blink::WebServiceWorkerCacheError reason);
void OnCacheStorageDeleteError(int request_id,
......@@ -81,12 +75,8 @@ class ServiceWorkerCacheStorageDispatcher
blink::WebServiceWorkerCacheError reason);
// From WebServiceWorkerCacheStorage:
virtual void dispatchGet(CacheStorageWithCacheCallbacks* callbacks,
const blink::WebString& cacheName);
virtual void dispatchHas(CacheStorageCallbacks* callbacks,
const blink::WebString& cacheName);
virtual void dispatchCreate(CacheStorageWithCacheCallbacks* callbacks,
const blink::WebString& cacheName);
virtual void dispatchOpen(CacheStorageWithCacheCallbacks* callbacks,
const blink::WebString& cacheName);
virtual void dispatchDelete(CacheStorageCallbacks* callbacks,
......@@ -144,9 +134,7 @@ class ServiceWorkerCacheStorageDispatcher
// Not owned. The script context containing this object.
ServiceWorkerScriptContext* script_context_;
WithCacheCallbacksMap get_callbacks_;
CallbacksMap has_callbacks_;
WithCacheCallbacksMap create_callbacks_;
WithCacheCallbacksMap open_callbacks_;
CallbacksMap delete_callbacks_;
KeysCallbacksMap keys_callbacks_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment