Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/power/renderer_freezer.h" | 5 #include "chrome/browser/chromeos/power/renderer_freezer.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 | 141 |
| 142 void RendererFreezer::OnScreenLockStateChanged(chromeos::ScreenLocker* locker, | 142 void RendererFreezer::OnScreenLockStateChanged(chromeos::ScreenLocker* locker, |
| 143 bool is_locked) { | 143 bool is_locked) { |
| 144 // The ScreenLocker class sends NOTIFICATION_SCREEN_LOCK_STATE_CHANGED when | 144 // The ScreenLocker class sends NOTIFICATION_SCREEN_LOCK_STATE_CHANGED when |
| 145 // the lock screen becomes ready, resulting in this code running synchronously | 145 // the lock screen becomes ready, resulting in this code running synchronously |
| 146 // to mark the screen locker renderer to remain unfrozen during a suspend | 146 // to mark the screen locker renderer to remain unfrozen during a suspend |
| 147 // request. Since this happens before the PowerManagerClient calls | 147 // request. Since this happens before the PowerManagerClient calls |
| 148 // RendererFreezer::SuspendImminent(), it is guaranteed that the screen locker | 148 // RendererFreezer::SuspendImminent(), it is guaranteed that the screen locker |
| 149 // renderer will not be frozen at any point. | 149 // renderer will not be frozen at any point. |
| 150 if (is_locked) { | 150 if (is_locked) { |
| 151 delegate_->SetShouldFreezeRenderer(locker->delegate() | 151 content::WebContents* web_contents = locker->delegate()->GetWebContents(); |
| 152 ->GetWebContents() | 152 if (web_contents) { |
|
Daniel Erat
2017/05/26 22:10:06
nit: mind adding a comment here mentioning why thi
jdufault
2017/05/26 23:15:20
Done.
| |
| 153 ->GetRenderProcessHost() | 153 delegate_->SetShouldFreezeRenderer( |
| 154 ->GetHandle(), | 154 web_contents->GetRenderProcessHost()->GetHandle(), false); |
| 155 false); | 155 } |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 | 158 |
| 159 void RendererFreezer::OnRenderProcessCreated(content::RenderProcessHost* rph) { | 159 void RendererFreezer::OnRenderProcessCreated(content::RenderProcessHost* rph) { |
| 160 const int rph_id = rph->GetID(); | 160 const int rph_id = rph->GetID(); |
| 161 | 161 |
| 162 if (gcm_extension_processes_.find(rph_id) != gcm_extension_processes_.end()) { | 162 if (gcm_extension_processes_.find(rph_id) != gcm_extension_processes_.end()) { |
| 163 LOG(ERROR) << "Received duplicate notifications about the creation of a " | 163 LOG(ERROR) << "Received duplicate notifications about the creation of a " |
| 164 << "RenderProcessHost with id " << rph_id; | 164 << "RenderProcessHost with id " << rph_id; |
| 165 return; | 165 return; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 rph->AddObserver(this); | 199 rph->AddObserver(this); |
| 200 return; | 200 return; |
| 201 } | 201 } |
| 202 | 202 |
| 203 // We didn't find an extension in this RenderProcessHost that is using GCM so | 203 // We didn't find an extension in this RenderProcessHost that is using GCM so |
| 204 // we can go ahead and freeze it on suspend. | 204 // we can go ahead and freeze it on suspend. |
| 205 delegate_->SetShouldFreezeRenderer(rph->GetHandle(), true); | 205 delegate_->SetShouldFreezeRenderer(rph->GetHandle(), true); |
| 206 } | 206 } |
| 207 | 207 |
| 208 } // namespace chromeos | 208 } // namespace chromeos |
| OLD | NEW |