OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/lifetime/keep_alive_registry.h" | 5 #include "chrome/browser/lifetime/keep_alive_registry.h" |
6 | 6 |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/lifetime/application_lifetime.h" | 8 #include "chrome/browser/lifetime/application_lifetime.h" |
9 #include "chrome/browser/lifetime/keep_alive_state_observer.h" | 9 #include "chrome/browser/lifetime/keep_alive_state_observer.h" |
10 #include "chrome/browser/lifetime/keep_alive_types.h" | 10 #include "chrome/browser/lifetime/keep_alive_types.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 DCHECK_GE(registered_keep_alives_[origin], 0); | 85 DCHECK_GE(registered_keep_alives_[origin], 0); |
86 if (new_count == 0) | 86 if (new_count == 0) |
87 registered_keep_alives_.erase(origin); | 87 registered_keep_alives_.erase(origin); |
88 | 88 |
89 if (restart == KeepAliveRestartOption::ENABLED) | 89 if (restart == KeepAliveRestartOption::ENABLED) |
90 --restart_allowed_count_; | 90 --restart_allowed_count_; |
91 | 91 |
92 bool new_keeping_alive = IsKeepingAlive(); | 92 bool new_keeping_alive = IsKeepingAlive(); |
93 bool new_restart_allowed = IsRestartAllowed(); | 93 bool new_restart_allowed = IsRestartAllowed(); |
94 | 94 |
| 95 // Update the KeepAlive state first, so that listeners can check if we are |
| 96 // trying to shutdown. |
| 97 if (new_keeping_alive != old_keeping_alive) |
| 98 OnKeepAliveStateChanged(new_keeping_alive); |
| 99 |
95 if (new_restart_allowed != old_restart_allowed) | 100 if (new_restart_allowed != old_restart_allowed) |
96 OnRestartAllowedChanged(new_restart_allowed); | 101 OnRestartAllowedChanged(new_restart_allowed); |
97 | 102 |
98 if (new_keeping_alive != old_keeping_alive) | |
99 OnKeepAliveStateChanged(new_keeping_alive); | |
100 | |
101 DVLOG(1) << "New state of the KeepAliveRegistry:" << *this; | 103 DVLOG(1) << "New state of the KeepAliveRegistry:" << *this; |
102 } | 104 } |
103 | 105 |
104 void KeepAliveRegistry::OnKeepAliveStateChanged(bool new_keeping_alive) { | 106 void KeepAliveRegistry::OnKeepAliveStateChanged(bool new_keeping_alive) { |
105 DVLOG(1) << "Notifying KeepAliveStateObservers: KeepingAlive changed to: " | 107 DVLOG(1) << "Notifying KeepAliveStateObservers: KeepingAlive changed to: " |
106 << new_keeping_alive; | 108 << new_keeping_alive; |
107 FOR_EACH_OBSERVER(KeepAliveStateObserver, observers_, | 109 FOR_EACH_OBSERVER(KeepAliveStateObserver, observers_, |
108 OnKeepAliveStateChanged(new_keeping_alive)); | 110 OnKeepAliveStateChanged(new_keeping_alive)); |
109 } | 111 } |
110 | 112 |
(...skipping 10 matching lines...) Expand all Loading... |
121 << ", KeepAlives=["; | 123 << ", KeepAlives=["; |
122 for (auto counts_per_origin_it : registry.registered_keep_alives_) { | 124 for (auto counts_per_origin_it : registry.registered_keep_alives_) { |
123 if (counts_per_origin_it != *registry.registered_keep_alives_.begin()) | 125 if (counts_per_origin_it != *registry.registered_keep_alives_.begin()) |
124 out << ", "; | 126 out << ", "; |
125 out << counts_per_origin_it.first << " (" << counts_per_origin_it.second | 127 out << counts_per_origin_it.first << " (" << counts_per_origin_it.second |
126 << ")"; | 128 << ")"; |
127 } | 129 } |
128 out << "]}"; | 130 out << "]}"; |
129 return out; | 131 return out; |
130 } | 132 } |
OLD | NEW |