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

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

Issue 2418373002: Reduce FOR_EACH_OBSERVER usage in content/browser/service_worker (Closed)
Patch Set: add bracket Created 4 years, 2 months 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
« no previous file with comments | « content/browser/service_worker/service_worker_registration.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_version.h" 5 #include "content/browser/service_worker/service_worker_version.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 367 }
368 368
369 // OnVersionStateChanged() invokes updates of the status using state 369 // OnVersionStateChanged() invokes updates of the status using state
370 // change IPC at ServiceWorkerHandle (for JS-land on renderer process) and 370 // change IPC at ServiceWorkerHandle (for JS-land on renderer process) and
371 // ServiceWorkerContextCore (for devtools and serviceworker-internals). 371 // ServiceWorkerContextCore (for devtools and serviceworker-internals).
372 // This should be done before using the new status by 372 // This should be done before using the new status by
373 // |status_change_callbacks_| which sends the IPC for resolving the .ready 373 // |status_change_callbacks_| which sends the IPC for resolving the .ready
374 // property. 374 // property.
375 // TODO(shimazu): Clarify the dependency of OnVersionStateChanged and 375 // TODO(shimazu): Clarify the dependency of OnVersionStateChanged and
376 // |status_change_callbacks_| 376 // |status_change_callbacks_|
377 FOR_EACH_OBSERVER(Listener, listeners_, OnVersionStateChanged(this)); 377 for (auto& observer : listeners_)
378 observer.OnVersionStateChanged(this);
378 379
379 std::vector<base::Closure> callbacks; 380 std::vector<base::Closure> callbacks;
380 callbacks.swap(status_change_callbacks_); 381 callbacks.swap(status_change_callbacks_);
381 for (const auto& callback : callbacks) 382 for (const auto& callback : callbacks)
382 callback.Run(); 383 callback.Run();
383 384
384 if (status == INSTALLED) 385 if (status == INSTALLED)
385 embedded_worker_->OnWorkerVersionInstalled(); 386 embedded_worker_->OnWorkerVersionInstalled();
386 else if (status == REDUNDANT) 387 else if (status == REDUNDANT)
387 embedded_worker_->OnWorkerVersionDoomed(); 388 embedded_worker_->OnWorkerVersionDoomed();
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 request->event_type, base::TimeTicks::Now() - request->start_time_ticks, 578 request->event_type, base::TimeTicks::Now() - request->start_time_ticks,
578 was_handled); 579 was_handled);
579 ServiceWorkerMetrics::RecordEventDispatchingDelay( 580 ServiceWorkerMetrics::RecordEventDispatchingDelay(
580 request->event_type, dispatch_event_time - request->start_time, 581 request->event_type, dispatch_event_time - request->start_time,
581 site_for_uma()); 582 site_for_uma());
582 583
583 RestartTick(&idle_time_); 584 RestartTick(&idle_time_);
584 TRACE_EVENT_ASYNC_END1("ServiceWorker", "ServiceWorkerVersion::Request", 585 TRACE_EVENT_ASYNC_END1("ServiceWorker", "ServiceWorkerVersion::Request",
585 request, "Handled", was_handled); 586 request, "Handled", was_handled);
586 pending_requests_.Remove(request_id); 587 pending_requests_.Remove(request_id);
587 if (!HasWork()) 588 if (!HasWork()) {
588 FOR_EACH_OBSERVER(Listener, listeners_, OnNoWork(this)); 589 for (auto& observer : listeners_)
590 observer.OnNoWork(this);
591 }
589 592
590 return true; 593 return true;
591 } 594 }
592 595
593 void ServiceWorkerVersion::RunAfterStartWorker( 596 void ServiceWorkerVersion::RunAfterStartWorker(
594 ServiceWorkerMetrics::EventType purpose, 597 ServiceWorkerMetrics::EventType purpose,
595 const base::Closure& task, 598 const base::Closure& task,
596 const StatusCallback& error_callback) { 599 const StatusCallback& error_callback) {
597 if (running_status() == EmbeddedWorkerStatus::RUNNING) { 600 if (running_status() == EmbeddedWorkerStatus::RUNNING) {
598 DCHECK(start_callbacks_.empty()); 601 DCHECK(start_callbacks_.empty());
(...skipping 26 matching lines...) Expand all
625 } 628 }
626 629
627 void ServiceWorkerVersion::AddControllee( 630 void ServiceWorkerVersion::AddControllee(
628 ServiceWorkerProviderHost* provider_host) { 631 ServiceWorkerProviderHost* provider_host) {
629 const std::string& uuid = provider_host->client_uuid(); 632 const std::string& uuid = provider_host->client_uuid();
630 CHECK(!provider_host->client_uuid().empty()); 633 CHECK(!provider_host->client_uuid().empty());
631 DCHECK(!base::ContainsKey(controllee_map_, uuid)); 634 DCHECK(!base::ContainsKey(controllee_map_, uuid));
632 controllee_map_[uuid] = provider_host; 635 controllee_map_[uuid] = provider_host;
633 // Keep the worker alive a bit longer right after a new controllee is added. 636 // Keep the worker alive a bit longer right after a new controllee is added.
634 RestartTick(&idle_time_); 637 RestartTick(&idle_time_);
635 FOR_EACH_OBSERVER(Listener, listeners_, 638 for (auto& observer : listeners_)
636 OnControlleeAdded(this, provider_host)); 639 observer.OnControlleeAdded(this, provider_host);
637 } 640 }
638 641
639 void ServiceWorkerVersion::RemoveControllee( 642 void ServiceWorkerVersion::RemoveControllee(
640 ServiceWorkerProviderHost* provider_host) { 643 ServiceWorkerProviderHost* provider_host) {
641 const std::string& uuid = provider_host->client_uuid(); 644 const std::string& uuid = provider_host->client_uuid();
642 DCHECK(base::ContainsKey(controllee_map_, uuid)); 645 DCHECK(base::ContainsKey(controllee_map_, uuid));
643 controllee_map_.erase(uuid); 646 controllee_map_.erase(uuid);
644 FOR_EACH_OBSERVER(Listener, listeners_, 647 for (auto& observer : listeners_)
645 OnControlleeRemoved(this, provider_host)); 648 observer.OnControlleeRemoved(this, provider_host);
646 if (!HasControllee()) 649 if (!HasControllee()) {
647 FOR_EACH_OBSERVER(Listener, listeners_, OnNoControllees(this)); 650 for (auto& observer : listeners_)
651 observer.OnNoControllees(this);
652 }
648 } 653 }
649 654
650 void ServiceWorkerVersion::AddStreamingURLRequestJob( 655 void ServiceWorkerVersion::AddStreamingURLRequestJob(
651 const ServiceWorkerURLRequestJob* request_job) { 656 const ServiceWorkerURLRequestJob* request_job) {
652 DCHECK(streaming_url_request_jobs_.find(request_job) == 657 DCHECK(streaming_url_request_jobs_.find(request_job) ==
653 streaming_url_request_jobs_.end()); 658 streaming_url_request_jobs_.end());
654 streaming_url_request_jobs_.insert(request_job); 659 streaming_url_request_jobs_.insert(request_job);
655 } 660 }
656 661
657 void ServiceWorkerVersion::RemoveStreamingURLRequestJob( 662 void ServiceWorkerVersion::RemoveStreamingURLRequestJob(
658 const ServiceWorkerURLRequestJob* request_job) { 663 const ServiceWorkerURLRequestJob* request_job) {
659 streaming_url_request_jobs_.erase(request_job); 664 streaming_url_request_jobs_.erase(request_job);
660 if (!HasWork()) 665 if (!HasWork()) {
661 FOR_EACH_OBSERVER(Listener, listeners_, OnNoWork(this)); 666 for (auto& observer : listeners_)
667 observer.OnNoWork(this);
668 }
662 } 669 }
663 670
664 void ServiceWorkerVersion::AddListener(Listener* listener) { 671 void ServiceWorkerVersion::AddListener(Listener* listener) {
665 listeners_.AddObserver(listener); 672 listeners_.AddObserver(listener);
666 } 673 }
667 674
668 void ServiceWorkerVersion::RemoveListener(Listener* listener) { 675 void ServiceWorkerVersion::RemoveListener(Listener* listener) {
669 listeners_.RemoveObserver(listener); 676 listeners_.RemoveObserver(listener);
670 } 677 }
671 678
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 // 1) The worker is a new one. 760 // 1) The worker is a new one.
754 // OR 761 // OR
755 // 2) The worker is an existing one but the entry in ServiceWorkerDatabase 762 // 2) The worker is an existing one but the entry in ServiceWorkerDatabase
756 // was written by old version Chrome (< M56), so |origin_trial_tokens| 763 // was written by old version Chrome (< M56), so |origin_trial_tokens|
757 // wasn't set in the entry. 764 // wasn't set in the entry.
758 if (!origin_trial_tokens_) { 765 if (!origin_trial_tokens_) {
759 origin_trial_tokens_ = TrialTokenValidator::GetValidTokensFromHeaders( 766 origin_trial_tokens_ = TrialTokenValidator::GetValidTokensFromHeaders(
760 url::Origin(scope()), http_info.headers.get()); 767 url::Origin(scope()), http_info.headers.get());
761 } 768 }
762 769
763 FOR_EACH_OBSERVER(Listener, listeners_, 770 for (auto& observer : listeners_)
764 OnMainScriptHttpResponseInfoSet(this)); 771 observer.OnMainScriptHttpResponseInfoSet(this);
765 } 772 }
766 773
767 void ServiceWorkerVersion::SimulatePingTimeoutForTesting() { 774 void ServiceWorkerVersion::SimulatePingTimeoutForTesting() {
768 ping_controller_->SimulateTimeoutForTesting(); 775 ping_controller_->SimulateTimeoutForTesting();
769 } 776 }
770 777
771 const net::HttpResponseInfo* 778 const net::HttpResponseInfo*
772 ServiceWorkerVersion::GetMainScriptHttpResponseInfo() { 779 ServiceWorkerVersion::GetMainScriptHttpResponseInfo() {
773 return main_script_http_info_.get(); 780 return main_script_http_info_.get();
774 } 781 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 } 830 }
824 } 831 }
825 832
826 void ServiceWorkerVersion::OnThreadStarted() { 833 void ServiceWorkerVersion::OnThreadStarted() {
827 DCHECK_EQ(EmbeddedWorkerStatus::STARTING, running_status()); 834 DCHECK_EQ(EmbeddedWorkerStatus::STARTING, running_status());
828 // Activate ping/pong now that JavaScript execution will start. 835 // Activate ping/pong now that JavaScript execution will start.
829 ping_controller_->Activate(); 836 ping_controller_->Activate();
830 } 837 }
831 838
832 void ServiceWorkerVersion::OnStarting() { 839 void ServiceWorkerVersion::OnStarting() {
833 FOR_EACH_OBSERVER(Listener, listeners_, OnRunningStateChanged(this)); 840 for (auto& observer : listeners_)
841 observer.OnRunningStateChanged(this);
834 } 842 }
835 843
836 void ServiceWorkerVersion::OnStarted() { 844 void ServiceWorkerVersion::OnStarted() {
837 DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, running_status()); 845 DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, running_status());
838 RestartTick(&idle_time_); 846 RestartTick(&idle_time_);
839 847
840 // Fire all start callbacks. 848 // Fire all start callbacks.
841 scoped_refptr<ServiceWorkerVersion> protect(this); 849 scoped_refptr<ServiceWorkerVersion> protect(this);
842 FinishStartWorker(SERVICE_WORKER_OK); 850 FinishStartWorker(SERVICE_WORKER_OK);
843 FOR_EACH_OBSERVER(Listener, listeners_, OnRunningStateChanged(this)); 851 for (auto& observer : listeners_)
852 observer.OnRunningStateChanged(this);
844 } 853 }
845 854
846 void ServiceWorkerVersion::OnStopping() { 855 void ServiceWorkerVersion::OnStopping() {
847 DCHECK(stop_time_.is_null()); 856 DCHECK(stop_time_.is_null());
848 RestartTick(&stop_time_); 857 RestartTick(&stop_time_);
849 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker", "ServiceWorkerVersion::StopWorker", 858 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker", "ServiceWorkerVersion::StopWorker",
850 stop_time_.ToInternalValue(), "Script", 859 stop_time_.ToInternalValue(), "Script",
851 script_url_.spec(), "Version Status", 860 script_url_.spec(), "Version Status",
852 VersionStatusToString(status_)); 861 VersionStatusToString(status_));
853 862
854 // Shorten the interval so stalling in stopped can be fixed quickly. Once the 863 // Shorten the interval so stalling in stopped can be fixed quickly. Once the
855 // worker stops, the timer is disabled. The interval will be reset to normal 864 // worker stops, the timer is disabled. The interval will be reset to normal
856 // when the worker starts up again. 865 // when the worker starts up again.
857 SetTimeoutTimerInterval( 866 SetTimeoutTimerInterval(
858 base::TimeDelta::FromSeconds(kStopWorkerTimeoutSeconds)); 867 base::TimeDelta::FromSeconds(kStopWorkerTimeoutSeconds));
859 FOR_EACH_OBSERVER(Listener, listeners_, OnRunningStateChanged(this)); 868 for (auto& observer : listeners_)
869 observer.OnRunningStateChanged(this);
860 } 870 }
861 871
862 void ServiceWorkerVersion::OnStopped(EmbeddedWorkerStatus old_status) { 872 void ServiceWorkerVersion::OnStopped(EmbeddedWorkerStatus old_status) {
863 if (IsInstalled(status())) { 873 if (IsInstalled(status())) {
864 ServiceWorkerMetrics::RecordWorkerStopped( 874 ServiceWorkerMetrics::RecordWorkerStopped(
865 ServiceWorkerMetrics::StopStatus::NORMAL); 875 ServiceWorkerMetrics::StopStatus::NORMAL);
866 } 876 }
867 if (!stop_time_.is_null()) 877 if (!stop_time_.is_null())
868 ServiceWorkerMetrics::RecordStopWorkerTime(GetTickDuration(stop_time_)); 878 ServiceWorkerMetrics::RecordStopWorkerTime(GetTickDuration(stop_time_));
869 879
(...skipping 12 matching lines...) Expand all
882 if (IsInstalled(status())) 892 if (IsInstalled(status()))
883 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.ScriptLoadSuccess", true); 893 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.ScriptLoadSuccess", true);
884 } 894 }
885 895
886 void ServiceWorkerVersion::OnScriptLoadFailed() { 896 void ServiceWorkerVersion::OnScriptLoadFailed() {
887 if (IsInstalled(status())) 897 if (IsInstalled(status()))
888 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.ScriptLoadSuccess", false); 898 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.ScriptLoadSuccess", false);
889 } 899 }
890 900
891 void ServiceWorkerVersion::OnRegisteredToDevToolsManager() { 901 void ServiceWorkerVersion::OnRegisteredToDevToolsManager() {
892 FOR_EACH_OBSERVER(Listener, listeners_, OnDevToolsRoutingIdChanged(this)); 902 for (auto& observer : listeners_)
903 observer.OnDevToolsRoutingIdChanged(this);
893 } 904 }
894 905
895 void ServiceWorkerVersion::OnReportException( 906 void ServiceWorkerVersion::OnReportException(
896 const base::string16& error_message, 907 const base::string16& error_message,
897 int line_number, 908 int line_number,
898 int column_number, 909 int column_number,
899 const GURL& source_url) { 910 const GURL& source_url) {
900 FOR_EACH_OBSERVER( 911 for (auto& observer : listeners_) {
901 Listener, 912 observer.OnErrorReported(this, error_message, line_number, column_number,
902 listeners_, 913 source_url);
903 OnErrorReported( 914 }
904 this, error_message, line_number, column_number, source_url));
905 } 915 }
906 916
907 void ServiceWorkerVersion::OnReportConsoleMessage(int source_identifier, 917 void ServiceWorkerVersion::OnReportConsoleMessage(int source_identifier,
908 int message_level, 918 int message_level,
909 const base::string16& message, 919 const base::string16& message,
910 int line_number, 920 int line_number,
911 const GURL& source_url) { 921 const GURL& source_url) {
912 FOR_EACH_OBSERVER(Listener, 922 for (auto& observer : listeners_) {
913 listeners_, 923 observer.OnReportConsoleMessage(this, source_identifier, message_level,
914 OnReportConsoleMessage(this, 924 message, line_number, source_url);
915 source_identifier, 925 }
916 message_level,
917 message,
918 line_number,
919 source_url));
920 } 926 }
921 927
922 bool ServiceWorkerVersion::OnMessageReceived(const IPC::Message& message) { 928 bool ServiceWorkerVersion::OnMessageReceived(const IPC::Message& message) {
923 bool handled = true; 929 bool handled = true;
924 IPC_BEGIN_MESSAGE_MAP(ServiceWorkerVersion, message) 930 IPC_BEGIN_MESSAGE_MAP(ServiceWorkerVersion, message)
925 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetClient, OnGetClient) 931 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetClient, OnGetClient)
926 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetClients, 932 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetClients,
927 OnGetClients) 933 OnGetClients)
928 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_OpenWindow, 934 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_OpenWindow,
929 OnOpenWindow) 935 OnOpenWindow)
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 script_cache_map_.WriteMetadata( 1112 script_cache_map_.WriteMetadata(
1107 url, data, base::Bind(&ServiceWorkerVersion::OnSetCachedMetadataFinished, 1113 url, data, base::Bind(&ServiceWorkerVersion::OnSetCachedMetadataFinished,
1108 weak_factory_.GetWeakPtr(), callback_id)); 1114 weak_factory_.GetWeakPtr(), callback_id));
1109 } 1115 }
1110 1116
1111 void ServiceWorkerVersion::OnSetCachedMetadataFinished(int64_t callback_id, 1117 void ServiceWorkerVersion::OnSetCachedMetadataFinished(int64_t callback_id,
1112 int result) { 1118 int result) {
1113 TRACE_EVENT_ASYNC_END1("ServiceWorker", 1119 TRACE_EVENT_ASYNC_END1("ServiceWorker",
1114 "ServiceWorkerVersion::OnSetCachedMetadata", 1120 "ServiceWorkerVersion::OnSetCachedMetadata",
1115 callback_id, "result", result); 1121 callback_id, "result", result);
1116 FOR_EACH_OBSERVER(Listener, listeners_, OnCachedMetadataUpdated(this)); 1122 for (auto& observer : listeners_)
1123 observer.OnCachedMetadataUpdated(this);
1117 } 1124 }
1118 1125
1119 void ServiceWorkerVersion::OnClearCachedMetadata(const GURL& url) { 1126 void ServiceWorkerVersion::OnClearCachedMetadata(const GURL& url) {
1120 int64_t callback_id = base::TimeTicks::Now().ToInternalValue(); 1127 int64_t callback_id = base::TimeTicks::Now().ToInternalValue();
1121 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", 1128 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker",
1122 "ServiceWorkerVersion::OnClearCachedMetadata", 1129 "ServiceWorkerVersion::OnClearCachedMetadata",
1123 callback_id, "URL", url.spec()); 1130 callback_id, "URL", url.spec());
1124 script_cache_map_.ClearMetadata( 1131 script_cache_map_.ClearMetadata(
1125 url, base::Bind(&ServiceWorkerVersion::OnClearCachedMetadataFinished, 1132 url, base::Bind(&ServiceWorkerVersion::OnClearCachedMetadataFinished,
1126 weak_factory_.GetWeakPtr(), callback_id)); 1133 weak_factory_.GetWeakPtr(), callback_id));
1127 } 1134 }
1128 1135
1129 void ServiceWorkerVersion::OnClearCachedMetadataFinished(int64_t callback_id, 1136 void ServiceWorkerVersion::OnClearCachedMetadataFinished(int64_t callback_id,
1130 int result) { 1137 int result) {
1131 TRACE_EVENT_ASYNC_END1("ServiceWorker", 1138 TRACE_EVENT_ASYNC_END1("ServiceWorker",
1132 "ServiceWorkerVersion::OnClearCachedMetadata", 1139 "ServiceWorkerVersion::OnClearCachedMetadata",
1133 callback_id, "result", result); 1140 callback_id, "result", result);
1134 FOR_EACH_OBSERVER(Listener, listeners_, OnCachedMetadataUpdated(this)); 1141 for (auto& observer : listeners_)
1142 observer.OnCachedMetadataUpdated(this);
1135 } 1143 }
1136 1144
1137 void ServiceWorkerVersion::OnPostMessageToClient( 1145 void ServiceWorkerVersion::OnPostMessageToClient(
1138 const std::string& client_uuid, 1146 const std::string& client_uuid,
1139 const base::string16& message, 1147 const base::string16& message,
1140 const std::vector<int>& sent_message_ports) { 1148 const std::vector<int>& sent_message_ports) {
1141 if (!context_) 1149 if (!context_)
1142 return; 1150 return;
1143 TRACE_EVENT1("ServiceWorker", 1151 TRACE_EVENT1("ServiceWorker",
1144 "ServiceWorkerVersion::OnPostMessageToDocument", 1152 "ServiceWorkerVersion::OnPostMessageToDocument",
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 } 1793 }
1786 pending_requests_.Clear(); 1794 pending_requests_.Clear();
1787 1795
1788 // Close all mojo services. This will also fire and clear all callbacks 1796 // Close all mojo services. This will also fire and clear all callbacks
1789 // for messages that are still outstanding for those services. 1797 // for messages that are still outstanding for those services.
1790 mojo_services_.clear(); 1798 mojo_services_.clear();
1791 1799
1792 // TODO(falken): Call SWURLRequestJob::ClearStream here? 1800 // TODO(falken): Call SWURLRequestJob::ClearStream here?
1793 streaming_url_request_jobs_.clear(); 1801 streaming_url_request_jobs_.clear();
1794 1802
1795 FOR_EACH_OBSERVER(Listener, listeners_, OnRunningStateChanged(this)); 1803 for (auto& observer : listeners_)
1796 if (should_restart) 1804 observer.OnRunningStateChanged(this);
1805 if (should_restart) {
1797 StartWorkerInternal(); 1806 StartWorkerInternal();
1798 else if (!HasWork()) 1807 } else if (!HasWork()) {
1799 FOR_EACH_OBSERVER(Listener, listeners_, OnNoWork(this)); 1808 for (auto& observer : listeners_)
1809 observer.OnNoWork(this);
1810 }
1800 } 1811 }
1801 1812
1802 void ServiceWorkerVersion::OnMojoConnectionError(const char* service_name) { 1813 void ServiceWorkerVersion::OnMojoConnectionError(const char* service_name) {
1803 // Simply deleting the service will cause error callbacks to be called from 1814 // Simply deleting the service will cause error callbacks to be called from
1804 // the destructor of the MojoServiceWrapper instance. 1815 // the destructor of the MojoServiceWrapper instance.
1805 mojo_services_.erase(service_name); 1816 mojo_services_.erase(service_name);
1806 } 1817 }
1807 1818
1808 void ServiceWorkerVersion::OnBeginEvent() { 1819 void ServiceWorkerVersion::OnBeginEvent() {
1809 if (should_exclude_from_uma_ || 1820 if (should_exclude_from_uma_ ||
1810 running_status() != EmbeddedWorkerStatus::RUNNING || 1821 running_status() != EmbeddedWorkerStatus::RUNNING ||
1811 idle_time_.is_null()) { 1822 idle_time_.is_null()) {
1812 return; 1823 return;
1813 } 1824 }
1814 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() - 1825 ServiceWorkerMetrics::RecordTimeBetweenEvents(base::TimeTicks::Now() -
1815 idle_time_); 1826 idle_time_);
1816 } 1827 }
1817 1828
1818 void ServiceWorkerVersion::FinishStartWorker(ServiceWorkerStatusCode status) { 1829 void ServiceWorkerVersion::FinishStartWorker(ServiceWorkerStatusCode status) {
1819 start_worker_first_purpose_ = base::nullopt; 1830 start_worker_first_purpose_ = base::nullopt;
1820 RunCallbacks(this, &start_callbacks_, status); 1831 RunCallbacks(this, &start_callbacks_, status);
1821 } 1832 }
1822 1833
1823 } // namespace content 1834 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_registration.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698