Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: content/browser/service_worker/service_worker_dispatcher_host.cc

Issue 26442004: Service worker registration error support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review nits Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/service_worker_dispatcher_host.h" 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
6 6
7 #include "base/strings/utf_string_conversions.h"
7 #include "content/browser/service_worker/service_worker_context.h" 8 #include "content/browser/service_worker/service_worker_context.h"
8 #include "content/common/service_worker_messages.h" 9 #include "content/common/service_worker_messages.h"
9 #include "ipc/ipc_message_macros.h" 10 #include "ipc/ipc_message_macros.h"
11 #include "third_party/WebKit/public/platform/WebServiceWorkerError.h"
10 #include "url/gurl.h" 12 #include "url/gurl.h"
11 13
14 using WebKit::WebServiceWorkerError;
15
12 namespace content { 16 namespace content {
13 17
14 ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost( 18 ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost(
15 int render_process_id, 19 int render_process_id,
16 ServiceWorkerContext* context) 20 ServiceWorkerContext* context)
17 : render_process_id_(render_process_id), context_(context) {} 21 : render_process_id_(render_process_id), context_(context) {}
18 22
19 ServiceWorkerDispatcherHost::~ServiceWorkerDispatcherHost() {} 23 ServiceWorkerDispatcherHost::~ServiceWorkerDispatcherHost() {}
20 24
21 bool ServiceWorkerDispatcherHost::OnMessageReceived(const IPC::Message& message, 25 bool ServiceWorkerDispatcherHost::OnMessageReceived(const IPC::Message& message,
(...skipping 24 matching lines...) Expand all
46 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( 50 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker(
47 int32 thread_id, 51 int32 thread_id,
48 int32 request_id, 52 int32 request_id,
49 const GURL& scope, 53 const GURL& scope,
50 const GURL& script_url) { 54 const GURL& script_url) {
51 // TODO(alecflett): add a ServiceWorker-specific policy query in 55 // TODO(alecflett): add a ServiceWorker-specific policy query in
52 // ChildProcessSecurityImpl. See http://crbug.com/311631. 56 // ChildProcessSecurityImpl. See http://crbug.com/311631.
53 57
54 // TODO(alecflett): Throw an error for origin mismatch, rather than 58 // TODO(alecflett): Throw an error for origin mismatch, rather than
55 // just returning. 59 // just returning.
56 if (scope.GetOrigin() != script_url.GetOrigin()) 60 if (scope.GetOrigin() != script_url.GetOrigin())
michaeln 2013/10/25 21:41:25 this can use the error return path now and probabl
michaeln 2013/10/26 00:57:39 was wondering what happened to this one... i guess
alecflett 2013/10/28 17:03:14 oops, just an oversight. Done. (Add added a fairly
57 return; 61 return;
58 62
63 if (!context_->enabled()) {
64 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError(
65 thread_id,
66 request_id,
67 WebKit::WebServiceWorkerError::DisabledError,
68 ASCIIToUTF16("ServiceWorker is disabled")));
69 return;
70 }
71
59 Send(new ServiceWorkerMsg_ServiceWorkerRegistered( 72 Send(new ServiceWorkerMsg_ServiceWorkerRegistered(
60 thread_id, request_id, NextWorkerId())); 73 thread_id, request_id, NextWorkerId()));
61 } 74 }
62 75
63 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker(int32 thread_id, 76 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker(int32 thread_id,
64 int32 request_id, 77 int32 request_id,
65 const GURL& scope) { 78 const GURL& scope) {
66 // TODO(alecflett): add a ServiceWorker-specific policy query in 79 // TODO(alecflett): add a ServiceWorker-specific policy query in
67 // ChildProcessSecurityImpl. See http://crbug.com/311631. 80 // ChildProcessSecurityImpl. See http://crbug.com/311631.
68 81
82 if (!context_->enabled()) {
83 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError(
84 thread_id,
85 request_id,
86 WebServiceWorkerError::DisabledError,
87 ASCIIToUTF16("ServiceWorker is disabled")));
88 return;
89 }
90
69 Send(new ServiceWorkerMsg_ServiceWorkerUnregistered( 91 Send(new ServiceWorkerMsg_ServiceWorkerUnregistered(
70 thread_id, request_id)); 92 thread_id, request_id));
71 } 93 }
72 94
73 } // namespace content 95 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698