Chromium Code Reviews| 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/profiler/scoped_tracker.h" | 8 #include "base/profiler/scoped_tracker.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 690 } | 690 } |
| 691 | 691 |
| 692 handle->version()->DispatchMessageEvent( | 692 handle->version()->DispatchMessageEvent( |
| 693 message, sent_message_ports, | 693 message, sent_message_ports, |
| 694 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 694 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| 695 } | 695 } |
| 696 | 696 |
| 697 void ServiceWorkerDispatcherHost::OnProviderCreated( | 697 void ServiceWorkerDispatcherHost::OnProviderCreated( |
| 698 int provider_id, | 698 int provider_id, |
| 699 int route_id, | 699 int route_id, |
| 700 ServiceWorkerProviderType provider_type) { | 700 ServiceWorkerProviderType provider_type, |
| 701 int navigation_provider_id) { | |
|
michaeln
2015/07/30 01:35:08
i don't like long names but 'nav_provider_id' is v
Fabrice (no longer in Chrome)
2015/08/06 15:39:15
Not using PlzNavigate prefix in variable/class nam
| |
| 701 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. | 702 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. |
| 702 tracked_objects::ScopedTracker tracking_profile( | 703 tracked_objects::ScopedTracker tracking_profile( |
| 703 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 704 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 704 "477117 ServiceWorkerDispatcherHost::OnProviderCreated")); | 705 "477117 ServiceWorkerDispatcherHost::OnProviderCreated")); |
| 705 TRACE_EVENT0("ServiceWorker", | 706 TRACE_EVENT0("ServiceWorker", |
| 706 "ServiceWorkerDispatcherHost::OnProviderCreated"); | 707 "ServiceWorkerDispatcherHost::OnProviderCreated"); |
| 707 if (!GetContext()) | 708 if (!GetContext()) |
| 708 return; | 709 return; |
| 709 if (GetContext()->GetProviderHost(render_process_id_, provider_id)) { | 710 if (GetContext()->GetProviderHost(render_process_id_, provider_id)) { |
| 710 bad_message::ReceivedBadMessage(this, | 711 bad_message::ReceivedBadMessage(this, |
| 711 bad_message::SWDH_PROVIDER_CREATED_NO_HOST); | 712 bad_message::SWDH_PROVIDER_CREATED_NO_HOST); |
| 712 return; | 713 return; |
| 713 } | 714 } |
| 715 | |
| 716 // PlzNavigate: | |
| 717 if (navigation_provider_id != kInvalidServiceWorkerProviderId) { | |
| 718 DCHECK_EQ(SERVICE_WORKER_PROVIDER_FOR_WINDOW, provider_type); | |
| 719 scoped_ptr<ServiceWorkerProviderHost> navigation_provider_host( | |
| 720 GetContext()->TakeNavigationProviderHost(navigation_provider_id)); | |
| 721 DCHECK(navigation_provider_host); | |
|
michaeln
2015/07/30 01:35:08
we can't trust these values are legit, !nav_provid
| |
| 722 navigation_provider_host->CompleteCrossSiteTransfer( | |
| 723 render_process_id_, route_id, provider_id, provider_type, this); | |
| 724 GetContext()->AddProviderHost(navigation_provider_host.Pass()); | |
| 725 return; | |
| 726 } | |
| 727 | |
| 714 scoped_ptr<ServiceWorkerProviderHost> provider_host( | 728 scoped_ptr<ServiceWorkerProviderHost> provider_host( |
| 715 new ServiceWorkerProviderHost(render_process_id_, route_id, provider_id, | 729 new ServiceWorkerProviderHost(render_process_id_, route_id, provider_id, |
| 716 provider_type, GetContext()->AsWeakPtr(), | 730 provider_type, GetContext()->AsWeakPtr(), |
| 717 this)); | 731 this)); |
| 718 GetContext()->AddProviderHost(provider_host.Pass()); | 732 GetContext()->AddProviderHost(provider_host.Pass()); |
| 719 } | 733 } |
| 720 | 734 |
| 721 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) { | 735 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) { |
| 722 TRACE_EVENT0("ServiceWorker", | 736 TRACE_EVENT0("ServiceWorker", |
| 723 "ServiceWorkerDispatcherHost::OnProviderDestroyed"); | 737 "ServiceWorkerDispatcherHost::OnProviderDestroyed"); |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1216 if (!handle) { | 1230 if (!handle) { |
| 1217 bad_message::ReceivedBadMessage(this, | 1231 bad_message::ReceivedBadMessage(this, |
| 1218 bad_message::SWDH_TERMINATE_BAD_HANDLE); | 1232 bad_message::SWDH_TERMINATE_BAD_HANDLE); |
| 1219 return; | 1233 return; |
| 1220 } | 1234 } |
| 1221 handle->version()->StopWorker( | 1235 handle->version()->StopWorker( |
| 1222 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1236 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| 1223 } | 1237 } |
| 1224 | 1238 |
| 1225 } // namespace content | 1239 } // namespace content |
| OLD | NEW |