summaryrefslogtreecommitdiffstats
path: root/content/child
diff options
context:
space:
mode:
authoralecflett@chromium.org <alecflett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-07 00:39:43 +0000
committeralecflett@chromium.org <alecflett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-07 00:39:43 +0000
commit2c12d3988689ece4e64ae54e6ade3407cce35282 (patch)
tree55360fa31fbadd9868a3defe435c3a2dd6c58ec3 /content/child
parent1913f753805b8871c83bb7f4a8f19d33cb2a77ad (diff)
downloadchromium_src-2c12d3988689ece4e64ae54e6ade3407cce35282.zip
chromium_src-2c12d3988689ece4e64ae54e6ade3407cce35282.tar.gz
chromium_src-2c12d3988689ece4e64ae54e6ade3407cce35282.tar.bz2
Service worker registration error support
This patch introduces use of WebServiceWorkerError as a means to propagate an error from the browser to the renderer, and further reflect this error via WebCallbacks into Blink BUG=285976 R=jam@chromium.org, michaeln@chromium.org, tsepez@chromium.org TBR=abarth Review URL: https://codereview.chromium.org/26442004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233438 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/child')
-rw-r--r--content/child/service_worker/service_worker_dispatcher.cc32
-rw-r--r--content/child/service_worker/service_worker_dispatcher.h12
2 files changed, 34 insertions, 10 deletions
diff --git a/content/child/service_worker/service_worker_dispatcher.cc b/content/child/service_worker/service_worker_dispatcher.cc
index 406de2d..b749ffd 100644
--- a/content/child/service_worker/service_worker_dispatcher.cc
+++ b/content/child/service_worker/service_worker_dispatcher.cc
@@ -11,6 +11,7 @@
#include "content/common/service_worker_messages.h"
#include "third_party/WebKit/public/web/WebSecurityOrigin.h"
+using WebKit::WebServiceWorkerError;
using WebKit::WebServiceWorkerProvider;
using base::ThreadLocalPointer;
using webkit_glue::WorkerTaskRunner;
@@ -44,10 +45,11 @@ ServiceWorkerDispatcher::~ServiceWorkerDispatcher() {
void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ServiceWorkerDispatcher, msg)
- IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerRegistered,
- OnServiceWorkerRegistered)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerRegistered, OnRegistered)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerUnregistered,
- OnServiceWorkerUnregistered)
+ OnUnregistered)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerRegistrationError,
+ OnRegistrationError)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
DCHECK(handled) << "Unhandled message:" << msg.type();
@@ -92,7 +94,7 @@ ServiceWorkerDispatcher* ServiceWorkerDispatcher::ThreadSpecificInstance(
return dispatcher;
}
-void ServiceWorkerDispatcher::OnServiceWorkerRegistered(
+void ServiceWorkerDispatcher::OnRegistered(
int32 thread_id,
int32 request_id,
int64 service_worker_id) {
@@ -114,8 +116,9 @@ void ServiceWorkerDispatcher::OnServiceWorkerRegistered(
pending_callbacks_.Remove(request_id);
}
-void ServiceWorkerDispatcher::OnServiceWorkerUnregistered(int32 thread_id,
- int32 request_id) {
+void ServiceWorkerDispatcher::OnUnregistered(
+ int32 thread_id,
+ int32 request_id) {
WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks =
pending_callbacks_.Lookup(request_id);
DCHECK(callbacks);
@@ -126,6 +129,23 @@ void ServiceWorkerDispatcher::OnServiceWorkerUnregistered(int32 thread_id,
pending_callbacks_.Remove(request_id);
}
+void ServiceWorkerDispatcher::OnRegistrationError(
+ int32 thread_id,
+ int32 request_id,
+ WebServiceWorkerError::ErrorType error_type,
+ const string16& message) {
+ WebServiceWorkerProvider::WebServiceWorkerCallbacks* callbacks =
+ pending_callbacks_.Lookup(request_id);
+ DCHECK(callbacks);
+ if (!callbacks)
+ return;
+
+ scoped_ptr<WebServiceWorkerError> error(
+ new WebServiceWorkerError(error_type, message));
+ callbacks->onError(error.release());
+ pending_callbacks_.Remove(request_id);
+}
+
void ServiceWorkerDispatcher::OnWorkerRunLoopStopped() { delete this; }
} // namespace content
diff --git a/content/child/service_worker/service_worker_dispatcher.h b/content/child/service_worker/service_worker_dispatcher.h
index 82a9f8b..4187ea6 100644
--- a/content/child/service_worker/service_worker_dispatcher.h
+++ b/content/child/service_worker/service_worker_dispatcher.h
@@ -8,6 +8,7 @@
#include "base/id_map.h"
#include "base/memory/ref_counted.h"
#include "base/strings/string16.h"
+#include "third_party/WebKit/public/platform/WebServiceWorkerError.h"
#include "third_party/WebKit/public/platform/WebServiceWorkerProvider.h"
#include "webkit/child/worker_task_runner.h"
@@ -57,11 +58,14 @@ class ServiceWorkerDispatcher : public webkit_glue::WorkerTaskRunner::Observer {
virtual void OnWorkerRunLoopStopped() OVERRIDE;
// The asynchronous success response to RegisterServiceWorker.
- void OnServiceWorkerRegistered(int32 thread_id,
- int32 request_id,
- int64 service_worker_id);
+ void OnRegistered(int32 thread_id, int32 request_id, int64 service_worker_id);
// The asynchronous success response to UregisterServiceWorker.
- void OnServiceWorkerUnregistered(int32 thread_id, int32 request_id);
+ void OnUnregistered(int32 thread_id,
+ int32 request_id);
+ void OnRegistrationError(int32 thread_id,
+ int32 request_id,
+ WebKit::WebServiceWorkerError::ErrorType error_type,
+ const string16& message);
IDMap<WebKit::WebServiceWorkerProvider::WebServiceWorkerCallbacks,
IDMapOwnPointer> pending_callbacks_;