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 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 return; | 632 return; |
633 } | 633 } |
634 | 634 |
635 handle->version()->DispatchMessageEvent( | 635 handle->version()->DispatchMessageEvent( |
636 message, sent_message_ports, | 636 message, sent_message_ports, |
637 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 637 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
638 } | 638 } |
639 | 639 |
640 void ServiceWorkerDispatcherHost::OnProviderCreated( | 640 void ServiceWorkerDispatcherHost::OnProviderCreated( |
641 int provider_id, | 641 int provider_id, |
642 int render_frame_id, | 642 int route_id, |
643 ServiceWorkerProviderType provider_type) { | 643 ServiceWorkerProviderType provider_type) { |
644 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. | 644 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. |
645 tracked_objects::ScopedTracker tracking_profile( | 645 tracked_objects::ScopedTracker tracking_profile( |
646 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 646 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
647 "477117 ServiceWorkerDispatcherHost::OnProviderCreated")); | 647 "477117 ServiceWorkerDispatcherHost::OnProviderCreated")); |
648 TRACE_EVENT0("ServiceWorker", | 648 TRACE_EVENT0("ServiceWorker", |
649 "ServiceWorkerDispatcherHost::OnProviderCreated"); | 649 "ServiceWorkerDispatcherHost::OnProviderCreated"); |
650 if (!GetContext()) | 650 if (!GetContext()) |
651 return; | 651 return; |
652 if (GetContext()->GetProviderHost(render_process_id_, provider_id)) { | 652 if (GetContext()->GetProviderHost(render_process_id_, provider_id)) { |
653 bad_message::ReceivedBadMessage(this, | 653 bad_message::ReceivedBadMessage(this, |
654 bad_message::SWDH_PROVIDER_CREATED_NO_HOST); | 654 bad_message::SWDH_PROVIDER_CREATED_NO_HOST); |
655 return; | 655 return; |
656 } | 656 } |
657 scoped_ptr<ServiceWorkerProviderHost> provider_host( | 657 scoped_ptr<ServiceWorkerProviderHost> provider_host( |
658 new ServiceWorkerProviderHost(render_process_id_, | 658 new ServiceWorkerProviderHost(render_process_id_, route_id, provider_id, |
659 render_frame_id, | 659 provider_type, GetContext()->AsWeakPtr(), |
660 provider_id, | |
661 provider_type, | |
662 GetContext()->AsWeakPtr(), | |
663 this)); | 660 this)); |
664 GetContext()->AddProviderHost(provider_host.Pass()); | 661 GetContext()->AddProviderHost(provider_host.Pass()); |
665 } | 662 } |
666 | 663 |
667 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) { | 664 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) { |
668 TRACE_EVENT0("ServiceWorker", | 665 TRACE_EVENT0("ServiceWorker", |
669 "ServiceWorkerDispatcherHost::OnProviderDestroyed"); | 666 "ServiceWorkerDispatcherHost::OnProviderDestroyed"); |
670 if (!GetContext()) | 667 if (!GetContext()) |
671 return; | 668 return; |
672 if (!GetContext()->GetProviderHost(render_process_id_, provider_id)) { | 669 if (!GetContext()->GetProviderHost(render_process_id_, provider_id)) { |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 if (!handle) { | 1169 if (!handle) { |
1173 bad_message::ReceivedBadMessage(this, | 1170 bad_message::ReceivedBadMessage(this, |
1174 bad_message::SWDH_TERMINATE_BAD_HANDLE); | 1171 bad_message::SWDH_TERMINATE_BAD_HANDLE); |
1175 return; | 1172 return; |
1176 } | 1173 } |
1177 handle->version()->StopWorker( | 1174 handle->version()->StopWorker( |
1178 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1175 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
1179 } | 1176 } |
1180 | 1177 |
1181 } // namespace content | 1178 } // namespace content |
OLD | NEW |