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

Side by Side Diff: chrome/browser/lifetime/keep_alive_registry.cc

Issue 2719813005: CrOS: Add print statements to help debug BrowserProcessImpl::Unpin crash. (Closed)
Patch Set: Whitespace. Created 3 years, 9 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
OLDNEW
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 void KeepAliveRegistry::Register(KeepAliveOrigin origin, 81 void KeepAliveRegistry::Register(KeepAliveOrigin origin,
82 KeepAliveRestartOption restart) { 82 KeepAliveRestartOption restart) {
83 DCHECK(!g_browser_process->IsShuttingDown()); 83 DCHECK(!g_browser_process->IsShuttingDown());
84 84
85 bool old_keeping_alive = IsKeepingAlive(); 85 bool old_keeping_alive = IsKeepingAlive();
86 bool old_restart_allowed = IsRestartAllowed(); 86 bool old_restart_allowed = IsRestartAllowed();
87 87
88 ++registered_keep_alives_[origin]; 88 ++registered_keep_alives_[origin];
89 ++registered_count_; 89 ++registered_count_;
90 90
91 LOG(ERROR) << "Registered: " << origin << ", Count:" << registered_count_;
91 if (restart == KeepAliveRestartOption::ENABLED) { 92 if (restart == KeepAliveRestartOption::ENABLED) {
92 ++restart_allowed_keep_alives_[origin]; 93 ++restart_allowed_keep_alives_[origin];
93 ++restart_allowed_count_; 94 ++restart_allowed_count_;
94 } 95 }
95 96
96 bool new_keeping_alive = IsKeepingAlive(); 97 bool new_keeping_alive = IsKeepingAlive();
97 bool new_restart_allowed = IsRestartAllowed(); 98 bool new_restart_allowed = IsRestartAllowed();
98 99
99 if (new_keeping_alive != old_keeping_alive) 100 if (new_keeping_alive != old_keeping_alive)
100 OnKeepAliveStateChanged(new_keeping_alive); 101 OnKeepAliveStateChanged(new_keeping_alive);
101 102
102 if (new_restart_allowed != old_restart_allowed) 103 if (new_restart_allowed != old_restart_allowed)
103 OnRestartAllowedChanged(new_restart_allowed); 104 OnRestartAllowedChanged(new_restart_allowed);
104 105
105 DVLOG(1) << "New state of the KeepAliveRegistry: " << *this; 106 DVLOG(1) << "New state of the KeepAliveRegistry: " << *this;
106 } 107 }
107 108
108 void KeepAliveRegistry::Unregister(KeepAliveOrigin origin, 109 void KeepAliveRegistry::Unregister(KeepAliveOrigin origin,
109 KeepAliveRestartOption restart) { 110 KeepAliveRestartOption restart) {
110 bool old_keeping_alive = IsKeepingAlive(); 111 bool old_keeping_alive = IsKeepingAlive();
111 bool old_restart_allowed = IsRestartAllowed(); 112 bool old_restart_allowed = IsRestartAllowed();
112 113
113 --registered_count_; 114 --registered_count_;
114 DCHECK_GE(registered_count_, 0); 115 DCHECK_GE(registered_count_, 0);
115 DecrementCount(origin, &registered_keep_alives_); 116 DecrementCount(origin, &registered_keep_alives_);
117 LOG(ERROR) << "Unregistered: " << origin << ", Count:" << registered_count_;
116 118
117 if (restart == KeepAliveRestartOption::ENABLED) { 119 if (restart == KeepAliveRestartOption::ENABLED) {
118 --restart_allowed_count_; 120 --restart_allowed_count_;
119 DecrementCount(origin, &restart_allowed_keep_alives_); 121 DecrementCount(origin, &restart_allowed_keep_alives_);
120 } 122 }
121 123
122 bool new_keeping_alive = IsKeepingAlive(); 124 bool new_keeping_alive = IsKeepingAlive();
123 bool new_restart_allowed = IsRestartAllowed(); 125 bool new_restart_allowed = IsRestartAllowed();
124 126
125 // Update the KeepAlive state first, so that listeners can check if we are 127 // Update the KeepAlive state first, so that listeners can check if we are
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 << ", KeepAlives=["; 163 << ", KeepAlives=[";
162 for (auto counts_per_origin_it : registry.registered_keep_alives_) { 164 for (auto counts_per_origin_it : registry.registered_keep_alives_) {
163 if (counts_per_origin_it != *registry.registered_keep_alives_.begin()) 165 if (counts_per_origin_it != *registry.registered_keep_alives_.begin())
164 out << ", "; 166 out << ", ";
165 out << counts_per_origin_it.first << " (" << counts_per_origin_it.second 167 out << counts_per_origin_it.first << " (" << counts_per_origin_it.second
166 << ")"; 168 << ")";
167 } 169 }
168 out << "]}"; 170 out << "]}";
169 return out; 171 return out;
170 } 172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698