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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 return; | 696 return; |
697 } | 697 } |
698 | 698 |
699 handle->version()->DispatchMessageEvent( | 699 handle->version()->DispatchMessageEvent( |
700 message, sent_message_ports, | 700 message, sent_message_ports, |
701 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 701 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
702 } | 702 } |
703 | 703 |
704 void ServiceWorkerDispatcherHost::OnProviderCreated( | 704 void ServiceWorkerDispatcherHost::OnProviderCreated( |
705 int provider_id, | 705 int provider_id, |
706 int render_frame_id, | 706 int route_id, |
707 ServiceWorkerProviderType provider_type) { | 707 ServiceWorkerProviderType provider_type) { |
708 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. | 708 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. |
709 tracked_objects::ScopedTracker tracking_profile( | 709 tracked_objects::ScopedTracker tracking_profile( |
710 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 710 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
711 "477117 ServiceWorkerDispatcherHost::OnProviderCreated")); | 711 "477117 ServiceWorkerDispatcherHost::OnProviderCreated")); |
712 TRACE_EVENT0("ServiceWorker", | 712 TRACE_EVENT0("ServiceWorker", |
713 "ServiceWorkerDispatcherHost::OnProviderCreated"); | 713 "ServiceWorkerDispatcherHost::OnProviderCreated"); |
714 if (!GetContext()) | 714 if (!GetContext()) |
715 return; | 715 return; |
716 if (GetContext()->GetProviderHost(render_process_id_, provider_id)) { | 716 if (GetContext()->GetProviderHost(render_process_id_, provider_id)) { |
717 bad_message::ReceivedBadMessage(this, | 717 bad_message::ReceivedBadMessage(this, |
718 bad_message::SWDH_PROVIDER_CREATED_NO_HOST); | 718 bad_message::SWDH_PROVIDER_CREATED_NO_HOST); |
719 return; | 719 return; |
720 } | 720 } |
721 scoped_ptr<ServiceWorkerProviderHost> provider_host( | 721 scoped_ptr<ServiceWorkerProviderHost> provider_host( |
722 new ServiceWorkerProviderHost(render_process_id_, | 722 new ServiceWorkerProviderHost(render_process_id_, route_id, provider_id, |
723 render_frame_id, | 723 provider_type, GetContext()->AsWeakPtr(), |
724 provider_id, | |
725 provider_type, | |
726 GetContext()->AsWeakPtr(), | |
727 this)); | 724 this)); |
728 GetContext()->AddProviderHost(provider_host.Pass()); | 725 GetContext()->AddProviderHost(provider_host.Pass()); |
729 } | 726 } |
730 | 727 |
731 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) { | 728 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) { |
732 TRACE_EVENT0("ServiceWorker", | 729 TRACE_EVENT0("ServiceWorker", |
733 "ServiceWorkerDispatcherHost::OnProviderDestroyed"); | 730 "ServiceWorkerDispatcherHost::OnProviderDestroyed"); |
734 if (!GetContext()) | 731 if (!GetContext()) |
735 return; | 732 return; |
736 if (!GetContext()->GetProviderHost(render_process_id_, provider_id)) { | 733 if (!GetContext()->GetProviderHost(render_process_id_, provider_id)) { |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1236 if (!handle) { | 1233 if (!handle) { |
1237 bad_message::ReceivedBadMessage(this, | 1234 bad_message::ReceivedBadMessage(this, |
1238 bad_message::SWDH_TERMINATE_BAD_HANDLE); | 1235 bad_message::SWDH_TERMINATE_BAD_HANDLE); |
1239 return; | 1236 return; |
1240 } | 1237 } |
1241 handle->version()->StopWorker( | 1238 handle->version()->StopWorker( |
1242 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1239 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
1243 } | 1240 } |
1244 | 1241 |
1245 } // namespace content | 1242 } // namespace content |
OLD | NEW |