OLD | NEW |
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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "content/browser/message_port_message_filter.h" | 10 #include "content/browser/message_port_message_filter.h" |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 BadMessageReceived(); | 576 BadMessageReceived(); |
577 | 577 |
578 // Retrieve the registration associated with |version_id|. | 578 // Retrieve the registration associated with |version_id|. |
579 ServiceWorkerVersion* version = GetContext()->GetLiveVersion(version_id); | 579 ServiceWorkerVersion* version = GetContext()->GetLiveVersion(version_id); |
580 if (!version) | 580 if (!version) |
581 return; | 581 return; |
582 ServiceWorkerRegistration* registration = | 582 ServiceWorkerRegistration* registration = |
583 GetContext()->GetLiveRegistration(version->registration_id()); | 583 GetContext()->GetLiveRegistration(version->registration_id()); |
584 DCHECK(registration); | 584 DCHECK(registration); |
585 | 585 |
| 586 // Set the document URL to the script url in order to allow |
| 587 // register/unregister/getRegistration on ServiceWorkerGlobalScope. |
| 588 provider_host->SetDocumentUrl(version->script_url()); |
| 589 |
586 ServiceWorkerRegistrationObjectInfo info; | 590 ServiceWorkerRegistrationObjectInfo info; |
587 ServiceWorkerVersionAttributes attrs; | 591 ServiceWorkerVersionAttributes attrs; |
588 GetRegistrationObjectInfoAndVersionAttributes( | 592 GetRegistrationObjectInfoAndVersionAttributes( |
589 provider_host->AsWeakPtr(), registration, &info, &attrs); | 593 provider_host->AsWeakPtr(), registration, &info, &attrs); |
590 | 594 |
591 Send(new ServiceWorkerMsg_AssociateRegistrationWithServiceWorker( | 595 Send(new ServiceWorkerMsg_AssociateRegistrationWithServiceWorker( |
592 kDocumentMainThreadId, provider_id, info, attrs)); | 596 kDocumentMainThreadId, provider_id, info, attrs)); |
593 } | 597 } |
594 | 598 |
595 ServiceWorkerRegistrationHandle* | 599 ServiceWorkerRegistrationHandle* |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 ServiceWorkerHandle* handle = handles_.Lookup(handle_id); | 968 ServiceWorkerHandle* handle = handles_.Lookup(handle_id); |
965 if (!handle) { | 969 if (!handle) { |
966 BadMessageReceived(); | 970 BadMessageReceived(); |
967 return; | 971 return; |
968 } | 972 } |
969 handle->version()->StopWorker( | 973 handle->version()->StopWorker( |
970 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 974 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
971 } | 975 } |
972 | 976 |
973 } // namespace content | 977 } // namespace content |
OLD | NEW |