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/embedded_worker_instance.h" | 5 #include "content/browser/service_worker/embedded_worker_instance.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
806 } | 806 } |
807 | 807 |
808 void EmbeddedWorkerInstance::OnDetached() { | 808 void EmbeddedWorkerInstance::OnDetached() { |
809 EmbeddedWorkerStatus old_status = status_; | 809 EmbeddedWorkerStatus old_status = status_; |
810 ReleaseProcess(); | 810 ReleaseProcess(); |
811 for (auto& observer : listener_list_) | 811 for (auto& observer : listener_list_) |
812 observer.OnDetached(old_status); | 812 observer.OnDetached(old_status); |
813 } | 813 } |
814 | 814 |
815 void EmbeddedWorkerInstance::Detach() { | 815 void EmbeddedWorkerInstance::Detach() { |
816 // This could be called on the UI thread if |client_| still be valid when the | |
817 // message loop on the UI thread gets destructed. | |
nhiroki
2016/11/02 07:59:50
Making an indirection could be saner than directly
horo
2016/11/02 08:22:54
+1
| |
818 // TODO(shimazu): Remove this after https://crbug.com/604762 is fixed | |
819 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) | |
820 return; | |
horo
2016/11/02 07:49:12
Please add DCHECK for mojo sw.
if (!BrowserThread
| |
816 registry_->DetachWorker(process_id(), embedded_worker_id()); | 821 registry_->DetachWorker(process_id(), embedded_worker_id()); |
817 OnDetached(); | 822 OnDetached(); |
818 } | 823 } |
819 | 824 |
820 base::WeakPtr<EmbeddedWorkerInstance> EmbeddedWorkerInstance::AsWeakPtr() { | 825 base::WeakPtr<EmbeddedWorkerInstance> EmbeddedWorkerInstance::AsWeakPtr() { |
821 return weak_factory_.GetWeakPtr(); | 826 return weak_factory_.GetWeakPtr(); |
822 } | 827 } |
823 | 828 |
824 bool EmbeddedWorkerInstance::OnMessageReceived(const IPC::Message& message) { | 829 bool EmbeddedWorkerInstance::OnMessageReceived(const IPC::Message& message) { |
825 for (auto& listener : listener_list_) { | 830 for (auto& listener : listener_list_) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
972 case SCRIPT_READ_FINISHED: | 977 case SCRIPT_READ_FINISHED: |
973 return "Script read finished"; | 978 return "Script read finished"; |
974 case STARTING_PHASE_MAX_VALUE: | 979 case STARTING_PHASE_MAX_VALUE: |
975 NOTREACHED(); | 980 NOTREACHED(); |
976 } | 981 } |
977 NOTREACHED() << phase; | 982 NOTREACHED() << phase; |
978 return std::string(); | 983 return std::string(); |
979 } | 984 } |
980 | 985 |
981 } // namespace content | 986 } // namespace content |
OLD | NEW |